Search in sources :

Example 16 with DateDetector

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

the class KeplerianPropagatorTest method testIssue224.

@Test
public void testIssue224() throws OrekitException, IOException, ClassNotFoundException {
    // Inertial frame
    Frame inertialFrame = FramesFactory.getEME2000();
    // Initial date
    TimeScale utc = TimeScalesFactory.getUTC();
    AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
    // Central attraction coefficient
    double mu = 3.986004415e+14;
    // Initial orbit
    // semi major axis in meters
    double a = 42100;
    // eccentricity
    double e = 0.01;
    // inclination
    double i = FastMath.toRadians(6);
    // perigee argument
    double omega = FastMath.toRadians(180);
    // right ascention of ascending node
    double raan = FastMath.toRadians(261);
    // mean anomaly
    double lM = 0;
    Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu);
    // Initial state definition
    SpacecraftState initialState = new SpacecraftState(initialOrbit);
    // Propagator
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, new LofOffset(inertialFrame, LOFType.VVLH));
    propagator.addAdditionalStateProvider(new SevenProvider());
    propagator.setEphemerisMode();
    // Impulsive burn 1
    final AbsoluteDate burn1Date = initialState.getDate().shiftedBy(200);
    ImpulseManeuver<DateDetector> impulsiveBurn1 = new ImpulseManeuver<DateDetector>(new DateDetector(burn1Date), new Vector3D(1000, 0, 0), 320);
    propagator.addEventDetector(impulsiveBurn1);
    // Impulsive burn 2
    final AbsoluteDate burn2Date = initialState.getDate().shiftedBy(300);
    ImpulseManeuver<DateDetector> impulsiveBurn2 = new ImpulseManeuver<DateDetector>(new DateDetector(burn2Date), new Vector3D(1000, 0, 0), 320);
    propagator.addEventDetector(impulsiveBurn2);
    propagator.propagate(initialState.getDate().shiftedBy(400));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(propagator.getGeneratedEphemeris());
    Assert.assertTrue(bos.size() > 2400);
    Assert.assertTrue(bos.size() < 2500);
    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(42100.0, currentState.getA(), 1.0e-3);
            } else if (currentState.getDate().durationFrom(burn1Date) > 0.001 && currentState.getDate().durationFrom(burn2Date) < -0.001) {
                Assert.assertEquals(42979.962, currentState.getA(), 1.0e-3);
            } else if (currentState.getDate().durationFrom(burn2Date) > 0.001) {
                Assert.assertEquals(43887.339, currentState.getA(), 1.0e-3);
            }
        }
    });
    ephemeris.propagate(ephemeris.getMaxDate());
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) ImpulseManeuver(org.orekit.forces.maneuvers.ImpulseManeuver) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) TimeScale(org.orekit.time.TimeScale) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) ByteArrayInputStream(java.io.ByteArrayInputStream) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) 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 17 with DateDetector

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

the class AttitudesSequenceTest method testBackwardPropagation.

@Test
public void testBackwardPropagation() 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 AttitudesSequence attitudesSequence = new AttitudesSequence();
    final AttitudeProvider past = new InertialProvider(Rotation.IDENTITY);
    final AttitudeProvider current = new InertialProvider(Rotation.IDENTITY);
    final AttitudeProvider future = new InertialProvider(Rotation.IDENTITY);
    final Handler handler = new Handler(current, past);
    attitudesSequence.addSwitchingCondition(past, current, new DateDetector(initialDate.shiftedBy(-500.0)), true, false, 10.0, AngularDerivativesFilter.USE_R, handler);
    attitudesSequence.addSwitchingCondition(current, future, new DateDetector(initialDate.shiftedBy(+500.0)), true, false, 10.0, AngularDerivativesFilter.USE_R, null);
    attitudesSequence.resetActiveProvider(current);
    SpacecraftState initialState = new SpacecraftState(initialOrbit);
    initialState = initialState.addAdditionalState("fortyTwo", 42.0);
    final Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, attitudesSequence, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
    propagator.resetInitialState(initialState);
    Assert.assertEquals(42.0, propagator.getInitialState().getAdditionalState("fortyTwo")[0], 1.0e-10);
    // Register the switching events to the propagator
    attitudesSequence.registerSwitchEvents(propagator);
    SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(-10000.0));
    Assert.assertEquals(42.0, finalState.getAdditionalState("fortyTwo")[0], 1.0e-10);
    Assert.assertEquals(1, handler.dates.size());
    Assert.assertEquals(-500.0, handler.dates.get(0).durationFrom(initialDate), 1.0e-3);
    Assert.assertEquals(-490.0, finalState.getDate().durationFrom(initialDate), 1.0e-3);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) FieldOrbit(org.orekit.orbits.FieldOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) 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) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) FieldPropagator(org.orekit.propagation.FieldPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Test(org.junit.Test)

Example 18 with DateDetector

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

the class ImpulseManeuverTest method testAdditionalStateNumerical.

@Test
public void testAdditionalStateNumerical() 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.0;
    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());
    double[][] tolerances = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
    DormandPrince853Integrator integrator = new DormandPrince853Integrator(1.0e-3, 60, tolerances[0], tolerances[1]);
    NumericalPropagator propagator = new NumericalPropagator(integrator);
    propagator.setOrbitType(initialOrbit.getType());
    PartialDerivativesEquations pde = new PartialDerivativesEquations("derivatives", propagator);
    final SpacecraftState initialState = pde.setInitialJacobians(new SpacecraftState(initialOrbit, initialAttitude));
    propagator.resetInitialState(initialState);
    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(36, finalState.getAdditionalState("derivatives").length);
    double[][] stateTransitionMatrix = new double[6][6];
    pde.getMapper().getStateJacobian(finalState, stateTransitionMatrix);
    for (int i = 0; i < 6; ++i) {
        for (int j = 0; j < 6; ++j) {
            double sIJ = stateTransitionMatrix[i][j];
            if (j == i) {
                // dPi/dPj and dVi/dVj are roughly 1 for small propagation times
                Assert.assertEquals(1.0, sIJ, 2.0e-4);
            } else if (j == i + 3) {
                // dVi/dPi is roughly the propagation time for small propagation times
                Assert.assertEquals(totalPropagationTime, sIJ, 4.0e-5 * totalPropagationTime);
            } else {
                // other derivatives are almost zero for small propagation times
                Assert.assertEquals(0, sIJ, 1.0e-4);
            }
        }
    }
}
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) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) PartialDerivativesEquations(org.orekit.propagation.numerical.PartialDerivativesEquations) InertialProvider(org.orekit.attitudes.InertialProvider) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) LofOffset(org.orekit.attitudes.LofOffset) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 19 with DateDetector

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

the class ImpulseManeuverTest method testInertialManeuver.

@Test
public void testInertialManeuver() 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 state = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
    final Orbit initialOrbit = new CartesianOrbit(state, FramesFactory.getEME2000(), mu);
    final double totalPropagationTime = 0.00001;
    final double driftTimeInSec = totalPropagationTime / 2.0;
    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);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC));
    DateDetector dateDetector = new DateDetector(epoch.shiftedBy(driftTimeInSec));
    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(driftTimeInSec / 4);
    propagator.addEventDetector(burnAtEpoch);
    SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
    final double finalVxExpected = initialVx + deltaX;
    final double finalVyExpected = initialVy + deltaY;
    final double finalVzExpected = initialVz + deltaZ;
    final double maneuverTolerance = 1e-4;
    final Vector3D finalVelocity = finalState.getPVCoordinates().getVelocity();
    Assert.assertEquals(finalVxExpected, finalVelocity.getX(), maneuverTolerance);
    Assert.assertEquals(finalVyExpected, finalVelocity.getY(), maneuverTolerance);
    Assert.assertEquals(finalVzExpected, finalVelocity.getZ(), maneuverTolerance);
}
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) 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) Test(org.junit.Test)

Example 20 with DateDetector

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

the class ImpulseManeuverTest method testBackAndForth.

@Test
public void testBackAndForth() throws OrekitException {
    final AttitudeProvider lof = new LofOffset(FramesFactory.getEME2000(), LOFType.VNC);
    final double mu = Constants.EIGEN5C_EARTH_MU;
    final AbsoluteDate iniDate = new AbsoluteDate(2003, 5, 1, 17, 30, 0.0, TimeScalesFactory.getUTC());
    final Orbit pastOrbit = new KeplerianOrbit(7e6, 1.0e-4, FastMath.toRadians(98.5), FastMath.toRadians(87.0), FastMath.toRadians(216.1807), FastMath.toRadians(319.779), PositionAngle.MEAN, FramesFactory.getEME2000(), iniDate, mu);
    final double pastMass = 2500.0;
    DateDetector dateDetector = new DateDetector(iniDate.shiftedBy(600));
    Vector3D deltaV = new Vector3D(12.0, 1.0, -4.0);
    final double isp = 300;
    ImpulseManeuver<DateDetector> maneuver = new ImpulseManeuver<DateDetector>(dateDetector, new InertialProvider(Rotation.IDENTITY), deltaV, isp).withMaxCheck(3600.0).withThreshold(1.0e-6);
    double span = 900.0;
    KeplerianPropagator forwardPropagator = new KeplerianPropagator(pastOrbit, lof, mu, pastMass);
    forwardPropagator.addEventDetector(maneuver);
    SpacecraftState futureState = forwardPropagator.propagate(pastOrbit.getDate().shiftedBy(span));
    KeplerianPropagator backwardPropagator = new KeplerianPropagator(futureState.getOrbit(), lof, mu, futureState.getMass());
    backwardPropagator.addEventDetector(maneuver);
    SpacecraftState rebuiltPast = backwardPropagator.propagate(pastOrbit.getDate());
    Assert.assertEquals(0.0, Vector3D.distance(pastOrbit.getPVCoordinates().getPosition(), rebuiltPast.getPVCoordinates().getPosition()), 2.0e-8);
    Assert.assertEquals(0.0, Vector3D.distance(pastOrbit.getPVCoordinates().getVelocity(), rebuiltPast.getPVCoordinates().getVelocity()), 2.0e-11);
    Assert.assertEquals(pastMass, rebuiltPast.getMass(), 5.0e-13);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) 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) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) LofOffset(org.orekit.attitudes.LofOffset) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) 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