Quantum Harmonic Oscillator

The quantum harmonic oscillator is a mathematical model that describes the behavior of a particle oscillating around an equilibrium point constrained to move along an axis with a harmonic potential. The system is described by the Hamiltonian: $$\hat{H} = \frac{\hat{p}^2}{2m} + \frac{1}{2}m\omega^2\hat{x}^2$$ where $m$ is the mass of the particle and $\omega$ is the frequency of harmonic motion.

The solution of the Schrödinger equation for the quantum harmonic oscillator is known and is given by the Hermite functions, which represent the stationary states of the oscillator. These states are quantized and their energy is given by the formula: $$ E_n = \hbar \omega \left( n + \frac{1}{2} \right) $$

$$\psi_n(x) = \frac{1}{\sqrt{2^n n!}} \left(\frac{m\omega}{\pi \hbar}\right)^{\frac{1}{4}} e^{-\frac{m\omega x^2}{2 \hbar}} H_n \left(\sqrt{\frac{m\omega}{\hbar}}x \right). $$
where $n$ is the quantum number identifying the energy state of the system, $\hbar$ is the reduced Planck constant, $H_n(x)$ are the Hermite polynomials of degree $n$. The eigenvalues of the system are the allowed energies of the particle in the harmonic potential, while the eigenfunctions are the wave functions describing the probability distribution of the particle in the harmonic potential.

The quantum harmonic oscillator has several applications in physics, particularly in quantum mechanics and quantum field theory. For example, it is used to describe the behavior of bound atoms and simple molecules, as well as to describe the behavior of subatomic particles such as electrons in a magnetic field. This is a very important mathematical model because it is one of the few quantum physical system models for which an exact analytical solution of the Schrödinger equation can be found. This makes the quantum harmonic oscillator one of the most studied models in quantum mechanics.

The code solves the eigenvalue problem of the quantum harmonic oscillator $1$D, setting $\hbar = \omega = 1$ for simplicity. In order to solve the problem, the discretization solution is adopted: in theory, the space is continuous, consisting of an infinite number of points. Unfortunately, the reasoning cannot be applied at the practical level where we can only deal with a finite number of points. So we want to adopt a very small step $dx$ in order to approximate the continuous model as best as possible. The discretization produces a simpler tridiagonal Hamiltonian $H_{discr}$, where in the main diagonal we find the terms $-2+V(x_i)$ and in the sub-diagonals we find $-1$.

The 'quantum_harmonic_oscillator function takes as input the minimum and maximum value of the $x$-axis, the discretization step of the $dx$ grid, and the number of eigenvalues to be computed.

First, the range of the $x$-axis, its mean value, and the number of steps within the range are calculated. Next, a matrix of the potential of the quantum harmonic oscillator and an associated diagonal matrix is created. The diagonal matrix consists of the sum of the potential and a constant. In addition, a subdiagonal to the tridiagonal matrix with constant values is created, so that $H_{disc}$ is obtained.

The eigenvalue problem is solved using the 'eigh_tridiagonal' function from the module 'scipy.linalg'. This function returns the eigenvalues and eigenvectors of the tridiagonal matrix from its three diagonals.

Finally, the 'print_results' function prints a table of the expected eigenvalues, the calculated eigenvalues, and the percentage difference between the two. In addition, a graph is generated showing the eigenvalues and eigenvectors of the quantum harmonic oscillator.

Quantum Harmonic Oscillator

Project Information

  • Category: Physics
  • Proeject Url:
  • About: This code is an exercise assigned during the MSc Physics of Matter in Quantum Computation course.

The quantum harmonic oscillator is a mathematical model that describes the behavior of a particle oscillating around an equilibrium point constrained to move along an axis with a harmonic potential. The system is described by the Hamiltonian: $$\hat{H} = \frac{\hat{p}^2}{2m} + \frac{1}{2}m\omega^2\hat{x}^2$$ where $m$ is the mass of the particle and $\omega$ is the frequency of harmonic motion.

The solution of the Schrödinger equation for the quantum harmonic oscillator is known and is given by the Hermite functions, which represent the stationary states of the oscillator. These states are quantized and their energy is given by the formula: $$ E_n = \hbar \omega \left( n + \frac{1}{2} \right) $$

$$\psi_n(x) = \frac{1}{\sqrt{2^n n!}} \left(\frac{m\omega}{\pi \hbar}\right)^{\frac{1}{4}} e^{-\frac{m\omega x^2}{2 \hbar}} H_n \left(\sqrt{\frac{m\omega}{\hbar}}x \right). $$
where $n$ is the quantum number identifying the energy state of the system, $\hbar$ is the reduced Planck constant, $H_n(x)$ are the Hermite polynomials of degree $n$. The eigenvalues of the system are the allowed energies of the particle in the harmonic potential, while the eigenfunctions are the wave functions describing the probability distribution of the particle in the harmonic potential.

The quantum harmonic oscillator has several applications in physics, particularly in quantum mechanics and quantum field theory. For example, it is used to describe the behavior of bound atoms and simple molecules, as well as to describe the behavior of subatomic particles such as electrons in a magnetic field. This is a very important mathematical model because it is one of the few quantum physical system models for which an exact analytical solution of the Schrödinger equation can be found. This makes the quantum harmonic oscillator one of the most studied models in quantum mechanics.

The code solves the eigenvalue problem of the quantum harmonic oscillator $1$D, setting $\hbar = \omega = 1$ for simplicity. In order to solve the problem, the discretization solution is adopted: in theory, the space is continuous, consisting of an infinite number of points. Unfortunately, the reasoning cannot be applied at the practical level where we can only deal with a finite number of points. So we want to adopt a very small step $dx$ in order to approximate the continuous model as best as possible. The discretization produces a simpler tridiagonal Hamiltonian $H_{discr}$, where in the main diagonal we find the terms $-2+V(x_i)$ and in the sub-diagonals we find $-1$.

The 'quantum_harmonic_oscillator function takes as input the minimum and maximum value of the $x$-axis, the discretization step of the $dx$ grid, and the number of eigenvalues to be computed.

First, the range of the $x$-axis, its mean value, and the number of steps within the range are calculated. Next, a matrix of the potential of the quantum harmonic oscillator and an associated diagonal matrix is created. The diagonal matrix consists of the sum of the potential and a constant. In addition, a subdiagonal to the tridiagonal matrix with constant values is created, so that $H_{disc}$ is obtained.

The eigenvalue problem is solved using the 'eigh_tridiagonal' function from the module 'scipy.linalg'. This function returns the eigenvalues and eigenvectors of the tridiagonal matrix from its three diagonals.

Finally, the 'print_results' function prints a table of the expected eigenvalues, the calculated eigenvalues, and the percentage difference between the two. In addition, a graph is generated showing the eigenvalues and eigenvectors of the quantum harmonic oscillator.