# No. 311 (Brown 1868): "Double three-legged gravity escapement. Two locking-wheels, A, B, C, and a, b, c, are here used with one set of lifting-pins between them. The two wheels are set wide enough apart to allow the pallets to lie between them. The teeth of the first-mentioned locking-wheel are stopped by a stop-tooth, D, on one pallet, and those of the other one by a stop-tooth, E, on the other pallet."
#
# Model (cm, gravity on). The escape-wheel is two three-legged locking-wheels, ABC in front and abc behind, legs in line, with one set of
# three lifting pins between them near the center at r 1.2; the legs end at r 2.6. The pallets lie between the two wheels. A constant torque turns it clockwise
# (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.6 either side
# of it at the same height, each weighted and each with a fork-pin 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 pins' path, and a short stop (D on A, in the front wheel's path; E on B, in the back wheel's), right under its
# arbor. A pin coming round pushes the face out and lifts the pallet's weight until a leg 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 leg, and the wheel goes a sixth of a turn until the other pallet's stop catches the next leg (its pin 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/gen311.py.
number: 311
slug: double-three-legged-gravity-escapement
name: "Double three-legged gravity escapement"
brown: "Double three-legged gravity escapement. Two locking-wheels, A, B, C, and a, b, c, are here used with one set of lifting-pins between them. The two wheels are set wide enough apart to allow the pallets to lie between them. The teeth of the first-mentioned locking-wheel are stopped by a stop-tooth, D, on one pallet, and those of the other one by a stop-tooth, E, on the other pallet."
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: 0.9, 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: [1.2, 0.0], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}   # a lifting pin
      - {kind: disc, center: [-0.6, -1.03923], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}
      - {kind: disc, center: [-0.6, 1.03923], radius: 0.15, y: [-0.6, -0.1], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [0, -1.35, 0], to: [2.6, -1.35, 0.0], radius: 0.1}   # a leg of the locking-wheel ABC
      - {kind: disc, center: [2.6, 0.0], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}   # its end, which locks on a stop
      - {kind: rod, from: [0, -1.35, 0], to: [-1.3, -1.35, -2.25167], radius: 0.1}
      - {kind: disc, center: [-1.3, -2.25167], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [0, -1.35, 0], to: [-1.3, -1.35, 2.25167], radius: 0.1}
      - {kind: disc, center: [-1.3, 2.25167], radius: 0.15, y: [-1.6, -1.1], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [0, 0.35, 0], to: [2.6, 0.35, 0.0], radius: 0.1}   # a leg of the locking-wheel abc
      - {kind: disc, center: [2.6, 0.0], radius: 0.15, y: [0.1, 0.6], collide: 2, color: "#5c5348"}   # its end, which locks on a stop
      - {kind: rod, from: [0, 0.35, 0], to: [-1.3, 0.35, -2.25167], radius: 0.1}
      - {kind: disc, center: [-1.3, -2.25167], radius: 0.15, y: [0.1, 0.6], collide: 2, color: "#5c5348"}
      - {kind: rod, from: [0, 0.35, 0], to: [-1.3, 0.35, 2.25167], radius: 0.1}
      - {kind: disc, center: [-1.3, 2.25167], radius: 0.15, y: [0.1, 0.6], collide: 2, color: "#5c5348"}
  - id: pallet_a
    shape: part
    pos: [-2.6, 0, 10.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: poly, points: [[-1.1615, -1.26191], [-1.01156, -1.25741], [-1.06856, 0.64173], [-1.2185, 0.63723]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}   # A's lifting face
      - {kind: poly, points: [[-2.45443, 0.14993], [-2.20455, 0.15743], [-2.20755, 0.25739], [-2.45743, 0.24989]], y: [-1.65, -1.05], collide: 1, color: "#b85c38"}   # the stop D, under which a leg locks
      - {kind: disc, center: [-2.6, 10.0], radius: 0.35, y: [-1.1, -0.6]}   # A's arbor
      - {kind: rod, from: [-2.6, -0.9, 10.0], to: [-2.6, -0.9, -2.7], radius: 0.07}   # its arm
      - {kind: rod, from: [-2.6, -0.9, 1.1], to: [-1.42, -0.9, 1.1], radius: 0.06}   # to its lifting face
      - {kind: rod, from: [-2.6, -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.6, 1.0, -2.7], to: [-4.0, 1.0, -3.2], radius: 0.06}
      - {kind: rod, from: [-2.6, -0.9, -2.7], to: [-2.6, 1.0, -2.7], radius: 0.06}
  - id: pallet_b
    shape: part
    pos: [2.6, 0, 10.0]
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: poly, points: [[1.75369, -0.63984], [1.90358, -0.63414], [1.83138, 1.26448], [1.68149, 1.25879]], y: [-0.95, -0.05], collide: 1, color: "#b85c38"}   # B's lifting face
      - {kind: poly, points: [[2.88956, -0.2464], [3.13938, -0.2369], [3.13558, -0.13697], [2.88576, -0.14647]], y: [0.05, 0.65], collide: 1, color: "#b85c38"}   # the stop E, on which a leg locks
      - {kind: disc, center: [2.6, 10.0], radius: 0.35, y: [-1.1, -0.6]}   # B's arbor
      - {kind: rod, from: [2.6, -0.9, 10.0], to: [3.46309, -0.9, -2.67064], radius: 0.07}   # its arm
      - {kind: rod, from: [3.20484, -0.9, 1.12058], to: [2.02757, -0.9, 1.04038], radius: 0.06}   # to its lifting face
      - {kind: rod, from: [3.46309, -0.9, -2.67064], to: [1.29261, 1.0, -3.62034], radius: 0.07}
      - {kind: rod, from: [1.29261, 1.0, -3.62034], to: [1.32659, 1.0, -4.11918], radius: 0.07}
      - {kind: disc, center: [1.32659, -4.11918], radius: 0.15, y: [0.75, 1.3], collide: 1, color: "#5c5348"}   # its fork-pin
      - {kind: disc, center: [4.89383, -3.07434], radius: 0.45, y: [0.7, 1.3], density: 120000.0, color: "#cfc6b4"}   # its weight
      - {kind: rod, from: [3.46309, 1.0, -2.67064], to: [4.89383, 1.0, -3.07434], radius: 0.06}
      - {kind: rod, from: [3.46309, -0.9, -2.67064], to: [3.46309, 1.0, -2.67064], 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.6, 10.0], radius: 0.15, y: [-1.2, -0.5], color: "#5c5348"}   # A's arbor's pin
      - {kind: disc, center: [2.6, 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.06801]}   # B; - : out (lifted); its banking at 0.06801 (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 sixth of a turn a beat
  - {type: advance, joint: j_wheel, beat: j_pend, expect: 1.0472, 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"}

