# PulayMixer¶

class PulayMixer(noncollinear_mixing=None, history_storage=None, noncollinear_restart=None)

Class for representing a Pulay mixer.

Parameters: noncollinear_mixing (bool) – A special routine is used for the noncollinear mixing if this flag is used. Default: False history_storage (Duplicated | Distributed) – Flag indicating whether the history should be stored on each process (Duplicated) or distributed across all processes (Distributed). Default: Automatic: Distributed in the absence of a preconditioner and noncollinear mixing. Duplicated otherwise. noncollinear_restart – Deprecated since version 2016.0: Use noncollinear_mixing instead.
historyStorage()
Returns: The flag indicating how the history is stored. Duplicated | Distributed
noncollinearMixing()
Returns: True if the non-collinear restart mixing algorithm should be used. bool
noncollinearRestart()
Returns: True if the non-collinear restart mixing algorithm should be used. bool

Deprecated since version 2016.0: Use noncollinearMixing() instead.

## Usage Examples¶

Set up a Pulay mixer with automatic memory distribution

# Iteration control parameters with automatic Pulay mixer
mixer=PulayMixer()
iteration_control_parameters=IterationControlParameters(algorithm=mixer)


Set up a Pulay mixer that uses the non-collinear restart mixing algorithm (and thus non-distributed history storage)

# Iteration control parameters with Pulay mixer (non-collinear mixing)
mixer=PulayMixer(noncollinear_mixing=True)
iteration_control_parameters=IterationControlParameters(algorithm=mixer)


Set up a Pulay mixer with explicitly distributed memory

# Iteration control parameters with distributed Pulay mixer.
mixer=PulayMixer(history_storage=Distributed)
iteration_control_parameters=IterationControlParameters(algorithm=mixer)


## Notes¶

PulayMixer implements the Pulay-Kerker method [Pul80].

In the Pulay mixing scheme the best guess for the next input is given by,

$h_{n+1}^\mathrm{in} = \eta \sum_{i=n-n^\mathrm{hist}}^{n} \alpha_i h_i^\mathrm{out} + (1-\eta) \sum_{i=1}^{n-n^\mathrm{hist}} \alpha_i h_i^\mathrm{in}$

where $$h_i^\mathrm{in}$$ is the input value and $$h_i^\mathrm{out}$$ is the output value of the mixing_variable at iteration $$i$$. Currently there is support for using HamiltonianVariable for mixing. The parameter $$\eta$$ is the damping_factor and $$n^\mathrm{hist}$$ the number_of_history_steps used for finding the input value for the next iteration. The variables $$\alpha_i$$ are obtained by minimizing the residual error of the mixing_variable assuming a linear relation between the residual errors of different iteration numbers.

The PulayMixer is available in both a memory-distributed and a non-memory-distributed version. The non-distributed version has a slight performance advantage, but in cases where the SCF history uses a considerable amount of memory, the distributed version can be used to avoid being memory limited.

In the default case, memory distribution is activated if the stored history would use more than 50 MB. However, memory distribution cannot be used when either a preconditioner or non-collinear mixing is used. In those cases, memory distribution will be disabled by default. If memory distribution was explicitly requested with history_storage=Distributed, an exception will be raised when the mixer is used. This is to avoid exceeding the expected memory usage by silently falling back to duplicated history storage.

### References¶

 [Pul80] P. Pulay. Convergence acceleration of iterative sequences. the case of scf iteration. Chem. Phys. Lett., 73(2):393–398, jul 1980. URL: http://www.sciencedirect.com/science/article/pii/0009261480803964.