use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class NRLMSISE00Test method getFieldOutputDensity.
private double getFieldOutputDensity(Object o, int index) {
try {
Method getDensity = getFieldOutputClass().getDeclaredMethod("getDensity", Integer.TYPE);
getDensity.setAccessible(true);
return ((RealFieldElement<?>) getDensity.invoke(o, index)).getReal();
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
Assert.fail(e.getLocalizedMessage());
return Double.NaN;
}
}
use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class EstimationTestUtils method geoStationnaryContext.
public static Context geoStationnaryContext(final String dataRoot) throws OrekitException {
Utils.setDataRoot(dataRoot);
Context context = new Context();
context.conventions = IERSConventions.IERS_2010;
context.utc = TimeScalesFactory.getUTC();
context.ut1 = TimeScalesFactory.getUT1(context.conventions, true);
context.displacements = new StationDisplacement[0];
String Myframename = "MyEarthFrame";
final AbsoluteDate datedef = new AbsoluteDate(2000, 1, 1, 12, 0, 0.0, context.utc);
final double omega = Constants.WGS84_EARTH_ANGULAR_VELOCITY;
final Vector3D rotationRate = new Vector3D(0.0, 0.0, omega);
TransformProvider MyEarthFrame = new TransformProvider() {
private static final long serialVersionUID = 1L;
public Transform getTransform(final AbsoluteDate date) {
final double rotationduration = date.durationFrom(datedef);
final Vector3D alpharot = new Vector3D(rotationduration, rotationRate);
final Rotation rotation = new Rotation(Vector3D.PLUS_K, -alpharot.getZ(), RotationConvention.VECTOR_OPERATOR);
return new Transform(date, rotation, rotationRate);
}
public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
final T rotationduration = date.durationFrom(datedef);
final FieldVector3D<T> alpharot = new FieldVector3D<>(rotationduration, rotationRate);
final FieldRotation<T> rotation = new FieldRotation<>(FieldVector3D.getPlusK(date.getField()), alpharot.getZ().negate(), RotationConvention.VECTOR_OPERATOR);
return new FieldTransform<>(date, rotation, new FieldVector3D<>(date.getField(), rotationRate));
}
};
Frame FrameTest = new Frame(FramesFactory.getEME2000(), MyEarthFrame, Myframename, true);
// Earth is spherical, rotating in one sidereal day
context.earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0.0, FrameTest);
context.sun = CelestialBodyFactory.getSun();
context.moon = CelestialBodyFactory.getMoon();
context.radiationSensitive = new IsotropicRadiationClassicalConvention(2.0, 0.2, 0.8);
context.dragSensitive = new IsotropicDrag(2.0, 1.2);
GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
AstronomicalAmplitudeReader aaReader = new AstronomicalAmplitudeReader("hf-fes2004.dat", 5, 2, 3, 1.0);
DataProvidersManager.getInstance().feed(aaReader.getSupportedNames(), aaReader);
Map<Integer, Double> map = aaReader.getAstronomicalAmplitudesMap();
GravityFieldFactory.addOceanTidesReader(new FESCHatEpsilonReader("fes2004-7x7.dat", 0.01, FastMath.toRadians(1.0), OceanLoadDeformationCoefficients.IERS_2010, map));
context.gravity = GravityFieldFactory.getNormalizedProvider(20, 20);
// semimajor axis for a geostationnary satellite
double da = FastMath.cbrt(context.gravity.getMu() / (omega * omega));
// context.stations = Arrays.asList(context.createStation( 0.0, 0.0, 0.0, "Lat0_Long0"),
// context.createStation( 62.29639, -7.01250, 880.0, "Slættaratindur")
// );
context.stations = Arrays.asList(context.createStation(0.0, 0.0, 0.0, "Lat0_Long0"));
// Station position & velocity in EME2000
final Vector3D geovelocity = new Vector3D(0., 0., 0.);
// Compute the frames transformation from station frame to EME2000
Transform topoToEME = context.stations.get(0).getBaseFrame().getTransformTo(FramesFactory.getEME2000(), new AbsoluteDate(2000, 1, 1, 12, 0, 0.0, context.utc));
// Station position in EME2000 at reference date
Vector3D stationPositionEME = topoToEME.transformPosition(Vector3D.ZERO);
// Satellite position and velocity in Station Frame
final Vector3D sat_pos = new Vector3D(0., 0., da - stationPositionEME.getNorm());
final Vector3D acceleration = new Vector3D(-context.gravity.getMu(), sat_pos);
final PVCoordinates pv_sat_topo = new PVCoordinates(sat_pos, geovelocity, acceleration);
// satellite position in EME2000
final PVCoordinates pv_sat_iner = topoToEME.transformPVCoordinates(pv_sat_topo);
// Geo-stationary Satellite Orbit, tightly above the station (l0-L0)
context.initialOrbit = new KeplerianOrbit(pv_sat_iner, FramesFactory.getEME2000(), new AbsoluteDate(2000, 1, 1, 12, 0, 0.0, context.utc), context.gravity.getMu());
context.stations = Arrays.asList(context.createStation(10.0, 45.0, 0.0, "Lat10_Long45"));
// Turn-around range stations
// Map entry = master station
// Map value = slave station associated
context.TARstations = new HashMap<GroundStation, GroundStation>();
context.TARstations.put(context.createStation(41.977, 13.600, 671.354, "Fucino"), context.createStation(43.604, 1.444, 263.0, "Toulouse"));
context.TARstations.put(context.createStation(49.867, 8.65, 144.0, "Darmstadt"), context.createStation(-25.885, 27.707, 1566.633, "Pretoria"));
return context;
}
use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class Geoid method getIntersectionPoint.
/**
* {@inheritDoc}
*
* <p> The intersection point is computed using a line search along the
* specified line. This is accurate when the geoid is slowly varying.
*/
@Override
public <T extends RealFieldElement<T>> FieldGeodeticPoint<T> getIntersectionPoint(final FieldLine<T> lineInFrame, final FieldVector3D<T> closeInFrame, final Frame frame, final FieldAbsoluteDate<T> date) throws OrekitException {
final Field<T> field = date.getField();
/*
* It is assumed that the geoid is slowly varying over it's entire
* surface. Therefore there will one local intersection.
*/
// transform to body frame
final Frame bodyFrame = this.getBodyFrame();
final FieldTransform<T> frameToBody = frame.getTransformTo(bodyFrame, date);
final FieldVector3D<T> close = frameToBody.transformPosition(closeInFrame);
final FieldLine<T> lineInBodyFrame = frameToBody.transformLine(lineInFrame);
// set the line's direction so the solved for value is always positive
final FieldLine<T> line;
if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
line = lineInBodyFrame.revert();
} else {
line = lineInBodyFrame;
}
final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
// calculate end points
// distance from line to center of earth, squared
final T d2 = line.pointAt(0.0).getNormSq();
// the minimum abscissa, squared
final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
final T minAbscissa2 = d2.negate().add(n * n);
// smaller end point of the interval = 0.0 or intersection with
// min_undulation sphere
final T lowPoint = minAbscissa2.getReal() < 0 ? field.getZero() : minAbscissa2.sqrt();
// the maximum abscissa, squared
final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
final T maxAbscissa2 = d2.negate().add(x * x);
// larger end point of the interval
final T highPoint = maxAbscissa2.sqrt();
// line search function
final RealFieldUnivariateFunction<T> heightFunction = z -> {
try {
final FieldGeodeticPoint<T> geodetic = transform(line.pointAt(z), bodyFrame, date);
return geodetic.getAltitude();
} catch (OrekitException e) {
// due to frame transform -> re-throw
throw new RuntimeException(e);
}
};
// compute answer
if (maxAbscissa2.getReal() < 0) {
// ray does not pierce bounding sphere -> no possible intersection
return null;
}
// solve line search problem to find the intersection
final FieldBracketingNthOrderBrentSolver<T> solver = new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(1.0e-14), field.getZero().add(1.0e-6), field.getZero().add(1.0e-15), 5);
try {
final T abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint, AllowedSolution.ANY_SIDE);
// return intersection point
return this.transform(line.pointAt(abscissa), bodyFrame, date);
} catch (MathRuntimeException e) {
// no intersection
return null;
}
}
use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class SolidTidesFieldTest method testK1Example.
@Test
public void testK1Example() throws OrekitException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
// the reference for this test is the example at the bottom of page 86, IERS conventions 2010 section 6.2.1
final PoissonSeriesParser k21Parser = new PoissonSeriesParser(18).withOptionalColumn(1).withDoodson(4, 3).withFirstDelaunay(10);
final String name = "/tides/tab6.5a-only-K1.txt";
final double pico = 1.0e-12;
final PoissonSeries c21Series = k21Parser.withSinCos(0, 17, pico, 18, pico).parse(getClass().getResourceAsStream(name), name);
final PoissonSeries s21Series = k21Parser.withSinCos(0, 18, -pico, 17, pico).parse(getClass().getResourceAsStream(name), name);
final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, false);
final TimeScalarFunction gmstFunction = IERSConventions.IERS_2010.getGMSTFunction(ut1);
Method getNA = IERSConventions.class.getDeclaredMethod("getNutationArguments", TimeScale.class);
getNA.setAccessible(true);
final FundamentalNutationArguments arguments = (FundamentalNutationArguments) getNA.invoke(IERSConventions.IERS_2010, ut1);
TimeVectorFunction deltaCSFunction = new TimeVectorFunction() {
public double[] value(final AbsoluteDate date) {
final BodiesElements elements = arguments.evaluateAll(date);
return new double[] { 0.0, c21Series.value(elements), s21Series.value(elements), 0.0, 0.0 };
}
public <T extends RealFieldElement<T>> T[] value(final FieldAbsoluteDate<T> date) {
// never called in this test
throw new OrekitInternalError(null);
}
};
SolidTidesField tf = new SolidTidesField(IERSConventions.IERS_2010.getLoveNumbers(), deltaCSFunction, IERSConventions.IERS_2010.getPermanentTide(), IERSConventions.IERS_2010.getSolidPoleTide(ut1.getEOPHistory()), FramesFactory.getITRF(IERSConventions.IERS_2010, false), Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, TideSystem.ZERO_TIDE, CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon());
Method frequencyDependentPart = SolidTidesField.class.getDeclaredMethod("frequencyDependentPart", AbsoluteDate.class, double[][].class, double[][].class);
frequencyDependentPart.setAccessible(true);
double[][] cachedCNM = new double[5][5];
double[][] cachedSNM = new double[5][5];
AbsoluteDate t0 = new AbsoluteDate(2003, 5, 6, 13, 43, 32.125, TimeScalesFactory.getUTC());
for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 300) {
AbsoluteDate date = t0.shiftedBy(dt);
for (int i = 0; i < cachedCNM.length; ++i) {
Arrays.fill(cachedCNM[i], 0.0);
Arrays.fill(cachedSNM[i], 0.0);
}
frequencyDependentPart.invoke(tf, date, cachedCNM, cachedSNM);
double thetaPlusPi = gmstFunction.value(date) + FastMath.PI;
Assert.assertEquals(470.9e-12 * FastMath.sin(thetaPlusPi) - 30.2e-12 * FastMath.cos(thetaPlusPi), cachedCNM[2][1], 2.0e-25);
Assert.assertEquals(470.9e-12 * FastMath.cos(thetaPlusPi) + 30.2e-12 * FastMath.sin(thetaPlusPi), cachedSNM[2][1], 2.0e-25);
}
}
use of org.hipparchus.RealFieldElement in project Orekit by CS-SI.
the class FieldCircularOrbitTest method doTestNonKeplerianDerivatives.
private <T extends RealFieldElement<T>> void doTestNonKeplerianDerivatives(Field<T> field) throws OrekitException {
final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, "2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
final FieldVector3D<T> position = new FieldVector3D<>(field.getZero().add(6896874.444705), field.getZero().add(1956581.072644), field.getZero().add(-147476.245054));
final FieldVector3D<T> velocity = new FieldVector3D<>(field.getZero().add(166.816407662), field.getZero().add(-1106.783301861), field.getZero().add(-7372.745712770));
final FieldVector3D<T> acceleration = new FieldVector3D<>(field.getZero().add(-7.466182457944), field.getZero().add(-2.118153357345), field.getZero().add(0.160004048437));
final TimeStampedFieldPVCoordinates<T> pv = new TimeStampedFieldPVCoordinates<>(date, position, velocity, acceleration);
final Frame frame = FramesFactory.getEME2000();
final double mu = Constants.EIGEN5C_EARTH_MU;
final FieldCircularOrbit<T> orbit = new FieldCircularOrbit<>(pv, frame, mu);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot().getReal(), 4.3e-8);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot().getReal(), 2.1e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot().getReal(), 5.4e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot().getReal(), 1.6e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot().getReal(), 7.3e-17);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot().getReal(), 3.4e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot().getReal(), 3.5e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot().getReal(), 5.3e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot().getReal(), 6.8e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot().getReal(), 5.7e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getCircularEx()), orbit.getCircularExDot().getReal(), 2.2e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getCircularEy()), orbit.getCircularEyDot().getReal(), 5.3e-17);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaV()), orbit.getAlphaVDot().getReal(), 4.3e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaE()), orbit.getAlphaEDot().getReal(), 1.2e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlphaM()), orbit.getAlphaMDot().getReal(), 3.7e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.TRUE)), orbit.getAlphaDot(PositionAngle.TRUE).getReal(), 4.3e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.ECCENTRIC)), orbit.getAlphaDot(PositionAngle.ECCENTRIC).getReal(), 1.2e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAlpha(PositionAngle.MEAN)), orbit.getAlphaDot(PositionAngle.MEAN).getReal(), 3.7e-15);
}
Aggregations