Python Scripting Example 1 - db_eplusout_reader Basics

This example shows how to create a simple Python script to write out a basic energy summary report after each simulation by accessing output variables reported in the EnergyPlus SQLite output file. The script could of course be extended to write more sophisticated reports depending on your model and your requirements.

 

The model is the same base model used in several other custom script tutorials.

 

The steps involved are as follows.

Step 1 - Create a base model

1. Create a new model located at London Gatwick.

 

2. Add a building using default settings and draw a rectangular block measuring 20m by 10m with block height of 3.5m as shown below.

 

3. Load the Generic Office Area Activity template at building level on the Activity Tab.

Step 2 - Write Custom Script

The next task is to write the script that will read the simulation results from the SQL output file and process and write them out as a summary report file. Steps are as follows.

1. Click on the Scripts toolbar icon to open the Script Manager dialog and click on the Enable scripts checkbox.

 

2. Click on the Script browse item. A list of the existing scripts appears in the Info panel to the right.

 

3. Click on the Python-Script category and press the Add new item Info toolbar icon to open the Edit script dialog.

 

4. Copy and paste the script below into the script window. In summary, the script works as follows. Before the IDF is generated for the simulation the SQLite output option in each building in the model is forced to be on. Then after the simulation the key heating, cooling, equipment and lighting energy consumption outputs are loaded from the eplusout.sql simulation output file, summed to create a total and written to a text file in the DesignBuilder EnergyPlus folder.

 

Tip: To save time you can copy the above script and paste it into the dialog. Note that Python requires the indentation as part of its syntax and when you paste the script the indents may become lost. In this case you must insert the indents manually after the paste. The easiest way to do that it by using the <Tab> key.

Step 3 - Run Simulation and Check Results

Now navigate to the Simulation tab and run an annual simulation, making sure that the Monthly and RunPeriod output option is checked under the Output Intervals for Reporting subheading.

 

Once the simulation is complete, navigate to the EnergyPlus folder (File > Folders > EnergyPlus folder menu command). A text file named "energy_report.txt" should be found there. The report should contain results like those below.

 

The following values have been retrieved from the .sql file.

 

Cooling Energy: 8783.43169749 kWh

 

Heating Energy: 8226.56484868 kWh

 

Equipment Energy: 7922.75824552 kWh

 

Lighting energy: 11450.1034080 kWh

 

Total Energy: 36382.8581997 kWh