📄 wtp_up.m
字号:
function [outstruct] = WTP_uP(u,P)
% -----------------------------------------------------------------
% function [outstruct] = WTP_PT(u,P)
%
% written by Francois Brissette in April 2005,
% based on original work by Philippe Daigle, May 2002
%
% calculates basic thermodynamic properties for water,
% follows IAPWS-97 formulation, Region 3 and 5 have NOT
% been implemented. This has been programmed for use by
% engineering students and regions 1, 2 and 4 cover the
% useful range. See www.iapws.org for the paper describing
% the formulation in details
%
% you are free to use, modify and distribute the functions as long
% as authorship is properly acknowledged
%
% INPUTS:
% u internal energy in kJ/kg
% P in kPa
%
% OUPUT:
% outstruct - a structure of strings that contains the following:
% pressure in kPa, temperature in C, specific volume in m3/kg,
% internal energy in kJ/kg, enthalpy in kJ/kg, entropy in kJ/kg/K
% as well as two messages giving info such as the state or error message
% in the case of incorrect data entry
%
% NB: This function does not use the reverse equations of the formulation
% but iterated using the direct equations for P and T. Results will
% be identical up to the tolerance defined in the function. Default is
% 10^-7
%
Pg=0; Tg=0; vg=0; ug=0; sg=0; hg=0;
Pf=0; Tf=0; vf=0; uf=0; sf=0; hf=0;
info_msg='';
info_msg_2='';
CK=273.15;
P=P/1000; % kPa to MPa
% first step - establish the thermodynamic state by supposing first that
% consitions are saturated
%
T=Pressure_State(P);
if P <= 16.53
[Pg,Tg,vg,ug,sg,hg] = property_PT(P,T,2); % Region 4 for steam
[Pf,Tf,vf,uf,sf,hf] = property_PT(P,T,1); % Region 1 for supercooled liquid
if u < ug & u > uf
state=3; % saturated
end
if u < uf
[Pf,Tf,vf,u_test,sf,hf] = property_PT(P,0.0001,1);
state=1; % supercooled liquid
end
if u > ug
state=2; % superheated vapour
end
end
if P > 16.53 % either it's condensed liquid if T < 350, superheated vapour if in region 2, or it is out of range (region 3)
n3=.0010192970039326;
n4=572.54459862746;
n5=13.918839778870;
Ttest=n4+sqrt((P-n5)/n3);
[Pg,Tg,vg,u_test2,sg,hg] = property_PT(P,350+CK,1); % verify the volume for condensed liquid at 350
if u<u_test2 % we are in region 1
state=1;
end
if Ttest>863.15 % T at which P = 100MPa along the line separating regions 2 and 3
Ttest=863.15;
end
[Pg,Tg,vg,ug,sg,hg] = property_PT(P,Ttest,2); % Region 2
if u > ug
state=2; % superheated vapour
end
if u < ug & u > u_test2
state=4; % out of range
end
if P > 100
state=4; % outside of range
end
end
[Pg,Tg,vg,u_test3,sg,hg] = property_PT(P,800+CK,2); % Region 2
if u > u_test3
state=4;
end
if T < 273.15001 % basic quality control
state=5;
end
if u < 0.00001 % basic quality control
state=6;
end
if state==1 % Liquide comprim
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -