from sympy import * from IPython.display import display params0, params1, params2, params3= symbols('params0 params1 params2 params3') E00, E01, E02, E11, E12, E22 = symbols('E00 E01 E02 E11 E12 E22') W, Q = symbols('W Q') Q=params0*(E00*E00)+params1*(E11*E11+E22*E22+2*E12*E12)+params2*(2*E01*E01+2*E02*E02) W=params3*(exp(Q)-1)/2 print("W=",W) print() for i in range(0,3): for j in range(0,3): if i<=j: print("result(",i,",",j,")=", end='') display(diff(W,'E%d%d' % (i,j))) print() #Indexes fourth order tensor A=Matrix(21,4, [ 0 , 0 , 0 , 0, 0 , 0 , 0 , 1, 0 , 0 , 0 , 2, 0 , 0 , 1 , 1, 0 , 0 , 1 , 2, 0 , 0 , 2 , 2, 0 , 1 , 0 , 1, 0 , 1 , 0 , 2, 0 , 1 , 1 , 1, 0 , 1 , 1 , 2, 0 , 1 , 2 , 2, 0 , 2 , 0 , 2, 0 , 2 , 1 , 1, 0 , 2 , 1 , 2, 0 , 2 , 2 , 2, 1 , 1 , 1 , 1, 1 , 1 , 1 , 2, 1 , 1 , 2 , 2, 1 , 2 , 1 , 2, 1 , 2 , 2 , 2, 2 , 2 , 2 , 2 ]) #for l in range(0,21): # print(A[l,0],A[l,1],A[l,2],A[l,3]) print() for l in range(0,21): print("result(",A[l,0],",",A[l,1],",",A[l,2],",",A[l,3],")=", end='') display(diff( diff(W,'E%d%d' % (A[l,0],A[l,1])) ,'E%d%d' % (A[l,2],A[l,3])))