Search in sources :

Example 31 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class DragForce method acceleration.

/**
 * {@inheritDoc}
 */
@Override
public Vector3D acceleration(final SpacecraftState s, final double[] parameters) throws OrekitException {
    final AbsoluteDate date = s.getDate();
    final Frame frame = s.getFrame();
    final Vector3D position = s.getPVCoordinates().getPosition();
    final double rho = atmosphere.getDensity(date, position, frame);
    final Vector3D vAtm = atmosphere.getVelocity(date, position, frame);
    final Vector3D relativeVelocity = vAtm.subtract(s.getPVCoordinates().getVelocity());
    return spacecraft.dragAcceleration(date, frame, position, s.getAttitude().getRotation(), s.getMass(), rho, relativeVelocity, parameters);
}
Also used : Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate)

Example 32 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class DragForce method getDensityWrtStateUsingFiniteDifferences.

/**
 * Compute density and its derivatives.
 * Using finite differences for the derivatives.
 * And doing the actual computation only for the derivatives with respect to position (others are set to 0.).
 * <p>
 * From a theoretical point of view, this method computes the same values
 * as {@link Atmosphere#getDensity(FieldAbsoluteDate, FieldVector3D, Frame)} in the
 * specific case of {@link DerivativeStructure} with respect to state, so
 * it is less general. However, it is *much* faster in this important case.
 * <p>
 * <p>
 * The derivatives should be computed with respect to position. The input
 * parameters already take into account the free parameters (6, 7 or 8 depending
 * on derivation with respect to drag coefficient and lift ratio being considered or not)
 * and order (always 1). Free parameters at indices 0, 1 and 2 correspond to derivatives
 * with respect to position. Free parameters at indices 3, 4 and 5 correspond
 * to derivatives with respect to velocity (these derivatives will remain zero
 * as the atmospheric density does not depend on velocity). Free parameter
 * at indexes 6 and 7 (if present) corresponds to derivatives with respect to drag coefficient
 * and/or lift ratio (one of these or both).
 * This 2 last derivatives will remain zero as atmospheric density does not depend on them.
 * </p>
 * @param date current date
 * @param frame inertial reference frame for state (both orbit and attitude)
 * @param position position of spacecraft in inertial frame
 * @param <T> type of the elements
 * @return the density and its derivatives
 * @exception OrekitException if derivatives cannot be computed
 * @since 9.0
 */
private <T extends RealFieldElement<T>> T getDensityWrtStateUsingFiniteDifferences(final AbsoluteDate date, final Frame frame, final FieldVector3D<T> position) throws OrekitException {
    // Retrieve derivation properties for parameter T
    // It is implied here that T is a DerivativeStructure
    // With order 1 and 6, 7 or 8 free parameters
    // This is all checked before in method isStateDerivatives
    final DSFactory factory = ((DerivativeStructure) position.getX()).getFactory();
    // Build a DerivativeStructure using only derivatives with respect to position
    final DSFactory factory3 = new DSFactory(3, 1);
    final FieldVector3D<DerivativeStructure> position3 = new FieldVector3D<>(factory3.variable(0, position.getX().getReal()), factory3.variable(1, position.getY().getReal()), factory3.variable(2, position.getZ().getReal()));
    // Get atmosphere properties in atmosphere own frame
    final Frame atmFrame = atmosphere.getFrame();
    final Transform toBody = frame.getTransformTo(atmFrame, date);
    final FieldVector3D<DerivativeStructure> posBodyDS = toBody.transformPosition(position3);
    final Vector3D posBody = posBodyDS.toVector3D();
    // Estimate density model by finite differences and composition
    // Using a delta of 1m
    final double delta = 1.0;
    final double x = posBody.getX();
    final double y = posBody.getY();
    final double z = posBody.getZ();
    final double rho0 = atmosphere.getDensity(date, posBody, atmFrame);
    final double dRhodX = (atmosphere.getDensity(date, new Vector3D(x + delta, y, z), atmFrame) - rho0) / delta;
    final double dRhodY = (atmosphere.getDensity(date, new Vector3D(x, y + delta, z), atmFrame) - rho0) / delta;
    final double dRhodZ = (atmosphere.getDensity(date, new Vector3D(x, y, z + delta), atmFrame) - rho0) / delta;
    final double[] dXdQ = posBodyDS.getX().getAllDerivatives();
    final double[] dYdQ = posBodyDS.getY().getAllDerivatives();
    final double[] dZdQ = posBodyDS.getZ().getAllDerivatives();
    // Density with derivatives:
    // - The value and only the 3 first derivatives (those with respect to spacecraft position) are computed
    // - Others are set to 0.
    final int p = factory.getCompiler().getFreeParameters();
    final double[] rhoAll = new double[p + 1];
    rhoAll[0] = rho0;
    for (int i = 1; i < 4; ++i) {
        rhoAll[i] = dRhodX * dXdQ[i] + dRhodY * dYdQ[i] + dRhodZ * dZdQ[i];
    }
    @SuppressWarnings("unchecked") final T rho = (T) (factory.build(rhoAll));
    return rho;
}
Also used : Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) Transform(org.orekit.frames.Transform) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D)

Example 33 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class DTM2000 method getDensity.

/**
 * {@inheritDoc}
 */
@Override
public <T extends RealFieldElement<T>> T getDensity(final FieldAbsoluteDate<T> date, final FieldVector3D<T> position, final Frame frame) throws OrekitException {
    // check if data are available :
    final AbsoluteDate dateD = date.toAbsoluteDate();
    if ((dateD.compareTo(inputParams.getMaxDate()) > 0) || (dateD.compareTo(inputParams.getMinDate()) < 0)) {
        throw new OrekitException(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE, dateD, inputParams.getMinDate(), inputParams.getMaxDate());
    }
    // compute day number in current year
    final Calendar cal = new GregorianCalendar();
    cal.setTime(date.toDate(TimeScalesFactory.getUTC()));
    final int day = cal.get(Calendar.DAY_OF_YEAR);
    // position in ECEF so we only have to do the transform once
    final Frame ecef = earth.getBodyFrame();
    final FieldVector3D<T> pEcef = frame.getTransformTo(ecef, date).transformPosition(position);
    // compute geodetic position
    final FieldGeodeticPoint<T> inBody = earth.transform(pEcef, ecef, date);
    final T alti = inBody.getAltitude();
    final T lon = inBody.getLongitude();
    final T lat = inBody.getLatitude();
    // compute local solar time
    final Vector3D sunPos = sun.getPVCoordinates(dateD, ecef).getPosition();
    final T y = pEcef.getY().multiply(sunPos.getX()).subtract(pEcef.getX().multiply(sunPos.getY()));
    final T x = pEcef.getX().multiply(sunPos.getX()).add(pEcef.getY().multiply(sunPos.getY()));
    final T hl = y.atan2(x).add(FastMath.PI);
    // get current solar activity data and compute
    return getDensity(day, alti, lon, lat, hl, inputParams.getInstantFlux(dateD), inputParams.getMeanFlux(dateD), inputParams.getThreeHourlyKP(dateD), inputParams.get24HoursKp(dateD));
}
Also used : Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint)

Example 34 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestEphemerisDatesBackward.

private <T extends RealFieldElement<T>> void doTestEphemerisDatesBackward(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, "2015-07-05", tai);
    FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, "2015-07-03", tai).shiftedBy(-0.1);
    FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(field, "2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS), zero, zero, zero, zero, zero, PositionAngle.TRUE, eci, initialDate, mu);
    OrbitType type = OrbitType.CARTESIAN;
    double[][] tol = NumericalPropagator.tolerances(1e-3, orbit.toOrbit(), type);
    FieldNumericalPropagator<T> prop = new FieldNumericalPropagator<>(field, new DormandPrince853FieldIntegrator<>(field, 0.1, 500, tol[0], tol[1]));
    prop.setOrbitType(type);
    prop.resetInitialState(new FieldSpacecraftState<>(new FieldCartesianOrbit<>(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(endDate, startDate);
    FieldBoundedPropagator<T> ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedFieldPVCoordinates<T> actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedFieldPVCoordinates<T> expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition().toVector3D(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity().toVector3D(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate).getReal(), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate).getReal(), OrekitMatchers.closeTo(0, 0));
    // test date
    FieldAbsoluteDate<T> date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date).getReal(), 0, 0);
}
Also used : Frame(org.orekit.frames.Frame) TimeScale(org.orekit.time.TimeScale) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 35 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class FieldNumericalPropagatorTest method doTestEphemerisDates.

private <T extends RealFieldElement<T>> void doTestEphemerisDates(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    // setup
    TimeScale tai = TimeScalesFactory.getTAI();
    FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, "2015-07-01", tai);
    FieldAbsoluteDate<T> startDate = new FieldAbsoluteDate<>(field, "2015-07-03", tai).shiftedBy(-0.1);
    FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(field, "2015-07-04", tai);
    Frame eci = FramesFactory.getGCRF();
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS), zero, zero, zero, zero, zero, PositionAngle.TRUE, eci, initialDate, mu);
    OrbitType type = OrbitType.CARTESIAN;
    double[][] tol = NumericalPropagator.tolerances(1e-3, orbit.toOrbit(), type);
    FieldNumericalPropagator<T> prop = new FieldNumericalPropagator<>(field, new DormandPrince853FieldIntegrator<>(field, 0.1, 500, tol[0], tol[1]));
    prop.setOrbitType(type);
    prop.resetInitialState(new FieldSpacecraftState<>(new FieldCartesianOrbit<>(orbit)));
    // action
    prop.setEphemerisMode();
    prop.propagate(startDate, endDate);
    FieldBoundedPropagator<T> ephemeris = prop.getGeneratedEphemeris();
    // verify
    TimeStampedFieldPVCoordinates<T> actualPV = ephemeris.getPVCoordinates(startDate, eci);
    TimeStampedFieldPVCoordinates<T> expectedPV = orbit.getPVCoordinates(startDate, eci);
    MatcherAssert.assertThat(actualPV.getPosition().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition().toVector3D(), 1.0));
    MatcherAssert.assertThat(actualPV.getVelocity().toVector3D(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity().toVector3D(), 1.0));
    MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate).getReal(), OrekitMatchers.closeTo(0, 0));
    MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate).getReal(), OrekitMatchers.closeTo(0, 0));
    // test date
    FieldAbsoluteDate<T> date = endDate.shiftedBy(-0.11);
    Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date).getReal(), 0, 0);
}
Also used : Frame(org.orekit.frames.Frame) TimeScale(org.orekit.time.TimeScale) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

Frame (org.orekit.frames.Frame)257 Test (org.junit.Test)169 AbsoluteDate (org.orekit.time.AbsoluteDate)153 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)117 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)99 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)79 SpacecraftState (org.orekit.propagation.SpacecraftState)79 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)70 OrekitException (org.orekit.errors.OrekitException)60 PVCoordinates (org.orekit.utils.PVCoordinates)58 Orbit (org.orekit.orbits.Orbit)51 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)50 TimeScale (org.orekit.time.TimeScale)46 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)46 GeodeticPoint (org.orekit.bodies.GeodeticPoint)41 TopocentricFrame (org.orekit.frames.TopocentricFrame)38 Transform (org.orekit.frames.Transform)38 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)35 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)33 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)31