# No. 251 (Brown 1868): "Releasing-hook, used in pile-driving machines. When the weight, W, is sufficiently raised, the upper ends of the hooks,
# A, by which it is suspended, are pressed inward by the sides of the slot, B, in the top of the frame; the weight is thus suddenly released, and
# falls with accumulating force on to the pile-head."
#
# Model (cm, gravity on, side view): the rope draws the crosshead up its guide at 2 cm/s (the one driven joint). The two hooks A are pinned to
# it; their lips are under the knob on the weight W, which stands on the pile-head on its own guide. The crosshead lifts W by the hooks. Their upper
# ends rise into the slot B in the frame's top, whose sides close in from 7 to 1.5 cm apart; they press the ends inward, the lips swing out
# from under the knob and W falls back on the pile-head. Generator: opencode-runs/batch11/gen251.py.
number: 251
slug: releasing-hook
name: Releasing-hook for pile-driving
brown: "Releasing-hook, used in pile-driving machines. When the weight, W, is sufficiently raised, the upper ends of the hooks, A, by which it is suspended, are pressed inward by the sides of the slot, B, in the top of the frame; the weight is thus suddenly released, and falls with accumulating force on to the pile-head."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 60, duration_s: 5.7, floor: false}
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#a39a88"
    pieces:
      - {kind: poly, points: [[-6.2, -4], [-5.0, -4], [-5.0, 31.5], [-6.2, 31.5]], y: [-1.2, 1.2], collide: 0}   # the uprights
      - {kind: poly, points: [[5.0, -4], [6.2, -4], [6.2, 31.5], [5.0, 31.5]], y: [-1.2, 1.2], collide: 0}
      - {kind: poly, points: [[-6.8, 30.0], [6.8, 30.0], [6.8, 31.5], [-6.8, 31.5]], y: [-1.2, 1.2], collide: 0}   # the head
  - id: slot
    shape: part
    pos: [0, 0, 0]
    fixed: true
    friction: 0.15
    color: "#8f8676"
    pieces:
      - {kind: poly, points: [[-4.6, 20.0], [-3.5, 20.0], [-0.75, 24.5], [-4.6, 24.5]], y: [-1.2, 1.2], collide: 1}   # the slot's side, closing in
      - {kind: poly, points: [[-4.6, 24.5], [-0.75, 24.5], [-0.75, 30.0], [-4.6, 30.0]], y: [-1.2, 1.2], collide: 1}
      - {kind: poly, points: [[3.5, 20.0], [4.6, 20.0], [4.6, 24.5], [0.75, 24.5]], y: [-1.2, 1.2], collide: 1}   # the slot's side, closing in
      - {kind: poly, points: [[0.75, 24.5], [4.6, 24.5], [4.6, 30.0], [0.75, 30.0]], y: [-1.2, 1.2], collide: 1}
  - id: pile
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#7d6e58"
    pieces:
      - {kind: poly, points: [[-2.6, -4], [2.6, -4], [2.6, 0], [-2.6, 0]], y: [-2.6, 2.6], collide: 2}   # the pile-head
  - id: weight
    shape: part
    pos: [0, 0, 3]
    mass: 1
    friction: 0.15
    color: "#c9bfa9"
    pieces:
      - {kind: poly, points: [[-3.4, 0.01], [3.4, 0.01], [3.4, 6], [-3.4, 6]], y: [-2.2, 2.2], collide: 1}   # W
      - {kind: poly, points: [[-0.3, 6], [0.3, 6], [0.3, 7], [-0.3, 7]], y: [-0.4, 0.4], collide: 1}   # its neck
      - {kind: poly, points: [[-0.8, 7], [0.8, 7], [0.8, 7.3], [0.3, 7.8], [-0.3, 7.8], [-0.8, 7.3]], y: [-0.4, 0.4], collide: 1}   # its knob
  - id: crosshead
    shape: part
    pos: [0, 0, 8.6]
    mass: 0.3
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-2.0, 8.2], [2.0, 8.2], [2.0, 9.2], [-2.0, 9.2]], y: [-0.9, -0.55], collide: 0}   # its cheeks (front and back of the hooks)
      - {kind: poly, points: [[-2.0, 8.2], [2.0, 8.2], [2.0, 9.2], [-2.0, 9.2]], y: [0.55, 0.9], collide: 0}
      - {kind: rod, from: [0, 0, 9.2], to: [0, 0, 36.0], radius: 0.2, collide: 0, color: "#7a6a50"}   # the rope
  - id: hook_l
    shape: part
    pos: [-1.3, 0, 8.6]
    mount: crosshead
    mass: 0.1
    friction: 0.15
    color: "#6f675a"
    pieces:
      - {kind: poly, points: [[-1.6, 6.4], [-1.0, 6.4], [-1.0, 8.9], [-1.6, 8.9]], y: [-0.5, 0.5], collide: 2}   # the jaw's shank
      - {kind: poly, points: [[-1.6, 6.4], [-0.38, 6.4], [-0.38, 6.95], [-1.6, 6.95]], y: [-0.5, 0.5], collide: 2}   # its lip, under W's knob
      - {kind: rod, from: [-1.3, 0, 8.6], to: [-2.8, 0, 12.0], radius: 0.3, collide: 2, capsule: true}   # the upper end
      - {kind: rod, from: [-2.8, 0, 12.0], to: [-2.4, 0, 14.5], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-1.3, -0.7, 8.6], to: [-1.3, 0.7, 8.6], radius: 0.22, collide: 0, color: "#3d3a34"}   # its pin
  - id: hook_r
    shape: part
    pos: [1.3, 0, 8.6]
    mount: crosshead
    mass: 0.1
    friction: 0.15
    color: "#6f675a"
    pieces:
      - {kind: poly, points: [[1.0, 6.4], [1.6, 6.4], [1.6, 8.9], [1.0, 8.9]], y: [-0.5, 0.5], collide: 2}   # the jaw's shank
      - {kind: poly, points: [[0.38, 6.4], [1.6, 6.4], [1.6, 6.95], [0.38, 6.95]], y: [-0.5, 0.5], collide: 2}   # its lip, under W's knob
      - {kind: rod, from: [1.3, 0, 8.6], to: [2.8, 0, 12.0], radius: 0.3, collide: 2, capsule: true}   # the upper end
      - {kind: rod, from: [2.8, 0, 12.0], to: [2.4, 0, 14.5], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [1.3, -0.7, 8.6], to: [1.3, 0.7, 8.6], radius: 0.22, collide: 0, color: "#3d3a34"}   # its pin
joints:
  - {id: j_w, type: slide, body: weight, axis: [0, 0, 1], damping: 0.05}   # W on its guide (+: up)
  - {id: j_lift, type: slide, body: crosshead, axis: [0, 0, 1], damping: 0.1}   # the crosshead, drawn up by the rope: the one driven joint
  - {id: j_hl, type: hinge, body: hook_l, axis: [0, 1, 0], damping: 0.0005, stiffness: 0.2, springref: -0.1}   # left hook (+: lip out)
  - {id: j_hr, type: hinge, body: hook_r, axis: [0, 1, 0], damping: 0.0005, stiffness: 0.2, springref: 0.1}   # right hook (-: lip out)
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_lift, kind: velocity, speed: 2, kv: 20000, max_torque: 80}
checks:
  - {type: ratio, out: j_w, in: j_lift, expect: 1.0, tol: 0.02, settle_s: 0.5, window_s: 3.0}   # W hangs by the hooks and goes up with the crosshead
  - {type: position, joint: j_w, min: -0.05, max: 0.05, settle_s: 5.1, window_s: 0.5}   # released: back down on the pile-head
  - {type: position, joint: j_hl, min: 0.2, max: 0.8, settle_s: 5.1, window_s: 0.5}   # the hooks thrown open by the slot
  - {type: position, joint: j_hr, min: -0.8, max: -0.2, settle_s: 5.1, window_s: 0.5}
  - {type: penetration, max: 0.002, settle_s: 0.3}
camera: {target: [0, 0, 13], position: [0, -110, 13], fov: 30}
display:
  output: j_w
  labels: {j_lift: "Crosshead (driver)", j_w: "Weight W", j_hl: "Hook A (left)", j_hr: "Hook A (right)"}

