Hello all users
I have a question about making a FreeFEM code for my problem. To be specific, as a simple nonlinear problem, I tried to solve the following differential equations.
F’‘(x) + F(x) - F(x)^3 =0, F(0) =0, F’(\infty) = 0
So, the solution for the above differential equation is tanh(x/\sqrt(2)).
In order to solve this nonlinear equation, I follow some examples in official documents.
The below codes are my code;
func InitialCondition = 1. * (x>0) + 0.;
mesh Th = square(100, 10, [10 *x, 2 * y]);
fespace Vh(Th, P2 , periodic = [[1,x], [3,x] ] );
Vh u, v;
Vh du;
Vh uold = InitialCondition;
for(int i = 1; i < 7; i++){
solve example(du,v)
= int2d(Th)( ( dx(du ) * dx(v) + dy(du) * dy(v) ) - du * v + 3 * ( dx(du))* uold * uold * v )
- int2d(Th)( ( dx(uold) * dx(v) + dy(uold) * dy(v) ) - uold * v + uold * uold * uold * v)
+ on( 4, du = 0);
uold[] -= du[];
plot(uold );
}
Whenever I modified this code, I couldn’t reach to correct solutions.
Thank you for your help