Objective
This article provides a comprehensive list of mathematical functions that can be utilized in building subexpressions for the Calculator Functionality and Optimizer in OLI Flowsheet: ESP. Additionally, it outlines the rules for definition naming conventions within OLI.
Disclaimer: The Calculator Functionality is only available in Version 12 of OLI Flowsheet: ESP. The list of functions below was accurate at the time of publication of this article; some functions may be deprecated or unsupported in future versions.
Common Mathematical Functions
The mathematical functions used in defining subexpressions for the Calculator Functionality and Optimizer are derived from the Lua programming language. Below is a list of common Lua mathematical functions supported by OLI.
Mathematical functions | Uses |
math.abs(x) | Return the absolute, or non-negative value of x. |
math.exp(x) | Returns the value e^x. |
x^y | Returns x to the power of y. |
math.sqrt(x) | Returns the square root of x, you can also use the expression x^0.5 to compute this value. |
math.log(x) | Returns the natural logarithm of x. |
math.log(x,10) | Returns the base-10 logarithm of x. |
math.pi | Returns the value of PI. |
math.ceil(x) | Returns the smallest integer larger than or equal to x. |
math.floor(x) | Returns the largest integer smaller than or equal to x. |
math.fmod(x, y) | Returns the remainder of the division of x by y that rounds the quotient towards zero. |
math.max(x, …) | Returns the maximum value among its arguments. |
math.min(x, …) | Returns the minimum value among its arguments. |
math.sin(x) | Returns the sine of x (assumed to be in radians). |
math.cos(x) | Returns the cosine of x (assumed to be in radians). |
math.tan(x) | Returns the tangent of x (assumed to be in radians). |
math.asin(x) | Returns the arcsine of x (in radians). |
math.acos(x) | Returns the arccosine of x (in radians). |
math.atan(x) | Returns the arctangent of x (in radians). |
math.deg(x) | Returns the angle x (given in radians) in degrees. |
math.rad(x) | Returns the angle x (given in degrees) in radians. |
Definition Naming Rules in the Calculator Functionality and Optimizer
- Names should not contain spaces (e.g., Calculated pH)
- Names should not start with numbers (e.g., 123ABC)
- Names consisting only of numbers are not allowed (e.g., 007)
- Avoid using special characters (e.g., XYZ(6), XYZ$)
- Avoid using “+”, “-“, “*” in names (e.g., XYZ-6, Calculated-pH)
- Names with underscores are acceptable (e.g., Calculated_pH)
- Names can start with an underscore (e.g., _XYZ)
Example: Leveraging Mathematical Functions in the Calculator Block
The image below demonstrates how to use the “math.sqrt()” function within the Calculator Block.
First, index into the calculated pH property for the “Outlet” stream and label it as “calc_pH.” Then, define the subexpression for the square root of the pH, label it as “sqrt_pH” in accordance with the naming rules outlined above, and set its value as “math.sqrt(calc_pH)” as shown below.
Outcomes
In this article, we reviewed the available mathematical functions and naming conventions for building subexpressions in the Calculator Functionality and Optimizer in OLI Flowsheet: ESP. This information is essential for ensuring accurate and efficient use of the tool's capabilities.