def test_water_top(self, water_system): top = water_system ff = gmso.ForceField(get_path('tip3p.xml')) for site in top.sites: site.atom_type = ff.atom_types[site.name] top.update_sites() top.update_atom_types() for bond in top.bonds: bond.bond_type = bond.connection_type = ff.bond_types[ 'opls_111~opls_112'] top.update_bonds() top.update_bond_types() for subtop in top.subtops: angle = gmso.core.angle.Angle( connection_members=[site for site in subtop.sites], name="opls_112~opls_111~opls_112", connection_type=ff.angle_types["opls_112~opls_111~opls_112"]) top.add_connection(angle) top.update_angles() top.update_angle_types() write_top(top, 'water.top')
def test_modified_potentials(self, ar_system): top = ar_system ff = gmso.ForceField(get_fn('ar.xml')) for site in top.sites: site.atom_type = ff.atom_types['Ar'] top.update_topology() top.atom_types[0].set_expression('sigma + epsilon*r') with pytest.raises(EngineIncompatibilityError): write_top(top, 'out.top') alternate_lj = '4*epsilon*sigma**12/r**12 - 4*epsilon*sigma**6/r**6' top.atom_types[0].set_expression(alternate_lj) write_top(top, 'ar.top')
def _parse_gmso(self, forcefield_files, **kwargs): """Parse metadata information when using GMSO as backend.""" if forcefield_files: self.ff = gmso.ForceField(forcefield_files, **kwargs) self._version = self.ff.version self._name = self.ff.name for name, atype in self.ff.atom_types.items(): self.atomTypeDefinitions[name] = atype.definition self.atomTypeOverrides[name] = atype.overrides self.atomTypeDesc[name] = atype.description self.atomTypeRefs[name] = set(atype.doi.split(",")) self.atomTypeClasses[name] = atype.atomclass if atype.tags.get("element"): ele = atype.tags["element"] if element.element_by_symbol(ele): self.atomTypeElements[atype.name] = ele else: self.non_element_types[ele] = None else: # Register atomtype with missing atomtype as atomistic (empty string) self.atomTypeElements[name] = "" return None