Hi, I am also trying to achieve the same thing with boundary conditions as -
# Boundary conditions
class top(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[1], 1., 1e-8)
class bot(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[1], 0., 1e-8)
boundaries = MeshFunction("size_t", mesh, mesh.geometry().dim() - 1)
top().mark(boundaries, 1)
bot().mark(boundaries, 2)
bc_top = DirichletBC(V.sub(1), Constant(1.), boundaries, 1)
bc_bottom = DirichletBC(V, Constant((0., 0.)), boundaries, 2)
bc_u = [bc_bottom, bc_top]
And I modified the elasto-plastic code with 2 conditions stated by @bleyerj as -
Nitermax, tol = 200, 1e-6 # parameters of the Newton-Raphson procedure
Nincr = 20
load_steps = [1., 2., 3.]
results = np.zeros((Nincr+1, 2))
for (i,t) in enumerate(load_steps):
A, Res = assemble_system(a, L, bc_u)
err0 = Res.norm("l2")
err1 = err0
print(err1/ err0)
print("Increment:", str(i + 1))
## 1st iteration with nonzero DirichletBC conditions
Du.interpolate(Constant((0, 0.1)))
niter = 0
while err1/err0 > tol and niter < Nitermax:
solve(A, du.vector(), Res, "umfpack")
Du.assign(Du+du)
deps = eps(Du)
sig_, n_elas_, beta_, dp_ = proj_sig(deps, sig_old, p)
local_project(sig_, W, sig)
local_project(n_elas_, W, n_elas)
local_project(beta_, W0, beta)
A, Res = assemble_system(a, L, bc_u)
err1 = Res.norm("l2")
print(err1/err0)
## 2nd iteration onwards => zero DirichletBC conditions
for bc in bc_u:
bc.homogenize()
niter += 1
u.assign(u+Du)
p.assign(p+local_project(dp_, W0))
sig_old.assign(sig)
p_avg.assign(project(p, P0))
results[i+1, :] = (u(0.5, 1.)[1], t)
But still the newton solver doesn’t converge and give nan values from 3rd iteration. Any guidance would be highly appreciable.
Thanks.
PS: Kindly have a look at my post Iterative solver diverging to get a better understanding of what I’m trying to do.