On Mon, Jul 2, 2012 at 11:12 AM, Jonathan Guyer <[email protected]> wrote:
> > On Jul 2, 2012, at 1:08 PM, Daniel Wheeler wrote: > > > 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) > > Also, to be able to use your position-depedent form, you should be able to > write > > c / psi.faceValue *np.tanh(40*pos) > > and then you're multiplying two FaceVariables and one of them is rank-1, > so everything should be OK > Woohoo! Works like a charm! Will be analyzing this for awhile. Thanks so much! > > _______________________________________________ > fipy mailing list > [email protected] > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] > -- Graduate Group of Ecology Doctoral Candidate Department of Environmental Science and Policy Center for Population Biology University of California, Davis
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
