Provide access to state derivatives in ContinuousOutputModel.
JIRA: MATH-1160
This commit is contained in:
parent
79ae77fda8
commit
25aa4bd366
|
@ -73,6 +73,9 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
2. A few methods in the FastMath class are in fact slower that their
|
2. A few methods in the FastMath class are in fact slower that their
|
||||||
counterpart in either Math or StrictMath (cf. MATH-740 and MATH-901).
|
counterpart in either Math or StrictMath (cf. MATH-740 and MATH-901).
|
||||||
">
|
">
|
||||||
|
<action dev="luc" type="fix" issue="MATH-1160" >
|
||||||
|
Provide access to state derivatives in ContinuousOutputModel.
|
||||||
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1138" due-to="Hank Grabowski">
|
<action dev="luc" type="fix" issue="MATH-1138" due-to="Hank Grabowski">
|
||||||
Fixed bicubic spline interpolator, using Akima splines.
|
Fixed bicubic spline interpolator, using Akima splines.
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -332,12 +332,25 @@ public class ContinuousOutputModel
|
||||||
* Get the state vector of the interpolated point.
|
* Get the state vector of the interpolated point.
|
||||||
* @return state vector at time {@link #getInterpolatedTime}
|
* @return state vector at time {@link #getInterpolatedTime}
|
||||||
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
|
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
|
||||||
|
* @see #getInterpolatedDerivatives()
|
||||||
* @see #getInterpolatedSecondaryState(int)
|
* @see #getInterpolatedSecondaryState(int)
|
||||||
*/
|
*/
|
||||||
public double[] getInterpolatedState() throws MaxCountExceededException {
|
public double[] getInterpolatedState() throws MaxCountExceededException {
|
||||||
return steps.get(index).getInterpolatedState();
|
return steps.get(index).getInterpolatedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the derivatives of the state vector of the interpolated point.
|
||||||
|
* @return derivatives of the state vector at time {@link #getInterpolatedTime}
|
||||||
|
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
|
||||||
|
* @see #getInterpolatedState()
|
||||||
|
* @see #getInterpolatedSecondaryState(int)
|
||||||
|
* @since 3.4
|
||||||
|
*/
|
||||||
|
public double[] getInterpolatedDerivatives() throws MaxCountExceededException {
|
||||||
|
return steps.get(index).getInterpolatedDerivatives();
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the interpolated secondary state corresponding to the secondary equations.
|
/** Get the interpolated secondary state corresponding to the secondary equations.
|
||||||
* @param secondaryStateIndex index of the secondary set, as returned by {@link
|
* @param secondaryStateIndex index of the secondary set, as returned by {@link
|
||||||
* org.apache.commons.math3.ode.ExpandableStatefulODE#addSecondaryEquations(
|
* org.apache.commons.math3.ode.ExpandableStatefulODE#addSecondaryEquations(
|
||||||
|
@ -345,6 +358,7 @@ public class ContinuousOutputModel
|
||||||
* ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)}
|
* ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)}
|
||||||
* @return interpolated secondary state at the current interpolation date
|
* @return interpolated secondary state at the current interpolation date
|
||||||
* @see #getInterpolatedState()
|
* @see #getInterpolatedState()
|
||||||
|
* @see #getInterpolatedDerivatives()
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
|
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -63,22 +63,29 @@ public class ContinuousOutputModelTest {
|
||||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||||
|
|
||||||
Random random = new Random(347588535632l);
|
Random random = new Random(347588535632l);
|
||||||
double maxError = 0.0;
|
double maxError = 0.0;
|
||||||
|
double maxErrorDot = 0.0;
|
||||||
for (int i = 0; i < 1000; ++i) {
|
for (int i = 0; i < 1000; ++i) {
|
||||||
double r = random.nextDouble();
|
double r = random.nextDouble();
|
||||||
double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
|
double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
|
||||||
cm.setInterpolatedTime(time);
|
cm.setInterpolatedTime(time);
|
||||||
double[] interpolatedY = cm.getInterpolatedState ();
|
double[] interpolatedY = cm.getInterpolatedState();
|
||||||
double[] theoreticalY = pb.computeTheoreticalState(time);
|
double[] interpolatedYDot = cm.getInterpolatedDerivatives();
|
||||||
|
double[] theoreticalY = pb.computeTheoreticalState(time);
|
||||||
|
double[] theoreticalYDot = new double[pb.getDimension()];
|
||||||
|
pb.doComputeDerivatives(time, theoreticalY, theoreticalYDot);
|
||||||
double dx = interpolatedY[0] - theoreticalY[0];
|
double dx = interpolatedY[0] - theoreticalY[0];
|
||||||
double dy = interpolatedY[1] - theoreticalY[1];
|
double dy = interpolatedY[1] - theoreticalY[1];
|
||||||
double error = dx * dx + dy * dy;
|
double error = dx * dx + dy * dy;
|
||||||
if (error > maxError) {
|
maxError = FastMath.max(maxError, error);
|
||||||
maxError = error;
|
double dxDot = interpolatedYDot[0] - theoreticalYDot[0];
|
||||||
}
|
double dyDot = interpolatedYDot[1] - theoreticalYDot[1];
|
||||||
|
double errorDot = dxDot * dxDot + dyDot * dyDot;
|
||||||
|
maxErrorDot = FastMath.max(maxErrorDot, errorDot);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue(maxError < 1.0e-9);
|
Assert.assertEquals(0.0, maxError, 1.0e-9);
|
||||||
|
Assert.assertEquals(0.0, maxErrorDot, 4.0e-7);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue