def create_subsys(self, structure: Union[Structure, Molecule]): """ Create the structure for the input """ subsys = Subsys() if isinstance(structure, Structure): subsys.insert(Cell(structure.lattice)) # Decide what basis sets/pseudopotentials to use basis_and_potential = get_basis_and_potential( [str(s) for s in structure.species], self.potential_and_basis ) # Insert atom kinds by identifying the unique sites (unique element and site properties) unique_kinds = get_unique_site_indices(structure) for k in unique_kinds.keys(): kind = k.split("_")[0] kwargs = {} if "magmom" in self.structure.site_properties: kwargs["magnetization"] = self.structure.site_properties["magmom"][ unique_kinds[k][0] ] if "ghost" in self.structure.site_properties: kwargs["ghost"] = self.structure.site_properties["ghost"][ unique_kinds[k][0] ] if "basis_set" in self.structure.site_properties: basis_set = self.structure.site_properties["basis_set"][ unique_kinds[k][0] ] else: basis_set = basis_and_potential[kind]["basis"] if "potential" in self.structure.site_properties: potential = self.structure.site_properties["potential"][ unique_kinds[k][0] ] else: potential = basis_and_potential[kind]["potential"] if "aux_basis" in self.structure.site_properties: kwargs["aux_basis"] = self.structure.site_properties["aux_basis"][ unique_kinds[k][0] ] subsys.insert( Kind(kind, alias=k, basis_set=basis_set, potential=potential, **kwargs) ) coord = Coord(structure, aliases=unique_kinds) subsys.insert(coord) self["FORCE_EVAL"].insert(subsys) self.basis_set_file_names = basis_and_potential["basis_filenames"] self.potential_file_name = basis_and_potential["potential_filename"]
def test_coords(self): for strucs in [nonsense_Structure, Si_structure, molecule]: coords = Coord(strucs) self.assertEqual(len(strucs.symbol_set), len(coords.keywords)) for c in coords.keywords.values(): self.assertIsInstance(c, KeywordList)