Search in sources :

Example 6 with ClassicalRungeKuttaIntegrator

use of org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator in project Orekit by CS-SI.

the class EventDetectorTest method testIssue108Numerical.

@Test
public void testIssue108Numerical() throws OrekitException {
    final TimeScale utc = TimeScalesFactory.getUTC();
    final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
    final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
    final double step = 60.0;
    final int n = 100;
    NumericalPropagator propagator = new NumericalPropagator(new ClassicalRungeKuttaIntegrator(step));
    propagator.resetInitialState(new SpacecraftState(orbit));
    GCallsCounter counter = new GCallsCounter(100000.0, 1.0e-6, 20, new StopOnEvent<GCallsCounter>());
    propagator.addEventDetector(counter);
    propagator.propagate(date.shiftedBy(n * step));
    Assert.assertEquals(n + 1, counter.getCount());
}
Also used : Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) PVCoordinates(org.orekit.utils.PVCoordinates) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) Test(org.junit.Test)

Example 7 with ClassicalRungeKuttaIntegrator

use of org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator in project Orekit by CS-SI.

the class MarshallSolarActivityFutureEstimationTest method getNumericalPropagator.

/**
 * Configure a numerical propagator.
 *
 * @param sun   Sun.
 * @param earth Earth.
 * @param ic    initial condition.
 * @return a propagator.
 * @throws OrekitException on error.
 */
private NumericalPropagator getNumericalPropagator(CelestialBody sun, OneAxisEllipsoid earth, SpacecraftState ic) throws OrekitException {
    // some non-integer step size to induce truncation error in flux interpolation
    final ODEIntegrator integrator = new ClassicalRungeKuttaIntegrator(120 + 0.1);
    NumericalPropagator propagator = new NumericalPropagator(integrator);
    DTM2000InputParameters flux = getFlux();
    final Atmosphere atmosphere = new DTM2000(flux, sun, earth);
    final IsotropicDrag satellite = new IsotropicDrag(1, 3.2);
    propagator.addForceModel(new DragForce(atmosphere, satellite));
    propagator.setInitialState(ic);
    propagator.setOrbitType(OrbitType.CARTESIAN);
    return propagator;
}
Also used : IsotropicDrag(org.orekit.forces.drag.IsotropicDrag) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) Atmosphere(org.orekit.forces.drag.atmosphere.Atmosphere) DragForce(org.orekit.forces.drag.DragForce) DTM2000(org.orekit.forces.drag.atmosphere.DTM2000) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) DTM2000InputParameters(org.orekit.forces.drag.atmosphere.DTM2000InputParameters)

Example 8 with ClassicalRungeKuttaIntegrator

use of org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator in project Orekit by CS-SI.

the class HolmesFeatherstoneAttractionModelTest method testZonalWithCunninghamReference.

// test the difference with the Cunningham model
@Test
@Deprecated
public void testZonalWithCunninghamReference() throws OrekitException {
    // initialization
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2000, 07, 01), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC());
    double i = FastMath.toRadians(98.7);
    double omega = FastMath.toRadians(93.0);
    double OMEGA = FastMath.toRadians(15.0 * 22.5);
    Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i, omega, OMEGA, 0, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
    propagator = new NumericalPropagator(new ClassicalRungeKuttaIntegrator(1000));
    propagator.addForceModel(new HolmesFeatherstoneAttractionModel(itrf, GravityFieldFactory.getNormalizedProvider(ae, mu, TideSystem.UNKNOWN, new double[][] { { 0.0 }, { 0.0 }, { normalizedC20 }, { normalizedC30 }, { normalizedC40 }, { normalizedC50 }, { normalizedC60 } }, new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 } })));
    propagator.setInitialState(new SpacecraftState(orbit));
    SpacecraftState hfOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY));
    propagator.removeForceModels();
    propagator.addForceModel(new CunninghamAttractionModel(itrf, GravityFieldFactory.getUnnormalizedProvider(ae, mu, TideSystem.UNKNOWN, new double[][] { { 0.0 }, { 0.0 }, { unnormalizedC20 }, { unnormalizedC30 }, { unnormalizedC40 }, { unnormalizedC50 }, { unnormalizedC60 } }, new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 } })));
    propagator.setInitialState(new SpacecraftState(orbit));
    SpacecraftState cOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY));
    Vector3D dif = hfOrb.getPVCoordinates().getPosition().subtract(cOrb.getPVCoordinates().getPosition());
    Assert.assertEquals(0, dif.getNorm(), 2e-9);
    Assert.assertTrue(propagator.getCalls() < 400);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) TimeComponents(org.orekit.time.TimeComponents) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 9 with ClassicalRungeKuttaIntegrator

use of org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator 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 10 with ClassicalRungeKuttaIntegrator

use of org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator in project Orekit by CS-SI.

the class EphemerisMode method main.

/**
 * Program entry point.
 * @param args program arguments (unused here)
 */
public static void main(String[] args) {
    try {
        // configure Orekit
        File home = new File(System.getProperty("user.home"));
        File orekitData = new File(home, "orekit-data");
        if (!orekitData.exists()) {
            System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
            System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
            System.exit(1);
        }
        DataProvidersManager manager = DataProvidersManager.getInstance();
        manager.addProvider(new DirectoryCrawler(orekitData));
        // Initial orbit parameters
        // semi major axis in meters
        double a = 24396159;
        // eccentricity
        double e = 0.72831215;
        // inclination
        double i = FastMath.toRadians(7);
        // perigee argument
        double omega = FastMath.toRadians(180);
        // right ascension of ascending node
        double raan = FastMath.toRadians(261);
        // mean anomaly
        double lM = 0;
        // Inertial frame
        Frame inertialFrame = FramesFactory.getEME2000();
        // Initial date in UTC time scale
        TimeScale utc = TimeScalesFactory.getUTC();
        AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
        // gravitation coefficient
        double mu = 3.986004415e+14;
        // Orbit construction as Keplerian
        Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu);
        // Initialize state
        SpacecraftState initialState = new SpacecraftState(initialOrbit);
        // Numerical propagation with no perturbation (only Keplerian movement)
        // Using a very simple integrator with a fixed step: classical Runge-Kutta
        // the step is ten seconds
        double stepSize = 10;
        AbstractIntegrator integrator = new ClassicalRungeKuttaIntegrator(stepSize);
        NumericalPropagator propagator = new NumericalPropagator(integrator);
        // Set the propagator to ephemeris mode
        propagator.setEphemerisMode();
        // Initialize propagation
        propagator.setInitialState(initialState);
        // Propagation with storage of the results in an integrated ephemeris
        SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(6000));
        System.out.println(" Numerical propagation :");
        System.out.println("  Final date : " + finalState.getDate());
        System.out.println("  " + finalState.getOrbit());
        // Getting the integrated ephemeris
        BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
        System.out.println(" Ephemeris defined from " + ephemeris.getMinDate() + " to " + ephemeris.getMaxDate());
        System.out.println(" Ephemeris propagation :");
        AbsoluteDate intermediateDate = initialDate.shiftedBy(3000);
        SpacecraftState intermediateState = ephemeris.propagate(intermediateDate);
        System.out.println("  date :  " + intermediateState.getDate());
        System.out.println("  " + intermediateState.getOrbit());
        intermediateDate = finalState.getDate();
        intermediateState = ephemeris.propagate(intermediateDate);
        System.out.println("  date :  " + intermediateState.getDate());
        System.out.println("  " + intermediateState.getOrbit());
        intermediateDate = initialDate.shiftedBy(-1000);
        System.out.println();
        System.out.println("Attempting to propagate to date " + intermediateDate + " which is OUT OF RANGE");
        System.out.println("This propagation attempt should fail, " + "so an error message shoud appear below, " + "this is expected and shows that errors are handled correctly");
        intermediateState = ephemeris.propagate(intermediateDate);
        // these two print should never happen as en exception should have been triggered
        System.out.println("  date :  " + intermediateState.getDate());
        System.out.println("  " + intermediateState.getOrbit());
    } catch (OrekitException oe) {
        System.out.println(oe.getMessage());
    }
}
Also used : Frame(org.orekit.frames.Frame) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) AbstractIntegrator(org.hipparchus.ode.AbstractIntegrator) DirectoryCrawler(org.orekit.data.DirectoryCrawler) DataProvidersManager(org.orekit.data.DataProvidersManager) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) File(java.io.File) BoundedPropagator(org.orekit.propagation.BoundedPropagator)

Aggregations

ClassicalRungeKuttaIntegrator (org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator)10 Test (org.junit.Test)7 SpacecraftState (org.orekit.propagation.SpacecraftState)7 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)6 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)6 AbsoluteDate (org.orekit.time.AbsoluteDate)5 Orbit (org.orekit.orbits.Orbit)4 Frame (org.orekit.frames.Frame)3 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)3 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)2 AbstractIntegrator (org.hipparchus.ode.AbstractIntegrator)2 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)2 CartesianOrbit (org.orekit.orbits.CartesianOrbit)2 CircularOrbit (org.orekit.orbits.CircularOrbit)2 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)2 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)2 AbstractIntegratedPropagator (org.orekit.propagation.integration.AbstractIntegratedPropagator)2 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)2 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)2 TimeScale (org.orekit.time.TimeScale)2