org.opensourcephysics.numerics.qss
Class Qss

java.lang.Object
  extended by org.opensourcephysics.numerics.qss.Qss
All Implemented Interfaces:
ODESolverInterpolator
Direct Known Subclasses:
Qss2

public class Qss
extends java.lang.Object
implements ODESolverInterpolator

An abstract class for Solvers based on QSS method

Author:
Francisco Esquembre, Ernesto Kofman

Constructor Summary
Qss(ODE ode)
           
 
Method Summary
 double[] bestInterpolate(double _time, double[] _state)
          Similar to interpolate(), but using the best estimate the algorith can provide and only between the current time and getMaximumTime().
 long getCounter()
          Returns the number of function evaluations required by the method to reach the tolerance
 double[] getCurrentRate()
          Returns the rate of the current state
 double getInternalStepSize()
          Returns the actual internal step size
 double getMaximumTime()
          Returns the maximum time forward in time (or minimum, if the step is negative) for which the solver can interpolate without doing any internal step.
 ODE getODE()
          Returns the ODE with which it was created.
 StateMemory getStateMemory()
          Provides access to the internal StateMemory responsible for interpolations.
 double getStepSize()
          Returns the current step size
 void initialize(double _stepSize)
          Initializes the interpolator and clears the memory.
 double internalStep()
          Steps the internal step as much as possible (respecting the step size and the tolerance, if any).
 double[] interpolate(double time, boolean useLeftApproximation, double[] state)
          Returns the value of the ODE's state[] at the given time in the provided state[] array.
 double[] interpolate(double time, boolean useLeftApproximation, double[] state, int beginIndex, int length)
           
 double interpolate(double time, boolean useLeftApproximation, int index)
           
 void reinitialize(double[] state)
          Does the minimum (soft) initialization of the solver to a given state.
 void setEstimateFirstStep(boolean _estimate)
          Makes adaptive steps estimate the best initial step after reinitialize().
 void setMaximumStepSize(double stepSize)
          Does nothing
 void setMemoryLength(double length)
          Sets the length of the memory requested to the solver.
 void setStepSize(double _stepSize)
          Changes the internal step size.
 void setToleranceArray(double[] absTol, double[] relTol)
          Sets a possibly different tolerance for each state
 void setTolerances(double absTol, double relTol)
          Sets the same relative and absolute tolerances for all states
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Qss

public Qss(ODE ode)
Method Detail

getODE

public final ODE getODE()
Description copied from interface: ODESolverInterpolator
Returns the ODE with which it was created.

Specified by:
getODE in interface ODESolverInterpolator
Returns:

getCurrentRate

public final double[] getCurrentRate()
Description copied from interface: ODESolverInterpolator
Returns the rate of the current state

Specified by:
getCurrentRate in interface ODESolverInterpolator
Returns:

setEstimateFirstStep

public final void setEstimateFirstStep(boolean _estimate)
Description copied from interface: ODESolverInterpolator
Makes adaptive steps estimate the best initial step after reinitialize(). If false, the given initial step (as set by setStepSize()) is used.

Specified by:
setEstimateFirstStep in interface ODESolverInterpolator

getStepSize

public final double getStepSize()
Description copied from interface: ODESolverInterpolator
Returns the current step size

Specified by:
getStepSize in interface ODESolverInterpolator
Returns:

setStepSize

public final void setStepSize(double _stepSize)
Description copied from interface: ODESolverInterpolator
Changes the internal step size. This is the step at which internal steps are computed for fixed step methods, and the initial step size (after reinitialize()) for variable step methods.

Specified by:
setStepSize in interface ODESolverInterpolator

setMaximumStepSize

public void setMaximumStepSize(double stepSize)
Does nothing

Specified by:
setMaximumStepSize in interface ODESolverInterpolator

initialize

public void initialize(double _stepSize)
Description copied from interface: ODESolverInterpolator
Initializes the interpolator and clears the memory. Implementing classes typically use this method to declare arrays, initialize the underlying ODESolver, set its step size, and call reinitialize().

Specified by:
initialize in interface ODESolverInterpolator

reinitialize

public void reinitialize(double[] state)
Description copied from interface: ODESolverInterpolator
Does the minimum (soft) initialization of the solver to a given state. The memory is preserved. Users of an ODESolverInterpolator MUST call reinitialize (or the harder initialize) whenever they change the state. Typically, solvers synchronize their internal states and auxiliary variables using the provided state.

Specified by:
reinitialize in interface ODESolverInterpolator
Parameters:
state - double[]

getMaximumTime

public double getMaximumTime()
Description copied from interface: ODESolverInterpolator
Returns the maximum time forward in time (or minimum, if the step is negative) for which the solver can interpolate without doing any internal step.

Specified by:
getMaximumTime in interface ODESolverInterpolator
Returns:
double The maximum advance time or NaN if there was any error.

getInternalStepSize

public double getInternalStepSize()
Description copied from interface: ODESolverInterpolator
Returns the actual internal step size

Specified by:
getInternalStepSize in interface ODESolverInterpolator
Returns:

internalStep

public double internalStep()
Description copied from interface: ODESolverInterpolator
Steps the internal step as much as possible (respecting the step size and the tolerance, if any).

Specified by:
internalStep in interface ODESolverInterpolator
Returns:
double Same as getMaximumTime()

setMemoryLength

public void setMemoryLength(double length)
Description copied from interface: ODESolverInterpolator
Sets the length of the memory requested to the solver. Must be a positive value. The user will then be able to ask for values of the state as far as the current time minus this length. 0 is the default for plain ODE, getMaximumDelay() is the minimum used by DDEs. Setting a value of Infinity makes the solver to remmeber for ever (i.e. as much as computer memory permits)

Specified by:
setMemoryLength in interface ODESolverInterpolator

getStateMemory

public StateMemory getStateMemory()
Description copied from interface: ODESolverInterpolator
Provides access to the internal StateMemory responsible for interpolations.

Specified by:
getStateMemory in interface ODESolverInterpolator
Returns:

interpolate

public double[] interpolate(double time,
                            boolean useLeftApproximation,
                            double[] state)
Description copied from interface: ODESolverInterpolator
Returns the value of the ODE's state[] at the given time in the provided state[] array. The time must be in the range of the memory or between the current time and getMaximumTime() for correct operation.

Specified by:
interpolate in interface ODESolverInterpolator
Parameters:
time - the time for the interpolation desired
useLeftApproximation - In case of doubt, approximate the value from the left (this is important if the state has a discontinuity at that instant of time, such as for DDEs)
state - placeholder for the returned state
Returns:
The state provided as argument or null if there is no interpolation available at this time.

interpolate

public double[] interpolate(double time,
                            boolean useLeftApproximation,
                            double[] state,
                            int beginIndex,
                            int length)

interpolate

public double interpolate(double time,
                          boolean useLeftApproximation,
                          int index)

bestInterpolate

public double[] bestInterpolate(double _time,
                                double[] _state)
Description copied from interface: ODESolverInterpolator
Similar to interpolate(), but using the best estimate the algorith can provide and only between the current time and getMaximumTime(). In some RK schemes, this results in computing the RK algorithm from the initial point. Therefore, this method typically involves a bigger computational load.

Specified by:
bestInterpolate in interface ODESolverInterpolator
Returns:
The state provided as argument or null if there was any previous error.

setTolerances

public final void setTolerances(double absTol,
                                double relTol)
Sets the same relative and absolute tolerances for all states

Specified by:
setTolerances in interface ODESolverInterpolator
Parameters:
tol - double

setToleranceArray

public void setToleranceArray(double[] absTol,
                              double[] relTol)
Sets a possibly different tolerance for each state

Parameters:
tol - double[]

getCounter

public long getCounter()
Description copied from interface: ODESolverInterpolator
Returns the number of function evaluations required by the method to reach the tolerance

Specified by:
getCounter in interface ODESolverInterpolator
Returns: