number: 338
slug: parallel-motion-radius-bar-above-beam
name: A parallel motion with the radius bar above the beam
brown: "Another modification, in which the radius bar is placed above the beam."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 100, solver: CG, multiccd: true, duration_s: 8, floor: false}
bodies:
  # the framing: the beam's centre O on its column, the radius rod's centre G, and the gland
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    density: 7800
    color: "#9a9284"
    pieces:
      - {kind: poly, points: [[-18.0000, -27.2000], [48.0000, -27.2000], [48.0000, -26.0000], [-18.0000, -26.0000]], y: [-4.6, 3.6], collide: 0}
      - {kind: poly, points: [[-1.6000, -26.0000], [1.6000, -26.0000], [1.6000, 0.0000], [-1.6000, 0.0000]], y: [2.0, 3.2], collide: 0}
      - {kind: rod, from: [0, -1.0, 0], to: [0, 3.2, 0], radius: 1.0, collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[19.6000, -26.0000], [21.2000, -26.0000], [21.2000, 7.8000], [19.6000, 7.8000]], y: [1.4, 2.0], collide: 0}
      - {kind: disc, center: [20.4000, 7.8000], radius: 1.0, y: [1.4, 2.0], collide: 0}
      - {kind: rod, from: [20.4000, -2.8, 7.8000], to: [20.4000, 2.0, 7.8000], radius: 0.4, collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[44.6000, -26.0000], [46.0000, -26.0000], [46.0000, -24.0000], [44.6000, -24.0000]], y: [-4.2, -2.6], collide: 0}
      - {kind: poly, points: [[40.5000, -24.0000], [46.0000, -24.0000], [46.0000, -22.6000], [40.5000, -22.6000]], y: [-4.2, -2.6], collide: 0}
      - {kind: poly, points: [[38.4000, -22.6000], [41.6000, -22.6000], [41.6000, -20.0000], [38.4000, -20.0000]], y: [-4.6, -2.2], collide: 0, color: "#7d776c"}
  # the beam, rocked on O (the driven joint), with its end pin U
  - id: beam
    shape: part
    pos: [0, 0, 0]
    mount: frame
    density: 7800
    color: "#b0a690"
    pieces:
      - {kind: poly, points: [[-12, -2.0], [0, -2.8], [41.2000, -1.2], [41.2000, 1.2], [0, 2.8], [-12, 2.0]], y: [-0.6, 0.6], collide: 0}
      - {kind: disc, center: [-12, 0], radius: 4.5, y: [-1.4, 1.4], collide: 0, color: "#7d776c"}   # a weight on the beam's other end, in place of the engine's crank side
      - {kind: disc, center: [0, 0], radius: 4.6, y: [-0.9, 0.9], collide: 0}
      - {kind: disc, center: [0, 0], radius: 1.2, y: [-1.1, 1.1], collide: 0, color: "#6f6a60"}
      - {kind: disc, center: [40.0000, 0], radius: 1.4, y: [-0.8, 0.8], collide: 0}
      - {kind: rod, from: [40.0000, -1.6, 0], to: [40.0000, 0.6, 0], radius: 0.4, collide: 0, color: "#6f6a60"}
  # the rod through the beam's end U: the radius bar's pin T at its upper end, the piston-rod's pin C at its lower end
  - id: V
    shape: part
    pos: [40.0000, 0, 0.0000]
    mount: beam
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [40.0000, -1.25, 7.8000], to: [40.0000, -1.25, -7.4941], radius: 0.35, collide: 0}
      - {kind: disc, center: [40.0000, 0.0000], radius: 0.9, y: [-1.6, -0.9], collide: 0}
      - {kind: disc, center: [40.0000, 7.8000], radius: 0.4, y: [-2.6, -0.9], collide: 2, color: "#6f6a60"}
      - {kind: disc, center: [40.0000, -7.4941], radius: 0.4, y: [-3.8, -0.9], collide: 2, color: "#6f6a60"}
  # the radius bar G T above the beam, on its fixed centre G; its eye a bearing on T
  - id: Rr
    shape: part
    pos: [20.4000, 0, 7.8000]
    mount: frame
    density: 7800
    color: "#a39a88"
    pieces:
      - {kind: rod, from: [20.4000, -2.3, 7.8000], to: [40.0000, -2.3, 7.8000], radius: 0.4, collide: 0}
      - {kind: disc, center: [20.4000, 7.8000], radius: 0.75, y: [-2.6, -2.0], collide: 0}
      - {kind: band, center: [40.0000, 7.8000], r: [0.42, 0.95], a: [0, 6.2832], y: [-2.6, -2.0], slices: 36, collide: 1}
  # the cross-head and the piston-rod: free to move across and up and down; only the pin C places it
  - {id: Px, shape: part, pos: [40.0000, 0, -7.4941], mount: frame, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [40.0000, -21], radius: 0.1, y: [-3.5, -3.4], collide: 0}]}
  - id: P
    shape: part
    pos: [40.0000, 0, -7.4941]
    mount: Px
    density: 7800
    color: "#b8ad96"
    pieces:
      - {kind: band, center: [40.0000, -7.4941], r: [0.42, 0.95], a: [0, 6.2832], y: [-3.8, -3.0], slices: 36, collide: 1}
      - {kind: rod, from: [40.0000, -3.4, -8.4441], to: [40.0000, -3.4, -21.4941], radius: 0.45, collide: 0, color: "#8f8a80"}
joints:
  - {id: j_O, type: hinge, body: beam, axis: [0, -1, 0], damping: 0.001}
  - {id: j_V, type: hinge, body: V, axis: [0, -1, 0], damping: 0.001}
  - {id: j_G, type: hinge, body: Rr, axis: [0, -1, 0], damping: 0.001}
  - {id: j_x, type: slide, body: Px, axis: [1, 0, 0], damping: 0.2, range: [-1, 1]}
  - {id: j_z, type: slide, body: P, axis: [0, 0, 1], damping: 0.2, range: [-7, 7]}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_O, kind: velocity, rpm: 0, swing: {amplitude: 0.14, hz: 0.25}, kv: 2000, max_torque: 100}
checks:
  # the beam, rocked on O, carries the rod's middle U up and down, and with it the piston-rod on its lower end ...
  - {type: follow, out: j_z, in: j_O, expect: 0.399, tol: 0.008, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  - {type: amplitude, joint: j_z, min: 0.054, max: 0.059, settle_s: 0.5, window_s: 7.0}
  # ... while the radius bar above the beam swings the same way, OU / GT = 2.04 times as far, so that the rod's
  # lower end C keeps to a straight line: under a millimetre across
  - {type: follow, out: j_G, in: j_O, expect: 2.058, tol: 0.05, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  - {type: position, joint: j_x, min: -0.1, max: 0.1, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [14, 0, -14], position: [14, -215, -6], fov: 30}
display:
  output: j_z
  labels: {j_O: "Beam, rocked on O (driver)", j_V: Rod T U C, j_G: Radius bar G T, j_x: Cross-head C across, j_z: Cross-head C and piston-rod}

