Hello. Currently I am working on solving forced convective flow. However, there is error said:
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
I dont know the mistakes. Here, I attach my coding. Thank you for your help.
from __future__ import print_function
from fenics import *
#set parameter values
rho = 997.1 #density water
mu = 1 #0.890*10^-3 #dynamic viscosity water
sigma = 0.05501 #electrical conductivity water
C = 4179 #heat capacitance water
c = 0.591 #thermal conductivity water
B_0 = 0
#create mesh
mesh = UnitSquareMesh(8,8)
#define function space
V = VectorElement('P', mesh.ufl_cell() , 2)
Q = FiniteElement('P', mesh.ufl_cell(), 2)
element = MixedElement([V, Q, Q])
W = FunctionSpace(mesh, element)
#define boundaries
outflow = 'near(x[1],1)'
walls = 'near(x[1],0)'
#define boundary condition
#walls
bcu_walls = DirichletBC(W.sub(0), Constant((0,0)), walls)
bcp_walls = DirichletBC(W.sub(1), Constant(0), walls) #pressure
bcT_walls = DirichletBC(W.sub(2), Constant(290), walls) #T_w
#outflow
bcu_outflow = DirichletBC(W.sub(0), Constant((1,0)), outflow) #u_e=1
bcp_outflow = DirichletBC(W.sub(1), Constant(1), outflow)
bcT_outflow = DirichletBC(W.sub(2), Constant(295), outflow) #uniform temperature
bcu = [bcu_walls, bcu_outflow]
bcT = [bcT_walls, bcT_outflow]
bcp = [bcp_walls, bcp_outflow]
bcs = bcu + bcT + bcp
#define test functions
(v, q, s) = TestFunctions(W)
#define functions
u = Function(W)
p = Function(W)
T = Function(W)
#split functions
w =Function(W)
(u, p, T) = w.split()
#define expression used in variational forms
n = FacetNormal(mesh)
mu = Constant(mu)
rho = Constant(rho)
sigma = Constant(sigma)
C = Constant(C)
c = Constant(c)
B_0 = Constant(B_0)
#define variational problem
F1 = div(u)*q*dx
F2 = rho*dot(dot(u,nabla_grad(u)),v)*dx + div(v)*p*dx - dot(n*p,v)*ds + mu*inner(nabla_grad(u),nabla_grad(v))*dx \
- mu*dot(nabla_grad(u)*n,v)*ds + sigma*pow(B_0,2)*dot(u,v)*dx
F3 = rho*C*dot(u,grad(T))*s*dx-c*div(grad(T))*s*dx
F = F1 + F2 + F3
# Create VTK files for visualization output
vtkfile_u = File('steady_system/u.pvd')
vtkfile_p = File('steady_system/p.pvd')
vtkfile_T = File('steady_system/T.pvd')
# Solve variational problem for time step
solve(F == 0, w)
# Save solution to file (VTK)
vtkfile_u << u
vtkfile_p << p
vtkfile_T << T
# Plot solution
plot(u, title='Velocity')
plot(p, title='Pressure')
plot(T, title='Temperature')
# Hold plot
interactive()