Thanks for the answer;
I tryed the first example in the documentation.
I wanted just to write code for the first part as a python programme
but I have an error message, could any one correct this this programme for
me?
***************************************************************************************************************
nx=50
dx=1.
from fipy.grid1D import Grid1D
mesh=Grid1D(nx=nx, dx=dx)
from fipy.variables.cellVariables import CellVariable
phi=CellVariable(name="solution variable",mesh=mesh,value=0)
D=1.
valueLeft=1.
valueRight=0.
from fipy.boundaryConditions.fixedValue import FixedValue
BCs=(FixedValue(faces=mesh.getFacesRight(), value=valueLeft),
FixedValue(faces=mesh.getFacesLeft(), value=valueRight))
from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
from fipy.terms.transientTerm import TransientTerm
eqX=TransientTerm()==ExplicitDiffusionTerm(coeff=D)
timeStepDuration=0.9*dx**2/(2*D)
steps=100
x=mesh.getCellCenters()[...,0]
t=timeStepDuration*steps
from fipy.tools.numerix import sqrt
phiAnalytical=CellVariable(name="analytical value", mesh=mesh)
try:
from scipy.special import erf
phiAnalytical.setValue(1-erf(x/(2*sqrt(D*t))))
except importError:
print "The Scipy library is not available to \
test the solution to the transient diffusion equation
if __name__ =='__main__':
from fipy import viewers
viewer=viewers.make(vars(phi, phiAnalytical), limits={'datamin':0,
'datamax':1.})
viewer.plot()
for step in range(steps):
eqX.solve(var=phi,boundaryConditions=BCs,dt=timeStepDuration)
if __name__=='__main__':
viewer.plot()
print phi.allclose(phiAnalytical, atol=7e-4)
if __name__ == '__main__':
raw_input("Explicit transcient diffusion. Press <return> to proceed...")
******************************************************************************************************************
here is the message error:
There an error in your program:
EOL while scanning single-quoted string
I dont understand this error message
regards
Franck.
2008/8/9 Jonathan Guyer <[EMAIL PROTECTED]>
>
>
> On Aug 9, 2008, at 10:15 AM, franck kalala wrote:
>
> Thanks for the answer. Then how do I set this initial value
>>
>> phi(x)=0 for x<0
>> phi(x)=1 for x>0
>>
>
> In FiPy 1.2:
>
> >>> x = mesh.getCellCenters()[..., 0]
> >>> phi.setValue(0, where=x < 0)
> >>> phi.setValue(1, where=x > 0)
>
> You should also specify what happens at x == 0.
>
>
> If you're using trunk/ then the first line would be
>
> >>> x, = mesh.getCellCenters()
>
>
>
>
--
***********************************************
***********************************************
Franck Kalala Mutombo
[EMAIL PROTECTED]
African Institut for Mathematical Sciences, Muizenberg Cape Town, South
Africa
[EMAIL PROTECTED]
************************************************
************************************************