Tdyn reference manual


Function Syntax

Most of the material and data fields of Tdyn may be defined by functions. Those data fields can be inserted by means of the function editor by pressing button shown in Figure 32. Note that this button in only available in those pages where any function field exists.

Figure 32. Function editor button.

It is also possible to start the function editor by right clicking the mouse on the insertion field.

Funtion editor allows comfortably definition of complex functions. It also includes some tools to help the insertion of functions: history list, function examples, variables list and operators list.

Figure 33. Function Editor

Next a brief explanation of the syntax of the functions used in Tdyn is given.

Variables:

The variables that can be used for the definition of the functions are:

 

Remarks:

Variables are used in functions without taking into accout its units. Their values are obtained using IS [m], [s], [Kg] unit system.

Global variables, available for any function:

t : Total (physical) time

it : Interval time. Time from the last restarting of the problem.

rand : Random number.

step : Current step of the analysis.

Geometrical variables, available for functions in domain scope (fluid or solid domain functions):

x : X cartesian coordinate of the point.

y : Y cartesian coordinate of the point.

z : Z cartesian coordinate of the point.

rhoc : ρ corresponding to cylindrical coordinates of the point. ρ is given by .

thetac : θ corresponding to cylindrical coordinates of the point. θ is given by .

rhos : ρ corresponding to spherical coordinates of the point. ρ is given by .

thetas : θ corresponding to spherical coordinates of the point. θ is given by .

phis : φ corresponding to spherical coordinates of the point. θ is given by .

nx : X component of the point normal.

ny : Y component of the point normal.

nz : Z component of the point normal.

Unknown or physical properties functions, that can be uses in fluid domain scope:

vx : X velocity component at the point (RANSOL module).

vy : Y velocity component at the point (RANSOL module).

vz : Z velocity component at the point (RANSOL module).

pr : Pressure of the point (RANSOL module).

vt : Eddy viscosity at the point (only available if turbulence model is selected) (RANSOL module).

ke : Eddy kinetic energy at the point (only available if turbulence model, based in the k equation is selected) (RANSOL module).

ep : Epsilon value at the point (only available if k-epsilon turbulence model is selected) (RANSOL module).

om : Omega  value at the point (only available if k-omega turbulence model is selected) (RANSOL module).

kt : Ktau (k*tau) value at the point (only available if k-ktau turbulence model is selected) (RANSOL module).

bt : Beta (wave elevation) value at the point (NAVAL module).

dn : Density of the point.

vs : Viscosity of the point (RANSOL module).

kvs : Kinematic viscosity of the point (RANSOL module).

cm : Compressibility factor at the point (RANSOL module).

tm : Temperature of the point (HEATRANS module).

cp : Specific heat of the point (HEATRANS module).

kis : Heat conductivity of the point (HEATRANS module).

sp : Concentration of the corresponding species at the point (ADVECT module). Number of species must be indicated after sp (i.e. sp1, sp7)

ph : Value of the corresponding variable at the point (URSOLVER module). Number of variable must be indicated after ph (i.e. ph1, ph7)

ds : Distance of the point to the closest wall (RANSOL module).

mx : Accumulated mesh deformation of the point in the x direction (ALEMESH module).

my : Accumulated mesh deformation of the point in the y direction (ALEMESH module).

mz : Accumulated mesh deformation of the point in the z direction (ALEMESH module).

Remarks:

Variables are evaluated at the previous time step (t-dt).

Variables are only available when corresponding module is active.

Unknown or physical properties functions, that can be uses in solid domain scope:

vx : X velocity component at the point (RANSOL module).

vy : Y velocity component at the point (RANSOL module).

vz : Z velocity component at the point (RANSOL module).

pr : Pressure of the point (RANSOL module).

dn : Fluid density of the point (RANSOL module).

vs : Fluid viscosity of the point (RANSOL module).

kvs : Fluid kinematic viscosity of the point (RANSOL module).

sdn : Solid density of the point.

tm : Temperature of the point (HEATRANS module).

cp : Specific heat of the point (HEATRANS module).

kxx : Heat conductivity (xx) of the point (HEATRANS module).

kxy : Heat conductivity (xy) of the point (HEATRANS module).

kxz : Heat conductivity (xz) of the point (HEATRANS module).

kyy : Heat conductivity (yy) of the point (HEATRANS module).

kyz : Heat conductivity (yz) of the point (HEATRANS module).

kzz : Heat conductivity (zz) of the point (HEATRANS module).

sp : Concentration of the corresponding species at the point (ADVECT module). Number of species must be indicated after sp (i.e. sp1, sp7)

ph : Value of the corresponding variable at the point (URSOLVER module). Number of variable must be indicated after ph (i.e. ph1, ph7)

ds : Distance of the point to the closest wall (RANSOL module).

mx : Accumulated mesh deformation of the point in the x direction (ALEMESH module).

my : Accumulated mesh deformation of the point in the y direction (ALEMESH module).

mz : Accumulated mesh deformation of the point in the z direction (ALEMESH module).

Remarks:

Variables are evaluated at the previous time step (t-dt).

Variables are only available when corresponding module is active.

Examples:

x+y

0.1*vx*vx

120.0*(tm-25)

0.1*sp2

sin(x-t)*log(y^2)

Constants:

The constants defined for functions internal compilation  are:

pi : 3.1415926535897932385

exp(1) : 2.7182818284590452354

dt : Time increment of the current step.

infinite : Infinite.

Function operators:

The function operators calculate the value of a standard function at the point defined by the given argument. The function operators that can be used for the definition of the Tdyn functions are:

 

sqrt : the sqrt function calculates the square root of the argument. Syntax: sqrt(·)

abs : the abs function calculates the absolute value of the argument. Syntax: abs(·)

ln : logarithm of the argument, e base. Syntax: ln(·)

log : logarithm of the argument, decimal base. Syntax: log(·)

fac : factorial of the argument. Syntax: fac(·)

sin : sine of the argument. Syntax: sin(·) (argument given in radians).

cos : cosine of the argument. Syntax: cos(·) (argument given in radians).

tan : tangent of the argument. Syntax: tan(·) (argument given in radians).

asin : The asin function returns the arcsine of the argument in the range –π/2 to π/2 radians. Syntax: asin(·).

acos : The acos function returns the arccosine of the argument in the range 0 to π radians. Syntax: acos(·).

atan : The atan function returns the arctangent of the argument in the range –π/2 to π/2 radians. Syntax: atan(·) (result given in radians).

sinh : hyperbolic sine of the argument. Syntax: sinh(·).

cosh : hyperbolic cosine of the argument. Syntax: cosh(·).

tanh : hyperbolic tangent of the argument. Syntax: tanh(·).

exp : the exp function calculates the exponential value of the argument. Syntax: exp(·).

heaviside : the heaviside function evaluates He, defined as:

 The syntax is heaviside(·,·), where the first argument is f and the second e.

Interpolate : performs a linear interpolation, based on the given data. Two arguments are required: a list of pairs (x,h), defining a polylineal curve, and a function defining the x value(-s) where the evaluation is to be done. Syntax:

 interpolate(#x1,h1,x2,h2,x3,h3,…# ·).

srand : The rand function returns a pseudorandom integer in the range 0 to 1, based on the argument given as seed. Syntax: srand(·).

int : Integer conversos. Syntax: int(·).

- : change sign operator. Syntax: (-expression).

maxs : Maximum of the surrounding values. For a given point, maximum of the values of the argument for the connected nodes is returned. Syntax maxs(.), where the argument is any unknown or physical property (see variables section for further information).

mins : Minimum of the surrounding values. For a given point, minimum of the values of the argument for the connected nodes is returned. Syntax mins(.), where the argument is any unknown or physical property (see variables section for further information).

meds : Average of the maximum and minimum of the surrounding values. For a given point, average of the maximum and minimum values of the argument for the connected nodes is returned. Syntax meds(.), where the argument is any unknown or physical property (see variables information).

aver : Average of the surrounding values. For a given point, average of the values of the argument for the connected nodes is returned. Syntax aver(.), where the argument is any unknown or physical property (see variables information). Weighted average is calculated by using standard FEM integration on the connected elements.

maxvar : Maximum of the values of the unknown or physical property given as argument (see variables section for further information). Syntax maxvar(.).

minvar : Minimum of the values of the unknown or physical property given as argument (see variables section for further information). Syntax minvar(.).

mat : Returns 1 if the point belongs to the material given as argument. This function is case insensitive. Syntax mat(.) where the argument is a material's name.

pfx : X Component of the pressure force of the given Body. Syntax: pfx(.) where the argument is a body's name.

pfy : Y Component of the pressure force of the given Body. Syntax: pfy(.) where the argument is a body's name.

pfz : Z Component of the pressure force of the given Body. Syntax: pfz(.) where the argument is a body's name.

vfx : X Component of the viscous (stress) force of the given Body. Syntax: vfx(.) where the argument is a body's name.

vfy : Y Component of the viscous (stress) force of the given Body. Syntax: vfy(.) where the argument is a body's name.

vfz : Z Component of the viscous (stress) force of the given Body. Syntax: vfz(.) where the argument is a body's name.

pmx : X Component of the pressure moment of the given Body. Syntax: pmx(.) where the argument is a body's name.

pmy : Y Component of the pressure moment of the given Body. Syntax: pmy(.) where the argument is a body's name.

pmz : Z Component of the pressure moment of the given Body. Syntax: pmz(.) where the argument is a body's name.

vmx : X Component of the viscous (stress) moment of the given Body. Syntax: vmx(.) where the argument is a body's name.

vmy : Y Component of the viscous (stress) moment of the given Body. Syntax: vmy(.) where the argument is a body's name.

vmz : Z Component of the viscous (stress) moment of the given Body. Syntax: vmz(.) where the argument is a body's name.

Examples:

2*sqrt(y)

x*fac(5)

srand(0)

log(abs(x))

exp(5)

interpolate(#1.0,2.0,2.0,2.5,3.0,2.0#t^2)

maxvar(vx)

mat(“Fluid”)

Operators:

Operators that can be used for Tdyn functions definitions are:

+ : adding operator.

  Syntax: [adding_expression] + [adding_expression].

- : substraction operator.

  Syntax: [substraction_expression] – [substraction_expression].

^ : exponent operator.

  Syntax: [exponent_expression] ^ [function_expression].

* : multiplicative operator.

  Syntax: [multiplicative_expression] * [multiplicative _expression].

/ : division operator.

  Syntax: [multiplicative_expression] / [quotient_expression].

div : integer division operator int(x/y+0.5).

  Syntax: ([multiplicative_expression]) div ([quotient_expres-sion]). Example: (x)div(2+y).

idiv : integer division operator int(x/y+0.5).Similar to div operator but with different syntax.

  Syntax: idiv ([multiplicative_expression], [quotient_expres-sion]). Example: idiv(x,2+y).

mod : integer division module operator int(x+0.5)%int(y+0.5).

  Syntax: ([multiplicative_expression]) mod ([quotient_expres-sion]). Example: (t)mod(2).

imod : integer division module operator int(x+0.5)%int(y+0.5).Similar to mod operator but with different syntax.

  Syntax: imod ([multiplicative_expression],[quotient_expres-sion]). Example: imod(t,2).

rdiv : real division operator int(x/y).

  Syntax: ([multiplicative_expression]) rdiv ([quotient_expres-sion]). Example: (t)rdiv(5).

ddiv : real division operator int(x/y). Similar to rdiv operator but with different syntax.

  Syntax: ddiv ([multiplicative_expression], [quotient_expres-sion]). Example: ddiv(t,5).

rmod : real division module operator x/y-int(x/y).

  Syntax: ([multiplicative_expression]) rmod ([quotient_expres-sion]). Example: (t)rmod(5).

dmod : real division module operator x/y-int(x/y). Similar to rmod operator but with different syntax.

  Syntax: dmod ([multiplicative_expression], [quotient_expres-sion]). Example: dmod(t,5).

max : maximum operator.

  Syntax: max ([expression], [expression]). Example: max(x,y).

min : minimum operator.

  Syntax: min ([expression], [expression]). Example: min(x,y).

 ~ : not operator.

  Syntax: ~[function_expression].

Examples:

(2*y)

(5*(y+1))/2

(z*y)mod(5)

imod(z*y) (5)

(5^4)

Relational operators:

The relational (binary) operators compare their first operand with their second operand to test validity of the specified relationship. The result of the relational expression is 1 if the tested relationship is true and 0 if it is false. The binary operators that can be used for Tdyn functions definitions are:

< : less than operator.

  Syntax: [expression] <  [expression].

< = : less or equal than operator.

  Syntax: [expression] <= [expression].

>= : greater or equal than operator.

  Syntax: [expression] >= [expression].

> : greater than operator.

  Syntax: [expression] > [expression].

= : equal operator.

  Syntax: [expression] = [expression].

!= : not equal operator.

  Syntax: [expression] != [expression].

& : and operator.

  Syntax: [expression] & [expression].

| : and operator.

  Syntax: [expression] | [expression].

Examples:

(y>2)

(x<=1)

(x!=1)

(y>2)&(x>2)&(x<3)&(y<3)

Cartesian derivatives:

It is also possible to use cartesian derivatives to evaluate functions in solid and fluid domains. The Cartesian derivative operators that can be used for Tdyn functions definitions are:

dx : X Cartesian derivative. The argument must be a variable defined in the whole domain (not a function).

dy : Y Cartesian derivative. The argument must be a variable defined in the whole domain (not a function).

dz : Z Cartesian derivative. The argument must be a variable defined in the whole domain (not a function).

Examples:

vx*dx(vx)

nx*dx(vx)+ny*dy(vx)

if-else statement:

The if statement controls conditional branching. The body of the if statement (elif_expression) is executed if the value of the expression is non zero. The syntax for the if statement is the following:

if(expression)then(elif_expression)else(next_expression)endif

being elif_expression an additional expression that may include an elif clause with next form:

(expression2)elif(elif_expression2)then(next_expression2)

Examples:

if(y>2)then(if(x<1)then(1)else(0)endif)else(0)endif

if(y>2)then(1)elif(x<1)then(2)else(0)endif