Search in sources :

Example 31 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class IsotropicRadiationCNES95Convention method radiationPressureAcceleration.

/**
 * {@inheritDoc}
 */
@Override
public FieldVector3D<DerivativeStructure> radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux, final double[] parameters, final String paramName) throws OrekitException {
    final DerivativeStructure absorptionCoeffDS;
    final DerivativeStructure specularReflectionCoeffDS;
    if (ABSORPTION_COEFFICIENT.equals(paramName)) {
        absorptionCoeffDS = factory.variable(0, parameters[0]);
        specularReflectionCoeffDS = factory.constant(parameters[1]);
    } else if (REFLECTION_COEFFICIENT.equals(paramName)) {
        absorptionCoeffDS = factory.constant(parameters[0]);
        specularReflectionCoeffDS = factory.variable(0, parameters[1]);
    } else {
        throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, ABSORPTION_COEFFICIENT + ", " + REFLECTION_COEFFICIENT);
    }
    final DerivativeStructure kP = absorptionCoeffDS.subtract(1).multiply(specularReflectionCoeffDS.subtract(1)).multiply(4.0 / 9.0).add(1).multiply(crossSection);
    return new FieldVector3D<>(kP.divide(mass), flux);
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) OrekitException(org.orekit.errors.OrekitException) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D)

Example 32 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class SolarRadiationPressure method getLightingRatio.

/**
 * Get the lighting ratio ([0-1]).
 * @param position the satellite's position in the selected frame.
 * @param frame in which is defined the position
 * @param date the date
 * @param <T> extends RealFieldElement
 * @return lighting ratio
 * @exception OrekitException if the trajectory is inside the central body
 * @since 7.1
 */
public <T extends RealFieldElement<T>> T getLightingRatio(final FieldVector3D<T> position, final Frame frame, final FieldAbsoluteDate<T> date) throws OrekitException {
    final T one = date.getField().getOne();
    final Vector3D sunPosition = sun.getPVCoordinates(date.toAbsoluteDate(), frame).getPosition();
    if (sunPosition.getNorm() < 2 * Constants.SUN_RADIUS) {
        // not around a planet,we consider lighting ratio is always 1
        return one;
    }
    // Compute useful angles
    final T[] angle = getEclipseAngles(sunPosition, position);
    // Sat-Sun / Sat-CentralBody angle
    final T sunsatCentralBodyAngle = angle[0];
    // Central Body apparent radius
    final T alphaCentral = angle[1];
    // Sun apparent radius
    final T alphaSun = angle[2];
    T result = one;
    // Is the satellite in complete umbra ?
    if (sunsatCentralBodyAngle.getReal() - alphaCentral.getReal() + alphaSun.getReal() <= ANGULAR_MARGIN) {
        result = date.getField().getZero();
    } else if (sunsatCentralBodyAngle.getReal() - alphaCentral.getReal() - alphaSun.getReal() < -ANGULAR_MARGIN) {
        // Compute a lighting ratio in penumbra
        final T sEA2 = sunsatCentralBodyAngle.multiply(sunsatCentralBodyAngle);
        final T oo2sEA = sunsatCentralBodyAngle.multiply(2).reciprocal();
        final T aS2 = alphaSun.multiply(alphaSun);
        final T aE2 = alphaCentral.multiply(alphaCentral);
        final T aE2maS2 = aE2.subtract(aS2);
        final T alpha1 = sEA2.subtract(aE2maS2).multiply(oo2sEA);
        final T alpha2 = sEA2.add(aE2maS2).multiply(oo2sEA);
        // Protection against numerical inaccuracy at boundaries
        final double almost0 = Precision.SAFE_MIN;
        final double almost1 = FastMath.nextDown(1.0);
        final T a1oaS = min(almost1, max(-almost1, alpha1.divide(alphaSun)));
        final T aS2ma12 = max(almost0, aS2.subtract(alpha1.multiply(alpha1)));
        final T a2oaE = min(almost1, max(-almost1, alpha2.divide(alphaCentral)));
        final T aE2ma22 = max(almost0, aE2.subtract(alpha2.multiply(alpha2)));
        final T P1 = aS2.multiply(a1oaS.acos()).subtract(alpha1.multiply(aS2ma12.sqrt()));
        final T P2 = aE2.multiply(a2oaE.acos()).subtract(alpha2.multiply(aE2ma22.sqrt()));
        result = one.subtract(P1.add(P2).divide(aS2.multiply(FastMath.PI)));
    }
    return result;
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D)

Example 33 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class ThirdBodyAttractionTest method accelerationDerivatives.

@Override
protected FieldVector3D<DerivativeStructure> accelerationDerivatives(final ForceModel forceModel, final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position, final FieldVector3D<DerivativeStructure> velocity, final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass) throws OrekitException {
    try {
        java.lang.reflect.Field bodyField = ThirdBodyAttraction.class.getDeclaredField("body");
        bodyField.setAccessible(true);
        CelestialBody body = (CelestialBody) bodyField.get(forceModel);
        double gm = forceModel.getParameterDriver(body.getName() + ThirdBodyAttraction.ATTRACTION_COEFFICIENT_SUFFIX).getValue();
        // compute bodies separation vectors and squared norm
        final Vector3D centralToBody = body.getPVCoordinates(date, frame).getPosition();
        final double r2Central = centralToBody.getNormSq();
        final FieldVector3D<DerivativeStructure> satToBody = position.subtract(centralToBody).negate();
        final DerivativeStructure r2Sat = satToBody.getNormSq();
        // compute relative acceleration
        final FieldVector3D<DerivativeStructure> satAcc = new FieldVector3D<>(r2Sat.sqrt().multiply(r2Sat).reciprocal().multiply(gm), satToBody);
        final Vector3D centralAcc = new Vector3D(gm / (r2Central * FastMath.sqrt(r2Central)), centralToBody);
        return satAcc.subtract(centralAcc);
    } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
        return null;
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) CelestialBody(org.orekit.bodies.CelestialBody)

Example 34 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class FieldCartesianOrbitTest method doTestCartesianToCartesian.

private <T extends RealFieldElement<T>> void doTestCartesianToCartesian(Field<T> field) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    T zero = field.getZero();
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
    FieldVector3D<T> position = new FieldVector3D<>(zero.add(-29536113.0), zero.add(30329259.0), zero.add(-100125.0));
    FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(-2194.0), zero.add(-2141.0), zero.add(-8.0));
    FieldPVCoordinates<T> FieldPVCoordinates = new FieldPVCoordinates<>(position, velocity);
    double mu = 3.9860047e14;
    FieldCartesianOrbit<T> p = new FieldCartesianOrbit<>(FieldPVCoordinates, FramesFactory.getEME2000(), date, mu);
    Assert.assertEquals(p.getPVCoordinates().getPosition().getX().getReal(), FieldPVCoordinates.getPosition().getX().getReal(), Utils.epsilonTest * FastMath.abs(FieldPVCoordinates.getPosition().getX().getReal()));
    Assert.assertEquals(p.getPVCoordinates().getPosition().getY().getReal(), FieldPVCoordinates.getPosition().getY().getReal(), Utils.epsilonTest * FastMath.abs(FieldPVCoordinates.getPosition().getY().getReal()));
    Assert.assertEquals(p.getPVCoordinates().getPosition().getZ().getReal(), FieldPVCoordinates.getPosition().getZ().getReal(), Utils.epsilonTest * FastMath.abs(FieldPVCoordinates.getPosition().getZ().getReal()));
    Assert.assertEquals(p.getPVCoordinates().getVelocity().getX().getReal(), FieldPVCoordinates.getVelocity().getX().getReal(), Utils.epsilonTest * FastMath.abs(FieldPVCoordinates.getVelocity().getX().getReal()));
    Assert.assertEquals(p.getPVCoordinates().getVelocity().getY().getReal(), FieldPVCoordinates.getVelocity().getY().getReal(), Utils.epsilonTest * FastMath.abs(FieldPVCoordinates.getVelocity().getY().getReal()));
    Assert.assertEquals(p.getPVCoordinates().getVelocity().getZ().getReal(), FieldPVCoordinates.getVelocity().getZ().getReal(), Utils.epsilonTest * FastMath.abs(FieldPVCoordinates.getVelocity().getZ().getReal()));
    Method initPV = FieldCartesianOrbit.class.getDeclaredMethod("initPVCoordinates", new Class[0]);
    initPV.setAccessible(true);
    Assert.assertSame(p.getPVCoordinates(), initPV.invoke(p, new Object[0]));
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) Method(java.lang.reflect.Method) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D)

Example 35 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D 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)

Aggregations

FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)124 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)53 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)49 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)38 Test (org.junit.Test)38 Frame (org.orekit.frames.Frame)36 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)31 OrekitException (org.orekit.errors.OrekitException)23 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)20 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)20 Decimal64 (org.hipparchus.util.Decimal64)18 FieldEquinoctialOrbit (org.orekit.orbits.FieldEquinoctialOrbit)15 OrbitType (org.orekit.orbits.OrbitType)15 AbsoluteDate (org.orekit.time.AbsoluteDate)15 DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)14 Transform (org.orekit.frames.Transform)14 FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)12 FieldEcksteinHechlerPropagator (org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator)10 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)9 ArrayList (java.util.ArrayList)8