Skip to content

Commit

Permalink
Fix FCI wfn symmetry validation code for Dooh symmetry (fix pyscf#2383)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Sep 7, 2024
1 parent c67deaa commit 3dc4547
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pyscf/fci/direct_spin1_symm.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,19 +519,34 @@ def _guess_wfnsym_cyl_sym(civec, strsa, strsb, orbsym):
if wfn_momentum == 0:
# For A1g and A1u, CI coefficient and its sigma_v associated one have
# the same sign
if (sign_a*sign_b * c_max[0,0].real * c_max[1,1].real > 1e-6 or
sign_a*sign_b * c_max[0,0].imag * c_max[1,1].imag > 1e-6): # A1
if (sign_a*sign_b * c_max[0,0].real * c_max[1,1].real > 1e-4 or
sign_a*sign_b * c_max[0,0].imag * c_max[1,1].imag > 1e-4): # A1
if wfn_ungerade:
wfnsym = 5
else:
wfnsym = 0
else:
elif (sign_a*sign_b * c_max[0,0].real * c_max[1,1].real < -1e-4 or
sign_a*sign_b * c_max[0,0].imag * c_max[1,1].imag < -1e-4): # A2
# For A2g and A2u, CI coefficient and its sigma_v associated one
# have opposite signs
if wfn_ungerade:
wfnsym = 4
else:
wfnsym = 1
elif abs(c_max[0,1] - c_max[1,0]) < 1e-4: # Off-diagonal terms only
# (E+)(E-') + (E-)(E+') => A1
if wfn_ungerade:
wfnsym = 5
else:
wfnsym = 0
elif abs(c_max[0,1] + c_max[1,0]) < 1e-4:
# (E+)(E-') - (E-)(E+') => A2
if wfn_ungerade:
wfnsym = 4
else:
wfnsym = 1
else:
raise RuntimeError('Symmetry broken wavefunction')

elif wfn_momentum % 2 == 1:
if abs(c_max[idx_a,idx_b].real) > 1e-6: # Ex
Expand Down
14 changes: 14 additions & 0 deletions pyscf/fci/test/test_spin1_symm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import math
import unittest
import numpy
from pyscf import gto, lib
Expand Down Expand Up @@ -222,6 +223,19 @@ def test_many_roots(self):
davidson_only=True, orbsym=orbsym)
self.assertAlmostEqual(e[0], -1.8, 9)

def test_guess_wfnsym_cyl_sym(self):
mol = gto.M(atom='C 0 0 0; C 0 0 1.5', basis='6-31g', symmetry=True)
mf = mol.RHF().run()
mc = mcscf.CASCI(mf, 8, 4)
mc.fcisolver.wfnsym = 'A1g'
ncas = {'A1g':2, 'A1u':2, 'E1gx':1, 'E1gy':1, 'E1ux':1, 'E1uy':1}
mo = mcscf.sort_mo_by_irrep(mc, mf.mo_coeff, ncas)
na = math.comb(8, 2)
ci0 = numpy.zeros((na, na))
ci0[1,1] = ci0[2,2] = .5**.5 # corresponding to (E+)(E-') + (E-)(E+') => A1
mc.kernel(mo, ci0=ci0)
self.assertAlmostEqual(mc.e_cas, -4.205889578214524, 9)

if __name__ == "__main__":
print("Full Tests for spin1-symm")
unittest.main()

0 comments on commit 3dc4547

Please sign in to comment.