Documente Academic
Documente Profesional
Documente Cultură
SageManifolds (/github/sagemanifolds/SageManifolds/tree/master)
/ Worksheets (/github/sagemanifolds/SageManifolds/tree/master/Worksheets)
/ v1.3 (/github/sagemanifolds/SageManifolds/tree/master/Worksheets/v1.3)
A more advanced notebook about Schwarzschild spacetime, involving many coordinate charts,
more tensor calculus and graphical outputs, is available here
(http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM
Click here
(https://raw.githubusercontent.com/sagemanifolds/SageManifolds/master/Worksheets/v1.3/SM_S
to download the notebook file (ipynb format). To run it, you must start SageMath with the
Jupyter interface, via the command sage -n jupyter
NB: a version of SageMath at least equal to 8.2 is required to run this notebook:
In [1]: version()
First we set up the notebook to display mathematical objects via LaTeX rendering:
Spacetime manifold ¶
We declare the spacetime manifold as a 4-dimensional Lorentzian manifold:
http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM_basic_Schwarzschild.ipynb 1/6
10/12/2018 Jupyter Notebook Viewer
Standard coordinates
The standard Schwarzschild-Droste coordinates are introduced via the method chart()
applied to the manifold object M . Note that the argument of chart() is a raw string (hence
the prefix r in front of it), which defines the range of each coordinate, if different from
(−∞, +∞), as well as its LaTeX symbol, if different from the Python symbol to denote the
coordinate. The Python variables for each coordinate are declared within the <...> operator
on the left-hand side, X denoting the Python variable chosen for the coordinate chart.
In [5]: X[:]
Out[5]: (t, r, θ, ϕ)
Out[6]: (t, ϕ)
Metric tensor
We introduce first the mass parameter m as a symbolic variable, via the function var() :
In [7]: m = var('m')
assume(m>=0)
The metric tensor of the Lorentzian manifold M is returned by the method metric() ; we
initialize its components in the chart X , which is the default (unique) chart on M :
http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM_basic_Schwarzschild.ipynb 2/6
10/12/2018 Jupyter Notebook Viewer
In [8]: g = M.metric()
g[0,0] = -(1-2*m/r)
g[1,1] = 1/(1-2*m/r)
g[2,2] = r^2
g[3,3] = (r*sin(th))^2
g.display()
Out[8]: 2m 1 2 2 2
g = ( − 1) dt ⊗ dt + (− ) dr ⊗ dr + r dθ ⊗ dθ + r sin (θ) dϕ ⊗ dϕ
2 m
r − 1
r
In [9]: g[:]
Out[9]: 2 m
− 1 0 0 0⎞
⎛ r
1
⎜ 0 − 0 0⎟
⎜ 2 m ⎟
−1
⎜ r ⎟
⎜ 2
⎟
⎜ 0 0 r 0⎟
⎝ 2 2 ⎠
0 0 0 r sin (θ)
In [10]: g[0,0]
Out[10]: 2m
− 1
r
Christoffel symbols
The Christoffel symbols of g with respect to the Schwarzschild-Droste coordinates are printed
by the method christoffel_symbols_display() applied to the metric object g . By
default, only the nonzero symbols and the nonredundant ones (taking into account the
symmetry of the last two indices) are displayed. Type g.christoffel_symbols_display? to
see all possible options.
http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM_basic_Schwarzschild.ipynb 3/6
10/12/2018 Jupyter Notebook Viewer
In [11]: g.christoffel_symbols_display()
Out[11]: Γ
t
t r
= −
m
2
2 mr−r
2
r 2 m −mr
Γ = −
t t 3
r
r m
Γ r r =
2
2 mr−r
r
Γ = 2m − r
θ θ
r 2
Γ = (2 m − r) sin (θ)
ϕ ϕ
θ 1
Γ =
r θ r
θ
Γ = − cos(θ) sin(θ)
ϕ ϕ
ϕ 1
Γ =
r ϕ r
ϕ cos(θ)
Γ =
θ ϕ sin(θ)
In [12]: g.christoffel_symbols()[0,0,1]
Out[12]: m
−
2
2 mr − r
Out[13]: True
Einstein equation
Let us check that g is a solution of the vacuum Einstein equation, i.e. that its Ricci tensor
vanishes identically:
In [14]: g.ricci()
In [15]: g.ricci().display()
http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM_basic_Schwarzschild.ipynb 4/6
10/12/2018 Jupyter Notebook Viewer
In [16]: g.ricci()[:]
Out[16]: 0 0 0 0
⎛ ⎞
⎜0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0⎟
⎝ ⎠
0 0 0 0
Curvature tensor
The Riemann curvature tensor is obtained by the method riemann() :
In [17]: R = g.riemann()
print(R)
In [18]: R.display()
Out[18]: 2m ∂ 2m ∂
Riem (g) = (− ) ⊗ dr ⊗ dt ⊗ dr + ( ) ⊗ dr ⊗ dr ⊗
2 3 2 3
2 mr − r ∂t 2 mr − r ∂t
2 2
m ∂ m sin (θ) ∂ m sin (θ)
⊗ dθ + ⊗ dθ ⊗ dθ ⊗ dt − ⊗ dϕ ⊗ dt ⊗ dϕ +
r ∂t r ∂t r ∂
2 2
2 (2 m − mr) ∂ 2 (2 m − mr) ∂ m ∂
− ⊗ dt ⊗ dt ⊗ dr + ⊗ dt ⊗ dr ⊗ dt −
4 4
r ∂r r ∂r r ∂r
2 2
m sin (θ) ∂ m sin (θ) ∂
⊗ dθ ⊗ dθ ⊗ dr − ⊗ dϕ ⊗ dr ⊗ dϕ + ⊗ dϕ ⊗ dϕ ⊗ d
r ∂r r ∂r
2
2m − mr ∂ m ∂
⊗ dt ⊗ dt ⊗ dθ + (− ) ⊗ dt ⊗ dθ ⊗ dt + (− )
4 2 3
r ∂θ 2 mr − r ∂
2
m ∂ 2 m sin (θ) ∂ 2 m sin
+ ( ) ⊗ dr ⊗ dθ ⊗ dr + ⊗ dϕ ⊗ dθ ⊗ dϕ −
2 3
2 mr − r ∂θ r ∂θ r
2 2
2m − mr ∂ 2m − mr ∂
+ ( ) ⊗ dt ⊗ dt ⊗ dϕ + (− ) ⊗ dt ⊗ dϕ ⊗ dt + (−
4 4
r ∂ϕ r ∂ϕ
m ∂ 2m ∂ 2
⊗ dr ⊗ dϕ + ( ) ⊗ dr ⊗ dϕ ⊗ dr − ⊗ dθ ⊗ dθ ⊗ dϕ +
2 3
2 mr − r ∂ϕ r ∂ϕ
http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM_basic_Schwarzschild.ipynb 5/6
10/12/2018 Jupyter Notebook Viewer
In [19]: R[0,1,0,1]
Out[19]: 2m
−
2 3
2 mr − r
Kretschmann scalar
The Kretschmann scalar is the "square" of the Riemann tensor defined by
abcd
K = R abcd R
To compute it, we must form first the tensor fields whose components are Rabcd and Rabcd .
They are obtained by respectively lowering and raising the indices of the components Ra bcd of
the Riemann tensor, via the metric g. These two operations are performed by the methods
down() and up() . The contraction is performed by summation on repeated indices, using
LaTeX notations:
In [21]: K.display()
Out[21]: M ⟶ R
2
48 m
(t, r, θ, ϕ) ⟼
6
r
The symbolic expression representing the scalar field K is returned by the method expr() :
In [22]: K.expr()
Out[22]: 48 m
2
6
r
http://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Worksheets/v1.3/SM_basic_Schwarzschild.ipynb 6/6