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

Commits on Apr 22, 2020

  1. Copy the full SHA
    01ae236 View commit details

Commits on Apr 23, 2020

  1. Test ToMathematica.

    pleroy committed Apr 23, 2020
    Copy the full SHA
    33a2c58 View commit details
  2. Copy the full SHA
    002c404 View commit details
  3. Cleanups.

    pleroy committed Apr 23, 2020
    Copy the full SHA
    a855d36 View commit details
  4. IWYU.

    pleroy committed Apr 23, 2020
    Copy the full SHA
    4eb7130 View commit details
  5. Cleanup.

    pleroy committed Apr 23, 2020
    Copy the full SHA
    71527ba View commit details

Commits on Apr 24, 2020

  1. Disable another test.

    pleroy committed Apr 24, 2020
    Copy the full SHA
    0d6fb26 View commit details
  2. Copy the full SHA
    b38c3c9 View commit details

Commits on Apr 25, 2020

  1. Merge pull request #2543 from pleroy/MathematicaTest

    Add tests to the mathematica project
    pleroy authored Apr 25, 2020
    Copy the full SHA
    dd25989 View commit details
10 changes: 7 additions & 3 deletions base/bundle.cpp
Original file line number Diff line number Diff line change
@@ -19,15 +19,18 @@ void Bundle::Add(Task task) {

Status Bundle::Join() {
joining_ = true;
all_done_.WaitForNotification();
if (number_of_active_workers_ > 0) {
all_done_.WaitForNotification();
}
JoinAll();
absl::ReaderMutexLock status_lock(&status_lock_);
return status_;
}

Status Bundle::JoinWithin(std::chrono::steady_clock::duration Δt) {
joining_ = true;
if (!all_done_.WaitForNotificationWithTimeout(absl::FromChrono(Δt))) {
if (number_of_active_workers_ > 0 &&
!all_done_.WaitForNotificationWithTimeout(absl::FromChrono(Δt))) {
absl::MutexLock l(&status_lock_);
status_ = Status(Error::DEADLINE_EXCEEDED, "bundle deadline exceeded");
}
@@ -38,7 +41,8 @@ Status Bundle::JoinWithin(std::chrono::steady_clock::duration Δt) {

Status Bundle::JoinBefore(std::chrono::system_clock::time_point t) {
joining_ = true;
if (!all_done_.WaitForNotificationWithDeadline(absl::FromChrono(t))) {
if (number_of_active_workers_ > 0 &&
!all_done_.WaitForNotificationWithDeadline(absl::FromChrono(t))) {
absl::MutexLock l(&status_lock_);
status_ = Status(Error::DEADLINE_EXCEEDED, "bundle deadline exceeded");
}
131 changes: 131 additions & 0 deletions mathematica/error_analysis_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include <map>
#include <string>
#include <vector>

#include "base/map_util.hpp"
#include "base/not_null.hpp"
#include "glog/logging.h"
#include "gtest/gtest.h"
#include "integrators/integrators.hpp"
#include "mathematica/integrator_plots.hpp"
#include "mathematica/mathematica.hpp"
#include "mathematica/local_error_analysis.hpp"
#include "mathematica/retrobop_dynamical_stability.hpp"
#include "quantities/parser.hpp"
#include "quantities/quantities.hpp"
#include "quantities/si.hpp"

namespace principia {

using base::Contains;
using base::make_not_null_unique;
using quantities::ParseQuantity;
using integrators::ParseFixedStepSizeIntegrator;

namespace mathematica {

class ErrorAnalysisTest : public ::testing::Test {
protected:
};

TEST_F(ErrorAnalysisTest, DISABLED_IntegratorPlots) {
GenerateSimpleHarmonicMotionWorkErrorGraphs();
// Circular.
GenerateKeplerProblemWorkErrorGraphs(0.0);
// Pluto.
GenerateKeplerProblemWorkErrorGraphs(0.25);
// 67P.
GenerateKeplerProblemWorkErrorGraphs(0.64);
// 1P.
GenerateKeplerProblemWorkErrorGraphs(0.967);
}

TEST_F(ErrorAnalysisTest, RetrobopDynamicalStability_PlotPredictableYears) {
PlotPredictableYears();
}

TEST_F(ErrorAnalysisTest, DISABLED_RetrobopDynamicalStability_PlotCentury) {
PlotCentury();
}

TEST_F(ErrorAnalysisTest,
DISABLED_RetrobopDynamicalStability_AnalyseGlobalError) {
AnalyseGlobalError();
}

TEST_F(ErrorAnalysisTest,
DISABLED_RetrobopDynamicalStability_StatisticallyAnalyseStability) {
google::LogToStderr();
StatisticallyAnalyseStability();
}

TEST_F(ErrorAnalysisTest, DISABLED_LocalErrorAnalysis) {
google::LogToStderr();
std::vector<std::string> argv = ::testing::internal::GetArgvs();
std::map<std::string, std::optional<std::string>> flags;
for (int i = 2; i < argv.size(); ++i) {
std::string const flag(argv[i]);
std::size_t const name_begin = flag.find_first_not_of("-/");
std::size_t const name_end = flag.find('=');
if (name_begin == std::string::npos) {
LOG(FATAL) << "Invalid flag syntax '" << flag << "', expected\n"
<< "(--|/)<flag_name>[=value]";
}
std::string const flag_name =
flag.substr(name_begin, name_end - name_begin);
if (name_end != std::string::npos) {
flags.emplace(flag_name, flag.substr(name_end + 1, std::string::npos));
}
flags.emplace(flag_name, std::nullopt);
}
if (flags.empty() || Contains(flags, "help") || Contains(flags, "?")) {
// Example:
// .\Release\x64\mathematica_tests.exe \
// --gtest_filter=ErrorAnalysisTest.LocalErrorAnalysis \
// --gravity_model=.\astronomy\kerbol_gravity_model.proto.txt \
// --initial_state=.\astronomy\kerbol_initial_state_0_0.proto.txt \
// --time_step=1h --integrator=QUINLAN_1999_ORDER_8A
std::printf(
"Usage:\n"
"mathematica_tests --gtest_filter=%s.%s \n"
" --gravity_model=<path>\n"
" --initial_state=<path>\n"
" --integrator=<fixed_step_size_integrator >\n"
" --time_step=<quantity(time)>\n"
" [--output_directory=<path>] default: .\n"
" [--fine_integrator=<fixed_step_size_integrator >] "
" default: BLANES_MOAN_2002_SRKN_14A\n"
" [--fine_step=<quantity(time)>] default: 1 min\n"
" [--granularity=<quantity(time)>] default: 1 d\n"
" [--duration=<quantity(time)>] default: 500 d\n",
testing::UnitTest::GetInstance()->current_test_info()->test_case_name(),
testing::UnitTest::GetInstance()->current_test_info()->name());
return;
}
auto const gravity_model_path =
std::filesystem::path(*flags["gravity_model"]);
auto const initial_state_path =
std::filesystem::path(*flags["initial_state"]);
auto solar_system = make_not_null_unique<SolarSystem<ICRS>>(
gravity_model_path, initial_state_path, /*ignore_frame=*/true);
auto const& integrator =
ParseFixedStepSizeIntegrator<Ephemeris<ICRS>::NewtonianMotionEquation>(
*flags["integrator"]);
auto const time_step = ParseQuantity<Time>(*flags["time_step"]);
auto const out =
std::filesystem::path(flags["output_directory"].value_or(".")) /
(std::string("local_error_analysis[") + solar_system->names()[0] + "," +
solar_system->epoch_literal() + "," + *flags["integrator"] + "," +
DebugString(time_step) + "].wl");
LocalErrorAnalyser analyser(std::move(solar_system), integrator, time_step);
analyser.WriteLocalErrors(
out,
ParseFixedStepSizeIntegrator<Ephemeris<ICRS>::NewtonianMotionEquation>(
flags["fine_integrator"].value_or("BLANES_MOAN_2002_SRKN_14A")),
ParseQuantity<Time>(flags["fine_step"].value_or("1 min")),
ParseQuantity<Time>(flags["granularity"].value_or("1 d")),
ParseQuantity<Time>(flags["duration"].value_or("500 d")));
}

} // namespace mathematica
} // namespace principia
3 changes: 3 additions & 0 deletions mathematica/integrator_plots.cpp
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ using quantities::Speed;
using quantities::SpecificEnergy;
using quantities::Stiffness;
using quantities::Time;
using quantities::si::Degree;
using quantities::si::Joule;
using quantities::si::Kilogram;
using quantities::si::Metre;
@@ -375,6 +376,8 @@ void GenerateKeplerProblemWorkErrorGraphs(double const eccentricity) {
KeplerianElements<World> elements;
elements.semimajor_axis = 1 * Metre;
elements.eccentricity = eccentricity;
elements.argument_of_periapsis = 0 * Degree;
elements.true_anomaly = 0 * Degree;
KeplerOrbit<World> const orbit(b1, b2, elements, t0);

auto const initial_dof = orbit.StateVectors(t0);
121 changes: 0 additions & 121 deletions mathematica/main.cpp

This file was deleted.

9 changes: 2 additions & 7 deletions mathematica/mathematica.hpp
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
#include "geometry/r3_element.hpp"
#include "numerics/fixed_arrays.hpp"
#include "physics/degrees_of_freedom.hpp"
#include "physics/discrete_trajectory.hpp"
#include "quantities/quantities.hpp"

namespace principia {
@@ -26,7 +25,6 @@ using geometry::R3Element;
using geometry::Vector;
using numerics::FixedVector;
using physics::DegreesOfFreedom;
using physics::DiscreteTrajectory;
using quantities::Quantity;
using quantities::Quotient;

@@ -39,8 +37,6 @@ std::string Option(std::string const& name, T const& right);
template<typename T>
std::string Assign(std::string const& name, T const& right);

std::string Export(std::string const& file, std::string const& expression);

template<typename T, typename U>
std::string PlottableDataset(std::vector<T> const& x, std::vector<U> const& y);

@@ -64,10 +60,10 @@ template<typename D>
std::string ToMathematica(Quantity<D> const& quantity);

template<typename S, typename F>
std::string ToMathematica(Bivector<S, F> const& bivector);
std::string ToMathematica(Vector<S, F> const& vector);

template<typename S, typename F>
std::string ToMathematica(Vector<S, F> const& vector);
std::string ToMathematica(Bivector<S, F> const& bivector);

template<typename V>
std::string ToMathematica(Point<V> const& point);
@@ -118,7 +114,6 @@ typename RemoveUnit<std::vector<T>>::Unitless ExpressIn(
using internal_mathematica::Apply;
using internal_mathematica::Assign;
using internal_mathematica::Escape;
using internal_mathematica::Export;
using internal_mathematica::ExpressIn;
using internal_mathematica::Option;
using internal_mathematica::PlottableDataset;
3 changes: 2 additions & 1 deletion mathematica/mathematica.vcxproj
Original file line number Diff line number Diff line change
@@ -19,10 +19,11 @@
<ClCompile Include="..\base\status.cpp" />
<ClCompile Include="..\numerics\cbrt.cpp" />
<ClCompile Include="..\physics\protector.cpp" />
<ClCompile Include="error_analysis_test.cpp" />
<ClCompile Include="integrator_plots.cpp" />
<ClCompile Include="local_error_analysis.cpp" />
<ClCompile Include="mathematica_test.cpp" />
<ClCompile Include="retrobop_dynamical_stability.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="integrator_plots.hpp" />
12 changes: 9 additions & 3 deletions mathematica/mathematica.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -12,11 +12,11 @@
<Filter Include="Scripts">
<UniqueIdentifier>{4e3369e9-9c33-43ea-8662-581a7f97470b}</UniqueIdentifier>
</Filter>
<Filter Include="Test Files">
<UniqueIdentifier>{148dae9a-4f1b-44c1-892c-dd534b1cee4f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="integrator_plots.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -38,6 +38,12 @@
<ClCompile Include="..\physics\protector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mathematica_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="error_analysis_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mathematica.hpp">
Loading