-
Notifications
You must be signed in to change notification settings - Fork 0
/
ns_isot_comp.m
60 lines (48 loc) · 1.06 KB
/
ns_isot_comp.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
% INIST -
% Interpolation of Nonideal Idiosyncratic Splendiferous Tables
% (c) Manel Soria - ETSIAT - UPC - 2014 A.D.
function [dat,q,w,Tv,pv,hv,sv]=ns_isot_comp(dat,n,Tin,pin,pout)
% T(K), p (bar)
% n intermediate stages vapour compression
% each stage is formed by an isentropic compression followed by
% isobaric cooling until Tin is reached
% initial pressure is pin, final pressure is pout
% returns:
% q: total heat kJ/kg
% w: total work kJ/kg
% Tv: temperature vector (1..2n+1)
% pv: pressure
% hv: enthalpy
% sv: entropy
f=(pout/pin)^(1/n)
Tv(1)=Tin;
pv(1)=pin;
for i=2:2*n+1
if mod(i,2)==0
pv(i)=pv(i-1)*f;
else
pv(i)=pv(i-1);
Tv(i)=Tin;
end
end
for i=1:2*n+1
dat=INIST(dat,'add_p',pv(i));
end
for i=1:2:2*n+1
hv(i)=INIST(dat,'h_pt',pv(i),Tv(i));
sv(i)=INIST(dat,'s_pt',pv(i),Tv(i));
end
for i=2:2:2*n
sv(i)=sv(i-1);
Tv(i)=INIST(dat,'t_ps',pv(i),sv(i));
hv(i)=INIST(dat,'h_pt',pv(i),Tv(i));
end
q=0;
w=0;
for i=1:2:2*n-1
w=w+hv(i+1)-hv(i);
end
for i=2:2:2*n
q=q+hv(i+1)-hv(i);
end
end