21. Arithmetical Expressions#
21.1. Introduction#
NaxToView includes an arithmetic expression engine that allows defining custom formulas to derive new results from finite element model data. This engine is used in four different contexts:
Context |
Purpose |
|---|---|
Derived Load Cases |
Combine results from different load cases and increments, including envelopes for structural sizing. |
Derived Components |
Create new result components from existing ones (vector magnitudes, equivalent stresses, failure criteria, etc.). |
Derived Attributes |
Generate data fields on the mesh computed from geometric or intrinsic properties of the model. |
Tags |
Display model values, file information, and expression results directly in the 3D viewer. |
All contexts share the same base set of operators and functions, but each has its own variable syntax and some exclusive functions.
21.2 General Concepts#
This section defines the fundamental data types, operators, precedence rules, and mathematical functions used by the NaxToView expression engine. These rules apply to all contexts: Derived Load Cases, Derived Components, Derived Attributes, and Tags.
21.2.1 Data Types#
The engine works with three fundamental data types:
Type |
Description |
Notation |
|---|---|---|
Scalar |
A single numerical value. Supports signs, decimals, and scientific notation. The special value |
|
Array |
An ordered list of scalars enclosed in brackets, separated by the regional list separator. |
|
Variable |
A named reference to a dataset in the model. Internally an array of |
|
Operational rules between types#
All operations involving arrays or variables are applied element‑wise:
Operand A |
Operand B |
Result |
Behavior |
|---|---|---|---|
Scalar |
Scalar |
Scalar |
|
Array/Variable [n] |
Scalar |
Array/Variable [n] |
|
Scalar |
Array/Variable [n] |
Array/Variable [n] |
|
Array/Variable [n] |
Array/Variable [n] |
Array/Variable [n] |
|
Note
When operating on two arrays or variables, they must have the same length. If dimensions do not match, the result is NaN.
21.2.2 Arithmetic Operators#
Operator |
Operation |
Example |
|---|---|---|
|
Addition |
|
|
Subtraction |
|
|
Multiplication |
|
|
Division |
|
|
Power |
|
|
Parentheses |
|
No spaces allowed: Expressions cannot contain whitespace. Incorrect: <LC1:FR1> + <LC2:FR1>
Correct: <LC1:FR1>+<LC2:FR1>
Division by zero: Produces NaN for the affected position but does not stop evaluation; other elements continue normally.
21.2.3 Evaluation Order (Precedence)#
The engine evaluates expressions using this strict priority order:
Priority |
Category |
Detail |
|---|---|---|
1 |
Expressions inside arrays |
Expressions inside |
2 |
Logarithmic functions |
|
3 |
Trigonometric functions |
|
4 |
Square root |
|
5 |
Envelope functions |
|
6 |
Min/Max functions |
|
7 |
Parentheses |
|
8 |
Power |
|
9 |
Multiplication |
|
10 |
Division |
|
11 |
Addition |
|
12 |
Subtraction |
|
Tip
Use parentheses to enforce a specific evaluation order and improve readability, e.g., (<LC1:FR1>+<LC2:FR1>)*1.5.
21.2.4 Mathematical Functions#
All functions accept a scalar, array, variable, or composite expression inside parentheses, and operate element‑wise.
Logarithms and Square Root#
Function |
Description |
Valid Domain |
|---|---|---|
|
Base‑10 logarithm |
x > 0 (outside domain → |
|
Natural logarithm |
x > 0 |
|
Square root |
x ≥ 0 |
Direct Trigonometric Functions#
Function |
Definition |
|---|---|
|
Sine |
|
Cosine |
|
Tangent |
|
Secant = 1/cos(x) |
|
Cosecant = 1/sin(x) |
|
Cotangent = 1/tan(x) |
Inverse Trigonometric Functions#
Function |
Description |
Input Domain |
Output Range |
|---|---|---|---|
|
Arcsine |
−1 ≤ x ≤ 1 |
[−π/2, π/2] |
|
Arccosine |
−1 ≤ x ≤ 1 |
[0, π] |
|
Arctangent |
All real values |
(−π/2, π/2) |
Hyperbolic Functions#
Function |
Definition |
|---|---|
|
(eˣ − e⁻ˣ) / 2 |
|
(eˣ + e⁻ˣ) / 2 |
|
sinh(x) / cosh(x) |
Note
If the argument is outside the valid domain or the result is infinite, that position becomes NaN. The rest of the array continues to evaluate normally.
21.2.5 Aggregation Functions (Min / Max)#
These functions accept multiple arguments, separated by comma or semicolon depending on regional settings.
Function |
Behavior (per position i) |
|---|---|
|
Returns the maximum value |
|
Returns the minimum value |
|
Returns the value with the largest absolute value (sign preserved) |
|
Returns the value with the smallest absolute value (sign preserved) |
Note
Single‑array case: If max() or min() receives a single array, it returns the global extreme value as a scalar. Useful for normalization: <CONTOUR>/max(<CONTOUR>).
21.2.6 Automatic Sign Simplification#
The engine automatically simplifies consecutive sign sequences:
Original |
Simplified |
Rule |
|---|---|---|
|
|
Double positive = positive |
|
|
Double negative = positive |
|
|
Positive–negative = negative |
|
|
Negative–positive = negative |
This also applies after *, /, ^, opening parentheses, and commas.
21.2.7 Regional Configuration#
The engine respects the OS regional settings for separators:
Region |
Decimal |
List |
Array Example |
|---|---|---|---|
English (US/UK) |
|
|
|
Spanish / French / German |
|
|
|
Warning
The list separator also applies to function arguments like max(), min(), and envelope functions. In Spanish settings: max(<LC1:FR1>;<LC2:FR1>).
21.3. Derived Load Cases#
Derived load cases allow you to combine results from different load cases and increments using arithmetic expressions. Each referenced variable represents a full array containing one value per node or per element in the model. This is the main tool for load combinations, envelopes, and multilinear post‑processing.
21.3.1 Variable Syntax#
Variables are enclosed between angle brackets < >:
Format |
Description |
Example |
|---|---|---|
|
Load case with ID id, increment with ID increment_id. The number after |
|
|
Derived load case with ID –id. The prefix |
|
Supported operations: All arithmetic operators, parentheses, all mathematical functions, min/max, and envelope functions (exclusive to this context).
Warning
No spaces allowed: Write expressions continuously: 1.5*<LC1:FR1>+1.35*<LC2:FR1>.
21.3.2 Envelope Functions#
Envelope functions are exclusive to Derived Load Cases and essential for structural sizing. For each node/element, they evaluate the extreme value among multiple load cases and can also identify which load case or increment yields that extreme.
Function |
Behavior per position i |
|---|---|
|
Returns the maximum value among all load cases. |
|
Returns the minimum value. |
|
Returns the value with the largest absolute magnitude, preserving its sign. |
|
Returns the value with the smallest absolute magnitude, preserving its sign. |
|
Computes amplitude: |
Warning
Restriction: Arguments of envelope functions must be only load‑case variables <LC…:FR…>. Scalars, literal arrays, and composite expressions are not allowed as direct arguments.
21.3.3 Envelope Result Modifiers#
Internally, each envelope function generates three arrays simultaneously. The modifier (suffix) selects which one is used:
Suffix |
Displayed Result |
|---|---|
(no suffix) |
Actual contour value (stress, displacement, etc.). |
|
Load case ID that provides the extreme at each node/element. |
|
Increment ID where the extreme occurs (useful in nonlinear analysis). |
21.3.4 Practical Examples#
Linear load combination
1.5*<LC1:FR1>+1.35*<LC2:FR1>+1.5*<LC3:FR1>
Each variable references increment ID 1 of its corresponding load case.
Combination using different increments
<LC1:FR1>+<LC2:FR3>+<LC3:FR1>
Combines increment 1 of LC1, increment 3 of LC2, and increment 1 of LC3. The number following FR is the increment ID as shown in the results tree.
Ultimate load from a limit‑state derived case
<LCD1:FR1>*1.5
Multiplies a derived load case (the previously defined limit combination, with derived ID 1) by the ultimate safety factor of 1.5.
Difference Between Increments (thermal delta)
<LC3:FR5>-<LC3:FR1>
Computes the result increment between increment ID 5 and increment ID 1 of the same thermal load case.
RSS Combination (Root Sum of Squares)
sqrt(<LC1:FR1>^2+<LC2:FR1>^2+<LC3:FR1>^2)
Quadratic combination of three independent load cases.
Maximum envelope for sizing
envmax(<LC1:FR1>,<LC2:FR1>,<LC3:FR1>,<LC4:FR1>)
For each node/element, retrieves the maximum stress (or displacement, etc.) among the four load cases.
Absolute‑value envelope with critical case identification
envextrememax(<LC1:FR1>,<LC2:FR1>,<LC3:FR1>):bylcid
Identifies, for each node/element, which load case produces the largest result magnitude. The contour displays the load case IDs, allowing visualization of regions dominated by each condition.
Envelope range (fatigue amplitude)
envrange(<LC1:FR1>,<LC2:FR1>,<LC3:FR1>,<LC4:FR1>)
Computes max − min at each point.
Margin of Safety Between Derived Load Cases
<LCD2:FR1>/<LCD1:FR1>-1
Calculates the margin of safety MS = (allowable load / applied load) − 1 using two previously defined derived cases.
Logarithmic transformation
log(<LC1:FR1>/<LC2:FR1>)
Base-10 logarithm of the ratio between two responses. Useful for representing amplitude ratios in decibels.
Envelope with increment identification
envmax(<LC1:FR1>,<LC1:FR2>,<LC1:FR3>,<LC1:FR4>):byicid
Maximum envelope among four increments of the same nonlinear load case. The modifier :byicid indicates at which load step the maximum is reached at each point.
21.4. Derived Components#
Derived components allow you to create new result components by combining existing ones for the same load case and increment. Each variable represents an array of data with one value per node or element.
21.4.1 Variable Syntax#
Format |
Description |
Example |
|---|---|---|
|
Component of an existing result group. result = name of the result group exactly as it appears in the loaded model. component = name of the component within that group. |
|
|
Previously created derived component. |
|
Note
Name source: Both the result group name and the component names come directly from the solver’s result file. For example, in a Nastran model, the stress group is typically STRESSES (not STRESS) with components XX, YY, XY, etc. Always verify exact names in the NaxToView results tree.
Supported operations: All operators, parentheses, mathematical functions, and min/max.
Note
Not available: Envelope functions (envmax, envmin, envrange, envextrememax, envextrememin) and modifiers :bylcid / :byicid are not available for derived components.
21.4.2 Practical Examples#
Displacement Vector Magnitude
sqrt(<CMPT_DISPLACEMENTS:X>^2+<CMPT_DISPLACEMENTS:Y>+<CMPT_DISPLACEMENTS:Z>^2)
Computes the total displacement magnitude from its three Cartesian components.
Von Mises stress (2D, shell)
sqrt(<CMPT_STRESSES:XX>^2+<CMPT_STRESSES:YY>^2-<CMPT_STRESSES:XX>*<CMPT_STRESSES:YY>+3*<CMPT_STRESSES:XY>^2)
Von Mises criterion for plane stress state (shell elements).
Von Mises stress (3D, full tensor)
sqrt(0.5*((<CMPT_STRESSES:XX>-<CMPT_STRESSES:YY>)^2+( <CMPT_STRESSES:YY>-<CMPT_STRESSES:ZZ>)^2+( <CMPT_STRESSES:ZZ>-<CMPT_STRESSES:XX>)^+6*(<CMPT_STRESSES:XY>^2+<CMPT_STRESSES:YZ>^2+<CMPT_STRESSES:XZ>^2)))
Von Mises criterion computed from the full 3D stress tensor. Use the component names corresponding to your model.
Maximum shear stress (simplified Tresca)
max(<CMPT_STRESSES:XX>,<CMPT_STRESSES:YY>,<CMPT_STRESSES:ZZ>)
- min(<CMPT_STRESSES:XX>,<CMPT_STRESSES:YY>,<CMPT_STRESSES:ZZ>)
Difference between the maximum and minimum normal stresses at each point. Approximation of Tresca stress using direct stresses.
Stress component in the XY plane
sqrt(<CMPT_STRESSES:XX>^2
+<CMPT_STRESSES:YY>^2
+2*<CMPT_STRESSES:XY>^2)
Equivalent stress in the XY plane for shell-type elements.
Reserve Factor (RF)
<CMPTD:Allowable>/<CMPTD:VonMises>
Reserve factor: ratio between allowable stress (previously defined as a derived component) and Von Mises stress. Values > 1 indicate positive margin.
Unit conversion
<CMPT_STRESSES:XX>*0.145038
Converts stresses from MPa to ksi (kilo-pounds per square inch).
Displacement in the XY Plane (Excluding Z Component)
sqrt(<CMPT_DISPLACEMENTS:X>^2
+<CMPT_DISPLACEMENTS:Y>^2)
Displacement projected onto the XY plane, useful for evaluating in-plane deformation without considering out-of-plane buckling.
Principal Stress Direction Angle
0.5*atan(2*<CMPT_STRESSES:XY>
/(<CMPT_STRESSES:XX>-<CMPT_STRESSES:YY>))
Angle of the principal stress direction in the plane (in radians). Applicable to shells and 2D elements.
Largest Absolute Component (Critical Stress)
extrememax(<CMPT_STRESSES:XX>,
<CMPT_STRESSES:YY>,
<CMPT_STRESSES:ZZ>)
Selects the normal stress with the greatest magnitude (tension or compression), preserving its sign. Useful for identifying the critical stress component at each point in the model.
21.5. Derived Attributes#
Derived attributes allow you to create data fields on the mesh computed from the model’s intrinsic properties and other existing attributes. Each variable is an array with one value per node or per element across the full model.
21.5.1 Available Variables#
Element Fields#
Available when the attribute item type is ELEMENTS:
Variable |
Description |
Value Type |
|---|---|---|
|
Element ID (solver pedigree ID) |
Integer |
|
Internal global ID (VTK index) |
Integer |
|
Current contour value being plotted |
Decimal |
|
Structural property ID assigned to the element |
Integer |
|
Material ID assigned |
Integer |
|
Element type according to the solver |
Integer |
|
Group/part ID |
Integer |
|
X coordinate of the element centroid |
Decimal |
|
Y coordinate of the element centroid |
Decimal |
|
Z coordinate of the element centroid |
Decimal |
|
Element normal vector as array |
Array [3] |
Node Fields#
Available when the attribute item type is NODES:
Variable |
Description |
Value Type |
|---|---|---|
|
Node ID (solver pedigree ID) |
Integer |
|
Internal global ID (VTK index) |
Integer |
|
Current contour value |
Decimal |
|
Group/part ID |
Integer |
|
Node X coordinate |
Decimal |
|
Node Y coordinate |
Decimal |
|
Node Z coordinate |
Decimal |
Supported operations: All operators, parentheses, math functions, and min/max.
Not available: Envelope functions cannot be used in Derived Attributes.
21.5.2 Referencing Other Attributes#
Any existing attribute (derived, imported, or contour) may be referenced by name:
<AttributeName>
The attribute must exist and have its data computed beforehand. Its array of values is injected directly into the formula.
21.5.3 Practical Examples#
Radial distance to Z-axis (cylindrical radius)
sqrt(<COORD_X>^2 + <COORD_Y>^2)
Computes the radius in cylindrical coordinates. Useful for fuselages, cylindrical tanks, or bodies of revolution.
Distance from the origin (spherical radius)
sqrt(<COORD_X>^2 + <COORD_Y>^2 + <COORD_Z>^2)
Radius in spherical coordinates measured from the origin of the global reference system.
Azimuth angle in the XY plane
atan(<COORD_Y> / <COORD_X>) Returns NaN where `<COORD_X> = 0`.
Angle in radians measured from the positive X-axis. Returns NaN where COORD_X = 0. Useful for parameterizing circular sections.
Relative Height with Respect to a Section
<COORD_Z> - 1250.0
Vertical distance of each node/element relative to section Z = 1250 mm (e.g., a reference frame).
Contour normalization with respect to global maximum
<CONTOUR> / max(<CONTOUR>)
Scales contour values to the range [0, 1] by dividing each value by the global maximum. Useful for comparing distributions of different magnitudes.
Ratio between custom attribute and Coordinate
<Espesor> / sqrt(<COORD_X>^2 + <COORD_Y>^2)
Thickness-to-radius ratio for an imported thickness attribute. Useful for verifying thickness/radius ratios in pressure vessels.
21.7. General Compatibility Table#
Functionality |
Load Case |
Component |
Attribute |
Tag |
|---|---|---|---|---|
|
Yes |
Yes |
Yes |
Yes |
Parentheses |
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes |
Yes |
|
Yes |
No |
No |
No |
|
Yes |
No |
No |
No |
|
Yes |
No |
No |
No |
Modifiers |
Yes |
No |
No |
No |
Variable ↔ Variable |
Yes |
Yes |
Yes |
Yes* |
Variable ↔ Scalar |
Yes |
Yes |
Yes |
Yes* |
Scalar ↔ Scalar |
Yes |
Yes |
Yes |
Yes |
Array ↔ Array |
Yes |
Yes |
Yes |
Yes* |
Array ↔ Scalar |
Yes |
Yes |
Yes |
Yes* |
Format |
No |
No |
No |
Yes |
Note
In tags, arrays come from Phase‑1 domain‑variable substitution (e.g., CONTOUR::ENTITY in element‑nodal mode, NORMAL::ENTITY, nodes in unstitched meshes, etc.).
21.8. Validation of Formulas and Errors#
21.8.1 Validation Process#
NaxToView automatically validates every formula before creating or editing a derived entity:
Reference parsing: All
<...>references in the formula are parsed.Entity existence checks:
Load cases: Verifies that the referenced load case and increment exist.
Components: Verifies that the referenced component exists in the active result.
Attributes: Validation is more flexible (accepts any valid attribute reference).
Test evaluation: The formula is evaluated with test data to verify that the syntax yields a valid result.
21.8.2 Error Codes#
Code |
Description |
|---|---|
|
Valid formula; it can be evaluated successfully. |
|
Incorrect syntax: misplaced operators, unclosed parentheses, wrong function name, etc. |
|
A referenced load case does not exist in the model. |
|
A referenced component does not exist in the active result. |
|
A referenced increment does not exist in the indicated load case. |
21.8.3 Common Errors and Solutions#
Problem |
Likely Cause |
Solution |
|---|---|---|
Result |
Widespread division by zero, square root of negative values, logarithm of zero. |
Check input data: ensure values are within the valid domain of the functions used. |
|
Some nodes/elements produce invalid operations (e.g., division by zero result). |
Normal in real models. Nodes/elements with |
Syntax error on creation |
Unclosed parentheses, double operator ( |
Ensure all parentheses are paired, function names are exact ( |
Variable not found |
The referenced load case, component, or attribute does not exist or is misspelled. |
Verify exact names in the NaxToView results tree. |
Increment not found |
The increment ID after |
Verify available increment IDs in the results tree. The number after |
Unexpected result from arrays of different sizes |
Two variables with different number of items are combined (e.g., nodal vs. elemental results). |
Ensure all variables in the formula share the same mapping/type. |
List separator not working |
OS regional settings use a different list separator. |
In Spain/France use |
|
Envelope functions are available only in Derived Load Cases. |
Use |
Tag shows the formula unevaluated |
Missing |
Wrap the expression inside |
Tag shows too many decimals |
No decimal‑format specifier used. |
Add |