diff --git a/contributors.md b/contributors.md index ca6849c38..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 diff --git a/examples/python/interface.py b/examples/python/interface.py index 3ea122a0e..5ac09378a 100644 --- a/examples/python/interface.py +++ b/examples/python/interface.py @@ -113,9 +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 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)) # IF ANY CUSTOM KPI CALCULATION, DEFINE STRUCTURES # ------------------------------------------------ @@ -142,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 @@ -157,20 +152,21 @@ 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 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 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) @@ -183,7 +179,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: @@ -201,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$' 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) diff --git a/releasenotes.md b/releasenotes.md index 9ee93e322..1790d2e84 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -16,7 +16,7 @@ Released on xx/xx/xxxx. - 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). - 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:**