Expressions > Inputs to expressions > Mathematical functions in expressions
Modulo function
The modulo function finds the remainder after division of a pair of numbers as follows:
\bmod (x,y) = x - y \cdot {\rm{trunc}}\left( {\frac{x}{y}} \right)
For example, the modulo of 5 and 2 is as follows:
{\rm{mod}}\left( {5,2} \right) = 5 - 2 \cdot {\rm{trunc}}\left( {\frac{5}{2}} \right)
The format for the modulo function is MOD(v1,v2), where v1 and v2 are dimensional or dimensionless arguments. The result that the software computes depends on the dimensionality of the arguments and the units for the expression.
If both arguments are dimensionless, the software computes the modulo and assigns the units of the expression to the result.For example, if the formula for an expression is MOD(5,2) and the unit of length for the expression is millimeters, the software returns 1 mm. If the unit of length for the expression is meters, the software returns 1 m.
If both arguments are dimensional, or one argument is dimensionless and the other is dimensional, the software does the following:Converts v1 and v2 to base units.Let v1' and v2' denote v1 and v2 converted to base units.If the units for the expression have the same dimensionality as v1, converts v1' to the units for the expression.Let v1" denote v1 converted to the units for the expression.If the units for the expression have the same dimensionality as v2, converts v2' to the units for the expression.Let v2" denote v2 converted to the units for the expression.Computes the following:{\rm{v}}1'' - {\rm{v2''}} \cdot {\rm{trunc}}\left( {\frac{{{\rm{v1''}}}}{{{\rm{v2''}}}}} \right)where the truncation discards the fractional portion of the quotient.Assigns the dimensions of the quotient v1/v2 to the computed value.If the dimensions for the units for the expression are the same as the dimensions for the quotient v1/v2, and:The modulo function is embedded in the formula for the expression with other mathematical functions, mathematical operations, and so on, converts the computed modulo from the units for the expression to the base units.The formula for the expression contains the modulo function only, converts the computed modulo from base units to the units for the expression.
Tip:
Because of the complexity of the modulo function, if either argument is dimensional, as a best practice, use the alternate form of the modulo function.
The alternate form of the modulo function produces results that are independent of the units for the expression. The format for this function is MOD(v1,v2,USEUNITS,TRUE), where v1 and v2 have the same dimensionality, or are both dimensionless.
When you specify MOD(v1,v2,USEUNITS,TRUE), the software does the following:
Converts v1 and v2 to base units.
Computes the following:{\rm{v}}1' - {\rm{v2'}} \cdot {\rm{trunc}}\left( {\frac{{{\rm{v1'}}}}{{{\rm{v2'}}}}} \right)where v1' and v2' are the values of v1 and v2 converted to base units, and the truncation discards the fractional portion of the quotient.
For example, if the formula for an expression is MOD(5[m],2[m],USEUNITS,TRUE) and the unit of length for the expression is millimeters, the software returns 1000 mm. If the unit of length for the expression is meters, the software returns 1 m.
If the formula for an expression is MOD(4[m],30[mm],USEUNITS,TRUE) and the unit of length for the expression is millimeters, the software returns 10 mm. If the unit of length for the expression is meters, the software returns 0.010 m.
In both examples, the results are physically equivalent. Thus, when you use the alternate form of the modulo function, the result is independent of the units for the expression.
Modulo function, Simcenter 3D 2021.1 Series
© 2020 Siemens
window.mainLanguage="en_US"
window.delivId=""
window.projectId=""
MathJax.Hub.Config({ TeX: { extensions: ["autoload-all.js"] }, tex2jax: { displayMath: [ ] }, "SVG": { scale: 125 } });
Source: https://docs.sw.siemens.com/en-US/doc/289054037/PL20200601120302950.advanced/xid1677796 · retrieved 2026-07-17