AndersonMixer¶
- class AndersonMixer(mixing_fraction=None, regularization_parameter=None)¶
Class representing a mixer following the Anderson mixing scheme [1].
- Parameters:
mixing_fraction (float) – The mixing fraction. Default: Automatically determined in the first step.
regularization_parameter (float) – Regularization parameter for numerical stability. Default: 0.01
- mixingFraction()¶
- Returns:
The fraction of the output to be mixed in with the next input.
- Return type:
float
- regularizationParameter()¶
- Returns:
The stabilization factor to be added to the diagonal of the linear system.
- Return type:
float
- uniqueString()¶
Return a unique string representing the state of the object.
Usage Examples¶
Set up an Anderson mixer which automatically sets the mixing fraction optimally:
# Iteration control parameters with the default Anderson mixer.
mixer=AndersonMixer()
iteration_control_parameters=IterationControlParameters(algorithm=mixer)
Set up an Anderson mixer with a user defined mixing fraction.
# Iteration control parameters with a custom Anderson mixer.
mixer=AndersonMixer(mixing_fraction=0.2)
iteration_control_parameters=IterationControlParameters(algorithm=mixer)
Notes¶
AndersonMixer implements the Anderson method [1], [2].
In the Anderson mixing scheme the best guess for the next input is given by
where \(\eta\) is the mixing fraction, \(h_i^\mathrm{in}\) is the input value
of the mixing_variable
at iteration \(i\), and \(\Delta (h^i) = h^{\rm out}_i - h^{\rm in}_i\)
is the residual vector.
\(\bar{h}^{\rm in}_{n}\) is determined using a linear combination of solutions from the previous
number_of_history_steps
:
in which the variables \(\theta^i_n\) are determined by minimizing the residual of \(\bar{h}^{\rm in}_n\).