Contravariant & Covariant indices in Tensors (Symbolic)

In [1]:
import sympy

from einsteinpy.symbolic import ChristoffelSymbols, RiemannCurvatureTensor

from einsteinpy.symbolic.predefined import Schwarzschild



sympy.init_printing()

Analysing the schwarzschild metric along with performing various operations

In [2]:
sch = Schwarzschild()

sch.tensor()
Out[2]:
$\displaystyle \left[\begin{matrix}1 - \frac{r_{s}}{r} & 0 & 0 & 0\\0 & - \frac{1}{c^{2} \left(1 - \frac{r_{s}}{r}\right)} & 0 & 0\\0 & 0 & - \frac{r^{2}}{c^{2}} & 0\\0 & 0 & 0 & - \frac{r^{2} \sin^{2}{\left(\theta \right)}}{c^{2}}\end{matrix}\right]$
In [3]:
sch_inv = sch.inv()

sch_inv.tensor()
Out[3]:
$\displaystyle \left[\begin{matrix}\frac{r}{r - r_{s}} & 0 & 0 & 0\\0 & \frac{c^{2} \left(- r + r_{s}\right)}{r} & 0 & 0\\0 & 0 & - \frac{c^{2}}{r^{2}} & 0\\0 & 0 & 0 & - \frac{c^{2}}{r^{2} \sin^{2}{\left(\theta \right)}}\end{matrix}\right]$
In [4]:
sch.order
Out[4]:
$\displaystyle 2$
In [5]:
sch.config
Out[5]:
'll'

Obtaining Christoffel Symbols from Metric Tensor

In [6]:
chr = ChristoffelSymbols.from_metric(sch_inv) # can be initialized from sch also

chr.tensor()
Out[6]:
$\displaystyle \left[\begin{matrix}\left[\begin{matrix}0 & \frac{r_{s}}{2 r^{2} \left(1 - \frac{r_{s}}{r}\right)} & 0 & 0\\\frac{r_{s}}{2 r^{2} \left(1 - \frac{r_{s}}{r}\right)} & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right] & \left[\begin{matrix}- \frac{r_{s} \left(- \frac{c^{2}}{2} + \frac{r_{s} c^{2}}{2 r}\right)}{r^{2}} & 0 & 0 & 0\\0 & \frac{r_{s} \left(- \frac{c^{2}}{2} + \frac{r_{s} c^{2}}{2 r}\right)}{r^{2} c^{2} \left(1 - \frac{r_{s}}{r}\right)^{2}} & 0 & 0\\0 & 0 & \frac{2 r \left(- \frac{c^{2}}{2} + \frac{r_{s} c^{2}}{2 r}\right)}{c^{2}} & 0\\0 & 0 & 0 & \frac{2 r \left(- \frac{c^{2}}{2} + \frac{r_{s} c^{2}}{2 r}\right) \sin^{2}{\left(\theta \right)}}{c^{2}}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & \frac{1}{r} & 0\\0 & \frac{1}{r} & 0 & 0\\0 & 0 & 0 & - \sin{\left(\theta \right)} \cos{\left(\theta \right)}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & \frac{1}{r}\\0 & 0 & 0 & \frac{\cos{\left(\theta \right)}}{\sin{\left(\theta \right)}}\\0 & \frac{1}{r} & \frac{\cos{\left(\theta \right)}}{\sin{\left(\theta \right)}} & 0\end{matrix}\right]\end{matrix}\right]$
In [7]:
chr.config
Out[7]:
'ull'

Changing the first index to covariant

In [8]:
new_chr = chr.change_config('lll') # changing the configuration to (covariant, covariant, covariant)

new_chr.tensor()
Out[8]:
$\displaystyle \left[\begin{matrix}\left[\begin{matrix}0 & \frac{r_{s}}{2 r^{2}} & 0 & 0\\\frac{r_{s}}{2 r^{2}} & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right] & \left[\begin{matrix}- \frac{r_{s}}{2 r^{2}} & 0 & 0 & 0\\0 & \frac{r_{s}}{2 c^{2} \left(r - r_{s}\right)^{2}} & 0 & 0\\0 & 0 & \frac{r}{c^{2}} & 0\\0 & 0 & 0 & \frac{r \sin^{2}{\left(\theta \right)}}{c^{2}}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & - \frac{r}{c^{2}} & 0\\0 & - \frac{r}{c^{2}} & 0 & 0\\0 & 0 & 0 & \frac{r^{2} \sin{\left(2 \theta \right)}}{2 c^{2}}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & - \frac{r \sin^{2}{\left(\theta \right)}}{c^{2}}\\0 & 0 & 0 & - \frac{r^{2} \sin{\left(2 \theta \right)}}{2 c^{2}}\\0 & - \frac{r \sin^{2}{\left(\theta \right)}}{c^{2}} & - \frac{r^{2} \sin{\left(2 \theta \right)}}{2 c^{2}} & 0\end{matrix}\right]\end{matrix}\right]$
In [9]:
new_chr.config
Out[9]:
'lll'

Any arbitary index configuration would also work!

In [10]:
new_chr2 = new_chr.change_config('lul')

new_chr2.tensor()
Out[10]:
$\displaystyle \left[\begin{matrix}\left[\begin{matrix}0 & \frac{r_{s}}{2 r \left(r - r_{s}\right)} & 0 & 0\\\frac{r_{s} c^{2} \left(- r + r_{s}\right)}{2 r^{3}} & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right] & \left[\begin{matrix}- \frac{r_{s}}{2 r \left(r - r_{s}\right)} & 0 & 0 & 0\\0 & - \frac{r_{s}}{2 r \left(r - r_{s}\right)} & 0 & 0\\0 & 0 & - \frac{1}{r} & 0\\0 & 0 & 0 & - \frac{1}{r}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & r - r_{s} & 0\\0 & \frac{1}{r} & 0 & 0\\0 & 0 & 0 & - \frac{1}{\tan{\left(\theta \right)}}\end{matrix}\right] & \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & \left(r - r_{s}\right) \sin^{2}{\left(\theta \right)}\\0 & 0 & 0 & \frac{\sin{\left(2 \theta \right)}}{2}\\0 & \frac{1}{r} & \frac{1}{\tan{\left(\theta \right)}} & 0\end{matrix}\right]\end{matrix}\right]$

Obtaining Riemann Tensor from Christoffel Symbols and manipulating it's indices

In [11]:
rm = RiemannCurvatureTensor.from_christoffels(new_chr2)

rm[0,0,:,:]
Out[11]:
$\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right]$
In [12]:
rm.config
Out[12]:
'ulll'
In [13]:
rm2 = rm.change_config("uuuu")

rm2[0,0,:,:]
Out[13]:
$\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right]$
In [14]:
rm3 = rm2.change_config("lulu")

rm3[0,0,:,:]
Out[14]:
$\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right]$
In [15]:
rm4 = rm3.change_config("ulll")

rm4.simplify()

rm4[0,0,:,:]
Out[15]:
$\displaystyle \left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{matrix}\right]$

It is seen that rm and rm4 are same as they have the same configuration