This is a simple example of how to train agent for building energy efficiency in virtual environment without the help of other external software, like fmi or OpenModelica. If you are interested in how research crowd do similar things, I write a blog to summarize it briefly.
In my example, to make it comprehensive, model-based and model-free are in this example. Model-free is to do load allocation by Q-learning. Model-based is to control the number of cooling towers and frequency of fans in them.
For every load, model-free is followed by model-based (load allocation first and then cooling tower control).
In model-free method, reward is about total COP (
The virtual system is a classical water system (chillers + water pumps + cooling towers).
Category | Details |
---|---|
Chillers | Chiller#1: with larger capacity, two chillers in total Chiller#2: with smaller capacity, one chiller. (details in .ipynb file 7. subfunction ) |
Pumps | Chilled Water Pump#1: with more nominal waterflow in nameplate Fixed Freq, two pumps in total Chilled Water Pump#2: with less nominal waterflow in nameplate Fixed Freq, one pump Cooling Water Pump#1: with more nominal waterflow in nameplate Fixed Freq, two pumps in total Cooling Water Pump#2: with less nominal waterflow in nameplate Fixed Freq, one pump |
Tower | All Cooling Towers are idential, with variable-speed fans |
Chillers are nexus of two water loops. Cooling water will go through cooling towers and chillers so that the temperature will be affected by these two components. You can calculate temperatures of cooling water from two perspectives. Theoretically you can get the same result from two sides. One perspective is chiller and law of energy conversion. The amount of heat transfer in chilled water loop should equal that in cooling water loop. Other persepctive is cooling tower. 8.8 calculate the temperature of cooling water entering cooling tower
in .ipynb)
To simplify, I use loop method instead of some methods to get converged results, which means cannot make sure the ultimate result 1.1 calculating outlet water temperature
)
Our focus on chillers can cooling towers makes us simplify water pumps. All water pumps are not variable-speed, they are with fixed frequency 50Hz. You can get my meaning in 2 Cooling Water Pump
-
1 Cooling Tower
includes cooling tower models and how to calculate$T_{cwl}$ from the perspective of cooling towers, the model of fan power is simple cubic formula, which is based on real equipment, you can change it if necessary. -
2 Cooling Water Pump
includes models of power (electricity consumption) and watetflow -
3 Chilled Water Pump
is the same as 2 -
4 Chiller
includes two kinds of chillers mentioned in table. How to calculate the COP, chiller model are from EnergyPlus database. -
In
7 subfunction
,7.2
presents chiller operation, how many chillers we need to operate to deal with load, which can determine pump operation. Noticably, for sake of energy-saving, we setT_chwe
is 12 Celsius. -
8.1 initialization
includes two parts, generating intial Q-table, and parameters of reward calculation. -
8.3
explains the situation when we need to use Q-learning to allocate load, if we need smaller and larger chillers, we need to use Q-learning. Otherwise don't use Q-learning. -
8.4 discretization
is for Q-Table, Q-Table needs discretization. -
8.6
calculate the temperature of main water leaving chillers because some difference between$T_{chwl}$ of smaller and larger chillers. -
8.9
is how to choose the optimal control set (for cooling towers) using model-based method after using Q-learning load allocation. But one thing needs to notice, model-based optimization for cooling tower control is necessary, whether Q-learning is used or not for every load.
file | details |
---|---|
QLearningAgent_VirtualEnv.ipynb | it is the core of the respository, including all details about how to do RL in Virtual Env for improvement of Building Energy Efficiency |
CoolingLoad.csv | data of load generated by users, based on a case |
Weather.csv | data of weather in a certain region |
EngineeringReference.pdf | The reference of the models involved in .ipynb file, and it is from EnergyPlus official website |
decoupling.jpg | a diagram in README.md |
SystemLayoutAbstract.jpg | a diagram in README.md |
README.md | a brief introduction of the respority |
The table structure is the column is action, 0.1, 0.15, 0.2, ... 1.0 (for load allocation for smaller chiller), for example, when
flowchart TD
A[Current Load] --> B[Load Discretization]
B --> C[Chiller Operation]
C --> D{Q-Learning?}
D -->|No| D1[Average Load Allocation]
D1 --> E[Optimize the Control for Cooling Towers]
D -->|Yes| F[Agent Decides Load Allocation]
F --> E
E --> E1(the Number of Cooling Towers under operation)
E --> E2(the Frequency of Fan in Cooling Towers)
E1 & E2 --> G[Enter the next load randomly]
G --> H{Maximum \n Iteration?}
H -->|Yes| I[Finish]
H -->|No| B