use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class NodeDetectorTest method testIssue138.
@Test
public void testIssue138() throws OrekitException {
double a = 800000 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
double e = 0.0001;
double i = FastMath.toRadians(98);
double w = -90;
double raan = 0;
double v = 0;
Frame inertialFrame = FramesFactory.getEME2000();
AbsoluteDate initialDate = new AbsoluteDate(2014, 01, 01, 0, 0, 0, TimeScalesFactory.getUTC());
AbsoluteDate finalDate = initialDate.shiftedBy(5000);
KeplerianOrbit initialOrbit = new KeplerianOrbit(a, e, i, w, raan, v, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU);
SpacecraftState initialState = new SpacecraftState(initialOrbit, 1000);
double[][] tol = NumericalPropagator.tolerances(10, initialOrbit, initialOrbit.getType());
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setInitialState(initialState);
// Define 2 instances of NodeDetector:
EventDetector rawDetector = new NodeDetector(1e-6, initialState.getOrbit(), initialState.getFrame()).withHandler(new ContinueOnEvent<NodeDetector>());
EventsLogger logger1 = new EventsLogger();
EventDetector node1 = logger1.monitorDetector(rawDetector);
EventsLogger logger2 = new EventsLogger();
EventDetector node2 = logger2.monitorDetector(rawDetector);
propagator.addEventDetector(node1);
propagator.addEventDetector(node2);
// First propagation
propagator.setEphemerisMode();
propagator.propagate(finalDate);
Assert.assertEquals(2, logger1.getLoggedEvents().size());
Assert.assertEquals(2, logger2.getLoggedEvents().size());
logger1.clearLoggedEvents();
logger2.clearLoggedEvents();
BoundedPropagator postpro = propagator.getGeneratedEphemeris();
// Post-processing
postpro.addEventDetector(node1);
postpro.addEventDetector(node2);
postpro.propagate(finalDate);
Assert.assertEquals(2, logger1.getLoggedEvents().size());
Assert.assertEquals(2, logger2.getLoggedEvents().size());
}
use of org.orekit.propagation.BoundedPropagator 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.BoundedPropagator in project Orekit by CS-SI.
the class OEMParserTest method testParseOemMissingOptionalData.
@Test
public void testParseOemMissingOptionalData() throws OrekitException, IOException {
final String ex = "/ccsds/OEMExample6.txt";
final InputStream inEntry = getClass().getResourceAsStream(ex);
final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
final OEMFile file = parser.parse(inEntry);
Assert.assertEquals(CcsdsTimeScale.UTC, file.getEphemeridesBlocks().get(0).getMetaData().getTimeSystem());
Assert.assertEquals("MARS GLOBAL SURVEYOR", file.getEphemeridesBlocks().get(0).getMetaData().getObjectName());
Assert.assertEquals("1996-062A", file.getEphemeridesBlocks().get(0).getMetaData().getObjectID());
Assert.assertEquals(1, file.getSatellites().size());
Assert.assertEquals(true, file.getSatellites().containsKey("1996-062A"));
Assert.assertEquals(false, file.getSatellites().containsKey("MARS GLOBAL SURVEYOR"));
Assert.assertEquals(1, file.getSatellites().size());
Assert.assertEquals("1996-062A", file.getSatellites().values().iterator().next().getId());
Assert.assertEquals(new AbsoluteDate("2002-12-18T12:00:00.331", TimeScalesFactory.getUTC()), file.getEphemeridesBlocks().get(0).getStartTime());
OemSatelliteEphemeris satellite = file.getSatellites().get("1996-062A");
Assert.assertEquals(satellite.getId(), "1996-062A");
Assert.assertEquals(satellite.getMu(), file.getMuUsed(), 0);
EphemeridesBlock actualBlock = satellite.getSegments().get(0);
Assert.assertEquals(actualBlock.getMu(), file.getMuUsed(), 0);
FactoryManagedFrame eme2000 = FramesFactory.getEME2000();
Frame actualFrame = actualBlock.getFrame();
AbsoluteDate actualStart = satellite.getStart();
Transform actualTransform = eme2000.getTransformTo(actualFrame, actualStart);
CelestialBody mars = CelestialBodyFactory.getMars();
TimeStampedPVCoordinates marsPV = mars.getPVCoordinates(actualStart, eme2000);
Assert.assertEquals(actualTransform.getTranslation(), marsPV.getPosition());
Assert.assertEquals(actualTransform.getVelocity(), marsPV.getVelocity());
Assert.assertEquals(actualTransform.getAcceleration(), marsPV.getAcceleration());
Assert.assertEquals(Rotation.distance(actualTransform.getRotation(), Rotation.IDENTITY), 0.0, 0.0);
Assert.assertEquals(actualTransform.getRotationRate(), Vector3D.ZERO);
Assert.assertEquals(actualTransform.getRotationAcceleration(), Vector3D.ZERO);
Assert.assertEquals(actualFrame.getName(), "Mars/EME2000");
Assert.assertEquals(actualBlock.getFrameString(), "EME2000");
Assert.assertEquals(actualBlock.getTimeScaleString(), "UTC");
Assert.assertEquals(actualBlock.getTimeScale(), TimeScalesFactory.getUTC());
Assert.assertEquals(actualBlock.getAvailableDerivatives(), CartesianDerivativesFilter.USE_PV);
Assert.assertEquals(satellite.getSegments().get(0).getStartTime(), actualStart);
Assert.assertEquals(satellite.getSegments().get(2).getStopTime(), satellite.getStop());
final BoundedPropagator propagator = satellite.getPropagator();
Assert.assertEquals(propagator.getMinDate(), satellite.getStart());
Assert.assertEquals(propagator.getMinDate(), satellite.getSegments().get(0).getStart());
Assert.assertEquals(propagator.getMaxDate(), satellite.getStop());
Assert.assertEquals(propagator.getMaxDate(), satellite.getSegments().get(2).getStop());
final List<TimeStampedPVCoordinates> dataLines = new ArrayList<>();
for (EphemeridesBlock block : file.getEphemeridesBlocks()) {
for (TimeStampedPVCoordinates dataLine : block.getEphemeridesDataLines()) {
if (dataLine.getDate().compareTo(satellite.getStart()) >= 0) {
dataLines.add(dataLine);
}
}
}
final int ulps = 12;
for (TimeStampedPVCoordinates coord : dataLines) {
Assert.assertThat(propagator.getPVCoordinates(coord.getDate(), actualFrame), OrekitMatchers.pvCloseTo(coord, ulps));
Assert.assertThat(propagator.propagate(coord.getDate()).getPVCoordinates(), OrekitMatchers.pvCloseTo(coord, ulps));
}
}
use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class SmallManeuverAnalyticalModelTest method testLowEarthOrbit2.
@Test
public void testLowEarthOrbit2() throws OrekitException {
Orbit leo = new CircularOrbit(7200000.0, -1.0e-5, 2.0e-4, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.0, PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
double mass = 5600.0;
AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
Vector3D dV = new Vector3D(-0.01, 0.02, 0.03);
double f = 20.0;
double isp = 315.0;
BoundedPropagator withoutManeuver = getEphemeris(leo, mass, t0, Vector3D.ZERO, f, isp);
BoundedPropagator withManeuver = getEphemeris(leo, mass, t0, dV, f, isp);
SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV, isp);
Assert.assertEquals(t0, model.getDate());
for (AbsoluteDate t = withoutManeuver.getMinDate(); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t.shiftedBy(60.0)) {
PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame());
PVCoordinates pvWith = withManeuver.getPVCoordinates(t, leo.getFrame());
PVCoordinates pvModel = model.apply(withoutManeuver.propagate(t).getOrbit()).getPVCoordinates(leo.getFrame());
double nominalDeltaP = new PVCoordinates(pvWith, pvWithout).getPosition().getNorm();
double modelError = new PVCoordinates(pvWith, pvModel).getPosition().getNorm();
if (t.compareTo(t0) < 0) {
// before maneuver, all positions should be equal
Assert.assertEquals(0, nominalDeltaP, 1.0e-10);
Assert.assertEquals(0, modelError, 1.0e-10);
} else {
// despite nominal deltaP exceeds 1 kilometer after less than 3 orbits
if (t.durationFrom(t0) > 0.1 * leo.getKeplerianPeriod()) {
Assert.assertTrue(modelError < 0.009 * nominalDeltaP);
}
Assert.assertTrue(modelError < 0.8);
}
}
}
use of org.orekit.propagation.BoundedPropagator in project Orekit by CS-SI.
the class SmallManeuverAnalyticalModelTest method testJacobian.
@Test
public void testJacobian() throws OrekitException {
Frame eme2000 = FramesFactory.getEME2000();
Orbit leo = new CircularOrbit(7200000.0, -1.0e-2, 2.0e-3, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.3, PositionAngle.MEAN, eme2000, new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
double mass = 5600.0;
AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
Vector3D dV0 = new Vector3D(-0.1, 0.2, 0.3);
double f = 400.0;
double isp = 315.0;
for (OrbitType orbitType : OrbitType.values()) {
for (PositionAngle positionAngle : PositionAngle.values()) {
BoundedPropagator withoutManeuver = getEphemeris(orbitType.convertType(leo), mass, t0, Vector3D.ZERO, f, isp);
SpacecraftState state0 = withoutManeuver.propagate(t0);
SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(state0, eme2000, dV0, isp);
Assert.assertEquals(t0, model.getDate());
Vector3D[] velDirs = new Vector3D[] { Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.ZERO };
double[] timeDirs = new double[] { 0, 0, 0, 1 };
double h = 1.0;
AbsoluteDate t1 = t0.shiftedBy(20.0);
for (int i = 0; i < 4; ++i) {
SmallManeuverAnalyticalModel[] models = new SmallManeuverAnalyticalModel[] { new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-4 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -4 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-3 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -3 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-2 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -2 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-1 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -1 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+1 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +1 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+2 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +2 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+3 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +3 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+4 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +4 * h, velDirs[i]), isp) };
double[][] array = new double[models.length][6];
Orbit orbitWithout = withoutManeuver.propagate(t1).getOrbit();
// compute reference orbit gradient by finite differences
double c = 1.0 / (840 * h);
for (int j = 0; j < models.length; ++j) {
orbitType.mapOrbitToArray(models[j].apply(orbitWithout), positionAngle, array[j], null);
}
double[] orbitGradient = new double[6];
for (int k = 0; k < orbitGradient.length; ++k) {
double d4 = array[7][k] - array[0][k];
double d3 = array[6][k] - array[1][k];
double d2 = array[5][k] - array[2][k];
double d1 = array[4][k] - array[3][k];
orbitGradient[k] = (-3 * d4 + 32 * d3 - 168 * d2 + 672 * d1) * c;
}
// analytical Jacobian to check
double[][] jacobian = new double[6][4];
model.getJacobian(orbitWithout, positionAngle, jacobian);
for (int j = 0; j < orbitGradient.length; ++j) {
Assert.assertEquals(orbitGradient[j], jacobian[j][i], 1.6e-4 * FastMath.abs(orbitGradient[j]));
}
}
}
}
}
Aggregations