1 | #*------------------------------------------------------------------- |
---|
2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
3 | * |
---|
4 | * This LIBRARY is free software; you can distribute it and/or modify |
---|
5 | * it under the therms of the ALSOC FREE LICENSE as available at |
---|
6 | * http://www.enq.ufrgs.br/alsoc. |
---|
7 | * |
---|
8 | * EMSO Copyright (C) 2004 - 2007 ALSOC, original code |
---|
9 | * from http://www.rps.eng.br Copyright (C) 2002-2004. |
---|
10 | * All rights reserved. |
---|
11 | * |
---|
12 | * EMSO is distributed under the therms of the ALSOC LICENSE as |
---|
13 | * available at http://www.enq.ufrgs.br/alsoc. |
---|
14 | * |
---|
15 | *-------------------------------------------------------------------- |
---|
16 | * Sample file for for using CalcOjbects. |
---|
17 | *-------------------------------------------------------------------- |
---|
18 | * Author: Rafael de Pelegrini Soares |
---|
19 | * $Id: sample_calc_object.mso 248 2007-04-24 17:14:46Z bicca $ |
---|
20 | *------------------------------------------------------------------*# |
---|
21 | |
---|
22 | using "types"; |
---|
23 | |
---|
24 | #**************************************************** |
---|
25 | * Model with some variables to be calculate further. |
---|
26 | * |
---|
27 | *# |
---|
28 | Model CalcBasic |
---|
29 | PARAMETERS |
---|
30 | outer NoComps as Integer; |
---|
31 | VARIABLES |
---|
32 | T as temperature; |
---|
33 | P as pressure; |
---|
34 | z(NoComps) as fraction; |
---|
35 | |
---|
36 | r1 as Real(Unit='K*K'); |
---|
37 | r2 as Real(Unit='atm*K'); |
---|
38 | r3 as Real; |
---|
39 | end |
---|
40 | |
---|
41 | #************************************************* |
---|
42 | * Model with a CalcObject for the calculations |
---|
43 | * |
---|
44 | *# |
---|
45 | Model Calc as CalcBasic |
---|
46 | PARAMETERS |
---|
47 | outer obj as Plugin(Type="sample"); |
---|
48 | dummy as Real(Default=0); |
---|
49 | |
---|
50 | EQUATIONS |
---|
51 | r1 = obj.method1(T, dummy); |
---|
52 | r2 = obj.method2(T, P); |
---|
53 | r3 = obj.method3(z); |
---|
54 | end |
---|
55 | |
---|
56 | |
---|
57 | #**************************************************** |
---|
58 | * Same as above but with the calculations |
---|
59 | * done by equations instead of external routines. |
---|
60 | * The results should be the same. |
---|
61 | *# |
---|
62 | Model Calc2 as CalcBasic |
---|
63 | EQUATIONS |
---|
64 | r1 = T^2; |
---|
65 | r2 = T*P; |
---|
66 | r3 = sum(z); |
---|
67 | end |
---|
68 | |
---|
69 | #******************************************************* |
---|
70 | * Checking if the results are the same for both |
---|
71 | * models (external calculations and explict equations). |
---|
72 | * |
---|
73 | * NOTE: IN ORDER TO RUN THIS EXAMPLE YOU NEED TO COMPILE |
---|
74 | * THE FILE calcsample.cpp IN YOUR INTERFACE DIRECTORY. YOU MUST |
---|
75 | REGISTER YOUR PLUGIN CALLED "sample" IN THE EMSO PLUGINS CONFIGURATION AS WELL. |
---|
76 | * |
---|
77 | *# |
---|
78 | FlowSheet CalcTest |
---|
79 | PARAMETERS |
---|
80 | obj as Plugin(Type="sample"); |
---|
81 | NoComps as Integer(Default = 5); |
---|
82 | |
---|
83 | DEVICES |
---|
84 | calc1 as Calc; |
---|
85 | calc2 as Calc2; |
---|
86 | |
---|
87 | SPECIFY |
---|
88 | #calc1.T = 100 * 'K'; |
---|
89 | #calc1.P = 100 * 'Pa'; |
---|
90 | calc1.z(1:NoComps-1) = 1/NoComps; |
---|
91 | calc1.r1 = 20000 * 'K*K'; |
---|
92 | calc1.r2 = 10000 * 'Pa*K'; |
---|
93 | calc1.r3 = 1; |
---|
94 | |
---|
95 | #calc2.T = 100 * 'K'; |
---|
96 | #calc2.P = 100 * 'Pa'; |
---|
97 | calc2.z(1:NoComps-1) = 1/NoComps; |
---|
98 | calc2.r1 = 20000 * 'K*K'; |
---|
99 | calc2.r2 = 10000 * 'Pa*K'; |
---|
100 | calc2.r3 = 1; |
---|
101 | |
---|
102 | OPTIONS |
---|
103 | Dynamic = false; |
---|
104 | end |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | #******************************************************* |
---|
109 | * Checking the explict equations. |
---|
110 | *# |
---|
111 | FlowSheet Calc2Test |
---|
112 | PARAMETERS |
---|
113 | NoComps as Integer(Default = 5); |
---|
114 | |
---|
115 | DEVICES |
---|
116 | calc2 as Calc2; |
---|
117 | |
---|
118 | SPECIFY |
---|
119 | #calc2.T = 100 * 'K'; |
---|
120 | #calc2.P = 100 * 'Pa'; |
---|
121 | calc2.z(1:NoComps-1) = 1/NoComps; |
---|
122 | calc2.r1 = 20000 * 'K*K'; |
---|
123 | calc2.r2 = 10000 * 'Pa*K'; |
---|
124 | calc2.r3 = 1; |
---|
125 | |
---|
126 | OPTIONS |
---|
127 | Dynamic = false; |
---|
128 | end |
---|