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

Last change on this file since 107 was 83, checked in by Paula Bettio Staudt, 16 years ago

Updated miscelaneous sample files header

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
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 83 2006-12-08 20:29:34Z paula $
20*------------------------------------------------------------------*#
21
22using "types";
23
24#****************************************************
25* Model with some variables to be calculate further.
26*
27*#
28Model CalcBasic
29        PARAMETERS
30ext 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;
39end
40
41#*************************************************
42* Model with a CalcObject for the calculations
43*
44*#
45Model Calc as CalcBasic
46        PARAMETERS
47ext     obj as CalcObject;
48
49        EQUATIONS
50        r1 = obj.method1(T, P);
51        r2 = obj.method2(T, P);
52        r3 = obj.method3(z);
53end
54
55
56#****************************************************
57* Same as above but with the calculations
58* done by equations instead of external routines.
59* The results should be the same.
60*#
61Model Calc2 as CalcBasic
62        EQUATIONS
63        r1 = T^2;
64        r2 = T*P;
65        r3 = sum(z);
66end
67
68#*******************************************************
69* Checking if the results are the same for both
70* models (external calculations and explict equations).
71*
72* NOTE: IN ORDER TO RUN THIS EXAMPLE YOU NEED TO COMPILE
73* THE FILE calcsample.cpp IN YOUR INTERFACE DIRECTORY
74*
75*#
76FlowSheet CalcTest
77        PARAMETERS
78        obj     as CalcObject(File = "calcsample");
79        NoComps as Integer(Default = 5);
80       
81        DEVICES
82        calc1   as Calc;
83        calc2   as Calc2;
84       
85        SPECIFY
86        #calc1.T = 100 * "K";
87        #calc1.P = 100 * "Pa";
88        calc1.z(1:NoComps-1) = 1/NoComps;
89        calc1.r1 = 20000 * "K*K";
90        calc1.r2 = 10000 * "Pa*K";
91        calc1.r3 = 1;
92       
93        #calc2.T = 100 * "K";
94        #calc2.P = 100 * "Pa";
95        calc2.z(1:NoComps-1) = 1/NoComps;
96        calc2.r1 = 20000 * "K*K";
97        calc2.r2 = 10000 * "Pa*K";
98        calc2.r3 = 1;
99
100        OPTIONS
101        relativeAccuracy = 1e-6;
102        #mode = "steady";
103end
104
105
106
107#*******************************************************
108* Checking the explict equations.
109*#
110FlowSheet Calc2Test
111        PARAMETERS
112        NoComps as Integer(Default = 5);
113       
114        DEVICES
115        calc2   as Calc2;
116       
117        SPECIFY
118        #calc2.T = 100 * "K";
119        #calc2.P = 100 * "Pa";
120        calc2.z(1:NoComps-1) = 1/NoComps;
121        calc2.r1 = 20000 * "K*K";
122        calc2.r2 = 10000 * "Pa*K";
123        calc2.r3 = 1;
124       
125        OPTIONS
126        relativeAccuracy = 1e-6;
127        mode = "steady";
128end
129
Note: See TracBrowser for help on using the repository browser.