Hi,
I have a complex equation to solve, in order to solve it I tried to mix the examples : "A system of advection–diffusion–reaction equations ", "A nonlinear Poisson equation" and "The heat equation" because my problem use different methods detailed in these examples.
I have the following error :
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
Newton solver finished in 0 iterations and 0 linear solver iterations.
I tried lots of things that I found here but nothing change.
Here is my code :
#coding=utf8
##############################
from fenics import *
##############################
mesh = RectangleMesh(Point(0.0, 0.0), Point(15.0, 5.0), 90, 30)
T = 5.0 # final time
num_steps = 10 # number of time steps
dt = T / num_steps # time step size
# Parameters
Dn = 1.
chi_0 = 1.
k_1 = 1.
rho_0 = 1.
omega = 1.
mu = 1.
lambda_0 = 1.
# Define function space for system of concentrations
P1 = FiniteElement('P', triangle, 1)
element = MixedElement([P1, P1, P1])
V = FunctionSpace(mesh, element)
# Define test functions
v_1, v_2, v_3 = TestFunctions(V)
# Define functions for pressure and concentrations
#w = Function(W)
u = Function(V)
u_n = Function(V)
# Split systeme functions to access components
u_1, u_2, u_3 = split(u)
u_n1, u_n2, u_n3 = split(u_n)
# Define expressions used in variational forms
k = Constant(dt)
Dn = Constant(Dn)
chi_0 = Constant(chi_0)
k_1 = Constant(k_1)
rho_0 = Constant(rho_0)
omega = Constant(omega)
mu = Constant(mu)
lambda_0 = Constant(lambda_0)
# Define variational problem
F = ((u_1 - u_n1) / k)*v_1*dx \
- Dn*dot(grad(u_1), grad(v_1))*dx \
+ ((chi_0*k_1*u_1) / (k_1 + u_3))*dot(grad(u_3), grad(v_1))*dx \
+ rho_0*u_1*dot(grad(u_2), grad(v_1))*dx \
+ ((u_2 - u_n2) / k)*v_2*dx \
- omega*u_1*v_2*dx + mu*u_1*u_2*v_2*dx \
+ ((u_3 - u_n3) / k)*v_3*dx + lambda_0*u_1*u_3*v_3*dx
# Create VTK files for visualization output
vtkfile_u_1 = File('endothecial_cells_migration/u_1.pvd')
vtkfile_u_2 = File('endothecial_cells_migration/u_2.pvd')
vtkfile_u_3 = File('endothecial_cells_migration/u_3.pvd')
# Create progress bar
progress = Progress('Time-stepping')
set_log_level(PROGRESS)
# Time-stepping
t = 0
for n in range(num_steps):
# Update current time
t += dt
# Solve variationnal problem for time step
solve(F == 0, u)
# Save solution to file (VTK)
_u_1, _u_2, _u_3 = u.split()
vtkfile_u_1 << (_u_1, t)
vtkfile_u_2 << (_u_2, t)
vtkfile_u_3 << (_u_3, t)
# Update previous solution
u_n.assign(u)
# UPdate progress bar
progress.update(t / T)
# Hold plot
interactive ()
I think that the problem come from the expression of F. Or maybe I need to change the arguments in the solver. But I didn't manage to correct the error.
Thank you for your help.