Automatic Generation and Integration of Equations of Motion by Operator Overloading Techniques s1
Total Page:16
File Type:pdf, Size:1020Kb
Automatic Generation and Integration of Equations of Motion for Linked Mechanical Systems
D. Todd Griffitha, John L. Junkinsa, and James D. Turnerb a Department of Aerospace Engineering, Texas A&M University, College Station, TX 77843-3141, [email protected], [email protected]. b Adjunct Faculty, Department of Aerospace Engineering, Texas A&M University and President Amdyn Systems, White GA 30184.
Abstract
This paper presents a new method for the automatic generation and integration of equations of motion using operator overloading techniques. An automatic differentiation tool (OCEA: Object Oriented Coordinate Embedding Method) is utilized to compute the partial derivatives required for implementing the traditional Lagrangian equations of motion. The user only builds the kinetic and potential energy. Unlike symbolic approaches, the OCEA-Lagrangian method builds the model on-the-fly, no complex pre-processing program must be developed for implementing Lagrange’s method. The new method combines the best of the symbolic and numerical equation of motion generation methods, while retaining the simplicity and elegance of the original Lagrangian method. The method is demonstrated for constrained and unconstrained linked flexible body systems.
Introduction
In industry, research, and the classroom, the study of dynamical systems by the generation and integration of equations of motion is a rite of passage for scientists and engineers. For all but the simplest problems, however, this task can be laborious and error-prone. Real-world applications requiring engineering-level fidelity models can take man-months to man-years of effort to develop and validate by hand. The most common energy-based equation of motion generation method consists of Lagrange’s method. There are two approaches for developing computer- based multibody dynamics models: (1) Symbolic methods that use computer symbol manipulation algorithms, and (2) Numerical codes that build the system kinematic and acceleration equations on-the-fly.
Symbolic manipulation engines such as MAPLE, MATHEMATICA, or MATHCAD are commercially available and theoretically capable of implementing Lagrange’s method. In practice, these computer symbol manipulating systems are tasked for carrying out the required differentiations of the scalar Lagrangian function. A serious limitation of this approach is that a model or engineering design changes corrupt the assumed model for the system Lagrangian and force extensive recalculations for all of the system partial derivatives. A further drawback of symbolic-based methods is that the resulting symbolic files can be huge and the resulting software is generally only machine-readable. Purely numerically based algorithms implement a generic solution algorithm for linking systems of rigid bodies that can undergo large and rapid relative motions. Examples of commercially available tools for the automated generation and integration of equations of motion include DADS, DISCOS, and ADAMS. Though powerful and broadly applicable, these tools use rigid algorithms and coordinate selections and are generally not amenable for introducing approximations or testing advanced solution algorithms. It is very difficult to generate linearized equations of motion or partial derivative models for the purely numerically based class of algorithms.
This paper presents a new method for the automatic generation and integration of equations of motion using operator overloading techniques for overcoming the limitations of both the symbolic and numerical multibody modeling and simulation tools.9,10 The new method combines the best of the symbolic and numerical equation of motion generation methods, while retaining the simplicity and elegance of the original Lagrangian method.5,9 An added benefit of the operator overloaded approach is that new approximation strategies and computational algorithms are easily introduced and evaluated.
Overview of OCEA and Automatic Differentiation
This approach utilizes the previously developed OCEA (Object Oriented Coordinate Embedding Method) extension for FORTRAN90 (F90).9,10 The OCEA package is an object-oriented automatic differentiation equation manipulation package. Computer implementation of differentiation is typically accomplished by two distinct approaches – automatic differentiation and symbolic differentiation.4 The primary distinction of these approaches is that automatic differentiation invokes the chain automatically and takes place in the background. This allows for time and memory optimized differentiation. Symbolic differentiation allows the analyst to view the expressions; however, it requires more user intervention. Typically, derivatives are computed using a symbolic differentiation program, such as Macsyma or Mathcad, and the derivatives then need to be either hand typed in a computer program or saved in a file that typically requires editing and compilation. OCEA defines embedded variables that represent abstract data types, where hidden dimensions (background arrays) are used for storing and manipulating partial derivative calculations. OCEA replaces each scalar variable in the problem with a differential n-tuple consisting of the following variables (second-order OCEA method): 2 f:= 臌轾 f蜒 f f (1) where and 2 denote symmetric first- and second-order gradient tensors with respect to a user-defined set of independent variables. The introduction of the abstract differential n-tuple allows the computer to continue to manipulate each scalar variable as a conventional scalar variable, even though the first and higher- order partial derivative are attached to the scalar variable in a hidden way. The individual objects are extracted, using OCEA’s adopted notation, as follows: f= f% E , �f f% V , and �2 f f% T . The automatic computation of the partial derivatives is achieved by operator-overloading methodologies that redefine the intrinsic mathematical operators and functions using the rules of calculus. For example, addition and multiplication are redefined as follows. 2 2 a+ b: =臌轾 a + b� a 蜒 b + a b (2) a* b := a * b抖 a * b a * b 臌轾 i( ) j i ( ) (3)
Thus the “+” and “*” operators are overloaded so that coding the left side expressions of Eqs. (2) and (3) causes all the right side computations to be carried out. More subtly, if z1 = a + b and z2 = a* b , then computing z3= z 1 + z 2 causes the results of Eqs. (2) and (3) to be propagated efficiently in the background to compute 轾 z=犏 a + b + a* b抖 ( z ) ( z ) 3 臌 i3 j i 3 .
Additional operations for the standard mathematical library functions, such as trigonometric and exponential functions, are redefined to account for the known rules of differentiation. In essence, this approach pre-codes, once and for all, all of the partial derivatives required for any problem, and the chain rule is implemented automatically in background operations that the user neither derives nor codes.
At compile time, and without user intervention, the OCEA-based approach links the subroutines and functions required for, for example, evaluating the system Lagrangian and its associated partial derivative models. Unlike conventional numerically based multibody codes, the resulting equations of motion are not hard- coded. Also, the expected computational efficiency is similar to a manually generated set of equations of motion and simulation code, because the entire operator-overloaded partial derivative calculation is optimally pre-defined at compile time.
Equations of Motion Formulations
For many decades, a primary focus of analytical dynamics has been the development of methods for generating equations of motion. The classical formulations include Newton/Euler methods, D’Alembert’s equations, the Lagrangian energy approach, and Hamiltonian approaches.2,6,7 More recent approaches have been developed in the past century including Kane’s equations, the Gibbs-Appell equations, and the Boltzmann/Hammel equations. Each of these methods have specific advantages and shortcomings when it comes to implementing them in multibody dynamics codes. An overview of some of these issues is given in Reference 1. One major result of this paper is a demonstration of the use of the automatic differentiation capability of OCEA to generate and simultaneously compute solutions of the equations of motion. The most obvious dynamic formulation to utilize automatic differentiation is Lagrange’s equations. This paper represents a step in a new direction in the automatic formulation and solution of equations of motion.
The end goal of this work is to model and simulate the behavior of linked mechanical systems. Special emphasis is given to the formulation of the equations of motion. This paper is an extension of previous work5 which demonstrated solutions by this method for linked rigid body systems, and is summarized as follows: (1) automatic generation of equations of motion via Lagrange’s Method, (2) a generalization of the kinetic energy expression for multiple flexible bodies, and (3) solutions for open- and closed-loop chains of flexible body systems.
Equations of Motion via Automatic Differentiation of the Lagrangian Function
In the Lagrangian formulation, partial derivatives of energy functions are utilized to produce the equations of motion. An obvious advantage of the Lagrangian formulation over, for example, Newton/Euler methods is that only velocity level kinematic expressions need to be developed in order to specify the energy functions, specifically kinetic energy. In this section, a framework is presented for solving a class of problems in which formulation of kinetic and potential energy functions are readily formed. The main result here is that automatic differentiation tools are very well suited for directly implementing the Lagrangian formulation in solving this important class of engineering problems.
Equation (4) presents the most general form of Lagrange’s equations, including generalized forces and constraint forces.
d骣抖 L L T 琪 - =Qλ + C (4) dt 桫抖q˙ q subject to Cq˙ = b where the Lagrangian is defined as L= T - V , Q are the generalized forces, C is the constraint Jacobian matrix, and λ is the vector of Lagrange multipliers. The kinetic energy (T ) is written as a function of the generalized coordinates ( q ) and the generalized velocities ( q˙ ), and the potential energy (V ) is a function of the generalized coordinates.
The implied derivatives with respect to the generalized coordinates and generalized velocities in these equations can be readily computed by automatic differentiation by simply specifying the Lagrangian function. OCEA completely automates all of these computations in the background. Organizing these equations in a manner in which they can be integrated; however, requires explicitly solving for the acceleration terms, which are buried in the first term of Eq. (4). The details can be found in Reference 6; therefore, we only summarize the key developments here. In order to integrate the equations of motion we need to compute the right hand side of a modified form of Eq. (4) which is given in Eq. (5).
-1 骣 L T q˙˙ =M琪- M˙ q + + Qλ + C (5) 桫 q
In order to compute the mass matrix and its time derivative come from the first term on the left hand side of Eq. (4). Considering the most common case of a natural 1 T system, T= T(q,q˙ ) = 2 q ˙ M ( q ) q ˙ we have d骣抖 L2 T 2 T 琪 =q˙˙j + q ˙ j dt桫抖 q˙i q ˙ i 抖 q ˙ j q ˙ i q j (6)
=mij q˙˙ j + m ˙ ij q ˙ j where 2 2 抖T˙ T M� mij � and M m˙ ij (7) 抖q˙i q ˙ j 抖 q ˙ i q j
By utilizing automatic differentiation, the constraint Jacobian matrix can also be formed automatically for a holonomic constraint of the form f(q ) = 0 since C = 抖f q .
As has been shown above, generating the equations given in Eq. (5) can be accomplished by simply specifying the Lagrangian function, the constraint relation, and the generalized forces. OCEA accomplishes all required derivative operations leading to the right hand side of Eq. (5). The background second partials of T , for example, can be accessed to obtain M from Eq. (7).
Formulations for Flexible Bodies
When the rigid body assumption is used to model a dynamical system, there is no need to consider spatial integrals over the body for computing kinetic and potential energy expressions (i.e. the Lagrangian). However, when flexibility is considered we encounter a Lagrangian expression which is computed as an integral over the volume of the body, and, of course, we require additional coordinates to define deformations. For the case of slender beams, we can simplify this to an integral over the length of the body. Furthermore, what is often done to simplify the formulation of equations of motion for flexible dynamical systems is the introduction of approximations for the flexible motion coordinates that aid in producing a Lagrangian with no explicit dependence on the spatial coordinates. Examples of approximation techniques include the well known Finite Element Method and Method of Assumed Modes.6,8 In essence, these techniques make it possible to produce a Lagrangian for the flexible dynamical system of the same form as that of a rigid body dynamical system. Thus, once the spatial discretization approximations are utilized, we can proceed to generate equations of motion for a flexible dynamical system just as we do for a rigid body dynamical system by directly implementing Lagrange’s Equations of the form of Eq. (5).
In this section, we demonstrate the use of OCEA in generating equations of motion for systems comprised of flexible elements. Toward this end, we develop recursive expressions for kinetic and potential energy functions for a series of linked flexible beams. Since we are not considering rapid angular motions of the beams, we model the beams using Euler-Bernoulli assumptions.
Generalization for Multiple Flexible Bodies
We now consider generating equations of motion for a chain of linked flexible bodies. It is assumed that the first link is pinned without translation, and successive links are joined with pins as shown in Fig. 1. Up to this point, we have not discussed the choice for generalized coordinates which is an important matter for an automated process. Make note in Fig. 1 that we choose absolute angular coordinates, which are measured with respect to a common frame, in this case the horizontal. Note the xi axis connects the tips of the flexible members; thus the elastic deformation of each domain vanish at the ends of that domain.
Y
y2 yp x2 xp
q2 x1 q p
y1 Figure 1: Geometry of multiple flexible link configuration q1 X The main development of this section is a recursion for the kinetic energy of the (p+1)th link of the form: 1 Lp+1 T= r ( x ) r˙ ( x , t ) r ˙ ( x , t ) dx (8) p+12 0 p + 1 p + 1 p + 1 p + 1 p + 1 p + 1 p + 1 ˙ where r p+1(x p + 1 ) is the mass density distribution and rp+1(xp+1 , t ) is the velocity expression for the (p+1)th link.
We begin the development of the velocity expression by looking at the first beam in the chain. The position and velocity of any point along the first beam are written as follows: ˆ ˆ r1(x 1 , t )= x 1 i 1 + v 1 ( x 1 , t ) j 1 (9)
˙ ˙ˆ ˙ ˆ r1(x 1 , t )= -q 1 v 1 ( x 1 , t ) i 1 +( v˙ 1 ( x 1 , t ) + x 1 q 1) j 1 (10)
v( x , t ) ˙ where 1 1 is the transverse beam deformation, q1 is angular velocity, and x1 is the coordinate measurement along the beam frame of reference.
The velocity of any point along the second beam in the chain can be written as ˙ ˙ ˙ˆ ˙ ˆ r2(x 2 , t )= r 1 ( L 1 , t ) -q 2 v 2 ( x 2 , t ) i 2 +( v˙ 2 ( x 2 , t ) + x 2 q 2) j 2 (11)
and, in general, the velocity expression for the (p+1)th link can be written as ˙ ˆ r˙p+1(x p+ 1 , t )= r ˙ p ( L p , t ) - q p+1 v p+1 ( x p+1 , t ) i p+1 (12) ˙ ˙ ˆ +(vp+ 1( x p+ 1 , t ) + x p+1q p+1) j p+1
˙ where the velocity of the tip of the pth link, rp(L p , t ) , is written as p ˙ˆ ˙ ˆ ˙ ˆ ˙ ˆ r˙p(L p , t )= L1q 1 j 1 + L 2 q 2 j 2 + ... + Lp q p j p = L i q i j i (13) i=1
Here, we have enforced the zero tip deformation constraint by choosing admissible ip x functions with zero deflection at the endpoints (i.e. f = sin(p+1 ) ).3 In this p+1, i Lp+1 way, the beams satisfy pinned-pinned boundary conditions. Additionally, the expression for beam tip velocity in Eq. (13) has been greatly simplified since vp+1( L p + 1 , t )= v˙ p+1 ( L p + 1 , t ) = 0 . Equation (12) can be written as p ˙ˆ ˙ ˆ r˙p+1(x p+ 1 , t )= Liq i j i - q p+1 v p+1 ( x p+1 , t ) i p+ 1 i=1 (14) ˙ ˙ ˆ +(vp+ 1( x p+ 1 , t ) + x p+1q p+1) j p+1
Now, we can rewrite the kinetic energy expression of Eq. (8) as 1 Lp+1 T= r r˙( x , t ) r ˙ ( x , t ) dx p+12 0 p + 1 p + 1 p + 1 p + 1 p + 1 p + 1 p p 骣 ˙ˆ骣 ˙ ˆ = 琪邋Liq ijig琪 L j q j j j 桫i=1桫 j = 1 (15) p 骣 ˙ˆ ˙ ˆ˙ ˙ ˆ +2琪 Liq i jig{ - q p+1 v p+1 i p+1 +( v p+1 + x p+1 q p+1) j p+1 } 桫i=1 ˙22 2 ˙ 2 ˙ 2 +qp+1vp+1 + v˙ p+1 +2 x p + 1 q p + 1 v ˙ p + 1 + x p+1 q p+1
We can proceed further in simplifying (15) by carrying out the remaining dot products. If we consider absolute angular coordinates which are measured from a common reference frame, then we can write the following expressions that relate any two frames, here frames i and j . ˆ ˆ 骣i 轾cos(qj- q i ) - sin( q j - q i ) 骣i 琪i = 琪j (16) ˆ 犏sin(q- q ) cos( q - q ) ˆj 桫ji 臌 j i j i 桫j
At this point, we can introduce approximations in order to facilitate automatic generation of ODE’s in terms of the time dependent variables by the assumed modes method. In Eq. (17) we introduce an expression for vp+1( x p + 1 , t ) : T v( x , t )= q ( t )f ( x ) = qφ ( t ) ( x ) . (17) p+1 p + 1 p + 1, i p + 1, i p + 1p+1 p + 1 p + 1
We note here that the first index before the comma denotes the body (p+1), and the indices after the comma indicate the index of the element of the array (i) in the typical mathematical notation.
Now with the relation given by Eq. (16) and the approximation given by Eq. (17), we can write Eq. (15) as
˙ ˙ Tp+1= T P + 1 (q , qθ , θ, )
p p p 1 ˙ ˙ ˙T ˙ =2 mp+1邋 L iq i L j q jcos( q j - q i) - q p + 1q p + 1 b p + 1 L i q i sin ( q p + 1 - q i ) i=1 j = 1 i = 1 (18) p p ˙ T ˙1 ˙ ˙ +qp+1 b p + 1邋L iq icos( q p + 1 - q i) +2 q p + 1 m p + 1 L p + 1 L i q i cos( q p + 1 - q i ) i=1 i = 1 1˙2 T 1 ˙ T ˙ ˙ ˙ T 1 2˙ 2 +2qp+1q p + 1M p + 1 q p + 1 + 2 q p + 1 M p + 1 q p + 1 + q p+1q p + 1 a p + 1+ 6 m p + 1 L p + 1q p + 1 where q , q˙ , θ , and θ˙ are the vectors containing all of the time dependent quantities for the flexible coordinates and the angular coordinates. The elements of the mass matrix, M p+1 , and the vectors, a p+1 and bp+1 are given in Eqs. (19-21), respectively.
L m M=p+1 r f f dx = p+1 d (19) p+1, ij0 p + 1 p + 1, i p + 1, j p + 1 2 ij
L m L a =p+1 rx f dx = - p+1 p + 1 cos( i p ) (20) p+1,i 0 p+1 p + 1 p + 1, i p + 1 ip
L m L b =r fdx =p+1 p + 1 (1 - cos( i p )) (21) p+1,i 0 p+1 p + 1, i p + 1 ip
Equation (18) is used to produce the kinetic energy for the second beam and so on for p 1. The potential energy due to bending is given as before as L 1 '' '' Vp+1(q p + 1 )= 2 q p + 1, i q p + 1, j EI p + 1 ( x p + 1 ) f p + 1, i f p + 1, j dx p + 1 0 (22) 1 T = 2 qp+1K p + 1 q p + 1
The kinetic and potential energy of the first link are to be specified individually as given in Eqs. (23) and (24), respectively. 1˙2T 1˙ T ˙ ˙ T 1 2 ˙ 2 T1=2q 1q 1 M 1 q 1 + 2 q 1 M 1 q 1 + q 1 q 1 a 1 + 6 m 1 L 1 q 1 (23)
1 T V1= 2 q 1 K 1 q 1 (24)
With Eqs. (18) and (22-24) we can form the Lagrangian function explicitly in terms of the time dependent coordinates ( q, q˙θ , θ, ˙ ) and implement Lagrange’s Equations of the standard form given in Eq. (4) in order to produce the equations of motion.
Examples
In this section three examples are presented which demonstrate the use of automatic differentiation for automatic generation and integration of equations of motion. The first is a simple illustrative example, and the final two examples demonstrate solutions for open- and closed-chain topologies of flexible bodies.
Spring Pendulum by Forming the Lagrangian Function
Here, we present an example in which the equations of motion are automatically generated and integrated by explicitly forming the Lagrangian function. The spring pendulum, as shown in Figure 2, is a simple two degree of freedom example which can be readily solved by hand. However, we present it here in order to overview the method, which can be applied generally to solving additional problems. r
θ
Figure 2: Spring Pendulum
As was mentioned previously, in order to solve this type of problem we need to simply specify the Lagrangian function, the constraint relations (if they exist), and the generalized forces, and as well, the system physical parameters and initial conditions. The Lagrangian function is L= T - V , where 1 ˙ 2 2˙ 2 T=2 m( r + r q ) (25) and 1 2 V=2 k( r - r0 ) + mg ( r 0 - r cosq ) (26) For this problem, no constraints need be specified and no additional forces need to be accounted for. However, it would be a simple matter to include force law expressions for damping elements or drag, or to modify the spring force model to account for these effects. In addition to the integration parameters, these are the only parameters to be specified in order to compute the solution. Only Eqs. (25) and (26) need to be programmed by the user.
A selection from the subroutine containing the above specified problem data for the spring pendulum is given in Appendix A. Here, it should be noted that the subroutine begins by including the EB_Handling routine (USE EB_HANDLING) which specifies that this subroutine contains data objects which are to be differentiated. Embedded variables and embedded functions are declared as TYPE(EB) which is an OCEA defined variable type. The specification of the kinetic and potential energy functions is highlighted in order to show that embedded functions are typed in a standard user- friendly manner. The structure of OCEA is such that by invoking EB_Handling, derivatives are automatically computed in the background without user intervention. Extraction of partial derivative information is also highlighted to show the ease with which the background-computed information can be accessed. Here, the analyst simply needs to define the dimension of the partial derivatives to be extracted. By setting this variable equal to the embedded function variable, for example, HES_L = L, we can readily extract the Hessian of the Lagrangian in order to get access to the mass matrix and its time derivative. The overhead associated with deriving, coding, and validating the equations of motion has been avoided. Open-Chain Topology of Flexible Bodies
In this section, we present simulated results for multiple flexible beams in an open-chain topology. Here, we define the kinetic and potential energy for the first link with Eqs. (23) and (24), respectively. For the second link and so on (p=1 and so on) we define the kinetic and potential energy by Eqs. (18) and (22).
The system is comprised of three beams, each with mass of 12 kg, length of 10 m, and stiffness (EI) of 14e3 Nm2. The beams are initially oriented with angles {q, q , q } = 3p , 3 p , 3 p as shown in Fig.1. All initial deflections are zero with the 1 2 3 { 2 2 2 } exception of the midpoint deflection of the third beam, which is q3,1 =0.01. All initial velocities are zero with the exception of the angular velocity of the third beam (q˙ =0.5rad ). 1 sec With the ability to quickly generate models and solutions for the motion, a considerable number of analyses are readily available. Here, we show results for the rigid body and flexible contributions to the kinetic energy of the individual links as shown in Figs. (3-5). Here we see that for this quite flexible system, the magnitudes of the kinetic energy due to flexibility (dotted lines) are of significant amplitude. The integration step size was chosen to satisfy constancy of total energy.
Figures 3-5: Kinetic Energy for Links 1, 2 and 3 Closed-Chain Topology of Flexible Bodies
In this section, we present simulated results for multiple flexible beams in a closed-chain constrained topology. Here, we define the kinetic and potential energy for the links as we did before; however, in this case, we must simply compute the constraint forces in order to satisfy the geometric constraints, which are of the holonomic form: n 骣 Lcos(q ) - D 琪i=1 i i φ =琪 n = 0 (27) 琪 L sin(q ) 桫 i=1 i i where n = 5 links and D=10 m. Constraint forces are computed by solving for the Lagrange multipliers using the Range-Space Method. Additionally, we include potential due to gravity from rest with initial angles for the links of {q, q , q , q , q } = 5p , 7 p ,0, p , 3 p . Initially, there is no flexible energy in the 1 2 3 4 5 { 4 4 4 4 } system. Damping is included at all joints with the exception of the base joint at {X, Y}={ 10,0} . The properties of the links is identical to the previous example with the exception that EI = 14e4 Nm. Again, conservation of total energy was used to determine the integration step size.
Figure 6 shows a few snap shots of the motion history for the 10 second simulation.
Figure 6: Motion for a 5 flexible link closed-chain system Conclusion
In this paper we present a new method for the automatic generation and integration of equations of motion using operator overloading techniques. The automatic differentiation tool (OCEA: Object Oriented Coordinate Embedding Method) was utilized to compute the partial derivatives required for implementing the traditional Lagrangian equations of motion. Several examples were presented to demonstrate the utility of automatic differentiation in generating equations of motion. A generalized simulation code was presented which can compute the motion for systems containing many flexible bodies. This generalized code was shown to solve example for an open chain, unconstrained topology and a closed chain constrained topology. Nonlinear multiple flexible body problems having an energy integral were considered. We used the constancy of the energy constant as evidence that accurate solutions were obtained.
References
[1] Banerjee, A. K., “Contributions of Multibody Dynamics to Space Flight: A Brief Review”, Journal of Guidance, Control, and Dynamics, Vol. 26, No. 3, May-June 2003, pgs. 385-394. [2] Baruh, H., Analytical Dynamics, McGraw Hill, New York, 1998. [3] Baruh,H. and Radisavljevic, V., "Modeling of Flexible Mechanisms by Constrained Coordinates," Journal of the Chinese Society of Mechanical Engineers, Vol. 21, No. 1, 2000, pp. 1-14. [4] Durrbaum, A., Klier, W., and Hahn, H., “Comparison of Automatic and Symbolic Differentiation in Mathematical Modeling and Computer Simulation of Rigid Body Systems”, Multibody System Dynamics, Vol. 7, pgs. 331-355, 2002. [5] Griffith, D.T., Sinclair, A.J., Turner, J.D., Hurtado, J.E., and Junkins, J.L., “Automatic Generation and Integration of Equations of Motion by Operator- Overloading Techniques,” AAS/AIAA Spaceflight Mechanics Meeting, February 8-12, 2004, Maui, HI, USA, Paper AAS 04-242. [6] Junkins, J.L. and Kim, Y., Introduction to Dynamics and Control of Flexible Structures, AIAA Education Series, 1993. [7] Schaub, H., and Junkins, J.L., Analytical Mechanics of Space Systems, AIAA, 2003. [8] Thomson, W.T., and Dahleh, M.D., Theory of Vibration with Applications, Prentice Hall, New Jersey, 1998. [9] Turner, J. D., "Automated Generation Of High-Order Partial Derivative Models, AIAA Journal, August 2003. [10] Turner, J. D., "Generalized Gradient Search And Newton's Methods For Multilinear Algebra Root-Solving And Optimization Applications," Invited Paper No. AAS 03-261, To Appear In The Proceedings Of The John L. Junkins Astrodynamics Symposium, George Bush Conference Center, College Station, Texas, May 23-24, 2003. APPENDIX A: FORTRAN 90 Subroutine for Spring Pendulum Note: X0(1)= r ; X 0(2) =q ; X 0(3) = r˙ ; X 0(4) = q˙
SUBROUTINE SPRING_PEND_EQNS( PASS, TIME, X0, DXDT, FLAG ) USE EB_HANDLING IMPLICIT NONE !.....ARGUMENT LIST VARIABLES ********** REAL(DP), INTENT(IN):: TIME TYPE(EB),DIMENSION(NV),INTENT(IN ):: X0 TYPE(EB),DIMENSION(NV), INTENT(INOUT):: DXDT
!.....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 REAL(DP), DIMENSION(NV/2,NV/2):: MASS, MASS_INVERSE, MASSDOT REAL(DP), DIMENSION(NV/2):: JAC_L_Q, QDOTDOT, QDOT TYPE(EB):: R0 ! UNSTRETCHED SPRING LENGTH REAL(DP):: GRAV
M = 1.0D0; K = 75.0D0 ! MASS AND STIFFNESS *********** T = 0.5D0*M*(X0(3)**2 + X0(1)**2*X0(4)**2) ! DEFINE KE V = 0.5D0*K*(X0(1)-R0)**2 + M*GRAV*(R0-X0(1)*COS(X0(2))) ! PE L = T – V ! DEFINE LAGRANGIAN FUNCTION
JAC_L = L ! EXTRACT JACOBIAN OF LAGRANGIAN JAC_L_Q = JAC_L(1:NV/2) ! EXTRACT PARTIALS W.R.T. GEN. COORDS.
HES_L = L ! EXTRACT 2nd 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 = MATMUL(MASS_INVERSE,(JAC_L_Q &- (MATMUL(MASSDOT,QDOT))))
DXDT(1)%E = X0(3)%E ! RDOT DXDT(2)%E = X0(4)%E ! THETADOT DXDT(3)%E = QDOTDOT(1) ! RDOTDOT DXDT(4)%E = QDOTDOT(2) ! THETADOTDOT
END SUBROUTINE SPRING_PEND_EQNS