qxmt.ansatze.pennylane package

Contents

qxmt.ansatze.pennylane package#

Submodules#

Module contents#

class qxmt.ansatze.pennylane.AllSinglesDoublesAnsatz(device, hamiltonian)#

Bases: BaseVQEAnsatz

All Singles and Doubles (AllSinglesDoubles) ansatz for quantum chemistry.

The AllSinglesDoubles ansatz is a fundamental variational quantum circuit for quantum chemistry calculations that systematically includes all possible single and double excitations from the Hartree-Fock reference state. This ansatz is particularly effective for strongly correlated molecular systems where both single and double excitations contribute significantly to the ground state wavefunction.

The ansatz constructs a quantum state by applying parameterized excitation operators:

|ψ⟩ = exp(∑ᵢ θᵢ Tᵢ) |HF⟩

where Tᵢ represents single and double excitation operators, θᵢ are variational parameters, and |HF⟩ is the Hartree-Fock reference state.

Key features: - Includes all chemically relevant single and double excitations - Maintains particle number conservation and proper spin symmetry - Provides systematic improvement over simpler ansätze like hardware-efficient circuits - Well-suited for molecules with moderate correlation effects - Computationally efficient compared to higher-order excitations

The number of parameters scales polynomially with system size, making it tractable for near-term quantum devices while providing sufficient flexibility for accurate ground state preparation in many molecular systems.

Parameters:
  • device (BaseDevice) – Quantum device for executing the variational circuit.

  • hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem, including information about electrons, orbitals, and molecular geometry.

hamiltonian#

Molecular Hamiltonian for the ansatz.

Type:

MolecularHamiltonian

wires#

Qubit indices used in the quantum circuit.

Type:

range

hf_state#

Hartree-Fock reference state as the initial quantum state.

Type:

np.ndarray

singles#

Indices of all possible single excitations from occupied to virtual orbitals.

Type:

list

doubles#

Indices of all possible double excitations from occupied to virtual orbitals.

Type:

list

n_params#

Total number of variational parameters (sum of singles and doubles).

Type:

int

Example

>>> from qxmt.hamiltonians.pennylane.molecular import MolecularHamiltonian
>>> from qxmt.devices import BaseDevice
>>>
>>> # Create Hamiltonian and device for H2 molecule
>>> hamiltonian = MolecularHamiltonian(...)
>>> device = BaseDevice(...)
>>>
>>> # Initialize AllSinglesDoubles ansatz
>>> ansatz = AllSinglesDoublesAnsatz(device, hamiltonian)
>>>
>>> # Initialize parameters (typically small random values)
>>> params = np.random.normal(0, 0.01, ansatz.n_params)
>>>
>>> # Build and execute quantum circuit
>>> ansatz.circuit(params)

References

Note

This ansatz is ideal for molecules where single and double excitations dominate the correlation energy. For systems requiring higher-order excitations, consider more sophisticated ansätze like kUpCCGSD or adaptive approaches.

circuit(params)#

Construct the AllSinglesDoubles quantum circuit.

Parameters:

params (np.ndarray) – Parameters for the AllSinglesDoubles circuit. The length of this array should match the number of single and double excitations.

Return type:

None

Note

The AllSinglesDoubles operation includes all possible single and double excitations from the Hartree-Fock reference state.

prepare_excitation()#

Prepare the single and double excitations.

This method generates all possible single and double excitations from the Hartree-Fock state.

The results are stored in the following attributes: - self.singles: List of single excitation indices - self.doubles: List of double excitation indices

Note

The number of excitations depends on the number of electrons and orbitals in the system.

Return type:

None

prepare_hf_state()#

Prepare the Hartree-Fock reference state.

This method creates the Hartree-Fock reference state using PennyLane’s qchem module. The Hartree-Fock state is a product state where the first n electrons occupy the lowest energy orbitals.

The state is stored in self.hf_state as a numpy array.

Note

The number of electrons and orbitals are obtained from the Hamiltonian.

Return type:

None

class qxmt.ansatze.pennylane.GeteFabricAnsatz(device, hamiltonian, n_layers=2, include_pi=False)#

Bases: BaseVQEAnsatz

Gate Fabric (GateFabric) ansatz for quantum chemistry calculations.

The GateFabric ansatz is a hardware-efficient variational quantum circuit that employs a structured arrangement of parameterized gates to prepare quantum states for molecular ground state calculations. This ansatz is designed to balance expressibility and trainability while maintaining compatibility with near-term quantum hardware constraints.

The circuit architecture consists of layers of alternating single-qubit rotations and two-qubit entangling gates arranged in a fabric-like pattern. Each layer applies: 1. Parameterized single-qubit rotations (RY gates) on all qubits 2. Controlled entangling operations between neighboring qubits 3. Optional phase gates when include_pi is enabled

The ansatz creates quantum states of the form:

|ψ⟩ = U_fabric^(L)(θ_L) ⋯ U_fabric^(1)(θ_1) |init⟩

where U_fabric^(i) represents the i-th layer, θ_i are variational parameters, and |init⟩ is the initial state (typically Hartree-Fock).

Key features: - Hardware-efficient design suitable for NISQ devices - Structured gate arrangement optimizing qubit connectivity - Adjustable circuit depth through layer parameter - Built-in initialization from Hartree-Fock state - Support for phase gates to enhance expressibility - Polynomial parameter scaling with system size

Parameters:
  • device (BaseDevice) – Quantum device for executing the variational circuit.

  • hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem, containing electron, orbital, and geometry information.

  • n_layers (int, optional) – Number of circuit layers. Higher values increase expressibility but also circuit depth and parameter count. Defaults to 2.

  • include_pi (bool, optional) – Whether to include additional phase (π) gates in the circuit. This can enhance expressibility at the cost of increased complexity. Defaults to False.

hamiltonian#

Molecular Hamiltonian for the ansatz.

Type:

MolecularHamiltonian

wires#

Qubit indices used in the quantum circuit.

Type:

range

n_layers#

Number of layers in the circuit architecture.

Type:

int

include_pi#

Flag indicating whether π gates are included.

Type:

bool

hf_state#

Hartree-Fock reference state for initialization.

Type:

np.ndarray

params_shape#

Shape of the parameter tensor for the circuit.

Type:

tuple

n_params#

Total number of variational parameters.

Type:

int

Example

>>> from qxmt.hamiltonians.pennylane.molecular import MolecularHamiltonian
>>> from qxmt.devices import BaseDevice
>>>
>>> # Create Hamiltonian and device
>>> hamiltonian = MolecularHamiltonian(...)
>>> device = BaseDevice(...)
>>>
>>> # Initialize GateFabric ansatz with 3 layers and π gates
>>> ansatz = GeteFabricAnsatz(device, hamiltonian, n_layers=3, include_pi=True)
>>>
>>> # Initialize parameters
>>> params = np.random.normal(0, 0.1, ansatz.n_params)
>>>
>>> # Build quantum circuit
>>> ansatz.circuit(params)

References

Note

For optimal performance and stability with automatic differentiation, it is recommended to use ‘parameter-shift’ as the diff_method instead of ‘adjoint’ or ‘best’. The GateFabric operation may not work correctly with adjoint differentiation in some cases due to its complex gate structure.

This ansatz is particularly useful when chemical intuition about excitations is limited or when exploring hardware-efficient implementations for specific quantum devices.

circuit(params)#

Construct the GeteFabric quantum circuit.

Parameters:

params (np.ndarray) – Parameters for the GeteFabric circuit. The length of this array should match the number of parameters required by the circuit.

Return type:

None

prepare_hf_state()#

Prepare the Hartree-Fock reference state.

This method creates the Hartree-Fock reference state using PennyLane’s qchem module. The Hartree-Fock state is a product state where the first n electrons occupy the lowest energy orbitals.

The state is stored in self.hf_state as a numpy array.

Note

The number of electrons and orbitals are obtained from the Hamiltonian.

Return type:

None

class qxmt.ansatze.pennylane.KUpCCGSDAnsatz(device, hamiltonian, k=1, delta_sz=0)#

Bases: BaseVQEAnsatz

k-Unitary Pair Coupled Cluster with Generalized Singles and Doubles (kUpCCGSD) ansatz.

The kUpCCGSD ansatz is an extension of the Unitary Pair Coupled Cluster (UpCC) framework that incorporates both generalized single and double excitations. This ansatz is particularly suitable for quantum chemistry calculations as it maintains physical properties such as particle number conservation and spin symmetry while providing a variational quantum circuit for molecular ground state preparation.

The ansatz constructs a quantum state by applying k repetitions of the UpCCGSD unitary operator to the Hartree-Fock reference state:

|ψ⟩ = [U_CCGSD(θ)]^k |HF⟩

where U_CCGSD(θ) includes both single and double excitation operators with parameters θ. The generalized singles include additional spin-flip excitations controlled by the delta_sz parameter, allowing for more flexible electronic structure descriptions.

Key features: - Maintains particle number and spin conservation - Includes generalized single excitations with spin selection rules - Supports multiple repetitions (k) of the unitary operator for enhanced expressibility - Compatible with various molecular systems and basis sets

Parameters:
  • device (BaseDevice) – Quantum device to use for executing the ansatz circuit.

  • hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem. Must contain information about electrons, orbitals, and molecular geometry.

  • k (int, optional) – Number of repetitions of the UpCCGSD unitary operator. Higher values increase circuit depth but may improve state preparation accuracy. Defaults to 1.

  • delta_sz (int, optional) – Spin selection rule for generalized single excitations. Specifies the allowed change in spin projection (sz[p] - sz[r] = delta_sz) where p and r are orbital indices. Valid values are 0, +1, and -1. Defaults to 0.

hamiltonian#

Molecular Hamiltonian for the ansatz.

Type:

MolecularHamiltonian

wires#

Qubit indices used in the quantum circuit.

Type:

range

k#

Number of UpCCGSD unitary repetitions.

Type:

int

delta_sz#

Spin selection rule parameter for generalized singles.

Type:

int

hf_state#

Hartree-Fock reference state as initial quantum state.

Type:

np.ndarray

params_shape#

Shape of the parameter array required for the ansatz.

Type:

tuple

n_params#

Total number of variational parameters.

Type:

int

Example

>>> from qxmt.hamiltonians.pennylane.molecular import MolecularHamiltonian
>>> from qxmt.devices import BaseDevice
>>>
>>> # Create Hamiltonian and device
>>> hamiltonian = MolecularHamiltonian(...)
>>> device = BaseDevice(...)
>>>
>>> # Initialize kUpCCGSD ansatz with 2 repetitions
>>> ansatz = KUpCCGSDAnsatz(device, hamiltonian, k=2, delta_sz=0)
>>>
>>> # Get parameter shape and initialize parameters
>>> param_shape = ansatz.params_shape
>>> params = np.random.normal(0, 0.1, ansatz.n_params)
>>>
>>> # Build quantum circuit
>>> ansatz.circuit(params)

References

Note

This ansatz is designed for near-term quantum devices and provides a balance between circuit depth and expressibility. The choice of k and delta_sz parameters should be optimized based on the specific molecular system and available quantum hardware.

circuit(params)#

Construct the UCCSD quantum circuit.

Parameters:

params (np.ndarray) – Parameters for the KUpCCGSD circuit. The length of this array should match the number of parameters required by the circuit.

Return type:

None

prepare_excitation_wires()#

Prepare the excitation wires for single and double excitations.

This method: 1. Generates all possible single and double excitations from the Hartree-Fock state 2. Converts these excitations to wire indices that can be used in the quantum circuit

The results are stored in the following attributes: - self.singles: List of single excitation indices - self.doubles: List of double excitation indices - self.s_wires: List of wire indices for single excitations - self.d_wires: List of wire indices for double excitations

Note

The number of excitations depends on the number of electrons and orbitals in the system.

Return type:

None

prepare_hf_state()#

Prepare the Hartree-Fock reference state.

This method creates the Hartree-Fock reference state using PennyLane’s qchem module. The Hartree-Fock state is a product state where the first n electrons occupy the lowest energy orbitals.

The state is stored in self.hf_state as a numpy array.

Note

The number of electrons and orbitals are obtained from the Hamiltonian.

Return type:

None

class qxmt.ansatze.pennylane.ParticleConservingU1Ansatz(device, hamiltonian, n_layers=2)#

Bases: BaseVQEAnsatz

Particle-Conserving U(1) ansatz for quantum chemistry calculations.

The ParticleConservingU1 ansatz is a hardware-efficient variational quantum circuit that respects U(1) particle number symmetry, making it particularly well-suited for quantum chemistry applications where particle number conservation is essential. This ansatz provides an excellent balance between expressibility and physical constraints.

The circuit architecture consists of layers of parameterized gates that preserve the total particle number throughout the computation. Each layer contains: 1. Single-qubit rotations that respect particle number conservation 2. Two-qubit gates that maintain the U(1) symmetry 3. Controlled operations that preserve fermion number

The ansatz constructs quantum states of the form:

|ψ⟩ = U_U1^(L)(θ_L) ⋯ U_U1^(1)(θ_1) |init⟩

where U_U1^(i) represents the i-th particle-conserving layer, θ_i are variational parameters, and |init⟩ is the initial state (typically Hartree-Fock).

Key features: - Strict particle number conservation (exact U(1) symmetry) - Hardware-efficient design for NISQ devices - Reduced parameter space due to symmetry constraints - Natural incorporation of physical quantum chemistry constraints - Improved optimization landscape compared to unconstrained ansätze - Compatible with fermionic mappings (Jordan-Wigner, Bravyi-Kitaev)

The U(1) symmetry constraint significantly reduces the parameter space and helps avoid unphysical states during optimization, leading to more stable and efficient variational quantum eigensolvers.

Parameters:
  • device (BaseDevice) – Quantum device for executing the variational circuit.

  • hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem, containing electron configuration, orbital basis, and molecular geometry.

  • n_layers (int, optional) – Number of circuit layers. Each layer applies particle-conserving operations while maintaining U(1) symmetry. Higher values increase expressibility but also circuit depth. Defaults to 2.

hamiltonian#

Molecular Hamiltonian for the ansatz.

Type:

MolecularHamiltonian

n_layers#

Number of layers in the circuit architecture.

Type:

int

wires#

Qubit indices used in the quantum circuit.

Type:

range

hf_state#

Hartree-Fock reference state for initialization.

Type:

np.ndarray

params_shape#

Shape of the parameter tensor for the circuit.

Type:

tuple

n_params#

Total number of variational parameters.

Type:

int

Example

>>> from qxmt.hamiltonians.pennylane.molecular import MolecularHamiltonian
>>> from qxmt.devices import BaseDevice
>>>
>>> # Create Hamiltonian and device
>>> hamiltonian = MolecularHamiltonian(...)
>>> device = BaseDevice(...)
>>>
>>> # Initialize ParticleConservingU1 ansatz with 4 layers
>>> ansatz = ParticleConservingU1Ansatz(device, hamiltonian, n_layers=4)
>>>
>>> # Initialize parameters
>>> params = np.random.normal(0, 0.02, ansatz.n_params)
>>>
>>> # Build quantum circuit (particle number automatically conserved)
>>> ansatz.circuit(params)

References

Note

This ansatz is particularly beneficial for systems where particle number conservation is crucial for physical accuracy. The U(1) symmetry constraint reduces the search space and can lead to faster convergence compared to unconstrained variational circuits.

The reduced parameter space makes this ansatz especially suitable for near-term quantum devices with limited coherence times, as it requires fewer optimization steps while maintaining chemical accuracy.

circuit(params)#

Construct the ParticleConservingU1 quantum circuit.

This method builds a quantum circuit that preserves particle number through U(1) symmetry. The circuit applies multiple layers of particle-conserving gates while maintaining the total number of particles (electrons) in the system.

Parameters:

params (np.ndarray) – Parameters for the ParticleConservingU1 circuit. The length of this array should match the number of parameters required by the circuit (determined by n_layers and number of qubits).

Return type:

None

prepare_hf_state()#

Prepare the Hartree-Fock reference state.

This method creates the Hartree-Fock reference state using PennyLane’s qchem module. The Hartree-Fock state is a product state where the first n electrons occupy the lowest energy orbitals.

The state is stored in self.hf_state as a numpy array.

Note

The number of electrons and orbitals are obtained from the Hamiltonian.

Return type:

None

class qxmt.ansatze.pennylane.ParticleConservingU2Ansatz(device, hamiltonian, n_layers=2)#

Bases: BaseVQEAnsatz

Particle-Conserving U(2) ansatz for quantum chemistry calculations.

The ParticleConservingU2 ansatz is an advanced hardware-efficient variational quantum circuit that respects both U(1) particle number symmetry and additional U(2) symmetries, providing enhanced physical constraints for quantum chemistry applications. This ansatz extends the U(1) framework by incorporating spin symmetries and additional conservation laws.

The U(2) symmetry group includes: - U(1) particle number conservation (total electron count) - Additional symmetries related to spin and orbital angular momentum - Enhanced preservation of physical quantum chemistry properties

The circuit architecture consists of layers of parameterized gates that preserve both particle number and spin-related quantities. Each layer contains: 1. Single-qubit rotations that respect U(2) symmetry constraints 2. Two-qubit gates that maintain particle and spin conservation 3. Controlled operations preserving fermion number and spin projections

The ansatz constructs quantum states of the form:

|ψ⟩ = U_U2^(L)(θ_L) ⋯ U_U2^(1)(θ_1) |init⟩

where U_U2^(i) represents the i-th particle and spin-conserving layer, θ_i are variational parameters, and |init⟩ is the initial state (typically Hartree-Fock).

Key features: - Strict particle number and enhanced symmetry conservation - Hardware-efficient design optimized for NISQ devices - Further reduced parameter space compared to U(1) due to additional constraints - Natural incorporation of spin and orbital symmetries - Improved stability and faster convergence in optimization - Enhanced compatibility with molecular symmetries and point groups - Reduced barren plateau effects due to symmetry constraints

The U(2) symmetry constraints provide even tighter control over the variational space, leading to more efficient optimization and better preservation of molecular properties during the quantum computation.

Parameters:
  • device (BaseDevice) – Quantum device for executing the variational circuit.

  • hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem, containing electron configuration, orbital basis, and molecular geometry.

  • n_layers (int, optional) – Number of circuit layers. Each layer applies particle and spin-conserving operations while maintaining U(2) symmetry. Higher values increase expressibility but also circuit depth. Defaults to 2.

hamiltonian#

Molecular Hamiltonian for the ansatz.

Type:

MolecularHamiltonian

n_layers#

Number of layers in the circuit architecture.

Type:

int

wires#

Qubit indices used in the quantum circuit.

Type:

range

hf_state#

Hartree-Fock reference state for initialization.

Type:

np.ndarray

params_shape#

Shape of the parameter tensor for the circuit.

Type:

tuple

n_params#

Total number of variational parameters.

Type:

int

Example

>>> from qxmt.hamiltonians.pennylane.molecular import MolecularHamiltonian
>>> from qxmt.devices import BaseDevice
>>>
>>> # Create Hamiltonian and device for molecular system
>>> hamiltonian = MolecularHamiltonian(...)
>>> device = BaseDevice(...)
>>>
>>> # Initialize ParticleConservingU2 ansatz with 3 layers
>>> ansatz = ParticleConservingU2Ansatz(device, hamiltonian, n_layers=3)
>>>
>>> # Initialize parameters (smaller values due to tighter constraints)
>>> params = np.random.normal(0, 0.01, ansatz.n_params)
>>>
>>> # Build quantum circuit (particle number and spin automatically conserved)
>>> ansatz.circuit(params)

References

Note

This ansatz is particularly beneficial for molecular systems where both particle number and spin conservation are critical. The U(2) symmetry constraints provide the most restrictive parameter space among particle-conserving ansätze, leading to highly stable optimization but potentially requiring more layers for complex molecular systems.

The enhanced symmetry preservation makes this ansatz ideal for systems with specific spin states or when studying spin-dependent properties. It is especially suitable for near-term quantum devices due to its efficient parameter usage and reduced noise sensitivity.

circuit(params)#

Construct the ParticleConservingU2 quantum circuit.

This method builds a quantum circuit that preserves particle number through U(2) symmetry. The circuit applies multiple layers of particle-conserving gates while maintaining the total number of particles (electrons) in the system.

Parameters:

params (np.ndarray) – Parameters for the ParticleConservingU2 circuit. The length of this array should match the number of parameters required by the circuit (determined by n_layers and number of qubits).

Return type:

None

prepare_hf_state()#

Prepare the Hartree-Fock reference state.

This method creates the Hartree-Fock reference state using PennyLane’s qchem module. The Hartree-Fock state is a product state where the first n electrons occupy the lowest energy orbitals.

The state is stored in self.hf_state as a numpy array.

Note

The number of electrons and orbitals are obtained from the Hamiltonian.

Return type:

None

class qxmt.ansatze.pennylane.UCCSDAnsatz(device, hamiltonian)#

Bases: BaseVQEAnsatz

Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz for quantum chemistry.

The UCCSD ansatz is a cornerstone variational quantum circuit for quantum chemistry calculations that implements the unitary coupled-cluster approximation with singles and doubles excitations. This ansatz provides a quantum analog of the classical coupled-cluster theory, maintaining the systematic improvability and chemical accuracy while being suitable for quantum computers.

The UCCSD ansatz constructs a quantum state through the exponential of anti-Hermitian operators:

|ψ⟩ = exp(T̂ - T̂†) |HF⟩ = exp(∑ᵢ θᵢ(τᵢ - τᵢ†)) |HF⟩

where T̂ = T̂₁ + T̂₂ includes single (T̂₁) and double (T̂₂) excitation operators, θᵢ are variational parameters, and |HF⟩ is the Hartree-Fock reference state.

The unitary form ensures: - Preservation of quantum state normalization - Size-extensivity (energy scales correctly with system size) - Exact reproduction of full configuration interaction in complete basis - Systematic inclusion of electron correlation effects

Key features: - Gold standard for quantum chemistry ansätze - Provides excellent accuracy for weakly to moderately correlated systems - Maintains proper fermion antisymmetry and particle number conservation - Systematic approach derived from established quantum chemistry theory - Serves as a benchmark for other variational ansätze

The circuit implements Trotter approximation of the unitary exponential, making it practical for near-term quantum devices while preserving the essential physics of electron correlation.

Parameters:
  • device (BaseDevice) – Quantum device for executing the variational circuit.

  • hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem, containing electron configuration, orbital basis, and molecular geometry.

hamiltonian#

Molecular Hamiltonian for the ansatz.

Type:

MolecularHamiltonian

wires#

Qubit indices used in the quantum circuit.

Type:

range

hf_state#

Hartree-Fock reference state for initialization.

Type:

np.ndarray

singles#

Indices of single excitations from occupied to virtual orbitals.

Type:

list

doubles#

Indices of double excitations from occupied to virtual orbitals.

Type:

list

s_wires#

Wire indices corresponding to single excitation operations.

Type:

list

d_wires#

Wire indices corresponding to double excitation operations.

Type:

list

n_params#

Total number of variational parameters.

Type:

int

Example

>>> from qxmt.hamiltonians.pennylane.molecular import MolecularHamiltonian
>>> from qxmt.devices import BaseDevice
>>>
>>> # Create Hamiltonian and device for molecular system
>>> hamiltonian = MolecularHamiltonian(...)
>>> device = BaseDevice(...)
>>>
>>> # Initialize UCCSD ansatz
>>> ansatz = UCCSDAnsatz(device, hamiltonian)
>>>
>>> # Initialize parameters (typically from classical coupled-cluster)
>>> params = np.zeros(ansatz.n_params)  # or from CCSD calculation
>>>
>>> # Build and execute quantum circuit
>>> ansatz.circuit(params)

References

Note

UCCSD is computationally more expensive than simpler ansätze but provides superior accuracy for systems where single and double excitations dominate correlation effects. For strongly correlated systems, consider adaptive methods or higher-order excitations.

The parameter initialization can benefit from classical coupled-cluster calculations to provide good starting points for the variational optimization.

circuit(params)#

Construct the UCCSD quantum circuit.

Parameters:

params (np.ndarray) – Parameters for the UCCSD circuit. The length of this array should match the number of single and double excitations.

Return type:

None

Note

The UCCSD operation includes both single and double excitations from the Hartree-Fock reference state.

prepare_excitation_wires()#

Prepare the excitation wires for single and double excitations.

This method: 1. Generates all possible single and double excitations from the Hartree-Fock state 2. Converts these excitations to wire indices that can be used in the quantum circuit

The results are stored in the following attributes: - self.singles: List of single excitation indices - self.doubles: List of double excitation indices - self.s_wires: List of wire indices for single excitations - self.d_wires: List of wire indices for double excitations

Note

The number of excitations depends on the number of electrons and orbitals in the system.

Return type:

None

prepare_hf_state()#

Prepare the Hartree-Fock reference state.

This method creates the Hartree-Fock reference state using PennyLane’s qchem module. The Hartree-Fock state is a product state where the first n electrons occupy the lowest energy orbitals.

The state is stored in self.hf_state as a numpy array.

Note

The number of electrons and orbitals are obtained from the Hamiltonian.

Return type:

None