function [p,uf,ufg,vf,vfg,sf,sfg]=steam_p(t);
% steam_p(t) : H2O saturation properties tabulation for given temperature
% function [p,uf,ufg,vf,vfg,sf,sfg]=steam_p(t);
% Saturation water properties for liquid/ vapor two phase states
% Given Temperature, output saturation Pressure and other properties
% ******************************************************************
% This is written for 2.672 lab class
% Inputs: t = temperature in K, in the range of 273.16 to 647.29
% Outputs: p = pressure in Pa
%          uf,ufg,vf,vfg,sf,sfg are variable names following the definition
%          in 2.40, all in SI units (J,kg etc.)
% When the input temperature is outside the range of interpolation,
% all the output variables will be set to Zero.
%-------------------------------------------------------------------------------
%        Note that all the variables are assumed scalar quantities
%--------------------------------------------------------------------------------

%data table
y=[
  .01,  .6113E-03,  .9964E-03,  .2056E+03, .01,        .25010E+04, .0,         .91562e+01
  5.0, .87000E-03, .10000E-02, .14716E+03, .21010E+02, .24897E+04, .76210E-01, .89507E+01
 10.0, .12300E-02, .10003E-02, .10643E+03, .41990E+02, .24779E+04, .15099E+00, .87510E+01
 15.0, .17000E-02, .10008E-02, .77977E+02, .62940E+02, .24661E+04, .22432E+00, .85582E+01
 20.0, .23400E-02, .10017E-02, .57837E+02, .83860E+02, .24543E+04, .29630E+00, .83721E+01
 25.0, .31700E-02, .10029E-02, .43401E+02, .10477E+03, .24425E+04, .36701E+00, .81922E+01
 30.0, .42400E-02, .10043E-02, .32928E+02, .12566E+03, .24307E+04, .43651E+00, .80181E+01
 35.0, .56200E-02, .10060E-02, .25244E+02, .14656E+03, .24188E+04, .50487E+00, .78495E+01
 40.0, .73800E-02, .10078E-02, .19545E+02, .16745E+03, .24069E+04, .57212E+00, .76861E+01
 45.0, .95800E-02, .10099E-02, .15275E+02, .18835E+03, .23949E+04, .63832E+00, .75278E+01
 50.0, .12340E-01, .10121E-02, .12045E+02, .20926E+03, .23829E+04, .70351E+00, .73741E+01
 55.0, .15740E-01, .10145E-02, .95779E+01, .23017E+03, .23708E+04, .76772E+00, .72248E+01
 60.0, .19920E-01, .10171E-02, .76775E+01, .25109E+03, .23586E+04, .83099E+00, .70798E+01
 65.0, .25010E-01, .10199E-02, .62013E+01, .27203E+03, .23463E+04, .89334E+00, .69388E+01
 70.0, .31160E-01, .10228E-02, .50452E+01, .29297E+03, .23339E+04, .95482E+00, .68017E+01
 75.0, .38550E-01, .10259E-02, .41331E+01, .31394E+03, .23214E+04, .10154E+01, .66681E+01
 80.0, .47360E-01, .10292E-02, .34081E+01, .33492E+03, .23088E+04, .10753E+01, .65380E+01
 85.0, .57800E-01, .10326E-02, .28278E+01, .35592E+03, .22961E+04, .11343E+01, .64111E+01
 90.0, .70110E-01, .10361E-02, .23603E+01, .37694E+03, .22832E+04, .11925E+01, .62873E+01
 95.0, .84530E-01, .10399E-02, .19812E+01, .39799E+03, .22701E+04, .12500E+01, .61665E+01
100.0, .10133E+00, .10437E-02, .16720E+01, .41906E+03, .22569E+04, .13069E+01, .60485E+01
105.0, .12080E+00, .10477E-02, .14182E+01, .44017E+03, .22436E+04, .13630E+01, .59332E+01
110.0, .14327E+00, .10519E-02, .12089E+01, .46132E+03, .22300E+04, .14185E+01, .58203E+01
115.0, .16906E+00, .10562E-02, .10352E+01, .48250E+03, .22162E+04, .14733E+01, .57099E+01
120.0, .19854E+00, .10606E-02, .89046E+00, .50372E+03, .22022E+04, .15276E+01, .56017E+01
125.0, .23210E+00, .10652E-02, .76917E+00, .52499E+03, .21880E+04, .15813E+01, .54957E+01
130.0, .27013E+00, .10700E-02, .66707E+00, .54631E+03, .21736E+04, .16344E+01, .53917E+01
135.0, .31308E+00, .10750E-02, .58073E+00, .56768E+03, .21589E+04, .16869E+01, .52896E+01
140.0, .36138E+00, .10801E-02, .50741E+00, .58910E+03, .21440E+04, .17390E+01, .51895E+01
145.0, .41552E+00, .10853E-02, .44489E+00, .61059E+03, .21287E+04, .17905E+01, .50910E+01
150.0, .47600E+00, .10908E-02, .39136E+00, .63215E+03, .21132E+04, .18416E+01, .49941E+01
155.0, .54333E+00, .10964E-02, .34535E+00, .65377E+03, .20974E+04, .18923E+01, .48988E+01
160.0, .61806E+00, .11022E-02, .30565E+00, .67547E+03, .20813E+04, .19425E+01, .48050E+01
165.0, .70077E+00, .11082E-02, .27129E+00, .69725E+03, .20648E+04, .19922E+01, .47126E+01
170.0, .79202E+00, .11145E-02, .24144E+00, .71912E+03, .20479E+04, .20416E+01, .46214E+01
175.0, .89244E+00, .11209E-02, .21542E+00, .74107E+03, .20307E+04, .20906E+01, .45314E+01
180.0, .10027E+01, .11275E-02, .19267E+00, .76312E+03, .20132E+04, .21393E+01, .44426E+01
185.0, .11233E+01, .11344E-02, .17272E+00, .78526E+03, .19952E+04, .21876E+01, .43548E+01
190.0, .12551E+01, .11415E-02, .15517E+00, .80752E+03, .19767E+04, .22356E+01, .42680E+01
195.0, .13987E+01, .11489E-02, .13969E+00, .82988E+03, .19579E+04, .22833E+01, .41821E+01
200.0, .15549E+01, .11565E-02, .12600E+00, .85237E+03, .19386E+04, .23307E+01, .40971E+01
205.0, .17243E+01, .11644E-02, .11386E+00, .87499E+03, .19188E+04, .23778E+01, .40128E+01
210.0, .19077E+01, .11726E-02, .10307E+00, .89773E+03, .18985E+04, .24247E+01, .39293E+01
215.0, .21060E+01, .11811E-02, .93444E-01, .92063E+03, .18776E+04, .24713E+01, .38463E+01
220.0, .23198E+01, .11900E-02, .84848E-01, .94367E+03, .18563E+04, .25178E+01, .37639E+01
225.0, .25501E+01, .11992E-02, .77150E-01, .96688E+03, .18343E+04, .25641E+01, .36820E+01
230.0, .27976E+01, .12087E-02, .70241E-01, .99027E+03, .18117E+04, .26102E+01, .36006E+01
235.0, .30632E+01, .12187E-02, .64027E-01, .10138E+04, .17885E+04, .26561E+01, .35194E+01
240.0, .33478E+01, .12291E-02, .58425E-01, .10376E+04, .17646E+04, .27020E+01, .34386E+01
245.0, .36523E+01, .12399E-02, .53366E-01, .10616E+04, .17400E+04, .27478E+01, .33579E+01
250.0, .39776E+01, .12513E-02, .48786E-01, .10858E+04, .17146E+04, .27935E+01, .32773E+01
255.0, .43246E+01, .12632E-02, .44633E-01, .11102E+04, .16885E+04, .28392E+01, .31968E+01
260.0, .46943E+01, .12756E-02, .40858E-01, .11349E+04, .16615E+04, .28849E+01, .31161E+01
265.0, .50877E+01, .12887E-02, .37421E-01, .11599E+04, .16335E+04, .29306E+01, .30353E+01
270.0, .55058E+01, .13025E-02, .34286E-01, .11852E+04, .16046E+04, .29764E+01, .29541E+01
275.0, .59496E+01, .13170E-02, .31419E-01, .12109E+04, .15747E+04, .30222E+01, .28725E+01
280.0, .64202E+01, .13324E-02, .28794E-01, .12368E+04, .15436E+04, .30683E+01, .27903E+01
285.0, .69186E+01, .13487E-02, .26384E-01, .12632E+04, .15113E+04, .31146E+01, .27074E+01
290.0, .74461E+01, .13659E-02, .24169E-01, .12900E+04, .14776E+04, .31611E+01, .26237E+01
295.0, .80037E+01, .13844E-02, .22128E-01, .13173E+04, .14426E+04, .32079E+01, .25389E+01
300.0, .85927E+01, .14041E-02, .20245E-01, .13451E+04, .14060E+04, .32552E+01, .24529E+01
305.0, .92143E+01, .14252E-02, .18502E-01, .13734E+04, .13677E+04, .33029E+01, .23656E+01
310.0, .98700E+01, .14480E-02, .16886E-01, .14024E+04, .13276E+04, .33512E+01, .22766E+01
315.0, .10561E+02, .14726E-02, .15383E-01, .14321E+04, .12855E+04, .34002E+01, .21856E+01
320.0, .11289E+02, .14995E-02, .13980E-01, .14626E+04, .12411E+04, .34500E+01, .20923E+01
325.0, .12056E+02, .15289E-02, .12666E-01, .14940E+04, .11940E+04, .35008E+01, .19961E+01
330.0, .12863E+02, .15615E-02, .11428E-01, .15265E+04, .11436E+04, .35528E+01, .18962E+01
335.0, .13712E+02, .15978E-02, .10256E-01, .15603E+04, .10895E+04, .36063E+01, .17916E+01
340.0, .14605E+02, .16387E-02, .91417E-02, .15955E+04, .10307E+04, .36616E+01, .16811E+01
345.0, .15545E+02, .16858E-02, .80773E-02, .16325E+04, .96640E+03, .37192E+01, .15636E+01
350.0, .16535E+02, .17411E-02, .70580E-02, .16719E+04, .89571E+03, .37800E+01, .14376E+01
355.0, .17577E+02, .18085E-02, .60507E-02, .17166E+04, .81377E+03, .38489E+01, .12953E+01
360.0, .18675E+02, .18959E-02, .50439E-02, .17642E+04, .72127E+03, .39210E+01, .11390E+01
365.0, .19833E+02, .20160E-02, .39956E-02, .18180E+04, .61004E+03, .40021E+01, .95580E+00
370.0, .21054E+02, .22136E-02, .27591E-02, .18902E+04, .45256E+03, .41108E+01, .70359E+00
374.14,.22090e+02, .31550e-02, .0,         .20993e+04, .0,         .44298e+01, .0];

ttab	=y(:,1)+273.15;
ptab	=y(:,2)*1e6;
vftab	=y(:,3);
vfgtab	=y(:,4);
hftab	=y(:,5)*1e3;
hfgtab	=y(:,6)*1e3;
sftab	=y(:,7)*1e3;
sfgtab	=y(:,8)*1e3;
uftab	=hftab-ptab.*vftab;
ufgtab	=hfgtab-ptab.*vfgtab;
clear y
%----------------------------------------------------
tmax=647.29;       %range of temperature (K)
tmin=273.16;
p  =0;
uf =0;
ufg=0;
vf =0;
vfg=0;
sf =0;
sfg=0;

if (t<=tmax) & (t>=tmin);
%+++++++++++++++++++interpolate++++++++++
p       =interp1(ttab,ptab,t);
uf      =interp1(ttab,uftab,t);
ufg     =interp1(ttab,ufgtab,t);
vf      =interp1(ttab,vftab,t);
vfg     =interp1(ttab,vfgtab,t);
sf      =interp1(ttab,sftab,t);
sfg     =interp1(ttab,sfgtab,t);
%++++++++++++++++++++++++++++++++++++++++
else;
disp('input temperature outside two phase range of 273.16 to 647.29 K')
disp(t)
end;
