From 9971d2a5bf28dbc86fbf9250c44ea63af4a6bedd Mon Sep 17 00:00:00 2001 From: Jaap Neven Date: Mon, 7 Oct 2024 15:02:19 +0200 Subject: [PATCH 1/6] Updated interface.py to print current timestep instead of previous --- examples/python/interface.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/python/interface.py b/examples/python/interface.py index 3ea122a0e..b3d94e1ad 100644 --- a/examples/python/interface.py +++ b/examples/python/interface.py @@ -113,9 +113,8 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 # Retrieve a list of measurements (outputs) for the model from REST API measurements = check_response(requests.get('{0}/measurements'.format(url))) print('Measurements:\t\t\t{0}'.format(measurements)) - # Get the default simulation timestep for the model for simulation run - step_def = check_response(requests.get('{0}/step'.format(url))) - print('Default Control Step:\t{0}'.format(step_def)) + # Get the user-defined simulation timestep for the model + print('Current Control Step:\t{0}'.format(step)) # IF ANY CUSTOM KPI CALCULATION, DEFINE STRUCTURES # ------------------------------------------------ From 846438592f94d161bc2255055871555b221becbc Mon Sep 17 00:00:00 2001 From: Jaap Neven Date: Tue, 15 Oct 2024 10:53:12 +0200 Subject: [PATCH 2/6] Changes accordingly to comment in PR # 688 --- examples/python/interface.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/python/interface.py b/examples/python/interface.py index b3d94e1ad..2901426d4 100644 --- a/examples/python/interface.py +++ b/examples/python/interface.py @@ -113,8 +113,6 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 # Retrieve a list of measurements (outputs) for the model from REST API measurements = check_response(requests.get('{0}/measurements'.format(url))) print('Measurements:\t\t\t{0}'.format(measurements)) - # Get the user-defined simulation timestep for the model - print('Current Control Step:\t{0}'.format(step)) # IF ANY CUSTOM KPI CALCULATION, DEFINE STRUCTURES # ------------------------------------------------ @@ -163,8 +161,9 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 if res: print('Successfully initialized the simulation') print('\nRunning test case...') - # Set simulation time step - res = check_response(requests.put('{0}/step'.format(url), json={'step': step})) + # Set and print simulation time step + control_step = check_response(requests.put('{0}/step'.format(url), json={'step': step})) + print('Current Control Step:\t{0}'.format(control_step['step'])) # Initialize input to simulation from controller u = controller.initialize() # Initialize forecast storage structure From 875c4b9b13a451e9d150f5b6e6eac36de7c2dab4 Mon Sep 17 00:00:00 2001 From: Jaap Neven Date: Tue, 15 Oct 2024 14:17:02 +0200 Subject: [PATCH 3/6] Issue_692: Avoiding clutter of custom KPIs in examples --- examples/python/interface.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/python/interface.py b/examples/python/interface.py index 2901426d4..46a12bb5f 100644 --- a/examples/python/interface.py +++ b/examples/python/interface.py @@ -181,7 +181,6 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 kpi.processing_data(y) # Process data as needed for custom KPI custom_kpi_value = kpi.calculation() # Calculate custom KPI value custom_kpi_result[kpi.name].append(round(custom_kpi_value, 2)) # Track custom KPI value - print('KPI:\t{0}:\t{1}'.format(kpi.name, round(custom_kpi_value, 2))) # Print custom KPI value custom_kpi_result['time'].append(y['time']) # Track custom KPI calculation time # If controller needs a forecast, get the forecast data and provide the forecast to the controller if controller.use_forecast: @@ -225,6 +224,10 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 unit = None print('{0}: {1} {2}'.format(key, kpi[key], unit)) + if customized_kpi_config is not None: + print('\nCustom KPI RESULTS \n------------------') + print(pd.DataFrame(custom_kpi_result)) + # POST PROCESS RESULTS # ------------------------------------------------------------------------- # Get result data From b9b5684ed9437dd10479e78b439f01bc2fe05cf9 Mon Sep 17 00:00:00 2001 From: Jaap Neven Date: Mon, 28 Oct 2024 09:33:58 +0100 Subject: [PATCH 4/6] Updated contributors.md and added #686 and #692 in releasenotes.md --- contributors.md | 1 + releasenotes.md | 1 + 2 files changed, 2 insertions(+) diff --git a/contributors.md b/contributors.md index ca6849c38..64867a7bc 100644 --- a/contributors.md +++ b/contributors.md @@ -31,3 +31,4 @@ Thank you to all who have provided guidance on the development of this software. - Michael Wetter, Lawrence Berkeley National Laboratory - Tao Yang, University of Southern Denmark - Ettore Zanetti, Lawrence Berkeley National Laboratory +- Jaap Neven, KU Leuven, VITO diff --git a/releasenotes.md b/releasenotes.md index 761157ab9..acda285b1 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -15,6 +15,7 @@ Released on xx/xx/xxxx. - Add a new directory ``/baselines``, containing baseline testing scripts and associated KPI results for the baseline controllers of all the testcases. This is for [#495](https://github.com/ibpsa/project1-boptest/issues/495). - Add support to ``parsing/parser.py`` for test case compilation using [Modelon's OPTIMICA Compiler Toolkit (OCT)](https://help.modelon.com/latest/reference/oct/). The parser can take arguments ``'JModelica'`` or ``'OCT'``, with ``'JModelica'`` as default. A user still requires access to an OCT license and software on their set up. This is for [#675](https://github.com/ibpsa/project1-boptest/issues/675). - Changed ``bestest_hydronic`` and ``bestest_hydronic_heat_pump`` Modelica implementations in this repository to utilize the Modelica IDEAS Library as a dependency for component models, instead of serving as extensions from the Modelica IDEAS Library. This is to simplify dependencies for maintaining the models, and is how other test cases are implemented. It required duplication of the model implementations from the Modelica IDEAS Library into this repository. This is for [#680](https://github.com/ibpsa/project1-boptest/issues/680). +- Updated ``examples/python/interface.py`` to print correct simulation time step, this is for [#686](https://github.com/ibpsa/project1-boptest/issues/686). Also removed clutter by printed custom KPI results, which is for [#692](https://github.com/ibpsa/project1-boptest/issues/692). **The following new test cases have been added:** From 7bac67074cf58838f2cd0e7573a9a8083b7dfaf4 Mon Sep 17 00:00:00 2001 From: David Blum Date: Mon, 28 Oct 2024 11:34:02 -0700 Subject: [PATCH 5/6] Additional cleanup --- examples/python/interface.py | 19 +++++++++---------- examples/python/testcase2.py | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/python/interface.py b/examples/python/interface.py index 46a12bb5f..5ac09378a 100644 --- a/examples/python/interface.py +++ b/examples/python/interface.py @@ -139,13 +139,11 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 if res == None: # If no time_period was specified (only electricity_price), initialize test with a specified start time and warmup period res = check_response(requests.put('{0}/initialize'.format(url), json={'start_time': start_time, 'warmup_period': warmup_period})) - print("RESULT: {}".format(res)) # Set final time and total time steps according to specified length (seconds) final_time = start_time + length total_time_steps = int(length / step) # calculate number of timesteps else: # If a time_period was specified, the initialization is complete - print("RESULT: {}".format(res)) # Record test simulation start time start_time = int(res['time']) # Set final time and total time steps to be very large since scenario defines length @@ -154,7 +152,6 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 else: # Initialize test with a specified start time and warmup period res = check_response(requests.put('{0}/initialize'.format(url), json={'start_time': start_time, 'warmup_period': warmup_period})) - print("RESULT: {}".format(res)) # Set final time and total time steps according to specified length (seconds) final_time = start_time + length total_time_steps = int(length / step) # calculate number of timesteps @@ -168,7 +165,8 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 u = controller.initialize() # Initialize forecast storage structure forecasts = None - print(requests.get('{0}/scenario'.format(url)).json()) + res = check_response(requests.get('{0}/scenario'.format(url))) + print('Current Scenario Setting:\t{0}'.format(res)) # Simulation Loop for t in range(total_time_steps): # Advance simulation with control input value(s) @@ -198,9 +196,14 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 # VIEW RESULTS # ------------------------------------------------------------------------- - # Report KPIs + # Report Custom KPIs + if customized_kpi_config is not None: + print('\nCustom KPI RESULTS \n------------------') + print(pd.DataFrame(custom_kpi_result)) + + # Report BOPTEST KPIs kpi = check_response(requests.get('{0}/kpi'.format(url))) - print('\nKPI RESULTS \n-----------') + print('\nBOPTEST KPI RESULTS \n-------------------') for key in kpi.keys(): if key == 'ener_tot': unit = 'kWh/m$^2$' @@ -224,10 +227,6 @@ def control_test(control_module='', start_time=0, warmup_period=0, length=24*360 unit = None print('{0}: {1} {2}'.format(key, kpi[key], unit)) - if customized_kpi_config is not None: - print('\nCustom KPI RESULTS \n------------------') - print(pd.DataFrame(custom_kpi_result)) - # POST PROCESS RESULTS # ------------------------------------------------------------------------- # Get result data diff --git a/examples/python/testcase2.py b/examples/python/testcase2.py index b6b1e5187..136246985 100644 --- a/examples/python/testcase2.py +++ b/examples/python/testcase2.py @@ -97,4 +97,3 @@ def run(plot=False): if __name__ == "__main__": kpi, df_res, custom_kpi_result = run() - print(kpi) From 9a7f4982b862a9e24e6f0acf0a8a95dc885341be Mon Sep 17 00:00:00 2001 From: David Blum Date: Mon, 28 Oct 2024 11:35:18 -0700 Subject: [PATCH 6/6] Small edits --- contributors.md | 2 +- releasenotes.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contributors.md b/contributors.md index 64867a7bc..1fdc63c2f 100644 --- a/contributors.md +++ b/contributors.md @@ -22,6 +22,7 @@ Thank you to all who have provided guidance on the development of this software. - Robert Lutes, Pacific Northwest National Laboratory - Bart Merema, dnergy - Kefei Mo, Pacific Northwest National Laboratory +- Jaap Neven, KU Leuven, VITO - Erik Paulson, Independent - Matt Robinson, University of Colorado - Boulder - Jermy Thomas, National Renewable Energy Laboratory @@ -31,4 +32,3 @@ Thank you to all who have provided guidance on the development of this software. - Michael Wetter, Lawrence Berkeley National Laboratory - Tao Yang, University of Southern Denmark - Ettore Zanetti, Lawrence Berkeley National Laboratory -- Jaap Neven, KU Leuven, VITO diff --git a/releasenotes.md b/releasenotes.md index 8e9414b8c..1790d2e84 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -15,8 +15,8 @@ Released on xx/xx/xxxx. - Add a new directory ``/baselines``, containing baseline testing scripts and associated KPI results for the baseline controllers of all the testcases. This is for [#495](https://github.com/ibpsa/project1-boptest/issues/495). - Add support to ``parsing/parser.py`` for test case compilation using [Modelon's OPTIMICA Compiler Toolkit (OCT)](https://help.modelon.com/latest/reference/oct/). The parser can take arguments ``'JModelica'`` or ``'OCT'``, with ``'JModelica'`` as default. A user still requires access to an OCT license and software on their set up. This is for [#675](https://github.com/ibpsa/project1-boptest/issues/675). - Changed ``bestest_hydronic`` and ``bestest_hydronic_heat_pump`` Modelica implementations in this repository to utilize the Modelica IDEAS Library as a dependency for component models, instead of serving as extensions from the Modelica IDEAS Library. This is to simplify dependencies for maintaining the models, and is how other test cases are implemented. It required duplication of the model implementations from the Modelica IDEAS Library into this repository. This is for [#680](https://github.com/ibpsa/project1-boptest/issues/680). -- Updated ``examples/python/interface.py`` to print correct simulation time step, this is for [#686](https://github.com/ibpsa/project1-boptest/issues/686). Also removed clutter by printed custom KPI results, which is for [#692](https://github.com/ibpsa/project1-boptest/issues/692). - Add ``activate`` control inputs that were missing in ``bestest_hydronic`` and ``bestest_hydronic_heat_pump`` Modelica documentation. This is for [#625](https://github.com/ibpsa/project1-boptest/issues/625). +- Updated ``examples/python/interface.py`` to print correct simulation time step, this is for [#686](https://github.com/ibpsa/project1-boptest/issues/686). Also removed clutter by printed custom KPI results, which is for [#692](https://github.com/ibpsa/project1-boptest/issues/692). **The following new test cases have been added:**