Hello everybody,
I am a French student and I am trying to model the emergence of patterns
on the fur of animals using the Turing equations (involving the
concentrations u and v) and to code it thanks to the FiPy library. A
pattern appearing only if the system is unstable, it is necessary that
the initial conditions on u and v can be changed. Here is my program
where everything is initialized to 0.5 ... which does not suit me so. I
have tried to find help on google and on French forums but no one could
help me. Can anyone explain me how to solve my problem ?
from fipy import *
from math import *
a = 0.25
b = 0.75
d = 20
nx = 20
ny = nx
dx = 1.
dy = dx
L = dx * nx
mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)
u = CellVariable(name = "concentration u", mesh = mesh, hasOld=True,
value = 0.5)
v = CellVariable(name = "concentration v", mesh = mesh, hasOld=True,
value = 0.5)
D = 1.
eqn0 = TransientTerm(var=u) == a - u + u*u*v + DiffusionTerm(1, var=u)
eqn1 = TransientTerm(var=v) == b - u*u*v + DiffusionTerm(D, var=v)
eqn = eqn0 & eqn1
#pas d'échange avec l'extérieur -> conditions de Neumann
u.faceGrad.constrain(((0,),(0,)), where=mesh.facesTop)
u.faceGrad.constrain(((0,),(0,)), where=mesh.facesBottom)
u.faceGrad.constrain(((0,),(0,)), where=mesh.facesRight)
u.faceGrad.constrain(((0,),(0,)), where=mesh.facesLeft)
v.faceGrad.constrain(((0,),(0,)), where=mesh.facesTop)
v.faceGrad.constrain(((0,),(0,)), where=mesh.facesBottom)
v.faceGrad.constrain(((0,),(0,)), where=mesh.facesRight)
v.faceGrad.constrain(((0,),(0,)), where=mesh.facesLeft)
vi = Viewer((u, v))
for t in range(1):
u.updateOld()
v.updateOld()
eqn.solve(dt=1.e-3)
vi.plot()
I tried adding the following lines of code ... but it does not work.
x, y = mesh.cellCenters
u.value = 0.5 + 0.5*sin(pi*x)*sin(pi*y)
v.value = 1 + sin(pi*x)*sin(pi*y)
Thank you in advance
Damien
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]