SimMechanics    

Trimming Mechanical Systems

Trimming a mechanical system refers to the process of finding solutions for the model that satisfy conditions on its inputs, outputs, and states that you specify, for example, steady-state solutions where some or all of the derivatives of the system's states are zero. To use this command to trim a system represented by a SimMechanics model, you must select the SimMechanics Trimming mode (see Trimming Mode). You must also specify the initial states of the system and the conditions that the solutions must satisfy. The following examples illustrate the process of trimming unconstrained and constrained mechanical systems, respectively.

Unconstrained Example: Spring-Loaded Double Pendulum

Consider the following spring-loaded double pendulum.

The joint connecting the upper and lower arms of this pendulum contains a torsional spring and damper system that exert a counterclockwise force directly proportional to the angular displacement and velocity of the joint, respectively. Suppose that the lower arm is folded upwards almost vertically and then allowed to fall under the force of gravity. At what point does the spring-damper system reach equilibrium; i.e., at what point does it cease to unfold?

To find an equilibrium point for this system:

  1. Build a SimMechanics model of the system.
  1. This diagram shows an example of such a demo model, mech_dpend_trim.

    This model uses Body blocks to model the upper and lower arms of the pendulum and a Revolute Joint block (J1) to model the connection between the pendulum and ground. The model uses a Subsystem block (J2) to model the spring-loaded revolute joint between the arms. The subsystem in turn uses a negative feedback loop consisting of Revolute Joint, Joint Sensor, Joint Actuator, Gain, and Sum blocks to model the spring-loaded joint. The feedback loop models a torsional spring and damper by multiplying the angular displacement and velocity, respectively, of the joint by constants. The loop sums the resulting torques and feeds them back into the joint via the Joint Actuator block. The result is that the joint experiences a torque that opposes its motion and is proportional to its angular displacement and velocity.

    The spring and damper constants used in this model were chosen by running the model with various candidate values and choosing the ones that resulted in a moderate deflection of the pendulum.

  1. Determine the layout of the model's state vector.
  1. You need to determine the layout of the model's state vector in order to tell the trim command where in the model's state space to start its search for the pendulum's equilibrium point (the point where it stops unfolding). Use the SimMechanics mech_stateVectorMgr command to perform this task.

    The StateNames field of the state vector object returned by mech_stateVectorMgr lists the names of the model's states in the order in which they appear in the model's state vector. Thus the field reveals that the model's state vector has the following structure:

  1. Determine an initial state vector.
  1. The initial state vector specifies the point in a system's state space where the trim command starts its search for an equilibrium point. The trim command searches the state space outward from the starting point, returning the first equilibrium point that it encounters. Thus, the starting point should not be at or near any of a system's trivial equilibrium points. In the case of the double pendulum, the point [0; 0; 0; 0] (i.e., the pendulum initially folded up and stationary) is a trivial equilibrium point and therefore to be avoided. The initial state vector must also be a column vector and must specify angular states in radians.

    Often, the choice of a good starting point can be found only by experiment, that is, by running the trim command repeatedly from different starting points to find a nontrivial equilibrium point. This is true of the double pendulum of this example. Experiment reveals that the following starting point

    yields a nontrivial equilibrium point. Therefore you can save time by creating an initial state vector set to these values.

  1. Set Trimming as the analysis type on the Parameters pane of the Mechanical Environment Settings dialog (see Choosing an Analysis Mode).
  1. This option inserts a constraints subsystem and associated output at the top level of the model.

    SimMechanics inserts the constraint output in order to make the constraints available to the trim command. The spring-loaded double pendulum has no constraints. Hence the constraint output port outputs nothing and is not needed to trim the pendulum.

  1. Enter the following commands to find the nearest equilibrium point to the starting point determined in
  1. The array ix specifies the starting point determined in step 3. The array iu specifies the initial inputs of the system. Its value is null because the system has no inputs. The third command executes the form of the trim command that finds a system's steady-state (equilibrium) points, i.e., the points where the system's state derivatives are zero. The array x contains the state vector corresponding to the first equilibrium point that the trim command finds:

    The resulting states are angular positions and velocities expressed in units of radians. Based on the layout of the model's state vector determined in step 2, the pendulum reaches equilibrium when its upper joint has deflected to an angle of -18.1341 degrees and its lower joint to an angle of -50.8901 degrees.

  1. Running the model in Forward Dynamics mode confirms that this is indeed an equilibrium point of the pendulum.

  1. The simulation reveals that the spring stops unfolding after about nine seconds, that is, it reaches a steady-state point. At this point the angles of the upper and lower joints are about -18 and -50 degrees, respectively, and the velocities are zero. The trim command can find the values of these states precisely.


  Open-Topology Example: Double Pendulum Constrained Example: Four-Bar System