def get_norm_cgto(ang_number,exponents,coefs_shell): """Gets the norms of contracted GTOs in a shell.""" from math import sqrt,pow from BioNanoLEGO.DenseMatrix import asmatrix,empty # Threshold of the norms NORM_THRESHOLD = 1e-17 # Gets the number of contractions num_contrs = len(coefs_shell) # Gets the number of primitives num_prims = len(exponents) # Initializes the norms of contracted GTOs norm_cgto = [0]*num_contrs # Sets the power expnt_power = float(ang_number)+1.5 # Sets up the matrix of radical overlap between two primitive GTOs rad_overlap = asmatrix(empty((num_prims,num_prims))) for iprim in xrange(num_prims): for jprim in xrange(num_prims): rad_overlap[iprim,jprim] = \ pow(2*sqrt(exponents[iprim]*exponents[jprim])/ \ (exponents[iprim]+exponents[jprim]),expnt_power) # Gets the norms of contracted GTOs for icontr in xrange(num_contrs): coeff_matrix = asmatrix(coefs_shell[icontr]) norm_cgto[icontr] = sqrt((coeff_matrix*rad_overlap*coeff_matrix.transpose())[0,0]) if norm_cgto[icontr] < NORM_THRESHOLD: raise ZeroDivisionError("Norm '%f' of CGTO '%d' is smaller than the threshold '%f'!" \ % (norm_cgto[icontr],icontr,NORM_THRESHOLD)) return norm_cgto
def getOneInt(self,other,operator,**options): """Calculates the integral of an one-electron operator. other: Basis sets of ket. molecule: Molecule class defined in Molecule.py. operator: One-electron operator, function object, see Gen1Int.py for example. """ from BioNanoLEGO.DenseMatrix import empty,asmatrix # Parallelize here, using dynamic parallelization # MASTER sends first initial jobs to all SLAVES, SLAVES do the job, # and send the results back, MASTER receives the result from one SLAVE, # does some computations (like reduce the number of working nodes), # and sends new job to it with job_tag and increases the number of # working nodes, or sends terminator_tag. # Sets up the integral matrix, using row-major order one_int = asmatrix(empty((self.num_basis_functions,other.num_basis_functions))) #from Parallel import mpi for idx_bra in xrange(self.num_shells): # Indices of basis functions in bra-shell strt_row = self.idx_shell[idx_bra]+1 end_row = self.idx_shell[idx_bra+1] for idx_ket in xrange(other.num_shells): # Indices of basis functions in ket-shell strt_col = other.idx_shell[idx_ket]+1 end_col = other.idx_shell[idx_ket+1]