Search in sources :

Example 16 with UnnormalizedSphericalHarmonics

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());
}
Also used : OrekitException(org.orekit.errors.OrekitException) UnnormalizedSphericalHarmonics(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Example 17 with UnnormalizedSphericalHarmonics

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());
}
Also used : Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) ArrayList(java.util.ArrayList) UnnormalizedSphericalHarmonics(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator)

Aggregations

UnnormalizedSphericalHarmonics (org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics)17 Test (org.junit.Test)13 AbsoluteDate (org.orekit.time.AbsoluteDate)6 OrekitException (org.orekit.errors.OrekitException)4 ArrayList (java.util.ArrayList)1 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)1 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)1 CircularOrbit (org.orekit.orbits.CircularOrbit)1 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)1 Orbit (org.orekit.orbits.Orbit)1 Propagator (org.orekit.propagation.Propagator)1 SpacecraftState (org.orekit.propagation.SpacecraftState)1 EcksteinHechlerPropagator (org.orekit.propagation.analytical.EcksteinHechlerPropagator)1 NSKey (org.orekit.propagation.semianalytical.dsst.utilities.CoefficientsFactory.NSKey)1 HansenTesseralLinear (org.orekit.propagation.semianalytical.dsst.utilities.hansen.HansenTesseralLinear)1 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)1