Main Content

Using Operating Points to Initialize Multibody Models

This example contains two models that show how to use operating points to initialize multibody models. The first model shows how to create an operating point, modify the target of a joint, and initialize the model with this operating point. The second model shows how to start a simulation of a flexible body from its deformed state.

An operating point has a hierarchical structure that contains targets and priorities for the block variables. You can create an operating point by using the simscape.op.create function to extract data from either a multibody model or logged simulation data. Additionally, you can modify, add, or remove variable targets in the operating point. For more information, see Extracting Variable Initialization Data into an Operating Point and Manipulating Operating Point Data. For information on how to set a model to use an operating point for initialization, see Applying Operating Point Data to Initialize Model.

After creating an operating point, making certain changes to a model, such as altering the joint input type, adding new joints, or changing flexible body settings, may result in errors or inaccurate results. If these changes are necessary, generate a new operating point.

Initialize Joint Variables for Four Bar Mechanism

This model shows how to create an operating point from a four-bar model, modify the target of a revolute joint, and initialize the model with the operating point for another simulation run.

1. Open the four-bar model. At the MATLAB command prompt, enter:

open_system("DocFourBar")

You can use the Variable Viewer to see the current targets and start values, which are the actual value of the variable computed by the solver, for block variables. To open the Variable Viewer, in the model window, on the Debug tab, click Simscape > Variable Viewer.

2. Create an operating point by extracting the start values from the model:

op = simscape.op.create(gcs,"Start")
op = 

  OperatingPoint with children:

  OperatingPoints:

   ChildId                      Size
   ___________________________  ____

   'Base-Crank Revolute'         1x1
   'Base-Rocker Revolute'        1x1
   'Connector-Rocker Revolute'   1x1
   'Crank-Connector Revolute'    1x1

3. To change the target of a block variable, use the simscape.op.Target method and the set function. For example, to change the velocity target of the Base-Crank Revolute joint to 100 deg/s, create a Target object named t and set it to the op object.

t = simscape.op.Target(100,"deg/s","High");
op = set(op,"Base-Crank Revolute/Rz/w",t);

4. Enable model initialization from the operating point and set the model to use the op object for initialization:

set_param(gcs,"SimscapeUseOperatingPoints","on")
set_param(gcs,"SimscapeOperatingPoint","op")

5. Update the Variable Viewer to check the new variable targets.

The velocity target of the Base-Crank Revolute joint is now 100 deg/s. The targets set in the operating point override the targets specified in the block diagrams.

Initialize Cantilever Beam with Static Deflection

This model shows how it initiate the simulation of a cantilever beam from a deformed state. You create an operating point using the logged simulation data captured when the cantilever beam reaches its static deflection, then, use this operating point to initialize the beam model for another simulation run.

1. Open the cantilever beam model. At the MATLAB command prompt, enter:

open_system("DocCantileverBeam") 

This example enables data logging for the whole model, with the Workspace variable name parameter set to simlogDocCantileverBeam. For more information, see Enable Simscape Data Logging for the Whole Model.

2. Simulate the model and examine the displacement of the free end of the beam in the Scope block.

Because the beam is subject only to gravity, with no other external loads, the beam undergoes transient vibrations due to gravitational forces. These vibrations gradually decay until the beam reaches a static deflection of 22.7 mm at the free end of the beam.

To avoid these transient vibrations, you can start a new simulation from this specific state.

3. Create an operating point from the simulation data logged at the 6th second, when the beam reaches the static deflection.

op = simscape.op.create(simlogDocCantileverBeam,6)
op =  

  OperatingPoint with children:
 
  OperatingPoints: 

   ChildId  Size 
   _______  ____ 

   'Beam'    1x1 

In the case of flexible bodies, the simulation log and the operating point contain information about the flexible body states, but you cannot access or modify this data. For example, it is not possible to access or change the data of the beam within the created operating point.

4. Initialize the model from the operating point and set the model to use the op object for initialization:

set_param(gcs,"SimscapeUseOperatingPoints","on")
set_param(gcs,"SimscapeOperatingPoint","op")

You can now run a simulation of the beam starting from this deformed state. For example, you can apply a vertical force at the free end in the z-direction, initiating after the first second. In the Tip Force block, change the force value to 5e5 N.

6. Simulate the model and view the displacement at the free end.

The Scope block shows the free end of the beam starts with an initial displacement of 22.7 mm and does not include the transient vibrations that occur before. After applying the tip force, the beam starts to vibrate and eventually stabilizes at a new static equilibrium.

See Also

| |

Related Topics