dipole_moment(mol, cutoff=1e-16, core=None, active=None)[source]

Return a function that computes the qubit dipole moment observable.

The dipole operator in the second-quantized form is

\[\hat{D} = -\sum_{pq} d_{pq} [\hat{c}_{p\uparrow}^\dagger \hat{c}_{q\uparrow} + \hat{c}_{p\downarrow}^\dagger \hat{c}_{q\downarrow}] - \hat{D}_\mathrm{c} + \hat{D}_\mathrm{n},\]

where the matrix elements \(d_{pq}\) are given by the integral of the position operator \(\hat{{\bf r}}\) over molecular orbitals \(\phi\)

\[d_{pq} = \int \phi_p^*(r) \hat{{\bf r}} \phi_q(r) dr,\]

and \(\hat{c}^{\dagger}\) and \(\hat{c}\) are the creation and annihilation operators, respectively. The contribution of the core orbitals and nuclei are denoted by \(\hat{D}_\mathrm{c}\) and \(\hat{D}_\mathrm{n}\), respectively, which are computed as

\[\hat{D}_\mathrm{c} = 2 \sum_{i=1}^{N_\mathrm{core}} d_{ii},\]


\[\hat{D}_\mathrm{n} = \sum_{i=1}^{N_\mathrm{atoms}} Z_i {\bf R}_i,\]

where \(Z_i\) and \({\bf R}_i\) denote, respectively, the atomic number and the nuclear coordinates of the \(i\)-th atom of the molecule.

The fermonic dipole operator is then transformed to the qubit basis which gives

\[\hat{D} = \sum_{j} c_j P_j,\]

where \(c_j\) is a numerical coefficient and \(P_j\) is a ternsor product of single-qubit Pauli operators \(X, Y, Z, I\).

  • mol (Molecule) – the molecule object

  • cutoff (float) – cutoff value for discarding the negligible dipole moment integrals

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

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


function that computes the qubit dipole moment observable

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]
>>> dipole_moment(mol)(*args)[2].ops
 PauliY(wires=[0]) @ PauliZ(wires=[1]) @ PauliY(wires=[2]),
 PauliX(wires=[0]) @ PauliZ(wires=[1]) @ PauliX(wires=[2]),
 PauliY(wires=[1]) @ PauliZ(wires=[2]) @ PauliY(wires=[3]),
 PauliX(wires=[1]) @ PauliZ(wires=[2]) @ PauliX(wires=[3]),