= Plugin - External Calculation Objects = [wiki:EMSO] is an equation-based tool, therefore most type of mathematical relations can be expressed directly as equations, using its modeling language. However, there are some cases in which using equations is barely convenient. Typical examples include: * The relationship cannot be expressed in a closed algebraic form without introducing many intermediate quantities with no physical sense; * The relationship requires lots of data parameters; * Already exists well established software that provides the required calculation; * It is difficult to converge the problem without decoupling the system. Exactly for the above cases, EMSO provides a mechanism where the user can ''plug'' code written in C, C++, or FORTRAN into the models. == Using a Plugin's == In order to ''plug'' external calculation code into the models the user needs to declare a ''special'' parameter, a Plugin: {{{ #!mso Model streamPH as stream PARAMETERS outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); VARIABLES x(NComp) as fraction(Brief = "Liquid Molar Fraction"); y(NComp) as fraction(Brief = "Vapour Molar Fraction"); EQUATIONS "Flash Calculation" [v, x, y] = PP.FlashPH(P, h, z); "Enthalpy" h = (1-v)*PP.LiquidEnthalpy(T, P, x) + v*PP.VapourEnthalpy(T, P, y); end }}} In the above example (see [../browser/trunk/eml/streams.mso streams.mso]), the parameter '''PP''' is the Plugin. == Plugin Methods == Once the Plugin was declared, the user can '''call''' its methods. Methods can have arguments and are called using the '''dot''' notation, eg: {{{ #!mso PP.LiquidEnthalpy(T, P, z) }}} In the above '''call''' three arguments are supplied: T, P, and z. Before running a simulation, EMSO will check if all methods used in models actually were implemented by the Plugin. EMSO also check if the number of arguments and its units of measurement are correct.