Search in sources :

Example 21 with DateDetector

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

the class ImpulseManeuverTest method testAdditionalStateKeplerian.

@Test
public void testAdditionalStateKeplerian() throws OrekitException {
    final double mu = CelestialBodyFactory.getEarth().getGM();
    final double initialX = 7100e3;
    final double initialY = 0.0;
    final double initialZ = 1300e3;
    final double initialVx = 0;
    final double initialVy = 8000;
    final double initialVz = 1000;
    final Vector3D position = new Vector3D(initialX, initialY, initialZ);
    final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
    final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
    final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
    final Orbit initialOrbit = new CartesianOrbit(pv, FramesFactory.getEME2000(), mu);
    final double totalPropagationTime = 10;
    final double deltaX = 0.01;
    final double deltaY = 0.02;
    final double deltaZ = 0.03;
    final double isp = 300;
    final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);
    final AttitudeProvider attitudeProvider = new LofOffset(initialOrbit.getFrame(), LOFType.VNC);
    final Attitude initialAttitude = attitudeProvider.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame());
    final SpacecraftState initialState = new SpacecraftState(initialOrbit, initialAttitude);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
    propagator.resetInitialState(initialState.addAdditionalState("testOnly", -1.0));
    DateDetector dateDetector = new DateDetector(epoch.shiftedBy(0.5 * totalPropagationTime));
    InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, RotationConvention.VECTOR_OPERATOR, 0, 0, 0));
    ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector, attitudeOverride, deltaV, isp).withThreshold(1.0e-3);
    propagator.addEventDetector(burnAtEpoch);
    SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
    Assert.assertEquals(1, finalState.getAdditionalStates().size());
    Assert.assertEquals(-1.0, finalState.getAdditionalState("testOnly")[0], 1.0e-15);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Attitude(org.orekit.attitudes.Attitude) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) InertialProvider(org.orekit.attitudes.InertialProvider) LofOffset(org.orekit.attitudes.LofOffset) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 22 with DateDetector

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

the class NumericalPropagatorTest method testContinueEvent.

@Test
public void testContinueEvent() throws OrekitException {
    final AbsoluteDate resetDate = initDate.shiftedBy(1000);
    CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.CONTINUE);
    propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking));
    final double dt = 3200;
    checking.assertEvent(false);
    Assert.assertEquals(0.0, propagator.getInitialState().getDate().durationFrom(initDate), 1.0e-10);
    propagator.setResetAtEnd(false);
    final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt));
    Assert.assertEquals(0.0, propagator.getInitialState().getDate().durationFrom(initDate), 1.0e-10);
    checking.assertEvent(true);
    final double n = FastMath.sqrt(initialState.getMu() / initialState.getA()) / initialState.getA();
    Assert.assertEquals(initialState.getA(), finalState.getA(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10);
    Assert.assertEquals(initialState.getHx(), finalState.getHx(), 1.0e-10);
    Assert.assertEquals(initialState.getHy(), finalState.getHy(), 1.0e-10);
    Assert.assertEquals(initialState.getLM() + n * dt, finalState.getLM(), 6.0e-10);
}
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 23 with DateDetector

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

the class NumericalPropagatorTest method testCloseEventDates.

/**
 * check propagation succeeds when two events are within the tolerance of
 * each other.
 */
@Test
public void testCloseEventDates() throws OrekitException {
    // setup
    DateDetector d1 = new DateDetector(10, 1, initDate.shiftedBy(15)).withHandler(new ContinueOnEvent<DateDetector>());
    DateDetector d2 = new DateDetector(10, 1, initDate.shiftedBy(15.5)).withHandler(new ContinueOnEvent<DateDetector>());
    propagator.addEventDetector(d1);
    propagator.addEventDetector(d2);
    // action
    AbsoluteDate end = initDate.shiftedBy(30);
    SpacecraftState actual = propagator.propagate(end);
    // verify
    Assert.assertEquals(actual.getDate().durationFrom(end), 0.0, 0.0);
}
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 24 with DateDetector

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

the class NumericalPropagatorTest method testResetDerivativesEvent.

@Test
public void testResetDerivativesEvent() throws OrekitException {
    final AbsoluteDate resetDate = initDate.shiftedBy(1000);
    CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.RESET_DERIVATIVES);
    propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking));
    final double dt = 3200;
    checking.assertEvent(false);
    Assert.assertEquals(0.0, propagator.getInitialState().getDate().durationFrom(initDate), 1.0e-10);
    propagator.setResetAtEnd(true);
    final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt));
    Assert.assertEquals(dt, propagator.getInitialState().getDate().durationFrom(initDate), 1.0e-10);
    checking.assertEvent(true);
    final double n = FastMath.sqrt(initialState.getMu() / initialState.getA()) / initialState.getA();
    Assert.assertEquals(initialState.getA(), finalState.getA(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10);
    Assert.assertEquals(initialState.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10);
    Assert.assertEquals(initialState.getHx(), finalState.getHx(), 1.0e-10);
    Assert.assertEquals(initialState.getHy(), finalState.getHy(), 1.0e-10);
    Assert.assertEquals(initialState.getLM() + n * dt, finalState.getLM(), 6.0e-10);
}
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 25 with DateDetector

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

the class RecordAndContinueTest method testGetEvents.

/**
 * check add and clear behavior.
 *
 * @throws OrekitException on error.
 */
@Test
public void testGetEvents() throws OrekitException {
    // setup
    RecordAndContinue<DateDetector> handler = new RecordAndContinue<DateDetector>();
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    DateDetector detector = new DateDetector(date);
    Frame eci = FramesFactory.getGCRF();
    Orbit orbit = new KeplerianOrbit(6378137 + 500e3, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, date, Constants.EIGEN5C_EARTH_MU);
    SpacecraftState s1 = new SpacecraftState(orbit);
    SpacecraftState s2 = s1.shiftedBy(-10);
    SpacecraftState s3 = s2.shiftedBy(1);
    SpacecraftState s4 = s3.shiftedBy(1);
    // actions
    Assert.assertEquals(Action.CONTINUE, handler.eventOccurred(s1, detector, true));
    Assert.assertEquals(Action.CONTINUE, handler.eventOccurred(s2, detector, true));
    Assert.assertEquals(Action.CONTINUE, handler.eventOccurred(s3, detector, false));
    // verify
    List<Event<DateDetector>> events = handler.getEvents();
    Assert.assertEquals(3, events.size());
    Assert.assertEquals(s1, events.get(0).getState());
    Assert.assertEquals(s2, events.get(1).getState());
    Assert.assertEquals(s3, events.get(2).getState());
    Assert.assertEquals(true, events.get(0).isIncreasing());
    Assert.assertEquals(true, events.get(1).isIncreasing());
    Assert.assertEquals(false, events.get(2).isIncreasing());
    for (Event<DateDetector> event : events) {
        Assert.assertEquals(detector, event.getDetector());
    }
    // action: clear
    handler.clear();
    // verify is empty
    Assert.assertEquals(0, handler.getEvents().size());
    // action add more
    Assert.assertEquals(Action.CONTINUE, handler.eventOccurred(s4, detector, false));
    // verify new events
    events = handler.getEvents();
    Assert.assertEquals(1, events.size());
    Assert.assertEquals(s4, events.get(0).getState());
    Assert.assertEquals(false, events.get(0).isIncreasing());
    Assert.assertEquals(detector, events.get(0).getDetector());
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) SpacecraftState(org.orekit.propagation.SpacecraftState) Frame(org.orekit.frames.Frame) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) Event(org.orekit.propagation.events.handlers.RecordAndContinue.Event) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) 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