Search in sources :

Example 1 with DSSTPropagator

use of org.orekit.propagation.semianalytical.dsst.DSSTPropagator in project Orekit by CS-SI.

the class AdditionalEquationsTest method testInitDSST.

/**
 * Test for issue #401
 *  with a DSST propagator
 */
@Test
public void testInitDSST() throws OrekitException {
    // setup
    final double reference = 3.5;
    InitCheckerEquations checker = new InitCheckerEquations(reference);
    Assert.assertFalse(checker.wasCalled());
    // action
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(60);
    DSSTPropagator propagatorDSST = new DSSTPropagator(integrator);
    propagatorDSST.setInitialState(initialState.addAdditionalState(checker.getName(), reference));
    propagatorDSST.addAdditionalEquations(checker);
    propagatorDSST.propagate(initDate.shiftedBy(600));
    // verify
    Assert.assertTrue(checker.wasCalled());
}
Also used : AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) DSSTPropagator(org.orekit.propagation.semianalytical.dsst.DSSTPropagator) Test(org.junit.Test)

Example 2 with DSSTPropagator

use of org.orekit.propagation.semianalytical.dsst.DSSTPropagator in project Orekit by CS-SI.

the class IntegratedEphemerisTest method doTestSerializationDSST.

private void doTestSerializationDSST(boolean meanOnly, int expectedSize) throws OrekitException, IOException, ClassNotFoundException {
    AbsoluteDate finalDate = initialOrbit.getDate().shiftedBy(Constants.JULIAN_DAY);
    final double[][] tol = DSSTPropagator.tolerances(1.0, initialOrbit);
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(10, Constants.JULIAN_DAY, tol[0], tol[1]);
    DSSTPropagator dsstProp = new DSSTPropagator(integrator, meanOnly);
    dsstProp.setInitialState(new SpacecraftState(initialOrbit), false);
    dsstProp.setEphemerisMode();
    final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    final UnnormalizedSphericalHarmonicsProvider gravity = GravityFieldFactory.getUnnormalizedProvider(8, 8);
    final CelestialBody sun = CelestialBodyFactory.getSun();
    final CelestialBody moon = CelestialBodyFactory.getMoon();
    final RadiationSensitive spacecraft = new IsotropicRadiationSingleCoefficient(20.0, 2.0);
    dsstProp.addForceModel(new DSSTZonal(gravity, 8, 7, 17));
    dsstProp.addForceModel(new DSSTTesseral(itrf, Constants.WGS84_EARTH_ANGULAR_VELOCITY, gravity, 8, 8, 4, 12, 8, 8, 4));
    dsstProp.addForceModel(new DSSTThirdBody(sun));
    dsstProp.addForceModel(new DSSTThirdBody(moon));
    dsstProp.addForceModel(new DSSTSolarRadiationPressure(sun, Constants.WGS84_EARTH_EQUATORIAL_RADIUS, spacecraft));
    dsstProp.propagate(finalDate);
    IntegratedEphemeris ephemeris = (IntegratedEphemeris) dsstProp.getGeneratedEphemeris();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(ephemeris);
    Assert.assertTrue("size = " + bos.size(), bos.size() > 9 * expectedSize / 10);
    Assert.assertTrue("size = " + bos.size(), bos.size() < 11 * expectedSize / 10);
    Assert.assertNotNull(ephemeris.getFrame());
    Assert.assertSame(ephemeris.getFrame(), dsstProp.getFrame());
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    IntegratedEphemeris deserialized = (IntegratedEphemeris) ois.readObject();
    Assert.assertEquals(deserialized.getMinDate(), deserialized.getMinDate());
    Assert.assertEquals(deserialized.getMaxDate(), deserialized.getMaxDate());
}
Also used : Frame(org.orekit.frames.Frame) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DSSTZonal(org.orekit.propagation.semianalytical.dsst.forces.DSSTZonal) RadiationSensitive(org.orekit.forces.radiation.RadiationSensitive) DSSTTesseral(org.orekit.propagation.semianalytical.dsst.forces.DSSTTesseral) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) AbsoluteDate(org.orekit.time.AbsoluteDate) DSSTSolarRadiationPressure(org.orekit.propagation.semianalytical.dsst.forces.DSSTSolarRadiationPressure) SpacecraftState(org.orekit.propagation.SpacecraftState) DSSTThirdBody(org.orekit.propagation.semianalytical.dsst.forces.DSSTThirdBody) UnnormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider) ByteArrayInputStream(java.io.ByteArrayInputStream) CelestialBody(org.orekit.bodies.CelestialBody) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) IsotropicRadiationSingleCoefficient(org.orekit.forces.radiation.IsotropicRadiationSingleCoefficient) DSSTPropagator(org.orekit.propagation.semianalytical.dsst.DSSTPropagator) ObjectInputStream(java.io.ObjectInputStream)

Example 3 with DSSTPropagator

use of org.orekit.propagation.semianalytical.dsst.DSSTPropagator in project Orekit by CS-SI.

the class DSSTPropagation method createDSSTProp.

/**
 * Set up the DSST Propagator
 *
 *  @param orbit initial orbit
 *  @param mass S/C mass (kg)
 *  @param initialIsOsculating if initial orbital elements are osculating
 *  @param outputIsOsculating if we want to output osculating parameters
 *  @param fixedStepSize step size for fixed step integrator (s)
 *  @param minStep minimum step size, if step is not fixed (s)
 *  @param maxStep maximum step size, if step is not fixed (s)
 *  @param dP position tolerance for step size control, if step is not fixed (m)
 *  @param shortPeriodCoefficients list of short periodic coefficients
 *  to output (null means no coefficients at all, empty list means all
 *  possible coefficients)
 *  @throws OrekitException
 */
private DSSTPropagator createDSSTProp(final Orbit orbit, final double mass, final boolean initialIsOsculating, final boolean outputIsOsculating, final double fixedStepSize, final double minStep, final double maxStep, final double dP, final List<String> shortPeriodCoefficients) throws OrekitException {
    AbstractIntegrator integrator;
    if (fixedStepSize > 0.) {
        integrator = new ClassicalRungeKuttaIntegrator(fixedStepSize);
    } else {
        final double[][] tol = DSSTPropagator.tolerances(dP, orbit);
        integrator = new DormandPrince853Integrator(minStep, maxStep, tol[0], tol[1]);
        ((AdaptiveStepsizeIntegrator) integrator).setInitialStepSize(10. * minStep);
    }
    DSSTPropagator dsstProp = new DSSTPropagator(integrator, !outputIsOsculating);
    dsstProp.setInitialState(new SpacecraftState(orbit, mass), initialIsOsculating);
    dsstProp.setSelectedCoefficients(shortPeriodCoefficients == null ? null : new HashSet<String>(shortPeriodCoefficients));
    return dsstProp;
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) AbstractIntegrator(org.hipparchus.ode.AbstractIntegrator) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) DSSTPropagator(org.orekit.propagation.semianalytical.dsst.DSSTPropagator) HashSet(java.util.HashSet)

Example 4 with DSSTPropagator

use of org.orekit.propagation.semianalytical.dsst.DSSTPropagator in project Orekit by CS-SI.

the class DSSTPropagation method run.

private void run(final File input, final File output) throws IOException, IllegalArgumentException, OrekitException, ParseException {
    // read input parameters
    KeyValueFileParser<ParameterKey> parser = new KeyValueFileParser<ParameterKey>(ParameterKey.class);
    try (final FileInputStream fis = new FileInputStream(input)) {
        parser.parseInput(input.getAbsolutePath(), fis);
    }
    // check mandatory input parameters
    if (!parser.containsKey(ParameterKey.ORBIT_DATE)) {
        throw new IOException("Orbit date is not defined.");
    }
    if (!parser.containsKey(ParameterKey.DURATION) && !parser.containsKey(ParameterKey.DURATION_IN_DAYS)) {
        throw new IOException("Propagation duration is not defined.");
    }
    // All dates in UTC
    final TimeScale utc = TimeScalesFactory.getUTC();
    final double rotationRate;
    if (!parser.containsKey(ParameterKey.CENTRAL_BODY_ROTATION_RATE)) {
        rotationRate = Constants.WGS84_EARTH_ANGULAR_VELOCITY;
    } else {
        rotationRate = parser.getDouble(ParameterKey.CENTRAL_BODY_ROTATION_RATE);
    }
    final int degree = parser.getInt(ParameterKey.CENTRAL_BODY_DEGREE);
    final int order = FastMath.min(degree, parser.getInt(ParameterKey.CENTRAL_BODY_ORDER));
    // Potential coefficients providers
    final UnnormalizedSphericalHarmonicsProvider unnormalized = GravityFieldFactory.getConstantUnnormalizedProvider(degree, order);
    final NormalizedSphericalHarmonicsProvider normalized = GravityFieldFactory.getConstantNormalizedProvider(degree, order);
    // Central body attraction coefficient (m³/s²)
    final double mu = unnormalized.getMu();
    // Earth frame definition
    final Frame earthFrame;
    if (!parser.containsKey(ParameterKey.BODY_FRAME)) {
        earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    } else {
        earthFrame = parser.getEarthFrame(ParameterKey.BODY_FRAME);
    }
    // Orbit definition
    final Orbit orbit = createOrbit(parser, utc, mu);
    // DSST propagator definition
    double mass = 1000.0;
    if (parser.containsKey(ParameterKey.MASS)) {
        mass = parser.getDouble(ParameterKey.MASS);
    }
    boolean initialIsOsculating = false;
    if (parser.containsKey(ParameterKey.INITIAL_ORBIT_IS_OSCULATING)) {
        initialIsOsculating = parser.getBoolean(ParameterKey.INITIAL_ORBIT_IS_OSCULATING);
    }
    boolean outputIsOsculating = initialIsOsculating;
    if (parser.containsKey(ParameterKey.OUTPUT_ORBIT_IS_OSCULATING)) {
        outputIsOsculating = parser.getBoolean(ParameterKey.OUTPUT_ORBIT_IS_OSCULATING);
    }
    List<String> shortPeriodCoefficients = null;
    if (parser.containsKey(ParameterKey.OUTPUT_SHORT_PERIOD_COEFFICIENTS)) {
        shortPeriodCoefficients = parser.getStringsList(ParameterKey.OUTPUT_SHORT_PERIOD_COEFFICIENTS, ',');
        if (shortPeriodCoefficients.size() == 1 && shortPeriodCoefficients.get(0).equalsIgnoreCase("all")) {
            // special case, we use the empty list to represent all possible (unknown) keys
            // we don't use Collections.emptyList() because we want the list to be populated later on
            shortPeriodCoefficients = new ArrayList<String>();
        } else if (shortPeriodCoefficients.size() == 1 && shortPeriodCoefficients.get(0).equalsIgnoreCase("none")) {
            // special case, we use null to select no coefficients at all
            shortPeriodCoefficients = null;
        } else {
            // general case, we have an explicit list of coefficients names
            Collections.sort(shortPeriodCoefficients);
        }
        if (shortPeriodCoefficients != null && !outputIsOsculating) {
            System.out.println("\nWARNING:");
            System.out.println("Short periodic coefficients can be output only if output orbit is osculating.");
            System.out.println("No coefficients will be computed here.\n");
        }
    }
    double fixedStepSize = -1.;
    double minStep = 6000.0;
    double maxStep = 86400.0;
    double dP = 1.0;
    if (parser.containsKey(ParameterKey.FIXED_INTEGRATION_STEP)) {
        fixedStepSize = parser.getDouble(ParameterKey.FIXED_INTEGRATION_STEP);
    } else {
        if (parser.containsKey(ParameterKey.MIN_VARIABLE_INTEGRATION_STEP)) {
            minStep = parser.getDouble(ParameterKey.MIN_VARIABLE_INTEGRATION_STEP);
        }
        if (parser.containsKey(ParameterKey.MAX_VARIABLE_INTEGRATION_STEP)) {
            maxStep = parser.getDouble(ParameterKey.MAX_VARIABLE_INTEGRATION_STEP);
        }
        if (parser.containsKey(ParameterKey.POSITION_TOLERANCE_VARIABLE_INTEGRATION_STEP)) {
            dP = parser.getDouble(ParameterKey.POSITION_TOLERANCE_VARIABLE_INTEGRATION_STEP);
        }
    }
    final DSSTPropagator dsstProp = createDSSTProp(orbit, mass, initialIsOsculating, outputIsOsculating, fixedStepSize, minStep, maxStep, dP, shortPeriodCoefficients);
    if (parser.containsKey(ParameterKey.FIXED_NUMBER_OF_INTERPOLATION_POINTS)) {
        if (parser.containsKey(ParameterKey.MAX_TIME_GAP_BETWEEN_INTERPOLATION_POINTS)) {
            throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "cannot specify both fixed.number.of.interpolation.points" + " and max.time.gap.between.interpolation.points");
        }
        dsstProp.setInterpolationGridToFixedNumberOfPoints(parser.getInt(ParameterKey.FIXED_NUMBER_OF_INTERPOLATION_POINTS));
    } else if (parser.containsKey(ParameterKey.MAX_TIME_GAP_BETWEEN_INTERPOLATION_POINTS)) {
        dsstProp.setInterpolationGridToMaxTimeGap(parser.getDouble(ParameterKey.MAX_TIME_GAP_BETWEEN_INTERPOLATION_POINTS));
    } else {
        dsstProp.setInterpolationGridToFixedNumberOfPoints(3);
    }
    // Set Force models
    setForceModel(parser, unnormalized, earthFrame, rotationRate, dsstProp);
    // Simulation properties
    AbsoluteDate start;
    if (parser.containsKey(ParameterKey.START_DATE)) {
        start = parser.getDate(ParameterKey.START_DATE, utc);
    } else {
        start = parser.getDate(ParameterKey.ORBIT_DATE, utc);
    }
    double duration = 0.;
    if (parser.containsKey(ParameterKey.DURATION)) {
        duration = parser.getDouble(ParameterKey.DURATION);
    }
    if (parser.containsKey(ParameterKey.DURATION_IN_DAYS)) {
        duration = parser.getDouble(ParameterKey.DURATION_IN_DAYS) * Constants.JULIAN_DAY;
    }
    double outStep = parser.getDouble(ParameterKey.OUTPUT_STEP);
    boolean displayKeplerian = true;
    if (parser.containsKey(ParameterKey.OUTPUT_KEPLERIAN)) {
        displayKeplerian = parser.getBoolean(ParameterKey.OUTPUT_KEPLERIAN);
    }
    boolean displayEquinoctial = true;
    if (parser.containsKey(ParameterKey.OUTPUT_EQUINOCTIAL)) {
        displayEquinoctial = parser.getBoolean(ParameterKey.OUTPUT_EQUINOCTIAL);
    }
    boolean displayCartesian = true;
    if (parser.containsKey(ParameterKey.OUTPUT_CARTESIAN)) {
        displayCartesian = parser.getBoolean(ParameterKey.OUTPUT_CARTESIAN);
    }
    // DSST Propagation
    dsstProp.setEphemerisMode();
    final double dsstOn = System.currentTimeMillis();
    dsstProp.propagate(start, start.shiftedBy(duration));
    final double dsstOff = System.currentTimeMillis();
    System.out.println("DSST execution time (without large file write) : " + (dsstOff - dsstOn) / 1000.);
    System.out.println("writing file...");
    final BoundedPropagator dsstEphem = dsstProp.getGeneratedEphemeris();
    dsstEphem.setMasterMode(outStep, new OutputHandler(output, displayKeplerian, displayEquinoctial, displayCartesian, shortPeriodCoefficients));
    dsstEphem.propagate(start, start.shiftedBy(duration));
    System.out.println("DSST results saved as file " + output);
    // Check if we want to compare numerical to DSST propagator (default is false)
    if (parser.containsKey(ParameterKey.NUMERICAL_COMPARISON) && parser.getBoolean(ParameterKey.NUMERICAL_COMPARISON)) {
        if (!outputIsOsculating) {
            System.out.println("\nWARNING:");
            System.out.println("The DSST propagator considers a mean orbit while the numerical will consider an osculating one.");
            System.out.println("The comparison will be meaningless.\n");
        }
        // Numerical propagator definition
        final NumericalPropagator numProp = createNumProp(orbit, mass);
        // Set Force models
        setForceModel(parser, normalized, earthFrame, numProp);
        // Numerical Propagation without output
        numProp.setEphemerisMode();
        final double numOn = System.currentTimeMillis();
        numProp.propagate(start, start.shiftedBy(duration));
        final double numOff = System.currentTimeMillis();
        System.out.println("Numerical execution time (including output): " + (numOff - numOn) / 1000.);
        // Add output
        final BoundedPropagator numEphemeris = numProp.getGeneratedEphemeris();
        File numOutput = new File(input.getParentFile(), "numerical-propagation.out");
        numEphemeris.setMasterMode(outStep, new OutputHandler(numOutput, displayKeplerian, displayEquinoctial, displayCartesian, null));
        System.out.println("Writing file, this may take some time ...");
        numEphemeris.propagate(numEphemeris.getMaxDate());
        System.out.println("Numerical results saved as file " + numOutput);
    }
}
Also used : KeyValueFileParser(fr.cs.examples.KeyValueFileParser) Frame(org.orekit.frames.Frame) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) IOException(java.io.IOException) TimeScale(org.orekit.time.TimeScale) FileInputStream(java.io.FileInputStream) AbsoluteDate(org.orekit.time.AbsoluteDate) UnnormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) OrekitException(org.orekit.errors.OrekitException) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) BoundedPropagator(org.orekit.propagation.BoundedPropagator) File(java.io.File) DSSTPropagator(org.orekit.propagation.semianalytical.dsst.DSSTPropagator)

Aggregations

DSSTPropagator (org.orekit.propagation.semianalytical.dsst.DSSTPropagator)4 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)3 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)3 UnnormalizedSphericalHarmonicsProvider (org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider)2 Frame (org.orekit.frames.Frame)2 SpacecraftState (org.orekit.propagation.SpacecraftState)2 AbsoluteDate (org.orekit.time.AbsoluteDate)2 KeyValueFileParser (fr.cs.examples.KeyValueFileParser)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 HashSet (java.util.HashSet)1 AbstractIntegrator (org.hipparchus.ode.AbstractIntegrator)1 ClassicalRungeKuttaIntegrator (org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator)1 Test (org.junit.Test)1 CelestialBody (org.orekit.bodies.CelestialBody)1