Tutorial: Numerical Geodesics

This tutorial demonstrates in brief how to use the numeric tools in pystein. For other tutorials see all tutorials.

Construct a metric from a twoform

M = Manifold('M', dim=2)
P = Patch('origin', M)

rho, phi, a = sympy.symbols('rho phi a', nonnegative=True)
cs = coords.CoordSystem('schw', P, [rho, phi])
drho, dphi = cs.base_oneforms()
ds2 = a ** 2 * ((1 / (1 - rho ** 2)) * tpow(drho, 2) + rho ** 2 * tpow(dphi, 2))
g = metric.Metric(twoform=ds2)
g

Compute the symbolic geodesic equations

full_simplify(geodesic.geodesic_equation(0, sympy.symbols('lambda'), g))

Numerically integrate the geodesic equations

init = (numpy.sin(numpy.pi / 4), 0.0, numpy.cos(numpy.pi / 4), numpy.pi / 4)
lambdas = numpy.arange(0, 2.1, 0.001)
df = geodesic.numerical_geodesic(g, init, lambdas)
df.head()
rho phi
0 0.707107 0.000000
1 0.707814 0.000785
2 0.708520 0.001568
3 0.709226 0.002349
4 0.709931 0.003129