# No. 7, Pulley Transmission (Brown 1868, p. 1).
#
# "A method of engaging, disengaging, and reversing the upright shaft at the left. The belt is shown
# on the middle one of the three pulleys on the lower shafts, a, b, which pulley is loose, and
# consequently no movement is communicated to the said shafts. When the belt is traversed on the
# left-hand pulley, which is fast on the hollow shaft, b, carrying the bevel-gear, B, motion is
# communicated in one direction to the upright shaft; and on its being traversed on to the right-hand
# pulley, motion is transmitted through the gear, A, fast on the shaft, a, which runs inside of b, and
# the direction of the upright shaft is reversed."
#
# Layout, as in the plate: the driving drum on its own horizontal shaft at the top right, a broad
# endless band down to three pulleys side by side on the lower horizontal shafting; on the left the
# two bevel gears A and B, keyed to the two concentric shafts a (inner, with the right pulley) and
# b (hollow, with the left pulley), one on each side of the bevel gear C on the upright shaft, which
# they therefore drive in opposite senses. C is the only gear that touches both A and B.
#
# Nothing but the drum is motor-driven. The band drives one pulley by friction, the pulley and the
# bevel gear keyed to the same shaft are one casting and turn together, and the bevel gears mesh by
# tooth-on-tooth contact (one convex hull per tooth, src/geom/bevel.ts). Which pulley the band is
# traversed onto is a passive configuration: the three states in `variants` are all tested, and the
# belt position is the only thing that differs between them. The plate shows the band on the loose
# middle pulley; this model as written shows it engaged on the left pulley so that it runs
# (`variant: engaged_b`).
number: 7
slug: pulley-transmission
name: Pulley Transmission
brown: "A method of engaging, disengaging, and reversing the upright shaft at the left. The belt is shown on the middle one of the three pulleys on the lower shafts, a, b, which pulley is loose, and consequently no movement is communicated to the said shafts."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  duration_s: 8
  solver: PGS          # Newton/CG are not stable through two simultaneous bevel meshes
  multiccd: true
  floor: false         # the shafting is carried in bearings, not standing on the ground
bodies:
  # Driving drum (top right): wide and grooved for the band at each of the three pulley stations,
  # so that the band can be traversed from one to another, and flanged so that it stays in its groove.
  - {id: drum, shape: pulley, radius: 4.0, width: 11.4, rim_width: 2.8, grooves: [[0, -3.8, 0], [0, 3.8, 0]], pos: [0, 11.8, 17], mass: 2.5, spokes: 4, hub: 1.0, flange: 0.3}
  # The middle pulley is loose on the shafting: its own body, free to spin, driving nothing.
  - {id: p_mid, shape: pulley, radius: 3.0, width: 2.6, pos: [0, 11.8, 0], mass: 0.8, spokes: 0, hub: 1.2, flange: 0.3}
  # One body per real shafting: the shaft itself, the wheel and the bevel gear keyed to it.
  - {id: shaft_b, shape: assembly, pos: [0, 0, 0], color: "#d9cfb6"}   # hollow shaft, carries B and the left pulley
  - {id: shaft_a, shape: assembly, pos: [0, 0, 0], color: "#cfc4a8"}   # inner shaft, runs inside b, carries A
  - {id: upright, shape: assembly, pos: [0, 0, 0], color: "#e2d8bf"}   # upright shaft, carries C and the flywheel
joints:
  - {id: j_drum, type: hinge, body: drum, axis: [0, 1, 0], damping: 0.002}
  - {id: j_mid, type: hinge, body: p_mid, axis: [0, 1, 0], damping: 0.02}
  - {id: j_b, type: hinge, body: shaft_b, axis: [0, 1, 0], damping: 0.005}
  - {id: j_a, type: hinge, body: shaft_a, axis: [0, 1, 0], damping: 0.005}
  - {id: j_up, type: hinge, body: upright, axis: [0, 0, 1], damping: 0.008}
wheels:
  - {id: p_left, body: shaft_b, pos: [0, 8, 0], radius: 3.0, width: 2.6, mass: 0.9, spokes: 0, hub: 1.6, flange: 0.3}
  - {id: p_right, body: shaft_a, pos: [0, 15.6, 0], radius: 3.0, width: 2.6, mass: 0.9, spokes: 0, hub: 0.7, flange: 0.3}
  - {id: flywheel, body: upright, pos: [0, 0, 19], quat: [0.7071068, 0.7071068, 0, 0], radius: 2.4, width: 0.8, mass: 0.9, spokes: 4, hub: 0.7, flange: 0.2, color: "#e8dcc0"}
bevels:
  # 45 deg cones, equal on all three gears, so that one cone C is tangent to A and to B, one on each
  # side. Phasing: a gap of A and of B centred on the contact generator (their local azimuth -90 deg)
  # and a tooth of C there; with an even tooth count the opposite generator of C meshes the other
  # gear exactly the same way, which is what reverses the upright shaft.
  - {id: gB, body: shaft_b, teeth: 20, pitch_radius: 4, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796}
  - {id: gA, body: shaft_a, teeth: 20, pitch_radius: 4, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796, quat: [0, 1, 0, 0]}
  - {id: gC, body: upright, teeth: 20, pitch_radius: 4, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0, quat: [0.7071068, 0.7071068, 0, 0]}
shafts:
  - {id: sh_a, body: shaft_a, from: [0, -4.8, 0], to: [0, 17.6, 0], radius: 0.55}
  - {id: sh_b, body: shaft_b, from: [0, 0.9, 0], to: [0, 17.2, 0], radius: 1.6, inner: 1.2}
  - {id: sh_up, body: upright, from: [0, 0, 0.4], to: [0, 0, 19], radius: 0.6}
belts:
  - id: belt
    around: [p_left, drum]
    links: 40
    thickness: 0.4
    width: 2.0
    density: 7800          # a flat steel band, as drawn; heavy links keep the elastic loop stable
    stiffness: 24000       # N/m per link
    damping: 2
    pretension: 40         # N, set by the springs' rest length (25 N let the band flap off its path during spin-up)
    friction: 0.7          # steel band on iron
contact: {solref: [0.0008, 1], solimp: [0.95, 0.99, 0.001], margin: 0}   # heavy band: a stiffer contact than No. 1
driver: {joint: j_drum, kind: velocity, rpm: 30, kv: 2, max_torque: 5}
# Passive configurations: the same machine with the band traversed onto another pulley.
variants:
  - id: engaged_b
    note: "band on the left pulley, fast on the hollow shaft b, carrying bevel gear B: the upright shaft turns"
    belt_around: {belt: [p_left, drum]}
  - id: loose
    note: "band on the loose middle pulley, as drawn in the plate: nothing is driven"
    belt_around: {belt: [p_mid, drum]}
  - id: engaged_a
    note: "band on the right pulley, fast on the inner shaft a, carrying bevel gear A: the upright shaft is reversed"
    belt_around: {belt: [p_right, drum]}
variant: engaged_b
checks:
  # Band on the drum (r 4.0) and the left pulley (r 3.0), open belt: the left pulley, and with it the
  # hollow shaft b, turns 4.0/3.0 = 1.3333 times as fast as the drum, less a little creep.
  - {type: ratio, out: j_b, in: j_drum, expect: 1.3333, tol: 0.08, settle_s: 1.5, window_s: 1}
  # B drives C, so the upright shaft turns equally fast the other way: this is the reversal of No. 7.
  - {type: ratio, out: j_up, in: j_drum, expect: -1.3333, tol: 0.09, settle_s: 1.5, window_s: 1}
  # The idle shaft a is dragged round by C through the mesh, the same way as the upright shaft.
  - {type: ratio, out: j_a, in: j_drum, expect: -1.3333, tol: 0.12, settle_s: 1.5, window_s: 1}
  # Nothing drives the loose pulley in this configuration: it only turns on its own bearing friction.
  - {type: still, joint: j_mid, max: 0.05, settle_s: 1.5, window_s: 1}
  - {type: belt_on, belt: belt, max_radial_dev: 1.2, max_lateral: 0.6, duration_s: 2.5}
  - {type: penetration, max: 0.0008, settle_s: 1.5}
camera: {target: [0, 6.5, 7.5], position: [72, 2, 22], fov: 30}   # front view as in the plate: bevels left, band and drum right
display:
  output: j_up
  labels: {j_drum: Drum (driver), j_b: "Hollow shaft b, gear B", j_a: "Inner shaft a, gear A", j_mid: Loose pulley, j_up: "Upright shaft, gear C"}
  expect: {default: -1.3333, engaged_b: -1.3333, loose: 0, engaged_a: 1.3333}
