qml.qchem.molecular_dipole¶
- molecular_dipole(molecule, method='dhf', active_electrons=None, active_orbitals=None, mapping='jordan_wigner', outpath='.', wires=None, args=None, cutoff=1e-16)[source]¶
Generate the dipole moment operator for a molecule in the Pauli basis.
The dipole operator in the second-quantized form is
ˆD=−∑pqdpq[ˆc†p↑ˆcq↑+ˆc†p↓ˆcq↓]−ˆDc+ˆDn,where the matrix elements dpq are given by the integral of the position operator ˆr over molecular orbitals ϕ
dpq=∫ϕ∗p(r)ˆrϕq(r)dr,and ˆc† and ˆc are the creation and annihilation operators, respectively. The contribution of the core orbitals and nuclei are denoted by ˆDc and ˆDn, respectively, which are computed as
ˆDc=2Ncore∑i=1diiandˆDn=Natoms∑i=1ZiRi,where Zi and Ri denote, respectively, the atomic number and the nuclear coordinates of the i-th atom of the molecule.
The fermionic dipole operator is then transformed to the qubit basis, which gives
ˆD=∑jcjPj,where cj is a numerical coefficient and Pj is a tensor product of single-qubit Pauli operators X,Y,Z,I. The qubit observables corresponding to the components ˆDx, ˆDy, and ˆDz of the dipole operator are then computed separately.
- Parameters
molecule (Molecule) – The molecule object
method (str) – Quantum chemistry method used to solve the mean field electronic structure problem. Available options are
method="dhf"
to specify the built-in differentiable Hartree-Fock solver, ormethod="openfermion"
to use the OpenFermion-PySCF plugin (this requiresopenfermionpyscf
to be installed).active_electrons (int) – Number of active electrons. If not specified, all electrons are considered to be active.
active_orbitals (int) – Number of active orbitals. If not specified, all orbitals are considered to be active.
mapping (str) – Transformation used to map the fermionic Hamiltonian to the qubit Hamiltonian. Input values can be
'jordan_wigner'
,'parity'
or'bravyi_kitaev'
.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 for partial mapping. If None, will use identity map.args (array[array[float]]) – Initial values of the differentiable parameters
cutoff (float) – Cutoff value for including the matrix elements ⟨α|ˆr|β⟩. The matrix elements with absolute value less than
cutoff
are neglected.
- Returns
The qubit observables corresponding to the components ˆDx, ˆDy and ˆDz of the dipole operator.
- 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]]) >>> mol = qml.qchem.Molecule(symbols, coordinates, charge=1) >>> dipole_obs = qml.qchem.molecular_dipole(mol, method="openfermion") >>> 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) )