# No. 62 (Brown 1868): "For transmitting two speeds, one of which is a different and variable motion."
#
# As No. 61 (cm; shafts along y, viewed from the far side), except that the third bevel-gear C is not
# held: it is fast on a fourth pulley (r 7.0), at the right of the other three, driven by its own band
# from a small pulley (r 3.5) on the upper shaft, so C turns the same way as the drum at 3.5/7.0 of
# its speed. The upper shaft (the one motor-driven shaft) carries the wide drum (r 7.0) and that small
# pulley. With the left band on the right-hand pulley (the one carrying B), the shaft would turn at
# double that pulley's speed if C were at rest; C turning the same way deducts its own rotation:
# shaft = 2 x carrier - C = 2 - 0.5 = 1.5 of the drum. (Brown's other case, the right
# band crossed so that C's rotation is added, is the same machine with a crossed band; it is not built
# here.) All bevels are No. 7's. Both bands are elastic chains of links driving by friction alone.
# Generator: opencode-runs/batch7/gen062.py.
number: 62
slug: two-speeds-variable-differential
name: Two speeds, one a variable differential motion
brown: "For transmitting two speeds, one of which is a different and variable motion. This is very similar to the last, except in the third bevel-gear being attached to a fourth pulley, at the right of the other three, and driven by a band from a small pulley on shaft above. When left-hand belt is on the pulley carrying the middle bevel-gear, and pulley at the right turns in the same direction, the amount of rotation of the third bevel-gear must be deducted from the double speed which the shaft would have if this gear was at rest. If, on the contrary, the right-hand belt be crossed so as to turn the pulley in an opposite direction, that amount must be added."
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: upper, shape: assembly, pos: [0, 0, 22.0], color: "#d9cfb6"}
  - {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}   # 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: assembly, pos: [0, 0, 0], color: "#cfc4a8"}   # C, its hollow shaft and the fourth pulley
joints:
  - {id: j_upper, type: hinge, body: upper, 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.005}
wheels:
  - {id: drum, body: upper, pos: [0, 5.6, 0], radius: 7.0, width: 14.6, rim_width: 2.8, grooves: [[0, -5.6, 0], [0, 2.4, 0], [0, 5.6, 0]], mass: 2.5, spokes: 4, hub: 1.0, flange: 0.3}
  - {id: p_small, body: upper, pos: [0, -10.0, 0], radius: 3.5, width: 2.6, mass: 0.5, spokes: 0, hub: 1.0, flange: 0.3}
  - {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}
  - {id: p_C, body: gearC, pos: [0, -10.0, 0], radius: 7.0, width: 2.6, mass: 0.8, spokes: 4, hub: 1.2, flange: 0.3}
bevels:
  - {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, -12.5, 0], to: [0, 13.6, 0], radius: 0.55}
  - {id: sh_C, body: gearC, from: [0, -11.4, 0], to: [0, -4.4, 0], radius: 1.0, inner: 0.6}
  - {id: sh_upper, body: upper, from: [0, -12.5, 0], to: [0, 13.6, 0], radius: 0.6}
belts:
  - id: belt
    around: [carrier, drum]
    links: 54
    thickness: 0.4
    width: 2.0
    density: 7800
    stiffness: 24000
    damping: 2
    pretension: 60
    friction: 0.7
  - id: belt_C
    around: [p_C, p_small]
    links: 48
    thickness: 0.4
    width: 2.0
    density: 7800
    stiffness: 24000
    damping: 6           # (at 2 its spans flapped in bursts, driven by the bevels' tooth ripple)
    pretension: 80
    friction: 0.7
contact: {solref: [0.0008, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_upper, kind: velocity, rpm: 20, kv: 2, max_torque: 5}
variants:
  - {id: deduct62, note: "left band on the pulley carrying B, C turning the same way: double speed less C's", belt_around: {belt: [carrier, drum], belt_C: [p_C, p_small]}}
  - {id: simple62, note: "left band on the middle pulley: the shaft turns with it", belt_around: {belt: [p_middle, drum], belt_C: [p_C, p_small]}}
variant: deduct62
checks:
  - {type: ratio, out: j_C, in: j_upper, expect: 0.5, tol: 0.03, settle_s: 1.5, window_s: 4}
  - {type: ratio, out: j_shaft, in: j_upper, expect: 1.5, tol: 0.08, 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: belt_on, belt: belt_C, 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, 6], position: [85, 60, 26], fov: 34}
display:
  output: j_shaft
  labels: {j_upper: "Upper shaft (driver)", j_loose: "Loose pulley", j_carrier: "Pulley carrying B", j_B: "Bevel B on its pin", j_shaft: "Shaft (bevel A, middle pulley)", j_C: "Bevel C on the fourth pulley"}
  expect: {default: 1.5}
  proof: {label: "Fourth pulley unkeyed from C", sub: "nothing drives or holds C: it runs back and the shaft hardly turns"}
