Package cnuphys.rk4
Class RungeKuttaZ
java.lang.Object
cnuphys.rk4.RungeKuttaZ
Static methods for Runge-Kutta 4 integration, including a constant stepsize
 method and an adaptive stepsize method.
- Author:
- heddle
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintadaptiveStepToTf(double[] yo, double to, double tf, double h, IDerivative deriv, IStopper stopper, IRkListener listener, double[] relTolerance, double[] hdata) Integrator that uses the RungeKutta advance with a Butcher Tableau and adaptive stepsize This version uses an IRk4Listener to notify the listener that the next step has been advanced.intadaptiveStepToTf(double[] yo, double to, double tf, double h, List<Double> t, List<double[]> y, IDerivative deriv, IStopper stopper, double[] relTolerance, double[] hdata) Integrator that uses the RungeKutta advance with a Butcher Tableau and adaptive stepsize and a tolerance vector.doubleGet the maximum step sizedoubleGet the minimum step sizevoidsetMaxStepSize(double maxSS) Set the maximum step sizevoidsetMinStepSize(double minSS) Set the minimum step size
- 
Field Details- 
DEFMINSTEPSIZEpublic static double DEFMINSTEPSIZE
- 
DEFMAXSTEPSIZEpublic static double DEFMAXSTEPSIZE
 
- 
- 
Constructor Details- 
RungeKuttaZpublic RungeKuttaZ()Create a RungeKutta object that can be used for integration
 
- 
- 
Method Details- 
adaptiveStepToTfpublic int adaptiveStepToTf(double[] yo, double to, double tf, double h, List<Double> t, List<double[]> y, IDerivative deriv, IStopper stopper, double[] relTolerance, double[] hdata) throws RungeKuttaException Integrator that uses the RungeKutta advance with a Butcher Tableau and adaptive stepsize and a tolerance vector. This version uses an IRk4Listener to notify the listener that the next step has been advanced. A very typical case is a 2nd order ODE converted to a 1st order where the dependent variables are x, y, z, vx, vy, vz and the independent variable is time.- Parameters:
- yo- initial values. Probably something like (xo, yo, zo, vxo, vyo, vzo).
- to- the initial value of the independent variable, e.g., time.
- tf- the maximum value of the independent variable.
- h- the starting steps size
- t- a list of the values of t at each step
- y- a list of the values of the state vector at each step
- deriv- the derivative computer (interface). This is where the problem specificity resides.
- stopper- if not- nullwill be used to exit the integration early because some condition has been reached.
- relTolerance- the error tolerance as fractional diffs. Note it is a vector, the same dimension of the problem, e.g., 6 for [x,y,z,vx,vy,vz].
- hdata- if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used, hdata[1] is the average stepsize used, and hdata[2] is the max stepsize used
- Returns:
- the number of steps used.
- Throws:
- RungeKuttaException
 
- 
adaptiveStepToTfpublic int adaptiveStepToTf(double[] yo, double to, double tf, double h, IDerivative deriv, IStopper stopper, IRkListener listener, double[] relTolerance, double[] hdata) throws RungeKuttaException Integrator that uses the RungeKutta advance with a Butcher Tableau and adaptive stepsize This version uses an IRk4Listener to notify the listener that the next step has been advanced. A very typical case is a 2nd order ODE converted to a 1st order where the dependent variables are x, y, z, vx, vy, vz and the independent variable is time.- Parameters:
- yo- initial values. Probably something like (xo, yo, zo, vxo, vyo, vzo).
- to- the initial value of the independent variable, e.g., time.
- tf- the maximum value of the independent variable.
- h- the starting steps size
- deriv- the derivative computer (interface). This is where the problem specificity resides.
- stopper- if not- nullwill be used to exit the integration early because some condition has been reached.
- listener- listens for each step * @param tableau the Butcher Tableau
- relTolerance- the error tolerance as fractional diffs. Note it is a vector, the same
- hdata- if not null, should be double[3]. Upon return, hdata[0] is the min stepsize used, hdata[1] is the average stepsize used, and hdata[2] is the max stepsize used
- Returns:
- the number of steps used.
- Throws:
- RungeKuttaException
 
- 
setMaxStepSizepublic void setMaxStepSize(double maxSS) Set the maximum step size- Parameters:
- maxSS- the maximum stepsize is whatever units you are using
 
- 
setMinStepSizepublic void setMinStepSize(double minSS) Set the minimum step size- Parameters:
- maxSS- the minimum stepsize is whatever units you are using
 
- 
getMaxStepSizepublic double getMaxStepSize()Get the maximum step size- Returns:
- the maximum stepsize is whatever units you are using
 
- 
getMinStepSizepublic double getMinStepSize()Get the minimum step size- Returns:
- the minimum stepsize is whatever units you are using
 
 
-