1from sympy
import symbols, trace, det, log, Pow, Rational, MatrixSymbol, Matrix, ccode
23 def first(X):
return Pow(det(F_), Rational(-2, dim)) * trace(X)
25 def second(X):
return Pow(det(F_), Rational(-4, dim)) * \
26 Rational(1, 2) * (trace(X)*trace(X) - trace(X*X))
27 energy = c1 * (first(RCG) - dim) + c2 * (second(RCG) - dim) + c3 * \
28 (first(RCG) - dim) * (second(RCG) - dim) + \
29 d1 * log(det(F_)) * log(det(F_))