Skip to content

Commit

Permalink
Initial files for cr3bp.
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Biscani authored and Francesco Biscani committed Sep 10, 2023
1 parent 1150c0f commit 39371eb
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/heyoka/kw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
67 changes: 67 additions & 0 deletions include/heyoka/model/cr3bp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2020, 2021, 2022, 2023 Francesco Biscani ([email protected]), Dario Izzo ([email protected])
//
// 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 <tuple>
#include <utility>
#include <vector>

#include <heyoka/config.hpp>
#include <heyoka/detail/igor.hpp>
#include <heyoka/detail/visibility.hpp>
#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>

HEYOKA_BEGIN_NAMESPACE

namespace model
{

namespace detail
{

template <typename... KwArgs>
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<decltype(p(kw::mu))>(p(kw::mu))};
}

return std::tuple{std::move(mu)};
}

HEYOKA_DLL_PUBLIC std::vector<std::pair<expression, expression>> 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<std::pair<expression, expression>> {
return std::apply(detail::cr3bp_impl, detail::cr3bp_common_opts(std::forward<decltype(kw_args)>(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<decltype(kw_args)>(kw_args)...));
};

} // namespace model

HEYOKA_END_NAMESPACE

#endif
1 change: 1 addition & 0 deletions include/heyoka/models.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef HEYOKA_MODELS_HPP
#define HEYOKA_MODELS_HPP

#include <heyoka/model/cr3bp.hpp>
#include <heyoka/model/fixed_centres.hpp>
#include <heyoka/model/mascon.hpp>
#include <heyoka/model/nbody.hpp>
Expand Down

0 comments on commit 39371eb

Please sign in to comment.