-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UCC and fully occupied MOs (Fix for issue #1277) #1286
Conversation
The configuration check looked for whether any number of alpha or beta orbitals was greater or equals than the number of particles. Obviously, there cannot be more particles than spin orbitals, and in order to handle this case, I updated the previous `any(n >= ...` to `any(n > ...`. For handling case where both alpha and beta are the same as the number of particles (i.e. He2 molecule), I created a new raise condition, notifying that the function is still not implemented. For the case where either alpha or beta is equals to the number of particles (i.e. H-He molecule), it should just pass through.
Sorry, I forgot to remove the spaces.
Pull Request Test Coverage Report for Build 7057038901
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks like a good start. Can you please also do the following changes?
- add a unittest which asserts that the behavior works as intended
- verify whether the docstrings on the section of which errors are being raised needs to be updated
- add a release note (see here for instructions)
And finally:
- please also check all of the above for the
HartreeFock
initial state and add a unittest if it already works (just to be certain that it won't break in the future)
Added a test case for HeH molecule, with (alpha, beta) = (2, 1). This should work after the changes in ucc.py
The tests complained because of the spelling of a molecule in a comment. And I reformatted a little.
Formatted the indentations correctly following the suggestions of black
Release notes created
So, @mrossinek
|
releasenotes/notes/fix-UCC-and-fully-occupied-MOs-c8fdf252a0607395.yaml
Outdated
Show resolved
Hide resolved
Deleted unnecessary parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me 👍
On a side note: I noticed that none of the errors which _check_configuration
(and _check_ucc_configuration
) might raise when raise_on_failure=True
are documented.. I guess this does not show up, because these are all part of internal methods, which get called under the hood in Qiskit's BlueprintCircuit
(which is a base-class of these circuits incl. HartreeFock
).
We should probably at some point look into addressing this documentation-wise.
Summary
Improved the functionality of UCC a little bit, to work if only one of the spin registers is fully occupied.
Details and comments
The configuration check looked for whether any number of alpha or beta orbitals (length of the spin register) was greater or equals than the number of particles.
Obviously, there cannot be more particles than spin orbitals, and in order to handle this case, I updated the previous
any(n >= ...
toany(n > ...
.For handling case where both alpha and beta are the same as the number of particles (i.e. (2, 2) for the He2 molecule), I created a new raise condition, notifying that the function is still not implemented.
Implementing this option will probably involve dealing with the empty excitation list at line 339.
For the case where either alpha or beta is equals to the number of particles (i.e. H-He molecule), it should just pass through.