Search in sources :

Example 21 with BoundedPropagator

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

the class EcksteinHechlerPropagatorTest method testIssue223.

@Test
public void testIssue223() throws OrekitException, IOException, ClassNotFoundException {
    // Definition of initial conditions
    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, provider);
    propagator.addAdditionalStateProvider(new SevenProvider());
    propagator.setEphemerisMode();
    propagator.propagate(initial.getDate().shiftedBy(40000));
    BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    Assert.assertSame(poleAligned, ephemeris.getFrame());
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(ephemeris);
    Assert.assertTrue(bos.size() > 2450);
    Assert.assertTrue(bos.size() < 2550);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    BoundedPropagator deserialized = (BoundedPropagator) ois.readObject();
    Assert.assertEquals(initial.getA(), deserialized.getInitialState().getA(), 1.0e-10);
    Assert.assertEquals(initial.getEquinoctialEx(), deserialized.getInitialState().getEquinoctialEx(), 1.0e-10);
    SpacecraftState s = deserialized.propagate(initial.getDate().shiftedBy(20000));
    Map<String, double[]> additional = s.getAdditionalStates();
    Assert.assertEquals(1, additional.size());
    Assert.assertEquals(1, additional.get("seven").length);
    Assert.assertEquals(7, additional.get("seven")[0], 1.0e-15);
}
Also used : 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) BoundedPropagator(org.orekit.propagation.BoundedPropagator) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 22 with BoundedPropagator

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

the class KeplerianPropagatorTest method testEphemerisModeWithHandler.

@Test
public void testEphemerisModeWithHandler() throws OrekitException {
    // setup
    AbsoluteDate initDate = AbsoluteDate.GPS_EPOCH;
    Orbit ic = new KeplerianOrbit(6378137 + 500e3, 1e-3, 0, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getGCRF(), initDate, mu);
    Propagator propagator = new KeplerianPropagator(ic);
    AbsoluteDate end = initDate.shiftedBy(90 * 60);
    // action
    final List<SpacecraftState> states = new ArrayList<>();
    propagator.setEphemerisMode((interpolator, isLast) -> {
        states.add(interpolator.getCurrentState());
        states.add(interpolator.getPreviousState());
    });
    propagator.propagate(end);
    final BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    // verify
    // got some data
    Assert.assertTrue(states.size() > 1);
    for (SpacecraftState state : states) {
        PVCoordinates actual = ephemeris.propagate(state.getDate()).getPVCoordinates();
        Assert.assertThat(actual, OrekitMatchers.pvIs(state.getPVCoordinates()));
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) 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) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) ArrayList(java.util.ArrayList) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) BoundedPropagator(org.orekit.propagation.BoundedPropagator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 23 with BoundedPropagator

use of org.orekit.propagation.BoundedPropagator 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 24 with BoundedPropagator

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

the class KeplerianPropagatorTest method testIssue223.

@Test
public void testIssue223() 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);
    propagator.addAdditionalStateProvider(new SevenProvider());
    propagator.setEphemerisMode();
    propagator.propagate(initialState.getDate().shiftedBy(40000));
    BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
    Assert.assertSame(inertialFrame, ephemeris.getFrame());
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(ephemeris);
    Assert.assertTrue(bos.size() > 2250);
    Assert.assertTrue(bos.size() < 2350);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    BoundedPropagator deserialized = (BoundedPropagator) ois.readObject();
    Assert.assertEquals(initialOrbit.getA(), deserialized.getInitialState().getA(), 1.0e-10);
    Assert.assertEquals(initialOrbit.getEquinoctialEx(), deserialized.getInitialState().getEquinoctialEx(), 1.0e-10);
    SpacecraftState s = deserialized.propagate(initialState.getDate().shiftedBy(20000));
    Map<String, double[]> additional = s.getAdditionalStates();
    Assert.assertEquals(1, additional.size());
    Assert.assertEquals(1, additional.get("seven").length);
    Assert.assertEquals(7, additional.get("seven")[0], 1.0e-15);
}
Also used : 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) ByteArrayInputStream(java.io.ByteArrayInputStream) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) BoundedPropagator(org.orekit.propagation.BoundedPropagator) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 25 with BoundedPropagator

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

the class TLEPropagatorTest method testEphemerisMode.

@Test
public void testEphemerisMode() throws OrekitException {
    TLEPropagator propagator = TLEPropagator.selectExtrapolator(tle);
    propagator.setEphemerisMode();
    AbsoluteDate initDate = tle.getDate();
    SpacecraftState initialState = propagator.getInitialState();
    // Simulate a full period of a GPS satellite
    // -----------------------------------------
    AbsoluteDate endDate = initDate.shiftedBy(period);
    propagator.propagate(endDate);
    // get the ephemeris
    BoundedPropagator boundedProp = propagator.getGeneratedEphemeris();
    // get the initial state from the ephemeris and check if it is the same as
    // the initial state from the TLE
    SpacecraftState boundedState = boundedProp.propagate(initDate);
    // Check results
    Assert.assertEquals(initialState.getA(), boundedState.getA(), 0.);
    Assert.assertEquals(initialState.getEquinoctialEx(), boundedState.getEquinoctialEx(), 0.);
    Assert.assertEquals(initialState.getEquinoctialEy(), boundedState.getEquinoctialEy(), 0.);
    Assert.assertEquals(initialState.getHx(), boundedState.getHx(), 0.);
    Assert.assertEquals(initialState.getHy(), boundedState.getHy(), 0.);
    Assert.assertEquals(initialState.getLM(), boundedState.getLM(), 1e-14);
    SpacecraftState finalState = boundedProp.propagate(endDate);
    // Check results
    Assert.assertEquals(initialState.getA(), finalState.getA(), 1e-1);
    Assert.assertEquals(initialState.getEquinoctialEx(), finalState.getEquinoctialEx(), 1e-1);
    Assert.assertEquals(initialState.getEquinoctialEy(), finalState.getEquinoctialEy(), 1e-1);
    Assert.assertEquals(initialState.getHx(), finalState.getHx(), 1e-3);
    Assert.assertEquals(initialState.getHy(), finalState.getHy(), 1e-3);
    Assert.assertEquals(initialState.getLM(), finalState.getLM(), 1e-3);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) BoundedPropagator(org.orekit.propagation.BoundedPropagator) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

BoundedPropagator (org.orekit.propagation.BoundedPropagator)50 Test (org.junit.Test)44 AbsoluteDate (org.orekit.time.AbsoluteDate)41 SpacecraftState (org.orekit.propagation.SpacecraftState)32 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)20 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)20 Orbit (org.orekit.orbits.Orbit)19 Frame (org.orekit.frames.Frame)16 CartesianOrbit (org.orekit.orbits.CartesianOrbit)15 CircularOrbit (org.orekit.orbits.CircularOrbit)15 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)14 OrekitException (org.orekit.errors.OrekitException)12 PVCoordinates (org.orekit.utils.PVCoordinates)10 Propagator (org.orekit.propagation.Propagator)9 TimeScale (org.orekit.time.TimeScale)9 LofOffset (org.orekit.attitudes.LofOffset)8 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6