qom.utils.solvers module¶
Module containing utility functions for solvers.
- qom.utils.solvers.get_func_Lyapunov_exponents(SystemClass, params: dict = {}, steady_state: bool = True, cb_update=None)¶
Function to get the function to obtain the Lyapunov exponents.
- Parameters:
SystemClass (
qom.systems.*
) – Uninitialized system class. Requires predefined system methods for certain solver methods.params (dict, optional) – Parameters for the solver. Refer to
qom.solvers.deterministic.HLESolver
,qom.solvers.deterministic.SSHLESolver
and qom.solvers.measure.get_Lyapunov_exponents for available parameters.steady_state (bool, default=True.) – Whether the calculated modes and correlations are steady state values or time series.
cb_update (callable, optional) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.
- Returns:
get_le – Function to obtain the Lyapunov exponents. Returns a
numpy.ndarray
with shape(2 * num_modes, )
.- Return type:
callable
- qom.utils.solvers.get_func_quantum_correlation_measures(SystemClass, params: dict = {}, steady_state: bool = True, cb_update=None)¶
Function to get the function to obtain the quantum correlation measures.
- Parameters:
SystemClass (
qom.systems.*
) – Uninitialized system class. Requires predefined system methods for certain solver methods.params (dict, optional) – Parameters for the solver. Refer to
qom.solvers.deterministic.HLESolver
,qom.solvers.deterministic.SSHLESolver
andqom.solvers.measure.QCMSolver
for available parameters.steady_state (bool, default=True.) – Whether the calculated modes and correlations are steady state values or time series.
cb_update (callable, optional) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.
- Returns:
get_qcm – Function to obtain the quantum correlation measures. Returns a
numpy.ndarray
with shape(dim, num_measure_codes)
.- Return type:
callable
- qom.utils.solvers.get_func_stability_zone(SystemClass, params: dict = {}, steady_state: bool = True, use_rhc: bool = False, cb_update=None)¶
Function to get the function to obtain the stability zone.
- Parameters:
SystemClass (
qom.systems.*
) – Uninitialized system class. Requires predefined system methods for certain solver methods.params (dict, optional) – Parameters for the solver. Refer to
qom.solvers.deterministic.HLESolver
,qom.solvers.deterministic.SSHLESolver
andqom.solvers.stability.RHCSolver
for available parameters. If the value of key"system_measure_name"
is"coeffs_A"
, the stability is calculated using the coefficients, else the drift matrices are used (fallback).steady_state (bool, default=True.) – Whether the calculated modes and correlations are steady state values or time series.
use_rhc (bool, default=False) – Option to use the Routh-Hurwitz criteria to calculate the counts for the unstable eigenvalues.
cb_update (callable, optional) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.
- Returns:
get_sz – Function to obtain the stability zone. Returns a
numpy.ndarray
with shape(dim, )
. Ifsteady_state
is set toTrue
, the array contains a single element denoting the multi-stability indicator. Refer toqom.solvers.measure.get_stability_zone
function for the meaning of indicators.- Return type:
callable
- qom.utils.solvers.get_func_system_measures(SystemClass, params: dict = {}, steady_state: bool = True, cb_update=None)¶
Function to get the function to obtain the system measures.
- Parameters:
SystemClass (
qom.systems.*
) – Uninitialized system class. Requires predefined system methods for certain solver methods.params (dict, optional) – Parameters for the solver. Refer to
qom.solvers.deterministic.HLESolver
andqom.solvers.deterministic.SSHLESolver
and qom.solvers.measure.get_system_measures for available parameters.steady_state (bool, default=True.) – Whether the calculated modes and correlations are steady state values or time series.
cb_update (callable, optional) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.
- Returns:
get_sm – Function to obtain the system measures. Returns a
numpy.ndarray
with shape(dim, )
plus the shape of each measure.- Return type:
callable
- qom.utils.solvers.plot_mcqt_solver_results(solver, params_plotter: dict)¶
Helper function to plot results.
- Parameters:
solver (
qom.solvers.stochastic.MCQTSolver
) – Instance of the solver.params_plotter (dict) – Parameters of the plotter. Refer to Notes of
qom.ui.plotters.base.BasePlotter
for all available parameters.
- qom.utils.solvers.run_mcqt_solver_instance(args)¶
Function to run a single instance of
wrap_mcqt_solver
.- Parameters:
args (list) – Arguments of the
wrap_mcqt_solver
function.- Returns:
solver – Instance of the solver.
- Return type:
- qom.utils.solvers.run_mcqt_solvers_in_parallel(system, params: dict, num_trajs: int = 1000, plot: bool = False, subplots: bool = False, params_plotter: dict = {}, max_processes: int = None, cb_update=None)¶
Function to run multiple MCQTSolver in parallel processes.
- Parameters:
system (
qom.systems.base
) – Instance of the system. Requires predefined system methodsget_ops_collapse
,get_ops_expect
,get_H_0
andget_ivc
. For time-dependent Hamiltonians, the methodget_H_t
should also be defined. Refer to Notes ofqom.solvers.stochastic.MCQTSolver
for their implementations.params (dict) – Parameters of the solver. Refer to Notes of
qom.solvers.stochastic.MCQTSolver
for all available options.num_trajs (int, default=1000) – Number of trajectories.
plot (bool, default=False) – Option to plot the results of the main process.
subplots (bool, default=False) – Option to plot the results of each subprocesses.
params_plotter (dict, optional) – Parameters of the plotter.
max_processes (int, optional) – Maximum number of solvers to run in parallel. The number of slices is decided by the dimensionality of the Hilbert space and the number of trajectories. For smaller number of trajectories, a single process is run without parallelization. Default value of dimension is \(5 \times 10^{4} / N\), where \(N\) is the dimension of the combined Hilbert space.
cb_update (callable) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.
- Returns:
solver – Instance of the solver.
- Return type:
- qom.utils.solvers.wrap_mcqt_solver(system, params: dict, num_trajs: int = 1000, plot: bool = False, params_plotter: dict = {}, cb_update=None, parallel=False, p_index: int = 0, p_start: float = None)¶
Function to wrap MCQTSolver.
- Parameters:
system (
qom.systems.base
) – Instance of the system. Requires predefined system methodsget_ops_collapse
,get_ops_expect
,get_H_0
andget_ivc
. For time-dependent Hamiltonians, the methodget_H_t
should also be defined. Refer to Notes ofqom.solvers.stochastic.MCQTSolver
for their implementations.params (dict) – Parameters of the solver. Refer to Notes of
qom.solvers.stochastic.MCQTSolver
for all available options.num_trajs (int, default=1000) – Number of trajectories.
plot (bool, default=False) – Option to plot the results of the main process.
params_plotter (dict, optional) – Parameters of the plotter.
cb_update (callable) – Callback function to update status and progress, formatted as
cb_update(status, progress, reset)
, wherestatus
is a string,progress
is a float andreset
is a boolean.parallel (bool, default=False) – Option to format outputs when running in parallel.
p_index (int, default=0) – Index of the process.
p_start (float, optional) – Time at which the process was started. If not provided, the value is initialized to current time.
- Returns:
solver – Instance of the solver.
- Return type: