Search in sources :

Example 16 with NormalizedSphericalHarmonicsProvider

use of org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider in project Orekit by CS-SI.

the class HolmesFeatherstoneAttractionModelTest method RealFieldExpectErrorTest.

/**
 *Same test as the previous one but not adding the ForceModel to the NumericalPropagator
 *    it is a test to validate the previous test.
 *    (to test if the ForceModel it's actually
 *    doing something in the Propagator and the FieldPropagator)
 */
@Test
public void RealFieldExpectErrorTest() throws OrekitException {
    DSFactory factory = new DSFactory(6, 0);
    DerivativeStructure a_0 = factory.variable(0, 7201009.7124401);
    DerivativeStructure e_0 = factory.variable(1, 1e-3);
    DerivativeStructure i_0 = factory.variable(2, 98.7 * FastMath.PI / 180);
    DerivativeStructure R_0 = factory.variable(3, 15.0 * 22.5 * FastMath.PI / 180);
    DerivativeStructure O_0 = factory.variable(4, 93.0 * FastMath.PI / 180);
    DerivativeStructure n_0 = factory.variable(5, 0.1);
    Field<DerivativeStructure> field = a_0.getField();
    DerivativeStructure zero = field.getZero();
    FieldAbsoluteDate<DerivativeStructure> J2000 = new FieldAbsoluteDate<>(field);
    Frame EME = FramesFactory.getEME2000();
    FieldKeplerianOrbit<DerivativeStructure> FKO = new FieldKeplerianOrbit<>(a_0, e_0, i_0, R_0, O_0, n_0, PositionAngle.MEAN, EME, J2000, Constants.EIGEN5C_EARTH_MU);
    FieldSpacecraftState<DerivativeStructure> initialState = new FieldSpacecraftState<>(FKO);
    SpacecraftState iSR = initialState.toSpacecraftState();
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = NumericalPropagator.tolerances(10.0, FKO.toOrbit(), type);
    AdaptiveStepsizeFieldIntegrator<DerivativeStructure> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    AdaptiveStepsizeIntegrator RIntegrator = new DormandPrince853Integrator(0.001, 200, tolerance[0], tolerance[1]);
    RIntegrator.setInitialStepSize(60);
    FieldNumericalPropagator<DerivativeStructure> FNP = new FieldNumericalPropagator<>(field, integrator);
    FNP.setOrbitType(type);
    FNP.setInitialState(initialState);
    NumericalPropagator NP = new NumericalPropagator(RIntegrator);
    NP.setOrbitType(type);
    NP.setInitialState(iSR);
    double[][] c = new double[3][1];
    c[0][0] = 0.0;
    c[2][0] = normalizedC20;
    double[][] s = new double[3][1];
    NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(6378136.460, mu, TideSystem.UNKNOWN, c, s);
    HolmesFeatherstoneAttractionModel forceModel = new HolmesFeatherstoneAttractionModel(itrf, provider);
    // FNP.addForceModel(forceModel);
    NP.addForceModel(forceModel);
    FieldAbsoluteDate<DerivativeStructure> target = J2000.shiftedBy(100.);
    FieldSpacecraftState<DerivativeStructure> finalState_DS = FNP.propagate(target);
    SpacecraftState finalState_R = NP.propagate(target.toAbsoluteDate());
    FieldPVCoordinates<DerivativeStructure> finPVC_DS = finalState_DS.getPVCoordinates();
    PVCoordinates finPVC_R = finalState_R.getPVCoordinates();
    Assert.assertFalse(FastMath.abs(finPVC_DS.toPVCoordinates().getPosition().getX() - finPVC_R.getPosition().getX()) < FastMath.abs(finPVC_R.getPosition().getX()) * 1e-11);
    Assert.assertFalse(FastMath.abs(finPVC_DS.toPVCoordinates().getPosition().getY() - finPVC_R.getPosition().getY()) < FastMath.abs(finPVC_R.getPosition().getY()) * 1e-11);
    Assert.assertFalse(FastMath.abs(finPVC_DS.toPVCoordinates().getPosition().getZ() - finPVC_R.getPosition().getZ()) < FastMath.abs(finPVC_R.getPosition().getZ()) * 1e-11);
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) Frame(org.orekit.frames.Frame) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) OrbitType(org.orekit.orbits.OrbitType) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 17 with NormalizedSphericalHarmonicsProvider

use of org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider in project Orekit by CS-SI.

the class HolmesFeatherstoneAttractionModelTest method testValue.

@Test
public void testValue() throws OrekitException {
    int max = 50;
    NormalizedSphericalHarmonicsProvider provider = new GleasonProvider(max, max);
    HolmesFeatherstoneAttractionModel model = new HolmesFeatherstoneAttractionModel(itrf, provider);
    double r = 1.25;
    for (double lambda = 0; lambda < 2 * FastMath.PI; lambda += 0.5) {
        for (double theta = 0.05; theta < 3.11; theta += 0.03) {
            Vector3D position = new Vector3D(r * FastMath.sin(theta) * FastMath.cos(lambda), r * FastMath.sin(theta) * FastMath.sin(lambda), r * FastMath.cos(theta));
            double refValue = provider.getMu() / position.getNorm() + model.nonCentralPart(AbsoluteDate.GPS_EPOCH, position, model.getMu());
            double value = model.value(AbsoluteDate.GPS_EPOCH, position, model.getMu());
            Assert.assertEquals(refValue, value, 1.0e-15 * FastMath.abs(refValue));
        }
    }
}
Also used : FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 18 with NormalizedSphericalHarmonicsProvider

use of org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider in project Orekit by CS-SI.

the class HolmesFeatherstoneAttractionModelTest method testHessian.

@Test
public void testHessian() throws OrekitException {
    int max = 50;
    NormalizedSphericalHarmonicsProvider provider = new GleasonProvider(max, max);
    HolmesFeatherstoneAttractionModel model = new HolmesFeatherstoneAttractionModel(itrf, provider);
    double r = 1.25;
    for (double lambda = 0; lambda < 2 * FastMath.PI; lambda += 0.5) {
        for (double theta = 0.05; theta < 3.11; theta += 0.03) {
            Vector3D position = new Vector3D(r * FastMath.sin(theta) * FastMath.cos(lambda), r * FastMath.sin(theta) * FastMath.sin(lambda), r * FastMath.cos(theta));
            double[][] refHessian = hessian(model, null, position, 1.0e-3);
            double[][] hessian = gradientHessian(model, null, position).getHessian();
            double normH2 = 0;
            double normE2 = 0;
            for (int i = 0; i < 3; ++i) {
                for (int j = 0; j < 3; ++j) {
                    double error = refHessian[i][j] - hessian[i][j];
                    normH2 += refHessian[i][j] * refHessian[i][j];
                    normE2 += error * error;
                }
            }
            Assert.assertEquals(0, FastMath.sqrt(normE2 / normH2), 5.0e-12);
        }
    }
}
Also used : FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 19 with NormalizedSphericalHarmonicsProvider

use of org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider in project Orekit by CS-SI.

the class OceanTidesTest method doTestTideEffect.

private void doTestTideEffect(IERSConventions conventions, double delta1, double delta2) throws OrekitException {
    Frame eme2000 = FramesFactory.getEME2000();
    Frame itrf = FramesFactory.getITRF(conventions, true);
    TimeScale utc = TimeScalesFactory.getUTC();
    UT1Scale ut1 = TimeScalesFactory.getUT1(conventions, true);
    AstronomicalAmplitudeReader aaReader = new AstronomicalAmplitudeReader("hf-fes2004.dat", 5, 2, 3, 1.0);
    DataProvidersManager.getInstance().feed(aaReader.getSupportedNames(), aaReader);
    Map<Integer, Double> map = aaReader.getAstronomicalAmplitudesMap();
    GravityFieldFactory.addOceanTidesReader(new FESCHatEpsilonReader("fes2004-7x7.dat", 0.01, FastMath.toRadians(1.0), OceanLoadDeformationCoefficients.IERS_2010, map));
    NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getConstantNormalizedProvider(5, 5);
    // initialization
    AbsoluteDate date = new AbsoluteDate(2003, 07, 01, 13, 59, 27.816, utc);
    Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, FastMath.toRadians(98.7), FastMath.toRadians(93.0), FastMath.toRadians(15.0 * 22.5), 0, PositionAngle.MEAN, eme2000, date, gravityField.getMu());
    AbsoluteDate target = date.shiftedBy(7 * Constants.JULIAN_DAY);
    ForceModel hf = new HolmesFeatherstoneAttractionModel(itrf, gravityField);
    SpacecraftState noTides = propagate(orbit, target, hf);
    SpacecraftState oceanTidesNoPoleTide = propagate(orbit, target, hf, new OceanTides(itrf, gravityField.getAe(), gravityField.getMu(), false, SolidTides.DEFAULT_STEP, SolidTides.DEFAULT_POINTS, 6, 6, conventions, ut1));
    SpacecraftState oceanTidesPoleTide = propagate(orbit, target, hf, new OceanTides(itrf, gravityField.getAe(), gravityField.getMu(), true, SolidTides.DEFAULT_STEP, SolidTides.DEFAULT_POINTS, 6, 6, conventions, ut1));
    Assert.assertEquals(delta1, Vector3D.distance(noTides.getPVCoordinates().getPosition(), oceanTidesNoPoleTide.getPVCoordinates().getPosition()), 0.01);
    Assert.assertEquals(delta2, Vector3D.distance(oceanTidesNoPoleTide.getPVCoordinates().getPosition(), oceanTidesPoleTide.getPVCoordinates().getPosition()), 0.01);
}
Also used : Frame(org.orekit.frames.Frame) Orbit(org.orekit.orbits.Orbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) ForceModel(org.orekit.forces.ForceModel) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) UT1Scale(org.orekit.time.UT1Scale) FESCHatEpsilonReader(org.orekit.forces.gravity.potential.FESCHatEpsilonReader) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) AstronomicalAmplitudeReader(org.orekit.forces.gravity.potential.AstronomicalAmplitudeReader)

Example 20 with NormalizedSphericalHarmonicsProvider

use of org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider in project Orekit by CS-SI.

the class SolidTidesTest method testDefaultInterpolation.

@Test
public void testDefaultInterpolation() throws OrekitException {
    IERSConventions conventions = IERSConventions.IERS_2010;
    Frame eme2000 = FramesFactory.getEME2000();
    Frame itrf = FramesFactory.getITRF(conventions, true);
    TimeScale utc = TimeScalesFactory.getUTC();
    UT1Scale ut1 = TimeScalesFactory.getUT1(conventions, true);
    NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getConstantNormalizedProvider(5, 5);
    // initialization
    AbsoluteDate date = new AbsoluteDate(1970, 07, 01, 13, 59, 27.816, utc);
    Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, FastMath.toRadians(98.7), FastMath.toRadians(93.0), FastMath.toRadians(15.0 * 22.5), 0, PositionAngle.MEAN, eme2000, date, gravityField.getMu());
    AbsoluteDate target = date.shiftedBy(7 * Constants.JULIAN_DAY);
    ForceModel hf = new HolmesFeatherstoneAttractionModel(itrf, gravityField);
    SpacecraftState raw = propagate(orbit, target, hf, new SolidTides(itrf, gravityField.getAe(), gravityField.getMu(), gravityField.getTideSystem(), true, Double.NaN, -1, conventions, ut1, CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon()));
    SpacecraftState interpolated = propagate(orbit, target, hf, new SolidTides(itrf, gravityField.getAe(), gravityField.getMu(), gravityField.getTideSystem(), conventions, ut1, CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon()));
    Assert.assertEquals(0.0, Vector3D.distance(raw.getPVCoordinates().getPosition(), interpolated.getPVCoordinates().getPosition()), // threshold would be 1.2e-3 for 30 days propagation
    2.0e-5);
}
Also used : FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState) Frame(org.orekit.frames.Frame) UT1Scale(org.orekit.time.UT1Scale) Orbit(org.orekit.orbits.Orbit) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) ForceModel(org.orekit.forces.ForceModel) IERSConventions(org.orekit.utils.IERSConventions) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) TimeScale(org.orekit.time.TimeScale) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Aggregations

NormalizedSphericalHarmonicsProvider (org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider)34 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)19 Test (org.junit.Test)18 Orbit (org.orekit.orbits.Orbit)18 SpacecraftState (org.orekit.propagation.SpacecraftState)18 AbsoluteDate (org.orekit.time.AbsoluteDate)17 Frame (org.orekit.frames.Frame)15 ForceModel (org.orekit.forces.ForceModel)14 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)11 HolmesFeatherstoneAttractionModel (org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel)11 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)10 TimeScale (org.orekit.time.TimeScale)10 UT1Scale (org.orekit.time.UT1Scale)10 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)8 OrbitType (org.orekit.orbits.OrbitType)8 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)8 PVCoordinates (org.orekit.utils.PVCoordinates)8 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)7 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)7 IERSConventions (org.orekit.utils.IERSConventions)7