On May 23, 2006, at 7:41 PM, Bjorn Hansen wrote:
I've got a PDE I'm trying to solve, and the examples + manual are
getting me *almost* there, but there are a couple of things I am
having trouble with.
Welcome, Bjørn!
I figure someone here should be able to help me pretty easily as I
think it is a fairly straight forward application of fipy. here is
the equation (solving for Psi, as a function of R and z):
To properly do cylindrical coordinates, you need a wedge-shaped mesh,
which we don't presently have. Creating one wouldn't be too hard, but
hopefully Daniel can chime in with what some of the inaccuracies are
with doing that.
In the meantime, I'm assuming you're using a Grid2D and taking its x
coordinate to be "R" and its y coordinate as "z".
To get the actual coordinate values, you can do:
>>> R = mesh.getCellCenters()[...,0]
>>> z = mesh.getCellCenters()[...,1]
and then just use those values in your Term coefficients.
R*(cost1)*Psi + 1/R * (const2)*Psi + del.(1/R * del Psi)
For the DiffusionTerm, since you're dealing with a flux from one cell
to another, you can get somewhat better results if you evaluate R on
the faces between cells. In principle, you should just be able to do:
>>> DiffusionTerm(coeff=1. / mesh.getFaceCenters()[...,0])
but because of the default coordinate system, some values of R(faces)
will be zero, giving you an infinite diffusivity. Probably the
easiest way to deal with that is to offset your mesh when you create it:
>>> mesh = Grid2D(nx=?, ny=?, dx=?, dy=?) + (epsilon,0)
- Jon
--
Jonathan E. Guyer, PhD
Metallurgy Division
National Institute of Standards and Technology
<http://www.metallurgy.nist.gov/>