diff --git a/tests/configs/earth_circular.txt b/tests/configs/earth_circular.txt new file mode 100644 index 0000000..4c08845 --- /dev/null +++ b/tests/configs/earth_circular.txt @@ -0,0 +1,11 @@ +# Test Configuration: Sun + Earth (circular orbit) +# Earth at 1 AU with circular orbit +# Expected orbital period: ~365 days +# +# Format: name mass(kg) radius(m) x(m) y(m) z(m) parent_index r g b eccentricity semi_major_axis(m) + +# Sun at origin (index 0) +Sun 1.989e30 6.96e8 0 0 0 -1 1.0 1.0 0.0 0 0 + +# Earth at 1 AU - circular orbit (index 1, parent Sun) +Earth 5.972e24 6.371e6 1.496e11 0 0 0 0.0 0.5 1.0 0 1.496e11 diff --git a/tests/configs/mars_circular.txt b/tests/configs/mars_circular.txt new file mode 100644 index 0000000..e09492d --- /dev/null +++ b/tests/configs/mars_circular.txt @@ -0,0 +1,11 @@ +# Test Configuration: Sun + Mars (circular orbit) +# Mars at 1.5 AU with circular orbit +# Expected orbital period: ~687 days +# +# Format: name mass(kg) radius(m) x(m) y(m) z(m) parent_index r g b eccentricity semi_major_axis(m) + +# Sun at origin (index 0) +Sun 1.989e30 6.96e8 0 0 0 -1 1.0 1.0 0.0 0 0 + +# Mars at 1.5 AU - circular orbit (index 1, parent Sun) +Mars 6.39e23 3.3895e6 2.244e11 0 0 0 0.8 0.3 0.1 0 2.244e11 diff --git a/tests/test_energy.cpp b/tests/test_energy.cpp index eea84c4..6e9b421 100644 --- a/tests/test_energy.cpp +++ b/tests/test_energy.cpp @@ -1,6 +1,7 @@ #include #include "../src/physics.h" #include "../src/bodies.h" +#include "../src/config_loader.h" #include "../src/test_utilities.h" #include @@ -11,13 +12,7 @@ TEST_CASE("Energy conservation - Earth circular orbit", "[energy][rk4]") { SimulationState* sim = create_simulation(10, TIME_STEP); - Vec3 sun_pos = {0, 0, 0}; - Vec3 sun_vel = {0, 0, 0}; - add_body(sim, "Sun", 1.989e30, 6.96e8, sun_pos, sun_vel, -1, 1.0, 1.0, 0.0, 0, 0); - - Vec3 earth_pos = {1.496e11, 0, 0}; - Vec3 earth_vel = {0, 29800, 0}; - add_body(sim, "Earth", 5.972e24, 6.371e6, earth_pos, earth_vel, 0, 0.0, 0.5, 1.0, 0, 1.496e11); + REQUIRE(load_system_config(sim, "tests/configs/earth_circular.txt")); double initial_energy = calculate_system_total_energy(sim); diff --git a/tests/test_orbital_period.cpp b/tests/test_orbital_period.cpp index 73cc91f..609c651 100644 --- a/tests/test_orbital_period.cpp +++ b/tests/test_orbital_period.cpp @@ -1,6 +1,7 @@ #include #include "../src/physics.h" #include "../src/bodies.h" +#include "../src/config_loader.h" #include "../src/test_utilities.h" #include @@ -12,13 +13,7 @@ TEST_CASE("Orbital period - Earth (RK4)", "[period][rk4]") { SimulationState* sim = create_simulation(10, TIME_STEP); - Vec3 sun_pos = {0, 0, 0}; - Vec3 sun_vel = {0, 0, 0}; - add_body(sim, "Sun", 1.989e30, 6.96e8, sun_pos, sun_vel, -1, 1.0, 1.0, 0.0, 0, 0); - - Vec3 earth_pos = {1.496e11, 0, 0}; - Vec3 earth_vel = {0, 29789, 0}; - add_body(sim, "Earth", 5.972e24, 6.371e6, earth_pos, earth_vel, 0, 0.0, 0.5, 1.0, 0, 1.496e11); + REQUIRE(load_system_config(sim, "tests/configs/earth_circular.txt")); OrbitTracker* tracker = create_orbit_tracker(1); @@ -51,13 +46,7 @@ TEST_CASE("Orbital period - Mars (RK4)", "[period][rk4]") { SimulationState* sim = create_simulation(10, TIME_STEP); - Vec3 sun_pos = {0, 0, 0}; - Vec3 sun_vel = {0, 0, 0}; - add_body(sim, "Sun", 1.989e30, 6.96e8, sun_pos, sun_vel, -1, 1.0, 1.0, 0.0, 0, 0); - - Vec3 mars_pos = {2.244e11, 0, 0}; - Vec3 mars_vel = {0, 24323, 0}; - add_body(sim, "Mars", 6.39e23, 3.3895e6, mars_pos, mars_vel, 0, 0.8, 0.3, 0.1, 0, 2.244e11); + REQUIRE(load_system_config(sim, "tests/configs/mars_circular.txt")); OrbitTracker* tracker = create_orbit_tracker(1);