Skip to content

Commit

Permalink
Merge pull request #443 from pyiron/atomicrex-file-names
Browse files Browse the repository at this point in the history
atomicrex file names
  • Loading branch information
Leimeroth authored Dec 19, 2022
2 parents da3a458 + 7cfb578 commit e4f66bf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pyiron_contrib/atomistics/atomicrex/structure_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def add_structure(
relative_weight=1,
clamp=True,
):
if "/" in identifier:
raise ValueError(
"Structure identifiers must not contain '/'. "
"Use .structure_file_path to use existing POSCAR files"
)

self._structures.add_structure(structure, identifier)
self._structures._per_chunk_arrays["fit"][
self._structures.prev_chunk_index
Expand Down Expand Up @@ -392,6 +398,14 @@ def from_hdf(self, hdf, group_name="structures"):
"relative_weight"
]

def _check_identifiers(self):
identifiers = self._structures.get_array("identifier")
if not np.all(np.char.find(identifiers, "/")==-1):
raise ValueError(
"Structure identifiers must not contain '/'. "
"Use .structure_file_path to use existing POSCAR files"
)

def write_xml_file(self, directory, name="structures.xml"):
"""
Internal helper function that writes an atomicrex style
Expand All @@ -401,6 +415,7 @@ def write_xml_file(self, directory, name="structures.xml"):
directory (string): Working directory.
name (str, optional): . Defaults to "structures.xml".
"""
self._check_identifiers()
self._shrink()
root = ET.Element("group")
if self.structure_file_path is None and "atomic-forces" in self.fit_properties:
Expand Down

0 comments on commit e4f66bf

Please sign in to comment.