1
1
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
https://revistascientificas.uach.mx/index.php/tecnociencia
ISSN-e: 2683-3360
Scientific Article
Dynamic Simulation of a Non-linear CSTR Using
Scilab/Xcos®: a Practical Approach for Chemical
Engineering Education
Simulación dinámica de un CSTR No Lineal usando Scilab/Xcos®: un
enfoque práctico para la enseñanza de la Ingeniería Química
*Correspondencia: Correo electrónico: ljuarezm@uach.mx (Luis Carlos Juárez-Martínez)
DOI: https://doi.org/10.54167/tch.v19i1.1874
Recibido: 13 de marzo de 2025; Aceptado: 30 de abril de 2025
Publicado por la Universidad Autónoma de Chihuahua, a través de la Dirección de Investigación y Posgrado.
Editor de Sección: Dr. Sergio Valle-Cervantes
Abstract
Understanding the dynamic behavior of chemical processes is essential for controlling industrial
operation, enhancing safety, and products quality. This work provides an accessible and practical
guide for students and educators to demonstrate the potential of Scilab/Xcos® as an open-source
alternative to MATLAB/Simulink®, for dynamic process simulation in chemical engineering
education. The study focuses on a non-linear Continuous Stirred Tank Reactor (CSTR) model, with
a classic example used to illustrate the different phenomena involved in reaction engineering. Two
different scenarios were simulated to analyze the transient behavior of the CSTR under different
coolant temperature perturbations. In the first case, a 10 K reduction in coolant temperature led to a
significant drop in reaction temperature and increase in reactant concentration. In the second case,
an increase of 5 K in coolant temperature resulted in oscillatory behavior, showcasing the reactor's
sensitivity to temperature changes. The presented simulation is consistent with reference values
from the literature, confirming the accuracy and reliability of the Xcos® model.
Key words: dynamics systems, open-source, MATLAB/simulink alternatives.
Luis Carlos Juárez-Martínez1*, Javier Tovar-Facio1, Rocío Anchondo-Granados1, Rosalía
Ruiz-Santos1, Anel Rocío Carrasco-Hernández1
1 Facultad de Ciencias Químicas, Universidad Autónoma de Chihuahua. Circuito Universitario S/N,
Campus UACH II, Chihuahua, Chih. 31125, México.
2
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Resumen
Comprender el comportamiento dinámico de los procesos químicos es esencial para el control de
procesos industriales, la mejora de la seguridad y la obtención de productos de calidad. Este trabajo
proporciona una guía accesible y práctica para estudiantes y educadores, demostrando el potencial
de Scilab/Xcos® como alternativa de código abierto a MATLAB/Simulink®, para la simulación
dinámica de procesos en la enseñanza de la ingeniería química. El trabajo se centra en el análisis de
un Reactor Continuo de Tanque Agitado (CSTR), utilizando un ejemplo clásico de la literatura para
ilustrar los distintos fenómenos involucrados en la ingeniería de reacciones cuando existen no
linealidades. Se simularon dos escenarios diferentes para analizar el comportamiento transitorio del
CSTR bajo distintas perturbaciones en la temperatura del refrigerante. En el primer caso, una
reducción de 10 K en la temperatura del refrigerante provocó una disminución significativa en la
temperatura de reacción y un aumento en la concentración del reactivo. En el segundo caso, un
incremento de 5 K en la temperatura del refrigerante resultó en un comportamiento oscilatorio,
evidenciando la sensibilidad del reactor a los cambios de temperatura. La simulación presentada es
consistente con los valores de referencia de la literatura, lo que confirma la precisión y confiabilidad
del modelo en Xcos® propuesto.
Palabras clave: sistemas dinámicos, código abierto, alternativas a MATLAB/simulink®.
1. Introduction
The design and operation of industrial plants to produce chemicals requires a solid
understanding of the dynamics systems. This field explores intricate mechanisms governing
chemical reactions with time varying behaviors, facilitating the anticipation, and regulation of
crucial variables like reaction rate, reaction conversion, and product selectivity. By understanding
the kinetics and thermodynamics involved, engineers can design efficient processes, decrease
production expenses, and mitigate environmental footprints. Moreover, process dynamics research
plays a crucial role in maintaining safety standards and products quality in the chemical industry,
while accelerating improvements in chemical processes (Shokry et al., 2020), automation
technologies (Shi et al., 2021), and process intensification (Baldea & Edgar, 2018).
In this respect, Simulink® a toolbox from MATLAB® has helped chemical engineering students at
many universities to learn dynamics and process control. Simulink® is a programming environment
characterized by its block-oriented architecture, making it well-suited for dynamic system modeling
and simulation. Its functionality extends to facilitating system-level design, automatic code
generation, and testing and verification embedded systems. A notable attribute of Simulink® is its
graphical editor and solvers, which enhance the intuitiveness and simplicity of modeling and
simulation tasks compared to conventional numerical coding methods (The MathWorks, 2025).
MATLAB/Simulink® has been used widely for chemical process control analysis. It is easy to find
research papers, tutorials and courses focused on the use of Simulink® for different process control
applications, such as: temperature control of heat exchangers (Jin et al., 2021), control of chemical
reactors (Muhammad et al., 2019) and distillation columns control (Minh, 2010). In addition, some
tutorials can be found at the MathWorks website (The MathWorks, 2025) and full material of
Dynamics and Control courses are available online (for example, Process Dynamics and Control by
3
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
J. Hedenren (Hedengren, 2024) or Process Dynamics, Operations and Control by B. Johnston (MIT
OpenCourseWare, 2024)).
Despite the good features offered by MATLAB/Simulink®, the main disadvantage is related to
licensing cost, which could limit the access to this tool in low and lower middle-income countries.
Consequently, open-source alternatives represent an attractive option for dynamic system modeling
and simulation. Students and educators can find dynamics and control tools that can be used in the
Python programming language; however, these require a level of experience in using this language
or computational tools that students do not always have. Xcos® is a dynamic systems modeler and
simulator that can make up for the lack of programming experience. This powerful tool is available
with Scilab®.
Scilab® offers the benefit of being an open-source simulation tool with a user-friendly interface. It
encompasses numerous mathematical functions and allows the integration of programs from other
languages, such as C++ and Fortran. Additionally, it features a control-oriented toolbox known as
Xcos®, which employs a block-oriented programming approach. Xcos® enables the creation of
mathematical models graphically, utilizing fundamental computing blocks in discrete and
continuous time domains (Dassault Systèmes, 2024).
The Autonomous University of Chihuahua (Universidad Autónoma de Chihuahua, UACH) in
Mexico, offers a process dynamics and control course at the ninth semester (the last semester) in the
undergraduate Chemical Engineering and Food Engineering programs. This subject is a chemical
engineering course commonly offered in other universities worldwide at the end of the program, as
mentioned by Moodley (Moodley, 2020).
Although, the exploration of chemical reactor dynamics starts with the chemical reactor design
course during the third year of the chemical engineering program at the UACH, the process
dynamics and control course is focused on understanding the dynamic performance and control
strategies of different process units such as: mixing tanks, separation columns, heat exchangers,
boilers, and chemical reactors. An important part of the course is that the students gain knowledge
about transient behavior of the processes to evaluate different scenarios that can be found in industry
related to normal and abnormal operation conditions. To achieve this, the use of computational tools
for modeling and simulating chemical processes in dynamic states is both crucial and necessary in
the classroom. The same assertion has been made by other authors such as, Moodley (2020), Vieira
et.al. (2019), and Henrique et.al. (2018).
According to Vieira et.al. (2019), Xcos® is an excellent option for studying dynamic simulations.
However, there is a lack of research papers focused on training and demonstrating the utility of
Xcos® for academic purposes, with most information concentrating on process control.
Hence, the aim of this paper is to present a useful guide for students and professors interested in the
field of chemical process dynamics by using the Scilab/Xcos® programming environment. Also, the
paper brings a comprehensive derivation of the dynamic mass and energy balance equations
involved in the system, by solving a classical non-linear Continuous Stirred Tank Reactor (CSTR)
dynamics example, described in the workhorse book of Process Dynamics and Control written by
Seaborg, et.al. (2016).
4
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
To facilitate reading, the paper is divided into the following sections: in Section 2 an example of
dynamic assessment process is presented, and mathematical model and implementation in Xcos® is
also presented. In section 3, the simulations results can be found. Finally, the conclusions are given
in section 4.
2. Materials and Methods
The study of continuous stirred-tank reactors in chemical engineering programs is of a great
importance because they are widely used in different industrial applications, such as:
pharmaceuticals (Hu, 2021), polymers manufacturing (Wang et al., 2018), in biotechnology to treat
petroleum wastewater (Pugazhendi et al., 2017), and some novel applications such as clean hydrogen
production (Ghimire et al., 2015).
Another important characteristic is that CSTR models are simpler than other reactors such as tubular
and packed-bed reactors. Hence, the study of continuous stirred-tank reactors offers a practical
means to demonstrate modeling principles for chemical reactors in an educational setting.
2.1. Model description
For this study, a non-isothermal continuous stirred-tank reactor was modeled and simulated,
adapted from (Seborg et al., 2016). In this setup, a liquid-phase chemical reaction is studied, where
species A irreversibly transforms into species B. The reaction equation can be represented as follows:
Eq. (1)
An assumption is that the reaction rate is determined by the concentration of component A,
following first-order reaction kinetics (Eq. 2).
Eq. (2)
Where 󰇛󰇜 is the reaction rate, 󰇛󰇜 is the reaction rate constant, and 󰇛󰇜 is the molar concentration of
the reactant .
For single-phase reactions, it can be assumed that the rate constant depends only on the reaction
temperature that it can be described by the Arrhenius equation, expressed by Eq. (3).
󰇛󰇜 󰇡
󰇢 Eq. (3)
Where 󰇛󰇜 is the frequency factor, 󰇛󰇜 is the activation energy, 󰇛󰇜 is the ideal gas constant, and 󰇛󰇜
is the absolute reaction temperature.
Regarding Eqs. (2) and (3), these are classified as semi-empirical relations since the parameters 󰇛󰇜
and 󰇛󰇜 are obtained by fitting experimental data.
In Fig. 1, the schematic diagram of the CSTR studied in this work is shown. As can be seen, only
component is fed to the reactor at a certain flow rate (), at temperature () with a molar
5
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
concentration 󰇛󰇜. The outlet stream exits the reactor at a flow rate of (), at the reaction
temperature () with a concentration of (). To keep reaction at the desired temperature (nominal
value), a cooling fluid is fed through the cooling coil at temperature ().
Figure 1. Continuous Stirred Tank Reactor adapted from Seaborg et.al. (2016).
Figura 1. Reactor Continuo de Tanque Agitado adaptado de Seaborg et al. (2016).
2.2 Mathematical model
This section provides the dynamic derivation of the mass and energy balance equations based
on fundamental principles.
Mass balance
The derivation of the ordinary differential equation that describes the accumulation rate of the
chemical reactants is based on several ideal assumptions (Seborg et al., 2016):
A complete mixing is considered.
Feed and products have constant densities, denoted as 󰇛󰇜
Reaction takes place at constant volume 󰇛󰇜.
Under the previous assumptions, the general mass balance equation can be expressed in the form
shown by Eq. (4).

 󰇗  󰇗  󰇗 Eq. (4)
The derivative term 󰇡
 󰇢 in Eq. (4) represents the material accumulation in the system, 󰇛󰇗 󰇜 and
󰇛󰇗 󰇜 are the inlet and outlet mass flow rates, respectively, (󰇗󰇜 is the generation rate of any chemical
6
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
species due to chemical reactions. Since 󰇛󰇜 and 󰇛󰇜 are constants, then the mass () and mass flow
rate (󰇗 ) can be expressed in the form of Eqs. (5) and (6), respectively.
Eq. (5)
󰇗 Eq. (6)
On the other hand, the rate of generation and consumption of the reactant (A, in this reaction) is
based on reaction kinetics; see Eq. (2). Assuming a well-mixed reactor condition, the reaction rate
󰇛󰇜 does not change with respect to the reactor position. Then, the generation rate of any species can
be expressed in the form of Eq. (7).
󰇗 Eq. (7)
For this example, a first-order reaction is considered with respect to A; hence, the kinetic equation is
given by Eq. (8)
 Eq. (8)
Substituting Eqs. (5–8) into Eq. (4) leads to Eq. (9):
󰇛󰇜
   Eq. (9)
Where 󰇛󰇜 and 󰇛󰇜 are the inlet and outlet volumetric flows, respectively.
Finally, since󰇛󰇜 and 󰇛󰇜 are constants, the inlet and outlet volumetric flow rates ( and ) are equal,
and this assumption must be satisfied at all the time (Seborg et al., 2016).
With the previous assumptions, the unsteady-state component balance for specie A (in molar units)
is described by Eq. (10).
  Eq. (10)
Energy balance
To derive the energy balance equation, the following assumptions are needed (Seborg et al., 2016):
The thermal capacitance of the coolant and the wall of the heat transfer tubes is negligible
compared to the thermal capacitance of reaction species inside the reaction tank.
Uniform coolant temperature distribution is considered, and it is denoted as 󰇛󰇜. Therefore,
any temperature changes in coolant temperature when passes through the tubes is
neglected.
The heat of mixing is negligible compared to the reaction enthalpy.
Thermal losses to the ambient and shaft work are neglected.
7
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
According to the assumptions, the dynamic general energy balance equation is presented in Eq. (11).

 󰇗 󰇗 󰇗 󰇗 Eq. (11)
Where derivative term 󰇡
󰇢represents the energy accumulation in the system, 󰇛󰇗󰇜 and (󰇗󰇜 are
the energy flow that enters and exits the system, and 󰇛󰇗󰇜 and (󰇗) is the rate of reaction heat.
To account the energy accumulation in the system, and the energy flow through the system, Eqs.
(12-14) are used in terms of density, volume and enthalpy.
Eq. (12)
󰇗 󰇗    Eq. (13)
󰇗 󰇗    Eq. (14)
Where 󰇛󰇜 is the reaction mass, 󰇛󰇗 󰇜 and (󰇗 󰇜are the inlet and outlet mass flow rates, and (󰇜,
󰇛󰇜 and 󰇛󰇜 are the inlet and outlet specific enthalpies.
The rate of heat generation (󰇗) due to the chemical reaction is accounted by Eq. (15), and the heat
transfer between the reaction and the coolant is expressed by Eq. (16).
󰇗 󰇛󰇜 Eq. (15)
󰇛 󰇜 Eq. (16)
Where 󰇛󰇜 is the change of enthalpy of reactants and products, 󰇛󰇜 is the reaction rate at
constant volume, 󰇛󰇜 represents the overall heat transfer coefficient, 󰇛󰇜 denotes the heat transfer
area, 󰇛󰇜 and 󰇛󰇜 are the average coolant and reaction temperatures, respectively.
Substituting Eqs. (12-16) in Eq. (11), the energy balance equation takes the form of Eq. (17), where
specific enthalpies can be written as the product of 󰇛 󰇜.

  󰇛󰇜󰇛 󰇜 Eq. (17)
2.3 Model implementation in Xcos®
The intuitive graphical editor in Xcos® simplifies the representation of mathematical models
through block diagrams, where each block corresponds to a predefined function or a user-defined
custom function. These blocks connect seamlessly within the interface, enabling straightforward
system design and analysis (Dassault Systèmes, 2024). In this section a brief description of the blocks
used on the CSTR model is presented.
8
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Xcos® Blocks description
To guide readers in creating the block diagram shown in Fig. 2, Table 1 provides a
description of each object used in this work. The block descriptions are available in the palette browser
within Xcos®.
CSTR model
The CSTR model, which includes Eqs. (3, 10, and 17), corresponds to a coupled set of
differential and algebraic equations. Each equation was implemented in separate subsystems
(SUPER_f blocks) to improve the understanding of the coupled system and facilitate the manipulation
of the variables involved, as shown in Fig. 2.
The illustration of Fig. 2 shows the interaction between subsystems. The initial guess is based on the
steady-state conditions for reaction temperature 󰇛󰇜 and specie A concentration 󰇛󰇜. Under these
conditions, the reaction rate constant 󰇛󰇜 is computed within the Arrhenius Equation Subsystem and
then passed to the Mass and Energy Balance Subsystems to update the reaction temperature and
concentration. This process repeats multiple times until the simulation is complete. The system
integrates user-defined functions with built-in Xcos blocks for mass and energy balances. The mass
balance equation is solved through a dedicated subsystem (highlighted in magenta), while the
energy balance is handled in a separate module (in red). The data flow arrows represent the
directional exchange of variables (e.g., concentration, temperature) between the subsystems and the
main function block.
Figure 2. Diagram of the coupled system implemented in Xcos® for the dynamic simulation of a Continuous
Stirred Tank Reactor (CSTR).
Figura 2. Diagrama del sistema acoplado implementado en Xcos® para la simulación dinámica de un reactor
continuo de tanque agitado (CSTR).
9
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Table 1. Description of the blocks used from palette browser in Xcos®.
Tabla 1. Descripción de los bloques utilizados del palette browser en Xcos®.
Description
This block is an integrator. The output is the integral of the
input at the current time step .
Set constant value block. This block allows setting a numeric
constant value.
This block performs addition or subtraction on scalar, vector or
matrix inputs. The input datatype is set with the datatype
parameter. The number of inputs or sign vector parameter defines
the number of inputs and operation. For a single vector's input,
the block collapses the elements of the vector. Vectors/matrices
inputs must have the same size.
This block computes element-wise multiplication or division of
its vector inputs. The number of inputs and operation are
specified with the number of inputs or sign vector parameter.
To multiply/divide the input , set in this parameter a vector
with  (multiply) or  (divide) for the input .
The unique output of this block generates a regular train of
events that are scheduled by parameter period in seconds. The
starting date of events generation can be set in seconds with the
Initialization Time parameter.
The Scope block displays its input with respect to simulation
time. Both axes have a common range. The Scope allows you to
adjust the amount of time and the range of input values
displayed. It has the feature to scale the graph at runtime.
This block opens a new Xcos® window for editing a new block
diagram. This diagram describes the internal functions of the
super block. Super block inputs and outputs (regular or event)
are designated by special (input or output) blocks.
This block can realize any type of Scicos block. The function of
the block is defined interactively using dialogue boxes and in
Scilab® language. During simulation, these instructions are
10
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
interpreted by Scilab®; the simulation of diagrams that include
these types of blocks is slower
Simulation parameters
The effect of sudden changes in coolant temperature (), was analyzed by replicating both
positive and negative step changes in (), as reported in Seborg et al. (2016).
Table 2 presents key parameters and nominal operating conditions for the Continuous Stirred Tank
Reactor. The system is described by ordinary differential equations (ODEs), with two state variables:
reactant concentration󰇛󰇜and reactor temperature 󰇛󰇜. The cooling water temperature 󰇛󰇜 serves
as the manipulated variable.
Table 2. Simulation parameters (Seborg et al., 2016).
Tabla 2. Parámetros de simulación (Seborg et al., 2016).
Parameter
Symbol
Value
Units
Activation energy
72,750

Arrhenius pre-exponential


Gas constant
8.314

Reactor volume
100
L
Density
1000

Heat capacity

0.239

Enthalpy of reaction

-50,000

Heat transfer coefficient

50,000

Feed flowrate
100

Feed concentration
1.0

Feed temperature
350
Initial concentration
0.5

Initial temperature
350
Coolant temperature
300
11
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Mass balance equation subsystem configuration
To implement the mass balance equation in Xcos® environment, Eq. (10) needs to be
rearranged as follows: the volume divides the equation to have only the derivative term at the left-
hand side of the equation. As a result, both terms on the right-hand side of Eq. (10) are also divided
by the volume (V), yielding a new equation, given in Eq. (18).

 Eq. (18)
The block diagram for Eq. (18) that is within the subsystem called Mass Balance Equation, is presented
in Fig. 3. The nominal parameters 󰇛󰇜, 󰇛󰇜, and 󰇛󰇜 are modeled using constant blocks since their
values remain unchanged during the simulation. To declare their respective value, the set context box
that can be found on the simulation tab was used. About algebraic operations, they are represented
by their respective addition, subtraction, multiplication and division blocks. To help readers
understand how these operations were performed, labels were added to the corresponding blocks
to indicate the type of computation carried out, see Fig. 3.
Figure 3. Block diagram in Xcos® representing the dynamic implementation of the mass balance equation for
the Continuous Stirred Tank Reactor (CSTR).
Figura3. Diagrama de bloques en Xcos® que representa la implementación dinámica de la ecuación de
balance de masa para el Reactor de Tanque Agitado Continuo (CSTR).
12
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
In Fig. 3 is shown the problem model. The model incorporates key input parameters such as flow
rate (), reactor volume (), and feed concentration (). The expression 󰇛󰇜󰇛󰇜 represents
the convective mass transport, and the term 󰇛󰇜 accounts for the first-order reaction kinetics. The
output concentration () is obtained through numerical integration and plotted in real time using
the Scope block.
The set context box allows variable definition and mathematical operations to simplify variable
manipulation, see Fig. 4.
Figure 4. Variable definition in set context for the mass balance equation.
Figura 4. Definición de variables en set context para la ecuación de balance de masa.
Finally, the integrator is set up with the initial condition . This action can be done by
clicking on the integrator block and typing the desired value on the initial condition blank space, see
Fig. 5.
Figure 5. Initial condition set up for the integrator block.
Figura 5. Configuración de la condición inicial para el bloque integrador .
13
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Energy balance equation subsystem
Analogous to the mass balance equation, Eq. (17) must be solved to isolate the derivative
term. To achieve this, Eq. (17) is divided by the product of 󰇛󰇜, resulting in a new equation, Eq.
(19).


󰇛 󰇜󰇛󰇜
 
󰇛󰇜 Eq. (19)
In Fig. 6, the block diagram to solve Eq. (19) is presented. In this case the nominal parameters were
also introduced as constant blocks, such as:  and .
Figure 6. Xcos® block diagram implementing the energy balance equation for the Continuous Stirred Tank
Reactor (CSTR).
Figura 6. Diagrama de bloques de Xcos® que implementa la ecuación de balance de energía para un Reactor
de Tanque Agitado Continuo (CSTR).
In Fig. 6 is shown how the model dynamically calculates the reactor temperature () by integrating
contributions from convective heat exchange 󰇛󰇜󰇛 󰇜, heat generated by the reaction
() and heat transfer with the cooling medium (). The values of the nominal
constant parameters were also set using the set context box (see Fig. 7).
14
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Figure 7. Variable definition in set context box for energy balance equation.
Figura 7. Definición de variables en set context para la ecuación de balance de energía.
For the reaction temperature integrator, the initial condition was set to 350 K, as shown in Fig. 8.
Figure 8. Initial condition set up for reaction temperature integrator block.
Figura 8. Configuración de la condición inicial para el bloque integrador de temperatura de reacción.
Arrhenius equation block
The Arrhenius equation is an exponential function that depends on temperature (Eq. 3). Each
time the reaction temperature changes, the reaction rate constant must be recalculated. In Xcos®,
solving this equation requires utilizing the user-defined function sfunc_block_m.
Double-clicking the sfunc_block_m opens a new configuration window. The first two entries, input
port sizes and output port sizes, should be set to [1,1] and [1,1], respectively. This configuration
indicates that a single input variable, the reaction temperature (T) from the Energy Balance
Subsystem enters the block, while a single output variable, the specific rate constant, exits. Once the
input and output port sizes are defined, click OK to proceed.
15
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
The previous action displays a new box where the function is introduced as follows: on the top of
the box the name of the function is written as Arrhenius Equation, then the inlet variable 󰇛󰇜 that
comes from the Energy Balance equation is defined as Global T. If more input variables are needed,
all of them must be settled as global variables.
To solve a time-dependent function in Xcos®, it must be expressed in the form  . The Arrhenius
equation is then solved in the form of Eq. (20).
󰇛󰇜 󰇡
󰇢 Eq. (20)
Where 󰇛󰇜;
;
;
 ;

Once the function is defined, click ok to continue. The new box, the global variable 󰇛󰇜 is rewritten
for initialization and click ok. If more input variables are needed, they must be declared here for their
respective initialization.
The fourth box is used to create additional commands such as: create graphics, export data
open/close graphics, etc. In this case the box has been left in blank, due to additional instructions are
not necessary. Finally, the last box can be used to define restriction for input, output and state
variables if needed, but in this case, it was also left in blank. The whole process of the user-defined
function configuration is depicted in Fig. 9.
Figure 9. The Arrhenius equation configuration using the sfunc_block_m.
Figura 9. Configuración de la ecuación de Arrhenius utilizando el sfunc_block_m.
16
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
3. Results and discussion
To analyze the transient behavior of the CSTR model presented in the previous section, two
different scenarios were simulated as follows: for the first case, enhanced cooling was simulated by
modifying from 300 K to 290 K. The second case focuses on reducing the cooling rate,
accomplished by increasing from 300 K to 305 K. For both cases, the simulation time was set to
10 minutes.
In the first case, decreasing the coolant temperature to 290 K has two major effects. First, the reaction
temperature drops by approximately 37 K, reaching a new steady-state value of 312.6 K. Second, the
molar concentration of the reactant 󰇛󰇜 increases from 0. mol/L to a new steady-state value of 0.952
mol/L.
For the second simulation, when the cooling jacket temperature is set at 305 K, the CSTR exhibits
sustained oscillations due to the exothermic nature of the reaction and its strong temperature
dependence. As the temperature spikes, the reaction accelerates quickly consuming reactant A. Once
the concentration drops, heat generation decreases, allowing the reactor to cool. The continuous feed
then restores the amount of A, initiating a new cycle.
This nonlinear feedback between reaction kinetics and heat removal leads to self-sustained
oscillations in temperature and concentration. As explained by Seborg et al. (2016), such behavior is
not unusual in chemical reactors, particularly under marginal or critical operating conditions. Small
variations in parameters like the coolant temperature, inlet concentration, or activation energy can
drastically shift the system from steady-state to oscillatory or even unstable regimes.
Figure 10. Reactor temperature response due to coolant temperature changes (), nominal temperature of 300
K. Left side represents the reference results from Seborg et al. (2016) and the right side shows the results
obtained with Xcos®.
Figura 10. Respuesta de la temperatura del reactor debido a cambios en la temperatura del refrigerante (Tc),
con una temperatura nominal de 300 K. El lado izquierdo representa los resultados de referencia de Seborg et
al. (2016), y el lado derecho muestra los resultados obtenidos con Xcos®.
According to this, the results obtained with Xcos® align with the reference values, confirming that
the CSTR model simulated in this study accurately represents the reference model reported by
17
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Seborg et al. (2016). Figs. 10 and 11 present a graphical comparison between the reference results and
the previously discussed simulations.
Figure 11. Concentration response due to coolant temperature changes (), nominal temperature
300 K. Left side represents the reference results from Seborg et al. (2016) and the right side shows
the results obtained with Xcos®.
Figura 11. Respuesta de la concentración debido a cambios en la temperatura del refrigerante (),
temperatura nominal de 300 K. El lado izquierdo representa los resultados de referencia Seborg et
al. (2016), y el lado derecho muestra los resultados obtenidos con Xcos®.
4. Conclusions
This study explored the use of Xcos® for solving dynamic chemical engineering problems.
Specifically, the dynamics of a continuous stirred tank reactor (CSTR) were analyzed, including
model description, mathematical formulation, and Xcos® implementation.
Although, the use of Scilab/Xcos® is not new in research or academia, most of the research papers
are focused on dynamics for control purposes of specific problems in which it is assumed that
readers have certain knowledge on the topic to understand both mathematical models and
implementation. Hence, the structure of this paper was intended to be a practical guide describing
the steps to follow for dynamic modeling and simulation with Xcos®, especially for students and
educators interested in dynamic systems.
The simulator was validated using a well-known example from Seborg et al. (2016), a widely used
textbook in process dynamics and control courses. The simulation results closely matched the
reference values, confirming the accuracy of the model. Therefore, this model can serve as a reliable
reference for educational projects and research activities related to chemical reaction engineering.
Currently, our research group is developing different unit operation simulators that are commonly
studied in chemical engineering programs. The research group aims to offer a wide range of models
for analyzing full plant process dynamics and supports the teaching process using open-source tools.
18
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Hence, we encourage readers to contact the corresponding author for access to the simulator or for
further guidance on how to implement the models discussed in the paper. The authors are open to
providing support for specific simulations, answering technical questions, and offering insights on
adapting the simulator to different case studies or research needs. Reaching out can help ensure the
correct use of the simulator and facilitate collaboration on improvements or extensions.
Acknowledge
The research group FCQ-GI-23-001 acknowledge the Secretary of Research and Postgraduate
Studies of the Faculty of Chemical Sciences, Universidad Autónoma de Chihuahua, for the support
to establish the research group.
Declaration of Competing Interest
The authors declare that there are no known financial conflicts of interest or personal
relationships that could have influenced the research presented in this paper.
References
Baldea, M., & Edgar, T. F. (2018). Dynamic process intensification. Current Opinion in Chemical
Engineering, 22: 48–53. https://doi.org/10.1016/J.COCHE.2018.08.003
Dassault Systèmes. (2024). Xcos | Scilab. https://www.scilab.org/download/scilab-2024.1.0
Ghimire, A., Frunzo, L., Pirozzi, F., Trably, E., Escudie, R., Lens, P. N. L., & Esposito, G. (2015). A
review on dark fermentative biohydrogen production from organic biomass: Process parameters
and use of by-products. Applied Energy, 144: 73–95.
https://doi.org/10.1016/J.APENERGY.2015.01.045
Hedengren, J. D. (2024). Process Dynamics and Control. https://apmonitor.com/che436/
Henrique, J. P., de Sousa, R., Secchi, A. R., Ravagnani, M. A. S. S., & Costa, C. B. B. (2018).
Optimization of chemical engineering problems with EMSO software. Computer Applications in
Engineering Education, 26(1): 141–161. https://doi.org/10.1002/CAE.21867
Hu, C. (2021). Reactor design and selection for effective continuous manufacturing of
pharmaceuticals. Journal of Flow Chemistry 11:3: 243–263. https://doi.org/10.1007/S41981-021-
00164-3
Jin, H. Z., Gu, Y., & Ou, G. F. (2021). Corrosion risk analysis of tube-and-shell heat exchangers and
design of outlet temperature control system. Petroleum Science, 18(4): 1219–1229.
https://doi.org/10.1016/J.PETSCI.2021.07.002
Minh, V. T. (2010). Modeling and control of distillation column in a petroleum process. Proceedings
of the 2010 5th IEEE Conference on Industrial Electronics and Applications, Taichung, Taiwan, ICIEA
2010: 259–263. https://doi.org/10.1109/ICIEA.2010.5516816
MIT OpenCourseWare. (2006). Process Dynamics, Operations, and Control. © 2001–2025 Massachusetts
Institute of Technology. https://ocw.mit.edu/courses/10-450-process-dynamics-operations-and-
control-spring-2006/
19
Juárez-Martínez et.al.
TECNOCIENCIA CHIHUAHUA, Vol. XIX (2025): enero-diciembre, e1874
Moodley, K. (2020). Improvement of the learning and assessment of the practical component of a
Process Dynamics and Control course for fourth year chemical engineering students. Education
for Chemical Engineers, 31: 1–10. https://doi.org/10.1016/J.ECE.2020.02.002
Muhammad, D., Ahmad, Z., & Aziz, N. (2019). Low density polyethylene tubular reactor control
using state space model predictive control. Chemical Engineering Communications, 208(4): 500–516.
https://doi.org/10.1080/00986445.2019.1674816
Pugazhendi, A., Qari, H., Al-Badry Basahi, J. M., Godon, J. J., & Dhavamani, J. (2017). Role of a
halothermophilic bacterial consortium for the biodegradation of PAHs and the treatment of
petroleum wastewater at extreme conditions. International Biodeterioration & Biodegradation, 121:
44–54. https://doi.org/10.1016/J.IBIOD.2017.03.015
Seborg, D. E., Edgar, T. F., Mellichamp, D. A., & Doyle III, F. J. (2016). Process Dynamics and Control
(Fourth edition). John Wiley & Sons, Inc.
Shi, Y., Prieto, P. L., Zepel, T., Grunert, S., & Hein, J. E. (2021). Automated Experimentation Powers
Data Science in Chemistry. Accounts of Chemical Research, 54(3): 546–555.
https://doi.org/10.1021/acs.accounts.0c00736
Shokry, A., Baraldi, P., Zio, E., & Espuña, A. (2020). Dynamic Surrogate Modeling for Multistep-
ahead Prediction of Multivariate Nonlinear Chemical Processes. Industrial and Engineering
Chemistry Research, 59(35): 15634–15655. https://doi.org/10.1021/acs.iecr.0c00729
The MathWorks, Inc. (2025). Simulink Online - MATLAB & Simulink.
https://la.mathworks.com/products/simulink-online.html
Vieira, E. B., Busch, W. F., Prata, D. M., & Santos, L. S. (2019). Application of Scilab/Xcos for process
control applied to chemical engineering educational projects. Computer Applications in Engineering
Education, 27(1): 154–165. https://doi.org/10.1002/CAE.22065
Wang, D., Yang, G., Guo, F., Wang, J., & Jiang, Y. (2018). Progress in Technology and Catalysts for
Continuous Stirred Tank Reactor Type Slurry Phase Polyethylene Processes. Petroleum Chemistry,
58(3): 264–273. https://doi.org/10.1134/S0965544118030064
2025 TECNOCIENCIA CHIHUAHUA.
Esta obra está bajo la Licencia Creative Commons Atribución No Comercial 4.0 Internacional.
https://creativecommons.org/licenses/by-nc/4.0/