delayed integrator internal state update after the call to step handler
to ensure integrator.getStepStart() and interpolator.getPreviousTime() are consistent. renamed getStepsize() into getSignedStepsize() git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@591661 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c9272ec872
commit
2071918a7a
|
@ -332,7 +332,7 @@ public abstract class AdaptiveStepsizeIntegrator
|
|||
return stepStart;
|
||||
}
|
||||
|
||||
public double getCurrentStepsize() {
|
||||
public double getCurrentSignedStepsize() {
|
||||
return stepSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public interface FirstOrderIntegrator {
|
|||
* <p>This method solves an Initial Value Problem (IVP).</p>
|
||||
* <p>Since this method stores some internal state variables made
|
||||
* available in its public interface during integration ({@link
|
||||
* #getCurrentStepsize()}), it is <em>not</em> thread-safe.</p>
|
||||
* #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p>
|
||||
* @param equations differential equations to integrate
|
||||
* @param t0 initial time
|
||||
* @param y0 initial value of the state vector at t0
|
||||
|
@ -95,15 +95,15 @@ public interface FirstOrderIntegrator {
|
|||
*/
|
||||
public double getCurrentStepStart();
|
||||
|
||||
/** Get the current value of the integration stepsize.
|
||||
/** Get the current signed value of the integration stepsize.
|
||||
* <p>This method can be called during integration (typically by
|
||||
* the object implementing the {@link FirstOrderDifferentialEquations
|
||||
* differential equations} problem) if the value of the current stepsize
|
||||
* differential equations} problem) if the signed value of the current stepsize
|
||||
* that is tried is needed.</p>
|
||||
* <p>The result is undefined if the method is called outside of
|
||||
* calls to {@link #integrate}</p>
|
||||
* @return current value of the stepsize
|
||||
* @return current signed value of the stepsize
|
||||
*/
|
||||
public double getCurrentStepsize();
|
||||
public double getCurrentSignedStepsize();
|
||||
|
||||
}
|
||||
|
|
|
@ -850,17 +850,18 @@ public class GraggBulirschStoerIntegrator
|
|||
if (! reject) {
|
||||
|
||||
// store end of step state
|
||||
stepStart += stepSize;
|
||||
double nextStep = stepStart + stepSize;
|
||||
System.arraycopy(y1, 0, y, 0, y0.length);
|
||||
|
||||
switchesHandler.stepAccepted(stepStart, y);
|
||||
switchesHandler.stepAccepted(nextStep, y);
|
||||
if (switchesHandler.stop()) {
|
||||
lastStep = true;
|
||||
}
|
||||
|
||||
// provide the step data to the step handler
|
||||
interpolator.storeTime(stepStart);
|
||||
interpolator.storeTime(nextStep);
|
||||
handler.handleStep(interpolator, lastStep);
|
||||
stepStart = nextStep;
|
||||
|
||||
if (switchesHandler.reset(stepStart, y) && ! lastStep) {
|
||||
// some switching function has triggered changes that
|
||||
|
|
|
@ -274,18 +274,19 @@ public abstract class RungeKuttaFehlbergIntegrator
|
|||
}
|
||||
|
||||
// the step has been accepted
|
||||
stepStart += stepSize;
|
||||
double nextStep = stepStart + stepSize;
|
||||
System.arraycopy(yTmp, 0, y, 0, y0.length);
|
||||
switchesHandler.stepAccepted(stepStart, y);
|
||||
switchesHandler.stepAccepted(nextStep, y);
|
||||
if (switchesHandler.stop()) {
|
||||
lastStep = true;
|
||||
} else {
|
||||
lastStep = forward ? (stepStart >= t) : (stepStart <= t);
|
||||
lastStep = forward ? (nextStep >= t) : (nextStep <= t);
|
||||
}
|
||||
|
||||
// provide the step data to the step handler
|
||||
interpolator.storeTime(stepStart);
|
||||
interpolator.storeTime(nextStep);
|
||||
handler.handleStep(interpolator, lastStep);
|
||||
stepStart = nextStep;
|
||||
|
||||
if (fsal) {
|
||||
// save the last evaluation for the next step
|
||||
|
|
|
@ -219,9 +219,9 @@ public abstract class RungeKuttaIntegrator
|
|||
}
|
||||
|
||||
// the step has been accepted
|
||||
stepStart += stepSize;
|
||||
double nextStep = stepStart + stepSize;
|
||||
System.arraycopy(yTmp, 0, y, 0, y0.length);
|
||||
switchesHandler.stepAccepted(stepStart, y);
|
||||
switchesHandler.stepAccepted(nextStep, y);
|
||||
if (switchesHandler.stop()) {
|
||||
lastStep = true;
|
||||
} else {
|
||||
|
@ -229,8 +229,9 @@ public abstract class RungeKuttaIntegrator
|
|||
}
|
||||
|
||||
// provide the step data to the step handler
|
||||
interpolator.storeTime(stepStart);
|
||||
interpolator.storeTime(nextStep);
|
||||
handler.handleStep(interpolator, lastStep);
|
||||
stepStart = nextStep;
|
||||
|
||||
if (switchesHandler.reset(stepStart, y) && ! lastStep) {
|
||||
// some switching function has triggered changes that
|
||||
|
@ -256,7 +257,7 @@ public abstract class RungeKuttaIntegrator
|
|||
return stepStart;
|
||||
}
|
||||
|
||||
public double getCurrentStepsize() {
|
||||
public double getCurrentSignedStepsize() {
|
||||
return stepSize;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue