Skip to content

selah_anderson ​

SELAH, L1: Anderson acceleration of the fixed-point iteration of an implicit stage.

The implicit stage U = E + gamma R(U) is the fixed point of G(U) = E + gamma R(U); the plain iteration U <- G(U) contracts only where |gamma lambda| < 1. Anderson's acceleration (Anderson 1965; Walker & Ni 2011, Algorithm AA) mixes the last m iterates instead: with f_k = G(x_k) - x_k and the differences dF_i = f_{i+1} - f_i, dG_i = G(x_{i+1}) - G(x_i) of the last m_k = min(m, k) iterations,

x_{k+1} = G(x_k) - sum_i c_i dG_i,  c = argmin || f_k - sum_i c_i dF_i ||_2.

On a linear residual it is a Krylov method (GMRES's iterates, Walker & Ni 2011, with m at least the iterations), so it converges where the plain iteration diverges, with no Jacobian.

anderson_mixing is driven by its caller inside the stage (D1 of #11): with the stage state x and R(x) in the stage's register, residual makes G(x), f and the new differences, and returns the partial sums of the iteration (f.f, G.G, dF_i.dF_new, dF_i.f) over its box; the caller sums them over its boxes and ranks (one reduction per iteration) and asks converged(sums); if not, mix(bx, x, sums) writes x_{k+1} into the stage state, by the least-squares solve on the host (the normal equations of the m_k x m_k Gram matrix, by Cholesky; the oldest differences dropped while it is not positive definite to rounding). Its registers (2 m + 2 of the field's size) are allocated at the first residual, from the field's bounds, on the device in a device build. Converged means ||f|| <= atol + rtol ||G(x)|| (2-norms over the whole field): then R(x) is the stage's residual, and the stepper's update E + gamma R(x) = G(x).

Source: src/lib/selah_anderson.F90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
ANDERSON_MAX_DEPTHinteger(kind=I4P)parameterThe largest depth m.

Derived Types ​

anderson_mixing ​

Anderson acceleration of depth m.

Components

NameTypeAttributesDescription
minteger(kind=I4P)Depth.
atolreal(kind=R_P)Absolute tolerance on ||f||.
rtolreal(kind=R_P)Relative tolerance, of ||G(x)||.
max_iterationsinteger(kind=I4P)Iterations before converged stops the run.
iterationsinteger(kind=I4P)residual calls since start.
mkinteger(kind=I4P)Differences held.
newestinteger(kind=I4P)The ring slot of the newest difference.
gramreal(kind=R_P)allocatabledF_i.dF_j, by ring slot.
coefreal(kind=R_P)allocatableThe mixing coefficients, by ring slot (host).
coef_dreal(kind=R_P)pointerTheir device copy.
regsreal(kind=R_P)pointerf, G(x), then dF and dG by ring slot.
lbrinteger(kind=I4P)The registers' bounds.
ubrinteger(kind=I4P)The registers' bounds.

Type-Bound Procedures

NameAttributesDescription
initializepass(self)Depth and tolerances.
destroypass(self)Free the registers.
startpass(self)A new solve.
sums_sizepass(self)The number of partial sums (2 m + 2).
residualpass(self)G(x), f, the differences; the partial sums of the box.
convergedpass(self)||f|| within the tolerance, from the reduced sums.
mixpass(self)x_{k+1} into the stage state.

anderson_mixing%initialize ​

Depth m (1 .. ANDERSON_MAX_DEPTH) and the tolerances (defaults: atol 0, rtol 1e-12, 100 iterations).

fortran
subroutine initialize(self, m, atol, rtol, max_iterations)

Arguments

NameTypeIntentAttributesDescription
selfclass(anderson_mixing)inoutMixing.
minteger(kind=I4P)inDepth.
atolreal(kind=R_P)inoptionalAbsolute tolerance.
rtolreal(kind=R_P)inoptionalRelative tolerance.
max_iterationsinteger(kind=I4P)inoptionalIterations allowed.

Call graph

anderson_mixing%destroy ​

Free the registers.

fortran
subroutine destroy(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(anderson_mixing)inoutMixing.

anderson_mixing%start ​

A new solve: no differences held.

fortran
subroutine start(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(anderson_mixing)inoutMixing.

anderson_mixing%sums_size ​

The partial sums residual returns: f.f, G.G, then dF_i.dF_new and dF_i.f for the m ring slots.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function sums_size(self) result(n)

Arguments

NameTypeIntentAttributesDescription
selfclass(anderson_mixing)inMixing.

anderson_mixing%residual ​

With r = R(x): G(x) = e + gam r, f = G(x) - x, the new differences dF = f - f_prev, dG = G(x) - G_prev (from the second call of a solve), and the box's partial sums: sums(1) = f.f, sums(2) = G.G, sums(2 + i) = dF_i.dF_new, sums(2 + m + i) = dF_i.f (ring slot i; 0 for an empty slot). The caller sums them over its boxes and ranks.

fortran
subroutine residual(self, bx, gam, e, r, x, sums)

Arguments

NameTypeIntentAttributesDescription
selfclass(anderson_mixing)inoutMixing.
bxtype(box)inBox.
gamreal(kind=R_P)ingamma = dt stage_gamma(k).
ereal(kind=R_P)inExplicit part E.
rreal(kind=R_P)inR(x).
xreal(kind=R_P)inThe iterate (the stage state).
sumsreal(kind=R_P)outPartial sums [2 m + 2].

Call graph

anderson_mixing%converged ​

||f|| <= atol + rtol ||G(x)||, from the caller's reduced sums; an error stop past max_iterations, or when a sum is not finite (the iteration diverged: Anderson converges for a contractive map, and beyond only with depth enough for the spectrum).

Returns: logical

fortran
function converged(self, sums) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(anderson_mixing)inMixing.
sumsreal(kind=R_P)inReduced sums.

anderson_mixing%mix ​

x_{k+1} = G(x_k) - sum_i c_i dG_i into the stage state, c from the reduced sums (the plain iteration G(x_k) at the first call of a solve).

fortran
subroutine mix(self, bx, x, sums)

Arguments

NameTypeIntentAttributesDescription
selfclass(anderson_mixing)inoutMixing.
bxtype(box)inBox.
xreal(kind=R_P)inoutThe stage state, x_{k+1} out.
sumsreal(kind=R_P)inReduced sums.

Call graph