diff --git a/qiskit_nature/algorithms/ground_state_solvers/adapt_vqe.py b/qiskit_nature/algorithms/ground_state_solvers/adapt_vqe.py index 9b93947064..cbfee411df 100644 --- a/qiskit_nature/algorithms/ground_state_solvers/adapt_vqe.py +++ b/qiskit_nature/algorithms/ground_state_solvers/adapt_vqe.py @@ -97,12 +97,10 @@ def _compute_gradients( self._ansatz.operators = self._excitation_list + [exc] # set the current ansatz vqe.ansatz = self._ansatz - ansatz_params = vqe.ansatz._parameter_table.keys() - # construct the expectation operator of the VQE - vqe._expect_op = vqe.construct_expectation(ansatz_params, self._main_operator) # evaluate energies parameter_sets = theta + [-self._delta] + theta + [self._delta] - energy_results = vqe._energy_evaluation(np.asarray(parameter_sets)) + energy_evaluation = vqe.get_energy_evaluation(self._main_operator) + energy_results = energy_evaluation(np.asarray(parameter_sets)) # compute gradient gradient = (energy_results[0] - energy_results[1]) / (2 * self._delta) res.append((np.abs(gradient), exc)) diff --git a/releasenotes/notes/fix-adapt-vqe-c9df0c06ea352b91.yaml b/releasenotes/notes/fix-adapt-vqe-c9df0c06ea352b91.yaml new file mode 100644 index 0000000000..ef17353356 --- /dev/null +++ b/releasenotes/notes/fix-adapt-vqe-c9df0c06ea352b91.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fix :class:`~qiskit_nature.algorithms.AdaptVQE` after the update of + :class:`~qiskit.algorithms.VQE` which deleted the internal ``_energy_evaluation`` + method that Adapt-VQE was relying on.