Commit ff545fde authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

Merge branch 'issue-691' into 'develop'

Improved consistency between getParametersDrivers() method signatures.

Closes #691

See merge request orekit/orekit!141
parents 1195843a 595fbf8b
......@@ -21,6 +21,9 @@
</properties>
<body>
<release version="11.0" date="TBD" description="TBD">
<action dev="bryan" type="update" issue="691">
Improved consistency between getParametersDrivers() method signatures.
</action>
<action dev="andrewsgoetz" type="add" issue="764">
Added new method to UTCScale which exposes the raw UTC-TAI offset data.
</action>
......
/* Copyright 2002-2021 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.forces;
import java.util.stream.Stream;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.attitudes.Attitude;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.attitudes.FieldAttitude;
import org.orekit.forces.empirical.ParametricAcceleration;
import org.orekit.propagation.FieldSpacecraftState;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.events.EventDetector;
import org.orekit.propagation.events.FieldEventDetector;
/** This class implements a parametric acceleration.
* <p>Parametric accelerations are intended to model lesser-known
* forces, estimating a few defining parameters from a parametric
* function using orbit determination. Typical parametric functions
* are polynomial (often limited to a constant term) and harmonic
* (often with either orbital period or half orbital period).</p>
* <p>An important operational example is the infamous GPS Y-bias,
* which is thought to be related to a radiator thermal radiation.
* Other examples could be to model leaks that produce roughly constant
* trust in some spacecraft-related direction.</p>
* <p>The acceleration direction is considered constant in either:
* </p>
* <ul>
* <li>inertial frame</li>
* <li>spacecraft frame</li>
* <li>a dedicated attitude frame overriding spacecraft attitude
* (this could for example be used to model solar arrays orientation
* if the force is related to solar arrays)</li>
* </ul>
* <p>
* If the direction of the acceleration is unknown, then three instances
* of this class should be used, one along the X axis, one along the Y
* axis and one along the Z axis and their parameters estimated as usual.
* </p>
* @since 9.0
* @author Luc Maisonobe
* @deprecated as of 10.3, replaced by {@link ParametricAcceleration}
*/
@Deprecated
public abstract class AbstractParametricAcceleration extends AbstractForceModel {
/** Direction of the acceleration in defining frame. */
private final Vector3D direction;
/** Flag for inertial acceleration direction. */
private final boolean isInertial;
/** The attitude to override, if set. */
private final AttitudeProvider attitudeOverride;
/** Simple constructor.
* @param direction acceleration direction in overridden spacecraft frame
* @param isInertial if true, direction is defined in the same inertial
* frame used for propagation (i.e. {@link SpacecraftState#getFrame()}),
* otherwise direction is defined in spacecraft frame (i.e. using the
* propagation {@link
* org.orekit.propagation.Propagator#setAttitudeProvider(AttitudeProvider)
* attitude law})
* @param attitudeOverride provider for attitude used to compute acceleration
* direction
*/
protected AbstractParametricAcceleration(final Vector3D direction, final boolean isInertial,
final AttitudeProvider attitudeOverride) {
this.direction = direction;
this.isInertial = isInertial;
this.attitudeOverride = attitudeOverride;
}
/** Check if direction is inertial.
* @return true if direction is inertial
*/
protected boolean isInertial() {
return isInertial;
}
/** Compute the signed amplitude of the acceleration.
* <p>
* The acceleration is the direction multiplied by the signed amplitude. So if
* signed amplitude is negative, the acceleratin is towards the opposite of the
* direction specified at construction.
* </p>
* @param state current state information: date, kinematics, attitude
* @param parameters values of the force model parameters
* @return norm of the acceleration
*/
protected abstract double signedAmplitude(SpacecraftState state, double[] parameters);
/** Compute the signed amplitude of the acceleration.
* <p>
* The acceleration is the direction multiplied by the signed amplitude. So if
* signed amplitude is negative, the acceleratin is towards the opposite of the
* direction specified at construction.
* </p>
* @param state current state information: date, kinematics, attitude
* @param parameters values of the force model parameters
* @param <T> type of the elements
* @return norm of the acceleration
*/
protected abstract <T extends RealFieldElement<T>> T signedAmplitude(FieldSpacecraftState<T> state, T[] parameters);
/** {@inheritDoc} */
@Override
public Vector3D acceleration(final SpacecraftState state, final double[] parameters) {
final Vector3D inertialDirection;
if (isInertial) {
// the acceleration direction is already defined in the inertial frame
inertialDirection = direction;
} else {
final Attitude attitude;
if (attitudeOverride == null) {
// the acceleration direction is defined in spacecraft frame as set by the propagator
attitude = state.getAttitude();
} else {
// the acceleration direction is defined in a dedicated frame
attitude = attitudeOverride.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
}
inertialDirection = attitude.getRotation().applyInverseTo(direction);
}
return new Vector3D(signedAmplitude(state, parameters), inertialDirection);
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> state,
final T[] parameters) {
final FieldVector3D<T> inertialDirection;
if (isInertial) {
// the acceleration direction is already defined in the inertial frame
inertialDirection = new FieldVector3D<>(state.getDate().getField(), direction);
} else {
final FieldAttitude<T> attitude;
if (attitudeOverride == null) {
// the acceleration direction is defined in spacecraft frame as set by the propagator
attitude = state.getAttitude();
} else {
// the acceleration direction is defined in a dedicated frame
attitude = attitudeOverride.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
}
inertialDirection = attitude.getRotation().applyInverseTo(direction);
}
return new FieldVector3D<>(signedAmplitude(state, parameters), inertialDirection);
}
/** {@inheritDoc} */
@Override
public Stream<EventDetector> getEventsDetectors() {
return Stream.empty();
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(final Field<T> field) {
return Stream.empty();
}
}
......@@ -595,21 +595,25 @@ public class BoxAndSolarArraySpacecraft implements RadiationSensitive, DragSensi
/** {@inheritDoc} */
@Override
public ParameterDriver[] getDragParametersDrivers() {
return liftParameterDriver == null ?
new ParameterDriver[] {
dragParameterDriver
} : new ParameterDriver[] {
dragParameterDriver, liftParameterDriver
};
public List<ParameterDriver> getDragParametersDrivers() {
// Initialize list of drag parameter drivers
final List<ParameterDriver> drivers = new ArrayList<>();
drivers.add(dragParameterDriver);
// Verify if the driver for lift ratio parameter is defined
if (liftParameterDriver != null) {
drivers.add(liftParameterDriver);
}
return drivers;
}
/** {@inheritDoc} */
@Override
public ParameterDriver[] getRadiationParametersDrivers() {
return new ParameterDriver[] {
absorptionParameterDriver, reflectionParameterDriver
};
public List<ParameterDriver> getRadiationParametersDrivers() {
// Initialize list of drag parameter drivers
final List<ParameterDriver> drivers = new ArrayList<>();
drivers.add(absorptionParameterDriver);
drivers.add(reflectionParameterDriver);
return drivers;
}
/** Get solar array normal in spacecraft frame.
......
......@@ -16,6 +16,7 @@
*/
package org.orekit.forces;
import java.util.List;
import java.util.stream.Stream;
import org.hipparchus.Field;
......@@ -105,10 +106,10 @@ public interface ForceModel {
* @since 9.0
*/
default double[] getParameters() {
final ParameterDriver[] drivers = getParametersDrivers();
final double[] parameters = new double[drivers.length];
for (int i = 0; i < drivers.length; ++i) {
parameters[i] = drivers[i].getValue();
final List<ParameterDriver> drivers = getParametersDrivers();
final double[] parameters = new double[drivers.size()];
for (int i = 0; i < drivers.size(); ++i) {
parameters[i] = drivers.get(i).getValue();
}
return parameters;
}
......@@ -120,10 +121,10 @@ public interface ForceModel {
* @since 9.0
*/
default <T extends RealFieldElement<T>> T[] getParameters(final Field<T> field) {
final ParameterDriver[] drivers = getParametersDrivers();
final T[] parameters = MathArrays.buildArray(field, drivers.length);
for (int i = 0; i < drivers.length; ++i) {
parameters[i] = field.getZero().add(drivers[i].getValue());
final List<ParameterDriver> drivers = getParametersDrivers();
final T[] parameters = MathArrays.buildArray(field, drivers.size());
for (int i = 0; i < drivers.size(); ++i) {
parameters[i] = field.getZero().add(drivers.get(i).getValue());
}
return parameters;
}
......@@ -169,12 +170,12 @@ public interface ForceModel {
* @return drivers for force model parameters
* @since 8.0
*/
ParameterDriver[] getParametersDrivers();
List<ParameterDriver> getParametersDrivers();
/** Get parameter value from its name.
* @param name parameter name
* @return parameter value
* @since 8.0
* @since 8.0
*/
ParameterDriver getParameterDriver(String name);
......
/* Copyright 2002-2021 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.forces;
import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.MathUtils;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitInternalError;
import org.orekit.forces.empirical.HarmonicAccelerationModel;
import org.orekit.propagation.FieldSpacecraftState;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** This class implements a {@link AbstractParametricAcceleration parametric acceleration}
* with harmonic signed amplitude.
* @since 9.0
* @author Luc Maisonobe
* @deprecated as of 10.3, replaced by {@link HarmonicAccelerationModel}
*/
@Deprecated
public class HarmonicParametricAcceleration extends AbstractParametricAcceleration {
/** Amplitude scaling factor.
* <p>
* 2⁻²⁰ is the order of magnitude of third body perturbing acceleration.
* </p>
* <p>
* We use a power of 2 to avoid numeric noise introduction
* in the multiplications/divisions sequences.
* </p>
*/
private static final double AMPLITUDE_SCALE = FastMath.scalb(1.0, -20);
/** Phase scaling factor.
* <p>
* 2⁻²³ is the order of magnitude of an angle corresponding to one meter along
* track for a Low Earth Orbiting satellite.
* </p>
* <p>
* We use a power of 2 to avoid numeric noise introduction
* in the multiplications/divisions sequences.
* </p>
*/
private static final double PHASE_SCALE = FastMath.scalb(1.0, -23);
/** Drivers for the parameters. */
private final ParameterDriver[] drivers;
/** Reference date for computing phase. */
private AbsoluteDate referenceDate;
/** Angular frequency ω = 2kπ/T. */
private final double omega;
/** Simple constructor.
* <p>
* The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
* γ is parameter {@code 0} and represents the full amplitude, t is current
* date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
* harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
* The value t-t₀ is in seconds.
* </p>
* <p>
* The fundamental period {@code T} is often set to the Keplerian period of the
* orbit and the harmonic multiplier {@code k} is often set to 1 or 2. The model
* has two parameters, one for the full amplitude and one for the phase at reference
* date.
* </p>
* <p>
* The two parameters for this model are the full amplitude (parameter 0) and the
* phase at reference date (parameter 1). Their reference values (used also as the
* initial values) are both set to 0. User can change them before starting the
* propagation (or orbit determination) by calling {@link #getParametersDrivers()}
* and {@link ParameterDriver#setValue(double)}.
* </p>
* @param direction acceleration direction in defining frame
* @param isInertial if true, direction is defined in the same inertial
* frame used for propagation (i.e. {@link SpacecraftState#getFrame()}),
* otherwise direction is defined in spacecraft frame (i.e. using the
* propagation {@link
* org.orekit.propagation.Propagator#setAttitudeProvider(AttitudeProvider)
* attitude law})
* @param prefix prefix to use for parameter drivers
* @param referenceDate reference date for computing phase, if null
* the reference date will be automatically set at propagation start
* @param fundamentalPeriod fundamental period (typically set to initial orbit
* {@link org.orekit.orbits.Orbit#getKeplerianPeriod() Keplerian period})
* @param harmonicMultiplier multiplier to compute harmonic period from
* fundamental period)
*/
public HarmonicParametricAcceleration(final Vector3D direction, final boolean isInertial,
final String prefix, final AbsoluteDate referenceDate,
final double fundamentalPeriod, final int harmonicMultiplier) {
this(direction, isInertial, null, prefix, referenceDate,
fundamentalPeriod, harmonicMultiplier);
}
/** Simple constructor.
* <p>
* The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
* γ is parameter {@code 0} and represents the full amplitude, t is current
* date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
* harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
* The value t-t₀ is in seconds.
* </p>
* <p>
* The fundamental period {@code T} is often set to the Keplerian period of the
* orbit and the harmonic multiplier {@code k} is often set to 1 or 2. The model
* has two parameters, one for the full amplitude and one for the phase at reference
* date.
* </p>
* <p>
* The two parameters for this model are the full amplitude (parameter 0) and the
* phase at reference date (parameter 1). Their reference values (used also as the
* initial values) are both set to 0. User can change them before starting the
* propagation (or orbit determination) by calling {@link #getParametersDrivers()}
* and {@link ParameterDriver#setValue(double)}.
* </p>
* @param direction acceleration direction in overridden spacecraft frame
* @param attitudeOverride provider for attitude used to compute acceleration
* direction
* @param prefix prefix to use for parameter drivers
* @param referenceDate reference date for computing phase, if null
* the reference date will be automatically set at propagation start
* @param fundamentalPeriod fundamental period (typically set to initial orbit
* {@link org.orekit.orbits.Orbit#getKeplerianPeriod() Keplerian period})
* @param harmonicMultiplier multiplier to compute harmonic period from
* fundamental period)
*/
public HarmonicParametricAcceleration(final Vector3D direction, final AttitudeProvider attitudeOverride,
final String prefix, final AbsoluteDate referenceDate,
final double fundamentalPeriod, final int harmonicMultiplier) {
this(direction, false, attitudeOverride, prefix, referenceDate,
fundamentalPeriod, harmonicMultiplier);
}
/** Simple constructor.
* @param direction acceleration direction in overridden spacecraft frame
* @param isInertial if true, direction is defined in the same inertial
* frame used for propagation (i.e. {@link SpacecraftState#getFrame()}),
* otherwise direction is defined in spacecraft frame (i.e. using the
* propagation {@link
* org.orekit.propagation.Propagator#setAttitudeProvider(AttitudeProvider)
* attitude law})
* @param attitudeOverride provider for attitude used to compute acceleration
* direction
* @param prefix prefix to use for parameter drivers
* @param referenceDate reference date for computing polynomials, if null
* the reference date will be automatically set at propagation start
* @param fundamentalPeriod fundamental period (typically set to initial orbit
* {@link org.orekit.orbits.Orbit#getKeplerianPeriod() Keplerian period})
* @param harmonicMultiplier multiplier to compute harmonic period from
* fundamental period)
*/
private HarmonicParametricAcceleration(final Vector3D direction, final boolean isInertial,
final AttitudeProvider attitudeOverride,
final String prefix, final AbsoluteDate referenceDate,
final double fundamentalPeriod, final int harmonicMultiplier) {
super(direction, isInertial, attitudeOverride);
this.referenceDate = referenceDate;
this.omega = harmonicMultiplier * MathUtils.TWO_PI / fundamentalPeriod;
try {
drivers = new ParameterDriver[] {
new ParameterDriver(prefix + " γ",
0.0, AMPLITUDE_SCALE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY),
new ParameterDriver(prefix + " φ",
0.0, PHASE_SCALE, -MathUtils.TWO_PI, MathUtils.TWO_PI),
};
} catch (OrekitException oe) {
// this should never happen as scales are hard-coded
throw new OrekitInternalError(oe);
}
}
/** {@inheritDoc} */
@Override
public boolean dependsOnPositionOnly() {
return isInertial();
}
/** {@inheritDoc} */
@Override
public void init(final SpacecraftState initialState, final AbsoluteDate target) {
if (referenceDate == null) {
referenceDate = initialState.getDate();
}
}
/** {@inheritDoc}.
* The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
* γ is parameter {@code 0} and represents the full amplitude, t is current
* date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
* harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
* The value t-t₀ is in seconds.
*/
@Override
protected double signedAmplitude(final SpacecraftState state, final double[] parameters) {
final double dt = state.getDate().durationFrom(referenceDate);
return parameters[0] * FastMath.sin(dt * omega + parameters[1]);
}
/** {@inheritDoc}
* The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
* γ is parameter {@code 0} and represents the full amplitude, t is current
* date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
* harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
* The value t-t₀ is in seconds.
*/
@Override
protected <T extends RealFieldElement<T>> T signedAmplitude(final FieldSpacecraftState<T> state, final T[] parameters) {
final T dt = state.getDate().durationFrom(referenceDate);
return parameters[0].multiply(dt.multiply(omega).add(parameters[1]).sin());
}
/** {@inheritDoc} */
@Override
public ParameterDriver[] getParametersDrivers() {
return drivers.clone();
}
}
/* Copyright 2002-2021 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.forces;
import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.forces.empirical.PolynomialAccelerationModel;
import org.orekit.propagation.FieldSpacecraftState;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** This class implements a {@link AbstractParametricAcceleration parametric acceleration}
* with polynomial signed amplitude.
* @since 9.0
* @author Luc Maisonobe
* @deprecated as of 10.3, replaced by {@link PolynomialAccelerationModel}
*/
@Deprecated
public class PolynomialParametricAcceleration extends AbstractParametricAcceleration {
/** Acceleration scaling factor.
* <p>
* 2⁻²⁰ is the order of magnitude of third body perturbing acceleration.
* </p>
* <p>
* We use a power of 2 to avoid numeric noise introduction
* in the multiplications/divisions sequences.
* </p>
*/
private static final double ACCELERATION_SCALE = FastMath.scalb(1.0, -20);
/** Drivers for the polynomial coefficients. */
private final ParameterDriver[] drivers;
/** Reference date for computing polynomials. */
private AbsoluteDate referenceDate;
/** Simple constructor.
* <p>
* The signed amplitude of the acceleration is ∑pₙ(t-t₀)ⁿ, where
* pₙ is parameter {@code n}, t is current date and t₀ is reference date.