Commit 3d77bcf3 authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

Updated computeMeanState and computeOsculatingState methods to static.

parent 36ade41a
......@@ -21,6 +21,13 @@
</properties>
<body>
<release version="11.0" date="TBD" description="TBD">
<action dev="bryan" type="update" issue="650">
Methods computeMeanState() and computeOsculatingState()
of FieldDSSTPropagator are now statics.
</action>
<action dev="bryan" type="update" issue="762">
TabulatelofOffset now implements BoundedAttitudeProvider.
</action>
<action dev="luc" type="update" issue="761">
TabulateProvider now implements BoundedAttitudeProvider.
</action>
......
......@@ -509,12 +509,13 @@ public class FieldDSSTPropagator<T extends RealFieldElement<T>> extends FieldAbs
* @param forces Forces to take into account
* @param attitudeProvider attitude provider (may be null if there are no Gaussian force models
* like atmospheric drag, radiation pressure or specific user-defined models)
* @param <T> type of the elements
* @return osculating state in a DSST sense
*/
@SuppressWarnings("unchecked")
public FieldSpacecraftState<T> computeOsculatingState(final FieldSpacecraftState<T> mean,
final AttitudeProvider attitudeProvider,
final Collection<DSSTForceModel> forces) {
public static <T extends RealFieldElement<T>> FieldSpacecraftState<T> computeOsculatingState(final FieldSpacecraftState<T> mean,
final AttitudeProvider attitudeProvider,
final Collection<DSSTForceModel> forces) {
//Create the auxiliary object
final FieldAuxiliaryElements<T> aux = new FieldAuxiliaryElements<>(mean.getOrbit(), I);
......@@ -522,9 +523,10 @@ public class FieldDSSTPropagator<T extends RealFieldElement<T>> extends FieldAbs
// Set the force models
final List<FieldShortPeriodTerms<T>> shortPeriodTerms = new ArrayList<FieldShortPeriodTerms<T>>();
for (final DSSTForceModel force : forces) {
final T[] parameters = force.getParameters(mean.getDate().getField());
force.registerAttitudeProvider(attitudeProvider);
shortPeriodTerms.addAll(force.initialize(aux, PropagationType.OSCULATING, force.getParameters(field)));
force.updateShortPeriodTerms(force.getParameters(field), mean);
shortPeriodTerms.addAll(force.initialize(aux, PropagationType.OSCULATING, parameters));
force.updateShortPeriodTerms(parameters, mean);
}
final FieldEquinoctialOrbit<T> osculatingOrbit = computeOsculatingOrbit(mean, shortPeriodTerms);
......@@ -550,11 +552,12 @@ public class FieldDSSTPropagator<T extends RealFieldElement<T>> extends FieldAbs
* @param attitudeProvider attitude provider (may be null if there are no Gaussian force models
* like atmospheric drag, radiation pressure or specific user-defined models)
* @param forceModel Forces to take into account
* @param <T> type of the elements
* @return mean state in a DSST sense
*/
public FieldSpacecraftState<T> computeMeanState(final FieldSpacecraftState<T> osculating,
final AttitudeProvider attitudeProvider,
final Collection<DSSTForceModel> forceModel) {
public static <T extends RealFieldElement<T>> FieldSpacecraftState<T> computeMeanState(final FieldSpacecraftState<T> osculating,
final AttitudeProvider attitudeProvider,
final Collection<DSSTForceModel> forceModel) {
return computeMeanState(osculating, attitudeProvider, forceModel, EPSILON_DEFAULT, MAX_ITERATIONS_DEFAULT);
}
......@@ -577,13 +580,14 @@ public class FieldDSSTPropagator<T extends RealFieldElement<T>> extends FieldAbs
* @param epsilon convergence threshold for mean parameters conversion
* @param maxIterations maximum iterations for mean parameters conversion
* @return mean state in a DSST sense
* @param <T> type of the elements
* @since 10.1
*/
public FieldSpacecraftState<T> computeMeanState(final FieldSpacecraftState<T> osculating,
final AttitudeProvider attitudeProvider,
final Collection<DSSTForceModel> forceModel,
final double epsilon,
final int maxIterations) {
public static <T extends RealFieldElement<T>> FieldSpacecraftState<T> computeMeanState(final FieldSpacecraftState<T> osculating,
final AttitudeProvider attitudeProvider,
final Collection<DSSTForceModel> forceModel,
final double epsilon,
final int maxIterations) {
final FieldOrbit<T> meanOrbit = computeMeanOrbit(osculating, attitudeProvider, forceModel, epsilon, maxIterations);
return new FieldSpacecraftState<>(meanOrbit, osculating.getAttitude(), osculating.getMass(), osculating.getAdditionalStates());
}
......@@ -697,15 +701,16 @@ public class FieldDSSTPropagator<T extends RealFieldElement<T>> extends FieldAbs
* @param forceModel force models
* @param epsilon convergence threshold for mean parameters conversion
* @param maxIterations maximum iterations for mean parameters conversion
* @param <T> type of the elements
* @return mean state
* @since 10.1
*/
@SuppressWarnings("unchecked")
private FieldOrbit<T> computeMeanOrbit(final FieldSpacecraftState<T> osculating, final AttitudeProvider attitudeProvider, final Collection<DSSTForceModel> forceModel,
final double epsilon, final int maxIterations) {
private static <T extends RealFieldElement<T>> FieldOrbit<T> computeMeanOrbit(final FieldSpacecraftState<T> osculating, final AttitudeProvider attitudeProvider, final Collection<DSSTForceModel> forceModel,
final double epsilon, final int maxIterations) {
// zero
final T zero = field.getZero();
final T zero = osculating.getDate().getField().getZero();
// rough initialization of the mean parameters
FieldEquinoctialOrbit<T> meanOrbit = (FieldEquinoctialOrbit<T>) OrbitType.EQUINOCTIAL.convertType(osculating.getOrbit());
......@@ -733,8 +738,9 @@ public class FieldDSSTPropagator<T extends RealFieldElement<T>> extends FieldAbs
// Set the force models
final List<FieldShortPeriodTerms<T>> shortPeriodTerms = new ArrayList<FieldShortPeriodTerms<T>>();
for (final DSSTForceModel force : forceModel) {
shortPeriodTerms.addAll(force.initialize(aux, PropagationType.OSCULATING, force.getParameters(field)));
force.updateShortPeriodTerms(force.getParameters(field), meanState);
final T[] parameters = force.getParameters(osculating.getDate().getField());
shortPeriodTerms.addAll(force.initialize(aux, PropagationType.OSCULATING, parameters));
force.updateShortPeriodTerms(parameters, meanState);
}
// recompute the osculating parameters from the current mean parameters
......@@ -778,13 +784,14 @@ public class FieldDSSTPropagator<T extends RealFieldElement<T>> extends FieldAbs
* </p>
* @param meanState initial mean state
* @param shortPeriodTerms short period terms
* @param <T> type of the elements
* @return osculating state
*/
private FieldEquinoctialOrbit<T> computeOsculatingOrbit(final FieldSpacecraftState<T> meanState,
final List<FieldShortPeriodTerms<T>> shortPeriodTerms) {
private static <T extends RealFieldElement<T>> FieldEquinoctialOrbit<T> computeOsculatingOrbit(final FieldSpacecraftState<T> meanState,
final List<FieldShortPeriodTerms<T>> shortPeriodTerms) {
final T[] mean = MathArrays.buildArray(field, 6);
final T[] meanDot = MathArrays.buildArray(field, 6);
final T[] mean = MathArrays.buildArray(meanState.getDate().getField(), 6);
final T[] meanDot = MathArrays.buildArray(meanState.getDate().getField(), 6);
OrbitType.EQUINOCTIAL.mapOrbitToArray(meanState.getOrbit(), PositionAngle.MEAN, mean, meanDot);
final T[] y = mean.clone();
for (final FieldShortPeriodTerms<T> spt : shortPeriodTerms) {
......
......@@ -27,7 +27,6 @@ import org.hipparchus.RealFieldElement;
import org.hipparchus.exception.DummyLocalizable;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.RotationOrder;
import org.hipparchus.ode.nonstiff.ClassicalRungeKuttaFieldIntegrator;
import org.hipparchus.util.Decimal64Field;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.MathUtils;
......@@ -895,8 +894,7 @@ public class FieldEcksteinHechlerPropagatorTest {
// Mean state computation
final List<DSSTForceModel> models = new ArrayList<>();
models.add(new DSSTZonal(provider));
final FieldDSSTPropagator<T> dsst = new FieldDSSTPropagator<>(field, new ClassicalRungeKuttaFieldIntegrator<>(field, zero.add(10.0)));
final FieldSpacecraftState<T> meanState = dsst.computeMeanState(initialState, Propagator.DEFAULT_LAW, models);
final FieldSpacecraftState<T> meanState = FieldDSSTPropagator.computeMeanState(initialState, Propagator.DEFAULT_LAW, models);
// Initialize Eckstein-Hechler model with mean state
final FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(meanState.getOrbit(), provider, PropagationType.MEAN);
......@@ -937,8 +935,7 @@ public class FieldEcksteinHechlerPropagatorTest {
// Mean state computation
final List<DSSTForceModel> models = new ArrayList<>();
models.add(new DSSTZonal(provider));
final FieldDSSTPropagator<T> dsst = new FieldDSSTPropagator<>(field, new ClassicalRungeKuttaFieldIntegrator<>(field, zero.add(10.0)));
final FieldSpacecraftState<T> meanState = dsst.computeMeanState(initialState, Propagator.DEFAULT_LAW, models);
final FieldSpacecraftState<T> meanState = FieldDSSTPropagator.computeMeanState(initialState, Propagator.DEFAULT_LAW, models);
// Initialize Eckstein-Hechler model with mean state
final FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(meanState.getOrbit(), Propagator.DEFAULT_LAW, zero.add(498.5), provider, PropagationType.MEAN);
......
......@@ -118,8 +118,7 @@ public class FieldDSSTPropagatorTest {
dsstForceModels.add(new DSSTThirdBody(CelestialBodyFactory.getMoon(), orbit.getMu().getReal()));
dsstForceModels.add(new DSSTThirdBody(CelestialBodyFactory.getSun(), orbit.getMu().getReal()));
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, osculatingState);
FieldSpacecraftState<T> meanState = dsstPropagator.computeMeanState(osculatingState, null, dsstForceModels);
FieldSpacecraftState<T> meanState = FieldDSSTPropagator.computeMeanState(osculatingState, null, dsstForceModels);
Assert.assertEquals( 0.421, osculatingState.getA().subtract(meanState.getA()).getReal(), 1.0e-3);
Assert.assertEquals(-5.23e-8, osculatingState.getEquinoctialEx().subtract(meanState.getEquinoctialEx()).getReal(), 1.0e-10);
Assert.assertEquals(15.22e-8, osculatingState.getEquinoctialEy().subtract(meanState.getEquinoctialEy()).getReal(), 1.0e-10);
......@@ -148,8 +147,7 @@ public class FieldDSSTPropagatorTest {
dsstForceModels.add(new DSSTThirdBody(CelestialBodyFactory.getMoon(), orbit.getMu().getReal()));
dsstForceModels.add(new DSSTThirdBody(CelestialBodyFactory.getSun(), orbit.getMu().getReal()));
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, osculatingState);
FieldSpacecraftState<T> meanState = dsstPropagator.computeMeanState(osculatingState, null, dsstForceModels);
FieldSpacecraftState<T> meanState = FieldDSSTPropagator.computeMeanState(osculatingState, null, dsstForceModels);
Assert.assertEquals( 0.421, osculatingState.getA().subtract(meanState.getA()).getReal(), 1.0e-3);
Assert.assertEquals(-5.23e-8, osculatingState.getEquinoctialEx().subtract(meanState.getEquinoctialEx()).getReal(), 1.0e-10);
Assert.assertEquals(15.22e-8, osculatingState.getEquinoctialEy().subtract(meanState.getEquinoctialEy()).getReal(), 1.0e-10);
......@@ -191,8 +189,7 @@ public class FieldDSSTPropagatorTest {
zero.add(FastMath.toRadians(12.0)),
PositionAngle.TRUE, eci, initialDate, zero.add(Constants.EIGEN5C_EARTH_MU));
final FieldSpacecraftState<T> state = new FieldSpacecraftState<>(orbit);
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, state);
FieldSpacecraftState<T> oscuState = dsstPropagator.computeOsculatingState(state, null, forces);
FieldSpacecraftState<T> oscuState = FieldDSSTPropagator.computeOsculatingState(state, null, forces);
Assert.assertEquals(7119927.097122, oscuState.getA().getReal(), 0.001);
}
......@@ -801,8 +798,7 @@ public class FieldDSSTPropagatorTest {
forces.add(zonal);
forces.add(tesseral);
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, meanState);
final FieldSpacecraftState<T> osculatingState = dsstPropagator.computeOsculatingState(meanState, null, forces);
final FieldSpacecraftState<T> osculatingState = FieldDSSTPropagator.computeOsculatingState(meanState, null, forces);
Assert.assertEquals(1559.1,
FieldVector3D.distance(meanState.getPVCoordinates().getPosition(),
osculatingState.getPVCoordinates().getPosition()).getReal(),
......@@ -829,11 +825,10 @@ public class FieldDSSTPropagatorTest {
forces.add(zonal);
forces.add(tesseral);
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, meanState);
final FieldSpacecraftState<T> osculatingState = dsstPropagator.computeOsculatingState(meanState, null, forces);
final FieldSpacecraftState<T> osculatingState = FieldDSSTPropagator.computeOsculatingState(meanState, null, forces);
// there are no Gaussian force models, we don't need an attitude provider
final FieldSpacecraftState<T> computedMeanState = dsstPropagator.computeMeanState(osculatingState, null, forces);
final FieldSpacecraftState<T> computedMeanState = FieldDSSTPropagator.computeMeanState(osculatingState, null, forces);
Assert.assertEquals(meanState.getA().getReal(), computedMeanState.getA().getReal(), 2.0e-8);
Assert.assertEquals(0.0,
......@@ -934,8 +929,7 @@ public class FieldDSSTPropagatorTest {
forces.add(zonal);
forces.add(tesseral);
// Computes J2 mean elements using the DSST osculating to mean converter
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, ss);
final FieldOrbit<T> meanOrb = dsstPropagator.computeMeanState(ss, null, forces).getOrbit();
final FieldOrbit<T> meanOrb = FieldDSSTPropagator.computeMeanState(ss, null, forces).getOrbit();
Assert.assertEquals(0.0164196, FastMath.toDegrees(orb.getI().subtract(meanOrb.getI()).getReal()), 1.0e-7);
}
......@@ -955,14 +949,13 @@ public class FieldDSSTPropagatorTest {
forces.add(moon);
forces.add(sun);
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, meanState);
final FieldSpacecraftState<T> osculatingState = dsstPropagator.computeOsculatingState(meanState, null, forces);
final FieldSpacecraftState<T> osculatingState = FieldDSSTPropagator.computeOsculatingState(meanState, null, forces);
Assert.assertEquals(734.3,
FieldVector3D.distance(meanState.getPVCoordinates().getPosition(),
osculatingState.getPVCoordinates().getPosition()).getReal(),
1.0);
final FieldSpacecraftState<T> computedMeanState = dsstPropagator.computeMeanState(osculatingState, null, forces);
final FieldSpacecraftState<T> computedMeanState = FieldDSSTPropagator.computeMeanState(osculatingState, null, forces);
Assert.assertEquals(734.3,
FieldVector3D.distance(osculatingState.getPVCoordinates().getPosition(),
computedMeanState.getPVCoordinates().getPosition()).getReal(),
......@@ -1007,14 +1000,13 @@ public class FieldDSSTPropagatorTest {
osculatingState.getMu().getReal()));
forces.add(new DSSTAtmosphericDrag(atmosphere, boxAndWing, osculatingState.getMu().getReal()));
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, osculatingState);
final FieldSpacecraftState<T> meanState = dsstPropagator.computeMeanState(osculatingState, attitudeProvider, forces);
final FieldSpacecraftState<T> meanState = FieldDSSTPropagator.computeMeanState(osculatingState, attitudeProvider, forces);
Assert.assertEquals(0.522,
FieldVector3D.distance(osculatingState.getPVCoordinates().getPosition(),
meanState.getPVCoordinates().getPosition()).getReal(),
0.001);
final FieldSpacecraftState<T> computedOsculatingState = dsstPropagator.computeOsculatingState(meanState, attitudeProvider, forces);
final FieldSpacecraftState<T> computedOsculatingState = FieldDSSTPropagator.computeOsculatingState(meanState, attitudeProvider, forces);
Assert.assertEquals(0.0,
FieldVector3D.distance(osculatingState.getPVCoordinates().getPosition(),
computedOsculatingState.getPVCoordinates().getPosition()).getReal(),
......@@ -1038,9 +1030,8 @@ public class FieldDSSTPropagatorTest {
// Surface force models that require an attitude provider
final Collection<DSSTForceModel> forces = new ArrayList<DSSTForceModel>();
forces.add(new DSSTAtmosphericDrag(atmosphere, boxAndWing, osculatingState.getMu().getReal()));
final FieldDSSTPropagator<T> dsstPropagator = setDSSTProp(field, osculatingState);
final FieldSpacecraftState<T> meanState = dsstPropagator.computeMeanState(osculatingState, attitudeProvider, forces);
final FieldSpacecraftState<T> computedOsculatingState = dsstPropagator.computeOsculatingState(meanState, attitudeProvider, forces);
final FieldSpacecraftState<T> meanState = FieldDSSTPropagator.computeMeanState(osculatingState, attitudeProvider, forces);
final FieldSpacecraftState<T> computedOsculatingState = FieldDSSTPropagator.computeOsculatingState(meanState, attitudeProvider, forces);
Assert.assertEquals(0.0, FieldVector3D.distance(osculatingState.getPVCoordinates().getPosition(), computedOsculatingState.getPVCoordinates().getPosition()).getReal(),
5.0e-6);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment