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