1 | #*--------------------------------------------------------------------- |
---|
2 | * This file is property of the author and cannot be used, copyed |
---|
3 | * or modified without permission. |
---|
4 | * |
---|
5 | * Copyright (C) 2002-2005 the author |
---|
6 | *---------------------------------------------------------------------- |
---|
7 | * Author: Rafael de Pelegrini Soares |
---|
8 | * $Id: sample_calc_object.mso 32 2006-09-23 00:16:00Z arge $ |
---|
9 | *---------------------------------------------------------------------- |
---|
10 | * |
---|
11 | * EMSO sample file for using CalcOjbects. |
---|
12 | * |
---|
13 | *-------------------------------------------------------------------*# |
---|
14 | |
---|
15 | using "types"; |
---|
16 | |
---|
17 | #**************************************************** |
---|
18 | * Model with some variables to be calculate further. |
---|
19 | * |
---|
20 | *# |
---|
21 | Model CalcBasic |
---|
22 | PARAMETERS |
---|
23 | ext NoComps as Integer; |
---|
24 | VARIABLES |
---|
25 | T as temperature; |
---|
26 | P as pressure; |
---|
27 | z(NoComps) as fraction; |
---|
28 | |
---|
29 | r1 as Real(Unit="K*K"); |
---|
30 | r2 as Real(Unit="atm*K"); |
---|
31 | r3 as Real; |
---|
32 | end |
---|
33 | |
---|
34 | #************************************************* |
---|
35 | * Model with a CalcObject for the calculations |
---|
36 | * |
---|
37 | *# |
---|
38 | Model Calc as CalcBasic |
---|
39 | PARAMETERS |
---|
40 | ext obj as CalcObject; |
---|
41 | |
---|
42 | EQUATIONS |
---|
43 | r1 = obj.method1(T, P); |
---|
44 | r2 = obj.method2(T, P); |
---|
45 | r3 = obj.method3(z); |
---|
46 | end |
---|
47 | |
---|
48 | |
---|
49 | #**************************************************** |
---|
50 | * Same as above but with the calculations |
---|
51 | * done by equations instead of external routines. |
---|
52 | * The results should be the same. |
---|
53 | *# |
---|
54 | Model Calc2 as CalcBasic |
---|
55 | EQUATIONS |
---|
56 | r1 = T^2; |
---|
57 | r2 = T*P; |
---|
58 | r3 = sum(z); |
---|
59 | end |
---|
60 | |
---|
61 | #******************************************************* |
---|
62 | * Checking if the results are the same for both |
---|
63 | * models (external calculations and explict equations). |
---|
64 | * |
---|
65 | * NOTE: IN ORDER TO RUN THIS EXAMPLE YOU NEED TO COMPILE |
---|
66 | * THE FILE calcsample.cpp IN YOUR INTERFACE DIRECTORY |
---|
67 | * |
---|
68 | *# |
---|
69 | FlowSheet CalcTest |
---|
70 | PARAMETERS |
---|
71 | obj as CalcObject(File = "calcsample"); |
---|
72 | NoComps as Integer(Default = 5); |
---|
73 | |
---|
74 | DEVICES |
---|
75 | calc1 as Calc; |
---|
76 | calc2 as Calc2; |
---|
77 | |
---|
78 | SPECIFY |
---|
79 | #calc1.T = 100 * "K"; |
---|
80 | #calc1.P = 100 * "Pa"; |
---|
81 | calc1.z(1:NoComps-1) = 1/NoComps; |
---|
82 | calc1.r1 = 20000 * "K*K"; |
---|
83 | calc1.r2 = 10000 * "Pa*K"; |
---|
84 | calc1.r3 = 1; |
---|
85 | |
---|
86 | #calc2.T = 100 * "K"; |
---|
87 | #calc2.P = 100 * "Pa"; |
---|
88 | calc2.z(1:NoComps-1) = 1/NoComps; |
---|
89 | calc2.r1 = 20000 * "K*K"; |
---|
90 | calc2.r2 = 10000 * "Pa*K"; |
---|
91 | calc2.r3 = 1; |
---|
92 | |
---|
93 | OPTIONS |
---|
94 | relativeAccuracy = 1e-6; |
---|
95 | #mode = "steady"; |
---|
96 | end |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | #******************************************************* |
---|
101 | * Checking the explict equations. |
---|
102 | *# |
---|
103 | FlowSheet Calc2Test |
---|
104 | PARAMETERS |
---|
105 | NoComps as Integer(Default = 5); |
---|
106 | |
---|
107 | DEVICES |
---|
108 | calc2 as Calc2; |
---|
109 | |
---|
110 | SPECIFY |
---|
111 | #calc2.T = 100 * "K"; |
---|
112 | #calc2.P = 100 * "Pa"; |
---|
113 | calc2.z(1:NoComps-1) = 1/NoComps; |
---|
114 | calc2.r1 = 20000 * "K*K"; |
---|
115 | calc2.r2 = 10000 * "Pa*K"; |
---|
116 | calc2.r3 = 1; |
---|
117 | |
---|
118 | OPTIONS |
---|
119 | relativeAccuracy = 1e-6; |
---|
120 | mode = "steady"; |
---|
121 | end |
---|
122 | |
---|