4d77e52f890be43fa3058291bad68bb2.ppt
- Количество слайдов: 26
Some Applications of Automatic Differentiati Rigid, Flexible, and Constrained Multibody Dynamics D. T. Griffith Sandia National Laboratories J. D. Turner Dynacs J. L. Junkins Texas A&M University ASME 2005 International Design Engineering Technical Conferences September 24, 2005
Folk theorem The Chain Rule, when applied by hand recursively to even moderately dimensioned nonlinear systems, for more than two orders of differentiation, stops being fun around age 45. Empirical Evidence: The master differentiator, James Turner tried to automate the process completely during his late forties. 2
Presentation Outline • Introduction to Automatic Differentiation • Modeling • Rigid and flexible multibody systems • Constrained multibody systems • Automatic generation of exact PDE/ODEs and BCs for hybrid systems validation of approximate solutions • Numerical Examples 3
Comparison of Computerized Differentiation Approaches • Symbolic Differentiation – Very useful and popular – Matlab, Maple, Mathcad, Macsyma – Pros: Can view expressions & control simplification/ approximation on screen – Cons: Result in lengthy expressions and require code generation/porting/de-bugging • Automatic Differentiation (AD) – Generally, not as well-known as Symbolic Differentiation – Recursive, automated use of Chain Rule … – Begins with FORTRAN, C or …code that computes the functions to be differentiated – ADIFOR, AD 01, ADOL-C, AUTODERIVE, OCEA – Pro: Derivatives computed & possibly coded without (*much*) user intervention – Historical Cons: Limited order of differentiation and also, usually requires code generation OCEA is a novel AD approach that enables 1 st- through 4 th-order derivatives, with zero code generation required. There are very important implications in many fields, including multi-body dynamics. 4
Overview of automatic differentiation by OCEA – OCEA (Object Oriented Coordinate Embedding Method) – Define new data structure (OCEA second-order method), for example for the function scalar f : – All intrinsic operators ( +, - , * , / , = ) are overloaded to enable, for example, addition and multiplication of OCEA variables. Examples: You code: OCEA computes: – Composite Functions (chain rule, use recursively, numerically!): You code: OCEA computes: – Let’s take a look at an illustrative example…. 5
Overview of automatic differentiation by OCEA • A second-order OCEA example • Suppose: OCEA-FORTRAN ! X(1) = x, Declare OCEA independent variables , type EB X(2) = y Type(EB): : X(2)We desire to Type(EB): : compute f 3 and most F 1, F 2, F 3 importantly its partials: Real(DP): : S_F 3, JAC_F 3(2), HES_F 3(2, 2) Declare OCEA dependent variables, type EB ! Code Functions F 1 = X(1)**3 + X(2) F 2 = (X(2)**2)*sin( X(1) ) F 3 = F 1 + F 2 function Jacobian Declare function and partial derivative arrays , type DP Hessian Code functions Extract partial You never had to derive, code, or debug: S_F 3 = F 3 ! Extract function JAC_F 3 = F 3 ! Extract Jacobian (2 x 1) HES_F 3 = F 3 ! Extract Hessian (2 x 2) derivative information 6
Equation of motion formulation using automatic differentiation Lagrange’s equations: Lagrangian: T, V: kinetic and potential energy q: generalized coordinates Q: generalized force subject to C(q): constraint Jacobian matrix l: Lagrange multipliers Of course, many choices for equation of motion formulation exist. The OCEA approach is broadly applicable, however, the utility of automatic differentiation can be immediately seen and appreciated for implementing Lagrange’s Equations… 7
Implementation of Lagrange’s Equations: A Direct Approach (1) Automatic Differentiation (AD) Specified & coded AD or specified & coded Many numerical methods AD or specified & coded Mass matrix and its time derivative extracted as second-order Automatic Differentiation of T … 8
Implementation of Lagrange’s Equations: A Direct Approach (2) Can also compute constraint matrix, C, automatically for holonomic type constraint. Now forming the equations: Accelerations computed after generating or prescribing all terms here. Now, can proceed with numerical integration……. 9
Illustrative Example: Spring Pendulum (1) r Lagranges Eqs: Directly invoke ODE solver in OCEA to get solution W/O hand derivation, coding, or checkout … only derive & code T, V 10
Spring Pendulum (2) SUBROUTINE SPRING_PEND_EQNS( PASS, TIME, X, DXDT, FLAG ) USE EB_HANDLING IMPLICIT NONE ******************** !. . . LOCAL VARIABLES TYPE(EB): : L, T, V ! LAGRANGIAN, KINETIC, POTENTIAL REAL(DP): : M, K ! MASS AND STIFFNESS VALUES REAL(DP), DIMENSION(NV): : JAC_L REAL(DP), DIMENSION(NV, NV): : HES_L ******************** ! X(1) = Q(1) = R, X(2) = Q(2) = THETA, X(3) = d. R/dt, X(4) = d. THETA/dt R 0 = 0. 55 D 0 GRAV = 9. 81 D 0 T = 0. 5 D 0*M*(X(3)**2 + X(1)**2*X(4)**2) ! DEFINE KE V = 0. 5 D 0*K*(X(1)-R 0)**2 + M*GRAV*(R 0 -X(1)*COS(X(2))) ! DEFINE PE L=T–V ! DEFINE LAGRANGIAN FUNCTION JAC_L = L JAC_L_Q = JAC_L(1: NV/2) ! EXTRACT d. L/(dq, dqdot) ! EXTRACT d. L/dq HES_L = L ! EXTRACT 2 nd ORDER PARTIALS OF LAGRANGIAN MASS = HES_L(NV/2+1: NV, NV/2+1: NV) ! EXTRACT MASS MATRIX MASSDOT = HES_L(NV/2+1: NV, 1: NV/2) ! EXTRACT MDOT ! QDOTDOT = INV(MASS)*(- MASSDOT*Q + JAC_L_Q ) ! SEE PAPER … ******************** DXDT(1)%E = X(3)%E ! RDOT DXDT(2)%E = X(4)%E ! THETADOT DXDT(3)%E = QDOTDOT(1) ! RDOTDOT DXDT(4)%E = QDOTDOT(2) ! THETADOTDOT END SUBROUTINE SPRING_PEND_EQNS 11
Geometry of Multiple Flexible Link Configuratio Note from the figure of a series of deformed links that the local coordinate frames attached to the links are defined such that the elastic deformation vanishes at the endpoints. This choice greatly simplifies the “downstream” velocity expressions. 12
Kinetic Energy Generalization for Flexible Link Assumed Modes Method used to transform the kinetic energy expression into a form which can be tamed by Lagrange’s Equations. The details can be found in the paper. Along with the potential energy expression, we can define the Lagrangian and proceed to generate the equations of motion…………. . 13
Example: Closed-chain 5 -link Manipulator (1) g 5 link manipulator D The Lagrangian expressions are developed for each link and summed to form the total system Lagrangian. Additionally, we specify two holonomic constraints of the form: And, we specify damping at all joints with the exception of the base end of link 5. OCEA automatically generates the equations of motion for the constrained system 14
Example: Closed-chain 5 -link Manipulator (2) 15
Example: 4 -link Planar Truss (1) 4 -link planar truss with “springs” across diagonal The Lagrangian expressions are developed for each link and summed to form the total system Lagrangian. Now, we consider translation as well. Additionally, we specify two holonomic constraints of the form: 3 2 4 1 OCEA automatically generates the equations of motion for the constrained system 16
Example: 4 -link Planar Truss (2) Starting with zero flexible energy initially, we can assess the suitability of rigid body modeling. Question: How much flexibility exists in the system? 17
Accuracy of Solutions: Comparison with Hard-coded Equ Motion for Flexible Double Pendulum(1) Angular coordinates and angular velocities 20
Accuracy of Solutions: Comparison with Hard-co Equations of Motion for Double Pendulum(2 ) Flexible coordinates for link one 21
Methods for Validating Solution Accuracy 1) Testing special cases that have exact analytical solutions 2) Evaluation of error in exact motion integrals 3) The method of manufactured solutions 4) The method of “nearby problems” Method #1 is a standard approach to validating solution accuracy. Here we look at a simple system which has an exact analytical solution. Methods #3 and #4 rely upon computing analytical source terms (fictitious generalized forces) by inverse dynamics which define a benchmark problem for validation studies. The difference is that with method #3 a benchmark solution is chosen a priori and may have no important physical meaning. With method #4, a benchmark solution is constructed as a neighbor of a candidate approximate solution for the motion being studied and thus has physical meaning. 22
Addendum to JLJ Folk Theorem Generating the exact ODE/PDE and boundary conditions for a distributed parameter system by hand or symbolic manipulation stops being fun at age 29! 27
Generating Exact PDE/ and. BCsfor Many Body ODEs Distributed Parameter Systems Lagrangian: Discrete/ODE: You code this. OCEA/AD computes these. Flexible/PDE: BCs: 28
Generating Exact PDE/ : Double Pendulum ODEs We can hard-code the exact equations of motion for the double pendulum and compare the difference with between these and the OCEA derived numerically evaluated equations. 31
Errors in. ODEs Double Pendulum : 32
Errors in. PDEs: Double Pendulum Link one Link two 33
Summary and Conclusions • Automatic Differentiation has broad potential in Dynamics and Control • Automating differentiation by operator overloading is a beautiful idea whose time has come – the applications are endless! • Ideal for implementing Lagrange’s Equations – this presentation provides some simple illustrations – a few important first steps along the path. • No hand derivation effort beyond code specifying the building of the Lagrangian, constraints and external forces is required. • OCEA also gives rise to new methods for solving differential equations – the time derivative computations can be automated, so that formal analytical continuation is easily done in lieu of traditional Runge-Kutta methods, for example. • Can automatically derive systems of PDEs and BCs for use in validating the accuracy of approximate solutions of flexible systems corresponding to the same modeling assumptions? 34
4d77e52f890be43fa3058291bad68bb2.ppt