diff --git a/benchmark/convert_anomalies_benchmark.cpp b/benchmark/convert_anomalies_benchmark.cpp index c9543ff6..2675f97d 100644 --- a/benchmark/convert_anomalies_benchmark.cpp +++ b/benchmark/convert_anomalies_benchmark.cpp @@ -98,7 +98,6 @@ void perform_test_accuracy(double min_ecc, double max_ecc, unsigned N) { } int main() { - unsigned seed = 7898935u; fmt::print("\nComputes speed at different eccentricity ranges:\n"); perform_test_speed(0, 0.5, 1000000); perform_test_speed(0.5, 0.9, 1000000); diff --git a/benchmark/propagate_lagrangian_benchmark.cpp b/benchmark/propagate_lagrangian_benchmark.cpp index 3d09cfb2..edeb6e45 100644 --- a/benchmark/propagate_lagrangian_benchmark.cpp +++ b/benchmark/propagate_lagrangian_benchmark.cpp @@ -54,7 +54,7 @@ void perform_test_speed( for (auto i = 0u; i < N; ++i) { auto ecc = ecc_d(rng_engine); auto sma = sma_d(rng_engine); - ecc > 1. ? sma = -sma : sma = sma; + ecc > 1. ? sma = -sma : sma; double f = pi; while (std::cos(f) < -1. / ecc && sma < 0.) { f = f_d(rng_engine); @@ -108,13 +108,12 @@ void perform_test_accuracy( while (std::cos(f) < -1. / ecc && sma < 0.) { ecc = ecc_d(rng_engine); sma = sma_d(rng_engine); - ecc > 1. ? sma = -sma : sma = sma; + ecc > 1. ? sma = -sma : sma; f = f_d(rng_engine); } - pos_vels[i] = { - sma, ecc, incl_d(rng_engine), Omega_d(rng_engine), omega_d(rng_engine), - f}; + pos_vels[i] = kep3::par2ic({sma, ecc, incl_d(rng_engine), + Omega_d(rng_engine), omega_d(rng_engine), f}, 1.); tofs[i] = tof_d(rng_engine); } // We log progress diff --git a/src/planets/keplerian.cpp b/src/planets/keplerian.cpp index dd881b87..1879abe1 100644 --- a/src/planets/keplerian.cpp +++ b/src/planets/keplerian.cpp @@ -28,10 +28,9 @@ keplerian::keplerian(const epoch &ref_epoch, const std::array, 2> &pos_vel, double mu_central_body, std::string name, std::array added_params) - : m_ref_epoch(ref_epoch), m_name(std::move(name)), + : m_ref_epoch(ref_epoch), m_pos_vel_0(pos_vel), m_name(std::move(name)), m_mu_central_body(mu_central_body), m_mu_self(added_params[0]), - m_radius(added_params[1]), m_ellipse(), m_safe_radius(added_params[2]), - m_pos_vel_0(pos_vel) { + m_radius(added_params[1]), m_safe_radius(added_params[2]), m_ellipse() { double R = std::sqrt(pos_vel[0][0] * pos_vel[0][0] + pos_vel[0][1] * pos_vel[0][1] + pos_vel[0][2] * pos_vel[0][2]); @@ -45,10 +44,9 @@ keplerian::keplerian(const epoch &ref_epoch, keplerian::keplerian(const epoch &ref_epoch, const std::array &par, double mu_central_body, std::string name, std::array added_params) - : m_ref_epoch(ref_epoch), m_name(std::move(name)), + : m_ref_epoch(ref_epoch), m_pos_vel_0(), m_name(std::move(name)), m_mu_central_body(mu_central_body), m_mu_self(added_params[0]), - m_radius(added_params[1]), m_ellipse(), m_safe_radius(added_params[2]), - m_pos_vel_0() { + m_radius(added_params[1]), m_safe_radius(added_params[2]), m_ellipse() { if (par[0] * (1 - par[1]) <= 0) { throw std::domain_error( diff --git a/test/ic2eq2ic_test.cpp b/test/ic2eq2ic_test.cpp index 81006d2b..822f9070 100644 --- a/test/ic2eq2ic_test.cpp +++ b/test/ic2eq2ic_test.cpp @@ -30,7 +30,7 @@ constexpr double pi{boost::math::constants::pi()}; TEST_CASE("ic2eq") { // Zero inclination and eccentricity { - auto par = ic2eq({1.0, 0.0, 0.0, 0.0, 1.0, 0.0}, 1.0); + auto par = ic2eq({{{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}}}, 1.0); REQUIRE(par[0] == 1.); // p is 1 REQUIRE(par[1] == 0.); // f is zero REQUIRE(par[2] == 0.); // g is zero @@ -40,7 +40,7 @@ TEST_CASE("ic2eq") { } // Orbit at 90 degrees inclination { - auto par = ic2eq({1.0, 0.0, 0.0, 0.0, 0.0, 1.1}, 1.0); + auto par = ic2eq({{{1.0, 0.0, 0.0}, {0.0, 0.0, 1.1}}}, 1.0); REQUIRE_THAT(par[0], WithinRel(1.2658227848101269 * (1. - 0.21 * 0.21), 1e-14)); REQUIRE_THAT(par[1], WithinRel(0.21, 1e-14)); @@ -51,7 +51,7 @@ TEST_CASE("ic2eq") { } // Orbit at 90 degrees inclination { - auto par = ic2eq({1.0, 0.0, 0.0, 0.0, 0.0, -1.1}, 1.0); + auto par = ic2eq({{{1.0, 0.0, 0.0}, {0.0, 0.0, -1.1}}}, 1.0); REQUIRE_THAT(par[0], WithinRel(1.2658227848101269 * (1. - 0.21 * 0.21), 1e-14)); REQUIRE_THAT(par[1], WithinRel(0.21, 1e-14)); diff --git a/test/ic2par2ic_test.cpp b/test/ic2par2ic_test.cpp index 21b07930..9f60f218 100644 --- a/test/ic2par2ic_test.cpp +++ b/test/ic2par2ic_test.cpp @@ -29,7 +29,7 @@ constexpr double pi{boost::math::constants::pi()}; TEST_CASE("ic2par") { // Singular orbit zero inclination and eccentricity { - auto par = ic2par({1.0, 0.0, 0.0, 0.0, 1.0, 0.0}, 1.0); + auto par = ic2par({{{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}}}, 1.0); REQUIRE(par[0] == 1.); // sma is 1 REQUIRE(par[1] == 0.); // ecc is zero REQUIRE(par[2] == 0.); // incl is zero @@ -39,7 +39,7 @@ TEST_CASE("ic2par") { } // Orbit at 90 degrees inclination { - auto par = ic2par({1.0, 0.0, 0.0, 0.0, 0.0, 1.1}, 1.0); + auto par = ic2par({{{1.0, 0.0, 0.0}, {0.0, 0.0, 1.1}}}, 1.0); REQUIRE_THAT(par[0], WithinRel(1.2658227848101269, 1e-13)); REQUIRE_THAT(par[1], WithinRel(0.21, 1e-13)); REQUIRE_THAT(par[2], WithinRel(pi / 2, 1e-13)); // incl at 90 degrees @@ -49,7 +49,7 @@ TEST_CASE("ic2par") { } // Orbit at 90 degrees inclination { - auto par = ic2par({1.0, 0.0, 0.0, 0.0, 0.0, -1.1}, 1.0); + auto par = ic2par({{{1.0, 0.0, 0.0}, {0.0, 0.0, -1.1}}}, 1.0); REQUIRE_THAT(par[0], WithinRel(1.2658227848101269, 1e-13)); REQUIRE_THAT(par[1], WithinRel(0.21, 1e-13)); REQUIRE_THAT(par[2], WithinRel(pi / 2, 1e-13)); // incl at 90 degrees @@ -59,7 +59,7 @@ TEST_CASE("ic2par") { } // Retrogade orbit { - auto par = ic2par({1.0, 0.0, 0.0, 0.0, -1.0, 0.1}, 1.0); + auto par = ic2par({{{1.0, 0.0, 0.0}, {0.0, -1.0, 0.1}}}, 1.0); REQUIRE_THAT(par[0], WithinRel(1.01010101010101, 1e-13)); REQUIRE_THAT(par[1], WithinRel(0.01, 1e-13)); REQUIRE_THAT(par[2], WithinRel(174.289406862500 / 180.0 * pi, @@ -70,8 +70,8 @@ TEST_CASE("ic2par") { } // A random orbit { - auto par = ic2par({-1.1823467354129, 0.0247369349235, -0.014848484784, - 0.00232349642367, 1.1225625625625, -0.34678634567}, + auto par = ic2par({{{-1.1823467354129, 0.0247369349235, -0.014848484784}, + {0.00232349642367, 1.1225625625625, -0.34678634567}}}, 1.0); REQUIRE_THAT(par[0], WithinRel(3.21921322281178, 1e-13)); REQUIRE_THAT(par[1], WithinAbs(0.63283595179672, 1e-13)); diff --git a/test/propagate_lagrangian_test.cpp b/test/propagate_lagrangian_test.cpp index de0c8db2..40dd481c 100644 --- a/test/propagate_lagrangian_test.cpp +++ b/test/propagate_lagrangian_test.cpp @@ -32,7 +32,8 @@ void test_propagate_lagrangian( double)> &propagate, unsigned int N = 10000) { { // Elliptical circular motion xy - std::array, 2> pos_vel = {1., 0, 0., 0., 1., 0.}; + std::array, 2> pos_vel = { + {{1., 0, 0.}, {0., 1., 0.}}}; propagate(pos_vel, pi / 2., 1.); auto &[pos, vel] = pos_vel; @@ -44,7 +45,8 @@ void test_propagate_lagrangian( REQUIRE_THAT(vel[2], WithinAbs(0., 1e-14)); } { // Elliptical circular motion xy - std::array, 2> pos_vel = {1., 0, 0., 0., 1., 0.}; + std::array, 2> pos_vel = { + {{1., 0, 0.}, {0., 1., 0.}}}; propagate(pos_vel, -pi / 2., 1.); auto &[pos, vel] = pos_vel; @@ -56,7 +58,8 @@ void test_propagate_lagrangian( REQUIRE_THAT(vel[2], WithinAbs(0., 1e-14)); } { // Elliptical circular motion xz - std::array, 2> pos_vel = {1., 0, 0., 0., 0., 1.}; + std::array, 2> pos_vel = { + {{1., 0, 0.}, {0., 0., 1.}}}; propagate(pos_vel, pi / 2., 1.); auto &[pos, vel] = pos_vel; @@ -68,7 +71,8 @@ void test_propagate_lagrangian( REQUIRE_THAT(vel[2], WithinAbs(0., 1e-14)); } { // Elliptical circular motion yz - std::array, 2> pos_vel = {0., 1, 0., 0., 0., 1.}; + std::array, 2> pos_vel = { + {{0., 1, 0.}, {0., 0., 1.}}}; propagate(pos_vel, pi / 2., 1.); auto &[pos, vel] = pos_vel; @@ -182,16 +186,16 @@ TEST_CASE("propagate_lagrangian") { TEST_CASE("infinite loop") { std::array, 2> pos_vel = { - 3.2479950146598147, 4.866100102242875, 0.8564969484971678, - 0.3140399734911721, 0.5042257639093218, 0.09475180867356801}; + {{3.2479950146598147, 4.866100102242875, 0.8564969484971678}, + {0.3140399734911721, 0.5042257639093218, 0.09475180867356801}}}; double tof = 6.023574175415248; kep3::propagate_lagrangian(pos_vel, -tof, 1.); } TEST_CASE("extreme_orbit") { std::array, 2> pos_vel = { - 0.8086322075411211, -1.3297145067523164, -2.4969299661382585, - -0.02869546877795607, 0.05765808202641542, -0.03999826575867087}; + {{0.8086322075411211, -1.3297145067523164, -2.4969299661382585}, + {-0.02869546877795607, 0.05765808202641542, -0.03999826575867087}}}; double tof = 4.454030166101634; kep3::propagate_lagrangian_u(pos_vel, tof, 1.); } \ No newline at end of file