Hi,
Thanks for your interest in FiPy. Having thought about your problem a
little bit, it occurred to me that N and C are indistinguishable. You
can model them both with the one equation and one variable. The left
most layer of cells can simply hold of N (or the layer of cells where
r=R1). You can also make the diffusion coefficient different in this
layer of cells. So you can write it like this,
assuming 2L = 1.0 and R1 = 0, and R2 = 1
nr = 10
nx = 10
dr = 0.1
dx = 0.1
## shift the mesh down one cell so that R=0 is the true boundary
m = Grid1D(nx=nx, ny=nr + 1, dx=dx, dy=dr) + [[0],[-dr]
CN = CellVariable(mesh=m, value=initialCondition)
D = FaceVariable(mesh=m)
X, R = mesh.getFaceCenters()
D[R < 0] = gammaN
D[R == 0] = gammaAdsorption
D[R > 0] = gammaC
eqn = TransientTerm() = DiffusionTerm(D)
while True:
eqn.solve(CN, dt=0.1)
I think this will work and you won't have to worry about boundary
conditions in any strange ways. The one thing to be careful about is
the boundary conditions on the X == L and X == -L boundaries. They
will have to be only for R > 0 otherwise you will be applying boundary
conditions to the ends of the 1D N domain.
Hope this helps. I'm sure you'll have some questions about what I did
above so feel free to ask.
Cheers
On Wed, Oct 7, 2009 at 8:43 AM, pibyfour <[email protected]> wrote:
> Hello all,
>
> I came across FiPy a few days ago and I'm certainly glad that I did -- it
> seems incredibly useful. I've now run through most of the simple examples
> and I think I understand what I'm doing. However, I want to solve a problem
> with some unusual boundary conditions and I'd like to make sure that I know
> how to implement them correctly. (Unfortunately, the manual is a little
> confusing with regard to boundary conditions)
>
> My problem is as follows. I have two concentrations C = C(r,x,t) and N =
> N(x,t). These are essentially bulk, C(r,x,t), and surface, N(x,t),
> concentrations in a particular geometry. Here, r is a radius with R1 <= r <=
> R2 and x is on an interval with -L <= x <= L. With various constants set
> equal to one, the equations that govern the concentrations are:
>
> dC/dt = nabla^{2} C,
> dN/dt = nabla^{2} N + dC/dr |_{r = R1},
>
> subject to some usual (fixed value and fixed flux) boundary conditions AND
> the condition that C(r,x,t) |_{r = R1} = N(x,t).
>
> Right now, my understanding is that I should specify C(r,x,t) |_{r = R1} =
> N(x,t) as an outlet boundary condition like Section 5.5 of the manual, and
> then I should just add the r part of the gradient of C(r,x,t) to the
> equation for N(x,t). Is this accurate?
>
> Any help would be really appreciated! And many thanks for making this
> software available.
>
--
Daniel Wheeler