# No. 44, Stepped gearing (Brown 1868): "used to transmit great force and give a continuous bearing
# to the teeth. Each wheel is composed of two, three, or more distinct spur-gears. The teeth, instead
# of being in line, are arranged in steps to give a continuous bearing."
#
# Model (cm): each wheel is three spur gears side by side on one shaft (1 wide each), the teeth of
# each a third of a pitch on from the last, so one of the three is always at the best of its
# engagement: a 20-tooth driver (pitch radius 5) and a 30-tooth follower (7.5), centres 12.5 apart
# (batch7/gen044.py). The three gears of a wheel are one rigid body. Only the driver is motor-driven.
number: 44
slug: stepped-gearing
name: Stepped gearing
brown: "A kind of gearing used to transmit great force and give a continuous bearing to the teeth. Each wheel is composed of two, three, or more distinct spur-gears. The teeth, instead of being in line, are arranged in steps to give a continuous bearing. This system is sometimes used for driving screw propellers, and sometimes, with a rack of similar character, to drive the beds of large iron-planing machines."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: CG
  multiccd: true
  duration_s: 6
  floor: false
bodies:
  - {id: ga, shape: assembly, pos: [0, 0, 0], color: "#e4d9bf"}
  - {id: gb, shape: assembly, pos: [12.5, 0, 0], color: "#e8dec6"}
  - {id: stubs, shape: frame, rods: [{from: [0, -4, 0], to: [0, 4, 0], radius: 0.5}, {from: [12.5, -4, 0], to: [12.5, 4, 0], radius: 0.5}], color: "#8f8a80"}
joints:
  - {id: j_a, type: hinge, body: ga, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_b, type: hinge, body: gb, axis: [0, 1, 0], damping: 0.05}
spurs:
  - {id: a0, body: ga, pos: [0, -1.000, 0], teeth: 20, module: 0.5, width: 0.980, backlash: 0.02, phase: 0.0000000}
  - {id: a1, body: ga, pos: [0, 0.000, 0], teeth: 20, module: 0.5, width: 0.980, backlash: 0.02, phase: 0.1047198}
  - {id: a2, body: ga, pos: [0, 1.000, 0], teeth: 20, module: 0.5, width: 0.980, backlash: 0.02, phase: 0.2094395}
  - {id: b0, body: gb, pos: [0, -1.000, 0], teeth: 30, module: 0.5, width: 0.980, backlash: 0.02, phase: 0.1047198}
  - {id: b1, body: gb, pos: [0, 0.000, 0], teeth: 30, module: 0.5, width: 0.980, backlash: 0.02, phase: 0.0349066}
  - {id: b2, body: gb, pos: [0, 1.000, 0], teeth: 30, module: 0.5, width: 0.980, backlash: 0.02, phase: -0.0349065}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_a, kind: velocity, rpm: 30, kv: 2, max_torque: 5}
checks:
  - {type: ratio, out: j_b, in: j_a, expect: -0.66667, tol: 0.003, settle_s: 1, window_s: 5}
  # the even bearing: slices of 1/24 s
  - {type: ratio_range, out: j_b, in: j_a, min: -0.70, max: -0.635, settle_s: 1, window_s: 5, slices: 120}
  - {type: penetration, max: 0.0008, settle_s: 0.5}
camera: {target: [6.25, 0, 0], position: [14, -44, 22], fov: 32}
display:
  output: j_b
  labels: {j_a: "Driver (3 x 20 teeth, stepped)", j_b: "Follower (3 x 30 teeth, stepped)"}
  expect: {default: -0.6667}
  proof: {label: "Teeth out of contact", sub: "the driver turns alone: the follower stops"}
