Skip to content

Commit

Permalink
osx debug warning fix
Browse files Browse the repository at this point in the history
  • Loading branch information
darioizzo committed Sep 20, 2023
1 parent 7b6ca6e commit d45eaee
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
1 change: 0 additions & 1 deletion benchmark/convert_anomalies_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions benchmark/propagate_lagrangian_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions src/planets/keplerian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ keplerian::keplerian(const epoch &ref_epoch,
const std::array<std::array<double, 3>, 2> &pos_vel,
double mu_central_body, std::string name,
std::array<double, 3> 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]);
Expand All @@ -45,10 +44,9 @@ keplerian::keplerian(const epoch &ref_epoch,
keplerian::keplerian(const epoch &ref_epoch, const std::array<double, 6> &par,
double mu_central_body, std::string name,
std::array<double, 3> 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(
Expand Down
6 changes: 3 additions & 3 deletions test/ic2eq2ic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ constexpr double pi{boost::math::constants::pi<double>()};
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
Expand All @@ -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));
Expand All @@ -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));
Expand Down
12 changes: 6 additions & 6 deletions test/ic2par2ic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ constexpr double pi{boost::math::constants::pi<double>()};
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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));
Expand Down
20 changes: 12 additions & 8 deletions test/propagate_lagrangian_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void test_propagate_lagrangian(
double)> &propagate,
unsigned int N = 10000) {
{ // Elliptical circular motion xy
std::array<std::array<double, 3>, 2> pos_vel = {1., 0, 0., 0., 1., 0.};
std::array<std::array<double, 3>, 2> pos_vel = {
{{1., 0, 0.}, {0., 1., 0.}}};
propagate(pos_vel, pi / 2., 1.);
auto &[pos, vel] = pos_vel;

Expand All @@ -44,7 +45,8 @@ void test_propagate_lagrangian(
REQUIRE_THAT(vel[2], WithinAbs(0., 1e-14));
}
{ // Elliptical circular motion xy
std::array<std::array<double, 3>, 2> pos_vel = {1., 0, 0., 0., 1., 0.};
std::array<std::array<double, 3>, 2> pos_vel = {
{{1., 0, 0.}, {0., 1., 0.}}};
propagate(pos_vel, -pi / 2., 1.);
auto &[pos, vel] = pos_vel;

Expand All @@ -56,7 +58,8 @@ void test_propagate_lagrangian(
REQUIRE_THAT(vel[2], WithinAbs(0., 1e-14));
}
{ // Elliptical circular motion xz
std::array<std::array<double, 3>, 2> pos_vel = {1., 0, 0., 0., 0., 1.};
std::array<std::array<double, 3>, 2> pos_vel = {
{{1., 0, 0.}, {0., 0., 1.}}};
propagate(pos_vel, pi / 2., 1.);
auto &[pos, vel] = pos_vel;

Expand All @@ -68,7 +71,8 @@ void test_propagate_lagrangian(
REQUIRE_THAT(vel[2], WithinAbs(0., 1e-14));
}
{ // Elliptical circular motion yz
std::array<std::array<double, 3>, 2> pos_vel = {0., 1, 0., 0., 0., 1.};
std::array<std::array<double, 3>, 2> pos_vel = {
{{0., 1, 0.}, {0., 0., 1.}}};
propagate(pos_vel, pi / 2., 1.);
auto &[pos, vel] = pos_vel;

Expand Down Expand Up @@ -182,16 +186,16 @@ TEST_CASE("propagate_lagrangian") {

TEST_CASE("infinite loop") {
std::array<std::array<double, 3>, 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<std::array<double, 3>, 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.);
}

0 comments on commit d45eaee

Please sign in to comment.