"FixedStep" Method for NDSolve
"FixedStep" Method for NDSolve
Introduction
It is often useful to carry out a numerical integration using fixed step sizes.
For example, certain methods such as "DoubleStep" and "Extrapolation" carry out a sequence of fixed-step integrations before combining the solutions to obtain a more accurate method with an error estimate that allows adaptive step sizes to be taken.
The method "FixedStep" allows any one-step integration method to be invoked using fixed step sizes.
This loads a package with some example problems and a package with some utility functions.
Needs["DifferentialEquations`NDSolveProblems`"];
Needs["DifferentialEquations`NDSolveUtilities`"];Examples
system = GetNDSolveProblem["BrusselatorODE"]This integrates a differential system using the method "ExplicitEuler" with a fixed step size of 1/10:
NDSolve[{y''[t] == -y[t], y[0] == 1, y'[0] == 0}, y, {t, 0, 1}, StartingStepSize -> 1 / 10, Method -> {"FixedStep", Method -> "ExplicitEuler"}]Actually the "ExplicitEuler" method has no adaptive step size control. Therefore, the integration is already carried out using fixed step sizes so the specification of "FixedStep" is unnecessary:
sol = NDSolve[system, StartingStepSize -> 1 / 10, Method -> "ExplicitEuler"];
StepDataPlot[sol, PlotRange -> {0, 0.2}]sol = NDSolve[system, StartingStepSize -> 1 / 10, Method -> "ExplicitRungeKutta"];
StepDataPlot[sol]sol = NDSolve[system, StartingStepSize -> 1 / 10, Method -> {"FixedStep", Method -> "ExplicitRungeKutta"}];
StepDataPlot[sol, PlotRange -> {0, 0.2}]The option MaxStepFraction provides an absolute bound on the step size that depends on the integration interval.
Since the default value of MaxStepFraction is 1/10, the step size in this example is bounded by one-tenth of the integration interval, which leads to using a constant step size of 1/20:
time = {T, 0, 1 / 2};
sol = NDSolve[system, time, StartingStepSize -> 1 / 10, Method -> {"FixedStep", Method -> "ExplicitRungeKutta"}];
StepDataPlot[sol, PlotRange -> {0, 0.2}]By setting the value of MaxStepFraction to a different value, the dependence of the step size on the integration interval can be relaxed or removed entirely:
sol = NDSolve[system, time, StartingStepSize -> 1 / 10, MaxStepFraction -> Infinity, Method -> {"FixedStep", Method -> "ExplicitRungeKutta"}];
StepDataPlot[sol, PlotRange -> {0, 0.2}]