示例#1
0
    def plot_n_wavefunction(self,
                            esys: Tuple[ndarray, ndarray] = None,
                            mode: str = 'real',
                            which: int = 0,
                            nrange: Tuple[int, int] = None,
                            **kwargs) -> Tuple[Figure, Axes]:
        """Plots transmon wave function in charge basis

        Parameters
        ----------
        esys:
            eigenvalues, eigenvectors
        mode:
            `'abs_sqr', 'abs', 'real', 'imag'`
        which:
             index or indices of wave functions to plot (default value = 0)
        nrange:
             range of `n` to be included on the x-axis (default value = (-5,6))
        **kwargs:
            plotting parameters
        """
        if nrange is None:
            nrange = self._default_n_range
        n_wavefunc = self.numberbasis_wavefunction(esys, which=which)
        amplitude_modifier = constants.MODE_FUNC_DICT[mode]
        n_wavefunc.amplitudes = amplitude_modifier(n_wavefunc.amplitudes)
        kwargs = {
            **defaults.wavefunction1d_discrete(mode),
            **kwargs
        }  # if any duplicates, later ones survive
        return plot.wavefunction1d_discrete(n_wavefunc, xlim=nrange, **kwargs)
示例#2
0
    def plot_n_wavefunction(self,
                            esys=None,
                            mode='real',
                            which=0,
                            nrange=None,
                            filename=None):
        """Plots transmon wave function in charge basis

        Parameters
        ----------
        esys: tuple(ndarray, ndarray), optional
            eigenvalues, eigenvectors
        mode: str from MODE_FUNC_DICT, optional
            `'abs_sqr', 'abs', 'real', 'imag'`
        which: int or tuple of ints, optional
             index or indices of wave functions to plot (default value = 0)
        nrange: tuple of two ints, optional
             range of `n` to be included on the x-axis (default value = (-5,6))
        filename: str, optional
            file path and name (not including suffix) for output

        Returns
        -------
        Figure, Axes
        """
        if nrange is None:
            nrange = self._default_n_range
        n_wavefunc = self.numberbasis_wavefunction(esys, which=which)
        modefunction = constants.MODE_FUNC_DICT[mode]
        n_wavefunc.amplitudes = modefunction(n_wavefunc.amplitudes)
        return plot.wavefunction1d_discrete(n_wavefunc,
                                            x_range=nrange,
                                            xlabel='n',
                                            ylabel=r'psi_j(n)',
                                            filename=filename)