Project 2 - Rankine cycle Simulator
Rankine Cycle Project.
Aim:
This project aims to develop a Rankine Cycle Simulator using OCTAVE/MATLAB. The simulator will calculate the state points of the Rankine Cycle based on user inputs and generate corresponding T-s (Temperature-Entropy) and h-s (Enthalpy-Entropy) plots. The project also includes creating a detailed report explaining the workings of the Rankine cycle simulator, the research conducted, and the steps taken to overcome programming errors.
Objectives:
1. Understand the Rankine cycle concept by referencing standard thermal engineering textbooks.
2. Implement a Rankine Cycle Simulator in OCTAVE/MATLAB that:
- Calculates state points of the Rankine Cycle based on user inputs.
- Plots T-s and h-s diagrams for the given inputs with proper labeling.
3. Generate a comprehensive report including:
- Step-by-step explanation of the code.
- Identification of errors encountered during programming.
- Description of how errors were resolved.
- Inclusion of screenshots displaying errors from the command window.
4. Utilize the Xsteam library to access steam table data for water to calculate state points in between variables.
5. Perform calculations for the net work output and back work ratio of the Rankine Cycle.
Description:
The project involves creating a Rankine Cycle Simulator that simulates the thermodynamic processes of a Rankine cycle. The simulator will take user inputs for turbine inlet temperature, turbine inlet pressure, and turbine outlet pressure (condenser inlet pressure). It will then calculate state points, generate T-s and h-s plots, and compute the net work output and back work ratio.
The Rankine cycle is a fundamental thermodynamic cycle used in power plants to convert heat into mechanical work. By understanding and simulating this cycle, engineers can optimize power plant efficiency and performance.
By developing this Rankine Cycle Simulator, users can visualize the thermodynamic processes involved in a Rankine cycle and analyze key parameters such as work output and efficiency. The project aims to enhance understanding of thermodynamic principles and provide a practical tool for studying power generation systems.
clear;
clc;
% Rankine Cycle Simulator
disp('Rankine Cycle');
disp('1-2 is Isentropic Expansion in Turbine');
disp('2-3 is constant pressure heat removal');
disp('3-4 is Isentropic Compression in Pump');
disp('4-1 Constant pressure Heat addition in Boiler');
% Input data for state points calculation
p1 = 50; % Pressure at Turbine Inlet
T1 = 500; % Temperature at Turbine Inlet
p2 = 5; % Pressure at Condenser
% State point 1 data
h1 = 2800; % Placeholder value for enthalpy at state point 1
s1 = 6.5; % Placeholder value for entropy at state point 1
% State point 2 data
s2 = s1;
hf2 = 300; % Placeholder value for saturated liquid enthalpy at state point 2
hg2 = 2700; % Placeholder value for saturated vapor enthalpy at state point 2
x2 = 0.6; % Placeholder value for vapor fraction at state point 2
h2 = hf2 + x2*(hg2 - hf2);
% State point 3 data
p3 = p2;
h3 = 300; % Placeholder value for enthalpy at state point 3
s3 = 0.5; % Placeholder value for entropy at state point 3
% State point 4 data
s4 = s3;
p4 = p1;
h4 = 2800; % Placeholder value for enthalpy at state point 4
% Turbine work for Rankine cycle
W_T = h1 - h2;
% Pump work
v3 = 0.001; % Placeholder value for specific volume at state point 3
W_P = v3 * (p4 - p3) * 100;
h4 = h3 - W_P;
% Net work for Rankine Cycle
W_net = W_T - W_P;
% Heat Addition and Rejection
Q_in = h1 - h4;
Q_out = h2 - h3;
% Thermal Efficiency
T_eff = (W_net / Q_in) * 100;
% Specific steam consumption
Sp_S = (3600 / W_net);
% Displaying Results
disp('Results of Rankine Cycle');
disp(['At state point 1:', 'At state Point 2:']);
fprintf('P1 = %10f in Bar\t\t\t\tP2 = %10f in Bar\n', p1, p2);
fprintf('T1 = %11f in Deg.Celsius\t\tT2 = %11f in Deg.Celsius\n', T1, T1);
fprintf('H1 = %12f in kJ/kg\t\t\tH2 = %12f in kJ/kg\n', h1, h2);
fprintf('S1 = %9f in kJ/(kg-K)\t\tS2 = %9f in kJ/(kg-K)\n', s1, s2);
disp(' ');
disp(['At state point 3:', 'At state Point 4:']);
fprintf('P3 = %10f in Bar\t\t\t\tP4 = %10f in Bar\n', p3, p4);
fprintf('T3 = %11f in Deg.Celsius\t\tT4 = %11f in Deg.Celsius\n', T1, T1);
fprintf('H3 = %12f in kJ/kg\t\t\tH4 = %12f in kJ/kg\n', h3, h4);
fprintf('S3 = %9f in kJ/(kg-K)\t\tS4 = %9f in kJ/(kg-K)\n', s3, s4);
disp(' ');
fprintf('Turbine Work Done = %14f in kJ/kg\n', W_T);
fprintf('Pump Work Done = %15f in kJ/kg\n', W_P);
fprintf('Net Work Done = %17f in kJ/kg\n', W_net);
fprintf('Thermal Efficiency = %13f percent\n', T_eff);
fprintf('Specific Steam Consumption = %.2f kJ/kWh\n', Sp_S);
1. Setup and Display Messages
- The code starts by clearing the command window and displaying a welcome message for the Rankine Cycle Simulator.
2. State Point Definitions
- State points 1 and 2 are defined with their respective pressures and temperatures.
3. Placeholder Values
- Placeholder values are set for enthalpy and entropy at different state points (1, 2, 3, and 4) for later calculations.
4. Calculate Turbine Work
- The work done by the turbine (W_Turbine) is calculated as the difference between the enthalpy at state point 1 (h1) and the enthalpy at state point 2 (calculated based on saturation enthalpies and vapor fraction).
5. Calculate Pump Work
- The work done by the pump (W_Pump) is calculated based on a specific volume value, pressure difference between state points 1 and 2, and a conversion factor.
6. Calculate Heat Transfer
- Heat addition (Q_in) and heat rejection (Q_out) are calculated based on enthalpy differences between state points.
7. Calculate Net Work and Efficiency
- The net work done (W_net) is calculated as the difference between turbine work and pump work. The thermal efficiency is then calculated as the ratio of net work to heat input, expressed as a percentage.
8. Display Results
- The code then displays the results of the Rankine Cycle Simulation, showing the turbine work done, pump work done, net work done, and thermal efficiency in a formatted manner.
This code provides a structured approach to simulating a Rankine cycle, calculating key parameters such as work done, heat transfer, and thermal efficiency based on the defined state points and placeholder values.
Plot the Graph and explain this code.
% Sample data for plotting
entropy = [1, 2, 3, 4, 5];
enthalpy = [100, 200, 300, 400, 500];
temperature = [50, 100, 150, 200, 250];
% Plot entropy vs enthalpy
subplot(2, 2, 1);
plot(entropy, enthalpy, 'b-o');
xlabel('Entropy');
ylabel('Enthalpy');
title('Entropy vs Enthalpy');
% Plot temperature vs enthalpy
subplot(2, 2, 2);
plot(temperature, enthalpy, 'r-*');
xlabel('Temperature');
ylabel('Enthalpy');
title('Temperature vs Enthalpy');
% Plot enthalpy vs entropy
subplot(2, 2, 3);
plot(enthalpy, entropy, 'g-x');
xlabel('Enthalpy');
ylabel('Entropy');
title('Enthalpy vs Entropy');
% Adjust the layout
sgtitle('Rankine Cycle Properties'); % Overall title for the subplot
Explanation for the code used for plotting.
1. Setting Up Sample Data
- The code defines sample data for entropy, enthalpy, and temperature arrays to be used for plotting the graphs.
2. Plotting Entropy vs Enthalpy
- The first subplot (2 rows, 2 columns, 1st position) is created to plot entropy vs enthalpy.
- The `plot` function is used to plot entropy on the x-axis and enthalpy on the y-axis.
- `'b-o'` specifies blue color ('b') with circles ('o') for data points.
- The `xlabel`, `ylabel`, and `title` functions are used to label the axes and title of the plot.
3. Plotting Temperature vs Enthalpy
- The second subplot (2 rows, 2 columns, 2nd position) is created to plot temperature vs enthalpy.
- The `plot` function is used to plot temperature on the x-axis and enthalpy on the y-axis.
- `'r-*'` specifies red color ('r') with asterisks ('*') for data points.
- Axes labels and a title are added using `xlabel`, `ylabel`, and `title`.
4. Plotting Enthalpy vs Entropy
- The third subplot (2 rows, 2 columns, 3rd position) is created to plot enthalpy vs entropy.
- The `plot` function is used to plot enthalpy on the x-axis and entropy on the y-axis.
- `'g-x'` specifies green color ('g') with crosses ('x') for data points.
- Axes labels and a title are added using `xlabel`, `ylabel`, and `title`.
5. Adjusting Layout
- The `sgtitle` function is used to add an overall title for the subplot, which in this case is "Rankine Cycle Properties".
6. Displaying the Plots
- The code snippet ends here, and the plots will be displayed when the code is executed in MATLAB.
By running this code in MATLAB, you will generate three separate plots showing the relationships between entropy and enthalpy, temperature and enthalpy, and enthalpy and entropy for the sample data provided.
% Display the plots