## 2 Optimisation Methods and Modelling
### HESS Control Rule
#### 2.4.1 Electrical Storage System (ESS) Control Rule  
The purpose of the ESS is to support the CHP by reducing the reliance on grid imports during peak price periods and storing the surplus energy from the CHP switching, thus reducing the overall running cost of meeting the loads. However, this requires a precise control rule. Two things need to be considered carefully in advance--the amount of energy required to meet each electrical peak demand and the exact time to begin charging. An ESS normally consists of a group of batteries, but in an Energy Hub system at building level, it is desirable to have more than one group of batteries due to the high frequency of charge cycles required. Compared with large electrical systems, the electricity demand at building level has higher uncertainty, thus the states (charging and discharging) of ESS may need to be changed very frequently. However, the life span of batteries will be significantly reduced if the states of batteries are changed too frequently. In [36], the authors describe that a simple two-battery system has a longer life span compared with a single battery system which has the same capacity. In this paper, the ESS consists of two groups of batteries, and two batteries are used separately to supply the electrical load at the two daytime peak demands (shown in Figure 4). Figure 4: Two-battery storage system control rule. In Figure 4, the first battery is charged before the morning peak, T\({}_{\text{P}}\)1, and discharged to compensate energy shortage for the first peak demand time T\({}_{\text{P}}\)2. (The energy shortage in the first peak demand time is the difference between electrical energy generated by CHP and the building's electrical demand). The second battery is charged from very early in the morning to the beginning of the second peak T\({}_{\text{P}}\)1 to T\({}_{\text{P}}\)3 and then discharged to compensate energy shortage for the second peak, T\({}_{\text{P}}\)4. The electricity used to charge batteries is normally the surplus electricity generated by the CHP system. Very occasionally, electricity from the grid is used to charge the battery. The two-battery storage system control algorithm is shown in the flowchart in Figure 5 and is as follows. Step 1: Find each of the two daily peak demand start and end times and calculate how much energy should be stored in advance for each peak. This can be done by analysing the historical data from the same month of the previous year and using the curve fitting algorithm described in [33]. Step 2: After finding the first peak demand start time (\(t_{\beta}\)), and the amount of energy shortage for the first peak demand (\(E_{fp}\)), the amount of theoretical surplus electrical energy (\(E_{Tho}\) in kilowatt hour) generated in each minute before the first peak can be calculated. \[E_{Tho}^{i}=\frac{P_{CHP}\times\eta_{ele}\times t\ -\ E_{his}^{i}}{1000\ \times\ 60} \tag{11}\]  
In Equation (11), \(P_{CHP}\) is CHP rated power in Watts, \(\eta_{ele}\) is CHP electrical efficiency, \(t\) is time in minutes and \(E_{his}^{i}\) is the average historical electricity consumption in the \(i\)th minute, in Joules. \(E_{Tho}^{i}\) is the theoretical surplus electrical energy that can be stored in the \(i\)th minute. Figure 5: Electrical Energy control rule. Step 3: Then, the \(E_{Theo}\) vector needs to be modified to get the total surplus electrical energy (\(E_{Total}\)) in each minute generated by CHP before the beginning of the first peak. To be specific, change all the values in the \(E_{Theo}\) vector whose value is less than zero to zero, and keep other terms the same, producing a modified vector \(E^{\prime}_{Theo}\). The formula of total energy can be stored before first peak start can be written as:  
\[E^{i}_{Total}=\sum_{i=i}^{t=\textit{first peak start time}}E^{i}_{Theo} \tag{12}\]  
Step 4: Comparing \(E^{i}_{Total}\) and \(E_{fp}\), find the highest value of \(i\) that makes \(E^{i}_{Total}\) greater than \(E_{fp}\).