Exemplo n.º 1
0
    def plot_wavefunction(self,
                          esys: Tuple[ndarray, ndarray] = None,
                          which: int = 0,
                          phi_grid: discretization.Grid1d = None,
                          mode: str = "abs",
                          zero_calibrate: bool = True,
                          **kwargs) -> Tuple[Figure, Axes]:
        """Plots 2d phase-basis wave function.

        Parameters
        ----------
        esys:
            eigenvalues, eigenvectors as obtained from `.eigensystem()`
        which:
            index of wave function to be plotted (default value = (0)
        phi_grid:
            used for setting a custom grid for phi; if None use self._default_grid
        mode:
            choices as specified in `constants.MODE_FUNC_DICT`
            (default value = 'abs_sqr')
        zero_calibrate:
            if True, colors are adjusted to use zero wavefunction amplitude as the
            neutral color in the palette
        **kwargs:
            plot options
        """
        amplitude_modifier = constants.MODE_FUNC_DICT[mode]
        wavefunc = self.wavefunction(esys, phi_grid=phi_grid, which=which)
        wavefunc.amplitudes = amplitude_modifier(wavefunc.amplitudes)
        if "figsize" not in kwargs:
            kwargs["figsize"] = (5, 5)
        return plot.wavefunction2d(wavefunc,
                                   zero_calibrate=zero_calibrate,
                                   **kwargs)
Exemplo n.º 2
0
    def plot_wavefunction(self, esys=None, which=0, theta_grid=None, mode='abs', zero_calibrate=True, **kwargs):
        """Plots 2d phase-basis wave function.

        Parameters
        ----------
        esys: ndarray, ndarray
            eigenvalues, eigenvectors as obtained from `.eigensystem()`
        which: int, optional
            index of wave function to be plotted (default value = (0)
        theta_grid: Grid1d, optional
            used for setting a custom grid for theta; if None use self._default_grid
        mode: str, optional
            choices as specified in `constants.MODE_FUNC_DICT` (default value = 'abs_sqr')
        zero_calibrate: bool, optional
            if True, colors are adjusted to use zero wavefunction amplitude as the neutral color in the palette
        **kwargs:
            plot options

        Returns
        -------
        Figure, Axes
        """
        theta_grid = theta_grid or self._default_grid

        amplitude_modifier = constants.MODE_FUNC_DICT[mode]
        wavefunc = self.wavefunction(esys, theta_grid=theta_grid, which=which)
        wavefunc.amplitudes = amplitude_modifier(wavefunc.amplitudes)
        return plot.wavefunction2d(wavefunc, zero_calibrate=zero_calibrate,
                                   xlabel=r'$\phi$', ylabel=r'$\theta$', **kwargs)
Exemplo n.º 3
0
    def plot_wavefunction(self,
                          esys=None,
                          which=0,
                          phi_grid=None,
                          theta_grid=None,
                          mode="abs",
                          zero_calibrate=True,
                          **kwargs) -> Tuple[Figure, Axes]:
        """
        Plots a 2D wave function in :math:`\\theta, \\phi` basis, at :math:`\\zeta = 0`

        Parameters
        ----------
        esys: ndarray, ndarray
            eigenvalues, eigenvectors as obtained from `.eigensystem()`
        which: int, optional
            index of wave function to be plotted (default value = (0)
        phi_grid: Grid1d, option
            used for setting a custom grid for phi; if None use self._default_phi_grid
        theta_grid: Grid1d, option
            used for setting a custom grid for theta; if None use
            self._default_theta_grid
        mode: str, optional
            choices as specified in `constants.MODE_FUNC_DICT` (default value = 'abs_sqr')
        zero_calibrate: bool, optional
            if True, colors are adjusted to use zero wavefunction amplitude as the neutral color in the palette
        **kwargs:
            plot options

        """
        phi_grid = phi_grid or self._default_phi_grid
        zeta_grid = discretization.Grid1d(0, 0, 1)
        theta_grid = theta_grid or self._default_theta_grid

        amplitude_modifier = constants.MODE_FUNC_DICT[mode]
        wavefunc = self.wavefunction(
            esys,
            phi_grid=phi_grid,
            zeta_grid=zeta_grid,
            theta_grid=theta_grid,
            which=which,
        )

        wavefunc.gridspec = discretization.GridSpec(
            np.asarray([
                [phi_grid.min_val, phi_grid.max_val, phi_grid.pt_count],
                [theta_grid.min_val, theta_grid.max_val, theta_grid.pt_count],
            ]))
        wavefunc.amplitudes = np.transpose(
            amplitude_modifier(
                spec_utils.standardize_phases(
                    wavefunc.amplitudes.reshape(phi_grid.pt_count,
                                                theta_grid.pt_count))))
        return plot.wavefunction2d(wavefunc,
                                   zero_calibrate=zero_calibrate,
                                   ylabel=r"$\theta$",
                                   xlabel=r"$\phi$",
                                   **kwargs)
Exemplo n.º 4
0
    def plot_wavefunction(self,
                          esys=None,
                          which=0,
                          theta_range=None,
                          theta_count=None,
                          mode='abs',
                          zero_calibrate=True,
                          figsize=(6, 2.75),
                          fig_ax=None):
        """Plots 2d phase-basis wave function.

        Parameters
        ----------
        esys: ndarray, ndarray
            eigenvalues, eigenvectors as obtained from `.eigensystem()`
        which: int, optional
            index of wave function to be plotted (default value = (0)
        theta_range: tuple(float, float), optional
            used for setting a custom plot range for theta
        theta_count: int, optional
            number of points to be used in the interval for theta
        mode: str, optional
            choices as specified in `constants.MODE_FUNC_DICT` (default value = 'abs_sqr')
        zero_calibrate: bool, optional
            if True, colors are adjusted to use zero wavefunction amplitude as the neutral color in the palette
        figsize: (float, float), optional
            figure size specifications for matplotlib
        fig_ax: Figure, Axes, optional
            existing Figure, Axis if previous objects are to be appended

        Returns
        -------
        Figure, Axes
        """
        theta_range, theta_count = self.try_defaults(theta_range, theta_count)

        modefunction = constants.MODE_FUNC_DICT[mode]
        wavefunc = self.wavefunction(esys,
                                     theta_count=theta_count,
                                     which=which)
        wavefunc.amplitudes = modefunction(wavefunc.amplitudes)
        return plot.wavefunction2d(wavefunc,
                                   figsize=figsize,
                                   zero_calibrate=zero_calibrate,
                                   fig_ax=fig_ax)