Search in sources :

Example 1 with Decimal64

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

the class NRLMSISE00Test method doTestVoidMethod.

private void doTestVoidMethod(NRLMSISE00 atm, RandomGenerator random, String methodName, double temperatureRelativeTolerance, double densityRelativeTolerance) throws OrekitException {
    try {
        // Common data for all cases
        final int doy = 172;
        final double sec = 29000.;
        final double lat = 60.;
        final double lon = -70.;
        final double hl = 16.;
        final double f107a = 149.;
        final double f107 = 150.;
        double[] ap = { 4., 100., 100., 100., 100., 100., 100. };
        Method methodD = getOutputClass().getDeclaredMethod(methodName, Double.TYPE);
        methodD.setAccessible(true);
        Method methodF = getFieldOutputClass().getDeclaredMethod(methodName, RealFieldElement.class);
        methodF.setAccessible(true);
        Object output = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
        Object fieldOutput = createFieldOutput(Decimal64Field.getInstance(), atm, doy, sec, lat, lon, hl, f107a, f107, ap);
        double maxTemperatureError = 0;
        double maxDensityError = 0;
        for (int i = 0; i < 100; ++i) {
            double alt = 500.0 * random.nextDouble();
            methodD.invoke(output, alt);
            methodF.invoke(fieldOutput, new Decimal64(alt));
            for (int index = 0; index < 2; ++index) {
                double tD = getOutputTemperature(output, index);
                double tF = getFieldOutputTemperature(fieldOutput, index);
                maxTemperatureError = FastMath.max(maxTemperatureError, FastMath.abs((tD - tF) / tF));
            }
            for (int index = 0; index < 9; ++index) {
                double dD = getOutputDensity(output, index);
                double dF = getFieldOutputDensity(fieldOutput, index);
                if (Double.isNaN(dD)) {
                    // when switches are off, some altitudes generate NaNs
                    // for example when switch 15 is 0, DM28 is not set and remains equals to 0
                    // so a division later on generate NaNs
                    Assert.assertTrue(Double.isNaN(dF));
                } else if (dD == 0) {
                    // some densities are forced to zero depending on altitude
                    Assert.assertEquals(dD, dF, Precision.SAFE_MIN);
                } else {
                    maxDensityError = FastMath.max(maxDensityError, FastMath.abs((dD - dF) / dD));
                }
            }
        }
        Assert.assertEquals(0.0, maxTemperatureError, temperatureRelativeTolerance);
        Assert.assertEquals(0.0, maxDensityError, densityRelativeTolerance);
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        Assert.fail(e.getLocalizedMessage());
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) Method(java.lang.reflect.Method) GeodeticPoint(org.orekit.bodies.GeodeticPoint) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with Decimal64

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

the class BoxAndSolarArraySpacecraftTest method testNormalSunAlignedField.

@Test
public void testNormalSunAlignedField() throws OrekitException {
    BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(0, 1e6, 0), Vector3D.ZERO), 20.0, Vector3D.PLUS_J, 0.0, 1.0, 0.0);
    Field<Decimal64> field = Decimal64Field.getInstance();
    FieldVector3D<Decimal64> normal = s.getNormal(FieldAbsoluteDate.getJ2000Epoch(field), FramesFactory.getEME2000(), FieldVector3D.getZero(field), FieldRotation.getIdentity(field));
    Assert.assertEquals(0, FieldVector3D.dotProduct(normal, Vector3D.PLUS_J).getReal(), 1.0e-16);
}
Also used : FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Decimal64(org.hipparchus.util.Decimal64) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) Test(org.junit.Test)

Example 3 with Decimal64

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

the class BoxAndSolarArraySpacecraftTest method testNormalOptimalRotationField.

@Test
public void testNormalOptimalRotationField() throws OrekitException {
    AbsoluteDate initialDate = propagator.getInitialState().getDate();
    CelestialBody sun = CelestialBodyFactory.getSun();
    BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, 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 4 with Decimal64

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

the class FieldAngularCoordinatesTest method testConversionConstructor.

@Test
public void testConversionConstructor() {
    AngularCoordinates ac = new AngularCoordinates(new Rotation(Vector3D.MINUS_J, 0.15, RotationConvention.VECTOR_OPERATOR), new Vector3D(0.001, 0.002, 0.003), new Vector3D(-1.0e-6, -3.0e-6, 7.0e-6));
    FieldAngularCoordinates<Decimal64> ac64 = new FieldAngularCoordinates<>(Decimal64Field.getInstance(), ac);
    Assert.assertEquals(0.0, Rotation.distance(ac.getRotation(), ac64.getRotation().toRotation()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(ac.getRotationRate(), ac64.getRotationRate().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(ac.getRotationAcceleration(), ac64.getRotationAcceleration().toVector3D()), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Decimal64(org.hipparchus.util.Decimal64) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Test(org.junit.Test)

Example 5 with Decimal64

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

the class FieldAngularCoordinatesTest method testResultAngularCoordinates.

@Test
public void testResultAngularCoordinates() throws OrekitException {
    Field<Decimal64> field = Decimal64Field.getInstance();
    Decimal64 zero = field.getZero();
    FieldVector3D<Decimal64> pos_B = new FieldVector3D<>(zero.add(-0.23723922134606962), zero.add(-0.9628700341496187), zero.add(0.1288365211879871));
    FieldVector3D<Decimal64> vel_B = new FieldVector3D<>(zero.add(2.6031808214929053E-7), zero.add(-8.141147978260352E-8), zero.add(-1.2908618653852553E-7));
    FieldVector3D<Decimal64> acc_B = new FieldVector3D<>(zero.add(-1.395403347295246E-10), zero.add(-2.7451871050415643E-12), zero.add(-2.781723303703499E-10));
    FieldPVCoordinates<Decimal64> B = new FieldPVCoordinates<Decimal64>(pos_B, vel_B, acc_B);
    FieldVector3D<Decimal64> pos_A = new FieldVector3D<>(zero.add(-0.44665912825286425), zero.add(-0.00965737694923173), zero.add(-0.894652087807798));
    FieldVector3D<Decimal64> vel_A = new FieldVector3D<>(zero.add(-8.897373390367405E-4), zero.add(2.7825509772757976E-4), zero.add(4.412017757970883E-4));
    FieldVector3D<Decimal64> acc_A = new FieldVector3D<>(zero.add(4.743595125825107E-7), zero.add(1.01875177357042E-8), zero.add(9.520371766790574E-7));
    FieldPVCoordinates<Decimal64> A = new FieldPVCoordinates<>(pos_A, vel_A, acc_A);
    FieldPVCoordinates<Decimal64> PLUS_K = new FieldPVCoordinates<>(new FieldVector3D<>(field.getZero(), field.getZero(), field.getOne()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()));
    FieldPVCoordinates<Decimal64> PLUS_J = new FieldPVCoordinates<>(new FieldVector3D<>(field.getZero(), field.getOne(), field.getZero()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()));
    FieldAngularCoordinates<Decimal64> fac = new FieldAngularCoordinates<>(A, B, PLUS_K, PLUS_J, 1.0e-6);
    AngularCoordinates ac = new AngularCoordinates(A.toPVCoordinates(), B.toPVCoordinates(), PLUS_K.toPVCoordinates(), PLUS_J.toPVCoordinates(), 1.0e-6);
    Assert.assertTrue(fac.getRotationRate().toVector3D().equals(ac.getRotationRate()));
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) 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