Hi, I’m trying to solve a buckling problem for an hyperelastic beam.
Here I show my code:
from dolfin import *
import fenics as fe
import time
mesh = RectangleMesh(Point(0.0, 0.0), Point(1.0, 0.1), 200, 50, "crossed")
V = VectorFunctionSpace(mesh, "Lagrange", 2)
left = CompiledSubDomain("near(x[0], side) && on_boundary", side=0.0, tol=10e-15)
right = CompiledSubDomain("near(x[0], side) && on_boundary", side=1.0, tol=10e-15)
c = Expression(("0.0", "0.0"), degree=2)
d = Expression(("-0.2", "0.0"), degree=2)
t = Expression(("0.0", "0.0"), degree=2)
du = TrialFunction(V)
v = TestFunction(V)
u = Function(V)
D = mesh.topology().dim()
print(D)
neumann_domain = MeshFunction("size_t", mesh, D-1)
neumann_domain.set_all(0)
CompiledSubDomain("near(x[0], side) && on_boundary", side=1.0, tol=10e-15).mark(neumann_domain, 1)
ds = Measure("ds", subdomain_data=neumann_domain)
bc1 = DirichletBC(V, c, left)
bc2 = DirichletBC(V, d, right)
bcs=[bc1,bc2]
# Kinematics
d = u.geometric_dimension()
I = Identity(d)
F = I + grad(u)
C = F.T*F
# Invariants of deformation tensors
Ic = tr(C)
J = det(F)
E, nu = 1e6, 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))
#Neo-Hookean
psi = (mu/2)*(Ic - 3) - mu*ln(J) + (lmbda/2)*(ln(J))**2
bb = Expression(("0.0", "-1000.0"), degree=2)
# Total potential energy
Pi = psi*dx - dot(t, u)*ds(1) #+ dot(bb,u)*dx
F = derivative(Pi, u, v)
# Compute Jacobian of F
J = derivative(F, u, du)
problem = NonlinearVariationalProblem(F, u, bcs, J)
solver = NonlinearVariationalSolver(problem)
prm = solver.parameters
prm['newton_solver']['absolute_tolerance'] = 1E-9
prm['newton_solver']['relative_tolerance'] = 1E-9
prm['newton_solver']['maximum_iterations'] = 200
solver.solve()
L2 = inner(u, u) * dx
H10 = inner(grad(u), grad(u)) * dx
energynorm = sqrt(assemble(psi*dx))
# H1 = inner(F, P) * dx
L2norm = sqrt(assemble(L2))
H10norm = sqrt(assemble(H10))
print("L2 norm = %.10f" % norm(u, norm_type="L2"))
print("H1 norm = %.10f" % norm(u, norm_type="H1"))
print("H10 norm = %.10f" % norm(u, norm_type="H10"))
# Plot solution
plot(u, title='Displacement', mode='displacement')
#NEO-HOOKEAN
With an imposed displacement of -0.2 on the free right end, I should obtain a solution with buckling, but I only get a solution with 0 vertical displacement.
How can I solve this issue?
Thank you