Skip to content

Commit

Permalink
constants updated and enriched
Browse files Browse the repository at this point in the history
  • Loading branch information
darioizzo committed Sep 16, 2024
1 parent 96199a8 commit 74226c2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
26 changes: 19 additions & 7 deletions doc/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ the various `pykep` objects and functionalities.
- Symbol in pykep
- Units
- Value
* - Astronomical Unit
* - Astronomical Unit
- pykep.AU
- :math:`m`
- 149597870700.0
- 1.495978707e+11
* - Cavendish constant
- pykep.CAVENDISH
- :math:`\frac{N m^2}{kg^2}`
- 7.36687e-10
- :math:`\frac{m^3}{sec^2 kg}`
- 6.67430e-11
* - Sun's gravitational parameter
- pykep.MU_SUN
- :math:`\frac{m^3}{sec^2}`
- 1.32712440018e+20
* - Earth's gravitational parameter
- 1.32712440041279419e20
* - Earth's gravitational parameter (JPL DE440)
- pykep.MU_EARTH
- :math:`\frac{m^3}{sec^2}`
- 398600441800000.0
- 3.98600435507e+14
* - Moon's gravitational parameter (JPL DE440)
- pykep.MU_MOON
- :math:`\frac{m^3}{sec^2}`
- 4.902800118e+12
* - Earth's velocity
- pykep.EARTH_VELOCITY
- :math:`\frac{m}{sec}`
Expand All @@ -43,6 +47,10 @@ the various `pykep` objects and functionalities.
- pykep.EARTH_J2
- --
- 0.00108262668
* - CR3BP: Moon-Earth parameter
- pykep.CR3BP_EARTH_MOON
- --
- 0.01215058439470971
* - Seconds in one day
- pykep.DAY2SEC
- --
Expand All @@ -51,3 +59,7 @@ the various `pykep` objects and functionalities.
- pykep.RAD2DEG
- --
- 57.29577951308232
* - Radians in one degree
- pykep.DEG2RAD
- --
- 0.017453292519943295
4 changes: 2 additions & 2 deletions doc/propagation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ seamlessly via variational equations.

The main routines are listed here:

Keplerian dynamics
Keplerian
******************

.. currentmodule:: pykep
Expand All @@ -23,7 +23,7 @@ Keplerian dynamics

---------------------------------------------------------

Non-Keplerian dynamics
Non-Keplerian
************************

.. currentmodule:: pykep
Expand Down
13 changes: 7 additions & 6 deletions include/kep3/core_astro/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ enum elements_type {
MEQ_R, // Modified Equinoctial Elements (retrogade)
POSVEL, // position and Velocity
};

inline constexpr double pi = boost::math::constants::pi<double>();
inline constexpr double half_pi = boost::math::constants::half_pi<double>();

inline constexpr double AU = 149597870700.0; // Astronomical Unit (m)
inline constexpr double CAVENDISH = 73.6687e-11; // Cavendish constant (N M^2 / kg^2)
inline constexpr double MU_SUN = 1.32712440018e20; // Sun's gravitational parameter (m^3/s^2 kg)
inline constexpr double MU_EARTH = 398600441800000.0; // Earth's gravitational parameter (m^3/s^2 kg)
inline constexpr double AU = 149597870700.0; // Astronomical Unit (m) - IAU 2012 Resolution B1
inline constexpr double CAVENDISH = 6.67430e-11; // Cavendish constant (m^3/s^2/kg)
inline constexpr double MU_SUN = 1.32712440041279419e20; // Sun's gravitational parameter (m^3/s^2 kg) - DE440
inline constexpr double MU_EARTH = 398600435507000.0; // Earth's gravitational parameter (m^3/s^2 kg) - DE440
inline constexpr double MU_MOON = 4902800118000.0; // Moon's gravitational parameter (m^3/s^2 kg) - DE440
inline constexpr double EARTH_VELOCITY = 29784.691831696804; // Earth's velocity. (m/s)
inline constexpr double EARTH_J2 = 1.08262668E-03;
inline constexpr double EARTH_RADIUS = 6378137; // Earth's radius (m)
Expand All @@ -39,6 +38,8 @@ inline constexpr double DAY2SEC = 86400.0;
inline constexpr double SEC2DAY = (1. / DAY2SEC);
inline constexpr double DAY2YEAR = (1. / 365.25);
inline constexpr double G0 = 9.80665; // Acceleration at Earth's surface (m/s^2)
inline constexpr double CR3BP_EARTH_MOON = 0.01215058439470971; // (M_moon + M_Earth) / M_Earth


} // namespace kep3

Expand Down
2 changes: 2 additions & 0 deletions pykep/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ PYBIND11_MODULE(core, m)
m.attr("EARTH_J2") = py::float_(kep3::EARTH_J2);
m.attr("EARTH_RADIUS") = py::float_(kep3::EARTH_RADIUS);
m.attr("RAD2DEG") = py::float_(kep3::RAD2DEG);
m.attr("DEG2RAD") = py::float_(kep3::RAD2DEG);
m.attr("DAY2SEC") = py::float_(kep3::DAY2SEC);
m.attr("SEC2DAY") = py::float_(kep3::SEC2DAY);
m.attr("DAY2YEAR") = py::float_(kep3::DAY2YEAR);
m.attr("G0") = py::float_(kep3::G0);
m.attr("CR3BP_EARTH_MOON") = py::float_(kep3::CR3BP_EARTH_MOON);

// We expose here global enums:
py::enum_<kep3::elements_type>(m, "el_type", "")
Expand Down
4 changes: 2 additions & 2 deletions pykep/docstrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ std::string get_stark_docstring()
{
return R"(get_stark(tol)
Gets the Taylor adaptive propagator (Heyoka) for the Stark problem from the global cache and returns a copy.
Returns a Taylor adaptive propagator (Heyoka) for the Stark problem retreiving one from a global cache and making a copy.
In `pykep`, abusing a term well established in electrodynamics,
this is the initial value problem of a fixed inertial thrust mass-varying spacecraft orbiting a main body.
Expand Down Expand Up @@ -1320,7 +1320,7 @@ std::string get_stark_var_docstring()
{
return R"(get_stark_var(tol)
Gets the variational (order 1) Taylor adaptive propagator (Heyoka) for the Stark problem from the global cache and returns a copy.
Returns a (order 1) variational Taylor adaptive propagator (Heyoka) for the Stark problem retreiving one from a global cache and making a copy.
.. note:
Variations are only considered with repsect to initial conditions and the fixed inertial thurst.
Expand Down
2 changes: 2 additions & 0 deletions test/ta_cr3bp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ TEST_CASE("dynamics")
std::vector<double> ic{1.01238082345234, -0.0423523523454, 0.22634376321,
-0.1232623614, 0.123462698209365, 0.123667064622};
std::copy(ic.begin(), ic.end(), ta.get_state_data());
// Assign value for cis-lunar case. (note: not the official pykep on in this case)
*ta.get_pars_data() = 0.01215058560962404;
auto out = ta.propagate_until(5.7856656782589234);
std::vector<double> const ground_truth = {0.43038358727124, -1.64650668902846, 0.10271923139472,
Expand All @@ -90,6 +91,7 @@ TEST_CASE("variational_dynamics")
std::vector<double> ic{1.01238082345234, -0.0423523523454, 0.22634376321,
-0.1232623614, 0.123462698209365, 0.123667064622};
std::copy(ic.begin(), ic.end(), ta.get_state_data());
// Assign value for cis-lunar case. (note: not the official pykep on in this case)
*ta.get_pars_data() = 0.01215058560962404;
auto out = ta.propagate_until(5.7856656782589234);
std::vector<double> const ground_truth = {0.43038358727124, -1.64650668902846, 0.10271923139472,
Expand Down

0 comments on commit 74226c2

Please sign in to comment.