On Mon, Feb 10, 2014 at 9:02 PM, yuan wang <[email protected]> wrote:
> Hi Jon,
>
> I think I didn't understand the operator variable completely. Thanks for
> pointing that out. And thank you for all the supports. Please see below an
> example of what I'm trying to do:
>
> kp['NO3'] = (k['R2'] * k_O2_NO3/(k_O2_NO3 + O2.var)).copy()
>
> kp['NO3'].setValue(0.,where = Qcc == 0)
>
>
> So, I'd like to set the the kp['NO3'] value to be equal to k['R2'] *
> k_O2_NO3/(k_O2_NO3 + O2.var. But when it hits to the next time, I got the
> error "TypeError: The value of an `_OperatorVariable` cannot be assigned".
> Then, after I adding the .copy() method behind, it works. kp['NO3'] becomes
> a CellVariable rather than an OperatorVariable.
My guess is that "copy()" just returns a plain old CellVariable
without its dependencies. Basically, the "copy()" is not exactly the
same object as the original.
Unfortunately, I'm not sure what you are trying to do above, I think
I'd need to see the full traceback to debug it. My hunch is that you
should be doing either
kp['NO3'][:] = numerix.array((k['R2'] * k_O2_NO3/(k_O2_NO3 + O2.var)))
to cast the RHS to be an array rather than a variable, if you want to
not have kp['NO3'] updated via lazy evaluation.
--
Daniel Wheeler
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]