View on GitHub
Open this notebook in GitHub to run it yourself
- Chemical Simulation
- The H2O Hamiltonian Simulation Problem
Output:
Output:
- Conclusion
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
!pip install -qq "classiq[chemistry]"
from openfermion.chem import MolecularData
from openfermionpyscf import run_pyscf
from classiq import *
from classiq.applications.chemistry.mapping import FermionToQubitMapper
from classiq.applications.chemistry.op_utils import qubit_op_to_qmod
from classiq.applications.chemistry.problems import FermionHamiltonianProblem
molecule_H2O_geometry = [
("O", (0.0, 0.0, 0.0)),
("H", (0, 0.586, 0.757)),
("H", (0, 0.586, -0.757)),
]
molecule = MolecularData(molecule_H2O_geometry, "sto-3g", 1, 0)
molecule = run_pyscf(molecule)
problem = FermionHamiltonianProblem.from_molecule(molecule, first_active_index=1)
mapper = FermionToQubitMapper()
hamiltonian = qubit_op_to_qmod(mapper.map(problem.fermion_hamiltonian))
@qfunc
def main(state: Output[QArray]) -> None:
allocate(hamiltonian.num_qubits, state)
suzuki_trotter(
hamiltonian,
evolution_coefficient=1,
order=1,
repetitions=1,
qbv=state,
)
preferences = Preferences(
custom_hardware_settings=CustomHardwareSettings(basis_gates=["cx", "u"])
)
qprog = synthesize(main, preferences=preferences)
print(
f"Classiq's exponentiation depth is {get_transpiled_circuit_metrics(qprog).depth}"
)
print(
f"Classiq's exponentiation CX-count is {get_transpiled_circuit_metrics(qprog).count_ops['cx']}"
)
show(qprog)
Classiq's exponentiation depth is 1471
Classiq's exponentiation CX-count is 1550
Quantum program link: https://platform.classiq.io/circuit/3HojwUh21Q8w0sOY01NcqmwFDS9
Was this page helpful?