Skip to content

Commit d6827fa

Browse files
committed
[ModelicaSystem] improve handling of model simulation
* ensure a message if logged if returncode != 0
1 parent 9dc12bf commit d6827fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

OMPython/ModelicaSystem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,15 +1146,15 @@ def simulate(
11461146
cmd_definition = om_cmd.definition()
11471147
returncode = self._session.run_model_executable(cmd_run_data=cmd_definition)
11481148
# and check returncode *AND* resultfile
1149-
if returncode != 0 and self._result_file.is_file():
1149+
if returncode != 0:
11501150
# check for an empty (=> 0B) result file which indicates a crash of the model executable
11511151
# see: https://github.com/OpenModelica/OMPython/issues/261
11521152
# https://github.com/OpenModelica/OpenModelica/issues/13829
1153-
if self._result_file.size() == 0:
1153+
if self._result_file.is_file() and self._result_file.size() == 0:
11541154
self._result_file.unlink()
11551155
raise ModelicaSystemError("Empty result file - this indicates a crash of the model executable!")
11561156

1157-
logger.warning(f"Return code = {returncode} but result file exists!")
1157+
logger.warning(f"Return code = {returncode} but result file was created!")
11581158

11591159
self._simulated = True
11601160

0 commit comments

Comments
 (0)