0 Votes

Resize windows

Last modified by WikiBot on 2024/01/24 12:43

Previous (Introduction to Python)     |     Back to Start     |     Next (Customized reports)

Resize windows with Python

In this example, you will use the IDA ICE Python API to resize windows. You want the building to use a maximum of 13000 kWh of energy for heating over a period of 1 year. To achieve this, you will change the size of the north-facing windows of the building. This will be done in steps of 80% size reduction until the building uses less than 13000 kWh of energy.

This exercise uses files from the examples zip file

Step 1: Setup the API

  • First, you need to set up the API. For this, you need to find the file util.py and set the variable path_to_ice to point to the bin folder in your IDA ICE installation (or another folder if you have IDA ICE installed elsewhere):

path_to_ice = "C:\\Program Files (x86)\\IDA ICE <YOUR IDA VERSION>\\bin\\"  

Note 1: Replace <YOUR IDA VERSION> with your IDA ICE version, e.g., 5.0 or 5.0 beta 28.

Note 2: If you use a Windows system, always use double backslashes \\ for specifying paths. 

  • Save the util.py after changing it.
  • Second, you also need to go to Services in Windows and make sure that the IDAMessageBrokerService is running. You can find Services by simply searching it in the Windows search bar.

services_search.png

services_present.png

services_present2.png

Step 2: Looking at an example Python script

Now, let's look at the example in resize_wins_example_util.py. It automatically finds all windows facing north, then it resizes them.  

Note 3: Replace <USER DIR> in the following path with your user directory where the downloaded examples are saved to.

  •  First, find and set the variable file_path to point to the file Testbuilding_API.IDM located in the same folder as the script resize_wins_example_util.py.

file_path = "C:\\<USER DIR>\\example\\Resize windows\\Testbuilding_API.IDM"

  • Define where to save the results of the window_resizing. Set the variable result to point to where you want to save the results.

result = "C:\\<USER DIR>\\example\\Resize windows\\Testbuilding_API_resized.IDM"

  • To run the script, open the command prompt terminal by searching cmd.exe in the Windows search bar.

cmd_search.png

cmd_present.png

  • Then go to IDA ICE distributed python directory by typing:

>> cd "C:\\Program Files (x86)\\IDA ICE <YOUR IDA VERSION>\\bin\\python"

  • Now you can run the resize_wins_example_util.py script by typing:

>> python.exe "C:\\<USER DIR>\\example\\Resize windows\\resize_wins_example_util.py"

  • Several simulations will be started, so be a bit patient.
  • Open the resulting building and look at the north-facing windows. How much did they change in size? Try replacing the energy target of 13000 kWh in the script with a lower value, and rerun the script.

Previous (Introduction to Python)     |     Back to Start     |     Next (Customized reports)