Thank you for your answer! When the coeffs are made into "Variable" as suggested, I get the error:
File "C:\Python27\lib\site-packages\fipy\terms\abstractDiffusionTerm.py",
line 188, in _calcGeomCoeff
raise IndexError, 'diffusion coefficent tensor is not an appropriate shape
for this mesh'
IndexError: diffusion coefficent tensor is not an appropriate shape for this
mesh
This is probably because myCoeff is of type "class
'fipy.variables.binaryOperatorVariable.binOp'" before I make it into a
"Variable".
Since we calculate all the values of our coeff values with an external
software, unfortunately we cannot define the coeff inside the DiffusionTerm().
Is there a way around this problem? (i.e. change the value of a
binaryOperatorVariable during calculation I guess?).
See attached file for the complete context.
Best Regards
Thomas
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Guyer,
Jonathan E. Dr.
Sent: den 20 mars 2014 22:47
To: FIPY
Subject: Re: update values of coefficients
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 ]
mailingListQuestion.py
Description: mailingListQuestion.py
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
