use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class FieldNumericalPropagatorTest method doTestEventDetectionBug.
private <T extends RealFieldElement<T>> void doTestEventDetectionBug(final Field<T> field) throws OrekitException {
T zero = field.getZero();
TimeScale utc = TimeScalesFactory.getUTC();
FieldAbsoluteDate<T> initialDate = new FieldAbsoluteDate<>(field, 2005, 1, 1, 0, 0, 0.0, utc);
T duration = zero.add(100000.0);
FieldAbsoluteDate<T> endDate = new FieldAbsoluteDate<>(initialDate, duration);
// Initialization of the frame EME2000
Frame EME2000 = FramesFactory.getEME2000();
// Initial orbit
double a = 35786000. + 6378137.0;
double e = 0.70;
double rApogee = a * (1 + e);
double vApogee = FastMath.sqrt(mu * (1 - e) / (a * (1 + e)));
FieldOrbit<T> geo = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(zero.add(rApogee), zero, zero), new FieldVector3D<>(zero, zero.add(vApogee), zero)), EME2000, initialDate, mu);
duration = geo.getKeplerianPeriod();
endDate = new FieldAbsoluteDate<>(initialDate, duration);
// Numerical Integration
final double minStep = 0.001;
final double maxStep = 1000;
final double initStep = 60;
final OrbitType type = OrbitType.EQUINOCTIAL;
final double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
final double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, minStep, maxStep, absTolerance, relTolerance);
integrator.setInitialStepSize(zero.add(initStep));
// Numerical propagator based on the integrator
FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(type);
T mass = field.getZero().add(1000.0);
FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(geo, mass);
propagator.setInitialState(initialState);
propagator.setOrbitType(OrbitType.CARTESIAN);
// Set the events Detectors
FieldApsideDetector<T> event1 = new FieldApsideDetector<>(geo);
propagator.addEventDetector(event1);
// Set the propagation mode
propagator.setSlaveMode();
// Propagate
FieldSpacecraftState<T> finalState = propagator.propagate(endDate);
// we should stop long before endDate
Assert.assertTrue(endDate.durationFrom(finalState.getDate()).getReal() > 40000.0);
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class ElevationDetectorTest method testPresTemp.
public void testPresTemp() throws OrekitException {
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, mu);
Propagator propagator = new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
// 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);
GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833), FastMath.toRadians(2.333), 0.0);
TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
EarthStandardAtmosphereRefraction refractionModel = new EarthStandardAtmosphereRefraction();
ElevationDetector detector = new ElevationDetector(topo).withRefraction(refractionModel).withHandler(new StopOnIncreasing<ElevationDetector>());
refractionModel.setPressure(101325);
refractionModel.setTemperature(290);
AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 20, 0, 0, utc);
propagator.resetInitialState(propagator.propagate(startDate));
propagator.addEventDetector(detector);
final SpacecraftState fs = propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
double elevation = topo.getElevation(fs.getPVCoordinates().getPosition(), fs.getFrame(), fs.getDate());
Assert.assertEquals(FastMath.toRadians(1.7026104902251749), elevation, 2.0e-5);
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class ElevationDetectorTest method testAgata.
@Test
public void testAgata() throws OrekitException {
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, mu);
Propagator propagator = new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
// 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);
GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833), FastMath.toRadians(2.333), 0.0);
TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
Checking checking = new Checking(topo);
ElevationDetector detector = new ElevationDetector(topo).withConstantElevation(FastMath.toRadians(5.0)).withHandler(checking);
Assert.assertNull(detector.getElevationMask());
Assert.assertNull(detector.getRefractionModel());
Assert.assertSame(topo, detector.getTopocentricFrame());
Assert.assertEquals(FastMath.toRadians(5.0), detector.getMinElevation(), 1.0e-15);
AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 12, 0, 0, utc);
propagator.resetInitialState(propagator.propagate(startDate));
propagator.addEventDetector(detector);
propagator.setMasterMode(10.0, checking);
propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class ElevationDetectorTest method testHorizon.
@Test
public void testHorizon() throws OrekitException {
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, mu);
Propagator propagator = new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
// 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);
GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833), FastMath.toRadians(2.333), 0.0);
TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
AtmosphericRefractionModel refractionModel = new EarthStandardAtmosphereRefraction();
ElevationDetector detector = new ElevationDetector(topo).withRefraction(refractionModel).withHandler(new StopOnIncreasing<ElevationDetector>());
Assert.assertSame(refractionModel, detector.getRefractionModel());
AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 20, 0, 0, utc);
propagator.resetInitialState(propagator.propagate(startDate));
propagator.addEventDetector(detector);
final SpacecraftState fs = propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
double elevation = topo.getElevation(fs.getPVCoordinates().getPosition(), fs.getFrame(), fs.getDate());
Assert.assertEquals(FastMath.toRadians(-0.5746255623877098), elevation, 2.0e-5);
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class EventDetectorTest method testIssue108Analytical.
@Test
public void testIssue108Analytical() throws OrekitException {
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 CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
final double step = 60.0;
final int n = 100;
KeplerianPropagator propagator = new KeplerianPropagator(orbit);
GCallsCounter counter = new GCallsCounter(100000.0, 1.0e-6, 20, new StopOnEvent<GCallsCounter>());
propagator.addEventDetector(counter);
propagator.setMasterMode(step, new OrekitFixedStepHandler() {
public void handleStep(SpacecraftState currentState, boolean isLast) {
}
});
propagator.propagate(date.shiftedBy(n * step));
Assert.assertEquals(n + 1, counter.getCount());
}
Aggregations