use of org.orekit.time.TimeComponents 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.time.TimeComponents in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testPositiveDuration.
@Test
public void testPositiveDuration() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
ConstantThrustManeuver maneuver = new ConstantThrustManeuver(date, 10.0, 400.0, 300.0, Vector3D.PLUS_K);
Assert.assertFalse(maneuver.dependsOnPositionOnly());
ParameterDriver[] drivers = maneuver.getParametersDrivers();
Assert.assertEquals(2, drivers.length);
Assert.assertEquals("thrust", drivers[0].getName());
Assert.assertEquals("flow rate", drivers[1].getName());
EventDetector[] switches = maneuver.getEventsDetectors().toArray(EventDetector[]::new);
Orbit o1 = dummyOrbit(date.shiftedBy(-1.0));
Assert.assertTrue(switches[0].g(new SpacecraftState(o1)) < 0);
Orbit o2 = dummyOrbit(date.shiftedBy(1.0));
Assert.assertTrue(switches[0].g(new SpacecraftState(o2)) > 0);
Orbit o3 = dummyOrbit(date.shiftedBy(9.0));
Assert.assertTrue(switches[1].g(new SpacecraftState(o3)) < 0);
Orbit o4 = dummyOrbit(date.shiftedBy(11.0));
Assert.assertTrue(switches[1].g(new SpacecraftState(o4)) > 0);
}
use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class ImpulseManeuverTest method testInclinationManeuver.
@Test
public void testInclinationManeuver() throws OrekitException {
final Orbit initialOrbit = new KeplerianOrbit(24532000.0, 0.72, 0.3, FastMath.PI, 0.4, 2.0, PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2008, 06, 23), new TimeComponents(14, 18, 37), TimeScalesFactory.getUTC()), 3.986004415e14);
final double a = initialOrbit.getA();
final double e = initialOrbit.getE();
final double i = initialOrbit.getI();
final double mu = initialOrbit.getMu();
final double vApo = FastMath.sqrt(mu * (1 - e) / (a * (1 + e)));
double dv = 0.99 * FastMath.tan(i) * vApo;
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VVLH));
propagator.addEventDetector(new ImpulseManeuver<NodeDetector>(new NodeDetector(initialOrbit, FramesFactory.getEME2000()), new Vector3D(dv, Vector3D.PLUS_J), 400.0));
SpacecraftState propagated = propagator.propagate(initialOrbit.getDate().shiftedBy(8000));
Assert.assertEquals(0.0028257, propagated.getI(), 1.0e-6);
}
use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class SmallManeuverAnalyticalModelTest method testLowEarthOrbit2.
@Test
public void testLowEarthOrbit2() throws OrekitException {
Orbit leo = new CircularOrbit(7200000.0, -1.0e-5, 2.0e-4, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.0, PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
double mass = 5600.0;
AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
Vector3D dV = new Vector3D(-0.01, 0.02, 0.03);
double f = 20.0;
double isp = 315.0;
BoundedPropagator withoutManeuver = getEphemeris(leo, mass, t0, Vector3D.ZERO, f, isp);
BoundedPropagator withManeuver = getEphemeris(leo, mass, t0, dV, f, isp);
SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV, isp);
Assert.assertEquals(t0, model.getDate());
for (AbsoluteDate t = withoutManeuver.getMinDate(); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t.shiftedBy(60.0)) {
PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame());
PVCoordinates pvWith = withManeuver.getPVCoordinates(t, leo.getFrame());
PVCoordinates pvModel = model.apply(withoutManeuver.propagate(t).getOrbit()).getPVCoordinates(leo.getFrame());
double nominalDeltaP = new PVCoordinates(pvWith, pvWithout).getPosition().getNorm();
double modelError = new PVCoordinates(pvWith, pvModel).getPosition().getNorm();
if (t.compareTo(t0) < 0) {
// before maneuver, all positions should be equal
Assert.assertEquals(0, nominalDeltaP, 1.0e-10);
Assert.assertEquals(0, modelError, 1.0e-10);
} else {
// despite nominal deltaP exceeds 1 kilometer after less than 3 orbits
if (t.durationFrom(t0) > 0.1 * leo.getKeplerianPeriod()) {
Assert.assertTrue(modelError < 0.009 * nominalDeltaP);
}
Assert.assertTrue(modelError < 0.8);
}
}
}
use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class SmallManeuverAnalyticalModelTest method testJacobian.
@Test
public void testJacobian() throws OrekitException {
Frame eme2000 = FramesFactory.getEME2000();
Orbit leo = new CircularOrbit(7200000.0, -1.0e-2, 2.0e-3, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.3, PositionAngle.MEAN, eme2000, new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
double mass = 5600.0;
AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
Vector3D dV0 = new Vector3D(-0.1, 0.2, 0.3);
double f = 400.0;
double isp = 315.0;
for (OrbitType orbitType : OrbitType.values()) {
for (PositionAngle positionAngle : PositionAngle.values()) {
BoundedPropagator withoutManeuver = getEphemeris(orbitType.convertType(leo), mass, t0, Vector3D.ZERO, f, isp);
SpacecraftState state0 = withoutManeuver.propagate(t0);
SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(state0, eme2000, dV0, isp);
Assert.assertEquals(t0, model.getDate());
Vector3D[] velDirs = new Vector3D[] { Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.ZERO };
double[] timeDirs = new double[] { 0, 0, 0, 1 };
double h = 1.0;
AbsoluteDate t1 = t0.shiftedBy(20.0);
for (int i = 0; i < 4; ++i) {
SmallManeuverAnalyticalModel[] models = new SmallManeuverAnalyticalModel[] { new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-4 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -4 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-3 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -3 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-2 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -2 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(-1 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, -1 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+1 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +1 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+2 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +2 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+3 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +3 * h, velDirs[i]), isp), new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0.shiftedBy(+4 * h * timeDirs[i])), eme2000, new Vector3D(1, dV0, +4 * h, velDirs[i]), isp) };
double[][] array = new double[models.length][6];
Orbit orbitWithout = withoutManeuver.propagate(t1).getOrbit();
// compute reference orbit gradient by finite differences
double c = 1.0 / (840 * h);
for (int j = 0; j < models.length; ++j) {
orbitType.mapOrbitToArray(models[j].apply(orbitWithout), positionAngle, array[j], null);
}
double[] orbitGradient = new double[6];
for (int k = 0; k < orbitGradient.length; ++k) {
double d4 = array[7][k] - array[0][k];
double d3 = array[6][k] - array[1][k];
double d2 = array[5][k] - array[2][k];
double d1 = array[4][k] - array[3][k];
orbitGradient[k] = (-3 * d4 + 32 * d3 - 168 * d2 + 672 * d1) * c;
}
// analytical Jacobian to check
double[][] jacobian = new double[6][4];
model.getJacobian(orbitWithout, positionAngle, jacobian);
for (int j = 0; j < orbitGradient.length; ++j) {
Assert.assertEquals(orbitGradient[j], jacobian[j][i], 1.6e-4 * FastMath.abs(orbitGradient[j]));
}
}
}
}
}
Aggregations