OK, I can write the equations with grad instead of faceGrad, but it doesn't
seem like the equations can be solved with what I've tried. I tried to use
eq.solve, which gives a TypeError, and to use sweep, which does not
converge in the while loop. I've linked the 2 versions of my code:
sweep version http://pastebin.com/5aH5DDKz
solve version http://pastebin.com/sBQj7knw

By the way, this code is trying to solve the equations attached to the
email (psi and phi are interchanged though).

On Wed, Dec 18, 2013 at 12:26 PM, Daniel Wheeler
<[email protected]>wrote:

> On Mon, Dec 16, 2013 at 4:30 PM, J Hung <[email protected]> wrote:
> > Hi,
> > I'm trying to find the best way to write my equation, which involves not
> > only diffusion terms in terms of two order parameters phi and psi, but
> also
> > terms like grad(phi) dot grad(laplacian(psi)). Since all these terms are
> > being added together, I'm trying to use faceGrad to make terms like
> > grad(phi) dot grad(laplacian(psi)) consistent with terms like
> > DiffusionTerm(var=phi). (Do you think this necessary?)
>
> I'm not sure. Can you paste up the tex for your equations? That might
> help because at the moment you have more than one variable, but only
> one equation, which is a little confusing.
>
>  > The way I'm trying to
> > express grad(phi) dot grad(laplacian(psi)) is
> >
> > DOT(phi.faceGrad,((psi.faceGrad).divergence).faceGrad)
> >
> > as in the following code:
> >
> >
> > import fipy as fp
> > mesh= fp.Grid2D(nx=500,ny=500,dx=0.25, dy=0.25)
> > phi = fp.CellVariable(name=r"$\phi$", mesh=mesh)
> > phi.setValue(fp.GaussianNoiseVariable(mesh=mesh, mean=0.5,
> variance=0.01))
> > psi = fp.CellVariable(name=r"$\psi$", mesh=mesh)
> > psi.setValue(fp.GaussianNoiseVariable(mesh=mesh, mean=0.5,
> variance=0.01))
> > PHI = phi.getArithmeticFaceValue()
> > PSI = psi.getArithmeticFaceValue()
> >
> > DOT = fp.numerix.dot
> > eq1=(fp.TransientTerm(var=phi) ==
> > DOT(phi.faceGrad,((psi.faceGrad).divergence).faceGrad)
> > +DiffusionTerm(coeff=PHI**2, var=phi)
> > -DiffusionTerm(coeff=PHI, var=psi))
> >
> >
> > But I get an error that the coefficient can not be a FaceVariable.
> Changing
> > the faceGrad to grad seems to make it alright, but would that affect the
> > accuracy?
>
> I'm not sure it matters a great deal for the first term on the RHS,
> but the term does need to end up being a "CellVariable" not a
> "FaceVariable". It'll be a "FaceVariable" in its current form. Change
> the outermost "faceGrad" to "grad" and things should work.

 --
> Daniel Wheeler
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>



-- 
Jane Hung
Graduate Student | MIT Department of Chemical Engineering
Hatton Lab 66-325 | Doyle Lab E18-509
[email protected] | 415.952.6325

<<attachment: teramoto yonezawa.PNG>>

_______________________________________________
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