From 29da3ee98c4dbd8e538fb51344e3f07e91ad9244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Thu, 27 Aug 2020 13:23:56 +0200 Subject: [PATCH] Simplify setting potentials for VASP Use: ``` job.potential["Al"] = "Al_sv_GW" job.potential["Ca"] = "Ca_sv_GW" ``` Or: ``` job.potential.Al = "Al_sv_GW" job.potential.Ca = "Ca_sv_GW" ``` In addition you can list the available potentials with: ``` job.list_potentials() ``` Or get more detailed information with: ``` job.potential_view ``` Finally to change the pseudo potential use: ``` job.input.potcar["xc"] = "LDA" # "GGA" or "LDA" ``` To mix different pseudo potential functionals you need to specify the absolute path to the corresponding potentials. Anyway mixing different pseudo potential functionals is not recommended. --- pyiron/vasp/base.py | 7 +++++-- pyiron/vasp/potential.py | 21 +++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pyiron/vasp/base.py b/pyiron/vasp/base.py index 6328bf272..9114ec12b 100644 --- a/pyiron/vasp/base.py +++ b/pyiron/vasp/base.py @@ -270,9 +270,12 @@ def potential_view(self): if self.structure is None: raise ValueError("Can't list potentials unless a structure is set") else: - return VaspPotentialFile(xc=self.input.potcar["xc"]).find( + df = VaspPotentialFile(xc=self.input.potcar["xc"]).find( self.structure.get_species_symbols().tolist() ) + if len(df) > 0: + df["Name"] = [n.split("-")[0] for n in df["Name"].values] + return df @property def potential_list(self): @@ -283,7 +286,7 @@ def potential_list(self): self.structure.get_species_symbols().tolist() ) if len(df) != 0: - return df["Name"] + return [n.split("-")[0] for n in df["Name"].values] else: return [] diff --git a/pyiron/vasp/potential.py b/pyiron/vasp/potential.py index 4eba9cb77..2887f427e 100644 --- a/pyiron/vasp/potential.py +++ b/pyiron/vasp/potential.py @@ -246,6 +246,9 @@ def __getattr__(self, item): else: raise AttributeError + def __setitem__(self, key, value): + self.__setattr__(key=key, value=value) + def __setattr__(self, key, value): if key in self._element_lst: self._potential_dict[key] = value @@ -389,6 +392,19 @@ def _set_potential_paths(self): ) if not (os.path.isfile(el_path)): raise ValueError("such a file does not exist in the pp directory") + elif el in self.modified_elements.keys(): + new_element = self.modified_elements[el] + if os.path.isabs(new_element): + el_path = new_element + else: + vasp_potentials.add_new_element( + parent_element=el, new_element=new_element + ) + el_path = find_potential_file( + path=vasp_potentials.find_default(new_element)["Filename"].values[ + 0 + ][0] + ) else: el_path = find_potential_file( path=vasp_potentials.find_default(el)["Filename"].values[0][0] @@ -412,10 +428,7 @@ def _set_potential_paths(self): self._dataset["Parameter"].append("pot_" + str(i)) self._dataset["Value"].append(el_path) self._dataset["Comment"].append("") - if el_obj.Abbreviation in self.modified_elements.keys(): - self.el_path_lst.append(self.modified_elements[el_obj.Abbreviation]) - else: - self.el_path_lst.append(el_path) + self.el_path_lst.append(el_path) def write_file(self, file_name, cwd=None): """