FORTRAN CODE
program steam_table real p(6),t(6),v(6),p1,p2,t1,t2,v1,v2,ps,ts,vg data p/10.0,11.0,12.0,13.0,14.0,15.0/ data t/179.9,184.1,188.0,191.6,195.0,198.3/ data v/0.1944,0.1774,0.1632,0.1512,0.1408,0.1317/ read*,ps do i=1,6 if(ps .le. p(i)) then p1=p(i-1) p2=p(i) t1=t(i-1) t2=t(i) v1=v(i-1) v2=v(i) goto 10 endif enddo 10 call steam (ps,p1,p2,t1,t2,ts) call steam (ps,p1,p2,v1,v2,vg) print*,ps,ts,vg end subroutine steam (x,x1,x2,y1,y2,y) real x,y,x1,x2,y1,y2 y=((y2-y1)/(x2-x1))*(x-x1)+y1 end
MATLAB CODE
% Steam Table Program clear, clc ps=input ('Input ps (10 <= ps <= 15)\n'); [ts, vg] = steamtable (ps) function [ts, vg] = steamtable(ps) % Steam table data p=[10, 11, 12, 13, 14, 15]; t=[179.9, 184.1, 188, 191.6, 195, 198.3]; v=[0.1944, 0.1774, 0.1632, 0.1512, 0.1408, 0.1317]; % Linear interpolation ts=interp1(p, t, ps); vg=interp1(p, v, ps); end
EES CODE
$UnitSystem SI Mass kJ C bar Deg T_s=t_sat(Steam,P=12.3 [bar]) "Saturation Temperature" v_g=volume(Steam,P=12.3 [bar], x=1 [-]) "Specific volume"