Equation Functions
- Last UpdatedJun 12, 2025
- 6 minute read
The following table describes some of the basic mathematical functions used by equations. If applicable, select the functions for additional information about each one.
|
Function |
Description |
Example |
|---|---|---|
|
abs(var) |
Returns the absolute value of var. |
x = abs(y) |
|
arcsin(var) |
Returns the inverse sine in radians of var. |
theta = arcsin(y) |
|
arccos(var) |
Returns the inverse cosine in radians of var. |
theta = arccos(x) |
|
arctan(var) |
Returns the inverse tangent in radians of var. |
theta = arctan(x/y) |
|
cos(var) |
Returns the cosine of var with var in radians. |
x = cos(theta) |
|
der(array) |
Creates a series of time derivative equations from an array variable dimensioned by fluidtype.complist. |
der(M) = fin*Zin - fout*Zout |
|
der(var) |
Creates an internal time derivative equation for var. |
der(M) = fin - fout |
|
exp(var) |
Returns the exponential value of var. |
x = exp(y) |
|
FSqrt(var,clip) |
Returns a square root of var for reverse flow calculations. If var is negative, the FSqrt returns a negative value. Returns a linear value if var is less than clip. |
y = FSqrt(P1-P2, 0.001) |
|
ln(var) |
Returns the natural logarithm of var. |
y = ln(x) |
|
log10(var) |
Returns the base 10 logarithm of var. |
y = log10(x) |
|
max(var1,var2) |
Returns the larger of var1 and var2. The arguments can be a variable, real parameter, or number value. This function uses the first argument as the default value. When the var1 and var2 values approach the same value, this function returns var1. If you use this function to compare a variable value to a constant value, you should always use the variable as the first argument. Otherwise, as the variable value approaches the constant value, the function uses the constant value instead of the variable, even for calculating derivatives. In this case, the solver interprets the constant value as a fixed constraint instead of a changeable, calculated value and may struggle to find a solution. |
y = max(var1, 4) |
|
max(array1) |
Returns the value of the largest array element. |
y = max(array1) |
|
max(array1, var1) |
Returns an array the size of array1, where every element is the larger of the array element or the scalar value var1. Var1 can be a variable, a real parameter, or a number value. This function uses the first argument as the default value. When the array1 and var1 values approach the same value, this function returns var1. If you use this function to compare array values to a constant value, you should always use the array as the first argument. Otherwise, as the array values approach the constant value, the function uses the constant value instead of the array elements, even for calculating values. In this case, the solver interprets the constant value as a fixed constraint instead of a changeable, calculated value and may struggle to find a solution. |
Ff = max(F, 0) |
|
min(var1,var2) |
Returns the smaller of var1 and var2 or a number value. The arguments can be a variable, real parameter, or number value. If you use this function to compare a variable value to a constant value, you should always use the variable as the first argument. Otherwise, as the variable value approaches the constant value, the function uses the constant value instead of the variable, even for calculating derivatives. In this case, the solver interprets the constant value as a fixed constraint instead of a changeable, calculated value and may struggle to find a solution. |
y = min(var1, par1) |
|
min(array1) |
Returns the value of the smallest array element. |
y = min(array1) |
|
min(array1, var1) |
Returns an array the size of array1, where every element is the smaller of the array element or the scalar value var1. Var1 can be a variable, a real parameter, or a number value. This function uses the first argument as the default value. When the array1 and var1 values approach the same value, this function returns var1. If you use this function to compare array values to a constant value, you should always use the array as the first argument. Otherwise, as the array values approach the constant value, the function uses the constant value instead of the array elements, even for calculating values. In this case, the solver interprets the constant value as a fixed constraint instead of a changeable, calculated value and may struggle to find a solution. |
Fr = min(F, 0) |
|
select(x,v1,v2) |
Returns v1 if x is greater than or equal to 0. Otherwise, returns v2. |
H = select(F,Hf,Hr) |
|
select(x,v1,v2,d) |
Returns v1 if x is greater than or equal to (+d). Returns v2 if x is less than (-d). Otherwise, returns a*v1+(1-a)*v2, where a = (d+x)/(2d). |
H = select(F,Hf,Hr,0.001) |
|
sum(array) |
Returns a scalar value with the sum of all elements of any array. Array may be an array of components or an array of ports. |
1 = sum(z) SumF = sum(In.F) – sum(Out.F) |
|
sin(var) |
Returns the sine of var where var is in radians. |
y = sin(theta) |
|
sign(var) |
Returns +1 if var is positive and -1 if var is negative. |
y = sign(x)*sqrt(abs(x)) |
|
sum(array) |
Returns the sum of all elements of an array variable dimensioned by a fluidtype.complist. |
mt = sum (m) |
|
sum(var1,var2...) |
Returns the sum of any number of scalar variables. |
x = sum(a, b, c) |
|
sum(portarray[ ].vararray) |
Returns an array the size of vararray, where each element is the value of a specific element of vararray summed over all portarray elements. Typically used in equations that need to sum component flowrates over a collection of streams connected to an input or output port. |
Assuming that MTotal1 and M are variables dimensioned to a fluidtype.CompList containing the three elements C1, C2, and C3; and MultiInPort is a port which has two input streams, S1 and S2. In that case, this equation MTotal1 = sum(MultiInPort[].M) will be expanded as follows: MTotal1[C1] = sum(MultiInPort[S1].M[C1] + MultiInPort[S2].M[C1]) MTotal1[C2] = sum(MultiInPort[S1].M[C2] + MultiInPort[S2].M[C2]) MTotal1[C3] = sum(MultiInPort[S1].M[C3] + MultiInPort[S2].M[C3]) |
|
sum(portarray.vararray[ ]) |
Returns an array the size of portarray, where each element is the value of a specific element of portarray summed over all vararray elements. Typically used in equations that need to sum component flowrates over a collection of streams connected to an input or output port. |
Assuming that M is a variable dimensioned to a fluidtype.CompList containing the three elements C1, C2, and C3; and MultiInPort is a port which has two input streams, S1 and S2; and the variable MTotal2 is dimensioned to MultiInPort.StreamList In that case, this equation MTotal2 = sum(MultiInPort.M[]) will be expanded as follows: MTotal2[S1] = sum(MultiInPort[S1].M[C1] + MultiInPort[S1].M[C2] + MultiInPort[S1].M[C3]) MTotal2[S2] = sum(MultiInPort[S2].M[C1] + MultiInPort[S2].M[C2] + MultiInPort[S2].M[C3]) |
|
sqrt(var) |
Returns the square root of var. Return an error if var is negative. |
f = sqrt(dp) |
|
tan(var) |
Returns the tangent of var where var is in radians. |
t = tan(theta) |
|
totalize("library:model.submodel.var") |
Returns the value of one or more totalized variables. The library, model, submodel, and var names are all optional, but you must include at least one name to return a nonzero value. The names that you include determine the context of the totalized value that the software returns. See Define totalized variables for more information. |
totalize("Process:Pump.Utility.ElectricityCost") returns the total electricity cost in the Utility submodel for all Process.Pump model instances in the simulation totalize("Process:Pump.ElectricityCost") returns the total electricity cost (regardless of submodel) for all Process.Pump model instances in the simulation totalize("Models:AODD.PlantAirCost") returns the total plant air cost for all custom AODD pump models in the simulation. totalize("Process:ElectricityCost") returns the total electricity cost (regardless of the submodel) for all Process Library model instances (for example, all Process.Pump and Process.Compressor model instances) in the simulation totalize("Utility") returns the totalized value for all totalized variables from all Utility submodels (for example, the Process.Pump.Utility.ElectricityCost and Process.Source.Utility.LPSteamCost submodels) in the simulation; the software treats all totalized variables as dimensionless, so you should take care that the desired submodels include only totalized variables with compatible units of measure (UOMs) totalize("ElectricityCost") returns the total electricity cost of all model instances in the simulation |
|
Tears variable var to reduce solver block size. |
x1 = tear(x) |