0% found this document useful (0 votes)
76 views10 pages

Modeling Chemical Reactions in Modelica by Use of

Modeling Chemical Reactions in Modelica by Use of

Uploaded by

Mejbahul Sarker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views10 pages

Modeling Chemical Reactions in Modelica by Use of

Modeling Chemical Reactions in Modelica by Use of

Uploaded by

Mejbahul Sarker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/228496177

Modeling Chemical Reactions in Modelica By Use of Chemo-bonds

Article · October 2009


DOI: 10.3384/ecp09430022

CITATIONS READS

4 266

4 authors, including:

François Cellier Jürgen Greifeneder


ETH Zurich Technische Hochschule Lübeck
219 PUBLICATIONS   3,461 CITATIONS    57 PUBLICATIONS   279 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Probabilistic delay time analysis in networked automation systems View project

Modeling and Simulation of Large Scale Dynamical Systems View project

All content following this page was uploaded by François Cellier on 22 May 2014.

The user has requested enhancement of the downloaded file.


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

Modeling Chemical Reactions in Modelica


By Use of Chemo-bonds
François E. Cellier Jürgen Greifeneder
ETH Zürich ABB AG, Corporate Research Center
Switzerland Germany
[email protected] [email protected]

Abstract His research was continued 12 years later by a


student of one of the authors, Michael Amrhein, who
This paper describes a new methodology for model- described for the first time a chemical reaction sys-
ing and simulating chemical reaction systems using tem by means of bond graphs [1].
vectors of chemo-bonds, called multi-chemo-bonds. In the remainder of this paper, we start out with
Chemical reactions are usually described through modeling the molar flows (Section 2) and put them
mass flows alone. Yet in reality, they are convective together in a multi-bond representation (Section 3).
flows, as the reactants carry their volume and heat In Section 4, the corresponding volume and entropy
with them in the reactions. Each combined flows will be added to the molar flows resulting in a
mass/volume/heat flow can be described by a che- chemo-bond model. Section 5 is similar to Section 3
mo-bond. The combination of all such flows can be and introduces multi-chemo-bonds. Section 6 finally
described by a vector of chemo-bonds, i.e., a multi- offers some conclusions.
chemo-bond.
Keywords: object-oriented modeling of chemical
reactions; chemo-bonds; thermo-bonds; multi- 2 The basic model
chemo-bonds; convective flows
In Amrhein’s work [1], the mass flow variable,

1 Introduction
Traditionally, chemical reaction sys-
tems are described as pure mass flow
systems. There is no need to consider
the energy flows as well, as long as
the thermo-dynamical properties of
the reaction system can be ignored.
As chemical reactions are characte-
rized by capacitive storage only, i.e.,
they don’t feature inductive storage,
the mass balance and energy balance
equations are decoupled from each
other [2].
A first attempt of describing the
thermodynamics of chemical reaction
systems in a systematic way was re-
ported in [5]. Unfortunately, the pri-
mary author of that paper, Aharon
Katzir-Katchalsky, died prematurely
during an attack by Palestinians on the
airport of Tel-Aviv. After his death,
this line of research stopped for sever-
al years. Fig.1: Chemical reaction bond graph

© The Modelica Association, 2009 142 DOI: 10.3384/ecp09430022


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

i.e., the molar flow of a reactant in a reaction, is ac- individual step reactions, namely:
companied by a potential variable, the chemical po-
tential, such that the product of the two variables
denotes energy flow. Amrhein’s bond graph simu-
lated simultaneously the mass flow and the mass-
energy flow through the reaction system. He mod-
eled a hydrogen-bromine reaction to be simulated
under different operating conditions. The simplest
experimental setup freezes the temperature and the Reaction #4, the least important of the five step reac-
pressure, i.e., the chemical reaction is simulated un- tions, was generously left out of the graph to keep
der isothermal and isobaric operating conditions. the graph planar. Second, the chemical reactors, i.e.,
Amrhein’s model is shown in Fig.1. the ChR-elements, require state information that is
Amrhein developed his new modeling methodol- being computed by the CS-elements. Hence there
ogy years before Modelica was created, and he need to be added signal paths between the CS-
coded his models in the old Dymola language before elements and the ChR-elements that were also left
a graphical interface had become available for Dy- out for enhanced readability.
mola. Hence the bond graph of Fig.1 is not a code, A completed graph of Amrhein’s model, now
but only a picture that was drawn manually to make coded in a current version of Dymola using BondLib
the code better understandable. [4] is shown in Fig.2. The grey lines are used to
The CS-elements represent the (capacitive) sto- connect bonds with junctions and vice-versa, i.e.,
rage of the five reactants, whereas the ChR-elements they represent the same energy flows as the bonds
represent the five individual step reactions. They are connected to them. The blue lines represent infor-
connected by a network of bonds, junctions, and mation flows. 0 and 1 represent junctions, and the
transformers representing the chemical reaction net- half-arrows represent bonds.
work. The model of Fig.2 can be simulated in Dymola
Yet, the graph shown in Fig.1 is far from com- without any problems, and for a temperature of T =
plete. First, it only shows four ChR-elements, al- 800 K and a pressure of p = 102 kPa, we obtain the
though the hydrogen-bromine reaction exhibits five trajectories shown in Fig.3.

Fig.2: Completed chemical reaction bond graph

© The Modelica Association, 2009 143


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

Initially, we start out with 0.0075 mol of H2 and Br2 Unfortunately, the bond graph of Fig.2 is a mess, and
 few researchers will be willing to go through the
each, create and consume the temporary atoms Br

and H , and after roughly 0.07 s, we end up with agony of describing chemical reactions in this fa-
shion. Therefore in the remainder of this paper, we
0.015 mol of HBr.
shall improve on the model step by step, and create
ever better models that can be used more easily.

3 The Chemical Reaction Network


The chemical potentials, i, of the reactants are com-
puted by the CS-elements. These are then transferred
across the chemical reaction network, which com-
putes the chemical potentials of the individual step
reactions, ki. The ChR-elements use that informa-
tion to determine the molar flow rates of the step
reactions,ki, which are then transferred back across
the chemical reaction network, which computes the
Fig.3: Chemical reaction trajectories
molar flow rates of the reactants,i. These are then
integrated inside the CS-elements into the states, i.e.,
The same results could have been obtained more eas-
the number of moles, ni, which in turn are needed by
ily by writing down the reaction rate equations di-
the ChR-elements to compute the flow rates. The
rectly, but the presented bond graph model is supe-
state vector is transferred from the CS-elements back
rior, because it represents not only the dynamics of
to the ChR-elements through separate signal paths,
the mass flows through the reactions, but also the
i.e., outside the bond graph.
corresponding energy flows. Each chemical bond
As already demonstrated in [2], the chemical
contains two variables, an effort , representing a
reaction network, relating reactants and step reac-
chemical potential, and a molar flow rate , tions to each other, can be interpreted as a multi-port
representing the mass flow, such that: transformer. Consequently, we can write:
P = ·

is the power flowing through the bond.


Hence the bond graph can also be used to com-
pute the power flows through the reaction network,
and we notice that the reaction is mildly exothermic,
as documented in Fig.4, where the entropy gain is
being shown. Roughly S = 0.06 J/K of entropy are
being generated during the reaction.

This can also be written as:

where N is the transfer matrix for the flow rates, and


M = NT is the transfer matrix for the chemical poten-
tials.
As we can describe the chemical reaction network
using a multi-port transformer, it makes sense to ex-
tract the five CS-elements into a single CF-element,
a capacitive field. As shown in Fig.5, this CF-
element has on its left side, the five state variables,
Fig.4: Entropy gain during chemical reaction grouped into a state vector, whereas on the right side,

© The Modelica Association, 2009 144


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

there is now a vector of bond connectors, each discussed before, whereas the bond graph connectors
representing one reactant. on top and below the mass flow connector are single
connectors, one representing the heat flow and the
other representing the volumetric flow. Under iso-
thermal and isobaric operating conditions, these two
connectors are used to impose from the outside the
desired temperature of T = 800 K and the desired
pressure of p = 102 kPa.
Finally, the vector connector of the RF-element
also needs to be converted to a multi-bond connec-
tor, as shown in Fig.8.

Fig.5: Capacitive field vector bond graph

For further processing, the vector of (grey) regular


bond connectors needs to be converted to a single
(blue) multi-bond connector, as shown in Fig.6. As
the conversion element has been implemented as a
bond, we need to add a 0-junction also, in order to
comply with the rule of all of our bond graph libra-
ries that all macro elements must end in junctions, Fig.8: Conversion of bond vector to multi-bond
rather than in bonds.
We are now ready to model the entire chemical reac-
tion using MultiBondLib [6], a second bond graph
library designed particularly for modeling mechani-
cal systems in two and three space dimensions. Yet,
Fig.6: Conversion of bond vector to multi-bond the library can also be used for any other model that
requires vectors of bonds.
In the same way as with the five CS-Elements, we The resulting model is shown in Fig.9. The chem-
can also stack the five ChR-elements into a single ical reaction network has not been modeled graphi-
RF-element, a resistive field, as shown in Fig.7. cally in this model, but rather, was represented using
a multi-port transformer (TF_H2Br2). The uncon-
nected MBG_defaults model shown at the bottom
right corner of Fig.9 represents the multi-bond world
model that sets the default dimension of all multi-
bonds to a value of five.

Fig.7: Resistive field vector bond graph


Fig.9: Chemical reaction modeled using multi-bonds
The attentive reader might already have discovered
that the resistive field has three bond graph connec- The simulation results obtained with this code are
tors: The one at the center on the right side is a vec- exactly the same as with the model of Fig.2, as these
tor connector representing the five mass flows as are truly identical models.

© The Modelica Association, 2009 145


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

4 Thermo-bonds and Chemo-bonds Each thermo-bond represents a parallel connec-


tion of three regular bonds, one for each of the three
As shown in Fig.10, an excerpt of Fig.1, each ChR- types of power flow. This is shown in Fig.11.
element has three bond graph connectors, one
representing mass flow (variables  and , i.e.,
chemical potential and molar flow rate), a second
representing volumetric flow (variables p and q, i.e.,
pressure and volumetric flow rate), and a third
representing heat flow (variables T and Sdot, i.e.,
temperature and entropy flow rate). Each of the
three pairs, when multiplied, represents a power flow
Fig.11: Composition of a thermo-bond
measured in Watts.
Since the thermo-bonds represent a specific physical
phenomenon, it made sense to associate thermo-
bonds with measurement units, i.e., whereas the reg-
ular (black) bonds of BondLib [4] and the (blue)
multi-bonds of MultiBondLib [6] are neutral, the
(red) thermo-bonds of ThermoBondLib [3] have
been associated with measurement units explicitly.
For convective flows, it was convenient to meas-
ure the mass flow, mdot, in kg/s. Consequently, the
Fig.10: ChR-element corresponding effort variable, g, must be measured
in J/kg, such that their product is once again a power
Although the three bonds represent different physical flow measured in Watts. The effort variable of mass
phenomena, they are mathematically identical. For flow, g, is the Gibbs potential, which sometimes is
this reason, it is important that bond variables are also called specific Gibbs energy.
declared as ‘Real’ in Modelica, rather than be asso- Notice that g has the same units as h, the specific
ciated with particular measurement units. These va- enthalpy, but it is not the same quantity:
riables may inherit measurement units through the
higher layers of the model architecture, but by them- h = g + T·s
selves, bond graph variables are neutral.
It is not possible to have mass flows without ac- where s denotes the specific entropy, i.e., the entropy
companying volume flows and heat flows, because per unit mass.
the masses always carry their own volume and heat Note: The Gibbs potential is still currently miss-
with them. The internal energy of matter of a mass ing in the SIunits library of Modelica.
can be written as: Since mass flows cannot occur without accompa-
nying volume and heat flows, it makes sense to in-
U = T·S – p·V + ·n terpret chemical reactions as convective flows, and
replace the (black) regular bonds of Fig.2 by (red)
with the corresponding power flow: thermo-bonds. In this way, there will be no need any
longer to treat the thermal and volumetric flows sep-
Udot = T · Sdot – p · q +  ·  arately from the mass flows, and the ChR-elements
 will now only have one thermo-bond connector.
Thus, each mass flow can be interpreted as a parallel Unfortunately, it is inconvenient to represent
connection of three individual power flows, one mass flows in chemical reactions as absolute mass
representing the mass flow itself, a second flows, measured in kg/s, because chemical reactions
representing the accompanying volumetric flow, and occur in relation to the number of molecules in-
a third representing the heat flow. volved, and not in relation to the weight of the reac-
As these three flows belong together, we have tants. Correspondingly, chemical mass flows are giv-
created a third bond graph library, called Thermo- en as molar flow rates, , measured in mol/s, and
BondLib [3] that has been designed specifically for correspondingly, the associated effort variable is the
modeling convective flows. chemical potential, , measured in J/mol.
It is easy to convert between the two types of
mass flows. This is simply a transformation, as

© The Modelica Association, 2009 146


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

shown in Fig.12. It would have been possible to deal The entire chemical reaction network is now shown
with molar flow rates using the ‘redeclare’ feature of in green. Each of the green bonds models three pa-
Modelica, but it was simpler to create yet another rallel energy flows. As the substances, represented
bond graph library, ChemBondLib, this time featur- through the (red) CF-elements, are modeled using
ing green chemo-bonds, that are identical to the red absolute masses (they are the very same CF-elements
thermo-bonds except for the way in which the mass that we had introduced in [3] before), one of the
flows are being represented. transformers shown in Fig.12 is placed between the
(green) chemical reaction network and each of the
(red) CF-elements.
The model is much simpler than that of Fig.2, be-
cause there is no longer any need to deal with the
heat and volumetric flows separately. These flows
are now transferred across the reaction network to-
gether with the mass flows.
The CF-elements now compute the three potential
(effort) variables, T, p, and . These variables are
then transferred across the chemical reaction network
Fig.12: Conversion from absolute mass flow rates to
to the side of the step reactions. The ChR-elements
molar flow rates
compute the three flow variables, Sdot, q, and .
We are now ready to formulate the third version of These are transferred back across the reaction net-
the chemical reaction model. This new model is work to the side of the reactants.
shown in Fig.13. Each CF-element computes a partial state vector
including the three variables S, V, and
n. The partial state vectors are conca-
tenated to a complete state vector in
the St-model that transfers the state
information back to the ChR-
elements, as the reactor models re-
quire the state information to compute
the flows.
As expected, the simulation results
obtained by this third version of the
model are identical to those received
earlier.

5 Multi-chemo-bonds or
Chemo-multi-bonds ?
We can now once again eliminate the
graphical representation of the chemi-
cal reaction network and replace it by
a multi-port transformer.
To this end, we again stack the five
CF-elements, as shown in Fig.14.
On the right side, we now have a
vector of (green) chemo-bond connec-
tors, each representing three flows, a
heat flow, a volumetric flow, and a
molar mass flow. Thus, the vector
chemo-bond connector can be inter-
preted as a multi-chemo-bond connec-
tor.
Fig.13: Chemical reaction modeled by chemo-bonds

© The Modelica Association, 2009 147


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

Fig.17: Conversion of connectors

As expected, the stacked reactor model of Fig.16 is


much simpler than the corresponding stacked reactor
model of Fig.7, because the thermal and pneumatic
flows are not handled separately any longer.
The complete model (fourth version) is shown in
Fig.18.

Fig.14: Capacitive reactant field

Fig.15 shows, how the vector of individual che-


mo-bonds gets converted to a single multi-bond.
Here, the multi-bond connector represents a vector of
length 15. Fig.18: Chemical reaction modeled by multi-chemo-
However for reasons that will become clear very bonds
soon, it was more convenient to rearrange the se-
quence of bonds within the multi-bond in such a way This time around, the transformation matrix of the
that the multi-bond contains first the five heat flows, multi-port transformer is of size 15x15. Yet, it can
followed by the five volumetric flows, followed by be composed easily from the previously introduced
the five molar mass flows. Thus, the multi-bond can N-matrix, assuming that we operate on multi-chemo-
be interpreted as a chemo-multi-bond connector. bonds rather than chemo-multi-bonds:

Fig.15: Conversion of connectors

In the same fashion, we can also stack the five ChR-


elements, as shown in Fig.16, with the corresponding The transformation matrix is a block-diagonal matrix
conversion of connectors shown in Fig.17. containing the same N-matrix three times along the
diagonal, once used to transform the heat flows, once
used to transform the volumetric flows, and once
used to transform the molar mass flows.
A comparison of the computational efficiencies
of the four models is given in Table 1.

Table 1: Comparison of computational efficiency

Fig.16: Resistive reaction field

© The Modelica Association, 2009 148


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

The first two models are indistinguishable concern- sired values inside the CF-elements. Since both the
ing their computational efficiencies. The third and temperature and the pressure were assumed constant,
fourth model are a bit less efficient computationally. also the chemical potentials, i, are constant, and
The reason is the following. In the first two models, consequently, also those values could be entered as
we recognized that we could add up the partial en- parameters.
tropy flows and the partial volume flows and inte- In the general case, T, p, and i will not be con-
grate them together, whereas in models three and stant, and they will have to be computed from state
four, each CF-element contains three separate states, information, as already demonstrated in the general
one describing the partial entropy, a second describ- CF-elements for air and water presented in [3].
ing the partial volume, and a third describing the par- Temperature and pressure equilibration between
tial mass of each of the five reactants. different reactants can be modeled using heat ex-
change (HE) elements and pressure/volume ex-
change (PVE) elements, placed between the different
6 Conclusions CF-elements, as demonstrated in [3].
In the special case of an isothermal operating
In this paper, we have shown how different types of condition, a controlled entropy flow out of the sto-
bond graphs can be used to describe chemical reac- rages (CF-elements) could then be added to the mod-
tion systems. el that equals the entropy flow generated by the reac-
Only a single reaction system was used for dem- tion system, such that the total entropy, and thereby
onstration, namely a hydrogen-bromine reaction si- also the temperature remain constant. Alternatively,
mulated under isothermal and isobaric operating an HE-element could be added between the reaction
conditions. system and the environment that guarantees that the
Although we have been able to demonstrate that temperature of the reaction system remains at the
the models become simpler as we treat chemical ambient temperature.
reactions as convective flows, there is a yet much In the special case of an isobaric operating condi-
more important reason for doing this, a reason that tion, either a controlled volume flow would need to
does not become obvious from reading this paper be imposed from the outside, or alternatively, a PVE-
alone. element could be added between the reaction system
Amrhein simulated the same reaction system un- and the environment that guarantees that the pressure
der a series of different operating conditions [1,2]. of the reaction system remains at the ambient pres-
He replaced the isothermal condition by an adiabatic sure.
condition, for example, and he replaced the isobaric Thus, general CF-elements can be used indepen-
condition by an isochoric condition. dently of the operating conditions, which then are
It becomes clear from reading his documents that imposed on the model by external control flows in
each of his models looks slightly different, i.e., the the same way as a chemical engineer would set up
bond graph had to be adjusted a bit from one set of his or her experiment in the lab.
operating conditions to another. Unfortunately, we did not have either the time or
The reason for this inconvenience is that Amrhein the space in this paper to demonstrate how such a
did not compute all quantities where they naturally setup would need to be modeled using the Chem-
belong. Consequently, his models violated some of BondLib and ThermoBondLib Modelica libraries,
the premises of object-oriented modeling. All of the and therefore, the proposed generalization will have
potential (effort) variables and all of the state va- to be postponed to another time and another publica-
riables should be computed at the side of the reac- tion.
tants, whereas all of the flow variables should be The research presented in this paper represents
evaluated at the side of the step reactions. only a very first step in an ongoing research effort.
Using the convective flow approach to modeling Reactions among ideal gases are particularly easy to
chemical reaction systems, it won’t be necessary any model and simulate, and isothermal and isobaric op-
longer to modify the bond graph from one set of op- erating conditions are among the most convenient
erating conditions to another, because all variables operating conditions that may be assumed.
are indeed being computed where they belong. Much more research is needed before we can
The implementation of the (red) CF-elements claim that we have created a universal approach to
used in the simulations of this paper are not yet fully modeling and simulating all kinds of chemical reac-
general. As we were only interested in isothermal tion systems in a truly object-oriented physically in-
and isobaric operating conditions, it sufficed to set spired manner.
the temperature, T, and the pressure, p, to their de-

© The Modelica Association, 2009 149


Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009

References Jürgen Greifeneder received a


diploma degree in Engineering Cy-
[1] Amrhein, M.: Bond Graph Modeling of bernetics from the University of
Chemical Reaction Dynamics. MS Thesis, Stuttgart, Germany in 2002. He
Department of Electrical and Computer En- then switched to the University of
gineering, University of Arizona, Tucson, Kaiserslautern, where he received a
AZ, 1990 Ph.D. in Electrical and Computer
Engineering in 2007 with a disser-
[2] Cellier, F.E.: Continuous System Modeling.
tation on the formal analysis of temporal behavior of
Springer-Verlag, New York, 1991
Networked Automation Systems (NAS) by use of
[3] Cellier, F.E. and Greifeneder, J.: Thermo- probabilistic model checking. Scientific stays at the
BondLib – A New Modelica Library for University of Arizona (USA), at the Ecole Normale
Modeling Convective Flows, In: Proc. 6th In- Supérieure de Cachan (F), and at the Universidade
ternational Modelica Conference, Bielefeld, de Brasília (BR) completed his education. Since
Germany (2008) Vol.1, 163-172 2008, Dr. Greifeneder is with the ABB Corporate
[4] Cellier, F.E. and Nebot, A.: The Modelica Research Center, Ladenburg, Germany, working in
Bond Graph Library, In: Proc. 4th Interna- the area of automation engineering with a focus on
tional Modelica Conference, Hamburg, Ger- simulation-based engineering. Dr. Greifeneder's
many (2005) Vol.1, 57-65 primary research interests concern modeling and si-
[5] Oster, G.F., Perelson, A.S., and Katzir- mulation methodologies.
Katchalsky A.: Network Thermodynamics:
Dynamic Modelling of Biophysical Systems,
In: Quarterly Reviews of Biophysics (1973)
Vol. 6(1), 1-134
[6] Zimmer, D. and Cellier, F.E.: The Modelica
Multi-bond Graph Library, In: Proc. 5th In-
ternational Modelica Conference, Vienna,
Austria (2006) Vol.2, 559-568

Author Biographies
François E. Cellier received his BS
degree in electrical engineering in
1972, his MS degree in automatic
control in 1973, and his PhD degree
in technical sciences in 1979, all
from the Swiss Federal Institute of
Technology (ETH) Zurich. Dr. Cellier worked at the
University of Arizona as professor of Electrical and
Computer Engineering from 1984 until 2005. He
then returned to his home country of Switzerland.
Dr. Cellier's main scientific interests concern model-
ing and simulation methodologies, and the design of
advanced software systems for simulation, computer
aided modeling, and computer-aided design. Dr. Cel-
lier has authored or co-authored more than 200 tech-
nical publications, and he has edited several books.
He published a textbook on Continuous System
Modeling in 1991 and a second textbook on Conti-
nuous System Simulation in 2006, both with Sprin-
ger-Verlag, New York.

© The Modelica Association, 2009 150

View publication stats

You might also like