1function [work, efficiency] = rankine(t1, p2, eta_pump, eta_turbine)
2%
3% This example computes the efficiency of a simple vapor power cycle.
4%
5help rankine
6
7% create an object representing water
8w = Water;
9
10% start with saturated liquid water at t1
11set(w,'T',t1,'Liquid',1.0);
12p1 = pressure(w);
13
14% pump it to p2
15pump_work = pump(w, p2, eta_pump);
16h2 = enthalpy_mass(w);
17p2 = pressure(w);
18
19% heat to saturated vapor
20set(w,'P',p2,'Vapor',1.0);
21h3 = enthalpy_mass(w);
22
23heat_added = h3 - h2;
24
25% expand adiabatically back to the initial pressure
26work = expand(w, p1, eta_turbine);
27
28% compute the efficiency
29efficiency = (work - pump_work)/heat_added;
30
31
32function w = pump(fluid, pfinal, eta)
33% PUMP - Adiabatically pump a fluid to pressure pfinal, using a pump
34% with isentropic efficiency eta.
35%
36h0 = enthalpy_mass(fluid);
37s0 = entropy_mass(fluid);
38set(fluid, 'S', s0, 'P', pfinal);
39h1s = enthalpy_mass(fluid);
40isentropic_work = h1s - h0;
41actual_work = isentropic_work / eta;
42h1 = h0 + actual_work;
43set(fluid, 'H',h1, 'P',pfinal);
44w = actual_work;
45
46
47function w = expand(fluid, pfinal, eta)
48% EXPAND - Adiabatically expand a fluid to pressure pfinal, using a
49% turbine with isentropic efficiency eta.
50%
51h0 = enthalpy_mass(fluid);
52s0 = entropy_mass(fluid);
53set(fluid, 'S', s0, 'P', pfinal);
54h1s = enthalpy_mass(fluid);
55isentropic_work = h0 - h1s;
56actual_work = isentropic_work * eta;
57h1 = h0 - actual_work;
58set(fluid, 'H',h1, 'P',pfinal);
59w = actual_work;
60