In: Mechanical Engineering
write a Fortran 77 language code for vapour absorption air source water heat pump producing 70k temperature
"!This problem demonstrates the use of user-written functions in
EES. Logic constructs
such as IF-THEN-ELSE and REPEAT-UNTIL can only be implemented in
functions and
procedures."
function Add1(x)
$Common AddMe
{a simple function that just adds the value in variable Addme to
the supplied value. Note that $Common allows values that are
defined in the Main program to be accessed (but not changed) in
Functions and Procedures.}
x:=x+Addme
add1:=x
end
function IfTest(x,y)
{demonstration of the one-line form of the IF-THEN-ELSE
logic.}
if (x<y) then a:=x*y else a:=x/y
IfTest:=a;
end;
function IfGoTo(x,y)
{goto statements are supported, but usually not needed.}
if (x<y) then goto 10
a:=x
b:=y
goto 20
10: a:=y
b:=x
20: c:=a/b
IfGoTo:=a/b
end
function IfBlock(x,y)
{demonstration of the block form of the IF-THEN-ELSE
statement.}
if (x<y) then
a:=y
b:=x
else
a:=x
b:=y
endif
IfBlock:=a/b
end
FUNCTION Factorial(N)
{calculates N factorial using the REPEAT-UNTIL construct.}
F:=1
Repeat
F:=F*N
N:=N-1
Until (N=1)
Factorial=F
END
Addme=1 "This variable will be used in the Add1 function"
g=Add1(1)
h=ifTest(3,4)
j=IfGoTo(5,6)
k=IfGoTo(5,6)
m=factorial(5)
$TabWidth 0.5 cm
"!Regenerative Rankine Cycle with 2 feedwater heaters"
"Purpose: Investigate the effect of pressures of two feedwater heaters on the efficiency of a Rankine - regenerative cycle. The cycle analysis is done for unit steam flow through the boiler. P[2] is the pressure of the low pressure feedwater heater which in this example is fixed at 200 psia in the Parametric table. P[4] is the higher extraction pressure which is varied in the table.
This problem demonstrates the use of Procedures. The parameters to the left of the : in the Procedure/Call statements are inputs. Outputs appear to the right of the colon. A Call statement references the Procedure.
Arrays are used for state variables so that the values can be plotted. In this case the cycle efficiency is plotted against the extraction pressure.
To run, select Solve Table from the Calculate menu.
"
PROCEDURE pump(P_in,P_out,Eff :h_in,h_out,W_p)
h_in:=ENTHALPY(STEAM,P=P_in,x=0);
v:=volume(STEAM,P=P_in,x=0)
W_p:=v*(P_in-P_out)/Eff*Convert((ft^3/lb_m)*(psia),Btu/lb_m)
h_out:=h_in-W_p
END
PROCEDURE turbine(h_in,P_in,P_out,Eff :h_out,W_t)
s_in:=entropy(STEAM,h=h_in,P=P_in)
h_out_id:=enthalpy(STEAM,s=s_in,P=P_out)
W_t:=(h_in-h_out_id)*Eff
h_out:=h_in-W_t
END
eta_turb=0.84
"Isentropic turbine efficiency; same for all turbines"
eta_pump=0.65
"Isentropic pump efficiency; same for all pumps"
"!Pump 3"
P[1]=1 [psia]
CALL Pump(P[1],P[2],eta_pump:h[1],h[2],W_p_3)
"!Pump 2"
CALL Pump(P[3],P[4],eta_pump:h[3],h[4],W_p_2)
"!Pump 1"
CALL Pump(P[5],P[6],eta_pump:h[5],h[6],W_p_1)
"!Boiler"
P[6]=P[7]
"neglect pressure drop thru boiler"
P[7]=900 [psia]
h[7]=enthalpy(STEAM,T=800,P=P[7])
Q=h[7]-h[6]
"!Turbine 1"
CALL Turbine(h[7],P[7],P[8],eta_turb:h[8],W_t_1)
P[8]=P[4]
"!Turbine 2"
CALL Turbine(h[8],P[8],P[9],eta_turb:h[9],W_t_2)
P[9]=P[2]
"!Turbine 3"
CALL Turbine(h[9],P[9],P[10],eta_turb:h[10],W_t_3)
P[10]=P[1]
"!Feedwater Heater 2"
P[3]=P[2]
f_2*h[9]+(1-f_2)*h[2]=h[3]
"!Feedwater Heater 1"
P[5]=P[4]
f_1*h[8]+(1-f_1)*h[4]=h[5]
"!Cycle Statistics"
W_t=W_t_1+(1-f_1)*(W_t_2)+(1-f_1)*(1-f_2)*W_t_3
W_p=W_p_1+(1-f_1)*W_p_2+(1-f_1)*(1-f_2)*W_p_3
W_net=W_t-W_p
Eff=W_net/Q
DUPLICATE i=1,10
T[i]=temperature(STEAM,h=h[i],P=P[i])
END
$Tabstops 0.25 1.5 in