Last active
August 29, 2015 14:21
-
-
Save dean-shaff/098b31763ff62cfb0dca to your computer and use it in GitHub Desktop.
GR_stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sympy as sym | |
x1, x2 = sym.symbols("x1 x2") | |
coord = [x1, x2] | |
g = sym.Matrix([[1,0],[0,x1**2]]) | |
ginv = g.inv() | |
def christoffel(coord, g, ginv, index1, index2, index3): | |
""" | |
coord is the list of coordinates, eg coord = [r, theta, phi] | |
where each coord entry is a SymPy symbol | |
g is the metric matrix | |
ginv is the inverse metric | |
index1 is the upper index. | |
index2 is the first lower index. | |
index3 is the second lower index. | |
""" | |
chris = 0 | |
if g.shape[0] != g.shape[1]: | |
print("You didn't define g correctly!") | |
size = g.shape[0] | |
for i in xrange(size): | |
chris += 0.5*ginv[i,index1]*(sym.diff(g[i,index2],coord[index3])+sym.diff(g[i,index3],coord[index2])-sym.diff(g[index2,index3],coord[i])) | |
return chris |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment