Repository navigation
Improve CI vector sign convention consistency in csf_fci. - #163
Merged
Merged
Conversation
Apply the correct sign factor corresponding to arranging the electrons like A'(unpaired) B'(unpaired) C'(pairs) where ci' = ai' bi', compared to the PySCF convention of A' B'.
Correct the sign convention of csfstring.c:FCICSFmakecsf. It had been like ai' a(i+1)' a(i+2)' ... b(j)' b(j+1)' b(j+2)'. It is now correctly ai' a(i+1)' a(i+2)' ... b(j+2)' b(j+1)' b(j)'. Also add test_spin_op.py from mrh.
Instead of just fixing output to the same norm as input, use the theoretically derived normalization factors.
sunqm
approved these changes
Oct 14, 2025
| from pyscf.fci import cistring | ||
| from itertools import product | ||
|
|
||
| np.random.seed(1) |
Contributor
There was a problem hiding this comment.
Is this reset to random seed necessary?
Collaborator
Author
There was a problem hiding this comment.
No it is not. I left that over from debugging; thanks for catching.
Left over from debugging, oops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For two microstates$m'$ and $m$ of a multiplet with spin $s$ ($m'\ge m$ ; $s\ge |m|$ ; $s\ge |m'|$ ;
m=(nelec[0]-nelec[1])/2), the full CI vectors ought to be related to one another aswhere
is the spin raising operator. Arranging for this relationship to be satisfied requires a consistent sign convention for FCI vectors in different Hilbert spaces and for CSFs in different electron configurations, which in turn requires accounting for the sign flips that occur corresponding to the anticommutation of electron creation operators when going from$m$ to $m'$ so that determinants consistently reflect the PySCF convention,
I did not originally account for this when writing the
csf_fcimodule. The sign convention ofcsf_fciwithout this PR corresponds toinstead, where$u,v$ are singly-occupied and $i$ are doubly-occupied orbitals (note the unpaired $\beta$ electrons in the wrong order, among other differences). The CSFs in different electron configurations differ by an arbitrary sign. This doesn't prevent the module from working for its current purposes because all operator matrix elements are computed in the determinant basis and the sign is consistent, but it does frustrate any attempt to use CSF basis states directly as anything other than signless axes defining a vector space.
This PR modifies the$m$ with a consistent sign. These modifications make it possible to, in future, directly compute things like $\langle \vec{s}'|\hat{O}|\vec{s}\rangle$ , where $\vec{s}$ is the unique CSF string, without returning to the determinant basis.
csf_fcimodule to correctly reflect the PySCF sign/normal-ordering convention at all times, so that a single CI vector in the CSF basis can be transformed into the determinant basis for anyFor validation purposes, this PR also adds the file
spin_op.pyto thecsf_fcimodule, although theoretically the code in that file is really more at home in thefci/spin_op.pyfile of the core modules.EDIT: clarified and expanded the explanation.