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

Contents of /trunk/models/sonic.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (show annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (11 years, 6 months ago) by jpye
File MIME type: text/x-ascend
File size: 3321 byte(s)
Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)
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, see <http://www.gnu.org/licenses/>.
16 *)
17 REQUIRE "atoms.a4l";
18 (*
19 Model of adiabatic compressible flow. The problem represents the flow of a
20 compressible gas in a circular pipe of constant diameter. There is a
21 disjunctive statement which represents whether the flow is sonic or
22 subsonic. This model requires the conditional solver CMSlv.
23
24 The problem is described in the thesis
25 J Zaher, 'Conditional Modeling', Ph.D. Thesis, Carnegie Mellon University,
26 Pittsburgh, PA, 15213. 1995.
27
28 Model by Vicente Rico-Ramirez, 10 Apr 1998.
29
30 If using the Tcl/Tk interface, see the associated script file sonic.a4s.
31 *)
32 MODEL sonic;
33
34 Pi IS_A pressure;
35 Pf IS_A pressure;
36 Pd IS_A pressure;
37 Ti IS_A temperature;
38 Tf IS_A temperature;
39 Mi IS_A fraction;
40 Mf IS_A fraction;
41 D IS_A distance;
42 F IS_A molar_rate;
43 friction IS_A factor;
44 gamma IS_A factor;
45 mw IS_A molar_mass;
46 L IS_A distance;
47 R IS_A molar_gas_constant;
48 Pifac IS_A factor;
49 sonic_flow IS_A boolean_var;
50
51 (* boundary *)
52 CONDITIONAL
53 cond: (Pd - Pf) * 1.0 {atm^-1} <= Mf - 1.0;
54 END CONDITIONAL;
55
56 sonic_flow == SATISFIED(cond,1e-08);
57
58 (* Variant Equations *)
59
60 not_sonic: Pf = Pd;
61 sonic: Mf = 1.0;
62
63 (* Disjunctive statement *)
64
65 WHEN (sonic_flow)
66 CASE TRUE:
67 USE sonic;
68 CASE FALSE:
69 USE not_sonic;
70 END WHEN;
71
72 (* Invariant Equations *)
73
74 R * F * Ti / Pi = Pifac * (D^2) * Mi/4.0 * (gamma * R *Ti/mw)^(1/2);
75
76 R * F * Tf / Pf = Pifac * (D^2) * Mf/4.0 * (gamma * R *Tf/mw)^(1/2);
77
78 Tf/Ti = (1 + 0.5*(gamma-1)*(Mi^2))/(1 + 0.5*(gamma-1)*(Mf^2));
79
80 1/(Mi^2) - 1/(Mf^2) - 4 * gamma * friction * L / D =
81 0.5 * (gamma + 1) * ln(
82 ((Mf^2)*(1 + 0.5*(gamma-1)*(Mi^2)))
83 / ((Mi^2)*(1 + 0.5*(gamma-1)*(Mf^2)))
84 );
85
86 METHODS
87
88 METHOD default_self;
89 END default_self;
90
91 METHOD specify;
92 FIX friction;
93 FIX gamma;
94 FIX mw;
95 FIX L;
96 FIX Ti;
97 FIX Pi;
98 FIX Pd;
99 FIX D;
100 FIX Pifac;
101 END specify;
102
103 METHOD values;
104 (* fixed values*)
105 friction := 0.01;
106 gamma := 1.292;
107 mw := 16 {g/g_mole};
108 L := 1 {m};
109 Ti := 300.0 {K};
110 Pi := 10.0 {atm};
111 Pd := 5.0 {atm};
112 D := 5.0 {cm}; (* boundary is 4.08844 {cm} *)
113 Pifac := 3.14159;
114
115 (* initial values *)
116 Mi := 0.5;
117 Mf := 0.5;
118 Tf := 300.0 {K};
119 Pf := 5.0 {atm};
120 F := 200.0 {g_mole/s};
121
122 (* initial boolean value *)
123 sonic_flow := SATISFIED(cond,1e-08);
124 END values;
125
126 METHOD on_load;
127 RUN default_self;
128 RUN reset;
129 RUN values;
130 END on_load;
131
132 METHOD self_test;
133 IF D < 4.08844 {cm} THEN
134 ASSERT sonic_flow == FALSE;
135 ELSE
136 ASSERT sonic_flow == TRUE;
137 END IF;
138 END self_test;
139
140 END sonic;

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