Class ExplicitRK23Solver
- java.lang.Object
-
- ptolemy.domains.continuous.kernel.ContinuousODESolver
-
- ptolemy.domains.continuous.kernel.solver.ExplicitRK23Solver
-
public class ExplicitRK23Solver extends ContinuousODESolver
This class implements the Explicit Runge-Kutta 2(3) ODE solving method. For an ODE of the form:dx/dt = f(x, t), x(0) = x0
it does the following:K0 = f(x(n), tn); K1 = f(x(n)+0.5*h*K0, tn+0.5*h); K2 = f(x(n)+0.75*h*K1, tn+0.75*h); x(n+1) = x(n)+(2/9)*h*K0+(1/3)*h*K0+(4/9)*h*K2; K3 = f(x(n+1), tn+h);
, and error control:LTE = h*[(-5.0/72.0)*K0 + (1.0/12.0)*K1 + (1.0/9.0)*K2 + (-1.0/8.0)*K3]
If the LTE is less than the error tolerance, then this step is considered successful, and the next integration step is predicted as:
h' = 0.8*Math.pow((ErrorTolerance/LTE), 1.0/3.0)
This is a second order method, but uses a third order procedure to estimate the local truncation error.- Since:
- Ptolemy II 6.0
- Version:
- $Id$
- Author:
- Jie Liu, Haiyang Zheng, Edward A. Lee
- Pt.AcceptedRating:
- Green (hyzheng)
- Pt.ProposedRating:
- Green (hyzheng)
-
-
Field Summary
Fields Modifier and Type Field Description protected static double[]
_TIME_INCREMENTS
The ratio of time increments within one integration step.-
Fields inherited from class ptolemy.domains.continuous.kernel.ContinuousODESolver
_director
-
-
Constructor Summary
Constructors Constructor Description ExplicitRK23Solver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
_getRound()
Return the current round.protected double
_getRoundTimeIncrement()
Get the current round factor.protected boolean
_isStepFinished()
Return true if the current integration step is finished.protected void
_reset()
Reset the solver, indicating to it that we are starting an integration step.protected void
_setRound(int round)
Set the round for the next integration step.int
getIntegratorAuxVariableCount()
Return the number of time increments plus one (to store the truncation error).void
integratorIntegrate(ContinuousIntegrator integrator)
Fire the given integrator.boolean
integratorIsAccurate(ContinuousIntegrator integrator)
Return true if the integration is accurate for the given integrator.double
integratorSuggestedStepSize(ContinuousIntegrator integrator)
Provide the predictedStepSize() method for the integrators under this solver.-
Methods inherited from class ptolemy.domains.continuous.kernel.ContinuousODESolver
_debug, _isDebugging, _makeSolverOf
-
-
-
-
Method Detail
-
getIntegratorAuxVariableCount
public final int getIntegratorAuxVariableCount()
Return the number of time increments plus one (to store the truncation error).- Specified by:
getIntegratorAuxVariableCount
in classContinuousODESolver
- Returns:
- The number of time increments plus one.
-
integratorIntegrate
public void integratorIntegrate(ContinuousIntegrator integrator) throws IllegalActionException
Fire the given integrator. This method performs the ODE solving algorithm described in the class comment.- Specified by:
integratorIntegrate
in classContinuousODESolver
- Parameters:
integrator
- The integrator of that calls this method.- Throws:
IllegalActionException
- If there is no director, or can not read input, or can not send output.
-
integratorIsAccurate
public boolean integratorIsAccurate(ContinuousIntegrator integrator)
Return true if the integration is accurate for the given integrator. This estimates the local truncation error for that integrator and compare it with the error tolerance.- Specified by:
integratorIsAccurate
in classContinuousODESolver
- Parameters:
integrator
- The integrator of that calls this method.- Returns:
- True if the integration is successful.
-
integratorSuggestedStepSize
public double integratorSuggestedStepSize(ContinuousIntegrator integrator)
Provide the predictedStepSize() method for the integrators under this solver. It uses the algorithm in the class comments to predict the next step size based on the current estimation of the local truncation error.- Specified by:
integratorSuggestedStepSize
in classContinuousODESolver
- Parameters:
integrator
- The integrator of that calls this method.- Returns:
- The next step size suggested by the given integrator.
-
_getRound
protected int _getRound()
Return the current round.- Specified by:
_getRound
in classContinuousODESolver
- Returns:
- The current round.
-
_getRoundTimeIncrement
protected final double _getRoundTimeIncrement()
Get the current round factor.- Specified by:
_getRoundTimeIncrement
in classContinuousODESolver
- Returns:
- The current round factor.
- See Also:
ContinuousODESolver._isStepFinished()
-
_isStepFinished
protected final boolean _isStepFinished()
Return true if the current integration step is finished. This method will return true if _incrementRound() has been called 4 or more times since _reset().- Specified by:
_isStepFinished
in classContinuousODESolver
- Returns:
- Return true if the solver has finished an integration step.
- See Also:
_reset()
-
_reset
protected final void _reset()
Reset the solver, indicating to it that we are starting an integration step. This method resets the round counter.- Specified by:
_reset
in classContinuousODESolver
-
_setRound
protected void _setRound(int round)
Set the round for the next integration step.- Specified by:
_setRound
in classContinuousODESolver
- Parameters:
round
- The round for the next integration step.- See Also:
ContinuousODESolver.getIntegratorAuxVariableCount()
-
-