Esempio n. 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. / 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)
Esempio n. 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.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)
Esempio n. 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)
Esempio n. 4
0
import numpy as np

from gpaw.test import equal
from gpaw.utilities.lapack import sqrt_matrix

# check sqrt of a matrix

A = [[20, 4], [4, 1]]
a = [[4.4, .8], [.8, .6]]
A = np.array(A, float)
print 'A=', A
a = np.array(a)
b = sqrt_matrix(A)
print 'sqrt(A)=', b
equal(((a - b)**2).sum(), 0, 1.e-12)
Esempio n. 5
0
from __future__ import print_function
import numpy as np

from gpaw.test import equal
from gpaw.utilities.lapack import sqrt_matrix

# check sqrt of a matrix

A = [[20, 4], [4, 1]]
a = [[4.4, .8], [.8, .6]]
A = np.array(A, float)
print('A=', A)
a = np.array(a)
b = sqrt_matrix(A)
print('sqrt(A)=', b)
equal(((a-b)**2).sum(), 0, 1.e-12)