Search in sources :

Example 6 with DateDetector

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

the class NumericalPropagatorTest method testStopEvent.

@Test
public void testStopEvent() throws OrekitException {
    final AbsoluteDate stopDate = initDate.shiftedBy(1000);
    CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.STOP);
    propagator.addEventDetector(new DateDetector(stopDate).withHandler(checking));
    Assert.assertEquals(1, propagator.getEventsDetectors().size());
    checking.assertEvent(false);
    final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200));
    checking.assertEvent(true);
    Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate), 1.0e-10);
    propagator.clearEventsDetectors();
    Assert.assertEquals(0, propagator.getEventsDetectors().size());
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 7 with DateDetector

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

the class DSSTPropagatorTest method testStopEvent.

@Test
public void testStopEvent() throws OrekitException {
    SpacecraftState state = getLEOState();
    setDSSTProp(state);
    final AbsoluteDate stopDate = state.getDate().shiftedBy(1000);
    CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.STOP);
    dsstProp.addEventDetector(new DateDetector(stopDate).withHandler(checking));
    checking.assertEvent(false);
    final SpacecraftState finalState = dsstProp.propagate(state.getDate().shiftedBy(3200));
    checking.assertEvent(true);
    Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate), 1.0e-10);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 8 with DateDetector

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

the class DSSTPropagatorTest method testContinueEvent.

@Test
public void testContinueEvent() throws OrekitException {
    SpacecraftState state = getLEOState();
    setDSSTProp(state);
    final AbsoluteDate resetDate = state.getDate().shiftedBy(1000);
    CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.CONTINUE);
    dsstProp.addEventDetector(new DateDetector(resetDate).withHandler(checking));
    final double dt = 3200;
    checking.assertEvent(false);
    final SpacecraftState finalState = dsstProp.propagate(state.getDate().shiftedBy(dt));
    checking.assertEvent(true);
    final double n = FastMath.sqrt(state.getMu() / state.getA()) / state.getA();
    Assert.assertEquals(state.getA(), finalState.getA(), 1.0e-10);
    Assert.assertEquals(state.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10);
    Assert.assertEquals(state.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10);
    Assert.assertEquals(state.getHx(), finalState.getHx(), 1.0e-10);
    Assert.assertEquals(state.getHy(), finalState.getHy(), 1.0e-10);
    Assert.assertEquals(state.getLM() + n * dt, finalState.getLM(), 6.0e-10);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 9 with DateDetector

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

the class OrekitStepHandlerTest method testIsInterpolated.

/**
 * Check {@link OrekitStepInterpolator#isPreviousStateInterpolated()} and {@link
 * OrekitStepInterpolator#isCurrentStateInterpolated()}.
 *
 * @throws OrekitException on error.
 */
@Test
public void testIsInterpolated() throws OrekitException {
    // setup
    NumericalPropagator propagator = new NumericalPropagator(new ClassicalRungeKuttaIntegrator(60));
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame eci = FramesFactory.getGCRF();
    SpacecraftState ic = new SpacecraftState(new KeplerianOrbit(6378137 + 500e3, 1e-3, 0, 0, 0, 0, PositionAngle.TRUE, eci, date, Constants.EIGEN5C_EARTH_MU));
    propagator.setInitialState(ic);
    propagator.setOrbitType(OrbitType.CARTESIAN);
    // detector triggers half way through second step
    DateDetector detector = new DateDetector(date.shiftedBy(90)).withHandler(new ContinueOnEvent<>());
    propagator.addEventDetector(detector);
    // action and verify
    Queue<Boolean> expected = new ArrayDeque<>(Arrays.asList(false, false, false, true, true, false));
    propagator.setMasterMode(new OrekitStepHandler() {

        @Override
        public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) {
            assertEquals(expected.poll(), interpolator.isPreviousStateInterpolated());
            assertEquals(expected.poll(), interpolator.isCurrentStateInterpolated());
        }
    });
    final AbsoluteDate end = date.shiftedBy(120);
    assertEquals(end, propagator.propagate(end).getDate());
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) Frame(org.orekit.frames.Frame) FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) AbsoluteDate(org.orekit.time.AbsoluteDate) ArrayDeque(java.util.ArrayDeque) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Test(org.junit.Test)

Example 10 with DateDetector

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

the class JacobianPropagatorConverter method getObjectiveFunction.

/**
 * {@inheritDoc}
 */
protected MultivariateVectorFunction getObjectiveFunction() {
    return new MultivariateVectorFunction() {

        /**
         * {@inheritDoc}
         */
        public double[] value(final double[] arg) throws IllegalArgumentException, OrekitExceptionWrapper {
            try {
                final double[] value = new double[getTargetSize()];
                final NumericalPropagator prop = builder.buildPropagator(arg);
                final int stateSize = isOnlyPosition() ? 3 : 6;
                final List<SpacecraftState> sample = getSample();
                for (int i = 0; i < sample.size(); ++i) {
                    final int row = i * stateSize;
                    if (prop.getInitialState().getDate().equals(sample.get(i).getDate())) {
                        // use initial state
                        fillRows(value, row, prop.getInitialState());
                    } else {
                        // use a date detector to pick up states
                        prop.addEventDetector(new DateDetector(sample.get(i).getDate()).withHandler(new EventHandler<DateDetector>() {

                            /**
                             * {@inheritDoc}
                             */
                            @Override
                            public Action eventOccurred(final SpacecraftState state, final DateDetector detector, final boolean increasing) throws OrekitException {
                                fillRows(value, row, state);
                                return row + stateSize >= getTargetSize() ? Action.STOP : Action.CONTINUE;
                            }
                        }));
                    }
                }
                prop.propagate(sample.get(sample.size() - 1).getDate().shiftedBy(10.0));
                return value;
            } catch (OrekitException ex) {
                throw new OrekitExceptionWrapper(ex);
            }
        }
    };
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) EventHandler(org.orekit.propagation.events.handlers.EventHandler) OrekitException(org.orekit.errors.OrekitException) MultivariateVectorFunction(org.hipparchus.analysis.MultivariateVectorFunction)

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