# Symbolically Understanding Christoffel Symbol and Riemann Curvature Tensor using EinsteinPy


```python
import sympy
from einsteinpy.symbolic import MetricTensor, ChristoffelSymbols, RiemannCurvatureTensor

sympy.init_printing()  # enables the best printing available in an environment
```

### Defining the metric tensor for 3d spherical coordinates


```python
syms = sympy.symbols('r theta phi')
# define the metric for 3d spherical coordinates
metric = [[0 for i in range(3)] for i in range(3)]
metric[0][0] = 1
metric[1][1] = syms[0]**2
metric[2][2] = (syms[0]**2)*(sympy.sin(syms[1])**2)
# creating metric object
m_obj = MetricTensor(metric, syms)
m_obj.tensor()
```

### Calculating the christoffel symbols


```python
ch = ChristoffelSymbols.from_metric(m_obj)
ch.tensor()
```


```python
ch.tensor()[1,1,0]
```

### Calculating the Riemann Curvature tensor


```python
# Calculating Riemann Tensor from Christoffel Symbols
rm1 = RiemannCurvatureTensor.from_christoffels(ch)
rm1.tensor()
```


```python
# Calculating Riemann Tensor from Metric Tensor
rm2 = RiemannCurvatureTensor.from_metric(m_obj)
rm2.tensor()
```

### Calculating the christoffel symbols for Schwarzschild Spacetime Metric
  - The expressions are unsimplified


```python
syms = sympy.symbols("t r theta phi")
G, M, c, a = sympy.symbols("G M c a")
# using metric values of schwarschild space-time
# a is schwarzschild radius
list2d = [[0 for i in range(4)] for i in range(4)]
list2d[0][0] = 1 - (a / syms[1])
list2d[1][1] = -1 / ((1 - (a / syms[1])) * (c ** 2))
list2d[2][2] = -1 * (syms[1] ** 2) / (c ** 2)
list2d[3][3] = -1 * (syms[1] ** 2) * (sympy.sin(syms[2]) ** 2) / (c ** 2)
sch = MetricTensor(list2d, syms)
sch.tensor()
```


```python
# single substitution
subs1 = sch.subs(a,0)
subs1.tensor()
```


```python
# multiple substitution
subs2 = sch.subs([(a,0), (c,1)])
subs2.tensor()
```


```python
sch_ch = ChristoffelSymbols.from_metric(sch)
sch_ch.tensor()
```

### Calculating the simplified expressions


```python
simplified = sch_ch.simplify()
simplified
```

9d9a3a48628adad033418ba3b5683714d11108c3
ipynb
Jupyter Notebook
docs/source/examples/Symbolically Understanding Christoffel Symbol and Riemann Curvature Tensor using EinsteinPy.ipynb
iamhardikat11/einsteinpy
7bf0ca0020b273e616b6e7c19aed7a5e13925444
MIT
2019-02-04T09:15:22.000Z
2022-03-19T13:50:17.000Z
docs/source/examples/Symbolically Understanding Christoffel Symbol and Riemann Curvature Tensor using EinsteinPy.ipynb
iamhardikat11/einsteinpy
7bf0ca0020b273e616b6e7c19aed7a5e13925444
MIT
2019-02-02T10:57:27.000Z
2022-02-26T16:37:05.000Z
docs/source/examples/Symbolically Understanding Christoffel Symbol and Riemann Curvature Tensor using EinsteinPy.ipynb
iamhardikat11/einsteinpy
7bf0ca0020b273e616b6e7c19aed7a5e13925444
MIT
2019-01-30T14:14:14.000Z
2022-02-28T21:18:18.000Z
Qwen/Qwen-72B
1. YES
2. YES