Search in sources :

Example 31 with FieldSpacecraftState

use of org.orekit.propagation.FieldSpacecraftState in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method createPropagator.

private <T extends RealFieldElement<T>> FieldNumericalPropagator<T> createPropagator(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(7.0e6), zero.add(1.0e6), zero.add(4.0e6));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-500.0), zero.add(8000.0), zero.add(1000.0));
    FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
    final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
    FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(orbit);
    OrbitType type = OrbitType.EQUINOCTIAL;
    double[][] tolerance = FieldNumericalPropagator.tolerances(zero.add(0.001), orbit, type);
    AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
    integrator.setInitialStepSize(zero.add(60));
    FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
    propagator.setOrbitType(type);
    propagator.setInitialState(initialState);
    return propagator;
}
Also used : DormandPrince853FieldIntegrator(org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldEquinoctialOrbit(org.orekit.orbits.FieldEquinoctialOrbit) OrbitType(org.orekit.orbits.OrbitType)

Example 32 with FieldSpacecraftState

use of org.orekit.propagation.FieldSpacecraftState in project Orekit by CS-SI.

the class FieldAbstractAnalyticalPropagator method basicPropagate.

/**
 * Propagate an orbit without any fancy features.
 * <p>This method is similar in spirit to the {@link #propagate} method,
 * except that it does <strong>not</strong> call any handler during
 * propagation, nor any discrete events, not additional states. It always
 * stop exactly at the specified date.</p>
 * @param date target date for propagation
 * @return state at specified date
 * @exception OrekitException if propagation cannot reach specified date
 */
protected FieldSpacecraftState<T> basicPropagate(final FieldAbsoluteDate<T> date) throws OrekitException {
    try {
        // evaluate orbit
        final FieldOrbit<T> orbit = propagateOrbit(date);
        // evaluate attitude
        final FieldAttitude<T> attitude = getAttitudeProvider().getAttitude(pvProvider, date, orbit.getFrame());
        // build raw state
        return new FieldSpacecraftState<>(orbit, attitude, getMass(date));
    } catch (OrekitException oe) {
        throw new OrekitException(oe);
    }
}
Also used : FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) OrekitException(org.orekit.errors.OrekitException)

Example 33 with FieldSpacecraftState

use of org.orekit.propagation.FieldSpacecraftState in project Orekit by CS-SI.

the class FieldKeplerianPropagator method fixState.

/**
 * Fix state to use a specified mu and remove derivatives.
 * <p>
 * This ensures the propagation model (which is based on calling
 * {@link Orbit#shiftedBy(double)}) is Keplerian only and uses a specified mu.
 * </p>
 * @param orbit orbit to fix
 * @param attitude current attitude
 * @param mass current mass
 * @param mu gravity coefficient to use
 * @return fixed orbit
 */
private FieldSpacecraftState<T> fixState(final FieldOrbit<T> orbit, final FieldAttitude<T> attitude, final T mass, final double mu) {
    final OrbitType type = orbit.getType();
    final T[] stateVector = MathArrays.buildArray(mass.getField(), 6);
    type.mapOrbitToArray(orbit, PositionAngle.TRUE, stateVector, null);
    final FieldOrbit<T> fixedOrbit = type.mapArrayToOrbit(stateVector, null, PositionAngle.TRUE, orbit.getDate(), mu, orbit.getFrame());
    return new FieldSpacecraftState<>(fixedOrbit, attitude, mass);
}
Also used : FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) OrbitType(org.orekit.orbits.OrbitType)

Example 34 with FieldSpacecraftState

use of org.orekit.propagation.FieldSpacecraftState in project Orekit by CS-SI.

the class TargetPointingTest method checkField.

private <T extends RealFieldElement<T>> void checkField(final Field<T> field, final GroundPointing provider, final Orbit orbit, final AbsoluteDate date, final Frame frame) throws OrekitException {
    final Attitude attitudeD = provider.getAttitude(orbit, date, frame);
    final FieldOrbit<T> orbitF = new FieldSpacecraftState<>(field, new SpacecraftState(orbit)).getOrbit();
    final FieldAbsoluteDate<T> dateF = new FieldAbsoluteDate<>(field, date);
    final FieldAttitude<T> attitudeF = provider.getAttitude(orbitF, dateF, frame);
    Assert.assertEquals(0.0, Rotation.distance(attitudeD.getRotation(), attitudeF.getRotation().toRotation()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(attitudeD.getSpin(), attitudeF.getSpin().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(attitudeD.getRotationAcceleration(), attitudeF.getRotationAcceleration().toVector3D()), 1.0e-15);
    final TimeStampedPVCoordinates pvD = provider.getTargetPV(orbit, date, frame);
    final TimeStampedFieldPVCoordinates<T> pvF = provider.getTargetPV(orbitF, dateF, frame);
    Assert.assertEquals(0.0, Vector3D.distance(pvD.getPosition(), pvF.getPosition().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(pvD.getVelocity(), pvF.getVelocity().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(pvD.getAcceleration(), pvF.getAcceleration().toVector3D()), 1.0e-15);
}
Also used : FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 35 with FieldSpacecraftState

use of org.orekit.propagation.FieldSpacecraftState in project Orekit by CS-SI.

the class AttitudesSequenceTest method doTestDayNightSwitchField.

private <T extends RealFieldElement<T>> void doTestDayNightSwitchField(final Field<T> field) throws OrekitException {
    // Initial state definition : date, orbit
    final FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
    final FieldVector3D<T> position = new FieldVector3D<>(field, new Vector3D(-6142438.668, 3492467.560, -25767.25680));
    final FieldVector3D<T> velocity = new FieldVector3D<>(field, new Vector3D(505.8479685, 942.7809215, 7435.922231));
    final FieldOrbit<T> initialOrbit = new FieldKeplerianOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
    // Attitudes sequence definition
    EventsLogger logger = new EventsLogger();
    final AttitudesSequence attitudesSequence = new AttitudesSequence();
    final AttitudeProvider dayObservationLaw = new LofOffset(initialOrbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(20), FastMath.toRadians(40), 0);
    final AttitudeProvider nightRestingLaw = new LofOffset(initialOrbit.getFrame(), LOFType.VVLH);
    final PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
    final PVCoordinatesProvider earth = CelestialBodyFactory.getEarth();
    final EclipseDetector ed = new EclipseDetector(sun, 696000000., earth, Constants.WGS84_EARTH_EQUATORIAL_RADIUS).withHandler(new ContinueOnEvent<EclipseDetector>() {

        private static final long serialVersionUID = 1L;

        int count = 0;

        public EventHandler.Action eventOccurred(final SpacecraftState s, final EclipseDetector d, final boolean increasing) {
            setInEclipse(s.getDate(), !increasing);
            if (count++ == 7) {
                return Action.STOP;
            } else {
                switch(count % 3) {
                    case 0:
                        return Action.CONTINUE;
                    case 1:
                        return Action.RESET_DERIVATIVES;
                    default:
                        return Action.RESET_STATE;
                }
            }
        }
    });
    final EventDetector monitored = logger.monitorDetector(ed);
    final Handler dayToNightHandler = new Handler(dayObservationLaw, nightRestingLaw);
    final Handler nightToDayHandler = new Handler(nightRestingLaw, dayObservationLaw);
    attitudesSequence.addSwitchingCondition(dayObservationLaw, nightRestingLaw, monitored, false, true, 300.0, AngularDerivativesFilter.USE_RRA, dayToNightHandler);
    attitudesSequence.addSwitchingCondition(nightRestingLaw, dayObservationLaw, monitored, true, false, 300.0, AngularDerivativesFilter.USE_RRA, nightToDayHandler);
    FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(initialOrbit);
    initialState = initialState.addAdditionalState("fortyTwo", field.getZero().add(42.0));
    if (ed.g(initialState.toSpacecraftState()) >= 0) {
        // initial position is in daytime
        setInEclipse(initialDate.toAbsoluteDate(), false);
        attitudesSequence.resetActiveProvider(dayObservationLaw);
    } else {
        // initial position is in nighttime
        setInEclipse(initialDate.toAbsoluteDate(), true);
        attitudesSequence.resetActiveProvider(nightRestingLaw);
    }
    // Propagator : consider the analytical Eckstein-Hechler model
    final FieldPropagator<T> propagator = new FieldEcksteinHechlerPropagator<T>(initialOrbit, attitudesSequence, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
    // Register the switching events to the propagator
    attitudesSequence.registerSwitchEvents(field, propagator);
    propagator.setMasterMode(field.getZero().add(60.0), new FieldOrekitFixedStepHandler<T>() {

        public void handleStep(FieldSpacecraftState<T> currentState, boolean isLast) throws OrekitException {
            // the Earth position in spacecraft frame should be along spacecraft Z axis
            // during night time and away from it during day time due to roll and pitch offsets
            final FieldVector3D<T> earth = currentState.toTransform().transformPosition(Vector3D.ZERO);
            final T pointingOffset = FieldVector3D.angle(earth, Vector3D.PLUS_K);
            // the g function is the eclipse indicator, its an angle between Sun and Earth limb,
            // positive when Sun is outside of Earth limb, negative when Sun is hidden by Earth limb
            final double eclipseAngle = ed.g(currentState.toSpacecraftState());
            if (currentState.getDate().durationFrom(lastChange).getReal() > 300) {
                if (inEclipse) {
                    Assert.assertTrue(eclipseAngle <= 0);
                    Assert.assertEquals(0.0, pointingOffset.getReal(), 1.0e-6);
                } else {
                    Assert.assertTrue(eclipseAngle >= 0);
                    Assert.assertEquals(0.767215, pointingOffset.getReal(), 1.0e-6);
                }
            } else {
                // we are in transition
                Assert.assertTrue(pointingOffset.getReal() + " " + (0.767215 - pointingOffset.getReal()), pointingOffset.getReal() <= 0.7672155);
            }
        }
    });
    // Propagate from the initial date for the fixed duration
    propagator.propagate(initialDate.shiftedBy(12600.));
    // as we have 2 switch events (even if they share the same underlying event detector),
    // and these events are triggered at both eclipse entry and exit, we get 8
    // raw events on 2 orbits
    Assert.assertEquals(8, logger.getLoggedEvents().size());
    // we have 4 attitudes switch on 2 orbits, 2 of each type
    Assert.assertEquals(2, dayToNightHandler.dates.size());
    Assert.assertEquals(2, nightToDayHandler.dates.size());
}
Also used : FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) EclipseDetector(org.orekit.propagation.events.EclipseDetector) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldOrekitFixedStepHandler(org.orekit.propagation.sampling.FieldOrekitFixedStepHandler) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) EventHandler(org.orekit.propagation.events.handlers.EventHandler) GeodeticPoint(org.orekit.bodies.GeodeticPoint) EventDetector(org.orekit.propagation.events.EventDetector) EventsLogger(org.orekit.propagation.events.EventsLogger) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)36 SpacecraftState (org.orekit.propagation.SpacecraftState)24 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)24 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)20 DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)20 OrbitType (org.orekit.orbits.OrbitType)20 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)17 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)17 Frame (org.orekit.frames.Frame)16 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)16 Test (org.junit.Test)15 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)15 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)15 PVCoordinates (org.orekit.utils.PVCoordinates)15 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)14 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)12 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)12 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)11 GaussianRandomGenerator (org.hipparchus.random.GaussianRandomGenerator)8 RandomGenerator (org.hipparchus.random.RandomGenerator)8