Tensor multiplication with different orders

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)

This should correspond to

inner(elast_fourth, outer(eps, eps))

unless I’m missing something. The operation dot(elast_fourth, eps) isn’t doing C_ijkl eps_kl (einstein summation) if that’s what you’re thinking. See this for more details.

3 Likes

Thank you so much for the quick response. Yes, this is what I was looking for!