Hello all,
   After some experimentation it seems to me the values of facesphi do
update after every time step and that the approach outlined in the second
email is a valid one. If I attempt to use just phi as the variable used to
set D I get an error due to the difference in shapes between D and phi. It
seems that my second email outlines the correct method to use a coefficient
that depends in a piecewise fashion on the variable being solved (were the
coeff is defined at the cell faces). Please correct me if I am wrong.
   Would it be worthwhile to expand the mesh1D diffusion example to include
a piecewise version of the final part of that example in which the
diffusion coefficient depends linearly on concentration? I am willing to
write a new version of the example and post it here if there is interest to
make the change.

Cheers,

Salomon


On Fri, Jan 4, 2013 at 4:30 PM, Salomon Turgman Cohen <[email protected]>wrote:

> Hello all,
>    A possibility is to define the diffusion as a variable (similar to
> mesh1D with position dependent diffusion). In this case I can use something
> like
>
> phi = CellVariable(name="Concentration (M)",mesh=mesh,value=0.0)
>
> and then:
>
> facesphi=phi.arithmeticFaceValue
>
> to obtain the concentration at the faces. Can I then use statements in the
> form:
>
> D.setValue(facesphi*slope+intercept,where="concentration rage")
>
> My concern is that facesphi will not update as the solution is being
> obtained.  Thanks for any guidance.
>
> Salomon
>
>
>
>
> On Fri, Jan 4, 2013 at 2:51 PM, Salomon Turgman Cohen 
> <[email protected]>wrote:
>
>> Hello developers and users,
>>    I am interesting in solving a simple 1D diffusion equation using fipy.
>> My requirement is that the diffusion coefficient is concentration
>> dependent. Following the mesh1D example I know how to do this if I have a
>> simple functional form to describe the diffusion's dependence on
>> concentration. However, what I have is just 5 data points of diffusion
>> versus concentration. What I want to do is a linear interpolation of the
>> diffusion in between the data points. I constructed the following function
>> as an example:
>>
>> def diffusion(phi):
>>     if (phi>=0.0) & (phi<0.902449):
>>         return phi*(-7.63256E-8) + 1.05240E-7
>>     elif (phi >= 0.902449) & (phi < 1.807062):
>>         return phi*(-1.37296E-08) + 4.87503E-08
>>     elif (phi >= 1.807061587) & (phi < 2.713202143):
>>         return phi*(-2.23797E-08) + 6.43815E-08
>>     elif (phi >= 2.713202143) & (phi < 3.570465711):
>>         return phi*-1.48121E-09 + 7.67966E-09
>>     elif (phi >= 3.570465711) & (phi < 4.425457264):
>>         return phi*-4.04495E-10 + 3.83529E-09
>>     elif (phi >= 4.425457264):
>>         return phi*-4.62147E-10 + 4.0904E-09
>>
>> But it cannot handle the arrays obtained from CellVariables command. What
>> would be the right way to do this?
>>
>> Thanks!
>>
>> --
>> Salomon Turgman Cohen
>> Postdoctoral Associate
>> Cornell University
>> (919) 341-9650
>>
>
>
>
> --
> Salomon Turgman Cohen
> Postdoctoral Associate
> Cornell University
> (919) 341-9650
>



-- 
Salomon Turgman Cohen
Postdoctoral Associate
Cornell University
(919) 341-9650
_______________________________________________
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