def testBadInput(self): """Asserts raise of ValueError for missing element input.""" with self.assertRaises(ValueError) as e: param.GetCovRad('AA') self.assertEqual(str(e.exception), 'No covalent radius found for element: AA')
def testEmptyInput(self): """Asserts raise of ValueError for empty string input.""" with self.assertRaises(ValueError) as e: param.GetCovRad('') self.assertEqual(str(e.exception), 'No covalent radius found for element: ')
def GetGeom(mol): """Read in molecular geometry data from molecule xyzq file. Parse 2-d array of strings from xyzq file into atomic data. First line contains (int) number of atoms. Second line is ignored comment. Each line after (3 to [n+2]) contains atom type, (float) 3 xyz cartesian coordinates [Angstrom], and (float) charge [e]. Args: mol (mmlib.molecule.Molecule): molecule with an associated xyzq input file. """ infile_array = _GetFileStringArray(mol.infile) mol.n_atoms = int(infile_array[0][0]) for i in range(mol.n_atoms): at_type = infile_array[i+2][0] at_coords = numpy.array( list(map(float, infile_array[i+2][1:1+const.NUMDIM]))) at_charge = float(infile_array[i+2][4]) at_element = GetElement(at_type) at_mass = param.GetAtMass(at_element) at_ro, at_eps = param.GetVdwParam(at_type) atom = molecule.Atom(at_type, at_coords, at_charge, at_ro, at_eps, at_mass) atom.SetCovRad(param.GetCovRad(at_element)) mol.atoms.append(atom) mol.mass += at_mass
def __init__(self, type_, coords, charge, ro, eps, mass): self.type_ = type_ self.element = fileio.GetElement(type_) self.SetCoords(coords) self.SetCharge(charge) self.SetRo(ro) self.SetEps(eps) self.SetMass(mass) self.SetCovRad(param.GetCovRad(self.element)) self.SetVels(numpy.zeros(const.NUMDIM)) self.SetAccs(numpy.zeros(const.NUMDIM)) self.SetPVels(numpy.zeros(const.NUMDIM)) self.SetPAccs(numpy.zeros(const.NUMDIM))
def __init__(self, type_, coords, charge, ro=None, eps=None): self.SetType(type_) self.SetCoords(coords) self.SetCharge(charge) if ro == None or eps == None: ro, eps = param.GetVdwParam(self.type_) self.SetRo(ro) self.SetEps(eps) self.SetElement(param.GetElement(type_)) self.SetMass(param.GetMass(self.element)) self.SetCovRad(param.GetCovRad(self.element)) self.SetVels(numpy.zeros(const.NUMDIM)) self.SetAccs(numpy.zeros(const.NUMDIM)) self.SetPVels(numpy.zeros(const.NUMDIM)) self.SetPAccs(numpy.zeros(const.NUMDIM))
def _GetAtom(mol, record): """Parse atom record into an atom object and append to molecule. Appends mmlib.molecule.Atom object to mmlib.molecule.Molecule object. Contents of atom object include (float*) xyz cartesian coordinates [Angstrom], (float) partial charge [e], (float) van der Waals radius [Angstrom], (float) van der Waals epsilon [kcal/mol], (str) atom type, (str) atomic element, (float) covalent radius, [Angstrom], and (float) mass [amu]. Args: mol (mmlib.molecule.Molecule): Molecule to append atom. record (str*): Array of strings from line of prm file. """ at_type = record[2] at_coords = numpy.array(list(map(float, record[3:3+const.NUMDIM]))) at_charge, at_ro, at_eps = list(map(float, record[6:9])) at_element = GetElement(at_type) at_mass = param.GetAtMass(at_element) atom = molecule.Atom(at_type, at_coords, at_charge, at_ro, at_eps, at_mass) atom.SetCovRad(param.GetCovRad(at_element)) mol.atoms.append(atom) mol.mass += at_mass
def testHeaviestAtom(self): """Asserts correct radius for heaviest present atom.""" self.assertEqual(param.GetCovRad('Kr'), 1.03)
def testHydrogen(self): """Asserts correct radius for hydrogen atom.""" self.assertEqual(param.GetCovRad('H'), 0.37)
def testDummyInput(self): """Asserts zero radius for dummy atom input.""" self.assertEqual(param.GetCovRad('X'), 0.0)