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 showing how to model a ammonia process |
---|
17 | *-------------------------------------------------------------------- |
---|
18 | * |
---|
19 | * This sample file needs VRTherm (www.vrtech.com.br) to run. |
---|
20 | * |
---|
21 | *---------------------------------------------------------------------- |
---|
22 | * Author: Rafael P. Soares |
---|
23 | * based on code from VRThech Tecnologias Industriais Ltda. |
---|
24 | * $Id: ammonia.mso 85 2006-12-08 20:43:24Z paula $ |
---|
25 | *--------------------------------------------------------------------*# |
---|
26 | |
---|
27 | using "stage_separators/flash"; |
---|
28 | using "mixers_splitters/splitter"; |
---|
29 | |
---|
30 | # A simple ideal compressor |
---|
31 | Model Compressor |
---|
32 | PARAMETERS |
---|
33 | ext PP as CalcObject; |
---|
34 | ext NComp as Integer; |
---|
35 | |
---|
36 | VARIABLES |
---|
37 | in Inlet as stream; |
---|
38 | out Outlet as stream_therm; |
---|
39 | |
---|
40 | EQUATIONS |
---|
41 | "Isentropic expansion" |
---|
42 | PP.VapourEntropy(Outlet.T, Outlet.P, Outlet.z) = |
---|
43 | PP.VapourEntropy(Inlet.T, Inlet.P, Inlet.z); |
---|
44 | |
---|
45 | "Global Molar Balance" |
---|
46 | Inlet.F = Outlet.F; |
---|
47 | "Component Molar Balance" |
---|
48 | Inlet.z = Outlet.z; |
---|
49 | |
---|
50 | "vaporization fraction " |
---|
51 | Outlet.v = 1.0; |
---|
52 | end |
---|
53 | |
---|
54 | # A simple 2 Inlet mixer. |
---|
55 | Model Mixer |
---|
56 | PARAMETERS |
---|
57 | ext PP as CalcObject; |
---|
58 | ext NComp as Integer; |
---|
59 | |
---|
60 | VARIABLES |
---|
61 | in Inlet1 as stream; |
---|
62 | in Inlet2 as stream; |
---|
63 | out Outlet as stream_therm; |
---|
64 | |
---|
65 | EQUATIONS |
---|
66 | "Energy Balance" |
---|
67 | Outlet.F * Outlet.h = Inlet1.F * Inlet1.h + Inlet2.F * Inlet2.h; |
---|
68 | |
---|
69 | Inlet1.P = Outlet.P; |
---|
70 | |
---|
71 | "Global Molar Balance" |
---|
72 | Inlet1.F + Inlet2.F = Outlet.F; |
---|
73 | "Component Molar Balance" |
---|
74 | Inlet1.z*Inlet1.F + Inlet2.z*Inlet2.F = Outlet.F * Outlet.z; |
---|
75 | "vaporization fraction" |
---|
76 | Outlet.v = Inlet1.v; |
---|
77 | end |
---|
78 | |
---|
79 | # A simple 'conversion' based reactor. |
---|
80 | Model Reactor |
---|
81 | PARAMETERS |
---|
82 | ext PP as CalcObject; |
---|
83 | ext NComp as Integer; |
---|
84 | NReac as Integer(Default=1); |
---|
85 | stoic(NComp, NReac) as Real (Brief = "Stoichiometric Matrix"); |
---|
86 | comp(NReac) as Integer(Default=1, Brief = "Key Component of the reaction"); |
---|
87 | |
---|
88 | VARIABLES |
---|
89 | in Inlet as stream; |
---|
90 | out Outlet as stream_therm; |
---|
91 | Outletz(NComp) as fraction; |
---|
92 | X(NReac) as fraction(Brief="Convertion of the key component"); |
---|
93 | |
---|
94 | EQUATIONS |
---|
95 | "Energy Balance" |
---|
96 | Outlet.F * Outlet.h = Inlet.F * Inlet.h; |
---|
97 | |
---|
98 | "Global Molar Balance" |
---|
99 | Outlet.F = Inlet.F * (1 - sum(Outletz)); |
---|
100 | |
---|
101 | for i in [1:NComp] |
---|
102 | "Component Molar Balance" |
---|
103 | Outletz(i) = Inlet.z(i) + sum(stoic(i,:)*X*Inlet.z(comp)); |
---|
104 | end |
---|
105 | |
---|
106 | "Normalize the outlet composition" |
---|
107 | Outlet.z * sum(Outletz) = Outletz; |
---|
108 | |
---|
109 | Outlet.P = Inlet.P; |
---|
110 | |
---|
111 | "vaporization fraction" |
---|
112 | Outlet.v = Inlet.v; |
---|
113 | end |
---|
114 | |
---|
115 | # Ammonia Process |
---|
116 | FlowSheet Ammonia |
---|
117 | PARAMETERS |
---|
118 | PP as CalcObject(Brief="Physical Properties", File="vrpp"); |
---|
119 | NComp as Integer; |
---|
120 | SET |
---|
121 | PP.Components = ["hydrogen", "nitrogen", "argon", "methane", "ammonia"]; |
---|
122 | PP.LiquidModel = "APR"; |
---|
123 | PP.VapourModel = "APR"; |
---|
124 | NComp = PP.NumberOfComponents; |
---|
125 | |
---|
126 | DEVICES |
---|
127 | FEED as streamTP; |
---|
128 | C101 as Compressor; |
---|
129 | R101 as Reactor; |
---|
130 | F101 as flash_Steady; |
---|
131 | F102 as flash_Steady; |
---|
132 | S101 as splitter; |
---|
133 | M101 as Mixer; |
---|
134 | M102 as Mixer; |
---|
135 | C102 as Compressor; |
---|
136 | |
---|
137 | VARIABLES |
---|
138 | purity as fraction(Brief="Purity of the product"); |
---|
139 | production as flow_mol(Unit = "lbmol/h", Brief="Ammonia in the product"); |
---|
140 | loose as flow_mol(Unit = "lbmol/h", Brief="Ammonia in the purge"); |
---|
141 | Q1 as heat_rate; |
---|
142 | Q2 as heat_rate; |
---|
143 | |
---|
144 | CONNECTIONS |
---|
145 | FEED to M101.Inlet1; |
---|
146 | M101.Outlet to C101.Inlet; |
---|
147 | C101.Outlet to M102.Inlet1; |
---|
148 | M102.Outlet to R101.Inlet; |
---|
149 | R101.Outlet to F101.Inlet; |
---|
150 | F101.OutletL to F102.Inlet; |
---|
151 | F102.OutletV to M101.Inlet2; |
---|
152 | F101.OutletV to S101.Inlet; |
---|
153 | S101.Outlet1 to C102.Inlet; |
---|
154 | C102.Outlet to M102.Inlet2; |
---|
155 | |
---|
156 | Q1 to F101.Q; |
---|
157 | Q2 to F102.Q; |
---|
158 | |
---|
159 | SET |
---|
160 | R101.comp = 2; # Key component of the reaction |
---|
161 | R101.stoic = [-3, -1, 0, 0, 2]; # Stoichiometry of the reaction |
---|
162 | |
---|
163 | SPECIFY |
---|
164 | FEED.F = 2000 * "lbmol/h"; |
---|
165 | FEED.T = (27 + 273.15) * "K"; |
---|
166 | FEED.P = 10 * "atm"; |
---|
167 | FEED.z = [0.74, 0.24, 0.01, 0.01, 0.0]; |
---|
168 | |
---|
169 | C101.Outlet.P = 200 * "atm"; |
---|
170 | C102.Outlet.P = 200 * "atm"; |
---|
171 | |
---|
172 | R101.X = 0.4; # Convertion of the reactor |
---|
173 | |
---|
174 | F101.OutletV.P = 199 * "atm"; |
---|
175 | F101.OutletV.T = (-34 + 273.15) * "K"; |
---|
176 | |
---|
177 | F102.OutletV.P = 10 * "atm"; |
---|
178 | F102.Q = 0 * "kJ/h"; |
---|
179 | |
---|
180 | # We can choose between one of the following specs |
---|
181 | S101.frac = 0.78; # Recycle fraction |
---|
182 | #loose = 1 * "lbmol/h"; # Ammonia in the purge |
---|
183 | |
---|
184 | EQUATIONS |
---|
185 | production = purity * F102.OutletL.F; |
---|
186 | purity = F102.OutletL.z(5); |
---|
187 | loose = S101.Outlet2.F * S101.Outlet2.z(5); |
---|
188 | |
---|
189 | OPTIONS |
---|
190 | mode = "steady"; |
---|
191 | relativeAccuracy = 1e-5; |
---|
192 | end |
---|
193 | |
---|