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.
Note You cannot use Driver or Joint Initial Condition Actuator blocks while trimming a model. |
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:
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.
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.
>> v = mech_stateVectorMgr('mech_dpend_trim/G'); >> v.StateNames ans = 'mech_dpend_trim/J2/RevoluteJoint:R1:Position' 'mech_dpend_trim/J1:R1:Position' 'mech_dpend_trim/J2/RevoluteJoint:R1:Velocity' 'mech_dpend_trim/J1:R1:Velocity'
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:
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
ix(1) = J2 (lower joint) angle = -35 degrees = -0.6109 radians ix(2) = J1 (upper joint) angle = -10 degrees = -0.1745 radians ix(3) = J2 angular velocity = 0 radians/sec ix(4) = J1 angular velocity = 0 radians/sec
yields a nontrivial equilibrium point. Therefore you can save time by creating an initial state vector set to these values.
Trimming
as the analysis type on the Parameters pane of the Mechanical Environment Settings dialog (see Choosing an Analysis Mode).
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.
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.
trim
command can find the values of these states precisely.
![]() | Open-Topology Example: Double Pendulum | Constrained Example: Four-Bar System | ![]() |