On Mar 20, 2014, at 11:06 AM, Thomas Barkar <[email protected]> wrote:

> I have a question about the setting of coefficients.
> We are currently trying to solve a diffusion problem with variable 
> coefficients. Is there a way to set a new value for the coefficients in every 
> time step?  See schematic example below:
>  
>  
> eq = TransientTerm() == DiffusionTerm(coeff=myCoeff1) - 
> DiffusionTerm((coeff=myCoeff2,myCoeff3))
> while t < duration:
>                              myCoeff1 = someNewValue
> myCoeff2 = someNewValue
> myCoeff3 = someNewValue
>                              eq.solve(var=phi, dt=dt)

Simplest case:

myCoeff1 = Variable(value=someValue)
myCoeff2 = Variable(value=someValue)
myCoeff3 = Variable(value=someValue)

eq = TransientTerm() == DiffusionTerm(coeff=myCoeff1) - 
DiffusionTerm((coeff=myCoeff2,myCoeff3))
while t < duration:
    myCoeff1.value = someNewValue
    myCoeff2.value = someNewValue
    myCoeff3.value = someNewValue
    eq.solve(var=phi, dt=dt)


If your coefficients are functions of solution variables or time, then you 
should just write myCoeff1 et al. as the appropriate expressions and let FiPy's 
lazy evaluation take care of things for you. See examples/diffusion/mesh1D.py 
for examples of a time-dependent boundary condition (a time-dependent 
coefficient would work the same) and of a coefficient that is a function of the 
solution variable.


_______________________________________________
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