Unitary Coupled Cluster (UCC) Ansatz¶
The Unitary Coupled Cluster (UCC) is a commonly used chemistry-inspired ansatz, which is a unitary version of the classical coupled cluster (CC) method [1] .
Syntax¶
UCCParameters
:
excitations: List[int]
– List of the desired excitations.
Allowed excitations:
- 1 for singles
- 2 for doubles
- 3 for triples
- 4 for quadruples
Example¶
First the circuit is initialized to the Hartree-Fock state, then the UCC function is applied to generate the desired excitations. Here they are single and double, making it a UCCSD ansatz.
qmod
{
"functions": [
{
"name": "main",
"param_decls": {},
"port_declarations": {},
"operand_declarations": {},
"parameters": [],
"body": [
{
"function": "molecule_hartree_fock",
"params": {
"molecule_problem": {
"expr": "struct_literal(MoleculeProblem, mapping=FermionMapping.JORDAN_WIGNER,z2_symmetries=False,molecule=struct_literal(Molecule, atoms=[struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.0)),struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.735))],spin=1,charge=0),freeze_core=False,remove_orbitals=[])"
}
},
"function_params": {
"parameters": [],
"input_decls": {},
"output_decls": {}
},
"control_states": [],
"inputs": {},
"inouts": {},
"outputs": {
"qbv": {
"name": "hf"
}
},
"name": "molecule_hartree_fock_cs4id_Gz2VZ8",
"operands": {}
},
{
"function": "molecule_ucc",
"params": {
"excitations": {
"expr": "[1, 2]"
},
"molecule_problem": {
"expr": "struct_literal(MoleculeProblem, mapping=FermionMapping.JORDAN_WIGNER,z2_symmetries=False,molecule=struct_literal(Molecule, atoms=[struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.0)),struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.735))],spin=1,charge=0),freeze_core=False,remove_orbitals=[])"
}
},
"function_params": {
"parameters": [],
"input_decls": {},
"output_decls": {}
},
"control_states": [],
"inputs": {
"qbv": {
"name": "hf"
}
},
"inouts": {},
"outputs": {},
"name": "molecule_ucc_cs4id_AkQUyJ",
"operands": {}
}
],
"local_handles": [
{
"name": "hf"
}
]
}
],
"types": [],
"classical_functions": [
{
"name": "cmain",
"param_decls": {},
"body": [
{
"name": "vqe_result",
"var_type": {
"kind": "vqe_result"
}
},
{
"invoked_expression": {
"function": "vqe",
"params": {
"hamiltonian": {
"expr": "molecule_problem_to_hamiltonian(struct_literal(MoleculeProblem, mapping=FermionMapping.JORDAN_WIGNER,z2_symmetries=False,molecule=struct_literal(Molecule, atoms=[struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.0)),struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.735))],spin=1,charge=0),freeze_core=False,remove_orbitals=[]))"
},
"maximize": {
"expr": "false"
},
"initial_point": {
"expr": "[]"
},
"optimizer_name": {
"expr": "Optimizer.COBYLA"
},
"max_iteration": {
"expr": "30"
},
"tolerance": {
"expr": "0.0"
},
"step_size": {
"expr": "0.0"
},
"skip_compute_variance": {
"expr": "false"
},
"alpha_cvar": {
"expr": "1.0"
}
},
"target_function": "main",
"target_params": {}
},
"assigned_variable": "vqe_result"
},
{
"name": "molecule_result",
"var_type": {
"kind": "struct_instance",
"name": "MoleculeResult"
}
},
{
"invoked_expression": {
"expr": "molecule_ground_state_solution_post_process(struct_literal(MoleculeProblem, mapping=FermionMapping.JORDAN_WIGNER,z2_symmetries=False,molecule=struct_literal(Molecule, atoms=[struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.0)),struct_literal(ChemistryAtom, element=Element.H,position=struct_literal(Position, x=0.0,y=0.0,z=0.735))],spin=1,charge=0),freeze_core=False,remove_orbitals=[]),vqe_result)"
},
"assigned_variable": "molecule_result"
},
{
"saved_variable": "molecule_result"
}
]
}
],
"constants": [],
"constraints": {
"max_gate_count": {}
},
"execution_preferences": {
"amplitude_amplification": {
"iterations": []
},
"random_seed": 3566037676,
"backend_preferences": {
"backend_service_provider": "IBM Quantum",
"backend_name": "aer_simulator",
"provider": {}
}
},
"preferences": {
"custom_hardware_settings": {
"basis_gates": [
"x",
"cz",
"id",
"cy",
"p",
"rx",
"tdg",
"sxdg",
"u2",
"sx",
"rz",
"t",
"z",
"u1",
"y",
"h",
"ry",
"sdg",
"cx",
"u",
"s"
]
},
"random_seed": 1528340255
}
}
from classiq import construct_chemistry_model, synthesize
from classiq.applications.chemistry import Molecule, MoleculeProblem
from classiq.applications.chemistry import UCCParameters, ChemistryExecutionParameters
from classiq.execution import OptimizerType
from classiq import execute
molecule = Molecule(
atoms=[("H", (0.0, 0.0, 0.0)), ("H", (0.0, 0.0, 0.735))],
)
gs_problem = MoleculeProblem(
molecule=molecule,
mapping="jordan_wigner",
)
ansatz_parameters = UCCParameters(
excitations=[1, 2],
)
execution_params = ChemistryExecutionParameters(
optimizer=OptimizerType.COBYLA,
max_iteration=30,
)
model = construct_chemistry_model(
chemistry_problem=gs_problem,
use_hartree_fock=True,
ansatz_parameters=ansatz_parameters,
execution_parameters=execution_params,
)
qprog = synthesize(model)
result = execute(qprog)
The output circuit:
[1] Panagiotis Kl. Barkoutsos, Jerome F. Gonthier, Igor Sokolov, Nikolaj Moll, Gian Salis, Andreas Fuhrer, Marc Ganzhorn, Daniel J. Egger, Matthias Troyer, Antonio Mezzacapo, Stefan Filipp, and Ivano Tavernelli Quantum algorithms for electronic structure calculations: Particle-hole Hamiltonian and optimized wave-function expansions Phys. Rev. A 98, 022322 (2018).