carapace_core/analysis/algorithm.rs
1use super::{LineSearch, TangentStrategy};
2
3/// Iteration strategy for resolving each step's equilibrium. Closed enum
4///. `docs/algorithms.md` designs `Newton`/`KrylovNewton` as three
5/// composable axes (tangent strategy, line search, Krylov acceleration)
6/// rather than a combinatorial pile of variants — see that doc for the
7/// full design and Xara reference map.
8#[derive(Debug, Clone, Copy)]
9pub enum Algorithm {
10 /// One tangent formation, one solve, no re-iteration and no convergence
11 /// check — correct (and exact, to solver tolerance) whenever the
12 /// tangent doesn't change with the solution, i.e. linear response.
13 /// Matches OpenSees' `Linear` algorithm semantics.
14 Linear,
15 /// Newton-family iteration: re-forms the residual every iteration and
16 /// solves against whichever tangent `tangent` says to form/factor
17 /// (`TangentStrategy`), until `ConvergenceTest` passes or its
18 /// `max_iter` is exceeded (`AnalysisError::FailedToConverge`).
19 /// `tangent: TangentStrategy::Current, line_search: None` is today's
20 /// old bare `NewtonRaphson` variant, exactly.
21 Newton {
22 /// Which tangent gets formed/factored at each iteration.
23 tangent: TangentStrategy,
24 /// `None`: accept each raw Newton correction outright. `Some(_)`:
25 /// rescale a correction that doesn't already satisfy the
26 /// convergence test at `eta = 1` (`docs/algorithms.md` §4).
27 line_search: Option<LineSearch>,
28 },
29 /// Modified Newton (solving against a *stale* tangent — `tangent`,
30 /// almost always `Initial`/`ReuseAtStepStart` in practice) with a
31 /// Krylov-subspace correction (`docs/algorithms.md` §5) applied to
32 /// each raw solve, extrapolating from the history of how the last
33 /// `max_dimension` corrections actually moved the residual to recover
34 /// most of full Newton's convergence rate without paying for a fresh
35 /// factorization every iteration.
36 KrylovNewton {
37 tangent: TangentStrategy,
38 max_dimension: usize,
39 },
40}