# Links¶

A link is used to model a force in the system

- It is a point to point force element:
- A force is applied on the first body and an opposite force is applied on the other body.
- The direction of the force is the direction of the line connecting the 2 points.
- The intensity must be given by the user.

- It is usefull to model elements for which the mass dynamics can be neglected such the spring damper of a car suspension.

- The force intensity must be calculated in the
*user_LinkForces*function:- The link length Z and the link velocity Zd are calculated by the
symbolic engine and given as arguments of the
*user_LinkForce*function. - The force intensity returned by the
*user_LinkForce*function is automatically projected in the body. - A positive force value tends to separate the bodies.
- A negative force value tends to bring closer the bodies.

- The link length Z and the link velocity Zd are calculated by the
symbolic engine and given as arguments of the

## Back to the pendulum-spring example¶

Add a spring-damper between a point on the base and a point on the pendulum with the following parameters:

- Spring stiffness: 200 N/m
- Damping: 20 Ns/m
- Free length: 0.05 m
- Geometry given on the figure, the link is attached to the fixed frame in the X positive direction.

REMARK:

Step 2, 4 and 5 are not impacted by theses function. See the

Bodies and jointspart for more information

### Step 1: Draw your multibody system¶

- Open the Pendulum Spring model in MBsysPad
- Add an anchor point on the base and fill the coordinates
- Add an anchor point on the pendulum and fill the coordinates
- Add the link to the diagram
- Click on the Link button in the toolbar
- Click on the first point
- Click on the second point
- Click on the link to edit its properties
- Change the name of the link

- Add a user model to store the parameter values of the spring damper:
- This page explain you how to add an user model for another application, only apply the step 1 and adapt it
- Name of the user model :
*mylink* - Parameter
*K*to store the spring stiffness - Parameter
*C*to store the damping - Parameter
*Z0*to store the free length

### Step 2: Generate your multibody equations¶

Regenerate the multibody equations with the same options as previously.

### Step 3: Write your user function¶

Matlab section:

- Edit the
*user_LinkForces*function (open the file from the userfctR subfolder of your project) - Write the force equations:

```
function Flink = user_LinkForces(Z,Zd,mbs_data,tsim,ilnk)
%...
% get the link id (see the "tips and trick" if you don't know the mbs_get_link_id function")
L1 = mbs_get_link_id(MBS_info,'MyLink');
switch(ilnk)
case L1
K = mbs_data.user_model.mylink.K;
C = mbs_data.user_model.mylink.C;
Z0 = mbs_data.user_model.mylink.L0;
Flink = K*(Z-Z0)+C*Zd;
end
%...
return
```

REMARK:

Sign convention: for a spring system

- Flink < 0 ==> compression (Z-Z0 < 0)
- Flink > 0 ==> traction (Z-Z0 > 0)

REMARK

If there are several links in the model, all the constitutive laws are introduced in the

user_LinkForcesfunction and the switch-case is used to distinguish the various links.

### Check the results¶

Plot the graph of the joint position (results ares avilaible in resultsR/ folder) and check your results with the following graph.