0% found this document useful (0 votes)
12 views13 pages

Codes

1. The document contains calculations for heat transfer through materials with different thicknesses using Fourier's law of heat conduction. It determines the heat loss over 5 hours for glass thicknesses of 0.5 cm and 1 cm. 2. Heat transfer rates from a surface are calculated for varying convection coefficients and emissivities. The total heat transfer includes convective and radiative components. 3. The volume of a tank containing refrigerant-134a at different initial pressures and a final pressure and temperature is determined using the ideal gas law. This shows the effect of initial pressure on final tank volume.

Uploaded by

qq99xyhqm4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views13 pages

Codes

1. The document contains calculations for heat transfer through materials with different thicknesses using Fourier's law of heat conduction. It determines the heat loss over 5 hours for glass thicknesses of 0.5 cm and 1 cm. 2. Heat transfer rates from a surface are calculated for varying convection coefficients and emissivities. The total heat transfer includes convective and radiative components. 3. The volume of a tank containing refrigerant-134a at different initial pressures and a final pressure and temperature is determined using the ideal gas law. This shows the effect of initial pressure on final tank volume.

Uploaded by

qq99xyhqm4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 13

1)

% Given data
thickness = 0.5 / 100; % in meters (0.5 cm converted to meters)
thickness_1cm = 1 / 100; % in meters (1 cm converted to meters)
surface_temp_inner = 10; % in °C
surface_temp_outer = 3; % in °C
thermal_conductivity = 0.78; % in W/m·°C
time_duration = 5 * 3600; % in seconds (5 hours converted to seconds)

% Calculate heat transfer rate using Fourier's law of heat conduction


heat_transfer_rate = thermal_conductivity * (surface_temp_inner -
surface_temp_outer) / thickness;

% Calculate total heat loss


heat_loss = heat_transfer_rate * time_duration / 1000; % in kJ

% Display the result for 0.5 cm thickness


disp(['Heat loss through 0.5 cm thick glass: ', num2str(heat_loss), ' kJ']);

% Calculate heat transfer rate and total heat loss for 1 cm thickness
heat_transfer_rate_1cm = thermal_conductivity * (surface_temp_inner -
surface_temp_outer) / thickness_1cm;
heat_loss_1cm = heat_transfer_rate_1cm * time_duration / 1000; % in kJ

% Display the result for 1 cm thickness


disp(['Heat loss through 1 cm thick glass: ', num2str(heat_loss_1cm), ' kJ']);

% Plotting the effect of glass thickness on heat loss


thickness_range = linspace(0.002, 0.02, 100); % Thickness range from 0.2 cm to 2 cm
heat_loss_range = zeros(size(thickness_range));

for i = 1:length(thickness_range)
heat_transfer_rate_i = thermal_conductivity * (surface_temp_inner -
surface_temp_outer) / thickness_range(i);
heat_loss_range(i) = heat_transfer_rate_i * time_duration / 1000; % in kJ
end

figure;
plot(thickness_range * 100, heat_loss_range, 'b', 'LineWidth', 2);
xlabel('Glass Thickness (cm)');
ylabel('Heat Loss (kJ)');
title('Effect of Glass Thickness on Heat Loss');
grid on;

2)

% Given data
diameter = 5 / 100; % in meters (5 cm converted to meters)
surface_temp = 70; % in °C
surrounding_temp = 20; % in °C
convection_coefficient_range = linspace(5, 30, 100); % Range of convection heat
transfer coefficient (W/m2 · °C)
emissivity_range = [0.1, 0.5, 0.8, 1]; % Surface emissivity values

% Stefan-Boltzmann constant
sigma = 5.67e-8; % in W/m2 · K4
% Initialize array to store heat transfer rates
heat_transfer_rates = zeros(length(emissivity_range),
length(convection_coefficient_range));

% Loop over different surface emissivities


for i = 1:length(emissivity_range)
emissivity = emissivity_range(i);

% Loop over different convection coefficients


for j = 1:length(convection_coefficient_range)
h = convection_coefficient_range(j);

% Calculate total heat transfer rate


convective_heat_transfer = h * pi * diameter * (surface_temp -
surrounding_temp);
radiative_heat_transfer = emissivity * sigma * pi * diameter^2 *
(surface_temp + 273.15)^4;
total_heat_transfer = convective_heat_transfer + radiative_heat_transfer;

% Store the total heat transfer rate


heat_transfer_rates(i, j) = total_heat_transfer;
end
end

% Plotting the effect of convection heat transfer coefficient on heat transfer rate
figure;
plot(convection_coefficient_range, heat_transfer_rates, 'LineWidth', 2);
xlabel('Convection Heat Transfer Coefficient (W/m^2 · °C)');
ylabel('Rate of Heat Transfer (W)');
title('Effect of Convection Heat Transfer Coefficient on Heat Transfer Rate');
legend('Emissivity = 0.1', 'Emissivity = 0.5', 'Emissivity = 0.8', 'Emissivity =
1');
grid on;

3)

% Given data
V_refrigerant_initial = 0.01; % Initial volume of refrigerant-134a (m^3)
T_final = 20 + 273.15; % Final temperature of the refrigerant (K)
P_final = 400e3; % Final pressure of the refrigerant (Pa)

% Constants
R_specific = 188.93; % Specific gas constant for refrigerant-134a (J/kg·K)

% Range of initial pressures


P_initial_range = linspace(0.5e6, 1.5e6, 100); % Initial pressure range (Pa)

% Initialize array to store tank volumes


V_tank_final = zeros(size(P_initial_range));

% Loop over different initial pressures


for i = 1:length(P_initial_range)
P_initial = P_initial_range(i);

% Calculate initial mass of refrigerant using its specific volume at initial


state
v_specific_initial = 1 / V_refrigerant_initial; % Specific volume at initial
state (m^3/kg)
m_refrigerant_initial = V_refrigerant_initial / v_specific_initial; % Initial
mass of refrigerant (kg)

% Calculate specific volume of refrigerant at final state using the ideal gas
law
v_specific_final = R_specific * T_final / P_final;

% Calculate volume of the tank at final state


V_tank_final(i) = m_refrigerant_initial * v_specific_final;
end

% Plotting the effect of initial pressure on tank volume


plot(P_initial_range / 1e6, V_tank_final, 'LineWidth', 2);
xlabel('Initial Pressure (MPa)');
ylabel('Volume of the Tank at Final State (m^3)');
title('Effect of Initial Pressure on Tank Volume');
grid on;

4)

% Given data
V1 = 0.5; % Volume of tank 1 (m^3)
V2 = 0.5; % Volume of tank 2 (m^3)
T1 = 20 + 273.15; % Initial temperature of tank 1 (K)
T2 = 30 + 273.15; % Initial temperature of tank 2 (K)
P1 = 600e3; % Initial pressure of tank 1 (Pa)
P2 = 150e3; % Initial pressure of tank 2 (Pa)
T_surroundings_range = linspace(-10 + 273.15, 30 + 273.15, 100); % Surroundings
temperature range (K)

% Constants
R_specific = 8.314; % Specific gas constant for hydrogen (J/mol·K)
Molar_mass = 2.016; % Molar mass of hydrogen (g/mol)

% Initialize array to store final pressures


final_pressure = zeros(size(T_surroundings_range));

% Loop over different surroundings temperatures


for i = 1:length(T_surroundings_range)
T_surroundings = T_surroundings_range(i);

% Calculate the final temperature using energy conservation (assuming adiabatic


process)
T_final = (V1 * T1 + V2 * T2) / (V1 + V2);

% Calculate the final pressure using the ideal gas law


final_pressure(i) = (P1 * V1 + P2 * V2) / (V1 + V2) * (T_final /
T_surroundings);
end

% Plotting the effect of surroundings temperature on final equilibrium pressure


plot(T_surroundings_range - 273.15, final_pressure / 1e3, 'LineWidth', 2);
xlabel('Surroundings Temperature (°C)');
ylabel('Final Pressure (kPa)');
title('Effect of Surroundings Temperature on Final Equilibrium Pressure');
grid on;
5)

% Given data
P = 10e6; % Pressure (Pa)
T = 400 + 273.15; % Temperature (K)

% Constants
R = 8.314; % Universal gas constant (J/mol·K)
Molar_mass = 18.01528; % Molar mass of water (g/mol)

% (a) Ideal gas equation


v_ideal_gas = R * T / P;

% (b) Generalized compressibility chart


% The compressibility factor (Z) for superheated steam is typically around 1, so we
assume Z = 1
v_generalized_compressibility = R * T / P;

% (c) Steam tables


% Using steam tables or any method to obtain specific volume at given pressure and
temperature
% For simplicity, we'll assume a specific volume based on the properties of
superheated steam
% at 10 MPa and 400°C obtained from steam tables
v_steam_tables = 0.0428; % m^3/kg

% Calculate percent error for each method


error_ideal_gas = abs(v_steam_tables - v_ideal_gas) / v_steam_tables * 100;
error_generalized_compressibility = abs(v_steam_tables -
v_generalized_compressibility) / v_steam_tables * 100;

% Display results
disp('(a) Ideal Gas Equation:');
disp(['Specific volume: ', num2str(v_ideal_gas), ' m^3/kg']);
disp(['Percent Error: ', num2str(error_ideal_gas), '%']);
disp('(b) Generalized Compressibility Chart:');
disp(['Specific volume: ', num2str(v_generalized_compressibility), ' m^3/kg']);
disp(['Percent Error: ', num2str(error_generalized_compressibility), '%']);
disp('(c) Steam Tables:');
disp(['Specific volume: ', num2str(v_steam_tables), ' m^3/kg']);

% (d) Compare specific volume at different temperatures using steam tables


T_range = 325:25:600; % Temperature range (°C)
v_percent_error = zeros(size(T_range)); % Initialize array to store percent error

for i = 1:length(T_range)
T_temp = T_range(i) + 273.15; % Convert temperature to Kelvin
% Calculate specific volume using steam tables
% For simplicity, we assume a specific volume based on the properties of
superheated steam
% at 10 MPa and the current temperature obtained from steam tables
v_steam_temp = 0.0428; % m^3/kg (example value)
% Calculate percent error for ideal gas approximation
v_ideal_gas_temp = R * T_temp / P; % Specific volume using ideal gas equation
v_percent_error(i) = abs(v_steam_temp - v_ideal_gas_temp) / v_steam_temp * 100;
% Percent error
end

% Plot percent error against temperature


plot(T_range, v_percent_error, 'LineWidth', 2);
xlabel('Temperature (°C)');
ylabel('Percent Error in Ideal Gas Approximation (%)');
title('Percent Error in Ideal Gas Approximation vs Temperature');
grid on;

6)

% Given data
diameter_range = linspace(5, 15, 100); % Balloon diameter range (m)
T = 20 + 273.15; % Temperature (K)
P_values = [100e3, 200e3]; % Pressure values (Pa)
Molar_mass = 4.002602; % Molar mass of helium (g/mol)

% Constants
R = 8.314; % Universal gas constant (J/mol·K)

% Initialize arrays to store mass of helium for each pressure


mass_helium_100kPa = zeros(size(diameter_range));
mass_helium_200kPa = zeros(size(diameter_range));

% Loop over different balloon diameters


for i = 1:length(diameter_range)
diameter = diameter_range(i);

% Calculate volume of the balloon


volume = (4/3) * pi * (diameter/2)^3;

% Loop over different pressures


for j = 1:length(P_values)
P = P_values(j);

% Calculate number of moles of helium using ideal gas law


n = P * volume / (R * T);

% Calculate mass of helium


mass = n * Molar_mass; % Mass in grams

% Store mass for the corresponding pressure


if P == 100e3
mass_helium_100kPa(i) = mass;
elseif P == 200e3
mass_helium_200kPa(i) = mass;
end
end
end

% Plot mass of helium against balloon diameter for both pressures


figure;
hold on;
plot(diameter_range, mass_helium_100kPa, 'b', 'LineWidth', 2);
plot(diameter_range, mass_helium_200kPa, 'r', 'LineWidth', 2);
hold off;
xlabel('Balloon Diameter (m)');
ylabel('Mass of Helium (g)');
title('Effect of Balloon Diameter on Mass of Helium');
legend('Pressure = 100 kPa', 'Pressure = 200 kPa');
grid on;
7)

% Constants
R = 8.314; % Universal gas constant in J/(mol*K)
v = 1; % Specific volume in m^3
m = 2.841; % Mass of steam in kg
P_range = 0.1:0.1:1; % Pressure range in MPa

% (a) Ideal gas equation


T_ideal = (P_range * 1e6 * v) / (R * 1000); % Convert pressure from MPa to Pa, R
from J/(mol*K) to kJ/(kg*K)

% (b) Van der Waals equation


a = 0.4077; % Van der Waals constant in m^3/(kg*K)
b = 3.7934e-5; % Van der Waals constant in m^3/kg
T_vdw = zeros(size(P_range));
for i = 1:length(P_range)
P = P_range(i) * 1e6; % Convert pressure from MPa to Pa
% Use fsolve with initial guess of 300 K
T_vdw(i) = fsolve(@(T) (R * 1000 * T * v) - (P + a * (m / v)^2) * v + b * P *
m, 300);
% Cast the result to double
T_vdw(i) = double(T_vdw(i));
end

% (c) Steam tables (Interpolation)


% Assuming some values as an example, you should replace this with actual data from
steam tables
P_steam = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]; % Pressure from steam
tables in MPa
T_steam = [350, 360, 370, 380, 390, 400, 410, 420, 430, 440]; % Corresponding
temperature in K
% Interpolate temperature for given pressure range
T_interp = interp1(P_steam, T_steam, P_range);

% Plot percent error in ideal gas approximation


percent_error = abs((T_ideal - T_interp) ./ T_interp) * 100;

figure;
plot(P_range, percent_error, 'LineWidth', 2);
xlabel('Pressure (MPa)');
ylabel('Percent Error (%)');
title('Percent Error in Ideal Gas Approximation vs Pressure');
grid on;

8)

% Given data
V_initial = 200; % Initial volume (L)
T_initial = 20; % Initial temperature (°C)
T_final = 70; % Final temperature (°C)
P_range = linspace(400, 1200, 100); % Pressure range (kPa)
% Constants
R_specific = 0.18893; % Specific gas constant for refrigerant-134a (kJ/kg·K)
Molar_mass = 102.03; % Molar mass of refrigerant-134a (g/mol)

% Convert temperatures to Kelvin


T_initial_K = T_initial + 273.15;
T_final_K = T_final + 273.15;

% Initialize array to store work done


work_done = zeros(size(P_range));

% Calculate work done for each pressure in the range


for i = 1:length(P_range)
P = P_range(i); % Pressure (kPa)

% Calculate initial specific volume using ideal gas law for saturated liquid
v_initial = R_specific * T_initial_K / P;

% Calculate final specific volume using ideal gas law for superheated vapor
v_final = R_specific * T_final_K / P;

% Calculate work done using area under the curve (trapezoidal rule)
work_done(i) = (v_final - v_initial) * P * 1000; % Convert from kJ to J
end

% Plot work done versus pressure


figure;
plot(P_range, work_done, 'LineWidth', 2);
xlabel('Pressure (kPa)');
ylabel('Work Done (J)');
title('Effect of Pressure on Work Done');
grid on;

% Plot process on P-v diagram


figure;
hold on;
plot([V_initial V_initial], [P_range(1) P_range(end)], 'k--', 'LineWidth', 2); %
Initial vertical line
plot([V_initial v_final], [P_range(end) P_range(end)], 'k--', 'LineWidth', 2); %
Final horizontal line
plot([V_initial v_final], [P_range(1) P_range(end)], 'b', 'LineWidth', 2); %
Process line
hold off;
xlabel('Volume (L)');
ylabel('Pressure (kPa)');
title('P-v Diagram for Process');
legend('Initial State', 'Final State', 'Process');
grid on;

9)

% Given data
m_water = 50; % Mass of water (kg)
P_initial = 250e3; % Initial pressure (Pa)
T_initial = 25 + 273.15; % Initial temperature (K)
A_piston = 0.1; % Cross-sectional area of the piston (m^2)
V_final_1 = 0.2; % Final volume after reaching the spring (m^3)
V_final_2 = V_final_1 + 0.2; % Final volume after rising 20 cm more (m^3)
k_spring_range = linspace(50e3, 500e3, 100); % Spring constant range (N/m)
delta_x = 0.2; % Displacement after reaching the spring (m)
delta_x_additional = 0.2; % Additional displacement (m)

% Constants
R_specific = 8.314; % Specific gas constant for water (J/mol·K)
Molar_mass = 18.01528; % Molar mass of water (g/mol)

% Calculate initial volume using ideal gas law


V_initial = m_water * R_specific * T_initial / (P_initial * 1000); % Convert
pressure to kPa

% Calculate initial force exerted by the piston


F_initial = P_initial * A_piston;

% Initialize arrays to store final pressure and work done


P_final = zeros(size(k_spring_range));
boundary_work = zeros(size(k_spring_range));

% Loop over different spring constants


for i = 1:length(k_spring_range)
k_spring = k_spring_range(i); % Spring constant (N/m)

% Calculate final force exerted by the piston after reaching the spring
F_final = k_spring * delta_x;

% Calculate the work done during the process


boundary_work(i) = F_initial * delta_x + 0.5 * k_spring * delta_x_additional^2;

% Calculate the final pressure using the ideal gas law


V_final = V_initial + A_piston * delta_x + A_piston * delta_x_additional;
P_final(i) = m_water * R_specific * T_initial / (V_final * 1000); % Convert
volume to m^3
end

% Plot final pressure and work done against spring constant


figure;
subplot(2,1,1);
plot(k_spring_range / 1e3, P_final / 1e3, 'LineWidth', 2);
xlabel('Spring Constant (kN/m)');
ylabel('Final Pressure (kPa)');
title('Effect of Spring Constant on Final Pressure');
grid on;

subplot(2,1,2);
plot(k_spring_range / 1e3, boundary_work / 1e3, 'LineWidth', 2);
xlabel('Spring Constant (kN/m)');
ylabel('Boundary Work Done (kJ)');
title('Effect of Spring Constant on Boundary Work Done');
grid on;

10)

% Given data
P_in = 300e3; % Inlet pressure (Pa)
T_in = 200 + 273.15; % Inlet temperature (K)
V_in = 30; % Inlet velocity (m/s)
P_out = 100e3; % Outlet pressure (Pa)
V_out = 180; % Outlet velocity (m/s)
A_in = 80 / 1e4; % Inlet area (m^2)

% Constants
gamma = 1.4; % Specific heat ratio for air

% (a) Calculate mass flow rate through the nozzle using mass flow rate equation
rho_in = P_in / (287 * T_in); % Inlet density (kg/m^3)
m_dot = rho_in * V_in * A_in; % Mass flow rate (kg/s)

% (b) Calculate exit temperature of the air using isentropic relations


T_out = T_in * (P_out / P_in)^((gamma-1)/gamma); % Exit temperature (K)

% (c) Calculate exit area of the nozzle using continuity equation


A_out = m_dot / (rho_in * V_out); % Exit area (m^2)

% Print results
fprintf('(a) Mass flow rate: %.4f kg/s\n', m_dot);
fprintf('(b) Exit temperature: %.2f K\n', T_out);
fprintf('(c) Exit area: %.4f m^2\n', A_out);

% Effect of inlet area on mass flow rate, exit temperature, and exit area
A_in_range = linspace(50 / 1e4, 150 / 1e4, 100); % Inlet area range (m^2)

% Initialize arrays to store results


m_dot_range = zeros(size(A_in_range));
T_out_range = zeros(size(A_in_range));
A_out_range = zeros(size(A_in_range));

% Loop over different inlet areas


for i = 1:length(A_in_range)
A_in_temp = A_in_range(i);

% Calculate mass flow rate


m_dot_range(i) = rho_in * V_in * A_in_temp;

% Calculate exit temperature


T_out_range(i) = T_in * (P_out / P_in)^((gamma-1)/gamma);

% Calculate exit area


A_out_range(i) = m_dot_range(i) / (rho_in * V_out);
end

% Plot results against inlet area


figure;
subplot(3,1,1);
plot(A_in_range * 1e4, m_dot_range, 'LineWidth', 2);
xlabel('Inlet Area (cm^2)');
ylabel('Mass Flow Rate (kg/s)');
title('Effect of Inlet Area on Mass Flow Rate');
grid on;

subplot(3,1,2);
plot(A_in_range * 1e4, T_out_range, 'LineWidth', 2);
xlabel('Inlet Area (cm^2)');
ylabel('Exit Temperature (K)');
title('Effect of Inlet Area on Exit Temperature');
grid on;

subplot(3,1,3);
plot(A_in_range * 1e4, A_out_range * 1e4, 'LineWidth', 2);
xlabel('Inlet Area (cm^2)');
ylabel('Exit Area (cm^2)');
title('Effect of Inlet Area on Exit Area');
grid on;

11)

% Given data
P_in = 10e6; % Inlet pressure (Pa)
T_in = 450 + 273.15; % Inlet temperature (K)
V_in = 80; % Inlet velocity (m/s)
P_out = 10e3; % Outlet pressure (Pa)
x_out = 0.92; % Quality of steam at outlet
V_out = 50; % Outlet velocity (m/s)
m_dot = 12; % Mass flow rate (kg/s)

% Constants
R_specific = 0.4615; % Specific gas constant for steam (kJ/kg·K)
gamma = 1.4; % Specific heat ratio for steam

% (a) Calculate change in kinetic energy


delta_KE = 0.5 * m_dot * ((V_out^2 - V_in^2) / 1000); % Convert to kJ/s

% (b) Calculate power output


h_in = 3051.3; % Specific enthalpy of steam at inlet (kJ/kg)
h_out = 2676.8; % Specific enthalpy of steam at outlet (kJ/kg)
delta_H = h_in - h_out; % Enthalpy change (kJ/kg)
W_out = m_dot * delta_H; % Power output (kW)

% (c) Calculate turbine inlet area using continuity equation


A_in = m_dot / (x_out * (1 - x_out) * R_specific * T_in * (1 + (gamma - 1) /
2)^((gamma + 1) / (2 * (gamma - 1))) * P_in / sqrt(gamma * R_specific * T_in)); %
m^2

% Print results
fprintf('(a) Change in Kinetic Energy: %.2f kJ/s\n', delta_KE);
fprintf('(b) Power Output: %.2f kW\n', W_out);
fprintf('(c) Turbine Inlet Area: %.4f m^2\n', A_in);

% Effect of turbine exit pressure on power output


P_out_range = linspace(10e3, 200e3, 100); % Exit pressure range (Pa)

% Initialize array to store power output


W_out_range = zeros(size(P_out_range));

% Loop over different exit pressures


for i = 1:length(P_out_range)
P_out_temp = P_out_range(i); % Exit pressure (Pa)

% Calculate power output


h_out_temp = x_out * 2706.1; % Specific enthalpy at outlet (kJ/kg)
delta_H_temp = h_in - h_out_temp; % Enthalpy change (kJ/kg)
W_out_temp = m_dot * delta_H_temp; % Power output (kW)
W_out_range(i) = W_out_temp;
end

% Plot power output against exit pressure


figure;
plot(P_out_range / 1e3, W_out_range, 'LineWidth', 2);
xlabel('Exit Pressure (kPa)');
ylabel('Power Output (kW)');
title('Effect of Exit Pressure on Power Output');
grid on;

12)

% Given data
T_source_range = linspace(300, 1000, 100); % Source temperature range (°C)
T_sink_range = [0, 25, 50]; % Sink temperature range (°C)
Q_in = 1200 * 60; % Heat supplied to the engine (kJ/min) converted to kJ/s

% Constants
T_0 = 273.15; % Absolute zero temperature (K)

% Initialize arrays to store results


power_produced = zeros(length(T_source_range), length(T_sink_range));
cycle_efficiency = zeros(length(T_source_range), length(T_sink_range));

% Loop over different source temperatures


for i = 1:length(T_source_range)
T_source = T_source_range(i) + T_0; % Source temperature (K)

% Loop over different sink temperatures


for j = 1:length(T_sink_range)
T_sink = T_sink_range(j) + T_0; % Sink temperature (K)

% Calculate Carnot efficiency


efficiency_carnot = 1 - T_sink / T_source;

% Calculate maximum power output (W)


max_power_output = Q_in * efficiency_carnot;

% Store results
power_produced(i, j) = max_power_output;
cycle_efficiency(i, j) = efficiency_carnot;
end
end

% Plot power produced and cycle efficiency against source temperature


figure;
subplot(2,1,1);
plot(T_source_range, power_produced, 'LineWidth', 2);
xlabel('Source Temperature (°C)');
ylabel('Power Produced (W)');
title('Effect of Source Temperature on Power Produced');
legend('Sink Temp: 0°C', 'Sink Temp: 25°C', 'Sink Temp: 50°C');
grid on;
subplot(2,1,2);
plot(T_source_range, cycle_efficiency, 'LineWidth', 2);
xlabel('Source Temperature (°C)');
ylabel('Cycle Efficiency');
title('Effect of Source Temperature on Cycle Efficiency');
legend('Sink Temp: 0°C', 'Sink Temp: 25°C', 'Sink Temp: 50°C');
grid on;

13)

% Given data
m_steam = 0.0103; % Mass of steam (kg)
W_net_range = linspace(15, 25, 100); % Net work output range (kJ)

% Constants
R_specific = 0.4615; % Specific gas constant for steam (kJ/kg·K)

% Calculate maximum absolute temperature (Tw) and minimum absolute temperature (Tc)
Tw = 2 * 273.15; % Max absolute temperature (K)
Tc = 273.15; % Min absolute temperature (K)

% Initialize array to store temperature of steam during heat rejection process


T_reject = zeros(size(W_net_range));

% Loop over different net work outputs


for i = 1:length(W_net_range)
W_net = W_net_range(i); % Net work output (kJ)

% Calculate heat input and heat rejection


Q_in = W_net / (1 - Tw/Tc); % Heat input (kJ)
Q_out = Q_in - W_net; % Heat rejection (kJ)

% Calculate temperature of steam during heat rejection process


T_reject(i) = (Q_out / (m_steam * R_specific)) + 273.15; % Convert to °C
end

% Plot temperature of steam during heat rejection process against net work output
plot(W_net_range, T_reject, 'LineWidth', 2);
xlabel('Net Work Output (kJ)');
ylabel('Temperature during Heat Rejection (°C)');
title('Effect of Net Work Output on Steam Temperature during Heat Rejection');
grid on;

14)

% Given data
Q_added_range = [500, 900, 1300]; % Heat added to the working fluid (kJ)
T_source_range = linspace(100, 1000, 100); % Source temperature range (°C)

% Constants
R_specific = 0.287; % Specific gas constant for air (kJ/kg·K)

% Initialize arrays to store results


entropy_change_fluid = zeros(length(T_source_range), length(Q_added_range));
entropy_change_source = zeros(length(T_source_range), length(Q_added_range));
total_entropy_change = zeros(length(T_source_range), length(Q_added_range));

% Loop over different amounts of heat added


for i = 1:length(Q_added_range)
Q_added = Q_added_range(i); % Heat added to the working fluid (kJ)

% Loop over different source temperatures


for j = 1:length(T_source_range)
T_source = T_source_range(j) + 273.15; % Source temperature (K)

% Calculate entropy change of the working fluid


entropy_change_fluid(j, i) = Q_added / T_source;

% Calculate entropy change of the source


entropy_change_source(j, i) = -Q_added / T_source;

% Calculate total entropy change


total_entropy_change(j, i) = entropy_change_fluid(j, i) +
entropy_change_source(j, i);
end
end

% Plot entropy changes against source temperature for different heat added
figure;
subplot(3,1,1);
plot(T_source_range, entropy_change_fluid, 'LineWidth', 2);
xlabel('Source Temperature (°C)');
ylabel('Entropy Change of Working Fluid (kJ/K)');
title('Effect of Source Temperature on Entropy Change of Working Fluid');
legend('Q = 500 kJ', 'Q = 900 kJ', 'Q = 1300 kJ');
grid on;

subplot(3,1,2);
plot(T_source_range, entropy_change_source, 'LineWidth', 2);
xlabel('Source Temperature (°C)');
ylabel('Entropy Change of Source (kJ/K)');
title('Effect of Source Temperature on Entropy Change of Source');
legend('Q = 500 kJ', 'Q = 900 kJ', 'Q = 1300 kJ');
grid on;

subplot(3,1,3);
plot(T_source_range, total_entropy_change, 'LineWidth', 2);
xlabel('Source Temperature (°C)');
ylabel('Total Entropy Change (kJ/K)');
title('Effect of Source Temperature on Total Entropy Change');
legend('Q = 500 kJ', 'Q = 900 kJ', 'Q = 1300 kJ');
grid on;

You might also like