- Function Definition
Functions are defined in one or more Python module files.
Python modules must be placed in a user-created Modules subdirectory in System Coupling's working directory.
Defined functions added to the coupled analysis are available for use in expressions.
Function names referenced in expressions may be different than the Python names of the functions.
Function arguments referenced in an expression are dimensionless and return dimensionless values.
- Function Validation
Expression modules and functions must follow Python's syntax and naming rules.
Expression function parameters must be unique within the analysis.
The number of arguments passed to a function in an expression must match the number of parameters defined for the function.
Functions are expected always to return the same value for given argument values.
A function that is called with no arguments, or with arguments that do not depend on any variables, is assumed to return an immutable value and may be referenced in an expression that resolves to an immutable value.
Inconsistencies between modules and expression definitions may cause validation errors. For more information, see Reloading Expression Function Modules.
- Function Evaluation
If a function does not reference any variables in its arguments (or has no arguments), then the expression is treated as if it is returning an immutable value. As such, it can be referenced in expressions resolving to an immutable value and will be evaluated at least once per solve.
If a function references a variable in its arguments, it will be called when the variable value updates (per iteration for iteration-based analyses or per step for step-based analyses).