def test_element_by_symbol(self): for symbol in ["N", "n", " N7"]: nitrogen = element.element_by_symbol(symbol) assert nitrogen.name == element.Nitrogen.name assert nitrogen.symbol == element.Nitrogen.symbol assert nitrogen.mass == element.Nitrogen.mass
def test_element_by_symbol(self): for symbol in ['N', 'n', ' N7']: nitrogen = element.element_by_symbol(symbol) assert nitrogen.name == element.Nitrogen.name assert nitrogen.symbol == element.Nitrogen.symbol assert nitrogen.mass == element.Nitrogen.mass
def test_bond_every_field_set(self, full_atom_type, are_equivalent_atoms): atom1 = Atom( name="test_atom1", label="test_label1", position=[0.0, 0.0, 0.0], charge=1.5, mass=2.0, element=element_by_symbol("C"), atom_type=full_atom_type, ) atom2 = Atom( name="test_atom1", label="test_label1", position=[0.1, 0.4, 0.5], charge=5, mass=2.6, element=element_by_symbol("H"), atom_type=full_atom_type, ) bond = Bond(name="test_bond1", connection_members=(atom1, atom2)) bond_type = BondType( name="test_bond_type", expression="a*b+c**2", parameters={ "a": 10 * u.nm, "b": 20 * u.angstrom }, independent_variables={"c"}, ) bond_copy = Bond.parse_raw(bond.json()) assert bond_copy.name == bond.name for member1, member2 in zip(bond.connection_members, bond_copy.connection_members): assert are_equivalent_atoms(member1, member2) assert bond_copy.bond_type == bond.bond_type
def test_atom_every_field_set(self, full_atom_type, are_equivalent_atoms): atom = Atom( name="test_atom", label="test_label", position=[0.0, 0.0, 0.0], charge=1.5, mass=2.0, element=element_by_symbol("C"), atom_type=full_atom_type, ) atom_copy = Atom.parse_raw(atom.json()) assert are_equivalent_atoms(atom, atom_copy)
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