use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testForwardAndBackward.
@Test
public void testForwardAndBackward() throws OrekitException {
final double isp = 318;
final double mass = 2500;
final double a = 24396159;
final double e = 0.72831215;
final double i = FastMath.toRadians(7);
final double omega = FastMath.toRadians(180);
final double OMEGA = FastMath.toRadians(261);
final double lv = 0;
final double duration = 3653.99;
final double f = 420;
final double delta = FastMath.toRadians(-7.4978);
final double alpha = FastMath.toRadians(351);
final AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
Assert.assertEquals(f, maneuver.getThrust(), 1.0e-10);
Assert.assertEquals(isp, maneuver.getISP(), 1.0e-10);
double[][] tol = NumericalPropagator.tolerances(1.0, orbit, OrbitType.KEPLERIAN);
AdaptiveStepsizeIntegrator integrator1 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator1.setInitialStepSize(60);
final NumericalPropagator propagator1 = new NumericalPropagator(integrator1);
propagator1.setInitialState(initialState);
propagator1.setAttitudeProvider(law);
propagator1.addForceModel(maneuver);
final SpacecraftState finalState = propagator1.propagate(fireDate.shiftedBy(3800));
AdaptiveStepsizeIntegrator integrator2 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator2.setInitialStepSize(60);
final NumericalPropagator propagator2 = new NumericalPropagator(integrator2);
propagator2.setInitialState(finalState);
propagator2.setAttitudeProvider(law);
propagator2.addForceModel(maneuver);
final SpacecraftState recoveredState = propagator2.propagate(orbit.getDate());
final Vector3D refPosition = initialState.getPVCoordinates().getPosition();
final Vector3D recoveredPosition = recoveredState.getPVCoordinates().getPosition();
Assert.assertEquals(0.0, Vector3D.distance(refPosition, recoveredPosition), 30.0);
Assert.assertEquals(initialState.getMass(), recoveredState.getMass(), 1.5e-10);
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testJacobianVs80Implementation.
@Test
public void testJacobianVs80Implementation() throws OrekitException {
final double isp = 318;
final double mass = 2500;
final double a = 24396159;
final double e = 0.72831215;
final double i = FastMath.toRadians(7);
final double omega = FastMath.toRadians(180);
final double OMEGA = FastMath.toRadians(261);
final double lv = 0;
final double duration = 3653.99;
final double f = 420;
final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
final AttitudeProvider law = new LofOffset(orbit.getFrame(), LOFType.VVLH);
final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
// before maneuver (Jacobian wrt. state is zero)
checkStateJacobianVs80Implementation(initialState, maneuver, law, 1.0e-50, false);
// in maneuver
SpacecraftState startState = initialState.shiftedBy(fireDate.durationFrom(initDate));
maneuver.getEventsDetectors().findFirst().get().eventOccurred(startState, true);
SpacecraftState midState = startState.shiftedBy(duration / 2.0);
checkStateJacobianVs80Implementation(midState, maneuver, law, 1.0e-20, false);
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class SmallManeuverAnalyticalModelTest method getEphemeris.
private BoundedPropagator getEphemeris(final Orbit orbit, final double mass, final AbsoluteDate t0, final Vector3D dV, final double f, final double isp) throws OrekitException {
AttitudeProvider law = new LofOffset(orbit.getFrame(), LOFType.LVLH);
final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
// set up numerical propagator
final double dP = 1.0;
double[][] tolerances = NumericalPropagator.tolerances(dP, orbit, orbit.getType());
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, tolerances[0], tolerances[1]);
integrator.setInitialStepSize(orbit.getKeplerianPeriod() / 100.0);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setOrbitType(orbit.getType());
propagator.setInitialState(initialState);
propagator.setAttitudeProvider(law);
if (dV.getNorm() > 1.0e-6) {
// set up maneuver
final double vExhaust = Constants.G0_STANDARD_GRAVITY * isp;
final double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust);
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(t0, dt, f, isp, dV.normalize());
propagator.addForceModel(maneuver);
}
propagator.setEphemerisMode();
propagator.propagate(t0.shiftedBy(5 * orbit.getKeplerianPeriod()));
return propagator.getGeneratedEphemeris();
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method wrongAttitude.
@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
AttitudeProvider wrongLaw = new AttitudeProvider() {
private static final long serialVersionUID = 5918362126173997016L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
};
EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, wrongLaw, provider);
propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method doTestWrappedAttitudeException.
private <T extends RealFieldElement<T>> void doTestWrappedAttitudeException(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7.8e6), zero.add(0.032), zero.add(0.4), zero.add(0.1), zero.add(0.2), zero.add(0.3), PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, new AttitudeProvider() {
private static final long serialVersionUID = 1L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
});
propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
Aggregations