Skip to content

Improve CI vector sign convention consistency in csf_fci. - #163

Merged
MatthewRHermes merged 7 commits into
pyscf:masterfrom
MatthewRHermes:fix_csf_sign
Oct 14, 2025
Merged

MatthewRHermes merged 7 commits into
pyscf:masterfrom
MatthewRHermes:fix_csf_sign

Conversation

@MatthewRHermes

@MatthewRHermes MatthewRHermes commented Oct 13, 2025 •

Copy link
Copy Markdown
Collaborator

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 as

$$ \langle m'|\hat{S}_+^{(m'-m)}|m\rangle = \sqrt{\frac{(s+m')!}{(s-m')!}\frac{(s-m)!}{(s+m)!}} \ge 0 $$

where

$$ \hat{S}_+ \equiv \sum_p \hat{a}_p^\dagger \hat{b}_p $$

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,

$$ \ldots \hat{a}_{i+1}^\dagger \hat{a}_{i}^\dagger \ldots \hat{b}_{j+1}^\dagger \hat{b}_{j}^\dagger \ldots |\mathrm{vac}\rangle $$

I did not originally account for this when writing the csf_fci module. The sign convention of csf_fci without this PR corresponds to

$$ \ldots \hat{a}_{u+1}^\dagger \hat{a}_{u}^\dagger \ldots \hat{b}_{v}^\dagger \hat{b}_{v+1}^\dagger \ldots \hat{a}_{i+1}^\dagger \hat{b}_{i+1}^\dagger \hat{a}_{i}^\dagger \hat{b}_{i}^\dagger \ldots |\mathrm{vac}\rangle $$

instead, 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 csf_fci module 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 any $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.

For validation purposes, this PR also adds the file spin_op.py to the csf_fci module, although theoretically the code in that file is really more at home in the fci/spin_op.py file of the core modules.

EDIT: clarified and expanded the explanation.

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.
Comment thread pyscf/csf_fci/test/test_spin_op.py Outdated
from pyscf.fci import cistring
from itertools import product

np.random.seed(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reset to random seed necessary?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it is not. I left that over from debugging; thanks for catching.

Left over from debugging, oops
@MatthewRHermes
MatthewRHermes merged commit e07db97 into pyscf:master Oct 14, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants