Search in sources :

Example 21 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class FundamentalNutationArgumentsTest method testDotField.

@Test
public void testDotField() throws OrekitException {
    final IERSConventions conventions = IERSConventions.IERS_2010;
    final TimeScale ut1 = TimeScalesFactory.getUT1(conventions, false);
    final FundamentalNutationArguments fna = conventions.getNutationArguments(ut1);
    final FieldAbsoluteDate<Decimal64> t0 = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), 2002, 4, 7, 12, 34, 22.5, TimeScalesFactory.getUTC());
    final UnivariateDifferentiableFunction gamma = differentiate(fna, t0, b -> b.getGamma());
    final UnivariateDifferentiableFunction l = differentiate(fna, t0, b -> b.getL());
    final UnivariateDifferentiableFunction lPrime = differentiate(fna, t0, b -> b.getLPrime());
    final UnivariateDifferentiableFunction f = differentiate(fna, t0, b -> b.getF());
    final UnivariateDifferentiableFunction d = differentiate(fna, t0, b -> b.getD());
    final UnivariateDifferentiableFunction lMe = differentiate(fna, t0, b -> b.getLMe());
    final UnivariateDifferentiableFunction lVe = differentiate(fna, t0, b -> b.getLVe());
    final UnivariateDifferentiableFunction lE = differentiate(fna, t0, b -> b.getLE());
    final UnivariateDifferentiableFunction lMa = differentiate(fna, t0, b -> b.getLMa());
    final UnivariateDifferentiableFunction lJu = differentiate(fna, t0, b -> b.getLJu());
    final UnivariateDifferentiableFunction lSa = differentiate(fna, t0, b -> b.getLSa());
    final UnivariateDifferentiableFunction lUr = differentiate(fna, t0, b -> b.getLUr());
    final UnivariateDifferentiableFunction lNe = differentiate(fna, t0, b -> b.getLNe());
    final UnivariateDifferentiableFunction pa = differentiate(fna, t0, b -> b.getPa());
    final DSFactory factory = new DSFactory(1, 1);
    double maxErrorGamma = 0;
    double maxErrorL = 0;
    double maxErrorLPrime = 0;
    double maxErrorF = 0;
    double maxErrorD = 0;
    double maxErrorLMe = 0;
    double maxErrorLVe = 0;
    double maxErrorLE = 0;
    double maxErrorLMa = 0;
    double maxErrorLJu = 0;
    double maxErrorLSa = 0;
    double maxErrorLUr = 0;
    double maxErrorLNe = 0;
    double maxErrorPa = 0;
    for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 60.0) {
        FieldBodiesElements<Decimal64> be = fna.evaluateAll(t0.shiftedBy(dt));
        DerivativeStructure dtDS = factory.variable(0, dt);
        maxErrorGamma = FastMath.max(maxErrorGamma, FastMath.abs(gamma.value(dtDS).getPartialDerivative(1) - be.getGammaDot().getReal()));
        maxErrorL = FastMath.max(maxErrorL, FastMath.abs(l.value(dtDS).getPartialDerivative(1) - be.getLDot().getReal()));
        maxErrorLPrime = FastMath.max(maxErrorLPrime, FastMath.abs(lPrime.value(dtDS).getPartialDerivative(1) - be.getLPrimeDot().getReal()));
        maxErrorF = FastMath.max(maxErrorF, FastMath.abs(f.value(dtDS).getPartialDerivative(1) - be.getFDot().getReal()));
        maxErrorD = FastMath.max(maxErrorD, FastMath.abs(d.value(dtDS).getPartialDerivative(1) - be.getDDot().getReal()));
        maxErrorLMe = FastMath.max(maxErrorLMe, FastMath.abs(lMe.value(dtDS).getPartialDerivative(1) - be.getLMeDot().getReal()));
        maxErrorLVe = FastMath.max(maxErrorLVe, FastMath.abs(lVe.value(dtDS).getPartialDerivative(1) - be.getLVeDot().getReal()));
        maxErrorLE = FastMath.max(maxErrorLE, FastMath.abs(lE.value(dtDS).getPartialDerivative(1) - be.getLEDot().getReal()));
        maxErrorLMa = FastMath.max(maxErrorLMa, FastMath.abs(lMa.value(dtDS).getPartialDerivative(1) - be.getLMaDot().getReal()));
        maxErrorLJu = FastMath.max(maxErrorLJu, FastMath.abs(lJu.value(dtDS).getPartialDerivative(1) - be.getLJuDot().getReal()));
        maxErrorLSa = FastMath.max(maxErrorLSa, FastMath.abs(lSa.value(dtDS).getPartialDerivative(1) - be.getLSaDot().getReal()));
        maxErrorLUr = FastMath.max(maxErrorLUr, FastMath.abs(lUr.value(dtDS).getPartialDerivative(1) - be.getLUrDot().getReal()));
        maxErrorLNe = FastMath.max(maxErrorLNe, FastMath.abs(lNe.value(dtDS).getPartialDerivative(1) - be.getLNeDot().getReal()));
        maxErrorPa = FastMath.max(maxErrorPa, FastMath.abs(pa.value(dtDS).getPartialDerivative(1) - be.getPaDot().getReal()));
    }
    Assert.assertEquals(0, maxErrorGamma, 8.0e-13);
    Assert.assertEquals(0, maxErrorL, 1.0e-14);
    Assert.assertEquals(0, maxErrorLPrime, 6.0e-16);
    Assert.assertEquals(0, maxErrorF, 6.0e-15);
    Assert.assertEquals(0, maxErrorD, 6.0e-15);
    Assert.assertEquals(0, maxErrorLMe, 2.0e-15);
    Assert.assertEquals(0, maxErrorLVe, 5.0e-16);
    Assert.assertEquals(0, maxErrorLE, 3.0e-16);
    Assert.assertEquals(0, maxErrorLMa, 4.0e-16);
    Assert.assertEquals(0, maxErrorLJu, 3.0e-17);
    Assert.assertEquals(0, maxErrorLSa, 4.0e-17);
    Assert.assertEquals(0, maxErrorLUr, 1.0e-16);
    Assert.assertEquals(0, maxErrorLNe, 8.0e-17);
    Assert.assertEquals(0, maxErrorPa, 3.0e-20);
}
Also used : IERSConventions(org.orekit.utils.IERSConventions) Decimal64(org.hipparchus.util.Decimal64) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) TimeScale(org.orekit.time.TimeScale) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) Test(org.junit.Test)

Example 22 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class DTM2000Test method testField.

@Test
public void testField() throws OrekitException {
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
    OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.460, 1.0 / 298.257222101, itrf);
    SolarInputs97to05 in = SolarInputs97to05.getInstance();
    earth.setAngularThreshold(1e-10);
    DTM2000 atm = new DTM2000(in, sun, earth);
    // Computation and results
    for (double alti = 400; alti < 1000; alti += 50) {
        for (double lon = 0; lon < 6; lon += 0.5) {
            for (double lat = -1.5; lat < 1.5; lat += 0.5) {
                for (double hl = 0; hl < 6; hl += 0.5) {
                    double rhoD = atm.getDensity(185, alti * 1000, lon, lat, hl, 50, 150, 0, 0);
                    Decimal64 rho64 = atm.getDensity(185, new Decimal64(alti * 1000), new Decimal64(lon), new Decimal64(lat), new Decimal64(hl), 50, 150, 0, 0);
                    Assert.assertEquals(rhoD, rho64.getReal(), rhoD * 1e-14);
                }
            }
        }
    }
}
Also used : Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Decimal64(org.hipparchus.util.Decimal64) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) SolarInputs97to05(org.orekit.SolarInputs97to05) Test(org.junit.Test)

Example 23 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class JB2008Test method testDensityField.

@Test
public void testDensityField() throws OrekitException {
    final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
    final JB2008 atm = new JB2008(new InputParams(), CelestialBodyFactory.getSun(), earth);
    final AbsoluteDate date = InputParams.TC[4];
    for (double alt = 100; alt < 1000; alt += 50) {
        for (double lat = -1.2; lat < 1.2; lat += 0.4) {
            for (double lon = 0; lon < 6.28; lon += 0.8) {
                final GeodeticPoint point = new GeodeticPoint(lat, lon, alt * 1000.);
                final Vector3D pos = earth.transform(point);
                Field<Decimal64> field = Decimal64Field.getInstance();
                // Run
                final double rho = atm.getDensity(date, pos, itrf);
                final Decimal64 rho64 = atm.getDensity(new FieldAbsoluteDate<>(field, date), new FieldVector3D<>(field.getOne(), pos), itrf);
                Assert.assertEquals(rho, rho64.getReal(), rho * 4.0e-13);
            }
        }
    }
}
Also used : Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Decimal64(org.hipparchus.util.Decimal64) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 24 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class BoxAndSolarArraySpacecraftTest method testNormalFixedRateField.

@Test
public void testNormalFixedRateField() throws OrekitException {
    AbsoluteDate initialDate = propagator.getInitialState().getDate();
    CelestialBody sun = CelestialBodyFactory.getSun();
    BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, initialDate, Vector3D.PLUS_K, 1.0e-3, 0.0, 1.0, 0.0);
    Field<Decimal64> field = Decimal64Field.getInstance();
    for (double dt = 0; dt < 4000; dt += 60) {
        AbsoluteDate date = initialDate.shiftedBy(dt);
        SpacecraftState state = propagator.propagate(date);
        FieldVector3D<Decimal64> normal = s.getNormal(new FieldAbsoluteDate<>(field, state.getDate()), state.getFrame(), new FieldVector3D<>(field, state.getPVCoordinates().getPosition()), new FieldRotation<>(field, state.getAttitude().getRotation()));
        Assert.assertEquals(0, FieldVector3D.dotProduct(normal, Vector3D.PLUS_J).getReal(), 1.0e-16);
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) CelestialBody(org.orekit.bodies.CelestialBody) Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 25 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class NRLMSISE00Test method testDensityField.

@Test
public void testDensityField() throws OrekitException {
    // Build the input params provider
    final InputParams ip = new InputParams();
    // Get Sun
    final PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
    // Get Earth body shape
    final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
    // Build the model
    final NRLMSISE00 atm = new NRLMSISE00(ip, sun, earth);
    // Build the date
    final AbsoluteDate date = new AbsoluteDate(new DateComponents(2003, 172), new TimeComponents(29000.), TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true));
    // Build the position
    final double alt = 400.;
    final double lat = 60.;
    final double lon = -70.;
    final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(lat), FastMath.toRadians(lon), alt * 1000.);
    final Vector3D pos = earth.transform(point);
    Field<Decimal64> field = Decimal64Field.getInstance();
    // Run
    final double rho = atm.getDensity(date, pos, itrf);
    final Decimal64 rho64 = atm.getDensity(new FieldAbsoluteDate<>(field, date), new FieldVector3D<>(field.getOne(), pos), itrf);
    Assert.assertEquals(rho, rho64.getReal(), rho * 2.0e-13);
}
Also used : Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Decimal64(org.hipparchus.util.Decimal64) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Aggregations

Decimal64 (org.hipparchus.util.Decimal64)41 Test (org.junit.Test)37 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)21 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)18 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)12 FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)10 AbsoluteDate (org.orekit.time.AbsoluteDate)9 RandomGenerator (org.hipparchus.random.RandomGenerator)5 Well19937a (org.hipparchus.random.Well19937a)5 GeodeticPoint (org.orekit.bodies.GeodeticPoint)4 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)4 Frame (org.orekit.frames.Frame)4 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)3 TimeScale (org.orekit.time.TimeScale)3 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)3 PVCoordinates (org.orekit.utils.PVCoordinates)3 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)3 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)2 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)2 CelestialBody (org.orekit.bodies.CelestialBody)2