python - Multiply a matrix and a tensor with symbolic entries using sympy -
i using sympy , module gravypy calculate quantities in general relativity (ricci tensor , scalar, christoffel symbols , on.)
i multiply matrix tensor, both symbolic entries, , simplify result each entry. have tried use 'tensorproduct' module sympy.physics.quantum, error:
sympy.core.sympify.sympifyerror: sympify of expression 'could not parse ''' failed, because of exception being raised: syntaxerror: invalid syntax (, line 1)
the full code following:
from sympy import * sympy.physics.quantum import tensorproduct gravipy import * import csv t, r, theta, phi = symbols('t, r, \\theta, \phi') x = coordinates('\chi', [t, r, theta, phi]) #defining coordinates m=symbols('m') #m mass metrics = diag(-(1-2*m/r), 1/(1-2*m/r), r**2, r**2*sin(theta)**2) metrics_inv = metrics.inv() gs = metrictensor('g', x, metrics) gs_inv = metrictensor('g_inv', x, metrics_inv) #defining metric tensor gs (that 4x4 matrix) , inverse gs_inv ga = christoffel('ga', gs) #calculating christoffel symbols, 4x4x4 matrices print(ga(all,all,all)) ga2k= tensorproduct(gs_inv,ga) #trying calculate product of metric , christoffel symbols
one thing notice module gravypy distinguishes between covariant , controvariant tensors.
any idea why can't use tensorproduct, , possible alternatives? new python.
Comments
Post a Comment