From 39371eb343f57aeef00f8769fc3434ce76471dae Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Sun, 10 Sep 2023 20:16:43 +0000 Subject: [PATCH] Initial files for cr3bp. --- include/heyoka/kw.hpp | 1 + include/heyoka/model/cr3bp.hpp | 67 ++++++++++++++++++++++++++++++++++ include/heyoka/models.hpp | 1 + 3 files changed, 69 insertions(+) create mode 100644 include/heyoka/model/cr3bp.hpp diff --git a/include/heyoka/kw.hpp b/include/heyoka/kw.hpp index 0a2c00eea..c28481287 100644 --- a/include/heyoka/kw.hpp +++ b/include/heyoka/kw.hpp @@ -28,6 +28,7 @@ IGOR_MAKE_NAMED_ARGUMENT(compact_mode); IGOR_MAKE_NAMED_ARGUMENT(high_accuracy); IGOR_MAKE_NAMED_ARGUMENT(parallel_mode); IGOR_MAKE_NAMED_ARGUMENT(prec); +IGOR_MAKE_NAMED_ARGUMENT(mu); } // namespace kw diff --git a/include/heyoka/model/cr3bp.hpp b/include/heyoka/model/cr3bp.hpp new file mode 100644 index 000000000..037c9738d --- /dev/null +++ b/include/heyoka/model/cr3bp.hpp @@ -0,0 +1,67 @@ +// Copyright 2020, 2021, 2022, 2023 Francesco Biscani (bluescarni@gmail.com), Dario Izzo (dario.izzo@gmail.com) +// +// This file is part of the heyoka library. +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef HEYOKA_MODEL_CR3BP_HPP +#define HEYOKA_MODEL_CR3BP_HPP + +#include +#include +#include + +#include +#include +#include +#include +#include + +HEYOKA_BEGIN_NAMESPACE + +namespace model +{ + +namespace detail +{ + +template +auto cr3bp_common_opts(KwArgs &&...kw_args) +{ + igor::parser p{kw_args...}; + + static_assert(!p.has_unnamed_arguments(), "This function accepts only named arguments"); + + expression mu{1e-3}; + if constexpr (p.has(kw::mu)) { + mu = expression{std::forward(p(kw::mu))}; + } + + return std::tuple{std::move(mu)}; +} + +HEYOKA_DLL_PUBLIC std::vector> cr3bp_impl(const expression &); + +HEYOKA_DLL_PUBLIC expression cr3bp_jacobi_impl(const expression &); + +} // namespace detail + +// NOTE: non-dimensional c3bp dynamics in the usual rotating (synodic) reference frame. +// Expressed in terms of canonical state variables. +inline constexpr auto cr3bp = [](auto &&...kw_args) -> std::vector> { + return std::apply(detail::cr3bp_impl, detail::cr3bp_common_opts(std::forward(kw_args)...)); +}; + +// NOTE: this returns a specific energy. +inline constexpr auto cr3bp_jacobi = [](auto &&...kw_args) -> expression { + return std::apply(detail::cr3bp_jacobi_impl, + detail::cr3bp_common_opts(std::forward(kw_args)...)); +}; + +} // namespace model + +HEYOKA_END_NAMESPACE + +#endif diff --git a/include/heyoka/models.hpp b/include/heyoka/models.hpp index 37ff4032f..12b11a67f 100644 --- a/include/heyoka/models.hpp +++ b/include/heyoka/models.hpp @@ -9,6 +9,7 @@ #ifndef HEYOKA_MODELS_HPP #define HEYOKA_MODELS_HPP +#include #include #include #include