Hi,
I've been having trouble getting this modification of the linear elasticity example found here working.
The Code:
from fenics import*
import time
# variables
rho = 1
g = 9.81
p = 1
W1 = 1/2 # where W is neo hookean
# create mesh
comm = mpi_comm_world()
mesh = UnitDiscMesh(comm, 20, 2, 3)
# create function space
V = VectorFunctionSpace(mesh, 'Lagrange', 1)
# boundary condition
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, (0, 0, 0), boundary)
# define cauchy stress and strain
def epsilon(u):
return 0.5*(nabla_grad(u) + nabla_grad(u).T)
def sigma(u):
return -p*Identity(d) + 2*W1*(Identity(d) + 2*epsilon(u) + nabla_grad(u)*nabla_grad(u).T)
#define trial and test functions
u = TrialFunction(V)
v = TestFunction(V)
d = u.geometric_dimension()
# variational problem
b = Constant((0, 0, -rho*g))
t_n = Constant((0, 0, 0))
a = inner(sigma(u), epsilon(v))*dx
L = dot(b, v)*dx +dot(t_n, v)*ds
# solution
u = Function(V)
solve(a == L, u, bc)
I know that the sigma term is the issue, because if I instead use the sigma found in the example the code will run with no issue.
I get the error " Expecting the left-hand side to be a bilinear form (not rank 1).
If I let sigma be -p*Identity(d), then I get the bilinear form error again.
The epsilon term runs fine by itself.
If I try and run `the product of the two gradient of u terms by themselves as the sigma function, I get the error
" raise ArityMismatch("Multiplying expressions with overlapping form argument number {0}, argument is {1}.".format(x.number(), x))
ArityMismatch: Multiplying expressions with overlapping form argument number 1, argument is v_1."
Any help would be appreciated.