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

Use current structure instead of output to update previous structure #483

Merged
merged 3 commits into from
Jan 6, 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
29 changes: 5 additions & 24 deletions pyiron_atomistics/atomistics/job/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def run_if_interactive(self):
self.interactive_initialize_interface()
if self._structure_previous is None:
self._structure_previous = self.structure.copy()
self._update_previous_structure()
jan-janssen marked this conversation as resolved.
Show resolved Hide resolved
if self._structure_current is not None:
if (
len(self._structure_current) != len(self._structure_previous)
Expand All @@ -134,6 +133,7 @@ def run_if_interactive(self):
else:
self._logger.debug("Generic library: structure changed!")
self.interactive_structure_setter(self._structure_current)
self._update_previous_structure()

def interactive_index_organizer(self):
index_merge_lst = self._interactive_species_lst.tolist() + list(
Expand All @@ -156,7 +156,7 @@ def interactive_index_organizer(self):
self.interactive_indices_setter(self._structure_current.indices)

def interactive_cell_organizer(self):
if not np.allclose(
if self._generic_input["calc_mode"] != 'static' or not np.allclose(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary for calc_minimize() only calc_minimize(pressure=0) right? And analogously it is not necessary for nvt and nve but npt.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the information about nvt, nve etc. included in the input?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we could go ahead with this version for now, right? I don't think communicating the cell size would significantly change something.

self._structure_current.cell,
self._structure_previous.cell,
rtol=1e-15, atol=1e-15,
Expand All @@ -168,7 +168,7 @@ def interactive_cell_organizer(self):
del self.interactive_input_functions['cell']

def interactive_positions_organizer(self):
if not np.allclose(
if self._generic_input["calc_mode"] != 'static' or not np.allclose(
self._structure_current.positions,
self._structure_previous.positions,
rtol=1e-15,
Expand Down Expand Up @@ -266,27 +266,8 @@ def interactive_volume_getter(self):
return self.initial_structure.get_volume()

def _update_previous_structure(self):
"""
Update the previous structure to the last step configuration
Args:
wrap_atoms (bool):
"""
try:
indices = self.output.indices[-1]
positions = self.output.positions[-1]
cell = self.output.cells[-1]
except IndexError:
return
if len(self._interactive_species_lst) == 0:
el_lst = [el.Abbreviation for el in self.structure.species]
else:
el_lst = self._interactive_species_lst.tolist()
self._structure_previous = self._structure_previous.__class__(
positions=positions,
cell=cell,
indices=indices,
species=[self._periodic_table.element(el) for el in el_lst],
)
"""Update the previous structure to the last step configuration."""
self._structure_previous = self.structure.copy()
samwaseda marked this conversation as resolved.
Show resolved Hide resolved

@staticmethod
def _extend_species_elements(struct_species, species_array):
Expand Down