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

Commits on May 10, 2021

  1. Copy the full SHA
    53b4c55 View commit details
  2. Copy the full SHA
    c2ba900 View commit details
  3. Copy the full SHA
    d1d9efd View commit details
  4. Copy the full SHA
    3e774f2 View commit details
  5. Cache expensive begin and end calls in

    DiscreteTrajectory iteration benchmarks.
    rnlahaye committed May 10, 2021
    Copy the full SHA
    fc81d60 View commit details
  6. Avoid interpolation in DiscreteTrajecotry::Evaluate*

    when unneccessary.
    rnlahaye committed May 10, 2021
    Copy the full SHA
    dbc80dc View commit details
  7. Optimizations for DiscreteTrajectory front, back,

    and begin.
    rnlahaye committed May 10, 2021
    Copy the full SHA
    f52362a View commit details
  8. Reconfigure Forkable iterator reference conversion.

    The conversion is now done by a static method instead of a constructor.
    There is also some documentation now.
    Also fixed inadvertently broken forkable_test.
    rnlahaye committed May 10, 2021
    Copy the full SHA
    89ca90a View commit details

Commits on May 11, 2021

  1. Copy the full SHA
    d368f1b View commit details
  2. Announce Green.

    pleroy authored May 11, 2021
    Copy the full SHA
    c43e8f2 View commit details

Commits on May 12, 2021

  1. Replaying.

    # Conflicts:
    #	journal/player_test.cpp
    pleroy committed May 12, 2021
    Copy the full SHA
    aad94fc View commit details
  2. More verbose logging.

    pleroy committed May 12, 2021
    Copy the full SHA
    c786899 View commit details
  3. A vessel which only has unfaithful parts is not manageable.

    # Conflicts:
    #	journal/player.cpp
    pleroy committed May 12, 2021
    Copy the full SHA
    25b8d16 View commit details
  4. Cleanup.

    pleroy committed May 12, 2021
    Copy the full SHA
    335164f View commit details

Commits on May 13, 2021

  1. Merge pull request #2983 from pleroy/2922b

    If a vessel only contains unfaithful parts, make it unmanageable
    pleroy authored May 13, 2021
    Copy the full SHA
    f2d5a6e View commit details
  2. Pull request comments.

    rnlahaye committed May 13, 2021
    Copy the full SHA
    d225a6b View commit details

Commits on May 14, 2021

  1. Copy the full SHA
    1201fda View commit details
  2. Lint.

    rnlahaye committed May 14, 2021
    Copy the full SHA
    4fcbf13 View commit details
  3. Merge pull request #2981 from rnlahaye/discrete-trajectory-evaluate

    Optimizations for DiscreteTrajectory
    pleroy authored May 14, 2021
    Copy the full SHA
    74e4b07 View commit details
  4. Copy the full SHA
    ba30229 View commit details
  5. Merge pull request #2985 from pleroy/Lov22

    Fix the Lov22 entry in the bibliography
    pleroy authored May 14, 2021
    Copy the full SHA
    ac7c89b View commit details

Commits on May 15, 2021

  1. Merge.

    pleroy committed May 15, 2021
    Copy the full SHA
    8015837 View commit details
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Principia

**[Grassmann](https://github.com/mockingbirdnest/Principia/wiki/Change-Log#grassmann), the April version of Principia, is available, with bug fixes and support for 1.11.2. Download it [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, and 1.11.2](https://bit.ly/3a36adx).**
**[Green](https://github.com/mockingbirdnest/Principia/wiki/Change-Log#green), the May version of Principia, is available, with bug fixes. Download it [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, and 1.11.2](https://bit.ly/3tpU45a).**

**For the convenience of Chinese users, downloads from 腾讯微云: [Principia Grassmann for 1.8.1—1.11.2](https://share.weiyun.com/1HxBrsnU), [Trappist-1 for Principia](https://share.weiyun.com/5wVtWYQ).**
**For the convenience of Chinese users, downloads from 腾讯微云: [Principia Green for 1.8.1—1.11.2](https://share.weiyun.com/hSkRB3Wq), [Trappist-1 for Principia](https://share.weiyun.com/5wVtWYQ).**

Principia is a mod for Kerbal Space Program (KSP) which implements N-body and extended body gravitation. Instead of being within the sphere of influence of a single celestial body at any point in time, your vessels are influenced by all the celestials. This makes it possible to implement missions that are more complex and more realistic than in the stock game, especially if used in conjunction with a mod like RealSolarSystem which has real-life celestials.

@@ -18,4 +18,4 @@ The [change log](https://github.com/mockingbirdnest/Principia/wiki/Change-Log) g

Principia is released on every [new moon](https://en.wikipedia.org/wiki/New_moon) with whatever features and bug fixes are ready at the time. This ensures relatively timely improvements and bug fixes.

Download the binary (Ubuntu, macOS, and Windows) [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, and 1.11.2](https://bit.ly/3a36adx). Download the [“Trappist-1 for Principia”](https://github.com/mockingbirdnest/Principia/wiki/Installing,-reporting-bugs,-and-frequently-asked-questions#installing-trappist-1-for-principia) mini-mod [here](https://bit.ly/2ZHf3Tt). Or, if you don't trust our binary, [build the mod](https://github.com/mockingbirdnest/Principia/blob/master/documentation/Setup.md) from the [Grassmann](https://github.com/mockingbirdnest/Principia/releases/tag/2021041203-Grassmann) release.
Download the binary (Ubuntu, macOS, and Windows) [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, and 1.11.2](https://bit.ly/3tpU45a). Download the [“Trappist-1 for Principia”](https://github.com/mockingbirdnest/Principia/wiki/Installing,-reporting-bugs,-and-frequently-asked-questions#installing-trappist-1-for-principia) mini-mod [here](https://bit.ly/2ZHf3Tt). Or, if you don't trust our binary, [build the mod](https://github.com/mockingbirdnest/Principia/blob/master/documentation/Setup.md) from the [Green](https://github.com/mockingbirdnest/Principia/releases/tag/2021051119-Green) release.
125 changes: 103 additions & 22 deletions benchmarks/discrete_trajectory.cpp
Original file line number Diff line number Diff line change
@@ -7,29 +7,57 @@
#include "benchmark/benchmark.h"
#include "geometry/frame.hpp"
#include "ksp_plugin/frames.hpp"
#include "quantities/elementary_functions.hpp"
#include "quantities/named_quantities.hpp"
#include "quantities/quantities.hpp"

namespace principia {
namespace physics {

using base::make_not_null_unique;
using base::not_null;
using geometry::Displacement;
using geometry::Frame;
using geometry::Handedness;
using geometry::Inertial;
using geometry::Instant;
using geometry::Velocity;
using ksp_plugin::World;
using quantities::AngularFrequency;
using quantities::Cos;
using quantities::Sin;
using quantities::Time;
using quantities::si::Metre;
using quantities::si::Radian;
using quantities::si::Second;

namespace {

// Creates a trajectory with the given number of steps.
not_null<std::unique_ptr<DiscreteTrajectory<World>>> CreateTrajectory(
// Creates a motionless trajectory with the given number of steps.
not_null<std::unique_ptr<DiscreteTrajectory<World>>> CreateMotionlessTrajectory(
int const steps) {
auto trajectory = make_not_null_unique<DiscreteTrajectory<World>>();
Instant t;
for (int i = 0; i < steps; i++, t += 1 * Second) {
trajectory->Append(t, {World::origin, World::unmoving});
for (Time t = 0 * Second; t < steps * Second; t += 1 * Second) {
trajectory->Append(Instant() + t, {World::origin, World::unmoving});
}
return trajectory;
}

// Creates a circular trajectory with the given number of steps in the XZ plane.
not_null<std::unique_ptr<DiscreteTrajectory<World>>> CreateCircularTrajectory(
int const steps) {
auto trajectory = make_not_null_unique<DiscreteTrajectory<World>>();
constexpr AngularFrequency ω = 1 * Radian / Second;
for (Time t = 0 * Second; t < steps * Second; t += 1 * Second) {
double const sin_ωt = Sin(ω * t);
double const cos_ωt = Cos(ω * t);
trajectory->Append(
Instant() + t,
{World::origin +
Displacement<World>({cos_ωt * Metre, 0 * Metre, sin_ωt * Metre}),
Velocity<World>({-sin_ωt * Metre / Second,
0 * Metre / Second,
cos_ωt * Metre / Second})});
}
return trajectory;
}
@@ -52,7 +80,7 @@ not_null<DiscreteTrajectory<World>*> ForkAt(DiscreteTrajectory<World>& parent,

void BM_DiscreteTrajectoryFront(benchmark::State& state) {
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(4);
CreateMotionlessTrajectory(4);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

@@ -63,7 +91,7 @@ void BM_DiscreteTrajectoryFront(benchmark::State& state) {

void BM_DiscreteTrajectoryBack(benchmark::State& state) {
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(4);
CreateMotionlessTrajectory(4);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

@@ -74,7 +102,7 @@ void BM_DiscreteTrajectoryBack(benchmark::State& state) {

void BM_DiscreteTrajectoryBegin(benchmark::State& state) {
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(4);
CreateMotionlessTrajectory(4);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

@@ -85,7 +113,7 @@ void BM_DiscreteTrajectoryBegin(benchmark::State& state) {

void BM_DiscreteTrajectoryEnd(benchmark::State& state) {
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(4);
CreateMotionlessTrajectory(4);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

@@ -94,78 +122,131 @@ void BM_DiscreteTrajectoryEnd(benchmark::State& state) {
}
}

void BM_DiscreteTrajectoryTMin(benchmark::State& state) {
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateMotionlessTrajectory(4);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

for (auto _ : state) {
fork->t_min();
}
}

void BM_DiscreteTrajectoryTMax(benchmark::State& state) {
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateMotionlessTrajectory(4);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

for (auto _ : state) {
fork->t_max();
}
}

void BM_DiscreteTrajectoryCreateDestroy(benchmark::State& state) {
int const steps = state.range(0);
for (auto _ : state) {
CreateTrajectory(steps);
CreateMotionlessTrajectory(steps);
}
}

void BM_DiscreteTrajectoryIterate(benchmark::State& state) {
int const steps = state.range(0);
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(steps);
CreateMotionlessTrajectory(steps);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

auto const begin = fork->begin();
auto const end = fork->end();
for (auto _ : state) {
for (auto it = fork->begin(); it != fork->end(); ++it) {
for (auto it = begin; it != end; ++it) {
}
}
}

void BM_DiscreteTrajectoryReverseIterate(benchmark::State& state) {
int const steps = state.range(0);
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(steps);
CreateMotionlessTrajectory(steps);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

auto const begin = fork->begin();
auto const end = fork->end();
for (auto _ : state) {
for (auto it = fork->end(); it != fork->begin(); --it) {
for (auto it = end; it != begin; --it) {
}
}
}

void BM_DiscreteTrajectoryFind(benchmark::State& state) {
int const steps = state.range(0);
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(steps);
CreateMotionlessTrajectory(steps);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

for (auto _ : state) {
// These times are in different segments of the fork.
fork->Find(Instant() + 333 * Second);
fork->Find(Instant() + 667 * Second);
fork->Find(Instant() + 833 * Second);
fork->Find(Instant() + 1.0 / 3.0 * steps * Second);
fork->Find(Instant() + 2.0 / 3.0 * steps * Second);
fork->Find(Instant() + 5.0 / 6.0 * steps * Second);
}
}

void BM_DiscreteTrajectoryLowerBound(benchmark::State& state) {
int const steps = state.range(0);
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateTrajectory(steps);
CreateMotionlessTrajectory(steps);
not_null<DiscreteTrajectory<World>*> const fork =
ForkAt(*ForkAt(*trajectory, 0.5), 0.75);

for (auto _ : state) {
// These times are in different segments of the fork.
fork->LowerBound(Instant() + 333 * Second);
fork->LowerBound(Instant() + 667 * Second);
fork->LowerBound(Instant() + 833 * Second);
fork->LowerBound(Instant() + 1.0 / 3.0 * steps * Second);
fork->LowerBound(Instant() + 2.0 / 3.0 * steps * Second);
fork->LowerBound(Instant() + 5.0 / 6.0 * steps * Second);
}
}

void BM_DiscreteTrajectoryEvaluateDegreesOfFreedomExact(
benchmark::State& state) {
int const steps = state.range(0);
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateCircularTrajectory(4);

Instant const t = Instant() + 1 * Second;
for (auto _ : state) {
trajectory->EvaluateDegreesOfFreedom(t);
}
}

void BM_DiscreteTrajectoryEvaluateDegreesOfFreedomInterpolated(
benchmark::State& state) {
not_null<std::unique_ptr<DiscreteTrajectory<World>>> const trajectory =
CreateCircularTrajectory(4);

Instant const t = Instant() + 1.5 * Second;
for (auto _ : state) {
trajectory->EvaluateDegreesOfFreedom(t);
}
}

BENCHMARK(BM_DiscreteTrajectoryFront);
BENCHMARK(BM_DiscreteTrajectoryBack);
BENCHMARK(BM_DiscreteTrajectoryBegin);
BENCHMARK(BM_DiscreteTrajectoryEnd);
BENCHMARK(BM_DiscreteTrajectoryTMin);
BENCHMARK(BM_DiscreteTrajectoryTMax);
BENCHMARK(BM_DiscreteTrajectoryCreateDestroy)->Range(8, 1024);
BENCHMARK(BM_DiscreteTrajectoryIterate)->Range(8, 1024);
BENCHMARK(BM_DiscreteTrajectoryReverseIterate)->Range(8, 1024);
BENCHMARK(BM_DiscreteTrajectoryFind)->Range(8, 1024);
BENCHMARK(BM_DiscreteTrajectoryLowerBound)->Range(8, 1024);
BENCHMARK(BM_DiscreteTrajectoryEvaluateDegreesOfFreedomExact);
BENCHMARK(BM_DiscreteTrajectoryEvaluateDegreesOfFreedomInterpolated);

} // namespace physics
} // namespace principia
2 changes: 1 addition & 1 deletion documentation/bibliography.bib
Original file line number Diff line number Diff line change
@@ -752,7 +752,7 @@ @article{LǐLǐLǐ2012

@article{Lovecraft1922,
author = {Lovecraft, Howard Phillips},
date = {1992-02/1992-07},
date = {1922-02/1922-07},
publisher = {Houtain, George Julian},
journaltitle = {Home Brew},
number = {1--6},
Binary file modified documentation/bibliography.pdf
Binary file not shown.
19 changes: 9 additions & 10 deletions journal/player_test.cpp
Original file line number Diff line number Diff line change
@@ -85,15 +85,17 @@ TEST_F(PlayerTest, DISABLED_SECULAR_Benchmarks) {
}

TEST_F(PlayerTest, DISABLED_SECULAR_Debug) {
google::LogToStderr();
// An example of how journaling may be used for debugging. You must set
// |path| and fill the |method_in| and |method_out_return| protocol buffers.
std::string path =
R"(P:\Public Mockingbird\Principia\Crashes\2975\JOURNAL.20210507-185451)"; // NOLINT
R"(P:\Public Mockingbird\Principia\Crashes\2922\JOURNAL.20210312-215639)"; // NOLINT
Player player(path);
int count = 0;
while (player.Play(count)) {
++count;
// Reset logging after each method so as to output all messages irrespective
// of what the game did.
google::LogToStderr();
LOG_IF(ERROR, (count % 100'000) == 0) << count
<< " journal entries replayed";
}
@@ -107,21 +109,18 @@ TEST_F(PlayerTest, DISABLED_SECULAR_Debug) {
serialization::Method method_in;
{
auto* extension = method_in.MutableExtension(
serialization::DeserializePlugin::extension);
serialization::FreeVesselsAndPartsAndCollectPileUps::extension);
auto* in = extension->mutable_in();
in->set_serialization("");
in->set_deserializer(2142487540208);
in->set_plugin(0);
in->set_compressor("gipfeli");
in->set_encoder("base64");
in->set_plugin(2718550096736);
in->set_delta_t(0.02);
}
serialization::Method method_out_return;
{
auto* extension = method_out_return.MutableExtension(
serialization::DeserializePlugin::extension);
serialization::FreeVesselsAndPartsAndCollectPileUps::extension);
}
LOG(ERROR) << "Running unpaired method:\n" << method_in.DebugString();
CHECK(RunIfAppropriate<DeserializePlugin>(
CHECK(RunIfAppropriate<FreeVesselsAndPartsAndCollectPileUps>(
method_in, method_out_return, player));
#endif
}
3 changes: 3 additions & 0 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -574,6 +574,9 @@ private string UnmanageabilityReasons(Vessel vessel) {
if (vessel.loaded && hack_gravity?.toggle.isOn == true) {
reasons.Add("vessel is loaded and gravity is being hacked");
}
if (vessel.parts.All(part => !PartIsFaithful(part))) {
reasons.Add("vessel is completely unfaithful");
}
if (reasons.Count == 0) {
return null;
} else {
9 changes: 5 additions & 4 deletions physics/discrete_trajectory.hpp
Original file line number Diff line number Diff line change
@@ -46,6 +46,9 @@ class DiscreteTrajectoryIterator
DiscreteTrajectoryTraits<Frame>> {
public:
struct reference {
explicit reference(
typename DiscreteTrajectoryTraits<Frame>::TimelineConstIterator it);

Instant const& time;
DegreesOfFreedom<Frame> const& degrees_of_freedom;
};
@@ -256,11 +259,9 @@ class DiscreteTrajectory : public Forkable<DiscreteTrajectory<Frame>,
std::vector<DiscreteTrajectory<Frame>**> const& forks);

// Returns the Hermite interpolation for the left-open, right-closed
// trajectory segment containing the given |time|, or, if |time| is |t_min()|,
// returns a first-degree polynomial which should be evaluated only at
// |t_min()|.
// trajectory segment bounded above by |upper|.
Hermite3<Instant, Position<Frame>> GetInterpolation(
Instant const& time) const;
Iterator const& upper) const;

Timeline timeline_;

Loading