Hi, I'm slightly new to fenics and I've been trying to solve the Gray-Scott model for some time. I've tried to adapt the Cahn-Hillard python demo file (found here: http://fenicsproject.org/documentation/dolfin/dev/python/_downloads/demo_cahn-hilliard.py) for this purpose and now I have trouble locating where my problem is. I assume it has some something to do with the weak form when I'm passing it to the Newton solver, i.e., I'm not quite sure I'm using the Test- and TrialFunctions in the right way.
Here is some of my code:
# Split mixed functions, where W: solution n+1
# W0: solution n
u, v = split(W)
u0, v0 = split(W0)
# Weak statement of the equations
# Implicit Euler/ Implicit time stepping, with q,p TestFunctions on the domain V*V
F1 = -u*q*dx + u0*q*dx \
+ D_u*inner(grad(u), grad(q))*dt*dx \
- u*v0*v0*q*dt*dx \
+ c*(1-u)*q*dt*dx
F2 = -v*p*dx + v0*p*dx \
+ D_v*inner(grad(v), grad(p))*dt*dx \
+ u0*v*v*p*dt*dx \
- (c+k)*v*p*dt*dx
F = F1 + F2
# Compute directional derivative about W in the direction of dp (Jacobian)
a = derivative(F, W, dp)
# Create nonlinear problem and Newton solver
problem = GrayScottEquations(a, F)
solver = NewtonSolver()
solver.parameters["linear_solver"] = "lu"
solver.parameters["convergence_criterion"] = "incremental"
solver.parameters["relative_tolerance"] = 1e-6
# Step in time
t = 0.0
T = 50*dt
while (t < T):
t += dt
W0.vector()[:] = W.vector()
solver.solve(problem, W.vector())
plot(W.split()[1])
plot(W.split()[0])
interactive()