Dear Users,
my question concerns the implementation of the boundary conditions in FiPy.
I would like to solve a 1D Conv-Diff-Equation with 3 control volumes
using CentralDifferenceConvectionTerm and DiffusionTerm of FiPy.
For me, it is not clear why the first row of the matrix of the linear
equation system is
> 9.000000 -2.500000 ---
and the right hand side is
> 6.5
The case is the following. Each control volume (W, C and E) has the
length 1/3. All coefficients (gamma, u, rho) in the equation is set to 1:
o---> x
|-D=1/3-|-D=1/3-|-D=1/3-|
x=0 x=1
phi=1 phi=0
v v
+-------+-------+-------+
| W | C | E |
o---x---o---x---o---x---o
| | | |
+-------+-------+-------+
If I discretize the equation in the first control volume (W), I get for
the matrix row
> 10.000000 -2.500000 ---
and for the right hand side
> 7.0
So this is a little bit different from FiPy. Is there any mistake from
my side?
Please find attached my notes on how calculating my matrix coefficients
(fipy_0.png) and my python script for fipy (fipy.py).
Warm regards,
Alex
import fipy as fp
nx = 3
dx = 1./nx
k = 0
U = 1.0
Gamma = 1.0
rho = 1.0
mesh = fp.Grid1D(nx=nx, dx=dx)
phi = fp.CellVariable(name="phi", mesh=mesh, value=0.)
phi.constrain( 1.0, mesh.facesLeft() )
phi.constrain( 0.0, mesh.facesRight() )
eq = fp.CentralDifferenceConvectionTerm(coeff=(rho * U,)) - fp.DiffusionTerm(coeff=Gamma) == 0.
eq.cacheMatrix()
eq.cacheRHSvector()
eq.solve( var=phi )
print( eq.matrix )
print( eq.RHSvector )
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]