use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testRoughBehaviour.
@Test
public void testRoughBehaviour() 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[] 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 };
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, absTolerance, relTolerance);
integrator.setInitialStepSize(60);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setInitialState(initialState);
propagator.setAttitudeProvider(law);
propagator.addForceModel(maneuver);
final SpacecraftState finalorb = propagator.propagate(fireDate.shiftedBy(3800));
final double massTolerance = FastMath.abs(maneuver.getFlowRate()) * maneuver.getEventsDetectors().findFirst().get().getThreshold();
Assert.assertEquals(2007.8824544261233, finalorb.getMass(), massTolerance);
Assert.assertEquals(2.6872, FastMath.toDegrees(MathUtils.normalizeAngle(finalorb.getI(), FastMath.PI)), 1e-4);
Assert.assertEquals(28970, finalorb.getA() / 1000, 1);
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testInertialManeuver.
@Test
public void testInertialManeuver() 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 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 double duration = 3653.99;
final double f = 420;
final double delta = FastMath.toRadians(-7.4978);
final double alpha = FastMath.toRadians(351);
final AttitudeProvider inertialLaw = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
final AttitudeProvider lofLaw = new LofOffset(orbit.getFrame(), LOFType.VNC);
final SpacecraftState initialState = new SpacecraftState(orbit, inertialLaw.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 maneuverWithoutOverride = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
Assert.assertEquals(f, maneuverWithoutOverride.getThrust(), 1.0e-10);
Assert.assertEquals(isp, maneuverWithoutOverride.getISP(), 1.0e-10);
// reference propagation:
// propagator already uses inertial law
// maneuver does not need to override it to get an inertial maneuver
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(inertialLaw);
propagator1.addForceModel(maneuverWithoutOverride);
final SpacecraftState finalState1 = propagator1.propagate(fireDate.shiftedBy(3800));
// test propagation:
// propagator uses a LOF-aligned law
// maneuver needs to override it to get an inertial maneuver
final ConstantThrustManeuver maneuverWithOverride = new ConstantThrustManeuver(fireDate, duration, f, isp, inertialLaw, Vector3D.PLUS_I);
Assert.assertEquals(f, maneuverWithoutOverride.getThrust(), 1.0e-10);
Assert.assertEquals(isp, maneuverWithoutOverride.getISP(), 1.0e-10);
AdaptiveStepsizeIntegrator integrator2 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator2.setInitialStepSize(60);
final NumericalPropagator propagator2 = new NumericalPropagator(integrator2);
propagator2.setInitialState(initialState);
propagator2.setAttitudeProvider(lofLaw);
propagator2.addForceModel(maneuverWithOverride);
final SpacecraftState finalState2 = propagator2.propagate(finalState1.getDate());
Assert.assertThat(finalState2.getPVCoordinates(), OrekitMatchers.pvCloseTo(finalState1.getPVCoordinates(), 1.0e-10));
// intentionally wrong propagation, that will produce a very different state
// propagator uses LOF attitude,
// maneuver forget to override it, so maneuver will be LOF-aligned in this case
AdaptiveStepsizeIntegrator integrator3 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator3.setInitialStepSize(60);
final NumericalPropagator propagator3 = new NumericalPropagator(integrator3);
propagator3.setInitialState(initialState);
propagator3.setAttitudeProvider(lofLaw);
propagator3.addForceModel(maneuverWithoutOverride);
final SpacecraftState finalState3 = propagator3.propagate(finalState1.getDate());
Assert.assertEquals(345859.0, Vector3D.distance(finalState1.getPVCoordinates().getPosition(), finalState3.getPVCoordinates().getPosition()), 1.0);
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class ImpulseManeuverTest method testAdditionalStateNumerical.
@Test
public void testAdditionalStateNumerical() throws OrekitException {
final double mu = CelestialBodyFactory.getEarth().getGM();
final double initialX = 7100e3;
final double initialY = 0.0;
final double initialZ = 1300e3;
final double initialVx = 0;
final double initialVy = 8000;
final double initialVz = 1000;
final Vector3D position = new Vector3D(initialX, initialY, initialZ);
final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
final Orbit initialOrbit = new CartesianOrbit(pv, FramesFactory.getEME2000(), mu);
final double totalPropagationTime = 10.0;
final double deltaX = 0.01;
final double deltaY = 0.02;
final double deltaZ = 0.03;
final double isp = 300;
final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);
final AttitudeProvider attitudeProvider = new LofOffset(initialOrbit.getFrame(), LOFType.VNC);
final Attitude initialAttitude = attitudeProvider.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame());
double[][] tolerances = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
DormandPrince853Integrator integrator = new DormandPrince853Integrator(1.0e-3, 60, tolerances[0], tolerances[1]);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setOrbitType(initialOrbit.getType());
PartialDerivativesEquations pde = new PartialDerivativesEquations("derivatives", propagator);
final SpacecraftState initialState = pde.setInitialJacobians(new SpacecraftState(initialOrbit, initialAttitude));
propagator.resetInitialState(initialState);
DateDetector dateDetector = new DateDetector(epoch.shiftedBy(0.5 * totalPropagationTime));
InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, RotationConvention.VECTOR_OPERATOR, 0, 0, 0));
ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector, attitudeOverride, deltaV, isp).withThreshold(1.0e-3);
propagator.addEventDetector(burnAtEpoch);
SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
Assert.assertEquals(1, finalState.getAdditionalStates().size());
Assert.assertEquals(36, finalState.getAdditionalState("derivatives").length);
double[][] stateTransitionMatrix = new double[6][6];
pde.getMapper().getStateJacobian(finalState, stateTransitionMatrix);
for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 6; ++j) {
double sIJ = stateTransitionMatrix[i][j];
if (j == i) {
// dPi/dPj and dVi/dVj are roughly 1 for small propagation times
Assert.assertEquals(1.0, sIJ, 2.0e-4);
} else if (j == i + 3) {
// dVi/dPi is roughly the propagation time for small propagation times
Assert.assertEquals(totalPropagationTime, sIJ, 4.0e-5 * totalPropagationTime);
} else {
// other derivatives are almost zero for small propagation times
Assert.assertEquals(0, sIJ, 1.0e-4);
}
}
}
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class ImpulseManeuverTest method testBackAndForth.
@Test
public void testBackAndForth() throws OrekitException {
final AttitudeProvider lof = new LofOffset(FramesFactory.getEME2000(), LOFType.VNC);
final double mu = Constants.EIGEN5C_EARTH_MU;
final AbsoluteDate iniDate = new AbsoluteDate(2003, 5, 1, 17, 30, 0.0, TimeScalesFactory.getUTC());
final Orbit pastOrbit = new KeplerianOrbit(7e6, 1.0e-4, FastMath.toRadians(98.5), FastMath.toRadians(87.0), FastMath.toRadians(216.1807), FastMath.toRadians(319.779), PositionAngle.MEAN, FramesFactory.getEME2000(), iniDate, mu);
final double pastMass = 2500.0;
DateDetector dateDetector = new DateDetector(iniDate.shiftedBy(600));
Vector3D deltaV = new Vector3D(12.0, 1.0, -4.0);
final double isp = 300;
ImpulseManeuver<DateDetector> maneuver = new ImpulseManeuver<DateDetector>(dateDetector, new InertialProvider(Rotation.IDENTITY), deltaV, isp).withMaxCheck(3600.0).withThreshold(1.0e-6);
double span = 900.0;
KeplerianPropagator forwardPropagator = new KeplerianPropagator(pastOrbit, lof, mu, pastMass);
forwardPropagator.addEventDetector(maneuver);
SpacecraftState futureState = forwardPropagator.propagate(pastOrbit.getDate().shiftedBy(span));
KeplerianPropagator backwardPropagator = new KeplerianPropagator(futureState.getOrbit(), lof, mu, futureState.getMass());
backwardPropagator.addEventDetector(maneuver);
SpacecraftState rebuiltPast = backwardPropagator.propagate(pastOrbit.getDate());
Assert.assertEquals(0.0, Vector3D.distance(pastOrbit.getPVCoordinates().getPosition(), rebuiltPast.getPVCoordinates().getPosition()), 2.0e-8);
Assert.assertEquals(0.0, Vector3D.distance(pastOrbit.getPVCoordinates().getVelocity(), rebuiltPast.getPVCoordinates().getVelocity()), 2.0e-11);
Assert.assertEquals(pastMass, rebuiltPast.getMass(), 5.0e-13);
}
use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.
the class ImpulseManeuverTest method testAdditionalStateKeplerian.
@Test
public void testAdditionalStateKeplerian() throws OrekitException {
final double mu = CelestialBodyFactory.getEarth().getGM();
final double initialX = 7100e3;
final double initialY = 0.0;
final double initialZ = 1300e3;
final double initialVx = 0;
final double initialVy = 8000;
final double initialVz = 1000;
final Vector3D position = new Vector3D(initialX, initialY, initialZ);
final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
final Orbit initialOrbit = new CartesianOrbit(pv, FramesFactory.getEME2000(), mu);
final double totalPropagationTime = 10;
final double deltaX = 0.01;
final double deltaY = 0.02;
final double deltaZ = 0.03;
final double isp = 300;
final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);
final AttitudeProvider attitudeProvider = new LofOffset(initialOrbit.getFrame(), LOFType.VNC);
final Attitude initialAttitude = attitudeProvider.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame());
final SpacecraftState initialState = new SpacecraftState(initialOrbit, initialAttitude);
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
propagator.resetInitialState(initialState.addAdditionalState("testOnly", -1.0));
DateDetector dateDetector = new DateDetector(epoch.shiftedBy(0.5 * totalPropagationTime));
InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, RotationConvention.VECTOR_OPERATOR, 0, 0, 0));
ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector, attitudeOverride, deltaV, isp).withThreshold(1.0e-3);
propagator.addEventDetector(burnAtEpoch);
SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
Assert.assertEquals(1, finalState.getAdditionalStates().size());
Assert.assertEquals(-1.0, finalState.getAdditionalState("testOnly")[0], 1.0e-15);
}
Aggregations