From f344d66a89cece213b2bfa2505a598ec2ccffb43 Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Tue, 19 Sep 2023 22:37:21 -0700 Subject: [PATCH] Remove trunc_workspace --- pyscf/pbc/tdscf/krhf.py | 4 ++-- pyscf/pbc/tdscf/kuhf.py | 4 ++-- pyscf/tdscf/dhf.py | 4 ++-- pyscf/tdscf/ghf.py | 4 ++-- pyscf/tdscf/gks.py | 2 +- pyscf/tdscf/rhf.py | 9 ++++++--- pyscf/tdscf/rks.py | 2 +- pyscf/tdscf/uhf.py | 4 ++-- pyscf/tdscf/uks.py | 2 +- 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/pyscf/pbc/tdscf/krhf.py b/pyscf/pbc/tdscf/krhf.py index 7ff6f791bc..829f47d48f 100644 --- a/pyscf/pbc/tdscf/krhf.py +++ b/pyscf/pbc/tdscf/krhf.py @@ -205,7 +205,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0k = self.init_guess(self._scf, kshift, self.nstates) - x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates, pick=pickeig)[1] + #x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates, pick=pickeig)[1] else: x0k = x0[i] @@ -336,7 +336,7 @@ def norm_xy(z, kconserv): if x0 is None: x0k = self.init_guess(self._scf, kshift, self.nstates) - x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates*2, pick=pickeig)[1] + #x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates*2, pick=pickeig)[1] else: x0k = x0[i] diff --git a/pyscf/pbc/tdscf/kuhf.py b/pyscf/pbc/tdscf/kuhf.py index 5452722788..0466cd0e7f 100644 --- a/pyscf/pbc/tdscf/kuhf.py +++ b/pyscf/pbc/tdscf/kuhf.py @@ -145,7 +145,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0k = self.init_guess(self._scf, kshift, self.nstates) - x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates, pick=pickeig)[1] + #x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates, pick=pickeig)[1] else: x0k = x0[i] @@ -286,7 +286,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0k = self.init_guess(self._scf, kshift, self.nstates) - x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates, pick=pickeig)[1] + #x0k = self.trunc_workspace(vind, x0k, nstates=self.nstates, pick=pickeig)[1] else: x0k = x0[i] diff --git a/pyscf/tdscf/dhf.py b/pyscf/tdscf/dhf.py index fe09ef5e37..943d2ec39a 100644 --- a/pyscf/tdscf/dhf.py +++ b/pyscf/tdscf/dhf.py @@ -451,7 +451,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] # FIXME: Is it correct to call davidson1 for complex integrals? self.converged, self.e, x1 = \ @@ -563,7 +563,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, w, x1 = \ lib.davidson_nosym1(vind, x0, precond, diff --git a/pyscf/tdscf/ghf.py b/pyscf/tdscf/ghf.py index 1cf0424e02..439df6e929 100644 --- a/pyscf/tdscf/ghf.py +++ b/pyscf/tdscf/ghf.py @@ -436,7 +436,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] # FIXME: Is it correct to call davidson1 for complex integrals self.converged, self.e, x1 = \ @@ -577,7 +577,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, w, x1 = \ lib.davidson_nosym1(vind, x0, precond, diff --git a/pyscf/tdscf/gks.py b/pyscf/tdscf/gks.py index 7681abba27..26276c91eb 100644 --- a/pyscf/tdscf/gks.py +++ b/pyscf/tdscf/gks.py @@ -123,7 +123,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, w2, x1 = \ lib.davidson1(vind, x0, precond, diff --git a/pyscf/tdscf/rhf.py b/pyscf/tdscf/rhf.py index dadfc73b7f..f07a10e8a7 100644 --- a/pyscf/tdscf/rhf.py +++ b/pyscf/tdscf/rhf.py @@ -740,7 +740,10 @@ def trunc_workspace(self, vind, x0, nstates=None, pick=None): return None, x0 else: heff = lib.einsum('xa,ya->xy', x0.conj(), vind(x0)) - e, u = scipy.linalg.eig(heff) # heff not necessarily Hermitian + if abs(heff - heff.conj().T).max() < 1e-12: + e, u = scipy.linalg.eigh(heff) + else: + e, u = scipy.linalg.eig(heff) # heff not necessarily Hermitian e = e.real order = numpy.argsort(e) e = e[order] @@ -866,7 +869,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, self.e, x1 = \ lib.davidson1(vind, x0, precond, @@ -1036,7 +1039,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, w, x1 = \ lib.davidson_nosym1(vind, x0, precond, diff --git a/pyscf/tdscf/rks.py b/pyscf/tdscf/rks.py index fc9860b8fd..974ee5d5f3 100644 --- a/pyscf/tdscf/rks.py +++ b/pyscf/tdscf/rks.py @@ -127,7 +127,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, w2, x1 = \ lib.davidson1(vind, x0, precond, diff --git a/pyscf/tdscf/uhf.py b/pyscf/tdscf/uhf.py index 92aabf0258..da5c8366bb 100644 --- a/pyscf/tdscf/uhf.py +++ b/pyscf/tdscf/uhf.py @@ -669,7 +669,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, self.e, x1 = \ lib.davidson1(vind, x0, precond, @@ -828,7 +828,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, w, x1 = \ lib.davidson_nosym1(vind, x0, precond, diff --git a/pyscf/tdscf/uks.py b/pyscf/tdscf/uks.py index d4301584f9..fda1411d7c 100644 --- a/pyscf/tdscf/uks.py +++ b/pyscf/tdscf/uks.py @@ -144,7 +144,7 @@ def pickeig(w, v, nroots, envs): if x0 is None: x0 = self.init_guess(self._scf, self.nstates) - x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] + #x0 = self.trunc_workspace(vind, x0, nstates=self.nstates, pick=pickeig)[1] self.converged, w2, x1 = \ lib.davidson1(vind, x0, precond,