Esempio n. 1
0
    def limitTorsions(self, numTors, type, simpleModel=1):
        """sets number of torsions to specified number by inactivating either those which
move the fewest atoms or those which move the most. if number is > than
current but less than possible, torsions are reactivated
        """

        print('lT: numTors=', numTors, ' type=', type)
        allAts = self.allAtoms
        root = self.ROOT
        torscount = self.torscount
        print('torscount=', torscount, end=' ')
        #NB: torscount is not necessarily the max
        #ie it could have been adjusted already
        at0 = self.allAtoms[0]
        if not hasattr(self, 'torTree') or not hasattr(at0, 'tt_ind'):
            self.torTree = TorTree(self.parser, root)
        torsionMap = self.torTree.torsionMap
        torsionMapNum = len(torsionMap)
        print('len(tm)=', torsionMapNum)
        possibleTors = self.possible_torscount
        if simpleModel:
            self.setTorsions(numTors, type)
            return

        #FIX THIS: what if want to increase active torsions
        if torscount == numTors:
            msg = 'specified number==number present: no adjustment'
            return 'msg'
        elif torscount < numTors:
            if torscount == possibleTors:
                #if torscount==torsionMapNum:
                msg = 'specified number == number possible: no adjustment'
                return msg
            else:
                #in this case turn on as many as possible
                #if numTors>=torsionMapNum:
                if numTors >= possibleTors:
                    #turn on everything
                    delta = possibleTors - torscount
                    #delta = torsionMapNum - torscount
                else:
                    delta = numTors - torscount
                self.turnOnTorsions(delta, type)
        else:
            #torscount>numTors
            #in this case turn them off
            delta = torscount - numTors
            self.turnOffTorsions(delta, type)
        msg = str(delta) + ' torsions changed'
        return msg
Esempio n. 2
0
 def buildTorsionTree(self):
     if not hasattr(self, 'ROOT'):
         print('must set ROOT first!')
         return
     self.torTree = TorTree(self.parser, self.ROOT)