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

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

Initial import of the library

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 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 1 2006-06-20 17:33:53Z 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*#
65FlowSheet CalcTest
66        PARAMETERS
67        obj     as CalcObject(File = "calcsample");
68        NoComps as Integer(Default = 5);
69       
70        DEVICES
71        calc1   as Calc;
72        calc2   as Calc2;
73       
74        SPECIFY
75        #calc1.T = 100 * "K";
76        #calc1.P = 100 * "Pa";
77        calc1.z(1:NoComps-1) = 1/NoComps;
78        calc1.r1 = 20000 * "K*K";
79        calc1.r2 = 10000 * "Pa*K";
80        calc1.r3 = 1;
81       
82        #calc2.T = 100 * "K";
83        #calc2.P = 100 * "Pa";
84        calc2.z(1:NoComps-1) = 1/NoComps;
85        calc2.r1 = 20000 * "K*K";
86        calc2.r2 = 10000 * "Pa*K";
87        calc2.r3 = 1;
88
89        OPTIONS
90        outputLevel = "all";
91        relativeAccuracy = 1e-6;
92        #mode = "steady";
93end
94
95
96
97#*******************************************************
98* Checking the explict equations.
99*#
100FlowSheet Calc2Test
101        PARAMETERS
102        NoComps as Integer(Default = 5);
103       
104        DEVICES
105        calc2   as Calc2;
106       
107        SPECIFY
108        #calc2.T = 100 * "K";
109        #calc2.P = 100 * "Pa";
110        calc2.z(1:NoComps-1) = 1/NoComps;
111        calc2.r1 = 20000 * "K*K";
112        calc2.r2 = 10000 * "Pa*K";
113        calc2.r3 = 1;
114       
115        OPTIONS
116        outputLevel = "all";
117        relativeAccuracy = 1e-6;
118        mode = "steady";
119end
120
Note: See TracBrowser for help on using the repository browser.