Functions and formulas - Code_Aster · 2020. 9. 23. · Outline 1. Array and parameters 2....

Preview:

Citation preview

Functionsand formulas

code_aster, salome_meca course materialGNU FDL licence (http://www.gnu.org/copyleft/fdl.html)

Outline

1. Array and parameters

2. Functions

3. Formulas

GNU FDL licence | code_aster, salome_meca course material

3

1. Array and parameters

Array – A list of real numbers

GNU FDL licence | code_aster, salome_meca course material

Usages:

Time discretization of non-linear or dynamic calculation, function definition, …

Define by command DEFI_LIST_REEL

Example: ListR = DEFI_LIST_REEL(VALE=(1.,3.,5.,7.,9.,11.))

ListR = DEFI_LIST_REEL(VALE=range(1.,13.,2.))

ListR = DEFI_LIST_REEL ( DEBUT =1., INTERVALLE = ( _F ( JUSQU_A = 5., NOMBRE = 2,),

_F ( JUSQU_A = 11., PAS=2.,),))

4

1. Array and parameters

Parameters in code_aster

GNU FDL licence | code_aster, salome_meca course material

Parameter names are determined by code_aster, NOT users

List of the most useful parameters

ABSC_CURV Curvilinear abscissa EPSI Strain

DXDYDZ

Displacement along XDisplacement along YDisplacement along Z

SIGM Stress

DRXDRYDRZ

Rotation around XRotation around YRotation around Z

INST Time

XYZ

Coordinate XCoordinate YCoordinate Z

TEMP Temperature

Outline

1. Array and parameters

2. Functions

3. Formulas

GNU FDL licence | code_aster, salome_meca course material

6

2. Functions

Function – Definition by (𝑥𝑖,𝑦𝑖):

GNU FDL licence | code_aster, salome_meca course material

Parameter 𝑥𝑖

Abscissas values are strictly increasing: 𝑥0 < 𝑥1 < 𝑥2 < 𝑥3 < 𝑥4 < 𝑥5 < ⋯

Function values 𝑦𝑖

7

2. Functions

Function – Mathematical sense

GNU FDL licence | code_aster, salome_meca course material

One value 𝑦𝑖 for one abscissa 𝑥𝑖:

Several values → NOT a function

Function has a domain definition

Function values can be real or

complex, but parameter must be real

Domain definition

8

2. Functions

Function – Trois extension possibilities

GNU FDL licence | code_aster, salome_meca course material

EXCLU – no extension (by default)

CONSTANT – extension by last value

LINEAR – extension by linear extrapolation

Keyword for

extension on left:

PROL_GAUCHE

Keyword for

extension on left:

PROL_DROITE

9

2. Functions

Function - Defined by command DEFI_FONCTION

GNU FDL licence | code_aster, salome_meca course material

Example

Definition with values

fonc = DEFI_FONCTION ( NOM_PARA = 'INST',

VALE=( 0. , 2. ,

1. ,3. ,

2. ,4. ,

3. ,3. ,)

PROL_GAUCHE = 'EXCLU',

PROL_DROITE = 'CONSTANT‘ )

10

2. Functions

Function - Defined by command DEFI_FONCTION

GNU FDL licence | code_aster, salome_meca course material

Example

Definition with arrays ABSC = DEFI_LIST_REEL ( VALE = ( 0., 1., 2., 3., ) )

ORDO = DEFI_LIST_REEL ( VALE = ( 2., 3., 4., 3., ) )

fonc = DEFI_FONCTION ( NOM_PARA = 'INST',

VALE_PARA = ABSC,

VALE_FONC = ORDO,

PROL_GAUCHE = 'EXCLU',

PROL_DROITE = 'CONSTANT‘ )

11

2. Functions

Function – Interpolation between points

GNU FDL licence | code_aster, salome_meca course material

linear interpolation (by default): INTERPOL = ‘LIN’

Logarithmic interpolation: INTERPOL = ‘LOG’

12

2. Functions

Function - Usages

GNU FDL licence | code_aster, salome_meca course material

Where using functions ?

Boundary conditions or loads (AFFE_CHAR_MECA_F command for instance)

Behavior law: traction curve for elastoplastic, laws depending on temperature

Multiplicative functions for boundary conditions or loads

Examples:

FORC = AFFE_CHAR_MECA ( … FORCE_CONTOUR = _F ( GROUP_MA='haut', FY=1.,),);

RAMPE = DEFI_FONCTION ( NOM_PARA = 'INST', VALE = ( 0.0, 0.0, 1000.,1000., ),);

RESU = STAT_NON_LINE ( … EXCIT=( _F ( CHARGE = FORC,

FONC_MULT = RAMPE,),), … )

Constant force 𝑓

Function 𝑔 𝑡 = 𝑡

Final load𝑓 ∗ 𝑔(𝑡)

13

2. Functions

Function – Other related commands

GNU FDL licence | code_aster, salome_meca course material

LIRE_FONCTION

Read function from file

INFO_FONCTION

Get information about function (maximum, rms, etc.)

IMPR_FONCTION

Print a function (for XmGrace software for instance)

RECU_FONCTION

Create function from results or from field

Outline

1. Array and parameters

2. Functions

3. Formulas

GNU FDL licence | code_aster, salome_meca course material

15

3. Formulas

FORMULA – Defined by a mathematical function

GNU FDL licence | code_aster, salome_meca course material

Using Python as a calculator

Main functions of Python math module (imported by default in Code_Aster)

For more information: http://docs.python.org/tut/tut.html,

http://docs.python.org/lib/module-math.html

Python function by command FORMULE

Python evaluation

SIa = FORMULE ( NOM_PARA = 'X', VALE = ‘sin(X)’ )

X = SIa (1.57)

Function of function

SIb = FORMULE ( NOM_PARA = 'X', VALE = ‘X*SIa(X)’ )

16

3. Formulas

FORMULA – Defined by a mathematical function

GNU FDL licence | code_aster, salome_meca course material

Python function by command FORMULE

High-level function

def HEAVISIDE(x) :

if x<0. : return 0.

If x>=0. : return 1.

F_HVS = FORMULE( NOM_PARA = 'INST', VALE = 'HEAVISIDE(INST) ' )

Function with several parameters

from math import pi

OMEGA = 30.

NAP = FORMULE ( NOM_PARA = ( ‘OMEGA ', 'FREQ'),

VALE = '(1./((2.*pi*FREQ)**2 - OMEGA**2 )**2 )’ )

0. si 1.

0. si 0.

x

<x=xHEAVISIDE

17

3. Formulas

FORMULA – Transform into code_aster function

GNU FDL licence | code_aster, salome_meca course material

Command CALC_FONC_INTERP

Example

SI = FORMULE ( NOM_PARA = 'INST', VALE = 'sin(INST)‘ )

DEPI = 2.*pi

LI1 = DEFI_LIST_REEL ( DEBUT = 0, INTERVALLE =_F ( JUSQU_A = DEPI,

NOMBRE = 200 ),)

F_SI = CALC_FONC_INTERP ( FONCTION = SI,

LIST_PARA = LI1,

PROL_GAUCHE = 'EXCLU',

PROL_DROITE = 'CONSTANT‘ )

Outline

1. Array and parameters

2. Functions

3. Formulas

GNU FDL licence | code_aster, salome_meca course material

Remarks

19

Remarks

Functions or formulas?

GNU FDL licence | code_aster, salome_meca course material

Function are tabulated

faster when using in low-level Fortran (behavior law for instance)

Formulas are « exact »: more precise

See zzzz100a test-case for several examples

NAPPE

Tabulated (discrete) function depending on two parameters

Function of function

End of presentation

Is something missing or unclear in this document?

Or feeling happy to have read such a clear tutorial?

Please, we welcome any feedbacks about Code_Aster training materials.

Do not hesitate to share with us your comments on the Code_Aster forum

dedicated thread.

GNU FDL licence | code_aster, salome_meca course material

Recommended