# No. 503 (Brown 1868): "A very simple form of the epicyclic train."
#
# Model (cm; the shaft A upright, seen from the side as Brown, B on the right). Straight bevels, module 0.5, apexes at one point on A, as
# Brown's: the two large wheels C and D (30 teeth, 7.5 cm pitch radius) and the small B (12 teeth, 3 cm) between them: D above, held fast by its hub in the frame's bracket;
# C below, loose on A and turned by its hub (the only input, a steady 20 rpm); B on the arm G, which stands out from the
# boss F fast on A, B turning freely on it. C turns B, B rolls round the fixed D and so carries the arm and the shaft A round, at half C's speed,
# the same way. Generator: opencode-runs/batch16/gen503.py.
number: 503
slug: simple-epicyclic-train-bevel
name: A very simple epicyclic train
brown: "A very simple form of the epicyclic train, in which F, G, is the arm, secured to the central shaft, A, upon which are loosely fitted the bevel-wheels, C, D. The arm is formed into an axle for the bevel-wheel, B, which is fitted to turn freely upon it. Motion may be given to the two wheels, C, D, in order to produce aggregate motion of the arm, or else to the arm and one of said wheels in order to produce aggregate motion of the other wheel."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  solver: PGS          # as Nos. 7 and 495: Newton/CG are not stable through two simultaneous bevel meshes
  multiccd: true
  duration_s: 6
  floor: false
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-13, -13.4], [10, -13.4], [10, -12.2], [-13, -12.2]], y: [-4, 4], collide: 0}   # the bed
      - {kind: poly, points: [[-13, -12.2], [-11, -12.2], [-11, 10.6], [-13, 10.6]], y: [-1.5, 1.5], collide: 0}   # the standard
      - {kind: poly, points: [[-13, 8.8], [-1.6, 8.8], [-1.6, 10.6], [-13, 10.6]], y: [-1.5, 1.5], collide: 0}   # the bracket holding D's hub
      - {kind: poly, points: [[-1.8, -12.2], [1.8, -12.2], [1.8, -10.8], [-1.8, -10.8]], y: [-1.8, 1.8], collide: 0}   # A's footstep
  - {id: fixD, shape: assembly, pos: [0, 0, 0], color: "#cfc4a8"}   # D, its hub held in the bracket
  - {id: shaftA, shape: assembly, pos: [0, 0, 0], color: "#d9cfb6"}
  - id: pinB
    shape: part
    pos: [0, 0, 0]
    mount: shaftA
    mass: 0.15
    color: "#d8ceba"
    pieces:
      - {kind: rod, from: [7.6, 0, 0], to: [8.6, 0, 0], radius: 1.1, color: "#cfc4a8", collide: 0}
  - {id: gearC, shape: assembly, pos: [0, 0, 0], color: "#cfc4a8"}   # C and its hub
joints:
  - {id: j_D, type: hinge, body: fixD, axis: [0, 0, 1], range: [-0.0002, 0.0002], damping: 0.01}   # D held fast
  - {id: j_A, type: hinge, body: shaftA, axis: [0, 0, 1], damping: 0.3}   # the shaft A with the arm F, G; its load
  - {id: j_B, type: hinge, body: pinB, axis: [1, 0, 0], damping: 0.001}
  - {id: j_C, type: hinge, body: gearC, axis: [0, 0, 1], damping: 0.01}   # C, loose on A: the driver
shafts:
  - {id: sA, body: shaftA, from: [0, 0, -11.2], to: [0, 0, 13], radius: 0.75}
  - {id: bossF, body: shaftA, from: [0, 0, -1.4], to: [0, 0, 1.4], radius: 1.6}   # the boss F, fast on A
  - {id: armG, body: shaftA, from: [0, 0, 0], to: [9.4, 0, 0], radius: 0.6}   # the arm G, B's axle
  - {id: capG, body: shaftA, from: [8.6, 0, 0], to: [9.4, 0, 0], radius: 1.0}
  - {id: hubD, body: fixD, from: [0, 0, 3.0], to: [0, 0, 10.6], radius: 1.6, inner: 0.8}
  - {id: hubC, body: gearC, from: [0, 0, -8.4], to: [0, 0, -3.0], radius: 1.6, inner: 0.8}
  - {id: collarC, body: gearC, from: [0, 0, -9.4], to: [0, 0, -8.4], radius: 2.6, inner: 0.8}
bevels:
  - {id: gD, body: fixD, teeth: 30, pitch_radius: 7.5, cone_angle: 1.1902899, face_width: 2.5, backlash: 0.1, phase: 0, quat: [0.7071068, 0.7071068, 0, 0]}
  - {id: gC, body: gearC, teeth: 30, pitch_radius: 7.5, cone_angle: 1.1902899, face_width: 2.5, backlash: 0.1, phase: 0, quat: [0.7071068, -0.7071068, 0, 0]}
  - {id: gB, body: pinB, teeth: 12, pitch_radius: 3, cone_angle: 0.3805064, face_width: 2.5, backlash: 0.1, phase: 0.261799, quat: [0.7071068, 0, 0, -0.7071068]}
contact: {solref: [0.0008, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_C, kind: velocity, rpm: 20, kv: 2, max_torque: 5}
checks:
  # D fixed: the arm (and A) turns half as fast as C, the same way; B turns on G as fast as the arm goes round
  - {type: ratio, out: j_A, in: j_C, expect: 0.5, tol: 0.015, settle_s: 1.5, window_s: 4}
  - {type: penetration, max: 0.001, settle_s: 1.5}
camera: {target: [-1.5, 0, -5], position: [-1.5, -72, -5], fov: 30}
display:
  output: j_A
  labels: {j_C: "Bevel C (driver)", j_A: "Shaft A and arm F, G", j_B: "Bevel B"}
  expect: {default: 0.5}
  proof: {label: "D's teeth out of contact", sub: "C spins B on its axle, but nothing carries the arm round"}

