This notebook demonstrates a few capabilities of SageMath in computations regarding the Kerr-Newman spacetime. The corresponding tools have been developed within the SageManifolds project.
NB: a version of SageMath at least equal to 9.2 is required to run this notebook:
version()
'SageMath version 10.1, Release Date: 2023-08-20'
First we set up the notebook to display mathematical objects using LaTeX rendering:
%display latex
and we initialize a time counter for benchmarking:
import time
comput_time0 = time.perf_counter()
Since some computations are quite heavy, we ask for running them in parallel on 8 threads:
Parallelism().set(nproc=8)
We declare the Kerr-Newman spacetime (or more precisely the part of it covered by Boyer-Lindquist coordinates) as a 4-dimensional Lorentzian manifold $\mathcal{M}$:
M = Manifold(4, 'M', latex_name=r'\mathcal{M}', structure='Lorentzian')
We then introduce the standard Boyer-Lindquist coordinates as a chart BL
(for Boyer-Lindquist) on $\mathcal{M}$, via the method chart()
, the argument of which is a string
(delimited by r"..."
because of the backslash symbols) expressing the coordinates names, their ranges (the default is $(-\infty,+\infty)$) and their LaTeX symbols:
BL.<t,r,th,ph> = M.chart(r"t r th:(0,pi):\theta ph:(0,2*pi):\phi")
print(BL); BL
Chart (M, (t, r, th, ph))
The 3 parameters $m$, $a$ and $q$ of the Kerr-Newman spacetime are declared as symbolic variables:
var('m a q')
We get the (yet undefined) spacetime metric:
g = M.metric()
The metric is defined by its components in the coordinate frame associated with Boyer-Lindquist coordinates, which is the current manifold's default frame:
rho2 = r^2 + (a*cos(th))^2
Delta = r^2 -2*m*r + a^2 + q^2
g[0,0] = -1 + (2*m*r-q^2)/rho2
g[0,3] = -a*sin(th)^2*(2*m*r-q^2)/rho2
g[1,1], g[2,2] = rho2/Delta, rho2
g[3,3] = (r^2 + a^2 + (2*m*r-q^2)*(a*sin(th))^2/rho2)*sin(th)^2
g.display()
The list of the non-vanishing components:
g.display_comp()
The component $g^{tt}$ of the inverse metric:
g.inverse()[0,0]
The lapse function:
N = 1/sqrt(-(g.inverse()[[0,0]])); N
N.display()
Let us first get the 1-forms $(\mathrm{d}t, \mathrm{d}r, \mathrm{d}\theta, \mathrm{d}\phi)$ as those forming the coframe associated with Boyer-Lindquist coordinates:
BL.coframe()
dt, dr, dth, dph = BL.coframe()[:]
dt, dph
The electromagnetic 4-potential 1-form $A$ of the Kerr-Newman solution is
A = - q*r/rho2 * (dt - a*sin(th)^2*dph)
A.set_name('A')
A.display()
The electromagnetic field tensor $F$ is computed as the exterior derivative of the 4-potential: $F = \mathrm{d} A$. In Sage, the exterior derivative of a $p$-form is returned by the function diff()
:
F = diff(A)
F.set_name('F')
F.display()
As a check, let us compare with Eq. (33.5) of Misner, Thorne & Wheeler (1973):
F == q/rho2^2 * (r^2-a^2*cos(th)^2)*dr.wedge( dt - a*sin(th)^2*dph ) \
+ 2*q/rho2^2 * a*r*cos(th)*sin(th)*dth.wedge( (r^2+a^2)*dph - a*dt )
We can get a short expression of $F$ by factoring the components:
F.apply_map(factor)
F.display()
The list of non-vanishing components of $F$:
F.display_comp()
The Hodge dual of $F$:
star_F = F.hodge_dual(g)
star_F.display()
Let us check that $F$ obeys the two (source-free) Maxwell equations:
diff(F).display()
diff(star_F).display()
The Levi-Civita connection $\nabla$ associated with $g$:
nabla = g.connection()
print(nabla)
Levi-Civita connection nabla_g associated with the Lorentzian metric g on the 4-dimensional Lorentzian manifold M
Let us verify that the covariant derivative of $g$ with respect to $\nabla$ vanishes identically:
nabla(g) == 0
Another view of the above property:
nabla(g).display()
The nonzero Christoffel symbols (skipping those that can be deduced by symmetry of the last two indices):
g.christoffel_symbols_display()
The default vector frame on the spacetime manifold is the coordinate basis associated with Boyer-Lindquist coordinates:
M.default_frame() is BL.frame()
BL.frame()
Let us consider the first vector field of this frame:
xi = BL.frame()[0] ; xi
print(xi)
Vector field ∂/∂t on the 4-dimensional Lorentzian manifold M
The 1-form associated to it by metric duality is
xi_form = xi.down(g)
xi_form.display()
Its covariant derivative is
nab_xi = nabla(xi_form)
print(nab_xi)
nab_xi.display()
Tensor field of type (0,2) on the 4-dimensional Lorentzian manifold M
Let us check that the vector field $\xi=\frac{\partial}{\partial t}$ obeys Killing equation:
nab_xi.symmetrize() == 0
Similarly, let us check that $\chi := \frac{\partial}{\partial\phi}$ is a Killing vector:
chi = BL.frame()[3] ; chi
nabla(chi.down(g)).symmetrize() == 0
Another way to check that $\xi$ and $\chi$ are Killing vectors is the vanishing of the Lie derivative of the metric tensor along them:
g.lie_derivative(xi) == 0
g.lie_derivative(chi) == 0
The Ricci tensor of $g$:
Ric = g.ricci()
print(Ric)
Field of symmetric bilinear forms Ric(g) on the 4-dimensional Lorentzian manifold M
Ric.display()
We can get a shorter expression by factorizing the components:
Ric.apply_map(factor)
Ric.display()
A matrix view of the components:
Ric[:]
Let us check that in the Kerr case, i.e. when $q=0$, the Ricci tensor is zero:
Ric_Kerr = Ric.copy()
Ric_Kerr.apply_map(lambda f: f.subs({q: 0}))
Ric_Kerr[:]
The Riemann curvature tensor of $g$:
R = g.riemann()
R.apply_map(factor)
print(R)
Tensor field Riem(g) of type (1,3) on the 4-dimensional Lorentzian manifold M
The component $R^0_{\ \, 101}$ of the Riemann tensor is
R[0,1,0,1]
The expression in the uncharged limit (Kerr spacetime) is
R[0,1,0,1].expr().subs(q=0).factor()
while in the non-rotating limit (Reissner-Nordström spacetime), it is
R[0,1,0,1].expr().subs(a=0).factor()
In the Schwarzschild limit, it reduces to
R[0,1,0,1].expr().subs(a=0, q=0)
Obviously, it vanishes in the flat space limit:
R[0,1,0,1].expr().subs(m=0, a=0, q=0)
The Ricci scalar $R = g^{ab} R_{ab}$ of the Kerr-Newman spacetime vanishes identically:
g.ricci_scalar().display()
The Einstein tensor is
G = Ric - 1/2*g.ricci_scalar()*g
print(G)
Field of symmetric bilinear forms Ric(g)-unnamed metric on the 4-dimensional Lorentzian manifold M
Since the Ricci scalar is zero, the Einstein tensor reduces to the Ricci tensor:
G == Ric
The invariant $F_{ab} F^{ab}$ of the electromagnetic field:
Fuu = F.up(g)
F2 = F['_ab']*Fuu['^ab']
print(F2)
Scalar field on the 4-dimensional Lorentzian manifold M
F2.display()
The energy-momentum tensor of the electromagnetic field:
Fud = F.up(g,0)
T = 1/(4*pi)*( F['_k.']*Fud['^k_.'] - 1/4*F2 * g )
T.apply_map(factor)
print(T)
Tensor field of type (0,2) on the 4-dimensional Lorentzian manifold M
T[:]
Check that the Einstein equation is satisfied:
G == 8*pi*T
Let us check the Bianchi identity $\nabla_p R^i_{\ \, j kl} + \nabla_k R^i_{\ \, jlp} + \nabla_l R^i_{\ \, jpk} = 0$:
DR = nabla(R) # long (takes a while)
print(DR)
Tensor field nabla_g(Riem(g)) of type (1,4) on the 4-dimensional Lorentzian manifold M
for i in M.irange():
for j in M.irange():
for k in M.irange():
for l in M.irange():
for p in M.irange():
print(DR[i,j,k,l,p] + DR[i,j,l,p,k] + DR[i,j,p,k,l], end=' ')
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
If the last sign in the Bianchi identity is changed to minus, the identity does no longer hold:
DR[0,1,2,3,1] + DR[0,1,3,1,2] + DR[0,1,1,2,3] # should be zero (Bianchi identity)
DR[0,1,2,3,1] + DR[0,1,3,1,2] - DR[0,1,1,2,3] # note the change of the second + to -
The tensor $R^\flat$, of components $R_{abcd} = g_{am} R^m_{\ \, bcd}$:
dR = R.down(g)
print(dR)
Tensor field of type (0,4) on the 4-dimensional Lorentzian manifold M
The tensor $R^\sharp$, of components $R^{abcd} = g^{bp} g^{cq} g^{dr} R^a_{\ \, pqr}$:
uR = R.up(g)
print(uR)
Tensor field of type (4,0) on the 4-dimensional Lorentzian manifold M
The Kretschmann scalar $K := R^{abcd} R_{abcd}$:
Kr_scalar = uR['^abcd']*dR['_abcd']
Kr_scalar.display()
A variant of this expression can be obtained by invoking the method factor()
on the coordinate function representing the scalar field in the manifold's default chart:
Kr = Kr_scalar.coord_function()
Kr.factor()
As a check, we can compare Kr to the formula given by R. Conn Henry, Astrophys. J. 535, 350 (2000):
Kr == 8/(r^2+(a*cos(th))^2)^6 *(
6*m^2*(r^6 - 15*r^4*(a*cos(th))^2 + 15*r^2*(a*cos(th))^4 - (a*cos(th))^6)
- 12*m*q^2*r*(r^4 - 10*(a*r*cos(th))^2 + 5*(a*cos(th))^4)
+ q^4*(7*r^4 - 34*(a*r*cos(th))^2 + 7*(a*cos(th))^4) )
The Schwarzschild value of the Kretschmann scalar is recovered by setting $a=0$ and $q=0$:
Kr.expr().subs(a=0, q=0)
Let us plot the Kretschmann scalar for $m=1$, $a=0.9$ and $q=0.5$:
K1 = Kr.expr().subs(m=1, a=0.9, q=0.5)
plot3d(K1, (r,1,3), (th, 0, pi), axes_labels=['r', 'theta', 'Kr'])
print("Total elapsed time: {} s".format(time.perf_counter() - comput_time0))
Total elapsed time: 1108.1922762840022 s
NB: most of the computational time is spent in checking the Bianchi identity.