You are on page 1of 14

Example of an Isothermal Continuous Reactor with

COPASI
Filipe Gama Freire
Department of Chemical Engineering
ISTUniversidade de Lisboa
Lisboa, Av. Rovisco Pais, 1 Portugal
December 5, 2014

Abstract
This article aims to fill an important gap in COPASI documentation and examples.
The most helpful example was Model of oscillating NF-kappaB signaling [1].
We implement and solve, in detail, a continuous flow stirred tank reactor (CSTR)
and validate the solution.

1
Contents
1 Introduction 3

2 First order isothermal CSTR 4

3 Second order isothermal CSTR 11

4 Conclusions 13

2
1 Introduction
COPASI is a software application for simulation and analysis of chemical/biochemical net-
works and their dynamics [2].
Its development concerned primarily batch systems. However, COPASI can be used to
analyse reactions conducted in open systems. For instance, due to its analogy to a batch
reactor, ideal tubular reactors can already be studied using COPASI. With only small tricks
we can also analyse the kinetics of reactions performed during CSTR startup.

System A general CSTR dynamics can be described as:


d(V Ci ) 1
= Q(Cio Ci ) + r(Cin )V
dt i
where:
V - reactor volume
Ci - Concentration of i species
Q - Volumetric flow rate
i - Stoichiometric coeficiente of the i species in the stoichiometric equation
r(Cin ) - rate of reaction
n - reaction order

Case For COPASI demonstration purpose, suppose a particular simple case:


dV d(V Ci ) d(Ci )
1. Liquid System. We can consider dt
= 0 and dt
=V dt

2. The reaction is elementary and is A B irreversible.


3. The system is isothermic,

So, the mass balance becomes


dCi
= Q/V Cio Q/V Ci k Ci
dt
where we can identify three terms: a source Q/V Cio , a sink Q/V Ci and a reaction k Ci

Validation

Analitical Solution This example is very simple and has a analytical solution for Ci (t =
0) = Co that is:
1  
Ci = Cio (Cio Co(1 + k V /Q))e(Q/V +k)t
1 + k V /Q

3
Other Solutions For more complex systems, like reaction orders different from zero or
one, or more than one reaction, we need numerical methods to solve them, but its always
possible to achieve a stationary state solution, given by:
dCi
= Q/V (Cio CiS ) k CiS = 0
dt
That for first order is easy to solve in order to Ci .
!
k V /Q
CiS = Cio 1 (1)
1 + k V /Q

where CiS is the stationary state outlet concentration of A.


For orders (n) different from zero or one, we need to solve the equation
n
Q/V (Cio CiS ) k CiS = 0

The V /Q, spatial time, will be a tricky part to input to COPASI, has we will see on the
implementation later on.

2 First order isothermal CSTR


Lets assume the following system:

1. k = 0.15 s1

2. the inverse of spatial time, the spatial velocity Q/V = 2 s1

3. Initial concentration in the reactor Co = 1 M

4. Inlet concentration of reactant, constant and equal to Cio = 2

COPASI implementation.

4
Figure 1: Defining units and time interval in COPASI

First we need to define the units Figure 1. For our case time is in s, volume in L, quantity
is mol and time interval 10 (20 times the spacial time, a stiff thing!).
Secondly, lets create a compartment, say for instance, reactor, with fixed type and volume
1 L, Figure 2.

5
Figure 2: Defining the reactor

For the elementary reaction


AB
we need four species (A, B, In and Out) and the tricky part, four reactions (reaction, SourceA,
OutA and OutB).
Lets introduce first the reaction itself as seen in Figure 3.
The second is not really a reaction but the inlet of A (SourceA) to the reactor as seen in
Figure 4.

Figure 3: Defining the reaction. Name, Rate Law and Parameter k1

6
Figure 4: Defining the inlet of A. Name, Rate Law and Parameter SV

SV is a global quantity and is the spatial velocity (Q/V). We can introduce a numerical
value or for commodity we can define it in Global Quantities section as seen in Figure 5

Figure 5: Defining SV the spatial velocity, in our case SV=2 but we use in the image a
Q/V=4.0/2.0 to demonstrate the possibility of putting equations here to achieve proper
understanding

7
If nothing more comes to the reactor its now necessary to define the sink, the outlets of
A and B, like in Figures 6 and 7.

Figure 6: Defining the outlet of A, of course that will be with the same parameter k1=SV,
because the volume and the volumetric flow rate are to be constant.

8
Figure 7: Defining the outlet of B with the same SV.

We need to define the inlet concentration of A, Figure 8

Figure 8: Defining the inlet concentration of A Cio .

And finally defining the initial condition, the concentration of A inside the reactor at
time=0, Figure 9.

9
Figure 9: Defining the initial concentration of A inside the reactor Cio .

Now, we can solve the system Runing the task Time Course after the creation of a output
with the Output Assistant (plots - Concentrations, Volumes and ...), Figure 10.

Figure 10: Solving the system.

And an automatic plot is generated, Figure 11

10
Figure 11: Plot of the concentration of A in the reactor and outlet with time compared with
the inlet and product concentration.

The easiest way to validate the result is to calculate the stationary concentration of A
that in Figure 11 is shown as approx. 1.86 mol/l and can be calculated as said before eq. 1,
!
k V /Q
CiS = Cio 1 = 2(1 0.15 1/2/(1 + 0.15 1/2) = 1.860
1 + k V /Q

3 Second order isothermal CSTR


For simplicity, let say that everything stays the same with the late example of first order
except, obviously, the kinetic equation, which will now be

2A B

The only thing to do is to change the reaction in the Reaction section to have a rate
expression of second order, Figure 12

11
Figure 12: Defining a second order reaction is the only thing to change to the last example.

Run again the Time Course Task and the automatic generated plot will appear, Figure
13.

12
Figure 13: Plot of the concentration of A in the reactor and outlet with time compared with
the inlet and product concentration for a second order system.

We can now validate the results by solving the system with a ODE solver like the odeint
of the scipy.integrate of Python gets a CiS = 1.611 that is fully compatible with the COPASI
solution (CiS = 1.61).
By solving the ODE with other mean, it is necessary to emphasise that COPASI resolved
the mass balance
dA
= SV (Cio A) 2 k1 A2 with : A(t = 0) = 1, Cio = 2 and k1 = 0.15
dt

4 Conclusions
The first example seemed to take a lot of work for such an easy task as to solve an ODE.
But the reader must pay attention to the possibilities of COPASI, namely the easy imple-
mentation of other systems, as we made the order change, with very complex mechanisms
and its strong ability to make Parameter Estimation with standard error determination.
We regret the absence of an easy implementation of non-isothermal systems but we
understand that is not usually on biochemical problem.

13
This paper is only intended to explain how to extend the huge COPASI capacity to
CSTRs and perhaps other open systems of Chemical Engineering.

References
[1] NF-kappaB signaling pathway oscillations, as published by Nelson et al. (2004), following
the one of Hoffman et al. (2002).

[2] COPASI: biochemical network simulator http://www.copasi.org

14