use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldEclipseDetectorTest method doTestInsideOcculted.
private <T extends RealFieldElement<T>> void doTestInsideOcculted(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.560), zero.add(-25767.25680));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.8479685), zero.add(942.7809215), zero.add(7435.922231));
FieldAbsoluteDate<T> iniDate = new FieldAbsoluteDate<>(field, 1969, 7, 28, 4, 0, 0.0, TimeScalesFactory.getTT());
final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getGCRF(), iniDate, mu);
FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(orbit);
double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 1000, absTolerance, relTolerance);
integrator.setInitialStepSize(field.getZero().add(60));
FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.setInitialState(initialState);
sun = CelestialBodyFactory.getSun();
earth = CelestialBodyFactory.getEarth();
sunRadius = 696000000.;
earthRadius = 6400000.;
FieldEclipseDetector<T> e = new FieldEclipseDetector<>(field.getZero().add(60.), field.getZero().add(1.e-3), sun, sunRadius, earth, earthRadius);
Vector3D p = sun.getPVCoordinates(AbsoluteDate.J2000_EPOCH, FramesFactory.getGCRF()).getPosition();
FieldSpacecraftState<T> s = new FieldSpacecraftState<>(new FieldCartesianOrbit<>(new TimeStampedFieldPVCoordinates<>(FieldAbsoluteDate.getJ2000Epoch(field), new FieldPVCoordinates<>(new FieldVector3D<>(field.getOne(), field.getZero(), field.getZero()).add(p), new FieldVector3D<>(field.getZero(), field.getZero(), field.getOne()))), FramesFactory.getGCRF(), mu));
Assert.assertEquals(FastMath.PI, e.g(s).getReal(), 1.0e-15);
}
use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestNoExtrapolation.
private <T extends RealFieldElement<T>> void doTestNoExtrapolation(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);
// Propagate of the initial at the initial date
final FieldSpacecraftState<T> finalState = propagator.propagate(initDate);
// Initial orbit definition
final FieldVector3D<T> initialPosition = initialState.getPVCoordinates().getPosition();
final FieldVector3D<T> initialVelocity = initialState.getPVCoordinates().getVelocity();
// Final orbit definition
final FieldVector3D<T> finalPosition = finalState.getPVCoordinates().getPosition();
final FieldVector3D<T> finalVelocity = finalState.getPVCoordinates().getVelocity();
// Check results
Assert.assertEquals(initialPosition.getX().getReal(), finalPosition.getX().getReal(), 1.0e-10);
Assert.assertEquals(initialPosition.getY().getReal(), finalPosition.getY().getReal(), 1.0e-10);
Assert.assertEquals(initialPosition.getZ().getReal(), finalPosition.getZ().getReal(), 1.0e-10);
Assert.assertEquals(initialVelocity.getX().getReal(), finalVelocity.getX().getReal(), 1.0e-10);
Assert.assertEquals(initialVelocity.getY().getReal(), finalVelocity.getY().getReal(), 1.0e-10);
Assert.assertEquals(initialVelocity.getZ().getReal(), finalVelocity.getZ().getReal(), 1.0e-10);
}
use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestResetStateEvent.
private <T extends RealFieldElement<T>> void doTestResetStateEvent(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_STATE) {
public FieldSpacecraftState<T> resetState(FieldDateDetector<T> detector, FieldSpacecraftState<T> oldState) {
return new FieldSpacecraftState<>(oldState.getOrbit(), oldState.getAttitude(), oldState.getMass().subtract(200.0));
}
};
propagator.addEventDetector(new FieldDateDetector<>(resetDate).withHandler(checking));
checking.assertEvent(false);
final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(3200));
checking.assertEvent(true);
Assert.assertEquals(initialState.getMass().getReal() - 200, finalState.getMass().getReal(), 1.0e-10);
}
use of org.orekit.orbits.FieldEquinoctialOrbit in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestContinueEvent.
private <T extends RealFieldElement<T>> void doTestContinueEvent(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.CONTINUE);
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(false);
final FieldSpacecraftState<T> finalState = propagator.propagate(initDate.shiftedBy(dt));
Assert.assertEquals(0.0, 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 doTestCartesian.
private <T extends RealFieldElement<T>> void doTestCartesian(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);
// Propagation of the initial at t + dt
final T dt = zero.add(3200);
propagator.setOrbitType(OrbitType.CARTESIAN);
final FieldPVCoordinates<T> finalState = propagator.propagate(initDate.shiftedBy(dt)).getPVCoordinates();
final FieldVector3D<T> pFin = finalState.getPosition();
final FieldVector3D<T> vFin = finalState.getVelocity();
// Check results
final FieldPVCoordinates<T> reference = initialState.shiftedBy(dt).getPVCoordinates();
final FieldVector3D<T> pRef = reference.getPosition();
final FieldVector3D<T> vRef = reference.getVelocity();
Assert.assertEquals(0, pRef.subtract(pFin).getNorm().getReal(), 2e-4);
Assert.assertEquals(0, vRef.subtract(vFin).getNorm().getReal(), 7e-8);
try {
propagator.getGeneratedEphemeris();
Assert.fail("an exception should have been thrown");
} catch (IllegalStateException ise) {
// expected
}
}
Aggregations