-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.m
558 lines (400 loc) · 13 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
%% Main program
% This program contains all other sub programs.
% It calculates the void fraction, vapor mass fraction, pressure,
% and temperature inside the tubes (calculation for one tube)
% We calculate these values, with and without gravity
close all
clear all
global Tsat Psat rhol_R245FA rhog_R245FA Hl_R245FA Hg_R245FA Cpl_R245FA Cpg_R245FA mul_R245FA mug_R245FA lambdal_R245FA lambdag_R245FA sigma_R245FA
global R_contact
global rhol rhog mul mug sigma Hg Hl hlg lambda Cpl Cpg g q m D G Z1 Z2 Tf P0 k fpl R lmt
global x Zz P ggeom qgeom N Jll Jgg Q_geom L_geom l_geom Np_geom
sim=input('What type of simulation do you want? (2 = with and without gravity / 1 = with gravity / 0 = without gravity) ');
m=0.01; % mass flux : from 5 to 30 g/s (sum of the 3 tubes)
D=12e-3; % tubes diameter
x0=0.3; % initial vapor mass fraction between 0 and 0.3
Tf=45; % initial fluid temperature
G=4*m/(pi*D^2); % surface flux
P0=0.3e6; % saturation vapor pressure at 45 degsC
lmt=0.99; % validity limit of the models
%% loading fluid properties
R245FA;
%% loading thermal properties
R_contact=5000; % contact resistance between the imitator and the fin
%% geometry definition
geom=importdata('elbow_geometry.txt');
Zgeom1=geom(:,1)/1000; % geometry position
Zgeom2=geom(:,2)/1000;
k_coude=geom(:,3); % elbow's presence
qgeom=geom(:,4); % surface flux
ggeom=geom(:,5); % gravity value
Q_geom=geom(:,6); % component power
L_geom=geom(:,7); % section's length
l_geom=geom(:,8); % width of the component
Np_geom=geom(:,9); % number of passages at the component level
% geometry initialisation
k=k_coude(1);
q=qgeom(1);
g=ggeom(1);
Z1=Zgeom1(1);
Z2=Zgeom2(1);
R=(Zgeom2(1)-Zgeom2(1))/pi; % radius of curvature (if existent)
if (sim==1) || (sim==2)
for i=2:length(Tsat)
if (Tf<=Tsat(i)) && (Tf>Tsat(i-1))
rhol=(rhol_R245FA(i)-rhol_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+rhol_R245FA(i);
rhog=(rhog_R245FA(i)-rhog_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+rhog_R245FA(i);
mul=(mul_R245FA(i)-mul_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+mul_R245FA(i);
mug=(mug_R245FA(i)-mug_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+mug_R245FA(i);
Hl=(Hl_R245FA(i)-Hl_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+Hl_R245FA(i);
Hg=(Hg_R245FA(i)-Hg_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+Hg_R245FA(i);
hlg=Hg-Hl;
end
end
%% initial Rg calculation
Rg0=Rg_initial(x0,g,rhol,rhog,mul,mug,m,D);
%% solving equations with gravity
[Z Rg]=ode45(@calcul_Rg_comp, [Zgeom1(1) Zgeom2(1)], [Rg0 x0 P0]);
Zz=Z;
Rgg=Rg(:,1);
x=Rg(:,2);
P=Rg(:,3);
Rg0=Rgg(length(Zz));
x0=x(length(Zz));
P0=P(length(Zz));
N(1)=length(Z);
% calculate values for all geometry
for j=2:length(Zgeom1)
q=qgeom(j);
g=ggeom(j);
k=k_coude(j);
Z1=Zgeom1(j);
Z2=Zgeom2(j);
R=(Zgeom2(j)-Zgeom2(j))/pi;
% condition on change of sign of g => recalculate initial Rg
if (ggeom(j)*ggeom(j-1)==0) && (Rg0<lmt)
Rg0=Rg_initial(x0,g,rhol,rhog,mul,mug,m,D);
end
[Z Rg]=ode45(@calcul_Rg_comp, [Zgeom1(j) Zgeom2(j)], [Rg0 x0 P0]);
n1=length(Zz);
n2=length(Z);
Rg0=Rg(n2,1);
x0=Rg(n2,2);
P0=Rg(n2,3);
N(j)=length(Z); % number of iterations in each g
for ij=n1+1:n1+n2
Zz(ij)=Z(ij-n1);
Rgg(ij)=Rg(ij-n1,1);
x(ij)=Rg(ij-n1,2);
P(ij)=Rg(ij-n1,3);
end
end
Z_g=Zz;
x_g=x; % to leave x free
Rg_g=Rgg;
P_g=P;
N_g=N;
%% velocity calculation
Jgg=G.*x./rhog;
Jll=G.*(1-x)./rhol;
Ugg=Jgg./Rgg;
Ull=Jll./(1.-Rgg);
%% temperature computation
[Tp_S_G Tc_S_G h_S_G]=temp_S_G;
[Tp_K Tc_K h_K]=temp_K;
[Tp_G_W Tc_G_W h_G_W]=temp_G_W;
%% compute pressure and temperature loss between
%% inlet and outlet
Delta_P=P_g(1)-P_g(length(P_g));
for i=2:length(Psat)
if (P(length(P))<=Psat(i)) && (P(length(P))>Psat(i-1))
Tf_min=(Tsat(i)-Tsat(i-1))/(Psat(i)-Psat(i-1))*(P(length(P))-Psat(i))+Tsat(i);
end
end
Delta_T=45-Tf_min;
%% Tmax curves
T_max=zeros(length(x_g),1);
for i=1:length(x_g)
if Z_g(i)<45
T_max(i)=65;
else
T_max(i)=80;
end
end
end
%% solving equations without gravity
if (sim==2) || (sim==0)
ggeom=zeros(length(ggeom),1); % null gravity here
Tf=45; % initial temperature
for i=2:length(Tsat)
if (Tf<=Tsat(i)) && (Tf>Tsat(i-1))
rhol=(rhol_R245FA(i)-rhol_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+rhol_R245FA(i);
rhog=(rhog_R245FA(i)-rhog_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+rhog_R245FA(i);
mul=(mul_R245FA(i)-mul_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+mul_R245FA(i);
mug=(mug_R245FA(i)-mug_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+mug_R245FA(i);
Hl=(Hl_R245FA(i)-Hl_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+Hl_R245FA(i);
Hg=(Hg_R245FA(i)-Hg_R245FA(i-1))/(Tsat(i)-Tsat(i-1))*(Tf-Tsat(i))+Hg_R245FA(i);
hlg=Hg-Hl;
end
end
g=ggeom(1);
x0=0.3; % initial title between 0 and 0.3
P0=0.3e6; % saturation vapor pressure at 45 degsC
Rg0=Rg_initial(x0,g,rhol,rhog,mul,mug,m,D);
[Z Rg]=ode45(@calcul_Rg_comp, [Zgeom1(1) Zgeom2(1)], [Rg0 x0 P0]);
Zz=Z;
Rgg=Rg(:,1);
x=Rg(:,2);
P=Rg(:,3);
Rg0=Rgg(length(Zz));
x0=x(length(Zz));
P0=P(length(Zz));
N(1)=length(Z);
for j=2:length(Zgeom1)
q=qgeom(j);
g=ggeom(j);
k=k_coude(j);
Z1=Zgeom1(j);
Z2=Zgeom2(j);
R=(Zgeom2(j)-Zgeom2(j))/pi;
[Z Rg]=ode45(@calcul_Rg_comp, [Zgeom1(j) Zgeom2(j)], [Rg0 x0 P0]);
n1=length(Zz);
n2=length(Z);
Rg0=Rg(n2,1);
x0=Rg(n2,2);
P0=Rg(n2,3);
N(j)=length(Z); % number of iterations in each g
for ij=n1+1:n1+n2
Zz(ij)=Z(ij-n1);
Rgg(ij)=Rg(ij-n1,1);
x(ij)=Rg(ij-n1,2);
P(ij)=Rg(ij-n1,3);
end
end
Z_no_g=Zz;
x_no_g=x;
Rg_no_g=Rgg;
P_no_g=P;
%% velocity calculation
Jgg=G.*x./rhog;
Jll=G.*(1-x)./rhol;
Ugg_no_g=Jgg./Rg_no_g;
Ull_no_g=Jll./(1.-Rg_no_g);
%% temperature calculation
[Tp_S_G_no_g Tc_S_G_no_g h_S_G_no_g]=temp_S_G;
[Tp_K_no_g Tc_K_no_g h_K_no_g]=temp_K;
[Tp_G_W_no_g Tc_G_W_no_g h_G_W_no_g]=temp_G_W;
%% compute pressure and temperature loss between
%% inlet and outlet
Delta_P_no_g=P_no_g(1)-P_no_g(length(P_no_g));
for i=2:length(Psat)
if (P_no_g(length(P_no_g))<=Psat(i)) && (P_no_g(length(P_no_g))>Psat(i-1))
Tf_min_no_g=(Tsat(i)-Tsat(i-1))/(Psat(i)-Psat(i-1))*(P_no_g(length(P_no_g))-Psat(i))+Tsat(i);
end
end
Delta_T_no_g=45-Tf_min_no_g;
%% Tmax curves
T_max_no_g=zeros(length(x_no_g),1);
for i=1:length(x_no_g)
if Z_no_g(i)<45
T_max_no_g(i)=65;
else
T_max_no_g(i)=80;
end
end
end
%% figures
if sim==1
figure(1)
plot(Z_g,Rg_g)
xlabel('Length of tubing')
ylabel('Vapour fraction Rg')
title('Evolution of vapour fraction in tubing, with gravity')
figure(2)
plot(Z_g,x_g)
xlabel('Length of tubing')
ylabel('Quality x')
title('Evolution of quality in tubing, with gravity')
figure(3)
plot(Z_g,Ugg)
hold on
plot(Z_g,Ull,'cyan')
hold off
xlabel('Length of tubing')
ylabel('Phase velocity')
title('Evolution of velocity in tubing, with gravity')
legend('vapour velocity, with gravity','liquid velocity, with gravity','location','Northwest')
figure(4)
plot(Z_g,P_g)
xlabel('Length of tubing')
ylabel('Pressure P')
title('Evolution of pressure in tubing, with gravity')
figure(5)
plot(Z_g,Tp_S_G)
hold on
plot(Z_g,Tp_G_W,'g')
plot(Z_g,Tp_K,'r')
hold off
xlabel('Length of tubing')
ylabel('Wall temperature')
title('Evolution of wall temperature in tubing, with gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
figure(7)
plot(Z_g,Tc_S_G)
hold on
plot(Z_g,Tc_G_W,'g')
plot(Z_g,Tc_K,'r')
plot(Z_g,T_max,'color',[1 1/2 0])
hold off
str1(1)={'Maximum temperature'};
text(20,67,str1,'color',[1 1/2 0])
xlabel('Length of tubing')
ylabel('Component temperature')
title('Evolution of component temperature in tubing, with gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
%% write results in a txt file
write_results;
fclose('all');
end
if sim==0
figure(1)
plot(Z_no_g,Rg_no_g,'r')
xlabel('Length of tubing')
ylabel('Vapour fraction Rg')
title('Evolution of vapour fraction in tubing, without gravity')
figure(2)
plot(Z_no_g,x_no_g,'r')
xlabel('Length of tubing')
ylabel('Quality x')
title('Evolution of quality in tubing, without gravity')
figure(3)
hold on
plot(Z_no_g,Ugg_no_g,'r')
plot(Z_no_g,Ull_no_g,'color',[1 0.5 0])
hold off
xlabel('Length of tubing')
ylabel('Phase velocity')
title('Evolution of velocity in tubing, without gravity')
legend('vapour velocity, without gravity','liquid velocity, without gravity','location','Northwest')
figure(4)
plot(Z_no_g,P_no_g,'r')
xlabel('Length of tubing')
ylabel('Pressure P')
title('Evolution of pressure in tubing, without gravity')
figure(6)
plot(Z_no_g,Tp_S_G_no_g)
hold on
plot(Z_no_g,Tp_G_W_no_g,'g')
plot(Z_no_g,Tp_K_no_g,'r')
hold off
xlabel('Length of tubing')
ylabel('Wall temperature')
title('Evolution of wall temperature in tubing, without gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
figure(8)
plot(Z_no_g,Tc_S_G_no_g)
hold on
plot(Z_no_g,Tc_G_W_no_g,'g')
plot(Z_no_g,Tc_K_no_g,'r')
plot(Z_no_g,T_max_no_g,'color',[1 1/2 0])
hold off
str1(1)={'Maximum temperature'};
text(20,67,str1,'color',[1 1/2 0])
xlabel('Length of tubing')
ylabel('Component temperature')
title('Evolution of component temperature in tubing, without gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
%% write results in a txt file
write_results_no_g;
fclose('all');
end
if sim==2
figure(1)
plot(Z_g,Rg_g)
hold on
plot(Z_no_g,Rg_no_g,'r')
hold off
xlabel('Length of tubing')
ylabel('Vapour fraction Rg')
title('Evolution of vapour fraction in tubing')
legend('with gravity','without gravity','location','Southeast')
figure(2)
plot(Z_g,x_g)
hold on
plot(Z_no_g,x_no_g,'r')
hold off
xlabel('Length of tubing')
ylabel('Quality x')
title('Evolution of quality in tubing')
legend('with gravity','without gravity','location','Southeast')
figure(3)
plot(Z_g,Ugg)
hold on
plot(Z_g,Ull,'cyan')
plot(Z_no_g,Ugg_no_g,'r')
plot(Z_no_g,Ull_no_g,'color',[1 0.5 0])
hold off
xlabel('Length of tubing')
ylabel('Phase velocity')
title('Evolution of velocity in tubing')
legend('vapour velocity, with gravity','liquid velocity, with gravity','vapour velocity, without gravity','liquid velocity, without gravity','location','Northwest')
figure(4)
plot(Z_g,P_g)
hold on
plot(Z_no_g,P_no_g,'r')
hold off
xlabel('Length of tubing')
ylabel('Pressure P')
title('Evolution of pressure in tubing')
legend('with gravity','without gravity')
figure(5)
plot(Z_g,Tp_S_G)
hold on
plot(Z_g,Tp_G_W,'g')
plot(Z_g,Tp_K,'r')
hold off
xlabel('Length of tubing')
ylabel('Wall temperature')
title('Evolution of wall temperature in tubing, with gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
figure(6)
plot(Z_no_g,Tp_S_G_no_g)
hold on
plot(Z_no_g,Tp_G_W_no_g,'g')
plot(Z_no_g,Tp_K_no_g,'r')
hold off
xlabel('Length of tubing')
ylabel('Wall temperature')
title('Evolution of wall temperature in tubing, without gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
figure(7)
plot(Z_g,Tc_S_G)
hold on
plot(Z_g,Tc_G_W,'g')
plot(Z_g,Tc_K,'r')
plot(Z_g,T_max,'color',[1 1/2 0])
hold off
str1(1)={'Maximum temperature'};
text(20,67,str1,'color',[1 1/2 0])
xlabel('Length of tubing')
ylabel('Component temperature')
title('Evolution of component temperature in tubing, with gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
figure(8)
plot(Z_no_g,Tc_S_G_no_g)
hold on
plot(Z_no_g,Tc_G_W_no_g,'g')
plot(Z_no_g,Tc_K_no_g,'r')
plot(Z_no_g,T_max_no_g,'color',[1 1/2 0])
hold off
str1(1)={'Maximum temperature'};
text(20,67,str1,'color',[1 1/2 0])
xlabel('Length of tubing')
ylabel('Component temperature')
title('Evolution of component temperature in tubing, without gravity')
legend('model of Schrock & Grossman','model of Gunger & Winterton','model of Kandlikar','location','Northwest')
%% write results in a txt file
write_results;
write_results_no_g;
fclose('all');
end