## Modeling Position-Based Mechanical Translational Systems

### Getting Started

This case study explores position-based mechanical translational modeling by using a custom Simscape™ example library. The library introduces a new domain and defines all of the fundamental components required to build position-based models.

The example library comes built and on your path. The source files for the example library are in the following namespace folder:

`matlabroot/toolbox/physmod/simscape/supporting_files/example_libraries/+PositionBasedTranslational`

where `matlabroot` is the MATLAB® root folder on your machine, as returned by entering

```matlabroot ```

in the MATLAB Command Window.

To open the example library, type

```PositionBasedTranslational_lib ```

The library is organized into elements, sources, and sensors, similar to the shipping Simscape libraries. The Utilities sublibrary contains the Translational Mechanical Properties block, which specifies the global parameters for all the blocks in the attached circuit. The Utilities sublibrary also contains interface blocks that allow connections between position-based and non-position-based mechanical translational ports.

### Position-Based Translational Domain Definition

To see the position-based mechanical translational domain definition, open the Simscape file `matlabroot/toolbox/physmod/simscape/supporting_files/example_libraries/+PositionBasedTranslational/Translational.ssc`, where `matlabroot` is the MATLAB root folder on your machine.

```domain Translational % Position-Based Mechanical Translational Domain % For every node, velocity is the derivative of position. % Copyright 2023 The MathWorks, Inc. parameters gravity = { 0, 'm/s^2'}; % Downward gravitational acceleration, g theta = { 0, 'deg' }; % Domain positive direction incline angle, θ end variables x = { 0, 'm' }; % Position v = { 0, 'm/s' }; % Velocity end variables(Balancing=true) f = { 0, 'N' }; % Force end equations der(x) == v; end end ```

The domain contains the following variables and parameters:

• Across variable x (position), in m

• Across variable v (velocity), in m/s

• Through variable f (force), in N

• Parameter gravity, specifying the downward gravitational acceleration

• Parameter theta, specifying the positive direction incline angle

The domain parameters, also accessible through the Translational Mechanical Properties block, are global parameters that propagate their values to all the blocks in the attached circuit.

The domain has two Across variables (position and velocity) and only one Through variable (force). Therefore, the `equations` section contains one equation that establishes the mathematical relationship between the position and velocity, der(x) = v. For more information, see Domain Equations.

### Position-Based Modeling Framework

In a position-based translational domain, blocks have a fixed orientation aligned with the global positive direction. Imagine all parts assembled on a rail.

Things to keep in mind:

• On the canvas, the World block sets the absolute zero position and velocity in the model.

• Model has a global positive direction.

• All the blocks have a positive direction, which always aligns with the global positive direction. The global positive direction is determined when you place the first two-port block or External Force Source block in the model. For the External Force Source block, which has one port, the positive direction is indicated by the arrow on the block icon.

For example, in the previous illustration, the global positive direction is from left to right. In your mental model, you can map the global positive direction of the model to represent left, right, up, or down.

• Blocks can move only in the positive or negative direction. If you rotate a block on the canvas, it affects only the schematic view. For more information, see Difference Between Schematic View and Physical View.

• Some blocks have length, specified as a block parameter or high-priority variable target. Other blocks are assumed to have zero length. When you place the blocks in the model and connect them, the software uses the block lengths to calculate the positions of all the block ports with respect to the absolute zero (the World block), as shown in the illustration.

For example, in the previous illustration, you connect the blocks and specify the lengths, l1, l2, and l4. The software computes the values of the global positions, p0, p1, p2, and p4, and sets the variable target l3 = l2.

#### Types of Blocks

The blocks in a position-based translational domain conceptually belong to several distinct types.

Block Type ConventionsSchematic Representation
World
• Sets absolute zero position and velocity

• For positive positions, the positive direction is away from the World frame

• Each position-based translational circuit requires a World block

Two-port blocks
• Have length, as well as positive direction

• The first two-port block placed on the canvas sets global positive direction, unless the model already contains an External Force Source block

• Port naming convention: B (base) and F (follower)

• Positive direction is from B to F

• Positive direction aligns with the global positive direction

One-port blocks
• Have no length, but have a positive direction

• Port naming convention: R (reference)

• Positive direction aligns with the global positive direction

#### Difference Between Schematic View and Physical View

In a position-based translational domain, it is important to differentiate the schematic view from the physical view. For example, these two models are identical.

The top model shows a purely schematic view. The bottom model better represents the physical view, that is, the way the model actually looks in the physical world: with the spring and the damper located between the mass and the frame and acting in parallel. In this model, the global positive direction is easy to visualize.

The best practice is to draw model schematic on canvas in a way that is consistent with the physical view. Things to keep in mind:

• Model canvas represents the schematic view. It shows block connectivity, not the part orientation.

• When you rotate parts in the schematic view, the parts are not rotating in the physical world. For better intuitive understanding of the model, do not rotate parts relative to the global positive direction.

• The World block represents a single point in space. Therefore, in most situations it is consistent with the physical view to have only one World block in a connected circuit.