Skip to content
LIBRARY
Components.Tests.MassDamperSpringFixed.md

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 ​

TranslationalComponents.Components.Tests.MassDamperSpringFixed()

Behavior ​

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
Flattened 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


Test Cases ​

Test Case case1 ​

julia
plt