# No. 169 (Brown 1868): "A modification of 168, in which a link is used to connect the pitman with the main crank, thereby dispensing with the slot in the said crank."
#
# Model (cm, no gravity; a plan): the main crank (3 cm; the one driven joint, 20 turns a minute, clockwise in the view) is joined by a 6.5 cm link to the pitman. The pitman, 19 cm long, is also carried by the second crank
# of invariable radius (3.6 cm) on its own shaft 7 cm from the main shaft, and its far end works the reciprocating moving power, drawn as a slide in fixed guides. All joints are pins; nothing collides.
# The pitman's pin end is compelled to move in a closed oval orbit, the second crank rocks 73 degrees and the slide goes 4.0 cm. Generator: opencode-runs/batch11/gen169.py.
number: 169
slug: crank-link-pitman-second-crank
name: A main crank and a second crank working one pitman
brown: "A modification of 168, in which a link is used to connect the pitman with the main crank, thereby dispensing with the slot in the said crank."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 9.0
  floor: false
  gravity: 0
bodies:
  - id: crank
    shape: part
    pos: [0, 0, 0]
    mass: 0.3
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0.0, 0.0, 0.0], to: [0.0, 0.0, 3.0], radius: 0.6, collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [0, -0.5, 0], to: [0, 1.5, 0], radius: 1.1, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0.0, -0.5, 3.0], to: [0.0, -0.4, 3.0], radius: 0.8, collide: 0, color: "#8f8a80"}
  - id: link
    shape: part
    pos: [0.0, 0, 3.0]
    mount: crank
    mass: 0.2
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [0.0, -0.9, 3.0], to: [-4.2699, -0.9, 7.9009], radius: 0.4, collide: 0, color: "#b8ad97"}
      - {kind: rod, from: [0.0, -1.4, 3.0], to: [0.0, -0.4, 3.0], radius: 0.55, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [-4.2699, -1.4, 7.9009], to: [-4.2699, -0.4, 7.9009], radius: 0.55, collide: 0, color: "#8f8a80"}
  - id: slide
    shape: part
    pos: [11.9466, 0, -2.0]
    mass: 0.3
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [10.7466, -2.3, -2.0], to: [18.9466, -2.3, -2.0], radius: 0.7, collide: 0, color: "#a89a7e"}   # the moving-power rod
      - {kind: poly, points: [[10.7466, -3.2], [13.1466, -3.2], [13.1466, -0.8], [10.7466, -0.8]], y: [-2.9, -1.7], collide: 0}
  - id: pitman
    shape: part
    pos: [11.9466, 0, -2.0]
    mount: slide
    mass: 0.4
    color: "#a89a7e"
    pieces:
      - {kind: rod, from: [-4.2699, -1.7, 7.9009], to: [11.9466, -1.7, -2.0], radius: 0.5, collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [-4.2699, -1.7, 7.9009], to: [-4.2699, -0.4, 7.9009], radius: 0.55, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [11.9466, -2.4, -2.0], to: [11.9466, -1.5, -2.0], radius: 0.6, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [3.4116, -2.6, 3.211], to: [3.4116, -1.5, 3.211], radius: 0.55, collide: 0, color: "#8f8a80"}
  - id: crank2
    shape: part
    pos: [7.0, 0, 3.5]
    mass: 0.25
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [7.0, -2.3, 3.5], to: [3.4116, -2.3, 3.211], radius: 0.6, collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [7.0, -2.0, 3.5], to: [7.0, 1.5, 3.5], radius: 1.1, collide: 0, color: "#8f8a80"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.4, -9], [1.4, -9], [1.0, 0], [-1.0, 0]], y: [1.8, 2.8], collide: 0}   # the main shaft's standard, behind
      - {kind: poly, points: [[5.6, -8.5], [8.4, -8.5], [8.0, 3.5], [6.0, 3.5]], y: [1.8, 2.8], collide: 0}   # and the second shaft's
      - {kind: poly, points: [[5.9466, -4.4], [25.9466, -4.4], [25.9466, -3.4], [5.9466, -3.4]], y: [-3.4, -1.4], collide: 0, color: "#b9b09c"}   # the guides
      - {kind: poly, points: [[5.9466, -0.6000000000000001], [25.9466, -0.6000000000000001], [25.9466, 0.3999999999999999], [5.9466, 0.3999999999999999]], y: [-3.4, -1.4], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[-15, -10.4], [26.9466, -10.4], [26.9466, -9.4], [-15, -9.4]], y: [-3, 3], collide: 0, color: "#b9b09c"}
joints:
  - {id: j_s, type: hinge, body: crank, axis: [0, 1, 0], damping: 0.002}   # the one driven joint: the main crank; + : clockwise
  - {id: j_k, type: hinge, body: link, axis: [0, 1, 0], damping: 0.002}
  - {id: j_e, type: slide, body: slide, axis: [1, 0, 0], damping: 0.05}   # the moving power's rod in its guides; + : to the right
  - {id: j_p, type: hinge, body: pitman, axis: [0, 1, 0], damping: 0.002}
  - {id: j_2, type: hinge, body: crank2, axis: [0, 1, 0], damping: 0.002}   # the second crank (it rocks); + : clockwise
pins:
  - {"id": "pin_lp", "a": "link", "b": "pitman", "at": [-4.2699, 0, 7.9009]}
  - {"id": "pin_q", "a": "crank2", "b": "pitman", "at": [3.4116, 0, 3.211]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_s, kind: velocity, rpm: 20, kv: 400.0, max_torque: 400}
checks:
  - {type: follow, out: j_e, in: j_s, expect: 0.0293, tol: 0.0023, min_r2: 0.99, settle_s: 0.0783, window_s: 0.2917}
  - {type: follow, out: j_2, in: j_s, expect: -0.9037, tol: 0.0723, min_r2: 0.99, settle_s: 0.0783, window_s: 0.2917}
  - {type: follow, out: j_e, in: j_s, expect: -0.0154, tol: 0.0012, min_r2: 0.99, settle_s: 1.37, window_s: 0.2917}
  - {type: follow, out: j_2, in: j_s, expect: 0.4428, tol: 0.0354, min_r2: 0.99, settle_s: 1.37, window_s: 0.2917}
  - {type: follow, out: j_e, in: j_s, expect: -0.0143, tol: 0.0011, min_r2: 0.99, settle_s: 1.87, window_s: 0.2917}
  - {type: follow, out: j_2, in: j_s, expect: 0.4897, tol: 0.0392, min_r2: 0.99, settle_s: 1.87, window_s: 0.2917}
  - {type: follow, out: j_e, in: j_s, expect: 0.0293, tol: 0.0023, min_r2: 0.99, settle_s: 3.0783, window_s: 0.2917}
  - {type: follow, out: j_2, in: j_s, expect: -0.9037, tol: 0.0723, min_r2: 0.99, settle_s: 3.0783, window_s: 0.2917}
  - {type: position, joint: j_e, min: -0.5404, max: 4.0281, settle_s: 0.0, window_s: 8.5}
camera: {target: [8.0, 0, -1.0], position: [8.0, -52.0, -1.0], fov: 34}
display:
  output: j_e
  labels: {j_s: "Main crank (driver)", j_k: "Link", j_e: "Moving power (slide)", j_p: "Pitman", j_2: "Second crank"}
  proof: {label: "Link unpinned", sub: "the main crank turns but the pitman and slide stand"}

