|
| 1 | +```@meta |
| 2 | +CollapsedDocStrings = true |
| 3 | +``` |
| 4 | + |
| 5 | +# Solver API |
| 6 | + |
| 7 | +DelayDiffEq.jl provides delay differential equation solvers through the method of steps approach. The core algorithm wraps ODE solvers from OrdinaryDiffEq.jl to handle the delays. |
| 8 | + |
| 9 | +## Method of Steps Algorithm |
| 10 | + |
| 11 | +The primary algorithm for solving delay differential equations in DelayDiffEq.jl is `MethodOfSteps`, which implements the method of steps approach for solving DDEs. |
| 12 | + |
| 13 | +```@docs |
| 14 | +MethodOfSteps |
| 15 | +``` |
| 16 | + |
| 17 | +### Algorithm Properties |
| 18 | + |
| 19 | +- **Adaptive**: Inherits adaptivity from the underlying ODE solver |
| 20 | +- **Order**: Depends on the chosen ODE algorithm |
| 21 | +- **Dense Output**: Available when the underlying ODE solver supports it |
| 22 | +- **State-Dependent Delays**: Supported through fixed-point iteration |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +### Basic Usage |
| 27 | + |
| 28 | +```julia |
| 29 | +using DelayDiffEq, OrdinaryDiffEq |
| 30 | + |
| 31 | +# Use with any ODE solver from OrdinaryDiffEq.jl |
| 32 | +alg = MethodOfSteps(Tsit5()) |
| 33 | +sol = solve(prob, alg) |
| 34 | +``` |
| 35 | + |
| 36 | +### Constrained vs Unconstrained |
| 37 | + |
| 38 | +By default, `MethodOfSteps` is unconstrained, meaning it can take steps larger than the minimal delay using fixed-point iteration: |
| 39 | + |
| 40 | +```julia |
| 41 | +# Unconstrained (default) - can take larger steps |
| 42 | +alg = MethodOfSteps(Tsit5()) |
| 43 | + |
| 44 | +# Constrained - steps limited to minimal delay |
| 45 | +alg = MethodOfSteps(Tsit5(); constrained = true) |
| 46 | +``` |
| 47 | + |
| 48 | +### Custom Fixed-Point Solver |
| 49 | + |
| 50 | +For unconstrained problems, you can specify the fixed-point iteration method: |
| 51 | + |
| 52 | +```julia |
| 53 | +# Use custom fixed-point solver |
| 54 | +alg = MethodOfSteps(Tsit5(); fpsolve = NLFunctional(; max_iter = 100)) |
| 55 | +``` |
| 56 | + |
| 57 | +## Recommended Algorithms |
| 58 | + |
| 59 | +The choice of underlying ODE algorithm depends on your problem characteristics: |
| 60 | + |
| 61 | +### Non-Stiff Problems |
| 62 | + |
| 63 | +For non-stiff delay differential equations: |
| 64 | + |
| 65 | +- **`MethodOfSteps(Tsit5())`**: Good general purpose solver (5th order) |
| 66 | +- **`MethodOfSteps(BS3())`**: For lower accuracy requirements (3rd order) |
| 67 | +- **`MethodOfSteps(Vern6())`**: For high accuracy requirements (6th order) |
| 68 | +- **`MethodOfSteps(Vern9())`**: For very high accuracy requirements (9th order) |
| 69 | + |
| 70 | +### Stiff Problems |
| 71 | + |
| 72 | +For stiff delay differential equations: |
| 73 | + |
| 74 | +- **`MethodOfSteps(Rosenbrock23())`**: Good for mildly stiff problems |
| 75 | +- **`MethodOfSteps(Rodas4())`**: General purpose stiff solver |
| 76 | +- **`MethodOfSteps(Rodas5())`**: High accuracy stiff solver |
| 77 | +- **`MethodOfSteps(KenCarp4())`**: Good stability properties |
| 78 | + |
| 79 | +### Low Storage Requirements |
| 80 | + |
| 81 | +For problems with memory constraints: |
| 82 | + |
| 83 | +- **`MethodOfSteps(SSPRK104())`**: Strong stability preserving, low storage |
| 84 | +- **`MethodOfSteps(OwrenZen3())`**: 3rd order low storage |
| 85 | +- **`MethodOfSteps(OwrenZen5())`**: 5th order low storage |
| 86 | + |
| 87 | +## Algorithm Selection Guide |
| 88 | + |
| 89 | +### Step 1: Determine Stiffness |
| 90 | + |
| 91 | +First, determine if your DDE is stiff. Signs of stiffness include: |
| 92 | +- Explicit methods require very small time steps |
| 93 | +- The solution has multiple time scales |
| 94 | +- There are rapid transients followed by slow dynamics |
| 95 | + |
| 96 | +### Step 2: Choose Tolerance |
| 97 | + |
| 98 | +- **High tolerance (>1e-2)**: Use lower order methods |
| 99 | +- **Medium tolerance (1e-8 to 1e-2)**: Use standard 4-5 order methods |
| 100 | +- **Low tolerance (<1e-8)**: Use high order methods |
| 101 | + |
| 102 | +### Step 3: Consider Problem Structure |
| 103 | + |
| 104 | +- **Discontinuous forcing**: Use low order methods or constrained stepping |
| 105 | +- **State-dependent delays**: May benefit from constrained stepping |
| 106 | +- **Conservation properties needed**: Consider symplectic integrators |
| 107 | + |
| 108 | +### Example Selection |
| 109 | + |
| 110 | +```julia |
| 111 | +# Non-stiff problem with medium accuracy |
| 112 | +alg = MethodOfSteps(Tsit5()) |
| 113 | + |
| 114 | +# Stiff problem with medium accuracy |
| 115 | +alg = MethodOfSteps(Rodas4()) |
| 116 | + |
| 117 | +# High accuracy non-stiff problem |
| 118 | +alg = MethodOfSteps(Vern9()) |
| 119 | + |
| 120 | +# Problem with frequent discontinuities |
| 121 | +alg = MethodOfSteps(BS3(); constrained = true) |
| 122 | +``` |
| 123 | + |
| 124 | +## Performance Tips |
| 125 | + |
| 126 | +1. **Use constrained stepping** when delays are much smaller than the timescale of the solution |
| 127 | +2. **Choose higher order methods** for smooth problems with stringent accuracy requirements |
| 128 | +3. **Use lower order methods** when the solution has many discontinuities |
| 129 | +4. **Monitor the number of fixed-point iterations** for unconstrained problems with state-dependent delays |
| 130 | + |
| 131 | +## See Also |
| 132 | + |
| 133 | +- [OrdinaryDiffEq.jl Solver Documentation](https://docs.sciml.ai/OrdinaryDiffEq/stable/) for details on the underlying ODE solvers |
| 134 | +- [DifferentialEquations.jl DDE Tutorial](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/dde_example/) for comprehensive examples |
0 commit comments