# No. 231 (Brown 1868): "Drag-link motion. Circular motion is transmitted from one crank to the other."
#
# Model (cm, gravity on): two parallel shafts whose axes are 2 apart (the drag-link's fixed link, its shortest), a crank on each (driving 6, driven 7),
# the cranks joined by a link (6) that turns on the driving crank's pin and is pinned to the driven crank's. The shortest link fixed, both cranks turn right
# round (Grashof: 2 + 7 <= the other two). The driving shaft is turned (30 rpm, the only driven joint); the driven shaft turns once to each of
# its turns, but unevenly: from 0.698 to 1.501 times its speed through the turn (slice means over eighths of a turn 0.716..1.408).
# Generator: opencode-runs/batch11/gen231.py.
number: 231
slug: drag-link-motion
name: Drag-link motion
brown: "Drag-link motion. Circular motion is transmitted from one crank to the other."
units: cm
sim:
  timestep: 0.0005
  integrator: implicitfast
  iterations: 50
  solver: PGS
  duration_s: 8
  floor: false
bodies:
  - id: crank_a
    shape: part
    pos: [0, 0, 0]
    mass: 0.8
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, -0.7, 0], to: [0, 9.0, 0], radius: 0.5, color: "#8f8a80"}   # the driving shaft
      - {kind: disc, center: [0, 0], radius: 0.9, y: [-1.3, -0.7]}   # the crank's boss
      - {kind: poly, points: [[-0.6, 0], [0.6, 0], [0.45, 6.0], [-0.45, 6.0]], y: [-1.25, -0.75]}   # the driving crank
      - {kind: disc, center: [0, 6.0], radius: 0.7, y: [-1.3, -0.7]}   # its eye
      - {kind: rod, from: [0, -2.4, 6.0], to: [0, -1.0, 6.0], radius: 0.3, color: "#8f8a80"}   # its pin
  - id: crank_b
    shape: part
    pos: [2.0, 0, 0]
    mass: 0.8
    color: "#cfc3a8"
    pieces:
      - {kind: rod, from: [2.0, -3.3, 0], to: [2.0, -13.0, 0], radius: 0.5, color: "#8f8a80"}   # the driven shaft, the other way
      - {kind: disc, center: [2.0, 0], radius: 0.9, y: [-3.3, -2.7]}   # the crank's boss
      - {kind: poly, points: [[1.5073, 0.3424], [2.4927, -0.3424], [6.3642, 5.4914], [5.6252, 6.005]], y: [-3.25, -2.75]}   # the driven crank
      - {kind: disc, center: [5.9947, 5.7482], radius: 0.7, y: [-3.3, -2.7]}   # its eye
      - {kind: rod, from: [5.9947, -3.0, 5.7482], to: [5.9947, -1.6, 5.7482], radius: 0.3, color: "#8f8a80"}   # its pin
  - id: link
    shape: part
    pos: [0.0, 0, 6.0]
    mount: crank_a
    mass: 0.3
    color: "#b8ad97"
    pieces:
      - {kind: disc, center: [0.0, 6.0], radius: 0.8, inner: 0.3, y: [-2.3, -1.7]}
      - {kind: rod, from: [0.0, -2.0, 6.0], to: [5.9947, -2.0, 5.7482], radius: 0.35}   # the link
      - {kind: disc, center: [5.9947, 5.7482], radius: 0.8, inner: 0.3, y: [-2.3, -1.7]}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.3, -9.0], [1.3, -9.0], [1.0, 0], [-1.0, 0]], y: [6.0, 7.2]}   # the driving shaft's standard
      - {kind: poly, points: [[0.7, -9.0], [3.3, -9.0], [3.0, 0], [1.0, 0]], y: [-11.2, -10.0]}   # the driven shaft's
      - {kind: poly, points: [[-6, -10.0], [8, -10.0], [8, -9.0], [-6, -9.0]], y: [-13, 9], color: "#b9b09c"}   # the bed
joints:
  - {id: j_a, type: hinge, body: crank_a, axis: [0, -1, 0], damping: 0.002}   # the one driven joint; +: counter-clockwise as seen
  - {id: j_b, type: hinge, body: crank_b, axis: [0, -1, 0], damping: 0.002}
  - {id: j_link, type: hinge, body: link, axis: [0, -1, 0], damping: 0.001}
pins:
  - {id: pin_b, a: link, b: crank_b, at: [5.9947, -2.0, 5.7482]}
driver: {joint: j_a, kind: velocity, rpm: 30, kv: 20.0, max_torque: 20}
checks:
  - {type: ratio, out: j_b, in: j_a, expect: 1.0, tol: 0.01, settle_s: 1, window_s: 6}   # turn for turn (3 whole turns)
  - {type: ratio_range, out: j_b, in: j_a, min: 0.686, max: 1.438, min_swing: 0.554, settle_s: 1, window_s: 6, slices: 24}   # unevenly: slice means 0.716..1.408
camera: {target: [1.0, 0, -2.0], position: [-40.0, -52.0, 20.0], fov: 34}
display:
  output: j_b
  labels: {j_a: "Driving crank", j_b: "Driven crank"}
  proof: {label: "Link unpinned from the driven crank", sub: "the driving crank turns, the driven crank swings to rest"}

