Ejemplo n.º 1
0
 def get_hessian_contrib(self, index, fc=None):
     '''
         Get the contribution to the covalent hessian of term with given
         index (and its slaves). If fc is given, set the fc of the master
         and its slave to the given fc.
     '''
     val = ForcePartValence(self.system)
     kind = self.vlist.vtab[index]['kind']
     masterslaves = [index] + self.terms[index].slaves
     if kind == 4:  #Cosine
         m, k, rv = self.get_params(index)
         if fc is not None: k = fc
         for jterm in masterslaves:
             ics = self.terms[jterm].ics
             args = (m, k, rv) + tuple(ics)
             val.add_term(Cosine(*args))
     elif kind == 3:  #cross
         k, rv0, rv1 = self.get_params(index)
         if fc is not None: k = fc
         for jterm in masterslaves:
             ics = self.terms[jterm].ics
             args = (k, rv0, rv1) + tuple(ics)
             val.add_term(Cross(*args))
     elif kind == 1:  #Polyfour
         a0, a1, a2, a3 = list(self.get_params(index))
         if fc is not None:
             a3 = 2.0 * fc
             a1 = -4.0 * fc * np.cos(a0)**2
         for jterm in masterslaves:
             ics = self.terms[jterm].ics
             args = ([0.0, a1, 0.0, a3], ) + tuple(ics)
             val.add_term(PolyFour(*args))
     elif kind == 0:  #Harmonic:
         k, rv = self.get_params(index)
         if fc is not None: k = fc
         for jterm in masterslaves:
             ics = self.terms[jterm].ics
             args = (k, rv) + tuple(ics)
             val.add_term(Harmonic(*args))
     else:
         raise ValueError('Term kind %i not supported' % kind)
     ff = ForceField(self.system, [val])
     hcov = estimate_cart_hessian(ff)
     return hcov
Ejemplo n.º 2
0
Archivo: cost.py Proyecto: boegel/yaff
 def run(self, ff):
     result = GeoOptSimulation.run(self, ff)
     result['hessian'] = estimate_cart_hessian(ff)
     return result
Ejemplo n.º 3
0
 def hessian(self, coords):
     self.ff.update_pos(coords.copy())
     hess = estimate_cart_hessian(self.ff)
     natoms = len(coords)
     return hess.reshape([natoms, 3, natoms, 3])