Skip to content

Commit

Permalink
Fix optional crash handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tjwsch committed Jun 12, 2024
1 parent 8a7ae1b commit f5bda6e
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions micro_manager/micro_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,21 @@ def solve(self) -> None:
np.sum(self._has_sim_crashed), crashed_sims_on_all_ranks
)

if self._is_parallel:
crash_ratio = (
np.sum(crashed_sims_on_all_ranks) / self._global_number_of_sims
)
else:
crash_ratio = np.sum(self._has_sim_crashed) / len(self._has_sim_crashed)
if self._is_parallel:
crash_ratio = (
np.sum(crashed_sims_on_all_ranks) / self._global_number_of_sims
)
else:
crash_ratio = np.sum(self._has_sim_crashed) / len(
self._has_sim_crashed
)

if crash_ratio > self._crash_threshold:
self._logger.info(
"{:.1%} of the micro simulations have crashed exceeding the threshold of {:.1%}. "
"Exiting simulation.".format(crash_ratio, self._crash_threshold)
)
sys.exit()
if crash_ratio > self._crash_threshold:
self._logger.info(
"{:.1%} of the micro simulations have crashed exceeding the threshold of {:.1%}. "
"Exiting simulation.".format(crash_ratio, self._crash_threshold)
)
sys.exit()

self._write_data_to_precice(micro_sims_output)

Expand Down Expand Up @@ -498,6 +500,9 @@ def initialize(self) -> None:
"The initialize() method is only allowed to return data which is required for the adaptivity calculation."
)

# Get initial data from micro simulations if initialize() method exists
if self._micro_sims_init:

# Call initialize() method of the micro simulation to check if it returns any initial data
if is_initial_data_required:
initial_micro_output = self._micro_sims[0].initialize(initial_data[0])
Expand Down

0 comments on commit f5bda6e

Please sign in to comment.