def setUp(self): """Initializes unit tests.""" # Tools of Gaussian type orbitals from BioNanoLEGO.GaussBasis.Tools import get_basis_data # Sets the minimum number of correct digits self.MIN_DIGITS = 8 # Test of hydrogen with cc-pcvdz basis set self.basis_data = get_basis_data('cc-pcvdz',int(1)) self.atom_idx = int(1) self.atom_coords = [0.0]*3 self.ref_spher_coefs = [[[0.34068906546973732,0.57789076418581309, \ 0.65773997994295252,0.26141493616307782], \ [0.00000000000000000,0.00000000000000000, \ 0.00000000000000000,0.52153672708181154]], \ [[1.9584045348700287]]] return
def __init__(self,molecule,basis_set=DEFAULT_BASIS,atom_basis=[]): """Initializes the real solid-harmonic Gaussians. molecule: The molecule class defined in Molecule.py. basis_set: A string like '6-31G**' gives the basis set for all atoms, except for those specified by keyword atom_basis. Default is 6-31G**. atom_basis: A list like [['6-31G**',xrange(4)], ['cc-pVDZ',[1,4,5]], ['STO-6G',6]] specifying individual basis set for each atom. The indices of atoms start from 0, and ends at the number of atoms minus 1. Note here, the atom with index 1 is given two basis set '6-31G**' and 'cc-pVDZ', which is useful for auxiliary basis sets. Default is []. """ # Shell of real solid-harmonic Gaussians from BioNanoLEGO.GaussBasis.Shell import SpherShell num_atoms = len(molecule) # Generates the list of basis sets of atoms in the molecule list_basis = [[]]*num_atoms for each_basis,atom_group in atom_basis: # List of atoms, such as ['6-31G**',xrange(4)], or ['cc-pVDZ',[1,4,5]] try: for atom_idx in atom_group: if 0 <= atom_idx < num_atoms: # Appends auxiliary basis set if list_basis[atom_idx]: list_basis[atom_idx].append(each_basis) else: list_basis[atom_idx] = [each_basis] else: raise IndexError("Atom index %d out of range!" %atom_idx) # single atom, such as ['STO-3G',6] except: if 0 <= atom_group < num_atoms: # Appends auxiliary basis set if list_basis[atom_group]: list_basis[atom_group].append(each_basis) else: list_basis[atom_group] = [each_basis] else: raise IndexError("Atom index %d out of range!" %atom_idx) # Shell list self.shells = [] self.num_shells = int(0) self.num_basis_functions = int(-1) # Start index of the basis functions in each shell, in the list of [-1,i1,i2,...,i_nshell] self.idx_shell = [int(-1)] # Index of list of atomic basis sets atom_idx = int(0) # Generates the basis set(s) for each atom for atom in molecule.atoms: #FIXME: I really do not want to touch the attribute of molecule! atom_id = atom.getAtomID() atom_coords = atom.getCoords() # Gets the list of basis set(s) for this atom if list_basis[atom_idx]: list_atom_basis = list_basis[atom_idx] else: list_atom_basis = [basis_set] # Loops over all the basis set(s) for this atom for each_basis in list_atom_basis: basis_data = get_basis_data(each_basis,atom.getAtomicNumber()) # Shell by shell for ang_number,expnts,coefs_shell in basis_data: shell_data = SpherShell(atom_id,atom_coords,ang_number,expnts,coefs_shell) self.shells.append(shell_data) self.num_shells += 1 self.num_basis_functions += shell_data.getNumContrs()*(2*shell_data.ang_number+1) self.idx_shell.append(self.num_basis_functions) atom_idx += 1 # Since we first set the number of basis functions as -1 self.num_basis_functions += 1