use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class NumericalPropagatorTest method testEphemerisDates.
@Test
public void testEphemerisDates() throws OrekitException {
// setup
TimeScale tai = TimeScalesFactory.getTAI();
AbsoluteDate initialDate = new AbsoluteDate("2015-07-01", 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(startDate, endDate);
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.frames.Frame in project Orekit by CS-SI.
the class NumericalPropagatorTest method testParallelismIssue258.
@Test
public void testParallelismIssue258() throws OrekitException, InterruptedException, ExecutionException, FileNotFoundException {
Utils.setDataRoot("regular-data:atmosphere:potential/grgs-format");
GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
final double mu = GravityFieldFactory.getNormalizedProvider(2, 2).getMu();
// Geostationary transfer orbit
// semi major axis in meters
final double a = 24396159;
// eccentricity
final double e = 0.72831215;
// inclination
final double i = FastMath.toRadians(7);
// perigee argument
final double omega = FastMath.toRadians(180);
// right ascension of ascending node
final double raan = FastMath.toRadians(261);
// mean anomaly
final double lM = 0;
final Frame inertialFrame = FramesFactory.getEME2000();
final TimeScale utc = TimeScalesFactory.getUTC();
final AbsoluteDate initialDate = new AbsoluteDate(2003, 1, 1, 00, 00, 00.000, utc);
final Orbit initialOrbit = new CartesianOrbit(new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu));
final SpacecraftState initialState = new SpacecraftState(initialOrbit, 1000);
// initialize the testing points
final List<SpacecraftState> states = new ArrayList<SpacecraftState>();
final NumericalPropagator propagator = createPropagator(initialState, OrbitType.CARTESIAN, PositionAngle.TRUE);
final double samplingStep = 10000.0;
propagator.setMasterMode(samplingStep, (state, isLast) -> states.add(state));
propagator.propagate(initialDate.shiftedBy(5 * samplingStep));
// compute reference errors, using serial computation in a for loop
final double[][] referenceErrors = new double[states.size() - 1][];
for (int startIndex = 0; startIndex < states.size() - 1; ++startIndex) {
referenceErrors[startIndex] = recomputeFollowing(startIndex, states);
}
final Consumer<SpacecraftState> checker = point -> {
try {
final int startIndex = states.indexOf(point);
double[] errors = recomputeFollowing(startIndex, states);
for (int k = 0; k < errors.length; ++k) {
Assert.assertEquals(startIndex + " to " + (startIndex + k + 1), referenceErrors[startIndex][k], errors[k], 1.0e-9);
}
} catch (OrekitException oe) {
Assert.fail(oe.getLocalizedMessage());
}
};
// serial propagation using Stream
states.stream().forEach(checker);
// parallel propagation using parallelStream
states.parallelStream().forEach(checker);
}
use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class NumericalPropagatorTest method createEllipticOrbit.
private CartesianOrbit createEllipticOrbit() throws OrekitException {
final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(6896874.444705, 1956581.072644, -147476.245054);
final Vector3D velocity = new Vector3D(166.816407662, -1106.783301861, -7372.745712770);
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity);
final Frame frame = FramesFactory.getEME2000();
final double mu = Constants.EIGEN5C_EARTH_MU;
return new CartesianOrbit(pv, frame, mu);
}
use of org.orekit.frames.Frame in project Orekit by CS-SI.
the class DSSTPropagatorTest method testEphemerisDates.
@Test
public void testEphemerisDates() throws OrekitException {
// setup
TimeScale tai = TimeScalesFactory.getTAI();
AbsoluteDate initialDate = new AbsoluteDate("2015-07-01", 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, Constants.EIGEN5C_EARTH_MU);
double[][] tol = DSSTPropagator.tolerances(1, orbit);
Propagator prop = new DSSTPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1]));
prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit)));
// action
prop.setEphemerisMode();
prop.propagate(startDate, endDate);
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.frames.Frame in project Orekit by CS-SI.
the class DSSTPropagatorTest method testPropagationWithThirdBody.
@Test
public void testPropagationWithThirdBody() throws OrekitException, IOException {
// Central Body geopotential 2x0
final UnnormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getUnnormalizedProvider(2, 0);
final Frame earthFrame = CelestialBodyFactory.getEarth().getBodyOrientedFrame();
DSSTForceModel zonal = new DSSTZonal(provider, 2, 1, 5);
DSSTForceModel tesseral = new DSSTTesseral(earthFrame, Constants.WGS84_EARTH_ANGULAR_VELOCITY, provider, 2, 0, 0, 2, 2, 0, 0);
// Third Bodies Force Model (Moon + Sun)
DSSTForceModel moon = new DSSTThirdBody(CelestialBodyFactory.getMoon());
DSSTForceModel sun = new DSSTThirdBody(CelestialBodyFactory.getSun());
// SIRIUS Orbit
final AbsoluteDate initDate = new AbsoluteDate(2003, 7, 1, 0, 0, 00.000, TimeScalesFactory.getUTC());
final Orbit orbit = new KeplerianOrbit(42163393., 0.2684, FastMath.toRadians(63.435), FastMath.toRadians(270.0), FastMath.toRadians(285.0), FastMath.toRadians(344.0), PositionAngle.MEAN, FramesFactory.getEME2000(), initDate, provider.getMu());
// Set propagator with state and force model
setDSSTProp(new SpacecraftState(orbit));
dsstProp.addForceModel(zonal);
dsstProp.addForceModel(tesseral);
dsstProp.addForceModel(moon);
dsstProp.addForceModel(sun);
// 5 days propagation
final SpacecraftState state = dsstProp.propagate(initDate.shiftedBy(5. * 86400.));
// Ref Standalone_DSST:
// a = 42163393.0 m
// h/ey = -0.06893353670734315
// k/ex = -0.2592789733084587
// p/hy = -0.5968524904937771
// q/hx = 0.1595005111738418
// lM = 183°9386620425922
Assert.assertEquals(42163393.0, state.getA(), 1.e-1);
Assert.assertEquals(-0.2592789733084587, state.getEquinoctialEx(), 5.e-7);
Assert.assertEquals(-0.06893353670734315, state.getEquinoctialEy(), 2.e-7);
Assert.assertEquals(0.1595005111738418, state.getHx(), 2.e-7);
Assert.assertEquals(-0.5968524904937771, state.getHy(), 5.e-8);
Assert.assertEquals(183.9386620425922, FastMath.toDegrees(MathUtils.normalizeAngle(state.getLM(), FastMath.PI)), 3.e-2);
}
Aggregations