def test_element_by_mass_exactness(self): cobalt = element.element_by_mass(58.9) nickel = element.element_by_mass(58.7) chlorine = element.element_by_mass(35, exact=False) assert cobalt == element.Cobalt assert nickel == element.Nickel assert chlorine == element.Chlorine
def _get_atoms(filename, topology, unit_style, type_list): """Parse the atom information in the LAMMPS data file.""" with open(filename, "r") as lammps_file: for i, line in enumerate(lammps_file): if "atoms" in line.split(): n_atoms = int(line.split()[0]) if "Atoms" in line.split(): break atom_lines = open(filename, "r").readlines()[i + 2:i + n_atoms + 2] for line in atom_lines: atom_line = line.split() atom_type = atom_line[2] charge = u.unyt_quantity(float(atom_line[3]), get_units(unit_style)["charge"]) coord = u.angstrom * u.unyt_array( [float(atom_line[4]), float(atom_line[5]), float(atom_line[6])]) site = Atom( charge=charge, position=coord, atom_type=type_list[int(atom_type) - 1], ) element = element_by_mass(site.atom_type.mass.value) site.name = element.name site.element = element topology.add_site(site) topology.update_sites() return topology
def test_element_by_mass(self): for mass in ["Fluorine-19", 19, 19 * u.amu]: fluorine = element.element_by_mass(mass) assert fluorine.name == element.Fluorine.name assert fluorine.symbol == element.Fluorine.symbol assert fluorine.mass == element.Fluorine.mass