use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestPropagationTypesElliptical.
private <T extends RealFieldElement<T>> void doTestPropagationTypesElliptical(Field<T> field) throws OrekitException {
T zero = field.getZero();
// setup
final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
FieldSpacecraftState<T> initialState;
FieldNumericalPropagator<T> propagator;
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));
final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
initialState = new FieldSpacecraftState<>(orbit);
OrbitType type = OrbitType.EQUINOCTIAL;
double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(zero.add(60));
propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(type);
propagator.setInitialState(initialState);
ForceModel gravityField = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getNormalizedProvider(5, 5));
propagator.addForceModel(gravityField);
// Propagation of the initial at t + dt
final FieldPVCoordinates<T> pv = initialState.getPVCoordinates();
final T dP = zero.add(0.001);
final T dV = pv.getPosition().getNormSq().multiply(pv.getVelocity().getNorm()).reciprocal().multiply(dP.multiply(initialState.getMu()));
final FieldPVCoordinates<T> pvcM = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.MEAN, propagator);
final FieldPVCoordinates<T> pviM = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.MEAN, propagator);
final FieldPVCoordinates<T> pveM = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.MEAN, propagator);
final FieldPVCoordinates<T> pvkM = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN, propagator);
final FieldPVCoordinates<T> pvcE = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC, propagator);
final FieldPVCoordinates<T> pviE = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.ECCENTRIC, propagator);
final FieldPVCoordinates<T> pveE = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.ECCENTRIC, propagator);
final FieldPVCoordinates<T> pvkE = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC, propagator);
final FieldPVCoordinates<T> pvcT = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.TRUE, propagator);
final FieldPVCoordinates<T> pviT = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.TRUE, propagator);
final FieldPVCoordinates<T> pveT = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.TRUE, propagator);
final FieldPVCoordinates<T> pvkT = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE, propagator);
Assert.assertEquals(0, pvcM.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 3.0);
Assert.assertEquals(0, pvcM.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 2.0);
Assert.assertEquals(0, pviM.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.6);
Assert.assertEquals(0, pviM.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.4);
Assert.assertEquals(0, pvkM.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.5);
Assert.assertEquals(0, pvkM.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.3);
Assert.assertEquals(0, pveM.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.2);
Assert.assertEquals(0, pveM.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.2);
Assert.assertEquals(0, pvcE.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 3.0);
Assert.assertEquals(0, pvcE.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 2.0);
Assert.assertEquals(0, pviE.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.03);
Assert.assertEquals(0, pviE.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.04);
Assert.assertEquals(0, pvkE.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.4);
Assert.assertEquals(0, pvkE.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.3);
Assert.assertEquals(0, pveE.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.2);
Assert.assertEquals(0, pveE.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.07);
Assert.assertEquals(0, pvcT.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 3.0);
Assert.assertEquals(0, pvcT.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 2.0);
Assert.assertEquals(0, pviT.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.3);
Assert.assertEquals(0, pviT.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.2);
Assert.assertEquals(0, pvkT.getPosition().subtract(pveT.getPosition()).getNorm().getReal() / dP.getReal(), 0.4);
Assert.assertEquals(0, pvkT.getVelocity().subtract(pveT.getVelocity()).getNorm().getReal() / dV.getReal(), 0.2);
}
use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestStopEvent.
private <T extends RealFieldElement<T>> void doTestStopEvent(Field<T> field) throws OrekitException {
T zero = field.getZero();
// setup
final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
FieldSpacecraftState<T> initialState;
FieldNumericalPropagator<T> propagator;
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));
final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
initialState = new FieldSpacecraftState<>(orbit);
OrbitType type = OrbitType.EQUINOCTIAL;
double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(zero.add(60));
propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(type);
propagator.setInitialState(initialState);
final FieldAbsoluteDate<T> stopDate = initDate.shiftedBy(1000);
CheckingHandler<FieldDateDetector<T>, T> checking = new CheckingHandler<FieldDateDetector<T>, T>(Action.STOP);
propagator.addEventDetector(new FieldDateDetector<>(stopDate).withHandler(checking));
Assert.assertEquals(1, propagator.getEventsDetectors().size());
checking.assertEvent(false);
final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(3200));
checking.assertEvent(true);
Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate).getReal(), 1.0e-10);
propagator.clearEventsDetectors();
Assert.assertEquals(0, propagator.getEventsDetectors().size());
}
use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestResetDerivativesEvent.
private <T extends RealFieldElement<T>> void doTestResetDerivativesEvent(Field<T> field) throws OrekitException {
T zero = field.getZero();
// setup
final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
FieldSpacecraftState<T> initialState;
FieldNumericalPropagator<T> propagator;
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));
final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
initialState = new FieldSpacecraftState<>(orbit);
OrbitType type = OrbitType.EQUINOCTIAL;
double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(zero.add(60));
propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(type);
propagator.setInitialState(initialState);
final FieldAbsoluteDate<T> resetDate = initDate.shiftedBy(1000);
CheckingHandler<FieldDateDetector<T>, T> checking = new CheckingHandler<FieldDateDetector<T>, T>(Action.RESET_DERIVATIVES);
propagator.addEventDetector(new FieldDateDetector<>(resetDate).withHandler(checking));
final double dt = 3200;
checking.assertEvent(false);
Assert.assertEquals(0.0, propagator.getInitialState().getDate().durationFrom(initDate).getReal(), 1.0e-10);
propagator.setResetAtEnd(true);
final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(dt));
Assert.assertEquals(dt, propagator.getInitialState().getDate().durationFrom(initDate).getReal(), 1.0e-10);
checking.assertEvent(true);
final double n = FastMath.sqrt(initialState.getMu() / initialState.getA().getReal()) / initialState.getA().getReal();
Assert.assertEquals(initialState.getA().getReal(), finalState.getA().getReal(), 1.0e-10);
Assert.assertEquals(initialState.getEquinoctialEx().getReal(), finalState.getEquinoctialEx().getReal(), 1.0e-10);
Assert.assertEquals(initialState.getEquinoctialEy().getReal(), finalState.getEquinoctialEy().getReal(), 1.0e-10);
Assert.assertEquals(initialState.getHx().getReal(), finalState.getHx().getReal(), 1.0e-10);
Assert.assertEquals(initialState.getHy().getReal(), finalState.getHy().getReal(), 1.0e-10);
Assert.assertEquals(initialState.getLM().getReal() + n * dt, finalState.getLM().getReal(), 6.0e-10);
}
use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestException.
private <T extends RealFieldElement<T>> void doTestException(Field<T> field) throws OrekitException {
T zero = field.getZero();
// setup
final FieldAbsoluteDate<T> initDate = FieldAbsoluteDate.getJ2000Epoch(field);
FieldSpacecraftState<T> initialState;
FieldNumericalPropagator<T> propagator;
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));
final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, mu);
initialState = new FieldSpacecraftState<>(orbit);
OrbitType type = OrbitType.EQUINOCTIAL;
double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit.toOrbit(), type);
AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(zero.add(60));
propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(type);
propagator.setInitialState(initialState);
propagator.setMasterMode(new FieldOrekitStepHandler<T>() {
private int countDown = 3;
private FieldAbsoluteDate<T> previousCall = null;
public void init(FieldSpacecraftState<T> s0, FieldAbsoluteDate<T> t) {
}
public void handleStep(FieldOrekitStepInterpolator<T> interpolator, boolean isLast) throws OrekitException {
if (previousCall != null) {
System.out.println(interpolator.getCurrentState().getDate().compareTo(previousCall) < 0);
}
if (--countDown == 0) {
throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "dummy error");
}
}
});
propagator.propagate(initDate.shiftedBy(-3600));
}
use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldEcksteinHechlerPropagatorTest method doPropagatedCartesian.
private <T extends RealFieldElement<T>> void doPropagatedCartesian(Field<T> field) throws OrekitException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
// Definition of initial conditions with position and velocity
// ------------------------------------------------------------
// with e around e = 1.4e-4 and i = 1.7 rad
FieldVector3D<T> position = new FieldVector3D<>(zero.add(3220103.), zero.add(69623.), zero.add(6449822.));
FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(6414.7), zero.add(-2006.), zero.add(-3180.));
FieldAbsoluteDate<T> initDate = date.shiftedBy(584.);
FieldOrbit<T> initialOrbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, provider.getMu());
// Extrapolator definition
// -----------------------
FieldEcksteinHechlerPropagator<T> extrapolator = new FieldEcksteinHechlerPropagator<>(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC, RotationOrder.XYZ, 0, 0, 0), provider);
// Extrapolation at a final date different from initial date
// ---------------------------------------------------------
// extrapolation duration in seconds
double delta_t = 100000.0;
FieldAbsoluteDate<T> extrapDate = initDate.shiftedBy(delta_t);
FieldSpacecraftState<T> finalOrbit = extrapolator.propagate(extrapDate);
Assert.assertEquals(0.0, finalOrbit.getDate().durationFrom(extrapDate).getReal(), 1.0e-9);
// computation of M final orbit
T LM = finalOrbit.getLE().subtract(finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin())).add(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos()));
Assert.assertEquals(LM.getReal(), finalOrbit.getLM().getReal(), Utils.epsilonAngle * FastMath.abs(finalOrbit.getLM().getReal()));
// test of tan ((LE - Lv)/2) :
Assert.assertEquals(FastMath.tan((finalOrbit.getLE().getReal() - finalOrbit.getLv().getReal()) / 2.), tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()).getReal(), Utils.epsilonAngle);
// test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE)
T deltaM = finalOrbit.getLM().subtract(initialOrbit.getLM());
T deltaE = finalOrbit.getLE().subtract(initialOrbit.getLE());
T delta = finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin()).subtract(initialOrbit.getEquinoctialEx().multiply(initialOrbit.getLE().sin())).subtract(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos())).add(initialOrbit.getEquinoctialEy().multiply(initialOrbit.getLE().cos()));
Assert.assertEquals(deltaM.getReal(), deltaE.getReal() - delta.getReal(), Utils.epsilonAngle * FastMath.abs(deltaE.getReal() - delta.getReal()));
// for final orbit
T ex = finalOrbit.getEquinoctialEx();
T ey = finalOrbit.getEquinoctialEy();
T hx = finalOrbit.getHx();
T hy = finalOrbit.getHy();
T LE = finalOrbit.getLE();
T ex2 = ex.multiply(ex);
T ey2 = ey.multiply(ey);
T hx2 = hx.multiply(hx);
T hy2 = hy.multiply(hy);
T h2p1 = hx2.add(1.).add(hy2);
T beta = ex2.negate().add(1.).subtract(ey2).sqrt().add(1.).reciprocal();
T x3 = ex.negate().add(ey2.multiply(beta).negate().add(1.).multiply(LE.cos())).add(beta.multiply(ex).multiply(ey).multiply(LE.sin()));
T y3 = ey.negate().add(ex2.negate().multiply(beta).add(1).multiply(LE.sin())).add(beta.multiply(ex).multiply(ey).multiply(LE.cos()));
FieldVector3D<T> U = new FieldVector3D<>(hx2.add(1).subtract(hy2).divide(h2p1), hx.multiply(hy).multiply(2).divide(h2p1), hy.multiply(-2).divide(h2p1));
FieldVector3D<T> V = new FieldVector3D<>(hx.multiply(2).multiply(hy).divide(h2p1), hy2.add(1).subtract(hx2).divide(h2p1), hx.multiply(2).divide(h2p1));
FieldVector3D<T> r = new FieldVector3D<>(finalOrbit.getA(), new FieldVector3D<>(x3, U, y3, V));
Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm().getReal(), r.getNorm().getReal(), Utils.epsilonTest * r.getNorm().getReal());
}
Aggregations