cstr_demo in matlab & r
DESCRIPTION
CSTR_demo in Matlab & R. save CSTR_fig1Matlab -v6;. figure(1). save CSTR_fig2Matlab -v6;. figure(2). save CSTR_fig3Matlab -v6;. figure(3). save CSTR_fig4Matlab -v6;. save(CSTR_fig4.Rdata). figure(4). save CSTR_fig5Matlab -v6;. figure(5). log10(s(1)/s(4)) = 3.019 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/1.jpg)
CSTR_demoin Matlab & R
![Page 2: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/2.jpg)
figure(1)
• save CSTR_fig1Matlab -v6;
0 10 20 30 40 50 600.5
11.5
F(t
)
Input flow rate
0 10 20 30 40 50 601.8
22.2
C0(
t)
Input concentration
0 10 20 30 40 50 60300
350
T0(
t)
Input temperature
0 10 20 30 40 50 60
340360
Tci
n(t)
Coolant temperature (red = hot, blue = cool)
0 10 20 30 40 50 60101520
Fc(
t)
Coolant flow rate
Input flow rate
Ft
0 10 20 30 40 50 60
0.5
1.0
1.5
Input concentration
C0t
0 10 20 30 40 50 60
1.8
2.0
2.2
Input temperature
T 0t
0 10 20 30 40 50 60
303
323
343
Coolant temparature (red = hot, blue = cool)
T cint
0 10 20 30 40 50 60
330
350
370
Coolant flow rate
F ct
0 10 20 30 40 50 60
10
15
20
![Page 3: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/3.jpg)
figure(2)
• save CSTR_fig2Matlab -v6;
0 10 20 30 40 50 600
0.5
1
1.5
2 Output concentration (red = hot, blue = cool)
C(t
)
0 10 20 30 40 50 60
340
360
380
400
420
T(t
)
Output temperature
0 10 20 30 40 50 60
0.5
1.0
1.5
Output concentration (red = hot, blue = cool)
C(t
)
0 10 20 30 40 50 60
340
360
380
400
420
Output temperature (red = hot, blue = cool)
T(t
)
![Page 4: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/4.jpg)
figure(3)
• save CSTR_fig3Matlab -v6;
0 10 20 30 40 50 601.2
1.4
1.6
C(t
)
Concentration
0 10 20 30 40 50 60330
340
350
360
T(t
)
Temperature
0 10 20 30 40 50 60
1.3
1.4
1.5
1.6
1.7
C(t
)
Concentration
0 10 20 30 40 50 60
33
53
40
34
53
50
35
5
T(t
)
Temperature
![Page 5: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/5.jpg)
figure(4)
• save CSTR_fig4Matlab -v6;
• save(CSTR_fig4.Rdata)
0 10 20 30 40 50 601.2
1.4
1.6
C(t
)
Concentration
0 10 20 30 40 50 60330
340
350
360
T(t
)
Temperature
0 10 20 30 40 50 60
1.3
1.5
1.7
Concentration
C(t
)
0 10 20 30 40 50 60
33
53
45
35
5Temperature
T(t
)
![Page 6: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/6.jpg)
figure(5)
• save CSTR_fig5Matlab -v6;
0 10 20 30 40 50 601.2
1.4
1.6
C(t
)
Concentration
0 10 20 30 40 50 60330
340
350
360
T(t
)
Temperature
0 10 20 30 40 50 60
1.3
1.5
1.7
C(t
)
Concentration
0 10 20 30 40 50 60
33
53
45
35
5
T(t
)
Temperature
![Page 7: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/7.jpg)
• log10(s(1)/s(4)) = 3.019
• log10(s12(1)/s12(2)) = 0.8261
• log10(s13(1)/s13(2)) = 1.1789
• log10(s34(1)/s34(2)) = 2.12
• log10(s123(1)/s123(3)) = 1.2357
• log10(s[1]/s[4]) = 3.019016
• log10(s12[1]/s12[2]) = 0.8260689
• log10(s13[1]/s13[2]) = 1.178939
• log10(s34[1]/s34[2]) = 2.11998
• log10(s123[1]/s123[3]) = 1.235720
![Page 8: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/8.jpg)
• lsqnonlin ... • log10(s1234(1)/
s1234(4)) = 3.0146• kref EoverR a b• Initial values: 0.4 0.8 1.7 0.5• Estimated values: 0.46617 0.83961 1.7014 0.50021• True values: 0.461 0.83301 1.678 0.5
• Cerrpct1234o = 0.114910
• Terrpct1234o = 0.026436
• nls ... • log10(s1234[1]/
s1234[4]) = 3.017296• kref EoverR a b• Initial values 0.4000000 0.8000000 1.700000 0.5000000• Estimated values 0.4661415 0.8397917 1.718248 0.4963714• True valules 0.4610000 0.8330100 1.678000 0.5000000
• Cerrpct1234o = 0.1145141
• Terrpct1234o = 0.02635538
![Page 9: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/9.jpg)
figure(6)
• save CSTR_fig6Matlab -v6;
0 10 20 30 40 50 601.2
1.4
1.6
C(t
)
Concentration (red = true, blue = estimated)
0 10 20 30 40 50 60330
340
350
360
T(t
)
Temperature
0 10 20 30 40 50 60
1.2
1.4
1.6
1.8
Concentration (red = true, blue = estimate)
C(t
)
0 10 20 30 40 50 60
33
03
40
35
03
60
Temperature
C(t
)
![Page 10: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/10.jpg)
• CerrpctHC = 1.712750
• TerrpctHC = 0.060908
• CerrpctHC = 1.832445
• TerrpctHC = 0.05692276
![Page 11: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/11.jpg)
figure(8) [no figure(7)]
• save CSTR_fig8Matlab -v6;
0 10 20 30 40 50 600.1
0.2
0.3
0.4
C(t
)
Concentration (red = true, blue = estimated)
0 10 20 30 40 50 60370
380
390
400
410
420
T(t
)
Temperature
0 10 20 30 40 50 60
0.1
00
.20
0.3
00
.40
Concentration (red = true, blue = estimates)
C(t
)
0 10 20 30 40 50 60
38
04
00
Temperature
T(t
)
![Page 12: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/12.jpg)
Estimated from Temperature Only
• CerrpctHTemp = 0.097899
• TerrpctHTemp = 0.025902
• R failed to solve the problem
• nls: stepsize < min • optim(Nelder-Mead,
BFGS, CG) NAs • nlminb: claimed
convergence too close to starting values
0 10 20 30 40 50 601.2
1.4
1.6
C(t
)
Concentration (red = true, blue = estimated)
0 10 20 30 40 50 60330
340
350
360
T(t
)
Temperature
![Page 13: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/13.jpg)
• kref EoverR a b• Initial values: 0.4 0.8 1.7 0.5• Estimated values: 0.45767 0.83001 1.7108 0.48561• True values: 0.461 0.83301 1.678 0.5
• CerrpctHConc = 0.097041
• TerrpctHConc = 0.028031
• kref EoverR a b• Initial values 0.4000000 0.8000000 1.700000 0.500000• Estimated values 0.4629777 0.8369693 1.623520 0.512704• True valules 0.4610000 0.8330100 1.678000 0.500000
• CerrpctHConc = 0.093428
• TerrpctHConc = 0.01241975
![Page 14: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/14.jpg)
Estimated from Concentration Only
• save CSTR_fig10Matlab -v6;
0 10 20 30 40 50 601.2
1.4
1.6
C(t
)
Concentration (red = true, blue = estimated)
0 10 20 30 40 50 60330
340
350
360
T(t
)
Temperature
0 10 20 30 40 50 60
1.3
1.4
1.5
1.6
1.7
Concentration (red = true, blue = estimates)
C(t
)
0 10 20 30 40 50 60
33
53
40
34
53
50
35
5Temperature
T(t
)
![Page 15: CSTR_demo in Matlab & R](https://reader033.vdocuments.net/reader033/viewer/2022051622/568151ac550346895dbfda51/html5/thumbnails/15.jpg)
last figure
• figure(11)• save
CSTR_fig11Matlab -v6;
• Conc: better fit from Matlab than R
0 10 20 30 40 50 600
0.1
0.2
0.3
0.4
C(t
)
Concentration (red = true, blue = estimated)
0 10 20 30 40 50 60370
380
390
400
410
420
T(t
)
Temperature
0 10 20 30 40 50 60
0.1
00
.20
0.3
00
.40
Concentration (red = true, blue = estimates)
C(t
)
0 10 20 30 40 50 60
38
04
00
Temperature
T(t
)