/[ascend]/trunk/models/ternary_plot.a4l
ViewVC logotype

Annotation of /trunk/models/ternary_plot.a4l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 576 - (hide annotations) (download) (as text)
Tue May 9 03:42:08 2006 UTC (18 years, 1 month ago) by johnpye
File MIME type: text/x-ascend
File size: 14607 byte(s)
Changed all cases of *.fixed := {TRUE,FALSE} to 'FIX' and 'FREE' statements.
1 aw0a 1 REQUIRE "atoms.a4l";
2     (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
3     REQUIRE "plot.a4l";
4     (* => plot.a4l, atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
5     PROVIDE "ternary_plot.a4l";
6    
7     (*
8     * ternary_plot.a4l
9     * by Kenneth H. Tyner
10     * Part of the ASCEND Library
11     * $Date: 1998/06/17 19:32:35 $
12     * $Revision: 1.6 $
13     * $Author: mthomas $
14     * $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/ternary_plot.a4l,v $
15     *
16     * This file is part of the ASCEND Modeling Library.
17     *
18     * Copyright (C) 1997 Carnegie Mellon University
19     *
20     * The ASCEND Modeling Library is free software; you can redistribute
21     * it and/or modify it under the terms of the GNU General Public
22     * License as published by the Free Software Foundation; either
23     * version 2 of the License, or (at your option) any later version.
24     *
25     * The ASCEND Modeling Library is distributed in hope that it will be
26     * useful, but WITHOUT ANY WARRANTY; without even the implied
27     * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28     * See the GNU General Public License for more details.
29     *
30     * You should have received a copy of the GNU General Public License
31     * along with the program; if not, write to the Free Software
32     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check
33     * the file named COPYING.
34     *)
35    
36     (*
37     T E R N A R Y _ P L O T . A 4 L
38     -------------------------------
39    
40     AUTHOR: Kenneth H. Tyner
41    
42     DATES: 6/97 - First Public Release
43    
44    
45     CONTENTS: Ternary plots to complement distillation modeling.
46    
47    
48    
49    
50    
51     NOTES: These models useable but are still in a state of flux.
52     The parameter lists may change without notice!!!!
53     *)
54     MODEL ternary_plot_right_all(
55     components WILL_BE set OF symbol_constant;
56     npnts IS_A set OF integer_constant;
57     comp_data[components][npnts] WILL_BE real;
58     ) WHERE (
59     CARD[components] = 3;
60     );
61     (* make triangle *)
62     nt_points IS_A set OF integer_constant;
63     nt_points :== [0..3];
64     x_points[nt_points] IS_A real;
65     y_points[nt_points] IS_A real;
66     triangle IS_A plt_curve(nt_points,y_points,x_points);
67    
68     FOR i IN components CREATE
69     FOR j IN [components - [i]] CREATE
70     curve[i][j] IS_A
71     plt_curve(npnts,comp_data[i],comp_data[j]);
72     END FOR;
73     END FOR;
74     FOR i IN components CREATE
75     FOR j IN [components - [i]] CREATE
76     plots[i][j][plot_set[i][j]] ALIASES (
77     triangle, curve[i][j]
78     ) WHERE plot_set[i][j] IS_A set OF symbol_constant
79     WITH_VALUE ('triangle','profile');
80     END FOR;
81     END FOR;
82     FOR i IN components CREATE
83     FOR j IN [components - [i]] CREATE
84     plot[i][j] IS_A
85     plt_plot_symbol(plot_set[i][j],
86     plots[i][j]);
87     END FOR;
88     END FOR;
89    
90     METHODS
91     METHOD default_self;
92     x_points[0,2,3] := 0;
93     x_points[1] := 1;
94     y_points[0,1,3] := 0;
95     y_points[2] := 1;
96     FOR i IN components DO
97     FOR j IN [components - [i]] DO
98     plot[i][j].title := 'i vs j';
99     plot[i][j].YLabel := i;
100     plot[i][j].XLabel := j;
101     plot[i][j].Ylow := 0;
102     plot[i][j].Yhigh := 1;
103     END FOR;
104     END FOR;
105     END default_self;
106     METHOD default_all;
107     RUN default_self;
108     END default_all;
109     METHOD scale_self;
110     END scale_self;
111     METHOD scale_all;
112     RUN scale_self;
113     END scale_all;
114     METHOD bound_self;
115     END bound_self;
116     METHOD bound_all;
117     RUN bound_self;
118     END bound_all;
119     METHOD check_self;
120     END check_self;
121     METHOD check_all;
122     RUN check_self;
123     END check_all;
124     END ternary_plot_right_all;
125    
126     MODEL ternary_plot_equilateral_all(
127     components WILL_BE set OF symbol_constant;
128     npnts WILL_BE set OF integer_constant;
129     comp_data[components][npnts] WILL_BE real;
130     ) WHERE (
131     CARD[components] = 3;
132     );
133     (* make triangle *)
134    
135     tcomp1[0..58] IS_A fraction;
136     tcomp2[0..58] IS_A fraction;
137    
138     nt_points IS_A set OF integer_constant;
139     nt_points :== [0..58];
140     x_points[nt_points] IS_A fraction;
141     y_points[nt_points] IS_A fraction;
142     triangle IS_A plt_curve(nt_points,y_points,x_points);
143    
144    
145     x_comp_top[1..2][components][npnts] IS_A fraction;
146     y_comp_top[components][npnts] IS_A fraction;
147    
148     FOR i IN components CREATE
149     FOR j IN npnts CREATE
150     x_comp_top[1][i][j] = (comp_data[CHOICE[components - [i]]][j] +
151     comp_data[components - [i,CHOICE[components - [i]]]][j])/2;
152     x_comp_top[2][i][j] = 1 - x_comp_top[1][i][j];
153     y_comp_top[i][j] = 2 * abs(comp_data[CHOICE[components - [i]]][j]
154     - x_comp_top[1][i][j]);
155     END FOR;
156     END FOR;
157    
158     FOR i IN components CREATE
159     FOR j IN [1..2] CREATE
160     curve[i][j] IS_A
161     plt_curve(npnts,y_comp_top[i],x_comp_top[j][i]);
162     END FOR;
163     END FOR;
164    
165     FOR i IN components CREATE
166     FOR j IN [1..2] CREATE
167     plots[i][j][plot_set[i][j]] ALIASES (
168     triangle, curve[i][j]
169     ) WHERE plot_set[i][j] IS_A set OF symbol_constant
170     WITH_VALUE ('triangle','profile');
171     END FOR;
172     END FOR;
173     FOR i IN components CREATE
174     FOR j IN [1..2] CREATE
175     plot[i][j] IS_A
176     plt_plot_symbol(plot_set[i][j],
177     plots[i][j]);
178     END FOR;
179     END FOR;
180    
181     METHODS
182     METHOD default_self;
183 johnpye 576 FIX tcomp1[0..58];
184     FIX tcomp2[0..58];
185 aw0a 1
186     tcomp1[0] := 1;
187     tcomp2[0] := 0;
188     FOR i IN [1..5] DO
189     tcomp1[4*i-3] := 0;
190     tcomp1[4*i-3+1] := 0;
191     tcomp2[4*i-3] := tcomp1[4*i-3-1];
192     tcomp2[4*i-3+1] := tcomp2[4*i-3] - 0.1;
193     tcomp1[4*i-3+2] := tcomp2[4*i-3+1];
194     tcomp1[4*i-3+3] := tcomp1[4*i-3+2] - 0.1;
195     tcomp2[4*i-3+2] := 0;
196     tcomp2[4*i-3+3] := 0;
197     END FOR;
198    
199     FOR i IN [6..10] DO
200     tcomp2[4*i-3] := tcomp2[4*i-4] + 0.1;
201     tcomp2[4*i-3+1] := tcomp2[4*i-3];
202     tcomp2[4*i-3+2] := tcomp2[4*i-3+1] + 0.1;
203     tcomp2[4*i-3+3] := tcomp2[4*i-3+2];
204    
205     tcomp1[4*i-3] := 0;
206     tcomp1[4*i-3+1] := 1 - tcomp2[4*i-3+1];
207     tcomp1[4*i-3+2] := 1 - tcomp2[4*i-3+2];
208     tcomp1[4*i-3+3] := 0;
209     END FOR;
210     tcomp1[40] := 0.1;
211     tcomp2[40] := 0.9;
212     FOR i IN [10..14] DO
213     tcomp1[4*i+1] := tcomp1[4*i+1-1];
214     tcomp1[4*i+1+1] := tcomp1[4*i+1] + 0.1;
215     tcomp1[4*i+1+2] := tcomp1[4*i+1+1];
216     tcomp1[4*i+1+3] := tcomp1[4*i+1+2] + 0.1;
217     tcomp2[4*i+1] := 0;
218     tcomp2[4*i+1+1] := 0;
219     tcomp2[4*i+1+2] := 1 - tcomp1[4*i+1+2];
220     tcomp2[4*i+1+3] := 1 - tcomp1[4*i+1+3];
221     END FOR;
222     tcomp1[59..60] := 1;
223     tcomp2[59..60] := 0;
224     FOR i IN components DO
225     FOR j IN [1..2] DO
226     plot[i][j].title := 'i vs j';
227     plot[i][j].YLabel := i;
228     plot[i][j].XLabel := j;
229     plot[i][j].Ylow := 0;
230     plot[i][j].Yhigh := 1;
231     END FOR;
232     END FOR;
233    
234     FOR i IN nt_points DO
235     x_points[i] := (tcomp2[i] - tcomp1[i] + 1)/2;
236     y_points[i] := 2 * abs(tcomp2[i] - x_points[i]);
237     END FOR;
238    
239     END default_self;
240     METHOD default_all;
241     RUN default_self;
242     END default_all;
243     METHOD scale_self;
244     END scale_self;
245     METHOD scale_all;
246     RUN scale_self;
247     END scale_all;
248     METHOD bound_self;
249     END bound_self;
250     METHOD bound_all;
251     RUN bound_self;
252     END bound_all;
253     METHOD check_self;
254     END check_self;
255     METHOD check_all;
256     RUN check_self;
257     END check_all;
258    
259     END ternary_plot_equilateral_all;
260    
261     MODEL ternary_plot_right(
262     Title IS_A symbol_constant;
263     components WILL_BE set OF symbol_constant;
264     y_comp IS_A symbol_constant;
265     x_comp IS_A symbol_constant;
266     npnts IS_A set OF integer_constant;
267     comp_data[components][npnts] WILL_BE fraction;
268     ) WHERE (
269     CARD[components] = 3;
270     y_comp IN components == TRUE;
271     x_comp IN components == TRUE;
272     );
273     (* make triangle *)
274     nt_points IS_A set OF integer_constant;
275     nt_points :== [0..3];
276     x_points[nt_points] IS_A real;
277     y_points[nt_points] IS_A real;
278     triangle IS_A plt_curve(nt_points,y_points,x_points);
279    
280     curve IS_A
281     plt_curve(npnts,comp_data[y_comp],comp_data[x_comp]);
282    
283     plots[plot_set] ALIASES (
284     triangle, curve
285     ) WHERE plot_set IS_A set OF symbol_constant
286     WITH_VALUE ('triangle','profile');
287     plot IS_A
288     plt_plot_symbol(plot_set,
289     plots);
290    
291     METHODS
292     METHOD default_self;
293     x_points[0,2,3] := 0;
294     x_points[1] := 1;
295     y_points[0,1,3] := 0;
296     y_points[2] := 1;
297    
298     plot.title := Title;
299     plot.YLabel := y_comp;
300     plot.XLabel := x_comp;
301     plot.Ylow := 0;
302     plot.Yhigh := 1;
303     plot.Xlow := 0;
304     plot.Xhigh := 1;
305     plots['profile'].legend := 'profile';
306     plots['triangle'].legend := 'triangle';
307     END default_self;
308     METHOD default_all;
309     RUN default_self;
310     END default_all;
311     METHOD scale_self;
312     END scale_self;
313     METHOD scale_all;
314     RUN scale_self;
315     END scale_all;
316     METHOD bound_self;
317     END bound_self;
318     METHOD bound_all;
319     RUN bound_self;
320     END bound_all;
321     METHOD check_self;
322     END check_self;
323     METHOD check_all;
324     RUN check_self;
325     END check_all;
326     END ternary_plot_right;
327    
328     MODEL ternary_plot_equilateral(
329     Title IS_A symbol_constant;
330     components WILL_BE set OF symbol_constant;
331     left_comp IS_A symbol_constant;
332     right_comp IS_A symbol_constant;
333     npnts IS_A set OF integer_constant;
334     comp_data[components][npnts] WILL_BE fraction;
335     ) WHERE (
336     CARD[components] = 3;
337     left_comp IN components == TRUE;
338     right_comp IN components == TRUE;
339     );
340     (* make triangle *)
341    
342     tcomp1[0..60] IS_A fraction;
343     tcomp2[0..60] IS_A fraction;
344    
345     nt_points IS_A set OF integer_constant;
346     nt_points :== [0..60];
347     x_points[nt_points] IS_A fraction;
348     y_points[nt_points] IS_A fraction;
349     triangle IS_A plt_curve(nt_points,y_points,x_points);
350    
351     x_comp_eq[npnts] IS_A fraction;
352     y_comp_eq[npnts] IS_A fraction;
353    
354     FOR i IN npnts CREATE
355     x_comp_eq[i] = (comp_data[right_comp][i] -
356     comp_data[left_comp][i] + 1)/2;
357     y_comp_eq[i] = 2 * abs(comp_data[right_comp][i] - x_comp_eq[i]);
358     END FOR;
359    
360     curve IS_A
361     plt_curve(npnts,y_comp_eq,x_comp_eq);
362    
363     plots[plot_set] ALIASES (
364     triangle, curve
365     ) WHERE plot_set IS_A set OF symbol_constant
366     WITH_VALUE ('triangle','profile');
367    
368     plot IS_A
369     plt_plot_symbol(plot_set,
370     plots);
371    
372     METHODS
373     METHOD default_self;
374 johnpye 576 FIX tcomp1[0..58];
375     FIX tcomp2[0..58];
376 aw0a 1
377    
378     tcomp1[0] := 1;
379     tcomp2[0] := 0;
380     FOR i IN [1..5] DO
381     tcomp1[4*i-3] := 0;
382     tcomp1[4*i-3+1] := 0;
383     tcomp2[4*i-3] := tcomp1[4*i-3-1];
384     tcomp2[4*i-3+1] := tcomp2[4*i-3] - 0.1;
385     tcomp1[4*i-3+2] := tcomp2[4*i-3+1];
386     tcomp1[4*i-3+3] := tcomp1[4*i-3+2] - 0.1;
387     tcomp2[4*i-3+2] := 0;
388     tcomp2[4*i-3+3] := 0;
389     END FOR;
390    
391     FOR i IN [6..10] DO
392     tcomp2[4*i-3] := tcomp2[4*i-4] + 0.1;
393     tcomp2[4*i-3+1] := tcomp2[4*i-3];
394     tcomp2[4*i-3+2] := tcomp2[4*i-3+1] + 0.1;
395     tcomp2[4*i-3+3] := tcomp2[4*i-3+2];
396    
397     tcomp1[4*i-3] := 0;
398     tcomp1[4*i-3+1] := 1 - tcomp2[4*i-3+1];
399     tcomp1[4*i-3+2] := 1 - tcomp2[4*i-3+2];
400     tcomp1[4*i-3+3] := 0;
401     END FOR;
402     tcomp1[40] := 0.1;
403     tcomp2[40] := 0.9;
404     FOR i IN [10..14] DO
405     tcomp1[4*i+1] := tcomp1[4*i+1-1];
406     tcomp1[4*i+1+1] := tcomp1[4*i+1] + 0.1;
407     tcomp1[4*i+1+2] := tcomp1[4*i+1+1];
408     tcomp1[4*i+1+3] := tcomp1[4*i+1+2] + 0.1;
409     tcomp2[4*i+1] := 0;
410     tcomp2[4*i+1+1] := 0;
411     tcomp2[4*i+1+2] := 1 - tcomp1[4*i+1+2];
412     tcomp2[4*i+1+3] := 1 - tcomp1[4*i+1+3];
413     END FOR;
414     tcomp1[59..60] := 1;
415     tcomp2[59..60] := 0;
416     FOR i IN nt_points DO
417     x_points[i] := (tcomp2[i] - tcomp1[i] + 1)/2;
418     y_points[i] := 2 * abs(tcomp2[i] - x_points[i]);
419     END FOR;
420     plot.title := Title;
421     FOR i IN [components - [left_comp] - [right_comp]] DO
422     plot.YLabel := i;
423     END FOR;
424     plot.XLabel := right_comp;
425     plot.Ylow := 0;
426     plot.Yhigh := 1;
427     plot.Xlow := 0;
428     plot.Xhigh := 1;
429     plots['profile'].legend := 'profile';
430     plots['triangle'].legend := 'triangle';
431     END default_self;
432     METHOD default_all;
433     RUN default_self;
434     END default_all;
435     METHOD scale_self;
436     END scale_self;
437     METHOD scale_all;
438     RUN scale_self;
439     END scale_all;
440     METHOD bound_self;
441     END bound_self;
442     METHOD bound_all;
443     RUN bound_self;
444     END bound_all;
445     METHOD check_self;
446     END check_self;
447     METHOD check_all;
448     RUN check_self;
449     END check_all;
450     METHOD seqmod;
451 johnpye 576 FIX tcomp1[0..60];
452     FIX tcomp2[0..60];
453 aw0a 1 END seqmod;
454     METHOD reset;
455     RUN seqmod;
456 johnpye 576 FIX comp_data[components][npnts];
457 aw0a 1 END reset;
458     END ternary_plot_equilateral;
459    
460     MODEL ternary_plot_equilateral2(
461     Title IS_A symbol_constant;
462     components WILL_BE set OF symbol_constant;
463     left_comp IS_A symbol_constant;
464     right_comp IS_A symbol_constant;
465     curves IS_A set OF symbol_constant;
466     curve[curves] WILL_BE plt_curve;
467     ) WHERE (
468     CARD[components] = 3;
469     left_comp IN components == TRUE;
470     right_comp IN components == TRUE;
471     );
472     (* make triangle *)
473    
474     tcomp1[0..60] IS_A fraction;
475     tcomp2[0..60] IS_A fraction;
476    
477     nt_points IS_A set OF integer_constant;
478     nt_points :== [0..60];
479     x_points[nt_points] IS_A fraction;
480     y_points[nt_points] IS_A fraction;
481     triangle IS_A plt_curve(nt_points,y_points,x_points);
482    
483     plots[plot_set] ALIASES (
484     triangle, curve[curves]
485     ) WHERE plot_set IS_A set OF symbol_constant
486     WITH_VALUE ('triangle',curves);
487    
488     plot IS_A
489     plt_plot_symbol(plot_set,
490     plots);
491    
492     METHODS
493     METHOD default_self;
494 johnpye 576 FIX tcomp1[0..58];
495     FIX tcomp2[0..58];
496 aw0a 1
497    
498     tcomp1[0] := 1;
499     tcomp2[0] := 0;
500     FOR i IN [1..5] DO
501     tcomp1[4*i-3] := 0;
502     tcomp1[4*i-3+1] := 0;
503     tcomp2[4*i-3] := tcomp1[4*i-3-1];
504     tcomp2[4*i-3+1] := tcomp2[4*i-3] - 0.1;
505     tcomp1[4*i-3+2] := tcomp2[4*i-3+1];
506     tcomp1[4*i-3+3] := tcomp1[4*i-3+2] - 0.1;
507     tcomp2[4*i-3+2] := 0;
508     tcomp2[4*i-3+3] := 0;
509     END FOR;
510    
511     FOR i IN [6..10] DO
512     tcomp2[4*i-3] := tcomp2[4*i-4] + 0.1;
513     tcomp2[4*i-3+1] := tcomp2[4*i-3];
514     tcomp2[4*i-3+2] := tcomp2[4*i-3+1] + 0.1;
515     tcomp2[4*i-3+3] := tcomp2[4*i-3+2];
516    
517     tcomp1[4*i-3] := 0;
518     tcomp1[4*i-3+1] := 1 - tcomp2[4*i-3+1];
519     tcomp1[4*i-3+2] := 1 - tcomp2[4*i-3+2];
520     tcomp1[4*i-3+3] := 0;
521     END FOR;
522     tcomp1[40] := 0.1;
523     tcomp2[40] := 0.9;
524     FOR i IN [10..14] DO
525     tcomp1[4*i+1] := tcomp1[4*i+1-1];
526     tcomp1[4*i+1+1] := tcomp1[4*i+1] + 0.1;
527     tcomp1[4*i+1+2] := tcomp1[4*i+1+1];
528     tcomp1[4*i+1+3] := tcomp1[4*i+1+2] + 0.1;
529     tcomp2[4*i+1] := 0;
530     tcomp2[4*i+1+1] := 0;
531     tcomp2[4*i+1+2] := 1 - tcomp1[4*i+1+2];
532     tcomp2[4*i+1+3] := 1 - tcomp1[4*i+1+3];
533     END FOR;
534     tcomp1[59..60] := 1;
535     tcomp2[59..60] := 0;
536     FOR i IN nt_points DO
537     x_points[i] := (tcomp2[i] - tcomp1[i] + 1)/2;
538     y_points[i] := 2 * abs(tcomp2[i] - x_points[i]);
539     END FOR;
540     plot.title := Title;
541     FOR i IN [components - [left_comp] - [right_comp]] DO
542     plot.YLabel := i;
543     END FOR;
544     plot.XLabel := right_comp;
545     plot.Ylow := 0;
546     plot.Yhigh := 1;
547     plot.Xlow := 0;
548     plot.Xhigh := 1;
549     FOR j IN curves DO
550     plots[j].legend := j;
551     END FOR;
552     plots['triangle'].legend := 'triangle';
553    
554     END default_self;
555     METHOD default_all;
556     RUN default_self;
557     END default_all;
558     METHOD scale_self;
559     END scale_self;
560     METHOD scale_all;
561     RUN scale_self;
562     END scale_all;
563     METHOD bound_self;
564     END bound_self;
565     METHOD bound_all;
566     RUN bound_self;
567     END bound_all;
568     METHOD check_self;
569     END check_self;
570     METHOD check_all;
571     RUN check_self;
572     END check_all;
573     METHOD values;
574     END values;
575     METHOD seqmod;
576 johnpye 576 FIX tcomp1[0..60];
577     FIX tcomp2[0..60];
578 aw0a 1 END seqmod;
579     END ternary_plot_equilateral2;

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