Hi Yun,

I think the problem is due to conflict of variable types between "1" and
"var2" in the computation of (1 - var2).

The following lines seem to work:

a = 0.01
var = CellVariable(mesh=mesh, value=0.)
var2 = CellVariable(mesh=mesh,value=1.)
dfactor = CellVariable(mesh=mesh,value=a)
dfactor.setValue(1-var2,where=((1-var2) > a))

Regards,
Aniruddha

On Fri, Jan 22, 2016 at 3:34 PM, Yun Tao <[email protected]> wrote:

> Hi FiPy community,
>
> I'm solving a diffusion equation for *var *on a 2D grid; the diffusion
> coefficient is set up as a function of another CellVariable *var2. *Problems
> pop up when I tried to truncate the coefficient value at each location to a
> small positive number *a*:
> ​
>
>> ​a = 0.01​
>
> dfactor =
>> ​max(​a,
>> 1-​var2
>> ​)​
>>
> eq = (TransientTerm() == DiffusionTerm(coeff=
>> ​d
>> factor)
>
>
> ​When I then tried solving it, I get the error message
>
>> ValueError: The truth value of an array with more than one element is
>> ambiguous. Use a.any() or a.all()​
>
>
> ​Alternatively, I tried
>
>> ​dfactor = numerix.fmax(a, (1-var2).value)
>
> but got
>
> ValueError: operands could not be broadcast together with shapes (10000,)
> (2,2)
>
> ​Experimenting with, for example, getValue() and other functions such as
>
>> dfactor = (1-var2)[(1-var2).value<a]=a
>
> also didn't work.
>
> Does anyone have ideas on the appropriate​
> ​
> ​ syntax to use?
>
> Thanks,
> Yun​
>
>
>
> --
> Yun Tao
> Postdoc
> Center for Infectious Disease Dynamics
> Pennsylvania State University
> State College, PA 16803
>
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
>
_______________________________________________
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