def hessian_calculation(self, N, d_coordinates, chains, atoms_hessian, cutoff, d_secondary, matrix_distances, l_coordinates, resrange1 = [], resrange2 = [], l_rem = [], verbose = False):

        '''This function calculates the Hessian matrix. At least its supposed to...'''

        if verbose == True:
            print 'calculating the hessian/second-order derivate Kirchoff/Laplacian matrix'
        
        import math, Numeric

        cutoff_sq = cutoff**2

        matrix_hessian = Numeric.zeros((3*N,3*N), typecode='d')
        
        for row_sup in range(N):
            for col_sup in range(N):

##                ## remove local contacts
##                if row_sup in resrange1 and col_sup in resrange2:
##                    continue

                if col_sup > row_sup:
                    xi = l_coordinates[row_sup][0]
                    xj = l_coordinates[col_sup][0]
                    yi = l_coordinates[row_sup][1]
                    yj = l_coordinates[col_sup][1]
                    zi = l_coordinates[row_sup][2]
                    zj = l_coordinates[col_sup][2]
                    x = xj-xi
                    y = yj-yi
                    z = zj-zi
                    dist_sq = x**2+y**2+z**2
##                    if dist_sq <= cutoff_sq:
                    sigmoidfactor = goodvibes_core.sigmoid(math.sqrt(dist_sq), cutoff)

                    ## stronger local contacts
                    if row_sup in resrange1 and col_sup in resrange2:
                        sigmoidfactor *= 4

                    vector = [x,y,z]
                    for row_sub in range(3):
                        for col_sub in range(3):

                            if col_sub >= row_sub: #fill supersymmetrical elements when j>=i
                                value = sigmoidfactor*-vector[row_sub]*vector[col_sub]/dist_sq
                                matrix_hessian[3*row_sup+row_sub,3*col_sup+col_sub] = value ##upper super off-diagonal; xixj, xiyj, xizj, yiyj, yizj, zizj
                                matrix_hessian[3*col_sup+col_sub,3*row_sup+row_sub] = value ##lower super off-diagonal; xjxi, yjxi, zjxi, yjyi, zjyi, zjzi
                                matrix_hessian[3*row_sup+row_sub,3*row_sup+col_sub] -= value ##super diagonal (row); xixi, xiyi, xizi, yiyi, yizi, zizi
                                matrix_hessian[3*col_sup+col_sub,3*col_sup+row_sub] -= value ##super diagonal (col); xjxj, yjxj, zjxj, yjyj, zjyj, zjzj
                                if col_sub > row_sub: #fill lower subsymmetrical elements
                                    matrix_hessian[3*row_sup+col_sub,3*col_sup+row_sub] = value #upper super off-diagonal; yixj, zixj, ziyj
                                    matrix_hessian[3*col_sup+row_sub,3*row_sup+col_sub] = value #lower super off-diagonal; xjyi, xjzi, yjzi
                                    matrix_hessian[3*row_sup+col_sub,3*row_sup+row_sub] -= value ##super diagonal; yixi, zixi, ziyi
                                    matrix_hessian[3*col_sup+row_sub,3*col_sup+col_sub] -= value ##super diagonal; yjxj, zjxj, zjyj

        return matrix_hessian
    def hessian_calculation(self,
                            N,
                            matrix_distances,
                            d_coordinates,
                            cutoff,
                            l_coordinates,
                            verbose=False):
        '''This function calculates the Hessian matrix. At least its supposed to...'''

        if verbose == True:
            print 'calculating the hessian/second-order derivate Kirchoff/Laplacian matrix'

        import math, Numeric, time

        matrix_hessian = Numeric.zeros(
            (3 * len(l_coordinates), 3 * len(l_coordinates)), typecode='d')

        ##
        ## write matrix
        ##
        row_sup = 0
        col_sup = 0
        for row_sup in range(len(l_coordinates)):
            for col_sup in range(row_sup + 1, len(l_coordinates)):

                xi = l_coordinates[row_sup][0]
                xj = l_coordinates[col_sup][0]
                yi = l_coordinates[row_sup][1]
                yj = l_coordinates[col_sup][1]
                zi = l_coordinates[row_sup][2]
                zj = l_coordinates[col_sup][2]
                x = xj - xi
                y = yj - yi
                z = zj - zi
                vector = [x, y, z]
                dist_sq = x**2 + y**2 + z**2
                sigmoidfactor = goodvibes_core.sigmoid(math.sqrt(dist_sq),
                                                       cutoff)
                factor = sigmoidfactor

                matrix_hessian = goodvibes_core.fill_matrix_hessian(
                    matrix_hessian,
                    factor,
                    row_sup,
                    col_sup,
                    dist_sq,
                    vector,
                )

        return matrix_hessian
Esempio n. 3
0
    def hessian_calculation(self, N, d_coordinates, chains, atoms_hessian, cutoff, d_secondary, matrix_distances, l_coordinates, resrange1 = [], resrange2 = [], l_rem = [], verbose = False):

        '''This function calculates the Hessian matrix. At least its supposed to...'''

        if verbose == True:
            print 'calculating the hessian/second-order derivate Kirchoff/Laplacian matrix'
        
        import math, Numeric

        cutoff_sq = cutoff**2

        matrix_hessian = Numeric.zeros((3*N,3*N), typecode='d')
        
        for row_sup in range(N):
            for col_sup in range(N):

                ## remove local contacts
                if row_sup in resrange1 and col_sup in resrange2:
                    continue

                if col_sup > row_sup:
                    xi = l_coordinates[row_sup][0]
                    xj = l_coordinates[col_sup][0]
                    yi = l_coordinates[row_sup][1]
                    yj = l_coordinates[col_sup][1]
                    zi = l_coordinates[row_sup][2]
                    zj = l_coordinates[col_sup][2]
                    x = xj-xi
                    y = yj-yi
                    z = zj-zi
                    dist_sq = x**2+y**2+z**2
##                    if dist_sq <= cutoff_sq:
                    sigmoidfactor = goodvibes_core.sigmoid(math.sqrt(dist_sq), cutoff)
                    vector = [x,y,z]
                    for row_sub in range(3):
                        for col_sub in range(3):

                            if col_sub >= row_sub: #fill supersymmetrical elements when j>=i
                                value = sigmoidfactor*-vector[row_sub]*vector[col_sub]/dist_sq
                                matrix_hessian[3*row_sup+row_sub,3*col_sup+col_sub] = value ##upper super off-diagonal; xixj, xiyj, xizj, yiyj, yizj, zizj
                                matrix_hessian[3*col_sup+col_sub,3*row_sup+row_sub] = value ##lower super off-diagonal; xjxi, yjxi, zjxi, yjyi, zjyi, zjzi
                                matrix_hessian[3*row_sup+row_sub,3*row_sup+col_sub] -= value ##super diagonal (row); xixi, xiyi, xizi, yiyi, yizi, zizi
                                matrix_hessian[3*col_sup+col_sub,3*col_sup+row_sub] -= value ##super diagonal (col); xjxj, yjxj, zjxj, yjyj, zjyj, zjzj
                                if col_sub > row_sub: #fill lower subsymmetrical elements
                                    matrix_hessian[3*row_sup+col_sub,3*col_sup+row_sub] = value #upper super off-diagonal; yixj, zixj, ziyj
                                    matrix_hessian[3*col_sup+row_sub,3*row_sup+col_sub] = value #lower super off-diagonal; xjyi, xjzi, yjzi
                                    matrix_hessian[3*row_sup+col_sub,3*row_sup+row_sub] -= value ##super diagonal; yixi, zixi, ziyi
                                    matrix_hessian[3*col_sup+row_sub,3*col_sup+col_sub] -= value ##super diagonal; yjxj, zjxj, zjyj

        return matrix_hessian
    def hessian_calculation(self, N, matrix_distances, d_coordinates, cutoff, l_coordinates, verbose=False):

        """This function calculates the Hessian matrix. At least its supposed to..."""

        if verbose == True:
            print "calculating the hessian/second-order derivate Kirchoff/Laplacian matrix"

        import math, Numeric, time

        matrix_hessian = Numeric.zeros((3 * len(l_coordinates), 3 * len(l_coordinates)), typecode="d")

        ##
        ## write matrix
        ##
        row_sup = 0
        col_sup = 0
        for row_sup in range(len(l_coordinates)):
            for col_sup in range(row_sup + 1, len(l_coordinates)):

                xi = l_coordinates[row_sup][0]
                xj = l_coordinates[col_sup][0]
                yi = l_coordinates[row_sup][1]
                yj = l_coordinates[col_sup][1]
                zi = l_coordinates[row_sup][2]
                zj = l_coordinates[col_sup][2]
                x = xj - xi
                y = yj - yi
                z = zj - zi
                vector = [x, y, z]
                dist_sq = x ** 2 + y ** 2 + z ** 2
                sigmoidfactor = goodvibes_core.sigmoid(math.sqrt(dist_sq), cutoff)
                factor = sigmoidfactor

                matrix_hessian = goodvibes_core.fill_matrix_hessian(
                    matrix_hessian, factor, row_sup, col_sup, dist_sq, vector
                )

        return matrix_hessian