Hello Derek -

Thanks for your question.

> So does this imply that the correct way to implement this source term would 
> be:
> 
>  ImplicitSourceTerm(coeff = r_H * C_A * A * (1 - H_bar()/K_H) - delta_H - 
> delta_D * S)

Yes

> With H_bar() being a function:
> 
> # Set up the summing of HSCs
> def H_bar():
>     return H.cellVolumeAverage * mesh.cellVolumes.sum()

> 
> 
> Am I incorrect in manually computing H_bar() at every timestep and then using 
> it as the source term coefficient? 

There's no reason to write a function here. Just define

    H_bar = H.cellVolumeAverage * mesh.cellVolumes.sum()

and then use

    (1 - H_bar / K_H)

in your source. FiPy will take care of updating the value as needed.


> Also, will there be any problems with A and S also being CellVariables in 
> this coupled PDE system?

No

> For the Convection term:
> 
> And as another question, for the convection term, is it appropriate to have 
> it as:
> 
> ConvectionTerm(coeff = v_A + C_phi + Phi() + S.faceGrad)

Do you mean

    ConvectionTerm(coeff = v_A + C_phi * Phi() * S.faceGrad)

?

ConvectionTerm represents $\nabla\cdot(\vec{u} H)$, but your expression is just 
$\vec{u} \cdot \nabla H$. You're missing $H \nabla\cdot\vec{u}$. Specifically, 
you have a source 

   ImplicitSourceTerm(coeff=C_phi * Phi() * S.faceGrad.divergence, var=H)


> As in the source term, will there be issues with having Phi() as a function 
> which changes at every timestep? 

Shouldn't be, but it depends how you define it. Basically, the thing to 
remember is that the function Phi() will not be called at each time step. The 
return value of the function will be evaluated at each time step. If the return 
value depends on your solution variable, then it will update. If the return 
value depends on the *value* of the solution variable, then it will not update. 

You're generally better off just writing a variable expression, e.g.,

    Phi = H * A * S + ...

than defining a function. 


- Jon
_______________________________________________
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