hqs_spin_mapper.orbital_optimization

Identify the basis of maximally spin-like orbitals from given set of 1-RDMs and 2-RDMs.

Functions

basis_optimization(i, j, rdm1, rdm2[, target])

Optimize the basis for extremal local parities via a single pairwise rotation of orbitals.

general_generator_matrix(angles[, index])

Returns the rotation generator matrix for a given orbital index and vector of angles.

general_rotation_matrix(angles[, index])

Returns the general rotation matrix for a given orbital index and vector of angles.

global_spin_orbital_optimization(...[, ...])

Determine spin-like orbitals via an optimization of local parities.

orbital_parity(angles, rdm1, rdm2[, index])

Returns the local parity of the chosen orbital after rotation with the specified angles.

orbital_parity_gradient(angles, rdm1, rdm2)

Returns the gradient of the local parity of the orbital with respect to the angles.

orbital_parity_hessian(angles, rdm1, rdm2[, ...])

Returns the Hessian of the local parity of the orbital with respect to the angles.

rotate_rdm1(rdm1, U, i, j)

Rotate the 1-RDM for pairwise rotations.

rotate_rdm2(rdm2, U, i, j)

Rotate the 2-RDM for pairwise rotations.

spin_orbital_optimization(transformable_system)

Identify spin-like orbitals using an optimization of the local parities.

Exceptions

SpinNotFoundException

Custom exception that is raised if the search for spin-like orbitals failed.

hqs_spin_mapper.orbital_optimization.spin_orbital_optimization(transformable_system: SpinFinder | Supports_SW_Transformation, space_reduction: bool = True, fast_mode: bool = False, target: str = 'minimum', _delta_sufficiently_spin_like: float = 0.001) None[source]

Identify spin-like orbitals using an optimization of the local parities.

Performs a sequence of pairwise rotation between orbital indices i and j trying to extremize the resulting local parity of the orbital i after rotation.

Parameters:
  • transformable_system (Supports_Spin_Optimization) – Container object for the system data.

  • space_reduction (bool) – Flag for performing rotations in the reduced search space only.

  • fast_mode (bool) – Flag for performing approximate rotations of the RDMs to increase speed. (This will result in slight inaccuracies of the RDMs.)

  • target (str) – Determine the extremum to be determined (default=minimum)

  • _delta_sufficiently_spin_like (float) – Orbitals i with this value for \(\delta\) in

:param :math:`P_i =: :type :math:`P_i =: -1 + delta

Raises:
  • InsufficientProtocolError – The transformable_system does not satisfy

  • Supports_SW_Transformation.

  • ValueError – Invalid target was specified.

hqs_spin_mapper.orbital_optimization.rotate_rdm1(rdm1: ndarray, U: ndarray, i: int, j: int) ndarray[source]

Rotate the 1-RDM for pairwise rotations.

Parameters:
  • rdm1 (np.ndarray) – Matrix description of the 1-RDM.

  • U (np.ndarray) – Rotation matrix \(U_{iq}\).

  • i (int) – First orbital index of the pair.

  • j (int) – Second orbital index of the pair.

Returns:

Rotated 1-RDM

Return type:

np.ndarray

hqs_spin_mapper.orbital_optimization.rotate_rdm2(rdm2: ndarray, U: ndarray, i: int, j: int) ndarray[source]

Rotate the 2-RDM for pairwise rotations.

Parameters:
  • rdm2 (np.ndarray) – Tensor description of the 2-RDM.

  • U (np.ndarray) – Rotation matrix \(U_{iq}\).

  • i (int) – First orbital index of the pair.

  • j (int) – Second orbital index of the pair.

Returns:

Rotated 2-RDM

Return type:

np.ndarray

hqs_spin_mapper.orbital_optimization.basis_optimization(i: int, j: int, rdm1: ndarray, rdm2: ndarray, target: str = 'minimum') Tuple[float, ndarray][source]

Optimize the basis for extremal local parities via a single pairwise rotation of orbitals.

Parameters:
  • i (int) – First orbital index

  • j (int) – Second orbital index

  • rdm1 (np.ndarray) – Matrix of 1-RDM

  • rdm2 (np.ndarray) – 4-Tensor of the 2-RDM

  • target (str) – Determine the extremum to be determined, i.e minimum, maximum or

  • extremum.

Returns:

Optimal rotation angle \(\phi_{ij}\) np.ndarray: Rotation matrix \(U_{iq}\).

Return type:

float

Raises:

ValueError – Invalid optimization target

hqs_spin_mapper.orbital_optimization.global_spin_orbital_optimization(transformable_system: SpinFinder | Supports_SW_Transformation, _algorithm: str = 'trust-ncg', _delta_sufficiently_spin_like: float = 0.001, _maxiter: int = 150) None[source]

Determine spin-like orbitals via an optimization of local parities.

Performs a sequence of pairwise rotation between orbital indices \(i\) and \(j\) trying to minimize the resulting local parity of the orbital \(i\).

Parameters:
  • transformable_system (Supports_Spin_Optimization) – Container object for the system data.

  • _algorithm (str) – Name of the scipy optimization algorithm. Default is trust-ncg

  • _delta_sufficiently_spin_like (float) – Orbitals i with \(P_i = (-1 + \delta)\) are not

  • optimized

  • _maxiter (int) – Maximum number of attempted iterations for the algorithm

Raises:

InsufficientProtocolError – transformable_system does not satisfy Supports_SW_Transformation.