# No. 389 (Brown 1868): "Lifting-jack operated by an eccentric, pawl, and ratchet. The upper pawl is a stop."
#
# Model (cm, gravity on): the rack-bar (6 cm wide, ratchet teeth of 2 cm pitch on its right face, their lower faces level, their upper
# faces sloping) slides up and down in the bore of the stock and carries the head and its load (4 kg in all). An eccentric (throw 1.6 cm, the
# one driven joint, 20 turns a minute) turns on a shaft in the stock's top; its strap ends in a hooked arm, the lifting pawl, whose point
# rests on the teeth by its own weight. As the eccentric's centre rises the pawl's point lifts the rack by the level face of a tooth; as it falls
# the point slides down the next sloping face and drops under the face below. The upper pawl, the stop, hangs from a bracket on the stock with
# its point on the teeth: the rack's rising teeth push it aside, and it catches the level face of each tooth as the lifting pawl goes down for
# the next. So the rack rises a tooth for each turn of the eccentric. All the pawl work is real contact.
# Generator: opencode-runs/batch13/gen389.py.
number: 389
slug: eccentric-lifting-jack
name: Lifting-jack operated by an eccentric, pawl and ratchet
brown: "Lifting-jack operated by an eccentric, pawl, and ratchet. The upper pawl is a stop."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 100, duration_s: 16, floor: false}
bodies:
  - id: stock
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-24, -8], [-3.3, -8], [-3.3, 30], [-8, 30], [-8, 8], [-10, 2], [-16, -2], [-20, -2], [-20, -5], [-24, -5]], y: [-4, 4], collide: 0}   # the stock, left of the bore
      - {kind: poly, points: [[3.3, -8], [24, -8], [24, -5], [20, -5], [20, -2], [16, -2], [10, 2], [8, 8], [8, 30], [3.3, 30]], y: [-4, 4], collide: 0}   # and right of it
      - {kind: poly, points: [[-3.3, -8], [3.3, -8], [3.3, -7], [-3.3, -7]], y: [-4, 4], collide: 0}
      - {kind: poly, points: [[7.6, 30], [10.9, 30], [10.9, 45], [7.6, 45]], y: [4.6, 5.6], collide: 0, color: "#b9b09c"}   # the bracket behind: the eccentric's shaft and the stop's pivot
      - {kind: rod, from: [10.5, 3.8, 33.0], to: [10.5, 5.6, 33.0], radius: 0.7, collide: 0, color: "#5e5850"}   # the eccentric's shaft
      - {kind: rod, from: [7.2, -1.6, 42.5], to: [7.2, 5.6, 42.5], radius: 0.35, collide: 0, color: "#5e5850"}   # the stop's pin
  - id: rack
    shape: part
    pos: [0, 0, 30]
    mass: 4.0
    friction: 0.15
    color: "#c9c2b2"
    pieces:
      - {kind: poly, points: [[-3.0, -4.0], [3.0, -4.0], [3.0, 56.0], [-3.0, 56.0]], y: [-2, 2], collide: 0}   # the rack-bar
      - {kind: poly, points: [[-6.5, 56.0], [6.5, 56.0], [5, 59.0], [-5, 59.0]], y: [-3.5, 3.5], collide: 0, color: "#a39d90"}   # its head
      - {kind: poly, points: [[2.7, 18.0], [4.1, 18.0], [2.7, 19.98]], y: [-2, 2], collide: 1}   # a tooth: level below, sloping above
      - {kind: poly, points: [[2.7, 20.0], [4.1, 20.0], [2.7, 21.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 22.0], [4.1, 22.0], [2.7, 23.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 24.0], [4.1, 24.0], [2.7, 25.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 26.0], [4.1, 26.0], [2.7, 27.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 28.0], [4.1, 28.0], [2.7, 29.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 30.0], [4.1, 30.0], [2.7, 31.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 32.0], [4.1, 32.0], [2.7, 33.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 34.0], [4.1, 34.0], [2.7, 35.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 36.0], [4.1, 36.0], [2.7, 37.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 38.0], [4.1, 38.0], [2.7, 39.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 40.0], [4.1, 40.0], [2.7, 41.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 42.0], [4.1, 42.0], [2.7, 43.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 44.0], [4.1, 44.0], [2.7, 45.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 46.0], [4.1, 46.0], [2.7, 47.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 48.0], [4.1, 48.0], [2.7, 49.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 50.0], [4.1, 50.0], [2.7, 51.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 52.0], [4.1, 52.0], [2.7, 53.98]], y: [-2, 2], collide: 1}
      - {kind: poly, points: [[2.7, 54.0], [4.1, 54.0], [2.7, 55.98]], y: [-2, 2], collide: 1}
  - id: ecc
    shape: part
    pos: [10.5, 0, 33.0]
    density: 7800
    color: "#6f675c"
    pieces:
      - {kind: rod, from: [10.5, -1.5, 31.4], to: [10.5, 1.5, 31.4], radius: 4.4, collide: 0}   # the eccentric
      - {kind: rod, from: [10.5, -1.7, 33.0], to: [10.5, 3.8, 33.0], radius: 0.9, collide: 0, color: "#3f3b35"}   # its shaft's boss
  - id: strap
    shape: part
    pos: [10.5, 0, 31.4]
    mount: ecc
    density: 7800
    friction: 0.15
    color: "#4f4a43"
    pieces:
      - {kind: rod, from: [10.5, -1.2, 31.4], to: [10.5, 1.2, 31.4], radius: 5.2, collide: 0}   # the strap round the eccentric
      - {kind: rod, from: [8.3, 0, 36.0], to: [4.9291, 0, 38.2592], radius: 0.55, collide: 0}   # its arm, the lifting pawl
      - {kind: rod, from: [4.9291, 0, 38.2592], to: [3.6, 0, 39.15], radius: 0.25, capsule: true, collide: 2}   # its point
  - id: stop
    shape: part
    pos: [7.2, 0, 42.5]
    density: 7800
    friction: 0.15
    color: "#4f4a43"
    pieces:
      - {kind: rod, from: [7.2, -1.2, 42.5], to: [7.2, 1.2, 42.5], radius: 1.0, collide: 0}   # the stop's eye
      - {kind: rod, from: [7.2, 0, 42.5], to: [4.5107, 0, 46.3845], radius: 0.45, collide: 0}   # the stop pawl
      - {kind: rod, from: [4.5107, 0, 46.3845], to: [3.6, 0, 47.7], radius: 0.25, capsule: true, collide: 2}   # its point
joints:
  - {id: j_e, type: hinge, body: ecc, axis: [0, -1, 0], damping: 0.01}   # the eccentric: the one driven joint
  - {id: j_l, type: hinge, body: strap, axis: [0, 1, 0], damping: 0.0005}   # the strap on the eccentric (free; its pawl falls onto the teeth)
  - {id: j_st, type: hinge, body: stop, axis: [0, 1, 0], damping: 0.0005, range: [-0.35, 0.35]}   # the stop pawl on its pin
  - {id: j_z, type: slide, body: rack, axis: [0, 0, 1], damping: 0.5}   # the rack in the bore (+ : up)
contact: {solref: [0.001, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_e, kind: velocity, rpm: 20.0, kv: 50.0, max_torque: 200}
checks:
  - {type: ratio, out: j_z, in: j_e, expect: 0.0031830989, tol: 0.0001591549, settle_s: 1, window_s: 15}   # a tooth a turn
  - {type: monotonic, joint: j_z, direction: 1, max_back: 0.015, settle_s: 0.5, window_s: 15.5}   # the stop holds it: it never runs back more than the overtravel
  - {type: clicks, joint: j_st, lift: 0.1, min: 4, settle_s: 0.5, window_s: 15.5}   # the stop clicks over each tooth
  - {type: penetration, max: 0.002, settle_s: 0.5}
camera: {target: [2.0, 0, 22.0], position: [2.0, -170.0, 22.0], fov: 34}
display:
  output: j_z
  labels: {j_e: "Eccentric (driver)", j_z: "Rack, lifted", j_l: "Lifting pawl", j_st: "Stop pawl"}
  proof: {label: "No stop", sub: "the rack goes down again with the lifting pawl"}
