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

Annotation of /trunk/models/sonic.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (hide annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (12 years, 4 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 jpye 1344 (* 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 jpye 2649 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 jpye 1344 *)
17 aw0a 1 REQUIRE "atoms.a4l";
18     (*
19 jpye 1344 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 aw0a 1
24 jpye 1344 The problem is described in the thesis
25     J Zaher, 'Conditional Modeling', Ph.D. Thesis, Carnegie Mellon University,
26     Pittsburgh, PA, 15213. 1995.
27 aw0a 1
28 jpye 1344 Model by Vicente Rico-Ramirez, 10 Apr 1998.
29    
30     If using the Tcl/Tk interface, see the associated script file sonic.a4s.
31 aw0a 1 *)
32     MODEL sonic;
33    
34 jpye 1344 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 jose 2071 R IS_A molar_gas_constant;
48 jpye 1344 Pifac IS_A factor;
49     sonic_flow IS_A boolean_var;
50 aw0a 1
51 jpye 1344 (* boundary *)
52     CONDITIONAL
53 aw0a 1 cond: (Pd - Pf) * 1.0 {atm^-1} <= Mf - 1.0;
54     END CONDITIONAL;
55    
56 jpye 1344 sonic_flow == SATISFIED(cond,1e-08);
57 aw0a 1
58 jpye 1344 (* Variant Equations *)
59 aw0a 1
60     not_sonic: Pf = Pd;
61     sonic: Mf = 1.0;
62    
63 jpye 1344 (* Disjunctive statement *)
64 aw0a 1
65 jpye 1344 WHEN (sonic_flow)
66     CASE TRUE:
67     USE sonic;
68     CASE FALSE:
69     USE not_sonic;
70 aw0a 1 END WHEN;
71    
72 jpye 1344 (* Invariant Equations *)
73 aw0a 1
74     R * F * Ti / Pi = Pifac * (D^2) * Mi/4.0 * (gamma * R *Ti/mw)^(1/2);
75 jpye 1344
76 aw0a 1 R * F * Tf / Pf = Pifac * (D^2) * Mf/4.0 * (gamma * R *Tf/mw)^(1/2);
77 jpye 1344
78 aw0a 1 Tf/Ti = (1 + 0.5*(gamma-1)*(Mi^2))/(1 + 0.5*(gamma-1)*(Mf^2));
79    
80 jpye 1344 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 aw0a 1
86 jpye 1344 METHODS
87 aw0a 1
88 jpye 1344 METHOD default_self;
89     END default_self;
90 aw0a 1
91 jpye 1344 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 aw0a 1
103 jpye 1344 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 aw0a 1
115 jpye 1344 (* 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 aw0a 1
122 jpye 1344 (* initial boolean value *)
123     sonic_flow := SATISFIED(cond,1e-08);
124     END values;
125 aw0a 1
126 jpye 1344 METHOD on_load;
127     RUN default_self;
128     RUN reset;
129     RUN values;
130     END on_load;
131 aw0a 1
132 jpye 1344 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