reacteqn.rlg 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. Tue Feb 10 12:28:03 2004 run on Linux
  2. % Examples for the conversion of reaction equations to ordinary
  3. % differential equations.
  4. % Example taken from Feinberg (Chemical Engineering):
  5. species := {A1,A2,A3,A4,A5};
  6. species := {a1,
  7. a2,
  8. a3,
  9. a4,
  10. a5}
  11. reac2ode { A1 + A4 <> 2A1, rho, beta,
  12. A1 + A2 <> A3, gamma, epsilon,
  13. A3 <> A2 + A5, theta, mue};
  14. 2
  15. {df(a1,t)=rho*a1*a4 - beta*a1 - gamma*a1*a2 + epsilon*a3,
  16. df(a2,t)= - gamma*a1*a2 + epsilon*a3 + theta*a3 - mue*a2*a5,
  17. df(a3,t)=gamma*a1*a2 - epsilon*a3 - theta*a3 + mue*a2*a5,
  18. 2
  19. df(a4,t)= - rho*a1*a4 + beta*a1 ,
  20. df(a5,t)=theta*a3 - mue*a2*a5}
  21. inputmat;
  22. [1 0 0 1 0]
  23. [ ]
  24. [1 1 0 0 0]
  25. [ ]
  26. [0 0 1 0 0]
  27. outputmat;
  28. [2 0 0 0 0]
  29. [ ]
  30. [0 0 1 0 0]
  31. [ ]
  32. [0 1 0 0 1]
  33. % Computation of the classical reaction matrix as difference
  34. % of output and input matrix:
  35. reactmat := outputmat-inputmat;
  36. [1 0 0 -1 0]
  37. [ ]
  38. reactmat := [-1 -1 1 0 0]
  39. [ ]
  40. [0 1 -1 0 1]
  41. % Example with automatic generation of rate constants and automatic
  42. % extraction of species.
  43. species := {};
  44. species := {}
  45. reac2ode { A1 + A4 <> 2A1,
  46. A1 + A2 <> A3,
  47. A3 <> A2 + A5};
  48. new species: a1
  49. new species: a4
  50. new species: a2
  51. new species: a3
  52. new species: a5
  53. 2
  54. {df(a1,t)= - a1 *rate(2) + a1*a4*rate(1) - a1*a2*rate(3) + a3*rate(4),
  55. 2
  56. df(a4,t)=a1 *rate(2) - a1*a4*rate(1),
  57. df(a2,t)= - a1*a2*rate(3) - a2*a5*rate(6) + a3*rate(5) + a3*rate(4),
  58. df(a3,t)=a1*a2*rate(3) + a2*a5*rate(6) - a3*rate(5) - a3*rate(4),
  59. df(a5,t)= - a2*a5*rate(6) + a3*rate(5)}
  60. on rounded;
  61. species := {};
  62. species := {}
  63. reac2ode { A1 + A4 <> 2A1, 17.3* 22.4**1.5,
  64. 0.04* 22.4**1.5 };
  65. new species: a1
  66. new species: a4
  67. 2
  68. {df(a1,t)= - 4.24064598853*a1 + 1834.07939004*a1*a4,
  69. 2
  70. df(a4,t)=4.24064598853*a1 - 1834.07939004*a1*a4}
  71. end;
  72. Time for test: 1 ms