0% found this document useful (0 votes)
268 views

Functions and Formulas: Code - Aster, Salome-Meca Course Material

The document discusses functions, formulas, and parameters in Code_Aster and Salome-Meca. It defines functions as tabulated discrete functions depending on one or two parameters. Formulas are defined as continuum mathematical formulas depending on several parameters. It provides examples of defining functions and formulas and discusses interpolation, extensions, and function of function definitions. Key parameters discussed include displacement, strain, stress, temperature, and time.

Uploaded by

Stefano Milani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
268 views

Functions and Formulas: Code - Aster, Salome-Meca Course Material

The document discusses functions, formulas, and parameters in Code_Aster and Salome-Meca. It defines functions as tabulated discrete functions depending on one or two parameters. Formulas are defined as continuum mathematical formulas depending on several parameters. It provides examples of defining functions and formulas and discusses interpolation, extensions, and function of function definitions. Key parameters discussed include displacement, strain, stress, temperature, and time.

Uploaded by

Stefano Milani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Functions and formulas

Code_Aster, Salome-Meca course material


GNU FDL licence (http://www.gnu.org/copyleft/fdl.html)
Definitions

FONCTION :
tabulated (discrete) function depending on one parameter

NAPPE :
tabulated (discrete) function depending on two
parameters

FORMULE :
continuum mathematic formula depending on several
parameters

2 - Code_Aster and Salome-Meca course material GNU FDL Licence


Parameters

Parameters : the most useful in Code_Aster

ABSC_CURV Curvilinear abscissa EPSI Strain


DX Displacement along X SIGM Stress
DY Displacement along Y
DZ Displacement along Z
DRX Rotation around X INST Time
DRY Rotation around Y
DRZ Rotation around Z
X Coordinate X TEMP Temperature
Y Coordinate Y
Z Coordinate Z

3 - Code_Aster and Salome-Meca course material GNU FDL Licence


General principles of code and platform (1/4)
Function : definition by (xi,yi)

Function

...
y2
y1
y0

Parameter
x0 x1 x2 x3 x4 x5 ...

Abscissas values are stricly increasing : x0<x1<x2<x3<x4<x5<x6<x7<x8<...

4 - Code_Aster and Salome-Meca course material GNU FDL Licence


Function
Function in Code_Aster : mathematical sense

One abscissa value, several


ordinate (y-axis) values:
→ NOT a function

Function have a domain of definition


domain of definition

R or C

Function can be complex or real


R
Abscissa is only real

5 - Code_Aster and Salome-Meca course material GNU FDL Licence


Function

EXCLU
By default, a function
EXCLU cannot be evaluated
outside its domain of
definition

Extension on left CONSTANT Extension on right


PROL_GAUCHE PROL_DROITE
CONSTANT

EXCLU :no extension (default)


CONSTANT :extension by last value
LINEAIRE :extension by linear extrapolation

6 - Code_Aster and Salome-Meca course material GNU FDL Licence


Function

Function : interpolation between points


Function y y
Function is lineary
y=
1 2
+y interpolated between two
x x 1
... (x1,y1) 1 2 points :
y2 INTERPOL='LIN' (default)
y1
y0 You could choose logarithmic
(x2,y2) interpolation :
INTERPOL='LOG'

Parameter
x0 x1 x2 x3 x4 x5 ...

7 - Code_Aster and Salome-Meca course material GNU FDL Licence


List of real values

Defining list of real : DEFI_LIST_REEL

ListR = DEFI_LIST_REEL(DEBUT =1.,


INTERVALLE=(_F(JUSQU_A=5.,NOMBRE=2,),
_F(JUSQU_A=11.,PAS=2.,),))

JUSQUA=5.,NOMBRE=2 JUSQUA=11.,PAS=2.
DEBUT=1.
PAS=2. PAS=2. PAS=2.

0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.

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

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

8 - Code_Aster and Salome-Meca course material GNU FDL Licence


Function
Function : Definition
fonc=DEFI_FONCTION(NOM_PARA='INST',
VALE=( 0. ,2. ,
fonc 1. ,3. ,
2. ,4. ,
4 3. ,3. ,)
. PROL_DROITE='CONSTANT'
3 PROL_GAUCHE='EXCLU',
. PROL_DROITE='CONSTANT')
2
.
1
. INST
0
. 0 1 2 3 4 5 6 ABSC=DEFI_LIST_REEL(VALE=(1.,2.,3.,4.,))
. . . . . . . ORDO=DEFI_LIST_REEL(VALE=(2.,3.,4.,3.,))
Complex function : fonc=DEFI_FONCTION(
VALE_C instead of VALE NOM_PARA='INST',
VALE_PARA=ABSC,
VALE_FONC=ORDO,
PROL_GAUCHE='EXCLU',
Abscissas increase PROL_DROITE='CONSTANT')
!

9 - Code_Aster and Salome-Meca course material GNU FDL Licence


Function
Function with two parameters: DEFI_NAPPE

nappe=DEFI_NAPPE(NOM_PARA='AMOR',
PARA=(0.01,0.02,), Function of function :
FONCTION=(DF1,DF2,)
PROL_DROITE='CONSTANT', Previous defined
PROL_GAUCHE='CONSTANT') functions

nappe=DEFI_NAPPE(NOM_PARA='PULS',
PARA=(0.01, 0.03,),
NOM_PARA_FONC='INST', Function of function :
DEFI_FONCTION=( Redefining functions
_F(VALE = (3.,1.,4.,2.,5.,3.,)), in DEFI_NAPPE
_F(VALE = (3.,3.,4.,4.,5.,5.,))))

See zzzz100a test-case for several examples

10 - Code_Aster and Salome-Meca course material GNU FDL Licence


Formula
Formula : defined by a mathematical function
form = FORMULE(NOM_PARA='X',
VALE= '''sin(X)''' )

« Using Python as a calculator »


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

The main functions of Python math module are imported by default in


Code_Aster (from math import * is not necessary)

Use triple quote ''' to define formulas


! on several lines in Python

See zzzz100a test-case for several examples

11 - Code_Aster and Salome-Meca course material GNU FDL Licence


Formula
Formula is Python function
SIa = FORMULE(NOM_PARA='X',VALE='sin(X)') Python evaluation
X = SIa(1.57)
print SIa(1.57)

SIa = FORMULE(NOM_PARA='X',VALE='sin(X)') Function of


SIb = FORMULE(NOM_PARA='X',VALE='X*SIa(X)') function
def HEAVISIDE(x) : High-level function
if x<0. : return 0.
If x>=0. : return 1. si
x 
HEAVISIDE
x=0. <0.
F_HVS = FORMULE( NOM_PARA = 'INST', 
VALE = 'HEAVISIDE(INST)') 
1.x
si 0.

from math import pi Function with


OMEGA = 30. several parameters
NAP = FORMULE(NOM_PARA = ('AMOR','FREQ'),
VALE =
'''(1./((2.*pi*FREQ)**2 - OMEGA**2 )**2
+(2.*AMOR*2.*pi*FREQ*OMEGA)**2)''')

See zzzz100a test-case for several examples


12 - Code_Aster and Salome-Meca course material GNU FDL Licence
Formula
Transform FORMULE in FONCTION:CALC_FONC_INTERP

SI = FORMULE(NOM_PARA = 'INST',
VALE = '''sin(INST)''')
DEPI = 2.*pi
PAS0 = DEPI/200.
LI1 = DEFI_LIST_REEL(DEBUT = 0,INTERVALLE=_F(JUSQU_A=DEPI,
PAS=PAS0),)
SI1 = CALC_FONC_INTERP(FONCTION = SI,
LIST_PARA = LI1,
PROL_GAUCHE ='EXCLU',
PROL_DROITE ='CONSTANT')

Transform FORMULE in NAPPE:CALC_FONC_INTERP

See zzzz100a test-case for several examples

13 - Code_Aster and Salome-Meca course material GNU FDL Licence


Remarks

Using FONCTION or FORMULE ?


• Function are tabulated : faster when using in low-level
Fortran (behavior law for instance)
• Formulas are « exact » : more precise
• Defining FORMULE and use CALC_FONC_INTERP !

Where using functions ?


• Boundary conditions (AFFE_CHAR_MECA_F command
for instance)
• Behavior law : traction curve for elastoplastic, laws
depending on temperature
• Multiplicative functions for boundary conditions in non-
linear

14 - Code_Aster and Salome-Meca course material GNU FDL Licence


Other commands

Read function from file LIRE_FONCTION


Get information about function (maximum, INFO_FONCTION
rms, etc.)
Print a function (for XmGrace software for IMPR_FUNCTION
instance)
Create function from results or from field RECU_FONCTION

• See zzzz100a test-case for several examples

15 - Code_Aster and Salome-Meca course material GNU FDL Licence


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.

16 - Code_Aster and Salome-Meca course material GNU FDL Licence

You might also like