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

Annotation of /trunk/models/plotcol.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2651 - (hide annotations) (download) (as text)
Thu Dec 13 07:29:48 2012 UTC (12 years, 3 months ago) by jpye
File MIME type: text/x-ascend
File size: 9276 byte(s)
Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)
1 aw0a 1 REQUIRE "column.a4l";
2     (* => column.a4l, flash.a4l, stream_holdup.a4l, thermodynamics.a4l,
3     * components.a4l, phases.a4l, atoms.a4l, measures.a4l, system.a4l,
4     * basemodel.a4l *)
5     REQUIRE "plot.a4l";
6     (* => plot.a4l, atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
7     PROVIDE "plotcol.a4c";
8     (*
9     * This file is part of the ASCEND Modeling Library and is released
10     * under the GNU Public License as described at the end of this file.
11     *)
12    
13     MODEL demo_plot_column(
14     components IS_A set OF symbol_constant;
15     reference IS_A symbol_constant;
16     n_trays IS_A integer_constant;
17     feed_location IS_A integer_constant;
18     ) WHERE (
19     reference IN components == TRUE;
20     n_trays > 5;
21     feed_location > 2;
22     feed_location < n_trays - 2;
23     ) REFINES demo_column;
24    
25     z_eq_tray_set ALIASES Column.VLE_set;
26     z_eq_tray_coord[z_eq_tray_set] IS_A real;
27    
28     z_eq_tray_above_set IS_A set OF integer_constant;
29     z_eq_tray_above_set :== [0 .. Column.N_trays-1];
30     z_eq_tray_above_coord[z_eq_tray_above_set] IS_A real;
31    
32     z_all_tray_set IS_A set OF integer_constant;
33     z_all_tray_set :== [0 .. Column.N_trays];
34     z_all_tray_coord[z_all_tray_set] IS_A real;
35    
36     z_icmp IS_A set OF integer_constant;
37     z_icmp :== [1..CARD[components]];
38    
39     Profile IS_A simple_column_profiles(Column);
40    
41     FOR i IN [components] CREATE
42     x_curves[i] IS_A plt_curve(
43     Profile.zx[i],
44     Profile.x[i],
45     z_eq_tray_coord
46     );
47     y_curves[i] IS_A plt_curve(
48     Profile.zy[i],
49     Profile.y[i],
50     z_eq_tray_coord
51     );
52     k_curves[i] IS_A plt_curve(
53     Profile.zk[i],
54     Profile.kvalues_when_full_thermo[i],
55     z_eq_tray_coord
56     );
57     END FOR;
58    
59     t_curve IS_A plt_curve(Profile.zT,Profile.T,z_eq_tray_coord);
60     t_curves[1] ALIASES t_curve;
61    
62     p_curve IS_A plt_curve(Profile.zP,Profile.P,z_eq_tray_coord);
63     p_curves[2] ALIASES p_curve;
64    
65     Q_curve IS_A plt_curve(Profile.zQ,Profile.Qin,z_all_tray_coord);
66     Q_curves[3] ALIASES Q_curve;
67    
68     L_curve IS_A plt_curve(Profile.zL,Profile.Lin,z_eq_tray_coord);
69     L_curves[4] ALIASES L_curve;
70    
71     V_curve IS_A plt_curve(Profile.zV,Profile.Vin,z_eq_tray_above_coord);
72     V_curves[5] ALIASES V_curve;
73    
74     Plot_x IS_A plt_plot_symbol(components,x_curves);
75     Plot_y IS_A plt_plot_symbol(components,y_curves);
76     Plot_K IS_A plt_plot_symbol(components,k_curves);
77     Plot_T IS_A plt_plot_integer([1],t_curves);
78     Plot_P IS_A plt_plot_integer([2],p_curves);
79     Plot_Q IS_A plt_plot_integer([3],Q_curves);
80     Plot_L IS_A plt_plot_integer([4],L_curves);
81     Plot_V IS_A plt_plot_integer([5],V_curves);
82    
83     (* this stuff needs work
84     (* in conversion process from bob's mcplot code.
85     SELECT (CARD[components])
86     CASE 2:
87     (* mccabe thiele plot only for 2 components *)
88    
89     (* these get mapped into parameters *)
90     mceq.npnt :== Plot_x.curve[reference].npnt;
91     mcstages.npnt :== 2*(Plot_x.curve[reference].npnt) + 1;
92     mcopline.npnt :== Plot_x.curve[reference].npnt+1;
93     mcident.npnt :== 2;
94     mcqline.npnt :== 2;
95    
96    
97     FOR j IN [1..mceq.npnt] CREATE
98     mceq.pnt[j].x, Plot_x.curve[reference].pnt[j].y ARE_THE_SAME;
99     mceq.pnt[j].y, Plot_y.curve[reference].pnt[j].y ARE_THE_SAME;
100    
101     mcstages.pnt[2*j-1], mcopline.pnt[j] ARE_THE_SAME;
102     mcstages.pnt[2*j], mceq.pnt[j] ARE_THE_SAME;
103     END FOR;
104    
105     FOR j IN [2..mcopline.npnt-1] CREATE
106     mcopline.pnt[j].x, Plot_x.curve[reference].pnt[j-1].y
107     ARE_THE_SAME;
108     mcopline.pnt[j].y, Plot_y.curve[reference].pnt[j].y
109     ARE_THE_SAME;
110     END FOR;
111    
112     mcstages.pnt[1].x, mcstages.pnt[1].y, Plot_y.curve[reference].pnt[1].y
113     ARE_THE_SAME;
114    
115     mcstages.pnt[2*(Plot_x.curve[reference].npnt)+1].x,
116     mcstages.pnt[2*(Plot_x.curve[reference].npnt)+1].y,
117     Plot_x.curve[reference].pnt[Plot_x.curve[reference].npnt].y
118     ARE_THE_SAME;
119    
120     mcstages.pnt[2*(Plot_x.curve[reference].npnt)+1],
121     mcopline.pnt[Plot_x.curve[reference].npnt+1] ARE_THE_SAME;
122    
123     mcident.pnt[1], mcopline.pnt[1] ARE_THE_SAME;
124     mcident.pnt[2], mcopline.pnt[mcopline.npnt] ARE_THE_SAME;
125    
126     mcqline.pnt[2], mceq.pnt[col.feed_loc] ARE_THE_SAME;
127    
128     (* stuff below here or something very like should work when complete *)
129    
130     (* I may be missing the distillate from mceq and mcstagex *)
131     mceq IS_A plt_curve(
132     Column.zx[reference],
133     Column.Profile_x[reference],
134     Column.Profile_y[reference]
135     );
136    
137     mcstagex[mc_sx_pts] ALIASES ((
138     (Column.Profile_x[reference][k],Column.Profile_x[reference][k])
139     | k IN z_eq_tray_set),
140     Column.Profile_x[reference][Column.N_trays])
141     WHERE mc_sx_pts IS_A set OF integer_constant;
142    
143     (* this one may be way off *)
144     mcstagey[mc_sy_pts] ALIASES ((
145     (Column.Profile_Y[reference][k+1],
146     Column.Profile_Y[reference][k])
147     | k IN z_eq_tray_set),
148     Column.Profile_x[reference][Column.N_trays])
149     WHERE mc_sy_pts IS_A set OF integer_constant;
150    
151     (* If we get all the curves built ok, this part is a nobrainer *)
152     mc_curves[mc_set] ALIASES (mceq,mcstages,mcopline,mcident,mcqline)
153     WHERE mc_set IS_A set OF integer_constant;
154    
155     Plot_MT IS_A plt_plot_integer(mc_set,mc_curves);
156    
157     OTHERWISE
158     END FOR; (* select CARD components *)
159    
160     *)
161     *)
162    
163     METHODS
164     METHOD values;
165     RUN demo_column::values;
166     z_all_tray_coord[0] := 0;
167     FOR i IN z_eq_tray_set DO
168     z_all_tray_coord[i] := i;
169     z_eq_tray_coord[i] := i;
170     z_eq_tray_above_coord[i-1] := i-1;
171     END FOR;
172     t_curve.legend := 'temperature';
173     p_curve.legend := 'pressure';
174     Q_curve.legend := 'enthalpy';
175     V_curve.legend := 'entering vapor';
176     L_curve.legend := 'entering liquid';
177     FOR i IN components DO
178     y_curves[i].legend := i;
179     x_curves[i].legend := i;
180     k_curves[i].legend := i;
181     END FOR;
182     Plot_x.title := 'Liquid Compositions';
183     Plot_y.title := 'Vapor Compositions';
184     Plot_K.title := 'Volatilities';
185     Plot_T.title := 'Temperature';
186     Plot_P.title := 'Pressure';
187     Plot_Q.title := 'Input heat';
188     Plot_L.title := 'Liquid Flow';
189     Plot_V.title := 'Vapor Flow';
190     Plot_P.XLabel := 'tray number';
191     Plot_T.XLabel := 'tray number';
192     Plot_y.XLabel := 'tray number';
193     Plot_x.XLabel := 'tray number';
194     Plot_K.XLabel := 'tray number';
195     Plot_Q.XLabel := 'tray number';
196     Plot_L.XLabel := 'tray number';
197     Plot_V.XLabel := 'tray number';
198     Plot_T.YLabel := '{K}';
199     Plot_P.YLabel := '{Pascal}';
200     Plot_y.YLabel := 'mole fraction';
201     Plot_x.YLabel := 'mole fraction';
202     Plot_K.YLabel := 'K value';
203     Plot_Q.YLabel := 'watt';
204     Plot_L.YLabel := 'mole/s';
205     Plot_V.YLabel := 'mole/s';
206     (* make composition plots cover 0 - 1 *)
207     Plot_x.Ylow := 0;
208     Plot_x.Yhigh := 1;
209     Plot_y.Ylow := 0;
210     Plot_y.Yhigh := 1;
211    
212     (* This part ok when Plot_MT is finished above.
213     IF CARD[components] == 2 THEN
214     Plot_MT.title := 'McCabe-Thiele Diagram';
215     Plot_MT.XLabel := 'Liquid composition';
216     Plot_MT.YLabel := 'Vapor composition';
217     mceq.legend := 'equilibrium';
218     mcstages.legend := 'stages';
219     mcopline.legend := 'operating line';
220     mcident.legend := 'x=y';
221     mcqline.legend := 'qline';
222     END FOR;
223     *)
224     END values;
225    
226     END demo_plot_column;
227    
228     MODEL testdemoplotmodel() REFINES testcmumodel();
229     METHODS
230     METHOD check_self;
231     RUN demo.check_self;
232     END check_self;
233     METHOD check_all;
234     RUN demo.check_all;
235     END check_all;
236     METHOD default_self;
237     RUN demo.default_self;
238     END default_self;
239     METHOD default_all;
240     RUN demo.scale_all;
241     END default_all;
242     METHOD scale_self;
243     RUN demo.scale_self;
244     END scale_self;
245     METHOD scale_all;
246     RUN demo.scale_all;
247     END scale_all;
248     METHOD bound_self;
249     RUN demo.bound_self;
250     END bound_self;
251     METHOD bound_all;
252     RUN demo.bound_all;
253     END bound_all;
254    
255     METHOD specify;
256     RUN demo.specify;
257     END specify;
258    
259     METHOD values;
260     RUN demo.values;
261     END values;
262     METHOD reset_to_mass_balance;
263     RUN demo.Column.reset_to_mass_balance;
264     END reset_to_mass_balance;
265    
266     METHOD reset_to_full_thermo;
267     RUN demo.Column.reset_to_full_thermo;
268     END reset_to_full_thermo;
269    
270     METHOD reset_to_adiabatic;
271     RUN demo.Column.reset_to_adiabatic;
272     END reset_to_adiabatic;
273    
274     END testdemoplotmodel;
275    
276     MODEL mw_demo_plot_column() REFINES testdemoplotmodel();
277     demo IS_A demo_plot_column(['methanol','water'],'water',13,7);
278     END mw_demo_plot_column;
279    
280     MODEL abc_demo_plot_column() REFINES testdemoplotmodel();
281     demo IS_A
282     demo_plot_column(['benzene','chloroform','acetone'],'benzene',13,7);
283     END abc_demo_plot_column;
284    
285     MODEL c567_demo_plot_column() REFINES testdemoplotmodel();
286     demo IS_A
287     demo_plot_column(['n_pentane','n_hexane','n_heptane'],'n_heptane',13,7);
288     END c567_demo_plot_column;
289    
290    
291     (*
292     * plotcol.a4c
293     * by Benjamin A Allan
294     * Part of the ASCEND Library
295     * $Date: 1998/06/17 19:22:22 $
296     * $Revision: 1.3 $
297     * $Author: mthomas $
298     * $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/plotcol.a4c,v $
299     *
300     * This file is part of the ASCEND Modeling Library.
301     *
302     * Copyright (C) 1998 Carnegie Mellon University
303     * Copyright (C) 1997 Benjamin A Allan
304     *
305     * The ASCEND Modeling Library is free software; you can redistribute
306     * it and/or modify it under the terms of the GNU General Public
307     * License as published by the Free Software Foundation; either
308     * version 2 of the License, or (at your option) any later version.
309     *
310     * The ASCEND Modeling Library is distributed in hope that it
311     * will be useful, but WITHOUT ANY WARRANTY; without even the implied
312     * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
313     * See the GNU General Public License for more details.
314     *
315     * You should have received a copy of the GNU General Public License
316 jpye 2651 * along with this program. If not, see <http://www.gnu.org/licenses/>.
317 aw0a 1 *)

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