Breakthroughs in smart grid technology make it possible to deliver electricity in controlled and intelligent ways to improve energy efﬁciency between the user and the utility. Demand-side management strategies can reduce overall energy usage and shift consumption to reduce peak loads. Electric water heaters account for 40% of residential energy consumption. Since they are thermal storage devices, advanced control strategies can improve their efﬁciency. But existing methods disregard the connection between the user and the grid. We propose a centrally adapted control model that allows for coordinated scheduling to adapt the optimal control schedule of each EWH, spreading the load into off-peak periods to ensure that the grid’s generation capacity is not exceeded. We consider two strategies for the delivery of hot water, temperature matching, and energy matching with Legionella sterilisation, and compare them to a baseline strategy where the thermostat is always switched on. Simulation results for a grid of 77 EWHs showed that an unconstrained peak load of 1.05 kW/EWH can be reduced as low as 0.4 kW/EWH and achieve a median energy saving per EWH of 0.38 kWh/day for the temperature matching strategy and 0.64 kWh/day for the energy matching strategy, without reducing the user’s comfort. Index Terms electric water heaters; demand-side management; peak demand reduction; smart grid I. I NTRODUCTION The prevailing view of electricity generation is that the system will be most efﬁcient when ﬂuctuations are mitigated as much as possible. This is in contrast to the earlier view that the generation capacity must be able to increase to satisfy any demand [1]. Techniques have been devised to smooth the demand proﬁle of the grid and limit the power demand [1]–[3]. This is particularly important in the case of electric water heaters (EWHs), as they account for 40% of the residential sector’s energy consumption, and this sector accounts for 20% of greenhouse gas emissions [4]–[9]. South Africa currently lacks the generation capacity to meet the demand on the grid. This has led to frequent power outages, necessitating load-shedding [10]. The energy required to operate the ﬁve million water heaters in the country is responsible for30 % to50 % of the peak loads on the grid [4], [6]. The country’s carbon footprint is also signiﬁcant, since approximately 88 % of the electricity is generated from coal [11]. Smart grids make it possible to deliver electricity in controlled, intelligent ways and encourage improved energy efﬁciency between the user and the utility [12], [13]. This can be achieved by load management and demand response strategies. Demand- side management aims to change the end-users’ electricity usage patterns to reduce their overall consumption or shift it to different times [14]. Achieving the goals of demand-side management can beneﬁt the environment by reducing the release of greenhouse gases [15]. The EWH is a thermal storage device with the ﬂexibility to achieve signiﬁcant energy savings [16]. For smart grid applications, the energy efﬁciency of EWHs can be improved by using thermal models and advanced control algorithms that typically reduce heat loss, maintain user comfort and prevent the growth of Legionella bacteria, which can cause the disease legionellosis [17], [18]. Such models and strategies have been extensively researched but few of them have been designed to reduce demand and overall energy [19]. The typical, and most energy inefﬁcient, control of EWHs, referred to as thermostat control (TC), is to leave the thermostat always on to maintain the water temperature at a set point. A better solution is schedule control (SC), in which the user decides when the water should be heated during the day to ensure user comfort while reducing thermal losses over the whole day [20]. The demand proﬁle for EWHs typically peaks in the morning and evening [21]. The proﬁle reﬂects the water usage behaviour of each household and is inﬂuenced by weather and time of use factors [22]–[24]. The grid demand for EWH control can be regulated through various demand-side management programs, such as load- response, incentive-based and direct load control [14]. In direct load control programs, the utility controls the operation of the user’s EWH remotely, via power line communication, to reduce the grid load during peak times. From the perspective of the user, the desired strategy reduces the overall energy usage but avoids causing discomfort. From the perspective of the utility, the desired strategy reduces the overall energy usage while smoothing out peak loads on the grid. The ideal demand-side management strategy achieves both these aims. Figure 1 shows how the energy usage, user discomfort levels and peak loads are distributed by existing strategies and by our new strategy, explained in this paper. Optimal control strategies have been proven to greatly reduce EWH energy usage while ensuring that user comfort levels are preserved. However, they fail to consider what the grid can manage without compromising the user’s comfort or reducing the energy savings. We propose a centrally adapted control (CAC) model that minimises all three attributes: peak load, energy usage and user discomfort. Fig. 1: Distribution of user discomfort levels, overall energy usage and peak load management for ﬁve control strategies. In this paper we present a two-stage optimisation system which ﬁrst determines the optimal control for each EWH without consideration for the grid and then determines the optimal centrally adapted control for multiple EWHs to ensure that the grid demand does not exceed the grid’s power supply limit. Contributions This paper presents a novel scheduling model that centrally adapts the control of EWHs to reduce peaks and ensure that the demand on the grid does not exceed the grid’s generation capacity. This provides a balance between the requirements of the user and those of the utility - a need which is disregarded by existing approaches. Our proposed method uses measured hot water usage data from 77 EWHs over four seasons, one week per season, and produces the optimal plan when the model hasperfect foreknowledge of water usage and then also when the water usages are predicted . The rest of the paper is structured as follows: Section II reviews the literature on individual EWH control and centralised control. Section III describes the system overview. Sections IV and V deﬁne the EWH model and the individual EWH optimisation algorithm. Section VI presents the scheduling model. Section VII describes the experimental setup. Sections VIII and IX present the results and conclusion. II. R ELATED WORK This section reviews work on control strategies for individual EWHs and centralised control to regulate grid demand. Table I summarises the main ﬁndings and highlights the challenges that remain and that this paper addresses. Individual EWH control Gholizadeh and Aravinthan [25] assessed the beneﬁts of adjusting the set-point temperature and using the day-ahead pricing to decrease the total cost of electricity for residential EWHs. The main factors they examined were consumer comfort, reduction of temperature variations, and health concerns such as Legionella . They determined cost savings of 5:9 %to6:4 %. However, their study used synthetic water proﬁles associated with the ASHRAE standard rather than ﬁeld-measured data. Booysen and Cloete [26] demonstrated how modern smart grid technologies can determine the impact of schedule control for large-scale experiments. Their experiment measured and analysed the energy usage, during two months’ schedule control, of ﬁve water heaters equipped with ETSI smart grid technology. The results were validated by a lab experiment with a two-node thermal model. Their work determined energy savings without accounting for temperature-matched or energy-matched outputs. Kepplinger et al. [27] proposed an incentive-driven demand-side management strategy that optimised the control of EWHs by predicting user behaviour. They solved the optimal control problem with a binary integer algorithm and estimated the future water consumption with a nearest-neighbour algorithm performed on historical time-series data. Using a night-tariff-switched EWH as a reference, they found the cost and energy savings with energy-matched outputs were both 12 % . TABLE I: Table of related work for individual and centralised control of EWHs. [25] [26] [27] [28] [29] [30] [31] [3] [32] This paper Control type Individual control 3 3 3 3 3 7 7 7 7 3 Centralised control 7 7 7 7 7 3 3 3 3 3 Control objective Time of Use optimisation 3 7 3 7 7 3 3 7 7 7 Energy optimisation 3 3 3 3 3 3 7 3 3 3 General Grid peak load level limits 7 7 7 7 7 7 7 3 3 3 Field-measured hot water 7 3 7 3 3 7 7 3 7 3 No user interaction 7 7 3 3 3 3 7 3 3 3 Temperature matched output 7 7 7 3 3 7 7 7 7 3 Energy matched output 7 7 3 3 3 7 7 7 7 3 Legionella prevention 3 7 7 3 3 7 7 3 7 3 User comfort 7 7 3 3 3 7 7 3 3 3 Optimal control 7 7 3 3 3 7 7 7 7 3 Booysen et al. [28] determined the theoretical energy savings that can be achieved by the optimal control of EWHs. They used a novel dynamic programming optimisation algorithm on a one-node EWH thermal model to determine the optimal scheduling of an EWH with knowledge of future water demand. Their simulations for 77 residential households for one month achieved energy savings of 8 % for temperature-matching and 18 % for energy-matching strategies. When they modiﬁed the energy matching strategy to prevent Legionella growth, the energy savings were reduced to 13 % . Ritchie et al. [29] built on this earlier work [28] by incorporating a two-node EWH thermal model and determining the energy savings. They developed a novel A* optimisation algorithm to determine the optimal control sequence for a two-node EWH when water demand is predicted. They used a hot water usage model developed in [33] to predict water usage based on historical water usage data and account for household uniqueness and factors that inﬂuence temporal variation. They achieved energy savings of 2:2 %for temperature-matching and 9:6 %for energy-matching strategies. Centralised control Kondoh et al. [30] investigated the potential of a direct-load control strategy that aggregates a load of water to provide a regulation service for the grid. They used a vertically oriented EWH thermal model that has two heating elements. The proposed algorithm controls the power usage of each EWH such that the total usage does not exceed the power limit of the grid. This was achieved by controlling the EWH target temperature and the grid load. A shortcoming of this study was that the algorithm failed to optimise the EWH energy storage to reduce thermal losses and instead tried to store as much thermal energy as possible. Cui et al. [31] presented a direct load control model that uses a cooperative gaming strategy in which the retailer lets the users compete indirectly in the market. This is achieved by dynamically adjusting the power scheduling and bidding strategy to correspond with market information. The model beneﬁts the retailer as risks are reduced and proﬁts increase. However, this model does not account for user comfort or the overall energy usage, and user interaction is required. Roux et al. [3] devised a centralised control of EWHs that takes into account user comfort, peak loads and overall energy usage. They simulated 34 EWHs with schedule control for 28 days. To ensure that the grid’s power limit was not exceeded, the model prioritised the delivery of electricity from the grid to the EWHs according to each EWH’s required time to reach the target temperature from the current temperature and expected time until the next hot water usage. By using a two-node EWH model, they successfully reduced a peak load of 62 kW to 50, 40, 30 and 20 kW with only a slight decline in user comfort. Xiang et al. [32] proposed a direct load control method for EWHs that produced a customer satisfaction prediction index based on a weight matrix. This matrix was calculated from hot water usage patterns and determined the user’s comfort levels. The proposed strategy produced a peak shifting service that ensured user comfort. III. S YSTEM OVERVIEW The aim of the system presented in this study is to minimise three factors: the overall electrical energy used by an individual EWH, the number of times the user experiences cold water temperatures, and the peak loads on the grid as a result of supplying electricity to many EWHs. Figure 2 shows an overview of the system. The software components that make up the system are an optimal EWH schedule planner, a hot water demand predictor, a probabilistic hot water usage model, and a temperature feedback controller. The physical components are an EWH, which is modelled with one-node thermodynamics, and a water mixer, which is simulated as a user who reacts to the initial hot water temperature and adjusts the ratio of cold to hot water to obtain the desired temperature. The utility components are the scheduling model and the grid power supply. The ﬁgure shows the ﬂow diagram for an individual EWH, but the inputs and outputs of the utility components are repeated and connected to all the other EWHs in the grid. Fig. 2: Overview of the components that make up the ﬁnal system. The physical and software components that correspond to the individual EWH and the utility components are speciﬁed. The optimal heating control sequence and corresponding optimal temperature plan are determined by the optimal schedule planner. This component uses an A* search algorithm (developed in [34]) to solve the optimal control problem for a one-node EWH. This component requires the optimisation constraints and heating control strategy to be speciﬁed. A scheduling model uses the optimal EWH plan and corresponding hot water usage proﬁles for all the EWHs connected to the grid to determine a modiﬁed optimal plan that ensures that the power demand does not exceed the grid power limit. This component also ensures that the modiﬁed optimal plan has minimal deviations from the original optimal EWH plan and that the comfort of the user is not negatively affected. The development of this algorithm is presented in Section VI. The temperature feedback controller compensates for when the optimal temperature trajectory deviates from the actual trajectory. It does this by determining the switching state of the heating element so that the internal temperature of the EWH comforms to the set-point temperature provided by the optimal plan. This gives the system the robustness to model uncertainties and reject disturbances such as unanticipated water usage. The temperature feedback controller determines whether power is available from the grid power supply for the individual EWH heating element. The term “power cut” refers to a moment when the temperature feedback controller cannot be provided with power for the EWH to successfully follow the optimal plan. The availability of power for each EWH is prioritised such that there is a fair distribution of power cuts to all the EWHs. The A* optimal schedule planner and scheduling model are performed for predicted hot water usage proﬁles. These proﬁles are produced by a hot water demand predictor which generates predicted water usages based on a probabilistic hot water usage model (refer to [33]). This model is developed from historical hot water usage data which is measured by ﬂow rate sensors. This paper determines the simulation results of the discussed system for a scenario where the A* optimal schedule planner and scheduling model have perfect foreknowledge of hot water usage and also for a scenario where the hot water usages are predicted . IV. EWH M ODEL The EWH is presented as a closed-loop and the feedback is provided by a thermostat. Figure 3 shows the modelling of a one-node EWH where the temperature inside the tank is assumed to be distributed uniformly. The hot water inside the tank can be represented as stored thermal energy, or Etank. When water is drawn from the tank at a volumetric ﬂow rate, Qdraw, and at a higher temperature, Toutlet, than the cold water temperature, Tinlet, in the inlet pipe situated at the bottom of the tank, thermal energy is removed from the tank and replaced by cold water. A heating element supplies electrical energy to increase the tank’s water temperature, Ttank, and the thermal energy. The thermostat measures the temperature of the water and determines the control state of the heating element to maintain the tank at the set-point temperature. Thermal energy loss, Eloss, is energy lost to the surrounding environment due to standing losses and is caused by a temperature difference between the tank and the ambient temperature, Tamband the rate is determined by the thermal resistance of the tank wall, RT. The EWH is presented in this study as a lumped-parameter model and the equations that describe the thermal dynamics were originally formulated by Nel [35]. The rate of change of thermal energy ﬂowing from the tank is deﬁned as follows: _Etank(t) =Pelec(t)Pdraw(t)Ploss(t) (1) wherePelecis the electrical power supplied by the heating element, Pdrawis the power in the hot water that ﬂows from the outlet pipe, and Plossis the power lost from the tank due to the standing losses. The power supplied by the heating element is deﬁned as follows: Fig. 3: One-node EWH showing the energy ﬂow, temperature, volume, ﬂow rate and thermal resistance. Pelec(t)2f0;Pratedg (2) where the “off” or “on” state of the heating element corresponds to delivering either zero power or power equal to the heating element’s rated power, Prated. The power of the hot water drawn from the tank is deﬁned as follows: Pdraw(t) =cPQdraw(t)[Toutlet(t)Tinlet(t)] (3) wherecPis the constant pressure-speciﬁc heat capacity of water and is the density of water. This equation shows that the output power drawn is dependent on the temperature difference of the outlet and inlet water pipes. The power lost from the tank in the form of thermal losses is deﬁned as follows: Ploss(t) =1 RT[Ttank(t)Tamb(t)] (4) This equation shows that the output power lost is dependent on the thermal resistance of the tank and the difference between the temperature of the water and the ambient temperature. Given the temperature of the water, the total thermal energy stored in the tank is calculated as follows: Etank(t) =cV tankTtank(t) (5) whereVtankis the volume of the tank. V. EWH OPTIMISATION This section presents the optimisation algorithm that produces the optimal heating schedule for an individual EWH. We ﬁrst deﬁne the optimal control problem then describe the A* algorithm. The output schedules for determining the grid optimisation of multiple EWHs are described in Section VI. The optimal temperature and heating plan for the one-node EWH are produced by an A* search algorithm. The algorithm was previously formulated for a stratiﬁed two-node EWH model by [34] and is modiﬁed in this study to produce the optimal plan for a one-node EWH. Optimal control problem The optimal control problem is to determine the optimal switching sequence for the heating element to minimise the total electrical energy supplied to the EWH while satisfying a given hot water usage proﬁle. The proﬁle is satisﬁed if the user never experiences a temperature below the minimum usage temperature, Tusage, when hot water is drawn from the tank. The system dynamics are deﬁned by the differential equations that describe the thermodynamics of the one-node EWH, speciﬁed by equations (1), (2), (3), (4) and (5). The state variable of the system is represented by x(t), deﬁned by the thermal energy of the tank, and is deﬁned as follows: x(t) =Etank (6) The state constraints are deﬁned by the physical limitations of the thermal energy of the tank. The lower and upper bounds are represented by EminandEmax. These correspond to the minimum and maximum admissible temperatures, TminandTmax, with a constant volume of Vtank. The control input is represented by u(t)and is deﬁned as Pelec, the electrical power supplied by the heating element. The control input is constrained to a power supply equal to either zero or Prated. The cost function has the objective of minimising the electrical energy and is deﬁned as follows: J=Ztf tiPelec(t)dt (7) wheretiandtfare the initial and ﬁnal time instants. Temperature proﬁle constraints are deﬁned to ensure that the hot water usage proﬁle is satisﬁed. The following inequality represents the objective of the temperature to satisfy the hot water usage proﬁle: Ttank(t)Tproﬁle(t) (8) whereTproﬁle are the constraints imposed and are expressed as follows: Tproﬁle(t) =8 < :Tusage ifQdraw(t)>0 TLegionella once per day Tmin otherwise9 = ;(9) whereTLegionella is the temperature required to prevent the growth of Legionella . These constraints show that the outlet water temperature cannot fall below Tusage during water usage, that the entire tank must be sufﬁciently heated to ensure Legionella prevention, and that the temperature of the water in the tank cannot exceed the minimum temperature, Tmin. A* search algorithm The A* search algorithm is a popular and widely used shortest path search algorithm. It can solve non-linear optimal control problems by creating multiple node-based paths that originate at a starting position and navigate towards a desired ﬁnal position. The algorithm performs efﬁciently as heuristics are introduced to help optimise the decision making. Before the A* search algorithm can be applied to the optimal control problem, the problem must be broken down into discrete time instants and states to represent the decision stages and choices, respectively. Since the hot water usage data is presented with one-minute resolution, equations (1), (2), (3), (4) and (5) are discretised with a per minute sampling period t. The purpose of the algorithm is to ﬁnd the shortest path from an initial state at time instant tito a goal state at time instant tf. At the initial state, the temperature of the entire tank is assumed to be at the starting temperature Tstart. At the goal state, the temperature of the entire tank must be equal to or greater than the ﬁnal temperature Tend. The boundary conditions for the optimal path, TstartandTend, are speciﬁed for the algorithm. A binary search tree data structure is deﬁned to aid the navigation of the search process (more information on the binary search tree data structure can be found in [36]). The binary search tree comprises multiple search paths that navigate from the initial state to the ﬁnal state. The paths are made up of nodes connecting states in the previous time instants to the calculated state in the next time instant as a result of the scenarios where the control input u= 0 andu= 1. Each search path ending calculates a cost that is the sum of two components: the amount of electrical energy that was required to reach its current position and the estimated amount of electrical energy that is still required to reach the ﬁnal state at the ﬁnal time instant. A priority queue keeps track of the cost of all the path endings, prioritises them from lowest to highest cost, determines which path ending is currently the closest to the desired ﬁnal state, and instructs that path (the optimal path) to extend further. The ﬁrst path that reaches the desired state at the ﬁnal time instant is also the optimal path and the algorithm stops executing. With the optimal path having been reached, the optimal temperature trajectory and heating schedule are produced for the given hot water usage proﬁle. Heating control strategies We present three heating control strategies in this study, labelled TC, TM and EML. Thermostat control (TC) : This is the baseline strategy against which we evaluate the energy savings achieved by our other two optimal control methods. This kind of control, the way an EWH typically operates, is extremely inefﬁcient. The water temperature is maintained at the temperature at which the thermostat is set. We therefore expect high standing losses as the water in the tank is always hot, even when no water is drawn for long periods. Temperature-matched optimal control (TM) : This strategy is produced by the A* search algorithm and determines the optimal control of the EWH for a given hot water usage proﬁle. We modify the temperature proﬁle constraints so that the temperature of the water in the tank at the start of each water usage is exactly matched to the temperature that is expected for the same water usage in TC. This strategy ensures that the temperature and energy of the water drawn from the EWH are not compromised by the reduction in the overall electrical energy that is supplied. Energy-matched optimal control with Legionella prevention (EML) : This strategy is similar to the previous strategy, except that the temperature is only constrained to Tusage during water usages. However, the hot water ﬂow rate is increased during water usages to ensure that an equivalent amount of energy is delivered, despite the lower temperature experienced by the user. However, as a lower temperature proﬁle can enable the growth of Legionella inside the tank, we mitigate this health risk by ensuring that the EWH is heated to TLegionella at least once a day. VI. CAC MODEL The previous section described how we produce the optimal heating schedule and temperature trajectory for a single EWH for a given hot water usage proﬁle. This provides the optimal switching sequence to minimise the overall electrical energy used while at the same time avoiding an increase in discomfort for the user. However, this does not take into account the requirements of the grid if all the domestic EWHs are operated at the same time. In this section we propose a solution that satisﬁes the following requirements: The user’s comfort remains at the same level of satisfaction as with the TC strategy. The household’s hot water usage demand is satisﬁed with minimal energy requirements. The grid’s power supply limit is not surpassed by the energy demand of a large number of EWHs. We present a centrally adapted control (CAC) model. This model simulates all the EWHs simultaneously by ﬁrst calculating the new temperature of each tank at the current time instant, and then proceeding to the next time instant. Once all the temperatures have been calculated for the current time instant, the total amount of electrical power used by all the EWHs at that time instant determines whether the grid’s power limit is exceeded. If the power limit is exceeded, the model chooses an individual EWH and time-shifts its heating element schedule backwards in time by one sample. The EWH that is chosen for the time-shift is drawn from the pool of EWHs that have their heating element in the “on” state for the current time instant. A priority queue ensures that the EWH that is chosen will be the one that has currently experienced the lowest number of time-shifts. We ﬁrst deﬁne the optimal scheduling problem and then describe the coordinated scheduling algorithm. To avoid confusion, in this section we refer to the optimal heating schedule for EWH iasuiand the temperature trajectory as Ti. We refer to the centrally adapted optimal heating schedule as u0 iand the temperature trajectory as T0 i. A. Problem formulation: Optimal scheduling problem Given the hot water usage proﬁle in terms of ﬂow rate Qusage,i , the optimal control sequence ui, and the optimal temperature trajectory Tifor many EWHs, and the maximum limit of the grid Plim, we determine the time-shifted optimal control matrix u0and time-shifted optimal temperature matrix T0that minimises the total energy used and satisfy the user’s comfort while ensuring that the overall power usage never exceeds the grid’s power limit at any time instant. Grid optimal control matrix : The grid optimal control matrix is deﬁned such that each row represents the optimal control sequence for a speciﬁc EWH, and is represented as follows: u=2 64u1 ... uI3 75=2 64u11::: u 1tf ......... uI1::: u Itf3 75 (10) whereIis the total number of EWHs and tfis the ﬁnal time instant. The state of the heating element is given as follows: uit=1 if heating element is active for EWH iat timet 0 otherwise (11) whereirefers to the EWH and trefers to the time instant. Grid control constraints The state of the heating elements for all the EWHs at any time instant is constrained such that the total power supply does not exceed the grid’s power limit, and is deﬁned as follows: IX i=1uitPlim8t21;2;:::;t f (12) wherePlimrefers to the grid’s power limit. Grid optimal temperature matrix The grid optimal temperature matrix is deﬁned such that each row represents the optimal temperature trajectory for a speciﬁc EWH, and is represented as follows: T=2 64T1 ... TI3 75=2 64T11::: T 1tf ......... TI1::: T Itf3 75 (13) Grid temperature constraint The grid optimal temperature matrix represents the reference signal that produces the optimal schedule. Since the optimisation of multiple EWHs aims to prevent the number of cold events increasing from the optimal plan, the reference temperature also becomes the constraint proﬁle for each corresponding EWH to ensure that the time-shifted optimal temperature never falls below this temperature proﬁle. The constraint is represented as follows: T0 itTit8i;t (14) When the optimal schedule is time-shifted and the temperature trajectory rises, a constraint prevents the time-shifted temperature from exceeding the maximum admissible temperature, Tmax, and is deﬁned as follows: T0 itTmax8i;t (15) Time-shifting The CAC model determines the best way to shift the heating schedules of the EWHs so as not to exceed the grid’s power limit. Time-shifting a heating schedule means shifting a sequence of samples which starts when the heating element is switched “on” at the current time instant (and switched “off” at the previous time instant), and ends when the heating element is switched “off” at the next time instant (and switched “on” at the current time instant). When an EWH needs to shift its heating schedule at a time instant because the grid’s power limit is exceeded, the shift must be backwards in time because a forward shift would result in more occurrences of cold events. The heating schedule must also shift by one sample at a time to ensure the minimal amount of shifting is required. This is because time-shifting the heating schedule will increase the EWH temperature to the temperature that was desired earlier. The temperature thus remains higher than the optimal temperature and the EWH’s energy savings from the optimal plan will be reduced because of higher standing losses. Time-shifting the heating schedule also increases the likelihood of the time-shifted temperature dropping below the grid temperature constraints, deﬁned by equation 14. In this event, the algorithm will add an extra sample with the heating element switched “on” after the time shift has occurred. Time-shift vector The time-shift vector is the total number of time-shifts that have occurred for each EWH, and is represented as follows: dT= [d1;d2;:::;d I] (16) wherediis the time-shift index for EWH ithat represents the total number of time-shifts that have been applied to its optimal heating schedule. EWH prioritising Given the time-shift vector, and the power limit being exceeded at time t, the EWH that is picked for time-shifting its heating schedule is determined by prioritising all the EWHs that have their heating elements in the “on” state at this time. The highest priority EWH has the smallest time-shift index. Cost function In Section V , the cost function for the optimal control problem of an individual EWH was deﬁned as follows: J=Ztf tiPelec(t)dt (17) This produced the optimal plan that minimises the overall electrical energy. However, time-shifting deviates the temperature trajectory away from the optimal path and increases the electrical energy usage. We deﬁne a new cost that minimises the occurrence of time-shifts. This also minimises the additional overall electrical energy used. For the optimal scheduling problem, the new cost function is deﬁned as follows: J0=IX 1di (18) B. Algorithm initialisation 1) Obtain the optimal heating scheduling and temperature trajectory matrices, as deﬁned in Section VI, as follows: u=2 64u11::: u 1tf ......... uI1::: u Itf3 75 T=2 64T11::: T 1tf ......... TI1::: T Itf3 75 2) Create matrices that represent the optimal heating schedule and temperature trajectory that will be populated by the algorithm execution, as follows: u0=2 64u0 11::: u0 1tf......... u0 I1::: u0 Itf3 75 T0=2 64T0 11::: T0 1tf......... T0 I1::: T0 Itf3 75 3) Create an array to represent the time-shift index for each EWH, as follows: d= [d1;d2;:::;d I] 4) Populate the optimal heating schedule matrix, temperature trajectory matrix and time-shift array, as follows: u0 it uit8i;t T0 it 08i;t di 08i 5) Populate the ﬁrst column of T0with the corresponding column of T, as follows: T0 i1 Ti18i 6) Assign time tto the second sample, as follows: t 2 C. Algorithm execution 1) Calculate the power and temperature for all EWHs at the current time instant, using equations (1) and (5), as follows: _E0 tank i,t(t) =u0 itPratedPdraw(t)Ploss(t) T0 i,t(t) =E0tank i,t(t) cV tank 2) Check that the power limit is not exceeded for the current time sample, as follows: IX i=1u0 itPlim8t21;2;:::;t f If the constraint is not satisﬁed, go to the next step. Otherwise, go to step 5. 3) For this step, only consider the EWHs that satisfy the following requirements: 1) the heating element is switched “on” at the current time instant, 2) the temperature proﬁle does not exceed the maximum admissible temperature of the tank, as expressed for EWH ias follows: T0 itTmax8t To identify the EWH iwith the highest priority, determine the entry of the time-shift vector with the lowest value, di. 4) In this step, time-shift the heating schedule of the prioritised EWH i. Set the control state of the heating element at the current time instant tto zero, as follows: ui;t 0 Next, determine the start of the considered switching sequence (the most recent time instant which switches the heating element “on”) and indicate it is as time instant ts. Switch the heating element “on” for the previous time instant, as follows: ui;ts1 1 and increment the time-shift index for EWH i, as follows: di di+ 1 Next, simulate EWH iforwards in time and ensure that the temperature proﬁle constraint is satisﬁed, as follows: T0 itTit8t If the constraint is not satisﬁed, extend the switching sequence further and backwards in time to ensure that this constraint is satisﬁed, as follows: ui;ts2 1 and set the current time instant, as follows: t ts2 TABLE II: Table of parameters used to obtain the results. Symbol Description Value Unit EWH model parameters  Density of water 1000kg m3 c Speciﬁc heat capacity of water 4184J kgK RTH Tank thermal resistance 0.4807Kday kWhTinlet Inlet water temperature of EWH 20 ° C Tamb Ambient air temperature 20 ° C Tset Target temperature 68.5 ° C Thyst Hysteresis (deadband) 1:5 °C Vtank Tank volume 150 L Prated Power rating of heating element 3 kW Optimisation parameters Tmin Minimum water temperature 20 ° C Tmax Maximum water temperature 70 ° C Ttank(use) Minimum target usage temperature 40 ° C Tstart Initial water temperature 68.5 ° C Grid parameters Number of water heaters 77 Plim Grid power limit 1, 0.8, 0.6, 0.4, 0.2kW EWH Water draw dataset D Duration 20 days t Sampling period 1 min Resolution 0.5 L Otherwise, set the current time instant, as follows: t ts1 5) Iftis at the ﬁnal time instant tf, stop the algorithm execution. Otherwise, go to step 1. VII. E XPERIMENTAL SETUP This section describes the experimental setup and components that are required for obtaining the simulation results in Section VIII. We describe the acquisition and characteristics of the hot water usage data set, the temperature feedback controller and hot water mixer and user, and the simulation setup. A. Hot water usage proﬁles The hot water usage data we use to determine the optimal control schedule was obtained from 77 households in South Africa using Smart EWH Controller devices [37]. The hot water proﬁle for each household consists of water ﬂow-rate data recorded per minute over four weeks, one week for each season, to take into account seasonal variations in household hot water usage behaviour [22], [38]–[41]. B. Temperature feedback controller The temperature feedback controller ensures that the measured outlet temperature of the simulated EWH follows the optimal temperature trajectory generated by the scheduling model. The controller does this by directly controlling the state of the heating element. It also determines whether power is available from the grid for use when additional power is required for the measured temperature to follow the optimal plan. Additional power is supplied to any EWH that is unable to meet its temperature requirements and is distributed evenly among all the EWHs. C. Hot water mixer and user The hot water mixer and user simulates the user experiencing the hot water outlet temperature and adjusting the ratio of hot to cold water to obtain the desired temperature. This is implemented for the simulator to ensure that all the EWHs in all three heating control strategies deliver the same amount of thermal energy. D. Simulation setup The software implementation (presented in Jupyter Notebook), simulation results, and hot water draw data are provided at https://dx.doi.org/10.25413/sun.16669651. E. Simulation parameters Table II lists the constants, parameters and water draw dataset used for the optimal scheduling and simulations. F . Metrics We use the term events to refer to aggregated water usage. An event starts and ends when the tap is opened (a zero ﬂow-rate sample is followed by a positive ﬂow-rate sample) and closed (a positive ﬂow-rate sample is followed by a zero ﬂow-rate sample). This deﬁnition allows water draw to be quantiﬁed into bundles and provides a simple way of referring to sections of water usage patterns. We use the term cold event for a water event where the user experiences an undesired temperature (i.e. if the temperature drops below Tusage). We count the number of cold events for the two optimal heating control strategies, TM and EML, compared to the baseline TC strategy. Tables III and IV show distributions of the daily amount of electricity used, thermal energy drawn, thermal energy losses, and outlet temperature at the start of water events for all 77 EWHs. The daily average amount of electricity used by a single EWH is determined using Pelecjh=PNh k=1Pelecjh(k)t DkWh/day (19) wherePelecjhis the daily average electricity used by water heater h,Pelecjh(k)is the instantaneous power used by water heater hat time instant k,Nhis the total number of samples, tis the sampling period, and Dis the total number of days. Similar equations are also used to calculate the daily average thermal energy used, Pdrawjh, and thermal energy loss, Plossjh. The distributions of the daily electrical energy savings for each control strategy are shown in Tables III and IV. These are expressed as a daily reduction in kWh and as a percentage. The energy savings are determined by comparing a particular control strategy with the baseline TC strategy. Using TM as an example, the daily energy savings for an individual EWH are calculated using the following equations: Pelecjh;TM(kWh/d ) =Pelecjh;TCPelecjh;TMkWh/day (20) Pelecjh;TM(%) =Pelecjh;TCPelecjh;TM Pelecjh;TC100% (21) We deﬁne a metric that measures the reduction in electrical energy savings for simulations of the centrally-adapted optimal control plans when compared to the identical simulations but with no set grid power limit. This is determined for the worst, average and best cases of reductions that were achieved for an individual EWH, as shown in Table V. We deﬁne a metric that measures the extremity of peaks in the grid’s electrical power demand proﬁle. The peak-to-average power ratio (PAPR) is calculated by dividing the peak value squared by the root mean square value squared, and is shown as follows: PAPR =jxpeakj2 xrms2(22) and is expressed in decibels as follows: PAPR dB= 10 log10jxpeakj2 xrms2(23) We express the power limit of the grid as the average amount of electrical power that is available for each EWH at any instant. We therefore express the grid limit askW EWHinstead of the overall power limit expressed in kW. We use power limits that range from 1 to 0.2kW EWHwith decrements of 0.2kW EWH. VIII. R ESULTS This section describes all the results obtained from the simulations. Tables III and IV show the results obtained with perfect foreknowledge of hot water usages and with predicted hot water usages. Figure 4 compares the simulation results for an identical EWH for the TC, TM and EML heating control strategies for a typical day’s usage proﬁle. Thermostat control (TC): The EWH temperature is always maintained at the set-point temperature (with hysteresis). If the temperature drops below this point, the heating element is switched on to raise it again. When the ﬁrst water usage occurs at t= 9, the temperature drops signiﬁcantly. The heating element is switched on and provides electrical power until the set-point temperature is reached. This water usage also resulted in a cold event since the temperature dropped below the cold event threshold. The electrical power consumption over the 48 hours for this strategy was 23:9 kWh . Temperature-matched optimal control (TM): The EWH temperature matches the corresponding temperature for TC at the start of each water usage, but remains lower than the TC temperature between water usages. A cold event is observed at t= 9. The electrical power consumption over the 48 hours for this strategy was 16:7 kWh . Energy-matched optimal control (EML): The EWH temperature remains above the cold event threshold temperature during water usage. The outlet ﬂow rate is increased so that more hot water is drawn from the EWH and the user mixes it with less cold water. The temperature remains lower than that of the TC and TM strategies between water usages. Since the temperature remains low for long periods, the EWH temperature is increased just before the largest water usage for the day to ensure the prevention of Legionella . It remains above 60°Cfor11 min att= 41 . The electrical power consumption over the 48 hours for this strategy was 16:1 kWh . (a) TC (b) TM (c) EML Fig. 4: Simulation results for identical EWHs for the TC, TM and EML heating control strategies over a 24-hour period. Each plot shows the EWH temperature (black), the outlet ﬂow rate (blue) and the heating element state (red). The temperature for TC is repeated in the other two plots for comparison. The cold event temperature ( 40°C) and the Legionella prevention temperature ( 60°C) are indicated with blue and red dashed lines, respectively. Figure 5 shows the temperature trajectory for an individual EWH for the optimal plan (red) and the time-shifted optimal plan (blue) when the grid power limit is 0.4 kW/EWH. The time-shifted optimal plan delays the heating schedule at 7 am, during the morning peak hours, because it increases the temperature earlier (at 3 am) than the optimal plan, which increases it at 7 am. This results in the temperature of the tank for the time-shifted optimal plan remaining higher than the temperature for the non-shifted optimal plan and the energy savings are reduced because of higher standing losses. Figure 6 shows the grid power demand over 24 hours for various grid power limits for the TM and EML heating control strategies. For TM, only the morning peak is ﬂattened when the grid limit is 0.6 kW/EWH or above. The evening peak only begins to ﬂatten for a grid limit of 0.4 kW/EWH or below. For a grid limit of 0.2 kW/EWH, the power demand remains at a constant level equivalent to the grid limit. This shows that the full power supply is used throughout the day. Comparing all the grid power limits, we see that ﬂattening a peak pushes the excess power demand further back in the day. The results for EML are similar to those for TM but because the evening peak is higher, it ﬂattens when the grid limit is set as high as 0.6 kW/EWH. Table III summarises the simulation results for all 77 EWHs when the three heating control strategies have perfect fore- knowledge of water usage. A dash in the power limit column indicates simulations with no set power limit. Fig. 5: Temperature plot over a 24-hour period for an individual EWH for the optimal temperature trajectory (red) and the time-shifted temperature trajectory (blue). (a) TM (b) EML Fig. 6: Grid power load (kW/EWH) for various grid limits (kW/EWH) over a 24-hour period for the various heating control strategies. The dash symbol indicates that no grid limit is set. Simulation results for TC : The median electricity usage for TC was the highest of all the control strategies at 5.94 kWh/day. This is because it had the highest median energy losses of 2.22 kWh/day. The median usage temperature was 68.0 ° C, which shows that this strategy maintained the temperature at the 68:5°Cset-point. The median energy used was 3.36 kWh/day. The PAPR for the overall grid power demand was 17.62 dB, which indicates that the proﬁle must have had many high peaks during the day, given the average power it required throughout the day. Simulation results for TM : When there was no set power limit, the median energy used was 3.37 kWh/day. The median electricity used was 5.46 kWh/day. This resulted in a distribution of energy savings, given as [ 25thpercentile ,median ,75th percentile ], of [ 0.28,0.44,0.64] kWh/day ([ 3.92,6.22,9.66]%). These savings were achieved because the median energy losses were reduced to 2.22 kWh/day. The distribution of the increased number of cold events, given as [ min,25thpercentile , median ,75thpercentile ,max], was [ 0,0,0,0,3]. The PAPR decreased to 11.53 dB. When the power limit was set to 1, 0.8, and 0.6 kW/EWH, the PAPR was reduced to 8.66, 6.82, and 4.63 dB. Despite the signiﬁcant impact these power limits had on ﬂattening the peaks, the rest of the results showed negligible changes, as can be seen in Figure 6a, where only the tip of the morning peak is ﬂattened, representing only a small portion of the overall demand. For a power limit of 0.4 kW/EWH, the energy savings are reduced to [ 0.19,0.38,0.54] kWh/day ([ 2.76,5.03,8.37]%) because the median usage temperature increased to 68.6 ° C. This is a consequence of time-shifting larger portions of the demand and rising usage temperatures. The PAPR decreased to 1.98 dB. We see the most signiﬁcant changes when the power limit was set to 0.2 kW/EWH. The median usage temperature dropped to 44.5 ° C, increasing the energy savings to [ 1.51,2.19,3.0] kWh/day ([ 27.37 ,34.08 ,47.56 ]%). However, the signiﬁcant drop in usage temperature increased the number of cold events to [0,3,9,24,137]. The PAPR decreased to 0 dB, meaning that the demand proﬁle was ﬂat throughout the day. Simulation results for EML : As with TM, the median energy used remained the same for all simulations. When there was no set power limit, the median electricity used was 4.95 kWh/day, which was less than that used by the simulations of TC and TM. The energy savings were [ 0.76,0.86,0.94] kWh/day ([ 7.88,16.81 ,21.27 ]%). Since the usage temperature did not have to match that of TC at the start of water usage, the median usage temperature was 54.2 ° C. This resulted in the median energy losses decreasing to 1.65 kWh/day. Again as with TM, the number of cold events increased to [ 0,0,0,0,3]. The PAPR was 11.98 dB. When the power limit was set to 1, 0.8, 0.6, 0.4, and 0.2 kW/EWH, the PAPR reduced to 9.16, 7.28, 4.93, 2.22 and 0 dB. However, the simulation results begin to show changes when the power limit is 0.6 kW/EWH. This can be explained by observing Figure 6b, where the evening peak is larger for EML than that of TM. Therefore, a larger portion of the grid is shifted for a power limit of 0.6 kW/EWH and below. When the power limit is set to 0.6 and 0.4 kW/EWH, the median usage temperature increased to 54.8° Cand 62.6° C. The energy savings respectively decreased to [ 0.72,0.78,0.87] kWh/day ([7.56,14.31 ,20.12 ]%) and [ 0.45,0.64,0.74] kWh/day ([ 5.38,11.72 ,17.88 ]%). For a power limit of 0.2 kW/EWH, the median usage temperature dropped to 37.9° Cand the energy savings increased to [ 2.11,2.62,3.27] kWh/day ([ 34.37 ,45.83 ,55.29 ] %). Similarly to TM, this is because there is insufﬁcient power for the grid to supply to all the EWHs. The energy savings were [ 1.51,2.19,3.0] kWh/day ([ 27.37 ,34.08 ,47.56 ]%) and the number of cold events increased to [ 0,9,21,42,130]. TABLE III: Simulation results when the planner has perfect foreknowledge of hot water usages for 77 EWHs. Power limit (kW= E)Tusage (°C) Electricity used (kWh=day )Energy used (kWh=day )Energy loss (kWh=day )Energy savings (kWh=day )Energy savings (%)Cold events* PAPR (dB) Thermostat control - 66.0,68.0,68.6 4.09 ,5.94,10.02 1.63 ,3.36,7.37 2.41 ,2.42,2.42 - - - 17.62 Temperature matching - 66.0,68.0,68.7 3.66 ,5.46,9.39 1.64 ,3.37,7.39 2.05 ,2.22,2.32 0.28 ,0.44,0.64 3.92 ,6.22,9.66 0 ,0,0,0,3 11.53 1 66.0,68.1,68.8 3.66 ,5.46,9.39 1.64 ,3.37,7.39 2.05 ,2.22,2.32 0.27 ,0.44,0.64 3.80 ,6.25,9.66 0 ,0,0,0,3 8.66 0.8 66.0,68.2,68.7 3.67 ,5.46,9.39 1.64 ,3.37,7.39 2.05 ,2.21,2.32 0.28 ,0.44,0.64 3.56 ,6.22,9.27 0 ,0,0,0,3 6.82 0.6 66.3,68.1,68.7 3.68 ,5.46,9.39 1.64 ,3.39,7.44 2.06 ,2.20,2.32 0.27 ,0.45,0.63 3.91 ,6.22,9.35 0 ,0,0,0,3 4.63 0.4 66.8,68.6,70.0 3.83 ,5.59,9.56 1.64 ,3.42,7.64 2.15 ,2.31,2.42 0.19 ,0.38,0.54 2.76 ,5.03,8.37 0 ,0,0,0,4 1.98 0.2 34.8,44.5,53.7 2.16 ,3.91,7.28 1.6 ,3.29,7.29 1.05 ,1.25,1.62 1.51 ,2.19,3.00 27.4 ,34.1,47.6 0 ,3,9,24,137 0.0 Energy matching with Legionella prevention - 52.0,54.2,57.5 3.20 ,4.95,9.26 1.64 ,3.36,7.38 1.57 ,1.65,1.77 0.76 ,0.86,0.94 7.88 ,16.81 ,21.27 0 ,0,0,0,3 11.98 1 52.0,54.2,57.5 3.21 ,4.96,9.26 1.64 ,3.36,7.38 1.57 ,1.65,1.77 0.76 ,0.86,0.94 7.88 ,16.69 ,21.19 0 ,0,0,0,3 9.16 0.8 52.0,54.2,57.5 3.20 ,4.96,9.26 1.64 ,3.36,7.39 1.57 ,1.65,1.78 0.76 ,0.84,0.93 7.78 ,16.69 ,21.19 0 ,0,0,0,3 7.28 0.6 52.4,54.8,57.7 3.30 ,5.0,9.30 1.64 ,3.39,7.43 1.62 ,1.69,1.80 0.72 ,0.78,0.87 7.56 ,14.31 ,20.12 0 ,0,0,0,3 4.93 0.4 60.5,62.6,64.2 3.38 ,5.15,9.36 1.65 ,3.43,7.72 2.04 ,2.10,2.22 0.45 ,0.64,0.74 5.38 ,11.72 ,17.88 0 ,0,0,0,3 2.22 0.2 35.1,37.9,43.7 1.86 ,3.05,6.78 1.62 ,3.35,7.39 0.92 ,1.08,1.22 2.11 ,2.62,3.27 34.4 ,45.83 ,55.3 0 ,9,21,42,130 0.0 Note: i) A dash in the power limit column indicates simulations with no set power limit. ii) The distributions are reported as 25thpercentile, median ,75thpercentile . iii) * The distributions for cold events are reported as min, 25thpercentile, median ,75thpercentile, max . Table IV shows similar results to the previous table with the exception that the three control strategies have predicted water usages. Simulation results for TM : When there was no set power limit, the median outlet temperature was 62.6° C. This is a decrease from the 68.1° Cobtained for TC because of water usage predictions. If water usage occurs for the actual proﬁle and not for the predicted proﬁle, the EWH temperature may not be at the desired temperature at the start of a water usage. The energy savings were [ 0.34,0.53,0.89] kWh/day ([ 3.22,4.68,7.44]%). The number of cold events increased to [ 0,0,0,0,40]. When the power limit was set and lowered, the usage temperatures continued to drop and the number of cold events signiﬁcantly increased. When the power limit was 0.2 kW/EWH, the number of cold events increased to [ 0,14,38,75,194]. Simulation results for EML : When there was no set power limit, the median outlet temperature was 48.7 ° C. The energy savings were [ 0.91,1.15,1.47] kWh/day ([ 8.86,11.82 ,15.51 ]%). Since the outlet temperature did not need to match that of TC at any time of the day, the number of cold events increased to [ 0,0,6,29,64]. We see a similar trend to that of TM as the power limit is set and lowered. When the power limit was 0.2 kW/EWH, the number of cold events increased to [0,23,39,82,195]. Table V shows the percentage point reduction in energy savings for the simulation results of the CAC model when compared to simulations where there was no set power limit. The ﬁrst column shows the grid power limits for the TM and EML heating TABLE IV: Simulation results when planning has predicted water usages for 77 EWHs. Power limit (kW= E)Tusage (°C) Electricity used (kWh=day )Energy used (kWh=day )Energy loss (kWh=day )Energy savings (kWh=day )Energy savings (%)Cold events* PAPR (dB) Thermostat control - 66.0,68.1,68.8 6.66 ,11.01 ,20.09 4.08 ,8.4,17.11 2.36 ,2.41,2.42 - - - 17.62 Temperature matching - 59.1,62.6,64.7 6.22 ,10.41 ,18.47 4.11 ,8.41,17.22 2.01 ,2.16,2.28 0.34 ,0.53,0.89 3.22 ,4.68,7.44 0 ,0,0,0,40 6.94 1 57.5,62.0,64.2 6.21 ,10.39 ,18.46 4.10 ,8.41,17.18 1.98 ,2.14,2.26 0.37 ,0.58,0.91 3.32 ,4.78,7.38 0 ,0,0,1,41 4.19 0.8 56.0,60.2,62.7 6.19 ,10.34 ,18.41 4.08 ,8.41,17.15 1.93 ,2.11,2.22 0.44 ,0.62,0.97 3.67 ,5.36,8.09 0 ,0,0,3,43 2.52 0.6 50.1,55.2,58.8 5.45 ,9.59,17.93 4.08 ,8.40,17.11 1.73 ,1.91,2.06 0.68 ,1.14,1.71 5.75 ,8.20,16.8 0 ,0,3,12,77 0.94 0.4 28.1,40.8,52.6 4.41 ,8.89,14.78 4.08 ,8.40,17.08 0.84 ,1.19,1.6 1.51 ,2.46,5.14 19.6 ,24.90 ,36.8 0 ,6,15,58,194 0.08 0.2 11.1,16.9,38.7 3.67 ,5.34,6.34 4.10 ,8.39,17.21 0.82 ,0.90,1.03 2.54 ,6.43,13.66 40.9 ,65.73 ,72.7 0 ,14,38,75,194 0.0 Energy matching with Legionella prevention - 44.5,48.7,52.3 5.61 ,9.76,18.28 4.08 ,8.40,17.09 1.32 ,1.49,1.67 0.91 ,1.15,1.47 8.86 ,11.82 ,15.51 0 ,0,6,29,64 7.49 1 44.4,48.7,52.3 5.61 ,9.69,18.26 4.08 ,8.40,17.09 1.31 ,1.48,1.66 0.98 ,1.22,1.68 9.40 ,13.23 ,16.41 0 ,0,6,29,64 4.71 0.8 44.0,47.9,51.5 5.52 ,9.73,18.10 4.08 ,8.4,17.09 1.28 ,1.46,1.65 1.14 ,1.35,1.79 10.1 ,13.71 ,18.7 0 ,1,7,31,68 3.03 0.6 40.4,44.8,49.4 5.04 ,8.96,17.31 4.08 ,8.40,17.08 1.14 ,1.35,1.59 1.26 ,1.75,2.29 12.7 ,17.02 ,25.0 0 ,5,11,40,93 1.31 0.4 26.8,34.9,40.5 3.97 ,7.78,14.22 4.08 ,8.40,17.08 0.80 ,0.99,1.18 2.24 ,3.0,5.59 26.0 ,31.89 ,37.7 0 ,15,31,64,135 0.18 0.2 11.7,17.6,33.2 2.89 ,5.29,6.64 4.08 ,8.46,17.20 0.78 ,0.86,0.95 3.17 ,6.47,12.91 51.1 ,62.80 ,69.9 0 ,23,39,82,195 0.0 Note: i) A dash in the power limit column indicates simulations with no set power limit. ii) The distributions are reported as 25thpercentile, median ,75thpercentile . iii) * The distributions for cold events are reported as min, 25thpercentile, median ,75thpercentile, max . control strategies, and the next three columns show the results for the worst, average and best cases for an EWH. For both of these heating control strategies, the average and best cases show no reductions in energy savings for grid limits of 0.8 kW/EWH and above. Otherwise, there is an increased reduction as the limit becomes lower. However, at grid limits of 0.4 kW/EWH and 0.2 kW/EWH the reduction in energy savings becomes negative, indicating an increase in the energy savings. This is caused by an insufﬁcient supply of power to satisfy all the EWH optimal temperature trajectories that have been time-shifted according to priority. Although we see the increased energy savings as a positive outcome, we acknowledge that they would also result in a higher risk of cold events, as can be seen in Tables III and IV. These results represent a scenario where there is insufﬁcient power supply to satisfy the users comfort for all the EWHs, regardless of how the heating control plan is scheduled. TABLE V: Percentage point reductions in energy savings for the simulation results of the time-shifted optimal plan compared to simulations where there was no set power limit. Power limit (kW)Worst case Average case Best case Temperature matching 1 0.26 0.0 0.0 0.8 0.46 0.0 0.0 0.6 1.01 0.04 0.0 0.4 5.75 1.47 -1.54 0.2 -9.16 -27.73 -72.14 Energy matching with Legionella prevention 1 0.41 0.0 0.0 0.8 1.09 0.10 0.0 0.6 4.54 0.59 0.0 0.4 11.58 3.81 -3.08 0.2 -6.63 -27.64 -52.92 Discussion of results Determining the optimal control for an individual EWH for a given water proﬁle with perfect foreknowledge of usages achieves the absolute best energy savings while not compromising the comfort of the user, as proven in [28]. However, there are signiﬁcant demand peaks in the morning and evening. These are evident in the PAPR of the grid demand for 77 EWHs when there is no set power limit. Table III shows that the PAPR for TM and EML was 11.53 and 11.98 dB. With the CAC model developed in this paper, the optimal control plan for each EWH can be adjusted to satisfy the power limits of the grid. There is no increase in the number of cold events when the power limit is set to as low as 0.4 kW/EWH. At this power limit, for TM the energy savings were [ 0.19,0.38,0.54] kWh/day ([ 2.76,5.03,8.37]%) and for EML [ 0.45,0.64,0.74] kWh/day ([ 5.38,11.72 ,17.88 ]%). Table V shows that when a power limit is set, for TM there is a percentage point decrease in energy savings of 5.75 and 1.47 for the worst and average cases and an increase of 1.54 for the best case, and for EML there is a percentage point decrease in energy savings of 11.58 and 3.81 for the worst and average cases and an increase of 3.08 for the best case. If the power limit is set lower than 0.4 kW/EWH, both of these heating control strategies fail to satisfy the optimal temperature trajectory and the number of cold events signiﬁcantly increases. The increase in the number of cold events was [ 0,3,9,24,137] for TM and [ 0,9,21,42,130] for EML. When the optimal plan predicts water usages, the simulations already fail to satisfy the optimal temperature trajectory when there is no set power limit. Table IV shows that the number of cold events increased to [ 0,0,0,0,40] for TM and [0.0,0,6,29,64] for EML. The corresponding energy savings were [ 0.34,0.53,0.89] kWh/day ([ 3.22,4.68,7.44]%) for TM and [ 0.91,1.15,1.47] kWh/day ([ 8.86,11.82 ,15.51 ]%) for EML. When the power limit is set and lowered, the simulations perform even worse and the number of cold events drastically increases still further for both heating control strategies. IX. C ONCLUSION In this paper, we ﬁll the gap left by other models for optimal EWH control. Our CAC model creates a balance between the needs of the user and those of the utility by modifying the optimal control schedule of individual EWHs to spread the load into off-peak periods so that the power supply limit of the grid is not exceeded and the user’s comfort is not reduced. We performed simulations for 77 EWHs over the four seasons, one week for each season. We developed a simulator that simultaneously controls all the EWHs with their corresponding optimal control schedules to obtain the results when the power limit is set to 1, 0.8, 0.6, 0.4 and 0.2 kW/EWH. We ﬁrst performed simulations for the scenario where the CAC model had perfect foreknowledge of water usage. The results show that the grid power limit can be set as low as 0.4 kW/EWH to ensure that the number of cold events does not increase. For this power limit, the median energy savings were 0.53 kWh/day (4.68 %) for TM and 1.15 kWh/day (11.82 %) for EML. Furthermore, the percentage point reduction in energy savings from simulations with no set power limit for the average case was small, at 1.47 for TM and 3.81 for EML. We performed further simulations for the scenario where the CAC model predicted water usages. Even when there was no set power limit, the number of cold events increased from that of TC with a distribution of [ 0,0,0,0,40] for TM and [0,0,6,29,64] for EML, and the median energy savings were 0.53 kWh/day for TM and 1.15 kWh/day for EML. Setting a power limit further increased the number of cold events. In future work, the CAC model, which minimises peak load, energy usage and user discomfort, could be implemented in a real-world scenario if hot water usage can be better predicted and the model is modiﬁed to improve its robustness to mispredictions. ACKNOWLEDGMENT We thank the following organisations for funding: MTN (S003061), the WRC (K1-7163) and Eskom (TESP-2019).