Saltire Software
Saltire Home  |  Products  |  About Saltire
 

A Symbolic Engineering Mechanics System Built on OEM Maple

Philip Todd, Robin McLeod & Marcia Harris

Table of contents

  1. Introduction
  2. System Architecture
    1. Analytix
    2. Creating Symbolic Analytix Models
    3. Interacting With Symbolic Analytix Models
      1. Adding variables to the IVT
      2. Extracting expressions from the IVT
      3. Displaying the IVT
      4. Geometric and mechanics functions
      5. Applying Maple functions to individual expressions
      6. Eliminating intermediate variables
  3. Example Problems
    1. Coupler Curve for a Geared 5-bar linkage
    2. Torque in a Crank/Piston
    3. Dynamics of a Double Pendulum
  4. Conclusions
  5. References

1. Introduction

A major limitation of the use of symbolic mathematics packages, such as Maple, by mechanical engineers is the difficulty of accurately converting a geometry based mechanical engineering problem into a set of algebraic equations which can then be manipulated, solved or visualized by the symbolic mathematics package.

In the last eight years, Variational Geometry has emerged as a natural and powerful language for the expression of mechanical engineering problems [1], [2], [6]; particularly problems in the realm of engineering mechanics. Problems involving the kinematic behavior of mechanisms may be succinctly expressed in the form of a constraint-based variational model of the geometry along with first and second derivatives of the constraints. With an additional capability for handling forces and masses, we add the ability to express problems in the statics and dynamics of mechanisms. The commercial package Analytix uses a variational geometry user interface as the means of specifying problems in the dynamic analysis of mechanisms [3-6]. These problems are then solved numerically in the package. Figure 1 shows an Analytix model of a four-bar linkage.

A Constructive Variational Geometry System represents engineering geometry as a sketch with constraints (also called "dimensions") given as labels on the sketch. "Constructive" refers to the classical constructions of Euclid's geometry, for example, the construction of a point of intersection, given two known lines. "Variational" means that numerical information resides in the dimensions, such as distance between points or measure of an angle, which are labeled on the diagram, rather than residing in the coordinates of points; therefore change or motion in the figure can be simply represented as change or variation in a constraint value.

In this paper, we present a system which converts an engineering mechanics problem, expressed as an Analytix model into a symbolic mathematical representation within Maple. We discuss the functions which were developed to allow the user to manipulate and display this mathematical model. We present several examples to show the process of using the hybrid system.

Our approach allows the engineering mechanics problem to be expressed in the natural graphical terms of a dimensioned sketch, while automatically performing the error prone process of converting the geometrically expressed problem into mathematics.

2. System Architecture

There are three components to the symbolic mechanics package: (i) the front end is a modified version of the Analytix variational geometry package; (ii) a layer of code converts from the Analytix representation of the mechanics problem to a symbolic representation; (iii) a set of Maple functions facilitates user interaction with the symbolic representation.

Component (i) is written in C, component (ii) contains C code and Maple code, component (iii) is entirely Maple code.

(i) Analytix

To create a model of a mechanism in the Analytix package, the user first sketches the mechanism. Typically the sketch contains a simplified representation of the mechanism's geometry. Links are usually represented by straight lines between joints or points of force application. Centers of gravity of any links with non-negligible mass are explicitly sketched.

The user then specifies the exact geometry by adding constraints to the drawing. The constraints specify angles or distances on the drawing. For a kinematic analysis, the constraints should represent quantities whose motion is known. In practice, for a single degree of freedom mechanism, all the constraints but one represent quantities which stay fixed throughout the motion of the mechanism. The final constraint represents the driver, whose motion is known. The Analytix system aids the constraint specification process by giving continuous feedback on whether the model is underconstrained, overconstrained, or consistently constrained. The constraint values may be numbers or expressions. Figure 1 shows an Analytix model for a four bar linkage.

alg1.gif (2914 bytes)

Figure 1: A four bar linkage specified by the lengths of three sides and one angle.

To perform a kinematic analysis, the user specifies the velocities and accelerations of any constraints which are in motion. (In the example of the four bar linkage (figure 1), all constraints would have 0 velocity and acceleration except the driving angle. If the crank is being driven at constant angular velocity v the angle would be given a velocity v and an acceleration 0.) The user also must specify a fixed point and a fixed line.

With the constraint velocities and accelerations given, the model is able to output on demand the position, velocity, and acceleration of any point of the mechanism and the angular velocity and angular acceleration of any line.

Static analysis of a mechanism may be performed in a very natural way in a Variational Geometry system by assuming that constraints carry reactions. Hence not only the motion, but also the statics of the model are defined by the constraints. If loads are applied to a mechanism in Analytix, reaction forces are generated in the constraints. The system will sum the constraint forces which impinge on a point to give the reaction force at that point. The system will integrate the forces on a single line segment to give shear force and bending moment.

Analytix allows external forces to be applied to any point on a mechanism and external torques to be applied to any line. These forces may be constant or they may vary with geometry, time or some other parameter. Analytix also provides conformal force elements: translational and rotational spring-damper-actuators.

To perform inverse dynamics in Analytix, the user specifies the instantaneous motion of the mechanism in the same way as for kinematics, but also applies forces and specifies the mass of points representing mass centers. The user also specifies the moment of inertia of lines which represent rigid links. The user can now generate the same reaction force outputs as for the static analysis, except the inertial forces generated by the accelerating masses will be taken into consideration.

In a dynamic analysis, some constraints represent quantities whose behavior is known in advance - either quantities which remain fixed or drivers, whose motion is given. Other constraints are free to accelerate in response to unbalanced forces present in the model. To set up a dynamic model, the user specifies the fixed constraints and the input drivers in the same way as for kinematic analysis. Free constraints are given initial values and initial velocities and marked as being free to accelerate.

(ii) Creating Symbolic Analytix Models

In a previous paper [4] a method was described for performing a symbolic analysis of dimensioned engineering drawings. Analysis of the constraint graph associated with the drawing led to its description as a sequence of elementary Euclidean constructions, each of which was responsible for constructing a single point or line from its specified relation to known (already constructed) points and lines.

For example, a construction sequence for the four bar linkage of figure 1 is given below.

    Construct a point (point P2) at the origin. 
    Construct a line (line L3) through point P2 in the direction of the x-axis. 
    Construct a point (point P4) on line L5 distance a from point P2. 
    Construct a line (line L5) through point P2 angle e degrees to line L3. 
    Construct a point (point P1) on line L3 distance b from point P2. 
    Construct a point (point P6) distance c from point P1 and distance d from point P4. 
    Construct a line (line L8) through points P1 and P6. 
    Construct a line (line L7) through points P4 and P6. 
    Construct a point (point P9) on line L7 distance d/2 from point P4.       

Each individual construction which is part of the sequence described above has a corresponding set of equations which may be solved to determine the unknown geometrical entity. These are described in [4].

In [4], expressions for the coordinates of the drawing's points and the coefficients of the drawing's lines were established in terms of the independent constraint values alone. With this approach, the system suffered from substantial intermediate expression expansion, and was able to deal only with rather simple drawings. In order to deal with drawings and engineering mechanics problems of arbitrary complexity, it was necessary to maintain a symbolic representation as a nested sequence of expressions with intermediate variables introduced by the system. This eliminated the exponential growth in individual expression complexity. However, as Maple is designed to manipulate single expressions rather than sequences of expressions with collective meaning, this necessitated a layer of code to allow the manipulation of our symbolic representations.

Table 1 shows the system output for the location of point P9. For comparison, table 2 shows the same expressions without intermediate variables.

maple1.gif (3894 bytes)

Table 1: Equations for the curve traced by point P9 on the four bar linkage shown in Figure 1.

FullySubstitute(P9x);      

maple2.gif (5490 bytes)

Table 2: Equation for P9x with all the intermediate variables eliminated.

Two different engineering mechanics functions are available to the user. Reaction(x) gives the pseudoforce in parameter x. InstallDiffEq([x0,...,xn]) creates new variables A_x0,...,A_xn representing the accelerations of x0,...,xn. In the process of assigning expressions to these accelerations, a number of new intermediate variables will be introduced (many representing derivatives of existing variables). Velocity variables V_x0,...,V_xn will also be introduced and treated as independent input variables. The methods used in these functions are described in [6].

(iii) Interacting With Symbolic Analytix Models

The Intermediate Variable Table (IVT) and the routines to support and manipulate this structure were written in the Maple symbolic programming language and coexist as a package running within Maple. We describe in the following the functions which constitute this library, grouped according to their use.

(a) Adding variables to the IVT

Install(varname,eqn) - Installs a new variable with defining (implicit or explicit) equation eqn.

InstallAreaMoments(name,pointlist) - installs a number of new variables corresponding to area moments of the polygon defined by the points in pointlist.

InstallDerivative(var,dvar) - installs an expression for the derivative of var with respect to dvar.

(b) Extracting Expressions from the IVT

Evaluate(expr) - returns expr with the equation from the IVT substituted for each variable in expr which is in the IVT. This is not done recursively

FullyEvaluate(expr) - A recursive version of the above.

EvaluateF(expr,assgn) - performs a floating point evaluation with numerical assignments given in assgn.

Equations(expr,style) - for each variable v in expr which is in the Intermediate Variable Table, returns the equation defining v. Style specifies whether implicit or explicit equations are desired.

FullEquations(expr,style) - A recursive version of the above

CFunction(fname,varlist) - creates a C function with name fname to evaluate the variables contained in the varlist. Inputs to the function are all the constants in the recursive definition of the variables in varlist.

(c) Displaying the IVT

Show(expr,style) - displays expr and the definitions (recursively) of all the table symbols involved in expr.

(d) Geometric and mechanics functions

Angle(line1,line2) - returns the angle between two lines

Area(pointlist) - returns the signed area of the closed polygon formed by the pointlist.

Distance(entity1,entity2) - returns the distance between the two entities.

InstallDiffEq(parlist) - for each parameter p in parlist, installs equations for the acceleration of p, A_p.

Reaction(var) - returns the reaction pseudoforce in variable var.

(e) Applying Maple functions to individual expressions

Apply(expr,fcn,arg2, ... , argn) - for each variable v in expr which is in the Intermediate

Variable Table, applies the function fcn to the expression defining v.

(f) Eliminating Intermediate Variables

Substitute(expr,varlist) - substitutes the definition of each of the variables in varlist into the definition of each of the variables in expr. If no second parameter is given, substitutes all intermediate variables explicitly found in the definition of each variable in expr.

FullySubstitute(expr) - a recursive version of the above which eliminates all intermediate variables from expr.

3. Example Problems

(i) Coupler Curve for a Geared 5-bar linkage

maple3.gif (2934 bytes)

Figure 2: An Analytix model of a geared 5-bar linkage.

In this example, we derive equations for the curve traced by one point on a geared five bar linkage. A gear pair is modeled in Analytix by creating a formula linking the values of two angles. In Figure 2, one angle is given a value t, while a second angle is given a value r*t+s. r is the gear ratio, s represents the offset between the gear angles in an initial configuration.

Table 3 gives the expressions derived by the system for the coupler curve drawn in figure 2.

Show(P6);      

maple4.gif (4357 bytes)

Table 3: Coordinates of the coupler curve for the geared five-bar linkage

(ii) Torque in a Crank / Piston

In our second example, we derive an equation for the torque generated by piston force F in a piston/crank mechanism. The Analytix model is parameterized by the crank length c, the length of the connecting rod L, and the crank angle a. Assuming a force of F (depicted as 1 in figure 3) applied at the piston, we require the torque in the crank.

alg21.gif (1500 bytes)

Figure 3: An Analytix model of a Piston Crank Mechanism

The Variational Geometry statics model assumes reaction forces in constraints balance any externally applied forces. Thus a statics question should be translated into a question regarding reaction forces in constraints. In this case, we require the reaction pseudoforce (actually a torque) in parameter a.

In Table 4, a new variable, torque, is introduced into the Intermediate Variable Table with a value equal to the reaction in parameter a. The system returns an expression for the torque which involves the intermediate variable P8a and its derivative with respect to a. To express torque as a single equation in the input parameters, we can apply the function FullySubstitute().

maple5.gif (3669 bytes)

Table 4: Equations for the torque in the crank generated by an input force F at crank angle a.

(iii) Dynamics of a Double Pendulum

In our third example, we use the system to derive the equations of motion for a double pendulum with unit masses at the end of each link. Figure 4 is the Analytix model of a double pendulum. The Variational Geometry model of dynamics assumes that one or more of the model's parameters is free to accelerate in response to unbalanced forces. In this case, we wish the angle parameters a and b to be free to accelerate.

alg23.gif (1895 bytes)

Figure 4: An Analytix model of a double pendulum.

The command to create the differential equations is:

        InstallDiffEq([a,b]);       

The system introduces new variables A_a and A_b for the accelerations of a and b, and new parameters V_a and V_b for the velocities of a and b. It then derives the equations of motion as expressions for A_a and A_b in terms of the input parameters along with V_a and V_b.

maple6.gif (4452 bytes)

Table 5: Equations for the accelerations A_a and A_b of the angles a and b. Parameters V_a and V_b are introduced by the system and represent the velocities of a and b, g is the acceleration due to gravity

The initial expressions for the accelerations in this example involved a large number of intermediate variables. Application of the function SimplifyTable() resulted in the equations shown in Figure 5. The parameter g seen in Table 5 is the acceleration due to gravity.

Table 6 shows the use of CFunction() to create code for evaluating these accelerations. CFunction() automatically derives which variables are inputs and which (any intermediate variables) are locals. The function may be called with the `optimized` option, in which case, further local variables are introduced for any common sub expressions in the evaluation.

Code generation in CFunction() uses the Maple function C(). In more complex dynamics problems, with dozens of intermediate variables introduced by the mechanics system and dozens more introduced by the use of the `optimized` option, the capability of automatically generating the wrapper code for a C function was essential.

CFunction(CalcAcc,[A_a,A_b]); 
 
void CalcAcc( 
                double b, 
                double a, 
                double g, 
                double V_b, 
                double V_a, 
                double *A_a_, 
                double *A_b_) 
{ 
      double A_a; 
      double A_b; 
      A_b = -(3.0*V_a*V_a*sin(b)-8.0*cos(a+b)*g-V_a*V_a*sin(2.0*b)+4.0\ 
*cos(b)*g 
*cos(a+b)+8.0*cos(b)*cos(a)*g-V_a*V_b*sin(2.0*b)-V_b*V_b*sin(2.0*b)/2-\ 
8.0*cos(a 
)*g+2.0*V_a*V_b*sin(b)+V_b*V_b*sin(b))/(-3.0/2.0+cos(2.0*b)/2); 
      A_a = -(V_a*V_a*sin(2.0*b)/2-4.0*cos(b)*g*cos(a+b)-V_a*V_a*sin(b\ 
)+8.0*cos 
(a)*g-2.0*V_a*V_b*sin(b)-V_b*V_b*sin(b))/(-3.0/2.0+cos(2.0*b)/2); 
      *A_a_ = A_a; 
      *A_b_ = A_b; 
}       

Table 6: CFunction() can be used to create a C function to evaluate these accelerations.

CFunction() Implementation Note

In the case shown above, we desire code for a sequence of equations, namely for an equation representing A_a and an equation representing A_b. The Maple function optimize() will accept a sequence of equations as input, however it is assumed that the last in the sequence of equations is the only one we actually care about. Hence any of the prior equations may be discarded if it is not deemed necessary in computing the final answer. For example, let's assume we want to generate code for x and y from the sequence of equations: [r=2*a, x=r, y=r*sin(t)].

optimize([r=2*a,x=r,y=r*sin(t)]); 
        y = 2 a sin(t)      

In order to ensure that all the equations in our output sequence are preserved we use the undocumented Maple function `optimize/statseq()` with as its first parameter the list of equations to be optimized and as its second parameter the list of output variables. This ensures these
outputs are preserved.

`optimize/statseq`([r=2*a,x=r,y=r*sin(t)],[x,y]);        

[ r = 2 a, x = r, y = r sin(t) ]

4. Conclusions

We have presented a system which allows engineering mechanics problems to be specified in an extremely intuitive and graphical manner through the medium of a variational geometry system while a mathematical formulation of the problem within Maple is made available to the
user. We have thus, for this problem domain, automated the error prone process of mathematical modeling which generally precedes mathematical analysis. The maintenance of an intermediate variable table enabled us to keep the complexity of this mathematical model
under control.

5. References

  1. Light R., Gossard D., (1982) "Modification of geometric models through variational geometry", CAD 14:209:214

  2. Fuller N. & Prusinkiewicz P. (1989) "Applications of Euclidean constructions to computer graphics", Visual Computer 5:53-67

  3. Todd P. (1986) "An algorithm for determining consistency and manufacturability of dimensioned drawings" CAD86 pp 36 - 41, Butterworths, London

  4. Todd P. and Cherry G., (1989) "Symbolic Analysis of Planar Drawings", Lecture Notes in Computer Science Vol 358 (P. Gianni ed.) 344-355

  5. Todd P. (1989) "A k-tree generalisation that characterises consistency of dimensioned engineering drawings", SIAM Journal of Discrete Mathematics 2:255-261.

  6. Todd P. (1992) "A Constructive Variational Geometry Based Mechanism Design Software Package" ASME DE-Vol 46, Mechanism Design & Synthesis, pp 267 - 273