Search in sources :

Example 21 with PVCoordinatesProvider

use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.

the class SolarRadiationPressureTest method testLighting.

@Test
public void testLighting() throws OrekitException, ParseException {
    // Initialization
    AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 3, 21), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC());
    Orbit orbit = new EquinoctialOrbit(42164000, 10e-3, 10e-3, FastMath.tan(0.001745329) * FastMath.cos(2 * FastMath.PI / 3), FastMath.tan(0.001745329) * FastMath.sin(2 * FastMath.PI / 3), 0.1, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
    OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.46, 1.0 / 298.25765, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    SolarRadiationPressure SRP = new SolarRadiationPressure(sun, earth.getEquatorialRadius(), (RadiationSensitive) new IsotropicRadiationCNES95Convention(50.0, 0.5, 0.5));
    double period = 2 * FastMath.PI * FastMath.sqrt(orbit.getA() * orbit.getA() * orbit.getA() / orbit.getMu());
    Assert.assertEquals(86164, period, 1);
    // creation of the propagator
    KeplerianPropagator k = new KeplerianPropagator(orbit);
    // intermediate variables
    AbsoluteDate currentDate;
    double changed = 1;
    int count = 0;
    for (int t = 1; t < 3 * period; t += 1000) {
        currentDate = date.shiftedBy(t);
        try {
            double ratio = SRP.getLightingRatio(k.propagate(currentDate).getPVCoordinates().getPosition(), FramesFactory.getEME2000(), currentDate);
            if (FastMath.floor(ratio) != changed) {
                changed = FastMath.floor(ratio);
                if (changed == 0) {
                    count++;
                }
            }
        } catch (OrekitException e) {
            e.printStackTrace();
        }
    }
    Assert.assertTrue(3 == count);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 22 with PVCoordinatesProvider

use of org.orekit.utils.PVCoordinatesProvider 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 PVCoordinatesProvider

use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.

the class NRLMSISE00Test method testDensityGradient.

@Test
public void testDensityGradient() 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);
    // Run
    DerivativeStructure zero = new DSFactory(1, 1).variable(0, 0.0);
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(5, 10.0);
    DerivativeStructure rhoX = differentiator.differentiate((double x) -> {
        try {
            return atm.getDensity(date, new Vector3D(1, pos, x, Vector3D.PLUS_I), itrf);
        } catch (OrekitException oe) {
            return Double.NaN;
        }
    }).value(zero);
    DerivativeStructure rhoY = differentiator.differentiate((double y) -> {
        try {
            return atm.getDensity(date, new Vector3D(1, pos, y, Vector3D.PLUS_J), itrf);
        } catch (OrekitException oe) {
            return Double.NaN;
        }
    }).value(zero);
    DerivativeStructure rhoZ = differentiator.differentiate((double z) -> {
        try {
            return atm.getDensity(date, new Vector3D(1, pos, z, Vector3D.PLUS_K), itrf);
        } catch (OrekitException oe) {
            return Double.NaN;
        }
    }).value(zero);
    DSFactory factory3 = new DSFactory(3, 1);
    Field<DerivativeStructure> field = factory3.getDerivativeField();
    final DerivativeStructure rhoDS = atm.getDensity(new FieldAbsoluteDate<>(field, date), new FieldVector3D<>(factory3.variable(0, pos.getX()), factory3.variable(1, pos.getY()), factory3.variable(2, pos.getZ())), itrf);
    Assert.assertEquals(rhoX.getValue(), rhoDS.getReal(), rhoX.getValue() * 2.0e-13);
    Assert.assertEquals(rhoY.getValue(), rhoDS.getReal(), rhoY.getValue() * 2.0e-13);
    Assert.assertEquals(rhoZ.getValue(), rhoDS.getReal(), rhoZ.getValue() * 2.0e-13);
    Assert.assertEquals(rhoX.getPartialDerivative(1), rhoDS.getPartialDerivative(1, 0, 0), FastMath.abs(2.0e-10 * rhoX.getPartialDerivative(1)));
    Assert.assertEquals(rhoY.getPartialDerivative(1), rhoDS.getPartialDerivative(0, 1, 0), FastMath.abs(2.0e-10 * rhoY.getPartialDerivative(1)));
    Assert.assertEquals(rhoZ.getPartialDerivative(1), rhoDS.getPartialDerivative(0, 0, 1), FastMath.abs(2.0e-10 * rhoY.getPartialDerivative(1)));
}
Also used : Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) 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) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) Test(org.junit.Test)

Example 24 with PVCoordinatesProvider

use of org.orekit.utils.PVCoordinatesProvider 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)

Example 25 with PVCoordinatesProvider

use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.

the class KeplerianPropagatorTest method tesWrapedAttitudeException.

@Test(expected = OrekitException.class)
public void tesWrapedAttitudeException() throws OrekitException {
    final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    KeplerianPropagator propagator = new KeplerianPropagator(orbit, new AttitudeProvider() {

        private static final long serialVersionUID = 1L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }

        public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }
    });
    propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAttitude(org.orekit.attitudes.FieldAttitude) Attitude(org.orekit.attitudes.Attitude) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldAttitude(org.orekit.attitudes.FieldAttitude) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Aggregations

PVCoordinatesProvider (org.orekit.utils.PVCoordinatesProvider)35 Test (org.junit.Test)28 Frame (org.orekit.frames.Frame)22 AbsoluteDate (org.orekit.time.AbsoluteDate)20 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)19 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)16 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)14 OrekitException (org.orekit.errors.OrekitException)13 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)12 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)11 SpacecraftState (org.orekit.propagation.SpacecraftState)11 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)8 Orbit (org.orekit.orbits.Orbit)8 DateComponents (org.orekit.time.DateComponents)8 TimeComponents (org.orekit.time.TimeComponents)8 AttitudeProvider (org.orekit.attitudes.AttitudeProvider)7 DummyLocalizable (org.hipparchus.exception.DummyLocalizable)6 GeodeticPoint (org.orekit.bodies.GeodeticPoint)6 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)6 TopocentricFrame (org.orekit.frames.TopocentricFrame)6