# No. 59 (Brown 1868): "For transmitting two speeds by gearing."
#
# As drawn (cm; the shafts run along y): the wide driving drum (r 4.0) on its own shaft 22.0 above the
# shaft line, the one motor-driven shaft. On the shaft line three equal pulleys: a loose one; the
# middle one fast on the main shaft, whose far end carries the small pinion (12 teeth); and
# one on a hollow shaft running on the main shaft, carrying the large spur-gear (30). Both
# are always in mesh with gears on the shaft below (36 and 18; one centre distance,
# 19.200000000000003, module 0.8). The band is an elastic chain of links driving by friction; on the middle pulley
# the shaft below turns slowly (12/36 of the drum, reversed), on the right-hand
# one quickly (30/18), on the loose one not at all (the variants). The shaft not
# under the band is turned back idly through its gears. Generator: opencode-runs/batch7/gen059.py.
number: 59
slug: two-speeds-by-gearing
name: Two speeds by gearing
brown: "For transmitting two speeds by gearing. The band is shown on the loose pulley—the left-hand one of the lower three. The middle pulley is fixed on the same shaft as the small pinion, and the pulley to the right on a hollow shaft, on the end of which is fixed the large spur-gear. When the band is on the middle pulley a slow motion is transmitted to the shaft below; but when it is on the right-hand pulley a quick speed is given, proportionate to the diameter of the gears."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  solver: PGS
  multiccd: true
  duration_s: 6
  floor: false
bodies:
  - {id: drum, shape: pulley, radius: 4.0, width: 10.4, rim_width: 2.8, grooves: [[0, -3.2, 0], [0, 0.0, 0], [0, 3.2, 0]], pos: [0, 3.2, 22.0], mass: 2.5, spokes: 4, hub: 1.0, flange: 0.3}
  - {id: p_loose, shape: pulley, radius: 4.0, width: 2.6, pos: [0, 6.4, 0], mass: 0.8, spokes: 0, hub: 1.0, flange: 0.3}
  - {id: main, shape: assembly, pos: [0, 0, 0], color: "#d9cfb6"}
  - {id: h1, shape: assembly, pos: [0, 0, 0], color: "#cfc4a8"}
  - {id: below, shape: assembly, pos: [0, 0, -19.2], color: "#e8dcc0"}
  - {id: stubs, shape: frame, rods: [{from: [0, 8.0, 0], to: [0, 9.4, 0], radius: 0.7}, {from: [0, -10.5, -19.2], to: [0, -1.0, -19.2], radius: 0.6}, {from: [0, -2.4, 22.0], to: [0, 8.8, 22.0], radius: 0.6}], color: "#8f8a80"}
joints:
  - {id: j_drum, type: hinge, body: drum, axis: [0, 1, 0], damping: 0.002}
  - {id: j_loose, type: hinge, body: p_loose, axis: [0, 1, 0], damping: 0.02}
  - {id: j_main, type: hinge, body: main, axis: [0, 1, 0], damping: 0.001}   # light bearings: at the quick speed the idle main shaft runs at 5x the drum
  - {id: j_h1, type: hinge, body: h1, axis: [0, 1, 0], damping: 0.001}
  - {id: j_below, type: hinge, body: below, axis: [0, 1, 0], damping: 0.02}   # the load (at 0.05 the band crept 6% at the quick speed: elastic creep goes with the torque carried)
wheels:
  - {id: p_main, body: main, pos: [0, 3.2, 0], radius: 4.0, width: 2.6, mass: 0.8, spokes: 0, hub: 0.6, flange: 0.3}
  - {id: p_h1, body: h1, pos: [0, 0.0, 0], radius: 4.0, width: 2.6, mass: 0.8, spokes: 0, hub: 1.0, flange: 0.3}
spurs:
  - {id: g_main, body: main, pos: [0, -8.0, 0], teeth: 12, module: 0.8, width: 2.4, backlash: 0.04, phase: 1.5708}
  - {id: G_main, body: below, pos: [0, -8.0, 0], teeth: 36, module: 0.8, width: 2.4, backlash: 0.04, phase: 1.6581}
  - {id: g_h1, body: h1, pos: [0, -4.0, 0], teeth: 30, module: 0.8, width: 2.4, backlash: 0.04, phase: 1.5708}
  - {id: G_h1, body: below, pos: [0, -4.0, 0], teeth: 18, module: 0.8, width: 2.4, backlash: 0.04, phase: 1.7453}
shafts:
  - {id: sh_main, body: main, from: [0, -9.6, 0], to: [0, 4.7, 0], radius: 0.5}
  - {id: sh_h1, body: h1, from: [0, -5.4, 0], to: [0, 1.4, 0], radius: 0.95, inner: 0.55}
  - {id: sh_below, body: below, from: [0, -10.5, 0], to: [0, -1.0, 0], radius: 0.6}
belts:
  - id: belt
    around: [p_main, drum]
    links: 48
    thickness: 0.4
    width: 2.0
    density: 7800
    stiffness: 24000
    damping: 2
    pretension: 40
    friction: 0.7
contact: {solref: [0.0008, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_drum, kind: velocity, rpm: 30, kv: 2, max_torque: 5}
variants:
  - {id: slow59, note: "band on the middle pulley, fast on the main shaft: the small pinion drives, the shaft below turns 12/36 of the drum's speed", belt_around: {belt: [p_main, drum]}}
  - {id: quick59, note: "band on the right-hand pulley, on the hollow shaft: the large gear drives, 30/18", belt_around: {belt: [p_h1, drum]}}
  - {id: loose59, note: "band on the loose pulley, as drawn: nothing is driven", belt_around: {belt: [p_loose, drum]}}
variant: slow59
checks:
  - {type: ratio, out: j_below, in: j_main, expect: -0.3333, tol: 0.004, settle_s: 1.5, window_s: 4}
  - {type: ratio, out: j_below, in: j_drum, expect: -0.3333, tol: 0.02, settle_s: 1.5, window_s: 4}
  - {type: ratio, out: j_h1, in: j_below, expect: -0.6, tol: 0.01, settle_s: 1.5, window_s: 4}
  - {type: belt_on, belt: belt, max_radial_dev: 1.2, max_lateral: 0.6, duration_s: 2.5}
  - {type: penetration, max: 0.001, settle_s: 1.5}
camera: {target: [0, -1, -10], position: [130, -100, 18], fov: 34}
display:
  tiers:
    - {id: full, label: Full, ms: 1.3403}
    - {id: friction, label: Friction model, timestep: 0.001, integrator: implicitfast, model: capstan, ms: 0.0405}
  output: j_below
  labels: {j_drum: "Drum (driver)", j_loose: "Loose pulley", j_main: "Main shaft (small pinion)", j_h1: "Hollow shaft (large gear)", j_below: "Shaft below"}
  expect: {default: -0.3333}
  proof: {label: "Shaft below out of mesh", sub: "the band turns the main shaft, but nothing reaches the shaft below"}
