Class RungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
- java.lang.Object
-
- org.apache.commons.math4.legacy.ode.AbstractFieldIntegrator<T>
-
- org.apache.commons.math4.legacy.ode.nonstiff.RungeKuttaFieldIntegrator<T>
-
- Type Parameters:
T
- the type of the field elements
- All Implemented Interfaces:
FirstOrderFieldIntegrator<T>
,FieldButcherArrayProvider<T>
- Direct Known Subclasses:
ClassicalRungeKuttaFieldIntegrator
,EulerFieldIntegrator
,GillFieldIntegrator
,LutherFieldIntegrator
,MidpointFieldIntegrator
,ThreeEighthesFieldIntegrator
public abstract class RungeKuttaFieldIntegrator<T extends RealFieldElement<T>> extends AbstractFieldIntegrator<T> implements FieldButcherArrayProvider<T>
This class implements the common part of all fixed step Runge-Kutta integrators for Ordinary Differential Equations.These methods are explicit Runge-Kutta methods, their Butcher arrays are as follows :
0 | c2 | a21 c3 | a31 a32 ... | ... cs | as1 as2 ... ass-1 |-------------------------- | b1 b2 ... bs-1 bs
- Since:
- 3.6
- See Also:
EulerFieldIntegrator
,ClassicalRungeKuttaFieldIntegrator
,GillFieldIntegrator
,MidpointFieldIntegrator
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RungeKuttaFieldIntegrator(Field<T> field, String name, T step)
Simple constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract org.apache.commons.math4.legacy.ode.nonstiff.RungeKuttaFieldStepInterpolator<T>
createInterpolator(boolean forward, T[][] yDotK, FieldODEStateAndDerivative<T> globalPreviousState, FieldODEStateAndDerivative<T> globalCurrentState, FieldEquationsMapper<T> mapper)
Create an interpolator.protected T
fraction(int p, int q)
Create a fraction.FieldODEStateAndDerivative<T>
integrate(FieldExpandableODE<T> equations, FieldODEState<T> initialState, T finalTime)
Integrate the differential equations up to the given time.T[]
singleStep(FirstOrderFieldDifferentialEquations<T> equations, T t0, T[] y0, T t)
Fast computation of a single step of ODE integration.-
Methods inherited from class org.apache.commons.math4.legacy.ode.AbstractFieldIntegrator
acceptStep, addEventHandler, addEventHandler, addStepHandler, clearEventHandlers, clearStepHandlers, computeDerivatives, getCurrentSignedStepsize, getCurrentStepStart, getEquations, getEvaluations, getEvaluationsCounter, getEventHandlers, getField, getMaxEvaluations, getName, getStepHandlers, getStepSize, getStepStart, initIntegration, isLastStep, resetOccurred, sanityChecks, setIsLastStep, setMaxEvaluations, setStateInitialized, setStepSize, setStepStart
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math4.legacy.ode.nonstiff.FieldButcherArrayProvider
getA, getB, getC
-
-
-
-
Constructor Detail
-
RungeKuttaFieldIntegrator
protected RungeKuttaFieldIntegrator(Field<T> field, String name, T step)
Simple constructor. Build a Runge-Kutta integrator with the given step. The default step handler does nothing.- Parameters:
field
- field to which the time and state vector elements belongname
- name of the methodstep
- integration step
-
-
Method Detail
-
fraction
protected T fraction(int p, int q)
Create a fraction.- Parameters:
p
- numeratorq
- denominator- Returns:
- p/q computed in the instance field
-
createInterpolator
protected abstract org.apache.commons.math4.legacy.ode.nonstiff.RungeKuttaFieldStepInterpolator<T> createInterpolator(boolean forward, T[][] yDotK, FieldODEStateAndDerivative<T> globalPreviousState, FieldODEStateAndDerivative<T> globalCurrentState, FieldEquationsMapper<T> mapper)
Create an interpolator.- Parameters:
forward
- integration direction indicatoryDotK
- slopes at the intermediate pointsglobalPreviousState
- start of the global stepglobalCurrentState
- end of the global stepmapper
- equations mapper for the all equations- Returns:
- external weights for the high order method from Butcher array
-
integrate
public FieldODEStateAndDerivative<T> integrate(FieldExpandableODE<T> equations, FieldODEState<T> initialState, T finalTime) throws NumberIsTooSmallException, DimensionMismatchException, MaxCountExceededException, NoBracketingException
Integrate the differential equations up to the given time.This method solves an Initial Value Problem (IVP).
Since this method stores some internal state variables made available in its public interface during integration (
FirstOrderFieldIntegrator.getCurrentSignedStepsize()
), it is not thread-safe.- Specified by:
integrate
in interfaceFirstOrderFieldIntegrator<T extends RealFieldElement<T>>
- Parameters:
equations
- differential equations to integrateinitialState
- initial state (time, primary and secondary state vectors)finalTime
- target time for the integration (can be set to a value smaller thant0
for backward integration)- Returns:
- final state, its time will be the same as
finalTime
if integration reached its target, but may be different if someFieldEventHandler
stops it at some point. - Throws:
NumberIsTooSmallException
- if integration step is too smallMaxCountExceededException
- if the number of functions evaluations is exceededNoBracketingException
- if the location of an event cannot be bracketedDimensionMismatchException
-
singleStep
public T[] singleStep(FirstOrderFieldDifferentialEquations<T> equations, T t0, T[] y0, T t)
Fast computation of a single step of ODE integration.This method is intended for the limited use case of very fast computation of only one step without using any of the rich features of general integrators that may take some time to set up (i.e. no step handlers, no events handlers, no additional states, no interpolators, no error control, no evaluations count, no sanity checks ...). It handles the strict minimum of computation, so it can be embedded in outer loops.
This method is not used at all by the
integrate(FieldExpandableODE, FieldODEState, RealFieldElement)
method. It also completely ignores the step set at construction time, and uses only a single step to go fromt0
tot
.As this method does not use any of the state-dependent features of the integrator, it should be reasonably thread-safe if and only if the provided differential equations are themselves thread-safe.
- Parameters:
equations
- differential equations to integratet0
- initial timey0
- initial value of the state vector at t0t
- target time for the integration (can be set to a value smaller thant0
for backward integration)- Returns:
- state vector at
t
-
-