# No. 296 (Brown 1868): "Lever escapement. The anchor or piece, B, which carries the pallets, is attached to lever, E, C, at one end of which is a notch, E. On a disk secured on the arbor of balance is fixed a small pin which enters the notch at the middle of each vibration, causing the pallet to enter in and retire from between the teeth of escape-wheel. The wheel gives an impulse to each of the pallets alternately as it leaves a tooth, and the lever gives impulse to the balance-wheel in opposite directions alternately."
#
# Model (cm, a plan of the watch: gravity off). The escape-wheel (15 ratchet teeth, tips r 3, clockwise) at the origin. The anchor B, 3.464 above it, carries the
# pallets, which embrace 2 1/2 teeth: each stone's locking face, where a tooth's point rests, leans -12 degrees so the tooth draws the pallet in (the draw);
# the stone's end is the impulse face, rising 0.3. The lever E C (6 long) has the notch E at its end, and two banking pins stop it at the ends of its travel
# (16.9 degrees; the joint's range). The balance's axis is 2 beyond the notch: on its disk is the pin, which enters the notch at the middle of each
# vibration, unlocks the pallet, and takes the impulse back through the notch. Only the wheel is driven (the mainspring). The balance is set going by hand: let go
# 2 rad from its rest. Generator: opencode-runs/batch12/gen296.py.
number: 296
slug: lever-escapement
name: Lever escapement
brown: "Lever escapement. The anchor or piece, B, which carries the pallets, is attached to lever, E, C, at one end of which is a notch, E. On a disk secured on the arbor of balance is fixed a small pin which enters the notch at the middle of each vibration, causing the pallet to enter in and retire from between the teeth of escape-wheel. The wheel gives an impulse to each of the pallets alternately as it leaves a tooth, and the lever gives impulse to the balance-wheel in opposite directions alternately."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 50, duration_s: 12, floor: false, gravity: 0}
bodies:
  - id: wheel
    shape: part
    pos: [0, 0, 0]
    mass: 0.003
    friction: 0.1
    color: "#e6d7b0"
    pieces:
      - {kind: disc, center: [0, 0], radius: 2.12, inner: 1.7, y: [-0.15, 0.15]}   # the rim
      - {kind: disc, center: [0, 0], radius: 0.5, y: [-0.15, 0.15]}   # the hub
      - {kind: poly, points: [[0.45962, 0.10607], [1.37886, 1.0253], [1.0253, 1.37886], [0.10607, 0.45962]], y: [-0.15, 0.15]}   # a spoke
      - {kind: poly, points: [[-0.10607, 0.45962], [-1.0253, 1.37886], [-1.37886, 1.0253], [-0.45962, 0.10607]], y: [-0.15, 0.15]}   # a spoke
      - {kind: poly, points: [[-0.45962, -0.10607], [-1.37886, -1.0253], [-1.0253, -1.37886], [-0.10607, -0.45962]], y: [-0.15, 0.15]}   # a spoke
      - {kind: poly, points: [[0.10607, -0.45962], [1.0253, -1.37886], [1.37886, -1.0253], [0.45962, -0.10607]], y: [-0.15, 0.15]}   # a spoke
      - {kind: disc, center: [0, 0], radius: 0.2, y: [-0.6, 0.6], color: "#8f8a80"}   # its arbor
      - {kind: poly, points: [[-1.73357, 2.44841], [-1.52959, 1.43888], [-1.7265, 1.19549], [-1.74525, 2.29096]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[-2.57956, 1.53163], [-1.98259, 0.69234], [-2.06349, 0.3899], [-2.52618, 1.38304]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[-2.97951, 0.35001], [-2.09279, -0.17391], [-2.04368, -0.4831], [-2.87032, 0.23598]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[-2.86428, -0.89212], [-1.84112, -1.01009], [-1.67049, -1.27258], [-2.71815, -0.95188]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[-2.25379, -1.98001], [-1.27111, -1.67161], [-1.00847, -1.84201], [-2.09599, -1.97516]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[-1.2536, -2.72552], [-0.48131, -2.0441], [-0.17207, -2.09294], [-1.11141, -2.65691]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[-0.03665, -2.99978], [0.39171, -2.06314], [0.69408, -1.98198], [0.06534, -2.87926]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[1.18664, -2.75534], [1.197, -1.72545], [1.44022, -1.52832], [1.23079, -2.60376]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[2.20474, -2.03448], [1.79532, -1.08941], [1.93733, -0.8104], [2.18343, -1.87804]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[2.84163, -0.96184], [2.08321, -0.26501], [2.09946, 0.04764], [2.75853, -0.8276]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[2.98717, 0.27711], [2.0109, 0.60522], [1.89857, 0.89745], [2.85666, 0.36595]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[2.61621, 1.46815], [1.59088, 1.3708], [1.36941, 1.59208], [2.46084, 1.49622]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[1.79288, 2.40533], [0.89578, 1.89936], [0.60346, 2.01143], [1.63953, 2.36777]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[0.65954, 2.9266], [0.0458, 2.0995], [-0.26684, 2.08298], [0.53472, 2.82992]], y: [-0.15, 0.15], collide: 2}   # a tooth
      - {kind: poly, points: [[-0.58784, 2.94184], [-0.8121, 1.93662], [-1.09099, 1.79436], [-0.66254, 2.80276]], y: [-0.15, 0.15], collide: 2}   # a tooth
  - id: anchor
    shape: part
    pos: [0, 0, 3.4641]
    mass: 0.004
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: disc, center: [0, 3.4641], radius: 0.35, y: [-0.5, 0.5], color: "#8f8a80"}   # the anchor's arbor B
      - {kind: poly, points: [[0.03324, 3.32811], [-1.65067, 2.9165], [-1.71716, 3.18849], [-0.03324, 3.6001]], y: [-0.25, -0.05]}   # an arm of the anchor
      - {kind: poly, points: [[-0.00429, 3.60404], [1.87473, 3.6617], [1.88332, 3.38183], [0.00429, 3.32417]], y: [-0.25, -0.05]}   # an arm of the anchor
      - {kind: poly, points: [[-1.63469, 2.33458], [-1.07768, 2.31108], [-1.47916, 3.17208], [-1.88867, 2.93291]], y: [-0.15, 0.15], collide: 1, color: "#b85c38"}   # the entry pallet
      - {kind: poly, points: [[1.40834, 2.97045], [1.79879, 2.5725], [2.0944, 3.47533], [1.66366, 3.5682]], y: [-0.15, 0.15], collide: 1, color: "#b85c38"}   # the exit pallet
      - {kind: poly, points: [[-0.16271, 3.74325], [0.07469, 3.77846], [-0.71011, 9.07058], [-0.94752, 9.03538]], y: [0.2, 0.4]}   # the lever E C
      - {kind: poly, points: [[-1.09367, 8.86206], [-0.51995, 8.94714], [-0.54195, 9.09552], [-1.11568, 9.01044]], y: [0.2, 0.4]}   # the notch's bottom
      - {kind: poly, points: [[-1.11568, 9.01044], [-0.93763, 9.03684], [-1.01522, 9.56011], [-1.19328, 9.53371]], y: [0.2, 0.4], collide: 1}   # the notch E: a horn
      - {kind: poly, points: [[-0.72001, 9.06912], [-0.54195, 9.09552], [-0.61955, 9.61879], [-0.7976, 9.59238]], y: [0.2, 0.4], collide: 1}   # the notch E: a horn
  - id: balance
    shape: part
    pos: [0, 0, 11.4641]
    mass: 0.1
    friction: 0.1
    color: "#d9c49a"
    pieces:
      - {kind: disc, center: [0, 11.4641], radius: 3.6, inner: 3.1, y: [0.85, 1.15]}   # the balance-wheel's rim
      - {kind: poly, points: [[0.21037, 11.20286], [2.84733, 9.99604], [2.97217, 10.26883], [0.33521, 11.47565]], y: [0.85, 1.15]}   # an arm of the balance-wheel
      - {kind: poly, points: [[0.12106, 11.7769], [-0.15228, 14.66399], [-0.45095, 14.63572], [-0.17761, 11.74863]], y: [0.85, 1.15]}   # an arm of the balance-wheel
      - {kind: poly, points: [[-0.33142, 11.41254], [-2.69505, 9.73227], [-2.52123, 9.48776], [-0.1576, 11.16802]], y: [0.85, 1.15]}   # an arm of the balance-wheel
      - {kind: disc, center: [0, 11.4641], radius: 0.25, y: [0.0, 1.3], color: "#8f8a80"}   # its arbor
      - {kind: disc, center: [0, 11.4641], radius: 2.25, y: [0.55, 0.65], color: "#cfc6b4"}   # the disk
      - {kind: disc, center: [-1.81859, 12.2964], radius: 0.08, y: [0.15, 0.65], collide: 2, color: "#b85c38"}   # the pin
  - id: plate
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8f8a80"
    pieces:
      - {kind: disc, center: [-0.95142, 8.1755], radius: 0.12, y: [0.2, 0.6]}   # a banking pin
      - {kind: disc, center: [0.95142, 8.1755], radius: 0.12, y: [0.2, 0.6]}   # a banking pin
joints:
  - {id: j_wheel, type: hinge, body: wheel, axis: [0, 1, 0], damping: 0.000003}   # the escape-wheel; + : clockwise (its way)
  - {id: j_anchor, type: hinge, body: anchor, axis: [0, 1, 0], range: [-0.002, 0.29645], damping: 1e-05, frictionloss: 0.0003}   # the anchor and lever; + : clockwise; the range is the banking pins
  - {id: j_bal, type: hinge, body: balance, axis: [0, 1, 0], stiffness: 0.0028, springref: -2.0, damping: 3e-06}   # the balance and its spring; + : clockwise
contact: {solref: [0.001, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
# The mainspring: a constant torque on the escape-wheel, clockwise. Nothing else is driven.
driver: {joint: j_wheel, kind: torque, torque: 0.0038, max_torque: 0.05}
checks:
  - {type: advance, joint: j_wheel, beat: j_bal, expect: 0.20944, tol: 0.03, settle_s: 3, window_s: 8.6}
  - {type: period, joint: j_bal, expect_s: 1.01868, tol: 0.03, settle_s: 3, window_s: 8}
  - {type: amplitude, joint: j_bal, min: 1.2, max: 3.0, sustain: 0.9, settle_s: 3, window_s: 8}
  - {type: penetration, max: 0.0005, settle_s: 1}
camera: {target: [0, 0, 2.8], position: [0, -80.0, 2.8], fov: 30}
display:
  output: j_wheel
  swing: j_bal
  labels: {j_wheel: "Escape-wheel (mainspring)", j_bal: "Balance", j_anchor: "Lever"}
  proof: {label: "Pallets and pin out of contact", sub: "nothing makes good the balance's losses, so its swing dies away, and the mainspring spins the wheel freely"}

