Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atomicrex file names #443

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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