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

Diff of /trunk/models/sonic.a4c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1343 by johnpye, Tue May 9 03:42:08 2006 UTC revision 1344 by jpye, Mon Mar 12 00:08:34 2007 UTC
# Line 1  Line 1 
1  REQUIRE "atoms.a4l";  (*  ASCEND modelling environment
2  (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)      Copyright (C) 1998, 2007 Carnegie Mellon University
 PROVIDE "sonic.a4c";  
 (*  
  * This file is part of the ASCEND Modeling Library and is released  
  * under the GNU Public License as described at the end of this file.  
  *  
  * Use of this module is demonstrated by the associated script file  
  * sonic.a4s.  
  *)  
3    
4  (*      This program is free software; you can redistribute it and/or modify
5     Ascend model of the Adiabatic compressible flow  example presented by      it under the terms of the GNU General Public License as published by
6  Zaher -- Conditional Modeling. Ph.D. Thesis, Carnegie Mellon University,      the Free Software Foundation; either version 2, or (at your option)
7  Pittsburgh, PA, 15213. 1995 --. The problem represents the flow of a      any later version.
8  compressible gas in a circular pipe of constant diameter. There is a  
9  disjunctive statement which represents whether the flow is sonic or      This program is distributed in the hope that it will be useful,
10  subsonic. It represent a problem which we can represent as a conditional      but WITHOUT ANY WARRANTY; without even the implied warranty of
11  model and  solve  with the ascend conditional solver CMSlv.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12        GNU General Public License for more details.
13  This model requires:      
14              "system.a4l"      You should have received a copy of the GNU General Public License
15                  "atoms.a4l"      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;  MODEL sonic;
35    
36      Pi      IS_A pressure;      Pi         IS_A pressure;
37      Pf          IS_A pressure;      Pf         IS_A pressure;
38      Pd          IS_A pressure;      Pd         IS_A pressure;
39      Ti          IS_A temperature;      Ti         IS_A temperature;
40      Tf      IS_A temperature;      Tf         IS_A temperature;
41      Mi      IS_A fraction;      Mi         IS_A fraction;
42      Mf          IS_A fraction;      Mf         IS_A fraction;
43      D       IS_A distance;      D          IS_A distance;
44      F       IS_A molar_rate;      F          IS_A molar_rate;
45      friction    IS_A factor;      friction   IS_A factor;
46      gamma       IS_A factor;      gamma      IS_A factor;
47      mw      IS_A molar_mass;      mw         IS_A molar_mass;
48      L           IS_A distance;      L          IS_A distance;
49      R       IS_A gas_constant;      R          IS_A gas_constant;
50      Pifac           IS_A factor;      Pifac      IS_A factor;
51          sonic_flow  IS_A boolean_var;      sonic_flow IS_A boolean_var;
52    
53  (* boundary *)      (* boundary *)
54          CONDITIONAL      CONDITIONAL
55            cond: (Pd - Pf) * 1.0 {atm^-1} <= Mf - 1.0;            cond: (Pd - Pf) * 1.0 {atm^-1} <= Mf - 1.0;
56      END CONDITIONAL;      END CONDITIONAL;
57    
58          sonic_flow == SATISFIED(cond,1e-08);      sonic_flow == SATISFIED(cond,1e-08);
59    
60  (* Variant Equations *)      (* Variant Equations *)
61    
62      not_sonic: Pf = Pd;      not_sonic: Pf = Pd;
63      sonic: Mf = 1.0;      sonic: Mf = 1.0;
64    
65  (* Disjunctive statement *)      (* Disjunctive statement *)
66    
67          WHEN (sonic_flow)      WHEN (sonic_flow)
68            CASE TRUE:          CASE TRUE:
69          USE sonic;              USE sonic;
70            CASE FALSE:          CASE FALSE:
71          USE not_sonic;              USE not_sonic;
72      END WHEN;      END WHEN;
73    
74  (* Invariant Equations *)      (* Invariant Equations *)
75    
76      R * F * Ti / Pi = Pifac * (D^2) * Mi/4.0 * (gamma * R *Ti/mw)^(1/2);      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);      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));      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 = 0.5*(gamma+1)*      1/(Mi^2) - 1/(Mf^2) - 4 * gamma * friction * L / D =
83                               ln( ((Mf^2)*(1 + 0.5*(gamma-1)*(Mi^2)))/          0.5 * (gamma + 1) * ln(
84                                   ((Mi^2)*(1 + 0.5*(gamma-1)*(Mf^2)))  );              ((Mf^2)*(1 + 0.5*(gamma-1)*(Mi^2)))
85                / ((Mi^2)*(1 + 0.5*(gamma-1)*(Mf^2)))  
86    METHODS          );
87    
88      METHOD default_self;  METHODS
89      END default_self;  
90        METHOD default_self;
91      METHOD specify;      END default_self;
92      FIX friction;  
93      FIX gamma;      METHOD specify;
94      FIX mw;          FIX friction;
95      FIX L;          FIX gamma;
96      FIX Ti;          FIX mw;
97      FIX Pi;          FIX L;
98      FIX Pd;          FIX Ti;
99      FIX D;          FIX Pi;
100      FIX Pifac;          FIX Pd;
101      END specify;          FIX D;
102            FIX Pifac;
103      METHOD values;      END specify;
104          (* fixed values*)  
105      friction := 0.01;      METHOD values;
106      gamma := 1.292;          (* fixed values*)
107      mw := 16 {g/g_mole};          friction := 0.01;
108      L := 1 {m};          gamma := 1.292;
109      Ti := 300.0 {K};          mw := 16 {g/g_mole};
110      Pi := 10.0 {atm};          L := 1 {m};
111      Pd := 5.0 {atm};          Ti := 300.0 {K};
112      D :=  5.0 {cm};      (* boundary is 4.08844 {cm} *)          Pi := 10.0 {atm};
113      Pifac := 3.14159;          Pd := 5.0 {atm};
114          (* initial values *)          D :=  5.0 {cm};      (* boundary is 4.08844 {cm} *)
115      Mi := 0.5;          Pifac := 3.14159;
116      Mf := 0.5;  
117      Tf := 300.0 {K};          (* initial values *)
118      Pf := 5.0 {atm};          Mi := 0.5;
119      F  := 200.0 {g_mole/s};          Mf := 0.5;
120            Tf := 300.0 {K};
121          (* initial boolean value *)          Pf := 5.0 {atm};
122          sonic_flow := SATISFIED(cond,1e-08);          F  := 200.0 {g_mole/s};
123      END values;  
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;  END sonic;
   
   
 (*  
  *  sonic.a4c  
  *  by Vicente Rico-Ramirez  
  *  April 10, 1998  
  *  Part of the ASCEND Library  
  *  $Date: 1998/06/17 19:15:06 $  
  *  $Revision: 1.3 $  
  *  $Author: mthomas $  
  *  $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/sonic.a4c,v $  
  *  
  *  This file is part of the ASCEND Modeling Library.  
  *  
  *  Copyright (C) 1998 Carnegie Mellon University  
  *  
  *  The ASCEND Modeling Library is free software; you can redistribute  
  *  it and/or modify it under the terms of the GNU General Public  
  *  License as published by the Free Software Foundation; either  
  *  version 2 of the License, or (at your option) any later version.  
  *  
  *  The ASCEND Modeling Library is distributed in hope that it will be  
  *  useful, but WITHOUT ANY WARRANTY; without even the implied  
  *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  *  See the GNU General Public License for more details.  
  *  
  *  You should have received a copy of the GNU General Public License  
  *  along with the program; if not, write to the Free Software  
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA.  Check  
  *  the file named COPYING.  
  *)  

Legend:
Removed from v.1343  
changed lines
  Added in v.1344

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