def charge_matrixelem(datastore, qbt_index_subsys, initial_state_idx=0, **kwargs): """ Parameters ---------- datastore: DataStore qbt_index_subsys: tuple(int, QuantumSystem) index of the qubit system within the underlying HilbertSpace, and qubit object initial_state_idx: int index of initial state **kwargs: dict standard plotting option (see separate documentation) Returns ------- Figure, Axes """ (qbt_index, qbt_subsys) = qbt_index_subsys label_list = [(initial_state_idx, final_idx) for final_idx in range(qbt_subsys.truncated_dim)] return plot.matelem_vs_paramvals(datastore, select_elems=label_list, mode='abs', **defaults.charge_matrixelem( datastore.param_name, **kwargs))
def charge_matrixelem( specdata: "SpectrumData", qbt_index_subsys: Tuple[int, "QuantumSystem"], initial_state_idx: int = 0, **kwargs ) -> Tuple[Figure, Axes]: """ Parameters ---------- specdata: qbt_index_subsys: index of the qubit system within the underlying HilbertSpace, and qubit object initial_state_idx: index of initial state **kwargs: standard plotting option (see separate documentation) """ (qbt_index, qbt_subsys) = qbt_index_subsys label_list = [ (initial_state_idx, final_idx) for final_idx in range(qbt_subsys.truncated_dim) ] return plot.matelem_vs_paramvals( specdata, select_elems=label_list, mode="abs", **defaults.charge_matrixelem(specdata.param_name or "", **kwargs) )
def charge_matrixelem(sweep, qbt_index, initial_state_idx=0, title=None, fig_ax=None): data_key = 'n_op_qbt{}'.format(qbt_index) specdata = copy.deepcopy(sweep.bare_specdata_list[qbt_index]) specdata.matrixelem_table = sweep.sweep_data[data_key] xlabel = sweep.param_name ylabel = r'$|\langle i |n| j \rangle|$' label_list = [(initial_state_idx, final_idx) for final_idx in range(sweep.hilbertspace[qbt_index].truncated_dim)] return plot.matelem_vs_paramvals(specdata, select_elems=label_list, mode='abs', xlabel=xlabel, ylabel=ylabel, title=title, fig_ax=fig_ax)
def plot_matelem_vs_paramvals(self, operator, param_name, param_vals, select_elems=4, mode='abs', x_range=None, y_range=None, filename=None, fig_ax=None): """Generates a simple plot of a set of eigenvalues as a function of one parameter. The individual points correspond to the a provided array of parameter values. Parameters ---------- operator: str name of class method in string form, returning operator matrix param_name: str name of parameter to be varied param_vals: ndarray parameter values to be plugged in select_elems: int or list, optional either maximum index of desired matrix elements, or list [(i1, i2), (i3, i4), ...] of index tuples for specific desired matrix elements (default value = 4) mode: str, optional entry from MODE_FUNC_DICTIONARY, e.g., `'abs'` for absolute value (default value = 'abs') x_range: (float, float), optional custom x-range for the plot (default value = False) y_range: (float, float), optional custom y-range for the plot (default value = False) filename: str, optional write graphics and parameter set to file if path and filename are specified (default value = None) fig_ax: tuple(Figure, Axes), optional fig and ax objects for matplotlib figure addition (default value = None) Returns ------- Figure, Axes """ if isinstance(select_elems, int): evals_count = select_elems else: flattened_list = [index for tupl in select_elems for index in tupl] evals_count = max(flattened_list) + 1 specdata = self.get_matelements_vs_paramvals(operator, param_name, param_vals, evals_count=evals_count, filename=None) return plot.matelem_vs_paramvals(specdata, select_elems=select_elems, mode=mode, x_range=x_range, y_range=y_range, filename=filename, fig_ax=fig_ax)
def plot_matelem_vs_paramvals( self, operator: str, param_name: str, param_vals: ndarray, select_elems: Union[int, List[Tuple[int, int]]] = 4, mode: str = "abs", num_cpus: int = settings.NUM_CPUS, **kwargs, ) -> Tuple[Figure, Axes]: """Generates a simple plot of a set of eigenvalues as a function of one parameter. The individual points correspond to the a provided array of parameter values. Parameters ---------- operator: name of class method in string form, returning operator matrix param_name: name of parameter to be varied param_vals: parameter values to be plugged in select_elems: either maximum index of desired matrix elements, or list [(i1, i2), (i3, i4), ...] of index tuples for specific desired matrix elements (default value = 4) mode: entry from MODE_FUNC_DICTIONARY, e.g., `'abs'` for absolute value (default value = 'abs') num_cpus: number of cores to be used for computation (default value = 1) **kwargs: standard plotting option (see separate documentation) """ if isinstance(select_elems, int): evals_count = select_elems else: flattened_list = [index for tupl in select_elems for index in tupl] evals_count = max(flattened_list) + 1 specdata = self.get_matelements_vs_paramvals(operator, param_name, param_vals, evals_count=evals_count, num_cpus=num_cpus) return plot.matelem_vs_paramvals(specdata, select_elems=select_elems, mode=mode, **kwargs)
def plot_matelem_vs_paramvals(self, operator, param_name, param_vals, select_elems=4, mode='abs', **kwargs): """Generates a simple plot of a set of eigenvalues as a function of one parameter. The individual points correspond to the a provided array of parameter values. Parameters ---------- operator: str name of class method in string form, returning operator matrix param_name: str name of parameter to be varied param_vals: ndarray parameter values to be plugged in select_elems: int or list, optional either maximum index of desired matrix elements, or list [(i1, i2), (i3, i4), ...] of index tuples for specific desired matrix elements (default value = 4) mode: str, optional entry from MODE_FUNC_DICTIONARY, e.g., `'abs'` for absolute value (default value = 'abs') **kwargs: dict standard plotting option (see separate documentation) Returns ------- Figure, Axes """ if isinstance(select_elems, int): evals_count = select_elems else: flattened_list = [index for tupl in select_elems for index in tupl] evals_count = max(flattened_list) + 1 specdata = self.get_matelements_vs_paramvals(operator, param_name, param_vals, evals_count=evals_count) return plot.matelem_vs_paramvals(specdata, select_elems=select_elems, mode=mode, **kwargs)