Hi,
I am trying to solve a simple 1d visco-plasticity problem which is already solved using Abaqus here (chapter 2):
Lele, S. P. (2008). On a class of strain gradient plasticity theories: formulation and numerical implementation (Doctoral dissertation, Massachusetts Institute of Technology).
I’m getting RuntimeError: Newton solver did not converge because maximum number of iterations reached
When I check the log file, I see my residual is “nan” from the very start, and it stays the same.
Could anyone please help? Let me know for any clarification. Here is the implementation:
## Set-up
from dolfinx import fem, log, mesh, nls
from mpi4py import MPI
import numpy as np
from petsc4py import PETSc
import ufl
log.set_output_file("log.txt")
## Parameters
n_elems = 1000
x_left = 0.0
x_right = 10.0
dt = 0.02
t_final = 0.5 # Final time
ud_target = 1.0 # Displacement target
loading_rate = ud_target / t_final
μ = 100e9 # Shear modulus
S0 = 100e6 # Flow resistance
d0 = 0.1 # Reference flow rate
m = 0.02 # Rate sensitivity parameter
## Mesh
msh = mesh.create_interval(MPI.COMM_WORLD, n_elems, (x_left, x_right))
## Function space
P2 = ufl.FiniteElement("Lagrange", msh.ufl_cell(), 2)
ME = fem.FunctionSpace(msh, P2 * P2)
# # Boundary conditions
left_facets = mesh.locate_entities_boundary(msh, dim=0,
marker=lambda x: np.isclose(x[0], x_left))
right_facets = mesh.locate_entities_boundary(msh, dim=0,
marker=lambda x: np.isclose(x[0], x_right))
end_facets = mesh.locate_entities_boundary(msh, dim=0,
marker=lambda x: np.logical_or(np.isclose(x[0], x_left),
np.isclose(x[0], x_right)))
bc_ud_left = fem.dirichletbc(PETSc.ScalarType(0.0),
fem.locate_dofs_topological(V=ME.sub(0), entity_dim=0, entities=left_facets),
ME.sub(0))
uD = fem.Constant(msh, PETSc.ScalarType(0.0)) # Displacement loading on the right end
bc_ud_right = fem.dirichletbc(uD,
fem.locate_dofs_topological(V=ME.sub(0), entity_dim=0, entities=right_facets),
ME.sub(0))
bc_γp = fem.dirichletbc(PETSc.ScalarType(0.0),
fem.locate_dofs_topological(V=ME.sub(1), entity_dim=0, entities=end_facets),
ME.sub(1))
bcs = [bc_ud_left, bc_ud_right, bc_γp]
## Variational form
v, q = ufl.TestFunctions(ME)
u = fem.Function(ME) # Current solution
u0 = fem.Function(ME) # Solution from the previous converged step
ud, γp = ufl.split(u) # ud = displacement
ud0, γp0 = ufl.split(u0)
# Initial conditions
u.x.array[:] = 0.0
τ = μ * (ufl.grad(ud)[0] - γp)
γp_dot = (γp - γp0) / dt
τp = S0 * (ufl.algebra.Abs(γp_dot) / d0)**m * ufl.sign(γp_dot)
F0 = τ * ufl.grad(v)[0] * ufl.dx
F1 = (τ - τp) * q * ufl.dx
F = F0 + F1
# # Solver
problem = fem.petsc.NonlinearProblem(F, u, bcs)
solver = nls.petsc.NewtonSolver(MPI.COMM_WORLD, problem)
# # Solution
t = 0.0
u0.x.array[:] = u.x.array
while (t < t_final):
t += dt
uD.value = t * loading_rate
r = solver.solve(u)
print(f"Step {int(t/dt)}: num iterations: {r[0]}")
u0.x.array[:] = u.x.array