def plot_density_matrices(self):
        from mpl_toolkits.mplot3d import Axes3D  # noqa: F401 unused import
        from qutip.visualization import matrix_histogram_complex
        fig = plt.figure()
        axs = [1, 2]
        axs = list(map(lambda x: fig.add_subplot(1, 2, x, projection="3d"), axs))

        fig.canvas.set_window_title(self._name + " F = {:.4f}".format(self._fidelity))
        matrix_histogram_complex(self._expect_dm, ax=axs[0])
        matrix_histogram_complex(self._experiment_rho, ax=axs[1])
Пример #2
0
def qpt_plot_combined(chi, lbls_list, title=None,
                      fig=None, ax=None, figsize=(8, 6),
                      threshold=None):
    """
    Visualize the quantum process tomography chi matrix. Plot bars with
    height and color corresponding to the absolute value and phase,
    respectively.

    Parameters
    ----------
    chi : array
        Input QPT chi matrix.
 
    lbls_list : list
        List of labels for QPT plot axes.

    title : string
        Plot title.

    fig : figure instance
        User defined figure instance used for generating QPT plot.

    ax : figure axis instance
        User defined figure axis instance used for generating QPT plot
        (alternative to the fig argument).

    threshold: float (None)
        Threshold for when bars of smaller height should be transparent. If 
        not set, all bars are colored according to the color map.

    Returns
    -------
    fig, ax : tuple
        A tuple of the matplotlib figure and axes instances used to produce
        the figure.
    """

    if ax is None:
        if fig is None:
            fig = plt.figure(figsize=figsize)
        ax = fig.add_subplot(1, 1, 1, projection='3d', position=[0, 0, 1, 1])

    xlabels = []
    for inds in _index_permutations([len(lbls) for lbls in lbls_list]):
        xlabels.append("".join(
            [lbls_list[k][inds[k]] for k in range(len(lbls_list))]))

    if not title:
        title = r"$\chi$"

    matrix_histogram_complex(chi, xlabels, xlabels, title=title, ax=ax,
                             threshold=threshold)

    return fig, ax
Пример #3
0
def qpt_plot_combined(chi, lbls_list, title=None, fig=None, ax=None):
    """
    Visualize the quantum process tomography chi matrix. Plot bars with
    height and color corresponding to the absolute value and phase,
    respectively.

    Parameters
    ----------
    chi : array
        Input QPT chi matrix.
    lbls_list : list
        List of labels for QPT plot axes.
    title : string
        Plot title.
    fig : figure instance
        User defined figure instance used for generating QPT plot.
    ax : figure axis instance
        User defined figure axis instance used for generating QPT plot
        (alternative to the fig argument).

    Returns
    -------
    An matplotlib figure instance for the plot.

    """

    if ax is None:
        if fig is None:
            fig = plt.figure(figsize=(8, 6))
        ax = fig.add_subplot(1, 1, 1, projection='3d', position=[0, 0, 1, 1])

    xlabels = []
    for inds in _index_permutations([len(lbls) for lbls in lbls_list]):
        xlabels.append("".join(
            [lbls_list[k][inds[k]] for k in range(len(lbls_list))]))

    if not title:
        title = r"$\chi$"

    matrix_histogram_complex(chi, xlabels, xlabels, title=title, ax=ax)

    return fig
Пример #4
0
def dmat_hist(rho, obj='all', ind=None, im=False):
    """Plots 3D histogram of specified density matrix.
    
    Parameters:
    -----------
    rho: qutip.Result.states
         density matrices per time instant
    obj: int
         Index of desired object in quantum system
    ind: int
         Index of specific density matrix to plot when rho is of qutip.Result.states format
    im: boolean
        Include imaginary part
    """
    
    if isinstance(rho, list):
        dm = rho[ind]
    else:
        dm = rho
    
    if obj != 'all':
        if not isinstance(obj, int):
            raise ValueError("Give integer value for 'obj'")
        dm = dm.ptrace(obj)
    
    if obj == 0:
        title = "Histogram of density matrix of qubit"
    elif (isinstance(obj, int) and obj > 0):
        title = "Histogram of density matrix of cavity {}".format(obj)
    elif obj == 'all':
        title = "Histogram of density matrix of total system"
    
    if im:
        matrix_histogram_complex(dm.full(), title=title)
    else:
        matrix_histogram(dm.full().real, title=title)