Skip to content

Commit

Permalink
Merge pull request #362 from bluescarni/pr/elp2000
Browse files Browse the repository at this point in the history
ELP2000 lunar theory
  • Loading branch information
bluescarni authored Nov 17, 2023
2 parents ec9d32a + 7da9340 commit 22e2873
Show file tree
Hide file tree
Showing 35 changed files with 46,117 additions and 80 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jobs:
conda_asan:
docker:
- image: cimg/base:current
resource_class: large
steps:
- checkout
- run:
Expand All @@ -13,7 +14,7 @@ jobs:
ubuntu_arm64:
machine:
image: ubuntu-2004:202101-01
resource_class: arm.medium
resource_class: arm.large
steps:
- checkout
- run:
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

project(heyoka VERSION 3.1.0 LANGUAGES CXX C)
project(heyoka VERSION 3.2.0 LANGUAGES CXX C)

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

Expand Down Expand Up @@ -253,13 +253,20 @@ set(HEYOKA_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_6.cpp"
# ELP2000 details.
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_1_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_4_9.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_10_15.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_16_21.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_22_36.cpp"
# Models.
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/pendulum.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/nbody.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/fixed_centres.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/rotating.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/mascon.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/vsop2013.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/elp2000.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/cr3bp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/ffnn.cpp"
# Math functions.
Expand Down Expand Up @@ -306,7 +313,7 @@ if(HEYOKA_WITH_SLEEF)
endif()

# Setup the heyoka ABI version number.
set(HEYOKA_ABI_VERSION 25)
set(HEYOKA_ABI_VERSION 26)

if(HEYOKA_BUILD_STATIC_LIBRARY)
# Setup of the heyoka static library.
Expand Down
1 change: 1 addition & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ ADD_HEYOKA_BENCHMARK(h_oscillator_lt)
ADD_HEYOKA_BENCHMARK(mb)
ADD_HEYOKA_BENCHMARK(vsop2013_elliptic)
ADD_HEYOKA_BENCHMARK(vsop2013_cartesian)
ADD_HEYOKA_BENCHMARK(elp2000_cartesian)
ADD_HEYOKA_BENCHMARK(pendulum_bench)
ADD_HEYOKA_BENCHMARK(pendulum_odeint)
ADD_HEYOKA_BENCHMARK(pcr3bp)
Expand Down
76 changes: 76 additions & 0 deletions benchmark/elp2000_cartesian.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// 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/.

#include <iostream>

#include <boost/program_options.hpp>

#include <fmt/core.h>
#include <fmt/ranges.h>

#include <spdlog/spdlog.h>
#include <spdlog/stopwatch.h>

#include <heyoka/kw.hpp>
#include <heyoka/llvm_state.hpp>
#include <heyoka/logging.hpp>
#include <heyoka/model/elp2000.hpp>

using namespace heyoka;
using namespace heyoka::model;

int main(int argc, char *argv[])
{
namespace po = boost::program_options;

double thresh{};

po::options_description desc("Options");

desc.add_options()("help", "produce help message")("thresh", po::value<double>(&thresh)->default_value(1e-7),
"threshold value");

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);

if (vm.count("help") != 0u) {
std::cout << desc << "\n";
return 0;
}

// Fetch the logger.
create_logger();
set_logger_level_trace();
auto logger = spdlog::get("heyoka");

spdlog::stopwatch sw;
auto sol = model::elp2000_cartesian_e2000(kw::thresh = thresh);
logger->trace("Creating the solution took: {}", sw);

llvm_state s;

sw.reset();
add_cfunc<double>(s, "func", sol, kw::compact_mode = true);
s.compile();
logger->trace("Compiling the solution took: {}", sw);

auto *cf_ptr
= reinterpret_cast<void (*)(double *, const double *, const double *, const double *)>(s.jit_lookup("func"));

double out[3]{};

for (auto date : {2469000.5, 2449000.5, 2429000.5, 2409000.5, 2389000.5}) {
const double tm = (date - 2451545.0) / (36525);

sw.reset();
cf_ptr(out, nullptr, nullptr, &tm);
logger->trace("Computing the solution took: {}", sw);
logger->trace("State for date {}: {}", date, out);
}
}
1 change: 1 addition & 0 deletions benchmark/vsop2013_cartesian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <boost/program_options.hpp>

#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/model/vsop2013.hpp>
#include <heyoka/taylor.hpp>

Expand Down
1 change: 1 addition & 0 deletions benchmark/vsop2013_elliptic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <boost/program_options.hpp>

#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/model/vsop2013.hpp>
#include <heyoka/taylor.hpp>

Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ coverage:
- "test/.*"
- "tutorial/.*"
- "src/detail/vsop2013/.*"
- "src/detail/elp2000/.*"

comment: off
16 changes: 16 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Changelog
=========

3.2.0 (unreleased)
------------------

New
~~~

- Add model implementing the ELP2000 analytical lunar theory
(`#362 <https://github.com/bluescarni/heyoka/pull/362>`__).

Changes
~~~~~~~

- Improve performance when creating symbolic expressions for
large sums and products
(`#362 <https://github.com/bluescarni/heyoka/pull/362>`__).

3.1.0 (2023-11-13)
------------------

Expand Down
43 changes: 43 additions & 0 deletions include/heyoka/detail/elp2000/elp2000_10_15.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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_DETAIL_ELP2000_ELP_10_15_HPP
#define HEYOKA_DETAIL_ELP2000_ELP_10_15_HPP

#include <cstdint>

#include <heyoka/config.hpp>

HEYOKA_BEGIN_NAMESPACE

namespace model::detail
{

extern const std::int8_t elp2000_idx_10[14328][11];
extern const double elp2000_phi_A_10[14328][2];

extern const std::int8_t elp2000_idx_11[5233][11];
extern const double elp2000_phi_A_11[5233][2];

extern const std::int8_t elp2000_idx_12[6631][11];
extern const double elp2000_phi_A_12[6631][2];

extern const std::int8_t elp2000_idx_13[4384][11];
extern const double elp2000_phi_A_13[4384][2];

extern const std::int8_t elp2000_idx_14[833][11];
extern const double elp2000_phi_A_14[833][2];

extern const std::int8_t elp2000_idx_15[1715][11];
extern const double elp2000_phi_A_15[1715][2];

} // namespace model::detail

HEYOKA_END_NAMESPACE

#endif
43 changes: 43 additions & 0 deletions include/heyoka/detail/elp2000/elp2000_16_21.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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_DETAIL_ELP2000_ELP_16_21_HPP
#define HEYOKA_DETAIL_ELP2000_ELP_16_21_HPP

#include <cstdint>

#include <heyoka/config.hpp>

HEYOKA_BEGIN_NAMESPACE

namespace model::detail
{

extern const std::int8_t elp2000_idx_16[170][11];
extern const double elp2000_phi_A_16[170][2];

extern const std::int8_t elp2000_idx_17[150][11];
extern const double elp2000_phi_A_17[150][2];

extern const std::int8_t elp2000_idx_18[114][11];
extern const double elp2000_phi_A_18[114][2];

extern const std::int8_t elp2000_idx_19[226][11];
extern const double elp2000_phi_A_19[226][2];

extern const std::int8_t elp2000_idx_20[188][11];
extern const double elp2000_phi_A_20[188][2];

extern const std::int8_t elp2000_idx_21[169][11];
extern const double elp2000_phi_A_21[169][2];

} // namespace model::detail

HEYOKA_END_NAMESPACE

#endif
34 changes: 34 additions & 0 deletions include/heyoka/detail/elp2000/elp2000_1_3.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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_DETAIL_ELP2000_ELP_1_3_HPP
#define HEYOKA_DETAIL_ELP2000_ELP_1_3_HPP

#include <cstdint>

#include <heyoka/config.hpp>

HEYOKA_BEGIN_NAMESPACE

namespace model::detail
{

extern const std::int8_t elp2000_idx_1[1023][4];
extern const double elp2000_A_B_1[1023][6];

extern const std::int8_t elp2000_idx_2[918][4];
extern const double elp2000_A_B_2[918][6];

extern const std::int8_t elp2000_idx_3[704][4];
extern const double elp2000_A_B_3[704][6];

} // namespace model::detail

HEYOKA_END_NAMESPACE

#endif
70 changes: 70 additions & 0 deletions include/heyoka/detail/elp2000/elp2000_22_36.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// 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_DETAIL_ELP2000_ELP_22_36_HPP
#define HEYOKA_DETAIL_ELP2000_ELP_22_36_HPP

#include <cstdint>

#include <heyoka/config.hpp>

HEYOKA_BEGIN_NAMESPACE

namespace model::detail
{

extern const std::int8_t elp2000_idx_22[3][5];
extern const double elp2000_phi_A_22[3][2];

extern const std::int8_t elp2000_idx_23[2][5];
extern const double elp2000_phi_A_23[2][2];

extern const std::int8_t elp2000_idx_24[2][5];
extern const double elp2000_phi_A_24[2][2];

extern const std::int8_t elp2000_idx_25[6][5];
extern const double elp2000_phi_A_25[6][2];

extern const std::int8_t elp2000_idx_26[4][5];
extern const double elp2000_phi_A_26[4][2];

extern const std::int8_t elp2000_idx_27[5][5];
extern const double elp2000_phi_A_27[5][2];

extern const std::int8_t elp2000_idx_28[20][5];
extern const double elp2000_phi_A_28[20][2];

extern const std::int8_t elp2000_idx_29[12][5];
extern const double elp2000_phi_A_29[12][2];

extern const std::int8_t elp2000_idx_30[14][5];
extern const double elp2000_phi_A_30[14][2];

extern const std::int8_t elp2000_idx_31[11][5];
extern const double elp2000_phi_A_31[11][2];

extern const std::int8_t elp2000_idx_32[4][5];
extern const double elp2000_phi_A_32[4][2];

extern const std::int8_t elp2000_idx_33[10][5];
extern const double elp2000_phi_A_33[10][2];

extern const std::int8_t elp2000_idx_34[28][5];
extern const double elp2000_phi_A_34[28][2];

extern const std::int8_t elp2000_idx_35[13][5];
extern const double elp2000_phi_A_35[13][2];

extern const std::int8_t elp2000_idx_36[19][5];
extern const double elp2000_phi_A_36[19][2];

} // namespace model::detail

HEYOKA_END_NAMESPACE

#endif
Loading

0 comments on commit 22e2873

Please sign in to comment.