Modelling a thermostated water bath with a spreadsheet

and VAX phone utilities can take as much time as faculty are willing to commit. ... quire how things are going or by writing messages to stu- dents th...
0 downloads 0 Views 5MB Size
detected the first time the report is submitted. Rather, the report was evaluated until significant errors were detected. It is the student's responsibility to correct the errors that were identified and then to check for errors subsequent to those that were identified. This may sound harsh but isn't if a report is clearly incomplete or fundamentally incorrect and is not worth grading. We feel it is the student's responsibility to fix it. Communicating with students via the electronic mail and VAX phone utilities can take as much time as faculty are willing to commit. Faculty can choose to encourage such communication by initiating calls to students to inquire how things are going or by writing messages to students they regularly see logged onto the system. Faculty may also choose only to respond to communication from students. All of these activities do require extra time of faculty. But we feel it has been worthwhile when we see the quality of work some students are able to produce. Acknowledgment We have appreciated the support of Andrew Lawlor, Coordinator of Academic Computing and Research at Edinboro Un~versityof Pennsylvania. Literature Cited

indicate how this model can be used either for classroom demonstration or as a student "laboratory" experiment. Qualitative Considerations Imagine that we come upon a working water bath composed of an object, a stirrer, a heater, a sensor, and a controller as in F i r e 1. There must be some sort of loss of heat to balance the heater input such as cooling coils distributed along the bottom. At higher temperatures this may be evaporation from the surface or conduction through the walls. The sensor can be a thermometer (see Fig. 2) fitted with a contact which opens a circuit when the mercury falls below the tip of the sensing wire and closes the circuit when the temperature rises enough to cause the mercury to come in contact with the sensing wire. The circuit causes a relay (Fig. 2) to operate in the controller, switching the heater off or on as the mercury in the thermoregulator is or is not touching the sensing wire. Suppose that, as we first see the water bath, the thermoregulator is signaling that the temperature has dropped below the desired value (the set point To)The controller, therefore, has turned on the heater, sending a current of warm water toward the sensor. During the time that the heat input is moving toward the sensor, the sensor temperature remains below the set point, continuing to drift

1. Multin, J. L.; Eiemsn, R J. J. Cham. Educ. lm,67,878-881. 2. Levkov,J. S . J Cham. E&. lW,M,3133. 3. Van Houten. J. J. Chem. Educ. 1988.65.A31CA316. 4. Van Houten. J. J Chem. Educ 1988,65,A315A316. 5. Whisnant,D. M. J. Chom. Educ. 1989,66,405. 6. A t h a o n , D. E.; Bmuer, D. C.:MeClsrd, R.W.; Barkley, D. S. q i M m i c Modes in Chemistry: N. Slmonson:Marina del Rey, CA, 1990. 7. Parker, 0.J.: Breneman. G. L. Spreadsheet Chamrslry; Rentice-Hall:Englewmd Cliffs, NJ, 1991. 8. 20r20,Version 2,4forVAXNMSsystems,AecessTeehnology, Ine.,SouthNatiek,MA, 7-0 9. MiemsoR Works: Mi-& Corporation: Redmond. WA. A""".

Modelling a Thermostated Water Bath with a Spreadsheet Benson R. Sundheim New York University New York City, NY I0003 A water bath is the most common means of establishinaa more or less constant temperature for a system being studied. Because electrical conductivitv. cell emf. chemical reaction rate, etc. vary with temperature, it is oken necessary to provide a means for establishing a particular temperature and a large battery jar or fish tank filled with water (or sometimes oil) provides an easy and reliable temperature environment for the system under study. A stirrer, a heater, the object being thermostated, some sort of temperature sensing device, and a means of using its output to control the heater are the essential features. Setting up a water bath for satisfactory operation entails some considerations that are not always well understood; namely, the most effective arrangement of the elements mentioned above, the most suitable values of such parameters as the heater size, or the settings on a proportional controller. Here we discuss these auestions malitativelv. ~roceedto a useful and easily understood computer model using a spreadsheet that can demonstrate the role of the relevant parameters in the behavior of real systems, and then discuss extensions to more complex situations ( I ) . Finally we 650

Journal of Chemical Education

Heater

Stirrer

Sensor

Obiect

Coolina Coils Figure 1. The array of elements of a thermostated water bath

sensor

Figure 2. A thermoregulator circuit for an on-off system. The sensor, a mercury contactor, causes the relay to operate which in turn switches the heater on or off.

A Simple Model An exploration of the properties of this picture of the operation of a water bath and its dependence on the variables of the system can be obtained by use of a mathematical model. I t is possible to set up a description of the system pictured in Figure 1in terms of differential equations. As it haooens. the on-off controller leads to a nonlinear and hence awkward formulation (2). Fortunately, a straightforward and realistic reoresentatiou can be constructed - using a spreadsheet (3).?he essential idea is based upon the f a d that recalculation (uodatine) of the entries in the cells of a spreadsheet takes >lace I'n a definite predetermined order. As a result, a sequence of cells can be set up to represent a sequence of positions in a system with their interactions designated by operations on the cell contents and the flow of time being represented by successive upd a t i n g ~one , for each time step. Specifically we model a cylindrical battery jar containing the thermostating fluid with a cooling coil a t the bottom, a stirrer, heater, sensor and object distributed in various cells. We imagine the path of the circulating fluid to be divided into a number of cells, say 12 for definiteness, and the elements of the system to be arranged in some particular way. (See Fig. 3.) The simulation is to compute the behavior of the svstem for anv oarticular confieuration and values of the parameters a i d b permit the determination of the effect of changing the configuration and parameters a t will. (As we will see, this representation is capable of considerable extension so a s to include manv different kinds of control systems.) .A

Figure 3. An arrangment of cells in a spreadsheet representation of a thermostated water bath. The dashed line indicates the direction of flow of fluid in the bath. The downward arrows indicate successive time steps. Cell A contains the heater, Cell C the sensor, and cell H the object. Representative assignments of cell instructions are: For cells A1 through L1, enter the chosen initial temperature distribution. (We have used T=20 for all cells except HI which is 19, thus representing a small abrupt excursion from the steady state.) For cell 82 enter +Bl+$MIX'(Cl+Al-2'61) - $COOL^Bl + $VELO'(Al-61). For cells A2 to L2, the entries are obtained by (relative)copying this cell and adjusting the two end cell addresses appropriately. Add to the entryinA2 +$HEAT'@IF(CITSET,l,O).Cells A2..L2 may then be copied downward for as many time steps as desired. downward. When the stream of warm water reaches it, the sensor begins to warm up eventually reaching the set point temperature and simals for the heat to be turned off. The str&m of warm water is shut off a t the heater, but some little time elapses before i t has all flowed past the sensor so that the sensor continues to be heated for a short while even &er the heater has been shut off. As a result, the sensor temperature overshoots the set point and then slowly drops a s the system cools. Finally, its temperature drops below the set point, and the cycle repeats itself. Summarizing, the time delay between the sensor signal and the heater output reaching the sensor produces a steady oscillation of the temperature around the desired value. I n order to minimize this time delay, it would seem plausible to place the sensor close to the heater and to supply vigorous stirring. The object being thermostated would then be placed downstream so that the oscillations in temperature are somewhat smoothed out before reaching it. The heater should be a s small a s possible so as to minimize the extent of the overshoot. Twoproblems arise from this setup. The object itself is not actually thermostated, and it may be somewhat cooler than the sensor because of the steady cooling. Furthermore, ifthe heater is small, the system will have difficulty in responding rapidly to fluctuations i n temperature (due to reactions, drafts, putting obiects into the bath.. etc.:.whereas. if the heater is laree, - . the temperature overshoots will be large. Acompromise must be struck between the need to avoid oscillation and the need to respond to temperature excursions. I n practice, the best arrangement is a stirrer directing its stream onto the heater and thence directly to the sensor. Many compact, commercially available thermoregulators are arrangedjust this way.' The object is downstream, and the cooling is uniformly distributed. The heater size is selected so a s to keep the heater on about half of the time. Asystem set up along these lines can be counted on to keep the temperature to within about 0.1 'C of the desired value and to Aspond quickly to sudden variations. 'Temperature control systems are marketed by Haake, Fisher, and Cole-Palmer, and several others.

.

Spreadsheet Representation Correspondence between the model and the spreadsheet representation is established a s follows. 'Although the real system is three-dimensional, its cylindrical structure and the circular path ofthe pumped fluid mean that we can approximate it as a linear series of volume elements, the last being mupled to the first. We arrange these as 12 successive cells running from left to right along a row of the spreadsheet. The last cell on the right far purposes of calculation is considered to he adjacent to the first cell on the left, thus closing the circular flow path as indicated by the dashed line in Figure 3. At any given time each cell is characterized by a local temperature which is the numerical value in the cell. 'At each time step, a cell containing none of the thermostat elements changrs its temperature at a rate that IS propor. tional to the alkwbraic diffrrcncein temperature of thc rell from thecell on its left (brought in by the stirring)nnd to the diNercnrr hetween tempermure of the wll and that of the cooling coil The new temperature ISentered in the cell immediately to [he right ofthe one undrr consideratmn. The temperature of the cell containing the sensor is used to calculate the sign of the difference between its temperature and the set point and hence determines whether the heater is on or off. .A cell containing the heater also experiences a contribution to the temperature change proportional to the size of the heater if it is switched on. 'In order to examine the system at a series of time steps, these formulas are entered into the second row and then mpied downward to form a series of mws, say 100, below the second one. The recalculation mode is set to "MANUAL" and "BY ROWS"and the desired initial temperature distribution is entered in the first row, The various proportionality constants are entered as named blocks in some convenient location. Updating produces a set of replicas of the initial conliguration, each at a time-successive time interval. (Becausethere are circular cell references. the recalculation is set for. e z . , five iteratmns to assure convergence., The temprrature of any cellcar, then br graphed agalnst the rimerindexnumber of the mw, to dee how the system behaves. Thr trrnperature

Volume 69 Number 8 August 1992

651

Figure 4. The temperature of various pans of an onnffcontrolled water bath as functions of time. Solid line: object, dotted line: heater, dashed line: sensor. Here $MIX=0.2, $COOL=0.0025,$HEAT=3, $VELO=0.4,$TSET=20.

Figure 6. The eHect of varying the size of the heater on the timeltemperature behavior of the object. (cf.Fig. 4 but note change in scale.) Dotted line: HEAT=7,solid line: HEAT=3.5,dashed line: HEAT= 1.75.

of a number of cells at each instant of time can be plotted on the same graph to get a feeling for the operation of the system. Altemativelv the temverature mav be ma~hedas a function of position in the'thermostat iagainst 'the index number of the column). Values of the various parameters may be changed and the calculation repeated. For this purpose it is convenient to establish a block of named variables for the various proportionality constants and to use their (absolute address)names at the appropriate places in the formulas. The labels and their meanines are as follows: HEAT (the rate at which heat 15 mtmduced'mto the first cell whrn the heater is fully ON,, COOL (the race at whmh hear w extracted from the systrrn by the coaling coils-it may also contain acontribution of heat loss to the surroundings through walls, surface evasporations, etc.); VELO (the rate at which the contents of a given cell are transferred to the next cell-a measure of vigor of the stirrer); TSET (the temperature at which the controller switches from OFF to ON): MIX (a ~arameterto allow for rhemixingofrell contents with cells on either side, hrought about by turhulenee and diflusion~. A listing ofthe cell entries for the second column of one varticular eonfiguration is given in the legend to Figure 3 , ' ~ s sentially the formula for each cell accounts for the balance of beat, representing the flow from cell to cell due to stirring and to mixing, the loss to the cooling coils, and, for the a l l containing the heater, the input from the heater. The l a t k

is switched ON or OFF depending on the temperature in the cell mntaining the sensor.

Some Results The r e ~ u l t sof a representative calculation of this sort are shown in Firmre 4. The initial conditions were a uniform temperature with a small perturbation introduced a t the position of the obiect (cell HI. Oscillations in temperat u r e follow this pert&bation such as might be caused by putting a conductivity cell into the bath. The mamitude and duration of these oscillations depend on the parameters of the system. For example, varying the stirring rate (Fig. 5, shows that the frequency ofoscillation of the heater decreases a s the stirring is decreased. Slower stirring gives time for more mixiLg so that the oscillations at thc object are diminished. The speed of the response is diminished a t slower stirring speeds. Varying the size of the heater (Fig. 6) shows that the closeness of control (rapidity of response) increases with heater size but so does thk tendency to oscillation. Experimentation with the arrangement, heating and cooling rates, and stirring shows that very careful matching of the heater and cooling rates and locating the sensor at or near the object gives the closest approach to the desired, constant temperature. Even the best resulting system, however, oscillates extensively and is very sensitive to minute fluctuations. Stability toward chanees in input and raoid recoverv reauire raoid stimne. -. large heating and cooling terms, and placement of the sensor near the heater. Pushine anv of these factors to extreme values leads to instabikie'and oscillations. When a n on-off control system is used, it is clear that considerable experimentation with the parameters of the system is required and that optimal h i e m e d i a t e values must be sought. The time lags intrinsic to the control system produce oscillations, slow recovery, and differences between the set point and the observed object temperature. For manv situations these are tolerable. If not. it mav be appropriate to turn to more complex control systems.

-

Fgure 5. The effect of varying the stirring rate on the ternperature~timebehavor of the object. (cf.Fig. 4 bbt note change in sca e.) Doned I ne: sold line. VELO-0.5; oottea ine. VE-O=0.4;dashed I ne VELO=0.3.

652

Journal of Chemical Education

"

A

More Sophisticated Systems I n order to improve the performance of a temperature control system, several steps may be taken. The on-off controller may be replaced with one whose output is proportional to the difference between the set point and the desired temperature (the "error signal"). This so-called "proportional control" requires two changes in the system; namely, in the sensor and in the controll&

Thermocouple

Temperature

Figure 7. (Right):The relationship of the output of a proportional controller to the temperature of the sensor. (Left):Schematic representation of a proportional wntroller. Suitable spreadsheet cell contents are as in Fig. 3 except for modifyingthe $HEAT term in B 1 to read +$HEAT'@IF(A3 c $TLOW,I ,(A3 - $TLOW)/($THIGH $TLOW))'@IF($A3c $THIGH.O,l). Since the intent is to cause the heater output to be increased as the temperature drops below the desired value and to be decreased when the temperature falls too low, it is necessary to use a sensor that produces a signal measurinp. the distance from the desired value. Many choices are including, thermocouples, thermistors, resistance thermometers, and a variety of mechanical devices. Acommon choice is a thermistor 161 ( a sem~conductorwith a high temperature coefficientof resistivity, in a Wheatstone bridge so that the output signal is approximately proportional to the deviation from the resistance appropriate to the set point. A thermistor provides high sensitivity and approximate linearity. It is not, however, reliable for estabiishing an accurate, predetermined set point. Other transducers, such as thermocouples or platinum rcslstance thermometers, provide more accuracy and linearity at the expense of sensitivity. As usual, the experimenter must choose the compromise most suitable for his particular problem. The controller is an electronic device that accepts the small voltaee sienal from the thermistor bridge or other transducer and converts it to a substantial power output. When the input simal is zero, the output should be the required. As the input sigapproximate&,eadistate nal changes about zero, the output power is increased or decreased appropriately. The heater output, of course, is proportional over a definite range. At the bottom of the range, the heater can only be shut completely off. At the top, it can only be completely on. It is customary to call the interval between these extremes the "proportioning band". (See Fig. 7.) Because the heater takes some account of the size of error signal, some significant decrease in the tendency to oscillate should be noted. The wider the proportioning band, the more account the system can take of large fluctuations; the narrower the band, the more closely the signal follows small excursions. Although the differential equation treatment of proportional control is easier than for on-off control, it is still awkward (4). Fortunately, incorporating proportioning control in the spreadsheet simulation discussed above is quite direct. It is only necessary to add more details to the single cell that computes the heater output from the error signal. The sensor temperature is used to compute the heater output called for by the function shown in Figure 6. A modification of this sort in the spreadsheet program (see legend to Fig. 7) leads to the results shown in Figure 7 (note the change in scale). Here we can see that this system is much more stable toward fluctuations and large

- -

L Z ,

0

, 10

,

20

30

, 40

,

50 TME

60

70

00

9

100

Fioure 8. The temoerature as afunction of time at various points in a or&onionallv conirolled svstem. (Note the chanae of scale from Fia. ,~ 4.) The initiai impulse he& was reduced to 1 9 . f ' ~ for convenience in graphing. Solid line: object,dotted line: sensor,dashed line: heater. ~

.~

perturbations than the on-off system and that the oscillations are damped, i.e., gradually diminish in magnitude. As a further refmement one might consider "anticipating" the temperature changes as a human operator might do. This is often done (5)by adding another term that is proportional to the time deAvativeif the sensor temperature to the expression for settinp the heater. Thus, if the temperature is changing rapidly, an extra large adjustment is made; whereas, a slowly moving change is met with a reduced adjustment. Yet another adjustment can be made, sometimes called "droop" control. It deals with the tendency we have observed for the temperature to be slightly displaced from the control point. This can be dealt with by adding a term proportional to the difference in the average of recent temperatures from the set point. In effect, it is proportional to the time integral of the signal. Both of these can be entered into the spreadsheet program in a direct fashion, both approximate integral and derivative terms are calculated readily from the appropriate cell entries in the spreadsheet. (Because theyinvolve past temperatures, they can only be entered for later time steps. As&ming the ceils have been arranged as described in the legend to Fig. 7 and that the twelve cells have been copied downward from Bl..B12 to Cl..E12, then add to cell

The cells E l to El2 can then be copied downward as before. Representative results obtained with such a modified program are shown in Figures 8 and 9. It may be seen that these adjustments further reduce the tendency to oscillation andbring the temperature nearer to the s i t point. Experimentation shows that these terms also must be chosen k t h care, extreme values again provoke wild oscillation. Since the tendeney to oscillate has been reduced greatly, better control is achieved by moving the sensor as close as possible to the object. The overall result is very much better than previously obtained with on-off control with respect to speed of response, stability, and accuracy of control. Classroom Use We have used this material in several ways, depending on the computer expertise of the class. 1. For beginning students, before a n experiment in which a

Volume 69 Number 8 August 1992

653

a dye to study the VELO and MIX parameters, varying the heater input, switching the cooling on or off, determining the time temperature profiles in various parts of the system, and rearranging the elements of the water bath.

Figure 9. Temperature a s a function of time when the sensor is placed on the object, with and without derivative and droop corrections. (Note the change of scale from Figs. 4 and 8). The initial impulse was reduced to 19.9 for convenience in graphing. Solid line: derivative and droop corrections, dashed line: derivative wrrection only, dotted line: neither wrrection. thermostat is to he used, a lecture using a mmputer with nroiection facilities is dven to elmlain the nrincides of , operation. The merhaGra of thc aDrendsheLt o p t h i o n are omitted. The students find the rapid updatmy uf the graphs following changes of parameters to be interesting and instructive. 2. For junior or senior students, who a r e familiar with spreadsheet operations, this material is employed as a "prelab" in which the students manipulate the model. 3. As a special laboratary project advanced students make semiquantitative correlations with experiment. They are asked to devise means of estimating appropriate values for the parameters. Methods used include the injection of

.

654

Journal of Chemical Education

Conclusions 1. The control of temperature has two main steps; namely, the determination of the temoerature a t same mint in the system and theprowsmn of hentmgor molmgrndnve the temperature toward the d e s ~ r r dvalue The iner.mblc time delay between the detection of a n error and its correction leads to s tendency toward oscillation. Continuous rather than on-off control reduces the tendency ta oscillation and improves control. Further refinements in the control function can lead to improved accuracy and eontrol. Requirements of close control and stability to large excursions, accuracy and speed of response, and simplicity and flexibility must be examined so as to establish a n acceptable balance between these factors. 2. Similar considerations apply to the control of other physical variables such a s pressure, liquid level, pH, electrical current. etc. The tsndencv for a control svstem to oscillate 1s uh~quitousandalways ansesfrom the tlmc lag hetween si~maland rerpunue. Once t h u merhanmn rs understwd. appmpriate adjustments usually can be made. 3. Computer simulations using spreadsheets afford a direct and effective means of understandine the role of the various oarameters and of t e s t i n ~different means of antimizing thclr value9 l'hry may hr inrorporntrd readily into chtmlmy instruutwn at several levrlr. Literature Cited 1. Schmley,J. F., Ed. nmpemh'm:1ta

Mporummpnt oM' Control in s e i p i p ond1ndustry;Ameriean Instihlte of Phyaiea: New York, 1982;Vol. 5,PartII. p 1333 R 2. Root*, W K Fundomnfolsof7bmpomfureConlrd;AcademicRess:NewYmk, 1980; Chaptpr 6. 3. See forexample. M a , W. J. 1 ~ ~ . 3 F a r S e i e n f & f s o n d E n g i m m ; S y b e x : S s n h & m , CA, 1981;J.Chem.Educ.: SoRrare.1989 IIB,0). 4. Farpn, E. M. C'yogenles 1874,14,2M. 5.Phdlips. C.:Harbar, R. Feedbock Conhol Systems;RentiiHall: New Jersey, 1988; p 250.