I encountered the issue that when defining my customized excitation list in the UCC algorithm, there was only one parameter. How to fix this so that the algorithm assign one parameter for each excitation defined? The code is as follow:

from qiskit import *
import numpy as np

#Operator Imports
from qiskit.opflow import Z, X, I

#Circuit imports
from qiskit_nature.drivers import PySCFDriver, UnitsType, QMolecule, FermionicDriver
from qiskit_nature.problems.second_quantization.electronic import ElectronicStructureProblem
from qiskit_nature.circuit.library import HartreeFock, UCCSD, UCC
from qiskit_nature.transformers import FreezeCoreTransformer, ActiveSpaceTransformer
from qiskit_nature.algorithms import GroundStateEigensolver
from qiskit_nature.results import EigenstateResult
from qiskit import Aer
from qiskit_nature.mappers.second_quantization import ParityMapper, JordanWignerMapper
from qiskit_nature.converters.second_quantization import QubitConverter
from qiskit.algorithms.optimizers import L_BFGS_B, SPSA, AQGD, CG, ADAM, P_BFGS, SLSQP, NELDER_MEAD
from qiskit.algorithms import VQE, NumPyMinimumEigensolver
from qiskit.circuit.library import TwoLocal, EfficientSU2
import matplotlib.pyplot as plt
import matplotlib
from qiskit.tools.visualization import circuit_drawer

driver = PySCFDriver(atom='H -1.9767, .0, 1.53054; \
                        O  .0, .0, .0; \
                        H 1.9767, .0, 1.53054;',

at = ActiveSpaceTransformer(8, 5)
ft = FreezeCoreTransformer()

problem = ElectronicStructureProblem(driver, q_molecule_transformers=[ft, at])

# generate the second-quantized operators
second_q_ops = problem.second_q_ops()
main_op = second_q_ops[0]

num_particles = (problem.molecule_data_transformed.num_alpha,

num_spin_orbitals = 2 * problem.molecule_data.num_molecular_orbitals
mapper = JordanWignerMapper()
converter = QubitConverter(mapper=mapper, two_qubit_reduction=True)
qubit_op = converter.convert(main_op, num_particles=num_particles)
init_state = HartreeFock(num_spin_orbitals, num_particles, converter)
# print(main_op)

def custom_excitation_list(num_spin_orbitals, num_particles):
   my_excitation_list = [((0, 2, 4, 6), (0 ,2, 4, 7), (0,2,5,6))]

   return my_excitation_list

circ = UCC(qubit_converter=converter, num_particles=num_particles, num_spin_orbitals=num_spin_orbitals, excitations=custom_excitation_list,  reps=1, initial_state=init_state)


1 Answer 1


It looks to me like the format of the excitation list is not very clear. Guessing based on your example I think the correct excitation list should be:

my_excitation_list = [
    ((0, 2), (4, 6)),
    ((0, 2), (4, 7)),
    ((0, 2), (5, 6)),

This code will result in 3 parameters, one per excitation.

Let me try to explain the format above: each entry in the excitation list must be a pair of tuples: ( (...), (...) ). The first entry of this pair should contain all orbital indices which are occupied, whereas the second tuple should contain all unoccupied orbitals into which the excitation occurs. Thus, ( (0, 2), (4, 6) ) will result in the electrons of the orbitals 0 and 2 to be excited into the orbitals 4 and 6, making this a double excitation.

I had a quick look at the documentation and noticed that it is referring to another module's documentation which is actually not available in the public docs, but can be found in the source code. I have opened an issue to address this, here.

I hope this clears up any confusion!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.