from spacetimeengine import *
from galgebra.printer import Format, GaLatexPrinter
Format()
from galgebra.ga import Ga
from galgebra.mv import ONE, ZERO, HALF
from IPython.display import display, Math
def show(x):
if isinstance(x, list):
for item in x:
display(Math(GaLatexPrinter.latex(item)))
else:
display(Math(GaLatexPrinter.latex(x)))
def build_ga_from_solution(solution, norm=False):
[metric, coordinate_set, _index_config, cosmological_constant] = solution
return Ga('', g=metric, coords=coordinate_set, norm=norm)
def dot_basis_r_basis(ga):
return [ga.dot(ga.basis[i], ga.r_basis[i]) for i in ga.n_range]
def gg(ga):
return simplify(ga.g * ga.g_inv)
def conv_christoffel_symbols(cf):
return permutedims(Array(cf), (2, 0, 1))
def show_christoffel_symbols(ga):
if ga.connect_flg:
display(conv_christoffel_symbols(ga.Christoffel_symbols(mode=1)))
display(conv_christoffel_symbols(ga.Christoffel_symbols(mode=2)))
minkowski = build_ga_from_solution(Solution().minkowski())
show(minkowski.mv())
minkowski.g
' \\left [ \\begin{array}{cccc} 1 & 0 & 0 & 0 \\\\ 0 & -1 & 0 & 0 \\\\ 0 & 0 & -1 & 0 \\\\ 0 & 0 & 0 & -1 \\end{array}\\right ] '
minkowski.e_sq
dot_basis_r_basis(minkowski)
gg(minkowski)
g4coords = (u, x, y, z) = symbols("u x y z")
g = [
[0, 0, -exp(-z), 0],
[0, HALF * u ** 2 * exp(4 * z), 0, 0],
[-exp(-z), 0, 12 * exp(-2 * z), u * exp(-z)],
[0, 0, u * exp(-z), HALF * u ** 2],
]
g4 = build_ga_from_solution([g, g4coords, None, 0])
show(g4.mv())
g4.g
' \\left [ \\begin{array}{cccc} 0 & 0 & - e^{- z} & 0 \\\\ 0 & \\frac{u^{2} e^{4 z}}{2} & 0 & 0 \\\\ - e^{- z} & 0 & 12 e^{- 2 z} & u e^{- z} \\\\ 0 & 0 & u e^{- z} & \\frac{u^{2}}{2} \\end{array}\\right ] '
g4.e_sq
dot_basis_r_basis(g4)
gg(g4)
show_christoffel_symbols(g4)
The classic black hole solution. Uncharged and rotationally stationary.
schwarzschild = build_ga_from_solution(Solution().schwarzschild())
show(schwarzschild.mv())
schwarzschild.g
' \\left [ \\begin{array}{cccc} - \\frac{2 G M}{c^{2} r} + 1 & 0 & 0 & 0 \\\\ 0 & - \\frac{1}{- \\frac{2 G M}{c^{2} r} + 1} & 0 & 0 \\\\ 0 & 0 & - r^{2} & 0 \\\\ 0 & 0 & 0 & - r^{2} {\\sin{\\left (\\theta \\right )}}^{2} \\end{array}\\right ] '
schwarzschild.e_sq
dot_basis_r_basis(schwarzschild)
gg(schwarzschild)
show_christoffel_symbols(schwarzschild)
The most famous wormhole solution.
einstein_rosen_bridge = build_ga_from_solution(Solution().einstein_rosen_bridge())
show(einstein_rosen_bridge.mv())
einstein_rosen_bridge.g
' \\left [ \\begin{array}{cccc} \\frac{- 2 m + r}{r} & 0 & 0 & 0 \\\\ 0 & - \\frac{4 r}{- 4 m + 2 r} & 0 & 0 \\\\ 0 & 0 & - r^{2} & 0 \\\\ 0 & 0 & 0 & - r^{2} {\\sin{\\left (\\theta \\right )}}^{2} \\end{array}\\right ] '
einstein_rosen_bridge.e_sq
dot_basis_r_basis(einstein_rosen_bridge)
gg(einstein_rosen_bridge)
show_christoffel_symbols(einstein_rosen_bridge)
wfa = build_ga_from_solution(Solution().weak_field_approximation())
show(wfa.mv())
wfa.g
' \\left [ \\begin{array}{cccc} c^{2} \\left(- \\frac{2 G M}{c^{2} r} + 1\\right) & 0 & 0 & 0 \\\\ 0 & - \\frac{1}{- \\frac{2 G M}{c^{2} r} + 1} & 0 & 0 \\\\ 0 & 0 & - r^{2} & 0 \\\\ 0 & 0 & 0 & - r^{2} {\\sin{\\left (\\theta \\right )}}^{2} \\end{array}\\right ] '
show(wfa.mvr())
wfa.e_sq
dot_basis_r_basis(wfa)
gg(wfa)
wfa.connect_flg
True
show_christoffel_symbols(wfa)
The spacetime for an expanding universe.
flrw = build_ga_from_solution(Solution().friedmann_lemaitre_robertson_walker())
show(flrw.mv())
flrw.g
' \\left [ \\begin{array}{cccc} 1 & 0 & 0 & 0 \\\\ 0 & - \\frac{{a }^{2}}{- k r^{2} + 1} & 0 & 0 \\\\ 0 & 0 & - r^{2} {a }^{2} & 0 \\\\ 0 & 0 & 0 & - r^{2} {a }^{2} {\\sin{\\left (\\theta \\right )}}^{2} \\end{array}\\right ] '
flrw.e_sq
dot_basis_r_basis(flrw)
gg(flrw)
A metric which describes a spacetime where the cosmic time is assigned to the meaning of a 4D hypersphere radius. The essential idea behind this spacetime is that the "3+1" dimensionality commonly referenced in physics can be meaningfully mapped to the "3+1" dimensionality associated with a hypersphere; by the "3" angular coordinates and the "1" radial coordinate.
hypersphere = build_ga_from_solution(Solution().hypersphere())
show(hypersphere.mv())
hypersphere.g
' \\left [ \\begin{array}{cccc} 1 & 0 & 0 & 0 \\\\ 0 & - t^{2} & 0 & 0 \\\\ 0 & 0 & - t^{2} {\\sin{\\left (\\psi \\right )}}^{2} & 0 \\\\ 0 & 0 & 0 & - t^{2} {\\sin{\\left (\\psi \\right )}}^{2} {\\sin{\\left (\\theta \\right )}}^{2} \\end{array}\\right ] '
hypersphere.e_sq
dot_basis_r_basis(hypersphere)
gg(hypersphere)
show_christoffel_symbols(hypersphere)
# Modified from https://github.com/spacetimeengineer/spacetimeengine/blob/master/spacetimeengine/src/solutions.py
def kerr_metric():
"""
Description
===========
Returns Kerr metric.
"""
# Index configuration for the metric
index_config = "dd"
x0, x1, x2, x3 = symbols('x0 x1 x2 x3')
# Reference to the coordiante system.
coordinate_set = [x0, x1, x2, x3]
# Cosmological constant.
cosmological_constant = 0
a, J, M, c, G, r, delt, sigm = symbols('a J M c G r Delta Sigma')
a = (J/(M*c))
rs = (2*G*M/(c**2))
sigm = (x1**2 + (J/(M*c))**2 * cos(x2)**2)
delt = (r**2 - x0 * (2*G*M/(c**2)) + (J/(M*c))**2)
# Metric solution.
metric = Matrix([
[ (1 - rs * x1 / (x1**2 + (J/(M*c))**2 * cos(x2)**2) ), 0, 0, (2*G*M/(c**2))*x1*(J/(M*c))*sin(x2)**2 / (x1**2 + (J/(M*c))**2 * cos(x2)**2) ],
[ 0, -1 * ( (r**2 - x0 * (2*G*M/(c**2)) + (J/(M*c))**2) / (x1**2 + (J/(M*c))**2 * cos(x2)**2) ), 0, 0 ],
[ 0, 0, -1 * (x1**2 + (J/(M*c))**2 * cos(x2)**2), 0 ],
[ (2*G*M/(c**2))*x1*(J/(M*c))*sin(x2)**2 / (x1**2 + (J/(M*c))**2 * cos(x2)**2), 0, 0, -1 * (x1**2 + (J/(M*c))**2 + (rs*x1*(J/(M*c))**2/(x1**2 + (J/(M*c))**2 * cos(x2)**2))*sin(x2))*sin(x2) ]
])
# An array detailing the solution.
solution_array = [ metric, coordinate_set, index_config, cosmological_constant ]
return solution_array
# kerr = build_ga_from_solution(kerr_metric())
# FIXME takes too long