REDUCE

20.47 REACTEQN: Support for Chemical Reaction Equation Systems

This package allows a user to transform chemical reaction systems into ordinary differential equation systems (ODE) corresponding to the laws of pure mass action.

Author: Herbert Melenk.

A single reaction equation is an expression of the form

\(\langle \)n1\(\rangle \)\(\langle \)s1\(\rangle \) + \(\langle \)n2\(\rangle \)\(\langle \)s2\(\rangle \) + …->\(\langle \)n3\(\rangle \)\(\langle \)s3\(\rangle \) + \(\langle \)n4\(\rangle \)\(\langle \)s4\(\rangle \) + …

or

\(\langle \)n1\(\rangle \)\(\langle \)s1\(\rangle \) + \(\langle \)n2\(\rangle \)\(\langle \)s2\(\rangle \) + …<>\(\langle \)n3\(\rangle \)\(\langle \)s3\(\rangle \) + \(\langle \)n4\(\rangle \)\(\langle \)s4\(\rangle \) + …

where the \(\langle \)si\(\rangle \) are arbitrary names of species (REDUCE symbols) and the \(\langle \)ni\(\rangle \) are positive integer numbers. The number 1 can be omitted. The connector -> describes a one way reaction, while <> describes a forward and backward reaction.

A reaction system is a list of reaction equations, each of them optionally followed by one or two expressions for the rate constants. A rate constant can a number, a symbol or an arbitrary REDUCE expression. If a rate constant is missing, an automatic constant of the form RATE(n) (where n is an integer counter) is generated. For double reactions the first constant is used for the forward direction, the second one for the backward direction.

The names of the species are collected in a list bound to the REDUCE share variable species. This list is automatically filled during the processing of a reaction system. The species enter in an order corresponding to their appearance in the reaction system and the resulting ode’s will be ordered in the same manner.

If a list of species is preassigned to the variable species either explicitly or from previous operations, the given order will be maintained and will dominate the formatting process. So the ordering of the result can be easily influenced by the user.

Syntax:

reac2ode{\(\langle \)reaction\(\rangle \) [,\(\langle \)rate\(\rangle \) [,\(\langle \)rate\(\rangle \)]] [,\(\langle \)reaction\(\rangle \) [,\(\langle \)rate\(\rangle \) [,\(\langle \)rate\(\rangle \)]]] …};

where two rates are applicable only for <> reactions.

Result is a system of explicit ordinary differential equations with polynomial righthand sides. As side effect the following variables are set:

Lists:

rates

list of the rates in the system

species

list of the species in the system

Matrices:

inputmat

matrix of the input coefficients

outputmat

matrix of the output coefficients

In the matrices the row number corresponds to the input reaction number, while the column number corresponds to the species index. Note: if the rates are numerical values, it will be in most cases appropriate to switch on REDUCE rounded mode for floating point numbers. That is

on rounded;

Inputmat and outputmat can be used for linear algebra type investigations of the reaction system. The classical reaction matrix is the difference of these matrices; however, the two matrices contain more information than their differences because the appearance of a species on both sides is not reflected by the reaction matrix.

EXAMPLES: This input

% Example taken from Feinberg (Chemical Engineering):

   species := {A1,A2,A3,A4,A5};

   reac2ode { A1 + A4 <> 2A1, rho, beta,
              A1 + A2 <> A3, gamma, epsilon,
              A3      <> A2 + A5, theta, mue};

gives the output


{df(a1,t)

                     2
 =rho*a1*a4 - beta*a1  - gamma*a1*a2 + epsilon*a3,

 df(a2,t)= - gamma*a1*a2 + epsilon*a3 + theta*a3

  - mue*a2*a5,

 df(a3,t)

 =gamma*a1*a2 - epsilon*a3 - theta*a3 + mue*a2*a5,

                                2
 df(a4,t)= - rho*a1*a4 + beta*a1 ,

 df(a5,t)=theta*a3 - mue*a2*a5}

The corresponding matrices are

 inputmat;

[1  0  0  1  0]
[             ]
[1  1  0  0  0]
[             ]
[0  0  1  0  0]

 outputmat;

[2  0  0  0  0]
[             ]
[0  0  1  0  0]
[             ]
[0  1  0  0  1]

% computation of the classical reaction matrix as
% difference of output and input matrix:

  reactmat := outputmat-inputmat;

            [1   0   0   -1  0]
            [                 ]
reactmat := [-1  -1  1   0   0]
            [                 ]
            [0   1   -1  0   1]

% Example with automatic generation of rate constants
% and automatic extraction of species

   species := {};

   reac2ode { A1 + A4 <> 2A1,
              A1 + A2 <> A3,
                   a3 <> A2 + A5};

new species: a1
new species: a4
                                                                     

                                                                     
new species: a2
new species: a3
new species: a5

               2
{df(a1,t)= - a1 *rate(2) + a1*a4*rate(1)

  - a1*a2*rate(3) + a3*rate(4),

            2
 df(a4,t)=a1 *rate(2) - a1*a4*rate(1),

 df(a2,t)= - a1*a2*rate(3) - a2*a5*rate(6)

  + a3*rate(5) + a3*rate(4),

 df(a3,t)=a1*a2*rate(3) + a2*a5*rate(6)

  - a3*rate(5) - a3*rate(4),

 df(a5,t)= - a2*a5*rate(6) + a3*rate(5)}

% Example with rates computed from numerical expressions

   species := {};

   reac2ode { A1 + A4 <> 2A1, 17.3* 22.4^1.5,
                              0.04* 22.4^1.5 };

new species: a1
new species: a4

{df(a1,t)

                     2
 = - 4.24064598853*a1  + 1834.07939004*a1*a4,

                          2
 df(a4,t)=4.24064598853*a1  - 1834.07939004*a1*a4}


Hosted by Download REDUCE Powered by MathJax