class DeformationEvaluationFunction:
    def __init__(self,
                 universe,
                 fc_length=0.7,
                 cutoff=1.2,
                 factor=46402.,
                 form='exponential'):
        self.universe = universe
        self.fc_length = fc_length
        self.cutoff = cutoff
        self.factor = factor

        nothing = Numeric.zeros((0, 2), Numeric.Int)
        self.pairs = NonbondedList(nothing, nothing, nothing, universe._spec,
                                   cutoff)
        self.pairs.update(universe.configuration().array)
        self.normalize = 0
        try:
            self.version = self.forms.index(form)
        except ValueError:
            raise ValueError("unknown functional form")

    forms = ['exponential', 'calpha']

    def newConfiguration(self):
        self.pairs.update(self.universe.configuration().array)
Exemple #2
0
 def nonbondedList(self, universe, subset1, subset2, global_data):
     try:
         from MMTK_forcefield import NonbondedList, NonbondedListTerm
     except ImportError:
         return None, None
     nbl = None
     update = None
     if 'nonbondedlist' in global_data.get('initialized'):
         nbl, update, cutoff = global_data.get('nonbondedlist')
     if nbl is None:
         excluded_pairs, one_four_pairs, atom_subset = \
                         self.excludedPairs(subset1, subset2, global_data)
         excluded_pairs = N.array(excluded_pairs)
         one_four_pairs = N.array(one_four_pairs)
         if atom_subset is not None:
             atom_subset = N.array(atom_subset)
         else:
             atom_subset = N.array([], N.Int)
         nbl = NonbondedList(excluded_pairs, one_four_pairs, atom_subset,
                             universe._spec, self.cutoff)
         update = NonbondedListTerm(nbl)
         update.info = 0
         global_data.set('nonbondedlist', (nbl, update, self.cutoff))
         global_data.add('initialized', 'nonbondedlist')
     else:
         if cutoff is not None and \
                    (self.cutoff is None or self.cutoff > cutoff):
             nbl.setCutoff(self.cutoff)
     return nbl, update
Exemple #3
0
    def test_nonbondedList(self):

        self.universe.configuration()
        atoms = self.universe.atomList()
        atom_indices = N.array([a.index for a in self.universe.atomList()])
        empty = N.zeros((0, 2), N.Int)

        for cutoff in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]:

            nblist = NonbondedList(empty, empty, atom_indices,
                                   self.universe._spec, cutoff)
            nblist.update(self.universe.configuration().array)
            distances = nblist.pairDistances()
            pairs1 = nblist.pairIndices()
            pairs1 = [sorted_tuple(pairs1[i]) for i in range(len(pairs1))
                      if distances[i] < cutoff]
            pairs1.sort(lambda a, b: cmp(a[0], b[0]) or cmp(a[1], b[1]))

            pairs2 = []
            for i in range(len(atoms)):
                for j in range(i+1, len(atoms)):
                    d = self.universe.distance(atoms[i], atoms[j])
                    if d < cutoff:
                        pairs2.append(sorted_tuple((atoms[i].index,
                                                    atoms[j].index)))
            pairs2.sort(lambda a, b: cmp(a[0], b[0]) or cmp(a[1], b[1]))

            self.assertEqual(pairs1, pairs2)
Exemple #4
0
 def evaluatorTerms(self, universe, subset1, subset2, global_data):
     if subset1 is not None:
         for s1, s2 in [(subset1, subset2), (subset2, subset1)]:
             set = {}
             for a in s1.atomList():
                 set[a.index] = None
             for a in s2.atomList():
                 try:
                     del set[a.index]
                 except KeyError: pass
         set = {}
         for a in subset1.atomList():
             set[a.index] = None
         for a in subset2.atomList():
             set[a.index] = None
         atom_subset = set.keys()
         atom_subset.sort()
         atom_subset = Numeric.array(atom_subset)
     else:
         atom_subset = Numeric.array([], Numeric.Int)
     nothing = Numeric.zeros((0,2), Numeric.Int)
     nbl = NonbondedList(nothing, nothing, atom_subset, universe._spec,
                         self.cutoff)
     update = NonbondedListTerm(nbl)
     cutoff = self.cutoff
     if cutoff is None:
         cutoff = 0.
     ev = CalphaTerm(universe._spec, nbl, cutoff,
                     self.scale_factor, self.version)
     return [update, ev]
Exemple #5
0
class DeformationEvaluationFunction:

    def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
		 factor = 46402.):
	self.universe = universe
	self.fc_length = fc_length
	self.cutoff = cutoff
	self.factor = factor

	nothing = Numeric.zeros((0,2), Numeric.Int)
	self.pairs = NonbondedList(nothing, nothing, nothing,
				   universe._spec, cutoff)
	self.pairs.update(universe.configuration().array)
	self.normalize = 0

    def newConfiguration(self):
	self.pairs.update(self.universe.configuration().array)
    def test_nonbondedList(self):

        self.universe.configuration()
        atoms = self.universe.atomList()
        atom_indices = N.array([a.index for a in self.universe.atomList()])
        empty = N.zeros((0, 2), N.Int)

        for cutoff in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]:

            nblist = NonbondedList(empty, empty, atom_indices,
                                   self.universe._spec, cutoff)
            nblist.update(self.universe.configuration().array)
            distances = nblist.pairDistances()
            pairs1 = nblist.pairIndices()
            pairs1 = [
                sorted_tuple(pairs1[i]) for i in range(len(pairs1))
                if distances[i] < cutoff
            ]
            pairs1.sort(lambda a, b: cmp(a[0], b[0]) or cmp(a[1], b[1]))

            pairs2 = []
            for i in range(len(atoms)):
                for j in range(i + 1, len(atoms)):
                    d = self.universe.distance(atoms[i], atoms[j])
                    if d < cutoff:
                        pairs2.append(
                            sorted_tuple((atoms[i].index, atoms[j].index)))
            pairs2.sort(lambda a, b: cmp(a[0], b[0]) or cmp(a[1], b[1]))

            self.assertEqual(pairs1, pairs2)
Exemple #7
0
class DeformationEvaluationFunction(object):

    def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
                 factor = 46402., form = 'exponential'):
        self.universe = universe
        self.fc_length = fc_length
        self.cutoff = cutoff
        self.factor = factor

        nothing = N.zeros((0,2), N.Int)
        self.pairs = NonbondedList(nothing, nothing, nothing,
                                   universe._spec, cutoff)
        self.pairs.update(universe.configuration().array)
        self.normalize = 0
        try:
            self.version = self.forms.index(form)
        except ValueError:
            raise ValueError("unknown functional form")

    forms = ['exponential', 'calpha']

    def newConfiguration(self):
        self.pairs.update(self.universe.configuration().array)
Exemple #8
0
 def evaluatorTerms(self, universe, subset1, subset2, global_data):
     nothing = N.zeros((0, 2), N.Int)
     if subset1 is not None:
         set1 = set(a.index for a in subset1.atomList())
         set2 = set(a.index for a in subset2.atomList())
         excluded_pairs = set(Utility.orderedPairs(list(set1-set2))) \
                          | set(Utility.orderedPairs(list(set2-set1)))
         excluded_pairs = N.array(list(excluded_pairs))
         atom_subset = list(set1 | set2)
         atom_subset.sort()
         atom_subset = N.array(atom_subset)
     else:
         atom_subset = N.array([], N.Int)
         excluded_pairs = nothing
     nbl = NonbondedList(excluded_pairs, nothing, atom_subset,
                         universe._spec, self.cutoff)
     update = NonbondedListTerm(nbl)
     cutoff = self.cutoff
     if cutoff is None:
         cutoff = 0.
     ev = ANTerm(universe._spec, nbl, cutoff, self.scale_factor)
     return [update, ev]