Search in sources :

Example 1 with OrekitFixedStepHandler

use of org.orekit.propagation.sampling.OrekitFixedStepHandler in project Orekit by CS-SI.

the class KeplerianPropagatorTest method fixedStep.

@Test
public void fixedStep() 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);
    KeplerianPropagator propagator = new KeplerianPropagator(orbit);
    final double step = 100.0;
    propagator.setMasterMode(step, new OrekitFixedStepHandler() {

        private AbsoluteDate previous;

        public void handleStep(SpacecraftState currentState, boolean isLast) throws OrekitException {
            if (previous != null) {
                Assert.assertEquals(step, currentState.getDate().durationFrom(previous), 1.0e-10);
            }
            previous = currentState.getDate();
        }
    });
    AbsoluteDate farTarget = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
    propagator.propagate(farTarget);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 2 with OrekitFixedStepHandler

use of org.orekit.propagation.sampling.OrekitFixedStepHandler 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 3 with OrekitFixedStepHandler

use of org.orekit.propagation.sampling.OrekitFixedStepHandler in project Orekit by CS-SI.

the class TabulatedLofOffsetTest method testSerialization.

@Test
public void testSerialization() throws OrekitException, IOException, ClassNotFoundException {
    // create a sample from Yaw compensation law
    final LOFType type = LOFType.VNC;
    final List<TimeStampedAngularCoordinates> sample = new ArrayList<TimeStampedAngularCoordinates>();
    final AttitudeProvider yawCompensLaw = new YawCompensation(orbit.getFrame(), new NadirPointing(orbit.getFrame(), earth));
    final Propagator originalPropagator = new KeplerianPropagator(orbit);
    originalPropagator.setAttitudeProvider(yawCompensLaw);
    originalPropagator.setMasterMode(10.0, new OrekitFixedStepHandler() {

        public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
            Rotation offsetAtt = currentState.getAttitude().getRotation();
            LofOffset aligned = new LofOffset(currentState.getFrame(), type);
            Rotation alignedAtt = aligned.getAttitude(currentState.getOrbit(), currentState.getDate(), currentState.getFrame()).getRotation();
            Rotation offsetProper = offsetAtt.compose(alignedAtt.revert(), RotationConvention.VECTOR_OPERATOR);
            sample.add(new TimeStampedAngularCoordinates(currentState.getDate(), offsetProper, Vector3D.ZERO, Vector3D.ZERO));
        }
    });
    originalPropagator.propagate(orbit.getDate().shiftedBy(2000));
    originalPropagator.setSlaveMode();
    // use the sample and generate an ephemeris
    final AttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample, 6, AngularDerivativesFilter.USE_RR);
    final Propagator rebuildingPropagator = new KeplerianPropagator(orbit);
    rebuildingPropagator.setAttitudeProvider(tabulated);
    rebuildingPropagator.setEphemerisMode();
    rebuildingPropagator.propagate(orbit.getDate().shiftedBy(5));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(rebuildingPropagator.getGeneratedEphemeris());
    // even despite we propagated only 5 seconds, the attitude sample is huge
    Assert.assertTrue(bos.size() > 17000);
    Assert.assertTrue(bos.size() < 18000);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    TabulatedLofOffset deserialized = (TabulatedLofOffset) ((BoundedPropagator) ois.readObject()).getAttitudeProvider();
    Assert.assertEquals(sample.size(), deserialized.getTable().size());
}
Also used : ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) ByteArrayInputStream(java.io.ByteArrayInputStream) LOFType(org.orekit.frames.LOFType) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OrekitException(org.orekit.errors.OrekitException) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 4 with OrekitFixedStepHandler

use of org.orekit.propagation.sampling.OrekitFixedStepHandler in project Orekit by CS-SI.

the class TabulatedLofOffsetTest method testYawCompensation.

@Test
public void testYawCompensation() throws OrekitException {
    // create a sample from Yaw compensation law
    final LOFType type = LOFType.VNC;
    final List<TimeStampedAngularCoordinates> sample = new ArrayList<TimeStampedAngularCoordinates>();
    final AttitudeProvider yawCompensLaw = new YawCompensation(orbit.getFrame(), new NadirPointing(orbit.getFrame(), earth));
    final Propagator originalPropagator = new KeplerianPropagator(orbit);
    originalPropagator.setAttitudeProvider(yawCompensLaw);
    originalPropagator.setMasterMode(1.0, new OrekitFixedStepHandler() {

        public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
            Rotation offsetAtt = currentState.getAttitude().getRotation();
            LofOffset aligned = new LofOffset(currentState.getFrame(), type);
            Rotation alignedAtt = aligned.getAttitude(currentState.getOrbit(), currentState.getDate(), currentState.getFrame()).getRotation();
            Rotation offsetProper = offsetAtt.compose(alignedAtt.revert(), RotationConvention.VECTOR_OPERATOR);
            sample.add(new TimeStampedAngularCoordinates(currentState.getDate(), offsetProper, Vector3D.ZERO, Vector3D.ZERO));
        }
    });
    originalPropagator.propagate(orbit.getDate().shiftedBy(2000));
    originalPropagator.setSlaveMode();
    // use the sample and compare it to original
    final AttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample, 6, AngularDerivativesFilter.USE_RR);
    final Propagator rebuildingPropagator = new KeplerianPropagator(orbit);
    rebuildingPropagator.setAttitudeProvider(tabulated);
    rebuildingPropagator.setMasterMode(0.3, new OrekitFixedStepHandler() {

        public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
            final SpacecraftState rebuilt = originalPropagator.propagate(currentState.getDate());
            final Rotation r1 = currentState.getAttitude().getRotation();
            final Rotation r2 = rebuilt.getAttitude().getRotation();
            Assert.assertEquals(0.0, Rotation.distance(r1, r2), 7.0e-6);
            checkField(Decimal64Field.getInstance(), tabulated, currentState.getOrbit(), currentState.getDate(), currentState.getFrame());
        }
    });
    rebuildingPropagator.propagate(orbit.getDate().shiftedBy(50), orbit.getDate().shiftedBy(1950));
}
Also used : ArrayList(java.util.ArrayList) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) LOFType(org.orekit.frames.LOFType) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OrekitException(org.orekit.errors.OrekitException) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) Test(org.junit.Test)

Example 5 with OrekitFixedStepHandler

use of org.orekit.propagation.sampling.OrekitFixedStepHandler 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)

Aggregations

SpacecraftState (org.orekit.propagation.SpacecraftState)16 OrekitFixedStepHandler (org.orekit.propagation.sampling.OrekitFixedStepHandler)16 Test (org.junit.Test)11 AbsoluteDate (org.orekit.time.AbsoluteDate)11 OrekitException (org.orekit.errors.OrekitException)10 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)8 Propagator (org.orekit.propagation.Propagator)7 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)7 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)6 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)6 Frame (org.orekit.frames.Frame)5 CircularOrbit (org.orekit.orbits.CircularOrbit)5 Orbit (org.orekit.orbits.Orbit)5 BoundedPropagator (org.orekit.propagation.BoundedPropagator)5 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 ObjectInputStream (java.io.ObjectInputStream)4 ObjectOutputStream (java.io.ObjectOutputStream)4 ArrayList (java.util.ArrayList)4