diff --git a/benches/reference_scenarios.rs b/benches/reference_scenarios.rs index b87d56f..cc6e7ba 100644 --- a/benches/reference_scenarios.rs +++ b/benches/reference_scenarios.rs @@ -10,6 +10,12 @@ //! scenario. A ratio of times is therefore close to a ratio of per-step cost, which is //! the thing worth comparing. If a future scenario's step counts diverge, its timing //! ratio means nothing until they are brought back together. +//! +//! One scenario is not like for like however the steps come out. Orekit's radiation +//! pressure registers eclipse event detectors, so its integrator locates the shadow +//! boundaries by root finding; this crate integrates straight through them. That is work +//! Orekit does and this does not, and it is arguably the better treatment, so the +//! radiation row is not purely a speed difference. use std::path::Path; use std::sync::Arc; diff --git a/scripts/generate-orekit-fixtures.sh b/scripts/generate-orekit-fixtures.sh index dd5bea9..1bd8c5f 100755 --- a/scripts/generate-orekit-fixtures.sh +++ b/scripts/generate-orekit-fixtures.sh @@ -177,6 +177,13 @@ public class Generate { */ static class UnroundedWeather implements NRLMSISE00InputParameters { private final CssiSpaceWeatherData inner; + /** One average per day, because that is how often it changes. + * + * Without this the eighty-one lookups run on every density evaluation, which is + * every stage of every step: measured at 279 ms of a 641 ms arc, so the timing + * would have been reporting this wrapper rather than Orekit. + */ + private final java.util.Map cache = new java.util.HashMap<>(); UnroundedWeather(CssiSpaceWeatherData inner) { this.inner = inner; @@ -195,11 +202,19 @@ public class Generate { } public double getAverageFlux(AbsoluteDate date) { + long day = (long) Math.floor(date.durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH) + / 86400.0); + Double known = cache.get(day); + if (known != null) { + return known; + } double sum = 0.0; for (int offset = -39; offset <= 41; offset++) { sum += inner.getDailyFlux(date.shiftedBy(offset * 86400.0)); } - return sum / 81.0; + double average = sum / 81.0; + cache.put(day, average); + return average; } public double[] getAp(AbsoluteDate date) { @@ -558,7 +573,7 @@ public class Generate { */ static void time() throws Exception { String[] names = { "two-body", "gravity-8", "gravity-20", "third-body", "radiation", - "drag-harris-priester", "drag-msis" }; + "drag-harris-priester", "drag-msis", "drag-msis-plain" }; for (String name : names) { // Build it fresh each run: a propagator carries its state, and reusing one // would time a different thing the second time round. @@ -637,6 +652,17 @@ public class Generate { new OneAxisEllipsoid(EARTH_RADIUS, EARTH_FLATTENING, itrf), BULGE_EXPONENT), new IsotropicDrag(AREA, CD))); } + if (name.equals("drag-msis-plain")) { + // The same thing with CSSI's published average, to show what the recomputing + // wrapper costs rather than assuming it is free. + p.addForceModel(new DragForce(new NRLMSISE00( + new CssiSpaceWeatherData(CssiSpaceWeatherData.DEFAULT_SUPPORTED_NAMES), + (ExtendedPositionProvider) CelestialBodyFactory.getSun(), + new OneAxisEllipsoid(EARTH_RADIUS, EARTH_FLATTENING, itrf)) + .withLocalSolarTimeMode(NRLMSISE00.LocalSolarTimeMode.MEAN) + .withSwitch(9, -1), + new IsotropicDrag(AREA, CD))); + } if (name.equals("drag-msis")) { p.addForceModel(new DragForce(new NRLMSISE00( new UnroundedWeather(new CssiSpaceWeatherData( diff --git a/tests/fixtures/orekit/msis-drag-low-earth.json b/tests/fixtures/orekit/msis-drag-low-earth.json index 8bb4602..8900966 100644 --- a/tests/fixtures/orekit/msis-drag-low-earth.json +++ b/tests/fixtures/orekit/msis-drag-low-earth.json @@ -1451,6 +1451,6 @@ { "elapsed": 86220.0, "position": [-6.655014145e+06, -1.271109816e+06, 1.780541525e-02], "velocity": [1.438812276e+03, -7.534656147e+03, -2.631428161e-06] }, { "elapsed": 86280.0, "position": [-6.553405536e+06, -1.719910498e+06, 1.760646718e-02], "velocity": [1.946838261e+03, -7.419614578e+03, -3.997873341e-06] }, { "elapsed": 86340.0, "position": [-6.421573259e+06, -2.160779117e+06, 1.732600875e-02], "velocity": [2.445880382e+03, -7.270355853e+03, -5.347406004e-06] }, - { "elapsed": 86400.0, "position": [-6.260125651e+06, -2.591682544e+06, 1.696524000e-02], "velocity": [2.933636216e+03, -7.087569454e+03, -6.673865269e-06] } + { "elapsed": 86400.0, "position": [-6.260125651e+06, -2.591682544e+06, 1.696524000e-02], "velocity": [2.933636216e+03, -7.087569454e+03, -6.673865270e-06] } ] }