Hi,

I'm working on solving a set of coupled PDEs, simple convection equations
with the same velocity. However, when I write the equations in a vector
form, I have trouble with the convection term coefficient - trouble that
originates in the building of the linear system.

*Short version:*
Does anyone have an example of solving a vector equation that contains a
convection term that is a variable on the mesh?

*Long version:*
Here's a more precise description of the problem I'm running into.

Suppose I'm solving for 9 species (9 equations) on a grid with 20 points.
Then I will need 20 velocities (a single velocity for all species, but
different at each point). Well, 21, since its actually a face-centered
component.

If I try and pass a FaceVariable as a coefficient to the (vector)
ConvectionTerm, I see problems relating to the matrix system size:

----------------8<------------------

from fipy import *

L = 0.50
nx = 10
dx = L/nx
inlet_velocity = 0.1

m = Grid1D(nx=nx, Lx=L)

# number of species
nsp = 9

# molar concentration variable vector
iv  = [[0.0] for i in range(nsp)]
c_i = CellVariable(mesh=m, hasOld=True, value=iv, elementshape=(nsp,))

# linear velocity variable
u_x = FaceVariable(mesh=m, value=inlet_velocity, rank=1)

species_eqn = ConvectionTerm(coeff=u_x,var=c_i) == 0
species_eqn.solve(var=c_i)

-------------------8<------------------

(Note that while this example is trivial due to a constant velocity, my
problem of interest has a variable velocity.)

The error I see when I run the solve() method relates to mismatched shapes
in the matrix system:

IndexError: id1 does not have the same size as b

I also tried specifying a velocity for each species, so that there are 9
u_x variables, like this:

u_x = FaceVariable(mesh=m, value=inlet_velocity, rank=1,
elementshape=(nsp,))

but saw the same error.

I also tried specifying the velocity variable u_x as a cell centered
variable, and still saw the same error.

I set a breakpoint where the error originates, which is in
fipy/terms/faceTerm.py in the _buildMatrix() method (line 165). The
variables id1 and id2, which contain interior points for the mesh, always
have size (nx-1), where nx is the number of mesh points in the x direction.
But the b vector always has size (nvar)*(nx-1), where nvar is the number of
unknown variables in the vector formulation. This leads to this mismatch
during the linear system construction process:

-----------------------8<------------------------

(Pdb) where
[...]
>
/Library/Python/2.7/site-packages/FiPy-3.1-py2.7.egg/fipy/terms/faceTerm.py(174)_buildMatrix()
-> L = SparseMatrix(mesh=mesh)

(Pdb) p id1.shape
(19,)

(Pdb) p id2.shape
(19,)

(Pdb) p b.shape
(180,)

------------------------8<-------------------------

I don't see a way to construct the coefficient matrix in a way that will
get around this problem. Any advice or input on getting convection
coefficients working for vector equations would be greatly appreciated.

Thanks!



Charles
_______________________________________________
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