qdk_chemistry.data.symmetries module
Symmetries data class for encoding physical symmetries of an electronic state.
The Symmetries class is a general container for symmetry information
that quantum algorithms can exploit to reduce circuit depth or qubit count.
- class qdk_chemistry.data.symmetries.Symmetries(n_alpha, n_beta)[source]
Bases:
DataClassImmutable container for the physical symmetries of an electronic state.
Symmetriesserves as the central object for communicating symmetry information to algorithms that can exploit it.- Parameters:
- Raises:
ValueError – If
n_alphaorn_betais negative.
Examples
>>> sym = Symmetries(n_alpha=2, n_beta=2) >>> sym.n_particles 4
>>> sym = Symmetries.from_wavefunction(wfn)
- classmethod from_wavefunction(wavefunction)[source]
Construct
Symmetriesfrom aWavefunction.Reads the active-space electron counts via
get_active_num_electrons().- Return type:
- Parameters:
wavefunction (Wavefunction) – A wavefunction carrying active-space electron information.
- Returns:
A new
Symmetriesinstance.
- classmethod from_ansatz(ansatz)[source]
Construct
Symmetriesfrom anAnsatz.Delegates to
from_wavefunction()using the ansatz’s wavefunction.- Return type:
- Parameters:
ansatz (Ansatz) – An ansatz bundling a Hamiltonian and wavefunction.
- Returns:
A new
Symmetriesinstance.
- to_hdf5(group)[source]
Save the symmetries to an HDF5 group.
- Return type:
- Parameters:
group (h5py.Group) – HDF5 group or file to write the symmetries to.
- classmethod from_json(json_data)[source]
Create a Symmetries from a JSON dictionary.
- Return type:
- Parameters:
json_data (dict[str, Any]) – Dictionary containing the serialized data.
- Returns:
New instance reconstructed from JSON data.
- Return type:
- Raises:
RuntimeError – If version field is missing or incompatible.
- classmethod from_hdf5(group)[source]
Load a Symmetries from an HDF5 group.
- Return type:
- Parameters:
group (h5py.Group) – HDF5 group or file containing the data.
- Returns:
New instance reconstructed from HDF5 data.
- Return type:
- Raises:
RuntimeError – If version attribute is missing or incompatible.