@Test public void testSpin() throws OrekitException { AbsoluteDate date = new AbsoluteDate( new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC()); 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); final AttitudeProvider law = new LofOffsetPointing( earthSpheric, new LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.XYX, 0.1, 0.2, 0.3), Vector3D.PLUS_K); 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.assertTrue(spin0.getNorm() > 1.0e-3); Assert.assertEquals(0.0, spin0.subtract(reference).getNorm(), 1.0e-10); }
/** create {@link #cache} and {@link #data} with neighborsSize = 3 */ @Before public void setUp() { data = Arrays.asList( date, date.shiftedBy(1), date.shiftedBy(2), date.shiftedBy(3), date.shiftedBy(4), date.shiftedBy(5)); cache = new ImmutableTimeStampedCache<AbsoluteDate>(3, data); }
@Test public void testStopEvent() throws OrekitException { final AbsoluteDate stopDate = initDate.shiftedBy(1000); CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.STOP); propagator.addEventDetector(new DateDetector(stopDate).withHandler(checking)); Assert.assertEquals(1, propagator.getEventsDetectors().size()); checking.assertEvent(false); final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200)); checking.assertEvent(true); Assert.assertEquals(0, finalState.getDate().durationFrom(stopDate), 1.0e-10); propagator.clearEventsDetectors(); Assert.assertEquals(0, propagator.getEventsDetectors().size()); }
@Test public void testEphemerisGenerationIssue14() throws OrekitException, IOException { // Propagation of the initial at t + dt final double dt = 3200; propagator.getInitialState(); propagator.setOrbitType(OrbitType.CARTESIAN); propagator.setEphemerisMode(); propagator.propagate(initDate.shiftedBy(dt)); final BoundedPropagator ephemeris1 = propagator.getGeneratedEphemeris(); Assert.assertEquals(initDate, ephemeris1.getMinDate()); Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMaxDate()); propagator.getPVCoordinates(initDate.shiftedBy(2 * dt), FramesFactory.getEME2000()); propagator.getPVCoordinates(initDate.shiftedBy(-2 * dt), FramesFactory.getEME2000()); // the new propagations should not have changed ephemeris1 Assert.assertEquals(initDate, ephemeris1.getMinDate()); Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMaxDate()); final BoundedPropagator ephemeris2 = propagator.getGeneratedEphemeris(); Assert.assertEquals(initDate.shiftedBy(-2 * dt), ephemeris2.getMinDate()); Assert.assertEquals(initDate.shiftedBy(2 * dt), ephemeris2.getMaxDate()); // generating ephemeris2 should not have changed ephemeris1 Assert.assertEquals(initDate, ephemeris1.getMinDate()); Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMaxDate()); }
@Test public void testCartesian() throws OrekitException { // Propagation of the initial at t + dt final double dt = 3200; propagator.setOrbitType(OrbitType.CARTESIAN); final PVCoordinates finalState = propagator.propagate(initDate.shiftedBy(dt)).getPVCoordinates(); final Vector3D pFin = finalState.getPosition(); final Vector3D vFin = finalState.getVelocity(); // Check results final PVCoordinates reference = initialState.shiftedBy(dt).getPVCoordinates(); final Vector3D pRef = reference.getPosition(); final Vector3D vRef = reference.getVelocity(); Assert.assertEquals(0, pRef.subtract(pFin).getNorm(), 2e-4); Assert.assertEquals(0, vRef.subtract(vFin).getNorm(), 7e-8); try { propagator.getGeneratedEphemeris(); Assert.fail("an exception should have been thrown"); } catch (IllegalStateException ise) { // expected } }
@Test public void testResetStateEvent() throws OrekitException { final AbsoluteDate resetDate = initDate.shiftedBy(1000); CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.RESET_STATE) { public SpacecraftState resetState(DateDetector detector, SpacecraftState oldState) { return new SpacecraftState( oldState.getOrbit(), oldState.getAttitude(), oldState.getMass() - 200.0); } }; propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking)); checking.assertEvent(false); final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(3200)); checking.assertEvent(true); Assert.assertEquals(initialState.getMass() - 200, finalState.getMass(), 1.0e-10); }
/** * check that the cache is immutable by changing the data passed in the constructor and returned * from methods. * * @throws TimeStampedCacheException */ @Test public void testImmutable() throws TimeStampedCacheException { // setup List<AbsoluteDate> actuals; List<AbsoluteDate> expecteds = new ArrayList<AbsoluteDate>(data); AbsoluteDate different = date.shiftedBy(-50); // actions + verify // check constructor data.set(0, different); Assert.assertArrayEquals(cache.getAll().toArray(), expecteds.toArray()); // check getAll actuals = cache.getAll(); try { actuals.set(0, different); } catch (UnsupportedOperationException e) { // exception ok } Assert.assertArrayEquals(cache.getAll().toArray(), expecteds.toArray()); // check getNeighbors actuals = cache.getNeighbors(date); try { actuals.set(0, different); } catch (UnsupportedOperationException e) { // exception ok } Assert.assertArrayEquals(cache.getAll().toArray(), expecteds.toArray()); }
private double[] derivativesErrors( PVCoordinatesProvider provider, AbsoluteDate date, Frame frame, OneAxisEllipsoid model) throws OrekitException { List<TimeStampedPVCoordinates> pvList = new ArrayList<TimeStampedPVCoordinates>(); List<TimeStampedPVCoordinates> groundPVList = new ArrayList<TimeStampedPVCoordinates>(); for (double dt = -0.25; dt <= 0.25; dt += 0.125) { TimeStampedPVCoordinates shiftedPV = provider.getPVCoordinates(date.shiftedBy(dt), frame); Vector3D p = model.projectToGround(shiftedPV.getPosition(), shiftedPV.getDate(), frame); pvList.add(shiftedPV); groundPVList.add( new TimeStampedPVCoordinates(shiftedPV.getDate(), p, Vector3D.ZERO, Vector3D.ZERO)); } TimeStampedPVCoordinates computed = model.projectToGround( TimeStampedPVCoordinates.interpolate(date, CartesianDerivativesFilter.USE_P, pvList), frame); TimeStampedPVCoordinates reference = TimeStampedPVCoordinates.interpolate(date, CartesianDerivativesFilter.USE_P, groundPVList); TimeStampedPVCoordinates pv0 = provider.getPVCoordinates(date, frame); Vector3D p0 = pv0.getPosition(); Vector3D v0 = pv0.getVelocity(); Vector3D a0 = pv0.getAcceleration(); return new double[] { Vector3D.distance(computed.getPosition(), reference.getPosition()) / p0.getNorm(), Vector3D.distance(computed.getVelocity(), reference.getVelocity()) / v0.getNorm(), Vector3D.distance(computed.getAcceleration(), reference.getAcceleration()) / a0.getNorm(), }; }
@Test public void testKepler() throws OrekitException { // Propagation of the initial at t + dt final double dt = 3200; final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(-60), initDate.shiftedBy(dt)); // Check results final double n = FastMath.sqrt(initialState.getMu() / initialState.getA()) / initialState.getA(); Assert.assertEquals(initialState.getA(), finalState.getA(), 1.0e-10); Assert.assertEquals(initialState.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10); Assert.assertEquals(initialState.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10); Assert.assertEquals(initialState.getHx(), finalState.getHx(), 1.0e-10); Assert.assertEquals(initialState.getHy(), finalState.getHy(), 1.0e-10); Assert.assertEquals(initialState.getLM() + n * dt, finalState.getLM(), 2.0e-9); }
@Test public void testContinueEvent() throws OrekitException { final AbsoluteDate resetDate = initDate.shiftedBy(1000); CheckingHandler<DateDetector> checking = new CheckingHandler<DateDetector>(Action.CONTINUE); propagator.addEventDetector(new DateDetector(resetDate).withHandler(checking)); final double dt = 3200; checking.assertEvent(false); final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt)); checking.assertEvent(true); final double n = FastMath.sqrt(initialState.getMu() / initialState.getA()) / initialState.getA(); Assert.assertEquals(initialState.getA(), finalState.getA(), 1.0e-10); Assert.assertEquals(initialState.getEquinoctialEx(), finalState.getEquinoctialEx(), 1.0e-10); Assert.assertEquals(initialState.getEquinoctialEy(), finalState.getEquinoctialEy(), 1.0e-10); Assert.assertEquals(initialState.getHx(), finalState.getHx(), 1.0e-10); Assert.assertEquals(initialState.getHy(), finalState.getHy(), 1.0e-10); Assert.assertEquals(initialState.getLM() + n * dt, finalState.getLM(), 6.0e-10); }
/** check propagation succeeds when two events are within the tolerance of each other. */ @Test public void testCloseEventDates() throws PropagationException { // setup DateDetector d1 = new DateDetector(10, 1, initDate.shiftedBy(15)) .withHandler(new ContinueOnEvent<DateDetector>()); DateDetector d2 = new DateDetector(10, 1, initDate.shiftedBy(15.5)) .withHandler(new ContinueOnEvent<DateDetector>()); propagator.addEventDetector(d1); propagator.addEventDetector(d2); // action AbsoluteDate end = initDate.shiftedBy(30); SpacecraftState actual = propagator.propagate(end); // verify Assert.assertEquals(actual.getDate().durationFrom(end), 0.0, 0.0); }
@Test public void testFrance() throws OrekitException { final BodyShape earth = new OneAxisEllipsoid( Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true)); GeographicZoneDetector d = new GeographicZoneDetector(20.0, 1.e-3, earth, buildFrance(), FastMath.toRadians(0.5)) .withHandler(new ContinueOnEvent<GeographicZoneDetector>()); Assert.assertEquals(20.0, d.getMaxCheckInterval(), 1.0e-15); Assert.assertEquals(1.0e-3, d.getThreshold(), 1.0e-15); Assert.assertEquals(0.5, FastMath.toDegrees(d.getMargin()), 1.0e-15); Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, d.getMaxIterationCount()); final TimeScale utc = TimeScalesFactory.getUTC(); final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257); final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922); final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc); final Orbit orbit = new EquinoctialOrbit( new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, Constants.EIGEN5C_EARTH_MU); Propagator propagator = new EcksteinHechlerPropagator( orbit, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60); EventsLogger logger = new EventsLogger(); propagator.addEventDetector(logger.monitorDetector(d)); propagator.propagate(date.shiftedBy(10 * Constants.JULIAN_DAY)); Assert.assertEquals(26, logger.getLoggedEvents().size()); }
@Test public void testEphemerisDatesBackward() throws OrekitException { // setup TimeScale tai = TimeScalesFactory.getTAI(); AbsoluteDate initialDate = new AbsoluteDate("2015-07-05", tai); AbsoluteDate startDate = new AbsoluteDate("2015-07-03", tai).shiftedBy(-0.1); AbsoluteDate endDate = new AbsoluteDate("2015-07-04", tai); Frame eci = FramesFactory.getGCRF(); KeplerianOrbit orbit = new KeplerianOrbit( 600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, initialDate, mu); double[][] tol = NumericalPropagator.tolerances(1, orbit, OrbitType.CARTESIAN); Propagator prop = new NumericalPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1])); prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit))); // action prop.setEphemerisMode(); prop.propagate(endDate, startDate); BoundedPropagator ephemeris = prop.getGeneratedEphemeris(); // verify TimeStampedPVCoordinates actualPV = ephemeris.getPVCoordinates(startDate, eci); TimeStampedPVCoordinates expectedPV = orbit.getPVCoordinates(startDate, eci); MatcherAssert.assertThat( actualPV.getPosition(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition(), 1.0)); MatcherAssert.assertThat( actualPV.getVelocity(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity(), 1.0)); MatcherAssert.assertThat( ephemeris.getMinDate().durationFrom(startDate), OrekitMatchers.closeTo(0, 0)); MatcherAssert.assertThat( ephemeris.getMaxDate().durationFrom(endDate), OrekitMatchers.closeTo(0, 0)); // test date AbsoluteDate date = endDate.shiftedBy(-0.11); Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date), 0, 0); }
/** * Approximate an already fitted model to polynomial only terms. * * <p>This method is mainly used in order to combine the large amplitude long periods with the * secular part as a new approximate polynomial model over some time range. This should be used * rather than simply extracting the polynomial coefficients from {@link #getFittedParameters()} * when some periodic terms amplitudes are large (for example Sun resonance effects on local solar * time in sun synchronous orbits). In theses cases, the pure polynomial secular part in the * coefficients may be far from the mean model. * * @param combinedDegree desired degree for the combined polynomial * @param combinedReference desired reference date for the combined polynomial * @param meanDegree degree of polynomial secular part to consider * @param meanHarmonics number of harmonics terms to consider * @param start start date of the approximation time range * @param end end date of the approximation time range * @param step sampling step * @return coefficients of the approximate polynomial (in increasing degree order), using the user * provided reference date */ public double[] approximateAsPolynomialOnly( final int combinedDegree, final AbsoluteDate combinedReference, final int meanDegree, final int meanHarmonics, final AbsoluteDate start, final AbsoluteDate end, final double step) { final List<WeightedObservedPoint> points = new ArrayList<WeightedObservedPoint>(); for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(step)) { points.add( new WeightedObservedPoint( 1.0, date.durationFrom(combinedReference), meanValue(date, meanDegree, meanHarmonics))); } return PolynomialCurveFitter.create(combinedDegree).fit(points); }
@Test(expected = OrekitException.class) public void testException() throws OrekitException { propagator.setMasterMode( new OrekitStepHandler() { private int countDown = 3; private AbsoluteDate previousCall = null; public void init(SpacecraftState s0, AbsoluteDate t) {} public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) throws PropagationException { if (previousCall != null) { Assert.assertTrue(interpolator.getInterpolatedDate().compareTo(previousCall) < 0); } if (--countDown == 0) { throw new PropagationException(LocalizedFormats.SIMPLE_MESSAGE, "dummy error"); } } }); propagator.propagate(initDate.shiftedBy(-3600)); }
@Test public void testResetAdditionalStateEvent() throws OrekitException { propagator.addAdditionalEquations( new AdditionalEquations() { public String getName() { return "linear"; } public double[] computeDerivatives(SpacecraftState s, double[] pDot) { pDot[0] = 1.0; return null; } }); propagator.setInitialState(propagator.getInitialState().addAdditionalState("linear", 1.5)); CheckingHandler<AdditionalStateLinearDetector> checking = new CheckingHandler<AdditionalStateLinearDetector>(Action.RESET_STATE) { public SpacecraftState resetState( AdditionalStateLinearDetector detector, SpacecraftState oldState) throws OrekitException { return oldState.addAdditionalState( "linear", oldState.getAdditionalState("linear")[0] * 2); } }; propagator.addEventDetector( new AdditionalStateLinearDetector(10.0, 1.0e-8).withHandler(checking)); final double dt = 3200; checking.assertEvent(false); final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt)); checking.assertEvent(true); Assert.assertEquals(dt + 4.5, finalState.getAdditionalState("linear")[0], 1.0e-8); Assert.assertEquals(dt, finalState.getDate().durationFrom(initDate), 1.0e-8); }
@Test public void testJacobianIssue18() throws OrekitException { // Body mu final double mu = 3.9860047e14; 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); 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.setAttitudeProvider(law); propagator.addForceModel(maneuver); propagator.setOrbitType(OrbitType.CARTESIAN); PartialDerivativesEquations PDE = new PartialDerivativesEquations("derivatives", propagator); PDE.selectParamAndStep("thrust", Double.NaN); Assert.assertEquals(3, PDE.getAvailableParameters().size()); Assert.assertEquals("central attraction coefficient", PDE.getAvailableParameters().get(0)); Assert.assertEquals("thrust", PDE.getAvailableParameters().get(1)); Assert.assertEquals("flow rate", PDE.getAvailableParameters().get(2)); propagator.setInitialState(PDE.setInitialJacobians(initialState, 7, 1)); final AbsoluteDate finalDate = fireDate.shiftedBy(3800); final SpacecraftState finalorb = propagator.propagate(finalDate); Assert.assertEquals(0, finalDate.durationFrom(finalorb.getDate()), 1.0e-11); }
@Test public void testEphemerisAdditionalState() throws OrekitException, IOException { // Propagation of the initial at t + dt final double dt = -3200; final double rate = 2.0; propagator.addAdditionalStateProvider( new AdditionalStateProvider() { public String getName() { return "squaredA"; } public double[] getAdditionalState(SpacecraftState state) { return new double[] {state.getA() * state.getA()}; } }); propagator.addAdditionalEquations( new AdditionalEquations() { public String getName() { return "extra"; } public double[] computeDerivatives(SpacecraftState s, double[] pDot) { pDot[0] = rate; return null; } }); propagator.setInitialState(propagator.getInitialState().addAdditionalState("extra", 1.5)); propagator.setOrbitType(OrbitType.CARTESIAN); propagator.setEphemerisMode(); propagator.propagate(initDate.shiftedBy(dt)); final BoundedPropagator ephemeris1 = propagator.getGeneratedEphemeris(); Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMinDate()); Assert.assertEquals(initDate, ephemeris1.getMaxDate()); try { ephemeris1.propagate(ephemeris1.getMinDate().shiftedBy(-10.0)); Assert.fail("an exception should have been thrown"); } catch (PropagationException pe) { Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier()); } try { ephemeris1.propagate(ephemeris1.getMaxDate().shiftedBy(+10.0)); Assert.fail("an exception should have been thrown"); } catch (PropagationException pe) { Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier()); } double shift = -60; SpacecraftState s = ephemeris1.propagate(initDate.shiftedBy(shift)); Assert.assertEquals(2, s.getAdditionalStates().size()); Assert.assertTrue(s.hasAdditionalState("squaredA")); Assert.assertTrue(s.hasAdditionalState("extra")); Assert.assertEquals(s.getA() * s.getA(), s.getAdditionalState("squaredA")[0], 1.0e-10); Assert.assertEquals(1.5 + shift * rate, s.getAdditionalState("extra")[0], 1.0e-10); try { ephemeris1.resetInitialState(s); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(OrekitMessages.NON_RESETABLE_STATE, oe.getSpecifier()); } }
@Test public void testAdditionalStateEvent() throws OrekitException { propagator.addAdditionalEquations( new AdditionalEquations() { public String getName() { return "linear"; } public double[] computeDerivatives(SpacecraftState s, double[] pDot) { pDot[0] = 1.0; return new double[7]; } }); try { propagator.addAdditionalEquations( new AdditionalEquations() { public String getName() { return "linear"; } public double[] computeDerivatives(SpacecraftState s, double[] pDot) { pDot[0] = 1.0; return new double[7]; } }); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(oe.getSpecifier(), OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE); } try { propagator.addAdditionalStateProvider( new AdditionalStateProvider() { public String getName() { return "linear"; } public double[] getAdditionalState(SpacecraftState state) { return null; } }); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(oe.getSpecifier(), OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE); } propagator.addAdditionalStateProvider( new AdditionalStateProvider() { public String getName() { return "constant"; } public double[] getAdditionalState(SpacecraftState state) { return new double[] {1.0}; } }); Assert.assertTrue(propagator.isAdditionalStateManaged("linear")); Assert.assertTrue(propagator.isAdditionalStateManaged("constant")); Assert.assertFalse(propagator.isAdditionalStateManaged("non-managed")); Assert.assertEquals(2, propagator.getManagedAdditionalStates().length); propagator.setInitialState(propagator.getInitialState().addAdditionalState("linear", 1.5)); CheckingHandler<AdditionalStateLinearDetector> checking = new CheckingHandler<AdditionalStateLinearDetector>(Action.STOP); propagator.addEventDetector( new AdditionalStateLinearDetector(10.0, 1.0e-8).withHandler(checking)); final double dt = 3200; checking.assertEvent(false); final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt)); checking.assertEvent(true); Assert.assertEquals(3.0, finalState.getAdditionalState("linear")[0], 1.0e-8); Assert.assertEquals(1.5, finalState.getDate().durationFrom(initDate), 1.0e-8); }