Advertisement
shamzed

yanni-problem2

Jul 17th, 2022
1,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 3.92 KB | None | 0 0
  1. h_11000 = 0:500:11000;
  2. h_30000 = 0:500:30000;
  3. temperature_c = 0;
  4. pressure = 0;
  5. temperature_k = 273.1;
  6. for ii = 1:numel(h_11000)
  7.   if h_11000(ii) > 25000
  8.     temperature_c(ii) = -131.21 + (0.00299 * h_11000(ii));
  9.     pressure(ii) = 2.488 * ((temperature_c(ii) + 273.1)/216.6)^(-11.388);
  10.   elseif h_11000(ii) > 11000 && h_11000(ii) <= 25000  % Lower Stratosphere
  11.     temperature_c(ii) = -56.46;
  12.     pressure(ii) = 22.65 * exp(1.73 - (0.000157 * h_11000(ii)));
  13.   else   % h < 11000
  14.     temperature_c(ii) = 15.04 - (0.00649 * h_11000(ii));
  15.     pressure(ii) = 101.29 * ((temperature_c(ii) + 273.1)/(288.08))^(5.256);
  16.   end
  17. end
  18.  
  19.  
  20. temperature_k = temperature_c + 273.1;
  21. [therm_eff, net_power, bwr, Wt, Wc, Q_in, Q_out, pr1, pr2, pr3, pr4, h1, h2, h3, h4] = function_1(pressure, temperature_k);
  22.  
  23.  
  24. for ii = 1:numel(h_30000)
  25.   if h_30000(ii) >= 25000
  26.     temperature_c(ii) = -131.21 + (0.00299 * h_30000(ii));
  27.     pressure(ii) = 2.488 * ((temperature_c(ii) + 273.1)/216.6)^(-11.388);
  28.   elseif h_30000(ii) > 11000 && h_30000(ii) < 25000  % Lower Stratosphere
  29.     temperature_c(ii) = -56.46;
  30.     pressure(ii) = 22.65 * exp(1.73 - (0.000157 * h_30000(ii)));
  31.   else   % h < 11000
  32.     temperature_c(ii) = 15.04 - (0.00649 * h_30000(ii));
  33.     pressure(ii) = 101.29 * ((temperature_c(ii) + 273.1)/(288.08))^(5.256);
  34.   end
  35. end
  36.  
  37. column_header = {'Thermal efficiency', 'Net power', 'Back Work Ratio', 'Turbine Power, Wt', 'Compressor Power, Wc', 'Rate of input heat, Qin', 'Rate of output heat, Qout', 'Pr1', 'Pr2', 'Pr3', 'Pr4', 'h1', 'h2', 'h3', 'h4'};
  38. column_units = {'', 'kW', '', 'kW', 'kW', 'kW', 'kW', '', '', '', '', 'kJ/kg', 'kJ/kg', 'kJ/kg', 'kJ/kg'};
  39.  
  40. xlswrite('output.xlsx', column_header, 'Sheet1', 'A1');
  41. xlswrite('output.xlsx', column_units, 'Sheet1', 'A2');
  42.  
  43. xlswrite('output.xlsx', transpose(therm_eff), 'Sheet1', 'A3');
  44. xlswrite('output.xlsx', transpose(net_power), 'Sheet1', 'B3');
  45. xlswrite('output.xlsx', transpose(bwr), 'Sheet1', 'C3');
  46. xlswrite('output.xlsx', transpose(Wt), 'Sheet1', 'D3');
  47. xlswrite('output.xlsx', transpose(Wc), 'Sheet1', 'E3');
  48. xlswrite('output.xlsx', transpose(Q_in), 'Sheet1', 'F3');
  49. xlswrite('output.xlsx', transpose(Q_out), 'Sheet1', 'G3');
  50. xlswrite('output.xlsx', transpose(pr1), 'Sheet1', 'H3');
  51. xlswrite('output.xlsx', transpose(pr2), 'Sheet1', 'I3');
  52. xlswrite('output.xlsx', transpose(pr3), 'Sheet1', 'J3');
  53. xlswrite('output.xlsx', transpose(pr4), 'Sheet1', 'K3');
  54. xlswrite('output.xlsx', transpose(h1), 'Sheet1', 'L3');
  55. xlswrite('output.xlsx', transpose(h2), 'Sheet1', 'M3');
  56. xlswrite('output.xlsx', transpose(h3), 'Sheet1', 'N3');
  57. xlswrite('output.xlsx', transpose(h4), 'Sheet1', 'O3');
  58.  
  59. figure(1)
  60. plot(pressure, h_30000,);
  61. xlabel("Pressure");
  62. ylabel("Height");
  63. title('Line Plot of Altitude against Pressure');
  64.  
  65. figure(2)
  66. plot(temperature_c, h_30000);
  67. xlabel("Temperature");
  68. ylabel("Height");
  69. title('Line Plot of Altitude against Temperature');
  70.  
  71. figure(3)
  72. subplot(3, 1, 1)
  73. plot(h_11000, therm_eff);
  74. xlabel("Altitude");
  75. ylabel("Thermal Efficiency");
  76. title('Line Plot of Thermal Efficiency against Altitude');
  77.  
  78. subplot(3, 1, 2)
  79. plot(h_11000, net_power);
  80. xlabel("Altitude");
  81. ylabel("Net Power");
  82. title('Line Plot of Net Power against Altitude');
  83.  
  84. subplot(3, 1, 3)
  85. plot(h_11000, bwr);
  86. xlabel("Altitude");
  87. ylabel("Back Work Ratio");
  88. title('Line Plot of Back Work Ratio against Altitude');
  89.  
  90. figure(4)
  91. subplot(2, 2, 1)
  92. plot(h_11000, Wt);
  93. xlabel("Altitude");
  94. ylabel("Turbine Power");
  95. title('Line Plot of Turbine Power against Altitude');
  96.  
  97. subplot(2, 2, 2)
  98. plot(h_11000, Wc);
  99. xlabel("Altitude");
  100. ylabel("Compressor Power");
  101. title('Line Plot of Compressor Power against Altitude');
  102.  
  103. subplot(2, 2, 3)
  104. plot(h_11000, Q_in);
  105. xlabel("Altitude");
  106. ylabel("Rate of input heat");
  107. title('Line Plot of Rate of input heat against Altitude');
  108.  
  109. subplot(2, 2, 4)
  110. plot(h_11000, Wt);
  111. xlabel("Altitude");
  112. ylabel("Rate of output heat");
  113. title('Line Plot of Rate of output heat against Altitude');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement