Reputation: 255
I like to calculate the Christoffel symbols from a given line element and assign the expressions of each of Christoffel symbols to the variables in a user-defined function.
I am using the Python package pytearcat in Jupyter Notebook on Colab:
!pip install pytearcat
import pytearcat as pt
import numpy as np
tau,x,y,z = pt.coords('tau,x,y,z')
a = pt.fun('a','tau')
phi = pt.fun('phi','x,y,z')
ds2 = 'ds2 = a**2*(-(1 + 2*phi)*dtau**2 + (1 - 2*phi)*(dx**2 + dy**2 + dz**2))'
g = pt.metric(ds2)
Chr = pt.christoffel(First_kind = False)
Chr.display("^,_,_")
It gives output like the following (They are 40 in total, only first 10 are shown in the screenshot):
def phi_xyz(x, y, z):
return -1.0*0.05/(np.sqrt(x**2 +y**2 + z**2))
def dphi_dx(x, y, z):
return 1.0*0.05*x/((x**2 +y**2 + z**2)**(3/2))
def dphi_dy(x, y, z):
return 1.0*0.05*y/((x**2 +y**2 + z**2)**(3/2))
def dphi_dz(x, y, z):
return 1.0*0.05*z/((x**2 +y**2 + z**2)**(3/2))
def geodesic(p, u):
tau, K_tau, x, K_x, y, K_y, z, K_z, a = p
dadtau = a**2*np.sqrt(1/a**3)
# Christoffel symbols from pytearcat
gamma_000 = (dadtau/a)
gamma_001 = dphi_dx(x, y, z)/(2*phi_xyz(x, y, z)+1)
gamma_002 = dphi_dy(x, y, z)/(2*phi_xyz(x, y, z)+1)
gamma_003 = dphi_dz(x, y, z)/(2*phi_xyz(x, y, z)+1)
gamma_010 = gamma_001
gamma_011 = -((2*phi_xyz(x,y,z)-1)*(dadtau/a))/((2*phi_xyz(x,y,z)+1)*a)
gamma_020 = gamma_002
gamma_022 = -((2*phi_xyz(x,y,z)-1)*(dadtau/a))/((2*phi_xyz(x,y,z)+1)*a)
gamma_030 = gamma_003
gamma_033 = -((2*phi_xyz(x,y,z)-1)*(dadtau/a))/((2*phi_xyz(x,y,z)+1)*a)
geo = -1.0*(gamma_000*K_tau**2 + 2.0*gamma_001*K_tau*K_x + 2.0*gamma_002*K_tau*K_y + 2.0*gamma_003*K_tau*K_z + gamma_011*K_x**2 + gamma_022*K_y**2 + gamma_033*K_z**2)
return geo
In function geodesic
, I manually wrote down variables related to Christoffel symbols by checking the output of Chr.display("^,_,_")
in the form like gamma_000 = (dadtau/a)
and so on.
I like to make the process automated so that I don't have to write all 40 of them manually. I like to use a method to assign them into my variables of the format gamma_ijk
from Chr = pt.christoffel(First_kind = False)
through a loop or something relevant in this context. How can I do it?
Update: The issue has been discussed in https://github.com/pytearcat/pytearcat/issues/14#issue-2408499687
Upvotes: 0
Views: 103