# No. 287 (Brown 1868): "Pickering’s governor. The balls are attached to springs the upper end of each of which is attached to a collar fixed on the spindle, and the lower end to a collar on the sliding sleeve. The springs yield in a proper degree to the centrifugal force of the balls, and raise the sleeve; and as the centrifugal force diminishes, they draw the balls toward the spindle and depress the sleeve."
#
# Model (cm, gravity on): the spindle is the one driven joint (150 turns a minute). Each of the two springs is a flat steel strip from a hinge on the collar fixed at the top of the
# spindle down to a hinge on the collar of the sleeve, which slides on the spindle; the ball (0.5 kg) is fast on the middle of the strip. The strip is modelled as two halves (9 cm each)
# whose bending stiffness sits in the joints at its two ends and at the ball (0.4 and 0.15 N m/rad), set so that at rest the springs hold the balls and the sleeve (0.3 kg) where they start,
# each half 0.3 rad from the upright. The sleeve is pinned to the strips' lower ends and to nothing else. As the spindle runs, the balls fly out against the springs and gravity, bowing the
# strips, and the strips' ends draw together, lifting the sleeve; the balance of spin, springs and weight puts each half at 0.687 rad, the sleeve 3.28 cm up. Generator: opencode-runs/batch12/gen287.py.
number: 287
slug: pickering-governor
name: Pickering’s governor
brown: "Pickering’s governor. The balls are attached to springs the upper end of each of which is attached to a collar fixed on the spindle, and the lower end to a collar on the sliding sleeve. The springs yield in a proper degree to the centrifugal force of the balls, and raise the sleeve; and as the centrifugal force diminishes, they draw the balls toward the spindle and depress the sleeve."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 9
  floor: false
bodies:
  - id: shaft
    shape: part
    pos: [0, 0, 0]
    mass: 0.4
    color: "#e4d9bf"
    pieces:
      - {kind: rod, from: [0, 0, 5.8039], to: [0, 0, 35.0], radius: 0.7, collide: 0}   # the spindle
      - {kind: rod, from: [0, 0, 29.4], to: [0, 0, 30.6], radius: 2.1, collide: 0, color: "#8f8a80"}   # the collar fixed on the spindle
      - {kind: rod, from: [0, 0, 32.6], to: [0, 0, 34.0], radius: 3.2, collide: 0, color: "#a3906f"}   # the driving pulley
  - id: sleeve
    shape: part
    pos: [0, 0, 12.8039]
    mount: shaft
    mass: 0.3
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [0, 0, 8.8039], to: [0, 0, 13.4039], radius: 1.1, collide: 0}   # the sliding sleeve
      - {kind: rod, from: [0, 0, 12.2039], to: [0, 0, 13.4039], radius: 2.1, collide: 0, color: "#8f8a80"}   # its collar
      - {kind: rod, from: [0, 0, 9.2039], to: [0, 0, 10.0039], radius: 2.4, collide: 0, color: "#8f8a80"}   # the groove for the valve lever
  - id: up_r
    shape: part
    pos: [1.6, 0, 30.0]
    mount: shaft
    mass: 0.52
    color: "#7d8a96"
    pieces:
      - {kind: poly, points: [[1.7337, 30.0414], [4.3934, 21.4433], [4.1259, 21.3606], [1.4663, 29.9586]], y: [-0.7, 0.7], collide: 0, density: 50}   # the spring's upper half (its mass, with the lower half's, is given to the ball)
      - {kind: rod, from: [1.6, -0.9, 30.0], to: [1.6, 0.9, 30.0], radius: 0.3, collide: 0, density: 50, color: "#5c5348"}
      - {kind: rod, from: [4.2597, -1.0, 21.402], to: [4.2597, 1.0, 21.402], radius: 1.9, collide: 0, color: "#8f8a80"}   # the ball, on the spring's middle
  - id: lo_r
    shape: part
    pos: [4.2597, 0, 21.402]
    mount: up_r
    mass: 0.02
    color: "#7d8a96"
    pieces:
      - {kind: poly, points: [[4.3934, 21.3606], [1.7337, 12.7626], [1.4663, 12.8453], [4.1259, 21.4433]], y: [-0.7, 0.7], collide: 0}   # the spring's lower half
      - {kind: rod, from: [1.6, -0.9, 12.8039], to: [1.6, 0.9, 12.8039], radius: 0.3, collide: 0, color: "#5c5348"}
  - id: up_l
    shape: part
    pos: [-1.6, 0, 30.0]
    mount: shaft
    mass: 0.52
    color: "#7d8a96"
    pieces:
      - {kind: poly, points: [[-1.7337, 30.0414], [-4.3934, 21.4433], [-4.1259, 21.3606], [-1.4663, 29.9586]], y: [-0.7, 0.7], collide: 0, density: 50}   # the spring's upper half (its mass, with the lower half's, is given to the ball)
      - {kind: rod, from: [-1.6, -0.9, 30.0], to: [-1.6, 0.9, 30.0], radius: 0.3, collide: 0, density: 50, color: "#5c5348"}
      - {kind: rod, from: [-4.2597, -1.0, 21.402], to: [-4.2597, 1.0, 21.402], radius: 1.9, collide: 0, color: "#8f8a80"}   # the ball, on the spring's middle
  - id: lo_l
    shape: part
    pos: [-4.2597, 0, 21.402]
    mount: up_l
    mass: 0.02
    color: "#7d8a96"
    pieces:
      - {kind: poly, points: [[-4.3934, 21.3606], [-1.7337, 12.7626], [-1.4663, 12.8453], [-4.1259, 21.4433]], y: [-0.7, 0.7], collide: 0}   # the spring's lower half
      - {kind: rod, from: [-1.6, -0.9, 12.8039], to: [-1.6, 0.9, 12.8039], radius: 0.3, collide: 0, color: "#5c5348"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, 0, 3.8039], to: [0, 0, 6.2039], radius: 1.5, collide: 0, color: "#8f8a80"}   # the spindle's step
      - {kind: poly, points: [[-8, 2.6039], [8, 2.6039], [8, 3.8039], [-8, 3.8039]], y: [-4, 4], collide: 0, color: "#b9b09c"}
joints:
  - {id: j_s, type: hinge, body: shaft, axis: [0, 0, 1], damping: 0.002}   # the one driven joint: the spindle
  - {id: j_z, type: slide, body: sleeve, axis: [0, 0, 1], range: [-0.05, 8], damping: 0.3}   # the sleeve; + : up
  - {id: j_r, type: hinge, body: up_r, axis: [0, -1, 0], stiffness: 0.4, springref: 0.2166, damping: 0.08}   # the right spring's upper end at the fixed collar; + : outward
  - {id: j_l, type: hinge, body: up_l, axis: [0, 1, 0], stiffness: 0.4, springref: 0.2166, damping: 0.08}   # the left; + : outward
  - {id: j_kr, type: hinge, body: lo_r, axis: [0, 1, 0], stiffness: 0.15, springref: 0.4331, damping: 0.002}   # the right spring bending at its ball; + : bowing out
  - {id: j_kl, type: hinge, body: lo_l, axis: [0, -1, 0], stiffness: 0.15, springref: 0.4331, damping: 0.002}
pins:
  - {"id": "pin_r", "a": "lo_r", "b": "sleeve", "at": [1.6, 0, 12.8039]}
  - {"id": "pin_l", "a": "lo_l", "b": "sleeve", "at": [-1.6, 0, 12.8039]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_s, kind: velocity, rpm: 150, kv: 1.0, max_torque: 5}
checks:
  - {type: follow, out: j_z, in: j_r, expect: 0.0849, tol: 0.0042, min_r2: 0.9813, settle_s: 0.0, window_s: 0.25}   # as the balls first fly out the sleeve rises as the springs' ends draw together: 2 x 9 (cos 0.3 - cos theta), m per radian of the upper half (least squares from 0.3 to 0.687 rad: the curve's own r2 is 0.9913)
  - {type: follow, out: j_l, in: j_r, expect: 1.0, tol: 0.03, min_r2: 0.995, settle_s: 0.0, window_s: 1.5}   # both balls alike
  - {type: position, joint: j_r, min: 0.3469, max: 0.4269, settle_s: 4.0, window_s: 4.5}   # the balls stand out where spin, springs and weight balance (0.387 rad past the start)
  - {type: position, joint: j_z, min: 2.9278, max: 3.6278, settle_s: 4.0, window_s: 4.5}   # and the sleeve stands up about 3.28 cm
camera: {target: [0, 0, 11.5], position: [0.0, -110.0, 13.5], fov: 34.0}
display:
  output: j_z
  labels: {j_s: "Spindle (driver)", j_r: "Right spring", j_l: "Left spring", j_z: "Sleeve (slide)"}
  proof: {label: "Pickering’s governor", sub: "the balls bow the springs and draw the sleeve up"}

