Example #1
0
    def diagonalize(self, istart=None, jend=None, energy_range=None, TDA=False):
        """Evaluate Eigenvectors and Eigenvalues"""

        ApB, AmB = self.map(istart, jend, energy_range)
        nij = len(self.kss)

        if TDA:
            # Tamm-Dancoff approximation (B=0)
            self.eigenvectors = 0.5 * (ApB + AmB)
            eigenvalues = np.zeros((nij))
            diagonalize(self.eigenvectors, eigenvalues)
            self.eigenvalues = eigenvalues ** 2
        else:
            # the occupation matrix
            C = np.empty((nij,))
            for ij in range(nij):
                C[ij] = 1.0 / self.kss[ij].fij

            S = C * inv(AmB) * C
            S = sqrt_matrix(inv(S).copy())

            # get Omega matrix
            M = np.zeros(ApB.shape)
            gemm(1.0, ApB, S, 0.0, M)
            self.eigenvectors = np.zeros(ApB.shape)
            gemm(1.0, S, M, 0.0, self.eigenvectors)

            self.eigenvalues = np.zeros((nij))
            diagonalize(self.eigenvectors, self.eigenvalues)
Example #2
0
    def diagonalize(self,
                    istart=None,
                    jend=None,
                    energy_range=None,
                    TDA=False):
        """Evaluate Eigenvectors and Eigenvalues"""

        ApB, AmB = self.map(istart, jend, energy_range)
        nij = len(self.kss)

        if TDA:
            # Tamm-Dancoff approximation (B=0)
            self.eigenvectors = 0.5 * (ApB + AmB)
            eigenvalues = np.zeros((nij))
            diagonalize(self.eigenvectors, eigenvalues)
            self.eigenvalues = eigenvalues**2
        else:
            # the occupation matrix
            C = np.empty((nij, ))
            for ij in range(nij):
                C[ij] = 1. / self.kss[ij].fij

            S = C * inv(AmB) * C
            S = sqrt_matrix(inv(S).copy())

            # get Omega matrix
            M = np.zeros(ApB.shape)
            gemm(1.0, ApB, S, 0.0, M)
            self.eigenvectors = np.zeros(ApB.shape)
            gemm(1.0, S, M, 0.0, self.eigenvectors)

            self.eigenvalues = np.zeros((nij))
            diagonalize(self.eigenvectors, self.eigenvalues)
Example #3
0
    def diagonalize(self, istart=None, jend=None, energy_range=None):
        """Evaluate Eigenvectors and Eigenvalues:"""

        map, kss = self.get_map(istart, jend, energy_range)
        nij = len(kss)
        if map is None:
            ApB = self.ApB.copy()
            AmB = self.AmB.copy()
            nij = len(kss)
        else:
            ApB = np.empty((nij, nij))
            AmB = np.empty((nij, nij))
            for ij in range(nij):
                for kq in range(nij):
                    ApB[ij,kq] = self.ApB[map[ij],map[kq]]
                    AmB[ij,kq] = self.AmB[map[ij],map[kq]]

        # the occupation matrix
        C = np.empty((nij,))
        for ij in range(nij):
            C[ij] = 1. / kss[ij].fij

        S = C * inv(AmB) * C
        S = sqrt_matrix(inv(S).copy())

        # get Omega matrix
        M = np.zeros(ApB.shape)
        gemm(1.0, ApB, S, 0.0, M)
        self.eigenvectors = np.zeros(ApB.shape)
        gemm(1.0, S, M, 0.0, self.eigenvectors)
        
        self.eigenvalues = np.zeros((len(kss)))
        self.kss = kss
        diagonalize(self.eigenvectors, self.eigenvalues)