Plotting Wavefunctions of the Quantum Harmonic Oscillator (LC Circuit)#

Let’s start by importing qiskit metal as well as some helpful libraries for math and plotting:

[1]:
import qiskit_metal as metal
import matplotlib.pyplot as plt
import numpy as np
import math

Next, let’s import the function “wavefunction” from the file “HO_wavefunctions.py” located in the analyses / hamiltonian folder. This function takes four arguments: the inductance (L), the capacitance (C), the energy level of the harmonic oscillator (n) and the values of charge (x=Q) for which the wavefunctions are calculated.

[2]:
from qiskit_metal.analyses.hamiltonian.HO_wavefunctions import wavefunction

We’ll define the charge to be in the range (-5,5) with 100 points in between. For simplicity, we’ll set L=C=1.0 in the examples below. We can plot the first five energy levels (N=0 through N=4) of the quantum oscillator by executing the code below:

[3]:
# Let's define the range of x-axis values (representating charge) to be from (-5,5)
x = np.linspace(-5,5,100)

# Let's plot the first five energy levels (N=0 through N=4) of the harmonic oscillator
# We'll just take L=C=1.0 for simplicity
plt.plot(x, wavefunction(1.0, 1.0, 0.0, x), 'k') # N=0; ground state (black)
plt.plot(x, wavefunction(1.0, 1.0, 1.0, x), 'b') # N=1; first excited state (blue)
plt.plot(x, wavefunction(1.0, 1.0, 2.0, x), 'r') # N=2; second excited state (red)
plt.plot(x, wavefunction(1.0, 1.0, 3.0, x), 'g') # N=3; third excited state (green)
plt.plot(x, wavefunction(1.0, 1.0, 4.0, x), 'y') # N=4; fourth excited state (yellow)
plt.xlabel("Charge [Q]")
plt.ylabel("Wavefunction [Psi]")

# show the plot
plt.show()

For more information, review the Introduction to Quantum Computing and Quantum Hardware lectures below

  • Superconducting Qubits I: Quantizing a Harmonic Oscillator, Josephson Junctions Part 1
Lecture Video Lecture Notes Lab
  • Superconducting Qubits I: Quantizing a Harmonic Oscillator, Josephson Junctions Part 2
Lecture Video Lecture Notes Lab
  • Superconducting Qubits I: Quantizing a Harmonic Oscillator, Josephson Junctions Part 3
Lecture Video Lecture Notes Lab
  • Superconducting Qubits II: Circuit Quantum Electrodynamics, Readout and Calibration Methods Part 1
Lecture Video Lecture Notes Lab
  • Superconducting Qubits II: Circuit Quantum Electrodynamics, Readout and Calibration Methods Part 2
Lecture Video Lecture Notes Lab
  • Superconducting Qubits II: Circuit Quantum Electrodynamics, Readout and Calibration Methods Part 3
Lecture Video Lecture Notes Lab