qc2.ansatz.qiskit

Submodules

Classes

LUCJ

LUCJ ansatz using Unitary Coupled-Cluster with Jastrow factor.

GateFabric

Gate Fabric ansatz implementation for Qiskit.

Package Contents

class qc2.ansatz.qiskit.LUCJ(mol: pyscf.gto.Mole, active_space: Iterable | None = None, n_reps: int = 2, initial_state: qiskit.circuit.QuantumCircuit | None = None, name: str | None = 'LUCJ')[source]

Bases: qiskit.circuit.library.blueprintcircuit.BlueprintCircuit

LUCJ ansatz using Unitary Coupled-Cluster with Jastrow factor.

mol
active_space = None
_num_spatial_orbitals
_num_particles
_num_qubits
n_reps = 2
ccsd = None
property num_qubits: int

The number of qubits.

property num_spatial_orbitals: int

The number of spatial orbitals.

property num_particles: tuple[int, int]

The number of particles.

_run_scf()[source]

Runs a self-consistent field calculation.

_set_initial_state(initial_state: qiskit.circuit.QuantumCircuit | None) None[source]

Sets the initial state circuit for the LUCJ ansatz.

Parameters:

initial_state – Initial state circuit (Hartree-Fock if None)

_check_configuration(raise_on_failure: bool = True) bool[source]

Check if the configuration of the NLocal class is valid.

Parameters:

raise_on_failure – Whether to raise on failure.

Returns:

True, if the configuration is valid and the circuit can be constructed. Otherwise an ValueError is raised.

Raises:
  • ValueError – If the numbr fo qubit is not set.

  • ValueError – If the number of spatial orbitals is lower than the number of particles

_build()[source]
get_operator() ffsim.UCJOpSpinBalanced[source]

” Returns the LUCJ operator.

get_state(initial_state: numpy.ndarray | None = None) numpy.ndarray[source]

Constructs and returns the LUCJ ansatz state.

class qc2.ansatz.qiskit.GateFabric(num_spatial_orbitals: int, num_particles: tuple, qubit_mapper: qiskit_nature.second_q.mappers.QubitMapper, initial_state: qiskit.circuit.QuantumCircuit | None = None, num_layers: int = 1, include_pi: bool = False, name: str | None = 'GateFabric')[source]

Bases: qiskit.circuit.library.blueprintcircuit.BlueprintCircuit

Gate Fabric ansatz implementation for Qiskit.

_num_qubits
_num_spatial_orbitals
_num_particles
_qubit_mapper
_num_layers = 1
_include_pi = False
_initial_state
property qubit_mapper: qiskit_nature.second_q.mappers.QubitMapper | None

The qubit operator mapper.

property num_qubits: int

The number of qubits.

property num_spatial_orbitals: int

The number of spatial orbitals.

property num_particles: tuple[int, int]

The number of particles.

_check_configuration(raise_on_failure: bool = True) bool[source]

Check if the configuration of the NLocal class is valid.

Parameters:

raise_on_failure – Whether to raise on failure.

Returns:

True, if the configuration is valid and the circuit can be constructed. Otherwise an ValueError is raised.

Raises:
  • ValueError – If the numbr fo qubit is not set.

  • ValueError – If the number of spatial orbitals is lower than the number of particles

_build() None[source]

Builds the Gate Fabric circuit

_gate_fabric_layer(circuit: qiskit.circuit.QuantumCircuit, parameters: list, wires: list) None[source]

Implements a single layer of Gate Fabric

_orbital_rotation(circuit: qiskit.circuit.QuantumCircuit, theta: qiskit.circuit.Parameter, qubits: list) None[source]

Implements the orbital rotation gate

_double_excitation(circuit: qiskit.circuit.QuantumCircuit, phi: qiskit.circuit.Parameter, qubits: list) None[source]

Implements the double excitation gate