Looping functions¶
Functions for iterating over parameter spaces in VCA and CDMFT calculations. These include loops with predictors, the Hartree procedure, and fading between parameter sets.
Looping utilities for VCA and CDMFT calculations.
Provides functions for iterating over parameter spaces with predictors, including
linear_loop(), controlled_loop(), fade(), Hartree_procedure(),
and file-driven loops. These functions are added as methods of the lattice model class.
- loop_from_file(self, task, file)¶
Performs a task ‘task’ over a set of model parameters defined in a file. The definition of each model instance must be done in the task ‘task’; it is not done by this looping function.
- Parameters:
task – function (task) to perform
file (str) – name of the data file specifying the solutions, in the same tab-separated format usually used to write solutions
- loop_from_table(self, task, data)¶
Performs a task ‘task’ over a set of model parameters defined in a table. The definition of each model instance must be done in the task ‘task’; it is not done by this looping function.
- Parameters:
task – function (task) to perform
data (ndarray) – table of parameters, with named columns, as read or filtered from numpy.genfromtxt()
- linear_loop(self, N, task, varia=None, params=None, predict=True)¶
Performs a loop with a predictor. The definition of each model instance must be done in ‘task’; it is not done by this looping function.
- Parameters:
- Returns:
None
- controlled_loop(self, task, varia=None, loop_param=None, loop_range=None, control_func=None, retry=None, max_retry=4, predict=True)¶
Performs a controlled loop for VCA or CDMFT with a predictor. The definition of each model instance must be done and returned by ‘task’; it is not done by this looping function.
- Parameters:
task – a function called at each step of the loop. Must return a model_instance.
varia ([str]) – names of the variational parameters
loop_param (str) – name of the parameter looped over
loop_range ((float, float, float)) – range of the loop (start, end, step)
control_func – (optional) name of the function that controls the loop (returns bool). Takes a model instance as argument
retry (char) – If None, stops on failure. If ‘refine’, adjusts the step (divide by 2) and retry. If ‘skip’, skip to next value.
max_retry (int) – Maximum number of retries of either type
predict (bool) – if True, uses a linear or quadratic predictor
- fade(self, task, P, n)¶
Fades the model between two sets of parameters, in n steps
- Parameters:
task – task to perform within the loop
P (dict) – dict of parameters with a tuple of values (start and finish) for each
n – number of steps
- Returns:
None
- controlled_fade(self, task, P, n, C, file='fade.tsv', tol=0.0001, method='Broyden', maxiter=32, alpha=0.0, eps_algo=0, bracket=None, delta=None, verb=False)¶
Fades the model between two sets of parameters, in n steps
- Parameters:
task – task to perform within the loop
P (dict) – dict of parameters with a tuple of values (start and finish) for each
n – number of steps
C (dict) – dict of adjustable parameters whose average (the value of C) should stay fixed during the fade
file (str) – file to which the converged results are written
tol (float) – precision on the averages
method (str) – method used for solving the nonlinear constraints
maxiter – maximum number of iterations for solving the constraints
alpha (float) – parameter used in some non linear solvers (broyden)
eps_algo (int) – convergence accelerator parameter in fixed_point
bracket ((float,float)) – bracket used in some nonlinear 1D solvers
delta (float) – interval used to update the bracket used in some nonlinear 1D solvers
verb (bool) – If True, writes progress reports
- Hartree_procedure(self, task, couplings, maxiter=32, iteration='fixed_point', eps_algo=0, file='hartree.tsv', SEF=False, pr=False, alpha=0.0)¶
Performs the Hartree approximation
- Parameters:
task – task to perform within the loop. Must return a model_instance
couplings (hartree) – sequence of couplings (or single coupling), of the Hartree class
maxiter (int) – maximum number of iterations
iteration (str) – method of iteration of parameters (‘fixed_point’ or ‘broyden’)
eps_algo (int) – number of elements in the epsilon algorithm convergence accelerator = 2*eps_algo + 1 (0 = no acceleration)
file (str) – name of the file to which the converged result is written via write_summary()
SEF (bool) – if True, computes the Potthoff functional at the end of the procedure
pr (bool) – if True, prints progress of each coupling update
alpha (float) – if iteration=’fixed_point’, damping parameter, otherwise trial inverse Jacobian (if a float, that is (1+alpha)*unit matrix)
- Returns:
model instance, converged inverse Jacobian
- flexible_loop(self, task, initial_mu, final_n, initial_step, delta_n=0.005, varia=[])¶
Performs a controlled loop for VCA or CDMFT with a predictor. The definition of each model instance must be done and returned by ‘task’; it is not done by this looping function.
- Parameters:
task – a function called at each step of the loop. Must return a model_instance.
initial_mu (float) – initial value of the chemical potential mu
final_n (float) – target final density at which the loop should stop
initial_step (float) – initial step in mu for the first iteration
delta_n (float) – approximate step in density to keep approximately constant across iterations
varia ([str]) – names of the variational parameters
- Returns:
None