Skip to content

Commit

Permalink
Remove trunc_workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Sep 20, 2023
1 parent 8d4d692 commit f344d66
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pyscf/pbc/tdscf/krhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions pyscf/pbc/tdscf/kuhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions pyscf/tdscf/dhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = \
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pyscf/tdscf/ghf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = \
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyscf/tdscf/gks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions pyscf/tdscf/rhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyscf/tdscf/rks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pyscf/tdscf/uhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyscf/tdscf/uks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f344d66

Please sign in to comment.