use of org.orekit.orbits.Orbit in project Orekit by CS-SI.
the class SpacecraftStateTest method testDateConsistencyClose.
/**
* Check orbit and attitude dates can be off by a few ulps. I see this when using
* FixedRate attitude provider.
*/
@Test
public void testDateConsistencyClose() throws OrekitException {
// setup
Orbit orbit10Shifts = orbit;
for (int i = 0; i < 10; i++) {
orbit10Shifts = orbit10Shifts.shiftedBy(0.1);
}
final Orbit orbit1Shift = orbit.shiftedBy(1);
Attitude shiftedAttitude = attitudeLaw.getAttitude(orbit1Shift, orbit1Shift.getDate(), orbit.getFrame());
// verify dates are very close, but not equal
Assert.assertNotEquals(shiftedAttitude.getDate(), orbit10Shifts.getDate());
Assert.assertEquals(shiftedAttitude.getDate().durationFrom(orbit10Shifts.getDate()), 0, Precision.EPSILON);
// action + verify no exception is thrown
new SpacecraftState(orbit10Shifts, shiftedAttitude);
}
use of org.orekit.orbits.Orbit in project Orekit by CS-SI.
the class EphemerisEventsTest method buildEphem.
private Ephemeris buildEphem(OrbitType type) throws IllegalArgumentException, OrekitException {
double mass = 2500;
double a = 7187990.1979844316;
double e = 0.5e-4;
double i = 1.7105407051081795;
double omega = 1.9674147913622104;
double OMEGA = FastMath.toRadians(261);
double lv = 0;
double mu = 3.9860047e14;
double ae = 6.378137e6;
double c20 = -1.08263e-3;
double c30 = 2.54e-6;
double c40 = 1.62e-6;
double c50 = 2.3e-7;
double c60 = -5.5e-7;
double deltaT = finalDate.durationFrom(initDate);
Orbit transPar = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
int nbIntervals = 720;
Propagator propagator = new EcksteinHechlerPropagator(transPar, mass, ae, mu, c20, c30, c40, c50, c60);
List<SpacecraftState> tab = new ArrayList<SpacecraftState>(nbIntervals + 1);
for (int j = 0; j <= nbIntervals; j++) {
SpacecraftState state = propagator.propagate(initDate.shiftedBy((j * deltaT) / nbIntervals));
tab.add(new SpacecraftState(type.convertType(state.getOrbit()), state.getAttitude(), state.getMass()));
}
return new Ephemeris(tab, 2);
}
use of org.orekit.orbits.Orbit in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method almostSphericalBody.
@Test
public void almostSphericalBody() throws OrekitException {
// Definition of initial conditions
// ---------------------------------
// with e around e = 1.4e-4 and i = 1.7 rad
Vector3D position = new Vector3D(3220103., 69623., 6449822.);
Vector3D velocity = new Vector3D(6414.7, -2006., -3180.);
AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, provider.getMu());
// Initialisation to simulate a Keplerian extrapolation
// To be noticed: in order to simulate a Keplerian extrapolation with the
// analytical
// extrapolator, one should put the zonal coefficients to 0. But due to
// numerical pbs
// one must put a non 0 value.
UnnormalizedSphericalHarmonicsProvider kepProvider = GravityFieldFactory.getUnnormalizedProvider(6.378137e6, 3.9860047e14, TideSystem.UNKNOWN, new double[][] { { 0 }, { 0 }, { 0.1e-10 }, { 0.1e-13 }, { 0.1e-13 }, { 0.1e-14 }, { 0.1e-14 } }, new double[][] { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } });
// Extrapolators definitions
// -------------------------
EcksteinHechlerPropagator extrapolatorAna = new EcksteinHechlerPropagator(initialOrbit, 1000.0, kepProvider);
KeplerianPropagator extrapolatorKep = new KeplerianPropagator(initialOrbit);
// Extrapolation at a final date different from initial date
// ---------------------------------------------------------
// extrapolation duration in seconds
double delta_t = 100.0;
AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);
SpacecraftState finalOrbitAna = extrapolatorAna.propagate(extrapDate);
SpacecraftState finalOrbitKep = extrapolatorKep.propagate(extrapDate);
Assert.assertEquals(finalOrbitAna.getDate().durationFrom(extrapDate), 0.0, Utils.epsilonTest);
// comparison of each orbital parameters
Assert.assertEquals(finalOrbitAna.getA(), finalOrbitKep.getA(), 10 * Utils.epsilonTest * finalOrbitKep.getA());
Assert.assertEquals(finalOrbitAna.getEquinoctialEx(), finalOrbitKep.getEquinoctialEx(), Utils.epsilonE * finalOrbitKep.getE());
Assert.assertEquals(finalOrbitAna.getEquinoctialEy(), finalOrbitKep.getEquinoctialEy(), Utils.epsilonE * finalOrbitKep.getE());
Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getHx(), finalOrbitKep.getHx()), finalOrbitKep.getHx(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getI()));
Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getHy(), finalOrbitKep.getHy()), finalOrbitKep.getHy(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getI()));
Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getLv(), finalOrbitKep.getLv()), finalOrbitKep.getLv(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getLv()));
Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getLE(), finalOrbitKep.getLE()), finalOrbitKep.getLE(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getLE()));
Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getLM(), finalOrbitKep.getLM()), finalOrbitKep.getLM(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getLM()));
}
use of org.orekit.orbits.Orbit in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method sameDateKeplerian.
@Test
public void sameDateKeplerian() throws OrekitException {
// Definition of initial conditions with Keplerian parameters
// -----------------------------------------------------------
AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
Orbit initialOrbit = new KeplerianOrbit(7209668.0, 0.5e-4, 1.7, 2.1, 2.9, 6.2, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, provider.getMu());
// Extrapolator definition
// -----------------------
EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, Propagator.DEFAULT_MASS, provider);
// Extrapolation at the initial date
// ---------------------------------
SpacecraftState finalOrbit = extrapolator.propagate(initDate);
// positions match perfectly
Assert.assertEquals(0.0, Vector3D.distance(initialOrbit.getPVCoordinates().getPosition(), finalOrbit.getPVCoordinates().getPosition()), 3.0e-8);
// velocity and circular parameters do *not* match, this is EXPECTED!
// the reason is that we ensure position/velocity are consistent with the
// evolution of the orbit, and this includes the non-Keplerian effects,
// whereas the initial orbit is Keplerian only. The implementation of the
// model is such that rather than having a perfect match at initial point
// (either in velocity or in circular parameters), we have a propagated orbit
// that remains close to a numerical reference throughout the orbit.
// This is shown in the testInitializationCorrectness() where a numerical
// fit is used to check initialization
Assert.assertEquals(0.137, Vector3D.distance(initialOrbit.getPVCoordinates().getVelocity(), finalOrbit.getPVCoordinates().getVelocity()), 1.0e-3);
Assert.assertEquals(126.8, finalOrbit.getA() - initialOrbit.getA(), 0.1);
}
use of org.orekit.orbits.Orbit in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method propagatedKeplerian.
@Test
public void propagatedKeplerian() throws OrekitException {
// Definition of initial conditions with Keplerian parameters
// -----------------------------------------------------------
AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
Orbit initialOrbit = new KeplerianOrbit(7209668.0, 0.5e-4, 1.7, 2.1, 2.9, 6.2, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, provider.getMu());
// Extrapolator definition
// -----------------------
EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC, RotationOrder.XYZ, 0, 0, 0), 2000.0, provider);
// Extrapolation at a final date different from initial date
// ---------------------------------------------------------
// extrapolation duration in seconds
double delta_t = 100000.0;
AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);
SpacecraftState finalOrbit = extrapolator.propagate(extrapDate);
Assert.assertEquals(0.0, finalOrbit.getDate().durationFrom(extrapDate), 1.0e-9);
// computation of M final orbit
double LM = finalOrbit.getLE() - finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE()) + finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE());
Assert.assertEquals(LM, finalOrbit.getLM(), Utils.epsilonAngle);
// test of tan((LE - Lv)/2) :
Assert.assertEquals(FastMath.tan((finalOrbit.getLE() - finalOrbit.getLv()) / 2.), tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()), Utils.epsilonAngle);
// test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE)
// with ex and ey the same for initial and final orbit
double deltaM = finalOrbit.getLM() - initialOrbit.getLM();
double deltaE = finalOrbit.getLE() - initialOrbit.getLE();
double delta = finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE()) - initialOrbit.getEquinoctialEx() * FastMath.sin(initialOrbit.getLE()) - finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE()) + initialOrbit.getEquinoctialEy() * FastMath.cos(initialOrbit.getLE());
Assert.assertEquals(deltaM, deltaE - delta, Utils.epsilonAngle * FastMath.abs(deltaE - delta));
// for final orbit
double ex = finalOrbit.getEquinoctialEx();
double ey = finalOrbit.getEquinoctialEy();
double hx = finalOrbit.getHx();
double hy = finalOrbit.getHy();
double LE = finalOrbit.getLE();
double ex2 = ex * ex;
double ey2 = ey * ey;
double hx2 = hx * hx;
double hy2 = hy * hy;
double h2p1 = 1. + hx2 + hy2;
double beta = 1. / (1. + FastMath.sqrt(1. - ex2 - ey2));
double x3 = -ex + (1. - beta * ey2) * FastMath.cos(LE) + beta * ex * ey * FastMath.sin(LE);
double y3 = -ey + (1. - beta * ex2) * FastMath.sin(LE) + beta * ex * ey * FastMath.cos(LE);
Vector3D U = new Vector3D((1. + hx2 - hy2) / h2p1, (2. * hx * hy) / h2p1, (-2. * hy) / h2p1);
Vector3D V = new Vector3D((2. * hx * hy) / h2p1, (1. - hx2 + hy2) / h2p1, (2. * hx) / h2p1);
Vector3D r = new Vector3D(finalOrbit.getA(), (new Vector3D(x3, U, y3, V)));
Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm(), r.getNorm(), Utils.epsilonTest * r.getNorm());
}
Aggregations