use of org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics in project Orekit by CS-SI.
the class EGMFormatReaderTest method testReadLimits.
@Test
public void testReadLimits() throws OrekitException {
Utils.setDataRoot("potential");
GravityFieldFactory.addPotentialCoefficientsReader(new EGMFormatReader("egm96_to5.ascii", true));
UnnormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getUnnormalizedProvider(3, 2);
UnnormalizedSphericalHarmonics harmonics = provider.onDate(provider.getReferenceDate());
try {
harmonics.getUnnormalizedCnm(3, 3);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
// expected
} catch (Exception e) {
Assert.fail("wrong exception caught: " + e.getLocalizedMessage());
}
try {
harmonics.getUnnormalizedCnm(4, 2);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
// expected
} catch (Exception e) {
Assert.fail("wrong exception caught: " + e.getLocalizedMessage());
}
harmonics.getUnnormalizedCnm(3, 2);
Assert.assertEquals(3, provider.getMaxDegree());
Assert.assertEquals(2, provider.getMaxOrder());
}
use of org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics in project Orekit by CS-SI.
the class EcksteinHechlerConverterTest method checkFit.
protected void checkFit(final Orbit orbit, final double duration, final double stepSize, final double threshold, final boolean positionOnly, final double expectedRMS) throws OrekitException {
// shift position by 3m
CircularOrbit modified = new CircularOrbit(new TimeStampedPVCoordinates(orbit.getDate(), new Vector3D(1, orbit.getPVCoordinates().getPosition(), 3.0, Vector3D.PLUS_J), orbit.getPVCoordinates().getVelocity()), orbit.getFrame(), orbit.getMu());
Propagator p = new EcksteinHechlerPropagator(modified, provider);
List<SpacecraftState> sample = new ArrayList<SpacecraftState>();
for (double dt = 0; dt < duration; dt += stepSize) {
sample.add(p.propagate(modified.getDate().shiftedBy(dt)));
}
UnnormalizedSphericalHarmonics harmonics = provider.onDate(orbit.getDate());
PropagatorBuilder builder = new EcksteinHechlerPropagatorBuilder(orbit, provider.getAe(), provider.getMu(), provider.getTideSystem(), harmonics.getUnnormalizedCnm(2, 0), harmonics.getUnnormalizedCnm(3, 0), harmonics.getUnnormalizedCnm(4, 0), harmonics.getUnnormalizedCnm(5, 0), harmonics.getUnnormalizedCnm(6, 0), OrbitType.CIRCULAR, PositionAngle.TRUE, 1.0);
FiniteDifferencePropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, threshold, 1000);
fitter.convert(sample, positionOnly);
Assert.assertEquals(expectedRMS, fitter.getRMS(), 0.01 * expectedRMS);
EcksteinHechlerPropagator prop = (EcksteinHechlerPropagator) fitter.getAdaptedPropagator();
Orbit fitted = prop.getInitialState().getOrbit();
final double eps = 1.0e-12;
Assert.assertEquals(modified.getPVCoordinates().getPosition().getX(), fitted.getPVCoordinates().getPosition().getX(), eps * modified.getPVCoordinates().getPosition().getX());
Assert.assertEquals(modified.getPVCoordinates().getPosition().getY(), fitted.getPVCoordinates().getPosition().getY(), eps * modified.getPVCoordinates().getPosition().getY());
Assert.assertEquals(modified.getPVCoordinates().getPosition().getZ(), fitted.getPVCoordinates().getPosition().getZ(), eps * modified.getPVCoordinates().getPosition().getZ());
Assert.assertEquals(modified.getPVCoordinates().getVelocity().getX(), fitted.getPVCoordinates().getVelocity().getX(), eps * modified.getPVCoordinates().getVelocity().getX());
Assert.assertEquals(modified.getPVCoordinates().getVelocity().getY(), fitted.getPVCoordinates().getVelocity().getY(), -eps * modified.getPVCoordinates().getVelocity().getY());
Assert.assertEquals(modified.getPVCoordinates().getVelocity().getZ(), fitted.getPVCoordinates().getVelocity().getZ(), -eps * modified.getPVCoordinates().getVelocity().getZ());
}
Aggregations