Skip to content

Commit

Permalink
Merge pull request #908 from pyiron/vasp_potential
Browse files Browse the repository at this point in the history
Simplify setting potentials for VASP
  • Loading branch information
jan-janssen committed Aug 27, 2020
2 parents 08c5e37 + 29da3ee commit 19a70e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
7 changes: 5 additions & 2 deletions pyiron/vasp/base.py
Expand Up @@ -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):
Expand All @@ -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 []

Expand Down
21 changes: 17 additions & 4 deletions pyiron/vasp/potential.py
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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):
"""
Expand Down

0 comments on commit 19a70e4

Please sign in to comment.