Newton solver issues on Neo-hookean solid model

Dear Fenics community,

My goal is to simulate kirigami/origami-like unfolding of structures. This is in principle a small deformation, large displacement problem. I’ve tried a few examples from the solid mechanics examples of Fenics and landed on Hyperelasticity.

I am encountering issues when trying to deform my structures: the newton solver diverges.

I provide below a fully working (until the divergence) minimal example (I run it in jupyter notebook):

Simple shape generation:

from dolfin import *
#mesh = UnitSquareMesh(32, 32)
#!dolfin-convert meshbase.msh meshbase.xml
from mshr import *
#mesh = Mesh('meshbase.xml');
import numpy as np
import matplotlib.pyplot as plt
import math

radius=1
n_pts=20
angles=np.linspace(0,2*np.pi,n_pts)
x=radius*np.cos(angles)
y=radius*np.sin(angles)
polygon=[]
for n in range(n_pts):
    polygon.append(Point(x[n],y[n]))

    #the outside_circle
Big_circle=Polygon(polygon)

#making the inset holes
ri=0.1
ro=0.8
off_center=0.05

angles_small=np.linspace(0,np.pi/2.,5)
angles_large=np.linspace(0,np.pi/2.,20)
x=ri*np.cos(angles_small)
x=np.hstack((x,np.ones(10)*x[-1]))
x=np.hstack((x,ro*np.cos(angles_large[::-1])))
x=np.hstack((x,np.linspace(ro,ri,10)))+off_center

y=ri*np.sin(angles_small)
y=np.hstack((y,np.linspace(ri,ro,10)))
y=np.hstack((y,ro*np.sin(angles_large[::-1])))
y=np.hstack((y,np.ones(10)*y[-1]))+off_center

holes=[]
for flip_x in [-1,1]:
    for flip_y in [-1,1]:
        hole=[]
        for n in range(len(x)):
            hole.append(Point(flip_x*x[n],flip_y*y[n]))
        try:
            inset_hole=Polygon(hole[::-1])
        except:
            inset_hole=Polygon(hole)
        Big_circle=Big_circle-inset_hole
to3d=Extrude2D(Big_circle,0.01)
mesh=generate_mesh(to3d,1)

By this point, I have a circular shape with 4 large holes inside. I want the outside rim to be fixed, and only the inside structure to unfold vertically under weight (pay attention to the z-scale : it is thin!)
mesh_hole

So I proceed with the model, adapted from the fenics page on neo-hookean solids:

parameters["form_compiler"]["cpp_optimize"] = True
ffc_options = {"optimize": True, \
               "eliminate_zeros": True, \
               "precompute_basis_const": True, \
               "precompute_ip_const": True}

    # Create mesh and define function space
V = VectorFunctionSpace(mesh, "Lagrange", 1)

# Mark boundary subdomians

def round_boundary(x, on_boundary):
    r = math.sqrt((x[0]*x[0]+x[1]*x[1]))
    return r > 0.9
bcs = [DirichletBC(V, Constant((0.0, 0.0, 0.0)), round_boundary)]

# Define functions
du = TrialFunction(V)            # Incremental displacement
v  = TestFunction(V)             # Test function
u  = Function(V)                 # Displacement from previous iteration
B  = Constant((0.0, -0.5, 0.0))  # Body force per unit volume
#T  = Constant((0.1,  0.0, 0.0))  # Traction force on the boundary

# Kinematics
d = u.geometric_dimension()
I = Identity(d)             # Identity tensor
F = I + grad(u)             # Deformation gradient
C = F.T*F                   # Right Cauchy-Green tensor

# Invariants of deformation tensors
Ic = tr(C)
J  = det(F)

# Elasticity parameters
E, nu = 1e5, 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))

# Stored strain energy density (compressible neo-Hookean model)
psi = (mu/2)*(Ic - 3) - mu*ln(J) + (lmbda/2)*(ln(J))**2

# Total potential energy
Pi = psi*dx - dot(B, u)*dx #- dot(T, u)*ds

# Compute first variation of Pi (directional derivative about u in the direction of v)
F = derivative(Pi, u, v)

# Compute Jacobian of F
J = derivative(F, u, du)

I took out the traction force, and I defined the boundary condition such that the rim is fixed.
Finally, I call the solver:

problem = NonlinearVariationalProblem(F, u, bcs, J,form_compiler_parameters=ffc_options)
solver = NonlinearVariationalSolver(problem)
solver.solve()

Looking at my console:

Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 2.021e-05 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Newton iteration 1: r (abs) = nan (tol = 1.000e-10) r (rel) = nan (tol = 1.000e-09)

I have tried to change the body force, the elasticity, etc. I simply run out of ideas. Any help is appreciated. Thanks !

Currently, you have only shared code for generating the mesh, not the code leading to the Newton solver and the error message

Edit: I cannot add more than 1 image per post. I want to provide an image of an output I would expect. This is from a similar structure deformed with Blender’s cloth simulation. I am trying to reproduce this kind of deformation in Fenics for physical accuracy, thinking the neo-hookean model might be appropriate.

This is a similar structure that unfolds like an origami under its own weight.