Processing math: 100%

qml.qchem.basis_rotation

basis_rotation(one_electron, two_electron, tol_factor=1e-05, **factorization_kwargs)[source]

Return the grouped coefficients and observables of a molecular Hamiltonian and the basis rotation unitaries obtained with the basis rotation grouping method.

Parameters
  • one_electron (array[float]) – One-electron integral matrix in the molecular orbital basis.

  • two_electron (array[array[float]]) – Two-electron integral tensor in the molecular orbital basis arranged in chemist notation.

  • tol_factor (float) – Threshold error value for discarding the negligible factors.

Keyword Arguments
  • tol_eigval (float) – Threshold error value for discarding the negligible factor eigenvalues. This can be used only when compressed=False.

  • cholesky (bool) – Use Cholesky decomposition for the two_electron instead of eigendecomposition. Default is False.

  • compressed (bool) – Use compressed double factorization for decomposing the two_electron.

  • regularization (string | None) – Type of regularization ("L1" or "L2") to be used for optimizing the factors. Default is to not include any regularization term.

  • **compression_kwargs – Look at the keyword arguments (compression_kwargs) in the factorize() method for all the available options with compressed=True.

Returns

Tuple containing grouped coefficients, grouped observables and basis rotation transformation matrices.

Return type

tuple(list[array[float]], list[list[Observable]], list[array[float]])

Example

>>> symbols  = ['H', 'H']
>>> geometry = np.array([[0.0, 0.0, 0.0],
...                      [1.398397361, 0.0, 0.0]], requires_grad=False)
>>> mol = qml.qchem.Molecule(symbols, geometry)
>>> core, one, two = qml.qchem.electron_integrals(mol)()
>>> coeffs, ops, unitaries = basis_rotation(one, two, tol_factor=1.0e-5)
>>> print(coeffs)
[array([-2.59579282,  0.84064649,  0.84064649,  0.45724992,  0.45724992]),
 array([ 5.60006390e-03, -9.73801723e-05, -9.73801723e-05,  2.84747318e-03,
         9.57150297e-05, -2.79878310e-03,  9.57150297e-05, -2.79878310e-03,
        -2.79878310e-03, -2.79878310e-03,  2.75092558e-03]),
 array([ 0.09060523,  0.04530262, -0.04530262, -0.04530262, -0.04530262,
        -0.04530262,  0.04530262]),
 array([ 1.6874169 , -0.68077716, -0.68077716,  0.17166195, -0.66913628,
         0.16872663, -0.66913628,  0.16872663,  0.16872663,  0.16872663,
         0.16584151])]

A second-quantized molecular Hamiltonian can be constructed in the chemist notation format following Eq. (1) of [PRX Quantum 2, 030305, 2021] as

H=α{,}pqTpqap,αaq,α+12α,β{,}pqrsVpqrsap,αaq,αar,βas,β,

where Vpqrs denotes a two-electron integral in the chemist notation and Tpq is obtained from the one- and two-electron integrals, hpq and hpqrs, as

Tpq=hpq12shpssq.

The tensor V can be converted to a matrix which is indexed by the indices pq and rs and eigendecomposed up to a rank R to give

Vpqrs=RrL(r)pqL(r)Trs,

where L denotes the matrix of eigenvectors of the matrix V. The molecular Hamiltonian can then be rewritten following Eq. (7) of [Phys. Rev. Research 3, 033055, 2021] as

H=α{,}pqTpqap,αaq,α+12Rr(α{,}pqL(r)pqap,αaq,α)2.

The orbital basis can be rotated such that each T and L(r) matrix is diagonal. The Hamiltonian can then be written following Eq. (2) of [npj Quantum Information, 7, 23 (2021)] as

H=U0(pdpnp)U0+RrUr(pqd(r)pqnpnq)Ur,

where the coefficients d are obtained by diagonalizing the T and L(r) matrices. The number operators np=apap can be converted to qubit operators using

np=1Zp2,

where Zp is the Pauli Z operator applied to qubit p. This gives the qubit Hamiltonian

H=U0(pO(0)p)U0+RrUr(qO(r)q)Ur,

where O=iciPi is a linear combination of Pauli words Pi that are a tensor product of Pauli Z and Identity operators. This allows all the Pauli words in each of the O terms to be measured simultaneously. This function returns the coefficients and the Pauli words grouped for each of the O terms as well as the basis rotation transformation matrices that are constructed from the eigenvectors of the T and L(r) matrices. Each column of the transformation matrix is an eigenvector of the corresponding T or L(r) matrix.