On Mon, Jul 11, 2011 at 8:51 AM, Julien Derr <julien.d...@gmail.com> wrote: > Hi Everyone, > > > I remind you what my problem is about, there is a diffusing field c, a > growing interface (defined by the level set parameter phi) and I wanted an > absorbing boundary at the interface, > > With the valuable help of Daniel and Jonathan, I modified this file > (MetalIonSourcevariable.py) like this > > To do this replace line 88 in > <http://matforge.org/fipy/browser/trunk/fipy/models/levelSet/electroChem/metalIonSourceVariable.py#L88> > > with "return self.distanceVar._cellInterfaceFlag * 1e+20". That will make > c=0 on the interface > (phi=0). > > I want to understand this trick, because I am now interested in putting an > appropriate source term in this problem.
It's a standard way to maintain an sort internal boundary condition of sorts. You set the source terms to be very large compared to the rest of the terms in the equation over a select region then only the source terms matter and you can maintain a variable's value at some predetermined value. > If I understand correctly the return value of this function is going to be > used later on, in a source term for the diffusing field. Yes, the "_MetalIonSourceVariable" is used as a coefficient in an ImplicitSourceTerm. See, <http://matforge.org/fipy/browser/trunk/fipy/models/levelSet/electroChem/metalIonDiffusionEquation.py#L145> > So why is it an > infinitely large value, if the boundary is absorbing ? and not a -infinity > term ? It could be either. It's just setting the value of the variable to be zero over the region of interest (the interface region in this case). > also if I want to add a positive source term, creation of a diffusive > species at the interface of a given finite value c1, how can I combinate > that with this infinity trick ?? You just need to construct the source terms in such a way that the value is the value you require for the given region S_p * value + S_c = 0 Make S_p and S_c large and have the correct ratio in a selected region. It's probably best to do this directly in the script by adding to the existing equations rather than messing directly with the internals of FiPy. The above is a for a fixed value. An internal flux is a little different. Hope this helps. -- Daniel Wheeler