Skip to content
Snippets Groups Projects
Commit baac1e69 authored by Jonathan Kriwet's avatar Jonathan Kriwet
Browse files

added option to force parameter to min(...) of other parameters

parent b3d75cd2
No related branches found
No related tags found
No related merge requests found
......@@ -187,6 +187,10 @@ class EnergyPlusCalibrator:
if self.force_same is not None:
for force_to, force_from in self.force_same.items():
check_param(force_to)
if isinstance(force_from[0], (list, tuple)):
for f in force_from[0]:
check_param(f)
else:
check_param(force_from[0])
def _get_tuner_paras_dict(self) -> Dict[str, Tuple[float, Tuple[float, float]]]:
......
......@@ -349,6 +349,7 @@ class EnergyPlusAPI(SimulationAPI):
_df = self._single_simulation_solo_mp(kwargs.copy())
else:
_df = self._single_simulation_solo(kwargs.copy())
if _df is None:
if queue is not None:
queue.put(None)
......@@ -466,8 +467,19 @@ class EnergyPlusAPI(SimulationAPI):
if self.force_same is not None and not dont_force_same:
for force_to, force_from in self.force_same.items():
if isinstance(force_from[0], str):
parameters[force_to] = parameters[force_from[0]] + \
force_from[1]
continue
elif not isinstance(force_from[0], tuple):
raise ValueError('force_from must be a tuple or a string')
#force_from is a tuple
if force_from[1] == 'min':
parameters[force_to] = min([parameters[i] for i in force_from[0]])
else:
raise NameError('force_from[1] must be "min"')
for key in self._set_output_timestep:
self._set_output_timestep[key] = self.sim_setup.dataframe_interval
......@@ -509,6 +521,10 @@ class EnergyPlusAPI(SimulationAPI):
self.logger.error('---ARGS---\n%s', result.args)
self.logger.error('---STDOUT---\n%s', result.stdout.decode())
self.logger.error('---STDERR---\n%s', result.stderr.decode())
error_file = _temp_output_directory / 'eplusout.err'
if error_file.exists():
with open(error_file, 'r') as f:
self.logger.error(f.read())
shutil.rmtree(_temp_output_directory)
shutil.rmtree(_temp_generated_inputs)
if fail_on_error:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment