From 7093ef4ad5c85816f134966f882c74a7055e1eb1 Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Thu, 2 Sep 2021 10:38:59 -0400 Subject: [PATCH] Changes behavior of IDF.simulate to return results directly if they exist (#218) --- archetypal/idfclass/idf.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/archetypal/idfclass/idf.py b/archetypal/idfclass/idf.py index 47e5de93..13f3dd69 100644 --- a/archetypal/idfclass/idf.py +++ b/archetypal/idfclass/idf.py @@ -1240,7 +1240,7 @@ def variables(self): self._variables = Variables(self) return self._variables - def simulate(self, **kwargs): + def simulate(self, force=False, **kwargs): """Execute EnergyPlus. Specified kwargs overwrite IDF parameters. ExpandObjects, Basement and Slab @@ -1248,6 +1248,9 @@ def simulate(self, **kwargs): Does not return anything. + Args: + force (bool): Force simulation even though results exist in `self.simulation_dir`. + Keyword Args: eplus_file (str): path to the idf file. weather_file (str): path to the EPW weather file. @@ -1302,9 +1305,11 @@ def simulate(self, **kwargs): energyplus command. See Also: - :meth:`simulation_files`, :meth:`processed_results` for simulation outputs. + :attr:`IDF.simulation_files`, :attr:`IDF.processed_results` for simulation outputs. """ + if self.simulation_dir.exists() and not force: # don't simulate if results exists + return self # First, update keys with new values for key, value in kwargs.items(): if f"_{key}" in self.__dict__.keys():