/[ascend]/trunk/models/sonic.a4c
ViewVC logotype

Contents of /trunk/models/sonic.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2071 - (show annotations) (download) (as text)
Fri Aug 28 02:42:47 2009 UTC (10 years, 3 months ago) by jose
File MIME type: text/x-ascend
File size: 3388 byte(s)
MERGE Jose's branch [2274]:[2584] into trunk
1 (* ASCEND modelling environment
2 Copyright (C) 1998, 2007 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *)
19 REQUIRE "atoms.a4l";
20 (*
21 Model of adiabatic compressible flow. The problem represents the flow of a
22 compressible gas in a circular pipe of constant diameter. There is a
23 disjunctive statement which represents whether the flow is sonic or
24 subsonic. This model requires the conditional solver CMSlv.
25
26 The problem is described in the thesis
27 J Zaher, 'Conditional Modeling', Ph.D. Thesis, Carnegie Mellon University,
28 Pittsburgh, PA, 15213. 1995.
29
30 Model by Vicente Rico-Ramirez, 10 Apr 1998.
31
32 If using the Tcl/Tk interface, see the associated script file sonic.a4s.
33 *)
34 MODEL sonic;
35
36 Pi IS_A pressure;
37 Pf IS_A pressure;
38 Pd IS_A pressure;
39 Ti IS_A temperature;
40 Tf IS_A temperature;
41 Mi IS_A fraction;
42 Mf IS_A fraction;
43 D IS_A distance;
44 F IS_A molar_rate;
45 friction IS_A factor;
46 gamma IS_A factor;
47 mw IS_A molar_mass;
48 L IS_A distance;
49 R IS_A molar_gas_constant;
50 Pifac IS_A factor;
51 sonic_flow IS_A boolean_var;
52
53 (* boundary *)
54 CONDITIONAL
55 cond: (Pd - Pf) * 1.0 {atm^-1} <= Mf - 1.0;
56 END CONDITIONAL;
57
58 sonic_flow == SATISFIED(cond,1e-08);
59
60 (* Variant Equations *)
61
62 not_sonic: Pf = Pd;
63 sonic: Mf = 1.0;
64
65 (* Disjunctive statement *)
66
67 WHEN (sonic_flow)
68 CASE TRUE:
69 USE sonic;
70 CASE FALSE:
71 USE not_sonic;
72 END WHEN;
73
74 (* Invariant Equations *)
75
76 R * F * Ti / Pi = Pifac * (D^2) * Mi/4.0 * (gamma * R *Ti/mw)^(1/2);
77
78 R * F * Tf / Pf = Pifac * (D^2) * Mf/4.0 * (gamma * R *Tf/mw)^(1/2);
79
80 Tf/Ti = (1 + 0.5*(gamma-1)*(Mi^2))/(1 + 0.5*(gamma-1)*(Mf^2));
81
82 1/(Mi^2) - 1/(Mf^2) - 4 * gamma * friction * L / D =
83 0.5 * (gamma + 1) * ln(
84 ((Mf^2)*(1 + 0.5*(gamma-1)*(Mi^2)))
85 / ((Mi^2)*(1 + 0.5*(gamma-1)*(Mf^2)))
86 );
87
88 METHODS
89
90 METHOD default_self;
91 END default_self;
92
93 METHOD specify;
94 FIX friction;
95 FIX gamma;
96 FIX mw;
97 FIX L;
98 FIX Ti;
99 FIX Pi;
100 FIX Pd;
101 FIX D;
102 FIX Pifac;
103 END specify;
104
105 METHOD values;
106 (* fixed values*)
107 friction := 0.01;
108 gamma := 1.292;
109 mw := 16 {g/g_mole};
110 L := 1 {m};
111 Ti := 300.0 {K};
112 Pi := 10.0 {atm};
113 Pd := 5.0 {atm};
114 D := 5.0 {cm}; (* boundary is 4.08844 {cm} *)
115 Pifac := 3.14159;
116
117 (* initial values *)
118 Mi := 0.5;
119 Mf := 0.5;
120 Tf := 300.0 {K};
121 Pf := 5.0 {atm};
122 F := 200.0 {g_mole/s};
123
124 (* initial boolean value *)
125 sonic_flow := SATISFIED(cond,1e-08);
126 END values;
127
128 METHOD on_load;
129 RUN default_self;
130 RUN reset;
131 RUN values;
132 END on_load;
133
134 METHOD self_test;
135 IF D < 4.08844 {cm} THEN
136 ASSERT sonic_flow == FALSE;
137 ELSE
138 ASSERT sonic_flow == TRUE;
139 END IF;
140 END self_test;
141
142 END sonic;

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22