Download presentation
Presentation is loading. Please wait.
Published bySabina Ellis Modified over 9 years ago
1
Automatic Generation of Numerical Codes Jože Korelc University of Ljubljana, Slovenia www.fgg.uni-lj.si/Symech/
2
2 J. KORELC, UNIVERSITY OF LJUBLJANA Solution procedure required by modern engineering M5 M ulti-field M ulti-scale M ulti-body M ulti-phase M ulti-objective F F
3
3 J. KORELC, UNIVERSITY OF LJUBLJANA Hybrid system for FE code generation and FE analysis AceGen code generator Computational Templates package FE environment dependend user subroutine interface C FORTRAN Mathematica AceGen input user subroutines tangent, residual post-processing.... suplementary subroutines initialization numerical integration Mathematica element source file CDriver C code Math link FEAP ELFEN MDriver full symbolic cappabilities Mathematica ABAQUS Driver Optimisation environment FE environment Mathematica Inverse
4
4 J. KORELC, UNIVERSITY OF LJUBLJANA Concepts of AceGen code generator simultaneous optimization of expressions and introduction of intermediate variables, expression optimisation based on heuristic procedures, generation of characteristic formulae, the whole program structure can be generated, automatic differentiation technique (forward and backward mode), multi-language code generation (FORTRAN, C/C++, Mathematica language), multi-environment code generation (automatic interface to numerical environments) methods for exploring of generated formulae and run time debugging of the generated programs special procedures are needed for non-local ( explicit form of the expressions is lost) AD inside a single subroutine
5
5 J. KORELC, UNIVERSITY OF LJUBLJANA Multi-language code generation with AceGen 1. Mathematical description 2. Symbolic description in AceGen 3. Automatically generated code SUBROUTINE Test(v,u1,x,L,g) REAL*8 v(500),u1(3),x,L,g(3) v(6)=x/L v(7)=1d0 - v(6) v(8)=v(6)*v(7) v(12)=2d0*(u(1)*v(6) + - u(2)*v(7) + u(3)*v(8)) g(1)=v(12)*v(6) g(2)=v(12)*v(7) g(3)=v(12)*v(8) END "Fortran" void Test(double v[501], double u1[3],double *x, double *L,double g[3]) { v[6]=*x/*L; v[7]=1e0 - v[6]; v[8]=v[6]*v[7]; v[12]=2e0*(u[0]*v[6] + u[1]*v[7]+ u[2]*v[8]); g[0]=v[12]*v[6]; g[1]=v[12]*v[7]; g[2]=v[12]*v[8]; }; "C++" Test[]:=Module[{}, $VV[6]=x$$/L$$; $VV[7]=1 - $VV[6]; $VV[8]=$VV[6]*$VV[7]; $VV[12]=2*(u$$[1]*$VV[6] + u$$[2]*$VV[7]+u$$[3]*$VV[8]); g$$[1]=$VV[6]*$VV[12]; g$$[2]=$VV[7]*$VV[12]; g$$[3]=$VV[8]*$VV[12]; ] "Mathematica"
6
6 J. KORELC, UNIVERSITY OF LJUBLJANA Multi-environment code generation MDriverCDriver Suplementary routines user subroutines
7
7 J. KORELC, UNIVERSITY OF LJUBLJANA Open problems Interactions: symbolic system - simultaneous simplification procedure symbolic system - automatic differentiation symbolic system - simultaneous generation of program structure automatic differentiation - simultaneous generation of program structure Verification & validation of generated codes: Are the equations solved correctly? Are the righ equations solved? Interactive debugging of automatically generated numerical codes
8
8 J. KORELC, UNIVERSITY OF LJUBLJANA Symbolic system - simultaneous simplification Simultaneous stochastic optimisation procedure (Korelc 1997) Additional operators Auxiliary variables have standardized form $V[i, j], where i is an index of auxiliary variable and j is an instance of the i-th auxiliary variable.
9
9 J. KORELC, UNIVERSITY OF LJUBLJANA Optimisation of an matrix - common sub expressions Original matrix (input for code generator): Code generator Vector of 3 new auxiliary variables: internal data base Result is simplified matrix, expressed with the new auxiliary variables Mathematica
10
10 J. KORELC, UNIVERSITY OF LJUBLJANA Symbolic system - flow control "If" construct "Do" construct fictive variable $V[i,3] $V[i,1] $V[i,2]
11
11 J. KORELC, UNIVERSITY OF LJUBLJANA Symbolic system - automatic differentiation Automatic differentiation technique (AD): –differentiation of the whole program –automatic differentiation tool generates a program code for the derivative from a program code for the basic function Reverse mode / Forward mode En hancements with respect to the standard AD technique: –AD procedure can be initiated at any time and at any point of derivation of the formulas and as many times as required –AD as code-to-code translator has to be replaced by the method that consistently extends current code rather than produce a new one –the results of all previous uses of AD have to be accounted for when AD is used several times inside the same subroutine –The user has to be able to use all the capabilities of the symbolic system on the final and intermediate results of AD procedure.
12
12 J. KORELC, UNIVERSITY OF LJUBLJANA AD exceptions Exceptions handling function: The basic situations that have to be considered are: there exists implicit dependency between variables that has to be considered for the differentiation there exists explicit dependency between variables that has to be neglected for the differentiation the evaluation of the derivative code would lead to numerical errors Example:
13
13 J. KORELC, UNIVERSITY OF LJUBLJANA Example: limit load optimisation of cantilever beam Task: find the shape (h(x)) of cantilever beam that has: –minimal volume –given ultimate load –ideal elasto-plastic material Properties of the problem: –transient coupled problem –gradient based optimisation b b A Response direct analysis optimal solution optimal shape?
14
14 J. KORELC, UNIVERSITY OF LJUBLJANA Formulation of the problem Three finite elemnts are needed to describe the problem: –2D elasto plastic element –line load element –prescribed displacement constrain element Objective function Newton-Raphson scheme to solve direct problem
15
15 J. KORELC, UNIVERSITY OF LJUBLJANA Solution Analytical solution can be obtained by assuming: –Bernoully beam theory –in optimal case every material point is in plastic condition Optimal finite element solution for given load
16
16 J. KORELC, UNIVERSITY OF LJUBLJANA Typical examples: Multi - field problems unduction heating T. Šuštar, C3M - Ljubljana, Slovenia Magnetic Thermal Mechanical
17
17 J. KORELC, UNIVERSITY OF LJUBLJANA Typical examples: Multi-scale problems MACRO - elastic properties of contact surface MICRO - 3D surface roughness MACRO - thermal properties of contact surface MACRO - lubricant flow in contact surface S. Stupkiewicz, IPPT, Warsaw, Poland
18
18 J. KORELC, UNIVERSITY OF LJUBLJANA Typical examples: structural analysis Sensitivity analysis of single-storey steel building four node shell elements and large displacement truss elements A
19
19 J. KORELC, UNIVERSITY OF LJUBLJANA Typical examples: Simulation of technological proces Two phase forging J. Lengiewicz, IPPT, Warsaw, Poland
20
20 J. KORELC, UNIVERSITY OF LJUBLJANA Conclusions Hybrid system presented is a powerfull tool for solving large-scale engineering problems System can be dowloaded from www.fgg.uni- lj.si/Symech/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.