**2.2 Electric water heater first principles equations**

Applying the principle of energy conservation in the electric water heater system, equation 1 could be written. This equation was based in a previews work made in modelling a gas water heater system, first time presented in [11].

$$\frac{dEs(t)}{dt} = \text{Qe(t - td) - wf(t)hvt(t)Ce - wf(t)cwt(t)Ce}{} \tag{1}$$

Where *dEs(t)/dt=MCe(dΔt(t)/dt)* is the energy variation of the system in the instant t, *Qe(t)* is the calorific absorbed energy, *wf(t)cwt(t)Ce* is the input water energy that enters in the system, *wf(t)hwt(t)Ce* is the output water energy that leaves the system, and Ce is the specific heat of the water, M is the water mass inside of the permutation chamber and td is the variable system time delay.

The time delay of the system has two parts: a fixed one that became from the transformation of energy and a variable part that became from the water flow that circulates in the permutation chamber.

M is the mass of water inside of the permutation chamber (measured value of 0,09Kg) and *Ce* is the specific heat of the water (tabled value of 4186 J/(KgK)). The maximum calorific absorbed energy *Qe(t)* is proportional to the maximum electric applied power of 5,0 KW.

The absorbed energy *Qe(t)* is proportional to the applied electric power *p(t)*. On each utilization of the water heater it was considered that *cwt(t)* is constant, it could change from utilization to utilization, but in each utilization it remains approximately constant. Its dynamics does not affect the dynamics of the output energy variation because its variation is too slow.

Writing equation 1 in to the Laplace domain and considering a fixed water flow *wf(t)=Wf* and fixed time delay td, it gives equation 2.

148 Frontiers of Model Predictive Control

Fig. 3. Photo of the electric water heater and the micro-controller board.

Applying the principle of energy conservation in the electric water heater system, equation 1 could be written. This equation was based in a previews work made in modelling a gas

Where *dEs(t)/dt=MCe(dΔt(t)/dt)* is the energy variation of the system in the instant t, *Qe(t)* is the calorific absorbed energy, *wf(t)cwt(t)Ce* is the input water energy that enters in the system, *wf(t)hwt(t)Ce* is the output water energy that leaves the system, and Ce is the specific heat of the water, M is the water mass inside of the permutation chamber and td is the

The time delay of the system has two parts: a fixed one that became from the transformation of energy and a variable part that became from the water flow that circulates in the

M is the mass of water inside of the permutation chamber (measured value of 0,09Kg) and *Ce* is the specific heat of the water (tabled value of 4186 J/(KgK)). The maximum calorific absorbed energy *Qe(t)* is proportional to the maximum electric applied power of 5,0 KW. The absorbed energy *Qe(t)* is proportional to the applied electric power *p(t)*. On each utilization of the water heater it was considered that *cwt(t)* is constant, it could change from utilization to utilization, but in each utilization it remains approximately constant. Its dynamics does not

Writing equation 1 in to the Laplace domain and considering a fixed water flow *wf(t)=Wf*

affect the dynamics of the output energy variation because its variation is too slow.

( ) ( - )- ( ) ( ) - ( ) ( ) *dEs t Qe t td wf t hwt t Ce wf t cwt t Ce dt* (1)

**2.2 Electric water heater first principles equations** 

water heater system, first time presented in [11].

and fixed time delay td, it gives equation 2.

variable system time delay.

permutation chamber.

$$\frac{\Delta t(\text{s})}{\text{Qc(s)}} = \frac{\frac{1}{\text{Vf} \text{fCe}}}{\frac{M}{\text{Vf} \text{f}} s + 1} e^{-\text{s}} \stackrel{\text{t} \text{d}}{=} \frac{\frac{1}{\text{Vf} \text{fCe}} \frac{\text{Vf} \text{f}}{M}}{s + \frac{\text{Vf} \text{f}}{M}} e^{-\text{s}} \stackrel{\text{t} \text{d}}{} \tag{2}$$

Passing to the discrete domain, with a sampling period of h=1 second and with discrete time delay ( ) ( ) int( ) 1 *td t d k h* , the final discrete transfer function is illustrated in equation 3.

$$
\Delta t (k+1) = \left( e^{-\frac{\mathsf{V}\mathsf{V}\mathsf{f}}{\mathsf{M}}} \right) \Delta t (k) + \left( \frac{1}{\mathsf{V}\mathsf{f}\mathsf{f}\mathsf{C}e} \left( 1 - e^{-\frac{\mathsf{V}\mathsf{f}\mathsf{f}}{\mathsf{M}}} \right) \right) \left( \mathsf{Q}e(k-\mathsf{r}\mathsf{d}(k)) \right) \tag{3}
$$

The real discrete time delay 1 2 *dk d k d k* () () () is given in equation 4, where 1 *dk s* () 3 is the fixed part of *d k*( ) that became from the transformation of energy 2 *d k*( ) and is the variable part of *d k*( ) that became from the water flow *wf(k)* that circulates in the permutation chamber.

$$\text{tr}\,d(k) = \begin{cases} 4 & \text{to} \quad wf(k) \text{s} = 1,75l \text{ / min} \\ 5 & \text{to} \quad 1,00l \text{ / min} < wf(k) < 1,75l \text{ / min} \\ 6 & \text{to} \quad wf(k) \text{s} = 1,00l \text{ / min} \end{cases} \tag{4}$$

Considering now the possibility of changes in the water flow, in the discrete domain *Wf=wf(k)* and ( ) <sup>2</sup> *d k* , the final transfer function is given in equation 5.

$$\begin{aligned} \Delta t \{ k+1 \} &= \left( e^{-\frac{wf(k-\tau d\_2(k))}{M}} \right) \Delta t \{ k \} + \\\\ \left( \frac{1}{wf(k-\tau d\_2(k)) \text{Ce}} \left( 1 - e^{-\frac{wf(k-\tau d\_2(k))}{M}} \right) \right) \{ Qe(k-\tau d(k)) \} \end{aligned} \tag{5}$$

Observing the real data of the system, the absorbed energy *Qe(t)* is a linear static function *f(.)* proportional to the applied electric power *p(t)* as expressed in equation 6.

$$Qe(k - \tau \, d(k)) = f\left(p(k - \tau \, d(k))\right) \tag{6}$$

Finally, the discrete global transfer function is given by equation 7.

$$\Delta t(k+1) = \left( e^{-\frac{wf(k-\tau d\_2(k))}{M}} \right) \Delta t(k) + \left( \frac{1}{wf(k) + \tau d\_2(k)C\tau} \right) \tag{7}$$

$$\left( \frac{1}{wf(k-\tau d\_2(k))C\epsilon} \left( 1 - e^{-\frac{wf(k-\tau d\_2(k))}{M}} \right) \right) \left( f\left( p(k-\tau d(k)) \right) \right)$$

Adaptable PID Versus Smith Predictive Control Applied to an Electric Water Heater System 151

From the validation test, figure 5 shows the two linear variable parameters expressed in

As can be seen the *A(k)* parameter that multiply with the regressor delta water temperature changes significantly with water flow *wf(k)* and the B(k) parameter that multiply with the

From the results it can be seen that for the small water flows the model presents a bigger error signal. This happens because of the small resolution of the water flow measurements and of the estimated integer time delays forced (a multiple of the sampling time h it is not

The first control loop tested is the adaptive proportional integral derivative control algorithm. Adaptive because we know that gain and time constant of the system changes with the input water flow. First it is described the control structure and its parameters and

This is a very simple and well known control strategy that has two control parameters *Kp* and *Kd* that are multiplied by the water flow, as illustrated in figure 6. The applied control

( ) ( 1) ( ) ( )

*f p k f p k wf kKek*

The P block gives the error proportional contribution, the *D* block gives the error derivative

The three control parameters were adjusted after several experimental tests in controlling the real system. This algorithm has some problems dealing with time constant and time delay variations of the system. With this control loop it is not possible to define a close loop

*p*

(10)

( ) ( ( ) ( 1))

*d*

contribution and the *I* block gives the control signal integral contribution.

*wf k K e k e k*

presents very small changes with the water flow *wf(k).*

equation 8 of the physical model used.

regressor applied power *f p* ( ( )) *k dk*

possible fractional time delays).

**3. Adaptive PID controller** 

second the real control results are showed.

**3.1 Adaptive PID control structure** 

signal is expressed in equation 10:

Fig. 5. The two linear variable parameters *A(k)* and *B(k)*.

If *A(k)* and *B(k)* are defined as expressed in equation 8, the final discrete transfer function is given as defined in equation 9.

$$A(k) = e^{-\frac{wf\{k-\tau d\_z(k)\}}{M}}$$

$$B(k) = \frac{1}{wf(k-\tau d\_2(k))\text{Ce}} \left(1 - e^{-\frac{wf\{k-\tau d\_z(k)\}}{M}}\right) \tag{8}$$

$$
\Delta t(k+1) = A(k)\Delta t(k) + B(k)\left(f\left(p(k-\tau d(k))\right)\right) \tag{9}
$$

#### **2.3 Physical model validation**

For validation of the presented discrete physical model, it is necessary to have open loop data of the real system. This data has been chosen to respect two important requirements: frequency and amplitude spectrum wide enough (Psichogios & Ungar, 1992). Respecting the necessary presupposes, the collect data is made via RS232 connection to the PC. The validation data and the physical model error are illustrated in figure 4.

Figure 4 shows the physical model error signal *e(k)*, which is equal to the difference between delta and estimated delta water temperature *e(k)= Δt(k)- Δtestimated(k)*. It can be seen from this signal, that the proposed model achieved very good results with a mean square error (MSE) of 1,32ºC2 for the all test set (1 to 1600).

Fig. 4. Open loop data used to validate the model.

From the validation test, figure 5 shows the two linear variable parameters expressed in equation 8 of the physical model used.

As can be seen the *A(k)* parameter that multiply with the regressor delta water temperature changes significantly with water flow *wf(k)* and the B(k) parameter that multiply with the regressor applied power *f p* ( ( )) *k dk* presents very small changes with the water flow *wf(k).*

Fig. 5. The two linear variable parameters *A(k)* and *B(k)*.

From the results it can be seen that for the small water flows the model presents a bigger error signal. This happens because of the small resolution of the water flow measurements and of the estimated integer time delays forced (a multiple of the sampling time h it is not possible fractional time delays).
