# No. 186 (Brown 1868): "Apparatus for disengaging the eccentric-rod from the valve-gear. By pulling up the spring handle below until it catches in the notch, a, the pin is disengaged from the gab in the eccentric-rod."
#
# Model (cm, no gravity; a plan): the eccentric (throw 2.4 cm, the one driven joint, 30 turns a minute) works the eccentric rod through a 13 cm drop-link; the rod slides to and fro 4.8 cm in its guide.
# Its end is the gab: a notch between two jaws that holds the pin (1.2 cm) of the rock-shaft arm (7 cm long), so the rock-shaft rocks 20 deg each way (real contact, 0.12 cm of play each side).
# The gab end of the rod is hinged, with a spring that holds it down; at 5 s a hand pulls up the spring handle (the hand schedule moves the spring's rest position, as the catch in the notch a holds it there)
# and the notch lifts clear of the pin: the rock-shaft stands where it is while the eccentric and rod go on. (Putting it back is not modelled.) Generator: opencode-runs/batch11/gen186.py.
number: 186
slug: disengaging-the-eccentric-rod
name: Disengaging the eccentric-rod from the valve-gear
brown: "Apparatus for disengaging the eccentric-rod from the valve-gear. By pulling up the spring handle below until it catches in the notch, a, the pin is disengaged from the gab in the eccentric-rod."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 9.0
  floor: false
  gravity: 0
bodies:
  - id: eccentric
    shape: part
    pos: [29.0, 0, 1.6]
    mass: 0.4
    color: "#cfc6b4"
    pieces:
      - {kind: disc, center: [29.0, 1.6], radius: 3.6, y: [-2.0, -1.2], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [29.0, 4.0], radius: 1.0, y: [-1.5, -0.9], collide: 0, color: "#b9b09c"}
      - {kind: disc, center: [29.0, 1.6], radius: 1.7, y: [-2.4, -2.0], collide: 0, color: "#8f8a80"}
  - id: link
    shape: part
    pos: [29.0, 0, 4.0]
    mount: eccentric
    mass: 0.3
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[29.1015, 3.4595], [16.325, 1.0595], [16.1219, 2.1405], [28.8985, 4.5405]], y: [-1.0, -0.5], collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [29.0, -1.6, 4.0], to: [29.0, -0.8, 4.0], radius: 0.5, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [16.2235, -1.0, 1.6], to: [16.2235, 0.1, 1.6], radius: 0.5, collide: 0, color: "#8f8a80"}
  - id: rod
    shape: part
    pos: [16.2235, 0, 1.6]
    mass: 0.4
    friction: 0.02
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[13.2235, 0.8], [17.0235, 0.8], [17.0235, 2.4], [13.2235, 2.4]], y: [-0.4, 0.4], collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [12.2235, -0.7, 1.6], to: [12.2235, 0.7, 1.6], radius: 0.45, collide: 0, color: "#8f8a80"}
  - id: gab
    shape: part
    pos: [12.2235, 0, 1.6]
    mount: rod
    mass: 0.3
    friction: 0.02
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-3.3765, 1.15], [13.2235, 1.15], [13.2235, 2.75], [-3.3765, 2.75]], y: [-0.4, 0.4], collide: 2, color: "#a89a7e"}
      - {kind: poly, points: [[0.9435, -0.9], [2.4435, -0.9], [2.4435, 1.16], [0.9435, 1.16]], y: [-0.4, 0.4], collide: 2, color: "#a89a7e"}
      - {kind: poly, points: [[-1.9965, -0.9], [-0.4965, -0.9], [-0.4965, 1.16], [-1.9965, 1.16]], y: [-0.4, 0.4], collide: 2, color: "#a89a7e"}
      - {kind: poly, points: [[-2.5765, 1.15], [-3.5765, 1.15], [-3.5765, -7.0], [-2.5765, -7.0]], y: [-0.4, 0.4], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-2.5765, -6.2], [-5.9765, -6.2], [-5.9765, -7.0], [-2.5765, -7.0]], y: [-0.4, 0.4], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-5.1765, -6.2], [-5.9765, -6.2], [-5.9765, 0.25], [-5.1765, 0.25]], y: [-0.4, 0.4], collide: 0, color: "#8f8a80"}
  - id: rocker
    shape: part
    pos: [0.0, 0, -7.0]
    mass: 0.2
    friction: 0.01
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-0.5497, -6.9824], [-0.3263, 0.014], [0.7732, -0.0211], [0.5497, -7.0176]], y: [0.6, 1.2], collide: 0, color: "#d9cfb6"}
      - {kind: rod, from: [0.2235, -0.45, -0.0036], to: [0.2235, 1.2, -0.0036], radius: 0.6, collide: 1, capsule: true, color: "#8f8a80"}
      - {kind: disc, center: [0.0, -7.0], radius: 2.4, y: [0.6, 1.2], collide: 0, color: "#cfc6b4"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [29.0, 0.0, 1.6], to: [29.0, 3.0, 1.6], radius: 1.0, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0.0, 0.0, -7.0], to: [0.0, 3.0, -7.0], radius: 0.9, collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-1.0, -9.4], [1.0, -9.4], [0.8, -7.0], [-0.8, -7.0]], y: [1.4, 2.6], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[27.8, 6.6], [30.2, 6.6], [30.0, 1.6], [28.0, 1.6]], y: [1.4, 2.6], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[-8.0, -9.4], [37.0, -9.4], [37.0, -10.4], [-8.0, -10.4]], y: [-3, 3], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[9.0, 0.6], [23.0, 0.6], [23.0, -0.2], [9.0, -0.2]], y: [-1.0, 1.0], collide: 0, color: "#a39a86"}
      - {kind: poly, points: [[9.0, 3.4], [23.0, 3.4], [23.0, 2.6], [9.0, 2.6]], y: [-1.0, 1.0], collide: 0, color: "#a39a86"}
joints:
  - {id: j_e, type: hinge, body: eccentric, axis: [0, -1, 0], damping: 0.002}   # the one driven joint
  - {id: j_l, type: hinge, body: link, axis: [0, -1, 0], damping: 0.002}
  - {id: j_rod, type: slide, body: rod, axis: [1, 0, 0], damping: 0.05}   # the eccentric rod in its guide
  - {id: j_g, type: hinge, body: gab, axis: [0, 1, 0], range: [-0.05, 0.4], stiffness: 40.0, springref: 0, damping: 0.05}   # the gab end of the rod; + lifts it (the hand lifts the spring handle)
  - {id: j_rk, type: hinge, body: rocker, axis: [0, -1, 0], damping: 0.0005}   # the rock-shaft arm
pins:
  - {"id": "pin_l", "a": "link", "b": "rod", "at": [16.2235, 0, 1.6]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_e, kind: velocity, rpm: 30, kv: 2.0, max_torque: 20}
hand:
  - {t: 5, springref: {j_g: 0.25}}
checks:
  - {type: follow, out: j_rk, in: j_rod, expect: -14.6, tol: 0.9, min_r2: 0.995, settle_s: 0.6, window_s: 0.8}   # engaged: the rock-shaft arm goes as the rod's stroke (asin of 4.8 cm on a 7 cm arm: 14.6 rad per m)
  - {type: follow, out: j_rk, in: j_rod, expect: -14.6, tol: 0.9, min_r2: 0.995, settle_s: 2.6, window_s: 0.8}
  - {type: position, joint: j_rod, min: -2.9, max: 2.5, settle_s: 0.0, window_s: 8.8}
  - {type: position, joint: j_g, min: 0.2, max: 0.3, settle_s: 5.6, window_s: 3.2}   # the gab is held up by the hand
  - {type: still, joint: j_rk, max: 0.02, settle_s: 6.6, window_s: 2.2}   # disengaged: the rock-shaft stands though the rod goes on
  - {type: follow, out: j_rod, in: j_e, expect: -0.0262, tol: 0.012, min_r2: 0.9, settle_s: 0.0, window_s: 0.25}   # and the eccentric keeps the rod going all the while
  - {type: penetration, max: 0.003, settle_s: 0.5}
camera: {target: [11.0, 0, -1.5], position: [11.0, -58.0, -1.5], fov: 34}
display:
  output: j_rk
  labels: {j_e: "Eccentric (driver)", j_rod: "Eccentric rod", j_rk: "Rock-shaft arm", j_g: "Gab (lifted by hand)"}

