Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. clc
  2. clear all
  3. close all
  4.  
  5. % ht = .076; %3 inches in meters
  6. % rhob = 727; %Density of gasoline
  7. % rhot = 670; %Density of feed
  8. % MWb = 103; %Molecular weight of gasoline
  9. % MWg = 48.14; %Molecular weight of propane/butane mix
  10. % MWt = (MWb+MWg)/2; %Avg molecular weight
  11. % Dk = 2.5; %Diameter of column
  12. % cb = 2.22; %Specific heat of gasoline
  13. B = 110.92; %Molar flow rate of bottoms
  14. %F = 15480; %Mass flow rate of feed
  15. D = 92.76; %Molar flow rate of distillate
  16. xF = .341; %Liquid fraction of feed
  17. %Increasing xF to 0.65 helps with the final value of the bottoms and the
  18. %distillate, but does not help with the overall shape
  19. LF = 104.25; %Molar liquid flow rate of feed
  20. VF = 98.52; %Molar vapor flow rate of feed
  21. % R = 5; %Reflux ratio
  22. L = 75.64; %Molar flow rate of liquid condensate below feed
  23. % Hnb = .386; % Forgot how we calculated this, I'll add later
  24. Mb = 31.11; %Holdup on bottom tray
  25. M = 5.8; %Holdup on every tray
  26. Md = 13.07; %Holdup on distallate drum
  27. % lamdab = -1.2552; %Latent heat of vaporization for distillate
  28. % tb = 144; %Temperature of bottoms
  29. % tf = 118; %Temperature of feed
  30. % lamda = lamdab*tf; %Latent heat of vaporization at feed temperature
  31. V = 66.34; %Molar flow rate of vapor above feed
  32. alpha = 5.68; %Used for finding VLE
  33. yF = alpha.*xF./(1+(alpha-1).*xF);
  34.  
  35. %V and L are to be added to VF and LF above and below the feed,
  36. %respectively. Otherwise, the flow rate should just be VF and LF
  37.  
  38.  
  39. %Model the equation as x' = A1*x + A2*y(x) + A3
  40. %All values are taken from model equations in the paper
  41. A1 = zeros(16,16);
  42. A2 = zeros(16,16);
  43.  
  44. A1(1,1) = -B/Mb;
  45. A1(1,2) = (L+LF)/Mb;
  46. for i = 2:7
  47. A1(i,i) = -(L+LF)/M;
  48. A1(i,i+1) = (L+LF)/M;
  49. end
  50. A1(8,8) = -(L+LF)/M;
  51. A1(8,9) = L/M;
  52. for i = 9:15
  53. A1(i,i) = -L/M;
  54. A1(i,i+1) = L/M;
  55. end
  56. A1(16,16) = -(L+D)/Md;
  57.  
  58. A2(1,1) = -V/Mb;
  59. for i = 2:8
  60. A2(i,i-1) = V/M;
  61. A2(i,i) = -V/M;
  62. end
  63. A2(9,8) = V/M;
  64. A2(9,9) = -(V+VF)/M;
  65. for i = 10:15
  66. A2(i,i-1) = (V+VF)/M;
  67. A2(i,i) = -(V+VF)/M;
  68. end
  69. A2(16,15) = (V+VF)/Md;
  70.  
  71. A3 = zeros(16,1);
  72. A3(8) = LF*xF/M;
  73. A3(9) = VF*yF/M;
  74.  
  75. x0 = zeros(16,1);
  76.  
  77. fun = @(x)[(dot(A1(1,:),x)+dot(A2(1,:),alpha.*x./(1+(alpha-1).*x))+A3(1));...
  78. (dot(A1(2,:),x)+dot(A2(2,:),alpha.*x./(1+(alpha-1).*x))+A3(2));...
  79. (dot(A1(3,:),x)+dot(A2(3,:),alpha.*x./(1+(alpha-1).*x))+A3(3));...
  80. (dot(A1(4,:),x)+dot(A2(4,:),alpha.*x./(1+(alpha-1).*x))+A3(4));...
  81. (dot(A1(5,:),x)+dot(A2(5,:),alpha.*x./(1+(alpha-1).*x))+A3(5));...
  82. (dot(A1(6,:),x)+dot(A2(6,:),alpha.*x./(1+(alpha-1).*x))+A3(6));...
  83. (dot(A1(7,:),x)+dot(A2(7,:),alpha.*x./(1+(alpha-1).*x))+A3(7));...
  84. (dot(A1(8,:),x)+dot(A2(8,:),alpha.*x./(1+(alpha-1).*x))+A3(8));...
  85. (dot(A1(9,:),x)+dot(A2(9,:),alpha.*x./(1+(alpha-1).*x))+A3(9));...
  86. (dot(A1(10,:),x)+dot(A2(10,:),alpha.*x./(1+(alpha-1).*x))+A3(10));...
  87. (dot(A1(11,:),x)+dot(A2(10,:),alpha.*x./(1+(alpha-1).*x))+A3(11));...
  88. (dot(A1(12,:),x)+dot(A2(12,:),alpha.*x./(1+(alpha-1).*x))+A3(12));...
  89. (dot(A1(13,:),x)+dot(A2(13,:),alpha.*x./(1+(alpha-1).*x))+A3(13));...
  90. (dot(A1(14,:),x)+dot(A2(14,:),alpha.*x./(1+(alpha-1).*x))+A3(14));...
  91. (dot(A1(15,:),x)+dot(A2(15,:),alpha.*x./(1+(alpha-1).*x))+A3(15));...
  92. (dot(A1(16,:),x)+dot(A2(16,:),alpha.*x./(1+(alpha-1).*x))+A3(16))];
  93.  
  94. tstep = 3600; %Number of steps
  95. tfinal = 4; %Total run time in hours
  96. %Runge-Kutta Parameters
  97. a1 = 1/2;
  98. a2 = 1/2;
  99. p = 1;
  100. q = 1;
  101. h = tfinal/tstep; %Timestep in hours
  102. xold = x0; %Use initial conditions
  103. xfinal = zeros(16,tstep+1);
  104. xfinal(:,1) = x0;
  105. time = linspace(0,tfinal,tstep+1);
  106. for i = 1:tstep
  107. xnew = xold + a1*h*fun(xold)+a2*h*fun(xold+h*fun(xold)); %One interation of Runge-Kutta to get new value
  108. xold = xnew; %Reset old value
  109. xfinal(:,i+1) = xnew; %Store new value
  110. end
  111. x1final = xfinal(1,:);
  112. x2final = xfinal(2,:);
  113. x3final = xfinal(3,:);
  114. x4final = xfinal(4,:);
  115. x5final = xfinal(5,:);
  116. x6final = xfinal(6,:);
  117. x7final = xfinal(7,:);
  118. x8final = xfinal(8,:);
  119. x9final = xfinal(9,:);
  120. x10final = xfinal(10,:);
  121. x11final = xfinal(11,:);
  122. x12final = xfinal(12,:);
  123. x13final = xfinal(13,:);
  124. x14final = xfinal(14,:);
  125. x15final = xfinal(15,:);
  126. x16final = xfinal(16,:);
  127. plot(time,x1final,time,x2final,time,x3final,time,x4final,time,x5final,...
  128. time,x6final,time,x7final,time,x8final,time,x9final,time,x10final,...
  129. time,x11final,time,x12final,time,x13final,time,x14final,time,...
  130. x15final,time,x16final)
  131. legend('Bottoms', 'Tray 1', 'Tray 2', 'Tray 3', 'Tray 4', 'Tray 5',...
  132. 'Tray 6', 'Tray 7', 'Tray 8', 'Tray 9', 'Tray 10', 'Tray 11',...
  133. 'Tray 12', 'Tray 13', 'Tray 14', 'Distillate', 'location',...
  134. 'northwest', 'NumColumns', 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement