Skip to content

Commit d2e35f7

Browse files
Update DAE initialization docs to use docstrings
- Reference docstrings for algorithm documentation - Keep examples and troubleshooting sections - Add algorithm selection guide table - More concise while maintaining all useful information
1 parent 578db82 commit d2e35f7

File tree

1 file changed

+53
-89
lines changed

1 file changed

+53
-89
lines changed

docs/src/features/dae_initialization.md

Lines changed: 53 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -20,97 +20,27 @@ for fully implicit DAEs, or the equivalent constraint for semi-explicit DAEs. Fi
2020

2121
## Available Initialization Algorithms
2222

23-
The `initializealg` keyword argument to `solve` controls how initialization is performed:
24-
25-
### `DefaultInit()`
26-
27-
The default initialization algorithm that automatically chooses the most appropriate method based on the problem structure:
28-
29-
- If the problem has `initialization_data` (typically from ModelingToolkit), uses `OverrideInit`
30-
- For DAE problems without `differential_vars`, uses `ShampineCollocationInit`
31-
- For DAE problems with `differential_vars`, uses `BrownBasicInit`
32-
- For ODE problems with mass matrices, uses `BrownBasicInit`
33-
34-
```julia
35-
sol = solve(prob, IDA()) # Uses DefaultInit() automatically
36-
```
37-
38-
### `CheckInit()`
39-
40-
Only verifies that the provided initial conditions are consistent within tolerance. This is useful when you've already computed consistent initial conditions yourself:
41-
42-
```julia
43-
sol = solve(prob, IDA(), initializealg = CheckInit())
44-
```
45-
46-
If the conditions are not consistent, this will error with a message explaining the inconsistency.
47-
48-
### `NoInit()`
49-
50-
Skips initialization entirely. Use this when you are certain your initial conditions are consistent:
51-
52-
```julia
53-
sol = solve(prob, IDA(), initializealg = NoInit())
23+
The `initializealg` keyword argument to `solve` controls how initialization is performed. All algorithms are documented with their docstrings:
24+
25+
```@docs
26+
DiffEqBase.DefaultInit
27+
DiffEqBase.CheckInit
28+
DiffEqBase.NoInit
29+
DiffEqBase.OverrideInit
30+
DiffEqBase.BrownBasicInit
31+
DiffEqBase.ShampineCollocationInit
5432
```
5533

56-
⚠️ **Warning**: Using `NoInit()` with inconsistent initial conditions will likely cause solver failures.
57-
58-
### `BrownBasicInit()`
59-
60-
Implements the algorithm from:
61-
> P.N. Brown, A.C. Hindmarsh, and L.R. Petzold, "Consistent Initial Condition Calculation for Differential-Algebraic Systems", SIAM J. Sci. Comput., 19(5), pp. 1495-1512, 1998.
62-
63-
This method modifies algebraic variables and their derivatives to be consistent while keeping differential variables fixed. It's most effective for index-1 DAEs when `differential_vars` is provided:
64-
65-
```julia
66-
prob = DAEProblem(f, du0, u0, tspan, differential_vars = [true, false, true])
67-
sol = solve(prob, IDA(), initializealg = BrownBasicInit())
68-
```
34+
## Algorithm Selection Guide
6935

70-
### `ShampineCollocationInit()`
71-
72-
Implements the algorithm from:
73-
> L.F. Shampine, "Consistent Initial Condition for Differential-Algebraic Systems", SIAM J. Sci. Comput., 22(6), pp. 2007-2026, 2001.
74-
75-
This method uses collocation on the first two steps to find consistent initial conditions, modifying both differential and algebraic variables:
76-
77-
```julia
78-
sol = solve(prob, IDA(), initializealg = ShampineCollocationInit())
79-
```
80-
81-
## Algorithm-Specific Options
82-
83-
Some solvers provide extended versions of these algorithms with additional options:
84-
85-
### OrdinaryDiffEq Extensions
86-
87-
OrdinaryDiffEq provides extended versions with additional parameters:
88-
89-
```julia
90-
using OrdinaryDiffEq
91-
92-
# Shampine with custom initial dt and nonlinear solver
93-
sol = solve(prob, DFBDF(),
94-
initializealg = ShampineCollocationInit(initdt = 0.001))
95-
96-
# Brown with custom absolute tolerance
97-
sol = solve(prob, DFBDF(),
98-
initializealg = BrownBasicInit(abstol = 1e-10))
99-
```
100-
101-
### Sundials (IDA)
102-
103-
The IDA solver from Sundials.jl uses initialization through the `initializealg` parameter:
104-
105-
```julia
106-
using Sundials
107-
108-
# Use Brown's algorithm
109-
sol = solve(prob, IDA(), initializealg = BrownBasicInit())
110-
111-
# Skip initialization if you know conditions are consistent
112-
sol = solve(prob, IDA(), initializealg = NoInit())
113-
```
36+
| Algorithm | When to Use | Modifies Variables |
37+
|-----------|-------------|-------------------|
38+
| `DefaultInit()` | Default choice - automatically selects appropriate method | Depends on selection |
39+
| `CheckInit()` | When you've computed consistent conditions yourself | No (verification only) |
40+
| `NoInit()` | When conditions are known to be perfectly consistent | No |
41+
| `OverrideInit()` | With ModelingToolkit problems | Yes (uses custom problem) |
42+
| `BrownBasicInit()` | For index-1 DAEs with `differential_vars` | Algebraic variables only |
43+
| `ShampineCollocationInit()` | For general DAEs without structure information | All variables |
11444

11545
## Examples
11646

@@ -182,6 +112,40 @@ prob = DAEProblem(sys, [x => 1.0, y => 0.0], (0.0, 10.0), [g => 9.81, L => 1.0])
182112
sol = solve(prob, DFBDF()) # Automatic initialization!
183113
```
184114

115+
## Algorithm-Specific Options
116+
117+
Some solvers provide extended versions of these algorithms with additional options:
118+
119+
### OrdinaryDiffEq Extensions
120+
121+
OrdinaryDiffEq provides extended versions with additional parameters:
122+
123+
```julia
124+
using OrdinaryDiffEq
125+
126+
# Shampine with custom initial dt and nonlinear solver
127+
sol = solve(prob, DFBDF(),
128+
initializealg = OrdinaryDiffEqCore.ShampineCollocationInitExt(initdt = 0.001))
129+
130+
# Brown with custom absolute tolerance
131+
sol = solve(prob, DFBDF(),
132+
initializealg = OrdinaryDiffEqCore.BrownFullBasicInit(abstol = 1e-10))
133+
```
134+
135+
### Sundials (IDA)
136+
137+
The IDA solver from Sundials.jl uses initialization through the `initializealg` parameter:
138+
139+
```julia
140+
using Sundials
141+
142+
# Use Brown's algorithm
143+
sol = solve(prob, IDA(), initializealg = BrownBasicInit())
144+
145+
# Skip initialization if you know conditions are consistent
146+
sol = solve(prob, IDA(), initializealg = NoInit())
147+
```
148+
185149
## Troubleshooting
186150

187151
### Common Issues and Solutions
@@ -192,7 +156,7 @@ sol = solve(prob, DFBDF()) # Automatic initialization!
192156
- Check that `differential_vars` correctly identifies differential vs algebraic variables
193157

194158
2. **Initialization fails to converge**
195-
- Relax tolerances: `initializealg = BrownBasicInit(abstol = 1e-8)`
159+
- Relax tolerances if using extended versions
196160
- Try a different initialization algorithm
197161
- Provide a better initial guess for algebraic variables
198162

0 commit comments

Comments
 (0)