def detect_ffatypes(self, ffatypes=None, ffatype_rules=None, ffatype_level=None): ''' Define atom types by explicitely giving them through the ffatypes keyword, defining atype rules using the ATSELECT language implemented in Yaff (see the Yaff documentation at http://molmod.github.io/yaff/ug_atselect.html) or by specifying the ffatype_level employing the built-in routine in QuickFF. ''' numbers = np.array([pt[symbol].number for symbol in self.structure.get_chemical_symbols()]) if self.structure.cell is None: system = System(numbers, self.structure.positions.copy()*angstrom) else: system = System(numbers, self.structure.positions.copy()*angstrom, rvecs=self.structure.cell*angstrom) system.detect_bonds() if not sum([ffatypes is None, ffatype_rules is None, ffatype_level is None]) == 2: raise IOError('Exactly one of ffatypes, ffatype_rules and ffatype_level should be defined') if ffatypes is not None: assert ffatype_rules is None, 'ffatypes and ffatype_rules cannot be defined both' system.ffatypes = ffatypes system.ffatype_ids = None system._init_derived_ffatypes() if ffatype_rules is not None: system.detect_ffatypes(ffatype_rules) if ffatype_level is not None: set_ffatypes(system, ffatype_level) self.ffatypes = system.ffatypes.copy() self.ffatype_ids = system.ffatype_ids.copy()
coords = fchk.fields.get('Current cartesian coordinates').reshape([len(numbers), 3]) grad = fchk.fields.get('Cartesian Gradient').reshape([len(numbers), 3]) hess = fchk.get_hessian().reshape([len(numbers), 3, len(numbers), 3]) #Construct Yaff System file system = System(numbers, coords) system.detect_bonds() system.set_standard_masses() #Construct a QuickFF SecondOrderTaylor object containing the AI reference with log.section('INIT', 2, timer='Initialization'): ai = SecondOrderTaylor('ai', coords=coords, energy=energy, grad=grad, hess=hess) #define atom types rules = [ ('H', '1 & =1%8'), #hydrogen atom with one oxygen neighbor ('O', '8 & =2%1'), #oxygen atom with two hydrogen neighbors ] system.detect_ffatypes(rules) #construct electrostatic force field from HE charges in gaussian_wpart.h5 with h5.File('gaussian_mbis.h5') as f: charges = f['charges'][:] scales = [1.0, 1.0, 1.0, 1.0] with log.section('INIT', 2, timer='Initialization'): ff_ei = get_ei_ff('EI', system, charges, scales, radii=None, average=True, pbc=[0,0,0]) #initialize and run program program = Program(system, ai, settings, ffrefs=[ff_ei] ) program.run()