[85] | 1 | #*------------------------------------------------------------------- |
---|
| 2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
[22] | 3 | * |
---|
[85] | 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 983 2016-05-27 00:50:02Z arge $ |
---|
| 25 | *--------------------------------------------------------------------*# |
---|
[22] | 26 | |
---|
| 27 | using "stage_separators/flash"; |
---|
| 28 | using "mixers_splitters/splitter"; |
---|
| 29 | |
---|
| 30 | # A simple ideal compressor |
---|
| 31 | Model Compressor |
---|
| 32 | PARAMETERS |
---|
[216] | 33 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
[185] | 34 | outer NComp as Integer; |
---|
[22] | 35 | |
---|
| 36 | VARIABLES |
---|
| 37 | in Inlet as stream; |
---|
[185] | 38 | out Outlet as streamPH; |
---|
[22] | 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 | end |
---|
| 50 | |
---|
| 51 | # A simple 2 Inlet mixer. |
---|
| 52 | Model Mixer |
---|
| 53 | PARAMETERS |
---|
[216] | 54 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
[185] | 55 | outer NComp as Integer; |
---|
[22] | 56 | |
---|
| 57 | VARIABLES |
---|
| 58 | in Inlet1 as stream; |
---|
| 59 | in Inlet2 as stream; |
---|
[185] | 60 | out Outlet as streamPH; |
---|
[22] | 61 | |
---|
| 62 | EQUATIONS |
---|
| 63 | "Energy Balance" |
---|
| 64 | Outlet.F * Outlet.h = Inlet1.F * Inlet1.h + Inlet2.F * Inlet2.h; |
---|
| 65 | |
---|
| 66 | Inlet1.P = Outlet.P; |
---|
| 67 | |
---|
| 68 | "Global Molar Balance" |
---|
| 69 | Inlet1.F + Inlet2.F = Outlet.F; |
---|
| 70 | "Component Molar Balance" |
---|
| 71 | Inlet1.z*Inlet1.F + Inlet2.z*Inlet2.F = Outlet.F * Outlet.z; |
---|
| 72 | end |
---|
| 73 | |
---|
| 74 | # A simple 'conversion' based reactor. |
---|
| 75 | Model Reactor |
---|
| 76 | PARAMETERS |
---|
[216] | 77 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
[185] | 78 | outer NComp as Integer; |
---|
[22] | 79 | NReac as Integer(Default=1); |
---|
| 80 | stoic(NComp, NReac) as Real (Brief = "Stoichiometric Matrix"); |
---|
| 81 | comp(NReac) as Integer(Default=1, Brief = "Key Component of the reaction"); |
---|
| 82 | |
---|
| 83 | VARIABLES |
---|
| 84 | in Inlet as stream; |
---|
[185] | 85 | out Outlet as streamPH; |
---|
[22] | 86 | Outletz(NComp) as fraction; |
---|
| 87 | X(NReac) as fraction(Brief="Convertion of the key component"); |
---|
| 88 | |
---|
| 89 | EQUATIONS |
---|
| 90 | "Energy Balance" |
---|
| 91 | Outlet.F * Outlet.h = Inlet.F * Inlet.h; |
---|
| 92 | |
---|
| 93 | "Global Molar Balance" |
---|
| 94 | Outlet.F = Inlet.F * (1 - sum(Outletz)); |
---|
| 95 | |
---|
[574] | 96 | for i in [1:NComp] do |
---|
[22] | 97 | "Component Molar Balance" |
---|
| 98 | Outletz(i) = Inlet.z(i) + sum(stoic(i,:)*X*Inlet.z(comp)); |
---|
| 99 | end |
---|
| 100 | |
---|
| 101 | "Normalize the outlet composition" |
---|
| 102 | Outlet.z * sum(Outletz) = Outletz; |
---|
| 103 | |
---|
| 104 | Outlet.P = Inlet.P; |
---|
| 105 | end |
---|
| 106 | |
---|
| 107 | # Ammonia Process |
---|
| 108 | FlowSheet Ammonia |
---|
| 109 | PARAMETERS |
---|
[218] | 110 | PP as Plugin(Brief="Physical Properties", Type="PP", |
---|
| 111 | Components = ["hydrogen", "nitrogen", "argon", "methane", "ammonia"], |
---|
[983] | 112 | LiquidModel = "ASRK", |
---|
| 113 | VapourModel = "ASRK"); |
---|
[22] | 114 | NComp as Integer; |
---|
| 115 | SET |
---|
[215] | 116 | |
---|
[22] | 117 | NComp = PP.NumberOfComponents; |
---|
| 118 | |
---|
| 119 | DEVICES |
---|
[185] | 120 | FEED as source; |
---|
[22] | 121 | C101 as Compressor; |
---|
| 122 | R101 as Reactor; |
---|
[185] | 123 | F101 as flash_steady; |
---|
| 124 | F102 as flash_steady; |
---|
[916] | 125 | S101 as splitter2; |
---|
[22] | 126 | M101 as Mixer; |
---|
| 127 | M102 as Mixer; |
---|
| 128 | C102 as Compressor; |
---|
| 129 | |
---|
| 130 | VARIABLES |
---|
| 131 | purity as fraction(Brief="Purity of the product"); |
---|
[185] | 132 | production as flow_mol(DisplayUnit = 'lbmol/h', Brief="Ammonia in the product"); |
---|
| 133 | loose as flow_mol(DisplayUnit = 'lbmol/h', Brief="Ammonia in the purge"); |
---|
[312] | 134 | Q1 as energy_source; |
---|
| 135 | Q2 as energy_source; |
---|
[22] | 136 | |
---|
| 137 | CONNECTIONS |
---|
[185] | 138 | FEED.Outlet to M101.Inlet1; |
---|
[22] | 139 | M101.Outlet to C101.Inlet; |
---|
| 140 | C101.Outlet to M102.Inlet1; |
---|
| 141 | M102.Outlet to R101.Inlet; |
---|
| 142 | R101.Outlet to F101.Inlet; |
---|
[916] | 143 | F101.OutletLiquid to F102.Inlet; |
---|
| 144 | F102.OutletVapour to M101.Inlet2; |
---|
| 145 | F101.OutletVapour to S101.Inlet; |
---|
[22] | 146 | S101.Outlet1 to C102.Inlet; |
---|
| 147 | C102.Outlet to M102.Inlet2; |
---|
| 148 | |
---|
[313] | 149 | Q1.OutletQ to F101.InletQ; |
---|
| 150 | Q2.OutletQ to F102.InletQ; |
---|
[22] | 151 | |
---|
| 152 | SET |
---|
| 153 | R101.comp = 2; # Key component of the reaction |
---|
| 154 | R101.stoic = [-3, -1, 0, 0, 2]; # Stoichiometry of the reaction |
---|
| 155 | |
---|
| 156 | SPECIFY |
---|
[578] | 157 | FEED.F = 2000 * 'lbmol/h'; |
---|
| 158 | FEED.T = (27 + 273.15) * 'K'; |
---|
| 159 | FEED.P = 10 * 'atm'; |
---|
| 160 | FEED.Composition = [0.74, 0.24, 0.01, 0.01, 0.0]; |
---|
[22] | 161 | |
---|
[185] | 162 | C101.Outlet.P = 200 * 'atm'; |
---|
| 163 | C102.Outlet.P = 200 * 'atm'; |
---|
[22] | 164 | |
---|
| 165 | R101.X = 0.4; # Convertion of the reactor |
---|
| 166 | |
---|
[916] | 167 | F101.OutletVapour.P = 199 * 'atm'; |
---|
| 168 | F101.OutletVapour.T = (-34 + 273.15) * 'K'; |
---|
[22] | 169 | |
---|
[916] | 170 | F102.OutletVapour.P = 10 * 'atm'; |
---|
[574] | 171 | F102.InletQ = 0 * 'kJ/h'; |
---|
[22] | 172 | |
---|
| 173 | # We can choose between one of the following specs |
---|
[916] | 174 | S101.FlowRatios(1) = 0.78; # Recycle fraction |
---|
[185] | 175 | #loose = 1 * 'lbmol/h'; # Ammonia in the purge |
---|
[22] | 176 | |
---|
| 177 | EQUATIONS |
---|
[916] | 178 | production = purity * F102.OutletLiquid.F; |
---|
| 179 | purity = F102.OutletLiquid.z(5); |
---|
[22] | 180 | loose = S101.Outlet2.F * S101.Outlet2.z(5); |
---|
| 181 | |
---|
| 182 | OPTIONS |
---|
[185] | 183 | Dynamic = false; |
---|
[247] | 184 | NLASolver( |
---|
| 185 | RelativeAccuracy = 1e-5 |
---|
| 186 | ); |
---|
[22] | 187 | end |
---|