Jonathan Guyer wrote:


On Apr 12, 2007, at 2:15 PM, Elizabeth Tseng wrote:


I should've been more explicit. I'm actually solving 3 PDEs, in which all variables influence one another. I have three variables to solve, A (which was the PHI in the last email), B, and C.

\frac{\partial A}{\partial t} = (D_1 / (r^2)) \frac{\partial}{\partial r} (r^2 \frac{\partial A}{\partial r}) - D_2 * A * C + D_3 * B

\frac{\partial B}{\partial t} = A * C - B

\frac{\partial C}{\partial t} = A * C + B - C

For the last two equations, I omitted the coefficients since they're constant.

OK. This is a bit more complicated, but I don't think it changes the fundamental approach, as far as the spherical Laplacian goes.

So for the equation part, I listed something like
eq_A = TransientTerm(coeff = r2) == ImplicitDiffusionTerm(coeff = <some coeff>*r2) + ImplicitSourceTerm(coeff = C * <some_coeff>) + <some_coeff> * B eq_B = TransientTerm() == <some coeff> * A * C - ImplicitSourceTerm(coeff = <some coeff>) eq_C = ImplicitSourceTerm(coeff = <some coeff> * A) + <some coeff> * B - <some coeff> * C

The boundary constraint is on A, which is dependent on time t. I think from the fipy manual I can figure out how to do that.

Boundary constraint? All of your equations will need boundary conditions, defined on both your inner and outer boundaries, but the default (\nabla A \cdot n = 0, etc.) is probably acceptable for most of these. Do you have an explicit boundary condition on A?
The boundary conditions for A is

\frac{\partial A}{\partial r}(0) = 0
and
A(R) = <some coeff> * 2 ^ (-t), where t is time
and
C' = C + B, where C' is a constant number, and B and C are what I'm solving

I listed there as
time = Variable()
BoundaryCondition_A = (FixedValue(faces=mesh.getFacesRight(),value=<some coeff> * (2 ** -time)), FixedFlux(faces=mesh.getFacesLeft(),value=0.)

What I did is increment the time variable by dt at each time step, and sweep for a number of times. Obviously I've listed something wrong because some of the values I get are negative....Also I noticed that the residual from the sweeping doesn't converge.....

Elizabeth



So since A is actually one diffusion term and two external source terms, how do I make this happen? If I multiply the first equation, as you suggested, on both sides by r**2, then I get:

\frac{\partial r2 PHI}{\partial t} = \frac{\partial}{\partial r} (D_1 r2 \frac{\partial PHI}{\partial r}) + D_2 * r^2 * A * C + D_3 * r^2 * B

That seems right.

How would I be able to represent the r^2 in term A*C and B then?

You can just use the r2 variable that I defined before.



Also, how do I solve three variables at each time step?

You'll need to sweep all three equations at each timestep (see FAQ 6.5). Examples 9.2, 9.3, and following show different treatments of solving more than one equation. Balancing the number of sweeps, the size of the timesteps, and the allowed residuals is going to take some experimentation on your part. Every problem is different.

Good luck,

Jon




Reply via email to