—Electric water heaters (EWHs) remain one of the main contributors to energy consumption in countries where they are used. EWH models serve as a step towards achieving optimised control, and can also be used to inform users of expected savings due to changes, if the model is energy-based. Various models have been proposed, but none of them include more than half of the six key features that the model presented in this paper supports: horizontal orientation; schedule control; low computational complexity; validation of the model; multinodal stratiﬁcation; and multinodal standing losses. The presented model is validated against six datasets: four comprising 900 hours with multiple water usage events; and two with only standing losses. The results show that the model estimates energy consumption over ten days including usage with an error of less than 2% and 5% for schedule control and thermostat control respectively. The simulation model is simple enough to execute ten days of simulation in less than 100 milliseconds on a standard desktop machine, 150 times faster than a prominent model from literature, making it also suitable for large scale simulations or for use on mobile devices. I. I NTRODUCTION Electricity grids in many developing countries are strug- gling to meet the ever increasing demand. For example, in South Africa rolling blackouts are implemented during peak hours to ensure that the national demand does not exceed the supply. Many utilities are investing in smart grid technologies and the use of demand-side management (DSM) as potential solutions. DSM aims to balance the supply and demand of the electricity grid by modifying the shape of the load curve (e.g. valley ﬁlling and peak shaving) through activities that inten- tionally modify consumer electricity consumption patterns [1]. The strongest argument for implementing DSM programs is for the deferral of costly infrastructure development [2]. DSM load control techniques can be classiﬁed into two broad categories based on the entity that is responsible for the control decisions. Direct (or centralised) load control refers to the remote control of customer appliances (e.g. water heaters) by a utility for the purposes of peak demand reduction or emergency situation handling [1]. Indirect (or decentralised) load control includes the involvement of consumers and provides them with the choice to participate in load reduction efforts. Customers are incentivised (e.g. through discounted rates) to reduce their electricity usage during peak periods or shift their demand to off-peak periods, often referred to as demand response [3], [4]. Residential electric water heaters (EWHs) are opportune appliances for demand response (DR) due to their ability to store thermal energy for prolonged periods of time withoutsigniﬁcant heat loss [5]. If customers are expected to par- ticipate actively in load management efforts, DR programs should increase consumers’ understanding of the beneﬁts of participation and improve their capability to participate [4]. Additionally, utilities need a means of estimating the effect of implementing DSM or DR programs as the optimal switching of thousands EWHs is not a trivial task. For example, if all EWHs are disconnected during the same period, a temporary over-consumption will be created at reconnection [6]. This is known as the cold load pick-up and can increase the aggregate power demands (due to loss of diversiﬁcation in the load) [6]. Furthermore, inefﬁcient management of EWHs can lead to unnecessary additional energy consumption by individual EWHs. For example, if a consumer only requires warm water in the morning, heating water in the evening is redundant and leads to increased standing losses. Also, if time- of-use tariffs are implemented, the energy cost of individual EWHs can be signiﬁcantly increased if the switching times are not co-ordinated accordingly. The intelligent EWH system, presented in [7], allows users to control the on and off times of their EWHs in 15-minute intervals as well as adjust the temperature setpoint. Energy and warm water usage is measured by the system and reported on a minutely basis to a data server. This control functionality, as well as monitoring of energy and warm water usage, can be performed through an online interface or via a smartphone application [7], [8]. The model presented in this paper is intended to be a computationally inexpensive EWH model that can be used by the smartphone application in [8] to provide users with instantaneous feedback on the effect of various control settings (e.g. decreasing set temperature) on the energy consumption of their EWH. A consumer’s water usage proﬁle can be obtained from the historical data stored on the data server to determine an accurate estimate of the overall energy usage of the EWH during the course of a day. The smartphone application could also be used by utilities to push real-time pricing information to consumer devices that could then use the proposed model to calculate and convey the potential monetary savings to consumers as a result of participation. Moreover, the model’s simplicity makes it well suited to the evaluation of DSM programs. In order for either of these tasks to be accomplished, an accurate and simple EWH model is required. The models available in literature are too inaccurate, too complex or limited to their application to vertically orientated EWHs only. For example, a one-node model, which assumes a uniform tank temperature, is presented by Dolan et al. [9] However, when usage events occur, the cold water entering the tank causes thermal stratiﬁcation of the water to occur, separating the higher density warm water from the lower density cold water [10]. Therefore, the one-node model no longer accurately models the temperature distribution in the EWH tank after a usage event has occurred, which will result in an underestimation of the outlet temperature, and consequently of the energy lost during usage events. The mixing layer in between the warm and cold nodes is called the thermocline and it moves along the height of the EWH tank during water usage and heating events [10]. To more accurately model the stratiﬁcation that occurs as a result of water withdrawal, two-nodes are used to model the warm and cold water layers separately. Although two-node models are presented in literature [11], [12], they do not take into account the nonlinear relationship between the nodes’ volumes and the exposed surface areas apparent in horizontal EWHs, and their accuracies have not been validated against measured data. Additionally, to the authors’ knowledge, there has been no validation, against real-world measurements, of a model that predicts the energy usage of an EWH under schedule control. In comparison to thermostat control, during schedule control the EWH is only allowed to heat the water in the tank during active times. A. Contribution The contributions of this paper are summarised in Ta- ble I. This paper presents a theoretical simulation model for an EWH for: two-node analysis of a horizontally orientated EWH with a varying thermocline position to accommodate horizontally oriented EWHs; calculating the standing losses for each node in the two-node state for both vertically and horizontally (varying exposed surface area) orientated EWHs; simulating the effect of implementing a schedule that controls the on and off times of the EWH. Additionally, the model is computationally inexpensive, and therefore suited to be used on a mobile device with limited processing power and battery capacity, and for evaluation of DSM programs where the behaviour of thousands of EWH devices must be simulated. The model takes approximately 100 milliseconds to perform a 10-day simulation for a single EWH on a standard desktop machine. Assuming each EWH takes 100 milliseconds to simulate over 10 days, it would take 100 desktop machines only 10 seconds to run a 10-day simulation for 10 000 EWHs. This is approximately 13 000 times faster than the existing PDE models, and 150 times faster than the existing one- and two-node models discussed in section II, despite the fact that they only support the simpler vertical orientation. The presented model scales better due to its lower computational complexity and because it is well-suited to evaluating the impact of DR programs for large numbers of EWHs (as would typically be required). Existing papers present thermal models and validates against temperature measurements. Additionally, the datasets used to validate existing work are based on limited lab experi- ments, and in many instances have no water draw and limited dataset sizes. The model in this paper is validated against electrical energy measurements in addition to temperature measurements, and is validated over a period of more than 900 hours of actual household use, collected over several months and spanning several seasons. The measurement data used forTABLE I. P RESENTED MODEL COMPARED TO STATE OF THE ART . Property [9] [11] [12] [13], [14] This paper Multinodal XX X X Horizontal orientation X X Schedule control  X Multinodal standing losses N/A X X X Validated model  X X Computationally inexpensive XXX X validation of the model consists of six datasets that make up a combined 53 days of household data (including 103 usage events), with measurement data sampled at a rate of one sample per minute – compared with limited validation in the work presented in section II. The model presented supports and is also tested against both schedule and thermostat control. The rest of this paper is structured as follows: section II describes related work in the physical modelling of EWHs; section III presents the proposed two-node model and the standing loss calculations thereof; section IV describes the details of the model’s implementation, including the parameter values used and a pseudocode implementation of the model; section V describes the results of the model implementation us- ing multiple datasets over several months; section VI describes the sensitivity analysis performed on the model to illustrate the importance of accurate input variable values for models as a guide for future research; and section VII concludes the paper. II. R ELATED WORK Dolan et al. [9] presents an EWH model for use in the modelling of aggregate residential EWH loads. Their one-node model simulates the average thermal response of the water in the EWH tank using a single ﬁrst-order differential equation. Assuming a uniform temperature distribution for the water in the tank accurately models the behaviour of the EWH in the absence of usage events. Kondoh et al. [11] describes a two-node model for a vertical EWH with two heating elements that operate inde- pendently. The thickness of the thermocline is assumed to be zero to simplify the modelling process. Their model assumes ﬁxed volumes for the lower, cold node and the upper, warm node and the temperature within each node is assumed to be uniform, with the upper node temperature always being higher than that of the lower node. The heat dissipation of each node to the surrounding environment is considered, but the value of thermal resistance of the EWH tank is estimated and not validated using measured data. Additionally, the water consumption proﬁles used for individual EWHs during sim- ulations were estimated using measured average residential load proﬁles. Although Kondoh et al. improved upon the one- node model of Dolan et al., their assumption of ﬁxed node volumes does not model the movement of the thermocline, and the model would therefore give erroneous energy ﬂows for large usage events, and also would not accurately estimate the standing losses of the two nodes. Moreover, no validation process is reported to determine the accuracy of the model. Diao et al. [12] presents a model for a vertically orientated EWH that switches between the one- and two-node state, depending on the operation of the EWH. When the EWH contains only warm water or has been fully depleted, they use the one-node state to model the behaviour of the EWH. In this state, their model is identical to that of [9] and it will remain in this state until a usage event occurs. Diao et al. deﬁne a two-node state that their model enters into when water is withdrawn from the EWH and, similar to [11], the temperature of each node is assumed to be uniform. In the two-node state, their model deﬁnes an equation that describes the height ( h) of the thermocline. This height moves during usage and heating events, simulating the movement of the thermocline for a vertical tank. If the value of hreaches the full height of the EWH tank (i.e. all the water in the tank is warm), then the model returns to the one-node state until another water withdrawal occurs. When their model is in the two- node state, the temperature of the upper node is held constant at the value of the average temperature of the water at the time that the usage event occurred, which does not accurately model the standing losses for the warm node. Additionally, this model is suitable for a vertically orientated EWH only, because the cross-sectional area of the tank is assumed to be constant. Furthermore, the simulated results of the model are not validated against measured data to conﬁrm the validity and accuracy of the model. Xu et al. [13] developed a partial differential equation (PDE) based model for simulating the temperature proﬁles at various locations in a vertically orientated EWH. The entire tank was discretised into bins of size 0.01 meters and standard ﬁnite difference was applied to solve the PDE used by the model to describe the temperature at varying positions in the tank at different times. The EWH had two elements that oper- ated independently and their states (and therefore the energy consumption of the EWH) were determined by computing the instantaneous temperatures at their respective positions. Four temperature sensors were installed along the tank from top to bottom to determine if the model was accurately simulating the thermal dynamics of the EWH. Their thermal model was validated against the measurement data collected over 250 hours, during which only four signiﬁcant usage events occurred. The validation process indicated that the simulated temperature values at the locations of the sensors were in good agreement with the temperature measurements. However, the computational complexity of the PDE model is signiﬁcantly higher than that of the one- and two-node models of [9], [11] and [12]. According to [13], the PDE model took 22 minutes to perform the 240 hour simulation with 1 minute simulation time steps. In South Africa alone, there are an estimated 5.4 million residential EWHs. If one were to simulate the aggregate response of only 10 000 EWHs, it would take 10 000 desktop machines 22 minutes to simulate these results. The simulation of a larger group of EWHs (e.g. 100 000) would require an excessively large amount of expensive computing power to obtain results in a reasonable time frame, therefore reducing the scalability of this model. This is problematic if the PDE model is to be used for demand response programs for which it will need to simulate the behaviour of millions of EWHs, or if the simulation is to be performed on mobile devices. The grey-box model presented by Farooq et al. [14] uses 8 one-node models to create a stratiﬁed model of the EWH tank. Similar to Xu et al., 8 temperature sensors were installed along the height of the tank to validate the simulated response of the model. The values of the input variables were obtainedusing parameter estimation techniques and high resolution measurement data (10 second sample rate). Although the simulated response of the eight nodes accurately matched the measurement data, the validation of the model was limited (less than 4 days of measurement data). Only two scenarios were used to validate the model: scenario 1, consisting of 70 hours of measurement data, during which no usage events occurred, to determine the model’s accuracy in the simulation of standing losses; and scenario 2, where the water in the EWH was heated to 60C and water was consumed at a constant rate of 90 grams per second over 2 hours. The response of the model when exposed to usage events of varying consumption amounts and draw rates at different intervals is not reported. Additionally, this model is unproven for EWHs that are horizontally orientated. Despite EWHs commonly being installed in a horizontal orientation in certain countries (e.g. South Africa), existing models do not cater for this orientation. Although one-node EWH models inherently accommodate horizontal alignment, they cannot accurately model EWH energy usage, because they do not take stratiﬁcation into account [13]. Horizontally in- stalled EWHs have a non-uniform cross sectional area between the two nodes (called the thermocline), and the surface area subject to standing losses for each node cannot be determined analytically. Existing models that incorporate two or more nodes are therefore not suited to this orientation and only support vertical EWHs [11]–[14]. Additionally, the available two-node models do not accurately accommodate standing losses while in the two-node state [11], [12]. Many of the mod- els presented in literature are not validated against measured data and their accuracy is unknown [9], [11], [12]. Moreover, none of existing works in literature validates modelled energy consumption against measured electrical energy. Only two of the existing sources report validation against measured data, and only validate the temperature values [13], [14]. III. M ODEL DEVELOPMENT This section describes the development of a model that accurately simulates the temperature and energy ﬂows inside an EWH. The model is based on energy ﬂow inside the tank that can be used to estimate the temperature of the water inside the tank. With knowledge of this temperature, the behaviour of the EWH heating element, and therefore the energy input into the EWH, can be estimated. Energy losses occur due to standing losses and warm water withdrawal from the EWH tank (i.e. usage). Firstly, a one-node model is described, similar to the solution in [9]. This model is then extended to a two-node model, taking into account the orientation and the standing losses in the two-node state. A. One-Node State For the one-node model, all the water in EWH tank is treated as a single body with uniform temperature. Therefore, when a usage event occurs, the water leaving the tank through the outlet pipe is assumed to be at the average temperature of the water inside the tank. Additionally, the cold water entering the tank from the inlet pipe, to replace the water used, is assumed to instantaneously mix with the water inside the tank, at the start of the present sample, to create a new average temperature. Under the assumption that water at the Tinside , VtankTambient Eloss EinputEusageFig. 1. One-node state energy ﬂow. inlet temperature is the baseline for zero energy, all the energy inside the EWH is then held by the remaining hot water inside the tank and the corresponding temperature change of the water in the EWH at sample [n+ 1] is given by the energy balance equation [7]: Einside [n+ 1] =Einside [n] (1) =VtankVusage [n+ 1] Vtank(2) Where: Einside [n+ 1] is the energy inside the EWH tank at sample [n+ 1], after the usage event occurs from sample [n] to sample [n+ 1]; Vtank is the total volume of water in the EWH; and V usage [n+ 1] is the volume of water used (equal to the volume to be heated) from sample [n]to sample [n+1]. Converting energy to temperature changes with E=cmT on both sides of Equation 1 results in: cVtank Tinside [n+ 1]Tinlet =c(VtankVusage [n+ 1]) Tinside [n]Tinlet (3) Where:cis the speciﬁc heat capacity of water; is the density of water; T inside [n+ 1] is the average temperature of water in the EWH tank at sample [n+ 1] , after the usage event that occurs from sample [n]to sample [n+ 1]; and Tinlet is the temperature of the water entering the tank from the inlet. Cancelling out the constants and solving for T inside [n+ 1] gives: Tinside [n+ 1] = Tinside [n]Tinlet +Tinlet (4) The energy (heat) lost during a usage event can then be obtained as follows: Eusage [n+1] =cVusage [n+1] Tinside [n]Tinside [n+1] (5) Where: Eusage [n+1] is the energy required to reheat the water in the EWH from the average temperature after the usage event (i.e. Tinside [n+ 1]) to the temperature it was before the usage event (i.e. T inside [n]). In addition to energy being lost through usage events, Figure 1 shows the other energy input and output that occur within the EWH when it is in the one-node state: standing losses (Eloss); and the energy input by the element (E input ). Energy input by the element is assumed to be distributed uniformly and instantaneously to all the water in the EWH tank in the one-node state. The temperature increase ( Tinside [n]) in the water in the tank as a result of energy input by the element can be calculated using: Einput[n] =cmtankTinside [n] (6)Tinside [n] =Einput[n] cVtank(7) Where: m tank is the mass of water in the EWH tank; and Einput[n]is derived from the power rating of the element and the time it is estimated to be on in sample [n]. Standing losses refer to the energy lost due to heat dissipa- tion from the water inside the EWH to the outside environment as a result of the temperature difference between them. These standing losses can be modelled using a temperature decay of the water inside the EWH tank toward the ambient temperature as described by [9]: _Tinside [n] =1 cmtankR Tinside [n]Tamb[n] (8) Where: Tinside [n]is the average temperature of the water in the EWH tank at sample [n];Ris the thermal resistance of the EWH tank; and T amb[n]is the temperature of the outside environment of the EWH at sample [n]. Solving 8 for T inside : Tinside [n+ 1] =Tamb[n] + Tinside [n]Tamb[n] e (9) =tn cmtankR(10) Where: Tinside [n+1] and Tinside [n]are the temperature of the water in the EWH tank at samples [n+1] and[n]respectively; andtnis the amount of time that elapses between samples [n+1]and[n](i.e. sampling interval). Equation 9 describes the exponential decay of the internal temperature of the EWH from its initial value at sample [n]towards the ambient temperature over one sampling interval. The energy lost to the environment (Eloss) over the sampling interval can then be calculated using: Eloss[n] =cmtankTinside [n] (11) Eloss[n] =cVtank Tinside [n]Tinside [n+ 1] (12) Therefore, the standing losses are given by the amount of energy needed to reheat all the water in the EWH tank to its initial temperature at sample [n]. B. Two-Node State The model remains in the one-node state until a signiﬁcant volume of water, called the threshold volume (V threshold ), is consumed over a short duration. After this usage threshold volume has been exceeded, the model transitions to the two- node state where the water in the tank is divided into two separate nodes, mimicking the natural stratiﬁcation that occurs in the EWH, as shown in Figure 2. The upper node consists of the remaining warm water in the tank after the usage event has occurred and the lower node consists of cold water from the inlet that has replaced the water drawn from the tank. In the two-state, when a usage event occurs, the volume of water leaving the upper node is replaced by water entering the lower node through the inlet pipe. It is assumed that the water entering the tank through the inlet pipe mixes instantaneously with the lower node. The temperature of the lower node, after mixing with the water entering the tank at the inlet temperature (Tlower[n+ 1]), can be obtained by using the one-node model for the lower node, i.e. modifying Equation 4 to obtain: Tlower[n+ 1] =  Tlower[n]Tinlet +Tinlet (13) Tambient Tupper , Vupper Tlower , Vlower Tinlet , VusageTupper , Vusage EinputEloss (upper) Eloss (lower)EusageFig. 2. Energy ﬂow, upper and lower nodes of two-node state. =Vlower[n]Vusage [n+ 1] Vlower[n](14) Where: V lower[n]is the volume of water contained in the lower node at sample [n]; and Tlower[n]is the temperature of the lower node at the start of the sample. Figure 2 shows all the energy transfers that are included in the two-node state, including: the standing losses for the upper node (E loss (upper )) and lower node (E loss (lower )); and the energy put in by the EWH element. While in the two-node state, all energy put in by the EWH element is assumed to be transferred to the lower node alone. The temperature increase of the water in the lower node ( Tlower[n]) as a result of the energy input from the element can be calculated as follows: Einput[n] =cVlower[n]Tlower[n] (15) Tlower[n] =Einput[n] cVlower[n](16) Where Einput[n]is derived from the power rating of the element and the time it is estimated to be on in sample [n]. This temperature is added to the initial temperature of the bottom node. When the temperature of the lower node equals that of the upper node, the two layers merge and the model returns to the one-node state. Figure 3 shows: the surface area of upper and lower nodes exposed to environment in the two-node state; the length of the EWH tank (L); and the radius of the EWH tank ( r). The EWH used for validating the model has a 150 litre tank, which is the most common EWH for domestic residences in South Africa. The typical length and radius of a 150 litre EWH are 1.0 and 0.219 meters respectively. The standing losses and subsequent thermal decay of the two nodes are considered separately in this state. The thermal resistance used to calculate the standing losses and thermal decay of a node is dependent on the surface area of the node exposed to the environment. This surface area for a horizontal EWH consists of: the area of the circular segments on either side of the cylinder, which are identical; and the area of the rectangle that makes up the portion of tank wall for a particular node. To calculate the surface area of this rectangle (A rectangle ), the arc length of the circular segment of each node must be known. Figure 3 shows: the arc length of the circular sector ( s); the central angle ( ); the area of the circular segment (A segment ); and the area of the isosceles triangle (A isosceles ) created by the chord that deﬁnes the circular segment. The circular segment and the isosceles triangle combined constitute the circular sector under consideration. Therefore, the area of the circular θ Aisosceles Asegmentr srL ArectangleFig. 3. Surface areas of EWH in horizontal orientation. segment is given by the difference between the area of the sector (Asector ) and the isosceles triangle: Asegment =Asector Aisosceles (17) Asegment =1 2r2 sin =1 2r2s rsins r (18) Equation 18 does not have an analytical solution, but a numerical solution for (and therefore s) can be obtained using the Newton-Raphson method [15]. Since the volume entering the EWH is measured, the volume of consumed water is known. This volume can then be used to calculate the surface area of the circular segment of the lower node using: Asegment =Vlower L(19) Where:Lis the length of the EWH tank. Setting Equation 18 equal to Equation 19 results in: Vlower L=1 2r2h sini (20) 2Vlower r2L=C (21) sin=C (22) For the Newton-Raphson method, the following function def- inition is used: f() =C+ sin (23) Equation 23 is a monotonically decreasing function over the range of = 0to2. An estimate of the arc length can then be obtained using the following equation, with an initial estimate of0=: i+1=if(i) f0(i)(24) Once the solution for Equation 24 has been determined, the area of the surrounding rectangle can be calculated using the arc length: Arectangle =sL=rL (25) The total exposed surface area of each node of the EWH is then given by: Aexposed = 2Asegment +Arectangle (26) The exposed surface area can then be used to determine the thermal conductance value of each node (G node) as follows: Gnode=1 R1000 24Aexposed(27) TABLE II. V ALUES USED TO MODEL THE EWH. Symbol Description Value Unit Ref  Water Density 1000kg m3 [13] c Speciﬁc Heat capacity of Water 4180J kgK[7] R EWH Thermal resistance 17.922Kday kWh G EWH Thermal conductance 1.386W m2K Tdeadband Thermostat Deadband 2C [13] Tinlet Inlet temperature 17, 19, 20, 22C [16] Tset EWH Set Temperature 65C VthresholdThreshold volume for two-node state transition30 l Vtank EWH Tank V olume 150 l r EWH radius 0.219 m L EWH length 1.0 m e Element efﬁciency 100 % Prated Element power rating 3000 W Where:Ris the value of the total thermal resistance of the EWH tank. The thermal resistance of each node (R node) can then be obtained by using the inverse of the value obtained from Equation 27. The thermal decay of each node can then be calculated by modifying Equation 9 to obtain: Tnode[n+ 1] =Tamb[n] + Tnode[n]Tamb[n] e (28) =tn cmnodeRnode(29) Where: Tnode[n+ 1] and Tnode[n]are the respective ﬁnal and initial temperatures of the node under consideration; and mnode is the mass of water of the node. Then, the standing losses for a given node (E loss (node )[n]) at sample [n]can be obtained using: Eloss (node )[n] =cVnode[n] Tnode[n]Tnode[n+ 1] (30) Where: V node[n]is the volume of water in the node under consideration at sample [n]. This model can also be applied to a vertical EWH. For a vertical EWH tank the cross-sectional area remains constant, eliminating the need for the estimation of arc length. This reduces the complexity of the calculations as the surface areas of the two nodes can be calculated analytically to determine the standing losses for each node separately. IV. E XPERIMENTAL SETUP This section describes the setup of the experiment, in- cluding choosing the conﬁguration constants and parameters, the chosen datasets captured from over 900 hours of actual household consumption, and the detail on the simulator that implements the model developed in section III. A. Model constants and parameters Table II lists the EWH parameter values used for the simulations. Minutely weather data from a local weather station was used to determine the ambient temperature for all the datasets that include usage events. For the datasets without usage events, only weather data reported every ﬁve minutes was available. Since the EWH is located indoors, it would be exposed to a higher temperature than the outdoor temperature and it was therefore decided to increase the for each interval do Energy out due to usage if usage event in sample [n] then if in one node state then if node Vthreshold is exceeded then Update Tlower[n+1] and Tupper[n+1] Enter two node state else Update Tinside[n+1] else in two node state Update Vlower[n+1], Vupper[n+1], Tlower[n+1], Tupper[n+1] if (Tlower[n+1] >= Tupper[n+1] OR Vupper[n+1] = 0) then Tinside[n+1] = Tlower[n] Enter one node state Calculate Eusage[n+1] Energy out due to standing losses if in one node state then Calculate Eloss[n] and Tinside[n+1] else in two node state Calculate length s using Newton-Raphson Update Rupper, Rlower Update Eloss(upper)[n], Tupper[n+1], Eloss(lower)[n], Tlower[n+1] Energy put in by the element if sample [n] is in an active time slot of schedule then Calculate Einput[n] from element rating and time it is on if in one node state then Calculate ∆Tinside[n] for full interval from Einput[n] if Tinside[n+1] + ∆Tinside[n] < Tset + Tdeadband / 2 then Tinside[n+1]+ = ∆Tinside[n] else element on for part of interval Calculate thermostat duty cycle and resulting Einput[n] Tinside[n+1] = Tset + Tdeadband / 2 else in two node state Calculate ∆Tlower[n] for full interval from Einput[n] Tlower[n+1] + = ∆Tlower[n] if Tlower[n+1] + ∆Tlower[n] >= Tupper[n+1] then Calculate Tinside[n+1] from Tupper[n+1] and Tlower[n+1] Enter one node state1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38:Fig. 4. Pseudocode for model developed in section III. ambient temperature value by 10%. Since the datasets span several months, the inlet temperature was measured once at the start of each dataset that included usage events to account for the change in soil temperature from season to season [16]. The inlet temperature was assumed to remain constant for the duration of each dataset. B. Datasets Water usage events were classiﬁed into three categories according to the volume of warm water used: small events, which were less than 15 litres (10 percent of the EWH tank volume); medium events, which were between 15 and 30 litres (between 10 and 20 percent of the EWH tank volume); and large events, which were greater than 30 litres (more than 20 percent of the EWH tank volume). Table III details all the datasets used in the validation of the model. Datasets 5 and 6 consist of 7 consecutive days each without energy usage and were used to determine the thermal resistance value, since for these datasets, only standing losses impacted the energy input by the element. Dataset 5 applied schedule control that allowed the EWH to heat water from 04:15 to 06:00 while dataset 6 utilised always on thermostat control. The datasets that include usage events are: dataset 1, which consists of 9 consecutive days in December 2014 (Summer) with a schedule that was active from 04:15 to 06:00; dataset 2, which is comprised of 10 consecutive days in March 2015 (Autumn) with a schedule that was active from 04:15 to 06:00; dataset 3 which is made up of 10 consecutive days in February 2015 (Summer) for always on thermostat control; and dataset 4, which consists of 10 consecutive days in June 2015 (Winter). TABLE III. R ESULTS FOR ONE-AND TWO-NODE MODELS . One-Node Model Two-Node Model Dataset DaysControl Mode# Small Events# Medium Events# Large EventsTotal EventsEnergy Input (Measured) [kWh]Energy Input (Calculated) [kWh]Error (%)Energy Input (Calculated) [kWh]Error (%) 1 9 Schedule 14 12 7 33 38.90 38.81 0.23 41.78 7.40 2 10 Schedule 8 9 7 24 41.86 42.23 0.88 44.91 7.28 3 10 Thermostat 2 6 6 14 52.35 48.65 7.07 51.58 1.47 4 10 Thermostat 13 1 18 32 115.20 92.89 19.37 110.26 4.29 5 7 Schedule 0 0 0 0 16.34 16.79 2.78 16.79 2.78 6 7 Thermostat 0 0 0 0 19.05 18.85 1.05 18.85 1.05 Cumulative Daily Water Usage (litres/2) Internal Temperature - Calculated (°C) Cumulative Daily Energy Input - Calculated (kWh×10) Cumulative Daily Energy Input - Measured (kWh×10) Ambient Temperature (°C) 19-Feb 20-Feb 21-Feb 22-Feb 23-Feb 24-Feb 25-Feb 26-Feb 27-Feb 28-Feb 1-Mar 010 20 30 40 50 60 70 80 90 Fig. 5. Graphed output of the two-node model for dataset 3. C. Simulator development The model presented in section III was developed using the Java programming language. This allows simulations to be run on a desktop PC as well as an Android smartphone in order to determine the average run time of the algorithm on both systems. Figure 4 shows the pseudocode implementation of the model. V. R ESULTS Before validating the results of the model for the datasets including usage events, it was necessary to determine the thermal resistance value used for the calculating the standing losses of the EWH. For datasets 5 and 6, shown in Table III, the energy input from the EWH element was calculated using the model and compared to the measured energy input. The value of R was varied from 13.92 to 20.88 and the overall error (deﬁned as the difference between the calculated and measured energy values) was calculated for the two datasets. An R value of 17.922Kday kWhproduced the best results for both datasets, with an error of 2.78% and 1.05% respectively across 7 days of simulation for each. This results in a G value of 1.386W m2K, which is similar to the value used by Xu et al. [13] After verifying the value of the thermal resistance, the fourdatasets with usage events, shown in Table III, were used to validate the accuracy of the developed EWH model. These datasets were simulated for a model that remains permanently in the one-node state, and separately for one that incorporates the two-node state. The results of these simulations are sum- marised in Table III. From Table III, it is evident that the one-node model more accurately determines the energy consumption of the EWH when schedule control is implemented. For datasets 1 and 2, the one-node model has an estimation error of 0.23% and 0.88% respectively, while the two-node model’s error is more than 6 percentage points higher for both datasets. However, when thermostat control is applied, the two-node model outperforms the one-node model. For datasets 3 and 4 the two-node model has an estimation error of 1.47% and 4.29% respectively. Figure 5 shows a graph of the simulation results of the 2 node model for dataset 3. The graph mainly illustrates the accuracy of the model through the comparison between the simulated and measured cumulative daily energy input over the 10 days. Also shown is the daily-cyclic ambient temperature, which affects the standing losses of the EWH. The small stepped increases in the energy input is as a result of the standing losses gradually depleting the temperature (and there- fore energy) in the EWH, which then causes the thermostat to activate the element, to replenish the temperature in the EWH. These steps can therefore be seen to match the sawtooth effect apparent in the simulated internal temperature, as it decays slowly due to standing losses and then is replenished quickly by the element. The large steps in the plotted cumulative daily water usage is as a result of large usage events – the larger the event, the larger the step. These large events cause the model to enter into the 2 node state if the threshold (Vthreshold ) is exceeded. When a water draw event occurs, the cold water from the inlet causes the average temperature inside the EWH to fall, and if the usage event volume exceeds the threshold volume, the model enters the 2 node state. Shortly after an event, the thermostat turns the element on to heat the colder water in the bottom node, which causes a step in the cumulative energy input. For both the standing loss replenishment and the post-event replenishment, the model uses the simple hysteresis-based thermostat model to determine the on-state of the element. From the graph, it is clear that the modelled energy input closely follows the measured data value. The time taken by the algorithm to complete a simulation of ten days on a desktop machine (Intel Core i7 2.30 GHz, 8 GB RAM) varied from 30 to 100 milliseconds. This time taken depends on both the number of usage events and the time spent in the two-node state, where the model is more computationally expensive, due to the iterative nature of the Newton-Raphson method. However, a lookup table of precom- puted values can be used to replace Newton-Raphson method. A simulation consisting of one day with schedule control (i.e. long periods of two-node state) was run on a Samsung Galaxy S4 (1.6 GHz and 1.2 GHz Quad Core, 2GB RAM) and took between 40 and 55 milliseconds to complete. A possible reason for the one-node model outperforming the two-node model for the datasets implementing schedule control is the lack of modelling of destratiﬁcation in the EWH tank. The only means of transitioning from the two-node state to the one-node state is if the temperatures of the upper and lower nodes (T upper and Tlower respectively) are equivalent. This occurs when: T upper decays to the T lower as a result of energy lost to the atmosphere; or T lower increases to T upper through heating by the element. The heating of the lower node simulates the rise of the thermocline [11] as the temperature of the node increases (rise due to change in density). If schedule control is implemented, the element is only allowed to heat the water in the tank for less than 2 hours a day. When the element is inactive the stratiﬁcation within the tank will decay (referred to as destratiﬁcation [17]) as heat is transferred from the upper to the lower node due to the temperature difference between them. The destratiﬁcation in the tank is difﬁcult to model, as it depends on: the mixing of the water from the inlet with the water already in the tank; heat conduction along the EWH tank; heat conduction between nodes at different temperatures; and heat dissipated to the environment through EWH tank [17]. VI. S ENSITIVITY ANALYSIS To determine the effect of each variable on the output of the one- and two-node models, a one-factor-at-a-time sensitivityTABLE IV . S ENSITIVITY ANALYSIS RESULTS . One-Node Model Two-Node Model Schedule Thermostat Schedule Thermostat Variable ( x)kxkkekkekkekkek Tinlet 1 % 0.250 0.313 0.215 0.309 Tset 1 % 1.382 1.806 1.159 1.597 Tamb (mod ) 1 % 0.188 0.162 0.154 0.134 Rmod 1 % 0.257 0.413 0.188 0.393 analysis was performed. Each variable was considered individ- ually (x) and incremented (by x) over a range of values. The change in the error ( e) was observed. Table IV summarises the average change in the overall error of the one- and two- node models, as a percentage, for each variable under both schedule and thermostat control. The results indicate that the one-node model is more sensitive (approximately 10% more) than the two-node model to changes in input variables. The set temperature value has the most signiﬁcant effect on the accuracy of both models. This highlights how important it is for DSM programs to consider the effect of different EWH settings. For example, the set temperatures of EWHs may vary from 55C to 70C and estimation errors of 5C can cause an energy estimation error of 10% or higher. Additionally, an error of 5% for the thermal resistance value or inlet temperature can cause an error of approximately 2% in the overall accuracy of the one- and two-node models. Since there were no direct measurements of the ambient temperature in the experiment, it is fortunate that this was the least sensitive parameter. This error may not be signiﬁcant when providing estimates to a single individual, but when simulating the energy consumption of thousands of EWHs, as is typical for DSM programs, it can create signiﬁcant errors in the overall estimates. This high- lights the importance of validating choices for input variable values, such as the value of thermal resistance which is often assumed for models in literature without any validation [11], [12]. Finally, it is important for DSM programs to consider seasonal and regional variations in inlet and average ambient temperature when modelling energy consumption in order to obtain accurate estimates. VII. C ONCLUSION A two-node EWH model was developed that can be used to accurately simulate EWHs during periods of usage and non- usage, regardless of orientation. The developed model was validated using 6 datasets that span several seasons, implement both schedule and thermostat control and include over 900 hours of measurement data with usage events, as well as 14 days of measured standing losses data. The results show that measured energy usage is modelled with an estimation error of less than 2% and 5% for schedule control and thermostat control respectively. As well as being accurate, the presented model has a low computational complexity, taking only 100 milliseconds to complete a 10 day simulation on a standard desktop machine. This makes the model ideal for evaluating the effect of DSM programs by simulating the impact of various control settings and usage proﬁles on the aggregate load proﬁle of multiple (i.e. several thousand) EWHs. The impact of input parameter values on the accuracy of the one- and two-node models under schedule and thermostat control was also investigated. The results of this sensitivity analysis are used to make recommendations for future work on the modelling of EWHs. VIII. A CKNOWLEDGEMENT The authors would like to thank MTN for their support through the MTN Mobile Innovation Lab at Stellenbosch University.