Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3c84cf6a8e29
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c0880ea1e4de
Choose a head ref
  • 6 commits
  • 4 files changed
  • 1 contributor

Commits on Jan 13, 2019

  1. Reset the status in the integrators when trying a new step. Propagate…

    … any error found during integration of the pile-up.
    pleroy committed Jan 13, 2019
    Copy the full SHA
    23998e2 View commit details
  2. Log a warning.

    pleroy committed Jan 13, 2019
    Copy the full SHA
    004dba7 View commit details
  3. Proper status update.

    pleroy committed Jan 13, 2019
    Copy the full SHA
    72725bd View commit details
  4. After egg's review.

    pleroy committed Jan 13, 2019
    Copy the full SHA
    f200464 View commit details
  5. Goto considered annoying.

    pleroy committed Jan 13, 2019
    Copy the full SHA
    de624b0 View commit details

Commits on Jan 14, 2019

  1. Merge pull request #2064 from pleroy/2056

    Propagate errors found during integration to kill the vessel
    pleroy authored Jan 14, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c0880ea View commit details
Original file line number Diff line number Diff line change
@@ -128,6 +128,7 @@ Status EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<
std::int64_t step_count = 0;

Status status;
Status step_status;

// No step size control on the first step. If this instance is being
// restarted we already have a value of |h| suitable for the next step, based
@@ -139,6 +140,10 @@ Status EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<
// Compute the next step with decreasing step sizes until the error is
// tolerable.
do {
// Reset the status as any error returned by a force computation for a
// rejected step is now moot.
step_status = Status::OK;

// Adapt step size.
// TODO(egg): find out whether there's a smarter way to compute that root,
// especially since we make the order compile-time.
@@ -188,7 +193,7 @@ Status EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<
q_stage[k] = q̂[k].value + h * c[i] * v̂[k].value + h² * Σj_a_ij_g_jk;
v_stage[k] = v̂[k].value + h * Σj_aʹ_ij_g_jk;
}
status.Update(
step_status.Update(
equation.compute_acceleration(t_stage, q_stage, v_stage, g[i]));
}

@@ -219,6 +224,8 @@ Status EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<
this->tolerance_to_error_ratio_(h, error_estimate);
} while (tolerance_to_error_ratio < 1.0);

status.Update(step_status);

if (!parameters.last_step_is_exact && t.value + (t.error + h) > t_final) {
// We did overshoot. Drop the point that we just computed and exit.
final_state = current_state;
Original file line number Diff line number Diff line change
@@ -125,6 +125,7 @@ Instance::Solve(Instant const& t_final) {
std::int64_t step_count = 0;

Status status;
Status step_status;

// No step size control on the first step. If this instance is being
// restarted we already have a value of |h| suitable for the next step, based
@@ -136,6 +137,10 @@ Instance::Solve(Instant const& t_final) {
// Compute the next step with decreasing step sizes until the error is
// tolerable.
do {
// Reset the status as any error returned by a force computation for a
// rejected step is now moot.
step_status = Status::OK;

// Adapt step size.
// TODO(egg): find out whether there's a smarter way to compute that root,
// especially since we make the order compile-time.
@@ -182,7 +187,8 @@ Instance::Solve(Instant const& t_final) {
}
q_stage[k] = q̂[k].value + h * c[i] * v̂[k].value + h² * Σj_a_ij_g_jk;
}
status.Update(equation.compute_acceleration(t_stage, q_stage, g[i]));
step_status.Update(
equation.compute_acceleration(t_stage, q_stage, g[i]));
}

// Increment computation and step size control.
@@ -212,6 +218,8 @@ Instance::Solve(Instant const& t_final) {
this->tolerance_to_error_ratio_(h, error_estimate);
} while (tolerance_to_error_ratio < 1.0);

status.Update(step_status);

if (!parameters.last_step_is_exact && t.value + (t.error + h) > t_final) {
// We did overshoot. Drop the point that we just computed and exit.
final_state = current_state;
19 changes: 10 additions & 9 deletions ksp_plugin/pile_up.cpp
Original file line number Diff line number Diff line change
@@ -340,13 +340,14 @@ Status PileUp::AdvanceTime(Instant const& t) {
// TODO(phl): Consider not setting |last_point_only| below as we would be
// fine with multiple points in the |psychohistory_| once all the classes
// have been changed.
CHECK_OK(ephemeris_->FlowWithAdaptiveStep(
psychohistory_,
Ephemeris<Barycentric>::NoIntrinsicAcceleration,
t,
adaptive_step_parameters_,
Ephemeris<Barycentric>::unlimited_max_ephemeris_steps,
/*last_point_only=*/true));
status.Update(
ephemeris_->FlowWithAdaptiveStep(
psychohistory_,
Ephemeris<Barycentric>::NoIntrinsicAcceleration,
t,
adaptive_step_parameters_,
Ephemeris<Barycentric>::unlimited_max_ephemeris_steps,
/*last_point_only=*/true));
}
} else {
// Destroy the fixed instance, it wouldn't be correct to use it the next
@@ -369,13 +370,13 @@ Status PileUp::AdvanceTime(Instant const& t) {
// aligns the function object on an 8-byte boundary, resulting in an
// addressing fault. With a reference, VS2015 knows what to do.
auto const intrinsic_acceleration = [&a](Instant const& t) { return a; };
CHECK_OK(ephemeris_->FlowWithAdaptiveStep(
status = ephemeris_->FlowWithAdaptiveStep(
history_.get(),
intrinsic_acceleration,
t,
adaptive_step_parameters_,
Ephemeris<Barycentric>::unlimited_max_ephemeris_steps,
/*last_point_only=*/false));
/*last_point_only=*/false);
psychohistory_ = history_->NewForkAtLast();
}

9 changes: 5 additions & 4 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -756,7 +756,7 @@ not_null<std::unique_ptr<PileUpFuture>> Plugin::CatchUpVessel(
// caller is catching-up two vessels belonging to the same pile-up in
// parallel.
Status const status = pile_up->DeformAndAdvanceTime(current_time_);
if (status.error() == Error::OUT_OF_RANGE) {
if (!status.ok()) {
vessel.DisableDownsampling();
}
vessel.AdvanceTime();
@@ -769,13 +769,14 @@ void Plugin::WaitForVesselToCatchUp(PileUpFuture& pile_up_future,
PileUp const* const pile_up = pile_up_future.pile_up;
auto& future = pile_up_future.future;
future.wait();
if (future.get().error() == Error::OUT_OF_RANGE) {
Status const status = future.get();
if (!status.ok()) {
for (not_null<Part*> const part : pile_up->parts()) {
not_null<Vessel*> const vessel =
FindOrDie(part_id_to_vessel_, part->part_id());
if (collided_vessels.insert(vessel).second) {
LOG(INFO) << "Vessel " << vessel->ShortDebugString()
<< " collided with a celestial";
LOG(WARNING) << "Vessel " << vessel->ShortDebugString()
<< " collided with a celestial: " << status.ToString();
}
}
}