source: trunk/sample/miscellaneous/sample_calc_object.mso @ 494

Last change on this file since 494 was 248, checked in by gerson bicca, 16 years ago

Updated solver options for the new language

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
RevLine 
[83]1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
[1]3*
[83]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*--------------------------------------------------------------------
[1]18* Author: Rafael de Pelegrini Soares
19* $Id: sample_calc_object.mso 248 2007-04-24 17:14:46Z bicca $
[83]20*------------------------------------------------------------------*#
[1]21
22using "types";
23
24#****************************************************
25* Model with some variables to be calculate further.
26*
27*#
28Model CalcBasic
29        PARAMETERS
[176]30outer NoComps as Integer;
[1]31        VARIABLES
32        T    as temperature;
33        P    as pressure;
34        z(NoComps) as fraction;
35       
[176]36        r1 as Real(Unit='K*K');
37        r2 as Real(Unit='atm*K');
[1]38        r3 as Real;
39end
40
41#*************************************************
42* Model with a CalcObject for the calculations
43*
44*#
45Model Calc as CalcBasic
46        PARAMETERS
[217]47outer obj as Plugin(Type="sample");
48        dummy as Real(Default=0);
49       
[1]50        EQUATIONS
[217]51        r1 = obj.method1(T, dummy);
[1]52        r2 = obj.method2(T, P);
53        r3 = obj.method3(z);
54end
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*#
62Model Calc2 as CalcBasic
63        EQUATIONS
64        r1 = T^2;
65        r2 = T*P;
66        r3 = sum(z);
67end
68
69#*******************************************************
70* Checking if the results are the same for both
71* models (external calculations and explict equations).
[2]72*
73* NOTE: IN ORDER TO RUN THIS EXAMPLE YOU NEED TO COMPILE
[248]74* THE FILE calcsample.cpp IN YOUR INTERFACE DIRECTORY. YOU MUST
75REGISTER YOUR PLUGIN CALLED     "sample" IN THE EMSO PLUGINS CONFIGURATION AS WELL.
[2]76*
[1]77*#
78FlowSheet CalcTest
79        PARAMETERS
[217]80        obj     as Plugin(Type="sample");
[1]81        NoComps as Integer(Default = 5);
[217]82
[1]83        DEVICES
84        calc1   as Calc;
85        calc2   as Calc2;
86       
87        SPECIFY
[176]88        #calc1.T = 100 * 'K';
89        #calc1.P = 100 * 'Pa';
[1]90        calc1.z(1:NoComps-1) = 1/NoComps;
[176]91        calc1.r1 = 20000 * 'K*K';
92        calc1.r2 = 10000 * 'Pa*K';
[1]93        calc1.r3 = 1;
94       
[176]95        #calc2.T = 100 * 'K';
96        #calc2.P = 100 * 'Pa';
[1]97        calc2.z(1:NoComps-1) = 1/NoComps;
[176]98        calc2.r1 = 20000 * 'K*K';
99        calc2.r2 = 10000 * 'Pa*K';
[1]100        calc2.r3 = 1;
101
102        OPTIONS
[217]103        Dynamic = false;
[1]104end
105
106
107
108#*******************************************************
109* Checking the explict equations.
110*#
111FlowSheet Calc2Test
112        PARAMETERS
113        NoComps as Integer(Default = 5);
114       
115        DEVICES
116        calc2   as Calc2;
117       
118        SPECIFY
[176]119        #calc2.T = 100 * 'K';
120        #calc2.P = 100 * 'Pa';
[1]121        calc2.z(1:NoComps-1) = 1/NoComps;
[176]122        calc2.r1 = 20000 * 'K*K';
123        calc2.r2 = 10000 * 'Pa*K';
[1]124        calc2.r3 = 1;
125       
126        OPTIONS
[176]127        Dynamic = false;
[1]128end
Note: See TracBrowser for help on using the repository browser.