You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

52 lines
1.5 KiB

#include <catch2/catch.hpp>
#include "dumbLog.h"
#include "../src/orbits.cpp"
// NOTE: using WithinAbs instead of Approx because:
// https://github.com/catchorg/Catch2/issues/1962
// https://github.com/catchorg/Catch2/issues/1507
using Catch::Matchers::WithinAbs;
// NOTE: example 4.6 in "Space Flight Dynamics" by Craig A. Kluever
TEST_CASE("orbit propagation", "[orbits]")
{
orbital_elements orbit = {};
ellipse_parameters ep = {};
ep.a = 26564.5; // meters
ep.e = 0.7411;
orbit.ep = ep;
// NOTE: solve for gravitational parameter from mean motion
double mean_motion = 0.00014582; // rad/s
orbit.mu = pow(mean_motion, 2) * pow(ep.a, 3);
double initial_anom = 260 * M_PI / 180; // radians
unsigned int time_step = 60 * 50; // seconds
double E1 = getEccAnomFromTrueAnom(ep.e, initial_anom);
REQUIRE_THAT(E1, WithinAbs(-0.8615, 1e-4));
double M1 = getMeanAnomFromEccAnom(E1, ep.e);
REQUIRE_THAT(M1, WithinAbs(-0.2992, 1e-4));
double n = getMeanMotion(orbit.mu, orbit.ep.a);
REQUIRE_THAT(n, WithinAbs(0.00014582, 1e-8));
double M2 = getPropagatedMeanAnom(M1, n, time_step);
REQUIRE_THAT(M2, WithinAbs(0.1383, 1e-5));
// TODO: could also test for the other trial values listed in table 4.1
double E2_1 = getInitialTrialValue(M2, ep.e);
REQUIRE_THAT(E2_1, WithinAbs(0.315452, 1e-5));
double ecc_anom = getPropagatedEccAnomaly(orbit, initial_anom, time_step);
REQUIRE_THAT(ecc_anom, WithinAbs(0.481518, 1e-5));
double true_anom = getPropagatedTrueAnomaly(orbit, initial_anom, time_step);
REQUIRE_THAT(true_anom, WithinAbs(1.1339, 1e-4));
}