use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class EphemerisSegmentPropagatorTest method testPropagator.
/**
* Check {@link EphemerisSegmentPropagator} and {@link EphemerisSegment#getPropagator()}.
*
* @throws Exception on error.
*/
@Test
public void testPropagator() throws Exception {
// setup
AbsoluteDate start = AbsoluteDate.J2000_EPOCH, end = start.shiftedBy(60);
Frame frame = FramesFactory.getEME2000();
List<TimeStampedPVCoordinates> coordinates = Arrays.asList(new TimeStampedPVCoordinates(start, new Vector3D(6778137, 0, 0), new Vector3D(0, 7.5e3, 0)), new TimeStampedPVCoordinates(start.shiftedBy(30), new Vector3D(6778137 + 1, 0, 0), new Vector3D(0, 7.5e3, 0)), new TimeStampedPVCoordinates(end, new Vector3D(6778137 + 3, 0, 0), new Vector3D(0, 7.5e3, 0)));
EphemerisSegment ephemeris = new EphemerisSegment() {
@Override
public double getMu() {
return Constants.EGM96_EARTH_MU;
}
@Override
public String getFrameCenterString() {
return null;
}
@Override
public String getFrameString() {
return null;
}
@Override
public Frame getFrame() throws OrekitException {
return frame;
}
@Override
public String getTimeScaleString() {
return null;
}
@Override
public TimeScale getTimeScale() throws OrekitException {
return null;
}
@Override
public int getInterpolationSamples() {
return 2;
}
@Override
public CartesianDerivativesFilter getAvailableDerivatives() {
return CartesianDerivativesFilter.USE_P;
}
@Override
public List<TimeStampedPVCoordinates> getCoordinates() {
return coordinates;
}
@Override
public AbsoluteDate getStart() {
return start;
}
@Override
public AbsoluteDate getStop() {
return end;
}
};
// action
BoundedPropagator propagator = ephemeris.getPropagator();
// verify
Assert.assertThat(propagator.getMinDate(), CoreMatchers.is(start));
Assert.assertThat(propagator.getMaxDate(), CoreMatchers.is(end));
Assert.assertThat(propagator.getFrame(), CoreMatchers.is(frame));
int ulps = 0;
PVCoordinates expected = new PVCoordinates(new Vector3D(6778137, 0, 0), new Vector3D(1.0 / 30, 0, 0));
Assert.assertThat(propagator.propagate(start).getPVCoordinates(), OrekitMatchers.pvCloseTo(expected, ulps));
Assert.assertThat(propagator.getPVCoordinates(start, frame), OrekitMatchers.pvCloseTo(expected, ulps));
expected = new PVCoordinates(new Vector3D(6778137 + 2, 0, 0), new Vector3D(2 / 30.0, 0, 0));
Assert.assertThat(propagator.propagate(start.shiftedBy(45)).getPVCoordinates(), OrekitMatchers.pvCloseTo(expected, ulps));
Assert.assertThat(propagator.getPVCoordinates(start.shiftedBy(45), frame), OrekitMatchers.pvCloseTo(expected, ulps));
expected = new PVCoordinates(new Vector3D(6778137 + 3, 0, 0), new Vector3D(2 / 30.0, 0, 0));
Assert.assertThat(propagator.propagate(end).getPVCoordinates(), OrekitMatchers.pvCloseTo(expected, ulps));
Assert.assertThat(propagator.getPVCoordinates(end, frame), OrekitMatchers.pvCloseTo(expected, ulps));
// check reset state is prohibited
SpacecraftState ic = propagator.propagate(start);
try {
propagator.resetInitialState(ic);
Assert.fail("Expected Exception");
} catch (OrekitException e) {
// expected
}
}
use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class OnBoardAntennaInterSatellitesRangeModifierTest method testEffect.
@Test
public void testEffect() throws OrekitException {
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 0.001);
propagatorBuilder.setAttitudeProvider(new LofOffset(propagatorBuilder.getFrame(), LOFType.LVLH));
// create perfect inter-satellites range measurements without antenna offset
final TimeStampedPVCoordinates original = context.initialOrbit.getPVCoordinates();
final Orbit closeOrbit = new CartesianOrbit(new TimeStampedPVCoordinates(context.initialOrbit.getDate(), original.getPosition().add(new Vector3D(1000, 2000, 3000)), original.getVelocity().add(new Vector3D(-0.03, 0.01, 0.02))), context.initialOrbit.getFrame(), context.initialOrbit.getMu());
final Propagator closePropagator = EstimationTestUtils.createPropagator(closeOrbit, propagatorBuilder);
closePropagator.setEphemerisMode();
closePropagator.propagate(context.initialOrbit.getDate().shiftedBy(3.5 * closeOrbit.getKeplerianPeriod()));
final BoundedPropagator ephemeris = closePropagator.getGeneratedEphemeris();
final Propagator p1 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> spacecraftCenteredMeasurements = EstimationTestUtils.createMeasurements(p1, new InterSatellitesRangeMeasurementCreator(ephemeris, Vector3D.ZERO, Vector3D.ZERO), 1.0, 3.0, 300.0);
// create perfect inter-satellites range measurements with antenna offset
final Vector3D apc1 = new Vector3D(-2.5, 0.0, 0);
final Vector3D apc2 = new Vector3D(0.0, 0.8, 0);
final Propagator p2 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> antennaCenteredMeasurements = EstimationTestUtils.createMeasurements(p2, new InterSatellitesRangeMeasurementCreator(ephemeris, apc1, apc2), 1.0, 3.0, 300.0);
final Propagator p3 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
OnBoardAntennaInterSatellitesRangeModifier modifier = new OnBoardAntennaInterSatellitesRangeModifier(apc1, apc2);
for (int i = 0; i < spacecraftCenteredMeasurements.size(); ++i) {
InterSatellitesRange sr = (InterSatellitesRange) spacecraftCenteredMeasurements.get(i);
sr.addModifier(modifier);
EstimatedMeasurement<InterSatellitesRange> estimated = sr.estimate(0, 0, new SpacecraftState[] { p3.propagate(sr.getDate()), ephemeris.propagate(sr.getDate()) });
InterSatellitesRange ar = (InterSatellitesRange) antennaCenteredMeasurements.get(i);
Assert.assertEquals(0.0, sr.getDate().durationFrom(ar.getDate()), 2.0e-8);
Assert.assertEquals(ar.getObservedValue()[0], estimated.getEstimatedValue()[0], 2.0e-5);
}
}
use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class NumericalPropagatorTest method testEphemerisDatesBackward.
@Test
public void testEphemerisDatesBackward() throws OrekitException {
// setup
TimeScale tai = TimeScalesFactory.getTAI();
AbsoluteDate initialDate = new AbsoluteDate("2015-07-05", tai);
AbsoluteDate startDate = new AbsoluteDate("2015-07-03", tai).shiftedBy(-0.1);
AbsoluteDate endDate = new AbsoluteDate("2015-07-04", tai);
Frame eci = FramesFactory.getGCRF();
KeplerianOrbit orbit = new KeplerianOrbit(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, initialDate, mu);
OrbitType type = OrbitType.CARTESIAN;
double[][] tol = NumericalPropagator.tolerances(1e-3, orbit, type);
NumericalPropagator prop = new NumericalPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1]));
prop.setOrbitType(type);
prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit)));
// action
prop.setEphemerisMode();
prop.propagate(endDate, startDate);
BoundedPropagator ephemeris = prop.getGeneratedEphemeris();
// verify
TimeStampedPVCoordinates actualPV = ephemeris.getPVCoordinates(startDate, eci);
TimeStampedPVCoordinates expectedPV = orbit.getPVCoordinates(startDate, eci);
MatcherAssert.assertThat(actualPV.getPosition(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition(), 1.0));
MatcherAssert.assertThat(actualPV.getVelocity(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity(), 1.0));
MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate), OrekitMatchers.closeTo(0, 0));
MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate), OrekitMatchers.closeTo(0, 0));
// test date
AbsoluteDate date = endDate.shiftedBy(-0.11);
Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date), 0, 0);
}
use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class NumericalPropagatorTest method testEphemerisAdditionalState.
@Test
public void testEphemerisAdditionalState() throws OrekitException, IOException {
// Propagation of the initial at t + dt
final double dt = -3200;
final double rate = 2.0;
propagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "squaredA";
}
public double[] getAdditionalState(SpacecraftState state) {
return new double[] { state.getA() * state.getA() };
}
});
propagator.addAdditionalEquations(new AdditionalEquations() {
public String getName() {
return "extra";
}
public double[] computeDerivatives(SpacecraftState s, double[] pDot) {
pDot[0] = rate;
return null;
}
});
propagator.setInitialState(propagator.getInitialState().addAdditionalState("extra", 1.5));
propagator.setOrbitType(OrbitType.CARTESIAN);
propagator.setEphemerisMode();
propagator.propagate(initDate.shiftedBy(dt));
final BoundedPropagator ephemeris1 = propagator.getGeneratedEphemeris();
Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMinDate());
Assert.assertEquals(initDate, ephemeris1.getMaxDate());
try {
ephemeris1.propagate(ephemeris1.getMinDate().shiftedBy(-10.0));
Assert.fail("an exception should have been thrown");
} catch (OrekitException pe) {
Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier());
}
try {
ephemeris1.propagate(ephemeris1.getMaxDate().shiftedBy(+10.0));
Assert.fail("an exception should have been thrown");
} catch (OrekitException pe) {
Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier());
}
double shift = -60;
SpacecraftState s = ephemeris1.propagate(initDate.shiftedBy(shift));
Assert.assertEquals(2, s.getAdditionalStates().size());
Assert.assertTrue(s.hasAdditionalState("squaredA"));
Assert.assertTrue(s.hasAdditionalState("extra"));
Assert.assertEquals(s.getA() * s.getA(), s.getAdditionalState("squaredA")[0], 1.0e-10);
Assert.assertEquals(1.5 + shift * rate, s.getAdditionalState("extra")[0], 1.0e-10);
try {
ephemeris1.resetInitialState(s);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.NON_RESETABLE_STATE, oe.getSpecifier());
}
}
use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class IntegratedEphemerisTest method testPartialDerivativesIssue16.
@Test
public void testPartialDerivativesIssue16() throws OrekitException {
final String eqName = "derivatives";
numericalPropagator.setEphemerisMode();
numericalPropagator.setOrbitType(OrbitType.CARTESIAN);
final PartialDerivativesEquations derivatives = new PartialDerivativesEquations(eqName, numericalPropagator);
final SpacecraftState initialState = derivatives.setInitialJacobians(new SpacecraftState(initialOrbit));
final JacobiansMapper mapper = derivatives.getMapper();
numericalPropagator.setInitialState(initialState);
numericalPropagator.propagate(initialOrbit.getDate().shiftedBy(3600.0));
BoundedPropagator ephemeris = numericalPropagator.getGeneratedEphemeris();
ephemeris.setMasterMode(new OrekitStepHandler() {
private final Array2DRowRealMatrix dYdY0 = new Array2DRowRealMatrix(6, 6);
public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) throws OrekitException {
SpacecraftState state = interpolator.getCurrentState();
Assert.assertEquals(mapper.getAdditionalStateDimension(), state.getAdditionalState(eqName).length);
mapper.getStateJacobian(state, dYdY0.getDataRef());
// no parameters, this is a no-op and should work
mapper.getParametersJacobian(state, null);
RealMatrix deltaId = dYdY0.subtract(MatrixUtils.createRealIdentityMatrix(6));
Assert.assertTrue(deltaId.getNorm() > 100);
Assert.assertTrue(deltaId.getNorm() < 3100);
}
});
ephemeris.propagate(initialOrbit.getDate().shiftedBy(1800.0));
}
Aggregations