geodpy 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geodpy-1.0.0/LICENSE +21 -0
- geodpy-1.0.0/PKG-INFO +116 -0
- geodpy-1.0.0/README.md +67 -0
- geodpy-1.0.0/pyproject.toml +38 -0
- geodpy-1.0.0/setup.cfg +4 -0
- geodpy-1.0.0/src/geodpy/__init__.py +3 -0
- geodpy-1.0.0/src/geodpy/body.py +113 -0
- geodpy-1.0.0/src/geodpy/coordinates/__init__.py +5 -0
- geodpy-1.0.0/src/geodpy/coordinates/cartesian.py +30 -0
- geodpy-1.0.0/src/geodpy/coordinates/coordinates.py +35 -0
- geodpy-1.0.0/src/geodpy/coordinates/lemaitre.py +49 -0
- geodpy-1.0.0/src/geodpy/coordinates/oblong_ellipsoid.py +43 -0
- geodpy-1.0.0/src/geodpy/coordinates/spherical.py +20 -0
- geodpy-1.0.0/src/geodpy/geodesics.py +45 -0
- geodpy-1.0.0/src/geodpy/plotters/__init__.py +5 -0
- geodpy-1.0.0/src/geodpy/plotters/body_plotter.py +105 -0
- geodpy-1.0.0/src/geodpy/plotters/plotters2D/__init__.py +3 -0
- geodpy-1.0.0/src/geodpy/plotters/plotters2D/body_plotter_2D.py +40 -0
- geodpy-1.0.0/src/geodpy/plotters/plotters2D/cartesian_plot_2D.py +50 -0
- geodpy-1.0.0/src/geodpy/plotters/plotters2D/polar_plot.py +44 -0
- geodpy-1.0.0/src/geodpy/plotters/plotters3D/__init__.py +2 -0
- geodpy-1.0.0/src/geodpy/plotters/plotters3D/body_plotter_3D.py +26 -0
- geodpy-1.0.0/src/geodpy/plotters/plotters3D/cartesian_plot_3D.py +56 -0
- geodpy-1.0.0/src/geodpy/to_lambda.py +18 -0
- geodpy-1.0.0/src/geodpy/utilities/__init__.py +1 -0
- geodpy-1.0.0/src/geodpy/utilities/base_run.py +50 -0
- geodpy-1.0.0/src/geodpy/validationTests/__init__.py +0 -0
- geodpy-1.0.0/src/geodpy/validationTests/schwarzschild.py +38 -0
- geodpy-1.0.0/src/geodpy.egg-info/PKG-INFO +116 -0
- geodpy-1.0.0/src/geodpy.egg-info/SOURCES.txt +31 -0
- geodpy-1.0.0/src/geodpy.egg-info/dependency_links.txt +1 -0
- geodpy-1.0.0/src/geodpy.egg-info/requires.txt +5 -0
- geodpy-1.0.0/src/geodpy.egg-info/top_level.txt +1 -0
geodpy-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Benjamin Gauthier
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
geodpy-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: geodpy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Computes space-time geodesics given an arbitrary metric and initial conditions.
|
|
5
|
+
Author-email: Benjamin Gauthier <benjamin.gauthier@hotmail.ca>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Benjamin Gauthier
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/Sneaker679/geodpy/tree/main
|
|
29
|
+
Keywords: general relativity,geodesics,geodesic,gr,astrophysics,astronomy,physics,riemann,riemann geometry,geometry,metric,space-time,spacetime
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Programming Language :: Python
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
35
|
+
Classifier: Environment :: Console
|
|
36
|
+
Classifier: Intended Audience :: Science/Research
|
|
37
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
38
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
39
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
41
|
+
Requires-Python: >=3.12
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Requires-Dist: numpy>=2.0.1
|
|
45
|
+
Requires-Dist: scipy>=1.14.0
|
|
46
|
+
Requires-Dist: sympy>=1.13.1
|
|
47
|
+
Requires-Dist: matplotlib>=3.9.1.post1
|
|
48
|
+
Requires-Dist: PyQt6>=6.7.1
|
|
49
|
+
|
|
50
|
+
# geodpy
|
|
51
|
+
This code aims to simulate geodesics given an arbitrary space-time metric.
|
|
52
|
+
|
|
53
|
+
## Capabilities
|
|
54
|
+
- Calculate symbolic geodesics
|
|
55
|
+
- Solve the trajectory of a body given an arbitrary metric and symbolic geodesics.
|
|
56
|
+
- Calculate the norm of the velocity of a body.
|
|
57
|
+
- Plot the trajectories on matplotlib in both 2D and 3D.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
- matplotlib
|
|
61
|
+
- sympy
|
|
62
|
+
- scipy
|
|
63
|
+
- numpy
|
|
64
|
+
|
|
65
|
+
You can install these dependencies using:
|
|
66
|
+
```bash
|
|
67
|
+
pip install matplotlib numpy scipy sympy
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Make sure these modules are correctly installed. Matplotlib in particular might require the installation of PyQt5 or PyQt6 depending on your system.
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
Clone the repository and go to the main folder `geodpy`. You can use these commands:
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/Sneaker679/geodpy
|
|
76
|
+
cd geodpy
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
In order to be able to import the classes and functions of this library, you will need to add the `./src` folder to your PYTHON PATH. Move to this folder using
|
|
80
|
+
```bash
|
|
81
|
+
cd src
|
|
82
|
+
```
|
|
83
|
+
and run the following command to add it to your path.
|
|
84
|
+
```bash
|
|
85
|
+
export PYTHONPATH="$(pwd):$PYTHONPATH"
|
|
86
|
+
```
|
|
87
|
+
To add the folder permanently to your PYTHON PATH, run this command instead.
|
|
88
|
+
```bash
|
|
89
|
+
echo 'export PYTHONPATH="$HOME'${PWD/#$HOME/}':$PYTHONPATH"' >> $HOME/.bashrc
|
|
90
|
+
```
|
|
91
|
+
or, for zsh terminals, run this.
|
|
92
|
+
```bash
|
|
93
|
+
echo 'export PYTHONPATH="$HOME'${PWD/#$HOME/}':$PYTHONPATH"' >> $HOME/.zshrc
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Basic Usage -> Using the examples
|
|
97
|
+
|
|
98
|
+
### Example with the Schwarzschild metric
|
|
99
|
+
In the `./examples/1_schwarzschild` folder, run any of the python files except for `schwarzschild.py` (since it acts as a module for the other files). For instance, you could run:
|
|
100
|
+
```bash
|
|
101
|
+
python3 2_crashing_traj.py
|
|
102
|
+
```
|
|
103
|
+
which will run a configuration of the Schwarzschild metric where a body is falling into a Schwarzschild black hole. A plot should be displayed on the screen using `matplotlib`.
|
|
104
|
+
|
|
105
|
+
### Structure of the examples
|
|
106
|
+
With the last example in mind, here is a more detailed overlook of how the examples are structured. This section will make it easier to understand how you can customize the orbits to your liking and experiment with the code.
|
|
107
|
+
|
|
108
|
+
In the `examples` folder are many examples that simulate geodesics with varied metrics, including the Schwarzschild, Kerr and Schwarzschild de Sitter metric. All these folders work in the same way. Taking the schwarzschild folder as an example, inside it are many files, the main one being `schwarzschild.py`. This script acts as a python module for the other files. Inside this code, there is a `schwarzschild()` function, which you can call with varied parameters to generate different geodesics. The other files in the `schwarzschild` folder are simple sripts who call the `schwarzschild()` function with different initial values. As it was shown in the previous section, the `2_crashing_traj.py` script, for example, yields a geodesic simulated near the event horizon of a non rotating Schwarzschild blackhole. You can run the other examples in the other folders the same way.
|
|
109
|
+
|
|
110
|
+
The README inside each example folders specifies the meaning of the constants and quantities used.
|
|
111
|
+
|
|
112
|
+
## Advanced Usage
|
|
113
|
+
For more advance usages, refer to `./docs/1_HowTo_trajectories.md`, `./docs/2_HowTo_coordinates.md` and `./docs/3_HowTo_plotters.md`.
|
|
114
|
+
|
|
115
|
+
## Interface
|
|
116
|
+
If you wish to see a more detailed overview of all the classes and functions at your disposition, be sure to checkout the `./docs/class_documentation/`. There are many Markdown files there explaining how all the classes and functions work. The REAMDEs in this folder also specify how you can import them.
|
geodpy-1.0.0/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# geodpy
|
|
2
|
+
This code aims to simulate geodesics given an arbitrary space-time metric.
|
|
3
|
+
|
|
4
|
+
## Capabilities
|
|
5
|
+
- Calculate symbolic geodesics
|
|
6
|
+
- Solve the trajectory of a body given an arbitrary metric and symbolic geodesics.
|
|
7
|
+
- Calculate the norm of the velocity of a body.
|
|
8
|
+
- Plot the trajectories on matplotlib in both 2D and 3D.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
- matplotlib
|
|
12
|
+
- sympy
|
|
13
|
+
- scipy
|
|
14
|
+
- numpy
|
|
15
|
+
|
|
16
|
+
You can install these dependencies using:
|
|
17
|
+
```bash
|
|
18
|
+
pip install matplotlib numpy scipy sympy
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Make sure these modules are correctly installed. Matplotlib in particular might require the installation of PyQt5 or PyQt6 depending on your system.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
Clone the repository and go to the main folder `geodpy`. You can use these commands:
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/Sneaker679/geodpy
|
|
27
|
+
cd geodpy
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
In order to be able to import the classes and functions of this library, you will need to add the `./src` folder to your PYTHON PATH. Move to this folder using
|
|
31
|
+
```bash
|
|
32
|
+
cd src
|
|
33
|
+
```
|
|
34
|
+
and run the following command to add it to your path.
|
|
35
|
+
```bash
|
|
36
|
+
export PYTHONPATH="$(pwd):$PYTHONPATH"
|
|
37
|
+
```
|
|
38
|
+
To add the folder permanently to your PYTHON PATH, run this command instead.
|
|
39
|
+
```bash
|
|
40
|
+
echo 'export PYTHONPATH="$HOME'${PWD/#$HOME/}':$PYTHONPATH"' >> $HOME/.bashrc
|
|
41
|
+
```
|
|
42
|
+
or, for zsh terminals, run this.
|
|
43
|
+
```bash
|
|
44
|
+
echo 'export PYTHONPATH="$HOME'${PWD/#$HOME/}':$PYTHONPATH"' >> $HOME/.zshrc
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Basic Usage -> Using the examples
|
|
48
|
+
|
|
49
|
+
### Example with the Schwarzschild metric
|
|
50
|
+
In the `./examples/1_schwarzschild` folder, run any of the python files except for `schwarzschild.py` (since it acts as a module for the other files). For instance, you could run:
|
|
51
|
+
```bash
|
|
52
|
+
python3 2_crashing_traj.py
|
|
53
|
+
```
|
|
54
|
+
which will run a configuration of the Schwarzschild metric where a body is falling into a Schwarzschild black hole. A plot should be displayed on the screen using `matplotlib`.
|
|
55
|
+
|
|
56
|
+
### Structure of the examples
|
|
57
|
+
With the last example in mind, here is a more detailed overlook of how the examples are structured. This section will make it easier to understand how you can customize the orbits to your liking and experiment with the code.
|
|
58
|
+
|
|
59
|
+
In the `examples` folder are many examples that simulate geodesics with varied metrics, including the Schwarzschild, Kerr and Schwarzschild de Sitter metric. All these folders work in the same way. Taking the schwarzschild folder as an example, inside it are many files, the main one being `schwarzschild.py`. This script acts as a python module for the other files. Inside this code, there is a `schwarzschild()` function, which you can call with varied parameters to generate different geodesics. The other files in the `schwarzschild` folder are simple sripts who call the `schwarzschild()` function with different initial values. As it was shown in the previous section, the `2_crashing_traj.py` script, for example, yields a geodesic simulated near the event horizon of a non rotating Schwarzschild blackhole. You can run the other examples in the other folders the same way.
|
|
60
|
+
|
|
61
|
+
The README inside each example folders specifies the meaning of the constants and quantities used.
|
|
62
|
+
|
|
63
|
+
## Advanced Usage
|
|
64
|
+
For more advance usages, refer to `./docs/1_HowTo_trajectories.md`, `./docs/2_HowTo_coordinates.md` and `./docs/3_HowTo_plotters.md`.
|
|
65
|
+
|
|
66
|
+
## Interface
|
|
67
|
+
If you wish to see a more detailed overview of all the classes and functions at your disposition, be sure to checkout the `./docs/class_documentation/`. There are many Markdown files there explaining how all the classes and functions work. The REAMDEs in this folder also specify how you can import them.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# pyproject.toml
|
|
2
|
+
|
|
3
|
+
[build-system]
|
|
4
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
5
|
+
build-backend = "setuptools.build_meta"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "geodpy"
|
|
9
|
+
version = "1.0.0"
|
|
10
|
+
description = "Computes space-time geodesics given an arbitrary metric and initial conditions."
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
authors = [{ name = "Benjamin Gauthier", email = "benjamin.gauthier@hotmail.ca" }]
|
|
13
|
+
license = { file = "LICENSE" }
|
|
14
|
+
classifiers = [
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Development Status :: 5 - Production/Stable",
|
|
20
|
+
"Environment :: Console",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Operating System :: POSIX :: Linux",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Astronomy"
|
|
26
|
+
]
|
|
27
|
+
keywords = ["general relativity", "geodesics", "geodesic", "gr", "astrophysics", "astronomy", "physics", "riemann", "riemann geometry", "geometry", "metric", "space-time", "spacetime"]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"numpy >= 2.0.1",
|
|
30
|
+
"scipy >= 1.14.0",
|
|
31
|
+
"sympy >= 1.13.1",
|
|
32
|
+
"matplotlib >= 3.9.1.post1",
|
|
33
|
+
"PyQt6 >= 6.7.1"
|
|
34
|
+
]
|
|
35
|
+
requires-python = ">=3.12"
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/Sneaker679/geodpy/tree/main"
|
geodpy-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from .geodesics import Geodesics
|
|
4
|
+
from .coordinates import Cartesian, Spherical
|
|
5
|
+
|
|
6
|
+
from sympy import *
|
|
7
|
+
from scipy.integrate import solve_ivp
|
|
8
|
+
from scipy.integrate._ivp.ivp import OdeResult
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
### Body class ###
|
|
12
|
+
# Class responsible for solving the geodesic differential equation system and storing the results. The class
|
|
13
|
+
# can also calculate the norm of the velocity vector and convert itself a cartesian coordinate system.
|
|
14
|
+
class Body:
|
|
15
|
+
|
|
16
|
+
def __init__(self, geodesics: Geodesics = None, position_vec: list = [0,0,0,0], velocity_vec: list = [0,0,0,0]) -> None:
|
|
17
|
+
self._geodesics = geodesics
|
|
18
|
+
if geodesics is not None: self._coordinates = geodesics._coordinates
|
|
19
|
+
else: self._coordinates = None
|
|
20
|
+
|
|
21
|
+
self.s = np.array([0])
|
|
22
|
+
self.pos = np.array([[position_vec[0]], [position_vec[1]], [position_vec[2]], [position_vec[3]]])
|
|
23
|
+
self.vel = np.array([[velocity_vec[0]], [velocity_vec[1]], [velocity_vec[2]], [velocity_vec[3]]])
|
|
24
|
+
self.vel_norm = None
|
|
25
|
+
|
|
26
|
+
self.solver_result = None
|
|
27
|
+
|
|
28
|
+
# Wrapper for scipy.integrate.solve_ivp
|
|
29
|
+
def solve_trajectory(
|
|
30
|
+
self,
|
|
31
|
+
time_interval: tuple[float, float],
|
|
32
|
+
method: str = "Radau",
|
|
33
|
+
max_step: float = 1,
|
|
34
|
+
atol: float = 1e-8,
|
|
35
|
+
rtol: float = 1e-8,
|
|
36
|
+
events: Callable = None,
|
|
37
|
+
) -> np.array:
|
|
38
|
+
|
|
39
|
+
self.solver_result = solve_ivp(
|
|
40
|
+
fun = Body.__diff_equations_system,
|
|
41
|
+
t_span = time_interval,
|
|
42
|
+
max_step = max_step,
|
|
43
|
+
y0 = np.append(self.pos[:,0], self.vel[:,0]),
|
|
44
|
+
method = method,
|
|
45
|
+
atol = atol,
|
|
46
|
+
rtol = rtol,
|
|
47
|
+
args=(self._geodesics._dₛuᵏ_lambda ,),
|
|
48
|
+
dense_output=False,
|
|
49
|
+
events=events
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
self.s = self.solver_result.t
|
|
53
|
+
self.pos = self.solver_result.y[0:4]
|
|
54
|
+
self.vel = self.solver_result.y[4:8]
|
|
55
|
+
|
|
56
|
+
return self.s, self.pos, self.vel
|
|
57
|
+
|
|
58
|
+
# Function solved with scipy.integrate.solve_ivp
|
|
59
|
+
@staticmethod
|
|
60
|
+
def __diff_equations_system(dτ, state, equations) -> tuple:
|
|
61
|
+
x0, x1, x2, x3, v0, v1, v2, v3 = state
|
|
62
|
+
|
|
63
|
+
a0 = equations[0](x0, x1, x2, x3, v0, v1, v2, v3)
|
|
64
|
+
a1 = equations[1](x0, x1, x2, x3, v0, v1, v2, v3)
|
|
65
|
+
a2 = equations[2](x0, x1, x2, x3, v0, v1, v2, v3)
|
|
66
|
+
a3 = equations[3](x0, x1, x2, x3, v0, v1, v2, v3)
|
|
67
|
+
|
|
68
|
+
return v0, v1, v2, v3, a0, a1, a2, a3
|
|
69
|
+
|
|
70
|
+
# Calculates the norm of the velocity vector for each points as a function of coordinate time.
|
|
71
|
+
# This function assumes that self.pos[0] is time.
|
|
72
|
+
def calculate_velocities(self, **kwargs) -> np.array:
|
|
73
|
+
velocity_equation = self._coordinates.velocity_equation(**kwargs)
|
|
74
|
+
|
|
75
|
+
# Defining the arguments for the lambda velocity equation
|
|
76
|
+
symbolic_args = list(self._coordinates.coords)[1:4]
|
|
77
|
+
symbolic_args.extend([coord.diff(self._coordinates.interval) for coord in symbolic_args])
|
|
78
|
+
|
|
79
|
+
# Making a lambdified velocity equation
|
|
80
|
+
velocity2_equation = velocity_equation ** 2 # Necessary because lambda function doesn't like taking the sqrt of an expression.
|
|
81
|
+
velocity2_equation_lambda = lambdify(symbolic_args, velocity2_equation, ["numpy", "scipy"])
|
|
82
|
+
|
|
83
|
+
t = self.pos[0]
|
|
84
|
+
|
|
85
|
+
args = []
|
|
86
|
+
args.append(self.pos[1])
|
|
87
|
+
args.append(self.pos[2])
|
|
88
|
+
args.append(self.pos[3])
|
|
89
|
+
|
|
90
|
+
# Taking derivative of position vector
|
|
91
|
+
for coord in range(3):
|
|
92
|
+
args.append(np.gradient(args[coord],t))
|
|
93
|
+
|
|
94
|
+
self.vel_norm = velocity2_equation_lambda(*args)**(1/2) # Taking square root to undo the square of earlier.
|
|
95
|
+
return self.vel_norm
|
|
96
|
+
|
|
97
|
+
# Creates a new Body object from the current body, but represented in cartesian coordinates.
|
|
98
|
+
def get_cartesian_body(self, **kwargs):
|
|
99
|
+
new_body = Body(geodesics = None)
|
|
100
|
+
new_body._coordinates = Cartesian
|
|
101
|
+
|
|
102
|
+
new_body.s = self.s
|
|
103
|
+
new_body.pos = self._coordinates.to_cartesian(self.pos, **kwargs)
|
|
104
|
+
return new_body
|
|
105
|
+
|
|
106
|
+
# Creates a new Body object from the current body, but represented in spherical body coordinates.
|
|
107
|
+
def get_spherical_body(self, **kwargs):
|
|
108
|
+
new_body = Body(geodesics = None)
|
|
109
|
+
new_body._coordinates = Spherical
|
|
110
|
+
|
|
111
|
+
new_body.s = self.s
|
|
112
|
+
new_body.pos = self._coordinates.to_spherical(self.pos, **kwargs)
|
|
113
|
+
return new_body
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from .coordinates import Coordinates
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from sympy import *
|
|
5
|
+
|
|
6
|
+
# Possible symbols
|
|
7
|
+
#t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
8
|
+
### Cartesian-coordinates class ###
|
|
9
|
+
# Cartesian representation of space-time
|
|
10
|
+
class Cartesian(Coordinates):
|
|
11
|
+
interval: Symbol = symbols('s')
|
|
12
|
+
coords: tuple[Function] = (Function('t')(interval), Function('x')(interval), Function('y')(interval), Function('z')(interval))
|
|
13
|
+
coords_string: tuple[str] = ('t', 'x', 'y', 'z')
|
|
14
|
+
t, x, y, z = coords
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def velocity_equation(cls, **kwargs) -> Function:
|
|
18
|
+
return (cls.x.diff(cls.interval)**2 + cls.y.diff(interval)**2 + cls.z.diff(cls.interval)**2)**(1/2)
|
|
19
|
+
|
|
20
|
+
def to_cartesian(pos: np.array, **kwargs) -> np.array:
|
|
21
|
+
return pos
|
|
22
|
+
|
|
23
|
+
def to_spherical(pos: np.array, **kwargs) -> np.array:
|
|
24
|
+
x, y, z = pos[1:4]
|
|
25
|
+
|
|
26
|
+
r = np.sqrt(x*x + y*y + z*z)
|
|
27
|
+
θ = np.arctan(np.sqrt(x*x + y*y)/z)
|
|
28
|
+
φ = np.arctan(y/x)
|
|
29
|
+
|
|
30
|
+
return np.array([pos[0], r, θ, φ])
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from abc import ABCMeta, abstractmethod
|
|
3
|
+
|
|
4
|
+
# Possible symbols
|
|
5
|
+
#t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
6
|
+
|
|
7
|
+
### Coordinates abstract class ###
|
|
8
|
+
# This abstract class is the base template for all coordinate systems implemented as classes.
|
|
9
|
+
class Coordinates(metaclass=ABCMeta):
|
|
10
|
+
@property
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def interval():
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
@abstractmethod
|
|
17
|
+
def coords():
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
@abstractmethod
|
|
22
|
+
def coords_string():
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def velocity_equation(cls, **kwargs):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def to_cartesian(pos: np.array, **kwargs):
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def to_spherical(pos: np.array, **kwargs):
|
|
35
|
+
pass
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from .coordinates import Coordinates
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from sympy import *
|
|
5
|
+
|
|
6
|
+
### Lemaitre-coordinates class ###
|
|
7
|
+
# Lemaitre coordinates of space-time cooresponding to a coordinate system where the observer is free-falling towards the origin
|
|
8
|
+
# instead of being static, like in a standard sperical coordinate system.
|
|
9
|
+
class Lemaitre(Coordinates):
|
|
10
|
+
interval: Symbol = symbols('s')
|
|
11
|
+
coords: tuple[Function] = (Function('T')(interval), Function('ρ')(interval), Function('θ')(interval), Function('φ')(interval))
|
|
12
|
+
coords_string: tuple[str] = ('T', 'ρ', 'θ', 'φ')
|
|
13
|
+
T, ρ, θ, φ = coords
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def velocity_equation(cls, **kwargs) -> Function:
|
|
17
|
+
rs = kwargs.get('rs',1)
|
|
18
|
+
raise NotImplementedError
|
|
19
|
+
|
|
20
|
+
def to_cartesian(pos: np.array, **kwargs) -> np.array:
|
|
21
|
+
rs = kwargs.get('rs',1)
|
|
22
|
+
|
|
23
|
+
T, ρ, θ, φ = pos
|
|
24
|
+
|
|
25
|
+
sinθ = np.sin(θ)
|
|
26
|
+
r = (3/2 * (ρ - T))**(2/3) * rs**(1/3)
|
|
27
|
+
|
|
28
|
+
cst = 3 * (4*rs*rs/9 * (ρ[0] - T[0]))**(1/3) + rs * (np.log(np.abs( (3/(2*rs) * (ρ[0] - T[0]))**(1/3) - 1 )) - np.log(np.abs( (3/(2*rs) * (ρ[0] - T[0]))**(1/3) + 1 )) )
|
|
29
|
+
t = T - 3 * (4*rs*rs/9 * (ρ - T))**(1/3) - rs * (np.log(np.abs( (3/(2*rs) * (ρ - T))**(1/3) - 1 )) - np.log(np.abs( (3/(2*rs) * (ρ - T))**(1/3) + 1 )) ) + cst
|
|
30
|
+
x = r * sinθ * np.cos(φ)
|
|
31
|
+
y = r * sinθ * np.sin(φ)
|
|
32
|
+
z = r * np.cos(θ)
|
|
33
|
+
|
|
34
|
+
return np.array([t, x, y, z])
|
|
35
|
+
|
|
36
|
+
def to_spherical(pos: np.array, **kwargs) -> np.array:
|
|
37
|
+
rs = kwargs.get('rs',1)
|
|
38
|
+
|
|
39
|
+
T, ρ, θ = pos[0:3]
|
|
40
|
+
|
|
41
|
+
sinθ = np.sin(θ)
|
|
42
|
+
|
|
43
|
+
cst = 3 * (4*rs*rs/9 * (ρ[0] - T[0]))**(1/3) + rs * (np.log(np.abs( (3/(2*rs) * (ρ[0] - T[0]))**(1/3) - 1 )) - np.log(np.abs( (3/(2*rs) * (ρ[0] - T[0]))**(1/3) + 1 )) )
|
|
44
|
+
t = T - 3 * (4*rs*rs/9 * (ρ - T))**(1/3) - rs * (np.log(np.abs( (3/(2*rs) * (ρ - T))**(1/3) - 1 )) - np.log(np.abs( (3/(2*rs) * (ρ - T))**(1/3) + 1 )) ) + cst
|
|
45
|
+
r = (3/2 * (ρ - T))**(2/3) * rs**(1/3)
|
|
46
|
+
|
|
47
|
+
return np.array([t, r, pos[2], pos[3]])
|
|
48
|
+
|
|
49
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from .coordinates import Coordinates
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from sympy import *
|
|
5
|
+
|
|
6
|
+
### OblongEllipsoid-coordinates class ###
|
|
7
|
+
# OblongEllipsoid representation of space-time, used in the Kerr metric example.
|
|
8
|
+
class OblongEllipsoid(Coordinates):
|
|
9
|
+
interval: Symbol = symbols('s')
|
|
10
|
+
coords: tuple[Function] = (Function('t')(interval), Function('r')(interval), Function('θ')(interval), Function('φ')(interval))
|
|
11
|
+
coords_string: tuple[str] = ('t', 'r', 'θ', 'φ')
|
|
12
|
+
t, r, θ, φ = coords
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def velocity_equation(cls, **kwargs) -> Function:
|
|
16
|
+
a = kwargs.get('a',0)
|
|
17
|
+
return ( cls.r.diff(cls.interval)**2 * (sin(cls.θ)**2 * cls.r**2/(cls.r**2 + a**2) + cos(cls.θ)**2) + cls.r**2 * cls.θ.diff(cls.interval)**2 + cls.r**2 * cls.φ.diff(cls.interval)**2 * sin(cls.θ)**2 + a**2 * (cls.θ.diff(cls.interval)**2 * cos(cls.θ)**2 + cls.φ.diff(cls.interval)**2 * sin(cls.θ)**2) )**(1/2)
|
|
18
|
+
|
|
19
|
+
def to_cartesian(pos: np.array, **kwargs) -> np.array:
|
|
20
|
+
a = kwargs.get('a',0)
|
|
21
|
+
|
|
22
|
+
r, θ, φ = pos[1:4]
|
|
23
|
+
|
|
24
|
+
sinθ = np.sin(θ)
|
|
25
|
+
|
|
26
|
+
x = np.sqrt(r*r + a*a) * sinθ * np.cos(φ)
|
|
27
|
+
y = np.sqrt(r*r + a*a) * sinθ * np.sin(φ)
|
|
28
|
+
z = r * np.cos(θ)
|
|
29
|
+
|
|
30
|
+
return np.array([pos[0], x, y, z])
|
|
31
|
+
|
|
32
|
+
def to_spherical(pos: np.array, **kwargs) -> np.array:
|
|
33
|
+
a = kwargs.get('a',0)
|
|
34
|
+
|
|
35
|
+
r, θ = pos[1:3]
|
|
36
|
+
|
|
37
|
+
sinθ = np.sin(θ)
|
|
38
|
+
|
|
39
|
+
r_sp = np.sqrt(r*r + a*a*sinθ*sinθ)
|
|
40
|
+
θ_sp = np.arctan(np.sqrt(1+a*a/(r*r))*np.tan(θ))
|
|
41
|
+
|
|
42
|
+
return np.array([pos[0], r_sp, θ_sp, pos[3]])
|
|
43
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from .coordinates import Coordinates
|
|
2
|
+
from .oblong_ellipsoid import OblongEllipsoid
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from sympy import *
|
|
6
|
+
|
|
7
|
+
### Spherical-OblongEllipsoid-coordinates class ###
|
|
8
|
+
# Spherical representation of space-time, used in the Schwarzschild metric example. This is a special case
|
|
9
|
+
# of the Oblong Ellipsoid reprensentation when a = 0, "a" being the rotation speed of a blackhole in the Kerr metric.
|
|
10
|
+
class Spherical(OblongEllipsoid):
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def velocity_equation(cls, **kwargs) -> Function:
|
|
14
|
+
return simplify(super(Spherical, Spherical).velocity_equation(a=0))
|
|
15
|
+
|
|
16
|
+
def to_cartesian(pos: np.array, **kwargs) -> np.array:
|
|
17
|
+
return super(Spherical, Spherical).to_cartesian(pos, a=0)
|
|
18
|
+
|
|
19
|
+
def to_spherical(pos: np.array, **kwargs) -> np.array:
|
|
20
|
+
return pos
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from .to_lambda import vector_to_lambda
|
|
2
|
+
from .coordinates import Coordinates
|
|
3
|
+
|
|
4
|
+
from sympy import *
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
### Geodesic class ###
|
|
8
|
+
# Class that acts as a variables container for all geodesics.
|
|
9
|
+
class Geodesics:
|
|
10
|
+
|
|
11
|
+
def __init__(self, coordinates: Coordinates, gₘₖ: Matrix):
|
|
12
|
+
assert gₘₖ.shape[0] == len(coordinates.coords)
|
|
13
|
+
|
|
14
|
+
# Automatic calculation of all geodesics variables
|
|
15
|
+
self._coordinates = coordinates
|
|
16
|
+
self._gₘₖ= gₘₖ
|
|
17
|
+
self._dₛuᵏ= self.__contravariant_acc()
|
|
18
|
+
self._dₛuᵏ_lambda = vector_to_lambda(coordinates, self._dₛuᵏ)
|
|
19
|
+
|
|
20
|
+
# Geodesic covariant equation : ∂ₛuⱼ = 1/2 * ∂ⱼ(gₘₖ) * uᵐ uᵏ where uᵏ = ∂ₛxᵏ
|
|
21
|
+
def __covariant_acc(self) -> Array:
|
|
22
|
+
dₛuⱼ: list[Function] = []
|
|
23
|
+
uᵐ : Array = Array(self._coordinates.coords).diff(self._coordinates.interval)
|
|
24
|
+
uᵐuᵏ: Array = tensorproduct(uᵐ,uᵐ)
|
|
25
|
+
|
|
26
|
+
for j, coord in enumerate(self._coordinates.coords):
|
|
27
|
+
dₛuⱼ.append(1/2 * tensorcontraction(tensorproduct(self._gₘₖ.diff(coord), uᵐuᵏ), (0,1,2,3)))
|
|
28
|
+
|
|
29
|
+
return Array(dₛuⱼ)
|
|
30
|
+
|
|
31
|
+
# Geodesic contravariant equation : ∂ₛuᵏ = gᵐᵏ(∂ₛuₘ - ∂ₛgₘⱼuʲ) where uᵏ = ∂ₛxᵏ
|
|
32
|
+
def __contravariant_acc(self) -> Array:
|
|
33
|
+
dₛuₘ_: Array = self.__covariant_acc()
|
|
34
|
+
gᵐᵏ_ : Matrix = self._gₘₖ.inv()
|
|
35
|
+
uʲ : Array = Array(self._coordinates.coords).diff(self._coordinates.interval)
|
|
36
|
+
|
|
37
|
+
dₛgₘⱼuʲ= tensorcontraction(tensorproduct( self._gₘₖ.diff(self._coordinates.interval), uʲ ), (1,2))
|
|
38
|
+
dₛuᵏ = tensorcontraction(tensorproduct( gᵐᵏ_ , dₛuₘ_ - dₛgₘⱼuʲ), (1,2))
|
|
39
|
+
|
|
40
|
+
return dₛuᵏ
|
|
41
|
+
|
|
42
|
+
def simplify(self):
|
|
43
|
+
self._dₛuᵏ= simplify(self._dₛuᵏ)
|
|
44
|
+
self._dₛuᵏ_lambda = vector_to_lambda(self._coordinates, self._dₛuᵏ)
|
|
45
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from .. import Body
|
|
2
|
+
|
|
3
|
+
from sympy import *
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
import matplotlib.animation as animation
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
from abc import ABCMeta, abstractmethod
|
|
9
|
+
|
|
10
|
+
# Possible symbols
|
|
11
|
+
#τ,t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
12
|
+
|
|
13
|
+
### BodyPlotter abstract class ###
|
|
14
|
+
# Class that facilitates the plotting of Body objects.
|
|
15
|
+
class BodyPlotter(metaclass=ABCMeta):
|
|
16
|
+
|
|
17
|
+
def __init__(self, body: Body) -> None:
|
|
18
|
+
self.body = body
|
|
19
|
+
self.coordinates = body._coordinates
|
|
20
|
+
|
|
21
|
+
self.fig, self.ax = None, None
|
|
22
|
+
self.fig_ani, self.ax_ani = None, None
|
|
23
|
+
self.fig_vel, self.ax_vel = None, None
|
|
24
|
+
|
|
25
|
+
self.ani = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Orbit plotting methods
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def plot(self, title: str) -> None:
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
def save_plot(self, file_name: str = "body") -> None:
|
|
34
|
+
if file_name[-4:] != ".pdf" and file_name[-4:] != ".png":
|
|
35
|
+
file_name += ".pdf"
|
|
36
|
+
self.fig.savefig(file_name)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Animation plotting methods
|
|
40
|
+
@abstractmethod
|
|
41
|
+
def animate(self, frame_interval: int = 20) -> None:
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
def _update_title(self,frame: int) -> str:
|
|
45
|
+
lenght = len(self.body.pos[0])
|
|
46
|
+
if frame >= lenght:
|
|
47
|
+
frame = lenght - 1
|
|
48
|
+
|
|
49
|
+
s = '{:e}'.format(self.body.s[frame]),
|
|
50
|
+
pos = [
|
|
51
|
+
'{:e}'.format(self.body.pos[0][frame]),
|
|
52
|
+
'{:e}'.format(self.body.pos[1][frame]),
|
|
53
|
+
'{:e}'.format(self.body.pos[2][frame]),
|
|
54
|
+
'{:e}'.format(self.body.pos[3][frame])
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
title = f"s= {s},"
|
|
58
|
+
for i, coord in enumerate(self.coordinates.coords_string):
|
|
59
|
+
title = ''.join([title, f" {coord}= {pos[i]}"])
|
|
60
|
+
if i != 3:
|
|
61
|
+
title = ''.join([title, ","])
|
|
62
|
+
|
|
63
|
+
return title
|
|
64
|
+
|
|
65
|
+
def save_animation(self, file_name: str = "body", dpi=100) -> None:
|
|
66
|
+
if file_name[-4:] != ".mp4":
|
|
67
|
+
file_name += ".mp4"
|
|
68
|
+
self.ani.save(file_name, dpi=dpi)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Velocity plot methods
|
|
72
|
+
def plot_velocity(self, title: str) -> None:
|
|
73
|
+
assert self.body.vel_norm is not None
|
|
74
|
+
|
|
75
|
+
self.fig_vel, self.ax_vel = plt.subplots()
|
|
76
|
+
|
|
77
|
+
self.ax_vel.set_ylabel("Velocity")
|
|
78
|
+
self.ax_vel.set_xlabel("Time")
|
|
79
|
+
|
|
80
|
+
self.ax_vel.plot(self.body.pos[0], self.body.vel_norm)
|
|
81
|
+
|
|
82
|
+
self.ax_vel.set_title(title)
|
|
83
|
+
|
|
84
|
+
def save_plot_velocity(self, file_name: str = "body_velocity") -> None:
|
|
85
|
+
if file_name[-4:] != ".pdf" and file_name[-4:] != ".png":
|
|
86
|
+
file_name += ".pdf"
|
|
87
|
+
self.fig_vel.savefig(file_name)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# Global plot methods
|
|
91
|
+
def show(self) -> None:
|
|
92
|
+
plt.show()
|
|
93
|
+
|
|
94
|
+
def clear_plots(self) -> None:
|
|
95
|
+
self.fig = self.fig_ani = self.ax = self.ax_ani, self.fig_vel, self.ax_vel = None
|
|
96
|
+
|
|
97
|
+
@abstractmethod
|
|
98
|
+
def info(self) -> None:
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
@staticmethod
|
|
102
|
+
def _prt_info(coord_name: str, ordering: str, used: str, comment: str = None) -> None:
|
|
103
|
+
print(f"{coord_name}:\n\t- Assumes ordering : <{ordering}> for state vectors but only <{used}> are used for plotting.")
|
|
104
|
+
if comment is not None:
|
|
105
|
+
print(f"\t- {comment}")
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from ..body_plotter import BodyPlotter
|
|
2
|
+
|
|
3
|
+
from sympy import *
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
import matplotlib.patches as patches
|
|
6
|
+
|
|
7
|
+
from abc import ABCMeta, abstractmethod
|
|
8
|
+
from copy import deepcopy
|
|
9
|
+
|
|
10
|
+
# Possible symbols
|
|
11
|
+
#τ,t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
12
|
+
|
|
13
|
+
### BodyPlotter2D abstract class ###
|
|
14
|
+
# Class that facilitates the plotting of 2D Body objects.
|
|
15
|
+
class BodyPlotter2D(BodyPlotter, metaclass=ABCMeta):
|
|
16
|
+
|
|
17
|
+
def add_custom_patches(*argv) -> None:
|
|
18
|
+
for patch in argv:
|
|
19
|
+
patch_ani = deepcopy(patch)
|
|
20
|
+
|
|
21
|
+
if self.fig is not None:
|
|
22
|
+
patch.set(transform=self.ax.transData._b)
|
|
23
|
+
self.ax.add_patch(patch)
|
|
24
|
+
|
|
25
|
+
if self.fig_ani is not None:
|
|
26
|
+
patch_ani.set(transform=self.ax_ani.transData._b)
|
|
27
|
+
self.ax_ani.add_patch(patch_ani)
|
|
28
|
+
|
|
29
|
+
def add_circle(self, center: tuple[float, float], radius: float, edgecolor: str, facecolor: str = None, fill: bool = True) -> None:
|
|
30
|
+
|
|
31
|
+
circle = patches.Circle(center, radius, edgecolor=edgecolor, fill=fill, facecolor=facecolor)
|
|
32
|
+
circle_ani = deepcopy(circle)
|
|
33
|
+
|
|
34
|
+
if self.fig is not None:
|
|
35
|
+
circle.set(transform=self.ax.transData._b)
|
|
36
|
+
self.ax.add_patch(circle)
|
|
37
|
+
|
|
38
|
+
if self.fig_ani is not None:
|
|
39
|
+
circle_ani.set(transform=self.ax_ani.transData._b)
|
|
40
|
+
self.ax_ani.add_patch(circle_ani)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from ..body_plotter import BodyPlotter
|
|
2
|
+
from .body_plotter_2D import BodyPlotter2D
|
|
3
|
+
|
|
4
|
+
from sympy import *
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import matplotlib.animation as animation
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from copy import deepcopy
|
|
10
|
+
|
|
11
|
+
# Possible symbols
|
|
12
|
+
#τ,t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
13
|
+
|
|
14
|
+
### CartesianPlot2D class ###
|
|
15
|
+
# Class that facilitates the plotting of 2D Body objects expressed in cartesian coordinates.
|
|
16
|
+
class CartesianPlot2D(BodyPlotter2D, BodyPlotter):
|
|
17
|
+
|
|
18
|
+
def plot(self, title: str) -> None:
|
|
19
|
+
self.fig, self.ax = plt.subplots()
|
|
20
|
+
border = np.max(self.body.pos[1:3]) * 1.2
|
|
21
|
+
self.ax.plot(self.body.pos[1], self.body.pos[2])
|
|
22
|
+
self.ax.set_xlim(-border, border)
|
|
23
|
+
self.ax.set_ylim(-border, border)
|
|
24
|
+
self.ax.set_aspect("equal")
|
|
25
|
+
self.ax.set_title(title)
|
|
26
|
+
self.ax.set_xlabel("x")
|
|
27
|
+
self.ax.set_ylabel("y")
|
|
28
|
+
|
|
29
|
+
def animate(self, frame_interval: int = 20) -> None:
|
|
30
|
+
self.fig_ani, self.ax_ani = plt.subplots(figsize=(16, 9), dpi=1920/16)
|
|
31
|
+
border = np.max(self.body.pos[1:4]) * 1.2
|
|
32
|
+
line = self.ax_ani.plot(self.body.pos[1], self.body.pos[2])[0]
|
|
33
|
+
self.ax_ani.set_xlim(-border, border)
|
|
34
|
+
self.ax_ani.set_ylim(-border, border)
|
|
35
|
+
self.ax_ani.set_aspect("equal")
|
|
36
|
+
self.ax_ani.set_xlabel("x")
|
|
37
|
+
self.ax_ani.set_ylabel("y")
|
|
38
|
+
|
|
39
|
+
def __update_animation(frame, line):
|
|
40
|
+
self.ax_ani.set_title(super(CartesianPlot2D, self)._update_title(frame))
|
|
41
|
+
x = self.body.pos[1][:frame]
|
|
42
|
+
y = self.body.pos[2][:frame]
|
|
43
|
+
line.set_xdata(x)
|
|
44
|
+
line.set_ydata(y)
|
|
45
|
+
return line
|
|
46
|
+
|
|
47
|
+
self.ani = animation.FuncAnimation(fig=self.fig_ani, func=__update_animation, save_count=self.body.pos.shape[1], interval=20, fargs=(line, ))
|
|
48
|
+
|
|
49
|
+
def info(self, print_info: bool = False) -> None:
|
|
50
|
+
super(CartesianPlot2D, self)._prt_info("2Dcartesian", "t x y z", "x y")
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from ..body_plotter import BodyPlotter
|
|
2
|
+
from .body_plotter_2D import BodyPlotter2D
|
|
3
|
+
|
|
4
|
+
from sympy import *
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import matplotlib.patches as patches
|
|
7
|
+
import matplotlib.animation as animation
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from copy import deepcopy
|
|
11
|
+
|
|
12
|
+
# Possible symbols
|
|
13
|
+
#τ,t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
14
|
+
|
|
15
|
+
### PolarPlot2D class ###
|
|
16
|
+
# Class that facilitates the plotting of 2D Body objects expressed in spherical coordinates.
|
|
17
|
+
class PolarPlot(BodyPlotter2D, BodyPlotter):
|
|
18
|
+
|
|
19
|
+
def plot(self, title: str) -> None:
|
|
20
|
+
self.fig, self.ax = plt.subplots(subplot_kw={"projection": "polar"})
|
|
21
|
+
border = np.max(self.body.pos[1]) * 1.2
|
|
22
|
+
self.ax.set_ylim(0, border)
|
|
23
|
+
self.ax.plot(self.body.pos[3], self.body.pos[1])
|
|
24
|
+
self.ax.set_title(title)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def animate(self, frame_interval: int = 20) -> None:
|
|
28
|
+
self.fig_ani, self.ax_ani = plt.subplots(subplot_kw={"projection": "polar"})
|
|
29
|
+
border = np.max(self.body.pos[1]) * 1.2
|
|
30
|
+
line = self.ax_ani.plot(self.body.pos[3], self.body.pos[1])[0]
|
|
31
|
+
self.ax_ani.set_ylim(0, border)
|
|
32
|
+
|
|
33
|
+
def __update_animation(frame, line):
|
|
34
|
+
self.ax_ani.set_title(super(PolarPlot, self)._update_title(frame))
|
|
35
|
+
r = self.body.pos[1][:frame]
|
|
36
|
+
φ = self.body.pos[3][:frame]
|
|
37
|
+
line.set_xdata(φ)
|
|
38
|
+
line.set_ydata(r)
|
|
39
|
+
return line
|
|
40
|
+
|
|
41
|
+
self.ani = animation.FuncAnimation(fig=self.fig_ani, func=__update_animation, save_count=self.body.pos.shape[1], interval=20, fargs=(line, ))
|
|
42
|
+
|
|
43
|
+
def info(self) -> None:
|
|
44
|
+
super(PolarPlot, self)._prt_info("Polar", "t r θ φ", "r φ", "Note: φ<0,2π>.")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from ..body_plotter import BodyPlotter
|
|
2
|
+
|
|
3
|
+
from sympy import *
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from abc import ABCMeta, abstractmethod
|
|
8
|
+
|
|
9
|
+
# Possible symbols
|
|
10
|
+
#τ,t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### BodyPlotter3D abstract class ###
|
|
14
|
+
# Class that facilitates the plotting of 3D Body objects.
|
|
15
|
+
class BodyPlotter3D(BodyPlotter, metaclass=ABCMeta):
|
|
16
|
+
|
|
17
|
+
def add_custom_surface(self, x: np.array, y: np.array, z: np.array, facecolor: str = 'k') -> None:
|
|
18
|
+
if self.fig is not None: self.ax.plot_surface(x, y, z, color=facecolor, zorder=1, shade=False)
|
|
19
|
+
if self.fig_ani is not None: self.ax_ani.plot_surface(x, y, z, color=facecolor, zorder=1, shade=False)
|
|
20
|
+
|
|
21
|
+
def add_sphere(self, center: tuple[float, float], radius: float, facecolor: str) -> None:
|
|
22
|
+
θ, φ = np.mgrid[0:2*np.pi:40j, 0:np.pi:20j]
|
|
23
|
+
x = radius * np.sin(θ) * np.cos(φ) + center[0]
|
|
24
|
+
y = radius * np.sin(θ) * np.sin(φ) + center[1]
|
|
25
|
+
z = radius * np.cos(θ) + center[2]
|
|
26
|
+
self.add_custom_surface(x, y, z, facecolor=facecolor)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from ..body_plotter import BodyPlotter
|
|
2
|
+
from .body_plotter_3D import BodyPlotter3D
|
|
3
|
+
|
|
4
|
+
from sympy import *
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import matplotlib.patches as patches
|
|
7
|
+
import matplotlib.animation as animation
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
# Possible symbols
|
|
11
|
+
#τ,t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
12
|
+
|
|
13
|
+
### CartesianPlot3D class ###
|
|
14
|
+
# Class that facilitates the plotting of Body objects.
|
|
15
|
+
class CartesianPlot3D(BodyPlotter3D, BodyPlotter):
|
|
16
|
+
|
|
17
|
+
def plot(self, title: str) -> None:
|
|
18
|
+
self.fig, self.ax = plt.subplots(subplot_kw={"projection":"3d", "computed_zorder": False})
|
|
19
|
+
border = np.max(self.body.pos[1:3]) * 1.2
|
|
20
|
+
self.ax.plot(self.body.pos[1], self.body.pos[2], self.body.pos[3])
|
|
21
|
+
self.ax.set_xlim(-border, border)
|
|
22
|
+
self.ax.set_ylim(-border, border)
|
|
23
|
+
self.ax.set_zlim(-border, border)
|
|
24
|
+
self.ax.set_aspect("equal")
|
|
25
|
+
self.ax.set_title(title)
|
|
26
|
+
self.ax.set_xlabel("x")
|
|
27
|
+
self.ax.set_ylabel("y")
|
|
28
|
+
self.ax.set_zlabel("z")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Animation plotting methods
|
|
32
|
+
def animate(self, frame_interval: int = 20) -> None:
|
|
33
|
+
self.fig_ani, self.ax_ani = plt.subplots(subplot_kw={"projection":"3d", "computed_zorder": False})
|
|
34
|
+
border = np.max(self.body.pos[1:4]) * 1.2
|
|
35
|
+
line = self.ax_ani.plot(self.body.pos[1], self.body.pos[2], self.body.pos[3])[0]
|
|
36
|
+
self.ax_ani.set_xlim(-border, border)
|
|
37
|
+
self.ax_ani.set_ylim(-border, border)
|
|
38
|
+
self.ax_ani.set_zlim(-border, border)
|
|
39
|
+
self.ax_ani.set_aspect("equal")
|
|
40
|
+
self.ax_ani.set_xlabel("x")
|
|
41
|
+
self.ax_ani.set_ylabel("y")
|
|
42
|
+
self.ax_ani.set_zlabel("z")
|
|
43
|
+
|
|
44
|
+
def __update_animation(frame, line):
|
|
45
|
+
self.ax_ani.set_title(super(CartesianPlot3D, self)._update_title(frame))
|
|
46
|
+
x = self.body.pos[1][:frame]
|
|
47
|
+
y = self.body.pos[2][:frame]
|
|
48
|
+
z = self.body.pos[3][:frame]
|
|
49
|
+
line.set_data_3d(x, y, z)
|
|
50
|
+
return line
|
|
51
|
+
|
|
52
|
+
self.ani = animation.FuncAnimation(fig=self.fig_ani, func=__update_animation, save_count=self.body.pos.shape[1], interval=20, fargs=(line, ))
|
|
53
|
+
|
|
54
|
+
def info(self) -> None:
|
|
55
|
+
super(CartesianPlot3D, self)._prt_info("3Dcartesian", "t x y z", "x y z")
|
|
56
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from .coordinates import Coordinates
|
|
2
|
+
|
|
3
|
+
from typing import Callable
|
|
4
|
+
|
|
5
|
+
from sympy import *
|
|
6
|
+
|
|
7
|
+
# Converts tensor arrays into lambda expressions, for later integration. Array must only depend on coordinates and their first derivative.
|
|
8
|
+
def vector_to_lambda(coordinates: Coordinates, expressions: Array) -> list[Callable]:
|
|
9
|
+
assert expressions.shape[0] == len(coordinates.coords)
|
|
10
|
+
lambda_functions : list[Function] = []
|
|
11
|
+
for k, expr in enumerate(expressions):
|
|
12
|
+
lambda_functions.append(expr_to_lambda(coordinates, expr))
|
|
13
|
+
return lambda_functions
|
|
14
|
+
|
|
15
|
+
def expr_to_lambda(coordinates: Coordinates, expression: Function) -> Callable:
|
|
16
|
+
args = list(coordinates.coords)
|
|
17
|
+
args.extend([coord.diff(coordinates.interval) for coord in coordinates.coords])
|
|
18
|
+
return lambdify(args, expression, ["scipy", "numpy"], cse=False, docstring_limit=0)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .base_run import basic
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from ..geodesics import Geodesics
|
|
2
|
+
from ..body import Body
|
|
3
|
+
from ..coordinates import Coordinates
|
|
4
|
+
|
|
5
|
+
from sympy import *
|
|
6
|
+
import matplotlib.patches as patches
|
|
7
|
+
|
|
8
|
+
# Possible symbols
|
|
9
|
+
#τ,t,r,a,b,c,θ,φ,η,ψ,x,y
|
|
10
|
+
|
|
11
|
+
### basic function ###
|
|
12
|
+
# The examples folder of the project uses this function to execute all its examples.
|
|
13
|
+
# This is in order to unify the similar logic/algorithm behind all tests.
|
|
14
|
+
def basic(
|
|
15
|
+
coordinates: Coordinates,
|
|
16
|
+
g_mk: Matrix,
|
|
17
|
+
initial_pos: list[float],
|
|
18
|
+
initial_vel: list[float],
|
|
19
|
+
simplify: bool,
|
|
20
|
+
solver_kwargs: dict = {},
|
|
21
|
+
verbose: int = 0
|
|
22
|
+
) -> None:
|
|
23
|
+
|
|
24
|
+
# Sets default values in case they were unspecified
|
|
25
|
+
solver_kwargs.setdefault("time_interval", (0,100) )
|
|
26
|
+
solver_kwargs.setdefault("method" , "Radau" )
|
|
27
|
+
solver_kwargs.setdefault("max_step" , solver_kwargs["time_interval"][1]*1e-3)
|
|
28
|
+
solver_kwargs.setdefault("atol" , 1e-8 )
|
|
29
|
+
solver_kwargs.setdefault("rtol" , 1e-8 )
|
|
30
|
+
solver_kwargs.setdefault("events" , None )
|
|
31
|
+
|
|
32
|
+
print("Calculating geodesics")
|
|
33
|
+
geodesics: Geodesics = Geodesics(coordinates, g_mk)
|
|
34
|
+
if simplify is True: geodesics.simplify()
|
|
35
|
+
body = Body(geodesics, initial_pos, initial_vel)
|
|
36
|
+
|
|
37
|
+
print("Solving trajectory")
|
|
38
|
+
body.solve_trajectory(**solver_kwargs)
|
|
39
|
+
|
|
40
|
+
# Printing
|
|
41
|
+
if verbose == 2:
|
|
42
|
+
print("Geodesic differential equations: ")
|
|
43
|
+
for equation in geodesics._dₛuᵏ:
|
|
44
|
+
pprint(equation)
|
|
45
|
+
print()
|
|
46
|
+
|
|
47
|
+
print("Integration result: ")
|
|
48
|
+
print(body.solver_result)
|
|
49
|
+
|
|
50
|
+
return body
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from .. import Body
|
|
3
|
+
|
|
4
|
+
# Energy check (k)
|
|
5
|
+
def check_k(body: Body, rs: float, tol: float = 0.00001) -> None:
|
|
6
|
+
r_values = body.pos[1]
|
|
7
|
+
dₛt_values = body.vel[0]
|
|
8
|
+
|
|
9
|
+
dₛt_init = dₛt_values[0]
|
|
10
|
+
r_init = r_values[0]
|
|
11
|
+
k_init = dₛt_init * (1 - rs/r_init)
|
|
12
|
+
|
|
13
|
+
check = True
|
|
14
|
+
for dₛt, r in zip(dₛt_values, r_values):
|
|
15
|
+
k = dₛt * (1 - rs/r)
|
|
16
|
+
if np.abs(k_init - k) > tol:
|
|
17
|
+
check = False
|
|
18
|
+
break
|
|
19
|
+
|
|
20
|
+
print(f"Energy conserved: {check}")
|
|
21
|
+
|
|
22
|
+
# Angular momentum check (h)
|
|
23
|
+
def check_h(body: Body, rs: float, tol: float = 0.00001) -> None:
|
|
24
|
+
r_values = body.pos[1]
|
|
25
|
+
dₛφ_values = body.vel[3]
|
|
26
|
+
|
|
27
|
+
dₛφ_init = dₛφ_values[0]
|
|
28
|
+
r_init = r_values[0]
|
|
29
|
+
h_init = r_init * r_init * dₛφ_init
|
|
30
|
+
|
|
31
|
+
check = True
|
|
32
|
+
for dₛφ, r in zip(dₛφ_values, r_values):
|
|
33
|
+
h = r*r * dₛφ
|
|
34
|
+
if np.abs(h_init - h) > tol:
|
|
35
|
+
check = False
|
|
36
|
+
break
|
|
37
|
+
|
|
38
|
+
print(f"Angular momentum conserved: {check}")
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: geodpy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Computes space-time geodesics given an arbitrary metric and initial conditions.
|
|
5
|
+
Author-email: Benjamin Gauthier <benjamin.gauthier@hotmail.ca>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Benjamin Gauthier
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/Sneaker679/geodpy/tree/main
|
|
29
|
+
Keywords: general relativity,geodesics,geodesic,gr,astrophysics,astronomy,physics,riemann,riemann geometry,geometry,metric,space-time,spacetime
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Programming Language :: Python
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
35
|
+
Classifier: Environment :: Console
|
|
36
|
+
Classifier: Intended Audience :: Science/Research
|
|
37
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
38
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
39
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
41
|
+
Requires-Python: >=3.12
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Requires-Dist: numpy>=2.0.1
|
|
45
|
+
Requires-Dist: scipy>=1.14.0
|
|
46
|
+
Requires-Dist: sympy>=1.13.1
|
|
47
|
+
Requires-Dist: matplotlib>=3.9.1.post1
|
|
48
|
+
Requires-Dist: PyQt6>=6.7.1
|
|
49
|
+
|
|
50
|
+
# geodpy
|
|
51
|
+
This code aims to simulate geodesics given an arbitrary space-time metric.
|
|
52
|
+
|
|
53
|
+
## Capabilities
|
|
54
|
+
- Calculate symbolic geodesics
|
|
55
|
+
- Solve the trajectory of a body given an arbitrary metric and symbolic geodesics.
|
|
56
|
+
- Calculate the norm of the velocity of a body.
|
|
57
|
+
- Plot the trajectories on matplotlib in both 2D and 3D.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
- matplotlib
|
|
61
|
+
- sympy
|
|
62
|
+
- scipy
|
|
63
|
+
- numpy
|
|
64
|
+
|
|
65
|
+
You can install these dependencies using:
|
|
66
|
+
```bash
|
|
67
|
+
pip install matplotlib numpy scipy sympy
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Make sure these modules are correctly installed. Matplotlib in particular might require the installation of PyQt5 or PyQt6 depending on your system.
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
Clone the repository and go to the main folder `geodpy`. You can use these commands:
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/Sneaker679/geodpy
|
|
76
|
+
cd geodpy
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
In order to be able to import the classes and functions of this library, you will need to add the `./src` folder to your PYTHON PATH. Move to this folder using
|
|
80
|
+
```bash
|
|
81
|
+
cd src
|
|
82
|
+
```
|
|
83
|
+
and run the following command to add it to your path.
|
|
84
|
+
```bash
|
|
85
|
+
export PYTHONPATH="$(pwd):$PYTHONPATH"
|
|
86
|
+
```
|
|
87
|
+
To add the folder permanently to your PYTHON PATH, run this command instead.
|
|
88
|
+
```bash
|
|
89
|
+
echo 'export PYTHONPATH="$HOME'${PWD/#$HOME/}':$PYTHONPATH"' >> $HOME/.bashrc
|
|
90
|
+
```
|
|
91
|
+
or, for zsh terminals, run this.
|
|
92
|
+
```bash
|
|
93
|
+
echo 'export PYTHONPATH="$HOME'${PWD/#$HOME/}':$PYTHONPATH"' >> $HOME/.zshrc
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Basic Usage -> Using the examples
|
|
97
|
+
|
|
98
|
+
### Example with the Schwarzschild metric
|
|
99
|
+
In the `./examples/1_schwarzschild` folder, run any of the python files except for `schwarzschild.py` (since it acts as a module for the other files). For instance, you could run:
|
|
100
|
+
```bash
|
|
101
|
+
python3 2_crashing_traj.py
|
|
102
|
+
```
|
|
103
|
+
which will run a configuration of the Schwarzschild metric where a body is falling into a Schwarzschild black hole. A plot should be displayed on the screen using `matplotlib`.
|
|
104
|
+
|
|
105
|
+
### Structure of the examples
|
|
106
|
+
With the last example in mind, here is a more detailed overlook of how the examples are structured. This section will make it easier to understand how you can customize the orbits to your liking and experiment with the code.
|
|
107
|
+
|
|
108
|
+
In the `examples` folder are many examples that simulate geodesics with varied metrics, including the Schwarzschild, Kerr and Schwarzschild de Sitter metric. All these folders work in the same way. Taking the schwarzschild folder as an example, inside it are many files, the main one being `schwarzschild.py`. This script acts as a python module for the other files. Inside this code, there is a `schwarzschild()` function, which you can call with varied parameters to generate different geodesics. The other files in the `schwarzschild` folder are simple sripts who call the `schwarzschild()` function with different initial values. As it was shown in the previous section, the `2_crashing_traj.py` script, for example, yields a geodesic simulated near the event horizon of a non rotating Schwarzschild blackhole. You can run the other examples in the other folders the same way.
|
|
109
|
+
|
|
110
|
+
The README inside each example folders specifies the meaning of the constants and quantities used.
|
|
111
|
+
|
|
112
|
+
## Advanced Usage
|
|
113
|
+
For more advance usages, refer to `./docs/1_HowTo_trajectories.md`, `./docs/2_HowTo_coordinates.md` and `./docs/3_HowTo_plotters.md`.
|
|
114
|
+
|
|
115
|
+
## Interface
|
|
116
|
+
If you wish to see a more detailed overview of all the classes and functions at your disposition, be sure to checkout the `./docs/class_documentation/`. There are many Markdown files there explaining how all the classes and functions work. The REAMDEs in this folder also specify how you can import them.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/geodpy/__init__.py
|
|
5
|
+
src/geodpy/body.py
|
|
6
|
+
src/geodpy/geodesics.py
|
|
7
|
+
src/geodpy/to_lambda.py
|
|
8
|
+
src/geodpy.egg-info/PKG-INFO
|
|
9
|
+
src/geodpy.egg-info/SOURCES.txt
|
|
10
|
+
src/geodpy.egg-info/dependency_links.txt
|
|
11
|
+
src/geodpy.egg-info/requires.txt
|
|
12
|
+
src/geodpy.egg-info/top_level.txt
|
|
13
|
+
src/geodpy/coordinates/__init__.py
|
|
14
|
+
src/geodpy/coordinates/cartesian.py
|
|
15
|
+
src/geodpy/coordinates/coordinates.py
|
|
16
|
+
src/geodpy/coordinates/lemaitre.py
|
|
17
|
+
src/geodpy/coordinates/oblong_ellipsoid.py
|
|
18
|
+
src/geodpy/coordinates/spherical.py
|
|
19
|
+
src/geodpy/plotters/__init__.py
|
|
20
|
+
src/geodpy/plotters/body_plotter.py
|
|
21
|
+
src/geodpy/plotters/plotters2D/__init__.py
|
|
22
|
+
src/geodpy/plotters/plotters2D/body_plotter_2D.py
|
|
23
|
+
src/geodpy/plotters/plotters2D/cartesian_plot_2D.py
|
|
24
|
+
src/geodpy/plotters/plotters2D/polar_plot.py
|
|
25
|
+
src/geodpy/plotters/plotters3D/__init__.py
|
|
26
|
+
src/geodpy/plotters/plotters3D/body_plotter_3D.py
|
|
27
|
+
src/geodpy/plotters/plotters3D/cartesian_plot_3D.py
|
|
28
|
+
src/geodpy/utilities/__init__.py
|
|
29
|
+
src/geodpy/utilities/base_run.py
|
|
30
|
+
src/geodpy/validationTests/__init__.py
|
|
31
|
+
src/geodpy/validationTests/schwarzschild.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
geodpy
|