Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
added cr3bp_char_quant and its tests (#1570)
Browse files Browse the repository at this point in the history
* added cr3bp_char_quant and its tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* attempt to fix tox error

* Updated to use bodies.Body

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added new lines and SystemChars works

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed /s and removed test for now

* Added test and the /contrib plotly html files

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added tests for cr3bp_char_quant

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* completed changes

* added cr3bp_char_quant and its tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* attempt to fix tox error

* Updated to use bodies.Body

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added new lines and SystemChars works

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed /s and removed test for now

* Added test and the /contrib plotly html files

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added tests for cr3bp_char_quant

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* completed changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
DhruvJ22 and pre-commit-ci[bot] committed Aug 23, 2022
1 parent d011e12 commit 47ec9c0
Show file tree
Hide file tree
Showing 8 changed files with 403 additions and 2 deletions.
88 changes: 87 additions & 1 deletion src/poliastro/bodies.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
* Uranus (⛢)
* Neptune (♆)
* Pluto (♇)
* Phobos
* Deimos
* Europa
* Ganyemede
* Enceladus
* Titan
* Titania
* Triton
* Charon
and a way to define new bodies (:py:class:`~Body` class).
Expand Down Expand Up @@ -52,6 +62,7 @@ class Body(
"J2",
"J3",
"mass",
"mean_a",
],
)
):
Expand All @@ -70,6 +81,7 @@ def __new__(
J2=0.0 * u.one,
J3=0.0 * u.one,
mass=None,
mean_a=0.0 * u.km,
):
if mass is None:
mass = k / G
Expand All @@ -87,6 +99,7 @@ def __new__(
_q(J2),
_q(J3),
_q(mass),
_q(mean_a),
)

@property
Expand Down Expand Up @@ -187,6 +200,7 @@ def plot(
R_mean=constants.R_mean_mercury,
R_polar=constants.R_polar_mercury,
rotational_period=constants.rotational_period_mercury,
mean_a=constants.mean_a_mercury,
)


Expand All @@ -201,6 +215,7 @@ def plot(
rotational_period=constants.rotational_period_venus,
J2=constants.J2_venus,
J3=constants.J3_venus,
mean_a=constants.mean_a_venus,
)


Expand All @@ -216,6 +231,7 @@ def plot(
mass=constants.M_earth,
J2=constants.J2_earth,
J3=constants.J3_earth,
mean_a=constants.mean_a_earth,
)


Expand All @@ -230,6 +246,7 @@ def plot(
rotational_period=constants.rotational_period_mars,
J2=constants.J2_mars,
J3=constants.J3_mars,
mean_a=constants.mean_a_mars,
)


Expand All @@ -243,6 +260,7 @@ def plot(
R_polar=constants.R_polar_jupiter,
rotational_period=constants.rotational_period_jupiter,
mass=constants.M_jupiter,
mean_a=constants.mean_a_jupiter,
)


Expand All @@ -255,6 +273,7 @@ def plot(
R_mean=constants.R_mean_saturn,
R_polar=constants.R_polar_saturn,
rotational_period=constants.rotational_period_saturn,
mean_a=constants.mean_a_saturn,
)


Expand All @@ -267,6 +286,7 @@ def plot(
R_mean=constants.R_mean_uranus,
R_polar=constants.R_polar_uranus,
rotational_period=constants.rotational_period_uranus,
mean_a=constants.mean_a_uranus,
)


Expand All @@ -279,6 +299,7 @@ def plot(
R_mean=constants.R_mean_neptune,
R_polar=constants.R_polar_neptune,
rotational_period=constants.rotational_period_neptune,
mean_a=constants.mean_a_neptune,
)


Expand All @@ -291,7 +312,7 @@ def plot(
R_mean=constants.R_mean_pluto,
R_polar=constants.R_polar_pluto,
rotational_period=constants.rotational_period_pluto,
)
) # No mean_a_pluto as Pluto is officially not a planet around Sun


Moon = Body(
Expand All @@ -303,4 +324,69 @@ def plot(
R_mean=constants.R_mean_moon,
R_polar=constants.R_polar_moon,
rotational_period=constants.rotational_period_moon,
mean_a=constants.mean_a_moon,
)


Phobos = Body(
parent=Mars,
k=constants.GM_phobos,
name="Phobos",
mean_a=constants.mean_a_phobos,
)

Deimoms = Body(
parent=Mars,
k=constants.GM_deimos,
name="Deimos",
mean_a=constants.mean_a_deimos,
)

Europa = Body(
parent=Jupiter,
k=constants.GM_europa,
name="Europa",
mean_a=constants.mean_a_europa,
)

Ganymede = Body(
parent=Jupiter,
k=constants.GM_ganymede,
name="Ganymede",
mean_a=constants.mean_a_ganymede,
)

Enceladus = Body(
parent=Saturn,
k=constants.GM_enceladus,
name="Enceladus",
mean_a=constants.mean_a_enceladus,
)

Titan = Body(
parent=Saturn,
k=constants.GM_titan,
name="Titan",
mean_a=constants.mean_a_titan,
)

Titania = Body(
parent=Uranus,
k=constants.GM_titania,
name="Titania",
mean_a=constants.mean_a_titania,
)

Triton = Body(
parent=Neptune,
k=constants.GM_triton,
name="Triton",
mean_a=constants.mean_a_triton,
)

Charon = Body(
parent=Pluto,
k=constants.GM_charon,
name="charon",
mean_a=constants.mean_a_charon,
)
56 changes: 56 additions & 0 deletions src/poliastro/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
J2000,
J2000_TDB,
J2000_TT,
GM_charon,
GM_deimos,
GM_earth,
GM_enceladus,
GM_europa,
GM_ganymede,
GM_jupiter,
GM_mars,
GM_mercury,
GM_moon,
GM_neptune,
GM_phobos,
GM_pluto,
GM_saturn,
GM_sun,
GM_titan,
GM_titania,
GM_triton,
GM_uranus,
GM_venus,
H0_earth,
Expand Down Expand Up @@ -58,6 +67,26 @@
Wdivc_sun,
rho0_earth,
)
from poliastro.constants.mean_elements import (
mean_a_charon,
mean_a_deimos,
mean_a_earth,
mean_a_enceladus,
mean_a_europa,
mean_a_ganymede,
mean_a_jupiter,
mean_a_mars,
mean_a_mercury,
mean_a_moon,
mean_a_neptune,
mean_a_phobos,
mean_a_saturn,
mean_a_titan,
mean_a_titania,
mean_a_triton,
mean_a_uranus,
mean_a_venus,
)
from poliastro.constants.rotational_elements import (
rotational_period_earth,
rotational_period_jupiter,
Expand Down Expand Up @@ -87,6 +116,15 @@
"GM_neptune",
"GM_pluto",
"GM_moon",
"GM_phobos",
"GM_deimos",
"GM_europa",
"GM_ganymede",
"GM_enceladus",
"GM_titan",
"GM_titania",
"GM_triton",
"GM_charon",
"M_earth",
"M_jupiter",
"M_sun",
Expand Down Expand Up @@ -142,4 +180,22 @@
"rotational_period_uranus",
"rotational_period_neptune",
"rotational_period_pluto",
"mean_a_mercury",
"mean_a_venus",
"mean_a_earth",
"mean_a_mars",
"mean_a_jupiter",
"mean_a_saturn",
"mean_a_uranus",
"mean_a_neptune",
"mean_a_moon",
"mean_a_phobos",
"mean_a_deimos",
"mean_a_europa",
"mean_a_ganymede",
"mean_a_enceladus",
"mean_a_titan",
"mean_a_titania",
"mean_a_triton",
"mean_a_charon",
]
2 changes: 1 addition & 1 deletion src/poliastro/constants/mean_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

mean_a_uranus = Constant(
"mean_a_uranus",
"Saturn's orbit mean semimajor axis around Sun",
"Uranus' orbit mean semimajor axis around Sun",
(19.18916464 * u.au.to(u.km)),
"km",
0,
Expand Down
Empty file.
46 changes: 46 additions & 0 deletions src/poliastro/core/threebody/cr3bp_quantities_calculations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
@author: Dhruv Jain, Multi-Body Dynamics Research Group, Purdue University
"""


def calculate_mu(mu1, mu2):
"""Calculate mu of CR3BP
Parameters
----------
mu1: float, km^3*s^-2
mu of P1
mu2: float, km^3*s^-2
mu of P2
Returns
-------
mu: float, dimensionless
mu2/(mu1+mu2), mu2<mu1
"""
return mu2 / (mu1 + mu2)


def calculate_tstar(mu1, mu2, lstar):
r"""Calculate t* of CR3BP
Parameters
----------
mu1: float, km^3*s^-2
mu of P1
mu2: float, km^3*s^-2
mu of P2
lstar: float, km
Characterisitc length of P1 - P2 system
Returns
-------
tstar: float, sec
Characterisitc time of P1-P2 system
Explicitly converted to u.s as mu1 and mu2 may be of different units
.. math::
\sqrt{\frac{l*^3}{M1+M2}}
"""
return (lstar**3 / (mu1 + mu2)) ** 0.5

0 comments on commit 47ec9c0

Please sign in to comment.