I want to solve the time-dependent convection-diffusion equation and am testing 
my code on a simple 1D case.

The flow field is a simple constant velocity. I've set D = 0, so no diffusion 
should happen at all.  
This system represents a little plug of high-concentration solute in a solvent 
that should flow down the tube
without spreading. Problem is that I get lots of spreading even when I set cell 
size and time-step very small.

Can anyone see what I'm doing wrong?

# Tube dimensions (cm)                                                          
                   

xlen = 1.0
flow_vel = 0.1
D = 0.0

# number of cells                                                               
                   

nx = 1000
dx = xlen/nx
Lx = dx*nx

mesh = Grid1D(dx=dx,nx=nx)

phi = CellVariable(name = "solution variable",
                   mesh = mesh,
                   value = 0.)

x = mesh.cellCenters[0]

phi.setValue(1.0, where=(x > 2*Lx/3. - Lx/20.0) & (x < 2*Lx/3.0 + Lx/20.0))

ConvCoef = [flow_vel]

eq = TransientTerm() == 
(DiffusionTerm(coeff=D)+PowerLawConvectionTerm(coeff=ConvCoef))

if __name__ == '__main__':
    viewer = Viewer(vars=phi, datamin=0., datamax=1.)
    viewer.plot()

timeStepDuration = 0.01
steps = 800

for step in range(steps):
    eq.solve(var=phi,dt=timeStepDuration)
    if __name__ == '__main__':
        viewer.plot()


Thanks! 

Richard

_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to