Search in sources :

Example 86 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class CircularOrbitTest method testNonKeplerianDerivatives.

@Test
public void testNonKeplerianDerivatives() throws OrekitException {
    final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(6896874.444705, 1956581.072644, -147476.245054);
    final Vector3D velocity = new Vector3D(166.816407662, -1106.783301861, -7372.745712770);
    final Vector3D acceleration = new Vector3D(-7.466182457944, -2.118153357345, 0.160004048437);
    final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
    final Frame frame = FramesFactory.getEME2000();
    final double mu = Constants.EIGEN5C_EARTH_MU;
    final CircularOrbit orbit = new CircularOrbit(pv, frame, mu);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot(), 4.3e-8);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot(), 2.1e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot(), 5.4e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot(), 1.6e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot(), 7.3e-17);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot(), 3.4e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot(), 3.5e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot(), 5.3e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot(), 6.8e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot(), 5.7e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getCircularEx()), orbit.getCircularExDot(), 2.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getCircularEy()), orbit.getCircularEyDot(), 5.3e-17);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaV()), orbit.getAlphaVDot(), 4.3e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaE()), orbit.getAlphaEDot(), 1.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaM()), orbit.getAlphaMDot(), 3.7e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.TRUE)), orbit.getAlphaDot(PositionAngle.TRUE), 4.3e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.ECCENTRIC)), orbit.getAlphaDot(PositionAngle.ECCENTRIC), 1.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.MEAN)), orbit.getAlphaDot(PositionAngle.MEAN), 3.7e-15);
}
Also used : TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Frame(org.orekit.frames.Frame) ObjectInputStream(java.io.ObjectInputStream) RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) Function(java.util.function.Function) PVCoordinates(org.orekit.utils.PVCoordinates) ArrayList(java.util.ArrayList) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) After(org.junit.After) ObjectOutputStream(java.io.ObjectOutputStream) FastMath(org.hipparchus.util.FastMath) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Utils(org.orekit.Utils) Before(org.junit.Before) Constants(org.orekit.utils.Constants) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) OrekitMatchers.relativelyCloseTo(org.orekit.OrekitMatchers.relativelyCloseTo) FramesFactory(org.orekit.frames.FramesFactory) IOException(java.io.IOException) Test(org.junit.Test) OrekitIllegalArgumentException(org.orekit.errors.OrekitIllegalArgumentException) MathUtils(org.hipparchus.util.MathUtils) OrekitMessages(org.orekit.errors.OrekitMessages) List(java.util.List) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) OrekitException(org.orekit.errors.OrekitException) TimeScalesFactory(org.orekit.time.TimeScalesFactory) MatrixUtils(org.hipparchus.linear.MatrixUtils) Transform(org.orekit.frames.Transform) Assert(org.junit.Assert) AbsoluteDate(org.orekit.time.AbsoluteDate) Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 87 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class FieldCircularOrbitTest method doTestNonKeplerianDerivatives.

private <T extends RealFieldElement<T>> void doTestNonKeplerianDerivatives(Field<T> field) throws OrekitException {
    final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, "2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
    final FieldVector3D<T> position = new FieldVector3D<>(field.getZero().add(6896874.444705), field.getZero().add(1956581.072644), field.getZero().add(-147476.245054));
    final FieldVector3D<T> velocity = new FieldVector3D<>(field.getZero().add(166.816407662), field.getZero().add(-1106.783301861), field.getZero().add(-7372.745712770));
    final FieldVector3D<T> acceleration = new FieldVector3D<>(field.getZero().add(-7.466182457944), field.getZero().add(-2.118153357345), field.getZero().add(0.160004048437));
    final TimeStampedFieldPVCoordinates<T> pv = new TimeStampedFieldPVCoordinates<>(date, position, velocity, acceleration);
    final Frame frame = FramesFactory.getEME2000();
    final double mu = Constants.EIGEN5C_EARTH_MU;
    final FieldCircularOrbit<T> orbit = new FieldCircularOrbit<>(pv, frame, mu);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot().getReal(), 4.3e-8);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot().getReal(), 2.1e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot().getReal(), 5.4e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot().getReal(), 1.6e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot().getReal(), 7.3e-17);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot().getReal(), 3.4e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot().getReal(), 3.5e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot().getReal(), 5.3e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot().getReal(), 6.8e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot().getReal(), 5.7e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getCircularEx()), orbit.getCircularExDot().getReal(), 2.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getCircularEy()), orbit.getCircularEyDot().getReal(), 5.3e-17);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaV()), orbit.getAlphaVDot().getReal(), 4.3e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaE()), orbit.getAlphaEDot().getReal(), 1.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaM()), orbit.getAlphaMDot().getReal(), 3.7e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.TRUE)), orbit.getAlphaDot(PositionAngle.TRUE).getReal(), 4.3e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.ECCENTRIC)), orbit.getAlphaDot(PositionAngle.ECCENTRIC).getReal(), 1.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.MEAN)), orbit.getAlphaDot(PositionAngle.MEAN).getReal(), 3.7e-15);
}
Also used : Frame(org.orekit.frames.Frame) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) Function(java.util.function.Function) FieldMatrixPreservingVisitor(org.hipparchus.linear.FieldMatrixPreservingVisitor) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) ArrayList(java.util.ArrayList) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) MathArrays(org.hipparchus.util.MathArrays) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FastMath(org.hipparchus.util.FastMath) Utils(org.orekit.Utils) Before(org.junit.Before) Constants(org.orekit.utils.Constants) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) OrekitMatchers.relativelyCloseTo(org.orekit.OrekitMatchers.relativelyCloseTo) FramesFactory(org.orekit.frames.FramesFactory) Test(org.junit.Test) OrekitIllegalArgumentException(org.orekit.errors.OrekitIllegalArgumentException) Field(org.hipparchus.Field) MathUtils(org.hipparchus.util.MathUtils) OrekitMessages(org.orekit.errors.OrekitMessages) List(java.util.List) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) OrekitException(org.orekit.errors.OrekitException) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) RealFieldElement(org.hipparchus.RealFieldElement) TimeScalesFactory(org.orekit.time.TimeScalesFactory) MatrixUtils(org.hipparchus.linear.MatrixUtils) Decimal64Field(org.hipparchus.util.Decimal64Field) Transform(org.orekit.frames.Transform) Assert(org.junit.Assert) Frame(org.orekit.frames.Frame) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates)

Example 88 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class SHMFormatReaderTest method testReadLimits.

@Test
public void testReadLimits() throws OrekitException {
    Utils.setDataRoot("potential");
    GravityFieldFactory.addPotentialCoefficientsReader(new SHMFormatReader("eigen_cg03c_coef", false));
    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 89 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class SolarRadiationPressureTest method testParameterDerivativeIsotropicSingle.

@Test
public void testParameterDerivativeIsotropicSingle() throws OrekitException {
    final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06, -1.32931592294715829e+04);
    final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03, -1.14097953925384523e+01);
    final SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel), FramesFactory.getGCRF(), new AbsoluteDate(2003, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()), Constants.EIGEN5C_EARTH_MU));
    RadiationSensitive rs = new IsotropicRadiationSingleCoefficient(2.5, 0.7);
    SolarRadiationPressure forceModel = new SolarRadiationPressure(CelestialBodyFactory.getSun(), Constants.WGS84_EARTH_EQUATORIAL_RADIUS, rs);
    checkParameterDerivative(state, forceModel, RadiationSensitive.REFLECTION_COEFFICIENT, 1.0, 2.0e-15);
    try {
        rs.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), Vector3D.ZERO, new double[2], RadiationSensitive.ABSORPTION_COEFFICIENT);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, oe.getSpecifier());
    }
    for (ParameterDriver driver : rs.getRadiationParametersDrivers()) {
        Assert.assertEquals(RadiationSensitive.REFLECTION_COEFFICIENT, driver.getName());
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) OrekitException(org.orekit.errors.OrekitException) ParameterDriver(org.orekit.utils.ParameterDriver) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 90 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class TIRFProviderTest method testConcurrentGetTransform.

/**
 * Checks that {@link TIRFProvider#getTransform(AbsoluteDate)} is thread safe.
 */
@Test
public void testConcurrentGetTransform() throws OrekitException, InterruptedException, ExecutionException {
    // subject under test
    final TIRFProvider tirf = new TIRFProvider(FramesFactory.getEOPHistory(IERSConventions.IERS_2010, false));
    // arbitrary date
    final AbsoluteDate start = new AbsoluteDate("2009-09-19T23:59:45.000", TimeScalesFactory.getUTC());
    // in seconds = 15min
    final double timeStep = 300;
    // the number of possible concurrent threads
    final int nJobs = 24;
    // the number of calculations per thread
    final int nPerJob = 1000;
    // tolerance of comparisons
    final double absTol = Precision.EPSILON;
    // the expected result
    final List<Transform> expecteds = new ArrayList<Transform>();
    for (int j = 0; j < nPerJob; j++) {
        final AbsoluteDate date = start.shiftedBy(timeStep * j);
        // action
        final Transform expected = tirf.getTransform(date);
        // verify
        expecteds.add(expected);
    }
    // build jobs for concurrent execution
    final List<Callable<Boolean>> jobs = new ArrayList<Callable<Boolean>>();
    for (int i = 0; i < nJobs; i++) {
        jobs.add(new Callable<Boolean>() {

            public Boolean call() throws Exception {
                for (int j = 0; j < nPerJob; j++) {
                    final AbsoluteDate date = start.shiftedBy(timeStep * j);
                    // action
                    final Transform actual = tirf.getTransform(date);
                    // verify
                    assertTransformEquals(expecteds.get(j), actual, absTol);
                }
                return true;
            }
        });
    }
    // run the jobs
    runConcurrentlyAndCheck(jobs, nJobs);
}
Also used : ArrayList(java.util.ArrayList) AbsoluteDate(org.orekit.time.AbsoluteDate) Callable(java.util.concurrent.Callable) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Aggregations

OrekitException (org.orekit.errors.OrekitException)332 AbsoluteDate (org.orekit.time.AbsoluteDate)150 Test (org.junit.Test)135 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)91 SpacecraftState (org.orekit.propagation.SpacecraftState)75 Frame (org.orekit.frames.Frame)62 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)59 ArrayList (java.util.ArrayList)48 Before (org.junit.Before)48 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)42 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)42 DateComponents (org.orekit.time.DateComponents)42 GeodeticPoint (org.orekit.bodies.GeodeticPoint)41 Orbit (org.orekit.orbits.Orbit)40 PVCoordinates (org.orekit.utils.PVCoordinates)37 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)36 IOException (java.io.IOException)32 InputStream (java.io.InputStream)31 Propagator (org.orekit.propagation.Propagator)30 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)28