# No. 312 (Brown 1868): "Bloxam’s gravity escapement. The pallets are lifted alternately by the small wheel, and the stopping is done by the action of the stops, A and B, on the larger wheel. E and F are the fork-pins which embrace the pendulum."
#
# Model (cm, gravity on). The escape-wheel is a small lifting wheel and a larger locking wheel on one arbor, each with five round-tipped teeth (at r 2 and
# r 3), turned clockwise by a constant torque (the weight). The pendulum hangs from a pivot 10 above the wheel's axis; the two pallets hang from arbors of
# their own 3 either side of it at the same height, each weighted and each with a fork-pin (E on the left, F on the right) lying against the pendulum rod
# 4 below the wheel's axis. A banking stops each pallet when it hangs against the rod. Each pallet has an upright lifting face in the small wheel's path,
# and a short stop (A on the left, B on the right) in the large wheel's path, right under its arbor. A tooth of the small wheel pushes the face out and lifts the
# pallet's weight until a tooth of the large wheel lands on the stop and the wheel is locked; the stop is struck nearly through the arbor, so it does not push
# the pallet. The pendulum swinging that way takes up the lifted pallet by its fork-pin, lifts it a little further, the stop slides from under the tooth, and the
# wheel goes a tenth of a turn until the other pallet's stop catches the next tooth (the small wheel having lifted that pallet). The pendulum returns with the
# pallet resting on it, and the pallet's weight falls further than it was taken up, to its banking: that is the impulse.
# The pendulum starts drawn 4 degrees to the right with B on its rod. The only input is the torque on the wheel. Generator: opencode-runs/batch12/gen312.py.
number: 312
slug: bloxams-gravity-escapement
name: "Bloxam’s gravity escapement"
brown: "Bloxam’s gravity escapement. The pallets are lifted alternately by the small wheel, and the stopping is done by the action of the stops, A and B, on the larger wheel. E and F are the fork-pins which embrace the pendulum."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 50, duration_s: 11, floor: false}
bodies:
  - id: wheel
    shape: part
    pos: [0, 0, 0]
    mass: 0.01
    friction: 0.1
    color: "#e6d7b0"
    pieces:
      - {kind: disc, center: [0, 0], radius: 1.7, y: [-0.6, -0.1]}   # the small wheel
      - {kind: disc, center: [0, 0], radius: 2.6, inner: 2.35, y: [-1.5, -1.2]}   # the large wheel (its rim)
      - {kind: rod, from: [0, -1.35, -2.5], to: [0, -1.35, 2.5], radius: 0.12}   # its arms
      - {kind: rod, from: [-2.5, -1.35, 0], to: [2.5, -1.35, 0], radius: 0.12}
      - {kind: disc, center: [0, 0], radius: 0.2, y: [-0.15, 0.6], color: "#8f8a80"}   # its arbor
      - {kind: disc, center: [2.0, 0.0], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}   # a tooth of the small wheel (its rounded tip)
      - {kind: disc, center: [0.61803, -1.90211], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}
      - {kind: disc, center: [-1.61803, -1.17557], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}
      - {kind: disc, center: [-1.61803, 1.17557], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}
      - {kind: disc, center: [0.61803, 1.90211], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [1.65, -0.35, 0.0], to: [2.0, -0.35, 0.0], radius: 0.12}
      - {kind: rod, from: [0.50988, -0.35, -1.56924], to: [0.61803, -0.35, -1.90211], radius: 0.12}
      - {kind: rod, from: [-1.33488, -0.35, -0.96985], to: [-1.61803, -0.35, -1.17557], radius: 0.12}
      - {kind: rod, from: [-1.33488, -0.35, 0.96985], to: [-1.61803, -0.35, 1.17557], radius: 0.12}
      - {kind: rod, from: [0.50988, -0.35, 1.56924], to: [0.61803, -0.35, 1.90211], radius: 0.12}
      - {kind: rod, from: [2.55, -1.35, 0.0], to: [3.0, -1.35, 0.0], radius: 0.12}   # a tooth of the large wheel
      - {kind: disc, center: [3.0, 0.0], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}   # its rounded tip, which locks on a stop
      - {kind: rod, from: [0.78799, -1.35, -2.42519], to: [0.92705, -1.35, -2.85317], radius: 0.12}
      - {kind: disc, center: [0.92705, -2.85317], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [-2.06299, -1.35, -1.49885], to: [-2.42705, -1.35, -1.76336], radius: 0.12}
      - {kind: disc, center: [-2.42705, -1.76336], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [-2.06299, -1.35, 1.49885], to: [-2.42705, -1.35, 1.76336], radius: 0.12}
      - {kind: disc, center: [-2.42705, 1.76336], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [0.78799, -1.35, 2.42519], to: [0.92705, -1.35, 2.85317], radius: 0.12}
      - {kind: disc, center: [0.92705, 2.85317], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}
  - id: pallet_a
    shape: part
    pos: [-3.0, 0, 10.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: poly, points: [[-1.96132, -1.27391], [-1.81138, -1.26941], [-1.85788, 0.27989], [-2.00782, 0.27539]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}   # the left pallet's lifting face
      - {kind: poly, points: [[-2.85443, 0.14993], [-2.60455, 0.15743], [-2.60755, 0.25739], [-2.85743, 0.24989]], y: [-1.65, -1.05], collide: 1, color: "#b85c38"}   # the stop A, under which a tooth locks
      - {kind: disc, center: [-3.0, 10.0], radius: 0.35, y: [-1.1, -0.6]}   # A's arbor
      - {kind: rod, from: [-3.0, -0.9, 10.0], to: [-3.0, -0.9, -2.7], radius: 0.07}   # its arm
      - {kind: rod, from: [-3.0, -0.9, 1.1], to: [-2.22, -0.9, 1.1], radius: 0.06}   # to its lifting face
      - {kind: rod, from: [-3.0, -0.9, -2.7], to: [-0.37, 1.0, -3.5], radius: 0.07}
      - {kind: rod, from: [-0.37, 1.0, -3.5], to: [-0.37, 1.0, -4.0], radius: 0.07}
      - {kind: disc, center: [-0.37, -4.0], radius: 0.15, y: [0.75, 1.3], collide: 1, color: "#5c5348"}   # its fork-pin
      - {kind: disc, center: [-5.0, -3.2], radius: 0.45, y: [0.7, 1.3], density: 120000.0, color: "#cfc6b4"}   # its weight
      - {kind: rod, from: [-3.0, 1.0, -2.7], to: [-5.0, 1.0, -3.2], radius: 0.06}
      - {kind: rod, from: [-3.0, -0.9, -2.7], to: [-3.0, 1.0, -2.7], radius: 0.06}
  - id: pallet_b
    shape: part
    pos: [3.0, 0, 10.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: poly, points: [[2.53943, -0.27487], [2.68932, -0.26918], [2.63052, 1.27971], [2.48063, 1.27402]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}   # the right pallet's lifting face
      - {kind: poly, points: [[3.28889, -0.24642], [3.53871, -0.23693], [3.53491, -0.137], [3.28509, -0.14649]], y: [-1.65, -1.05], collide: 1, color: "#b85c38"}   # the stop B, on which a tooth locks
      - {kind: disc, center: [3.0, 10.0], radius: 0.35, y: [-1.1, -0.6]}   # B's arbor
      - {kind: rod, from: [3.0, -0.9, 10.0], to: [3.86226, -0.9, -2.67069], radius: 0.07}   # its arm
      - {kind: rod, from: [3.60426, -0.9, 1.12054], to: [2.82606, -0.9, 1.06758], radius: 0.06}   # to its lifting face
      - {kind: rod, from: [3.86226, -0.9, -2.67069], to: [1.29264, 1.0, -3.64741], radius: 0.07}
      - {kind: rod, from: [1.29264, 1.0, -3.64741], to: [1.32659, 1.0, -4.14626], radius: 0.07}
      - {kind: disc, center: [1.32659, -4.14626], radius: 0.15, y: [0.75, 1.3], collide: 1, color: "#5c5348"}   # its fork-pin
      - {kind: disc, center: [5.89159, -3.03375], radius: 0.45, y: [0.7, 1.3], density: 120000.0, color: "#cfc6b4"}   # its weight
      - {kind: rod, from: [3.86226, 1.0, -2.67069], to: [5.89159, 1.0, -3.03375], radius: 0.06}
      - {kind: rod, from: [3.86226, -0.9, -2.67069], to: [3.86226, 1.0, -2.67069], radius: 0.06}
  - id: pendulum
    shape: part
    pos: [0, 0, 10.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: disc, center: [0, 10.0], radius: 0.5, y: [0.6, 1.4]}   # the pendulum's boss
      - {kind: rod, from: [0, 1.0, 10.0], to: [1.28352, 1.0, -8.35518], radius: 0.2, color: "#8f8a80"}   # the rod
      - {kind: poly, points: [[0.82591, -4.67814], [1.22493, -4.65024], [1.12727, -3.25365], [0.72825, -3.28155]], y: [0.8, 1.2], collide: 2, color: "#8f8a80"}   # where the fork-pins bear on it
      - {kind: disc, center: [1.39513, -9.95128], radius: 2.2, y: [0.7, 1.3], density: 240000.0, color: "#e6d7b0"}   # the bob
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: disc, center: [0, 10.0], radius: 0.25, y: [0.4, 1.6], color: "#5c5348"}   # the pendulum's pin
      - {kind: disc, center: [-3.0, 10.0], radius: 0.15, y: [-1.2, -0.5], color: "#5c5348"}   # A's arbor's pin
      - {kind: disc, center: [3.0, 10.0], radius: 0.15, y: [-1.2, -0.5], color: "#5c5348"}   # B's
      - {kind: poly, points: [[-0.6, -0.6], [0.6, -0.6], [0.6, 0.6], [-0.6, 0.6]], y: [0.6, 0.8]}   # the cock behind the wheel
joints:
  - {id: j_wheel, type: hinge, body: wheel, axis: [0, 1, 0], damping: 4e-05}   # the escape-wheel; + : clockwise (its way)
  - {id: j_a, type: hinge, body: pallet_a, axis: [0, 1, 0], damping: 2e-05, range: [0, 0.11]}   # A; + : out (lifted); 0 its banking
  - {id: j_b, type: hinge, body: pallet_b, axis: [0, 1, 0], damping: 2e-05, range: [-0.04, 0.06795]}   # B; - : out (lifted); its banking at 0.06795 (it starts out, on the rod)
  - {id: j_pend, type: hinge, body: pendulum, axis: [0, 1, 0], damping: 0.002}   # the pendulum; + : clockwise (the bob to the left)
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
# The weight: a constant torque on the wheel, clockwise. Nothing else is driven.
driver: {joint: j_wheel, kind: torque, torque: 0.0017, max_torque: 1}
checks:
  - {type: period, joint: j_pend, tol: 0.04, settle_s: 3, window_s: 6}
  # a tenth of a turn a beat
  - {type: advance, joint: j_wheel, beat: j_pend, expect: 0.62832, tol: 0.03, settle_s: 3, window_s: 7.3}
  - {type: monotonic, joint: j_wheel, direction: 1, max_back: 0.04, settle_s: 2, window_s: 7}
  - {type: amplitude, joint: j_pend, min: 0.03, max: 0.2, sustain: 0.9, settle_s: 3, window_s: 6}
  - {type: penetration, max: 0.0005, settle_s: 1}
camera: {target: [0, 0, 1.5], position: [0, -44, 1.5], fov: 30}
display:
  output: j_pend
  swing: j_pend
  labels: {j_wheel: "Escape-wheel (weight)", j_pend: "Pendulum", j_a: "Pallet A", j_b: "Pallet B"}
  proof: {label: "Pallets out of contact", sub: "the weight spins the wheel freely, and nothing makes good the pendulum's losses"}

