def addColvars(self, name, cvType, atomIDs): """ Implements the addition of a collective variable to the list of collective variables held by this walker. Arguments: ----------------------- name - A internal string used to reference this collective variable. Collective variable names must be unique. cvType - A string refering to the type of collective variable. Currently the following variables are supported: * 'bond' * 'angle' * 'dihedral' * 'x', 'y', 'z' positions * 'x', 'y', 'z' velocity components atomIDs - A list of the atom indecies involved in the collective variable. Should provide the right number of atom indecies for the collective variable: * 'bond' -> 2 * 'angle'-> 3 * 'dihedral' -> 4 * position or velocity component -> 1 """ # make sure we know what the cv type is. __knownCVs__ = ['x', 'y', 'z', 'vx', 'vy', 'vz'] assert cvType in __knownCVs__, "cvType that was provided was not understood." # check to make sure the name is unique. for cv in self.colvars: assert cv.name != name, "Collective variable names must be unique." # now append the collective variable to the walker list. Initialize a collective variable object. self.colvars.append(collectiveVariables.collectiveVariables(name, cvType, atomIDs)) return 0
def add_colvars(self, name, cvType, atomIDs): """ Implements the addition of a collective variable to the list of collective variables held by this walker. Arguments: ----------------------- name - A internal string used to reference this collective variable. Collective variable names must be unique. cvType - A string refering to the type of collective variable. Currently the following variables are supported: * 'bond' * 'angle' * 'dihedral' * 'x', 'y', 'z' positions * 'x', 'y', 'z' velocity components atomIDs - A list of the atom indecies involved in the collective variable. Should provide the right number of atom indecies for the collective variable: * 'bond' -> 2 * 'angle'-> 3 * 'dihedral' -> 4 * position or velocity component -> 1 """ # make sure we know what the cv type is. __knownCVs__ = ['bond', 'angle', 'dihedral', 'x', 'y', 'z', 'vx', 'vy', 'vz', 'fe'] assert cvType in __knownCVs__, "cvType that was provided was not understood." # check to make sure the name is unique. for cv in self.colvars: assert cv.name != name, "Collective variable names must be unique." # now append the collective variable to the walker list. Initialize a collective variable object. self.colvars.append(collectiveVariables.collectiveVariables(name, cvType, atomIDs)) # grab a handle to the new object cv = self.colvars[-1] # first set the group for the colvar self.command("group " + cv.name + " id " + " ".join(map(str,cv.atomIDs))) # now set the appropriate colvar as a compute to LAMMPS if cv.type == 'bond': self.command("compute " + cv.name + " " + cv.name + " bond/local dist" ) elif cv.type == 'angle': self.command("compute " + cv.name + " " + cv.name + " angle/local theta") elif cv.type == 'dihedral': self.command("compute " + cv.name + " " + cv.name + " dihedral/local phi") elif cv.type == 'x': self.command("compute " + cv.name + " " + cv.name + " property/atom x") elif cv.type == 'y': self.command("compute " + cv.name + " " + cv.name + " property/atom y") elif cv.type == 'z': self.command("compute " + cv.name + " " + cv.name + " property/atom z") elif cv.type == "vx": self.command("compute " + cv.name + " " + cv.name + " property/atom vx") elif cv.type == "vy": self.command("compute " + cv.name + " " + cv.name + " property/atom vy") elif cv.type == "vz": self.command("compute " + cv.name + " " + cv.name + " property/atom vz") self.propagate(0, pre='yes') self.ref_cv = self.get_colvars() return 0