On Thu, Jun 19, 2014 at 11:53 AM, Benny Malengier
<benny.maleng...@gmail.com> wrote:
> Hi,
>
> another question. This time on SourceTerm use. I'm checking an article with
> diffusion and reaction. So some species diffuse, others only react (waiting
> for diffused species to start). If there is an example with this floating on
> the internet, do point it my way!

Not that I'm aware of.

> You then have a coupled set of equations, of which one of the non diffusive
> species will have equation like
>
> eqn3 = TransientTerm(var=P0) == ImplicitSourceTerm(-k3*M1, var=P0) +
> ImplicitSourceTerm(-k5*M2, var=P0)
>
>
> eqn4 = TransientTerm(var=P1) == ImplicitSourceTerm(k3*P0, var=M1)
>
>
> M1 will have another equation that has a diffusionterm.
>
> In eqn3 it is normal to use ImplicitSourceTerm as the rhs has -k3 M1 P0.

Yes, but the right splitting for "-k3 * M1 * P0" is probably

   k3 * M1 * P0 - ImplicitSourceTerm(k3 * M1, var=P0) -
ImplicitSourceTerm(k3 * P0, var=M1)

> In eqn4, we could actually write
>
>
> eqn4 = TransientTerm(var=P1) == k3*P0*M1
>
>
> or
>
>
> eqn4 = TransientTerm(var=P1) == ImplicitSourceTerm(k3*M1, var=P0)
>
>
> In light that all will be coupled in one equation to solve, will this lead
> to different solutions?

It shouldn't assuming that there isn't an instability. Eventually,
they should converge to the same result, but not at the the same rate.

> Or will fipy internally all give this the same
> matrix formulation?

It certainly won't give the same matrix formulation for different
implicit / explicit choices. User needs to be aware of what's going
on.

> Also, in eqn3, the first term in rhs is actually -k3 M1 P0. It seems nicest
> if somehow it is guaranteed that values as in eqn4 for this term would be
> used. Will this be the case in this formulation?

Don't understand the question fully. Do you mean that it would be nice
to be using the latest value of "M1"? This won't happen as "M1" is
explicit in Equation 3. Either "P0" is explicit or "M1" will be
explicit in Equation 3 (or both). There is no way to avoid this.

> Perhaps there is a way to do this nicer and introduce a helper variable,
> U=M1*P0, so as to have only in eqn3 and eqn4 ImplicitSourceTerm(-k3, var=U)
> and ImplicitSourceTerm(k3, var=U) respectively. If so, how to go about to do
> this. If I do ImplicitSourceTerm(-k3, var=M1*P0) I get immediately the error
>
> fipy.terms.SolutionVariableNumberError: Different number of solution
> variables and equations.

The helper variable won't buy you anything. Use a Taylor expansion to
make the correct explicit / implicit choice

    S = Sc + var1 * dS / dvar1 + var2 * dS / dvar2

if S is the source term. The other choice would be to do full Newton iteration.

> So, I would need an equation for U, would that be
>
> eqnhelper = ImplicitSourceTerm(1, var=U) == M1*P0
>
> Or am I making things too complicated now.

This doesn't help since you still have an explicit representation for
M1 and P0 in one of the equations.

Cheers,

Daniel


-- 
Daniel Wheeler
_______________________________________________
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to