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 activate_nonperiodic(self): """ Activates a calculation with non-periodic calculations by turning of PBC and changing the poisson solver. Still requires a CELL to put the atoms """ kwds = { "POISSON_SOLVER": Keyword("POISSON_SOLVER", "MT"), "PERIODIC": Keyword("PERIODIC", "NONE"), } self["FORCE_EVAL"]["DFT"].insert(Section("POISSON", subsections={}, keywords=kwds)) if not self.check("FORCE_EVAL/SUBSYS/CELL"): x = max(s.coords[0] for s in self.structure.sites) y = max(s.coords[1] for s in self.structure.sites) z = max(s.coords[2] for s in self.structure.sites) self["FORCE_EVAL"]["SUBSYS"].insert(Cell(lattice=Lattice([[x, 0, 0], [0, y, 0], [0, 0, z]]))) self["FORCE_EVAL"]["SUBSYS"]["CELL"].add(Keyword("PERIODIC", "NONE"))