# No. 226 (Brown 1868): "This movement is designed to double the speed by gears of equal diameters and numbers of teeth -- a result once generally supposed to be
# impossible. Six bevel-gears are employed. ..." (the full description is under brown:)
#
# Model (cm; F along y, B upright): six equal bevel-gears (20 teeth, pitch radius 4, 45-degree cones, No. 61's). The gear on B, at the top, gears with
# one gear fast on F and one on the hollow shaft C, loose on F, so F and C turn opposite ways at B's speed. 12 further along, C's second gear and E (loose on F)
# face each other with D between them; D turns on a pin in the frame A, which is fast on F and reaches round E. So A carries D round with F while C's second gear
# turns D on its pin. Only B is driven (15 rpm). Relative to the frame, C runs backwards at twice F's speed, so D turns E forward at twice F's speed relative
# to the frame, and E makes three turns to B's one (E = 2 A - C), not two as the description counts it (it takes C's turn relative to the frame as one).
# A counterweight on A balances D and the frame (gravity on). Generator: opencode-runs/batch11/gen226.py.
number: 226
slug: six-bevels-double-speed
name: Speed multiplied by six equal bevel-gears
brown: "This movement is designed to double the speed by gears of equal diameters and numbers of teeth\u2014a result once generally supposed to be impossible. Six bevel-gears are employed. The gear on the shaft, B, is in gear with two others\u2014one on the shaft, F, and the other on the same hollow shaft with C, which turns loosely on F. The gear, D, is carried by the frame, A, which, being fast on the shaft, F, is made to rotate, and therefore takes round D with it. E is loose on the shaft, F, and gears with D. Now, suppose the two gears on the hollow shaft, C, were removed and D prevented from turning on its axis; one revolution given to the gear on B would cause the frame, A, also to receive one revolution, and as this frame carries with it the gear, D, gearing with E, one revolution would be imparted to E; but if the gears on the hollow shaft, C, were replaced, D would receive also a revolution on its axis during the one revolution of B, and thus would produce two revolutions of E."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  solver: PGS
  multiccd: true
  duration_s: 6
  floor: false
bodies:
  - id: shaftB
    shape: part
    pos: [0, 0, 0]
    mass: 0.3
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, 0, 5.4], to: [0, 0, 15.5], radius: 0.55, collide: 0, color: "#8f8a80"}   # B
      - {kind: rod, from: [0, 0, 14.6], to: [4.5, 0, 14.6], radius: 0.35, collide: 0}   # a crank
      - {kind: rod, from: [4.5, 0, 14.6], to: [4.5, 0, 17.0], radius: 0.45, collide: 0}   # its handle
  - id: shaftF
    shape: part
    pos: [0, 0, 0]
    mass: 0.4
    color: "#cfc4a8"
    pieces:
      - {kind: rod, from: [0, 7.5, 0], to: [0, -22.0, 0], radius: 0.55, collide: 0, color: "#8f8a80"}   # F
      - {kind: rod, from: [0, -18.9, 0], to: [0, -20.1, 0], radius: 1.1, collide: 0}   # the frame A, clamped on F
      - {kind: rod, from: [0, -19.5, 0], to: [0, -19.5, 8.6], radius: 0.45, collide: 0}
      - {kind: rod, from: [0, -19.5, 8.6], to: [0, -12.0, 8.6], radius: 0.45, collide: 0}
      - {kind: rod, from: [0, -12.0, 8.6], to: [0, -12.0, 6.6], radius: 0.6, collide: 0}   # D's bearing
      - {kind: rod, from: [0, -19.5, 0], to: [0, -19.5, -7.8], radius: 0.45, collide: 0}
      - {kind: disc, center: [0, -7.8], radius: 1.5, y: [-20.1, -18.9], collide: 0, color: "#a39d90"}   # the counterweight
  - id: hollowC
    shape: part
    pos: [0, 0, 0]
    mass: 0.3
    color: "#c9b88f"
    pieces:
      - {kind: rod, from: [0, -1.8, 0], to: [0, -10.2, 0], radius: 0.95, collide: 0}   # C, loose on F
  - id: gearD
    shape: part
    pos: [0, -12.0, 0]
    mount: shaftF
    mass: 0.05
    color: "#d8ceba"
    pieces:
      - {kind: rod, from: [0, -12.0, 1.2], to: [0, -12.0, 7.2], radius: 0.4, collide: 0, color: "#8f8a80"}   # D's pin
  - id: gearE
    shape: part
    pos: [0, 0, 0]
    mass: 0.2
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [0, -13.8, 0], to: [0, -18.3, 0], radius: 0.95, collide: 0}   # E's hub, loose on F
      - {kind: disc, center: [0, 0], radius: 3.0, inner: 0.95, y: [-18.3, -17.5], collide: 0}   # and a pulley on it
      - {kind: poly, points: [[-0.3, 0.9], [0.3, 0.9], [0.3, 3.0], [-0.3, 3.0]], y: [-18.5, -18.3], collide: 0, color: "#6b5a44"}   # a mark on it
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, 0, 10.5], to: [0, 0, 12.0], radius: 1.1, collide: 0}   # B's bearing
      - {kind: rod, from: [0, 0, 11.2], to: [0, 9.5, 11.2], radius: 0.5, collide: 0}
      - {kind: rod, from: [0, 6.2, 0], to: [0, 7.4, 0], radius: 1.1, collide: 0}   # F's bearings
      - {kind: rod, from: [0, -20.5, 0], to: [0, -21.7, 0], radius: 1.1, collide: 0}
      - {kind: poly, points: [[-1.2, -10.5], [1.2, -10.5], [0.8, 0], [-0.8, 0]], y: [6.2, 7.4], collide: 0}
      - {kind: rod, from: [0, 9.5, 11.2], to: [0, 9.5, -10.5], radius: 0.6, collide: 0}
      - {kind: poly, points: [[-1.2, -10.5], [1.2, -10.5], [0.8, 0], [-0.8, 0]], y: [-21.7, -20.5], collide: 0}
      - {kind: poly, points: [[-5, -11.5], [5, -11.5], [5, -10.5], [-5, -10.5]], y: [-23.5, 11], collide: 0, color: "#b9b09c"}
joints:
  - {id: j_B, type: hinge, body: shaftB, axis: [0, 0, 1], damping: 0.002}   # the one driven joint
  - {id: j_F, type: hinge, body: shaftF, axis: [0, 1, 0], damping: 0.002}
  - {id: j_C, type: hinge, body: hollowC, axis: [0, 1, 0], damping: 0.002}
  - {id: j_D, type: hinge, body: gearD, axis: [0, 0, 1], damping: 0.001}
  - {id: j_E, type: hinge, body: gearE, axis: [0, 1, 0], damping: 0.01}   # the load
bevels:
  - {id: gB, body: shaftB, pos: [0, 0, 0], teeth: 20, pitch_radius: 4.0, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0, quat: [0.7071068, 0.7071068, 0, 0], color: "#e4d9bf"}
  - {id: gF, body: shaftF, pos: [0, 0, 0], teeth: 20, pitch_radius: 4.0, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796, quat: [1, 0, 0, 0], color: "#d8ccae"}
  - {id: gC1, body: hollowC, pos: [0, 0, 0], teeth: 20, pitch_radius: 4.0, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796, quat: [0, 1, 0, 0], color: "#cdbd96"}
  - {id: gC2, body: hollowC, pos: [0, -12.0, 0], teeth: 20, pitch_radius: 4.0, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796, quat: [1, 0, 0, 0], color: "#cdbd96"}
  - {id: gD, body: gearD, pos: [0, 0, 0], teeth: 20, pitch_radius: 4.0, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0, quat: [0.7071068, 0.7071068, 0, 0], color: "#e4d9bf"}
  - {id: gE, body: gearE, pos: [0, -12.0, 0], teeth: 20, pitch_radius: 4.0, cone_angle: 0.7853982, face_width: 3, backlash: 0.04, phase: 0.1570796, quat: [0, 1, 0, 0], color: "#c4b48c"}
contact: {solref: [0.0008, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_B, kind: velocity, rpm: 15, kv: 2, max_torque: 5}
checks:
  - {type: ratio, out: j_F, in: j_B, expect: -1.0, tol: 0.02, settle_s: 1, window_s: 4}   # F turns at B's speed (the sense as the axes are taken)
  - {type: ratio, out: j_C, in: j_F, expect: -1.0, tol: 0.02, settle_s: 1, window_s: 4}   # C the other way
  - {type: ratio, out: j_E, in: j_F, expect: 3.0, tol: 0.03, settle_s: 1, window_s: 4}   # E = 2 A - C = 3 F (kinematics); the description counts 2
  - {type: penetration, max: 0.001, settle_s: 1}
camera: {target: [0.0, -7.0, -10.0], position: [85.0, 36.0, 26.0], fov: 34}
display:
  output: j_E
  labels: {j_B: "Gear on B (driver)", j_F: "Shaft F and frame A", j_C: "Hollow shaft C", j_D: "Gear D on its pin", j_E: "Gear E (loose on F)"}
  proof: {label: "Teeth out of contact", sub: "B turns alone: F, C and E stand"}

