def get_fftable(self): ''' A method to return a FFTable instance containing all force field parameters (force constants and rest values). ''' fftab = FFTable() for icname in sorted(self.pot.terms.keys()): ks = [] q0s = [] ms = [] for term in self.pot.terms[icname]: ks.append(term.k) q0s.append(term.q0) if isinstance(term, CosineTerm): ms.append(term.A) if isinstance(term, CosineTerm): fftab.add(icname, DataArray(data=ks, unit=term.ic.kunit), DataArray(data=q0s, unit=term.ic.qunit), m=DataArray(data=ms, unit='au') ) else: fftab.add(icname, DataArray(data=ks, unit=term.ic.kunit), DataArray(data=q0s, unit=term.ic.qunit) ) return fftab
def estimate_from_pt(self, trajectories, skip_dihedrals=True, verbose=True): #SHLL end ''' Second Step of force field development: calculate harmonic force field parameters for every internal coordinate separately from perturbation trajectories. **Arguments** trajectories A dictionairy containing numpy arrays representing perturbation trajectories for each icname. **Optional Arguments** skip_dihedrals If set to True, the dihedral ff parameters will not be calculated. ''' ff = FFTable() #SHLL 1606 #-- transfer potential info from program to fftable ff.stretch_pot_kind = self.stretch_pot_kind ff.bend_pot_kind = self.bend_pot_kind #SHLL end maxlength = max([len(icname) for icname in self.model.val.pot.terms.keys()]) + 2 for icname in sorted(self.model.val.pot.terms.keys()): ics = self.system.ics[icname] if skip_dihedrals and icname.startswith('dihed'): continue ks = DataArray(unit=ics[0].kunit) # print 'kunit:',ics[0].kunit #GBdebug q0s = DataArray(unit=ics[0].qunit) for ic in ics: #SHLL 1508 #-- estimate spf or harmcos potential params if icname.startswith('bond') and self.stretch_pot_kind.lower()=='spf': k, q0 = self.pert_theory.estimate(ic,trajectories[ic.name], pot_kind=self.stretch_pot_kind) elif icname.startswith('angle') and self.bend_pot_kind.lower()=='harmcos': k, q0 = self.pert_theory.estimate(ic,trajectories[ic.name], pot_kind=self.bend_pot_kind) else: k, q0 = self.pert_theory.estimate(ic,trajectories[ic.name], pot_kind='harmonic') #original # k, q0 = self.pert_theory.estimate(ic,trajectories[ic.name]) #SHLL end ks.append(k) q0s.append(q0) ff.add(icname, ks, q0s) descr = icname + ' '*(maxlength-len(icname)) if verbose: print ' %s K = %s q0 = %s' % ( descr, ks.string(), q0s.string() ) self.model.val.update_fftable(ff) return ff