# No. 52, Another kind of clutch-box (Brown 1868): "The disk-wheel to the right has two holes,
# corresponding to the studs fixed in the other disk; and, being pressed against it, the studs enter
# the holes, when the two disks rotate together."
#
# Model (cm): two shafts in line (along y). The driving shaft carries a disk fixed on it with two
# round-ended studs standing out of its face. The driven shaft (the machinery, a bearing load) carries
# the disk-wheel on a feather: a slide joint along the shaft on the driven shaft's own body, so the
# wheel turns with that shaft and slides on it. Its face has two holes (each walled by six blocks) on
# the studs' circle. The fork at the top of the iron lever stands in the groove of the wheel's hub;
# a spring holds the lever where the hand sets it: pressed in at 2 s, drawn back at 5.5 s. Pressed
# in, the wheel's face rides on the stud ends until the holes come round to them, then the spring
# drives it home and the studs carry the wheel round. Only the driving shaft is motor-driven.
# Generated by batch7/gen052.py.
number: 52
slug: stud-clutch-box
name: Stud clutch-box
brown: "Another kind of clutch-box. The disk-wheel to the right has two holes, corresponding to the studs fixed in the other disk; and, being pressed against it, the studs enter the holes, when the two disks rotate together."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 500
  solver: CG
  multiccd: false
  duration_s: 8
  floor: false
bodies:
  - id: drv
    shape: part
    pos: [0, 0, 0]
    density: 7800
    friction: 0.15
    color: "#e4d9bf"
    pieces:
      - {kind: rod, from: [0, -14, 0], to: [0, -0.5, 0], radius: 0.6, color: "#8f8a80"}
      - {kind: disc, center: [0, 0], radius: 5, y: [-1.5, -0.5]}
      - {kind: disc, center: [0, 0], radius: 1.6, y: [-3, -1.5]}
      - {kind: disc, center: [0, 0], radius: 4.5, inner: 0.6, y: [-9, -7.6], color: "#9c958a"}   # the driving pulley
      - {kind: rod, from: [3.0, -0.5, 0.0], to: [3.0, 0.8, 0.0], radius: 0.45, collide: 1, capsule: true}
      - {kind: rod, from: [-3.0, -0.5, 0.0], to: [-3.0, 0.8, 0.0], radius: 0.45, collide: 1, capsule: true}
  - id: shaft
    shape: part
    pos: [0, 0, 0]
    density: 7800
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, 0.4, 0], to: [0, 17, 0], radius: 0.6, color: "#8f8a80"}
      - {kind: rod, from: [0, 1.5, 0.6], to: [0, 10, 0.6], radius: 0.18, color: "#6f6a60"}   # the feather
  - id: disk
    shape: part
    pos: [0, 0, 0]
    mount: shaft
    density: 7800
    friction: 0.15
    color: "#e8dec6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 5.6, inner: 3.8, y: [1.1, 3.4]}   # the wheel's rim
      - {kind: disc, center: [0, 0], radius: 2.2, inner: 0.6, y: [1.5, 3.0]}
      - {kind: disc, center: [0, 0], radius: 5.6, inner: 0.6, y: [3.0, 3.4]}   # the web behind the face
      - {kind: poly, points: [[3.8083, 0.0], [4.1083, 0.0], [3.5541, 0.9598], [3.4041, 0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[3.4041, 0.7], [3.5541, 0.9598], [2.4459, 0.9598], [2.5959, 0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[2.5959, 0.7], [2.4459, 0.9598], [1.8917, 0.0], [2.1917, 0.0]], y: [1.5, 3.0]}
      - {kind: poly, points: [[2.1917, 0.0], [1.8917, 0.0], [2.4459, -0.9598], [2.5959, -0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[2.5959, -0.7], [2.4459, -0.9598], [3.5541, -0.9598], [3.4041, -0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[3.4041, -0.7], [3.5541, -0.9598], [4.1083, -0.0], [3.8083, -0.0]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-2.1917, 0.0], [-1.8917, 0.0], [-2.4459, 0.9598], [-2.5959, 0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-2.5959, 0.7], [-2.4459, 0.9598], [-3.5541, 0.9598], [-3.4041, 0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-3.4041, 0.7], [-3.5541, 0.9598], [-4.1083, 0.0], [-3.8083, 0.0]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-3.8083, 0.0], [-4.1083, 0.0], [-3.5541, -0.9598], [-3.4041, -0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-3.4041, -0.7], [-3.5541, -0.9598], [-2.4459, -0.9598], [-2.5959, -0.7]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-2.5959, -0.7], [-2.4459, -0.9598], [-1.8917, 0.0], [-2.1917, 0.0]], y: [1.5, 3.0]}
      - {kind: poly, points: [[2.059, 0.775], [3.5564, 1.3386], [3.2472, 2.1602], [2.6089, 2.7629], [1.5104, 1.5996]], y: [1.5, 3.0]}
      - {kind: poly, points: [[1.9186, 1.0766], [3.3139, 1.8595], [2.7332, 2.8945], [1.6667, 3.415], [0.9649, 1.9771]], y: [1.5, 3.0]}
      - {kind: poly, points: [[1.5104, 1.5996], [2.6089, 2.7629], [1.7461, 3.5776], [0.5729, 3.7566], [0.3317, 2.1749]], y: [1.5, 3.0]}
      - {kind: poly, points: [[0.9649, 1.9771], [1.6667, 3.415], [0.6002, 3.9355], [-0.5729, 3.7566], [-0.3317, 2.1749]], y: [1.5, 3.0]}
      - {kind: poly, points: [[0.3317, 2.1749], [0.5729, 3.7566], [-0.6002, 3.9355], [-1.6667, 3.415], [-0.9649, 1.9771]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-0.3317, 2.1749], [-0.5729, 3.7566], [-1.7461, 3.5776], [-2.6089, 2.7629], [-1.5104, 1.5996]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-0.9649, 1.9771], [-1.6667, 3.415], [-2.7332, 2.8945], [-3.3139, 1.8595], [-1.9186, 1.0766]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-1.5104, 1.5996], [-2.6089, 2.7629], [-3.2472, 2.1602], [-3.5564, 1.3386], [-2.059, 0.775]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-2.059, -0.775], [-3.5564, -1.3386], [-3.2472, -2.1602], [-2.6089, -2.7629], [-1.5104, -1.5996]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-1.9186, -1.0766], [-3.3139, -1.8595], [-2.7332, -2.8945], [-1.6667, -3.415], [-0.9649, -1.9771]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-1.5104, -1.5996], [-2.6089, -2.7629], [-1.7461, -3.5776], [-0.5729, -3.7566], [-0.3317, -2.1749]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-0.9649, -1.9771], [-1.6667, -3.415], [-0.6002, -3.9355], [0.5729, -3.7566], [0.3317, -2.1749]], y: [1.5, 3.0]}
      - {kind: poly, points: [[-0.3317, -2.1749], [-0.5729, -3.7566], [0.6002, -3.9355], [1.6667, -3.415], [0.9649, -1.9771]], y: [1.5, 3.0]}
      - {kind: poly, points: [[0.3317, -2.1749], [0.5729, -3.7566], [1.7461, -3.5776], [2.6089, -2.7629], [1.5104, -1.5996]], y: [1.5, 3.0]}
      - {kind: poly, points: [[0.9649, -1.9771], [1.6667, -3.415], [2.7332, -2.8945], [3.3139, -1.8595], [1.9186, -1.0766]], y: [1.5, 3.0]}
      - {kind: poly, points: [[1.5104, -1.5996], [2.6089, -2.7629], [3.2472, -2.1602], [3.5564, -1.3386], [2.059, -0.775]], y: [1.5, 3.0]}
      - {kind: rod, from: [2.2, 1.8, -1.25], to: [3.8, 1.8, -1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [2.2, 2.45, -1.25], to: [3.8, 2.45, -1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [2.2, 3.1, -1.25], to: [3.8, 3.1, -1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [2.2, 1.8, 1.25], to: [3.8, 1.8, 1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [2.2, 2.45, 1.25], to: [3.8, 2.45, 1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [2.2, 3.1, 1.25], to: [3.8, 3.1, 1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [1.7247, 1.8, 1.3658], to: [2.9791, 1.8, 2.3591], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [1.452, 1.8, 1.6528], to: [2.508, 1.8, 2.8548], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [1.1323, 1.8, 1.8863], to: [1.9557, 1.8, 3.2581], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [0.7758, 1.8, 2.0587], to: [1.3401, 1.8, 3.5559], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [0.3943, 1.8, 2.1644], to: [0.6811, 1.8, 3.7385], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [0.0, 1.8, 2.2], to: [0.0, 1.8, 3.8], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-0.3943, 1.8, 2.1644], to: [-0.6811, 1.8, 3.7385], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-0.7758, 1.8, 2.0587], to: [-1.3401, 1.8, 3.5559], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-1.1323, 1.8, 1.8863], to: [-1.9557, 1.8, 3.2581], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-1.452, 1.8, 1.6528], to: [-2.508, 1.8, 2.8548], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-1.7247, 1.8, 1.3658], to: [-2.9791, 1.8, 2.3591], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-2.2, 1.8, 1.25], to: [-3.8, 1.8, 1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-2.2, 2.45, 1.25], to: [-3.8, 2.45, 1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-2.2, 3.1, 1.25], to: [-3.8, 3.1, 1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-2.2, 1.8, -1.25], to: [-3.8, 1.8, -1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-2.2, 2.45, -1.25], to: [-3.8, 2.45, -1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-2.2, 3.1, -1.25], to: [-3.8, 3.1, -1.25], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-1.7247, 1.8, -1.3658], to: [-2.9791, 1.8, -2.3591], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-1.452, 1.8, -1.6528], to: [-2.508, 1.8, -2.8548], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-1.1323, 1.8, -1.8863], to: [-1.9557, 1.8, -3.2581], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-0.7758, 1.8, -2.0587], to: [-1.3401, 1.8, -3.5559], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-0.3943, 1.8, -2.1644], to: [-0.6811, 1.8, -3.7385], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [-0.0, 1.8, -2.2], to: [-0.0, 1.8, -3.8], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [0.3943, 1.8, -2.1644], to: [0.6811, 1.8, -3.7385], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [0.7758, 1.8, -2.0587], to: [1.3401, 1.8, -3.5559], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [1.1323, 1.8, -1.8863], to: [1.9557, 1.8, -3.2581], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [1.452, 1.8, -1.6528], to: [2.508, 1.8, -2.8548], radius: 0.3, collide: 2, capsule: true}
      - {kind: rod, from: [1.7247, 1.8, -1.3658], to: [2.9791, 1.8, -2.3591], radius: 0.3, collide: 2, capsule: true}
      - {kind: disc, center: [0, 0], radius: 1.4, inner: 0.6, y: [3.4, 7]}
      - {kind: disc, center: [0, 0], radius: 2.4, y: [4.6, 5.2], collide: 2}
      - {kind: disc, center: [0, 0], radius: 2.4, y: [6.4, 7.0], collide: 2}
  - id: lever
    shape: part
    pos: [0, 5.8, -13]
    density: 7800
    friction: 0.05
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [0, 5.8, -13], to: [0, 5.8, -2.4], radius: 0.35}
      - {kind: poly, points: [[-0.9, -2.3], [0.9, -2.3], [0.9, -1.6], [-0.9, -1.6]], y: [5.35, 6.25], collide: 1}   # the fork's prong in the groove
      - {kind: rod, from: [0, 5.8, -13], to: [0, 10.5, -19], radius: 0.35}   # the handle
      - {kind: disc, center: [0, -19], radius: 1.2, y: [9.3, 11.7]}   # its knob
      - {kind: disc, center: [0, -13], radius: 0.7, y: [5.3, 6.3]}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.2, -21], [1.2, -21], [0.8, -13], [-0.8, -13]], y: [4.0, 4.8]}
      - {kind: poly, points: [[-1.5, -21], [1.5, -21], [1.0, 0], [-1.0, 0]], y: [-12, -11]}
      - {kind: disc, center: [0, 0], radius: 1.3, y: [-12, -11]}
      - {kind: poly, points: [[-1.5, -21], [1.5, -21], [1.0, 0], [-1.0, 0]], y: [14, 15]}
      - {kind: disc, center: [0, 0], radius: 1.3, y: [14, 15]}
      - {kind: poly, points: [[-4, -22], [4, -22], [4, -21], [-4, -21]], y: [-14, 17], color: "#b9b09c"}
joints:
  - {id: j_drv, type: hinge, body: drv, axis: [0, 1, 0], damping: 0.001}
  - {id: j_shaft, type: hinge, body: shaft, axis: [0, 1, 0], damping: 0.1}   # the machinery it drives
  - {id: j_feather, type: slide, body: disk, axis: [0, 1, 0], range: [-1.3, 0.3], damping: 0.5}
  - {id: j_lever, type: hinge, body: lever, axis: [1, 0, 0], range: [-0.04, 0.2], stiffness: 8, springref: 0, damping: 1}
hand:
  - {t: 2, springref: {j_lever: 0.16}}
  - {t: 5.5, springref: {j_lever: -0.04}}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_drv, kind: velocity, rpm: 20, kv: 2, max_torque: 5}
checks:
  # out of gear: the driven shaft stands
  - {type: ratio, out: j_shaft, in: j_drv, expect: 0, tol: 0.01, settle_s: 0.5, window_s: 1.4}
  # pressed in at 2 s: once the holes come round to the studs, the two disks rotate together
  - {type: ratio, out: j_shaft, in: j_drv, expect: 1, tol: 0.005, settle_s: 3.6, window_s: 1.8}
  # drawn back at 5.5 s: it stops again
  - {type: ratio, out: j_shaft, in: j_drv, expect: 0, tol: 0.01, settle_s: 6.5, window_s: 1.5}
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [0, 2, -8], position: [80, -45, 10], fov: 30}
display:
  output: j_shaft
  labels: {j_drv: "Driving shaft (disk with studs)", j_shaft: "Driven shaft (disk-wheel on its feather)", j_lever: "Lever", j_feather: "Disk-wheel on the feather"}
  proof: {label: "Studs out of contact", sub: "the lever presses the wheel in, but the studs pass through it: the driven shaft stands"}
