Thanks a lot, now it perfectly works ! :-) Damien <div>-------- Message d'origine --------</div><div>De : "Guyer, Jonathan E. Dr. (Fed)" <jonathan.gu...@nist.gov> </div><div>Date :05/10/2016 17:21 (GMT+01:00) </div><div>À : FIPY <FIPY@nist.gov> </div><div>Objet : Re: problem with my initial conditions </div><div> </div>I suspect the problem is that by doing `from math import *`, you are importing a version of the `sin` function that only operates on single numbers, not on fields. As a result, u and v get assigned uniform values.
`from numpy import *` would be better. `from fipy.tools.numerix import *` would be better, still. `from fipy import numerix as nmx` would be best of all. > On Oct 5, 2016, at 8:32 AM, Damien CHUDEAU <damien-r.chud...@orange.fr> wrote: > > 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 > fipy@nist.gov > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] _______________________________________________ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
_______________________________________________ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]