Express¶
The express
module contains a database of pre-computed, example data sets (see below) generated with classical compute methods as well as
helpful methods and model hamiltonians for use in testing and benchmarking.
Express methods¶
Each example data set is stored in a structured .h5
file which can be
loaded as a Python namedtuple
collection as follows:
from inquanto.express import load_h5, list_h5
print("Available express files:\n", list_h5())
h2_sto3g_data = load_h5("h2_sto3g.h5", as_tuple=True)
hamiltonian = h2_sto3g_data.hamiltonian_operator
print("\nFile description:\n", h2_sto3g_data.description)
print("\nHamiltonian operator:\n", hamiltonian.to_FermionOperator())
print("\nH2 STO-3G CCSD Energy:\n" + str(h2_sto3g_data.energy_ccsd) +' Ha')
Available express files:
['beh2_purvis_A_purvis_symmetry.h5', 'h2_1_ring_sto3g.h5', 'beh2_sto3g_symmetry.h5', 'h2o_sto3g_symmetry.h5', 'beh2_purvis_A_purvis_cas44_symmetry.h5', 'h2_4_ring_sto3g.h5', 'h2_4_pbc_sto3g.h5', 'lih_631g.h5', 'h2_sto3g.h5', 'h2_3_ring_sto3g.h5', 'h4_square_sto3g_m3.h5', 'h2_1_pbc_sto3g.h5', 'h3_chain_sto3g.h5', 'nh3_sto3g_symmetry.h5', 'h2_2_ring_sto3g.h5', 'h2_2_pbc_sto3g.h5', 'h2_1_pbc_631g.h5', 'lih_sto3g.h5', 'hehp_sto3g_symmetry.h5', 'h3p_chain_sto3g.h5', 'heh_sto3g_u.h5', 'ch2_sto3g_m3.h5', 'ch4_sto3g.h5', 'ch4_sto3g_symmetry.h5', 'h3p_sto3g_c2v.h5', 'h2_1_ring_631g.h5', 'h2_2_pbc_631g.h5', 'h2_3_pbc_sto3g.h5', 'h2_5_pbc_sto3g.h5', 'h2_5_ring_sto3g.h5', 'nh3_sto3g.h5', 'h2_sto3g_symmetry.h5', 'h5_sto3g_m2.h5', 'h3_sto3g_m2.h5', 'h2_2_ring_631g.h5', 'beh2_purvis_E_purvis_cas44_symmetry.h5', 'h2_631g_symmetry.h5', 'h2o_sto3g.h5', 'ch2_sto3g_m3_u.h5', 'beh2_purvis_E_purvis_cas22_symmetry.h5', 'h2_sto3g_long.h5', 'beh2_purvis_E_purvis_symmetry.h5', 'beh2_purvis_A_purvis_cas22_symmetry.h5', 'h2_631g.h5', 'hehp_sto3g.h5', 'beh2_sto3g.h5', 'h5_sto3g_m2_u.h5', 'h3_sto3g_m2_u.h5', 'lih_sto3g_symmetry.h5']
File description:
H2 molecule with bond length 0.7122Å, calculated with the sto3g basis set in a spin-restricted formalism.
Hamiltonian operator:
(0.7430177069924179, ), (-1.270292724390438, F0^ F0 ), (-0.45680735030941033, F2^ F2 ), (-1.270292724390438, F1^ F1 ), (-0.45680735030941033, F3^ F3 ), (0.48890859745047327, F2^ F0^ F0 F2 ), (0.48890859745047327, F3^ F1^ F1 F3 ), (0.6800618575841273, F1^ F0^ F0 F1 ), (0.6685772770134888, F2^ F1^ F1 F2 ), (0.1796686795630157, F1^ F0^ F2 F3 ), (-0.17966867956301558, F2^ F1^ F0 F3 ), (-0.17966867956301558, F3^ F0^ F1 F2 ), (0.1796686795630155, F3^ F2^ F0 F1 ), (0.6685772770134888, F3^ F0^ F0 F3 ), (0.7028135332762804, F3^ F2^ F2 F3 )
H2 STO-3G CCSD Energy:
-1.1368465754747636 Ha
A list of the available data sets is given below, or can be queried with the
list_h5()
function.
In addition to the data sets listed below, the express module contains additional tools for easily running simple
calculations. The run_rhf()
and run_rohf()
functions allow for
quick SCF calculations providing basic data:
from inquanto.express import run_rhf
e_total, mo_energy, mo_coeff, rdm1 = run_rhf(h2_sto3g_data.hamiltonian_operator, h2_sto3g_data.n_electron)
print("Hartree-Fock energy: {}".format(e_total))
Hartree-Fock energy: -1.117505884204331
Similarly, the run_vqe()
function performs a simple, state-vector VQE calculation,
as shown in the quick-start guide:
from inquanto.express import run_vqe
from inquanto.states import FermionState
from inquanto.spaces import FermionSpace
from inquanto.ansatzes import FermionSpaceAnsatzUCCSD
from pytket.extensions.qiskit import AerStateBackend
backend = AerStateBackend()
state = FermionState([1, 1, 0, 0])
space = FermionSpace(4)
ansatz = FermionSpaceAnsatzUCCSD(fermion_space=space, fermion_state=state)
qubit_hamiltonian = hamiltonian.qubit_encode()
vqe = run_vqe(ansatz, qubit_hamiltonian, backend)
print("VQE Energy: ", round(vqe.final_value, 8))
# TIMER BLOCK-0 BEGINS AT 2024-11-20 16:02:20.932835
# TIMER BLOCK-0 ENDS - DURATION (s): 0.1970085 [0:00:00.197009]
VQE Energy: -1.13684658
When preparing to process circuits on noisy quantum hardware it can be useful to first
employ simple noise models in simulations. The get_noisy_backend()
function
returns a shot-based AerBackend simulator class which includes only CNOT depolarizing errors and readout error.
from inquanto.express import get_noisy_backend
noisy_aer = get_noisy_backend(n_qubits=4, cx_err=0.01, ro_err=0.001)
type(noisy_aer)
pytket.extensions.qiskit.backends.aer.AerBackend
This can be used as a direct replacement when AerBackend is used in examples and tutorials to study the effect of noise.
Model hamiltonians¶
Finally, the express
module also contains drivers for generating simple Hubbard Hamiltonians,
such as the dimer:
from inquanto.express import DriverHubbardDimer
hubbard_dimer_driver = DriverHubbardDimer(t=0.2, u=2.0)
dimer_ham, dimer_space, dimer_hf_state = hubbard_dimer_driver.get_system()
print('Dimer Hamiltonian:\n', dimer_ham.normal_ordered().compress())
Dimer Hamiltonian:
(-0.2, F2^ F0 ), (-0.2, F0^ F2 ), (-0.2, F3^ F1 ), (-0.2, F1^ F3 ), (-2.0, F1^ F0^ F1 F0 ), (-2.0, F3^ F2^ F3 F2 )
As well as the Hamiltonians for chain (finite number of sites with end sites not connected) and ring (finite number of sites with end sites connected) topologies:
from inquanto.express import DriverGeneralizedHubbard
hubbard_ring_driver = DriverGeneralizedHubbard(t=-0.2, u=2.0, n=3, ring=True)
hubbard_chain_driver = DriverGeneralizedHubbard(t=-0.2, u=2.0, n=3, ring=False)
ring_ham, ring_space, ring_hf_state = hubbard_ring_driver.get_system()
chain_ham, chain_space, chain_hf_state = hubbard_chain_driver.get_system()
print('\nRing Hamiltonian:\n', ring_ham.normal_ordered().compress())
print('\nChain Hamiltonian:\n', chain_ham.normal_ordered().compress())
Ring Hamiltonian:
(-0.2, F0^ F2 ), (-0.2, F0^ F4 ), (-0.2, F2^ F0 ), (-0.2, F2^ F4 ), (-0.2, F4^ F0 ), (-0.2, F4^ F2 ), (-0.2, F1^ F3 ), (-0.2, F1^ F5 ), (-0.2, F3^ F1 ), (-0.2, F3^ F5 ), (-0.2, F5^ F1 ), (-0.2, F5^ F3 ), (-2.0, F1^ F0^ F1 F0 ), (-2.0, F3^ F2^ F3 F2 ), (-2.0, F5^ F4^ F5 F4 )
Chain Hamiltonian:
(-0.2, F0^ F2 ), (-0.2, F2^ F0 ), (-0.2, F2^ F4 ), (-0.2, F4^ F2 ), (-0.2, F1^ F3 ), (-0.2, F3^ F1 ), (-0.2, F3^ F5 ), (-0.2, F5^ F3 ), (-2.0, F1^ F0^ F1 F0 ), (-2.0, F3^ F2^ F3 F2 ), (-2.0, F5^ F4^ F5 F4 )
Note the minus sign for the t
argument for DriverGeneralizedHubbard
(whereas for
DriverHubbardDimer
t
is negated when the Hamiltonian is constructed). This reflects the different conventions used in the literature; in some conventions t
is kept negative, while in general the sign can be absorbed into the coefficients. Hence for a more “general” approach, the sign of the user-provided t
is not changed in DriverGeneralizedHubbard
. To
generate the same Hubbard dimer Hamiltonian as above with DriverGeneralizedHubbard
, use:
from inquanto.express import DriverGeneralizedHubbard
hubbard_dimer_driver = DriverGeneralizedHubbard(t=-0.2, u=2.0, n=2, ring=False)
dimer_ham, dimer_space, dimer_hf_state = hubbard_dimer_driver.get_system()
print('Dimer Hamiltonian:\n', dimer_ham.normal_ordered().compress())
Dimer Hamiltonian:
(-0.2, F0^ F2 ), (-0.2, F2^ F0 ), (-0.2, F1^ F3 ), (-0.2, F3^ F1 ), (-2.0, F1^ F0^ F1 F0 ), (-2.0, F3^ F2^ F3 F2 )
List of Express files¶
The full list of chemical data sets included in the express
module are given below. Files are
labeled by the system atoms and structure. Charges are indicated by p
for + and n
for -
appended to the atom list, and basis sets are labeled (e.g. sto3g
). A spin multiplicity greater than 1
is labeled as m#
, where 2
labels a doublet state. Lastly, u
indicates the unrestricted
Hartree-Fock formalism, and no such label always implies restricted Hartree-Fock.
File name |
Description |
---|---|
beh2_purvis_A_purvis_cas22_symmetry.h5 |
BeH2 molecule geometry A from G. D. Purvis III, R. Shepard, F. B. Brown and R. J. Bartlett, Int. J. Quantum Chem., 1983, 23, 835–845. |
beh2_purvis_A_purvis_cas44_symmetry.h5 |
BeH2 molecule geometry A from G. D. Purvis III, R. Shepard, F. B. Brown and R. J. Bartlett, Int. J. Quantum Chem., 1983, 23, 835–845. |
beh2_purvis_A_purvis_symmetry.h5 |
BeH2 molecule geometry A from G. D. Purvis III, R. Shepard, F. B. Brown and R. J. Bartlett, Int. J. Quantum Chem., 1983, 23, 835–845. |
beh2_purvis_E_purvis_cas22_symmetry.h5 |
BeH2 molecule geometry E from G. D. Purvis III, R. Shepard, F. B. Brown and R. J. Bartlett, Int. J. Quantum Chem., 1983, 23, 835–845. |
beh2_purvis_E_purvis_cas44_symmetry.h5 |
BeH2 molecule geometry E from G. D. Purvis III, R. Shepard, F. B. Brown and R. J. Bartlett, Int. J. Quantum Chem., 1983, 23, 835–845. |
beh2_purvis_E_purvis_symmetry.h5 |
BeH2 molecule geometry E from G. D. Purvis III, R. Shepard, F. B. Brown and R. J. Bartlett, Int. J. Quantum Chem., 1983, 23, 835–845. |
beh2_sto3g.h5 |
BeH2 molecule, calculated with the sto3g basis set, with a spin-restricted formalism. |
beh2_sto3g_symmetry.h5 |
BeH2 molecule, calculated with point group symmetries in the sto3g basis, with a spin-restricted formalism. |
ch2_sto3g_m3.h5 |
CH2 molecule with spin multiplicity 3. Calculated with the sto3g basis set in a spin-restricted formalism. |
ch2_sto3g_m3_u.h5 |
CH2 molecule with spin multiplicity 3. Calculated with the sto3g basis set in a spin-unrestricted formalism. |
ch4_sto3g.h5 |
CH4 molecule, calculated with the sto3g basis set in a spin-restricted formalism. |
ch4_sto3g_symmetry.h5 |
CH4 molecule, calculated with point group symmetries in the sto3g basis, with a spin-restricted formalism. |
h2_1_pbc_631g.h5 |
H2 molecule in a tetragonal unit cell with periodic boundary conditions. Calculated with the 631g basis set in a spin-restricted formalism. |
h2_1_pbc_sto3g.h5 |
H2 molecule in a tetragonal unit cell with periodic boundary conditions. Calculated with the sto3g basis set in a spin-restricted formalism. |
h2_1_ring_631g.h5 |
A single H2 molecule, calculated with the 631g basis in a spin-restricted formalism. |
h2_1_ring_sto3g.h5 |
A single H2 molecule, calculated with the sto3g basis in a spin-restricted formalism. |
h2_2_pbc_631g.h5 |
2x1x1 supercell of the periodic H2 system in h2_1_pbc_631g.h5. |
h2_2_pbc_sto3g.h5 |
2x1x1 supercell of the periodic H2 system in h2_1_pbc_sto3g.h5. |
h2_2_ring_631g.h5 |
2 H2 molecules in a ring geometry, calculated with the 631g basis in a spin-restricted formalism. |
h2_2_ring_sto3g.h5 |
2 H2 molecules in a ring geometry, calculated with the sto3g basis in a spin-restricted formalism. |
h2_3_pbc_sto3g.h5 |
3x1x1 supercell of the periodic H2 system in h2_1_pbc_sto3g.h5. |
h2_3_ring_sto3g.h5 |
3 H2 molecules in a ring geometry, calculated with the sto3g basis in a spin-restricted formalism. |
h2_4_pbc_sto3g.h5 |
4x1x1 supercell of the periodic H2 system in h2_1_pbc_sto3g.h5. |
h2_4_ring_sto3g.h5 |
4 H2 molecules in a ring geometry, calculated with the sto3g basis in a spin-restricted formalism. |
h2_5_pbc_sto3g.h5 |
5x1x1 supercell of the periodic H2 system in h2_1_pbc_sto3g.h5. |
h2_5_ring_sto3g.h5 |
5 H2 molecules in a ring geometry, calculated with the sto3g basis in a spin-restricted formalism. |
h2_631g.h5 |
H2 molecule with bond length 0.73Å, calculated with the 631g basis set in a spin-restricted formalism. |
h2_631g_symmetry.h5 |
H2 molecule, calculated with point group symmetries in the 631g basis, with a spin-restricted formalism. |
h2_sto3g.h5 |
H2 molecule with bond length 0.7122Å, calculated with the sto3g basis set in a spin-restricted formalism. |
h2_sto3g_long.h5 |
H2 molecule with a longer bond length of 0.735Å compared to h2_sto3g.h5. |
h2_sto3g_symmetry.h5 |
H2 molecule, calculated with point group symmetries in the sto3g basis, with a spin-restricted formalism. |
h2o_sto3g.h5 |
H2O molecule, calculated with the sto3g basis set in a spin-restricted formalism. |
h2o_sto3g_symmetry.h5 |
H2O molecule, calculated with point group symmetries in the sto3g basis, with a spin-restricted formalism. |
h3_chain_sto3g.h5 |
Linear chain of three H atoms with seperation 0.9Å, calculated with the sto3g basis in a spin-restricted formalism. |
h3_sto3g_m2.h5 |
Linear chain of three H atoms with spin multiplicity 2, calculated with the sto3g basis in a spin-restricted formalism. |
h3_sto3g_m2_u.h5 |
Linear chain of three H atoms with spin multiplicity 2, calculated with the sto3g basis in a spin-unrestricted formalism. |
h3p_chain_sto3g.h5 |
Linear H3+ chain with seperation 0.9Å, calculated with the sto3g basis in a spin-restricted formalism. |
h3p_sto3g_c2v.h5 |
H3+ chain with C2v symmetry, calculated with point group symmetries in the sto3g basis, with a spin-restricted formalism. |
h4_square_sto3g_m3.h5 |
Four H atoms in a square geometry with spin multiplicity 3, calculated with the sto3g basis in a spin-restricted formalism |
h5_sto3g_m2.h5 |
H5 molecule with spin multiplicity 2. Calculated with the sto3g basis set in a spin-restricted formalism. |
h5_sto3g_m2_u.h5 |
H5 molecule with spin multiplicity 2. Calculated with the sto3g basis set in a spin-unrestricted formalism. |
heh_sto3g_u.h5 |
HeH molecule with bond length 0.772Å and spin multiplicity 2. Calculated with the sto3g basis set in a spin-unrestricted formalism. |
hehp_sto3g.h5 |
HeH+ molecule with bond length 0.772Å. Calculated with the sto3g basis set in the spin-restricted formalism. |
hehp_sto3g_symmetry.h5 |
HeH+ molecule with bond length 0.772Å. Calculated with point group symmetries in the sto3g basis set in the spin-restricted formalism. |
lih_631g.h5 |
LiH molecule with bond length 1.64Å, calculated with the 631g basis in a spin-restricted formalism. |
lih_sto3g.h5 |
LiH molecule with bond length 1.511Å, calculated with the sto3g basis in a spin-restricted formalism. |
lih_sto3g_symmetry.h5 |
LiH molecule with bond length 1.511Å, calculated with point group symmetries in the sto3g basis, with a spin-restricted formalism. |
nh3_sto3g.h5 |
NH3 molecule, calculated in the sto3g basis set with a spin-restricted formalism. |
nh3_sto3g_symmetry.h5 |
NH3 molecule, calculated with point group symmetries in the sto3g basis, with a spin-restricted formalism. |