I cannot use the diff function to obtain the second order Kirchoff-Piola tensor, as shown in the following snippet:
# Large displacements kinematics
def largeKinematics(u):
"""Return the strain tensor, and the significant invariants."""
d = u.geometric_dimension()
I = fe.Identity(d)
Fgrad = I + fe.grad(u)
C = Fgrad.T*Fgrad
E = 0.5*(C - I)
return E
E = largeKinematics(u)
# Stored strain energy density for a generic model
def strainDensityFunction(E):
return lambda_/2.*(fe.tr(E))**2. + mu*fe.tr(E*E)
psi = strainDensityFunction(E)
debugStress = False
if debugStress:
# Computation of the stresses
S = fe.diff(psi, E)
S_project = fe.project(S, Z)
sigmaViewer = fe.File('paraview/stress.pvd')
sigmaViewer << S_project
I have understood that I need to define a Variable object, but I cannot work out how to call the constructor and then apply the differentiation.
Thank you in advance for your help, if you need any additional code, please let me know.
Ale N.