heatcool.nb 1 ME 163 Heating and Cooling of Buildings In this notebook, we use Mathematica to graph the solution to a modified version of Problem 9 in Exercises 3.3 of Fundamentals of Differential Equations and Boundary Value Problems, by Nagle and Saff. For reference purposes, the problem is restated here. ü Problem Statement A warehouse is being built that will have neither heating nor cooling. Depending on the amount of insulation, the time constant for the building may range from 1 to 5 hr. To illustrate the effect insulation will have on the temperature inside the warehouse, assume the outside temperature varies as a sine wave, with a minimum of 16°C at 2:00 A.M. and a maximum of 32°C at 2:00 PM. Assuming the exponential term (which involves the initial temperature T0 ) has died off, what is the range of temperatures inside the building if the time constant is 1 hr? If the time constant is 5 hr? What is the range of permissible time constants if we require that the building temperature drop no lower than 20°C and go no higher than 30°C? ü Solution Obtained in Class We solved this problem in class. The external temperature is given by M[t], where In[37]:= M@t_D := Tavg + A * Cos@w * Ht - t0LD The parameter values are In[38]:= Tavg = 24.0; In[39]:= A = 8.0; In[40]:= w = N@Pi ê 12.0D; In[41]:= t0 = 14.0; The solution for the temperature T[t] has a transient part Trans[t] and a periodic part Tper[t], given by In[42]:= Trans@t_D := c * Exp@-k * tD In[43]:= Tper@t_D := Tavg + HHk * AL ê Sqrt@k^ 2 + w ^ 2DL * Cos@w * Ht - t0L - fD In[44]:= T@t_D := Trans@tD + Tper@tD The maximum and minimum internal temperatures for the periodic solution, as a function of k, are given by In[45]:= Tmax@k_D := Tavg + HHk * AL ê Sqrt@k ^ 2 + w ^ 2DL heatcool.nb 2 In[46]:= Tmin@k_D := Tavg - HHk * AL ê Sqrt@k ^ 2 + w ^ 2DL The parameters are given by In[47]:= k = 1.0; In[48]:= f := ArcSin@w ê Sqrt@k ^ 2 + w ^ 2DD In[49]:= c := T0 - Tavg - HHk * AL ê Sqrt@k ^ 2 + w ^ 2DL * Cos@w * t0 + fD The initial temperature isn't very important here, because the main interest is in the periodic response rather than the start-up transient. We somewhat arbitrarily take it to be 35°C. This is an unrealistically large value, but we will see that it has only a transitory effect. In[50]:= T0 = 35.0; ü Graphs of Solution for k-1 = 1 hr and 5 hr We graph the external temperature, the periodic solution and the full solution, all over two periods. The external is dashed, the periodic is black and the full solution is red. ü k=1 In[51]:= k = 1.0; Plot@M@tD, 8t, 0, 48<, PlotRange -> 815, 35<, AxesLabel -> 8"t", "T"<, PlotStyle -> 8Dashing@80.01<D<D; In[52]:= graphext1 = T 35 32.5 30 27.5 25 22.5 20 17.5 10 20 30 40 t heatcool.nb 3 In[53]:= graphfull1 = Plot@T@tD, 8t, 0, 48<, PlotRange -> 815, 35<, AxesLabel -> 8"t", "T"<, PlotStyle -> 8RGBColor@1, 0, 0D<, PlotLabel -> "k = 1"D; T 35 k = 1 32.5 30 27.5 25 22.5 20 17.5 10 20 30 In[54]:= graphper1 = Plot@Tper@tD, 8t, 0, 48<, 40 t PlotRange -> 815, 35<, AxesLabel -> 8"t", "T"<, PlotLabel -> "k = 1"D; T 35 k = 1 32.5 30 27.5 25 22.5 20 17.5 10 20 Now we compare the full and periodic solutions. 30 40 t heatcool.nb 4 In[55]:= Show@graphfull1, graphper1D; T 35 k = 1 32.5 30 27.5 25 22.5 20 17.5 10 20 30 40 t We see that after about 5 hours they are in agreement. The maximum and minimum internal temperatures are In[56]:= Tmax@1.0D Out[56]= 31.7392 In[57]:= Tmin@1.0D Out[57]= 16.2608 ü k = 0.2 Now we repeat for k -1 = 5 hours. We expect for this longer time constant, that the transients will last a little longer, and the range of temperature fluctuations in the building will be somewhat less. In[58]:= k = 0.2; heatcool.nb 5 In[59]:= graphfull2 = Plot@T@tD, 8t, 0, 48<, PlotRange -> 815, 35<, AxesLabel -> 8"t", "T"<, PlotStyle -> 8RGBColor@1, 0, 0D<, PlotLabel -> "k = 0.2"D; T 35 k = 0.2 32.5 30 27.5 25 22.5 20 17.5 10 20 30 In[60]:= graphper2 = Plot@Tper@tD, 8t, 0, 48<, 40 t PlotRange -> 815, 35<, AxesLabel -> 8"t", "T"<, PlotLabel -> "k = 0.2"D; T 35 k = 0.2 32.5 30 27.5 25 22.5 20 17.5 10 20 We compare the full and periodic solutions. 30 40 t heatcool.nb 6 In[61]:= Show@graphper2, graphfull2D; T 35 k = 0.2 32.5 30 27.5 25 22.5 20 17.5 10 20 30 40 t As expected, the transients last longer, but after about a day, they are gone forever. The maximum and minimum temperatures are In[62]:= Tmax@0.2D Out[62]= 28.8565 In[63]:= Tmin@0.2D Out[63]= 19.1435 ü Comparison of k = 1.0 and k = 0.2 Now we compare the graphs of the periodic solution for the two different k values, along with the external temperature. In[64]:= Show@graphper1, graphper2, graphext1, PlotLabel -> "Comparison for Different k Values"D; T 35 Comparison for Different k Values 32.5 30 27.5 25 22.5 20 17.5 10 20 30 40 t heatcool.nb 7 This graph tells a lot about how the system response depends on k. For the smallest time constant (k = 1), the building temperature comes close to following the external temperature. The amplitude of fluctuations in the building is a little lower than outside, and there is a slight phase lag, but the differences between building temperature and outside temperature are rather small, as one might expect in this case of relatively poor insulation. For the larger time constant (k = 0.2), there is more insulation, and the effects are more pronounced. The temperature fluctuations inside are definitely smaller than outside, and there is a definite phase lag. ü Choosing k to Keep the Temperature in the Prescribed Range In this last section, we construct a sequence of graphs of the periodic response for different k-values, and then we will animate them to get a dynamic picture of how the solution depends on k. We will use this sequence to determine the values of k which keep the temperature within the desired range. The range is defined by In[65]:= Ttop = 30.0; In[66]:= Tbot = 20.0; We construct the sequence from large k-values (short time constants) to small k-values (long time constants). We do this for equally spaced time constants, in 0.5 hr increments from 0.5 hours to 24 hours. We first define a function kgraph which produces the graph of the periodic solution, but does not display it. Then we define a function graphseq[start,finish,inc] which produces a sequence of graphs with time constants running from start to finish with increment = inc. On the graph sequence, the maximum permissible temperature is shown in red, the minimum in blue. Plot@8Ttop, Tbot<, 8t, 0, 48<, PlotRange -> 814.5, 35<, AxesOrigin -> 80, 15<, DisplayFunction -> Identity, PlotStyle -> 8RGBColor@1, 0, 0D, RGBColor@0, 0, 1D<D; In[67]:= topbotgraph = In[68]:= kgraph := Plot@Tper@tD, 8t, 0, 48<, AxesLabel -> 8"t HhrL", "T"<, PlotRange -> 814.5, 35<, AxesOrigin -> 80, 15<, DisplayFunction -> Identity, PlotLabel -> SequenceForm@"1êk = ", PaddedForm@1.0 ê k, 83, 1<D, " hr"DD; Module@8i<, Do@Hk = 1.0 ê i; Show@kgraph, graphext1, topbotgraph, DisplayFunction -> $DisplayFunctionDL, 8i, start, finish, inc<DD In[69]:= graphseq@start_, finish_, inc_D := Now we execute graphseq to produce a sequence of graphs with time constants running from 0.5 hr to 24 hr in 0.5 hr increments. We will then animate the sequence of graphs. In the printed version of this notebook, only the first of the 48 graphs is shown. Step through the graphs to determine the range of time constants which keeps the temperature in the prescribed range. The minimum value of k which works corresponds to the smallest amount of insulation that will keep the temperature in the desired range. The printed version of the notebook shows only the first graph in the sequence. In[70]:= graphseq@0.5, 24.0, 0.5D; heatcool.nb 8 T 35 1êk = 0.5 hr 30 25 20 10 20 30 40 t HhrL