1
$\begingroup$

I am trying to obtain the expectation value of the S^2 operator with respect to VQE wave function in an older version of qiskit (0.26). To that end, I tried:

from qiskit.chemistry.results import * 
a = EigenstateResult(results)
b = ElectronicStructureResult(a)
print(b.total_angular_momentum)

where

results = vqe.run(quantum_instance)

Unfortunately, I only got 'False' as my output, whereas I expected something like 'S^2: 0.000'. Can someone help me with where I'm going wrong?

$\endgroup$

1 Answer 1

3
$\begingroup$

Your qiskit installation is quite old. qiskit.chemistry is part of the now deprecated and unsupported Qiskit Aqua, see migration guide if you need. Qiskit Nature was the replacement for the chemistry logic there, which it seems you are using as well. The result from VQE is not an ElectronicStructureResult rather it has observable values for operators which feed into the S^2 computation.

I suggest looking at this tutorial for the ground state https://qiskit.org/documentation/nature/tutorials/03_ground_state_solvers.html (you will see the right place now to import things from including VQE) and take particular note of the section The calculation and the results where the result from the GroundStateEigensolver is printed and which includes S^2.

$\endgroup$
1
  • $\begingroup$ Thank you very much! :-) $\endgroup$ Commented Jul 17, 2022 at 12:32

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.