Null Geodesics functionality has been implemented into EinsteinPy, with PR#527, having been merged ππ. I apologize for no blogs in the past 3 weeks. There was a COVID situation here, that required multiple tests and isolation and all that it entails. This led to me foregoing an entire week. And, when that had settled, I had to take the call on abandoning the plan of numerically integrating the Geodesics equations, due to the massive error accumulation, as discussed in my last blog. A confusing fact about that, was that Mathematica could still keep the error build-up to a minimum, while Python simply could not, even with adaptive and symplectic schemes. But the symplectic schemes did bring the error down, by around 2 orders of magnitude, which gave me the idea to take a Hamiltonian approach, which would increase the number of ODEs to solve, but drop the order by 1. And, as it turns out, the Kerr Hamiltonian is separable (Carter, 1968a [1]), which makes the implementation even simpler. In this blog, I will be discussing this approach, which has finally led to proper geodesic calculations. I have also included some plots (and a cool animation) for Kerr & Schwarzschild Null-like (and Time-like) geodesics.
Some Physics...
In Chapter 33 of Gravitation [2], the authors expound on Carter's seminal paper from 1968, titled, "Global Structure of the Kerr Family of Gravitational Fields", and present some nice results from it, one of which is a derivation of the Kerr (super-)Hamiltonian, which can be written as follows (in the M-Unit system (
):
where, and are the energy and orbital angular momentum of the test particle, respectively. Note that, this Hamiltonian is for a general test particle, i.e., it can be massive or massless. Then, the dynamical equations of motion can be derived easily, using Hamilton's principle, i.e.:
I calculated these in Mathematica, and the corresponding notebooks and the Python code, making use of these, can be accessed here.
...and some plots
Unfortunately, even with these first order ODEs, the error accumulation issue in Python persisted, as can be observed in the plots below. Note that, these results were obtained with a symplectic leapfrog solver, which should, in principal keep the error build-up to a minimum.
Although, for shorter integration durations, the results were good.
After discussions with my mentors, I looked into other languages, that could help and we chose Julia, due to its excellent DifferentialEquations.jl suite and "closeness" with Python. Another key bit is that, the HamiltonianProblem type, offered by DiffEqPhysics, immensely simplifies the process of solving the system, as it uses Forward Mode Automatic Differentiation to automatically calculate the partial derivatives from the Hamiltonian. The separable nature of the Hamiltonian helps here. Considering all this, I implemented a module in Julia and voilΓ , the results are accurate, even for some quirky geodesics.
Now came the problem of integrating the Julia code with EinsteinPy, for which I looked towards PyJulia. However, it has some issues with installation on *nix systems. So, I opted to write my own wrapper, using Python's subprocess
. and, with the help of my GSoC mentor, Shreyas, packaged the Julia module and the Python wrapper into what is now einsteinpy_geodesics
, an add-on module to EinsteinPy.
einsteinpy / einsteinpy-geodesics
Python wrapper for a Julia solver for geodesics in the Kerr family of spacetimes. Maintainer : @jes24
Name: | EinsteinPy Geodesics |
---|---|
Website: | https://docs.geodesics.einsteinpy.org/en/latest/ |
Version: | 0.2.dev0 |
EinsteinPy Geodesics is an addon package for EinsteinPy, that wraps over Julia's excellent DifferentialEquations.jl suite and provides a python interface to solve for geodesics in Kerr & Schwarzschild spacetime EinsteinPy is an open source pure Python package, dedicated to problems arising in General Relativity and Gravitational Physics As with EinsteinPy, EinsteinPy Geodesics is released under the MIT license.
Documentation
Complete documentation for this module can be accessed at https://docs.geodesics.einsteinpy.org/en/latest/ (Courtesy: Read the Docs).
Requirements
EinsteinPy Geodesics requires Python >= 3.7, Julia >= 1.5 and the following Julia packages:
-
- Julia
-
- DifferentialEquations.jl >= 6.15
- ODEInterfaceDiffEq.jl >= 3.7
Installation
First, ensure that, Julia is installed in your system and added to PATH. See https://julialang.org/downloads/platform/ for platform specific binaries and installation instructions. einsteinpy_geodesics also requires DifferentialEquations.jl and ODEInterfaceDiffEq.jl. You can add them, like so:
$ julia julia> using Pkg julia> Pkg.add("DifferentialEquations") julia> Pkg.add("ODEInterfaceDiffEq")
Finally, einsteinpy_geodesics canβ¦
On top of this, I also overhauled the geodesic plotting module and added support for 3D animations, parametric plots and choice of spatial coordinates in 2D plots, in both Static
and Interactive
modes (that use matplotlib
and plotly
respectively). I present some of the plots, produced through the final API, below. The plots shown here, have a mix of both Static
and Interactive
back-ends, as well as time-like and null-like geodesics.
Until next time...
The EinsteinPy geodesics API currently provides a choice of solvers, between a python back-end and a julia back-end, through the optional einsteinpy_geodesics
add-on. I will continue to work on improving the python back-end, but for now, einsteinpy_geodesics
adds proper & accurate geodesic calculations to EinsteinPy, in the Kerr family of spacetimes (that includes Schwarzschild). Also, a notable aspect of the HamiltonianProblem
approach is that, in principle, it should be easily extensible to Kerr-Newman geodesics, which is something, I'd like to explore, as soon as my GSoC commitment is over. I have another short blog coming up, that explains how to use the API (and has more cool plots), that will probably also be the last GSoC blog. Till then, I leave you with a nice animation, created entirely with EinsteinPy.
References:
[1]: Carter, Brandon; Global Structure of the Kerr Family of Gravitational Fields, 1968 , Physical Review, 174(5), pp. 1559-1571
[2]: Misner, Charles W. and Thorne, K.S. and Wheeler, J.A; Gravitation, 1973, W. H. Freeman, ISBN: 978-0-7167-0344-0, 978-0-691-17779-3
Top comments (0)