Skip to content

Commit

Permalink
Merge pull request #52 from bluescarni/pr/updates
Browse files Browse the repository at this point in the history
Update to heyoka 3.0.0
  • Loading branch information
bluescarni authored Oct 7, 2023
2 parents e78054b + c686b98 commit 59572ba
Show file tree
Hide file tree
Showing 17 changed files with 391 additions and 253 deletions.
16 changes: 6 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

project(cascade VERSION 0.1.6 LANGUAGES CXX C)
project(cascade VERSION 0.1.7 LANGUAGES CXX C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/yacma")

Expand Down Expand Up @@ -143,8 +143,8 @@ set(CASCADE_SRC_FILES

# Setup of the cascade shared library.
add_library(cascade SHARED "${CASCADE_SRC_FILES}")
set_property(TARGET cascade PROPERTY VERSION "1.0")
set_property(TARGET cascade PROPERTY SOVERSION 1)
set_property(TARGET cascade PROPERTY VERSION "2.0")
set_property(TARGET cascade PROPERTY SOVERSION 2)
set_target_properties(cascade PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(cascade PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)

Expand Down Expand Up @@ -175,19 +175,15 @@ find_package(Boost 1.73 REQUIRED)
target_link_libraries(cascade PUBLIC Boost::boost)

# fmt.
find_package(fmt CONFIG REQUIRED)
find_package(fmt REQUIRED CONFIG)
target_link_libraries(cascade PUBLIC fmt::fmt)

# heyoka.
find_package(heyoka CONFIG REQUIRED)
find_package(heyoka 3.0.0 REQUIRED CONFIG)
target_link_libraries(cascade PUBLIC heyoka::heyoka)
message(STATUS "heyoka version: ${heyoka_VERSION}")
if(heyoka_VERSION VERSION_LESS 0.21.0)
message(FATAL_ERROR "heyoka>=0.21.0 is required, but heyoka ${heyoka_VERSION} was found instead")
endif()

# spdlog.
find_package(spdlog CONFIG REQUIRED)
find_package(spdlog REQUIRED CONFIG)
target_link_libraries(cascade PRIVATE spdlog::spdlog)

# Installation of the header files.
Expand Down
8 changes: 4 additions & 4 deletions benchmark/2022_leo_pop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <heyoka/math/pow.hpp>
#include <heyoka/math/sin.hpp>
#include <heyoka/math/sqrt.hpp>
#include <heyoka/math/sum_sq.hpp>
#include <heyoka/math/time.hpp>

#include <cascade/logging.hpp>
Expand Down Expand Up @@ -194,7 +193,8 @@ int main(int ac, char *av[])
H5Easy::File par_file("test_par_612813.hdf5", H5Easy::File::ReadOnly);
par_file.getDataSet("/par").read(pars);

// We switch off drag as to avoid to see too many reentries (in connection to the event reentry_radius being halved)
// We switch off drag as to avoid to see too many reentries (in connection to the event reentry_radius being
// halved)
drag_factor = 0.;
} else {
state = read_file("test_ic_19647.txt");
Expand Down Expand Up @@ -229,7 +229,7 @@ int main(int ac, char *av[])
auto dyn = dynamics::kepler(GMe);

// Add the J2 terms.
auto magr2 = hy::sum_sq({x, y, z});
auto magr2 = x * x + y * y + z * z;
auto J2term1 = GMe * (Re * Re) * std::sqrt(5) * C20 / (2. * hy::sqrt(magr2));
auto J2term2 = 3. / (magr2 * magr2);
auto J2term3 = 15. * (z * z) / (magr2 * magr2 * magr2);
Expand Down Expand Up @@ -275,7 +275,7 @@ int main(int ac, char *av[])
dyn[5].second += fC22z + fS22z;

// Add the drag force.
auto magv2 = hy::sum_sq({vx, vy, vz});
auto magv2 = vx * vx + vy * vy + vz * vz;
auto magv = hy::sqrt(magv2);
// Here we consider a spherical Earth ... would be easy to account for the oblateness effect on the altitude.
auto altitude = hy::sqrt(magr2) - Re;
Expand Down
5 changes: 2 additions & 3 deletions benchmark/haumea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <heyoka/math/cos.hpp>
#include <heyoka/math/pow.hpp>
#include <heyoka/math/sin.hpp>
#include <heyoka/math/sum_sq.hpp>
#include <heyoka/math/time.hpp>

#include <cascade/logging.hpp>
Expand Down Expand Up @@ -126,8 +125,8 @@ int main()
auto pert_y_s = mu_s * ((y_s - y) * dps_m3 - y_s * dcs_m3);
auto pert_z_s = mu_s * ((z_s - z) * dps_m3 - z_s * dcs_m3);

const auto I = (Ac * x * x + Bc * y * y + Cc * z * z) / hy::sum_sq({x, y, z});
const auto Vell = G / 2. * (Ac + Bc + Cc - 3. * I) * hy::pow(hy::sum_sq({x, y, z}), -3. / 2);
const auto I = (Ac * x * x + Bc * y * y + Cc * z * z) / (x * x + y * y + z * z);
const auto Vell = G / 2. * (Ac + Bc + Cc - 3. * I) * hy::pow(x * x + y * y + z * z, -3. / 2);

pert_x_s += hy::diff(Vell, x);
pert_y_s += hy::diff(Vell, y);
Expand Down
15 changes: 11 additions & 4 deletions cascade.py/dynamics/_simple_earth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import typing
import heyoka as hy


def _compute_atmospheric_density(h):
"""
Returns the heyoka expression for the atmosheric density in kg.m^3.
Expand Down Expand Up @@ -46,10 +47,16 @@ def _compute_atmospheric_density(h):


def simple_earth(
J2: bool=True, J3: bool=False, C22S22: bool=True, sun: bool=False, moon: bool=False, SRP: bool=False, drag: bool=True
J2: bool = True,
J3: bool = False,
C22S22: bool = True,
sun: bool = False,
moon: bool = False,
SRP: bool = False,
drag: bool = True,
) -> typing.List[typing.Tuple[hy.expression, hy.expression]]:
"""Perturbed dynamics around the Earth.
Returns heyoka expressions to be used as dynamics in :class:`~cascade.sim` and corresponding
to the Earth orbital environment as perturbed by selectable term (all in SI units).
Expand Down Expand Up @@ -121,7 +128,7 @@ def simple_earth(
dyn = kepler(mu=GMe_SI)

# Define the radius squared
magr2 = hy.sum_sq([x, y, z])
magr2 = x**2 + y**2 + z**2

Re_SI = Re_ * 1000
if J2:
Expand Down Expand Up @@ -314,7 +321,7 @@ def simple_earth(
drag_par_idx = 0
if drag:
# Adds the drag force.
magv2 = hy.sum_sq([vx, vy, vz])
magv2 = vx**2 + vy**2 + vz**2
magv = hy.sqrt(magv2)
# Here we consider a spherical Earth ... would be easy to account for the oblateness effect.
altitude = hy.sqrt(magr2) - Re_SI
Expand Down
4 changes: 2 additions & 2 deletions cascade.py/notebooks/2 - space_debris (simulation).ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"outputs": [],
"source": [
"# Add the J2 terms.\n",
"magr2 = hy.sum_sq([x, y, z])\n",
"magr2 = x**2+y**2+z**2\n",
"J2term1 = GMe*(Re**2)*np.sqrt(5)*C20/(2*magr2**(1./2))\n",
"J2term2 = 3/(magr2**2)\n",
"J2term3 = 15*(z**2)/(magr2**3)\n",
Expand Down Expand Up @@ -216,7 +216,7 @@
"outputs": [],
"source": [
"# Adds the drag force.\n",
"magv2 = hy.sum_sq([vx, vy, vz])\n",
"magv2 = vx**2+vy**2+vz**2\n",
"magv = hy.sqrt(magv2)\n",
"# Here we consider a spherical Earth ... would be easy to account for the oblateness effect.\n",
"altitude = (hy.sqrt(magr2) - Re)\n",
Expand Down
2 changes: 1 addition & 1 deletion cascade.py/notebooks/random_leo_J2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"dyn = csc.dynamics.kepler(mu = GMe)\n",
"\n",
"# Add the J2 terms.\n",
"magR2 = hy.sum_sq([x, y, z])\n",
"magR2 = x**2+y**2+z**2\n",
"J2term1 = GMe*(Re**2)*np.sqrt(5)*C20/(2*magR2**(1./2))\n",
"J2term2 = 3/(magR2**2)\n",
"J2term3 = 15*(z**2)/(magR2**3)\n",
Expand Down
Loading

0 comments on commit 59572ba

Please sign in to comment.