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: 50c7dd848be9
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8985a9c6e406
Choose a head ref

Commits on Dec 2, 2018

  1. Factor out the flowing code.

    pleroy committed Dec 2, 2018
    Copy the full SHA
    f45423e View commit details
  2. Templatize the parameters.

    pleroy committed Dec 2, 2018
    Copy the full SHA
    d825008 View commit details
  3. Copy the full SHA
    9ce6afc View commit details
  4. Copy the full SHA
    9dd197d View commit details
  5. Copy the full SHA
    9a1652c View commit details
  6. Copy the full SHA
    84c3d81 View commit details
  7. Serialization of Fine.

    pleroy committed Dec 2, 2018
    Copy the full SHA
    515e247 View commit details
  8. Copy the full SHA
    efc3a3d View commit details
  9. One test still failing.

    pleroy committed Dec 2, 2018
    Copy the full SHA
    c384373 View commit details
  10. Copy the full SHA
    b850d35 View commit details
  11. Fix the failing test.

    pleroy committed Dec 2, 2018
    Copy the full SHA
    b7add7d View commit details

Commits on Dec 6, 2018

  1. Copy the full SHA
    caa0d1c View commit details
  2. Move out.

    pleroy committed Dec 6, 2018
    Copy the full SHA
    c4ed143 View commit details
  3. Copy the full SHA
    87d1dca View commit details
  4. Move out.

    pleroy committed Dec 6, 2018
    Copy the full SHA
    d724a36 View commit details
  5. Copy the full SHA
    87a978f View commit details

Commits on Dec 7, 2018

  1. Copy the full SHA
    524cd10 View commit details
  2. Copy the full SHA
    a14d6a3 View commit details
  3. Another compilation error.

    pleroy committed Dec 7, 2018
    Copy the full SHA
    89a0c64 View commit details
  4. Lint.

    pleroy committed Dec 7, 2018
    Copy the full SHA
    9d4632c View commit details

Commits on Dec 8, 2018

  1. Merge pull request #2013 from pleroy/1931b

     Distinguish AdaptiveStepParameters and GeneralizedAdaptiveStepParameters in name only
    pleroy authored Dec 8, 2018
    Copy the full SHA
    8985a9c View commit details
50 changes: 43 additions & 7 deletions ksp_plugin/flight_plan.cpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
#include <optional>
#include <vector>

#include "integrators/embedded_explicit_generalized_runge_kutta_nyström_integrator.hpp"
#include "integrators/embedded_explicit_runge_kutta_nyström_integrator.hpp"
#include "integrators/methods.hpp"
#include "testing_utilities/make_not_null.hpp"
@@ -16,8 +17,10 @@ using base::make_not_null_unique;
using geometry::Position;
using geometry::Vector;
using geometry::Velocity;
using integrators::EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator;
using integrators::EmbeddedExplicitRungeKuttaNyströmIntegrator;
using integrators::methods::DormandالمكاوىPrince1986RKN434FM;
using integrators::methods::Fine1987RKNG34;
using quantities::Acceleration;
using quantities::si::Metre;
using quantities::si::Second;
@@ -29,14 +32,18 @@ FlightPlan::FlightPlan(
Instant const& desired_final_time,
not_null<Ephemeris<Barycentric>*> const ephemeris,
Ephemeris<Barycentric>::AdaptiveStepParameters const&
adaptive_step_parameters)
adaptive_step_parameters,
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters const&
generalized_adaptive_step_parameters)
: initial_mass_(initial_mass),
initial_time_(initial_time),
initial_degrees_of_freedom_(initial_degrees_of_freedom),
desired_final_time_(desired_final_time),
root_(make_not_null_unique<DiscreteTrajectory<Barycentric>>()),
ephemeris_(ephemeris),
adaptive_step_parameters_(adaptive_step_parameters) {
adaptive_step_parameters_(adaptive_step_parameters),
generalized_adaptive_step_parameters_(
generalized_adaptive_step_parameters) {
CHECK(desired_final_time_ >= initial_time_);

// Set the (single) point of the root.
@@ -220,6 +227,8 @@ void FlightPlan::WriteToMessage(
desired_final_time_.WriteToMessage(message->mutable_desired_final_time());
adaptive_step_parameters_.WriteToMessage(
message->mutable_adaptive_step_parameters());
generalized_adaptive_step_parameters_.WriteToMessage(
message->mutable_generalized_adaptive_step_parameters());
for (auto const& manœuvre : manœuvres_) {
manœuvre.WriteToMessage(message->add_manoeuvre());
}
@@ -228,15 +237,34 @@ void FlightPlan::WriteToMessage(
std::unique_ptr<FlightPlan> FlightPlan::ReadFromMessage(
serialization::FlightPlan const& message,
not_null<Ephemeris<Barycentric>*> const ephemeris) {
std::unique_ptr<Ephemeris<Barycentric>::AdaptiveStepParameters>
adaptive_step_parameters;
Instant initial_time = Instant::ReadFromMessage(message.initial_time());
std::unique_ptr<DegreesOfFreedom<Barycentric>> initial_degrees_of_freedom;
CHECK(message.has_adaptive_step_parameters());
adaptive_step_parameters =
auto const adaptive_step_parameters =
std::make_unique<Ephemeris<Barycentric>::AdaptiveStepParameters>(
Ephemeris<Barycentric>::AdaptiveStepParameters::ReadFromMessage(
message.adaptive_step_parameters()));

bool const is_pre_εὔδοξος =
!message.has_generalized_adaptive_step_parameters();
std::unique_ptr<Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters>
generalized_adaptive_step_parameters;
if (is_pre_εὔδοξος) {
generalized_adaptive_step_parameters = std::make_unique<
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters>(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
/*max_steps=*/1,
/*length_integration_tolerance=*/1 * Metre,
/*speed_integration_tolerance=*/1 * Metre / Second);
} else {
generalized_adaptive_step_parameters = std::make_unique<
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters>(
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters::
ReadFromMessage(message.generalized_adaptive_step_parameters()));
}

initial_degrees_of_freedom =
std::make_unique<DegreesOfFreedom<Barycentric>>(
DegreesOfFreedom<Barycentric>::ReadFromMessage(
@@ -248,7 +276,8 @@ std::unique_ptr<FlightPlan> FlightPlan::ReadFromMessage(
*initial_degrees_of_freedom,
Instant::ReadFromMessage(message.desired_final_time()),
ephemeris,
*adaptive_step_parameters);
*adaptive_step_parameters,
*generalized_adaptive_step_parameters);

for (int i = 0; i < message.manoeuvre_size(); ++i) {
auto const& manoeuvre = message.manoeuvre(i);
@@ -268,6 +297,13 @@ FlightPlan::FlightPlan()
root_(make_not_null_unique<DiscreteTrajectory<Barycentric>>()),
ephemeris_(testing_utilities::make_not_null<Ephemeris<Barycentric>*>()),
adaptive_step_parameters_(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
/*max_steps=*/1,
/*length_integration_tolerance=*/1 * Metre,
/*speed_integration_tolerance=*/1 * Metre / Second),
generalized_adaptive_step_parameters_(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
@@ -329,7 +365,7 @@ void FlightPlan::BurnLastSegment(NavigationManœuvre const& manœuvre) {
segments_.back(),
manœuvre.FrenetIntrinsicAcceleration(),
manœuvre.final_time(),
adaptive_step_parameters_,
generalized_adaptive_step_parameters_,
max_ephemeris_steps_per_frame,
/*last_point_only=*/false).ok();
if (!reached_desired_final_time) {
6 changes: 5 additions & 1 deletion ksp_plugin/flight_plan.hpp
Original file line number Diff line number Diff line change
@@ -44,7 +44,9 @@ class FlightPlan {
Instant const& desired_final_time,
not_null<Ephemeris<Barycentric>*> ephemeris,
Ephemeris<Barycentric>::AdaptiveStepParameters const&
adaptive_step_parameters);
adaptive_step_parameters,
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters const&
generalized_adaptive_step_parameters);
virtual ~FlightPlan() = default;

virtual Instant initial_time() const;
@@ -172,6 +174,8 @@ class FlightPlan {
std::vector<NavigationManœuvre> manœuvres_;
not_null<Ephemeris<Barycentric>*> ephemeris_;
Ephemeris<Barycentric>::AdaptiveStepParameters adaptive_step_parameters_;
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters
generalized_adaptive_step_parameters_;
// The last |anomalous_segments_| of |segments_| are anomalous, i.e. they
// either end prematurely or follow an anomalous segment; in the latter case
// they are empty.
14 changes: 14 additions & 0 deletions ksp_plugin/integrators.cpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
#include <limits>

#include "geometry/named_quantities.hpp"
#include "integrators/embedded_explicit_generalized_runge_kutta_nyström_integrator.hpp"
#include "integrators/embedded_explicit_runge_kutta_nyström_integrator.hpp"
#include "integrators/methods.hpp"
#include "integrators/symmetric_linear_multistep_integrator.hpp"
@@ -14,10 +15,12 @@ namespace ksp_plugin {
namespace internal_integrators {

using geometry::Position;
using integrators::EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator;
using integrators::EmbeddedExplicitRungeKuttaNyströmIntegrator;
using integrators::SymmetricLinearMultistepIntegrator;
using integrators::SymplecticRungeKuttaNyströmIntegrator;
using integrators::methods::BlanesMoan2002SRKN14A;
using integrators::methods::Fine1987RKNG34;
using integrators::methods::DormandالمكاوىPrince1986RKN434FM;
using integrators::methods::Quinlan1999Order8A;
using quantities::si::Minute;
@@ -38,6 +41,17 @@ DefaultEphemerisFixedStepParameters() {
/*step=*/35 * Minute);
}

Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters
DefaultBurnParameters() {
return Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
/*max_steps=*/1000,
/*length_integration_tolerance=*/1 * Metre,
/*speed_integration_tolerance=*/1 * Metre / Second);
}

Ephemeris<Barycentric>::FixedStepParameters DefaultHistoryParameters() {
return Ephemeris<Barycentric>::FixedStepParameters(
SymmetricLinearMultistepIntegrator<Quinlan1999Order8A,
3 changes: 3 additions & 0 deletions ksp_plugin/integrators.hpp
Original file line number Diff line number Diff line change
@@ -19,12 +19,15 @@ Ephemeris<Barycentric>::AccuracyParameters
DefaultEphemerisAccuracyParameters();
Ephemeris<Barycentric>::FixedStepParameters
DefaultEphemerisFixedStepParameters();
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters
DefaultBurnParameters();
Ephemeris<Barycentric>::FixedStepParameters DefaultHistoryParameters();
Ephemeris<Barycentric>::AdaptiveStepParameters DefaultPredictionParameters();
Ephemeris<Barycentric>::AdaptiveStepParameters DefaultPsychohistoryParameters();

} // namespace internal_integrators

using internal_integrators::DefaultBurnParameters;
using internal_integrators::DefaultEphemerisAccuracyParameters;
using internal_integrators::DefaultEphemerisFixedStepParameters;
using internal_integrators::DefaultHistoryParameters;
5 changes: 4 additions & 1 deletion ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -850,10 +850,13 @@ void Plugin::CreateFlightPlan(GUID const& vessel_guid,
Instant const& final_time,
Mass const& initial_mass) const {
CHECK(!initializing_);
// TODO(phl): Serialize the burn parameters. We should also probably
// distinguish the coast parameters from the prediction parameters.
FindOrDie(vessels_, vessel_guid)->CreateFlightPlan(
final_time,
initial_mass,
prediction_parameters_);
prediction_parameters_,
DefaultBurnParameters());
}

void Plugin::ComputeAndRenderApsides(
7 changes: 5 additions & 2 deletions ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
@@ -222,15 +222,18 @@ void Vessel::CreateFlightPlan(
Instant const& final_time,
Mass const& initial_mass,
Ephemeris<Barycentric>::AdaptiveStepParameters const&
flight_plan_adaptive_step_parameters) {
flight_plan_adaptive_step_parameters,
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters const&
flight_plan_generalized_adaptive_step_parameters) {
auto const history_last = history_->last();
flight_plan_ = std::make_unique<FlightPlan>(
initial_mass,
/*initial_time=*/history_last.time(),
/*initial_degrees_of_freedom=*/history_last.degrees_of_freedom(),
final_time,
ephemeris_,
flight_plan_adaptive_step_parameters);
flight_plan_adaptive_step_parameters,
flight_plan_generalized_adaptive_step_parameters);
}

void Vessel::DeleteFlightPlan() {
4 changes: 3 additions & 1 deletion ksp_plugin/vessel.hpp
Original file line number Diff line number Diff line change
@@ -137,7 +137,9 @@ class Vessel {
Instant const& final_time,
Mass const& initial_mass,
Ephemeris<Barycentric>::AdaptiveStepParameters const&
flight_plan_adaptive_step_parameters);
flight_plan_adaptive_step_parameters,
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters const&
flight_plan_generalized_adaptive_step_parameters);

// Deletes the |flight_plan_|. Performs no action unless |has_flight_plan()|.
virtual void DeleteFlightPlan();
23 changes: 20 additions & 3 deletions ksp_plugin_test/flight_plan_test.cpp
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "integrators/embedded_explicit_generalized_runge_kutta_nyström_integrator.hpp"
#include "integrators/embedded_explicit_runge_kutta_nyström_integrator.hpp"
#include "integrators/methods.hpp"
#include "integrators/symmetric_linear_multistep_integrator.hpp"
@@ -26,9 +27,11 @@ using geometry::Barycentre;
using geometry::Displacement;
using geometry::Position;
using geometry::Velocity;
using integrators::EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator;
using integrators::EmbeddedExplicitRungeKuttaNyströmIntegrator;
using integrators::SymmetricLinearMultistepIntegrator;
using integrators::methods::DormandالمكاوىPrince1986RKN434FM;
using integrators::methods::Fine1987RKNG34;
using integrators::methods::QuinlanTremaine1990Order12;
using physics::BodyCentredNonRotatingDynamicFrame;
using physics::DegreesOfFreedom;
@@ -96,7 +99,14 @@ class FlightPlanTest : public testing::Test {
/*final_time=*/t0_ + 1.5 * Second,
ephemeris_.get(),
Ephemeris<Barycentric>::AdaptiveStepParameters(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
/*max_steps=*/1000,
/*length_integration_tolerance=*/1 * Milli(Metre),
/*speed_integration_tolerance=*/1 * Milli(Metre) / Second),
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
/*max_steps=*/1000,
@@ -176,12 +186,19 @@ TEST_F(FlightPlanTest, Singular) {
/*final_time=*/singularity + 100 * Second,
ephemeris_.get(),
Ephemeris<Barycentric>::AdaptiveStepParameters(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
/*max_steps=*/1000,
/*length_integration_tolerance=*/1 * Milli(Metre),
/*speed_integration_tolerance=*/1 * Milli(Metre) / Second));
/*speed_integration_tolerance=*/1 * Milli(Metre) / Second),
Ephemeris<Barycentric>::GeneralizedAdaptiveStepParameters(
EmbeddedExplicitRungeKuttaNyströmIntegrator<
DormandالمكاوىPrince1986RKN434FM,
Position<Barycentric>>(),
/*max_steps=*/1,
/*length_integration_tolerance=*/1 * Metre,
/*speed_integration_tolerance=*/1 * Metre / Second));
DiscreteTrajectory<Barycentric>::Iterator begin;
DiscreteTrajectory<Barycentric>::Iterator end;
flight_plan_->GetSegment(0, begin, end);
6 changes: 4 additions & 2 deletions ksp_plugin_test/vessel_test.cpp
Original file line number Diff line number Diff line change
@@ -325,7 +325,8 @@ TEST_F(VesselTest, FlightPlan) {
.WillOnce(Return(Status::OK));
vessel_.CreateFlightPlan(astronomy::J2000 + 3.0 * Second,
10 * Kilogram,
DefaultPredictionParameters());
DefaultPredictionParameters(),
DefaultBurnParameters());
EXPECT_TRUE(vessel_.has_flight_plan());
EXPECT_EQ(0, vessel_.flight_plan().number_of_manœuvres());
EXPECT_EQ(1, vessel_.flight_plan().number_of_segments());
@@ -345,7 +346,8 @@ TEST_F(VesselTest, SerializationSuccess) {
.WillRepeatedly(Return(Status::OK));
vessel_.CreateFlightPlan(astronomy::J2000 + 3.0 * Second,
10 * Kilogram,
DefaultPredictionParameters());
DefaultPredictionParameters(),
DefaultBurnParameters());

vessel_.WriteToMessage(&message,
serialization_index_for_pile_up.AsStdFunction());
4 changes: 3 additions & 1 deletion physics/ephemeris.hpp
Original file line number Diff line number Diff line change
@@ -127,6 +127,8 @@ class Ephemeris {
friend class Ephemeris<Frame>;
};

using GeneralizedAdaptiveStepParameters = AdaptiveStepParameters;

class PHYSICS_DLL FixedStepParameters final {
public:
FixedStepParameters(
@@ -222,7 +224,7 @@ class Ephemeris {
not_null<DiscreteTrajectory<Frame>*> trajectory,
GeneralIntrinsicAcceleration intrinsic_acceleration,
Instant const& t,
AdaptiveStepParameters const& parameters,
GeneralizedAdaptiveStepParameters const& parameters,
std::int64_t max_ephemeris_steps,
bool last_point_only);

2 changes: 2 additions & 0 deletions serialization/ksp_plugin.proto
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ message FlightPlan {
required Point desired_final_time = 3;
repeated Manoeuvre manoeuvre = 8;
required Ephemeris.AdaptiveStepParameters adaptive_step_parameters = 11;
required Ephemeris.AdaptiveStepParameters
generalized_adaptive_step_parameters = 13;

// Pre-Cardano.
reserved 4, 5, 6, 7;