Skip to content

Second Quantized Hamiltonian

The user can define its chemical problem using second quantized (fermionic) hamiltonian instead of defining the geometry of the molecule. Thus, the user can utilize the power of quantum chemistry software packages such as PYSCF, PSI4 etc., to derive the best suiting hamiltonian for its model.

The user can choose from a vast collection of basis sets, apply complicated symmetries or benefit from existing classical chemical solvers.

Here, we will present a short example of this method using PYSCF. First, using PYSCf a molecule will be converted to fermionic operator. Then, the solving process continues within the standard pipeline.

from classiq.interface.chemistry.molecule import Molecule
from classiq.interface.chemistry.ground_state_problem import MoleculeProblem
from classiq.applications.chemistry.pyscf_hamiltonian import (

molecule = Molecule(
        ("H", (0.0, 0.0, 0.0)),
        ("H", (0.0, 0.0, 0.735)),
molecule_problem = MoleculeProblem(

hamiltonian_problem = generate_hamiltonian_from_pyscf(molecule_problem)

from classiq import ModelDesigner
from classiq.builtin_functions import HardwareEfficientAnsatz
from classiq.interface.chemistry.ground_state_solver import GroundStateSolver
from classiq.interface.executor.optimizer_preferences import GroundStateOptimizer

model_designer = ModelDesigner()

hwea_params = HardwareEfficientAnsatz(
    num_qubits=NUM_QUBITS, connectivity_map=[(0, 1), (1, 2), (2, 3)], reps=3

circuit = model_designer.synthesize()

gs_solver = GroundStateSolver(

result = gs_solver.solve()

A basic script to convert MoleculeProblem to HamiltonianProblem using PYSCF is given in classiq.applications.chemistry.pyscf_hamiltonian. The user can extend it, to use more features from PYSCF.

The rest of the solving process is regular.