Repository for RV code I created during my internship at MPIA, 2023. This code can be used for simple exoplanet and binary stars RV modeling.
Before using the code, please install kepler.py
:
pip install kepler.py
This code is better run in an interactive notebook *.ipynb
file instead of running it in *.py
.
Steps to use the code:
- Copy and run the code in
RV.py
to the first block of the Python notebook - Define the input parameters: primary mass
$M_1$ (kg), secondary mass$M_2$ (kg), semi-major axis$a$ (m), eccentricity$e$ , inclination$i$ (rad), argument of periastron$\omega$ (rad), period$P$ (s), and the time of periastron passage$T_0$ (s).
You can convert$a$ to$P$ or vice versa usingptoa
oratop
function fromRV.py
. - Create an array of time
$t$ you want to simulate, with$T_0$ as the first element of the array. Ensure that all the time unit in the array is in seconds (s). - Steps on simulation:
- Calculate the average angular speed of the (secondary) object in the orbit using
avg_ang_speed
function, using$P$ as the function's input. - Calculate the mean anomaly using
mean_anomaly
function, using$t$ and average angular speed as the input. - Calculate the eccentric anomaly and true anomaly using
kepler_solve
function, with mean anomaly and$e$ as the input. - Calculate the polar coordinate position of the object in orbit,
$r$ and$\theta$ withpos
function, using$a$ ,$e$ , and true anomaly as the input. - Finally, calculate the radial velocity with
radial_velocity
function, using true anomaly$\omega$ ,$e$ , systemic velocity,$a$ ,$i$ , and$M_1$ ,$M_2$ .
Finally, You can plot RV vs
An example ipynb
file for any RV simulation (2-body and multiple bodies) is provided in this repository.
Note: beware of the notation of the system when doing the simulation.
This code is a very simple form of simulating the RV plot and needs a lot of improvisation. Feel free to contribute to this repository!