functions and formulas - code aster · functions and formulas. 2 - code_aster and salome-meca...

16
Code_Aster, Salome-Meca course material GNU FDL licence (http://www.gnu.org/copyleft/fdl.html) Functions and formulas

Upload: dangngoc

Post on 31-Dec-2018

269 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

Code_Aster, Salome-Meca course materialGNU FDL licence (http://www.gnu.org/copyleft/fdl.html)

Functions and formulas

Page 2: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

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

Page 3: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

3 - 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

DY

DZ

Displacement along XDisplacement along YDisplacement along Z

SIGM Stress

DRXDRY

DRZ

Rotation around XRotation around YRotation around Z

INST Time

X

Y

Z

Coordinate XCoordinate YCoordinate Z

TEMP Temperature

Page 4: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

General principles of code and platform (1/4)

Function : definition by (xi,yi)

Parameterx1 x2 x3 x4 x5 ...x0

y0

y1

y2

...

Function

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

Page 5: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Function in Code_Aster : mathematical sense

Function

One abscissa value, several

ordinate (y-axis) values:

→ NOT a function

Function have a domain of definition

Function can be complex or real

Abscissa is only real

domain of definition

Cor R

R

Page 6: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Function

By default, a function

cannot be evaluated

outside its domain of

definition

Extension on rightPROL_DROITE

Extension on leftPROL_GAUCHE

EXCLU :no extension (default)

CONSTANT :extension by last value

LINEAIRE :extension by linear extrapolation

CONSTANT

CONSTANT

EXCLUEXCLU

Page 7: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Function : interpolation between points

Function

Function : interpolation between points

Parameterx1 x2 x3 x4 x5 ...x0

y0

y1

y2

...

Function Function is lineary

interpolated between two

points :INTERPOL='LIN' (default)

You could choose logarithmic

interpolation : INTERPOL='LOG'

(x1,y1)

(x2,y2)

1

21

21y+

xx

yy

=y

Page 8: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

8 - 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.,),))

DEBUT=1.

1.0. 2. 3. 4. 5. 7.6. 8. 9. 10. 11.

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

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

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

PAS=2. PAS=2. PAS=2.

Page 9: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Function

Function : Definition

fonc=DEFI_FONCTION(NOM_PARA='INST',

VALE=( 0. ,2. ,

1. ,3. ,

2. ,4. ,

3. ,3. ,)

PROL_GAUCHE='EXCLU',

PROL_DROITE='CONSTANT')

INST

fonc

0

.

1

.

2

.

3

.

4

.

0

.

1

.

2

.

3

.

4

.

5

.

6

.

PROL_DROITE='CONSTANT'

ABSC=DEFI_LIST_REEL(VALE=(1.,2.,3.,4.,))

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')

Complex function :VALE_C instead of VALE

! Abscissas increase

Page 10: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Function

Function with two parameters: DEFI_NAPPE

See zzzz100a test-case for several examples

nappe=DEFI_NAPPE(NOM_PARA='AMOR',

PARA=(0.01,0.02,),

FONCTION=(DF1,DF2,)

PROL_DROITE='CONSTANT',

PROL_GAUCHE='CONSTANT')

Function of function :

Previous defined

functions

nappe=DEFI_NAPPE(NOM_PARA='PULS',

PARA=(0.01, 0.03,),

NOM_PARA_FONC='INST',

DEFI_FONCTION=(

_F(VALE = (3.,1.,4.,2.,5.,3.,)),

_F(VALE = (3.,3.,4.,4.,5.,5.,))))

Function of function :

Redefining functions in DEFI_NAPPE

Page 11: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Formula

Formula : defined by a mathematical function

See zzzz100a test-case for several examples

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

Page 12: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Formula

Formula is Python function

See zzzz100a test-case for several examples

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

X = SIa(1.57)

print SIa(1.57)

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

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

Python evaluation

Function of

function

def HEAVISIDE(x) :

if x<0. : return 0.

If x>=0. : return 1.

F_HVS = FORMULE( NOM_PARA = 'INST',

VALE = 'HEAVISIDE(INST)')

0. si 1.

0. si 0.

x

<x=xHEAVISIDE

High-level function

from math import pi

OMEGA = 30.

NAP = FORMULE(NOM_PARA = ('AMOR','FREQ'),

VALE =

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

+(2.*AMOR*2.*pi*FREQ*OMEGA)**2)''')

Function with

several parameters

Page 13: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Formula

Transform FORMULE in FONCTION:CALC_FONC_INTERP

Transform FORMULE in NAPPE:CALC_FONC_INTERP

See zzzz100a test-case for several examples

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')

Page 14: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

14 - 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

Page 15: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

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

Other commands

• See zzzz100a test-case for several examples

Read function from file LIRE_FONCTION

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

INFO_FONCTION

Print a function (for XmGrace software for instance)

IMPR_FUNCTION

Create function from results or from field RECU_FONCTION

Page 16: Functions and formulas - Code Aster · Functions and formulas. 2 - Code_Aster and Salome-Meca course material GNU FDL Licence Definitions ... DRX DRY DRZ Rotation around X Rotation

16 - 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.