qdk_chemistry.plugins.qiskit.conversion module
Conversion utilities for QDK Chemistry to Qiskit interoperability.
This module provides functions to convert QDK Chemistry objects into Qiskit-compatible representations, particularly for quantum circuit simulation and state preparation.
- qdk_chemistry.plugins.qiskit.conversion.apply_matrix_compression_ops(circuit, ops)[source]
Apply matrix compression operations to a Qiskit QuantumCircuit.
Supports all
MatrixCompressionTypeoperations: X, CX, SWAP, CCX, SELECT, and SELECT_AND.- Parameters:
circuit (
QuantumCircuit) – Qiskit QuantumCircuit to append gates to (modified in place).ops (
list[MatrixCompressionOp]) – List of MatrixCompressionOp to apply.
- Return type:
- qdk_chemistry.plugins.qiskit.conversion.create_statevector_from_wavefunction(wavefunction, normalize=True)[source]
Create a Qiskit-compatible statevector from a QDK Chemistry wavefunction.
This function converts a QDK Chemistry wavefunction into a dense statevector representation suitable for use with Qiskit quantum circuit simulators.
The register uses
num_modes * bits_per_modequbits with little-endian ordering. A standard spin-half wavefunction (bits_per_mode == 2) maps each spatial orbital to two qubits — alpha on the lower half, beta on the upper half — for2 * num_active_orbitalsqubits; a spinless subspace (bits_per_mode == 1) uses one qubit per mode. Each determinant’s coefficient is placed at its basis-state index.- Parameters:
wavefunction (
Wavefunction) – The wavefunction to convert to statevector representation. Must have a defined active space with the same number of alpha and beta orbitals.normalize (
bool) – Whether to normalize the resulting statevector to unit norm. Default is True.
- Returns:
- Dense complex statevector of size 2^(num_modes * bits_per_mode).
The dtype is always complex128, even if the wavefunction has real coefficients.
- Return type:
- Raises:
ValueError – If the wavefunction has no active determinants.
Examples
>>> from qiskit.quantum_info import Statevector >>> # Assuming we have a wavefunction already >>> sv_array = create_statevector_from_wavefunction(wavefunction) >>> qiskit_sv = Statevector(sv_array) >>> print(f"Statevector dimension: {len(sv_array)}")