The name is absent



Stata Technical Bulletin

29


Example 2: Regulation of the shower water temperature

a) Negative feedback without delay

We wish to regulate the warm water flux (with temperature Tw = 50o C) to obtain the desired temperature (Topt = 35o
C), maintaining a cold water flux of 0.2 l/s. Let the cold water temperature be
Tc = 10o C. The state variables of the system
can be the warm water flux (IVw) and the cold water flux (Wc).

We assume no variation in the IVc flux (VAc = 0) and the warm water regulation depending on temperature difference
ɪopt —
T. V is the auxiliary variable representing the temperature of the mixed water. We assume also a perfect regulation, with
no delays in perceiving the real temperature at the mixer level. The total flux (V) is considered given by the summation of IVc
and IVw. The model, recorded as a .dct file, is as follows:

dictionary -(

* file showerl.dct

* Shower water temperature regulation - 1 - WITHOUT DELAY

* Cold water flux constant - regulation of warm water flux

* to obtain the desired temperature (Topt).

str70 .model

J-

”* — state variables —                                      ,,

”S Wc=Wc+dt*VAc                 Cold water flux (l/s)         ”

”S Ww=Ww+dt*VAw                 Warm water flux (l/s)         ”

,,* Note: in this case fluxes are levels, not rates.            ,,

”R VAc=O                        Variat. rate cold flux (1/s/s)”

”R VAw=K*(Topt-T)               Variat. rate warm flux (1/s/s)”

”1 Wc=O.2                                                              ”

”1 Ww=O                                                            ”

”P Topt=35                      Optimal temperature (C)       ”

”P Tc=IO                        Cold water temperature (C)    ”

”P Tw=50                        Warm water temperature (C)    ”

”A T=(Tc*Wc+Tw*Ww)∕(Wc+Ww)      Shower water temperature      ”

ιp κ=Qi03                         Adjusting speed                ”

To read this file and perform the simulation, we type

. infile using shower
dictionary -(

* file showerl.dct

* Shower water temperature regulation - 1 - WITHOUT DELAY

* Cold water flux constant - regulation of warm water flux

* to obtain the desired temperature (Topt).
str70 .model

>

(15 observations read)

. simula, dt(0.2) tspan(12)

The simulation results reported in Figure 6(a) show that after a few seconds the system reaches the equilibrium and T equals
the optimal temperature.

b) Negative feedback with a constant information delay

Really, there is a delay in perceiving the real water temperature at the mixer level. This determines a difficult regulation
with temperature higher and lower than the optimal. The desired condition is obtained later and with oscillating warm water
fluxes. This situation can be simulated by inserting an “information delay” in the VAw rate calculation of the previous model.
This is done by modifying our model:

. replace .model=,'R VAw=IDL[K*(Topt-T) ,dly] ” in 7

. replace .model="P dly=l,' in 16

The first command inserts a constant information delay of dly seconds in the VAw rate; the second command assigns the value
to the dly parameter. Recalling the simulation command,

. simula, dt(0.2) tspan(12)

we obtain the results shown in Figure 6(b). The constant information delay produces an oscillating behavior of the warm water
flux.



More intriguing information

1. Prizes and Patents: Using Market Signals to Provide Incentives for Innovations
2. WP 1 - The first part-time economy in the world. Does it work?
3. EFFICIENCY LOSS AND TRADABLE PERMITS
4. The name is absent
5. AGRIBUSINESS EXECUTIVE EDUCATION AND KNOWLEDGE EXCHANGE: NEW MECHANISMS OF KNOWLEDGE MANAGEMENT INVOLVING THE UNIVERSITY, PRIVATE FIRM STAKEHOLDERS AND PUBLIC SECTOR
6. Unemployment in an Interdependent World
7. Regional science policy and the growth of knowledge megacentres in bioscience clusters
8. The Works of the Right Honourable Edmund Burke
9. Evaluating the Success of the School Commodity Food Program
10. Input-Output Analysis, Linear Programming and Modified Multipliers