sisl.mixing.AndersonMixer
- class sisl.mixing.AndersonMixer(weight: float | int = 0.2, history: int | History = 0)[source]
Bases:
BaseHistoryWeightMixer
Anderson mixing
The Anderson mixing assumes that the mixed input/output are linearly related. Hence
\[|\bar{n}^{m}_{\mathrm{in}/\mathrm{out}\rangle = (1 - \beta)|n^{m}_{\mathrm{in}/\mathrm{out}\rangle + \beta|n^{m-1}_{\mathrm{in}/\mathrm{out}\rangle\]Here the optimal choice \(\beta\) is calculated as:
\[\begin{split}\boldsymbol\delta_i &= \mathbf f_i^{\mathrm{out}} - \mathbf f_i^{\mathrm{in}} \\ \beta &= \frac{\langle \boldsymbol\delta_i | \boldsymbol\delta_i - \boldsymbol\delta_{i-1}\rangle} {\langle \boldsymbol\delta_i - \boldsymbol\delta_{i-1}| \boldsymbol\delta_i - \boldsymbol\delta_{i-1} \rangle}\end{split}\]Finally the resulting output becomes:
\[|n^{m+1}\rangle = (1 - \alpha)|\bar n^m_{\mathrm{in}}\rangle + \alpha|\bar n^m_{\mathrm{out}}\rangle\]See [5] for more details.
Methods
set_history
(history)Replace the current history in the mixer with a new one
set_weight
(weight)Set a new weight for this mixer
Attributes
History object tracked by this mixer
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]
Calculate a new variable \(\mathbf f'\) using input and output of the functional
- 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.