1 EQE038 – Simulação e Otimização de Processos Químicos Argimiro R. Secchi – Aula 2 – Concepts of modeling and simulation. Object-oriented modeling in EMSO. EQ/UFRJ 30 de agosto de 2013
2 Applications of Process Modeling tools applications
3 Market: if the price of a product increases, what will be the reduction of demand and what should be the new scheduling of production? Production planning: having several sources of raw material and several manufacturing plants, how to distribute the raw material among these plants and what products each plant has to produce? Synthesis: what process should be used for manufacturing a given product? Design: what type and size of equipment are necessary to produce a given product? Operation: what operating condition will maximize the production of a product? Control: how a process input can be manipulated to keep a measured process output at its desired value? Safety: if an equipment failure occur, what will be the impact over the operators and other equipments? Environment: how long will take to biodegrade a contaminated soil by dangerous waste? Some questions that could be answered with these applications
4 Difficulties in Dynamic Simulation Reliable models High-Index DAE systems Large-Scale systems Model consistency: - Degree of Freedom (DoF) - Dynamic Degree of Freedom (DDoF) - Units of measurement - Structural non-singularity - Consistent initial condition
5 Modeling in Latin: modus = a measure, a small representation of a designed or existing object. from dictionary: a mathematical or physical system, obeying certain specified conditions, whose behavior is used for understanding a physical, biological or social system, with analogy in some aspects. Is only an approximate representation of a real system. Process model: a set a equations and specifications that allows to predict the behavior of a process. empirical relations first principles or mechanistic model Concepts of Modeling and Simulation
6 Model Building A mathematical model has: A set of model parameters (reaction order, valve constant, etc.) A set of variables (temperatures, pressures, flow rates, etc.) A set of equations (algebraic and differential) relating the variables Problems in model building: Number of equations and variables do not match (DoF 0) Equations of the model are inconsistent (linear dependence, UOM, etc.) The number of initial conditions and DDoF do not match
7 Modeling Tools The available tools for process modeling may be classified into: Block-Oriented focus on the flowsheet topology using standardized unit models and streams to link these unit models Equation-Oriented rely purely on mathematical rather than phenomena-based descriptions, making difficult to customize and reuse existing models Object-Oriented Models are recursively decomposed into a hierarchy of sub-models and inheritance concepts are used to refine previously defined models into new models (Bogusch and Marquardt, 1997)
8 Object-Oriented Modeling A process flowsheet model can be hierarchically decomposed: Plant Separation System Pretreat. System Reaction System Separation System Column 1 Column 2Column 3 Column Feed Tray Linked Trays Condenser Splitter Pump Rebolier Linked Trays Tray
9 Object-Oriented Modeling Tray mass balance energy balance thermodynamic equilibrium mol fraction normalization abstract model liquid flow model vapor flow model concrete model (ideal tray) efficiency model concrete model (real tray)
10 Object-Oriented Modeling Abstract models: are models that embody coherent and cohesive, but incomplete concepts, and in turn, make these characteristics available to their specializations via inheritance. While we would never create instances (devices) of abstract models, we most certainly would make their individual characteristics available to more specialized models via inheritance. Concrete models: are complete models, usually derived from abstract models, ready to be instantiated, i.e., we can create devices (e.g., equipments) of concrete models. Model types
11 Object-Oriented Modeling Inheritance: is the process whereby one object acquires (gets, receives) characteristics from one or more other objects. Aggregation: is the process of creating a new object from two or more other objects, or an object that is composed of two or more other objects. OOM main concepts Feed Tray Linked Trays Condenser Splitter Pump Rebolier Column model = Condenser + Splitter + Pump + Linked Trays + Feed Tray + Reboiler
12 Object-Oriented Modeling ABACUSS II (Barton, 1999) ASCEND (Piela, 1989) Dymola (Elmqvist, 1978) EcosimPro (EA Int. & ESA, 1999) EMSO (Soares and Secchi, 2003) gPROMS/Speedup (Barton and Pantelides, 1994) Modelica (Modelica Association, 1996) ModKit (Bogusch et al., 2001) MPROSIM (Rao et al., 2004) Omola (Andersson, 1994) ProMoT (Tränkle et al., 1997) Examples of general-purpose object-oriented modeling languages:
13 Streams Inlet Material stream feeding the tank Outlet Material stream leaving the tank Parameters k Valve constant D Hydraulic diameter of the tank Variables A Tank cross section area VTank volume h Tank level Devices: source, tank, sink Available model of the tank >>>Model with circular cross section >>>Model with square cross section Object-Oriented Modeling A simpler example Level Tank source sink
14 Object-Oriented Modeling Model equations F in F out mass balance: valve equation: liquid volume: Inheritance
15 Object-Oriented Modeling using "types"; Model Tank_Basic PARAMETERS k as Real (Brief=“Valve constant", Unit=’m^2.5/h’, Default = 12); D as length (Brief=“Tank hydraulic diameter", Default = 4); VARIABLES in Fin as flow_vol (Brief=“Feed flow rate"); out Fout as flow_vol (Brief =“Output flow rate"); A as area (Brief=“Cross section area"); V as volume (Brief=“Liquid volume"); h as length (Brief=“Tank level"); EQUATIONS “Mass balance“ Fin - Fout = diff(V); “Valve equation“ Fout = k * sqrt(h); “Liquid volume“ V = A * h; end EMSO: F in F out Abstract model mass balance: valve equation: liquid volume:
16 Object-Oriented Modeling Model Tank_Square as Tank_Basic EQUATIONS “Cross section area“ A = D^2; end EMSO Concrete models Model Tank_Circular as Tank_Basic PARAMETERS Pi as Real (Default = ); EQUATIONS “Cross section area" A = (Pi * D^2) / 4; end Inheritance F in F out
17 Object-Oriented Modeling using "tank_oom"; FlowSheet Tanks DEVICES source as Feed; T_c as Tank_Circular; T_sq as Tank_Square; sink as Sink; CONNECTIONS source.F to T_c.Fin; T_c.Fout to T_sq.Fin; T_sq.Fout to sink.F; SET T_c.D = 3 * ’m’; T_sq.D = 3 * ’m’; SPECIFY source.F = 20 * ’m^3/h’; INITIAL T_c.h = 1 * ’m’; T_sq.h = 2 * ’m’; OPTIONS TimeStart = 0; TimeEnd = 20; TimeStep = 0.5; TimeUnit = ’h’; end F out F in F out source sink Flowsheet EMSO:
18 Object-Oriented Modeling Model switching Model Tank_Section as Tank_Basic PARAMETERS Pi as Real (Default = ); Section as Switcher (Valid = ["Circular", "Square"], Default = "Circular"); EQUATIONS switch Section case "Circular": “Cross section area" A = (Pi * D^2)/4; case "Square": “Cross section area" A = D^2; end using "tank_oom"; FlowSheet Tanks2 DEVICES source as Feed; T_c as Tank_Section; T_sq as Tank_Section; sink as Sink; CONNECTIONS source.F to T_c.Fin; T_c.Fout to T_sq.Fin; T_sq.Fout to sink.F; SET T_c.D = 3 * ’m’; T_sq.D = 3 * ’m’; T_c.Section = ”Circular”; T_sq.Section = ”Square”; SPECIFY source.F = 20 * ’m^3/h’; INITIAL T_c.h = 1 * ’m’; T_sq.h = 2 * ’m’; OPTIONS TimeStart = 0; TimeEnd = 20; TimeStep = 0.5; TimeUnit = ’h’; end
19 Object-Oriented Modeling Aggregation Level Tank source sink P0P0 P0P0 P Tank model mass balance: liquid volume: outlet pressure: valve equation: Valve model mass balance: pressure drop:
20 Object-Oriented Modeling using "types"; Model Tank_Basic PARAMETERS D as length (Brief=“Tank hydraulic diameter", Default = 4); rg as Real (Brief=“rho * g", Unit =’kg/(m*s)^2’, Default = 1e4); VARIABLES in Sin as stream (Brief=“Inlet stream"); out Sout as stream (Brief =“Outlet stream"); A as area (Brief=“Cross section area"); V as volume (Brief=“Liquid volume"); h as length (Brief=“Tank level"); valve as Valve (Brief=“Valve model"); CONNECTIONS Sout to valve.Sin; EQUATIONS “Mass balance“ Sin.F – Sout.F = diff(V); “Liquid volume“ V = A * h; “Outlet pressure“ Sout.P = Sin.P + rg * h; end Tank model with valve Valve model using "types"; Model Valve PARAMETERS k as Real (Brief=“Valve constant", Unit=’m^2.5/h’, Default = 12); rg as Real (Brief=“rho * g", Unit =’kg/(m*s)^2’, Default = 1e4); VARIABLES in Sin as stream (Brief=“Inlet stream"); out Sout as stream (Brief =“Outlet stream"); DP as press_delta (Brief=“Pressure drop"); EQUATIONS “Mass balance“ Sin.F = Sout.F; “Valve equation“ Sout.F = k * sqrt(DP/rg); “Pressure drop“ DP = Sin.P – Sout.P; end
21 Object-Oriented Modeling using "tank_valve_oom"; FlowSheet Tanks DEVICES source as Feed; T_c as Tank_Circular; T_sq as Tank_Square; sink as Sink; CONNECTIONS source.Sout to T_c.Sin; T_c.valve.Sout to T_sq.Sin; T_sq.valve.Sout to sink.Sin; SET T_c.D = 3 * ’m’; T_sq.D = 3 * ’m’; SPECIFY source.Sout.F = 20 * ’m^3/h’; source.Sout.P = 1 * ’atm’; T_c.valve.Sout.P = 1 * ’atm’; sink.Sin.P = 1 * ’atm’; INITIAL T_c.h = 1 * ’m’; T_sq.h = 2 * ’m’; OPTIONS TimeStart = 0; TimeEnd = 20; TimeStep = 0.5; TimeUnit = ’h’; end Flowsheet
22 Modeling workshop Model equations mass balance: valve equation: F in F out h A = h (D h) liquid volume: F in F out
23 Flowsheet Modeling workshop FinFin F out source F out h sink = 20 m 3 /h D = 3 m h(0) = 1 m D = 3 m h(0) = 2 m D = 3 m h(0) = 2.5 m
24 Elementos Básicos na Modelagem 1.Descrição do processo e definição do problema 2.Teoria e aplicação das leis fundamentais 3.Hipóteses e considerações simplificadoras 4.Equacionamento 5.Análise de Consistência 6.Solução desejada 7.Matemática e computação 8.Solução e validação Definir o Modelo Construir o Modelo Validar o Modelo
25 1. Process Description and Problem Definition Process Description – Process objectives – Process flowsheet – Process operation unit operations and control Problem Definition – Simulation objectives – Simulation applications Modeling
26 Process Description Example: level tank A liquid flows in and out of a tank due to gravitational forces. We wish to analyze the volume, height and flowrate variations in the tank (system response) as function of feed disturbances. Modeling
27 2. Fundamental Laws: Theory and Applications - mass conservation - momentum conservation - energy conservation Bases to be used in the modeling Modeling
28 Modeling Levels
29 Modelo Microscópico Modelo de Gradientes Múltiplos Modelo de Máximo Gradiente Modelo de Macroscópico Modeling Levels
30 3. Simplifying Assumptions - constant specific mass - isothermal - perfect mixture - Establish the assumptions and simplifications Define the model limitations Modeling
31 4. Mathematical Model Data mining for simulation – Collect data and information of the studied system – Identify the engineering unit of measurements – Specify operating procedures – Specify the operating regions of the variables Memory of Calculation – Mathematical model – Define unit of measurements of variables and parameters – Define and specify free variables – Define and determine values of parameters – Define and establish initial conditions Modeling
32 Mathematical Model First Principles Models Conservation laws Empirical Models Neural Nets Fuzzy Logic Parametric Hybrid Models
33 Build process equipment models – Identify and create abstract and concrete models – Declare variables and parameters – Write model equations – Compose the equipment model via inheritance and aggregation Build process flowsheet – Declare flowsheet devices – Define process connections – Set process parameters values – Specify process free variables – Establish initial conditions – Establish simulation options Mathematical Model In the simulator Modeling
34 F in F out mass balance: valve equation: liquid volume: Mathematical Model (1) (2) (3) (4)
35 5. Consistency Analysis Model consistency analysis for unit of measurements (UOM) Degree of freedom analysis Dynamic degree of freedom analysis variableUOM F in, F out m 3 h -1 Vm 3 Am 2 h, Dm km 2.5 h -1 th equations (1): [m 3 h -1 ] – [m 3 h -1 ] = [m 3 ] / [h] (2): [m 3 h -1 ] = [m 2.5 h -1 ] ([h]) 0.5 (3): [m 3 ] = [m 2 ] [m] (4): [m 2 ] = ([m]) 2 Modeling
36 variables: F in, F out, V, A, h, D, k, t 8 constants: k, D 2 specifications: t 1 driving forces: F in 1 unknown variables: V, h, A, F out 4 equations: 4 Degree of Freedom = variables – constants – specification – driving forces – equations = unknown variables – equations = 8 – 2 – 1 – 1 – 4 = 0 Dynamic Degree of freedom (index < 2) = differential equations = 1 Needs 1 initial condition: h(0) 1 Consistency Analysis Modeling
37 For the given example and initial condition (h 0 or V 0 ), we wish to analyze h(F in ), V(F in ) and F out (F in ). 6. Desired Solution Plan case studies Define: – Objectives of the study – Problems to be solved – Evaluation criteria Modeling
38 7. Computation Define the desired accuracy Specify the simulation time and reporting interval Verify the necessity of specialized solvers (high-index problems) Modeling
39 Analyze simulation results Analyze state variables dynamics Test model fitting with plant data – Compare simulation x plant 8. Solution and Validation Modeling
40 Check output sensitivity to input disturbances Carry out parametric sensitivity analysis Analyze output data with statistical techniques Verify results coherence Document obtained results Solution and Validation Modeling
41 Start with a simple model and gradually increase complexity when necessary; The model should have sufficient details to capture the essence of the studied system; It is not necessary to reproduce each element of the system; Models with excessive details are expensive, difficult to implement and to solve; Interact with people that operate the equipment; Deeply understand the process behavior. Remarks Modeling
42 – A simple in EMSO – Starting EMSO
43
44 Model
45 Equations The order the equations appear in the model do not matter Equivalent Equations Can be written in any user desired form Model Language – Equation-based system Model Language – Equation-based system
46 The modeling and simulation of complex systems is facilitated by the use of the Object-Oriented concept The system can be decomposed in several components, each one described separately using its constitutive equations The components of the system exchange information through the connecting ports System Equipment Component Model Language – Object-Oriented Modeling Model Language – Object-Oriented Modeling
47 Model Components Including sub- models and types Automatic model documentation Symbol of variable in LaTeX command for documentation Basic sections to create a math. model Port location to draw a flowsheet connection Input and output connections
48 Real, Integer, Switcher, Plugin Parameters and variables are declared within their valid domains and units using types created based on the built-in types: Real, Integer, Switcher, Plugin Basic Variable Types in a Model
49 Building a Model: A simple example – level tank Streams Inlet Material stream feeding the tank Outlet Material stream leaving the tank Parameters k Valve constant D Hydraulic diameter of the tank Variables A Tank cross section area VTank volume h Tank level Devices: source, tank, sink Available model of the tank >>>Model with circular cross section >>>Model with square cross section
50 Material Stream Modeling The material stream carries the information entering and leaving the equipment VARIABLES Fvolumetric flowrate Ttemperature Ppressure Source Source - component that has a feed material stream. output connection It has an output connection Sink Sink - component that receives an output material stream. input connection It has an input connection Source Sink
51 Inlet Feed material stream to the tank Fin inlet volumetric flowrate Tin inlet temperature Pin inlet pressure Outlet Output material stream from the tank Fout outlet volumetric flowrate Tout outlet temperature Pout outlet pressure Level Tank Modeling
52 F in F out Level Tank: Inheritance Basic tank Circular tankSquare tank
53 Menu New Model File Name Destination Creating a MSO file for Model
54 using including references to other files. Model a new model is declared with the keyword Model and its name. a model contains a few basic sections: PARAMETERS section which defines the parameters of the model. VARIABLES section which defines the variables of the model. EQUATIONS section which describes the model equations. Creating a Model using the template
55 Including pre- defined types of EMSO Model Documentation selecting the desired unit of measure Symbol of variable are LaTeX commands Using the types defined in the file “types.mso” Creating a Material Stream Model
56 Using the same file Output Connection Creating a Source Stream Model Model Documentation
57 Creating a Sink Stream Model Using the same file Input Connection Model Documentation
58 Reference Model Ports Creating new UOM EMSO Built-In Function EMSOquickRef.pdf Creating a Basic Tank Model
59 Inheritance Model inherits all the attributes of the class from which it derives SET Defining values for parameters Equation Writing the particular equations model Creating the Circular Tank Model Using the same file
60 Creating the Square Tank Model Using the same file Inheritance Model inherits all the attributes of the class from which it derives Equation Writing the particular equations model
61 FlowSheet
62 EMSO FlowSheets In EMSO the user can manipulate various FlowSheets at same time DEVICES The equipment are called DEVICES FlowSheet A FlowSheet consists of a series of unit operations or equipment connected to each other Process Diagram – FlowSheet
63 streamPH The system modeling is made by the use, configuration and connection of pre-existing components FlowSheet Language – Component-based system FlowSheet Language – Component-based system
64 FlowSheet Components Degree of Freedom Dynamic Degree of Freedom Simulation options Parameters of DEVICES
65 Creating a MSO file for FlowSheet Menu New FlowSheet File Name Destination
66 using including references to other files. FlowSheet A process diagram is declared with the keyword FlowSheet and its name. A FlowSheet contains some basic sections: PARAMETERS DEVICES CONNECTIONS SET SPECIFY INITIAL OPTIONS... Creating a FlowSheet using the template
67 Degree of Freedom Dynamic Degree of Freedom Simulation options Parameters of DEVICES FlowSheet for the Level Tank
68 EMSO analyzes the consistency of the system created in the FlowSheet Consistency Analysis of the Process
69 Simulation details Simulation of the Level Tank Process
70 Horizontal axis is always the independent variable (usually time) double-click Level Tank Results
71 Building a system consisting of three tanks connected in series Series of Level Tanks
72 Degrees of freedom increases Series of Level Tanks - FlowSheet
73 Series of Level Tanks - Results
74 Building a more interesting Model: CSTR with Van der Vusse reaction Streams Inlet Feed material stream with molar concentration Outlet Output material stream with molar concentration Parameters Cv Valve constant k1 Constant of reaction rate 1 k2 Constant of reaction rate 2 k3 Constant of reaction rate 3 ACross-section area Variables V Reactor volume r1, r2, r3 Reaction rates Ca, Cb, Cc, Cd Molar concentrations h Reactor level tau Residence time
75 Van der Vusse Reactor – Modeling Component mass balances Reaction rates Residence time Perfect mixing
76 Adding molar concentration in the material stream Van der Vusse Reactor – Stream Model
77 Van der Vusse Reactor – Attributes
78 Van der Vusse Reactor Model
79 Van der Vusse Reactor – Model Equations
80 Van der Vusse Reactor – FlowSheet
81 Van der Vusse Reactor – Results
82 Exercises 1) Simulate the CSTR example for different values of the valve constant to find the one that maximizes the concentration of component B at the outlet of the reactor at steady state. Comment the results; 2) Modify the reactor model by adding an opening fraction on the outlet valve: and make this fraction vary sinusoidally x = (1 + sin ( t )) / 2, where t is given in hours. Use a Cv value of 20 m 2,5 /h. Comment the results for a 20 h simulation; 3) Build a block diagram to simulate the CSTR process.
83 References Himmelblau, D. M. & Bischoff, K. B., "Process Analysis and Simulation - Deterministic Systems", John Wiley & Sons, Felder, R. M. & Rousseau, R. W., "Elementary Principles of Chemical Processes", John Wiley & Sons, Denn, M., "Process Modeling", Longman, New York, Luyben, W. L., "Process Modeling, Simulation, and Control for Chemical Engineers", McGraw-Hill, Silebi, C.A. & Schiesser, W.E., “Dynamic Modeling of Transport Process Systems”, Academic Press, Inc., Ogunnaike, B.A. & Ray, W.H., “Process Dynamics, Modeling, and Control”, Oxford Univ. Press, New York, Rice, R.G. & Do, D.D., “Applied Mathematics and Modeling for Chemical Engineers”, John Wiley & Sons, Bequette, B.W., “Process Dynamics: Modeling, Analysis, and Simulation”, Prentice Hall, Engell, S. E Klatt, K.-U. Nonlinear Control of a Non-Minimum-Phase CSTR, Proc. of American Control Conference, Los Angeles, 2041 – 2045 (1993). Rodrigues, R., R.P. Soares and A.R Secchi. Teaching Chemical Reaction Engineering Using EMSO Simulator. Computer Applications in Engineering Education, Wiley (2008). Soares, R.P. and A.R. Secchi. EMSO: A New Environment for Modeling, Simulation and Optimization. ESCAPE 13, Lappeenranta, Finlândia, 947 – 952 (2003).
84 For helping in the preparation of this material Special thanks to For supporting the ALSOC Project. Prof. Rafael de Pelegrini Soares, D.Sc. Eng. Gerson Balbueno Bicca, M.Sc. Eng. Euclides Almeida Neto, D.Sc. Eng. Eduardo Moreira de Lemos, D.Sc. Eng. Marco Antônio Müller
85... thank you for your attention! Process Modeling, Simulation and Control Lab Prof. Argimiro Resende Secchi, D.Sc.Prof. Argimiro Resende Secchi, D.Sc. Phone: Phone: EP 2013 Solutions for Process Control and Optimization Solutions for Process Control and Optimization