Using Geodesics (Back-ends & Plotting)

Importing required modules

Note that, for the Julia backend to work, you should have ``einsteinpy_geodesics`` installed, along with its dependencies (e.g. ``julia``). Read more `here <>`__.

import numpy as np

from einsteinpy.geodesic import Geodesic, Timelike, Nulllike
from einsteinpy.plotting import GeodesicPlotter, StaticGeodesicPlotter, InteractiveGeodesicPlotter

Example 1: Exploring Schwarzschild Time-like Spiral Capture, using Python Backend and GeodesicPlotter

Defining initial conditions

# Initial Conditions
position = [2.15, np.pi / 2, 0.]
momentum = [0., 0., -1.5]
a = 0. # Schwarzschild Black Hole
end_lambda = 10.
step_size = 0.005
return_cartesian = True
time_like = True
julia = False # Using Python

Calculating Geodesic

geod = Geodesic(
    time_like=time_like, # Necessary to switch between Time-like and Null-like Geodesics, while using `Geodesic`

e:\coding\gsoc\github repos\myfork\einsteinpy\src\einsteinpy\geodesic\ RuntimeWarning:

                Using Python backend to solve the system. This backend is currently in beta and the
                solver may not be stable for certain sets of conditions, e.g. long simulations
                (`end_lambda > 50.`) or high initial radial distances (`position[0] > ~5.`).
                In these cases or if the output does not seem accurate, it is highly recommended to
                switch to the Julia backend, by setting `julia=True`, in the constructor call.

Geodesic Object:
            Type = (Time-like),
            Position = ([2.15, 1.5707963267948966, 0.0]),
            Momentum = ([0.0, 0.0, -1.5]),
            Spin Parameter = (0.0)
            Solver details = (
                Backend = (Python)
                Step-size = (0.005),
                End-Lambda = (10.0)
                Trajectory = (
                    (array([0.000e+00, 5.000e-03, 1.000e-02, ..., 9.990e+00, 9.995e+00,
       1.000e+01]), array([[ 2.15000000e+00,  0.00000000e+00,  1.31649531e-16,
         0.00000000e+00,  0.00000000e+00, -1.50000000e+00],
       [ 2.14999615e+00, -1.61252735e-02,  1.31652998e-16,
         2.26452642e-02,  1.49020159e-19, -1.50000000e+00],
       [ 2.14998455e+00, -3.22521873e-02,  1.31663397e-16,
         4.52748906e-02,  2.98024624e-19, -1.50000000e+00],
       [-1.08571331e+01, -9.57951275e+00,  8.86589316e-16,
         1.14573395e+00,  4.59929900e-17, -1.50000000e+00],
       [-1.09329973e+01, -9.50157334e+00,  8.86940089e-16,
         1.14568933e+00,  4.59962746e-17, -1.50000000e+00],
       [-1.10083027e+01, -9.42303446e+00,  8.87290849e-16,
         1.14564476e+00,  4.59995565e-17, -1.50000000e+00]]))
                Output Position Coordinate System = (Cartesian)

Plotting using GeodesicPlotter

Note that, GeodesicPlotter automatically switches between “Static” and “Interactive” plots. Since, we are in a Jupyter Notebook or Interactive Environment, it uses the “Interactive” backend.

gpl = GeodesicPlotter()
gpl.plot(geod, color="green")