Project 2 - Rankine cycle Simulator
AIM=To create Rankine cycle
The Rankine cycle is an idealized thermodynamic cycle of a constant pressure heat engine that converts part of heat into mechanical work. In this cycle, the heat is supplied externally to a closed loop, which usually uses water (in a liquid and vapor phase) as the working fluid.

Here
Process & State points Explanation:
state1___ is vapor point
state2__ is liquid+ vapor point
state3__ is is liquid saturation point
state4___ is a liquid point
state5__is aliquid saturation point
state6__is avapor saturation point
process b/w 1_2___ Isentropic Expansion process ,here as per thermodynamics, change in volume occurs for which the expansion takes place , results in decrease in pressure & temp because of total heat transferd into work produced ..p dvwhich is constant entropy process . here the work is done isentropically/adiabatically ,without temp difference ,
so work produced =p*dv
In rankine cycle the super heated vapor is expanded isentropically ,due this the some amt of heat energy is converted into workproduced..is discharged to the condenser (partially condensed). The steam works on the surroundings (blades of the turbine) and loses an amount of enthalpy equal to the work that leaves the system. The work done by the turbine is given by WT = h2-h1. Again the entropy remains unchanged.
Isobaric heat rejection (in a heat exchanger) – In this phase, the cycle completes by a constant-pressure process in which heat is rejected from the partially condensed steam. There is heat transfer from the vapor to cooling water flowing in a cooling circuit. The vapor condenses, and the temperature of the cooling water increases. The net heat rejected is given by Qre = h3-h2
Isobaric heat addition (in a heat exchanger – boiler) – In this phase (between state 4 and state 1), there is a constant-pressure heat transfer to the liquid condensate from an external source since the chamber is open to flow in and out. The feedwater is heated to the boiling point of that fluid and then evaporated in the boiler The net heat added is given by Qadd = h1 – h4
Isentropic compression:
During isentropic compression the where the volume changes due to changes volume the pressure & temp decreases here the feed water compress isentropically /adiabatically produce workdone without temp difference ie.,Q=0
win= h3-h4
%Rankine cycle
clear all
close all
clc
fprintf("\n RANKINE cycle simulator ");
fprintf(" \n\n1-2 is isentropic expansion in the turbine");
fprintf("\n\n2-3 is constant pressure heat rejection in the condensor");
fprintf("\n\n3-4 is isentropic compression process");
fprintf("\n\n4-1 is constant heat addition in the boiler");
%state points: Description
%state point1_we have (super heated vapor) only_ so,high temp's & pressures
%state point2_We have (saturated liquid+vapor)_so low temp's & pressures
%state point3_We have (saturated liquid) only_so,low temp's & pressures
%state point4_We have (liquid) only _so,some high temp's & pressures
%state point5_We have (saturated liquid) only_some high temp's & pressures
%state point6_We have(saturated vaopr) only_hig temp's & pressures
% Given inputs
p1=input("\n Enter the pressure at the turbine inlet (in bar):");
t1=input(" \n Enter the temperature at the turbine inlet (in degree celcius ):");
p2=input("\n Enter the pressure at the condensor inlet (in bar):");
%At state point 1__only vopor content
p1=30;
t1=400;
h1=XSteam('h_pt',p1,t1);%Enthalpy
s1=XSteam('s_pt',p1,t1);%entropy
v1=XSteam('v_pt',p1,t1);%specific volume
%At state point 2___ liqid+vapor content/saturation/condensation point
s2=s1;
p2=0.05;
t2=XSteam('Tsat_p',p2);
hf2=XSteam('hL_p',p2);
hg2=XSteam('hV_p',p2);
sf2=XSteam('sL_p',p2);
sg2=XSteam('sV_p',p2);
x2=((s2-sf2)/(sg2-sf2));
h2=hf2+(x2*(hg2-hf2));
%state point 3__liquid only content/saurationliquid
t3=t2;
p3=p2;
h3=XSteam('hL_p',p3);
s3=XSteam('sL_p',p3);
v3=XSteam('vL_p',p3);
% State point 4
s4=s3;
p4=p1;
cp4=XSteam('cp_ps',p4,s4);
cv4=XSteam('cv_ps',p4,s4);
g4=(cp4/cv4);
o=(g4-1)/g4;
t4=t3*(p4/p3)^o;
%work done by pump
wp=v3*(p4-p3)*100;
h4=h3+wp;
%At state point 5
h5=XSteam('hL_p',p1);
s5=XSteam('sL_p',p1);
t5=XSteam('Tsat_p',p1);
%At state point 6
h6=XSteam('hV_p',p1);
s6=XSteam('sV_p',p1);
t6=t5;
Qin=(h4-h1);
Qout=(h3-h2);
wout=(h1-h2);
win=(h3-h4);
Wnet=(win-wout);
efficiency=Wnet/Qin;
%creating temp array
T=linspace(0,400,1000);
%Creating saturation curve by [Enthalpy & Entropy]
for i=1:length(T)
sf(i)=XSteam('sL_T',T(i));
sg(i)=XSteam('sV_T',T(i));
hf(i)=XSteam('hL_T',T(i));
hg(i)=XSteam('hV_T',T(i));
end
%plotting
%T_S diagram
figure(1)
hold on
plot(sf,T)
plot(sg,T)
xlabel('Entropy')
ylabel('temp')
title('Rankine_cycle ')
text(2.14,180,'liquid_line')
text(6.3,208,'vapor_line')
text(6.92,400,'state point (1)')
text(6.1,233.8,' (6)')
text(2.6,233.8, '(5)')
text(0.47,32,'(3)')
text(6.9,32.8,'(2)')
%H_S diagram
plot([s1,s2],[t1,t2])
plot([s2,s3],[t2,t3])
plot([s5,s6],[t5,t6])
plot([s6,s1],[t6,t1])
plot([s5,s3],[t5,t3])
figure(2)
hold on
plot(sf,T)
plot(sg,T)
xlabel('Entropy')
ylabel('enthalpy')
title('Rankine_cycle')
plot([s1,s4],[h1,h4])
plot([s2,s3],[h2,h3])
plot([s1,s2],[h1,h2])
plot([s4,s3],[h4,h3])
text(0.47,137.7,'state points (3),(4)')
text(6.92,15621.4,'state point (1)')
text(6.9,3231.5,'state point (2)')


since rankine cycle works on water,so water is a pure substance
A substance that has fixed chemical composition throughout is called pure substance.
phase's of pure substance_solid ,liquid ,gas
phase transformation:in solids
1_Molecules in a solid are closely packed together
2_because of small distance b/w molecules the attractive forces of molecules are large & strong &keep at fixed position.
3_attractive forces turn into repulsive forces when d=0
4_cannot move with relative to each other & oscillate about their fixed position
5_the velocity of molecules depends on temp
In liquids:
1_molecular spacing will be distance..
2_the molecules no longer at fixed position
3_attractive forces are small because of their distance.
In gaseous;
1_the molecules are far apart from each other
2_increases randomness.&continiously colliding with each other & walls of the container.
3_Molecules in gas phase are at considerably higher energy levels
4_so Gas must release a large amt of its energy before its condense it.
saturated liquid:
AS heat transfered untill it reaches 100c.and at this point still liquid but any heat addition leads to vaporise.the liquid about to vaporise or phase change process occurs.
saturated vapor:
Any heat loss from this vapor,will cause some of the vapor to condensate a phase change process
superheated vapor:
As a single phase the furthur transfer of heat increases both temp & specific volume,if we transfer some heat from vapor the temp drop somewhat but no condensation will take place as long as the temp remains above 100c is called superheated steam.