Search in sources :

Example 76 with KeplerianOrbit

use of org.orekit.orbits.KeplerianOrbit 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 77 with KeplerianOrbit

use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.

the class KeplerianPropagatorTest method testIssue14.

@Test
public void testIssue14() throws OrekitException {
    AbsoluteDate initialDate = AbsoluteDate.J2000_EPOCH;
    final KeplerianOrbit initialOrbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), initialDate, 3.986004415e14);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
    propagator.setEphemerisMode();
    propagator.propagate(initialDate.shiftedBy(initialOrbit.getKeplerianPeriod()));
    PVCoordinates pv1 = propagator.getPVCoordinates(initialDate, FramesFactory.getEME2000());
    propagator.setEphemerisMode();
    propagator.propagate(initialDate.shiftedBy(initialOrbit.getKeplerianPeriod()));
    PVCoordinates pv2 = propagator.getGeneratedEphemeris().getPVCoordinates(initialDate, FramesFactory.getEME2000());
    Assert.assertEquals(0.0, pv1.getPosition().subtract(pv2.getPosition()).getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, pv1.getVelocity().subtract(pv2.getVelocity()).getNorm(), 1.0e-15);
}
Also used : TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 78 with KeplerianOrbit

use of org.orekit.orbits.KeplerianOrbit 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 79 with KeplerianOrbit

use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.

the class KeplerianPropagatorTest method testPropagationDate.

/**
 * Check that the date returned by {@link KeplerianPropagator#propagate(AbsoluteDate)}
 * is the same as the date passed to propagate().
 *
 * @throws OrekitException on error.
 */
@Test
public void testPropagationDate() throws OrekitException {
    // setup
    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH;
    // date s.t. target - date rounds down when represented as a double.
    AbsoluteDate target = initDate.shiftedBy(20.0).shiftedBy(FastMath.ulp(20.0) / 4);
    Orbit ic = new KeplerianOrbit(6378137 + 500e3, 1e-3, 0, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getGCRF(), initDate, mu);
    Propagator propagator = new KeplerianPropagator(ic);
    // action
    SpacecraftState actual = propagator.propagate(target);
    // verify
    Assert.assertEquals(target, actual.getDate());
}
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) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 80 with KeplerianOrbit

use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.

the class TabulatedEphemerisTest method testGetFrame.

@Test
public void testGetFrame() throws MathIllegalArgumentException, IllegalArgumentException, OrekitException {
    // setup
    Frame frame = FramesFactory.getICRF();
    AbsoluteDate date = AbsoluteDate.JULIAN_EPOCH;
    // create ephemeris with 2 arbitrary points
    SpacecraftState state = new SpacecraftState(new KeplerianOrbit(1e9, 0.01, 1, 1, 1, 1, PositionAngle.TRUE, frame, date, mu));
    Ephemeris ephem = new Ephemeris(Arrays.asList(state, state.shiftedBy(1)), 2);
    // action + verify
    Assert.assertSame(ephem.getFrame(), frame);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) Frame(org.orekit.frames.Frame) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)211 Test (org.junit.Test)175 AbsoluteDate (org.orekit.time.AbsoluteDate)154 SpacecraftState (org.orekit.propagation.SpacecraftState)146 Orbit (org.orekit.orbits.Orbit)101 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)96 Frame (org.orekit.frames.Frame)71 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)65 CartesianOrbit (org.orekit.orbits.CartesianOrbit)57 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)54 DateComponents (org.orekit.time.DateComponents)50 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)46 PVCoordinates (org.orekit.utils.PVCoordinates)45 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)43 TimeComponents (org.orekit.time.TimeComponents)43 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)42 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)41 Propagator (org.orekit.propagation.Propagator)39 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)36 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)35