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