diff --git a/pyscf/fci/direct_spin1_symm.py b/pyscf/fci/direct_spin1_symm.py index 981e170f42..3b9a6528bb 100644 --- a/pyscf/fci/direct_spin1_symm.py +++ b/pyscf/fci/direct_spin1_symm.py @@ -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 diff --git a/pyscf/fci/test/test_spin1_symm.py b/pyscf/fci/test/test_spin1_symm.py index 58a055e9be..29e44f965b 100644 --- a/pyscf/fci/test/test_spin1_symm.py +++ b/pyscf/fci/test/test_spin1_symm.py @@ -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 @@ -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()