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


_______________________________________________
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