qml.qchem.generate_hamiltonian

generate_hamiltonian(mol_name, mol_geo_file, mol_charge, multiplicity, basis_set, qc_package='pyscf', n_active_electrons=None, n_active_orbitals=None, mapping='jordan_wigner', outpath='.')[source]

Generates the qubit Hamiltonian based on geometry and mean field electronic structure.

An active space can be defined, otherwise the Hamiltonian is expanded in the full basis of Hartree-Fock (HF) molecular orbitals.

Example usage:

>>> H, n_qubits = generate_hamiltonian('h2', 'h2.xyz', 0, 1, 'sto-3g')
>>> print(n_qubits)
4
>>> print(H)
(-0.04207897647782188) [I0]
+ (0.17771287465139934) [Z0]
+ (0.1777128746513993) [Z1]
+ (-0.24274280513140484) [Z2]
+ (-0.24274280513140484) [Z3]
+ (0.17059738328801055) [Z0 Z1]
+ (0.04475014401535161) [Y0 X1 X2 Y3]
+ (-0.04475014401535161) [Y0 Y1 X2 X3]
+ (-0.04475014401535161) [X0 X1 Y2 Y3]
+ (0.04475014401535161) [X0 Y1 Y2 X3]
+ (0.12293305056183801) [Z0 Z2]
+ (0.1676831945771896) [Z0 Z3]
+ (0.1676831945771896) [Z1 Z2]
+ (0.12293305056183801) [Z1 Z3]
+ (0.176276408043196) [Z2 Z3]
Parameters
  • mol_name (str) – name of the molecule

  • mol_geo_file (str) – name of the file containing the geometry of the molecule

  • mol_charge (int) – net charge of the molecule

  • multiplicity (int) – multiplicity of the Hartree-Fock reference state

  • basis_set (str) – atomic Gaussian-type orbitals basis set. Basis set availability per element can be found here

  • qc_package (str) – quantum chemistry package (pyscf or psi4) used to solve the mean field electronic structure problem

  • n_active_electrons (int) – number of active electrons. If not specified, all electrons are considered to be active

  • n_active_orbitals (int) – number of active orbitals. If not specified, all orbitals are considered to be active

  • mapping (str) – the transformation ('jordan_wigner' or 'bravyi_kitaev') used to map the second-quantized electronic Hamiltonian to the qubit Hamiltonian

  • outpath (str) – path to the directory containing output files

Returns

the fermionic-to-qubit transformed Hamiltonian and the number of qubits

Return type

tuple[pennylane.Hamiltonian, int]