Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New planet class #16

Merged
merged 19 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: c++20
TabWidth: 4
UseTab: Never
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-hicpp-uppercase-literal-suffix,-readability-uppercase-literal-suffix,-modernize-use-trailing-return-type,-readability-named-parameter,-hicpp-named-parameter,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-header-guard,-cppcoreguidelines-macro-usage,-google-runtime-references,-readability-isolate-declaration,-fuchsia-default-arguments-calls,-fuchsia-overloaded-operator,-fuchsia-default-arguments-declarations,-readability-else-after-return,-google-runtime-int,-hicpp-signed-bitwise,-cert-dcl21-cpp,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-avoid-c-arrays,-hicpp-avoid-c-arrays,-modernize-avoid-c-arrays,-modernize-use-transparent-functors,-cert-dcl16-c,-cppcoreguidelines-pro-type-union-access,-bugprone-branch-clone,-fuchsia-statically-constructed-objects,-cppcoreguidelines-pro-bounds-constant-array-index,-readability-static-accessed-through-instance,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-llvmlibc-restrict-system-libc-headers,-llvmlibc-callee-namespace,-llvmlibc-implementation-in-namespace,-llvm-else-after-return,-fuchsia-trailing-return,-readability-identifier-length,-altera-unroll-loops,-altera-id-dependent-backward-branch,-altera-struct-pack-align,-performance-no-int-to-ptr,-readability-function-cognitive-complexity'
Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-hicpp-uppercase-literal-suffix,-readability-uppercase-literal-suffix,-modernize-use-trailing-return-type,-readability-named-parameter,-hicpp-named-parameter,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-header-guard,-cppcoreguidelines-macro-usage,-google-runtime-references,-readability-isolate-declaration,-fuchsia-default-arguments-calls,-fuchsia-overloaded-operator,-fuchsia-default-arguments-declarations,-readability-else-after-return,-google-runtime-int,-hicpp-signed-bitwise,-cert-dcl21-cpp,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-avoid-c-arrays,-hicpp-avoid-c-arrays,-modernize-avoid-c-arrays,-modernize-use-transparent-functors,-cert-dcl16-c,-cppcoreguidelines-pro-type-union-access,-bugprone-branch-clone,-fuchsia-statically-constructed-objects,-cppcoreguidelines-pro-bounds-constant-array-index,-readability-static-accessed-through-instance,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-llvmlibc-restrict-system-libc-headers,-llvmlibc-callee-namespace,-llvmlibc-implementation-in-namespace,-llvm-else-after-return,-fuchsia-trailing-return,-readability-identifier-length,-altera-unroll-loops,-altera-id-dependent-backward-branch,-altera-struct-pack-align,-performance-no-int-to-ptr,-readability-function-cognitive-complexity,-llvmlibc-inline-function-decl'
WarningsAsErrors: '*'
AnalyzeTemporaryDtors: false
FormatStyle: none
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- uses: actions/checkout@v3
- name: Build
run: bash tools/gha_osx_debug.sh
windows_2019_release:
runs-on: windows-2019
windows_2022_release:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- name: Add msbuild to PATH
Expand All @@ -40,7 +40,7 @@ jobs:
run: |
mkdir build
cd build
cmake ../ -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Miniconda\envs\kep3_devel\Library -Dkep3_BUILD_TESTS=yes -DBoost_NO_BOOST_CMAKE=ON
cmake ../ -G "Visual Studio 17 2022" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Miniconda\envs\kep3_devel\Library -Dkep3_BUILD_TESTS=yes -DBoost_NO_BOOST_CMAKE=ON
cmake --build . -j4 --config Release --target install
ctest -j4 -V -C Release --output-on-failure
linux_coverage:
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ set(kep3_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/core_astro/ic2eq2ic.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/core_astro/eq2par2eq.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/core_astro/propagate_lagrangian.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/type_name.cpp"
)

# Setup of the kep3 shared library.
Expand Down
16 changes: 3 additions & 13 deletions config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,15 @@
#ifndef kep3_CONFIG_HPP
#define kep3_CONFIG_HPP

// NOTE: include this so that we can
// detect _LIBCPP_VERSION below.
#include <ciso646>

// Start of defines instantiated by CMake.

// clang-format off
#define kep3_VERSION "@kep3_VERSION@"
#define kep3_VERSION_MAJOR @kep3_VERSION_MAJOR@
#define kep3_VERSION_MINOR @kep3_VERSION_MINOR@
#define kep3_VERSION_PATCH @kep3_VERSION_PATCH@
// clang-format on

// End of defines instantiated by CMake.

#if defined(__clang__) && defined(_LIBCPP_VERSION)

// When using clang + libc++, prefer the name-based
// extract() implementation for UDx classes. See
// the explanation in typeid_name_extract.hpp.
#define kep3_PREFER_TYPEID_NAME_EXTRACT

#endif

#endif
34 changes: 16 additions & 18 deletions include/kep3/core_astro/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#ifndef kep3_CONSTANTS_H
#define kep3_CONSTANTS_H

#include <cmath>

#include <boost/math/constants/constants.hpp>

namespace kep3
Expand All @@ -25,22 +23,22 @@ enum elements_type {
POSVEL, // position and Velocity
};

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

constexpr double AU = 149597870700.0; // Astronomical Unit (m)
constexpr double CAVENDISH = 73.6687e-11; // Cavendish constant (N M^2 / kg^2)
constexpr double MU_SUN = 1.32712440018e20; // Sun's gravitational parameter (m^3/s^2 kg)
constexpr double MU_EARTH = 398600441800000.0; // Earth's gravitational parameter (m^3/s^2 kg)
constexpr double EARTH_VELOCITY = 29784.691831696804; // Earth's velocity. (m/s)
constexpr double EARTH_J2 = 1.08262668E-03;
constexpr double EARTH_RADIUS = 6378137; // Earth's radius (m)
constexpr double DEG2RAD = (pi / 180.0);
constexpr double RAD2DEG = (180.0 / pi);
constexpr double DAY2SEC = 86400.0;
constexpr double SEC2DAY = (1. / DAY2SEC);
constexpr double DAY2YEAR = (1. / 365.25);
constexpr double G0 = 9.80665; // Acceleration at Earth's surface (m/s^2)
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 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)
inline constexpr double DEG2RAD = (pi / 180.0);
inline constexpr double RAD2DEG = (180.0 / pi);
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)

} // namespace kep3

Expand Down
30 changes: 15 additions & 15 deletions include/kep3/core_astro/convert_anomalies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#define kep3_CONVERT_ANOMALIES_H

#include <cmath>
#include <stdexcept>
#include <limits>
#include <stdexcept>

#include <boost/math/constants/constants.hpp>
#include <boost/math/tools/roots.hpp>
Expand All @@ -29,7 +29,7 @@ namespace kep3
inline double m2e(double M, double ecc)
{
if (ecc >= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
}
// We compute the sin and cos of the mean anomaly which are used also later
// for the initial guess (3rd order expansion of Kepler's equation).
Expand Down Expand Up @@ -61,7 +61,7 @@ inline double m2e(double M, double ecc)
inline double e2m(double E, double ecc)
{
if (ecc >= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
}
return (E - ecc * std::sin(E));
}
Expand All @@ -70,7 +70,7 @@ inline double e2m(double E, double ecc)
inline double e2f(double E, double ecc)
{
if (ecc >= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
}
return 2 * std::atan(std::sqrt((1 + ecc) / (1 - ecc)) * std::tan(E / 2));
}
Expand All @@ -79,7 +79,7 @@ inline double e2f(double E, double ecc)
inline double f2e(double f, double ecc)
{
if (ecc >= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
}
return 2 * std::atan(std::sqrt((1 - ecc) / (1 + ecc)) * std::tan(f / 2));
}
Expand All @@ -88,7 +88,7 @@ inline double f2e(double f, double ecc)
inline double m2f(double M, double ecc)
{
if (ecc >= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return e2f(m2e(M, ecc), ecc);
}
Expand All @@ -97,7 +97,7 @@ inline double m2f(double M, double ecc)
inline double f2m(double f, double ecc)
{
if (ecc >= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return e2m(f2e(f, ecc), ecc);
}
Expand All @@ -106,7 +106,7 @@ inline double f2m(double f, double ecc)
inline double zeta2f(double f, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return 2 * std::atan(std::sqrt((1 + ecc) / (ecc - 1)) * std::tan(f / 2));
}
Expand All @@ -115,7 +115,7 @@ inline double zeta2f(double f, double ecc)
inline double f2zeta(double zeta, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return 2 * std::atan(std::sqrt((ecc - 1) / (1 + ecc)) * std::tan(zeta / 2));
}
Expand All @@ -125,7 +125,7 @@ inline double f2zeta(double zeta, double ecc)
inline double n2h(double N, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
// The Initial guess (TODO(darioizo) improve)
double IG = 1.;
Expand All @@ -148,7 +148,7 @@ inline double n2h(double N, double ecc)
inline double h2n(double H, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return (ecc * std::sinh(H) - H);
}
Expand All @@ -157,7 +157,7 @@ inline double h2n(double H, double ecc)
inline double h2f(double H, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return 2 * std::atan(std::sqrt((1 + ecc) / (ecc - 1)) * std::tanh(H / 2));
}
Expand All @@ -166,7 +166,7 @@ inline double h2f(double H, double ecc)
inline double f2h(double f, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return 2 * std::atanh(std::sqrt((ecc - 1) / (1 + ecc)) * std::tan(f / 2));
}
Expand All @@ -175,7 +175,7 @@ inline double f2h(double f, double ecc)
inline double n2f(double N, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return h2f(n2h(N, ecc), ecc);
}
Expand All @@ -184,7 +184,7 @@ inline double n2f(double N, double ecc)
inline double f2n(double f, double ecc)
{
if (ecc <= 1) {
return std::numeric_limits<double>::quiet_NaN() ;
return std::numeric_limits<double>::quiet_NaN();
};
return h2n(f2h(f, ecc), ecc);
}
Expand Down
2 changes: 0 additions & 2 deletions include/kep3/core_astro/convert_julian_dates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#ifndef kep3_CONVERT_JULIAN_DATES_HPP
#define kep3_CONVERT_JULIAN_DATES_HPP

#include "kep3/epoch.hpp"
#include <chrono>
namespace kep3
{
inline double jd2mjd(double in)
Expand Down
1 change: 0 additions & 1 deletion include/kep3/core_astro/propagate_lagrangian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define kep3_PROPAGATE_LAGRANGIAN_H

#include <array>
#include <cmath>

#include <kep3/detail/visibility.hpp>

Expand Down
Loading