Search in sources :

Example 1 with RandomGenerator

use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.

the class DragForceTest method RealFieldTest.

/**
 *Testing if the propagation between the FieldPropagation and the propagation
 * is equivalent.
 * Also testing if propagating X+dX with the propagation is equivalent to
 * propagation X with the FieldPropagation and then applying the taylor
 * expansion of dX to the result.
 */
@Test
public void RealFieldTest() throws OrekitException {
    DSFactory factory = new DSFactory(6, 4);
    DerivativeStructure a_0 = factory.variable(0, 7e6);
    DerivativeStructure e_0 = factory.variable(1, 0.01);
    DerivativeStructure i_0 = factory.variable(2, 1.2);
    DerivativeStructure R_0 = factory.variable(3, 0.7);
    DerivativeStructure O_0 = factory.variable(4, 0.5);
    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();
    ClassicalRungeKuttaFieldIntegrator<DerivativeStructure> integrator = new ClassicalRungeKuttaFieldIntegrator<>(field, zero.add(6));
    ClassicalRungeKuttaIntegrator RIntegrator = new ClassicalRungeKuttaIntegrator(6);
    OrbitType type = OrbitType.EQUINOCTIAL;
    FieldNumericalPropagator<DerivativeStructure> FNP = new FieldNumericalPropagator<>(field, integrator);
    FNP.setOrbitType(type);
    FNP.setInitialState(initialState);
    NumericalPropagator NP = new NumericalPropagator(RIntegrator);
    NP.setOrbitType(type);
    NP.setInitialState(iSR);
    final DragForce forceModel = new DragForce(new HarrisPriester(CelestialBodyFactory.getSun(), new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true))), new BoxAndSolarArraySpacecraft(1.5, 2.0, 1.8, CelestialBodyFactory.getSun(), 20.0, Vector3D.PLUS_J, 1.2, 0.7, 0.2));
    FNP.addForceModel(forceModel);
    NP.addForceModel(forceModel);
    FieldAbsoluteDate<DerivativeStructure> target = J2000.shiftedBy(1000.);
    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.assertEquals(finPVC_DS.toPVCoordinates().getPosition().getX(), finPVC_R.getPosition().getX(), FastMath.abs(finPVC_R.getPosition().getX()) * 1e-11);
    Assert.assertEquals(finPVC_DS.toPVCoordinates().getPosition().getY(), finPVC_R.getPosition().getY(), FastMath.abs(finPVC_R.getPosition().getY()) * 1e-11);
    Assert.assertEquals(finPVC_DS.toPVCoordinates().getPosition().getZ(), finPVC_R.getPosition().getZ(), FastMath.abs(finPVC_R.getPosition().getZ()) * 1e-11);
    long number = 23091991;
    RandomGenerator RG = new Well19937a(number);
    GaussianRandomGenerator NGG = new GaussianRandomGenerator(RG);
    UncorrelatedRandomVectorGenerator URVG = new UncorrelatedRandomVectorGenerator(new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, new double[] { 1e3, 0.005, 0.005, 0.01, 0.01, 0.01 }, NGG);
    double a_R = a_0.getReal();
    double e_R = e_0.getReal();
    double i_R = i_0.getReal();
    double R_R = R_0.getReal();
    double O_R = O_0.getReal();
    double n_R = n_0.getReal();
    for (int ii = 0; ii < 1; ii++) {
        double[] rand_next = URVG.nextVector();
        double a_shift = a_R + rand_next[0];
        double e_shift = e_R + rand_next[1];
        double i_shift = i_R + rand_next[2];
        double R_shift = R_R + rand_next[3];
        double O_shift = O_R + rand_next[4];
        double n_shift = n_R + rand_next[5];
        KeplerianOrbit shiftedOrb = new KeplerianOrbit(a_shift, e_shift, i_shift, R_shift, O_shift, n_shift, PositionAngle.MEAN, EME, J2000.toAbsoluteDate(), Constants.EIGEN5C_EARTH_MU);
        SpacecraftState shift_iSR = new SpacecraftState(shiftedOrb);
        NumericalPropagator shift_NP = new NumericalPropagator(RIntegrator);
        shift_NP.setInitialState(shift_iSR);
        shift_NP.addForceModel(forceModel);
        SpacecraftState finalState_shift = shift_NP.propagate(target.toAbsoluteDate());
        PVCoordinates finPVC_shift = finalState_shift.getPVCoordinates();
        // position check
        FieldVector3D<DerivativeStructure> pos_DS = finPVC_DS.getPosition();
        double x_DS = pos_DS.getX().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double y_DS = pos_DS.getY().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double z_DS = pos_DS.getZ().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        // System.out.println(pos_DS.getX().getPartialDerivative(1));
        double x = finPVC_shift.getPosition().getX();
        double y = finPVC_shift.getPosition().getY();
        double z = finPVC_shift.getPosition().getZ();
        Assert.assertEquals(x_DS, x, FastMath.abs(x - pos_DS.getX().getReal()) * 1e-5);
        Assert.assertEquals(y_DS, y, FastMath.abs(y - pos_DS.getY().getReal()) * 1e-5);
        Assert.assertEquals(z_DS, z, FastMath.abs(z - pos_DS.getZ().getReal()) * 1e-5);
        // velocity check
        FieldVector3D<DerivativeStructure> vel_DS = finPVC_DS.getVelocity();
        double vx_DS = vel_DS.getX().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double vy_DS = vel_DS.getY().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double vz_DS = vel_DS.getZ().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double vx = finPVC_shift.getVelocity().getX();
        double vy = finPVC_shift.getVelocity().getY();
        double vz = finPVC_shift.getVelocity().getZ();
        Assert.assertEquals(vx_DS, vx, FastMath.abs(vx) * 1e-7);
        Assert.assertEquals(vy_DS, vy, FastMath.abs(vy) * 1e-7);
        Assert.assertEquals(vz_DS, vz, FastMath.abs(vz) * 1e-7);
        // acceleration check
        FieldVector3D<DerivativeStructure> acc_DS = finPVC_DS.getAcceleration();
        double ax_DS = acc_DS.getX().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double ay_DS = acc_DS.getY().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double az_DS = acc_DS.getZ().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
        double ax = finPVC_shift.getAcceleration().getX();
        double ay = finPVC_shift.getAcceleration().getY();
        double az = finPVC_shift.getAcceleration().getZ();
        Assert.assertEquals(ax_DS, ax, FastMath.abs(ax) * 1e-5);
        Assert.assertEquals(ay_DS, ay, FastMath.abs(ay) * 1e-5);
        Assert.assertEquals(az_DS, az, FastMath.abs(az) * 1e-5);
    }
}
Also used : Frame(org.orekit.frames.Frame) ClassicalRungeKuttaFieldIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaFieldIntegrator) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) GaussianRandomGenerator(org.hipparchus.random.GaussianRandomGenerator) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) Well19937a(org.hipparchus.random.Well19937a) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) RandomGenerator(org.hipparchus.random.RandomGenerator) GaussianRandomGenerator(org.hipparchus.random.GaussianRandomGenerator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) BoxAndSolarArraySpacecraft(org.orekit.forces.BoxAndSolarArraySpacecraft) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) HarrisPriester(org.orekit.forces.drag.atmosphere.HarrisPriester) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) OrbitType(org.orekit.orbits.OrbitType) UncorrelatedRandomVectorGenerator(org.hipparchus.random.UncorrelatedRandomVectorGenerator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 2 with RandomGenerator

use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.

the class NRLMSISE00Test method testgtd7SwitchesOn.

@Test
public void testgtd7SwitchesOn() throws OrekitException {
    RandomGenerator random = new Well19937a(0x3439206bdd4dff5dl);
    NRLMSISE00 atm = new NRLMSISE00(null, null, null);
    for (int i = 1; i <= 23; ++i) {
        atm = atm.withSwitch(i, 1);
    }
    doTestVoidMethod(atm, random, "gtd7", 5.0e-16, 3.0e-14);
}
Also used : Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 3 with RandomGenerator

use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.

the class NRLMSISE00Test method testgts7SwitchesOn.

@Test
public void testgts7SwitchesOn() throws OrekitException {
    RandomGenerator random = new Well19937a(0xb6dcf73ed5e5d985l);
    NRLMSISE00 atm = new NRLMSISE00(null, null, null);
    for (int i = 1; i <= 23; ++i) {
        atm = atm.withSwitch(i, 1);
    }
    doTestVoidMethod(atm, random, "gts7", 1.0e-50, 6.0e-14);
}
Also used : Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 4 with RandomGenerator

use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.

the class NRLMSISE00Test method testgtd7dSwitchesOn.

@Test
public void testgtd7dSwitchesOn() throws OrekitException {
    RandomGenerator random = new Well19937a(0x4bbb424422a1b909l);
    NRLMSISE00 atm = new NRLMSISE00(null, null, null);
    for (int i = 1; i <= 23; ++i) {
        atm = atm.withSwitch(i, 1);
    }
    doTestVoidMethod(atm, random, "gtd7d", 3.0e-16, 3.0e-14);
}
Also used : Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 5 with RandomGenerator

use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.

the class NRLMSISE00Test method testgtd7dSwitchesOff.

@Test
public void testgtd7dSwitchesOff() throws OrekitException {
    RandomGenerator random = new Well19937a(0x7f6da37655e30103l);
    NRLMSISE00 atm = new NRLMSISE00(null, null, null);
    for (int i = 1; i <= 23; ++i) {
        atm = atm.withSwitch(i, 0);
    }
    doTestVoidMethod(atm, random, "gtd7d", 1.0e-50, 2.0e-14);
}
Also used : Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Aggregations

RandomGenerator (org.hipparchus.random.RandomGenerator)100 Test (org.junit.Test)78 Well19937a (org.hipparchus.random.Well19937a)73 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)33 Well1024a (org.hipparchus.random.Well1024a)27 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)22 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)22 GeodeticPoint (org.orekit.bodies.GeodeticPoint)20 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)19 PVCoordinates (org.orekit.utils.PVCoordinates)15 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)15 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)14 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)14 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)14 Frame (org.orekit.frames.Frame)10 GaussianRandomGenerator (org.hipparchus.random.GaussianRandomGenerator)8 UncorrelatedRandomVectorGenerator (org.hipparchus.random.UncorrelatedRandomVectorGenerator)8 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)8 OrbitType (org.orekit.orbits.OrbitType)8 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)8