sisl.mixing.DIISMixer

class sisl.mixing.DIISMixer(weight: TypeWeight = 0.1, history: TypeArgHistory = 2, metric: TypeMetric | None = None)

Bases: BaseHistoryWeightMixer

Direct inversion of the iterative subspace (DIIS mixing)

This mixing method (also known as Pulay mixing) estimates the next trial function given a set of previously inputs and derivatives of those inputs.

Its implementation is general in the sense that one can manually define which values are used for the subspace. I.e. generally the subspace metric is calculated using:

\[\begin{split}\boldsymbol\delta_i &= \mathbf f_i^{\mathrm{out}} - \mathbf f_i^{\mathrm{in}} \\ \mathbf M_{ij} &= \langle \boldsymbol\delta_i | \boldsymbol\delta_j\rangle\end{split}\]

And then the mixing coefficients is calculated using the regular method for a matrix \(\mathbf M\). Generally the metric is calculated using \(\boldsymbol\delta\), however, by calling the object with an optional 3rd argument, the metric will use that argument instead of \(\boldsymbol\delta\) but still use \(\boldsymbol\delta\) when extrapolating the coefficients. This may be useful for testing various metrics based on alternate values.

Alternatively one can pass a metric argument that can pre-process the \(\boldsymbol\delta\) variable.

Parameters:
  • weight (float, optional) – weight used for the derivative of the functional. The mixer will use a weight of \(1-w\) for the old value

  • history (int or History, optional) – how many history steps it will use in the estimation of the new functional

  • metric (callable, optional) – the metric used for the two values, defaults to lambda a, b: a.ravel().conj().dot(b.ravel).real

Methods

coefficients()

Calculate coefficients of the Lagrangian

mix(coefficients)

Calculate a new variable \(\mathbf f'\) using history and input coefficients

set_history(history)

Replace the current history in the mixer with a new one

set_weight(weight)

Set a new weight for this mixer

solve_lagrange()

Calculate the coefficients according to Pulay's method, return everything + Lagrange multiplier

Attributes

history

History object tracked by this mixer

weight

This mixers mixing weight, the weight is the fractional contribution of the derivative

__call__(f: T, df: T, delta: Any | None = None, append: bool = True) T[source]

Append data to the history (omitting None values)!

coefficients() npt.NDArray[np.float64][source]

Calculate coefficients of the Lagrangian

mix(coefficients: numpy.typing.ArrayLike) Any[source]

Calculate a new variable \(\mathbf f'\) using history and input coefficients

Parameters:

coefficients (numpy.ndarray) – coefficients used for extrapolation

set_history(history: int | History) None

Replace the current history in the mixer with a new one

Parameters:

history – if an int a new History object will be created with that number of history elements Otherwise the object will be directly attached to the mixer.

set_weight(weight: float | int)

Set a new weight for this mixer

Parameters:

weight (float) – the new weight for this mixer, it must be bigger than 0

solve_lagrange() tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]][source]

Calculate the coefficients according to Pulay’s method, return everything + Lagrange multiplier

property history: History

History object tracked by this mixer

property weight: float | int

This mixers mixing weight, the weight is the fractional contribution of the derivative