I am experimenting with the UCC module in qiskit nature. From pyscf
, I got 1-body and 2-body integrals (I need to use custom integrals) and thus created a mapped Hamiltonian. Then, I create a UCC object and find the optimal parameters, and finally, I visualize the circuit. The code I used (without imports & pyscf
-overhead) is shown below.
electronic_energy = ElectronicEnergy.from_raw_integrals(
ElectronicBasis.MO, one_body_ints, two_body_ints
)
hamiltonian = electronic_energy.second_q_ops()[0]
qubit_converter = QubitConverter(mapper=JordanWignerMapper())
qubit_op = qubit_converter.convert(hamiltonian,num_particles=num_particles)
initial_state = HartreeFock(
num_spin_orbitals=num_spin_orbitals,
num_particles=num_particles,
qubit_converter=qubit_converter,
)
reps=1
var_form = UCC(
excitations="sd",
num_particles=num_particles,
num_spin_orbitals=num_spin_orbitals,
initial_state=initial_state,
qubit_converter=qubit_converter,
reps=reps,
)
optimizer=COBYLA(maxiter=1000)
vqe = VQE(ansatz=var_form, optimizer=optimizer,quantum_instance=Aer.get_backend("aer_simulator_statevector"))
vqe_result =vqe.compute_minimum_eigenvalue(qubit_op)
from qiskit.tools.visualization import circuit_drawer
circuit=vqe.get_optimal_circuit()
circuit_drawer(circuit, output='mpl', plot_barriers=False)
plt.show()
I thought that I could visualize the full circuit by printing/drawing the circuit object. This is however not the case, all I get is the following:
How can I visualize the full circuit?