{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Schwarzschild spacetime: basic computations\n", "\n", "This notebook shows how to use SageMath to compute the Christoffel symbols of standard coordinates in Schwarzschild spacetime, as well as the Riemann curvature tensor and the Kretschmann scalar. The corresponding tools have been developed within the [SageManifolds](http://sagemanifolds.obspm.fr) project (version 1.2, as included in SageMath 8.2).\n", "\n", "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.2/SM_Schwarzschild.ipynb).\n", "\n", "Click [here](https://raw.githubusercontent.com/sagemanifolds/SageManifolds/master/Worksheets/v1.2/SM_Schwarzschild.ipynb) to download the notebook file (ipynb format). To run it, you must start SageMath with the Jupyter interface, via the command `sage -n jupyter`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*NB:* a version of SageMath at least equal to 8.2 is required to run this worksheet:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'SageMath version 8.2, Release Date: 2018-05-05'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "version()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we set up the notebook to display mathematical objects via LaTeX rendering:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%display latex" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Spacetime manifold\n", "\n", "We declare the spacetime manifold as a 4-dimensional Lorentzian manifold:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4-dimensional Lorentzian manifold M\n" ] } ], "source": [ "M = Manifold(4, 'M', structure='Lorentzian')\n", "print(M)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Standard coordinates\n", "\n", "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 \n", "defines the range of each coordinate, if different from $(-\\infty, +\\infty)$, 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." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "Chart (M, (t, r, th, ph))" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X. = M.chart(r\"t r:(0,+oo) th:(0,pi):\\theta ph:(0,2*pi):\\phi\")\n", "X" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "(t, r, th, ph)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X[:]" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "(t, ph)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X[0], X[3]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Metric tensor\n", "\n", "We introduce first the mass parameter $m$ as a symbolic variable, via the function `var()`:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "m = var('m')\n", "assume(m>=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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`:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "g = (2*m/r - 1) dt*dt - 1/(2*m/r - 1) dr*dr + r^2 dth*dth + r^2*sin(th)^2 dph*dph" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = M.metric()\n", "g[0,0] = -(1-2*m/r)\n", "g[1,1] = 1/(1-2*m/r)\n", "g[2,2] = r^2\n", "g[3,3] = (r*sin(th))^2\n", "g.display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Viewing the metric components as a matrix:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "[ 2*m/r - 1 0 0 0]\n", "[ 0 -1/(2*m/r - 1) 0 0]\n", "[ 0 0 r^2 0]\n", "[ 0 0 0 r^2*sin(th)^2]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g[:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Accessing to a specific component:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "2*m/r - 1" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g[0,0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Christoffel symbols\n", "\n", "The Christoffel symbols of $g$ with respect to the Schwarzschild-Droste coordinates are\n", "printed by the method `christoffel_symbols_display()` applied to the metric object `g`. By \n", "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." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "Gam^t_t,r = -m/(2*m*r - r^2) \n", "Gam^r_t,t = -(2*m^2 - m*r)/r^3 \n", "Gam^r_r,r = m/(2*m*r - r^2) \n", "Gam^r_th,th = 2*m - r \n", "Gam^r_ph,ph = (2*m - r)*sin(th)^2 \n", "Gam^th_r,th = 1/r \n", "Gam^th_ph,ph = -cos(th)*sin(th) \n", "Gam^ph_r,ph = 1/r \n", "Gam^ph_th,ph = cos(th)/sin(th) " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g.christoffel_symbols_display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Accessing to a Christoffel symbol specified by its indices:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "-m/(2*m*r - r^2)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g.christoffel_symbols()[0,0,1]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Checking the symmetry on the last two indices:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "True" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g.christoffel_symbols()[0,0,1] == g.christoffel_symbols()[0,1,0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Einstein equation\n", "\n", "Let us check that $g$ is a solution of the vacuum Einstein equation, i.e. that its Ricci tensor vanishes identically:" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "Field of symmetric bilinear forms Ric(g) on the 4-dimensional Lorentzian manifold M" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g.ricci()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "Ric(g) = 0" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g.ricci().display()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "[0 0 0 0]\n", "[0 0 0 0]\n", "[0 0 0 0]\n", "[0 0 0 0]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g.ricci()[:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Curvature tensor\n", "\n", "The Riemann curvature tensor is obtained by the method `riemann()`:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tensor field Riem(g) of type (1,3) on the 4-dimensional Lorentzian manifold M\n" ] } ], "source": [ "R = g.riemann()\n", "print(R)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Contrary to the Ricci tensor, it is not identically zero:" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "Riem(g) = -2*m/(2*m*r^2 - r^3) d/dt*dr*dt*dr + 2*m/(2*m*r^2 - r^3) d/dt*dr*dr*dt - m/r d/dt*dth*dt*dth + m/r d/dt*dth*dth*dt - m*sin(th)^2/r d/dt*dph*dt*dph + m*sin(th)^2/r d/dt*dph*dph*dt - 2*(2*m^2 - m*r)/r^4 d/dr*dt*dt*dr + 2*(2*m^2 - m*r)/r^4 d/dr*dt*dr*dt - m/r d/dr*dth*dr*dth + m/r d/dr*dth*dth*dr - m*sin(th)^2/r d/dr*dph*dr*dph + m*sin(th)^2/r d/dr*dph*dph*dr + (2*m^2 - m*r)/r^4 d/dth*dt*dt*dth - (2*m^2 - m*r)/r^4 d/dth*dt*dth*dt - m/(2*m*r^2 - r^3) d/dth*dr*dr*dth + m/(2*m*r^2 - r^3) d/dth*dr*dth*dr + 2*m*sin(th)^2/r d/dth*dph*dth*dph - 2*m*sin(th)^2/r d/dth*dph*dph*dth + (2*m^2 - m*r)/r^4 d/dph*dt*dt*dph - (2*m^2 - m*r)/r^4 d/dph*dt*dph*dt - m/(2*m*r^2 - r^3) d/dph*dr*dr*dph + m/(2*m*r^2 - r^3) d/dph*dr*dph*dr - 2*m/r d/dph*dth*dth*dph + 2*m/r d/dph*dth*dph*dth" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "R.display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The component $R^0_{\\ \\,101} = R^t_{\\ \\,trt}$ of the Riemann tensor:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "-2*m/(2*m*r^2 - r^3)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "R[0,1,0,1]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Kretschmann scalar\n", "\n", "The Kretschmann scalar is the \"square\" of the Riemann tensor defined by \n", "$$ K = R_{abcd} R^{abcd}$$\n", "To compute it, we must form first the tensor fields whose components are $R_{abcd}$ and \n", "$R^{abcd}$. They are obtained by respectively lowering and raising the indices of the components $R^a_{\\ \\, 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:" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "Scalar field on the 4-dimensional Lorentzian manifold M" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "K = R.down(g)['_{abcd}'] * R.up(g)['^{abcd}']\n", "K" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "M --> R\n", "(t, r, th, ph) |--> 48*m^2/r^6" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "K.display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The symbolic expression representing the scalar field $K$ is returned by the method `expr()`:" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "48*m^2/r^6" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "K.expr()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "SageMath 8.2", "language": "", "name": "sagemath" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" } }, "nbformat": 4, "nbformat_minor": 2 }