---
url: /dyad/dev/stdlib/MultibodyComponents/components/LineForceWithMass.md
description: >-
  Dyad LineForceWithMass docs.  Line force component with optional point mass on
  the line between two frames.
---

# `LineForceWithMass` {#LineForceWithMass}

Line force component with optional point mass on the line between two frames.

Extends `LineForceBase` for geometry. Provides translational flanges (`flange_a`, `flange_b`) for connecting 1D force elements (springs, dampers).

When `m > 0`, a point mass at position `lengthfraction` along the line contributes inertia and gravity forces. When `m = 0`, the mass terms vanish.

This component extends from [`LineForceBase`](LineForceBase.md)

## Usage {#Usage}

`MultibodyComponents.LineForceWithMass(s_small=1e-10, m=1.0, lengthfraction=0.5)`

## Parameters: {#Parameters:}

|                        Name |                                                                                          Description | Units | Default value |
| ---------------------------:| ----------------------------------------------------------------------------------------------------:| -----:| -------------:|
| `fixed_rotation_at_frame_a` |                                                                                                      |     – |         false |
| `fixed_rotation_at_frame_b` |                                                                                                      |     – |         false |
|                   `hasmass` |                                                                                                      |     – |          true |
|             `point_gravity` |                   Use a point-gravity field pointing towards the world origin (structural; see Body) |     – |         false |
|                   `s_small` |                                                                                                      |     – |         1e-10 |
|                         `m` |                                                                                                 mass |    kg |           1.0 |
|            `lengthfraction` | Location of point mass with respect to frame_a as a fraction of the distance from frame_a to frame_b |     – |           0.5 |

## Connectors {#Connectors}

* `frame_a` - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several `Frame`

connectors that can be connected together ([`Frame3D`](/stdlib/Dyad/connectors/Frame3D#Frame3D))

* `frame_b` - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several `Frame`

connectors that can be connected together ([`Frame3D`](/stdlib/Dyad/connectors/Frame3D#Frame3D))

* `flange_a` - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. ([`Flange`](/stdlib/Dyad/connectors/Flange#Flange))

* `flange_b` - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. ([`Flange`](/stdlib/Dyad/connectors/Flange#Flange))

## Variables {#Variables}

|      Name |                                                                                 Description | Units |
| ---------:| -------------------------------------------------------------------------------------------:| -----:|
|  `length` |                            Distance between the origin of frame_a and the origin of frame_b |     m |
|       `s` | (Guarded) distance between the origin of frame_a and the origin of frame_b (>= s_small)) |     m |
| `r_rel_0` |                             Position vector from frame_a to frame_b resolved in world frame |     m |
| `e_rel_0` |                   Unit vector in direction from frame_a to frame_b, resolved in world frame |     – |
|      `fa` |                                                                  scalar force from flange_a |     N |
|      `fb` |                                                                  scalar force from flange_b |     N |
|  `r_CM_0` |                     Position vector from world frame to point mass, resolved in world frame |     m |
|  `v_CM_0` |                                                                  First derivative of r_CM_0 |   m/s |
| `ag_CM_0` |                                                             D(v_CM_0) - gravityAcceleration |  m/s2 |

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
Line force component with optional point mass on the line between two frames.

Extends `LineForceBase` for geometry. Provides translational flanges
(`flange_a`, `flange_b`) for connecting 1D force elements (springs, dampers).

When `m > 0`, a point mass at position `lengthfraction` along the line
contributes inertia and gravity forces. When `m = 0`, the mass terms vanish.
"""
component LineForceWithMass
  extends LineForceBase
  flange_a = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": -50, "x2": 300, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  flange_b = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 700, "y1": -50, "x2": 800, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter hasmass::Boolean = true
  "mass"
  parameter m::Mass = 1.0 if hasmass
  "Location of point mass with respect to frame_a as a fraction of the distance from frame_a to frame_b"
  parameter lengthfraction::Real = 0.5 if hasmass
  "scalar force from flange_a"
  variable fa::Dyad.Force
  "scalar force from flange_b"
  variable fb::Dyad.Force
  "Position vector from world frame to point mass, resolved in world frame"
  variable r_CM_0::Position[3] if hasmass
  "First derivative of r_CM_0"
  variable v_CM_0::Velocity[3] if hasmass
  "D(v_CM_0) - gravityAcceleration"
  variable ag_CM_0::Acceleration[3] if hasmass
  "Use a point-gravity field pointing towards the world origin (structural; see Body)"
  structural parameter point_gravity::Boolean = false
relations
  # Flange positions along the line
  flange_a.s = 0
  flange_b.s = length
  # Flange forces
  fa = flange_a.f
  fb = flange_b.f
  if hasmass
    # Point mass dynamics
    r_CM_0 = frame_a.r_0 + r_rel_0 * lengthfraction
    v_CM_0 = der(r_CM_0)
    ag_CM_0 = der(v_CM_0) - gravity_acceleration(r_CM_0, point_gravity)
    # Force balance at frames (with mass)
    frame_a.f = resolve2(frame_a.R, m * (1 - lengthfraction) * ag_CM_0 - e_rel_0 * fa)
    frame_b.f = resolve2(frame_b.R, m * lengthfraction * ag_CM_0 - e_rel_0 * fb)
  else
    # Force balance at frames (massless)
    frame_a.f = -resolve2(frame_a.R, fa * e_rel_0)
    frame_b.f = -resolve2(frame_b.R, fb * e_rel_0)
  end
end
```

```dyad
"""
Line force component with optional point mass on the line between two frames.

Extends `LineForceBase` for geometry. Provides translational flanges
(`flange_a`, `flange_b`) for connecting 1D force elements (springs, dampers).

When `m > 0`, a point mass at position `lengthfraction` along the line
contributes inertia and gravity forces. When `m = 0`, the mass terms vanish.
"""
component LineForceWithMass
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter fixed_rotation_at_frame_a::Boolean = false
  structural parameter fixed_rotation_at_frame_b::Boolean = false
  parameter s_small::Real = 1e-10
  "Distance between the origin of frame_a and the origin of frame_b"
  variable length::Length
  "(Guarded) distance between the origin of frame_a and the origin of frame_b (>= s_small))"
  variable s::Length
  "Position vector from frame_a to frame_b resolved in world frame"
  variable r_rel_0::Position[3]
  "Unit vector in direction from frame_a to frame_b, resolved in world frame"
  variable e_rel_0::Real[3]
  flange_a = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": -50, "x2": 300, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  flange_b = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 700, "y1": -50, "x2": 800, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter hasmass::Boolean = true
  "mass"
  parameter m::Mass = 1.0 if hasmass
  "Location of point mass with respect to frame_a as a fraction of the distance from frame_a to frame_b"
  parameter lengthfraction::Real = 0.5 if hasmass
  "scalar force from flange_a"
  variable fa::Dyad.Force
  "scalar force from flange_b"
  variable fb::Dyad.Force
  "Position vector from world frame to point mass, resolved in world frame"
  variable r_CM_0::Position[3] if hasmass
  "First derivative of r_CM_0"
  variable v_CM_0::Velocity[3] if hasmass
  "D(v_CM_0) - gravityAcceleration"
  variable ag_CM_0::Acceleration[3] if hasmass
  "Use a point-gravity field pointing towards the world origin (structural; see Body)"
  structural parameter point_gravity::Boolean = false
relations
  # Relative position and distance
  r_rel_0 = frame_b.r_0 - frame_a.r_0
  length = norm_(r_rel_0)
  assert(length > s_small, "The distance between the origin of frame_a and the origin of frame_b of a line force component became smaller than parameter s_small.")
  s = max(length, s_small)
  e_rel_0 = r_rel_0 / s
  # frame_a: fix rotation to identity or set tau = 0
  if fixed_rotation_at_frame_a
    frame_a.R = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
  else
    frame_a.tau = [0, 0, 0]
  end
  # frame_b: fix rotation to identity or set tau = 0
  if fixed_rotation_at_frame_b
    frame_b.R = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
  else
    frame_b.tau = [0, 0, 0]
  end
  # Flange positions along the line
  flange_a.s = 0
  flange_b.s = length
  # Flange forces
  fa = flange_a.f
  fb = flange_b.f
  if hasmass
    # Point mass dynamics
    r_CM_0 = frame_a.r_0 + r_rel_0 * lengthfraction
    v_CM_0 = der(r_CM_0)
    ag_CM_0 = der(v_CM_0) - gravity_acceleration(r_CM_0, point_gravity)
    # Force balance at frames (with mass)
    frame_a.f = resolve2(frame_a.R, m * (1 - lengthfraction) * ag_CM_0 - e_rel_0 * fa)
    frame_b.f = resolve2(frame_b.R, m * lengthfraction * ag_CM_0 - e_rel_0 * fb)
  else
    # Force balance at frames (massless)
    frame_a.f = -resolve2(frame_a.R, fa * e_rel_0)
    frame_b.f = -resolve2(frame_b.R, fb * e_rel_0)
  end
metadata {}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
