HeisenbergModel class
- class HeisenbergModel(N, J)
A class that simulates the 1D Heisenberg model, a fundamental model in quantum mechanics for understanding magnetic properties in materials.
- Parameters:
N (int) – The number of spins in the 1D Heisenberg chain.
J (float) – The exchange interaction strength between neighboring spins.
- N
The number of spins in the Heisenberg chain.
- J
The coupling constant representing the strength of the exchange interaction.
- Sx
The Pauli X matrix used to represent spin interactions along the x-axis.
- Sy
The Pauli Y matrix used to represent spin interactions along the y-axis.
- Sz
The Pauli Z matrix used to represent spin interactions along the z-axis.
- I
The identity matrix representing no spin interaction.
- build_hamiltonian()
Constructs the Hamiltonian matrix for the Heisenberg model using the tensor product of Pauli matrices to represent spin interactions.
- Returns:
The Hamiltonian matrix of the system.
- Return type:
torch.Tensor
- solve_eigenvalues()
Diagonalizes the Hamiltonian matrix to find the eigenvalues and eigenvectors, which represent the energy levels and the corresponding quantum states of the system.
- Returns:
A tuple containing an array of eigenvalues and a matrix of eigenvectors.
- Return type:
(torch.Tensor, torch.Tensor)
- plot_energy_levels(eigenvalues)
Generates a plot of the energy levels of the Heisenberg model.
- Parameters:
eigenvalues (torch.Tensor) – The array of energy levels obtained from diagonalizing the Hamiltonian.
Example Usage
To instantiate the HeisenbergModel, calculate the energy levels, and plot them, you can use the following code:
model = HeisenbergModel(N=4, J=1)
eigenvalues, eigenvectors = model.solve_eigenvalues()
model.plot_energy_levels(eigenvalues)
The output will be a matplotlib plot displaying the energy levels of a 1D Heisenberg chain with 4 spins and an exchange interaction strength of 1.