# No. 133 (Brown 1868): "A simple press motion is given through the hand-crank on the pinion-shaft; the pinion communicating motion to the toothed sector, which acts upon the platen, by means of the rod which connects it therewith."
#
# Model (cm, gravity on): a hand-crank turns a 14-tooth pinion (module 0.8, the one driven joint, swung 1.29 rad each way); it works a toothed sector of 40 teeth pitch (16.0 cm radius) pivoted at the bottom, which turns 0.350 rad to the radian of the crank,
# 26 degrees each way. A rod from the wrist of the sector (6 cm from its pivot) to the platen between the columns lifts and lowers it 5.0 cm. The platen is a light carriage carried by a spring (the plate has none), so that the rod alone moves it.
# Generator: opencode-runs/batch10/gen133.py.
number: 133
slug: hand-crank-pinion-sector-platen
name: Hand-crank pinion and sector working a press platen
brown: "A simple press motion is given through the hand-crank on the pinion-shaft; the pinion communicating motion to the toothed sector, which acts upon the platen, by means of the rod which connects it therewith."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 16.0
  floor: false
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-16, 0], [34, 0], [34, 2], [-16, 2]], y: [-5, 7], collide: 0, color: "#b9b09c"}   # the base
      - {kind: poly, points: [[-12.4, 2], [-8.6, 2], [-8.6, 46.1518], [-12.4, 46.1518]], y: [3.4, 7.0], collide: 0}   # the columns
      - {kind: poly, points: [[8.6, 2], [12.4, 2], [12.4, 46.1518], [8.6, 46.1518]], y: [3.4, 7.0], collide: 0}
      - {kind: poly, points: [[-15, 46.1518], [15, 46.1518], [15, 51.1518], [-15, 51.1518]], y: [0, 8], collide: 0, color: "#bdb4a0"}   # the head
      - {kind: poly, points: [[-16.5, 51.1518], [16.5, 51.1518], [16.5, 53.1518], [-16.5, 53.1518]], y: [-1, 9], collide: 0, color: "#c9c0ac"}
      - {kind: rod, from: [0.0, -1.9, 9.0], to: [0.0, 2.6, 9.0], radius: 1.4, collide: 0, color: "#8f8a80"}   # the sector's pivot
      - {kind: poly, points: [[-2.2, 2], [2.2, 2], [1.4, 9.0], [-1.4, 9.0]], y: [2.2, 3.4], collide: 0}   # its standard behind
      - {kind: rod, from: [17.4748, -0.1, 21.6962], to: [17.4748, 2.6, 21.6962], radius: 0.9, collide: 0, color: "#8f8a80"}   # the pinion's shaft
      - {kind: poly, points: [[16.0748, 2], [18.8748, 2], [18.4748, 21.6962], [16.4748, 21.6962]], y: [2.2, 3.4], collide: 0}
  - id: sector
    shape: part
    pos: [0.0, 0, 9.0]
    mass: 0.8
    friction: 0.1
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[0.0, 9.0], [14.9635, 6.63], [15.1237, 8.1081], [15.1383, 9.5948], [15.0071, 11.0757], [14.7314, 12.5367], [14.3138, 13.9636], [13.7584, 15.3427], [13.0704, 16.6607], [12.2566, 17.9049], [11.3248, 19.0634], [10.2838, 20.125], [9.1439, 21.0794], [7.9159, 21.9175], [6.6116, 22.6312], [5.2437, 23.2136], [3.8252, 23.6591], [2.37, 23.9635]], y: [-1.4, -0.2], collide: 0}   # the web
      - {kind: disc, center: [0.0, 9.0], radius: 3.2, inner: 1.0, y: [-1.7, 0.0], collide: 0}
      - {kind: poly, points: [[0.1948, 10.3864], [6.1365, 9.5513], [5.7468, 6.7786], [-0.1948, 7.6136]], y: [-1.4, -0.2], collide: 0}   # the arm to the wrist
      - {kind: disc, center: [5.9416, 8.165], radius: 1.9, inner: 0.0, y: [-1.4, -0.2], collide: 0}
      - {kind: poly, points: [[14.8808, 5.7885], [15.1449, 7.4559], [16.4107, 6.7542], [16.3015, 6.0646]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[15.2, 8.1559], [15.2, 9.8441], [16.56, 9.3491], [16.56, 8.6509]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[15.1449, 10.5441], [14.8808, 12.2115], [16.3015, 11.9354], [16.4107, 11.2458]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[14.7169, 12.8943], [14.1952, 14.4998], [15.6416, 14.4493], [15.8574, 13.7853]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[13.9265, 15.1486], [13.1601, 16.6528], [14.5966, 16.8291], [14.9136, 16.207]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[12.7932, 17.2514], [11.8009, 18.6172], [13.1921, 19.0161], [13.6025, 18.4513]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[11.3449, 19.1512], [10.1512, 20.3449], [11.4628, 20.9565], [11.9565, 20.4628]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[9.6172, 20.8009], [8.2514, 21.7932], [9.4513, 22.6025], [10.0161, 22.1921]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[7.6528, 22.1601], [6.1486, 22.9265], [7.207, 23.9136], [7.8291, 23.5966]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[5.4998, 23.1952], [3.8943, 23.7169], [4.7853, 24.8574], [5.4493, 24.6416]], y: [-1.4, -0.2], collide: 1}
      - {kind: poly, points: [[3.2115, 23.8808], [1.5441, 24.1449], [2.2458, 25.4107], [2.9354, 25.3015]], y: [-1.4, -0.2], collide: 1}
  - id: rod
    shape: part
    pos: [5.9416, 0, 8.165]
    mount: sector
    mass: 0.3
    friction: 0.1
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [5.9416, -2.2, 8.165], to: [0.0, -2.2, 31.4179], radius: 0.6, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [5.9416, -2.7, 8.165], to: [5.9416, 0.0, 8.165], radius: 0.8, collide: 0, color: "#6f6a60"}
      - {kind: rod, from: [0.0, -2.7, 31.4179], to: [0.0, -1.0, 31.4179], radius: 0.8, collide: 0, color: "#6f6a60"}
  - id: pinion
    shape: part
    pos: [17.4748, 0, 21.6962]
    mass: 0.4
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: disc, center: [17.4748, 21.6962], radius: 4.75, inner: 0.0, y: [-1.4, -0.2], collide: 0}
      - {kind: poly, points: [[17.4748, 22.3962], [28.4748, 22.3962], [28.4748, 20.9962], [17.4748, 20.9962]], y: [-2.6, -1.4], collide: 0, color: "#a8a398"}   # the hand-crank
      - {kind: rod, from: [28.4748, -3.8, 21.6962], to: [28.4748, -1.4, 21.6962], radius: 1.0, collide: 0, color: "#8f8a80"}   # its handle
      - {kind: rod, from: [17.4748, -2.9, 21.6962], to: [17.4748, 0.0, 21.6962], radius: 1.0, collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[13.681, 18.6368], [14.9523, 17.5261], [13.6848, 16.8276], [13.159, 17.2869]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[15.3841, 17.2937], [17.0115, 16.8446], [16.1725, 15.6653], [15.4995, 15.851]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[17.5013, 16.8226], [19.1624, 17.124], [18.9182, 15.6975], [18.2312, 15.5728]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[19.6132, 17.3167], [20.979, 18.309], [21.3779, 16.9178], [20.8131, 16.5074]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[21.3016, 18.6783], [22.1016, 20.1649], [23.0647, 19.0845], [22.7338, 18.4697]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[22.2321, 20.6376], [22.3078, 22.3241], [23.6442, 21.7685], [23.6129, 21.071]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[22.2203, 22.8065], [21.5567, 24.3589], [23.0019, 24.4382], [23.2763, 23.7962]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[21.2685, 24.7555], [19.9972, 25.8663], [21.2648, 26.5648], [21.7906, 26.1054]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[19.5654, 26.0986], [17.9381, 26.5477], [18.777, 27.727], [19.4501, 27.5413]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[17.4482, 26.5697], [15.7872, 26.2683], [16.0314, 27.6948], [16.7183, 27.8195]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[15.3363, 26.0756], [13.9705, 25.0833], [13.5716, 26.4745], [14.1364, 26.8849]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[13.6479, 24.714], [12.8479, 23.2274], [11.8849, 24.3078], [12.2157, 24.9226]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[12.7175, 22.7548], [12.6417, 21.0683], [11.3053, 21.6238], [11.3366, 22.3213]], y: [-1.4, -0.2], collide: 2}
      - {kind: poly, points: [[12.7293, 20.5858], [13.3928, 19.0335], [11.9477, 18.9541], [11.6733, 19.5961]], y: [-1.4, -0.2], collide: 2}
  - id: platen
    shape: part
    pos: [0.0, 0, 31.4179]
    mass: 0.6
    friction: 0.1
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-11, 34.8179], [11, 34.8179], [11, 37.8179], [-11, 37.8179]], y: [-3, 3], collide: 0, color: "#bdb4a0"}   # the platen
      - {kind: poly, points: [[-3.4, 34.8179], [3.4, 34.8179], [1.2, 32.0179], [-1.2, 32.0179]], y: [-2.2, -0.6], collide: 0}   # the fork the rod ends in
      - {kind: poly, points: [[-3.4, 34.8179], [3.4, 34.8179], [1.2, 32.0179], [-1.2, 32.0179]], y: [-3.2, -2.8], collide: 0}
joints:
  - {id: j_p, type: hinge, body: pinion, axis: [0, 1, 0], damping: 0.002}   # the one driven joint, the hand-crank; + : clockwise
  - {id: j_s, type: hinge, body: sector, axis: [0, 1, 0], damping: 0.01}   # + : clockwise, the platen falling
  - {id: j_w, type: hinge, body: rod, axis: [0, 1, 0], damping: 0.005}
  - {id: j_t, type: slide, body: platen, axis: [0, 0, 1], damping: 0.5, stiffness: 160.0, springref: 3.6787}   # + : up; a light spring takes the carriage's weight
pins:
  - {id: pin_t, a: rod, b: platen, at: [0.0, 0, 31.4179]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_p, kind: velocity, rpm: 0, swing: {amplitude: 1.29, hz: 0.2}, kv: 40.0, max_torque: 40}
checks:
  - {type: follow, out: j_s, in: j_p, expect: -0.35, tol: 0.0105, min_r2: 0.995, settle_s: 1.0, window_s: 14}   # the sector turns the other way, 14/40 of the crank
  - {type: follow, out: j_t, in: j_s, expect: -0.0618, tol: 0.0043, min_r2: 0.98, settle_s: 0.75, window_s: 0.7}   # the platen's speed per radian of the sector (the wrist's lever arm changes with the sector's angle)
  - {type: follow, out: j_t, in: j_s, expect: -0.0616, tol: 0.0043, min_r2: 0.98, settle_s: 1.5, window_s: 0.7}   # the platen's speed per radian of the sector (the wrist's lever arm changes with the sector's angle)
  - {type: follow, out: j_t, in: j_s, expect: -0.0481, tol: 0.0034, min_r2: 0.98, settle_s: 2.8, window_s: 0.7}   # the platen's speed per radian of the sector (the wrist's lever arm changes with the sector's angle)
  - {type: follow, out: j_t, in: j_s, expect: -0.0494, tol: 0.0035, min_r2: 0.98, settle_s: 4.1, window_s: 0.7}   # the platen's speed per radian of the sector (the wrist's lever arm changes with the sector's angle)
  - {type: amplitude, joint: j_s, min: 0.4063, max: 0.4741, settle_s: 1, window_s: 15}
  - {type: position, joint: j_t, min: -2.9844, max: 3.4339, settle_s: 0.0, window_s: 16}
camera: {target: [8, 0, 20.0], position: [8, -135.0, 20.0], fov: 34}
display:
  output: j_t
  labels: {j_p: "Hand-crank and pinion (driver)", j_s: "Toothed sector", j_t: "Platen"}
  proof: {label: "Rod removed", sub: "the sector swings but the platen stays"}

