#*------------------------------------------------------------------- * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. * * This LIBRARY is free software; you can distribute it and/or modify * it under the therms of the ALSOC FREE LICENSE as available at * http://www.enq.ufrgs.br/alsoc. * * EMSO Copyright (C) 2004 - 2007 ALSOC, original code * from http://www.rps.eng.br Copyright (C) 2002-2004. * All rights reserved. * * EMSO is distributed under the therms of the ALSOC LICENSE as * available at http://www.enq.ufrgs.br/alsoc. * *-------------------------------------------------------------------- * Sample file for for using CalcOjbects. *-------------------------------------------------------------------- * Author: Rafael de Pelegrini Soares * $Id: sample_calc_object.mso 248 2007-04-24 17:14:46Z bicca $ *------------------------------------------------------------------*# using "types"; #**************************************************** * Model with some variables to be calculate further. * *# Model CalcBasic PARAMETERS outer NoComps as Integer; VARIABLES T as temperature; P as pressure; z(NoComps) as fraction; r1 as Real(Unit='K*K'); r2 as Real(Unit='atm*K'); r3 as Real; end #************************************************* * Model with a CalcObject for the calculations * *# Model Calc as CalcBasic PARAMETERS outer obj as Plugin(Type="sample"); dummy as Real(Default=0); EQUATIONS r1 = obj.method1(T, dummy); r2 = obj.method2(T, P); r3 = obj.method3(z); end #**************************************************** * Same as above but with the calculations * done by equations instead of external routines. * The results should be the same. *# Model Calc2 as CalcBasic EQUATIONS r1 = T^2; r2 = T*P; r3 = sum(z); end #******************************************************* * Checking if the results are the same for both * models (external calculations and explict equations). * * NOTE: IN ORDER TO RUN THIS EXAMPLE YOU NEED TO COMPILE * THE FILE calcsample.cpp IN YOUR INTERFACE DIRECTORY. YOU MUST REGISTER YOUR PLUGIN CALLED "sample" IN THE EMSO PLUGINS CONFIGURATION AS WELL. * *# FlowSheet CalcTest PARAMETERS obj as Plugin(Type="sample"); NoComps as Integer(Default = 5); DEVICES calc1 as Calc; calc2 as Calc2; SPECIFY #calc1.T = 100 * 'K'; #calc1.P = 100 * 'Pa'; calc1.z(1:NoComps-1) = 1/NoComps; calc1.r1 = 20000 * 'K*K'; calc1.r2 = 10000 * 'Pa*K'; calc1.r3 = 1; #calc2.T = 100 * 'K'; #calc2.P = 100 * 'Pa'; calc2.z(1:NoComps-1) = 1/NoComps; calc2.r1 = 20000 * 'K*K'; calc2.r2 = 10000 * 'Pa*K'; calc2.r3 = 1; OPTIONS Dynamic = false; end #******************************************************* * Checking the explict equations. *# FlowSheet Calc2Test PARAMETERS NoComps as Integer(Default = 5); DEVICES calc2 as Calc2; SPECIFY #calc2.T = 100 * 'K'; #calc2.P = 100 * 'Pa'; calc2.z(1:NoComps-1) = 1/NoComps; calc2.r1 = 20000 * 'K*K'; calc2.r2 = 10000 * 'Pa*K'; calc2.r3 = 1; OPTIONS Dynamic = false; end