Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 3.23 KB | None | 0 0
  1. // This script is part of a calculation of the reaction rate of the chemical reaction with coal and oxygen. The calculation is done by iterating over steps. First the reaction rate of each component is calculated on each step. Using this rate the script calculates the new concentration of each component. Also the heat release of the chemical reaction is calculated.
  2.  
  3. // The reaction rate is influenced by the temperature. Due to the heat release of the reaction, the iteration needs to be done to approximate more accurate results.
  4.  
  5. //------------------------
  6. // Input Data
  7. //------------------------
  8. clear;
  9. "Beginn"
  10. T0      =  300;         // temperature
  11. ER      =  12682;
  12. h       =  -2.2035D7;
  13. cw      =  610400;
  14. d       =  1;
  15. cB0 =  560;
  16. cO0     =  0.06;
  17. cS0     =  0;
  18. cG0     =  0;
  19. MB      =  3948.5265;  
  20. MO      =  31.9988;
  21. MS      =  2192.5792;
  22. MG      =  30.7989406666667;
  23. nuB     =  -1;
  24. nuO     =  -89.5;
  25. nuS     =  1;
  26. nuG     =  150;
  27. K1      =  2.3574D7;
  28. K2      =  3.929D8;
  29. abbruchT = 730;
  30. abbruchC = 0.0001;
  31.  
  32. //----------------------------------------------------------
  33. // Target File
  34. //----------------------------------------------------------
  35. pathname = get_absolute_file_path('b.sce');
  36. getshortpathname(pathname);
  37. tarFile2 = mopen(pathname+'b2.csv','w');
  38.  
  39. //----------------------------------------------------------
  40. // Functions
  41. //----------------------------------------------------------
  42. // Reaction Rates
  43. function RB2 = calcReactRateB2(cB2a,cO2a,T2a)
  44.   RB2 = -cB2a * cO2a * K2 * exp(-(ER/T2a)) *60*60*24;
  45. endfunction
  46. function RO2 = calcReactRateO2(RB2)
  47.   RO2 = (nuO/nuB)*(MO/MB)*RB2;
  48. endfunction
  49. function RS2 = calcReactRateS2(RB2)
  50.   RS2 = (nuS/nuB)*(MS/MB)*RB2;
  51. endfunction
  52. function RG2 = calcReactRateG2(RB2)
  53.   RG2 = (nuG/nuB)*(MG/MB)*RB2;
  54. endfunction
  55. // Concentrations
  56. function cB2 = calcConB2(cB2a,RB2)
  57.   cB2 = cB2a+RB2*d;
  58. endfunction
  59. function cO2 = calcConO2(cO2a,RO2)
  60.   cO2 = cO2a+RO2*d;
  61. endfunction
  62. function cS2 = calcConS2(cS2a,RS2)
  63.   cS2 = cS2a+RS2*d;
  64. endfunction
  65. function cG2 = calcConG2(cG2a,RG2)
  66.   cG2 = cG2a+RG2*d;
  67. endfunction
  68. // Heat Release
  69. function q2 = calcHeatRelease2(RB2)
  70.   q2 = RB2*h*d;
  71. endfunction
  72. function Tzu2 = calcTempInc2(q2)
  73.   Tzu2 = q2/cw;
  74. endfunction
  75. function T2 = calcTemp2(T2a,Tzu2)
  76.   T2 = T2a + Tzu2;
  77. endfunction
  78. // Balance
  79. function z2 = calcConBalance2(cB2,cO2,cS2,cG2)
  80.   z2 = cB2 + cO2 + cS2 + cG2;
  81. endfunction
  82. function v2 = calcRateBalance2(RB2,RO2,RS2,RG2)
  83.   v2 = RB2 + RO2 + RS2 + RG2;
  84. endfunction
  85.  
  86. //----------------------------------------------------------
  87. // Values in step 0
  88. //----------------------------------------------------------
  89. t=0;
  90. // definieren
  91. RB2 = 0; RO2 = 0; RS2 = 0; RG2=0;
  92. cB2 = cB0; cO2 = cO0; cS2 = cS0; cG2 = cG0;
  93. q2 = 0; Tzu2 = 0; T2 = T0;
  94. z2 = calcConBalance2(cB2,cO2,cS2,cG2);
  95. v2 = calcRateBalance2(RB2,RO2,RS2,RG2);
  96. // schreiben
  97. mfprintf(tarFile2,'%f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\t %30.29f\n',t,RB2,RO2,RS2,RG2,cB2,cO2,cS2,cG2,q2,Tzu2,T2,z2,v2)
  98.  
  99. // iteration left out to minimize the example
  100.  
  101. //----------------------------------------------------------
  102. // close file
  103. //----------------------------------------------------------
  104. mclose(tarFile2);
  105. "Fertig!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement