qxmt.hamiltonians.base module

qxmt.hamiltonians.base module#

class qxmt.hamiltonians.base.BaseHamiltonian(platform)

Bases: ABC

Base class for quantum Hamiltonians.

This abstract base class defines the interface for Hamiltonian representations in quantum computing. It provides a common structure for different types of Hamiltonians across various quantum computing platforms.

Parameters:

platform (str) – Name of the quantum computing platform (e.g., “pennylane”).

hamiltonian

The Hamiltonian operator. Type depends on the platform.

n_qubits

Number of qubits required to represent the Hamiltonian.

abstractmethod get_hamiltonian()

Get the Hamiltonian operator.

This method must be implemented by subclasses to return the Hamiltonian operator in the format required by the specific platform.

Returns:

The Hamiltonian operator. The exact type depends on the platform.

Return type:

Any

Note

The returned operator should be compatible with the quantum computing platform specified in the constructor.

abstractmethod get_n_qubits()

Get the number of qubits required to represent the Hamiltonian.

This method must be implemented by subclasses to return the number of qubits needed to represent the Hamiltonian on a quantum computer.

Returns:

Number of qubits required.

Return type:

int

Note

This value is used to validate that the quantum device has sufficient qubits to handle the Hamiltonian.