====== Expression ====== The expression block can be used to specify an arbitrary function of the model [[Parameter|parameters]] and /or the quantity in other blocks (such as [[Compartment|compartments]] and [[Lookup_table|lookup tables]]. The value of this block is available for use during the simulations. ===== Creating an expression ===== From the [[Projects_window|Projects window]] * Expand the Project to which you wish to add the expression by clicking the + symbol next to it. Right-click on ‘Blocks’, or a [[Sub-system|sub-system]] in ‘Blocks’, and select **Expression** from the pop-up menu. From the [[Matrix_window|Matrix window]] * Right click an empty diagonal cell of the matrix and select **Expression** from the the pop-up menu. From the [[Blocks_window|Blocks window]] * Place the mouse cursor over the table and right-click on it. Select **Create | Expression** from the pop-up menu, //or// * In the title bar, select **Expression** from the **Type** drop-down list and click on the {{:New24.png|New}} button. ===== Editing an expression ===== |Note|Most block properties can be edited directly in the [[Blocks_window|blocks window]].| The block editor is shown by right-clicking the block in a window and selecting **Edit**. In the [[Blocks_window|Blocks window]], you can also show the block editor by selecting the block and clicking the {{:Edit24.png|Edit}} button, or by double-clicking the right-most “validation” column of the block. The block editor has three tabs: ==== Properties ==== This page lets you edit basic properties such as name, sub-system and base unit. See [[Editing_properties|editing properties]] for more information. By clicking ** Settings** button **Evaluation mode** is available. **Evaluation mode** allows the user to specify when, during simulation, the expression is evaluated. ==== Appearance ==== This page lets you edit the visual properties of the block in the [[Matrix_window|matrix window]] and [[Graph_window|graph window]]. See [[Editing_appearance|editing appearance]] for more information. ==== Values ==== |Note|When entering an expression, you can also enter names of objects that are not yet created and let Ecolego use [[Automatic_object_creation|automatic object creation]] to define them.| This page lets you specify the algebraich expression and other index specific properties. See [[Editing_values|Editing values]] for more information. **Dimension** - You can specify the dimension of the block by using the **Type** drop down list. Depending on the dimension the index drop down lists are activated. **Data** * **//Indices//** - For blocks that are non-scalar, the first columns will specify indices from the [[Index_list|index lists]]. This allows you to specify different expressions for different indices. The top row is named “default” and can be used when the same value should be set for all indices. * **Expression** - The expression can contain any number of [[Parameter|parameters]], [[Block|blocks]] and [[Function|functions]]. The [[Expression_editing_tool|Expression editing tool]] can be used to quickly find available functions and objects to use in the expression. Also refer to [[Expression_syntax|expression syntax]] for details on mathematical format and how to specify conditions. * **Information** - By using the [[Table_control_button|Table control button]] {{:tablecontrol.png}} you can display more columns that will help you document your model. * **Arguments** - Used to define arguments that should be sent to the expression (see below). ===== Arguments ===== In some situations it is useful to require [[Argument|arguments]] to be sent to the expression. These arguments then be used in the equation, together with parameters and other blocks. The expressions then becomes a function, and will only be used as an “abstract”. * Arguments allow you to define an equation in one place, to be used in many places using different parameters. * An expression for which arguments have been defined will never be available as a simulation result. ==== Defining arguments ==== Use the right-hand side table to add (or remove arguments. Click in the table fields to change argument names or to write descriptions for the arguments. ==== Using arguments ==== Once an argument has been added, you can use it in the equations of the expressions. ==== Calling an expression with arguments ==== You reference an expression by writing the name (or [[ID|ID]]) of the expression. If the expression requires arguments, you also add parenthesis and a comma-separated list of argument values - like with any function. Examples: * For an expression named MyExpression, which takes two arguments: MyExpression( 134.2, time/2 ) * Calling the equation for Lead defined in a [[Material|material]] dependent expression which requires one argument: AnotherExpression[Lead]( 432.2 ) ===== See also ===== * [[Block|Blocks]] * [[Blocks_window|Blocks window]] * [[Matrix_window|Matrix window]] * [[Graph_window|Graph window]]