1 | #*------------------------------------------------------------------- |
---|
2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
3 | * |
---|
4 | * This LIBRARY is free software; you can distribute it and/or modify |
---|
5 | * it under the therms of the ALSOC FREE LICENSE as available at |
---|
6 | * http://www.enq.ufrgs.br/alsoc. |
---|
7 | * |
---|
8 | * EMSO Copyright (C) 2004 - 2007 ALSOC, original code |
---|
9 | * from http://www.rps.eng.br Copyright (C) 2002-2004. |
---|
10 | * All rights reserved. |
---|
11 | * |
---|
12 | * EMSO is distributed under the therms of the ALSOC LICENSE as |
---|
13 | * available at http://www.enq.ufrgs.br/alsoc. |
---|
14 | * |
---|
15 | *-------------------------------------------------------------------- |
---|
16 | * Sample file for for a high-index optimal control problem. |
---|
17 | *-------------------------------------------------------------------- |
---|
18 | * Author: Rafael de Pelegrini Soares |
---|
19 | * $Id$ |
---|
20 | *--------------------------------------------------------------------*# |
---|
21 | using "types"; |
---|
22 | |
---|
23 | Model FlashRaoult |
---|
24 | ATTRIBUTES |
---|
25 | Info = " |
---|
26 | This is a very simple (wrong) model with dynamics only on the energy. |
---|
27 | |
---|
28 | It should be used for ilustration purposes only."; |
---|
29 | |
---|
30 | PARAMETERS |
---|
31 | NComp as Integer; |
---|
32 | |
---|
33 | # Antoine constants |
---|
34 | A(NComp) as Real; |
---|
35 | B(NComp) as Real; |
---|
36 | C(NComp) as Real; |
---|
37 | |
---|
38 | Cv as Real(Unit = 'J/mol/K'); |
---|
39 | DHvap(NComp) as energy_mol; |
---|
40 | |
---|
41 | VARIABLES |
---|
42 | F as flow_mol; |
---|
43 | L as flow_mol; |
---|
44 | V as flow_mol; |
---|
45 | z(NComp) as fraction; |
---|
46 | x(NComp) as fraction; |
---|
47 | y(NComp) as fraction; |
---|
48 | n(NComp) as mol; |
---|
49 | nt as mol; |
---|
50 | |
---|
51 | T as temperature; |
---|
52 | P as pressure; |
---|
53 | Psat(NComp) as pressure; |
---|
54 | |
---|
55 | Q as power; |
---|
56 | E as energy; |
---|
57 | |
---|
58 | EQUATIONS |
---|
59 | "Component Molar Balance" |
---|
60 | diff(n) = F*z - (L*x + V*y); |
---|
61 | |
---|
62 | nt = sum(n); |
---|
63 | x = n/nt; |
---|
64 | |
---|
65 | "Energy Balance" |
---|
66 | diff(E) = Q - V*sum(DHvap*y); |
---|
67 | |
---|
68 | "Internal energy" |
---|
69 | E = nt*Cv*T; |
---|
70 | |
---|
71 | "Raoult's Law" |
---|
72 | P*y = Psat*x; |
---|
73 | |
---|
74 | "Antoine for Vapour Pressure" |
---|
75 | ln(Psat/'kPa') = A - B/(T/'K'- 273.15 + C); |
---|
76 | |
---|
77 | "Molar Fraction sum" |
---|
78 | sum(y) = 1; |
---|
79 | end |
---|
80 | |
---|
81 | |
---|
82 | FlowSheet FlashRaoultTest |
---|
83 | DEVICES |
---|
84 | fl as FlashRaoult; |
---|
85 | |
---|
86 | SET |
---|
87 | fl.NComp = 3; |
---|
88 | # Antoine constants (Acetone, Acetonitrile, Nitromethane) |
---|
89 | fl.A = [14.31, 14.89, 14.75]; |
---|
90 | fl.B = [2756, 3413, 3331]; |
---|
91 | fl.C = [228, 250, 227]; |
---|
92 | |
---|
93 | fl.Cv = 30 * 'J/mol/K'; |
---|
94 | fl.DHvap = [10, 20, 30] * 'kJ/mol'; |
---|
95 | |
---|
96 | EQUATIONS |
---|
97 | # Disturb |
---|
98 | #if time < 0.5 * 'h' then |
---|
99 | # fl.z = [0.45, 0.35, 0.2]; |
---|
100 | #else |
---|
101 | # fl.z = [0.55, 0.25, 0.2]; |
---|
102 | #end |
---|
103 | |
---|
104 | SPECIFY |
---|
105 | # Feed condition |
---|
106 | fl.F = 1 * 'kmol/h'; |
---|
107 | # Steady-state feed |
---|
108 | #fl.z = [0.45, 0.35, 0.2]; |
---|
109 | # Disturb on feed composition |
---|
110 | fl.z = [0.55, 0.25, 0.2]; |
---|
111 | |
---|
112 | # Desired production of y1 (index 2 - will determine the "perfect" heat profile) |
---|
113 | fl.V = 0.1 * 'kmol/h'; |
---|
114 | fl.y(1) = 0.7; |
---|
115 | fl.nt = 1 * 'kmol'; |
---|
116 | |
---|
117 | # Default specification (index 1 - heat is given) |
---|
118 | #fl.V = 0.1 * 'kmol/h'; |
---|
119 | #fl.Q = 0.37 * 'kW'; |
---|
120 | #fl.nt = 1 * 'kmol'; |
---|
121 | |
---|
122 | # Fixed Temperature (index 2 - will determine the "perfect" heat profile) |
---|
123 | #fl.T = (90+273.15) * 'K'; |
---|
124 | #fl.V = 0.1 * 'kmol/h'; |
---|
125 | #fl.nt = 1 * 'kmol'; |
---|
126 | |
---|
127 | # Fixed Pressure (index 2 - will determine the "perfect" heat profile) |
---|
128 | #fl.P = 1.2 * 'atm'; |
---|
129 | #fl.V = 0.1 * 'kmol/h'; |
---|
130 | #fl.nt = 1 * 'kmol'; |
---|
131 | |
---|
132 | INITIAL |
---|
133 | #fl.T = (80+273.15) * 'K'; |
---|
134 | #fl.nt = 1 * 'kmol'; |
---|
135 | |
---|
136 | # Steady-state composition with feed = [0.45, 0.35, 0.2]; |
---|
137 | fl.x(1) = 0.4222; |
---|
138 | fl.x(2) = 0.3622; |
---|
139 | |
---|
140 | # steady state compositions |
---|
141 | # diff(fl.n(1:2)) = 0 * 'mol/s'; |
---|
142 | |
---|
143 | OPTIONS |
---|
144 | TimeEnd = 4; |
---|
145 | TimeStep = 0.05; |
---|
146 | TimeUnit = 'h'; |
---|
147 | |
---|
148 | #DAESolver(File="dasslc"); # slow integration |
---|
149 | DAESolver(File="mebdf"); # much faster |
---|
150 | |
---|
151 | Dynamic = true; |
---|
152 | end |
---|