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: 918fea46cbc6
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 581a64459026
Choose a head ref
  • 8 commits
  • 9 files changed
  • 1 contributor

Commits on Nov 6, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b486af4 View commit details

Commits on Nov 7, 2021

  1. Fix the benchmarks.

    pleroy committed Nov 7, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2523345 View commit details
  2. Lint.

    pleroy committed Nov 7, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3c420a0 View commit details
  3. Copy the full SHA
    d428af6 View commit details
  4. Fix sizes.

    pleroy committed Nov 7, 2021
    Copy the full SHA
    2d977e2 View commit details
  5. After egg's review.

    pleroy committed Nov 7, 2021
    Copy the full SHA
    6ff16e2 View commit details
  6. Fix a test.

    pleroy committed Nov 7, 2021
    Copy the full SHA
    ed825fe View commit details
  7. Merge pull request #3196 from pleroy/Continue

    Convert benchmark to DiscreteTraject0ry
    pleroy authored Nov 7, 2021
    Copy the full SHA
    581a644 View commit details
33 changes: 18 additions & 15 deletions benchmarks/apsides.cpp
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
#include "physics/apsides.hpp"
#include "physics/body_centred_non_rotating_dynamic_frame.hpp"
#include "physics/body_surface_dynamic_frame.hpp"
#include "physics/discrete_traject0ry.hpp"
#include "physics/ephemeris.hpp"
#include "physics/solar_system.hpp"
#include "quantities/astronomy.hpp"
@@ -78,7 +79,7 @@ class ApsidesBenchmark : public benchmark::Fixture {
ephemeris_->Prolong(begin->time);

BodySurfaceDynamicFrame<ICRS, ITRS> const itrs(ephemeris_, earth_);
ilrsa_lageos2_trajectory_icrs_ = new DiscreteTrajectory<ICRS>;
ilrsa_lageos2_trajectory_icrs_ = new DiscreteTraject0ry<ICRS>;
ilrsa_lageos2_trajectory_icrs_->Append(
begin->time,
itrs.FromThisFrameAtTime(begin->time)(begin->degrees_of_freedom));
@@ -97,7 +98,7 @@ class ApsidesBenchmark : public benchmark::Fixture {

BodyCentredNonRotatingDynamicFrame<ICRS, GCRS> const gcrs(ephemeris_,
earth_);
ilrsa_lageos2_trajectory_gcrs_ = new DiscreteTrajectory<GCRS>;
ilrsa_lageos2_trajectory_gcrs_ = new DiscreteTraject0ry<GCRS>;
for (auto const& [time, degrees_of_freedom] :
*ilrsa_lageos2_trajectory_icrs_) {
ilrsa_lageos2_trajectory_gcrs_->Append(
@@ -116,47 +117,49 @@ class ApsidesBenchmark : public benchmark::Fixture {
static Ephemeris<ICRS>* ephemeris_;
static OblateBody<ICRS> const* earth_;
static ContinuousTrajectory<ICRS> const* earth_trajectory_;
static DiscreteTrajectory<ICRS>* ilrsa_lageos2_trajectory_icrs_;
static DiscreteTrajectory<GCRS>* ilrsa_lageos2_trajectory_gcrs_;
static DiscreteTraject0ry<ICRS>* ilrsa_lageos2_trajectory_icrs_;
static DiscreteTraject0ry<GCRS>* ilrsa_lageos2_trajectory_gcrs_;
};

SolarSystem<ICRS>* ApsidesBenchmark::solar_system_2010_ = nullptr;
Ephemeris<ICRS>* ApsidesBenchmark::ephemeris_ = nullptr;
OblateBody<ICRS> const* ApsidesBenchmark::ApsidesBenchmark::earth_ = nullptr;
ContinuousTrajectory<ICRS> const*
ApsidesBenchmark::ApsidesBenchmark::earth_trajectory_ = nullptr;
DiscreteTrajectory<ICRS>* ApsidesBenchmark::ilrsa_lageos2_trajectory_icrs_ =
DiscreteTraject0ry<ICRS>* ApsidesBenchmark::ilrsa_lageos2_trajectory_icrs_ =
nullptr;
DiscreteTrajectory<GCRS>* ApsidesBenchmark::ilrsa_lageos2_trajectory_gcrs_ =
DiscreteTraject0ry<GCRS>* ApsidesBenchmark::ilrsa_lageos2_trajectory_gcrs_ =
nullptr;

BENCHMARK_F(ApsidesBenchmark, ComputeApsides)(benchmark::State& state) {
for (auto _ : state) {
DiscreteTrajectory<ICRS> apoapsides;
DiscreteTrajectory<ICRS> periapsides;
DiscreteTraject0ry<ICRS> apoapsides;
DiscreteTraject0ry<ICRS> periapsides;
ComputeApsides(*earth_trajectory_,
*ilrsa_lageos2_trajectory_icrs_,
ilrsa_lageos2_trajectory_icrs_->begin(),
ilrsa_lageos2_trajectory_icrs_->end(),
/*max_points=*/std::numeric_limits<int>::max(),
apoapsides,
periapsides);
CHECK_EQ(2364, apoapsides.Size());
CHECK_EQ(2365, periapsides.Size());
CHECK_EQ(2364, apoapsides.size());
CHECK_EQ(2365, periapsides.size());
}
}

BENCHMARK_F(ApsidesBenchmark, ComputeNodes)(benchmark::State& state) {
for (auto _ : state) {
DiscreteTrajectory<GCRS> ascending;
DiscreteTrajectory<GCRS> descending;
ComputeNodes(ilrsa_lageos2_trajectory_gcrs_->begin(),
DiscreteTraject0ry<GCRS> ascending;
DiscreteTraject0ry<GCRS> descending;
ComputeNodes(*ilrsa_lageos2_trajectory_gcrs_,
ilrsa_lageos2_trajectory_gcrs_->begin(),
ilrsa_lageos2_trajectory_gcrs_->end(),
Vector<double, GCRS>({0, 0, 1}),
/*max_points=*/std::numeric_limits<int>::max(),
ascending,
descending);
CHECK_EQ(2365, ascending.Size());
CHECK_EQ(2365, descending.Size());
CHECK_EQ(2365, ascending.size());
CHECK_EQ(2365, descending.size());
}
}

26 changes: 13 additions & 13 deletions benchmarks/ephemeris.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
#include "integrators/symplectic_runge_kutta_nyström_integrator.hpp"
#include "ksp_plugin/frames.hpp"
#include "physics/degrees_of_freedom.hpp"
#include "physics/discrete_trajectory.hpp"
#include "physics/discrete_traject0ry.hpp"
#include "physics/ephemeris.hpp"
#include "physics/massless_body.hpp"
#include "quantities/astronomy.hpp"
@@ -87,7 +87,7 @@ namespace physics {

namespace {

using Flow = void(not_null<DiscreteTrajectory<Barycentric>*> const trajectory,
using Flow = void(not_null<DiscreteTraject0ry<Barycentric>*> const trajectory,
Instant const& t,
Ephemeris<Barycentric>& ephemeris);

@@ -204,7 +204,7 @@ void BM_EphemerisLEOProbe(benchmark::State& state) {
state.PauseTiming();
// A probe in low earth orbit.
MasslessBody probe;
DiscreteTrajectory<Barycentric> trajectory;
DiscreteTraject0ry<Barycentric> trajectory;
DegreesOfFreedom<Barycentric> const earth_degrees_of_freedom =
at_спутник_1_launch->degrees_of_freedom(
SolarSystemFactory::name(SolarSystemFactory::Earth));
@@ -239,7 +239,7 @@ void BM_EphemerisLEOProbe(benchmark::State& state) {
EvaluatePosition(final_time) -
trajectory.back().degrees_of_freedom.position()).
Norm();
steps = trajectory.Size();
steps = trajectory.size();
state.ResumeTiming();
}
std::stringstream ss;
@@ -274,7 +274,7 @@ void BM_EphemerisTranslunarSpaceProbe(benchmark::State& state) {
state.PauseTiming();
// A probe orbiting the Earth beyond the orbit of the Moon.
MasslessBody probe;
DiscreteTrajectory<Barycentric> trajectory;
DiscreteTraject0ry<Barycentric> trajectory;
DegreesOfFreedom<Barycentric> const earth_degrees_of_freedom =
at_спутник_1_launch->degrees_of_freedom(
SolarSystemFactory::name(SolarSystemFactory::Earth));
@@ -309,7 +309,7 @@ void BM_EphemerisTranslunarSpaceProbe(benchmark::State& state) {
EvaluatePosition(final_time) -
trajectory.back().degrees_of_freedom.position()).
Norm();
steps = trajectory.Size();
steps = trajectory.size();
state.ResumeTiming();
}
std::stringstream ss;
@@ -340,7 +340,7 @@ void BM_EphemerisMultithreadingBenchmark(benchmark::State& state) {
at_спутник_1_launch->degrees_of_freedom(earth_name);

MasslessBody probe;
std::list<DiscreteTrajectory<Barycentric>> trajectories;
std::list<DiscreteTraject0ry<Barycentric>> trajectories;
for (int i = 0; i < state.range(0); ++i) {
KeplerianElements<Barycentric> elements;
elements.eccentricity = 0;
@@ -426,7 +426,7 @@ void EphemerisL4ProbeBenchmark(Time const integration_duration,
Identity<ICRS, Barycentric> to_barycentric;
Identity<Barycentric, ICRS> from_barycentric;
MasslessBody probe;
auto trajectory = std::make_unique<DiscreteTrajectory<Barycentric>>();
auto trajectory = std::make_unique<DiscreteTraject0ry<Barycentric>>();
DegreesOfFreedom<Barycentric> const sun_degrees_of_freedom =
at_спутник_1_launch->degrees_of_freedom(
SolarSystemFactory::name(SolarSystemFactory::Sun));
@@ -476,7 +476,7 @@ void EphemerisL4ProbeBenchmark(Time const integration_duration,
}

while (state.KeepRunning()) {
not_null<std::unique_ptr<DiscreteTrajectory<Barycentric>>> trajectory =
not_null<std::unique_ptr<DiscreteTraject0ry<Barycentric>>> trajectory =
make_l4_probe_trajectory();
state.PauseTiming();

@@ -496,7 +496,7 @@ void EphemerisL4ProbeBenchmark(Time const integration_duration,
SolarSystemFactory::name(
SolarSystemFactory::Earth)).EvaluatePosition(final_time) -
trajectory->back().degrees_of_freedom.position()).Norm();
steps = trajectory->Size();
steps = trajectory->size();
state.ResumeTiming();
}
std::stringstream ss;
@@ -538,7 +538,7 @@ void BM_EphemerisStartup(benchmark::State& state) {
}

void FlowEphemerisWithAdaptiveStep(
not_null<DiscreteTrajectory<Barycentric>*> const trajectory,
not_null<DiscreteTraject0ry<Barycentric>*> const trajectory,
Instant const& t,
Ephemeris<Barycentric>& ephemeris) {
CHECK_OK(ephemeris.FlowWithAdaptiveStep(
@@ -556,7 +556,7 @@ void FlowEphemerisWithAdaptiveStep(
}

void FlowEphemerisWithFixedStepSLMS(
not_null<DiscreteTrajectory<Barycentric>*> const trajectory,
not_null<DiscreteTraject0ry<Barycentric>*> const trajectory,
Instant const& t,
Ephemeris<Barycentric>& ephemeris) {
auto const instance = ephemeris.NewInstance(
@@ -570,7 +570,7 @@ void FlowEphemerisWithFixedStepSLMS(
}

void FlowEphemerisWithFixedStepSRKN(
not_null<DiscreteTrajectory<Barycentric>*> const trajectory,
not_null<DiscreteTraject0ry<Barycentric>*> const trajectory,
Instant const& t,
Ephemeris<Barycentric>& ephemeris) {
auto const instance = ephemeris.NewInstance(
10 changes: 6 additions & 4 deletions benchmarks/planetarium_plot_methods.cpp
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
#include "astronomy/time_scales.hpp"
#include "benchmark/benchmark.h"
#include "physics/body_centred_non_rotating_dynamic_frame.hpp"
#include "physics/discrete_traject0ry.hpp"
#include "physics/solar_system.hpp"
#include "testing_utilities/solar_system_factory.hpp"

@@ -36,7 +37,7 @@ using ksp_plugin::NavigationFrame;
using ksp_plugin::Planetarium;
using physics::BodyCentredNonRotatingDynamicFrame;
using physics::DegreesOfFreedom;
using physics::DiscreteTrajectory;
using physics::DiscreteTraject0ry;
using physics::Ephemeris;
using physics::KeplerianElements;
using physics::KeplerOrbit;
@@ -155,7 +156,7 @@ class Satellites {
*goes_8_instance));
}

DiscreteTrajectory<Barycentric> const& goes_8_trajectory() const {
DiscreteTraject0ry<Barycentric> const& goes_8_trajectory() const {
return goes_8_trajectory_;
}

@@ -191,7 +192,7 @@ class Satellites {
not_null<std::unique_ptr<Ephemeris<Barycentric>>> const ephemeris_;
not_null<MassiveBody const*> const earth_;
not_null<std::unique_ptr<NavigationFrame>> const earth_centred_inertial_;
DiscreteTrajectory<Barycentric> goes_8_trajectory_;
DiscreteTraject0ry<Barycentric> goes_8_trajectory_;
};

} // namespace
@@ -206,7 +207,8 @@ void RunBenchmark(benchmark::State& state,
// This is the time of a lunar eclipse in January 2000.
constexpr Instant now = "2000-01-21T04:41:30,5"_TT;
while (state.KeepRunning()) {
lines = planetarium.PlotMethod2(satellites.goes_8_trajectory().begin(),
lines = planetarium.PlotMethod2(satellites.goes_8_trajectory(),
satellites.goes_8_trajectory().begin(),
satellites.goes_8_trajectory().end(),
now,
/*reverse=*/false);
1 change: 0 additions & 1 deletion ksp_plugin/ksp_plugin.vcxproj
Original file line number Diff line number Diff line change
@@ -72,7 +72,6 @@
<ClCompile Include="..\numerics\cbrt.cpp" />
<ClCompile Include="..\numerics\elliptic_functions.cpp" />
<ClCompile Include="..\numerics\elliptic_integrals.cpp" />
<ClCompile Include="..\physics\protector.cpp" />
<ClCompile Include="celestial.cpp" />
<ClCompile Include="equator_relevance_threshold.cpp" />
<ClCompile Include="flight_plan.cpp" />
3 changes: 0 additions & 3 deletions ksp_plugin/ksp_plugin.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -160,9 +160,6 @@
<ClCompile Include="equator_relevance_threshold.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\physics\protector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="orbit_analyser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
1 change: 0 additions & 1 deletion ksp_plugin_test/ksp_plugin_test.vcxproj
Original file line number Diff line number Diff line change
@@ -49,7 +49,6 @@
<ClCompile Include="..\numerics\cbrt.cpp" />
<ClCompile Include="..\numerics\elliptic_functions.cpp" />
<ClCompile Include="..\numerics\elliptic_integrals.cpp" />
<ClCompile Include="..\physics\protector.cpp" />
<ClCompile Include="..\testing_utilities\string_log_sink.cpp" />
<ClCompile Include="benchmark.cpp" />
<ClCompile Include="celestial_test.cpp" />
3 changes: 0 additions & 3 deletions ksp_plugin_test/ksp_plugin_test.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -161,9 +161,6 @@
<ClCompile Include="..\ksp_plugin\equator_relevance_threshold.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\physics\protector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="orbit_analyser_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
65 changes: 32 additions & 33 deletions ksp_plugin_test/plugin_integration_test.cpp
Original file line number Diff line number Diff line change
@@ -64,11 +64,13 @@ using testing_utilities::RelativeError;
using testing_utilities::SolarSystemFactory;
using testing_utilities::operator""_⑴;
using ::testing::AllOf;
using ::testing::AnyOf;
using ::testing::Eq;
using ::testing::Ge;
using ::testing::Gt;
using ::testing::Le;
using ::testing::Lt;
using ::testing::SizeIs;

namespace {

@@ -243,16 +245,16 @@ TEST_F(PluginIntegrationTest, BodyCentredNonrotatingNavigationIntegration) {
-1.0 * AstronomicalUnit / Hour,
0.0 * AstronomicalUnit / Hour}) * (t - initial_time);
auto const& vessel = *plugin_->GetVessel(vessel_guid);
auto const history =vessel.history();
auto const psychohistory =vessel.psychohistory();
auto const history = vessel.history();
auto const psychohistory = vessel.psychohistory();
auto const rendered_trajectory =
plugin_->renderer().RenderBarycentricTrajectoryInWorld(
plugin_->CurrentTime(),
history->begin(),
psychohistory->end(),
sun_world_position,
plugin_->PlanetariumRotation());
EXPECT_THAT(rendered_trajectory.size(), AllOf(Ge(61), Le(4261)));
EXPECT_THAT(rendered_trajectory, SizeIs(AllOf(Ge(61), Le(4262))));
Position<World> const earth_world_position =
sun_world_position + alice_sun_to_world(plugin_->CelestialFromParent(
SolarSystemFactory::Earth).displacement());
@@ -352,36 +354,33 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingNavigationIntegration) {
{ 0.1 * AstronomicalUnit / Hour,
-1.0 * AstronomicalUnit / Hour,
0.0 * AstronomicalUnit / Hour}) * (t - initial_time);
auto const& vessel = *plugin_->GetVessel(vessel_guid);
auto const history =vessel.history();
auto const psychohistory =vessel.psychohistory();
auto const rendered_trajectory =
plugin_->renderer().RenderBarycentricTrajectoryInWorld(
plugin_->CurrentTime(),
history->begin(),
psychohistory->end(),
sun_world_position,
plugin_->PlanetariumRotation());
EXPECT_EQ(4321, rendered_trajectory.size());
Position<World> const earth_world_position =
sun_world_position +
alice_sun_to_world(
plugin_->CelestialFromParent(SolarSystemFactory::Earth)
.displacement());
Position<World> const moon_world_position =
earth_world_position +
alice_sun_to_world(
plugin_->CelestialFromParent(SolarSystemFactory::Moon)
.displacement());
Length const earth_moon =
(moon_world_position - earth_world_position).Norm();
for (auto const& [time, degrees_of_freedom] : rendered_trajectory) {
Position<World> const position = degrees_of_freedom.position();
Length const satellite_earth = (position - earth_world_position).Norm();
Length const satellite_moon = (position - moon_world_position).Norm();
EXPECT_THAT(RelativeError(earth_moon, satellite_earth), Lt(0.0907));
EXPECT_THAT(RelativeError(earth_moon, satellite_moon), Lt(0.131));
EXPECT_THAT(RelativeError(satellite_moon, satellite_earth), Lt(0.148));
auto const& vessel = *plugin_->GetVessel(vessel_guid);
auto const history = vessel.history();
auto const psychohistory = vessel.psychohistory();
auto const rendered_trajectory =
plugin_->renderer().RenderBarycentricTrajectoryInWorld(
plugin_->CurrentTime(),
history->begin(),
psychohistory->end(),
sun_world_position,
plugin_->PlanetariumRotation());
EXPECT_THAT(rendered_trajectory, SizeIs(AnyOf(4321, 9414)));
Position<World> const earth_world_position =
sun_world_position +
alice_sun_to_world(plugin_->CelestialFromParent(SolarSystemFactory::Earth)
.displacement());
Position<World> const moon_world_position =
earth_world_position +
alice_sun_to_world(plugin_->CelestialFromParent(SolarSystemFactory::Moon)
.displacement());
Length const earth_moon = (moon_world_position - earth_world_position).Norm();
for (auto const& [time, degrees_of_freedom] : rendered_trajectory) {
Position<World> const position = degrees_of_freedom.position();
Length const satellite_earth = (position - earth_world_position).Norm();
Length const satellite_moon = (position - moon_world_position).Norm();
EXPECT_THAT(RelativeError(earth_moon, satellite_earth), Lt(0.0907));
EXPECT_THAT(RelativeError(earth_moon, satellite_moon), Lt(0.131));
EXPECT_THAT(RelativeError(satellite_moon, satellite_earth), Lt(0.148));
}
// Check that there are no spikes in the rendered trajectory, i.e., that three
// consecutive points form a sufficiently flat triangle. This tests issue
Loading