# No. 392 (Brown 1868): "Gig-saw, the lower end connected with a crank which works it, and the upper end connected with a spring which keeps it strained without a gate."
#
# Model (cm, gravity on, Brown's front elevation): a crank of 6 cm on the wheel's shaft (the one driven joint, 48 turns a minute) works the
# lower crosshead up and down in its guides under the table by a connecting rod (15 cm). The saw blade is pinned at its top in the upper crosshead,
# which slides in its own guides above the table and hangs by a link from the end of the spring, a leaf clamped at its far end (a stiff bar on a
# sprung hinge at the clamp, 6.5 N·m/rad, set 0.65 rad). The blade's lower end carries a cross-pin under the hook of the lower crosshead: the
# crank pulls the blade down by that hook, and only the spring draws it up again, so the blade is always in tension and needs no gate (frame).
# The hook and pin are real contact; a blade cannot push. Generator: opencode-runs/batch13/gen392.py.
number: 392
slug: gig-saw
name: Gig-saw
brown: "Gig-saw, the lower end connected with a crank which works it, and the upper end connected with a spring which keeps it strained without a gate."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 60, solver: PGS, duration_s: 8, floor: false}
bodies:
  - id: wheel
    shape: part
    pos: [0, 0, 0]
    density: 7800
    color: "#d9cfb6"
    pieces:
      - {kind: band, center: [0, 0], r: [7.4, 9], a: [0, 6.2832], y: [0.6, 2.6], slices: 40}
      - {kind: disc, center: [0, 0], radius: 1.6, inner: 0.5, y: [0.2, 3.0]}
      - {kind: rod, from: [0.9899, 1.6, 0.9899], to: [5.3033, 1.6, 5.3033], radius: 0.55}
      - {kind: rod, from: [-0.9899, 1.6, 0.9899], to: [-5.3033, 1.6, 5.3033], radius: 0.55}
      - {kind: rod, from: [-0.9899, 1.6, -0.9899], to: [-5.3033, 1.6, -5.3033], radius: 0.55}
      - {kind: rod, from: [0.9899, 1.6, -0.9899], to: [5.3033, 1.6, -5.3033], radius: 0.55}
      - {kind: rod, from: [0, -1.0, 0], to: [-6, -1.0, 0], radius: 0.7, color: "#a39d90"}   # the crank
      - {kind: disc, center: [0, 0], radius: 1.3, y: [-1.6, -0.4], color: "#a39d90"}
      - {kind: rod, from: [-6, -2.6, 0], to: [-6, -0.4, 0], radius: 0.4, color: "#6f6a60"}   # its pin
      - {kind: rod, from: [0, -0.4, 0], to: [0, 4.0, 0], radius: 0.5, color: "#8f8a80"}   # the shaft
  - id: conrod
    shape: part
    pos: [-6, 0, 0]
    mount: wheel
    density: 7800
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [-6, -2.2, 0], to: [0, -2.2, 13.7477], radius: 0.55}
      - {kind: disc, center: [-6, 0], radius: 1.0, inner: 0.4, y: [-2.6, -1.8]}
  - id: lower
    shape: part
    pos: [0, 0, 13.7477]
    density: 7800
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-2.2, 12.5477], [2.2, 12.5477], [2.2, 14.9477], [-2.2, 14.9477]], y: [-1.4, 1.4]}
      - {kind: disc, center: [0, 13.7477], radius: 0.6, y: [-2.8, -1.4], color: "#6f6a60"}
      # the hook's two cheeks either side of the blade, their lower faces bearing on the blade's cross-pin
      - {kind: poly, points: [[-1.4, 14.9477], [1.4, 14.9477], [1.4, 17.6477], [-1.4, 17.6477]], y: [-1.4, -0.35], color: "#a89a7e"}
      - {kind: poly, points: [[-1.4, 14.9477], [1.4, 14.9477], [1.4, 17.6477], [-1.4, 17.6477]], y: [0.35, 1.4], color: "#a89a7e"}
      - {kind: poly, points: [[-1.4, 16.7477], [1.4, 16.7477], [1.4, 17.6477], [-1.4, 17.6477]], y: [-1.4, -0.35], collide: 1}
      - {kind: poly, points: [[-1.4, 16.7477], [1.4, 16.7477], [1.4, 17.6477], [-1.4, 17.6477]], y: [0.35, 1.4], collide: 1}
  - id: saw
    shape: part
    pos: [0, 0, 36.3477]
    density: 7800
    friction: 0.2
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [0, -1.2, 16.3477], to: [0, 1.2, 16.3477], radius: 0.4, collide: 2, capsule: true, color: "#6f6a60"}   # the blade's cross-pin
      - {kind: poly, points: [[-0.6, 15.7477], [0.6, 15.7477], [0.6, 36.9477], [-0.6, 36.9477]], y: [-0.06, 0.06], color: "#8f8a80"}   # the blade
      - {kind: poly, points: [[-0.6, 18.3477], [-0.6, 19.1477], [-1.05, 19.1477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 19.1477], [-0.6, 19.9477], [-1.05, 19.9477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 19.9477], [-0.6, 20.7477], [-1.05, 20.7477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 20.7477], [-0.6, 21.5477], [-1.05, 21.5477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 21.5477], [-0.6, 22.3477], [-1.05, 22.3477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 22.3477], [-0.6, 23.1477], [-1.05, 23.1477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 23.1477], [-0.6, 23.9477], [-1.05, 23.9477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 23.9477], [-0.6, 24.7477], [-1.05, 24.7477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 24.7477], [-0.6, 25.5477], [-1.05, 25.5477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 25.5477], [-0.6, 26.3477], [-1.05, 26.3477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 26.3477], [-0.6, 27.1477], [-1.05, 27.1477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 27.1477], [-0.6, 27.9477], [-1.05, 27.9477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 27.9477], [-0.6, 28.7477], [-1.05, 28.7477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 28.7477], [-0.6, 29.5477], [-1.05, 29.5477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 29.5477], [-0.6, 30.3477], [-1.05, 30.3477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 30.3477], [-0.6, 31.1477], [-1.05, 31.1477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 31.1477], [-0.6, 31.9477], [-1.05, 31.9477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 31.9477], [-0.6, 32.7477], [-1.05, 32.7477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-0.6, 32.7477], [-0.6, 33.5477], [-1.05, 33.5477]], y: [-0.06, 0.06], color: "#8f8a80"}
      - {kind: poly, points: [[-2.2, 35.1477], [2.2, 35.1477], [2.2, 37.5477], [-2.2, 37.5477]], y: [-1.4, 1.4], density: 2000}   # the upper crosshead
      - {kind: disc, center: [0, 36.3477], radius: 0.5, y: [-1.7, -1.4], color: "#6f6a60"}
  - id: spring
    shape: part
    pos: [28, 0, 50]
    density: 7800
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-1.2, 49.65], [28, 49.65], [28, 50.35], [-1.2, 50.35]], y: [-0.6, 0.6]}
      - {kind: poly, points: [[-1.2, 50.35], [-0.6, 50.35], [-0.6, 51.3], [-1.2, 51]], y: [-0.6, 0.6]}   # its hook
  - id: link
    shape: part
    pos: [0, 0, 50]
    mount: spring
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [0, -1.0, 50], to: [0, -1.0, 37.5477], radius: 0.3}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cdc0a4"
    pieces:
      - {kind: poly, points: [[-24, 25], [-1.2, 25], [-1.2, 26.8], [-24, 26.8]], y: [-6, 6], color: "#b9a888"}   # the table, slotted for the blade
      - {kind: poly, points: [[1.2, 25], [24, 25], [24, 26.8], [1.2, 26.8]], y: [-6, 6], color: "#b9a888"}
      - {kind: poly, points: [[-3.4, 7.7477], [-2.4, 7.7477], [-2.4, 25], [-3.4, 25]], y: [-1.4, 1.4]}   # the lower guides
      - {kind: poly, points: [[2.4, 7.7477], [3.4, 7.7477], [3.4, 25], [2.4, 25]], y: [-1.4, 1.4]}
      - {kind: poly, points: [[-3.4, 29.5], [-2.4, 29.5], [-2.4, 47.5], [-3.4, 47.5]], y: [-1.4, 1.4]}   # the upper guides
      - {kind: poly, points: [[2.4, 29.5], [3.4, 29.5], [3.4, 47.5], [2.4, 47.5]], y: [-1.4, 1.4]}
      - {kind: poly, points: [[26.5, 48.8], [30.5, 48.8], [30.5, 51.2], [26.5, 51.2]], y: [-1.4, 1.4], color: "#b9b09c"}   # the spring's clamp
      - {kind: rod, from: [28, -1.8, 51.4], to: [28, 1.8, 51.4], radius: 0.35, color: "#6f6a60"}
      - {kind: rod, from: [29.4, -1.8, 51.4], to: [29.4, 1.8, 51.4], radius: 0.35, color: "#6f6a60"}
      - {kind: rod, from: [0, 3.0, 0], to: [0, 6.0, 0], radius: 0.9}   # the shaft's bearing
joints:
  - {id: j_w, type: hinge, body: wheel, axis: [0, 1, 0], damping: 0.01}   # the wheel and crank: the one driven joint
  - {id: j_r, type: hinge, body: conrod, axis: [0, 1, 0], damping: 0.001}
  - {id: j_x, type: slide, body: lower, axis: [0, 0, 1], damping: 0.05}   # + : up
  - {id: j_u, type: slide, body: saw, axis: [0, 0, 1], damping: 0.05, range: [-5.2, 8.5]}   # the blade with the upper crosshead; its guides' lower stop
  - {id: j_k, type: hinge, body: spring, axis: [0, 1, 0], damping: 0.01, stiffness: 6.5, springref: 0.65}   # the leaf, sprung at its clamp; + : its end up
  - {id: j_lk, type: hinge, body: link, axis: [0, 1, 0], damping: 0.001}
pins:
  - {id: p_rod, a: conrod, b: lower, at: [0, 0, 13.7477]}
  - {id: p_spring, a: link, b: saw, at: [0, 0, 37.5477]}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_w, kind: velocity, rpm: 48, kv: 20, max_torque: 50}
checks:
  - {type: amplitude, joint: j_x, min: 0.058, max: 0.062, settle_s: 1, window_s: 6.5}   # the crank works the lower crosshead a 12 cm stroke
  - {type: follow, out: j_u, in: j_x, expect: 1.0, tol: 0.02, min_r2: 0.999, settle_s: 1, window_s: 6.5}   # the blade, drawn up by the spring, keeps with it both ways
  - {type: position, joint: j_k, min: -0.25, max: 0.3, settle_s: 1, window_s: 6.5}   # the leaf works within its set (0.65 rad): always strained
  - {type: penetration, max: 0.0015, settle_s: 0.5}
camera: {target: [4, 0, 20], position: [4, -128, 20], fov: 34}
display:
  output: j_u
  labels: {j_w: "Wheel and crank (driver)", j_x: "Lower crosshead", j_u: "Blade and upper crosshead", j_k: "Spring"}
