source: mso/sample/miscellaneous/sample_calc_object.mso @ 2

Last change on this file since 2 was 2, checked in by Rafael de Pelegrini Soares, 16 years ago

Added comment on sample_calc_object.mso

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
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 2 2006-06-20 17:36:02Z rafael $
9*----------------------------------------------------------------------
10*
11* EMSO sample file for using CalcOjbects.
12*
13*-------------------------------------------------------------------*#
14
15using "types";
16
17#****************************************************
18* Model with some variables to be calculate further.
19*
20*#
21Model CalcBasic
22        PARAMETERS
23ext 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;
32end
33
34#*************************************************
35* Model with a CalcObject for the calculations
36*
37*#
38Model Calc as CalcBasic
39        PARAMETERS
40ext     obj as CalcObject;
41
42        EQUATIONS
43        r1 = obj.method1(T, P);
44        r2 = obj.method2(T, P);
45        r3 = obj.method3(z);
46end
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*#
54Model Calc2 as CalcBasic
55        EQUATIONS
56        r1 = T^2;
57        r2 = T*P;
58        r3 = sum(z);
59end
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*#
69FlowSheet 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        outputLevel = "all";
95        relativeAccuracy = 1e-6;
96        #mode = "steady";
97end
98
99
100
101#*******************************************************
102* Checking the explict equations.
103*#
104FlowSheet Calc2Test
105        PARAMETERS
106        NoComps as Integer(Default = 5);
107       
108        DEVICES
109        calc2   as Calc2;
110       
111        SPECIFY
112        #calc2.T = 100 * "K";
113        #calc2.P = 100 * "Pa";
114        calc2.z(1:NoComps-1) = 1/NoComps;
115        calc2.r1 = 20000 * "K*K";
116        calc2.r2 = 10000 * "Pa*K";
117        calc2.r3 = 1;
118       
119        OPTIONS
120        outputLevel = "all";
121        relativeAccuracy = 1e-6;
122        mode = "steady";
123end
124
Note: See TracBrowser for help on using the repository browser.