Jim421616

Modelling Assignment

Sep 29th, 2021 (edited)
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.14 KB | None | 0 0
  1. %script file to solve tank's in series (assignment question 1)
  2. %ModellingAssignmentFns contains the ODE's
  3.  
  4. %Definition of global variables
  5. global t
  6. global M1 % Mass in tank 1 kg
  7. global M2 % Mass in tank 2 kg
  8. global cp % Specific heat capacity of reactant J.kg-1 °C-1
  9. global T1 % Temperature in tank 1 °C
  10. global T2 % Temperature in tank 2 °C
  11. global THi % Temperature of jacket fluid in °C
  12. global THo % Temperature of jacket fluid out °C
  13. global THm % Temperature of jacket between tank 1 and 2 °C
  14. global E % Activation energy J.mol-1
  15. global R % Ideal gas constant J.mol-1K-1
  16. global k % Rate constant (mol.kg-1)1-n s-1
  17. global T1i % Initial temperature in tank 1 °C
  18. global T2i % Initial temperature in tank 2 °C
  19. global F % Flowrate between tanks kg.s-1
  20. global q % Flowrate of heating fluid in jackets kg.s-1
  21. global cpw % Specific heat capacity of heating fluid J.kg-1 °C-1
  22. global C1 % Concentration in tank 1 mol.kg-1
  23. global C2 % Concentration in tank 2 mol.kg-1
  24. global Cf % Feed concentration to tank 1 mol.kg-1
  25. global UA % Overall htc jacket to tanks W.m-2°C-1
  26. global C1i % Initial concentration in tank 1 mol.kg-1
  27. global C2i % Initial concentration in tank 2 mol.kg-1
  28.  
  29. % Quantify variables
  30. % t time s
  31. M1 = 50; % Mass in tank 1 kg
  32. M2 = 50; % Mass in tank 2 kg
  33. cp = 4180; % Specific heat capacity of reactant J.kg-1 °C-1
  34. E = 50; % Activation energy J.mol-1
  35. R = 8.314; % Ideal gas constant J.mol-1K-1
  36.  
  37. F = 100/60/10; % Flowrate between tanks kg.s-1
  38. q = 100; % Flowrate of heating fluid in jackets kg.s-1
  39. cpw = 4180; % Specific heat capacity of heating fluid J.kg-1 °C-1
  40. Cf = 20; % Feed concentration to tank 1 mol.kg-1
  41. UA = 50; % Overall htc jacket to tanks W.m-2°C-1
  42.  
  43.  
  44. % Define the simulation time
  45. tSpan = 60;
  46. tStop = 3600;
  47.  
  48. % Initial conditions
  49. T1i = 20; % Initial temperature in tank 1 °C
  50. T2i = 20; % Initial temperature in tank 2 °C
  51. C1i = 50; % Initial concentration in tank 1 mol.kg-1
  52. C2i = 50; % Initial concentration in tank 2 mol.kg-1
  53.  
  54. [t, T1, T2, C1, C2] = ode45('ModellingAssignment1BFuns', [0:tSpan:tStop], [t, T1i, T2i, C1i, C2i]);
  55.  
  56. % Plot the graphs
  57. % Once we have the solutions to the ODEs, this bit should be easy.
Add Comment
Please, Sign In to add comment