Hi Jon, Thanks! It works perfectly. However, we are also trying to implement a sensible adaptive time-step control for this problem and have faced some problems.
If the default solver (trilinos LinearGMRESSolver) is used we find that the mobility/diffusion coefficient and the thermodynamic factor is only evaluated at the beginning of the time-step which causes numerical instabilities if these have a strong variation with composition. In order to have a fully implicit integration the mobility and the thermodynamic factor need to be evaluated also at the end of the time-step, taking the composition variation of the mobility into account. Is this possible ? The included Cahn-Hilliard code shows that the evaluation of the mobility at a certain grid-point is only evaluated with the composition at the start of the time-step. Any input on this would be great. Thanks. Joakim -----Ursprungligt meddelande----- Från: [email protected] [mailto:[email protected]] För Guyer, Jonathan E. Dr. Skickat: den 24 mars 2014 20:40 Till: FIPY Ämne: Re: Solving the Cahn-Hilliard equation Hi Joakim - On Mar 23, 2014, at 7:16 PM, Joakim Odqvist <[email protected]> wrote: > All these samples produce different results (where code1.py is the correct). > In order to get the coupling with the external thermodynamics package we need > to use an approach that is shown in code3.py. Are you sure code1.py is correct? The `[i]` in DiffusionTerm(coeff=D*(13077.922*(1/(PHI[i]-PHI[i]**2))-96000.0)) mean that the diffusion coefficient depends only on the value of PHI at the i'th position. If I correct this to DiffusionTerm(coeff=D*(13077.922*(1/(PHI-PHI**2))-96000.0)) then code1.py and code2.py give the same results. code3.py gives a different answer because function() is only evaluated when eq is first declared and the coefficient is unchanging after that. > How can we define the problem in such a way so we can obtain the same results > in code1.py and code3.py? The attached script is how I'd do it by declaring a specialized FaceVariable subclass, with the caveat that it's exceptionally slow because of the Python loop, so that's *not* how I'd do it. Ideally, you want to query TC/TQ (or whatever) for the full array of values at one time and let the loop happen in C. If you can't do that, then you'll want to look into declaring _calcValue using Cython to do the loop for you in C.
code4.py
Description: code4.py
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
