Getting the error Index in position 1 exceeds array bounds. Index must not exceed 1. Error in thermotest5 (line 13) h1 = XSteam('h_pT', p1, t1); % Specific Enthalpy at Turbin
1 view (last 30 days)
Show older comments
%XSteam=addpath('C:\Users\ellam\Downloads\XSteam_Matlab_v2.6');
% Load steam property data from the xsteam library
%water = XSteam('water');
% Rankine Cycle Parameters
p1 = 10; % Boiler Pressure [bar]
p2 = 0.05; % Condenser Pressure [bar]
t1 = 500; % Temperature at Turbine Inlet [C]
t3 = 50; % Temperature at Condenser Outlet [C]
mdot = 100; % Mass Flow Rate [kg/s]
% Fluid Properties
h1 = XSteam('h_pT', p1, t1) % Specific Enthalpy at Turbine Inlet
s1 = XSteam('s_pT', p1, t1) % Specific Entropy at Turbine Inlet
h2 = XSteam('h_ps', p2, s1) % Specific Enthalpy at Condenser Outlet
s2 = XSteam('s_pT', p2, t3) % Specific Entropy at Condenser Outlet
% Stage 1: Turbine
w_turbine = mdot * (h1 - h2); % Turbine Work Output
t2 = XSteam('T_ps', p2, s1)% Temperature at Turbine Outlet
% Stage 2: Condenser
q_condenser = mdot * (h2 - XSteam('hL_p', p2)) % Heat Removed in Condenser
% Stage 3: Pump
h3s = XSteam('h_ps', p2, s1) % Isentropic Specific Enthalpy at Pump Inlet
h3 = h2 + (h3s - h2) / 0.85; % Specific Enthalpy at Pump Inlet
w_pump = mdot * (h3 - h2); % Pump Work Input
t4 = XSteam('T_ps', p1, s2) % Temperature at Pump Outlet
% Stage 4: Boiler
q_boiler = mdot * (h1 - h3); % Heat Added in Boiler
% Efficiency Calculation
q_in = q_boiler;
q_out = q_condenser;
eta = (q_in - q_out) / q_in;
% Display Results
fprintf('Stage 1: Turbine\n');
fprintf('Turbine Work Output: %0.2f MW\n', w_turbine / 1e6);
fprintf('Turbine Outlet Temperature: %0.2f C\n', t2);
fprintf('\n');
fprintf('Stage 2: Condenser\n');
fprintf('Heat Removed in Condenser: %0.2f MW\n', q_condenser / 1e6);
fprintf('Condenser Outlet Temperature: %0.2f C\n', t3);
fprintf('\n');
fprintf('Stage 3: Pump\n');
fprintf('Pump Work Input: %0.2f MW\n', w_pump / 1e6);
fprintf('Pump Outlet Temperature: %0.2f C\n', t4);
fprintf('\n');
fprintf('Stage 4: Boiler\n');
fprintf('Heat Added in Boiler: %0.2f MW\n', q_boiler / 1e6);
fprintf('Boiler Pressure: %0.2f bar\n', p1);
fprintf('\n');
fprintf('Rankine Cycle Efficiency: %0.2f %%\n', eta * 100);
3 Comments
Torsten
on 13 Mar 2023
Put XSteam.m in your working directory and run the code from above. If you have MATLAB Release 2022b installed, it should work because it works with MATLAB online, as you can see.
Answers (1)
Sai Sumanth Korthiwada
on 27 Mar 2023
Hi Ella,
I have executed the code you have mentioned above in MATLAB R2022b, and it worked without any error for me. I have attached the '.mlx' file with the code and an image displaying the execution, for your reference.
Please ensure that the file is present in the working directory path. If not present, in the “Current Folder” browser, right click on the folder in which the file is in and select "Add to path" and click on "select folders and subfolders" option. Now, the file gets added to the MATLAB working directory path. Execute the file again, it should work.
Hope this helps!
0 Comments
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!