Acegen Code Generator
Total Page:16
File Type:pdf, Size:1020Kb
AAcceeGGeenn SMSInitialize "test", "Language" −> "Fortran" ; SMSModule "test", Real x$$, f$$ ; x£ SMSReal x$$ ; @ D Module : @test @ DD @ D SMSIf x<= 0 ; f• x2; SMSElse ; @ D f§ Sin x ; J. Korelc SMSEndIf f ; @D SMSExport@ D f, f$$ ; SMSWrite@"test"D ; Function :@ testD 4 formulae, 18 sub−expressions 0 File@ createdD : test.f Size : 850 @ D UNIVERSITY OF LJUBLJANA FACULTY OF CIVIL AND GEODETIC ENGINEERING 2006 2 AceGen code generator AceGen Contents AceGen Contents ................................................................................................................... 2 Tutorial ........................................................................................................................................ 7 Preface ............................................................................................................................... 7 Introduction ..................................................................................................................... 8 General .......... 8 AceGen .......... 8 Mathematica and AceGen ...... 10 Bibliography .. 11 Standard AceGen Procedure ................................................................................... 12 Load AceGen package ........... 12 Description of Introductory Example 12 Description of AceGen Characteristic Steps .. 12 Generation of C code . 15 Generation of MathLink code 16 Generation of Matlab code .... 18 Symbolic-Numeric Interface ..................................................................................... 19 Auxiliary Variables ........................................................................................................ 21 User Interface ................................................................................................................. 25 Verification of Automatically Generated Code ................................................. 34 Expression Optimization ........................................................................................... 38 Program Flow Control ................................................................................................. 40 Algebraic Operations .................................................................................................. 44 Automatic Differentiation ...... 44 Symbolic Evaluation .. 48 Linear Algebra ........... 49 Other Algebraic Computations .......... 51 Advanced Features ............................................................................................................... 52 Arrays ................................................................................................................................. 52 User Defined Functions .............................................................................................. 54 Exceptions in Differentiation ................................................................................... 56 Characteristic Formulae ............................................................................................. 60 Non-local Operations .................................................................................................. 65 Signatures of the Expressions ................................................................................ 66 Reference Guide ..................................................................................................................... 69 AceGen Session ............................................................................................................ 69 SMSInitialize . 69 SMSModule ... 71 SMSWrite ...... 72 SMSEvaluateCellsWithTag ... 74 AceGen code generator 3 SMSVerbatim 75 SMSPrint ....... 76 Basic Assignments ...................................................................................................... 79 SMSR or £ ..... 79 SMSV or ¢ ..... 80 SMSM or ¥ .... 80 SMSS or ¤ .... 81 SMSInt .......... 82 SMSSimplify . 82 SMSVariables 83 Symbolic-numeric Interface ..................................................................................... 83 SMSReal ........ 83 SMSInteger .... 84 SMSLogical ... 84 SMSRealList . 85 SMSExport .... 87 SMSCall ........ 88 Smart Assignments ...................................................................................................... 90 SMSFreeze .... 90 SMSFictive .... 95 SMSReplaceAll ......... 96 SMSSmartReduce ...... 98 SMSSmartRestore ..... 98 SMSRestore ... 99 Arrays ................................................................................................................................. 99 SMSArray ...... 99 SMSPart ......... 100 SMSReplacePart ........ 101 SMSDot ......... 101 SMSSum ........ 102 Differentiation ................................................................................................................. 103 SMSD 103 SMSDefineDerivative ............ 106 Program Flow Control ................................................................................................. 107 SMSIf 107 SMSElse ........ 111 SMSEndIf ...... 112 SMSDo .......... 112 SMSEndDo .... 116 SMSReturn, SMSBreak, SMSContinue ......... 117 Utilities ....................................................................................................................................... 118 Debugging ........................................................................................................................ 118 SMSSetBreak 118 SMSLoadSession ....... 118 SMSAnalyze .. 118 SMSClearBreak ......... 121 SMSActivateBreak .... 121 4 AceGen code generator Random Value Functions .......................................................................................... 121 SMSAbs ........ 121 SMSSign ........ 122 SMSKroneckerDelta .. 122 SMSSqrt ........ 122 SMSMin,SMSMax .... 122 SMSRandom . 123 General Functions ........................................................................................................ 123 SMSNumberQ ........... 123 SMSPower ..... 123 SMSTime ....... 123 SMSUnFreeze ............ 123 Linear Algebra ................................................................................................................ 124 SMSLinearSolve ........ 124 SMSLUFactor ............ 124 SMSLUSolve . 124 SMSFactorSim ........... 124 SMSInverse ... 125 SMSDet ......... 125 SMSKrammer 125 Tensor Algebra ............................................................................................................... 125 SMSCovariantBase .... 125 SMSCovariantMetric . 126 SMSContravariantMetric ....... 126 SMSChristoffell1 ....... 127 SMSChristoffell2 ....... 127 SMSTensorTransformation ... 128 SMSDCovariant ......... 128 Mechanics of Solids ..................................................................................................... 129 SMSLameToHooke, SMSHookeToLame, SMSHookeToBulk, SMSBulkToHooke . 129 SMSPlaneStressMatrix, SMSPlaneStrainMatrix ........ 129 SMSEigenvalues ........ 130 SMSMatrixExp .......... 130 SMSInvariantsI,SMSInvariantsJ ........ 130 General Numerical Environments ................................................................................... 131 MathLink Environment .............................................................................................. 131 SMSInstallMathLink . 131 SMSLinkNoEvaluations ........ 131 SMSSetLinkOptions .. 131 Matlab Environment ..................................................................................................... 132 Finite Element Environments ............................................................................................ 133 FE Environments Introduction ................................................................................ 133 Standard FE Procedure .............................................................................................. 135 User defined environment interface ..................................................................... 139 Reference Guide ............................................................................................................ 141 SMSTemplate 141 SMSStandardModule . 141 AceGen code generator 5 Template Constants ... 147 Element Topology ..... 151 Node Identification .... 155 Numerical Integration 155 Elimination of local unknowns .......... 162 Subroutine: "Sensitivity pseudo-load" and "Dependent sensitivity" .. 163 Subroutine: "Postprocessing" 165 Data Structures .............................................................................................................. 166 Environment Data ...... 166 Integer Type Environment Data ......... 166 Real Type Environment Data . 171 Node Data Structures . 172 Node Specification Data ........ 172 Node Data ...... 173 Element Data Structures ........ 174 Domain Specification Data .... 174 Element Data . 179 Problem Solving Environments .............................................................................. 179 AceFEM ......... 179 FEAP 179 ELFEN ........... 182 Other environments ... 185 Interactions: Templates-AceGen-AceFEM ......................................................... 186 Interactions: Glossary 186 Interactions: Element Topology ......... 186 Interactions: Memory Management ... 187 Interactions: Element Description ...... 187 Interactions: Input Data ......... 188 Interactions: Mathematica ..... 188 Interactions: Presentation of Results .. 189 Interactions: General .. 189 AceGen Examples .................................................................................................................. 190 About AceGen Examples ........................................................................................... 190