Skip to content
LIBRARY
examples.ThreeSprings.md

examples.ThreeSprings

Three springs

This example mirrors the Modelica three-springs and demonstrates that we can connect massless force elements together.

The example connects three springs together at a single point. The springs are all massless and do normally not have any state variables. We must tell the lower spring component (spring3) to act as root by setting fixed_rotation_at_frame_b = true.

The topology is:

  • worldbar1 (horizontal) → spring1.frame_a

  • worldbar2 (out of plane) → spring3.frame_a

  • spring1.frame_b, spring2.frame_a, and spring3.frame_b all meet at a single point

  • spring2.frame_bbody1 (the only massive element, with quaternion state)

Usage

MultibodyComponents.examples.ThreeSprings()

Behavior

Source

dyad
"""
# Three springs

This example mirrors the [Modelica three-springs](https://doc.modelica.org/om/Modelica.Mechanics.MultiBody.Examples.Elementary.ThreeSprings.html)
and demonstrates that we can connect massless force elements together.

The example connects three springs together at a single point. The springs are
all massless and do normally not have any state variables. We must tell the
lower spring component (`spring3`) to act as root by setting
`fixed_rotation_at_frame_b = true`.

The topology is:
- `world` → `bar1` (horizontal) → `spring1.frame_a`
- `world` → `bar2` (out of plane) → `spring3.frame_a`
- `spring1.frame_b`, `spring2.frame_a`, and `spring3.frame_b` all meet at a
  single point
- `spring2.frame_b` → `body1` (the only massive element, with quaternion state)
"""
example component ThreeSprings
  world = MultibodyComponents.World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 80, "y1": 90, "x2": 180, "y2": 190, "rot": 0}
      },
      "tags": []
    }
  }
  body1 = MultibodyComponents.Body(m = 0.8, I_11 = 0.1, I_22 = 0.1, I_33 = 0.1, I_21 = 1e-6, I_31 = 1e-6, I_32 = 1e-6, r_cm = [0, -0.2, 0], orientation_state = OrientationState.Quaternion(), r_0(initial = [0.5, -0.3, 0])) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 480, "y1": 620, "x2": 380, "y2": 720, "rot": 270}
      },
      "tags": []
    }
  }
  bar1 = MultibodyComponents.FixedTranslation(r = [0.3, 0, 0]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 90, "x2": 360, "y2": 190, "rot": 0}
      },
      "tags": []
    }
  }
  bar2 = MultibodyComponents.FixedTranslation(r = [0, 0, 0.3]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 220, "x2": 270, "y2": 320, "rot": 90}
      },
      "tags": []
    }
  }
  spring1 = MultibodyComponents.Spring(c = 20, s_unstretched = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 480, "y1": 220, "x2": 380, "y2": 320, "rot": 270}
      },
      "tags": []
    }
  }
  spring2 = MultibodyComponents.Spring(c = 40, s_unstretched = 0.1, color = [0, 0, 0.3, 1]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 480, "y1": 470, "x2": 380, "y2": 570, "rot": 270}
      },
      "tags": []
    }
  }
  spring3 = MultibodyComponents.Spring(c = 20, s_unstretched = 0.1, fixed_rotation_at_frame_b = true) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 360, "x2": 360, "y2": 460, "rot": 0}
      },
      "tags": []
    }
  }
relations
  # initial body1.Q_hat = [1, 0, 0, 0]
  guess spring1.r_rel_0 = [-0.2, -0.2, 0.2]
  connect(bar1.frame_b, spring1.frame_a) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 430, "y": 140}], "E": 2}]
    }
  }
  connect(world.frame_b, bar1.frame_a, bar2.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 220, "y": 140}],
      "renderStyle": "standard"
    }
  }
  connect(spring3.frame_a, bar2.frame_b) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 220, "y": 410}], "E": 2}]
    }
  }
  connect(spring1.frame_b, spring3.frame_b, spring2.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 430, "y": 410}], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 430, "y": 410}],
      "renderStyle": "standard"
    }
  }
  connect(body1.frame_a, spring2.frame_b) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
end
Flattened Source
dyad
"""
# Three springs

This example mirrors the [Modelica three-springs](https://doc.modelica.org/om/Modelica.Mechanics.MultiBody.Examples.Elementary.ThreeSprings.html)
and demonstrates that we can connect massless force elements together.

The example connects three springs together at a single point. The springs are
all massless and do normally not have any state variables. We must tell the
lower spring component (`spring3`) to act as root by setting
`fixed_rotation_at_frame_b = true`.

The topology is:
- `world` → `bar1` (horizontal) → `spring1.frame_a`
- `world` → `bar2` (out of plane) → `spring3.frame_a`
- `spring1.frame_b`, `spring2.frame_a`, and `spring3.frame_b` all meet at a
  single point
- `spring2.frame_b` → `body1` (the only massive element, with quaternion state)
"""
example component ThreeSprings
  world = MultibodyComponents.World() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 80, "y1": 90, "x2": 180, "y2": 190, "rot": 0}
      },
      "tags": []
    }
  }
  body1 = MultibodyComponents.Body(m = 0.8, I_11 = 0.1, I_22 = 0.1, I_33 = 0.1, I_21 = 1e-6, I_31 = 1e-6, I_32 = 1e-6, r_cm = [0, -0.2, 0], orientation_state = OrientationState.Quaternion(), r_0(initial = [0.5, -0.3, 0])) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 480, "y1": 620, "x2": 380, "y2": 720, "rot": 270}
      },
      "tags": []
    }
  }
  bar1 = MultibodyComponents.FixedTranslation(r = [0.3, 0, 0]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 90, "x2": 360, "y2": 190, "rot": 0}
      },
      "tags": []
    }
  }
  bar2 = MultibodyComponents.FixedTranslation(r = [0, 0, 0.3]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 220, "x2": 270, "y2": 320, "rot": 90}
      },
      "tags": []
    }
  }
  spring1 = MultibodyComponents.Spring(c = 20, s_unstretched = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 480, "y1": 220, "x2": 380, "y2": 320, "rot": 270}
      },
      "tags": []
    }
  }
  spring2 = MultibodyComponents.Spring(c = 40, s_unstretched = 0.1, color = [0, 0, 0.3, 1]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 480, "y1": 470, "x2": 380, "y2": 570, "rot": 270}
      },
      "tags": []
    }
  }
  spring3 = MultibodyComponents.Spring(c = 20, s_unstretched = 0.1, fixed_rotation_at_frame_b = true) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 360, "x2": 360, "y2": 460, "rot": 0}
      },
      "tags": []
    }
  }
relations
  # initial body1.Q_hat = [1, 0, 0, 0]
  guess spring1.r_rel_0 = [-0.2, -0.2, 0.2]
  connect(bar1.frame_b, spring1.frame_a) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 430, "y": 140}], "E": 2}]
    }
  }
  connect(world.frame_b, bar1.frame_a, bar2.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 220, "y": 140}],
      "renderStyle": "standard"
    }
  }
  connect(spring3.frame_a, bar2.frame_b) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 220, "y": 410}], "E": 2}]
    }
  }
  connect(spring1.frame_b, spring3.frame_b, spring2.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 430, "y": 410}], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 430, "y": 410}],
      "renderStyle": "standard"
    }
  }
  connect(body1.frame_a, spring2.frame_b) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {}
end


Test Cases

No test cases defined.

  • Examples

  • Experiments

  • Analyses