Animations in EinsteinPy¶
Importing required modules¶
[1]:
import numpy as np
from einsteinpy.geodesic import Timelike
from einsteinpy.plotting import StaticGeodesicPlotter
Defining various parameters¶
Initial position & momentum of the test partcle
Spin of the Kerr Black Hole in
metric_params
Other solver parameters
Note that, we are working in M-Units (\(G = c = M = 1\)).
[2]:
# Constant Radius Orbit
position = [4, np.pi / 3, 0.]
momentum = [0., 0.767851, 2.]
a = 0.99
steps = 400.
delta = 0.5
Calculating geodesic¶
[3]:
geod = Timelike(
metric="Kerr",
metric_params=(a,),
position=position,
momentum=momentum,
steps=steps,
delta=delta,
return_cartesian=True
)
Animating¶
[4]:
%matplotlib widget
# Use %matplotlib ipympl instead if you are working in Visual Studio Code.
# You may need to `pip install ipympl` first.
sgpl = StaticGeodesicPlotter()
sgpl.animate(geod, interval=1)
sgpl.show()
Saving animation as .gif¶
[5]:
# You may need to install imagemagick separately to save the animation as a gif
# sgpl.ani.save('animation.gif', writer='imagemagick', fps=30)