Commit 36df068d authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Merge branch 'develop' into orekit-time_span_drivers

parents e21db3eb eeeb9ec9
......@@ -21,9 +21,18 @@
</properties>
<body>
<release version="12.0" date="TBD" description="TBD">
<action dev="pascal" type="fix" issue="1021">
Fixed regression introduced in EventEnablingPredicateFilter when fixing issue 1017.
</action>
<action dev="luc" type="fix" issue="1020">
Fixed regression introduced in ImpulseManeuver when fixing issue 1017.
</action>
<action dev="luc" type="update" issue="1017">
Removed generics in EventHandler.
</action>
<action dev="pascal" type="fix" issue="996">
Fixed HolmesFeatherstoneAttractionModel error with a degree 0 gravity field.
</action>
<action dev="luc" type="update" issue="1013">
Use SI units (i.e. seconds) in GNSSDate.
</action>
......
......@@ -86,13 +86,13 @@ public class AttitudesSequence implements AttitudeProvider {
private transient TimeSpanMap<AttitudeProvider> activated;
/** Switching events list. */
private final List<Switch<?>> switches;
private final List<Switch> switches;
/** Constructor for an initially empty sequence.
*/
public AttitudesSequence() {
activated = null;
switches = new ArrayList<Switch<?>>();
switches = new ArrayList<>();
}
/** Reset the active provider.
......@@ -118,7 +118,7 @@ public class AttitudesSequence implements AttitudeProvider {
* @param propagator propagator that will handle the events
*/
public void registerSwitchEvents(final Propagator propagator) {
for (final Switch<?> s : switches) {
for (final Switch s : switches) {
propagator.addEventDetector(s);
}
}
......@@ -136,7 +136,7 @@ public class AttitudesSequence implements AttitudeProvider {
* @param <T> type of the field elements
*/
public <T extends CalculusFieldElement<T>> void registerSwitchEvents(final Field<T> field, final FieldPropagator<T> propagator) {
for (final Switch<?> sw : switches) {
for (final Switch sw : switches) {
propagator.addEventDetector(new FieldEventDetector<T>() {
/** {@inheritDoc} */
......@@ -292,8 +292,8 @@ public class AttitudesSequence implements AttitudeProvider {
}
// add the switching condition
switches.add(new Switch<T>(switchEvent, switchOnIncrease, switchOnDecrease,
past, future, transitionTime, transitionFilter, handler));
switches.add(new Switch(switchEvent, switchOnIncrease, switchOnDecrease,
past, future, transitionTime, transitionFilter, handler));
}
......@@ -305,18 +305,16 @@ public class AttitudesSequence implements AttitudeProvider {
/** {@inheritDoc} */
public <T extends CalculusFieldElement<T>> FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv,
final FieldAbsoluteDate<T> date,
final Frame frame) {
final FieldAbsoluteDate<T> date,
final Frame frame) {
return activated.get(date.toAbsoluteDate()).getAttitude(pvProv, date, frame);
}
/** Switch specification.
* @param <T> class type for the generic version
*/
private class Switch<T extends EventDetector> implements EventDetector, EventHandler {
/** Switch specification. */
private class Switch implements EventDetector, EventHandler {
/** Event. */
private final T event;
private final EventDetector event;
/** Event direction triggering the switch. */
private final boolean switchOnIncrease;
......@@ -354,7 +352,7 @@ public class AttitudesSequence implements AttitudeProvider {
* should match past and future attitude laws
* @param switchHandler handler to call for notifying when switch occurs (may be null)
*/
Switch(final T event,
Switch(final EventDetector event,
final boolean switchOnIncrease, final boolean switchOnDecrease,
final AttitudeProvider past, final AttitudeProvider future,
final double transitionTime, final AngularDerivativesFilter transitionFilter,
......@@ -388,8 +386,7 @@ public class AttitudesSequence implements AttitudeProvider {
}
/** {@inheritDoc} */
public void init(final SpacecraftState s0,
final AbsoluteDate t) {
public void init(final SpacecraftState s0, final AbsoluteDate t) {
// reset the transition parameters (this will be done once for each switch,
// despite doing it only once would have sufficient; its not really a problem)
......@@ -477,7 +474,7 @@ public class AttitudesSequence implements AttitudeProvider {
@Override
public SpacecraftState resetState(final EventDetector detector, final SpacecraftState oldState) {
// delegate to underlying event
return event.getHandler().resetState(detector, oldState);
return event.getHandler().resetState(event, oldState);
}
/** Provider for transition phases.
......
......@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.List;
import org.hipparchus.CalculusFieldElement;
import org.hipparchus.Field;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Gradient;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
......@@ -150,7 +151,9 @@ public class HolmesFeatherstoneAttractionModel extends AbstractForceModel implem
// scaled sectorial terms corresponding to equation 28 in Holmes and Featherstone paper
sectorial = new double[degree + 1];
sectorial[0] = FastMath.scalb(1.0, -SCALING);
sectorial[1] = FastMath.sqrt(3) * sectorial[0];
if (degree > 0) {
sectorial[1] = FastMath.sqrt(3) * sectorial[0];
}
for (int m = 2; m < sectorial.length; ++m) {
sectorial[m] = FastMath.sqrt((2 * m + 1) / (2.0 * m)) * sectorial[m - 1];
}
......@@ -728,7 +731,9 @@ public class HolmesFeatherstoneAttractionModel extends AbstractForceModel implem
// initialize array
final double[] aOrN = new double[provider.getMaxDegree() + 1];
aOrN[0] = 1;
aOrN[1] = aOr;
if (provider.getMaxDegree() > 0) {
aOrN[1] = aOr;
}
// fill up array
for (int n = 2; n < aOrN.length; ++n) {
......@@ -750,7 +755,9 @@ public class HolmesFeatherstoneAttractionModel extends AbstractForceModel implem
// initialize array
final T[] aOrN = MathArrays.buildArray(aOr.getField(), provider.getMaxDegree() + 1);
aOrN[0] = aOr.getField().getOne();
aOrN[1] = aOr;
if (provider.getMaxDegree() > 0) {
aOrN[1] = aOr;
}
// fill up array
for (int n = 2; n < aOrN.length; ++n) {
......
......@@ -196,7 +196,7 @@ public class ImpulseManeuver extends AbstractDetector<ImpulseManeuver> {
// filter underlying event
final ImpulseManeuver im = (ImpulseManeuver) detector;
final Action underlyingAction = im.trigger.getHandler().eventOccurred(s, detector, increasing);
final Action underlyingAction = im.trigger.getHandler().eventOccurred(s, im.trigger, increasing);
return (underlyingAction == Action.STOP) ? Action.RESET_STATE : Action.CONTINUE;
......
......@@ -291,14 +291,14 @@ public class EventEnablingPredicateFilter
public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
final EventEnablingPredicateFilter ef = (EventEnablingPredicateFilter) detector;
final Transformer transformer = ef.forward ? ef.transformers[ef.transformers.length - 1] : ef.transformers[0];
return ef.rawDetector.getHandler().eventOccurred(s, ef, transformer == Transformer.PLUS ? increasing : !increasing);
return ef.rawDetector.getHandler().eventOccurred(s, ef.rawDetector, transformer == Transformer.PLUS ? increasing : !increasing);
}
/** {@inheritDoc} */
@Override
public SpacecraftState resetState(final EventDetector detector, final SpacecraftState oldState) {
final EventEnablingPredicateFilter ef = (EventEnablingPredicateFilter) detector;
return ef.rawDetector.getHandler().resetState(ef, oldState);
return ef.rawDetector.getHandler().resetState(ef.rawDetector, oldState);
}
}
......
......@@ -246,7 +246,7 @@ public class EventSlopeFilter<T extends EventDetector> extends AbstractDetector<
public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
@SuppressWarnings("unchecked")
final EventSlopeFilter<T> esf = (EventSlopeFilter<T>) detector;
return esf.rawDetector.getHandler().eventOccurred(s, esf, esf.filter.getTriggeredIncreasing());
return esf.rawDetector.getHandler().eventOccurred(s, esf.rawDetector, esf.filter.getTriggeredIncreasing());
}
/** {@inheritDoc} */
......@@ -254,7 +254,7 @@ public class EventSlopeFilter<T extends EventDetector> extends AbstractDetector<
public SpacecraftState resetState(final EventDetector detector, final SpacecraftState oldState) {
@SuppressWarnings("unchecked")
final EventSlopeFilter<T> esf = (EventSlopeFilter<T>) detector;
return esf.rawDetector.getHandler().resetState(esf, oldState);
return esf.rawDetector.getHandler().resetState(esf.rawDetector, oldState);
}
}
......
......@@ -26,6 +26,9 @@ import java.util.List;
import java.util.Map;
import java.util.Queue;
import org.hipparchus.analysis.UnivariateFunction;
import org.hipparchus.analysis.solvers.BracketedUnivariateSolver;
import org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver;
import org.hipparchus.exception.MathRuntimeException;
import org.hipparchus.ode.DenseOutputModel;
import org.hipparchus.ode.ExpandableODE;
......@@ -887,14 +890,14 @@ public abstract class AbstractIntegratedPropagator extends AbstractPropagator {
/** {@inheritDoc} */
@Override
public double getThreshold() {
return detector.getThreshold();
public int getMaxIterationCount() {
return detector.getMaxIterationCount();
}
/** {@inheritDoc} */
@Override
public int getMaxIterationCount() {
return detector.getMaxIterationCount();
public BracketedUnivariateSolver<UnivariateFunction> getSolver() {
return new BracketingNthOrderBrentSolver(0, detector.getThreshold(), 0, 5);
}
/** {@inheritDoc} */
......
......@@ -28,6 +28,7 @@ import java.util.Queue;
import org.hipparchus.CalculusFieldElement;
import org.hipparchus.Field;
import org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver;
import org.hipparchus.exception.MathIllegalArgumentException;
import org.hipparchus.exception.MathIllegalStateException;
import org.hipparchus.ode.FieldDenseOutputModel;
......@@ -881,14 +882,15 @@ public abstract class FieldAbstractIntegratedPropagator<T extends CalculusFieldE
/** {@inheritDoc} */
@Override
public T getThreshold() {
return detector.getThreshold();
public int getMaxIterationCount() {
return detector.getMaxIterationCount();
}
/** {@inheritDoc} */
@Override
public int getMaxIterationCount() {
return detector.getMaxIterationCount();
public FieldBracketingNthOrderBrentSolver<T> getSolver() {
final T zero = detector.getThreshold().getField().getZero();
return new FieldBracketingNthOrderBrentSolver<>(zero, detector.getThreshold(), zero, 5);
}
/** {@inheritDoc} */
......
......@@ -16,6 +16,9 @@
*/
package org.orekit.forces.gravity;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import org.hipparchus.Field;
import org.hipparchus.analysis.differentiation.DSFactory;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
......@@ -80,9 +83,6 @@ import org.orekit.utils.IERSConventions;
import org.orekit.utils.PVCoordinates;
import org.orekit.utils.PVCoordinatesProvider;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
public class HolmesFeatherstoneAttractionModelTest extends AbstractLegacyForceModelTest {
......@@ -198,7 +198,7 @@ public class HolmesFeatherstoneAttractionModelTest extends AbstractLegacyForceMo
}
private GradientHessian gradientHessian(final HolmesFeatherstoneAttractionModel hfModel,
final AbsoluteDate date, final Vector3D position)
final AbsoluteDate date, final Vector3D position)
{
try {
......@@ -1187,6 +1187,48 @@ public class HolmesFeatherstoneAttractionModelTest extends AbstractLegacyForceMo
}
@Test
public void testIssue996() {
Utils.setDataRoot("regular-data:potential/grgs-format");
GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));
// initialization
AbsoluteDate date = new AbsoluteDate(new DateComponents(2000, 07, 01),
new TimeComponents(13, 59, 27.816),
TimeScalesFactory.getUTC());
double i = FastMath.toRadians(98.7);
double omega = FastMath.toRadians(93.0);
double OMEGA = FastMath.toRadians(15.0 * 22.5);
Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i , omega, OMEGA,
0, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
Vector3D pos = orbit.getPosition(itrf);
double[] zeroGradient = new double[] {-0., 0., 0.};
NormalizedSphericalHarmonicsProvider provider00 = GravityFieldFactory.getNormalizedProvider(0, 0);
HolmesFeatherstoneAttractionModel hfModel00 = new HolmesFeatherstoneAttractionModel(itrf, provider00);
Assertions.assertEquals(0., hfModel00.nonCentralPart(date, pos, mu));
Assertions.assertEquals(mu / pos.getNorm(), hfModel00.value(date, pos, mu));
Assertions.assertArrayEquals(zeroGradient, hfModel00.gradient(date, pos, mu));
NormalizedSphericalHarmonicsProvider provider10 = GravityFieldFactory.getNormalizedProvider(1, 0);
HolmesFeatherstoneAttractionModel hfModel10 = new HolmesFeatherstoneAttractionModel(itrf, provider10);
Assertions.assertEquals(0., hfModel10.nonCentralPart(date, pos, mu));
Assertions.assertEquals(mu / pos.getNorm(), hfModel10.value(date, pos, mu));
Assertions.assertArrayEquals(zeroGradient, hfModel10.gradient(date, pos, mu));
NormalizedSphericalHarmonicsProvider provider11 = GravityFieldFactory.getNormalizedProvider(1, 1);
HolmesFeatherstoneAttractionModel hfModel11 = new HolmesFeatherstoneAttractionModel(itrf, provider11);
Assertions.assertEquals(0., hfModel11.nonCentralPart(date, pos, mu));
Assertions.assertEquals(mu / pos.getNorm(), hfModel11.value(date, pos, mu));
Assertions.assertArrayEquals(zeroGradient, hfModel11.gradient(date, pos, mu));
}
@BeforeEach
public void setUp() {
itrf = null;
......
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