QuantumHarmonicOscillator class

class QuantumHarmonicOscillator(n, omega)

Represents a quantum harmonic oscillator, which is a fundamental model for quantum systems with quadratic potential energy.

Parameters:
  • n (int) – The number of quantum states to consider in the model.

  • omega (float) – The angular frequency of the oscillator.

n

The number of quantum states included in the model.

omega

The angular frequency of the harmonic oscillator.

hamiltonian

The Hamiltonian matrix representing the quantum harmonic oscillator.

create_annihilation_operator()

Generates the annihilation operator matrix, which is a lower-triangular matrix whose entries are related to the square root of the quantum number of each state.

Returns:

The annihilation operator matrix for n quantum states.

Return type:

torch.Tensor

create_hamiltonian()

Constructs the Hamiltonian matrix for the quantum harmonic oscillator using the annihilation and creation (adjoint of annihilation) operators.

Returns:

The Hamiltonian matrix for the oscillator.

Return type:

torch.Tensor

find_eigenstates()

Diagonalizes the Hamiltonian matrix to find the eigenvalues and eigenvectors, which correspond to the energy levels and quantum states of the oscillator.

Returns:

A tuple containing an array of eigenvalues and a matrix of eigenvectors.

Return type:

(torch.Tensor, torch.Tensor)

print_eigenvalues()

Prints the eigenvalues of the Hamiltonian, which represent the energy levels of the quantum harmonic oscillator.

Example Usage

The following example demonstrates how to instantiate the QuantumHarmonicOscillator class and print out the energy levels of the oscillator:

# Initialize the quantum harmonic oscillator with 10 states and an angular frequency of 1.0
qho = QuantumHarmonicOscillator(n=10, omega=1.0)

# Print the energy levels of the oscillator
qho.print_eigenvalues()

This will display the energy levels of a quantum harmonic oscillator with 10 quantum states and an angular frequency of 1.0.