use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.
the class SolarRadiationPressureTest method testRoughOrbitalModifs.
@Test
public void testRoughOrbitalModifs() throws ParseException, OrekitException, FileNotFoundException {
// initialization
AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 7, 1), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC());
Orbit orbit = new EquinoctialOrbit(42164000, 10e-3, 10e-3, FastMath.tan(0.001745329) * FastMath.cos(2 * FastMath.PI / 3), FastMath.tan(0.001745329) * FastMath.sin(2 * FastMath.PI / 3), 0.1, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
final double period = orbit.getKeplerianPeriod();
Assert.assertEquals(86164, period, 1);
PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
// creation of the force model
OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.46, 1.0 / 298.25765, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
SolarRadiationPressure SRP = new SolarRadiationPressure(sun, earth.getEquatorialRadius(), new IsotropicRadiationCNES95Convention(500.0, 0.7, 0.7));
// creation of the propagator
double[] absTolerance = { 0.1, 1.0e-9, 1.0e-9, 1.0e-5, 1.0e-5, 1.0e-5, 0.001 };
double[] relTolerance = { 1.0e-4, 1.0e-4, 1.0e-4, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-7 };
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(900.0, 60000, absTolerance, relTolerance);
integrator.setInitialStepSize(3600);
final NumericalPropagator calc = new NumericalPropagator(integrator);
calc.addForceModel(SRP);
// Step Handler
calc.setMasterMode(FastMath.floor(period), new SolarStepHandler());
AbsoluteDate finalDate = date.shiftedBy(10 * period);
calc.setInitialState(new SpacecraftState(orbit, 1500.0));
calc.propagate(finalDate);
Assert.assertTrue(calc.getCalls() < 7100);
}
use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.
the class TidalDisplacementTest method doTestDehant.
private void doTestDehant(final IERSConventions conventions, final boolean removePermanentDeformation, final boolean replaceModels, final double expectedDx, final double expectedDy, final double expectedDz, final double tolerance) throws OrekitException {
Frame itrf = FramesFactory.getITRF(conventions, false);
TimeScale ut1 = TimeScalesFactory.getUT1(conventions, false);
final double re;
final double sunEarthSystemMassRatio;
final double earthMoonMassRatio;
if (replaceModels) {
// constants consistent with DEHANTTIDEINEL.F reference program
// available at <ftp://tai.bipm.org/iers/conv2010/chapter7/dehanttideinel/>
// and Copyright (C) 2008 IERS Conventions Center
re = 6378136.6;
final double massRatioSun = 332946.0482;
final double massRatioMoon = 0.0123000371;
sunEarthSystemMassRatio = massRatioSun * (1.0 / (1.0 + massRatioMoon));
earthMoonMassRatio = 1.0 / massRatioMoon;
} else {
// constants consistent with IERS and JPL
re = Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS;
sunEarthSystemMassRatio = Constants.JPL_SSD_SUN_EARTH_PLUS_MOON_MASS_RATIO;
earthMoonMassRatio = Constants.JPL_SSD_EARTH_MOON_MASS_RATIO;
}
// fake providers generating only the positions from the reference program test
PVCoordinatesProvider fakeSun = (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(137859926952.015, 54228127881.435, 23509422341.6960), Vector3D.ZERO, Vector3D.ZERO);
PVCoordinatesProvider fakeMoon = (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(-179996231.920342, -312468450.131567, -169288918.592160), Vector3D.ZERO, Vector3D.ZERO);
TidalDisplacement td = new TidalDisplacement(re, sunEarthSystemMassRatio, earthMoonMassRatio, fakeSun, fakeMoon, conventions, removePermanentDeformation);
FundamentalNutationArguments arguments = null;
if (replaceModels) {
try {
// we override the official IERS conventions 2010 arguments with fake arguments matching DEHANTTIDEINEL.F code
String regularArguments = "/assets/org/orekit/IERS-conventions/2010/nutation-arguments.txt";
arguments = new FundamentalNutationArguments(conventions, ut1, IERSConventions.class.getResourceAsStream(regularArguments), regularArguments) {
private static final long serialVersionUID = 20170913L;
@Override
public BodiesElements evaluateAll(final AbsoluteDate date) {
BodiesElements base = super.evaluateAll(date);
double fhr = date.getComponents(ut1).getTime().getSecondsInUTCDay() / 3600.0;
double t = base.getTC();
// Doodson fundamental arguments as per DEHANTTIDEINEL.F code
double s = 218.31664563 + (481267.88194 + (-0.0014663889 + (0.00000185139) * t) * t) * t;
double tau = fhr * 15 + 280.4606184 + (36000.7700536 + (0.00038793 + (-0.0000000258) * t) * t) * t - s;
double pr = (1.396971278 + (0.000308889 + (0.000000021 + (0.000000007) * t) * t) * t) * t;
double h = 280.46645 + (36000.7697489 + (0.00030322222 + (0.000000020 + (-0.00000000654) * t) * t) * t) * t;
double p = 83.35324312 + (4069.01363525 + (-0.01032172222 + (-0.0000124991 + (0.00000005263) * t) * t) * t) * t;
double zns = 234.95544499 + (1934.13626197 + (-0.00207561111 + (-0.00000213944 + (0.00000001650) * t) * t) * t) * t;
double ps = 282.93734098 + (1.71945766667 + (0.00045688889 + (-0.00000001778 + (-0.00000000334) * t) * t) * t) * t;
s += pr;
// rebuild Delaunay arguments from Doodson arguments, ignoring derivatives
return new BodiesElements(date, base.getTC(), FastMath.toRadians(s + tau), 0.0, FastMath.toRadians(s - p), 0.0, FastMath.toRadians(h - ps), 0.0, FastMath.toRadians(s + zns), 0.0, FastMath.toRadians(s - h), 0.0, FastMath.toRadians(-zns), 0.0, base.getLMe(), 0.0, base.getLVe(), 0.0, base.getLE(), 0.0, base.getLMa(), 0.0, base.getLJu(), 0.0, base.getLSa(), 0.0, base.getLUr(), 0.0, base.getLNe(), 0.0, base.getPa(), 0.0);
}
};
// we override the official IERS conventions 2010 tides displacements with tides displacements matching DEHANTTIDEINEL.F code
String table73a = "/tides/tab7.3a-Dehant.txt";
Field diurnalCorrectionField = td.getClass().getDeclaredField("frequencyCorrectionDiurnal");
diurnalCorrectionField.setAccessible(true);
Method diurnalCorrectionGetter = IERSConventions.class.getDeclaredMethod("getTidalDisplacementFrequencyCorrectionDiurnal", String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
diurnalCorrectionGetter.setAccessible(true);
diurnalCorrectionField.set(td, diurnalCorrectionGetter.invoke(null, table73a, 18, 15, 16, 17, 18));
} catch (SecurityException | NoSuchMethodException | NoSuchFieldException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
Assert.fail(e.getLocalizedMessage());
}
} else {
arguments = conventions.getNutationArguments(ut1);
}
Vector3D fundamentalStationWettzell = new Vector3D(4075578.385, 931852.890, 4801570.154);
AbsoluteDate date = new AbsoluteDate(2009, 4, 13, 0, 0, 0.0, ut1);
Vector3D displacement = td.displacement(arguments.evaluateAll(date), itrf, fundamentalStationWettzell);
Assert.assertEquals(expectedDx, displacement.getX(), tolerance);
Assert.assertEquals(expectedDy, displacement.getY(), tolerance);
Assert.assertEquals(expectedDz, displacement.getZ(), tolerance);
}
use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method wrongAttitude.
@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
AttitudeProvider wrongLaw = new AttitudeProvider() {
private static final long serialVersionUID = 5918362126173997016L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
}
};
EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, wrongLaw, provider);
propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method doTestWrappedAttitudeException.
private <T extends RealFieldElement<T>> void doTestWrappedAttitudeException(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7.8e6), zero.add(0.032), zero.add(0.4), zero.add(0.1), zero.add(0.2), zero.add(0.3), PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, new AttitudeProvider() {
private static final long serialVersionUID = 1L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
});
propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
use of org.orekit.utils.PVCoordinatesProvider in project Orekit by CS-SI.
the class FieldOfViewDetectorTest method testDihedralFielOfView.
@Test
public void testDihedralFielOfView() throws OrekitException {
// Definition of initial conditions with position and velocity
// ------------------------------------------------------------
// Extrapolator definition
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, earthCenterAttitudeLaw);
// Event definition : square field of view, along X axis, aperture 56°
final double maxCheck = 1.;
final PVCoordinatesProvider sunPV = CelestialBodyFactory.getSun();
final Vector3D center = Vector3D.MINUS_J;
final Vector3D axis1 = Vector3D.PLUS_K;
final Vector3D axis2 = Vector3D.PLUS_I;
final double aperture1 = FastMath.toRadians(28);
final double aperture2 = FastMath.toRadians(28);
final EventDetector sunVisi = new FieldOfViewDetector(sunPV, new FieldOfView(center, axis1, aperture1, axis2, aperture2, 0.0)).withMaxCheck(maxCheck).withHandler(new DihedralSunVisiHandler());
Assert.assertSame(sunPV, ((FieldOfViewDetector) sunVisi).getPVTarget());
Assert.assertEquals(0, ((FieldOfViewDetector) sunVisi).getFieldOfView().getMargin(), 1.0e-15);
double eta = FastMath.acos(FastMath.sin(aperture1) * FastMath.sin(aperture2));
double theoreticalArea = MathUtils.TWO_PI - 4 * eta;
Assert.assertEquals(theoreticalArea, ((FieldOfViewDetector) sunVisi).getFieldOfView().getZone().getSize(), 1.0e-15);
// Add event to be detected
propagator.addEventDetector(sunVisi);
// Extrapolate from the initial to the final date
propagator.propagate(initDate.shiftedBy(6000.));
}
Aggregations