#*--------------------------------------------------------------------- * This file is property of the author and cannot be used, copyed * or modified without permission. * * Copyright (C) 2002-2005 the author *---------------------------------------------------------------------- * Author: Rafael de Pelegrini Soares * $Id: sample_calc_object.mso 2 2006-06-20 17:36:02Z rafael $ *---------------------------------------------------------------------- * * EMSO sample file for using CalcOjbects. * *-------------------------------------------------------------------*# using "types"; #**************************************************** * Model with some variables to be calculate further. * *# Model CalcBasic PARAMETERS ext 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 ext obj as CalcObject; EQUATIONS r1 = obj.method1(T, P); 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 * *# FlowSheet CalcTest PARAMETERS obj as CalcObject(File = "calcsample"); 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 outputLevel = "all"; relativeAccuracy = 1e-6; #mode = "steady"; 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 outputLevel = "all"; relativeAccuracy = 1e-6; mode = "steady"; end