use of org.orekit.attitudes.Attitude 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.Attitude 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);
}
use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class KeplerianPropagatorTest method tesWrapedAttitudeException.
@Test(expected = OrekitException.class)
public void tesWrapedAttitudeException() throws OrekitException {
final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
KeplerianPropagator propagator = new KeplerianPropagator(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 <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
});
propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class AbstractAnalyticalPropagator method basicPropagate.
/**
* Propagate an orbit without any fancy features.
* <p>This method is similar in spirit to the {@link #propagate} method,
* except that it does <strong>not</strong> call any handler during
* propagation, nor any discrete events, not additional states. It always
* stop exactly at the specified date.</p>
* @param date target date for propagation
* @return state at specified date
* @exception OrekitException if propagation cannot reach specified date
*/
protected SpacecraftState basicPropagate(final AbsoluteDate date) throws OrekitException {
try {
// evaluate orbit
final Orbit orbit = propagateOrbit(date);
// evaluate attitude
final Attitude attitude = getAttitudeProvider().getAttitude(pvProvider, date, orbit.getFrame());
// build raw state
return new SpacecraftState(orbit, attitude, getMass(date));
} catch (OrekitException oe) {
throw new OrekitException(oe);
}
}
use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class Ephemeris method basicPropagate.
@Override
public /**
* {@inheritDoc}
*/
SpacecraftState basicPropagate(final AbsoluteDate date) throws OrekitException {
final SpacecraftState evaluatedState;
final AbsoluteDate central;
if (date.compareTo(minDate) < 0 && FastMath.abs(date.durationFrom(minDate)) <= extrapolationThreshold) {
// avoid TimeStampedCacheException as we are still within the tolerance before minDate
central = minDate;
} else if (date.compareTo(maxDate) > 0 && FastMath.abs(date.durationFrom(maxDate)) <= extrapolationThreshold) {
// avoid TimeStampedCacheException as we are still within the tolerance after maxDate
central = maxDate;
} else {
central = date;
}
final List<SpacecraftState> neighbors = cache.getNeighbors(central).collect(Collectors.toList());
evaluatedState = neighbors.get(0).interpolate(date, neighbors);
final AttitudeProvider attitudeProvider = getAttitudeProvider();
if (attitudeProvider == null) {
return evaluatedState;
} else {
pvProvider.setCurrentState(evaluatedState);
final Attitude calculatedAttitude = attitudeProvider.getAttitude(pvProvider, date, evaluatedState.getFrame());
return new SpacecraftState(evaluatedState.getOrbit(), calculatedAttitude, evaluatedState.getMass());
}
}
Aggregations