In [1]:
from spacetimeengine import *
In [2]:
from galgebra.printer import Format, GaLatexPrinter
Format()
from galgebra.ga import Ga
from galgebra.mv import ONE, ZERO, HALF
In [3]:
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)))
In [4]:
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)
In [5]:
def dot_basis_r_basis(ga):
return [ga.dot(ga.basis[i], ga.r_basis[i]) for i in ga.n_range]
In [6]:
def gg(ga):
return simplify(ga.g * ga.g_inv)
In [7]:
def conv_christoffel_symbols(cf):
return permutedims(Array(cf), (2, 0, 1))
In [8]:
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)))
In [9]:
minkowski = build_ga_from_solution(Solution().minkowski())
In [10]:
show(minkowski.mv())
In [11]:
minkowski.g
Out[11]:
In [12]:
minkowski.e_sq
Out[12]:
In [13]:
dot_basis_r_basis(minkowski)
Out[13]:
In [14]:
gg(minkowski)
Out[14]:
In [15]:
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])
In [16]:
show(g4.mv())
In [17]:
g4.g
Out[17]:
In [18]:
g4.e_sq
Out[18]:
In [19]:
dot_basis_r_basis(g4)
Out[19]:
In [20]:
gg(g4)
Out[20]:
In [21]:
show_christoffel_symbols(g4)
In [22]:
schwarzschild = build_ga_from_solution(Solution().schwarzschild())
In [23]:
show(schwarzschild.mv())
In [24]:
schwarzschild.g
Out[24]:
In [25]:
schwarzschild.e_sq
Out[25]:
In [26]:
dot_basis_r_basis(schwarzschild)
Out[26]:
In [27]:
gg(schwarzschild)
Out[27]:
In [28]:
show_christoffel_symbols(schwarzschild)
In [29]:
einstein_rosen_bridge = build_ga_from_solution(Solution().einstein_rosen_bridge())
In [30]:
show(einstein_rosen_bridge.mv())
In [31]:
einstein_rosen_bridge.g
Out[31]:
In [32]:
einstein_rosen_bridge.e_sq
Out[32]:
In [33]:
dot_basis_r_basis(einstein_rosen_bridge)
Out[33]:
In [34]:
gg(einstein_rosen_bridge)
Out[34]:
In [35]:
show_christoffel_symbols(einstein_rosen_bridge)
In [36]:
wfa = build_ga_from_solution(Solution().weak_field_approximation())
In [37]:
show(wfa.mv())
In [38]:
wfa.g
Out[38]:
In [39]:
show(wfa.mvr())
In [40]:
wfa.e_sq
Out[40]:
In [41]:
dot_basis_r_basis(wfa)
Out[41]:
In [42]:
gg(wfa)
Out[42]:
In [43]:
wfa.connect_flg
Out[43]:
In [44]:
show_christoffel_symbols(wfa)
In [45]:
flrw = build_ga_from_solution(Solution().friedmann_lemaitre_robertson_walker())
In [46]:
show(flrw.mv())
In [47]:
flrw.g
Out[47]:
In [48]:
flrw.e_sq
Out[48]:
In [49]:
dot_basis_r_basis(flrw)
Out[49]:
In [50]:
gg(flrw)
Out[50]:
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.
In [51]:
hypersphere = build_ga_from_solution(Solution().hypersphere())
In [52]:
show(hypersphere.mv())
In [53]:
hypersphere.g
Out[53]:
In [54]:
hypersphere.e_sq
Out[54]:
In [55]:
dot_basis_r_basis(hypersphere)
Out[55]:
In [56]:
gg(hypersphere)
Out[56]:
In [57]:
show_christoffel_symbols(hypersphere)
In [58]:
# 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
In [59]:
# kerr = build_ga_from_solution(kerr_metric())
# FIXME takes too long
In [ ]: