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());
}
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);
}
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);
}
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());
}
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);
}
Aggregations