colder.gauge package
adiabatic gauge potential module
- class colder.gauge.adiabatic_potential.cache_lcd_numpy(agpobj)[source]
Bases:
objectThis class collects the intermidiate result of AGP to be cached.
- __init__(agpobj)[source]
Makes the LCD cache from AGP.
- Parameters:
agpobj (adiabaticgp) – adiabaticgp object.
- class colder.gauge.adiabatic_potential.adiabaticgp(total_sites: int, H: hamiltonian_collection, ansatz: hamiltonian_collection, sort_params: bool = True, enable_cache: bool = True, inject_cache: None | cache_lcd_numpy = None)[source]
Bases:
object- __init__(total_sites: int, H: hamiltonian_collection, ansatz: hamiltonian_collection, sort_params: bool = True, enable_cache: bool = True, inject_cache: None | cache_lcd_numpy = None) None[source]
Creates an Adiabatic Gauge Potential for system H and GP ansatz. The total number of spins must be provided.
- Parameters:
total_sites (int) – Number of sites.
H (colder.core.physics.hamiltonian_collection) – System hamiltonian.
ansatz (colder.core.physics.hamiltonian_collection) – Ansatz hamiltonian.
sort_params (bool, optional) – Sort parameters in alphabetic order. Defaults to True.
enable_cache (bool, optional) – If True, caching is enabled. Defaults to True.
inject_cache (Union[None,cache_lcd_numpy], optional) – If not None, use a cache object instead of computing the AGP from scratch. Defaults to None.
- Raises:
Exception – The APG cache object is not valid.
- set_cache(cc: cache_lcd_numpy) None[source]
Inject a cache object.
- Parameters:
cc (cache_lcd_numpy) – AGP cache.
- get_cache() cache_lcd_numpy | None[source]
Returns the AGP cache, if computed.
- Returns:
AGP cache or None if not yet computed.
- Return type:
Union[cache_lcd_numpy, None]
- get_lcd_equation_byvar(var: str)[source]
Computes the LCD equations for variable var.
- Parameters:
var (str) – Name of the variable to be collected.
- get_lcd_equations() List[source]
Compute the LCD equations for all variables.
- Returns:
List of symbolic equations for each variable in ansatz.
- Return type:
List
- retrieve_model_symbols() List[source]
Returns the list of all symbols for this AGP model.
- Returns:
List of symbols in this AGP model.
- Return type:
List
- make_lcd_numpy(symbols_check: bool = True, modules: str = 'numpy', args_override: List | None = None) callable | List[source]
Compute simbolically the LCD equations as a linear system and lambdify the matrices to numpy array depending on system symbols. Remark: this is the cached object.
- Parameters:
symbols_check (bool, optional) – If True, symbol consistency is checked. Defaults to True.
modules (str, optional) – Module for lambidify target. Defaults to ‘numpy’. Strongly suggest to not change this, unless you know what you are doing.
args_override (List, optional) – Override expected_symbols. Defaults to None.
- Raises:
Exception – Unexpected symbols in equation.
- Returns:
Callable functions for A, B. List of symbols to provide as arguments to A and B.
- Return type:
Union[callable, callable, List]
- lcd_numerical_solver(time: ndarray, finj: dict, fargs: dict = {}, nocache: bool = False) ndarray[source]
Solve LCD equations for time, given a schedule injected through finj.
- Parameters:
time (np.ndarray) – Time array to solve for.
finj (dict) – Dictionary of callable functions to be called for each time step.
fargs (dict, optional) – Arguments of the interpolator functions. Defaults to {}.
nocache (bool, optional) – If True, forces the computation of LCD from scratch. Otherwise, cache is used, if available. Defaults to False.
- Raises:
Exception – Injection dictionary has unexpected arguments. Are you sure the cache is correct?
- Returns:
Numerical solution for each unique parameter of this model.
- Return type:
np.ndarray
- lcd_numerical_solver_from_range(trange: tuple, nsamples: int, finj: dict, fargs: dict = {}) ndarray[source]
Call lcd_numerical_solver for a time array in range trange.
- Parameters:
trange (tuple) – Range of time to solve for.
nsamples (int) – Number of time steps.
finj (dict) – Dictionary of callable functions to be called for each time step.
fargs (dict, optional) – Arguments of the interpolator functions. Defaults to {}.
- Returns:
Numerical solution for each unique parameter of this model.
- Return type:
np.ndarray
- lcd_interpolated_solver(trange: tuple, nsamples: int, finj: dict, fargs: dict = {}, bc_type: str = 'clamped') dict[str, interpolator1D][source]
Solve numerically the LCD for time in trange and return a dictionary of values for each unique parameter of the system.
- Parameters:
trange (tuple) – Range of time to solve.
nsamples (int) – Number of time samples.
finj (dict) – Dictionary of callable functions to be called for each time step.
fargs (dict, optional) – Arguments of the interpolator functions. Defaults to {}.
bc_type (str, optional) – Spline option. Defaults to ‘clamped’.
- Returns:
Dictionary for each interpolator associated to unique driving parameters of the system.
- Return type:
dict[str, cnum.interpolator1D]
- match_interpolated_injections(system_interpolators: dict) dict[source]
Returns a dictionary for of callable function for the parameters in system and their derivatives.
- Parameters:
system_interpolators (dict) – Dictionary of interpolators.
- Returns:
Dictionary of interpolators for function and derivatives.
- Return type:
dict