electron_integrals(mol, core=None, active=None)[source]

Return a function that computes the one- and two-electron integrals in the molecular orbital basis.

The one- and two-electron integrals are required to construct a molecular Hamiltonian in the second-quantized form

\[H = \sum_{pq} h_{pq} c_p^{\dagger} c_q + \frac{1}{2} \sum_{pqrs} h_{pqrs} c_p^{\dagger} c_q^{\dagger} c_r c_s,\]

where \(c^{\dagger}\) and \(c\) are the creation and annihilation operators, respectively, and \(h_{pq}\) and \(h_{pqrs}\) are the one- and two-electron integrals. These integrals can be computed by integrating over molecular orbitals \(\phi\) as

\[h_{pq} = \int \phi_p(r)^* \left ( -\frac{\nabla_r^2}{2} - \sum_i \frac{Z_i}{|r-R_i|} \right ) \phi_q(r) dr,\]


\[h_{pqrs} = \int \frac{\phi_p(r_1)^* \phi_q(r_2)^* \phi_r(r_2) \phi_s(r_1)}{|r_1 - r_2|} dr_1 dr_2.\]

The molecular orbitals are constructed as a linear combination of atomic orbitals as

\[\phi_i = \sum_{\nu}c_{\nu}^i \chi_{\nu}.\]

The one- and two-electron integrals can be written in the molecular orbital basis as

\[h_{pq} = \sum_{\mu \nu} C_{p \mu} h_{\mu \nu} C_{\nu q},\]


\[h_{pqrs} = \sum_{\mu \nu \rho \sigma} C_{p \mu} C_{q \nu} h_{\mu \nu \rho \sigma} C_{\rho r} C_{\sigma s}.\]

The \(h_{\mu \nu}\) and \(h_{\mu \nu \rho \sigma}\) terms refer to the elements of the core matrix and the electron repulsion tensor, respectively, and \(C\) is the molecular orbital expansion coefficient matrix.

  • mol (Molecule) – the molecule object

  • core (list[int]) – indices of the core orbitals

  • active (list[int]) – indices of the active orbitals


function that computes the core constant and the one- and two-electron integrals

Return type



>>> symbols  = ['H', 'H']
>>> geometry = np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]], requires_grad = False)
>>> alpha = np.array([[3.42525091, 0.62391373, 0.1688554],
>>>                   [3.42525091, 0.62391373, 0.1688554]], requires_grad=True)
>>> mol = qml.qchem.Molecule(symbols, geometry, alpha=alpha)
>>> args = [alpha]
>>> electron_integrals(mol)(*args)
 array([[-1.3902192695e+00,  0.0000000000e+00],
        [-4.4408920985e-16, -2.9165331336e-01]]),
 array([[[[ 7.1443907755e-01, -2.7755575616e-17],
          [ 5.5511151231e-17,  1.7024144301e-01]],
         [[ 5.5511151231e-17,  1.7024144301e-01],
          [ 7.0185315353e-01,  6.6613381478e-16]]],
        [[[-1.3877787808e-16,  7.0185315353e-01],
          [ 1.7024144301e-01,  2.2204460493e-16]],
         [[ 1.7024144301e-01, -4.4408920985e-16],
          [ 6.6613381478e-16,  7.3883668974e-01]]]]))