source: branches/gui/sample/miscellaneous/sample_gasliquid.mso @ 915

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

Another sample file for discontinuities.

File size: 4.3 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* FlowSheet showing how to use the 'if' conditional.
17* Ref: K.M. Moudgalya & V. Ryali (2001). Chemical Engineering Science
18*      v.56, n.11, pp.3595-3609
19*--------------------------------------------------------------------
20* Author: Arge
21* $Id: $
22*--------------------------------------------------------------------*#
23
24using "types";
25
26Model GasLiquid
27        PARAMETERS
28        kgx     as positive (Unit = 'mol/atm/s');
29        klx     as positive (Unit = 'mol/atm/s');
30        R       as positive (Default = 0.082, Unit = 'atm * l / (mol * K)');
31        T       as temperature;
32        Po      as pressure;
33        Vd      as volume (DisplayUnit = 'l');
34        V       as volume (DisplayUnit = 'l');
35        roL     as dens_mol (DisplayUnit = 'mol/l');
36
37        VARIABLES
38        Mg      as mol (DisplayUnit = 'mol');
39        Ml      as mol (DisplayUnit = 'mol');
40        Fg      as flow_mol (DisplayUnit = 'mol/s');
41        Fl      as flow_mol (DisplayUnit = 'mol/s');
42        P       as pressure;
43
44        EQUATIONS
45        P = Mg * R * T / (V - Ml/roL);
46
47        if Ml > Vd * roL then
48                diff(Mg) = Fg;
49                diff(Ml) = Fl - klx * (P - Po);
50        else
51                diff(Mg) = Fg - kgx * (P - Po);
52                diff(Ml) = Fl;
53        end
54
55        SET
56        roL = 50 * 'mol/l';
57        V = 10 * 'l';
58        Vd = 5 * 'l';
59        T = 300 * 'K';
60        Po = 1 * 'atm';
61        kgx = 0.1 * 'mol/atm/s';
62        klx = 0.1 * 'mol/atm/s';
63end
64
65
66FlowSheet GasLiq1 as GasLiquid
67
68        SPECIFY
69        Fg = 0.1 * 'mol/s';
70        Fl = 2.5 * 'mol/s';
71
72        INITIAL
73        P = 3.5 * 'atm';
74        Ml = 245 * 'mol';
75
76        OPTIONS
77#       TimeStep = 100; # for statistical purpose (Detailed Output)
78        TimeStep = 1; # for graphical purpose
79        TimeEnd = 100;
80        TimeUnit = 's';
81        DAESolver  (File = "dasslc",
82                                RelativeAccuracy = 1e-4,
83                                AbsoluteAccuracy = 1e-6);
84end
85
86
87FlowSheet GasLiq2 as GasLiquid
88
89        SPECIFY
90        Fg = 2.0 * 'mol/s';
91        Fl = 1.0 * 'mol/s';
92
93        INITIAL
94        P = 1.0 * 'atm';
95        Ml = 249 * 'mol';
96
97        OPTIONS
98#       TimeStep = 10; # for statistical purpose (Detailed Output)
99        TimeStep = 0.1; # for graphical purpose
100        TimeEnd = 10;
101        TimeUnit = 's';
102        DAESolver  (File = "dasslc",
103                                RelativeAccuracy = 1e-4,
104                                AbsoluteAccuracy = 1e-6);
105end
106
107
108Model GasLiquid_reg
109        PARAMETERS
110        kgx     as positive (Unit = 'mol/atm/s');
111        klx     as positive (Unit = 'mol/atm/s');
112        R       as positive (Default = 0.082, Unit = 'atm * l / (mol * K)');
113        T       as temperature;
114        Po      as pressure;
115        Vd      as volume (DisplayUnit = 'l');
116        V       as volume (DisplayUnit = 'l');
117        roL     as dens_mol (DisplayUnit = 'mol/l');
118        eps as Real (Default=1e-5);
119
120        VARIABLES
121        Mg      as mol (DisplayUnit = 'mol');
122        Ml      as mol (DisplayUnit = 'mol');
123        Fg      as flow_mol (DisplayUnit = 'mol/s');
124        Fl      as flow_mol (DisplayUnit = 'mol/s');
125        P       as pressure;
126        n       as Real;
127
128        EQUATIONS
129        P = Mg * R * T / (V - Ml/roL);
130
131        n = 0.5 * (1 + tanh((Ml/(Vd * roL)-1)/eps)); # regularization function
132#       n = 0.5 * (1+((Ml/(Vd * roL)-1)/eps)/(sqrt(1+((Ml/(Vd * roL)-1)/eps)^2))); # regularization function
133
134        diff(Mg) = Fg - kgx * (P - Po)*(1-n);
135        diff(Ml) = Fl - klx * (P - Po)*n;
136
137        SET
138        roL = 50 * 'mol/l';
139        V = 10 * 'l';
140        Vd = 5 * 'l';
141        T = 300 * 'K';
142        Po = 1 * 'atm';
143        kgx = 0.1 * 'mol/atm/s';
144        klx = 0.1 * 'mol/atm/s';
145end
146
147FlowSheet GasLiq1_reg as GasLiquid_reg
148
149        SPECIFY
150        Fg = 0.1 * 'mol/s';
151        Fl = 2.5 * 'mol/s';
152
153        INITIAL
154        P = 3.5 * 'atm';
155        Ml = 245 * 'mol';
156
157        OPTIONS
158#       TimeStep = 100; # for statistical purpose (Detailed Output)
159        TimeStep = 1; # for graphical purpose
160        TimeEnd = 100;
161        TimeUnit = 's';
162        DAESolver  (File = "dasslc",
163                                RelativeAccuracy = 1e-4,
164                                AbsoluteAccuracy = 1e-6);
165end
166
167
168FlowSheet GasLiq2_reg as GasLiquid_reg
169
170        SPECIFY
171        Fg = 2.0 * 'mol/s';
172        Fl = 1.0 * 'mol/s';
173
174        INITIAL
175        P = 1.0 * 'atm';
176        Ml = 249 * 'mol';
177
178        OPTIONS
179#       TimeStep = 10; # for statistical purpose (Detailed Output)
180        TimeStep = 0.1; # for graphical purpose
181        TimeEnd = 10;
182        TimeUnit = 's';
183        DAESolver  (File = "dasslc",
184                                RelativeAccuracy = 1e-4,
185                                AbsoluteAccuracy = 1e-6);
186end
Note: See TracBrowser for help on using the repository browser.