source: trunk/sample/optimization/ammonia.mso @ 313

Last change on this file since 313 was 313, checked in by Argimiro Resende Secchi, 15 years ago

Change name of outlet energy stream to OutletQ.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.8 KB
Line 
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 313 2007-07-14 16:45:55Z arge $
25*--------------------------------------------------------------------*#
26
27using "stage_separators/flash";
28using "mixers_splitters/splitter";
29
30# A simple ideal compressor
31Model Compressor
32        PARAMETERS
33outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
34outer NComp as Integer;
35       
36        VARIABLES
37in      Inlet as stream;
38out     Outlet as streamPH;
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;
49end
50
51# A simple 2 Inlet mixer.
52Model Mixer
53        PARAMETERS
54outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
55outer NComp as Integer;
56       
57        VARIABLES
58in      Inlet1 as stream;
59in      Inlet2 as stream;
60out     Outlet as streamPH;
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;
72end
73
74# A simple 'conversion' based reactor.
75Model Reactor
76        PARAMETERS
77outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
78outer NComp as Integer;
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
84in      Inlet as stream;
85out     Outlet as streamPH;
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       
96        for i in [1:NComp]
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;
105end
106
107# Ammonia Process
108FlowSheet Ammonia
109        PARAMETERS
110        PP      as Plugin(Brief="Physical Properties", Type="PP",
111                Components = ["hydrogen", "nitrogen", "argon", "methane", "ammonia"],
112                LiquidModel = "APR",
113                VapourModel = "APR");
114        NComp   as Integer;
115        SET
116       
117        NComp = PP.NumberOfComponents;
118       
119        DEVICES
120        FEED   as source;
121        C101   as Compressor;
122        R101   as Reactor;
123        F101   as flash_steady;
124        F102   as flash_steady;
125        S101   as splitter;
126        M101   as Mixer;
127        M102   as Mixer;
128        C102   as Compressor;
129
130        VARIABLES
131        purity as fraction(Brief="Purity of the product");
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");
134        Q1 as energy_source;
135        Q2 as energy_source;
136
137        CONNECTIONS
138        FEED.Outlet    to   M101.Inlet1;
139        M101.Outlet    to   C101.Inlet;
140        C101.Outlet    to   M102.Inlet1;
141        M102.Outlet    to   R101.Inlet;
142        R101.Outlet    to   F101.Inlet;
143        F101.OutletL   to   F102.Inlet;
144        F102.OutletV   to   M101.Inlet2;
145        F101.OutletV   to   S101.Inlet;
146        S101.Outlet1   to   C102.Inlet;
147        C102.Outlet    to   M102.Inlet2;
148       
149        Q1.OutletQ      to   F101.InletQ;
150        Q2.OutletQ      to   F102.InletQ;       
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
157        FEED.Outlet.F = 2000 * 'lbmol/h';
158        FEED.Outlet.T = (27 + 273.15) * 'K';
159        FEED.Outlet.P = 10 * 'atm';
160        FEED.Outlet.z = [0.74, 0.24, 0.01, 0.01, 0.0];
161       
162        C101.Outlet.P = 200 * 'atm';
163        C102.Outlet.P = 200 * 'atm';
164       
165        R101.X = 0.4; # Convertion of the reactor
166       
167        F101.OutletV.P = 199 * 'atm';
168        F101.OutletV.T = (-34 + 273.15) * 'K';
169       
170        F102.OutletV.P = 10 * 'atm';
171        F102.InletQ.Q = 0 * 'kJ/h';
172       
173        # We can choose between one of the following specs
174        S101.frac = 0.78; # Recycle fraction
175        #loose = 1 * 'lbmol/h'; # Ammonia in the purge
176       
177        EQUATIONS
178        production = purity * F102.OutletL.F;
179        purity = F102.OutletL.z(5);
180        loose  = S101.Outlet2.F * S101.Outlet2.z(5);
181       
182        OPTIONS
183        Dynamic = false;
184        NLASolver(
185                RelativeAccuracy = 1e-5
186        );
187end
Note: See TracBrowser for help on using the repository browser.