In this month’s blog I will attempt to present a “roadmap” for constructing structurally consistent and solvable dynamic process models. I tried to keep it short and simple, but I soon realised that this was nearly impossible, since leaving out certain details would make it difficult for a reader to grasp the complete picture.
So, this blog is a bit longer than usual. But if you take the time to consume it, you will certainly get more insight in how to properly set up a correct, structurally solvable dynamic process model (using any equation based solver).
A more thorough discussion on this subject is given in the document “Concepts and Modelling Methodology”. Just click on the link to download a copy.
In order to characterize the behaviour of a process, information is needed about the natural state of this process (at a given time) and about the change of this state with time. The natural state of a process can be described by the values of a set of fundamental extensive quantities, while the change of state is given by the balance equations of those fundamental variables.
The fundamental extensive variables represent the ”extent” of the process c.q. the quantities being conserved in the process. In other words: they represent quantities for which the conservation principle and consequently also the superposition principle applies. So, for these variables, the balance equations are valid. In most chemical processes, the fundamental variables are: component mass, total energy and (sometimes) momentum.
The dynamic behaviour of a system can be modelled by applying the conservation principles to the fundamental extensive quantities of the system. The principle of conservation of any extensive quantity (x) of a system states that what gets transferred into the system must either leave again or is transformed into another extensive quantity or must accumulate in the system (In other words: no extensive quantity is lost).
In my PhD thesis I showed that the dynamic part (i.e. the differential equations) of physical-chemical-biological processes can be represented in a concise, abstract canonical form, which can be isolated from the static part (i.e. the algebraic equations). This canonical form, which is the smallest representation possible, incorporates very visibly the structure of the process model as it was defined by the person who modelled the process: The system decomposition (physical topology) and the species distribution (species topology) are very visible in the model definition. The transport (z) and production (r) rates always appear linearly in the balance equations, when presented in this form:
dx/dt = A z + B r
x :: Fundamental state vector (Primary State vector)
z :: Flow of extensive quantities (Transport rates)
r :: Kinetics of extensive quantity conversion (Reaction rates)
A:: Interconnection matrix
B:: Stoichiometric coefficient matrix
The classification of variables that is presented here is, in the first place, based on the structural elements of the modelling approach (namely systems and connections).
The matrices A and B are completely defined by the model designer’s definition of the physical and species topology of the process under investigation. Therefore these matrices are trivial to setup (and are actually automatically constructed by Mobatec Modeller). The only things a model designer has to do to complete the model are:
- Provide a link between the transport and reaction rate vectors and the primary state vector. Each element in the transport and reaction rate vectors has to be (directly or indirectly) linked to the primary state vector. This “linking” is done with one or more algebraic equations. If certain elements of the rate vectors are not defined in the algebraic equations, the mathematical system will have too many unknowns and can consequently not be solved.
- Give a mapping which maps the primary state of each system in a secondary state. This mapping is necessary because usually transport and reaction rates are defined as functions of secondary state variables (a heat flow can, for example, be expressed as a function of temperature difference).
So, in addition to the balance equations, we need other relationships to express thermodynamic equilibria, reaction rates, transport rates for heat, mass, momentum, and so on. Such additional relationships are needed to complete the mathematical modelling of the process. A model designer should be allowed to choose a particular relationship from a set of alternatives and to connect the selected relationship to a balance equation or to another defined relationship. The algebraic equations are divided into three main classes, namely system equations, connection equations and reaction equations.
For each system that is defined within the physical topology of a process, a mapping is needed which maps the primary state variables (x) into a set of “secondary state” variables (y = f(x)). The primary states of a system are fundamental quantities for describing the behaviour of the system. The fundamental state is defined intrinsically through the fundamental behaviour equations. The application of fundamental equations of component mass and energy balances intrinsically defines component mass and energy as the fundamental state variables. Alternative state variables are required for the determination of the transfer rate of extensive quantities and their production/consumption rate.
The equations that define secondary state variables do not have to be written in explicit form, by the way, but it has to be possible to solve the equations (either algebraically or numerically) such that the primary state can be mapped into the secondary state. This means that each defined equation has to define a new variable. Equations that link previously defined variables together are not allowed, since the number of equation would then exceed the number of variables and the set of equations of this system would thus be over-determined.
The flow rates (z), which emerge in the balance equations of a system, represent the transfer of extensive quantities to and from adjacent systems. These flow rates can be specified or linked to transfer laws, which are usually empirical or semi-empirical relationships. These relationships are usually functions of the states, and the physical and geometrical properties of the two connected systems. For example, the rate of conductive heat transfer Q through a surface A between two objects with different temperatures can be given by:
Q = U * A * (Tor – Ttar)
This relationship depends on the temperatures Tor and Ttar of the origin and target object respectively. Temperature is of course a (secondary) state variable. The rate of heat transfer also depends on the overall heat transfer coefficient U, which is a physical property of the common boundary segment between the two systems, and on the total area of heat transfer A, which is a geometrical property.
A transfer law thus describes the transfer of an extensive quantity between two adjacent systems (z = f(yor, ytar)). The transfer rate usually depends on the state of the two connected systems and the properties of the boundary in between.
Depending on the time scale of interest, we can divide reactions into three groups:
- Very slow reactions (slow in the measure of the considered range of time scales). These reactions do not appreciably occur and may be simply ignored.
- Reactions that occur in the time-scale of interest. For these reactions kinetic rate laws can be used.
- Very fast reactions (relative to the considered time scale), for which is assumed that the equilibrium is reached instantaneously.
As the non-reactive parts do not further contribute to the discussion, they are left out in the sequel. The fast (equilibrium) reactions go beyond the scope of this blog and are therefore also not discussed.
For the “normal” reactions the reaction rates of the reactions in the relevant times scale must be defined by kinetic rate equations. The production terms are linked to kinetic laws, which are empirical equations. They are usually written as a function of a set of intensive quantities, such as concentrations, temperature and pressure (r = f(ysys)). For example, the reaction rate r of a first-order reaction taking place in a lump is given by:
r = V * k0 * EXP(-E/(R * T)) * cA
r :: Reaction rate of a first-order reaction
V :: Volume of the system
k0 :: Pre-exponential kinetic constant
E :: Activation energy for the reaction
R :: Ideal gas constant
T :: Temperature of the reacting system
cA :: Concentration of component A in the system
Temperature and concentration(s) of the reactive component(s) are state variables (y) of the reactive system. Reaction constants and their associated parameter such as activation energy and pre-exponential factors are physical properties. In some cases, also geometrical properties of the system are part of the definition of the kinetic law, such as the porosity or other surface characterizing quantities.
When a dynamic process model is formulated and proper initial conditions have been defined, then the information flow of a simulation can be depicted as in the above figure. Starting from the initial conditions x0, the secondary state variables y of all the systems can be calculated (via the System Equations y=f(x)). Subsequently, the flow rates z of all the defined connections and the reaction rates r of all the defined reactions can be calculated (z = f(yor, ytar); r = f(ysys)). These rates are the inputs of the balance equations, so now the integrator can compute values for the primary state variables x on the next time step. With these variables, the secondary state y can be calculated again and the loop continues until the defined end time is reached.
To put it in other words: A model designer should only be concerned with the algebraic equations (the right hand side of the figure), which means that the primary state variables x of each system can be considered as “known”. Systems are only interacting with each other through connections and therefore the calculation of the secondary variables of each system can be done completely independent of other systems.
The system equations map the primary state x into a secondary state y for each individual system, and each defined equation has to define a (secondary) variable. In some cases two or more equations may introduce two or more new variables, such that these equations have to be solved simultaneously in order to get a value for the variables.
For connection and reaction equations a similar conclusion can be drawn. For these equations the secondary variables of the systems (y) can be considered as “known”.
Looking at modelling like this, makes it a lot easier than trying to understand/debug the complete model of a process. Just divide your model into systems and connections, assign equations to those objects (typically not more than 10) and solve any problem that arises per object. Resolving a problem (or even several) of about 10 equations is a lot easier than when hundreds or more are considered at the same time!
Do you have experience with making (large) dynamic process models?
I invite to post your experiences, insights and/or suggestions in the comment box below, such that we can all learn something from it.
To your success!