use of org.orekit.propagation.Propagator 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.propagation.Propagator in project Orekit by CS-SI.
the class FiniteDifferencePropagatorConverterTest method testGetObjectiveFunctionParametersOnlyScaledOnce.
/**
* Test case for bug #362. Check that scaling is only applied once.
*
* @throws OrekitException on error.
*/
@Test
public void testGetObjectiveFunctionParametersOnlyScaledOnce() throws OrekitException {
// setup
// create some arbitrary sample data to run with
Frame eci = FramesFactory.getGCRF();
double gm = Constants.EIGEN5C_EARTH_MU;
AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
Propagator source = new KeplerianPropagator(new KeplerianOrbit(6878137, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, date, gm));
// Create a mock builder that allows us to check the values passed to it
PropagatorBuilder builder = Mockito.mock(PropagatorBuilder.class);
ParameterDriversList list = new ParameterDriversList();
list.add(new ParameterDriver("p1", 0, 1e-3, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
Mockito.when(builder.getOrbitalParametersDrivers()).thenReturn(list);
Mockito.when(builder.getPropagationParametersDrivers()).thenReturn(new ParameterDriversList());
Mockito.when(builder.getFrame()).thenReturn(eci);
Mockito.when(builder.getSelectedNormalizedParameters()).thenReturn(new double[1]);
Mockito.when(builder.buildPropagator(Mockito.any(double[].class))).thenReturn(source);
// subject under test
FiniteDifferencePropagatorConverter converter = new FiniteDifferencePropagatorConverter(builder, 1, 100);
// set some internal variables in FDPC that are not settable using another
// interface
converter.convert(source, 1, 2);
// Forget all the side effect of the call to convert()
Mockito.clearInvocations(builder);
// action
converter.getModel().value(new ArrayRealVector(1));
// verify
Mockito.verify(builder).buildPropagator(new double[] { 0 });
Mockito.verify(builder).buildPropagator(new double[] { 1 });
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class KeplerianConverterTest method checkFit.
protected void checkFit(final Orbit orbit, final double duration, final double stepSize, final double threshold, final boolean positionOnly, final double expectedRMS, final String... freeParameters) throws OrekitException {
Propagator p = new KeplerianPropagator(orbit);
List<SpacecraftState> sample = new ArrayList<SpacecraftState>();
for (double dt = 0; dt < duration; dt += stepSize) {
sample.add(p.propagate(orbit.getDate().shiftedBy(dt)));
}
PropagatorBuilder builder = new KeplerianPropagatorBuilder(OrbitType.KEPLERIAN.convertType(orbit), PositionAngle.MEAN, 1.0);
FiniteDifferencePropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, threshold, 1000);
fitter.convert(sample, positionOnly, freeParameters);
Assert.assertEquals(expectedRMS, fitter.getRMS(), 0.01 * expectedRMS);
KeplerianPropagator prop = (KeplerianPropagator) fitter.getAdaptedPropagator();
Orbit fitted = prop.getInitialState().getOrbit();
final double eps = 1.0e-12;
Assert.assertEquals(orbit.getPVCoordinates().getPosition().getX(), fitted.getPVCoordinates().getPosition().getX(), eps * orbit.getPVCoordinates().getPosition().getX());
Assert.assertEquals(orbit.getPVCoordinates().getPosition().getY(), fitted.getPVCoordinates().getPosition().getY(), eps * orbit.getPVCoordinates().getPosition().getY());
Assert.assertEquals(orbit.getPVCoordinates().getPosition().getZ(), fitted.getPVCoordinates().getPosition().getZ(), eps * orbit.getPVCoordinates().getPosition().getZ());
Assert.assertEquals(orbit.getPVCoordinates().getVelocity().getX(), fitted.getPVCoordinates().getVelocity().getX(), -eps * orbit.getPVCoordinates().getVelocity().getX());
Assert.assertEquals(orbit.getPVCoordinates().getVelocity().getY(), fitted.getPVCoordinates().getVelocity().getY(), eps * orbit.getPVCoordinates().getVelocity().getY());
Assert.assertEquals(orbit.getPVCoordinates().getVelocity().getZ(), fitted.getPVCoordinates().getVelocity().getZ(), eps * orbit.getPVCoordinates().getVelocity().getZ());
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testCloseEvents.
@Test
public void testCloseEvents() throws OrekitException {
// setup
double tolerance = 1;
Propagator propagator = getPropagator(10);
RecordAndContinue<EventDetector> handler = new RecordAndContinue<>();
TimeDetector detector1 = new TimeDetector(5).withHandler(handler).withMaxCheck(10).withThreshold(tolerance);
propagator.addEventDetector(detector1);
TimeDetector detector2 = new TimeDetector(5.5).withHandler(handler).withMaxCheck(10).withThreshold(tolerance);
propagator.addEventDetector(detector2);
// action
propagator.propagate(epoch.shiftedBy(20));
// verify
List<Event<EventDetector>> events = handler.getEvents();
Assert.assertEquals(2, events.size());
Assert.assertEquals(5, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(detector1, events.get(0).getDetector());
Assert.assertEquals(5.5, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(detector2, events.get(1).getDetector());
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testToleranceStopReverse.
/**
* check when root finding tolerance > event finding tolerance.
*/
@Test
public void testToleranceStopReverse() throws OrekitException {
// setup
double maxCheck = 10;
// less than 1 ulp
double tolerance = 1e-18;
double t1 = -15.1;
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
FlatDetector detectorA = new FlatDetector(t1).withHandler(new Handler<>(events, Action.STOP)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
// action
SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(-30.0));
// verify
Assert.assertEquals(1, events.size());
// use root finder tolerance instead of event finder tolerance.
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertSame(detectorA, events.get(0).getDetector());
Assert.assertEquals(t1, finalState.getDate().durationFrom(epoch), tolerance);
// try to resume propagation
finalState = propagator.propagate(epoch.shiftedBy(-30.0));
// verify it got to the end
Assert.assertEquals(-30.0, finalState.getDate().durationFrom(epoch), 0.0);
}
Aggregations