use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class FixedRateTest method testZeroRate.
@Test
public void testZeroRate() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(2004, 3, 2), new TimeComponents(13, 17, 7.865), TimeScalesFactory.getUTC());
final Frame frame = FramesFactory.getEME2000();
FixedRate law = new FixedRate(new Attitude(date, frame, new Rotation(0.48, 0.64, 0.36, 0.48, false), Vector3D.ZERO, Vector3D.ZERO));
PVCoordinates pv = new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056));
Orbit orbit = new KeplerianOrbit(pv, frame, date, 3.986004415e14);
Rotation attitude0 = law.getAttitude(orbit, date, frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude0, law.getReferenceAttitude().getRotation()), 1.0e-10);
Rotation attitude1 = law.getAttitude(orbit.shiftedBy(10.0), date.shiftedBy(10.0), frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude1, law.getReferenceAttitude().getRotation()), 1.0e-10);
Rotation attitude2 = law.getAttitude(orbit.shiftedBy(20.0), date.shiftedBy(20.0), frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude2, law.getReferenceAttitude().getRotation()), 1.0e-10);
}
use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class FixedRateTest method testSpin.
@Test
public void testSpin() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
final double rate = 2 * FastMath.PI / (12 * 60);
AttitudeProvider law = new FixedRate(new Attitude(date, FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate, Vector3D.PLUS_K), Vector3D.ZERO));
KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
Propagator propagator = new KeplerianPropagator(orbit, law);
double h = 0.01;
SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
SpacecraftState s0 = propagator.propagate(date);
SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus);
double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus);
Vector3D spin0 = s0.getAttitude().getSpin();
Vector3D reference = AngularCoordinates.estimateRate(sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), 2 * h);
Assert.assertEquals(0.0, spin0.subtract(reference).getNorm(), 1.0e-14);
}
use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class AdapterPropagatorTest method testLowEarthOrbit.
@Test
public void testLowEarthOrbit() throws OrekitException, ParseException, IOException {
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.1, 0.2, 0.3);
double f = 20.0;
double isp = 315.0;
double vExhaust = Constants.G0_STANDARD_GRAVITY * isp;
double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust);
BoundedPropagator withoutManeuver = getEphemeris(leo, mass, 5, new LofOffset(leo.getFrame(), LOFType.LVLH), t0, Vector3D.ZERO, f, isp, false, false, null);
BoundedPropagator withManeuver = getEphemeris(leo, mass, 5, new LofOffset(leo.getFrame(), LOFType.LVLH), t0, dV, f, isp, false, false, null);
// we set up a model that reverts the maneuvers
AdapterPropagator adapterPropagator = new AdapterPropagator(withManeuver);
AdapterPropagator.DifferentialEffect effect = new SmallManeuverAnalyticalModel(adapterPropagator.propagate(t0), dV.negate(), isp);
adapterPropagator.addEffect(effect);
adapterPropagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "dummy 3";
}
public double[] getAdditionalState(SpacecraftState state) {
return new double[3];
}
});
// the adapted propagators do not manage the additional states from the reference,
// they simply forward them
Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 1"));
Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 2"));
Assert.assertTrue(adapterPropagator.isAdditionalStateManaged("dummy 3"));
for (AbsoluteDate t = t0.shiftedBy(0.5 * dt); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t.shiftedBy(60.0)) {
PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame());
PVCoordinates pvReverted = adapterPropagator.getPVCoordinates(t, leo.getFrame());
double revertError = new PVCoordinates(pvWithout, pvReverted).getPosition().getNorm();
Assert.assertEquals(0, revertError, 0.45);
Assert.assertEquals(2, adapterPropagator.propagate(t).getAdditionalState("dummy 1").length);
Assert.assertEquals(1, adapterPropagator.propagate(t).getAdditionalState("dummy 2").length);
Assert.assertEquals(3, adapterPropagator.propagate(t).getAdditionalState("dummy 3").length);
}
}
use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class AdapterPropagatorTest method testNonKeplerian.
@Test
public void testNonKeplerian() throws OrekitException, ParseException, IOException {
Orbit leo = new CircularOrbit(7204319.233600575, 4.434564637450575E-4, 0.0011736728299091088, 1.7211611441767323, 5.5552084166959474, 24950.321259193086, PositionAngle.TRUE, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2003, 9, 16), new TimeComponents(23, 11, 20.264), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU);
double mass = 4093.0;
AbsoluteDate t0 = new AbsoluteDate(new DateComponents(2003, 9, 16), new TimeComponents(23, 14, 40.264), TimeScalesFactory.getUTC());
Vector3D dV = new Vector3D(0.0, 3.0, 0.0);
double f = 40.0;
double isp = 300.0;
double vExhaust = Constants.G0_STANDARD_GRAVITY * isp;
double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust);
// setup a specific coefficient file for gravity potential as it will also
// try to read a corrupted one otherwise
GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getNormalizedProvider(8, 8);
BoundedPropagator withoutManeuver = getEphemeris(leo, mass, 10, new LofOffset(leo.getFrame(), LOFType.VNC), t0, Vector3D.ZERO, f, isp, true, true, gravityField);
BoundedPropagator withManeuver = getEphemeris(leo, mass, 10, new LofOffset(leo.getFrame(), LOFType.VNC), t0, dV, f, isp, true, true, gravityField);
// we set up a model that reverts the maneuvers
AdapterPropagator adapterPropagator = new AdapterPropagator(withManeuver);
SpacecraftState state0 = adapterPropagator.propagate(t0);
AdapterPropagator.DifferentialEffect directEffect = new SmallManeuverAnalyticalModel(state0, dV.negate(), isp);
AdapterPropagator.DifferentialEffect derivedEffect = new J2DifferentialEffect(state0, directEffect, false, GravityFieldFactory.getUnnormalizedProvider(gravityField));
adapterPropagator.addEffect(directEffect);
adapterPropagator.addEffect(derivedEffect);
adapterPropagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "dummy 3";
}
public double[] getAdditionalState(SpacecraftState state) {
return new double[3];
}
});
// the adapted propagators do not manage the additional states from the reference,
// they simply forward them
Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 1"));
Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 2"));
Assert.assertTrue(adapterPropagator.isAdditionalStateManaged("dummy 3"));
double maxDelta = 0;
double maxNominal = 0;
for (AbsoluteDate t = t0.shiftedBy(0.5 * dt); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t.shiftedBy(600.0)) {
PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame());
PVCoordinates pvWith = withManeuver.getPVCoordinates(t, leo.getFrame());
PVCoordinates pvReverted = adapterPropagator.getPVCoordinates(t, leo.getFrame());
double nominal = new PVCoordinates(pvWithout, pvWith).getPosition().getNorm();
double revertError = new PVCoordinates(pvWithout, pvReverted).getPosition().getNorm();
maxDelta = FastMath.max(maxDelta, revertError);
maxNominal = FastMath.max(maxNominal, nominal);
Assert.assertEquals(2, adapterPropagator.propagate(t).getAdditionalState("dummy 1").length);
Assert.assertEquals(1, adapterPropagator.propagate(t).getAdditionalState("dummy 2").length);
Assert.assertEquals(3, adapterPropagator.propagate(t).getAdditionalState("dummy 3").length);
}
Assert.assertTrue(maxDelta < 120);
Assert.assertTrue(maxNominal > 2800);
}
use of org.orekit.time.TimeComponents in project Orekit by CS-SI.
the class AdapterPropagatorTest method testEccentricOrbit.
@Test
public void testEccentricOrbit() throws OrekitException, ParseException, IOException {
Orbit heo = new KeplerianOrbit(90000000.0, 0.92, FastMath.toRadians(98.0), FastMath.toRadians(12.3456), FastMath.toRadians(123.456), FastMath.toRadians(1.23456), 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 = heo.getDate().shiftedBy(1000.0);
Vector3D dV = new Vector3D(-0.01, 0.02, 0.03);
double f = 20.0;
double isp = 315.0;
double vExhaust = Constants.G0_STANDARD_GRAVITY * isp;
double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust);
BoundedPropagator withoutManeuver = getEphemeris(heo, mass, 5, new LofOffset(heo.getFrame(), LOFType.LVLH), t0, Vector3D.ZERO, f, isp, false, false, null);
BoundedPropagator withManeuver = getEphemeris(heo, mass, 5, new LofOffset(heo.getFrame(), LOFType.LVLH), t0, dV, f, isp, false, false, null);
// we set up a model that reverts the maneuvers
AdapterPropagator adapterPropagator = new AdapterPropagator(withManeuver);
AdapterPropagator.DifferentialEffect effect = new SmallManeuverAnalyticalModel(adapterPropagator.propagate(t0), dV.negate(), isp);
adapterPropagator.addEffect(effect);
adapterPropagator.addAdditionalStateProvider(new AdditionalStateProvider() {
public String getName() {
return "dummy 3";
}
public double[] getAdditionalState(SpacecraftState state) {
return new double[3];
}
});
// the adapted propagators do not manage the additional states from the reference,
// they simply forward them
Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 1"));
Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 2"));
Assert.assertTrue(adapterPropagator.isAdditionalStateManaged("dummy 3"));
for (AbsoluteDate t = t0.shiftedBy(0.5 * dt); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t.shiftedBy(300.0)) {
PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, heo.getFrame());
PVCoordinates pvReverted = adapterPropagator.getPVCoordinates(t, heo.getFrame());
double revertError = Vector3D.distance(pvWithout.getPosition(), pvReverted.getPosition());
Assert.assertEquals(0, revertError, 2.5e-5 * heo.getA());
Assert.assertEquals(2, adapterPropagator.propagate(t).getAdditionalState("dummy 1").length);
Assert.assertEquals(1, adapterPropagator.propagate(t).getAdditionalState("dummy 2").length);
Assert.assertEquals(3, adapterPropagator.propagate(t).getAdditionalState("dummy 3").length);
}
}
Aggregations