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

Contents of /trunk/models/ternary_plot.a4l

Parent Directory Parent Directory | Revision Log Revision Log


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

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