The solver converged with the inlet velocity of 0.01 m/s, while it did not converge with the inlet velocity of 0.1 m/s. I checked the Re number. The flow is laminar. Who can help me? Thank you!
The following is the error message and code.
*** -------------------------------------------------------------------------
*** Error: Unable to solve nonlinear system with NewtonSolver.
*** Reason: Newton solver did not converge because maximum number of iterations reached.
*** Where: This error was encountered inside NewtonSolver.cpp.
*** Process: 0
*** DOLFIN version: 2019.1.0
from dolfin import *
import mshr
import matplotlib.pyplot as plt
from mshr import *
from fenics import *
mu = 1.05E-3
rho = 1000
#Generate mesh with mshr
domain = (Rectangle(dolfin.Point(0., -5.0E-3), dolfin.Point(15.0E-3, 5.0E-3)) +
Rectangle(dolfin.Point(15.0E-3, -30.0E-3), dolfin.Point(135.0E-3, 30.0E-3)) +
Rectangle(dolfin.Point(135.0E-3, -5.0E-3), dolfin.Point(150.0E-3, 5.0E-3)))
mesh = generate_mesh(domain, 100)
V = VectorElement(‘P’, mesh.ufl_cell(), 2)
Q = FiniteElement(‘P’, mesh.ufl_cell(), 1)
TH = MixedElement([V, Q])
W = FunctionSpace(mesh, TH)
#Defining the boundary
#plot(mesh)
inflow = ‘near(x[0], 0.0)’
outflow = ‘near(x[0], 150.0E-3)’
walls = (‘near(x[1], 5.0E-3) || near(x[1], 30.0E-3) || near(x[0],15.0E-3) || near(x[1], -5.0E-3) ||’ +
‘near(x[0], 135.0E-3) || near(x[1], -30.0E-3)’)
#Defining boundary conditions
bcu_inflow = DirichletBC(W.sub(0), Constant((0.1, 0.0)), inflow)
bcp_outflow = DirichletBC(W.sub(1), Constant(0), outflow)
bcu_noslip = DirichletBC(W.sub(0), Constant((0.0, 0.0)), walls)
bcs = [bcu_noslip, bcu_inflow, bcp_outflow]
#Define variational forms
v, q = TestFunctions(W)
w = Function(W)
dw= TrialFunction(W)
u, p = split(w)
#Equation
F1 = mu*inner(grad(u),grad(v))dx + rhoinner(dot(grad(u),u),v)*dx
- inner(p, div(v))*dx - inner(q, div(u))*dx
J = derivative(F1, w, dw)
newton_solver_parameters={“nonlinear_solver”: “newton”,
“newton_solver” :{“linear_solver” : “mumps”,
“maximum_iterations”: 50,
“report”: True,
“error_on_nonconvergence”: True
}
}
problem = NonlinearVariationalProblem(F1, w, bcs, J)
solver = NonlinearVariationalSolver(problem)
solver.parameters.update(newton_solver_parameters)
solver.solve()
u, p = split(w)
plot(u)