Search in sources :

Example 26 with DateDetector

use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.

the class AttitudesSequenceTest method testTooShortTransition.

@Test
public void testTooShortTransition() {
    double threshold = 1.5;
    double transitionTime = 0.5;
    try {
        new AttitudesSequence().addSwitchingCondition(new InertialProvider(Rotation.IDENTITY), new InertialProvider(Rotation.IDENTITY), new DateDetector(1000.0, threshold, AbsoluteDate.J2000_EPOCH), true, false, transitionTime, AngularDerivativesFilter.USE_R, null);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.TOO_SHORT_TRANSITION_TIME_FOR_ATTITUDES_SWITCH, oe.getSpecifier());
        Assert.assertEquals(transitionTime, ((Double) oe.getParts()[0]).doubleValue(), 1.0e-10);
        Assert.assertEquals(threshold, ((Double) oe.getParts()[1]).doubleValue(), 1.0e-10);
    }
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Example 27 with DateDetector

use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.

the class PropagatorsParallelizerTest method testOrekitException.

@Test
public void testOrekitException() throws OrekitException {
    final AbsoluteDate startDate = orbit.getDate();
    final AbsoluteDate endDate = startDate.shiftedBy(3600.0);
    List<Propagator> propagators = Arrays.asList(buildEcksteinHechler(), buildNumerical());
    propagators.get(0).addEventDetector(new DateDetector(startDate.shiftedBy(900.0)).withHandler((state, detector, increasing) -> {
        throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "inTest");
    }));
    try {
        new PropagatorsParallelizer(propagators, (interpolators, isLast) -> {
        }).propagate(startDate, endDate);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertNull(oe.getCause());
        Assert.assertEquals(LocalizedCoreFormats.SIMPLE_MESSAGE, oe.getSpecifier());
        Assert.assertEquals("inTest", (String) oe.getParts()[0]);
    }
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) Arrays(java.util.Arrays) ForceModel(org.orekit.forces.ForceModel) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) IERSConventions(org.orekit.utils.IERSConventions) Orbit(org.orekit.orbits.Orbit) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) After(org.junit.After) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) OrbitType(org.orekit.orbits.OrbitType) PositionAngle(org.orekit.orbits.PositionAngle) DateDetector(org.orekit.propagation.events.DateDetector) FastMath(org.hipparchus.util.FastMath) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Utils(org.orekit.Utils) Before(org.junit.Before) Constants(org.orekit.utils.Constants) DateComponents(org.orekit.time.DateComponents) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FramesFactory(org.orekit.frames.FramesFactory) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Test(org.junit.Test) GravityFieldFactory(org.orekit.forces.gravity.potential.GravityFieldFactory) OrekitMessages(org.orekit.errors.OrekitMessages) List(java.util.List) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) OrekitException(org.orekit.errors.OrekitException) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) TimeScalesFactory(org.orekit.time.TimeScalesFactory) LocalizedCoreFormats(org.hipparchus.exception.LocalizedCoreFormats) TimeComponents(org.orekit.time.TimeComponents) Assert(org.junit.Assert) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) UnnormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) OrekitException(org.orekit.errors.OrekitException) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 28 with DateDetector

use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.

the class PropagatorsParallelizerTest method testStopOnEarlyEvent.

@Test
public void testStopOnEarlyEvent() throws OrekitException {
    final AbsoluteDate startDate = orbit.getDate();
    final AbsoluteDate endDate = startDate.shiftedBy(3600.0);
    final AbsoluteDate stopDate = startDate.shiftedBy(0.01);
    List<Propagator> propagators = Arrays.asList(buildEcksteinHechler(), buildNumerical());
    propagators.get(0).addEventDetector(new DateDetector(stopDate).withHandler(new StopOnEvent<>()));
    List<SpacecraftState> results = new PropagatorsParallelizer(propagators, (interpolators, isLast) -> {
    }).propagate(startDate, endDate);
    Assert.assertEquals(2, results.size());
    Assert.assertEquals(0.0, results.get(0).getDate().durationFrom(stopDate), 1.0e-15);
    Assert.assertEquals(0.0, results.get(1).getDate().durationFrom(stopDate), 1.0e-15);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) Arrays(java.util.Arrays) ForceModel(org.orekit.forces.ForceModel) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) IERSConventions(org.orekit.utils.IERSConventions) Orbit(org.orekit.orbits.Orbit) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) ODEIntegrator(org.hipparchus.ode.ODEIntegrator) After(org.junit.After) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) OrbitType(org.orekit.orbits.OrbitType) PositionAngle(org.orekit.orbits.PositionAngle) DateDetector(org.orekit.propagation.events.DateDetector) FastMath(org.hipparchus.util.FastMath) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Utils(org.orekit.Utils) Before(org.junit.Before) Constants(org.orekit.utils.Constants) DateComponents(org.orekit.time.DateComponents) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FramesFactory(org.orekit.frames.FramesFactory) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Test(org.junit.Test) GravityFieldFactory(org.orekit.forces.gravity.potential.GravityFieldFactory) OrekitMessages(org.orekit.errors.OrekitMessages) List(java.util.List) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) OrekitException(org.orekit.errors.OrekitException) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) TimeScalesFactory(org.orekit.time.TimeScalesFactory) LocalizedCoreFormats(org.hipparchus.exception.LocalizedCoreFormats) TimeComponents(org.orekit.time.TimeComponents) Assert(org.junit.Assert) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) UnnormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) StopOnEvent(org.orekit.propagation.events.handlers.StopOnEvent) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 29 with DateDetector

use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method testIssue224Backward.

@Test
public void testIssue224Backward() throws OrekitException, IOException, ClassNotFoundException {
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(154.);
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    Frame eme2000 = FramesFactory.getEME2000();
    Vector3D pole = itrf.getTransformTo(eme2000, date).transformVector(Vector3D.PLUS_K);
    Frame poleAligned = new Frame(FramesFactory.getEME2000(), new Transform(date, new Rotation(pole, Vector3D.PLUS_K)), "pole aligned", true);
    CircularOrbit initial = new CircularOrbit(7208669.8179538045, 1.3740461966386876E-4, -3.2364250248363356E-5, FastMath.toRadians(97.40236024565775), FastMath.toRadians(166.15873160992115), FastMath.toRadians(90.1282370098961), PositionAngle.MEAN, poleAligned, date, provider.getMu());
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(initial, new LofOffset(poleAligned, LOFType.VVLH), 1000.0, provider);
    propagator.addAdditionalStateProvider(new SevenProvider());
    propagator.setEphemerisMode();
    // Impulsive burns
    final AbsoluteDate burn1Date = initial.getDate().shiftedBy(-200);
    ImpulseManeuver<DateDetector> impulsiveBurn1 = new ImpulseManeuver<DateDetector>(new DateDetector(burn1Date), new Vector3D(0.0, 500.0, 0.0), 320);
    propagator.addEventDetector(impulsiveBurn1);
    final AbsoluteDate burn2Date = initial.getDate().shiftedBy(-300);
    ImpulseManeuver<DateDetector> impulsiveBurn2 = new ImpulseManeuver<DateDetector>(new DateDetector(burn2Date), new Vector3D(0.0, 500.0, 0.0), 320);
    propagator.addEventDetector(impulsiveBurn2);
    propagator.propagate(initial.getDate().shiftedBy(-400));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(propagator.getGeneratedEphemeris());
    Assert.assertTrue(bos.size() > 2950);
    Assert.assertTrue(bos.size() < 3050);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    BoundedPropagator ephemeris = (BoundedPropagator) ois.readObject();
    ephemeris.setMasterMode(10, new OrekitFixedStepHandler() {

        public void handleStep(SpacecraftState currentState, boolean isLast) {
            if (currentState.getDate().durationFrom(burn1Date) > 0.001) {
                Assert.assertEquals(97.402, FastMath.toDegrees(currentState.getI()), 1.0e-3);
            } else if (currentState.getDate().durationFrom(burn1Date) < -0.001 && currentState.getDate().durationFrom(burn2Date) > 0.001) {
                Assert.assertEquals(98.164, FastMath.toDegrees(currentState.getI()), 1.0e-3);
            } else if (currentState.getDate().durationFrom(burn2Date) < -0.001) {
                Assert.assertEquals(99.273, FastMath.toDegrees(currentState.getI()), 1.0e-3);
            }
        }
    });
    ephemeris.propagate(ephemeris.getMinDate());
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) ImpulseManeuver(org.orekit.forces.maneuvers.ImpulseManeuver) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) ByteArrayInputStream(java.io.ByteArrayInputStream) Transform(org.orekit.frames.Transform) LofOffset(org.orekit.attitudes.LofOffset) BoundedPropagator(org.orekit.propagation.BoundedPropagator) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 30 with DateDetector

use of org.orekit.propagation.events.DateDetector in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method date.

@Test
public void date() throws OrekitException {
    final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, provider);
    final AbsoluteDate stopDate = AbsoluteDate.J2000_EPOCH.shiftedBy(500.0);
    propagator.addEventDetector(new DateDetector(stopDate));
    AbsoluteDate farTarget = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
    SpacecraftState propagated = propagator.propagate(farTarget);
    Assert.assertEquals(0, stopDate.durationFrom(propagated.getDate()), 1.0e-10);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

DateDetector (org.orekit.propagation.events.DateDetector)31 Test (org.junit.Test)27 AbsoluteDate (org.orekit.time.AbsoluteDate)27 SpacecraftState (org.orekit.propagation.SpacecraftState)25 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)15 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)13 Orbit (org.orekit.orbits.Orbit)12 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)9 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)9 LofOffset (org.orekit.attitudes.LofOffset)8 AttitudeProvider (org.orekit.attitudes.AttitudeProvider)7 OrekitException (org.orekit.errors.OrekitException)7 CartesianOrbit (org.orekit.orbits.CartesianOrbit)6 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)6 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)5 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)5 Frame (org.orekit.frames.Frame)5 Arrays (java.util.Arrays)4 List (java.util.List)4 LocalizedCoreFormats (org.hipparchus.exception.LocalizedCoreFormats)4