Hello,
I am trying to conduct a multiplication like eps: C: eps, where epsilon is the 2nd-order strain tensor, and C is a 4th-order elasticity tensor. For that, I am using the below code, however, the line energy = inner(stress, eps)
gives the error: ufl.log.UFLException: Shapes do not match. Please note that I am using this sample code to see how I should do the multiplication of C_ijkl eps_kl eps_ij.
Any help is much appreciated.
from dolfin import *
mesh = RectangleMesh(Point(-0.5,-0.5),Point(0.5,0.5), 40, 40)
V = VectorFunctionSpace(mesh, "CG", 1)
y = Function(V)
def energy(y):
F = variable(grad(y))
I = Identity(len(y))
eps = 0.5* ((F-I).T + F-I )
e11, e12, e21, e22 = eps[0,0], eps[0,1], eps[1,0], eps[1,1]
E = (e11**2 + 2*e12**2 + e22**2) + (e11**2 + e22**2 + 2*e11 * e22)
elast_fourth = diff(diff(E, F), F)
stress = dot(elast_fourth , eps)
energy = inner(stress, eps)
return energy
energy(y)