Advertisement
shamzed

yanni_userfuntion

Jul 17th, 2022
1,649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.30 KB | None | 0 0
  1. function [therm_eff, net_power, bwr, Wt, Wc, Q_in, Q_out, pr1, pr2, pr3, pr4, h1, h2, h3, h4] = function_1(pr_in, t_in)
  2.   pkg load io;
  3.   data = xlsread('Air properties.xlsx');
  4.   temp = data(:,1);
  5.   h = data(:,2);
  6.   pr = data(:,3);
  7.   u = data(:,4);
  8.   vr = data(:,5);
  9.   s = data(:,6);
  10.  
  11.   % given data:
  12.   p_ratio1 = 10;
  13.   p_ratio2 = 0.1;
  14.   t3 = 1400;
  15.   flowrate = 5;
  16.  
  17.   % finding h1
  18.   h1 = interp1(temp, h, t_in);
  19.  
  20.   % finding h2
  21.   pr1 = interp1(temp, pr, t_in);
  22.   pr2 = pr1 * p_ratio1;
  23.   h2 = interp1(pr, h, pr2);
  24.  
  25.   % finding h3
  26.   index2 = find(temp == t3);
  27.   h3 = h(index2);
  28.  
  29.   % finding h4
  30.   pr3 = pr(index2);
  31.   pr4 = pr3 * p_ratio2;
  32.   h4 = interp1(pr, h, pr4);
  33.  
  34.   % finding the thermal efficiency
  35.   therm_eff = 0;
  36.   for jj = 1:numel(h1)
  37.     therm_eff(jj) = ((h3 - h4) - (h2(jj) - h1(jj)))/(h3 - h2(jj));
  38.   end
  39.  
  40.   % back work ratio
  41.   bwr = (h2 - h1)/(h3 - h4);
  42.  
  43.   % Net power in KW
  44.   m_dot = 0;
  45.   for jj = 1:numel(pr_in)
  46.     m_dot(jj) = ((flowrate * (pr_in(jj)) * (10^3))/((8.314/28.97) * t_in(jj))) * (1/10^3);
  47.     net_power(jj) = m_dot(jj) * ((h3 - h4) - (h2(jj) - h1(jj)));
  48.   end
  49.  
  50.   Wt = m_dot * (h3 - h4);
  51.   for jj = 1:numel(h1)
  52.     Wc(jj) = m_dot(jj) * (h2(jj) - h1(jj));
  53.     Q_in(jj) = m_dot(jj) * (h3 - h2(jj));
  54.     Q_out(jj) = m_dot(jj) * (h4 - h1(jj));
  55.   endfor
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement