quchip.viz.device

Per-device spectrum and eigenstate plots.

Functions

plot_energy_levels(device, *[, ax, color, ...])

Plot a single device's bare-Hamiltonian eigenenergies.

plot_wavefunction(device, n, *[, ax, color])

Plot the represented-basis probability weights of eigenstate n.

quchip.viz.device.plot_energy_levels(device, *, ax=None, color=None, linewidth=2.0)[source]

Plot a single device’s bare-Hamiltonian eigenenergies.

Each eigenvalue of device.hamiltonian() is drawn as a horizontal bar annotated with its index in the represented basis. The y-axis is energy in GHz. For a DuffingTransmon the gaps reveal the anharmonicity directly; for a Resonator they are exactly equal.

Parameters:
  • device (BaseDevice) – The device whose bare spectrum should be plotted.

  • ax (matplotlib.axes.Axes, optional) – Existing axes to draw onto. When None a new figure is created.

  • color (str, optional) – Line colour for every level. Defaults to the first tab10 colour.

  • linewidth (float) – Width of each level bar.

Returns:

The figure holding the energy-ladder axes (ax.figure when ax was given).

Return type:

Figure

Examples

>>> import quchip as qc
>>> qubit = qc.DuffingTransmon(freq=5.0, anharmonicity=-0.3, levels=4)
>>> qubit.plot_energy_levels()
quchip.viz.device.plot_wavefunction(device, n, *, ax=None, color=None)[source]

Plot the represented-basis probability weights of eigenstate n.

Shows |<k|psi_n>|^2 for each bare basis state |k>, k = 0 ... levels - 1, where |k> indexes whatever basis device.hamiltonian() is expressed in. Every stock device model shipped with quchip — including DuffingTransmon, ChargeBasisTransmon, Fluxonium, and Resonator — returns a Hamiltonian that is already diagonal in its own retained eigenbasis, so eigenstate n is exactly |n> and the bar chart is a single delta bar for every one of them: this plot cannot show “mixing” for any built-in model. Mixing becomes visible only for a custom device whose hamiltonian() returns a matrix that is not diagonal in its represented basis.

Parameters:
  • device (BaseDevice) – The device whose eigenstates are diagonalised.

  • n (int) – Eigenstate index (0 <= n < device.levels).

  • ax (matplotlib.axes.Axes, optional) – Existing axes to draw onto. When None a new figure is created.

  • color (str, optional) – Bar colour. Defaults to a per-index tab10 cycle.

Returns:

The figure holding the bar-chart axes (ax.figure when ax was given).

Return type:

Figure

Raises:

IndexErrorn is outside [0, device.levels).

Examples

>>> import quchip as qc
>>> transmon = qc.DuffingTransmon(freq=5.0, anharmonicity=-0.3, levels=4)
>>> transmon.plot_wavefunction(n=1)