POLYMATH Report          DEQ 
 Ordinary Differential Equations       2016-May-31 

Calculated values of DEQ variables
  Variable Initial value Final value Minimal value Maximal value
1 dTdt 0 -0.000357 -1.93193 0.534818
2 errsum 0 400.108 0 432.873
3 Kc 50 50 50 50
4 q 10000 2.0E+04 10000 2.08E+04
5 rhoVCp 4000 4000 4000 4000
6 step 0 1 0 1
7 t 0 200 0 200
8 T 80 80.0074 65.2723 81.2948
9 T0 80 80.0077 65.3897 81.305
10 taud 1 1 1 1
11 tauI 2 2 2 2
12 taum 5 5 5 5
13 Ti 60 40 40 60
14 Tm 80 80.0088 66.444 81.1869
15 Tr 80 80 80 80
16 WC 500 500 500 500

Differential equations
1 d(T)/d(t) = (WC*(Ti-T)+q)/rhoVCp
2 d(T0)/d(t) = (T-T0-(taud/2)*dTdt)*2/taud
3 d(Tm)/d(t) = (T0-Tm)/taum
4 d(errsum)/d(t) = Tr-Tm

Explicit equations
1 WC = 500
2 rhoVCp = 4000
3 taud = 1
4 taum = 5
5 Tr = 80
6 Kc = 50
7 tauI = 2
8 step = if (t<10) then (0) else (1)
9 Ti = 60+step*(-20)
10 q = 10000+Kc*(Tr-Tm)+Kc/tauI*errsum
11 dTdt = (WC*(Ti-T)+q)/rhoVCp

Problem source text
# S. 23(b)* - ODE System
# Dynamics of Heated Tank-Closed loop
# Verified Final Values: T = 80.0074,T0 = 80.0077, Tm = 80.0088
# Ref.: Comput. Appl. Eng. Educ. 6: 178-179, 1998
d(T)/d(t)=(WC*(Ti-T)+q)/rhoVCp
d(T0)/d(t)=(T-T0-(taud/2)*dTdt)*2/taud
d(Tm)/d(t)=(T0-Tm)/taum
d(errsum)/d(t)=Tr-Tm
WC=500
rhoVCp=4000
taud=1
taum=5
Tr=80
Kc=50
tauI=2
step=if (t<10) then (0) else (1)
Ti=60+step*(-20)
q=10000+Kc*(Tr-Tm)+Kc/tauI*errsum
dTdt=(WC*(Ti-T)+q)/rhoVCp
t(0)=0
T(0)=80
T0(0)=80
Tm(0)=80
errsum(0)=0
t(f)=200

Matlab formatted problem
Create m file called PolyOde.m and paste the following text into it.
% S. 23(b)* - ODE System
% Dynamics of Heated Tank-Closed loop
% Verified Final Values: T = 80.0074,T0 = 80.0077, Tm = 80.0088
% Ref.: Comput. Appl. Eng. Educ. 6: 178-179, 1998
function PolyOde
   tspan = [0 200]; % Range for the independent variable
   y0 = [80; 80; 80; 0]; % Initial values for the dependent variables
   [t,y]=ode45(@ODEfun,tspan, y0);
   plot (t,y);
   xlabel('t');
   legend('T','T0','Tm','errsum');
   fprintf('T = %16.6f \n',y(length(y),1));
   fprintf('T0 = %16.6f \n',y(length(y),2));
   fprintf('Tm = %16.6f \n',y(length(y),3));
   fprintf('errsum = %16.6f \n',y(length(y),4));
end

function dYfuncvecdt = ODEfun(t,Yfuncvec)
   T = Yfuncvec(1);
   T0 = Yfuncvec(2);
   Tm = Yfuncvec(3);
   errsum = Yfuncvec(4);
   WC = 500;
   rhoVCp = 4000;
   taud = 1;
   taum = 5;
   Tr = 80;
   Kc = 50;
   tauI = 2;
   if (t < 10)
       step = 0;
   else
       step = 1;
   end

   Ti = 60 + step * -20;
   q = 10000 + Kc * (Tr - Tm) + Kc / tauI * errsum;
   dTdt = (WC * (Ti - T) + q) / rhoVCp;
   dTdt = (WC * (Ti - T) + q) / rhoVCp;
   dT0dt = (T - T0 - (taud / 2 * dTdt)) * 2 / taud;
   dTmdt = (T0 - Tm) / taum;
   derrsumdt = Tr - Tm;
   dYfuncvecdt = [dTdt; dT0dt; dTmdt; derrsumdt];
end

General Settings
Total number of equations 15
Number of differential equations 4
Number of explicit equations 11
Reporting digits 8
Elapsed time 0.30 sec
Solution method RKF_45
Step size guess. h 1E-06
Truncation error tolerance. eps 1E-06
Calculated Intermediate data points 50

Calculated data points
    t T T0 Tm errsum step Ti q dTdt
1 0 80 80 80 0 0 60 10000 0
2 9.72046 80 80 80 0 0 60 10000 0
3 12.1067 75.3711 77.3793 79.7222 0.076471 1 40 1.0E+04 -1.93193
4 16.0413 69.5293 70.7197 76.2467 7.20605 1 40 1.03E+04 -1.13709
5 20.6823 66.0914 66.5786 71.2938 36.432 1 40 1.13E+04 -0.468535
6 24.1075 65.2723 65.3897 68.5732 71.2128 1 40 1.22E+04 -0.11393
7 28.7251 65.7574 65.5311 66.6211 129.23 1 40 1.37E+04 0.218398
8 33.5317 67.5007 67.0673 66.444 194.624 1 40 1.52E+04 0.421824
9 37.5105 69.4508 68.9361 67.3501 247.012 1 40 1.65E+04 0.508056
10 42.0875 71.8843 71.3509 69.1285 301.062 1 40 1.78E+04 0.534818
11 44.3359 73.0656 72.5446 70.1664 324.352 1 40 1.83E+04 0.525689
12 48.8047 75.2592 74.7917 72.3441 363.452 1 40 1.93E+04 0.476684
13 53.3801 77.1847 76.7959 74.5201 393.443 1 40 2.0E+04 0.40082
14 58.1476 78.7756 78.4783 76.5388 414.628 1 40 2.05E+04 0.310888
15 60.6264 79.4305 79.1802 77.4492 422.058 1 40 2.06E+04 0.264048
16 65.8306 80.4442 80.2852 79.0126 431.057 1 40 2.08E+04 0.172418
17 68.5878 80.8022 80.6854 79.6488 432.873 1 40 2.08E+04 0.129598
18 74.5403 81.2289 81.1859 80.6035 431.853 1 40 2.08E+04 0.053985
19 76.6827 81.2884 81.2659 80.8227 430.315 1 40 2.07E+04 0.027643
20 81.0917 81.2948 81.305 81.1027 425.992 1 40 2.06E+04 -0.00775
21 84.2917 81.2263 81.2529 81.1869 422.305 1 40 2.05E+04 -0.021607
22 89.363 81.0397 81.0817 81.1697 416.264 1 40 2.04E+04 -0.041143
23 94.8747 80.7867 80.8339 81.015 410.197 1 40 2.02E+04 -0.046953
24 98.0747 80.6367 80.6831 80.8899 407.144 1 40 2.02E+04 -0.046909
25 101.275 80.4939 80.5374 80.7537 404.513 1 40 2.01E+04 -0.04466
26 104.859 80.3484 80.3872 80.5993 402.089 1 40 2.0E+04 -0.039017
27 111.002 80.1458 80.1745 80.3555 399.176 1 40 2.0E+04 -0.030527
28 114.202 80.0655 80.0887 80.2468 398.216 1 40 2.0E+04 -0.025079
29 117.402 80.002 80.0201 80.1535 397.58 1 40 1.99E+04 -0.019797
30 120.556 79.9549 79.9683 80.0771 397.22 1 40 1.99E+04 -0.013535
31 124.408 79.9156 79.924 80.0044 397.07 1 40 1.99E+04 -0.0094
32 130.808 79.8865 79.8886 79.9285 397.313 1 40 1.99E+04 -0.003004
33 133.182 79.8844 79.8848 79.9125 397.503 1 40 1.99E+04 -0.00085
34 137.398 79.889 79.8871 79.897 397.909 1 40 2.0E+04 0.00175
35 140.598 79.8976 79.8945 79.8941 398.245 1 40 2.0E+04 0.002681
36 146.461 79.9194 79.9154 79.9026 398.848 1 40 2.0E+04 0.00398
37 148.044 79.9259 79.9218 79.907 398.999 1 40 2.0E+04 0.004137
38 153.818 79.9497 79.9457 79.9269 399.481 1 40 2.0E+04 0.004071
39 157.018 79.9619 79.9582 79.9391 399.695 1 40 2.0E+04 0.003803
40 160.881 79.9749 79.9717 79.9535 399.903 1 40 2.0E+04 0.003213
41 166.828 79.9908 79.9885 79.9734 400.118 1 40 2.0E+04 0.002461
42 170.028 79.9971 79.9953 79.9824 400.188 1 40 2.0E+04 0.001984
43 172.544 80.0011 79.9996 79.9884 400.225 1 40 2.0E+04 0.00158
44 176.719 80.0059 80.0049 79.9966 400.255 1 40 2.0E+04 0.000985
45 183.119 80.0096 80.0093 80.0047 400.248 1 40 2.0E+04 0.000424
46 185.584 80.0101 80.0099 80.0067 400.234 1 40 2.0E+04 0.000201
47 188.228 80.0102 80.0102 80.0081 400.214 1 40 2.0E+04 -4.65E-06
48 192.968 80.0095 80.0097 80.0093 400.173 1 40 2.0E+04 -0.000174
49 196.168 80.0087 80.009 80.0093 400.143 1 40 2.0E+04 -0.000272
50 200 80.0074 80.0077 80.0088 400.108 1 40 2.0E+04 -0.000357