コード例 #1
0
ファイル: qubit_base.py プロジェクト: zlatko-minev/scqubits
    def plot_matrixelements(self,
                            operator,
                            evecs=None,
                            evals_count=6,
                            mode='abs',
                            **kwargs):
        """Plots matrix elements for `operator`, given as a string referring to a class method
        that returns an operator matrix. E.g., for instance `trm` of Transmon, the matrix element plot
        for the charge operator `n` is obtained by `trm.plot_matrixelements('n')`.
        When `esys` is set to None, the eigensystem with `which` eigenvectors is calculated.

        Parameters
        ----------
        operator: str
            name of class method in string form, returning operator matrix
        evecs: ndarray, optional
            eigensystem data of evals, evecs; eigensystem will be calculated if set to None (default value = None)
        evals_count: int, optional
            number of desired matrix elements, starting with ground state (default value = 6)
        mode: str, optional
            entry from MODE_FUNC_DICTIONARY, e.g., `'abs'` for absolute value (default)
        **kwargs: dict
            standard plotting option (see separate documentation)

        Returns
        -------
        Figure, Axes
        """
        matrixelem_array = self.matrixelement_table(operator, evecs,
                                                    evals_count)
        return plot.matrix(matrixelem_array, mode, **kwargs)
コード例 #2
0
    def plot_matrixelements(
        self,
        operator: str,
        evecs: ndarray = None,
        evals_count: int = 6,
        mode: str = "abs",
        show_numbers: bool = False,
        show3d: bool = True,
        **kwargs,
    ) -> Tuple[Figure, Axes]:
        """Plots matrix elements for `operator`, given as a string referring to a
        class method that returns an operator matrix. E.g., for instance `trm` of
        Transmon, the matrix element plot for the charge operator `n` is obtained by
        `trm.plot_matrixelements('n')`. When `esys` is set to None, the eigensystem
        with `which` eigenvectors is calculated.

        Parameters
        ----------
        operator:
            name of class method in string form, returning operator matrix
        evecs:
            eigensystem data of evals, evecs; eigensystem will be calculated if set to
             None (default value = None)
        evals_count:
            number of desired matrix elements, starting with ground state
            (default value = 6)
        mode:
            entry from MODE_FUNC_DICTIONARY, e.g., `'abs'` for absolute value (default)
        show_numbers:
            determines whether matrix element values are printed on top of the plot
            (default: False)
        show3d:
            whether to show a 3d skyscraper plot of the matrix alongside the 2d plot
            (default: True)
        **kwargs:
            standard plotting option (see separate documentation)
        """
        matrixelem_array = self.matrixelement_table(operator, evecs,
                                                    evals_count)
        if not show3d:
            return plot.matrix2d(matrixelem_array,
                                 mode=mode,
                                 show_numbers=show_numbers,
                                 **kwargs)
        return plot.matrix(matrixelem_array,
                           mode=mode,
                           show_numbers=show_numbers,
                           **kwargs)