use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FundamentalNutationArgumentsTest method testDotField.
@Test
public void testDotField() throws OrekitException {
final IERSConventions conventions = IERSConventions.IERS_2010;
final TimeScale ut1 = TimeScalesFactory.getUT1(conventions, false);
final FundamentalNutationArguments fna = conventions.getNutationArguments(ut1);
final FieldAbsoluteDate<Decimal64> t0 = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), 2002, 4, 7, 12, 34, 22.5, TimeScalesFactory.getUTC());
final UnivariateDifferentiableFunction gamma = differentiate(fna, t0, b -> b.getGamma());
final UnivariateDifferentiableFunction l = differentiate(fna, t0, b -> b.getL());
final UnivariateDifferentiableFunction lPrime = differentiate(fna, t0, b -> b.getLPrime());
final UnivariateDifferentiableFunction f = differentiate(fna, t0, b -> b.getF());
final UnivariateDifferentiableFunction d = differentiate(fna, t0, b -> b.getD());
final UnivariateDifferentiableFunction lMe = differentiate(fna, t0, b -> b.getLMe());
final UnivariateDifferentiableFunction lVe = differentiate(fna, t0, b -> b.getLVe());
final UnivariateDifferentiableFunction lE = differentiate(fna, t0, b -> b.getLE());
final UnivariateDifferentiableFunction lMa = differentiate(fna, t0, b -> b.getLMa());
final UnivariateDifferentiableFunction lJu = differentiate(fna, t0, b -> b.getLJu());
final UnivariateDifferentiableFunction lSa = differentiate(fna, t0, b -> b.getLSa());
final UnivariateDifferentiableFunction lUr = differentiate(fna, t0, b -> b.getLUr());
final UnivariateDifferentiableFunction lNe = differentiate(fna, t0, b -> b.getLNe());
final UnivariateDifferentiableFunction pa = differentiate(fna, t0, b -> b.getPa());
final DSFactory factory = new DSFactory(1, 1);
double maxErrorGamma = 0;
double maxErrorL = 0;
double maxErrorLPrime = 0;
double maxErrorF = 0;
double maxErrorD = 0;
double maxErrorLMe = 0;
double maxErrorLVe = 0;
double maxErrorLE = 0;
double maxErrorLMa = 0;
double maxErrorLJu = 0;
double maxErrorLSa = 0;
double maxErrorLUr = 0;
double maxErrorLNe = 0;
double maxErrorPa = 0;
for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 60.0) {
FieldBodiesElements<Decimal64> be = fna.evaluateAll(t0.shiftedBy(dt));
DerivativeStructure dtDS = factory.variable(0, dt);
maxErrorGamma = FastMath.max(maxErrorGamma, FastMath.abs(gamma.value(dtDS).getPartialDerivative(1) - be.getGammaDot().getReal()));
maxErrorL = FastMath.max(maxErrorL, FastMath.abs(l.value(dtDS).getPartialDerivative(1) - be.getLDot().getReal()));
maxErrorLPrime = FastMath.max(maxErrorLPrime, FastMath.abs(lPrime.value(dtDS).getPartialDerivative(1) - be.getLPrimeDot().getReal()));
maxErrorF = FastMath.max(maxErrorF, FastMath.abs(f.value(dtDS).getPartialDerivative(1) - be.getFDot().getReal()));
maxErrorD = FastMath.max(maxErrorD, FastMath.abs(d.value(dtDS).getPartialDerivative(1) - be.getDDot().getReal()));
maxErrorLMe = FastMath.max(maxErrorLMe, FastMath.abs(lMe.value(dtDS).getPartialDerivative(1) - be.getLMeDot().getReal()));
maxErrorLVe = FastMath.max(maxErrorLVe, FastMath.abs(lVe.value(dtDS).getPartialDerivative(1) - be.getLVeDot().getReal()));
maxErrorLE = FastMath.max(maxErrorLE, FastMath.abs(lE.value(dtDS).getPartialDerivative(1) - be.getLEDot().getReal()));
maxErrorLMa = FastMath.max(maxErrorLMa, FastMath.abs(lMa.value(dtDS).getPartialDerivative(1) - be.getLMaDot().getReal()));
maxErrorLJu = FastMath.max(maxErrorLJu, FastMath.abs(lJu.value(dtDS).getPartialDerivative(1) - be.getLJuDot().getReal()));
maxErrorLSa = FastMath.max(maxErrorLSa, FastMath.abs(lSa.value(dtDS).getPartialDerivative(1) - be.getLSaDot().getReal()));
maxErrorLUr = FastMath.max(maxErrorLUr, FastMath.abs(lUr.value(dtDS).getPartialDerivative(1) - be.getLUrDot().getReal()));
maxErrorLNe = FastMath.max(maxErrorLNe, FastMath.abs(lNe.value(dtDS).getPartialDerivative(1) - be.getLNeDot().getReal()));
maxErrorPa = FastMath.max(maxErrorPa, FastMath.abs(pa.value(dtDS).getPartialDerivative(1) - be.getPaDot().getReal()));
}
Assert.assertEquals(0, maxErrorGamma, 8.0e-13);
Assert.assertEquals(0, maxErrorL, 1.0e-14);
Assert.assertEquals(0, maxErrorLPrime, 6.0e-16);
Assert.assertEquals(0, maxErrorF, 6.0e-15);
Assert.assertEquals(0, maxErrorD, 6.0e-15);
Assert.assertEquals(0, maxErrorLMe, 2.0e-15);
Assert.assertEquals(0, maxErrorLVe, 5.0e-16);
Assert.assertEquals(0, maxErrorLE, 3.0e-16);
Assert.assertEquals(0, maxErrorLMa, 4.0e-16);
Assert.assertEquals(0, maxErrorLJu, 3.0e-17);
Assert.assertEquals(0, maxErrorLSa, 4.0e-17);
Assert.assertEquals(0, maxErrorLUr, 1.0e-16);
Assert.assertEquals(0, maxErrorLNe, 8.0e-17);
Assert.assertEquals(0, maxErrorPa, 3.0e-20);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FixedRateTest method doTestNonZeroRate.
private <T extends RealFieldElement<T>> void doTestNonZeroRate(final Field<T> field) throws OrekitException {
final T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 3, 2), new TimeComponents(13, 17, 7.865), TimeScalesFactory.getUTC());
final T rate = zero.add(2 * FastMath.PI / (12 * 60));
final Frame frame = FramesFactory.getEME2000();
FixedRate law = new FixedRate(new Attitude(date.toAbsoluteDate(), frame, new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate.getReal(), Vector3D.PLUS_K), Vector3D.ZERO));
FieldPVCoordinates<T> pv = new FieldPVCoordinates<>(field.getOne(), new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056)));
FieldOrbit<T> orbit = new FieldKeplerianOrbit<>(pv, FramesFactory.getEME2000(), date, 3.986004415e14);
FieldRotation<T> attitude0 = law.getAttitude(orbit, date, frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude0.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude1 = law.getAttitude(orbit.shiftedBy(zero.add(10.0)), date.shiftedBy(10.0), frame).getRotation();
Assert.assertEquals(10 * rate.getReal(), Rotation.distance(attitude1.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude2 = law.getAttitude(orbit.shiftedBy(zero.add(-20.0)), date.shiftedBy(-20.0), frame).getRotation();
Assert.assertEquals(20 * rate.getReal(), Rotation.distance(attitude2.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
Assert.assertEquals(30 * rate.getReal(), Rotation.distance(attitude2.toRotation(), attitude1.toRotation()), 1.0e-10);
FieldRotation<T> attitude3 = law.getAttitude(orbit.shiftedBy(zero.add(0.0)), date, frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude3.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FixedRateTest method doTestZeroRate.
private <T extends RealFieldElement<T>> void doTestZeroRate(final Field<T> field) throws OrekitException {
final T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 3, 2), new TimeComponents(13, 17, 7.865), TimeScalesFactory.getUTC());
final Frame frame = FramesFactory.getEME2000();
FixedRate law = new FixedRate(new Attitude(date.toAbsoluteDate(), frame, new Rotation(0.48, 0.64, 0.36, 0.48, false), Vector3D.ZERO, Vector3D.ZERO));
FieldPVCoordinates<T> pv = new FieldPVCoordinates<>(field.getOne(), new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056)));
FieldOrbit<T> orbit = new FieldKeplerianOrbit<>(pv, frame, date, 3.986004415e14);
FieldRotation<T> attitude0 = law.getAttitude(orbit, date, frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude0.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude1 = law.getAttitude(orbit.shiftedBy(zero.add(10.0)), date.shiftedBy(10.0), frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude1.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude2 = law.getAttitude(orbit.shiftedBy(zero.add(20.0)), date.shiftedBy(20.0), frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude2.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FixedRateTest method doTestSpin.
private <T extends RealFieldElement<T>> void doTestSpin(final Field<T> field) throws OrekitException {
final T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
final T rate = zero.add(2 * FastMath.PI / (12 * 60));
AttitudeProvider law = new FixedRate(new Attitude(date.toAbsoluteDate(), FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate.getReal(), Vector3D.PLUS_K), Vector3D.ZERO));
FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7178000.0), zero.add(1.e-4), zero.add(FastMath.toRadians(50.)), zero.add(FastMath.toRadians(10.)), zero.add(FastMath.toRadians(20.)), zero.add(FastMath.toRadians(30.)), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
FieldPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, law);
T h = zero.add(0.01);
FieldSpacecraftState<T> sMinus = propagator.propagate(date.shiftedBy(h.negate()));
FieldSpacecraftState<T> s0 = propagator.propagate(date);
FieldSpacecraftState<T> sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
double errorAngleMinus = FieldRotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation()).getReal();
double evolutionAngleMinus = FieldRotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation()).getReal();
Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus);
double errorAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(h.negate()).getAttitude().getRotation()).getReal();
double evolutionAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation()).getReal();
Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus);
FieldVector3D<T> spin0 = s0.getAttitude().getSpin();
FieldVector3D<T> reference = FieldAngularCoordinates.estimateRate(sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), h.multiply(2));
Assert.assertEquals(0.0, spin0.subtract(reference).getNorm().getReal(), 1.0e-14);
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class NRLMSISE00 method getDensity.
/**
* {@inheritDoc}
*/
@Override
public <T extends RealFieldElement<T>> T getDensity(final FieldAbsoluteDate<T> date, final FieldVector3D<T> position, final Frame frame) throws OrekitException {
// check if data are available :
final AbsoluteDate dateD = date.toAbsoluteDate();
if ((dateD.compareTo(inputParams.getMaxDate()) > 0) || (dateD.compareTo(inputParams.getMinDate()) < 0)) {
throw new OrekitException(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE, dateD, inputParams.getMinDate(), inputParams.getMaxDate());
}
// compute day number in current year and the seconds within the day
final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
final DateTimeComponents dtc = dateD.getComponents(ut1);
final int doy = dtc.getDate().getDayOfYear();
final T sec = date.durationFrom(new AbsoluteDate(dtc.getDate(), TimeComponents.H00, ut1));
// compute geodetic position (km and °)
final FieldGeodeticPoint<T> inBody = earth.transform(position, frame, date);
final T alt = inBody.getAltitude().divide(1000.);
final T lon = inBody.getLongitude().multiply(180.0 / FastMath.PI);
final T lat = inBody.getLatitude().multiply(180.0 / FastMath.PI);
// compute local solar time
final T lst = localSolarTime(dateD, position, frame);
// get solar activity data and compute
final FieldOutput<T> out = new FieldOutput<>(doy, sec, lat, lon, lst, inputParams.getAverageFlux(dateD), inputParams.getDailyFlux(dateD), inputParams.getAp(dateD));
out.gtd7d(alt);
// return the local density
return out.getDensity(TOTAL_MASS);
}
Aggregations