Daniel Wheeler <daniel.wheeler2@...> writes:

> 
> Hi Clément,
> 
> There is a lot going on in those equations and they are not trivial to
> implement in FiPy, but I think the problem is tractable in FiPy.
> 
> On Tue, Mar 22, 2016 at 8:26 AM, douarre <douarre <at>
creatis.insa-lyon.fr> wrote:
> >
> > #==== Variables
> >
===============================================================================
> > n = CellVariable(mesh=m)
> > c = CellVariable(mesh=m)
> > v = CellVariable(mesh=m,rank=1) #v is a vector field
> 
> I think that it would be better to treat `v` as a two separate
> variables. This is unfortunate, but a requirement in FiPy as the
> interface doesn't really support vector equations yet. So use,
> 
> vx = CellVariable(mesh=m)
> vy = CellVariable(mesh=m
> 
> and
> 
> v = CellVariable(mesh=m, rank=1)
> 
> and then assign the values of vx and vy to v during the loop. I'm not
> sure if there is way to do this implicity, so just do it explicity for
> now.
> 
> > #equations
> > eq1 = TransientTerm(var=n) == UpwindConvectionTerm(coeff=v,var=n);
> 
> `eq1` is okay
> 
> > eq2 = TransientTerm(var=v) == -v*v.getGrad()+mu*c.getGrad();
> 
> `eq2` should be
> 
> nx = CellVariable(mesh=m, rank=1, value=0.)
> ny = CellVariable(mesh=m, rank=1, value=0.)
> nx[0] = 1.
> ny[1] = 1.
> eq2x = TransientTerm(var=vx) +UpwindConvectionTerm(coeff=v / 2,
> var=vx) == CentralDifferenceConvectionTerm(coeff=mu * nx, var=c);
> eq2x = TransientTerm(var=vy) +UpwindConvectionTerm(coeff=v / 2,
> var=vy) == CentralDifferenceConvectionTerm(coeff=mu * ny, var=c);
> 
> > eq3 = TransientTerm(var=c) + PowerLaw== DiffusionTerm(coeff=D, var=c)
+alpha * n -
> > c/tau;
> 
> eq3 = TransientTerm(var=c) == DiffusionTerm(coeff=D, var=c) +
> ImplicitSourceTerm(coeff=alpha, var=n) - ImplicitSourceTerm(var=c,
> coeff=1. / tau)
> 
> Remember that the `v` needs to be updated by `vx` and `vy` explicitly.
> 
> I hope that helps some.
> 
> Thanks,
> 
> Daniel
> 

Hello Daniel, and thank you very much for your swift answer.

Everything is working now, that is to say I don't have the errors I
described above, code runs 'till the end everytime and i get the patterns I
except.
I had thought of this solution of seperating v into vx and vy. But I was
pretty sure FiPy could handle this sort of vector-scalar coupling, maybe
lured by the possibility to explicitly set variables as vectors.
Thank you also for re-writing the equations.

I find it fantastic that you guys are so dilligent to answer newcommers'
questions.

Cheers from France,
Clément

_______________________________________________
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