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: DataClass

Immutable container for the physical symmetries of an electronic state.

Symmetries serves as the central object for communicating symmetry information to algorithms that can exploit it.

Parameters:
  • n_alpha (int) – Number of alpha (spin-up) electrons in the active space.

  • n_beta (int) – Number of beta (spin-down) electrons in the active space.

Raises:

ValueError – If n_alpha or n_beta is negative.

Examples

>>> sym = Symmetries(n_alpha=2, n_beta=2)
>>> sym.n_particles
4
>>> sym = Symmetries.from_wavefunction(wfn)
__init__(n_alpha, n_beta)[source]

Initialize Symmetries with active-space electron counts.

Parameters:
Return type:

None

classmethod from_wavefunction(wavefunction)[source]

Construct Symmetries from a Wavefunction.

Reads the active-space electron counts via get_active_num_electrons().

Return type:

Symmetries

Parameters:

wavefunction (Wavefunction) – A wavefunction carrying active-space electron information.

Returns:

A new Symmetries instance.

classmethod from_ansatz(ansatz)[source]

Construct Symmetries from an Ansatz.

Delegates to from_wavefunction() using the ansatz’s wavefunction.

Return type:

Symmetries

Parameters:

ansatz (Ansatz) – An ansatz bundling a Hamiltonian and wavefunction.

Returns:

A new Symmetries instance.

property n_alpha: int[source]

Number of alpha (spin-up) electrons in the active space.

property n_beta: int[source]

Number of beta (spin-down) electrons in the active space.

property n_particles: int[source]

Total number of active electrons (n_alpha + n_beta).

property sz: float[source]

Spin projection quantum number \(S_z = (n_\alpha - n_\beta) / 2\).

property spin_multiplicity: int[source]

Spin multiplicity \(2S + 1 = |n_\alpha - n_\beta| + 1\).

get_summary()[source]

Get a human-readable summary of the symmetries.

Return type:

str

Returns:

Summary string describing the symmetries.

Return type:

str

to_json()[source]

Convert the symmetries to a dictionary for JSON serialization.

Return type:

dict[str, Any]

Returns:

Dictionary representation of the symmetries.

Return type:

dict[str, Any]

to_hdf5(group)[source]

Save the symmetries to an HDF5 group.

Return type:

None

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:

Symmetries

Parameters:

json_data (dict[str, Any]) – Dictionary containing the serialized data.

Returns:

New instance reconstructed from JSON data.

Return type:

Symmetries

Raises:

RuntimeError – If version field is missing or incompatible.

classmethod from_hdf5(group)[source]

Load a Symmetries from an HDF5 group.

Return type:

Symmetries

Parameters:

group (h5py.Group) – HDF5 group or file containing the data.

Returns:

New instance reconstructed from HDF5 data.

Return type:

Symmetries

Raises:

RuntimeError – If version attribute is missing or incompatible.