Hi Daniel,
Thanks for the tip. The coupling functionality is working very nicely.
I'm trying to solve the following differential equation under the condition
that Psi=1 at x=0:
0 = \frac{\partial\phi}{\partial x} - \frac{\partial^{3}\phi}{\partial
x^{3}} + x^{2}\phi,
The results are qualitatively matching separate output from Mathematica.
However, the graph's vertical scale is all off. In fact, it scales
depending on the value of Lx. In addition, it isn't obeying the boundary on
the left side of the mesh.
I can't see why this is happening. Any idea what's going on? Here is the
code: (I used yours as a template)
from fipy import *
xmax = 10.
nx = 1000.
mesh = Grid1D(nx=nx, Lx=xmax)
x = mesh.getCellCenters()[0]
psi = CellVariable(name=r'$\psi$', hasOld=True, mesh=mesh)#, value=0.)
phi = CellVariable(name=r'$\phi$', hasOld=True, mesh=mesh)
psi.constrain(1, mesh.facesLeft)
psi.constrain(0, mesh.facesRight)
#phi.constrain(0, mesh.facesLeft)
phi.constrain(0, mesh.facesRight)
eqn1 = 0 == UpwindConvectionTerm(coeff = [[1]], var=psi) -
DiffusionTerm(coeff = 1, var=phi) + ImplicitSourceTerm(coeff = x, var=psi)
eqn2 = ImplicitSourceTerm(coeff = 1, var=phi) == UpwindConvectionTerm(coeff
= [[1]], var = psi)
eqn = eqn1 & eqn2
vi = Viewer(vars=(psi,phi), datamin=-1.5, datamax=1.5)
eqn.solve()
print psi
vi.plot()
raw_input('stopped')
On a separate note, one of the things I'm going to do next is define the
mesh from -xmax to +xmax. I know how to do this using the following line:
mesh = Grid1D(nx=nx, Lx=2*xmax) + [[-xmax]]
However, I would still need to set the value of $\psi$ at x=0. But since
x=0 is now no longer at the boundary of the mesh, it appears that one would
somehow need to set a value of Psi right in the middle of the mesh - a
"non-boundary condition". Can FiPy do this?
Many thanks.
Regards,
Altan
On Wed, Jun 13, 2012 at 11:44 AM, Daniel Wheeler
<[email protected]>wrote:
> On Wed, Jun 13, 2012 at 11:31 AM, Daniel Wheeler
> <[email protected]> wrote:
>
> > I have reposted the question to the mailing list. In the mean time, I
> > will have a look at the code that you created. The equation that I am
> > trying to solve for is:
> >
> > 0=\frac{\partial\phi}{\partial x}+i*\frac{\partial^{2}\phi}{\partial
> > x^{2}}-\frac{\partial^{3}\phi}{\partial x^{3}}+x^{2}\phi,
>
> You'll need to use three equations. One for the third order and one
> each for the real and imaginary parts (all coupled together).
>
> > A rookie question, but what does it mean to be on /trunk?
>
> You need to download an unreleased version of the code using
> subversion. Unfortunately, the coupling functionality has not yet been
> officially released yet. See
>
> <http://www.ctcms.nist.gov/fipy/documentation/SVN.html#documentation-svn>
>
> > For the second question, I was thinking to do that as well - ie just
> > split up the equations into real and imaginary parts and then solve them
> > separately. But before starting, I wanted to just confirm that there's
> > no other way to go about it.
>
> Using the coupling functionality should work well with this equation.
>
> Good luck.
>
> --
> Daniel Wheeler
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]