On Dec 10, 2012, at 3:47 PM, Adrian Jacobo wrote:
>> Not for me. If you're seeing something else, then it may come down to either
>> boundary conditions or parameter values. We probably need to see a minimal
>> script that exhibits what you're seeing.
> I send you attached a minimal script that shows one of the problems
> I'm having. Now I'm solving two uncoupled equations. This script
> produces the right solution for C (everything is zero) but B starts at
> B_0=2 and despite having the boundary conditions fixed at B=B_0 the
> solution evolves to B=1 (which violates the boundary conditions).
This turns out to be because you initialized B with an integer value. Try
making this change:
--- a/BufferDifussion.py
+++ b/BufferDifussion.py
@@ -29,7 +29,7 @@ mesh = fp.Grid3D(dx=dx, dy=dy,dz=dz, nx=nx, ny=ny,nz=nz)
#-----Equation parammeters, variables and definition-----#
D_c = 2e-10 # [m^2 s^-1]
D_b = 2e-11 # [m^2 s^-1]
-B_0 = 2 # [mol/m^3]
+B_0 = 2. # [mol/m^3]
C = fp.CellVariable(name = "Calcium",
mesh = mesh, value = 0.)
You should get a warning for this, but don't for some reason with coupled
equations. I've reopened http://matforge.org/fipy/ticket/143#comment:4 to
figure out what's wrong.
>>> Am I doing something wrong there?
>>> I also think that the nonlinear terms should be defined as ImplicitSource
>>> terms, but I don't know which variable should I use in the definition,
>>> since one of the terms depends both on B and C.
>> I would be inclined to make the eqC implicit in B and eqB implicit in C in
>> order to couple the equations together.
>>
>>
> Can you explain me how to do that?
I would be inclined to change
eqC = (fp.TransientTerm(var=C) ==
fp.DiffusionTerm(coeff=D_c,var=C) - K*(B*C-K_d*(B_0-B)))
eqB = (fp.TransientTerm(var=B) ==
fp.DiffusionTerm(coeff=D_b,var=B) - K*(B*C-K_d*(B_0-B)))
to
eqC = (fp.TransientTerm(var=C) ==
fp.DiffusionTerm(coeff=D_c,var=C)
- fp.ImplicitSourceTerm(coeff=K*(C+K_d), var=B)
+ K * K_d * B_0)
eqB = (fp.TransientTerm(var=B) ==
fp.DiffusionTerm(coeff=D_b,var=B)
- fp.ImplicitSourceTerm(coeff=K*B, var=C)
- fp.ImplicitSourceTerm(coeff=K*K_d, var=B)
+ K * K_d * B_0)
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]