*Tip: Start typing in the input box for immediate search results.Can't find what you're looking for? Submit a support request here.*

# Formula Overview

## Introduction

Formulae are expressions which may be used in the definition of geometry, thickness, materials and boundary condition data records, and during various data extraction operations in results processing. Clicking the Formula icon or opening the Edit drop-down and clicking “Formulae” opens the Formula(e) pane, used for entering and editing formula record definitions (Figure 1).

## Defining Formulae

To define a formula record, provide the following information:

**Name:**Provide a name for the formula. This is how you will access the formula when using it in your model.__Tip:__*When creating boundary conditions, materials, etc. you can hold Alt-P or Alt-F to see a pop-up list of defined parameters or formulae respectively. Then just select the formula you want to use.*

**System Option:**Choose Cartesian, Cylindrical or Spherical system type that will be used when the formula references spatial variables such as X, Y and Z.**Angle Option:**A formula may be defined as a function of an angle measured counterclockwise from the positive X-axis (0 to 2pi) or from the negative X-axis (-pi to pi).**Constants:**You may define constants and then reference the constants in the formula using a C followed by the constant number, for example: C1, C2, etc. Up to 100 constants may be defined.**Subexpressions:**You may define sub-expressions, and then reference these sub-expressions in the formula using curly brackets around the sub-expression number, for example: {1}. Subexpressions are limited to 31 characters long.**Formula:**define the formula using any combination of solution variables, parameters, constants, sub-expressions and other formulae. You may use the standard intrinsic functions such as sin() and cos() and other special StressCheck intrinsic functions such as deg() and rad(). StressCheck also recognizes intrinsic constants such as PI (π). Intrinsic functions are listed in Tables 1-3. Note that in order to reference a formula in the definition of another formula, you must surround the referenced formula name in curly brackets {}.

Once all formula definition information has been entered, click the **Accept **button to add the formula record definition.

The below animation demonstrates a formula defined by a constant, subexpression and parameter:

### Intrinsic Functions

The intrinsic functions in Table 1 include common mathematical functions, as well as conditional, relational, equality, logical operators.

**Table ****1****: StressCheck Intrinsic Functions**

Function | Description |

sqrt(x) | Square Root |

sin(x) | Sine |

cos(x) | Cosine |

tan(x) | Tangent |

sinh(x) | Hyperbolic sine |

cosh(x) | Hyperbolic cosine |

tanh(x) | Hyperbolic tangent |

asin(x) | Arc sine |

acos(x) | Arc cosine |

atan(x) | Arc tangent |

log10(x) | Log base 10 |

log(x) | Natural log |

exp(x) | e^{x} |

deg(x) | Convert radians to degrees |

rad(x) | Convert degrees to radians |

abs(x) | Absolute value |

atan2(y;x) | Arc tangent (y/x) |

mod(x;y) | Modulus |

min(x;y) | Minimum of 2 values |

max(x;y) | Maximum of 2 values |

if(condition;true;false)* | Test for relational condition |

x :lt: y | Less than relation |

x :gt: y | Greater than relation |

x :eq: y | Equality relation |

x :ne: y | Inequality relation |

x :le: y | Less than or equal relation |

x :ge: y | Greater than or equal relation |

x :and: y | And relation |

x :or: y | Or relation |

Note that the asterisked function “if” is intended for use only in special situations in the formula input pane. To create an “if” statement, all three arguments, the condition, true value, and false value, must be provided. For example, writing “if(X>0;1000;100)” means that if the X value in the selected reference system is greater than 0, set the formula value to 1000, and if less than or equal to 0, set the formula value to 100.

Also note that when an intrinsic function requires more than one argument, the arguments must be separated by a semi-colon (;) not a comma (,) as you might expect. This is because the comma is used as a data delimiter in the StressCheck input file.

For an example of a formula spring coefficient based on X, Y, Z coordinates, refer to StressCheck Tutorial: Defining a Formula Spring Coefficient.

### Section Property Functions

The following functions shown in Table 2 are a special set of functions for use in formulae used in the application of 3D loads. These functions are evaluated on a set of elements, element faces or surfaces and are referenced without any arguments or parentheses. When applying a load based on a formula with one of these parameters, the function will automatically detect the mesh entities the formula is being applied to and calculate the value of the function accordingly:

**Table ****2****: Section Property Intrinsic Functions**

Function | Description |

sparea | Area |

spvol | Volume |

spctrx, spctry, spctrz | X, Y, Z centroidal axis |

spmomx, spmomy | X, Y Moment of inertia about centroidal axis |

spcross | Cross moment of inertia |

spmom1, spmom2 | Moment of inertia with respect to 1^{st} and 2^{nd} principal directions |

spangle | First principal angle |

#### Section Properties in Formula Traction Loads

Once the group of element faces or surfaces is selected, the section properties are computed by the program before the tractions are applied. The steps involved are as follows:

1. Create a local Cartesian coordinate system in such a way that the xy-plane of the local system is in the same plane as the group of element faces or surfaces to be loaded.

2. Create a load record by selecting the Load class, enter the Load ID, select the group of element faces or surfaces for which the section properties should be computed. The element faces or surfaces should all be flat and contained in the same plane. Select the local system defined in step 1, and enter the formula name to be created in step 3.

3. Create a formula with the name given in step 2 that uses the Section Property Function name(s) in Table 2.

At the time of the formula evaluation to compute the load vector associated with the prescribed traction, the program will compute all the section properties of the selected faces, and use the ones included in the formula definition.

For an example of using section properties to define a parabolic shear stress distribution, refer to StressCheck Tutorial: Defining and Assigning a Parabolic Shear Stress Formula Distribution.

### Location/Distance Functions

The last set of intrinsic functions are used to get information about the location of existing points and nodes:

**Table ****3****: Point/Node Functions**

Function | Description |

$n_d(n1;n2) | distance from node “n1” to node “n2” |

$n_x(n1) | x coordinate of node “n1” |

$n_y(n1) | y coordinate of node “n1” |

$n_z(n1) | z coordinate of node “n1” |

$n_u(n1;b1) | U offset of node “n1” projected to boundary “b1” |

$n_v(n1;b1) | V offset of node “n1” projected to boundary “b1” |

$n_ud(n1;b1) (degrees) | U offset of node “n1” projected to boundary “b1” |

$n_vd(n1;b1) (degrees) | V offset of node “n1” projected to boundary “b1” |

$p_d(p1;p2) | distance from point “p1” to point “p2” |

$p_x(p1) | x coordinate of point “p1” |

$p_y(p1) | y coordinate of point “p1” |

$p_z(p1) | z coordinate of point “p1” |

$p_u(p1;b1) | U offset of point “p1” projected to boundary “b1” |

$p_v(p1;b1) | V offset of point “p1” projected to boundary “b1” |

$p_ud(p1;b1) (degrees) | U offset of point “p1” projected to boundary “b1” |

$p_vd(p1;b1) (degrees) | V offset of point “p1” projected to boundary “b1” |

## Editing Formulae

To edit a formula record definition, first select the formula name to be edited from the list of available formula record definitions in the Formula(e) pane. Once selected, the Formula(e) pane should be populated with the associated formula record inputs (e.g., formula name, expression, constants, etc.). Then, after making your changes, click the **Replace** button to update the formula record definition.

## Using Formulae

To use a formula as a model input (e.g. material property, normal traction, spring coefficient, etc.) or when extracting results (e.g. fringe plots, points extractions), simply enter the formula name in the input field (or begin typing the formula name and select it from the autofill options, as shown in Figure 3):

Tip: to display a list of currently defined formula names, hold ALT+F while the input field is in focus (Figure 5). Note that formula names will appear in purple text, with a pipe symbol (|) preceding the formula name. It should also be noted that formulas that are preceded by a the pipe symbol may not reference spatial variables within the expression (i.e. x , y, z).

## Exporting/Importing Formulae

Formulae may be exported/imported (as .par files) using the File > Export and File > Import options, respectively.

For more details, refer to Importing Model Inputs.

## Deleting Formulae

After clicking on a formula name, the entire formula record definition row will be selected and the **Delete **button may be used to remove the selected formula record definition. Note: an error will occur if that formula has any dependencies.

To remove all formula record definitions, click the **Purge **button.