---
url: /dyad/stable/stdlib/TranslationalComponents/tests/Components.Tests.MassDamperSpringFixed.md
description: >-
  Dyad Components.Tests.MassDamperSpringFixed docs.  A one-dimensional
  translational mechanical system composed of a mass, spring, and damper
  connected to a fixed point.
---

# `Components.Tests.MassDamperSpringFixed` {#Components.Tests.MassDamperSpringFixed}

A one-dimensional translational mechanical system composed of a mass, spring, and damper connected to a fixed point.

This component represents a classic damped harmonic oscillator. A mass (`body`) is attached to one end of a parallel combination of a linear spring (`spring`) and a viscous damper (`damper`). The other end of this spring-damper combination is connected to a fixed reference point (`ground`). The `L=0` parameter for the `Mass` subcomponent, and the initial condition `body.flange_b.s = 0` for the mass's second flange (often specified in simulation setup or test metadata), imply that `body.flange_a.s` directly represents the absolute displacement `x` of the mass.

## Usage {#Usage}

`TranslationalComponents.Components.Tests.MassDamperSpringFixed()`

## Behavior {#Behavior}

$$ \begin{align}
0 &= \mathrm{connect}\left( spring\_{+}flange\_{a}, body\_{+}flange\_{a}, damper\_{+}flange\_{a} \right) \\
0 &= \mathrm{connect}\left( spring\_{+}flange\_{b}, damper\_{+}flange\_{b}, ground\_{+}flange \right) \\
\mathtt{damper.s_rel}\left( t \right) &=  - \mathtt{damper.flange_a.s}\left( t \right) + \mathtt{damper.flange_b.s}\left( t \right) \\
\mathtt{damper.v_rel}\left( t \right) &= \frac{\mathrm{d}\mathtt{damper.s_rel}\left( t \right)}{\mathrm{d}t} \\
\mathtt{damper.flange_b.f}\left( t \right) &= \mathtt{damper.f}\left( t \right) \\
\mathtt{damper.flange_a.f}\left( t \right) &=  - \mathtt{damper.f}\left( t \right) \\
\mathtt{damper.f}\left( t \right) &= \mathtt{damper.d} ~ \mathtt{damper.v_rel}\left( t \right) \\
\mathtt{damper.lossPower}\left( t \right) &= \mathtt{damper.f}\left( t \right) ~ \mathtt{damper.v_rel}\left( t \right) \\
\mathtt{spring.s_rel}\left( t \right) &=  - \mathtt{spring.flange_a.s}\left( t \right) + \mathtt{spring.flange_b.s}\left( t \right) \\
\mathtt{spring.flange_b.f}\left( t \right) &= \mathtt{spring.f}\left( t \right) \\
\mathtt{spring.flange_a.f}\left( t \right) &=  - \mathtt{spring.f}\left( t \right) \\
\mathtt{spring.f}\left( t \right) &= \mathtt{spring.c} ~ \left( \mathtt{spring.s_rel}\left( t \right) - \mathtt{spring.s_rel0} \right) \\
\mathtt{body.flange_a.s}\left( t \right) &=  - \frac{1}{2} ~ \mathtt{body.L} + \mathtt{body.s}\left( t \right) \\
\mathtt{body.flange_b.s}\left( t \right) &= \frac{\mathtt{body.L}}{2} + \mathtt{body.s}\left( t \right) \\
\mathtt{body.v}\left( t \right) &= \frac{\mathrm{d}\mathtt{body.s}\left( t \right)}{\mathrm{d}t} \\
\mathtt{body.a}\left( t \right) &= \frac{\mathrm{d}\mathtt{body.v}\left( t \right)}{\mathrm{d}t} \\
\left( \mathtt{body.a}\left( t \right) + \mathtt{body.g} ~ \sin\left( \mathtt{body.theta} \right) \right) ~ \mathtt{body.m} &= \mathtt{body.flange_a.f}\left( t \right) + \mathtt{body.flange_b.f}\left( t \right) \\
\mathtt{ground.flange.s}\left( t \right) &= \mathtt{ground.s0}
\end{align}
$$

## Source {#Source}

```dyad
"""
A one-dimensional translational mechanical system composed of a mass, spring, and damper connected to a fixed point.

This component represents a classic damped harmonic oscillator. A mass (`body`) is attached to
one end of a parallel combination of a linear spring (`spring`) and a viscous damper (`damper`).
The other end of this spring-damper combination is connected to a fixed reference point (`ground`).
The `L=0` parameter for the `Mass` subcomponent, and the initial condition `body.flange_b.s = 0`
for the mass's second flange (often specified in simulation setup or test metadata), imply that
`body.flange_a.s` directly represents the absolute displacement `x` of the mass.
"""
test component MassDamperSpringFixed
  "The viscous damper subcomponent."
  damper = TranslationalComponents.Components.Damper(d = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 295, "x2": 395, "y1": 120, "y2": 220}}}
  }
  "The linear spring subcomponent."
  spring = TranslationalComponents.Components.Spring(c = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 35, "x2": 135, "y1": 220, "y2": 320}}}
  }
  "The translational mass subcomponent."
  body = TranslationalComponents.Components.Mass(m = 1, L = 0) {
    "Dyad": {"placement": {"diagram": {"x1": 165, "x2": 265, "y1": 20, "y2": 120}}}
  }
  "The fixed mechanical ground subcomponent."
  ground = TranslationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 420, "x2": 520, "y1": 200, "y2": 300}}}
  }
relations
  connect(spring.flange_a, body.flange_a, damper.flange_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 20, "y": 270}, {"x": 20, "y": 70}], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": -1, "M": [{"x": 150, "y": 170}], "E": 3}
      ],
      "junctions": [{"x": 150, "y": 70}]
    }
  }
  connect(spring.flange_b, damper.flange_b, ground.flange) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 410, "y": 270}], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": -1, "M": [{"x": 470, "y": 170}], "E": 3}
      ],
      "junctions": [{"x": 410, "y": 170}]
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 20,
        "initial": {"body.flange_b.s": 0, "damper.flange_b.f": 0},
        "atol": {"body.v": 0.001},
        "expect": {"final": {"body.v": 0}, "signals": ["body.v"]}
      }
    }
  }
}
end
```

```dyad
"""
A one-dimensional translational mechanical system composed of a mass, spring, and damper connected to a fixed point.

This component represents a classic damped harmonic oscillator. A mass (`body`) is attached to
one end of a parallel combination of a linear spring (`spring`) and a viscous damper (`damper`).
The other end of this spring-damper combination is connected to a fixed reference point (`ground`).
The `L=0` parameter for the `Mass` subcomponent, and the initial condition `body.flange_b.s = 0`
for the mass's second flange (often specified in simulation setup or test metadata), imply that
`body.flange_a.s` directly represents the absolute displacement `x` of the mass.
"""
test component MassDamperSpringFixed
  "The viscous damper subcomponent."
  damper = TranslationalComponents.Components.Damper(d = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 295, "x2": 395, "y1": 120, "y2": 220}}}
  }
  "The linear spring subcomponent."
  spring = TranslationalComponents.Components.Spring(c = 1) {
    "Dyad": {"placement": {"diagram": {"x1": 35, "x2": 135, "y1": 220, "y2": 320}}}
  }
  "The translational mass subcomponent."
  body = TranslationalComponents.Components.Mass(m = 1, L = 0) {
    "Dyad": {"placement": {"diagram": {"x1": 165, "x2": 265, "y1": 20, "y2": 120}}}
  }
  "The fixed mechanical ground subcomponent."
  ground = TranslationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 420, "x2": 520, "y1": 200, "y2": 300}}}
  }
relations
  connect(spring.flange_a, body.flange_a, damper.flange_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 20, "y": 270}, {"x": 20, "y": 70}], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": -1, "M": [{"x": 150, "y": 170}], "E": 3}
      ],
      "junctions": [{"x": 150, "y": 70}]
    }
  }
  connect(spring.flange_b, damper.flange_b, ground.flange) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 410, "y": 270}], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": -1, "M": [{"x": 470, "y": 170}], "E": 3}
      ],
      "junctions": [{"x": 410, "y": 170}]
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 20,
        "initial": {"body.flange_b.s": 0, "damper.flange_b.f": 0},
        "atol": {"body.v": 0.001},
        "expect": {"final": {"body.v": 0}, "signals": ["body.v"]}
      }
    }
  }
}
end
```

## Test Cases {#Test-Cases}

### Test Case `case1` {#Test-Case-case1}

```julia
plt
```

![](uqmqxww.svg)

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Damper`](Components.Tests.MassDamperSpringFixed.md)

  * [`Fixed`](Components.Tests.MassDamperSpringFixed.md)

  * [`Mass`](Components.Tests.MassDamperSpringFixed.md)

  * [`Spring`](Components.Tests.MassDamperSpringFixed.md)
