On Mon, Jul 2, 2012 at 6:56 AM, Yun Tao <[email protected]> wrote: > > 1. In Equation [1], when I set the coefficient of the ConvectionTerm to a > function of psi, it returns > > *TypeError*: unsupported operand type(s) for *: 'binOp' and 'unOp' > > > I gather this may due to me multiplying a FaceVariable to a CellVariable > as a consequence of me using a position-dependent convection term. However, > when I tested what happens if I remove the space-dependence, I get > > *VectorCoeffError*: The coefficient must be a vector value. > > > Of course, when I take out the dependence on psi altogether, everything's > fine. >
The coefficient does need to be a vector value. Unfortunately, a function of psi alone is not a vector field, but a scalar field. Multiply it by a vector. For example, >>> import fipy as fp >>> fp.Grid1D(nx=2) >>> v = fp.CellVariable(mesh=m) >>> (v * [[1]]).rank 1 >>> (v * [[1]]).shape (1, 2) > 2. In Equation [2], what is the proper way to assign the variables? I > could have > > eq2 = (TransientTerm(var=psi) == ImplicitSourceTerm(var=phi) + >> ImplicitSourceTerm(coeff=c**phi*, var=*psi*) > > > or, equally, > > eq2 = (TransientTerm(var=psi) == ImplicitSourceTerm(var=phi) + >> ImplicitSourceTerm(coeff=c**psi*, var=*phi*) > > > Does it even make any difference? > Shouldn't do, but I'm not entirely sure. Try it and see. I would say that the former is probably better. > > Can't say it enough, but thank you again for all your kind and generous > help. > No problem. Cheers -- Daniel Wheeler
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
