use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.
the class FiniteDifferencePropagatorConverterTest method testGetObjectiveFunctionParametersOnlyScaledOnce.
/**
* Test case for bug #362. Check that scaling is only applied once.
*
* @throws OrekitException on error.
*/
@Test
public void testGetObjectiveFunctionParametersOnlyScaledOnce() throws OrekitException {
// setup
// create some arbitrary sample data to run with
Frame eci = FramesFactory.getGCRF();
double gm = Constants.EIGEN5C_EARTH_MU;
AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
Propagator source = new KeplerianPropagator(new KeplerianOrbit(6878137, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, date, gm));
// Create a mock builder that allows us to check the values passed to it
PropagatorBuilder builder = Mockito.mock(PropagatorBuilder.class);
ParameterDriversList list = new ParameterDriversList();
list.add(new ParameterDriver("p1", 0, 1e-3, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
Mockito.when(builder.getOrbitalParametersDrivers()).thenReturn(list);
Mockito.when(builder.getPropagationParametersDrivers()).thenReturn(new ParameterDriversList());
Mockito.when(builder.getFrame()).thenReturn(eci);
Mockito.when(builder.getSelectedNormalizedParameters()).thenReturn(new double[1]);
Mockito.when(builder.buildPropagator(Mockito.any(double[].class))).thenReturn(source);
// subject under test
FiniteDifferencePropagatorConverter converter = new FiniteDifferencePropagatorConverter(builder, 1, 100);
// set some internal variables in FDPC that are not settable using another
// interface
converter.convert(source, 1, 2);
// Forget all the side effect of the call to convert()
Mockito.clearInvocations(builder);
// action
converter.getModel().value(new ArrayRealVector(1));
// verify
Mockito.verify(builder).buildPropagator(new double[] { 0 });
Mockito.verify(builder).buildPropagator(new double[] { 1 });
}
use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testEventCausedByStateReset.
/**
* Test a reset event triggering another event at the same time.
*/
@Test
public void testEventCausedByStateReset() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-6;
double t1 = 15.0;
SpacecraftState newState = new SpacecraftState(new KeplerianOrbit(6378137 + 500e3, 0, FastMath.PI / 2, 0, 0, FastMath.PI / 2, PositionAngle.TRUE, eci, epoch.shiftedBy(t1), mu));
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
TimeDetector detectorA = new TimeDetector(t1).withHandler(new Handler<EventDetector>(events, Action.RESET_STATE) {
@Override
public SpacecraftState resetState(EventDetector detector, SpacecraftState oldState) {
return newState;
}
}).withMaxCheck(maxCheck).withThreshold(tolerance);
LatitudeCrossingDetector detectorB = new LatitudeCrossingDetector(earth, FastMath.toRadians(80)).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
propagator.addEventDetector(detectorB);
// action
propagator.propagate(epoch.shiftedBy(40.0));
// verify
// really we only care that the Rules of Event Handling are not violated,
Assert.assertEquals(2, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertEquals(detectorA, events.get(0).getDetector());
Assert.assertEquals(t1, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(1).isIncreasing());
Assert.assertEquals(detectorB, events.get(1).getDetector());
}
use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.
the class CloseEventsAbstractTest method testEventCausedByStateResetReverse.
/**
* Test a reset event triggering another event at the same time.
*/
@Test
public void testEventCausedByStateResetReverse() throws OrekitException {
// setup
double maxCheck = 10;
double tolerance = 1e-6;
double t1 = -15.0;
SpacecraftState newState = new SpacecraftState(new KeplerianOrbit(6378137 + 500e3, 0, FastMath.PI / 2, 0, 0, FastMath.PI / 2, PositionAngle.TRUE, eci, epoch.shiftedBy(t1), mu));
// shared event list so we know the order in which they occurred
List<Event<EventDetector>> events = new ArrayList<>();
TimeDetector detectorA = new TimeDetector(t1).withHandler(new Handler<EventDetector>(events, Action.RESET_STATE) {
@Override
public SpacecraftState resetState(EventDetector detector, SpacecraftState oldState) {
return newState;
}
}).withMaxCheck(maxCheck).withThreshold(tolerance);
LatitudeCrossingDetector detectorB = new LatitudeCrossingDetector(earth, FastMath.toRadians(80)).withHandler(new RecordAndContinue<>(events)).withMaxCheck(maxCheck).withThreshold(tolerance);
Propagator propagator = getPropagator(10);
propagator.addEventDetector(detectorA);
propagator.addEventDetector(detectorB);
// action
propagator.propagate(epoch.shiftedBy(-40.0));
// verify
// really we only care that the Rules of Event Handling are not violated,
Assert.assertEquals(2, events.size());
Assert.assertEquals(t1, events.get(0).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(true, events.get(0).isIncreasing());
Assert.assertEquals(detectorA, events.get(0).getDetector());
Assert.assertEquals(t1, events.get(1).getState().getDate().durationFrom(epoch), tolerance);
Assert.assertEquals(false, events.get(1).isIncreasing());
Assert.assertEquals(detectorB, events.get(1).getDetector());
}
use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.
the class ElevationDetectorTest method testIssue110.
@Test
public void testIssue110() throws OrekitException {
// KEPLERIAN PROPAGATOR
final Frame eme2000Frame = FramesFactory.getEME2000();
final AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH;
final double a = 7000000.0;
final Orbit initialOrbit = new KeplerianOrbit(a, 0.0, FastMath.PI / 2.2, 0.0, FastMath.PI / 2., 0.0, PositionAngle.TRUE, eme2000Frame, initDate, Constants.EGM96_EARTH_MU);
final KeplerianPropagator kProp = new KeplerianPropagator(initialOrbit);
// earth shape
final OneAxisEllipsoid earthShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
// Ground station
final GeodeticPoint stat = new GeodeticPoint(FastMath.toRadians(35.), FastMath.toRadians(149.8), 0.);
final TopocentricFrame station = new TopocentricFrame(earthShape, stat, "GSTATION");
// detector creation
// =================
final double maxCheck = 600.;
final double threshold = 1.0e-3;
final EventDetector rawEvent = new ElevationDetector(maxCheck, threshold, station).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<ElevationDetector>());
final EventsLogger logger = new EventsLogger();
kProp.addEventDetector(logger.monitorDetector(rawEvent));
// PROPAGATION with DETECTION
final AbsoluteDate finalDate = initDate.shiftedBy(30 * 60.);
kProp.propagate(finalDate);
Assert.assertEquals(2, logger.getLoggedEvents().size());
Assert.assertTrue(logger.getLoggedEvents().get(0).isIncreasing());
Assert.assertEquals(478.945, logger.getLoggedEvents().get(0).getState().getDate().durationFrom(initDate), 1.0e-3);
Assert.assertFalse(logger.getLoggedEvents().get(1).isIncreasing());
Assert.assertEquals(665.721, logger.getLoggedEvents().get(1).getState().getDate().durationFrom(initDate), 1.0e-3);
}
use of org.orekit.orbits.KeplerianOrbit in project Orekit by CS-SI.
the class ElevationDetectorTest method testIssue136.
@Test
public void testIssue136() throws OrekitException {
// Initial state definition : date, orbit
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
// inertial frame for orbit definition
Frame inertialFrame = FramesFactory.getEME2000();
Orbit initialOrbit = new KeplerianOrbit(6828137.005, 7.322641382145889e-10, 1.6967079057368113, 0.0, 1.658054062748353, 0.0001223149429077902, PositionAngle.MEAN, inertialFrame, initialDate, Constants.EIGEN5C_EARTH_MU);
// Propagator : consider a simple Keplerian motion (could be more elaborate)
Propagator kepler = new EcksteinHechlerPropagator(initialOrbit, Constants.EGM96_EARTH_EQUATORIAL_RADIUS, Constants.EGM96_EARTH_MU, Constants.EGM96_EARTH_C20, 0.0, 0.0, 0.0, 0.0);
// Earth and frame
// equatorial radius in meter
double ae = 6378137.0;
// flattening
double f = 1.0 / 298.257223563;
// terrestrial frame at an arbitrary date
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
// Station
final double longitude = FastMath.toRadians(-147.5);
final double latitude = FastMath.toRadians(64);
final double altitude = 160;
final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
// Event definition
final double maxcheck = 120.0;
final double elevation = FastMath.toRadians(5.);
final double threshold = 10.0;
final EventDetector rawEvent = new ElevationDetector(maxcheck, threshold, sta1Frame).withConstantElevation(elevation).withHandler(new ContinueOnEvent<ElevationDetector>());
final EventsLogger logger = new EventsLogger();
kepler.addEventDetector(logger.monitorDetector(rawEvent));
// Propagate from the initial date to the first raising or for the fixed duration
kepler.propagate(initialDate.shiftedBy(60 * 60 * 24.0 * 40));
int countIncreasing = 0;
int countDecreasing = 0;
for (LoggedEvent le : logger.getLoggedEvents()) {
if (le.isIncreasing()) {
++countIncreasing;
} else {
++countDecreasing;
}
}
Assert.assertEquals(314, countIncreasing);
Assert.assertEquals(314, countDecreasing);
}
Aggregations