Search in sources :

Example 41 with DormandPrince853Integrator

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

the class NodeDetectorTest method testIssue138.

@Test
public void testIssue138() throws OrekitException {
    double a = 800000 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
    double e = 0.0001;
    double i = FastMath.toRadians(98);
    double w = -90;
    double raan = 0;
    double v = 0;
    Frame inertialFrame = FramesFactory.getEME2000();
    AbsoluteDate initialDate = new AbsoluteDate(2014, 01, 01, 0, 0, 0, TimeScalesFactory.getUTC());
    AbsoluteDate finalDate = initialDate.shiftedBy(5000);
    KeplerianOrbit initialOrbit = new KeplerianOrbit(a, e, i, w, raan, v, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU);
    SpacecraftState initialState = new SpacecraftState(initialOrbit, 1000);
    double[][] tol = NumericalPropagator.tolerances(10, initialOrbit, initialOrbit.getType());
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    NumericalPropagator propagator = new NumericalPropagator(integrator);
    propagator.setInitialState(initialState);
    // Define 2 instances of NodeDetector:
    EventDetector rawDetector = new NodeDetector(1e-6, initialState.getOrbit(), initialState.getFrame()).withHandler(new ContinueOnEvent<NodeDetector>());
    EventsLogger logger1 = new EventsLogger();
    EventDetector node1 = logger1.monitorDetector(rawDetector);
    EventsLogger logger2 = new EventsLogger();
    EventDetector node2 = logger2.monitorDetector(rawDetector);
    propagator.addEventDetector(node1);
    propagator.addEventDetector(node2);
    // First propagation
    propagator.setEphemerisMode();
    propagator.propagate(finalDate);
    Assert.assertEquals(2, logger1.getLoggedEvents().size());
    Assert.assertEquals(2, logger2.getLoggedEvents().size());
    logger1.clearLoggedEvents();
    logger2.clearLoggedEvents();
    BoundedPropagator postpro = propagator.getGeneratedEphemeris();
    // Post-processing
    postpro.addEventDetector(node1);
    postpro.addEventDetector(node2);
    postpro.propagate(finalDate);
    Assert.assertEquals(2, logger1.getLoggedEvents().size());
    Assert.assertEquals(2, logger2.getLoggedEvents().size());
}
Also used : Frame(org.orekit.frames.Frame) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Test(org.junit.Test)

Example 42 with DormandPrince853Integrator

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

the class IntegratedEphemerisTest method setUp.

@Before
public void setUp() {
    Utils.setDataRoot("regular-data:potential/icgem-format");
    GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("eigen-6s-truncated", true));
    // Definition of initial conditions with position and velocity
    Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
    Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
    double mu = 3.9860047e14;
    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
    initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    // Numerical propagator definition
    double[] absTolerance = { 0.0001, 1.0e-11, 1.0e-11, 1.0e-8, 1.0e-8, 1.0e-8, 0.001 };
    double[] relTolerance = { 1.0e-8, 1.0e-8, 1.0e-8, 1.0e-9, 1.0e-9, 1.0e-9, 1.0e-7 };
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 500, absTolerance, relTolerance);
    integrator.setInitialStepSize(100);
    numericalPropagator = new NumericalPropagator(integrator);
}
Also used : ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) PVCoordinates(org.orekit.utils.PVCoordinates) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) AbsoluteDate(org.orekit.time.AbsoluteDate) Before(org.junit.Before)

Example 43 with DormandPrince853Integrator

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

the class SolarBodyTest method testPropagationVsEphemeris.

@Test
public void testPropagationVsEphemeris() throws OrekitException {
    Utils.setDataRoot("regular-data");
    // Creation of the celestial bodies of the solar system
    final CelestialBody sun = CelestialBodyFactory.getSun();
    final CelestialBody mercury = CelestialBodyFactory.getMercury();
    final CelestialBody venus = CelestialBodyFactory.getVenus();
    final CelestialBody earth = CelestialBodyFactory.getEarth();
    final CelestialBody mars = CelestialBodyFactory.getMars();
    final CelestialBody jupiter = CelestialBodyFactory.getJupiter();
    final CelestialBody saturn = CelestialBodyFactory.getSaturn();
    final CelestialBody uranus = CelestialBodyFactory.getUranus();
    final CelestialBody neptune = CelestialBodyFactory.getNeptune();
    final CelestialBody pluto = CelestialBodyFactory.getPluto();
    // Starting and end dates
    final AbsoluteDate startingDate = new AbsoluteDate(2000, 1, 2, TimeScalesFactory.getUTC());
    AbsoluteDate endDate = startingDate.shiftedBy(30 * Constants.JULIAN_DAY);
    final Frame icrf = FramesFactory.getICRF();
    // fake orbit around negligible point mass at solar system barycenter
    double negligibleMu = 1.0e-3;
    SpacecraftState initialState = new SpacecraftState(new CartesianOrbit(venus.getPVCoordinates(startingDate, icrf), icrf, startingDate, negligibleMu));
    // Creation of the numerical propagator
    final double[][] tol = NumericalPropagator.tolerances(1000, initialState.getOrbit(), OrbitType.CARTESIAN);
    AbstractIntegrator dop1 = new DormandPrince853Integrator(1.0, 1.0e5, tol[0], tol[1]);
    NumericalPropagator propag = new NumericalPropagator(dop1);
    propag.setOrbitType(OrbitType.CARTESIAN);
    propag.setInitialState(initialState);
    propag.setMu(negligibleMu);
    // Creation of the ForceModels
    propag.addForceModel(new BodyAttraction(sun));
    propag.addForceModel(new BodyAttraction(mercury));
    propag.addForceModel(new BodyAttraction(earth));
    propag.addForceModel(new BodyAttraction(mars));
    propag.addForceModel(new BodyAttraction(jupiter));
    propag.addForceModel(new BodyAttraction(saturn));
    propag.addForceModel(new BodyAttraction(uranus));
    propag.addForceModel(new BodyAttraction(neptune));
    propag.addForceModel(new BodyAttraction(pluto));
    // checks are done within the step handler
    propag.setMasterMode(1000.0, new OrekitFixedStepHandler() {

        public void handleStep(SpacecraftState currentState, boolean isLast) throws OrekitException {
            // propagated position should remain within 1400m of ephemeris for one month
            Vector3D propagatedP = currentState.getPVCoordinates(icrf).getPosition();
            Vector3D ephemerisP = venus.getPVCoordinates(currentState.getDate(), icrf).getPosition();
            Assert.assertEquals(0, Vector3D.distance(propagatedP, ephemerisP), 1400.0);
        }
    });
    propag.propagate(startingDate, endDate);
}
Also used : Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) AbstractIntegrator(org.hipparchus.ode.AbstractIntegrator) OrekitException(org.orekit.errors.OrekitException) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) Test(org.junit.Test)

Example 44 with DormandPrince853Integrator

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

the class AttitudesSequenceTest method testResetDuringTransitionForward.

@Test
public void testResetDuringTransitionForward() throws OrekitException {
    // Initial state definition : date, orbit
    final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final TopocentricFrame volgograd = new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(48.7), FastMath.toRadians(44.5), 24.0), "Волгоград");
    final AttitudesSequence attitudesSequence = new AttitudesSequence();
    final double transitionTime = 250.0;
    final AttitudeProvider nadirPointing = new NadirPointing(initialOrbit.getFrame(), earth);
    final AttitudeProvider targetPointing = new TargetPointing(initialOrbit.getFrame(), volgograd.getPoint(), earth);
    final ElevationDetector eventDetector = new ElevationDetector(volgograd).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<>());
    final List<AbsoluteDate> nadirToTarget = new ArrayList<>();
    attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, (previous, next, state) -> nadirToTarget.add(state.getDate()));
    final double[][] tolerance = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
    final AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 300.0, tolerance[0], tolerance[1]);
    final NumericalPropagator propagator = new NumericalPropagator(integrator);
    GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
    propagator.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), GravityFieldFactory.getNormalizedProvider(8, 8)));
    propagator.setInitialState(new SpacecraftState(initialOrbit, nadirPointing.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame())));
    propagator.setAttitudeProvider(attitudesSequence);
    attitudesSequence.registerSwitchEvents(propagator);
    propagator.propagate(initialDate.shiftedBy(6000));
    // check that if we restart a forward propagation from an intermediate state
    // we properly get an interpolated attitude despite we missed the event trigger
    final AbsoluteDate midTransition = nadirToTarget.get(0).shiftedBy(0.5 * transitionTime);
    SpacecraftState state = propagator.propagate(midTransition.shiftedBy(-60), midTransition);
    Rotation nadirR = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
    Rotation targetR = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
    final double reorientationAngle = Rotation.distance(nadirR, targetR);
    Assert.assertEquals(0.5 * reorientationAngle, Rotation.distance(state.getAttitude().getRotation(), nadirR), 0.03 * reorientationAngle);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) ElevationDetector(org.orekit.propagation.events.ElevationDetector) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) ArrayList(java.util.ArrayList) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) FieldOrbit(org.orekit.orbits.FieldOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Example 45 with DormandPrince853Integrator

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

the class AttitudesSequenceTest method testOutOfSyncCalls.

@Test
public void testOutOfSyncCalls() throws OrekitException {
    // Initial state definition : date, orbit
    final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final TopocentricFrame volgograd = new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(48.7), FastMath.toRadians(44.5), 24.0), "Волгоград");
    final AttitudesSequence attitudesSequence = new AttitudesSequence();
    final double transitionTime = 250.0;
    final AttitudeProvider nadirPointing = new NadirPointing(initialOrbit.getFrame(), earth);
    final AttitudeProvider targetPointing = new TargetPointing(initialOrbit.getFrame(), volgograd.getPoint(), earth);
    final ElevationDetector eventDetector = new ElevationDetector(volgograd).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<>());
    final Handler nadirToTarget = new Handler(nadirPointing, targetPointing);
    attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, nadirToTarget);
    final Handler targetToNadir = new Handler(targetPointing, nadirPointing);
    attitudesSequence.addSwitchingCondition(targetPointing, nadirPointing, eventDetector, false, true, transitionTime, AngularDerivativesFilter.USE_RR, targetToNadir);
    final double[][] tolerance = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
    final AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 300.0, tolerance[0], tolerance[1]);
    final NumericalPropagator propagator = new NumericalPropagator(integrator);
    GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
    propagator.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), GravityFieldFactory.getNormalizedProvider(8, 8)));
    propagator.setInitialState(new SpacecraftState(initialOrbit, nadirPointing.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame())));
    propagator.setAttitudeProvider(attitudesSequence);
    attitudesSequence.registerSwitchEvents(propagator);
    propagator.setMasterMode(10, (state, isLast) -> {
        Attitude nadirAttitude = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
        Attitude targetAttitude = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
        Attitude stateAttitude = state.getAttitude();
        if (nadirToTarget.dates.isEmpty() || state.getDate().durationFrom(nadirToTarget.dates.get(0)) < 0) {
            // we are stabilized in nadir pointing, before first switch
            checkEqualAttitudes(nadirAttitude, stateAttitude);
        } else if (state.getDate().durationFrom(nadirToTarget.dates.get(0)) <= transitionTime) {
            // we are in transition from nadir to target
            checkBetweenAttitudes(nadirAttitude, targetAttitude, stateAttitude);
        } else if (targetToNadir.dates.isEmpty() || state.getDate().durationFrom(targetToNadir.dates.get(0)) < 0) {
            // we are stabilized in target pointing between the two switches
            checkEqualAttitudes(targetAttitude, stateAttitude);
        } else if (state.getDate().durationFrom(targetToNadir.dates.get(0)) <= transitionTime) {
            // we are in transition from target to nadir
            checkBetweenAttitudes(targetAttitude, nadirAttitude, stateAttitude);
        } else {
            // we are stabilized back in nadir pointing, after second switch
            checkEqualAttitudes(nadirAttitude, stateAttitude);
        }
    });
    propagator.propagate(initialDate.shiftedBy(6000));
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) FieldOrbit(org.orekit.orbits.FieldOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) ElevationDetector(org.orekit.propagation.events.ElevationDetector) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldOrekitFixedStepHandler(org.orekit.propagation.sampling.FieldOrekitFixedStepHandler) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) EventHandler(org.orekit.propagation.events.handlers.EventHandler) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Aggregations

DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)83 SpacecraftState (org.orekit.propagation.SpacecraftState)69 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)63 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)51 Test (org.junit.Test)51 AbsoluteDate (org.orekit.time.AbsoluteDate)47 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)42 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)40 Orbit (org.orekit.orbits.Orbit)36 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)32 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)32 CartesianOrbit (org.orekit.orbits.CartesianOrbit)31 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)30 OrbitType (org.orekit.orbits.OrbitType)29 PVCoordinates (org.orekit.utils.PVCoordinates)29 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)27 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)26 Frame (org.orekit.frames.Frame)25 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)20 DateComponents (org.orekit.time.DateComponents)18