use of org.hipparchus.geometry.euclidean.threed.FieldVector3D 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.hipparchus.geometry.euclidean.threed.FieldVector3D 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.hipparchus.geometry.euclidean.threed.FieldVector3D 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.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class TimeStampedPVCoordinatesTest method testToDerivativeStructureVector2.
@Test
public void testToDerivativeStructureVector2() throws OrekitException {
FieldVector3D<DerivativeStructure> fv = new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)).toDerivativeStructureVector(2);
Assert.assertEquals(1, fv.getX().getFreeParameters());
Assert.assertEquals(2, fv.getX().getOrder());
Assert.assertEquals(1.0, fv.getX().getReal(), 1.0e-10);
Assert.assertEquals(0.1, fv.getY().getReal(), 1.0e-10);
Assert.assertEquals(10.0, fv.getZ().getReal(), 1.0e-10);
Assert.assertEquals(-1.0, fv.getX().getPartialDerivative(1), 1.0e-15);
Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1), 1.0e-15);
Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1), 1.0e-15);
Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2), 1.0e-15);
Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2), 1.0e-15);
Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2), 1.0e-15);
checkPV(new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)), new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, fv), 1.0e-15);
for (double dt = 0; dt < 10; dt += 0.125) {
Vector3D p = new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)).shiftedBy(dt).getPosition();
Assert.assertEquals(p.getX(), fv.getX().taylor(dt), 1.0e-14);
Assert.assertEquals(p.getY(), fv.getY().taylor(dt), 1.0e-14);
Assert.assertEquals(p.getZ(), fv.getZ().taylor(dt), 1.0e-14);
}
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldAngularCoordinatesTest method testResultAngularCoordinates.
@Test
public void testResultAngularCoordinates() throws OrekitException {
Field<Decimal64> field = Decimal64Field.getInstance();
Decimal64 zero = field.getZero();
FieldVector3D<Decimal64> pos_B = new FieldVector3D<>(zero.add(-0.23723922134606962), zero.add(-0.9628700341496187), zero.add(0.1288365211879871));
FieldVector3D<Decimal64> vel_B = new FieldVector3D<>(zero.add(2.6031808214929053E-7), zero.add(-8.141147978260352E-8), zero.add(-1.2908618653852553E-7));
FieldVector3D<Decimal64> acc_B = new FieldVector3D<>(zero.add(-1.395403347295246E-10), zero.add(-2.7451871050415643E-12), zero.add(-2.781723303703499E-10));
FieldPVCoordinates<Decimal64> B = new FieldPVCoordinates<Decimal64>(pos_B, vel_B, acc_B);
FieldVector3D<Decimal64> pos_A = new FieldVector3D<>(zero.add(-0.44665912825286425), zero.add(-0.00965737694923173), zero.add(-0.894652087807798));
FieldVector3D<Decimal64> vel_A = new FieldVector3D<>(zero.add(-8.897373390367405E-4), zero.add(2.7825509772757976E-4), zero.add(4.412017757970883E-4));
FieldVector3D<Decimal64> acc_A = new FieldVector3D<>(zero.add(4.743595125825107E-7), zero.add(1.01875177357042E-8), zero.add(9.520371766790574E-7));
FieldPVCoordinates<Decimal64> A = new FieldPVCoordinates<>(pos_A, vel_A, acc_A);
FieldPVCoordinates<Decimal64> PLUS_K = new FieldPVCoordinates<>(new FieldVector3D<>(field.getZero(), field.getZero(), field.getOne()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()));
FieldPVCoordinates<Decimal64> PLUS_J = new FieldPVCoordinates<>(new FieldVector3D<>(field.getZero(), field.getOne(), field.getZero()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()), new FieldVector3D<>(field.getZero(), field.getZero(), field.getZero()));
FieldAngularCoordinates<Decimal64> fac = new FieldAngularCoordinates<>(A, B, PLUS_K, PLUS_J, 1.0e-6);
AngularCoordinates ac = new AngularCoordinates(A.toPVCoordinates(), B.toPVCoordinates(), PLUS_K.toPVCoordinates(), PLUS_J.toPVCoordinates(), 1.0e-6);
Assert.assertTrue(fac.getRotationRate().toVector3D().equals(ac.getRotationRate()));
}
Aggregations