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

Faster build #650

Merged
merged 3 commits into from
Sep 12, 2015
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
10 changes: 9 additions & 1 deletion integrators/simple_harmonic_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ TEST_P(SimpleHarmonicMotionTest, Error) {
parameters_.initial.momenta.emplace_back(Speed());
parameters_.initial.time = Time();
#ifdef _DEBUG
parameters_.tmax = 100.0 * SIUnit<Time>();
parameters_.tmax = 10.0 * SIUnit<Time>();
#else
parameters_.tmax = 1000.0 * SIUnit<Time>();
#endif
Expand Down Expand Up @@ -269,7 +269,11 @@ TEST_P(SimpleHarmonicMotionTest, Convergence) {
parameters_.initial.positions.emplace_back(SIUnit<Length>());
parameters_.initial.momenta.emplace_back(Speed());
parameters_.initial.time = Time();
#if defined(_DEBUG)
parameters_.tmax = 1 * SIUnit<Time>();
#else
parameters_.tmax = 100 * SIUnit<Time>();
#endif
parameters_.sampling_period = 0;
parameters_.Δt = GetParam().beginning_of_convergence;
int const step_sizes = 50;
Expand Down Expand Up @@ -312,9 +316,11 @@ TEST_P(SimpleHarmonicMotionTest, Convergence) {
LOG(INFO) << "Convergence data for q :\n" <<
BidimensionalDatasetMathematicaInput(log_step_sizes, log_q_errors);
#endif
#if !defined(_DEBUG)
EXPECT_THAT(RelativeError(GetParam().convergence_order, q_convergence_order),
Lt(0.02));
EXPECT_THAT(q_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
double const v_convergence_order = Slope(log_step_sizes, log_p_errors);
double const v_correlation =
PearsonProductMomentCorrelationCoefficient(log_step_sizes, log_p_errors);
Expand All @@ -324,12 +330,14 @@ TEST_P(SimpleHarmonicMotionTest, Convergence) {
LOG(INFO) << "Convergence data for p :\n" <<
BidimensionalDatasetMathematicaInput(log_step_sizes, log_q_errors);
#endif
#if !defined(_DEBUG)
// SPRKs with odd convergence order have a higher convergence order in p.
EXPECT_THAT(
RelativeError(((GetParam().convergence_order + 1) / 2) * 2,
v_convergence_order),
Lt(0.02));
EXPECT_THAT(v_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
}

TEST_P(SimpleHarmonicMotionTest, Symplecticity) {
Expand Down
14 changes: 14 additions & 0 deletions integrators/symplectic_runge_kutta_nyström_integrator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ void Test1000SecondsAt1Millisecond(
AngularFrequency const ω = 1 * Radian / Second;
Time const period = 2 * π * Second;
Instant const t_initial;
#if defined(_DEBUG)
Instant const t_final = t_initial + 1 * Second;
#else
Instant const t_final = t_initial + 1000 * Second;
#endif
Time const step = 1 * Milli(Second);
int const steps = static_cast<int>((t_final - t_initial) / step) - 1;

Expand Down Expand Up @@ -190,8 +194,10 @@ void Test1000SecondsAt1Millisecond(
q_error = std::max(q_error, AbsoluteError(q_initial * Cos(ω * t), q));
v_error = std::max(v_error, AbsoluteError(-v_amplitude * Sin(ω * t), v));
}
#if !defined(_DEBUG)
EXPECT_EQ(expected_position_error, q_error);
EXPECT_EQ(expected_velocity_error, v_error);
#endif
}

// Integrates with diminishing step sizes, and checks the order of convergence.
Expand All @@ -204,7 +210,11 @@ void TestConvergence(Integrator const& integrator,
AngularFrequency const ω = 1 * Radian / Second;
Time const period = 2 * π * Second;
Instant const t_initial;
#if defined(_DEBUG)
Instant const t_final = t_initial + 10 * Second;
#else
Instant const t_final = t_initial + 100 * Second;
#endif

Time step = beginning_of_convergence;
int const step_sizes = 50;
Expand Down Expand Up @@ -255,20 +265,24 @@ void TestConvergence(Integrator const& integrator,
LOG(INFO) << "Convergence order in q : " << q_convergence_order;
LOG(INFO) << "Correlation : " << q_correlation;

#if !defined(_DEBUG)
EXPECT_THAT(RelativeError(integrator.order, q_convergence_order),
Lt(0.02));
EXPECT_THAT(q_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
double const v_convergence_order = Slope(log_step_sizes, log_p_errors);
double const v_correlation =
PearsonProductMomentCorrelationCoefficient(log_step_sizes, log_p_errors);
LOG(INFO) << "Convergence order in p : " << v_convergence_order;
LOG(INFO) << "Correlation : " << v_correlation;
#if !defined(_DEBUG)
// SPRKs with odd convergence order have a higher convergence order in p.
EXPECT_THAT(
RelativeError(integrator.order + (integrator.order % 2),
v_convergence_order),
Lt(0.02));
EXPECT_THAT(v_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
}

// Test that the error in energy does not correlate with the number of steps
Expand Down
25 changes: 12 additions & 13 deletions ksp_plugin_test/plugin_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ class PluginIntegrationTest : public testing::Test {
TEST_F(PluginIntegrationTest, AdvanceTimeWithCelestialsOnly) {
InsertAllSolarSystemBodies();
plugin_->EndInitialization();
#if defined(_DEBUG)
Time const δt = 2 * Second;
#else
Time const δt = 0.02 * Second;
#endif
Angle const planetarium_rotation = 42 * Radian;
// We step for long enough that we will find a new segment.
Instant t = initial_time_;
Expand Down Expand Up @@ -165,8 +169,11 @@ TEST_F(PluginIntegrationTest, BodyCentredNonrotatingRenderingIntegration) {
Permutation<AliceSun, World> const alice_sun_to_world =
Permutation<AliceSun, World>(Permutation<AliceSun, World>::XZY);
Time const δt_long = 10 * Minute;
#if !defined(_DEBUG)
#if defined(_DEBUG)
Time const δt_short = 1 * Minute;
#else
Time const δt_short = 0.02 * Second;
#endif
Instant t = initial_time_ + δt_short;
// Exercise #267 by having small time steps at the beginning of the trajectory
// that are not synchronized with those of the Earth.
Expand All @@ -176,12 +183,6 @@ TEST_F(PluginIntegrationTest, BodyCentredNonrotatingRenderingIntegration) {
1 * Radian / Pow<2>(Minute) * Pow<2>(t - initial_time_));
plugin_->InsertOrKeepVessel(satellite, SolarSystem::kEarth);
}
#else
Instant t = initial_time_ + δt_long;
plugin_->AdvanceTime(t, 0 * Radian); // This ensures the history is nonempty.
plugin_->InsertOrKeepVessel(satellite, SolarSystem::kEarth);
t += δt_long;
#endif
for (; t < initial_time_ + 12 * Hour; t += δt_long) {
plugin_->AdvanceTime(
t,
Expand Down Expand Up @@ -246,11 +247,12 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingRenderingIntegration) {
Permutation<AliceSun, World>(Permutation<AliceSun, World>::XZY);
Time const δt_long = 1 * Hour;
#if defined(_DEBUG)
Time const duration = 1 * Day;
Instant t = initial_time_ + δt_long;
Time const duration = 12 * Hour;
Time const δt_short = 20 * Second;
#else
Time const δt_short = 0.02 * Second;
Time const duration = 20 * Day;
Time const δt_short = 0.02 * Second;
#endif
Instant t = initial_time_ + δt_short;
// Exercise #267 by having small time steps at the beginning of the trajectory
// that are not synchronized with those of the Earth and Moon.
Expand All @@ -260,7 +262,6 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingRenderingIntegration) {
1 * Radian / Pow<2>(Minute) * Pow<2>(t - initial_time_));
plugin_->InsertOrKeepVessel(satellite, SolarSystem::kEarth);
}
#endif
for (; t < initial_time_ + duration; t += δt_long) {
plugin_->AdvanceTime(
t,
Expand Down Expand Up @@ -302,7 +303,6 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingRenderingIntegration) {
EXPECT_THAT(rendered_trajectory[i].end,
Eq(rendered_trajectory[i + 1].begin));
}
#if !defined(_DEBUG)
// Check that there are no spikes in the rendered trajectory, i.e., that three
// consecutive points form a sufficiently flat triangle. This tests issue
// #256.
Expand All @@ -314,7 +314,6 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingRenderingIntegration) {
(rendered_trajectory[i].end -
rendered_trajectory[i + 1].end).Norm()) / 1.5)) << i;
}
#endif
}

// The Enterprise D is a low orbit around a massive body with unit gravitational
Expand Down