# No. 61 (Brown 1868): "For transmitting two speeds, one a differential motion."
#
# As drawn (cm; the shafts run along y, the view from the far side, so Brown's left is +y): the wide
# drum (r 7.0) on the upper shaft, 22.0 above, the one motor-driven shaft. On the lower shaft three equal
# pulleys (r 7.0): a loose one; the middle one fast on the shaft, with the bevel-gear A on its hub; and
# the right-hand one, also loose on the shaft, which carries the bevel-gear B transversely on a pin.
# The third bevel-gear C, loose on the shaft beyond, is held by a weighted friction-band: a curb of
# a shoe across the top of a drum on C's hub, pressed down by a weighted lever, so C is held by
# friction alone and could slip on a sudden change of speed. All three bevels are No. 7's
# (20 teeth, 45-degree cones, apexes at one point). With the band on the middle pulley the shaft turns
# with it (simple motion; B and the right pulley idle round at half speed). With the band on the right
# pulley, B is carried round and rolls on the held C, so it turns A, and the shaft, at double the
# pulley's speed: the differential motion. The band is an elastic chain of links driving by friction.
# Generator: opencode-runs/batch7/gen061.py.
number: 61
slug: two-speeds-differential
name: Two speeds, one a differential motion
brown: "For transmitting two speeds, one a differential motion. The band is shown on a loose pulley on lower shaft. The middle pulley is fast on said shaft, and has a small bevel-gear secured to its hub. Pulley on the right, which, like that on the left, is loose on shaft, carries, transversely, another bevel-gear. A third bevel-gear, loose upon the shaft, is held by a friction-band which is weighted at the end. On moving band on middle pulley a simple motion is the result, but when it is moved to right-hand pulley a double speed is given to shaft. The friction-band or curb on the third bevel-gear is to allow it to slip a little on a sudden change of speed."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  solver: PGS          # as No. 7: Newton/CG are not stable through two simultaneous bevel meshes
  multiccd: true
  duration_s: 6
  floor: false
bodies:
  - {id: drum, shape: pulley, radius: 7.0, width: 14.6, rim_width: 2.8, grooves: [[0, -5.6, 0], [0, 2.4, 0], [0, 5.6, 0]], pos: [0, 5.6, 22.0], mass: 2.5, spokes: 4, hub: 1.0, flange: 0.3}
  - {id: p_loose, shape: pulley, radius: 7.0, width: 2.6, pos: [0, 11.2, 0], mass: 0.8, spokes: 4, hub: 1.0, flange: 0.3}
  - {id: carrier, shape: pulley, radius: 7.0, width: 2.6, pos: [0, 0, 0], mass: 0.8, spokes: 2, hub: 1.0, flange: 0.3}   # the right-hand pulley: B rides on it
  - id: pinB
    shape: part
    pos: [0, 0, 0]
    mount: carrier
    mass: 0.15
    color: "#d8ceba"
    pieces:
      - {kind: rod, from: [0, 0, 1.2], to: [0, 0, 6.8], radius: 0.4, color: "#8f8a80"}   # B's pin, out along a spoke
  - {id: shaft, shape: assembly, pos: [0, 0, 0], color: "#d9cfb6"}
  - id: gearC
    shape: part
    pos: [0, 0, 0]
    mass: 0.4
    friction: 0.6
    color: "#cfc4a8"
    pieces:
      - {kind: rod, from: [0, -7.5, 0], to: [0, -7.3, 0], radius: 3.2, capsule: true, collide: 2}   # the curb's drum on C's hub (round, so the shoe runs smooth on it)
      - {kind: rod, from: [0, -8.4, 0], to: [0, -4.6, 0], radius: 0.9, color: "#8f8a80"}   # C's hub, loose on the shaft
  - id: brake
    shape: part
    pos: [-7, -7.4, 3.7]
    mass: 1.6
    friction: 0.6
    color: "#6b5a44"
    pieces:
      - {kind: rod, from: [0, -8.6, 3.7], to: [0, -6.2, 3.7], radius: 0.5, capsule: true, collide: 1}   # the shoe, across the drum's top
      - {kind: rod, from: [-7, -7.4, 3.7], to: [9, -7.4, 3.7], radius: 0.35}   # the lever, pivoted at the left
      - {kind: rod, from: [9, -7.4, 3.7], to: [9, -7.4, -0.2999999999999998], radius: 0.15}   # the weight's hook
      - {kind: disc, center: [9, -1.7999999999999998], radius: 1.6, y: [-8.6, -6.2], color: "#55504a"}   # the weight
  - {id: post, shape: frame, rods: [{from: [-7, -7.4, 3.7], to: [-7, -7.4, -12], radius: 0.4}], 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.01}
  - {id: j_carrier, type: hinge, body: carrier, axis: [0, 1, 0], damping: 0.005}
  - {id: j_B, type: hinge, body: pinB, axis: [0, 0, 1], damping: 0.001}
  - {id: j_shaft, type: hinge, body: shaft, axis: [0, 1, 0], damping: 0.02}   # the load
  - {id: j_C, type: hinge, body: gearC, axis: [0, 1, 0], damping: 0.002}   # loose on the shaft: only the friction-band holds it
  - {id: j_brake, type: hinge, body: brake, axis: [0, 1, 0], damping: 0.05, range: [-0.3, 0.3]}   # the weighted lever
wheels:
  - {id: p_middle, body: shaft, pos: [0, 8.0, 0], radius: 7.0, width: 2.6, mass: 0.8, spokes: 4, hub: 0.9, flange: 0.3}
bevels:
  # No. 7's three bevels, apexes at one point on the shaft: A (on the shaft) and C face each other along
  # it, B stands across between them on its pin in the right-hand pulley.
  - {id: gA, body: shaft, teeth: 20, pitch_radius: 4, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796}
  - {id: gC, body: gearC, teeth: 20, pitch_radius: 4, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796, quat: [0, 1, 0, 0]}
  - {id: gB, body: pinB, 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, body: shaft, from: [0, -9.6, 0], to: [0, 13.6, 0], radius: 0.55}
belts:
  - id: belt
    around: [carrier, drum]
    links: 54
    thickness: 0.4
    width: 2.0
    density: 7800
    stiffness: 24000
    damping: 2
    pretension: 60        # N: at 40 the long, light-loaded band flapped (1.7 radial) after 2 s
    friction: 0.7
contact: {solref: [0.0008, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_drum, kind: velocity, rpm: 20, kv: 2, max_torque: 5}
variants:
  - {id: double61, note: "band on the right-hand pulley: B is carried round on the held C and turns the shaft at double speed", belt_around: {belt: [carrier, drum]}}
  - {id: simple61, note: "band on the middle pulley: the shaft turns with it (simple motion)", belt_around: {belt: [p_middle, drum]}}
  - {id: loose61, note: "band on the loose pulley, as drawn: nothing is driven", belt_around: {belt: [p_loose, drum]}}
variant: double61
checks:
  - {type: ratio, out: j_shaft, in: j_carrier, expect: 2.0, tol: 0.01, settle_s: 1.5, window_s: 4}
  - {type: ratio, out: j_shaft, in: j_drum, expect: 2.0, tol: 0.08, settle_s: 1.5, window_s: 4}
  - {type: still, joint: j_C, max: 0.05, 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, 0, 6], position: [80, 55, 26], fov: 34}
display:
  tiers:
    - {id: full, label: Full, ms: 2.1486}
    - {id: friction, label: Friction model, timestep: 0.001, integrator: implicitfast, model: capstan, ms: 0.1507}
  output: j_shaft
  labels: {j_drum: "Drum (driver)", j_loose: "Loose pulley", j_carrier: "Right-hand pulley (carries B)", j_B: "Bevel B on its pin", j_shaft: "Shaft (bevel A, middle pulley)", j_C: "Bevel C (curbed)"}
  expect: {default: 2.0}
  proof: {label: "Friction-band lifted off C", sub: "nothing holds C: it runs back and the shaft hardly turns"}
