-
Notifications
You must be signed in to change notification settings - Fork 4
/
NFP_plotisobar.m
104 lines (88 loc) · 2.45 KB
/
NFP_plotisobar.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
function NFP_plotisobar(dat,pv,varargin)
% NFP -
% Non-ideal Fluid Properties (previously INIST)
% (c) Manel Soria, Caleb Fuster, Lorenzo Frezza
% Data downloaded from NIST web page
% ESEIAAT - UPC - 2014-2020
%
% NFP_plotisobar(dat,p,color,thickness)
% NFP_plotisobar: plot isobar vector
% dat: species
% p: isobar vector
% color (optional): isobar colors
% thickness (optional): line thickness
%
% examples:
% NFP_plotisobar('N2',[10,20],'k',2)
global IND
path = fileparts(which(mfilename));
addpath(genpath(path));
try
if isempty(IND) || ~isfield(IND,dat)
set = load(dat);
IND.(dat) = set.(dat);
end
catch
error('%s not found',dat)
end
switch numel(varargin)
case 0
color='k';
thickness=1;
case 1
color=varargin{1};
thickness=1;
case 2
color=varargin{1};
thickness=varargin{2};
otherwise
error('uhh too many arguments');
end
for j=1:length(pv)% plot isobar number j
ok = 0;
for ii=1:length(IND.(dat).isoP)
if IND.(dat).isoP{ii}.P==pv(j)
plot(IND.(dat).isoP{ii}.s,IND.(dat).isoP{ii}.T,color,'LineWidth',thickness);
hold on
ok = 1;
break;
end
if ii < length(IND.(dat).isoP) && IND.(dat).isoP{ii+1}.P > pv(j) && IND.(dat).isoP{ii}.P < pv(j)
Snext = IND.(dat).isoP{ii+1}.s;
Sprev = IND.(dat).isoP{ii}.s;
Pnext = IND.(dat).isoP{ii+1}.P;
Pprev = IND.(dat).isoP{ii}.P;
Tprev = IND.(dat).isoP{ii}.T;
Tnext = IND.(dat).isoP{ii+1}.T;
lprev = length(Sprev);
lnext = length(Snext);
if lnext ~= lprev
if lnext < lprev
Sprev = Sprev(2:end);
Tprev = Tprev(2:end);
else
Snext = Snext(2:end);
Tnext = Tnext(2:end);
end
end
S = (Snext - Sprev) ./ (Pnext -Pprev) .* (pv(j) - Pprev) + Sprev;
T = (Tnext+Tprev)/2;
plot(S,T,color,'LineWidth',thickness);
hold on
ok = 1;
break;
end
end
if ok == 0
error('Isobar (%e) not found',pv(j))
end
end
% plot saturation bell
plot(IND.(dat).sl,IND.(dat).Tsat,'r','LineWidth',thickness);
plot(IND.(dat).sv,IND.(dat).Tsat,'r','LineWidth',thickness);
title(IND.(dat).name);
xlabel('s (kJ/kgK)');
ylabel('T (K)');
grid
return
end