QZH_xia
December 17, 2024, 2:42am
1
Hello,
I am learning to write FreeFem code for the Cahn-Hilliard equation with Neumann boundary conditions. I have simplified one of the nonlinear terms, but it seems that the int2d
function requires a bilinear form. I believe this is where my problem lies. How should I write the integration for a nonlinear form?
Bao_h1_Neu3.edp (3.0 KB)
Lina
fb77
(François Bouchut)
December 17, 2024, 8:53am
2
You cannot write a bilinear varf for a nonlinear term.
Instead you have to write a linear varf
varf bphi(unused,zz) = int2d(Th)(Fhat()*zz/epsilon);
real[int] b2 = bphi(0,Vh);
Here the value of phi
is taken via the definition of Fhat()
Also, the definition of A should be
matrix A = [[Amumu,Amuphi],[Aphimu,Aphiphi]];
It leads to a blow up, probably because your nonlinearity is taken explicitly.
Instead you should use an implicit scheme (put \phi^{n+1} instead of \phi^n in F_\phi ), but this has to be resolved by an iteration scheme like the Newton method, as is done in
Cahn-Hilliard.edp (3.2 KB)
This is a simplification to P1 from https://community.freefem.org/t/can-you-tell-me-what-is-the-error-on-this-codes-progrrame-running-still-exact-and-approximate-solution-not-matching/3220/16 where Discontinuous Galerkin is used with P1dc