# No. 309 (Brown 1868): "Mudge’s gravity escapement. The pallets, A, B, instead of being on one arbor, are on two, as shown at C. The pendulum plays between the fork-pins, P, Q, and so raises one of the weighted pallets out of the wheel at each vibration. When the pendulum returns the pallet falls with it, and the weight of the pallet gives the impulse."
#
# Model (cm, gravity on). The escape-wheel has five pins at r 2 on its front face, turned clockwise by a constant torque (the weight). The pendulum hangs from a
# pivot 10 above the wheel's axis; the two pallets A (left) and B (right) hang from arbors of their own 2 either side of it at the same height, each weighted and
# each with a fork-pin (P on A, Q on B) 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 a hook in the wheel's path: an upright face, and a short stop right under (B) or over (A) its arbor. A pin coming round pushes the face out,
# lifting the pallet's weight by the curve of its path, until it 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 pin, and the wheel goes on until the other pallet's stop catches the next pin (having lifted that pallet too). 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 same whatever the weight on the wheel.
# 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/gen309.py.
number: 309
slug: mudges-gravity-escapement
name: "Mudge’s gravity escapement"
brown: "Mudge’s gravity escapement. The pallets, A, B, instead of being on one arbor, are on two, as shown at C. The pendulum plays between the fork-pins, P, Q, and so raises one of the weighted pallets out of the wheel at each vibration. When the pendulum returns the pallet falls with it, and the weight of the pallet gives the impulse."
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.1, 0.05]}   # the wheel
      - {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 pin
      - {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"}
  - id: pallet_a
    shape: part
    pos: [-2.0, 0, 10.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: poly, points: [[-1.96086, -1.30391], [-1.81093, -1.29941], [-1.85743, 0.24989], [-2.00736, 0.24539]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}   # A's hook: its face, and the stop under which a pin locks
      - {kind: poly, points: [[-1.85443, 0.14993], [-1.60455, 0.15743], [-1.60755, 0.25739], [-1.85743, 0.24989]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}
      - {kind: disc, center: [-2.0, 10.0], radius: 0.35, y: [-1.1, -0.6]}   # A's arbor
      - {kind: rod, from: [-2.0, -0.9, 10.0], to: [-2.0, -0.9, -2.7], radius: 0.07}   # its arm
      - {kind: rod, from: [-2.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: [-4.0, -3.2], radius: 0.45, y: [0.7, 1.3], density: 120000.0, color: "#cfc6b4"}   # its weight
      - {kind: rod, from: [-2.0, 1.0, -2.7], to: [-4.0, 1.0, -3.2], radius: 0.06}
      - {kind: rod, from: [-2.0, -0.9, -2.7], to: [-2.0, 1.0, -2.7], radius: 0.06}
  - id: pallet_b
    shape: part
    pos: [2.0, 0, 10.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: poly, points: [[2.54038, -0.23684], [2.69028, -0.23113], [2.63123, 1.31774], [2.48133, 1.31203]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}   # B's hook: its face, and the stop on which a pin locks
      - {kind: poly, points: [[2.29057, -0.24637], [2.54038, -0.23684], [2.53657, -0.13692], [2.28676, -0.14644]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}
      - {kind: disc, center: [2.0, 10.0], radius: 0.35, y: [-1.1, -0.6]}   # B's arbor
      - {kind: rod, from: [2.0, -0.9, 10.0], to: [2.86434, -0.9, -2.67055], radius: 0.07}   # its arm
      - {kind: rod, from: [2.86434, -0.9, -2.67055], to: [1.29256, 1.0, -3.57963], radius: 0.07}
      - {kind: rod, from: [1.29256, 1.0, -3.57963], to: [1.32659, 1.0, -4.07847], radius: 0.07}
      - {kind: disc, center: [1.32659, -4.07847], radius: 0.15, y: [0.75, 1.3], collide: 1, color: "#5c5348"}   # its fork-pin
      - {kind: disc, center: [4.89373, -3.03328], radius: 0.45, y: [0.7, 1.3], density: 120000.0, color: "#cfc6b4"}   # its weight
      - {kind: rod, from: [2.86434, 1.0, -2.67055], to: [4.89373, 1.0, -3.03328], radius: 0.06}
      - {kind: rod, from: [2.86434, -0.9, -2.67055], to: [2.86434, 1.0, -2.67055], 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: [-2.0, 10.0], radius: 0.15, y: [-1.2, -0.5], color: "#5c5348"}   # A's arbor's pin
      - {kind: disc, center: [2.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: 0.0001}   # 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.06811]}   # B; - : out (lifted); its banking at 0.06811 (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.003, 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"}

