qml.qchem.dipole_of¶
- dipole_of(symbols, coordinates, name='molecule', charge=0, mult=1, basis='sto-3g', package='pyscf', core=None, active=None, mapping='jordan_wigner', cutoff=1e-12, outpath='.', wires=None)[source]¶
Computes the electric dipole moment operator in the Pauli basis.
The second quantized dipole moment operator ˆD of a molecule is given by
ˆD=−∑α,β⟨α|ˆr|β⟩[ˆc†α↑ˆcβ↑+ˆc†α↓ˆcβ↓]+ˆDn.In the equation above, the indices α,β run over the basis of Hartree-Fock molecular orbitals and the operators ˆc† and ˆc are the electron creation and annihilation operators, respectively. The matrix elements of the position operator ˆr are computed as
⟨α|ˆr|β⟩=∑i,jC∗αiCβj⟨i|ˆr|j⟩,where |i⟩ is the wave function of the atomic orbital, Cαi are the coefficients defining the molecular orbitals, and ⟨i|ˆr|j⟩ is the representation of operator ˆr in the atomic basis.
The contribution of the nuclei to the dipole operator is given by
ˆDn=Natoms∑i=1ZiRiˆI,where Zi and Ri denote, respectively, the atomic number and the nuclear coordinates of the i-th atom of the molecule.
- Parameters
symbols (list[str]) – symbols of the atomic species in the molecule
coordinates (array[float]) – 1D array with the atomic positions in Cartesian coordinates. The coordinates must be given in atomic units and the size of the array should be
3*N
whereN
is the number of atoms.name (str) – name of the molecule
charge (int) – charge of the molecule
mult (int) – spin multiplicity mult=Nunpaired+1 of the Hartree-Fock (HF) state based on the number of unpaired electrons occupying the HF orbitals
basis (str) – Atomic basis set used to represent the molecular orbitals. Basis set availability per element can be found here
package (str) – quantum chemistry package (pyscf) used to solve the mean field electronic structure problem
core (list) – indices of core orbitals
active (list) – indices of active orbitals
mapping (str) – transformation (
'jordan_wigner'
,'parity'
, or'bravyi_kitaev'
) used to map the fermionic operator to the Pauli basiscutoff (float) – Cutoff value for including the matrix elements ⟨α|ˆr|β⟩. The matrix elements with absolute value less than
cutoff
are neglected.outpath (str) – path to the directory containing output files
wires (Wires, list, tuple, dict) – Custom wire mapping used to convert the qubit operator to an observable measurable in a PennyLane ansatz. For types Wires/list/tuple, each item in the iterable represents a wire label corresponding to the qubit number equal to its index. For type dict, only int-keyed dict (for qubit-to-wire conversion) is accepted. If None, will use identity map (e.g. 0->0, 1->1, …).
- Returns
the qubit observables corresponding to the components ˆDx, ˆDy and ˆDz of the dipole operator in atomic units.
- Return type
list[pennylane.Hamiltonian]
Example
>>> symbols = ["H", "H", "H"] >>> coordinates = np.array([0.028, 0.054, 0.0, 0.986, 1.610, 0.0, 1.855, 0.002, 0.0]) >>> dipole_obs = dipole_of(symbols, coordinates, charge=1) >>> print([(h.wires) for h in dipole_obs]) [Wires([0, 1, 2, 3, 4, 5]), Wires([0, 1, 2, 3, 4, 5]), Wires([0])]
>>> dipole_obs[0] # x-component of D ( 0.4781123173263876 * Z(0) + 0.4781123173263876 * Z(1) + -0.3913638489489803 * (Y(0) @ Z(1) @ Y(2)) + -0.3913638489489803 * (X(0) @ Z(1) @ X(2)) + -0.3913638489489803 * (Y(1) @ Z(2) @ Y(3)) + -0.3913638489489803 * (X(1) @ Z(2) @ X(3)) + 0.2661114704527088 * (Y(0) @ Z(1) @ Z(2) @ Z(3) @ Y(4)) + 0.2661114704527088 * (X(0) @ Z(1) @ Z(2) @ Z(3) @ X(4)) + 0.2661114704527088 * (Y(1) @ Z(2) @ Z(3) @ Z(4) @ Y(5)) + 0.2661114704527088 * (X(1) @ Z(2) @ Z(3) @ Z(4) @ X(5)) + 0.7144779061810713 * Z(2) + 0.7144779061810713 * Z(3) + -0.11734958781031017 * (Y(2) @ Z(3) @ Y(4)) + -0.11734958781031017 * (X(2) @ Z(3) @ X(4)) + -0.11734958781031017 * (Y(3) @ Z(4) @ Y(5)) + -0.11734958781031017 * (X(3) @ Z(4) @ X(5)) + 0.24190977644645698 * Z(4) + 0.24190977644645698 * Z(5) )