Comparison of Simulation Tools for Dynamic Models
Total Page:16
File Type:pdf, Size:1020Kb
Comparison of Simulation Tools for Dynamic Models Sveinung M. Sund1, Marianne Plouvier2, and Bernt Lie1 1University of South-Eastern Norway, [email protected], 2IMT Mines Albi, France Abstract els to experimental data, to reuse such models for pro- cess design, stability analysis, control design, estimator Macroscopic models are used extensively in process en- design, etc. The various simulation tools have different gineering, and can often be posed as DAE (Differential support for and capabilities wrt. analysis and synthesis. Algebraic Equation) models. Three generic tools for solv- An important question is then: is it wise to aim at a one- ing such DAEs are compared: OpenModelica, Julia, and language/tool solution, or is it better to use different tools MATLAB. To make the comparison concrete, a simple for simulation and design/synthesis as long as the lan- non-linear process model from the literature was extended guages can interact? by removing simplifying assumptions; the more complex model was posed as DAEs. Some implementation details 1.2 Previous Work of DAE models in OpenModelica, Julia, and MATLAB Specialized process engineering tools are well developed, are given. Selected simulation results are given, with re- e.g., from AspenTech1, Process Systems Enterprise2, etc. sulting execution time. The three tools gave identical sim- More generic tools are also popular, such as Modelica ulation results. The tools are then compared wrt. cost, based tools (OpenModelica3, JModelica.org4, Dymola5, ease of use, documentation, numeric quality, Eco-system etc.), other high level tools (DAE Tools6, APMonitor7), , and possibility for reuse of models/library. Overall, Julia script based tools (MATLAB8, Python9, Julia10, etc.), and appears may appear as the best choice. However, Model- computer algebra systems (Mathematica11, Maple12, etc.). ica is found to be easier to use, so an ideal solution would The possibility to integrate OpenModelica with Python to probably be some tight integration of Modelica with Julia. enable more extended analysis was studied in (Lie et al., Keywords : process modeling, dynamics, DAEs, simula- 2016). tion tool. A simple model of a nonlinear, open loop unstable re- actor is given in (Seborg et al., 2011), and is used in var- 1 Introduction ious control studies (Henson and Seborg, 1997). In a stu- 1.1 Background dent project/exam paper at University College of South- east Norway13, this model has been extended into a DAE Macroscopic models are used extensively in process engi- model by removing some of the simplifying assumptions. neering, and can in general be posed as a set of differen- Both of these models are suitable for testing basic capabil- tial equations stemming from conservation/balance laws ities of simulation tools for handling small-scale models. with the addition of algebraic relations describing thermo- dynamics, transport laws, reaction engineering, etc. The 1.3 Organization of Paper result is a set of Differential Algebraic Equations (DAE) In this paper, we compare the suitability of selected tools with a relatively simple structure. Such DAE models can (OpenModelica, Julia, MATLAB) for solving macro- be transformed/reduced to Ordinary Differential Equa- scopic DAE models in process engineering. The paper tions (ODEs) with some effort. The resulting ODEs are often simpler than the DAEs, thus more efficient solvers 1www.aspentech.com may be available. At the same time, reducing DAEs to 2www.psenterprise.com/products/gproms ODEs also eliminates many variable which may be of in- 3https://openmodelica.org/ terest to study. 4www.jmodelica.org 5www.3ds.com/products-services/catia/ In education, as well as in engineering practice, it is im- products/dymola portant to choose simulation tools for doing experiments 6http://daetools.com on such models. Important aspects are, e.g.: cost, ease 7http://apmonitor.com of use, how well the tool is documented, numeric qual- 8https://mathworks.com ity, Eco-system (packages/functions for plotting, analysis, 9www.anaconda.com 10 random numbers, control packages, access to time series https://julialang.org 11www.wolfram.com database, etc.), possibility of reuse of the model (model 12www.maplesoft.com library, extract information for control design, etc.). 13Course FM1015 Modelling of Dynamic Systems, www.usn.no Dynamic models are used for design and operation of /academics/study-and-subjectplans/#/ systems, and it is therefore of interest to fit such mod- subjects/FM1015_2018H_1 https://doi.org/10.3384/ecp18153177 177 Proceedings of The 59th Conference on Simulation and Modelling (SIMS 59), 26-28 September 2018, Oslo Metropolitan University, Norway is organized as follows. In Section 2, an overview of a suitable DAE model structure is given, with details of the case study model. In Section 3, some general character- istics and specific implementation details of the models in the chosen languages are given. In Section 4, selected simulation results are given, together with some resulting execution times. In Section 5, the findings are discussed, Figure 1. Cooled liquid reactor with reaction aA ! B. before some conclusions are drawn in Section 6. An ap- pendix gives some model details. 2.2 Process Overview 2 Model Overview We consider a liquid reactor of constant volume V, with ˙ 2.1 Mechanistic Model Structure influent volumetric flow rate Vi, influent concentration cA;i of reactant A carried via an inert solvent S,14 and influent Mechanistic models at the macroscopic level can typically temperature Ti, Fig. 1. be described using balance laws of form It is of interest to convert species A into species B through an exothermic reaction dx = f (x;z;u;q) (1) dt aA ! B; (4) where differential variable x is the “balanced” property the products are carried out of the reactor via solvent S. To (amount, momentum, energy), while z is some auxil- keep control of reactor temperature T, heat rate Q˙ is added iary algebraic variable, u is some input variable and q by flowing a liquid at temperature Tc through the tube side is some model constant/parameter. Such models need to of a coil/heat exchanger. With a high flow rate of the cool- be complemented with transport/thermodynamic/reaction ing liquid, Tc is constant through the heat exchanger, and laws (constitutive laws) of form the heat rate can be described as 0 = g(x;z;u;q): (2) Q˙ = U A(Tc − T): (5) Together, Eqs. 1 and 2 form a set of differential-algebraic where U A is a parameter. If Tc < T, Q˙ < 0 and the reactor equations, DAE. The set of differential variables and alge- is cooled. braic variables is referred to as the model descriptor, (x;z). The rate of reaction r is given as Such DAE models are conceptually simple to formulate, but may contain relatively many descriptor variables and a r = kcA (6) many parameters q. DAE models can be manipulated into sets of ordinary where a is the reaction order and k is given by the Arrhe- differential equations, ODE, of form nius expression ( ) dx˜ ( ) E=R = f˜ x˜;u;q˜ (3) k = k exp − . (7) dt 0 T wherex ˜ is a state of the system. For DAE models of index The operation of the reactor is influenced by inputs V˙ , 1, dimx ≥ dimx ˜, while for DAE models of index larger i c ; , T and Tc, and it is of interest to study how these in- than 1, it is possible that dimx ≤ dimx ˜. Normally dimq ≥ A i i fluence the outputs cA, cB and T. ( ) dimq˜. Although the case study has inputs u = V˙i;cA;i;Ti;Tc Tools for analyzing ODE models (solvers, stability con- and outputs y = (cA;cB;T), in a control problem one may cepts, etc.) are better developed than tools for DAE mod- choose to control the temperature y = T by manipulat- els. ODE models are smaller and faster to solve, but man- (ing the input) u = Tc. In that case, the additional inputs ual model simplification may introduce (model) errors. V˙i;cA;i;Ti may be considered disturbances. DAE models, on the other hand, hold more information For practical purposes, the cooling liquid temperature (the algebraic variables), and are simpler to formulate, so ◦ 15 Tc 2 [4;90] C or so. In reality, Tc is not directly con- there are important advantages in keeping models in DAE trollable. Instead, an influent “cooling” temperature T form. c;i could be varied while temperature Tc in the heat exchanger It is of interest to compare how easy it is to formulate is varied via manipulating the cooling liquid flow rate. DAE models and solve them in popular modeling/simu- lation tools. For such a comparison, it is convenient to 14Inert implies non-reacting. introduce a case study. 15If vaporized, higher temperatures may be achieved. https://doi.org/10.3384/ecp18153177 178 Proceedings of The 59th Conference on Simulation and Modelling (SIMS 59), 26-28 September 2018, Oslo Metropolitan University, Norway ˙ • ≡ 2.3 Balance Equations VB;i 0 (no feed of species B). Equations 12, 13, and 17 For the given process, the following balance equations are are based on the assumption of ideal solution, and are not relevant, generally valid. Equations 14–16, on the other hand, are valid by definition. dmS In addition to the ideal solution assumption, we need = m˙ − m˙ (8) dt S;i S;e a model of liquid specific enthalpy. For an ideal (in- dn compressible) liquid with temperature independent spe- A = n˙ − n˙ + n˙ (9) dt A;i A;e A;g cific heat capacity: dnB • ◦ • ◦ = n˙ − n˙ ; + n˙ ; (10) ˆ ˆ − dt B;i B e B g HS = HS + cˆp;S (T T ) (18) ( ) dU ◦ ◦ = H˙i − H˙e + Q˙ (11) 16 Hˆ ;T dt and similar for species A and B. Here, S are specific enthalpy at standard state and a chosen reference 6 dx ◦ wherex ˙ indicates flow of variable x (in general,x ˙ = dt ), m temperature T .