# No. 402 (Brown 1868): "G. O. Guernsey’s patent escapement for watches. In this escapement two balance-wheels are employed, carried by the same driving-power, but oscillating in opposite directions, for the purpose of counteracting the effect of any sudden jar upon a watch or time-piece. The jar which would accelerate motion of one wheel would retard the motion of other. Anchor, A, is secured to lever, B, having an interior and exterior toothed segment at its end, each one of which gears with the pinion of balance-wheels."
#
# Model (cm, a watch's plan, no gravity): the escape-wheel (30 teeth, tips r 5) is turned by a constant torque (the mainspring: the one input). The anchor A
# (No. 289's dead-beat pallets) is fast to the lever B, which ends in a toothed segment: its outer teeth (pitch radius 9) gear with the pinion (10 teeth)
# of one balance-wheel, its inner teeth (pitch radius 7.2) with the pinion (8) of the other, both 6 times the segment's turn. So the balances, each
# on its own hair-spring, swing in opposite directions, and a jar that would speed one would slow the other. Only the teeth touch (pallets on the wheel's
# teeth, segment on the pinions). Generator: opencode-runs/batch13/gen402.py.
number: 402
slug: guernsey-double-balance-escapement
name: Guernsey's escapement with two balance-wheels
brown: "G. O. Guernsey’s patent escapement for watches. In this escapement two balance-wheels are employed, carried by the same driving-power, but oscillating in opposite directions, for the purpose of counteracting the effect of any sudden jar upon a watch or time-piece. The jar which would accelerate motion of one wheel would retard the motion of other. Anchor, A, is secured to lever, B, having an interior and exterior toothed segment at its end, each one of which gears with the pinion of balance-wheels."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 60, duration_s: 12, floor: false, gravity: 0}
bodies:
  - id: wheel
    shape: part
    pos: [0, 0, 0]
    density: 8500
    friction: 0.1
    color: "#e6d7b0"
    pieces:
      - kind: wheel
        center: [0, 0]
        teeth: 30
        tooth: [[3.9, -0.0756], [3.9, -0.165], [4.45, -0.075], [5.0, 0]]
        phase: 1.78278
        root: 4.2
        rim: 3.6
        hub: 0.8
        spokes: 4
        spoke_width: 0.45
        y: [-0.25, 0.25]
        collide: 2
      - {kind: disc, center: [0, 0], radius: 0.25, y: [-0.7, 0.9], color: "#8f8a80"}
  - id: anchor
    shape: part
    pos: [-6.12373, 0, 3.53554]
    density: 8500
    friction: 0.1
    color: "#d9cfba"
    pieces:
      - {kind: disc, center: [-6.12373, 3.53554], radius: 0.6, y: [-0.6, 0.35]}   # the hub on the anchor's arbor
      - {kind: poly, points: [[-5.71432, 3.32367], [-1.2675, 5.12365], [-1.53014, 5.7725], [-5.97697, 3.97253]], y: [-0.3, 0.3]}   # the anchor A
      - {kind: poly, points: [[-6.42876, 3.18991], [-5.77573, -1.47472], [-5.08249, -1.37767], [-5.73552, 3.28696]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-1.47323, 5.94993], [-1.41162, 5.82737], [-1.76466, 5.65566], [-1.82165, 5.76904]], y: [-0.35, 0.35], collide: 1}   # its pallets (dead-beat locking faces)
      - {kind: poly, points: [[-1.41162, 5.82737], [-1.35324, 5.70323], [-1.71065, 5.54083], [-1.76466, 5.65566]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-1.35324, 5.70323], [-1.29813, 5.57761], [-1.65967, 5.42462], [-1.71065, 5.54083]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-1.29813, 5.57761], [-1.24633, 5.45059], [-1.61175, 5.30711], [-1.65967, 5.42462]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-1.24633, 5.45059], [-1.19787, 5.32226], [-1.56692, 5.1884], [-1.61175, 5.30711]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-1.19787, 5.32226], [-1.15279, 5.1927], [-1.52522, 5.06855], [-1.56692, 5.1884]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-1.15279, 5.1927], [-1.11111, 5.06201], [-1.48666, 4.94765], [-1.52522, 5.06855]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-1.11111, 5.06201], [-1.07287, 4.93027], [-1.45129, 4.82578], [-1.48666, 4.94765]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-1.46506, 4.87465], [-1.39946, 4.62075], [-1.07286, 4.93028], [-1.08775, 4.9831]], y: [-0.35, 0.35], collide: 1, color: "#b85c38"}
      - {kind: poly, points: [[-4.82757, -1.45147], [-4.95856, -1.48369], [-5.04733, -1.10128], [-4.92632, -1.07151]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-4.95856, -1.48369], [-5.09034, -1.51247], [-5.16908, -1.12786], [-5.04733, -1.10128]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-5.09034, -1.51247], [-5.22284, -1.53779], [-5.29148, -1.15126], [-5.16908, -1.12786]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-5.22284, -1.53779], [-5.35595, -1.55963], [-5.41445, -1.17144], [-5.29148, -1.15126]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-5.35595, -1.55963], [-5.48959, -1.57799], [-5.53791, -1.18839], [-5.41445, -1.17144]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-5.48959, -1.57799], [-5.62367, -1.59283], [-5.66177, -1.20211], [-5.53791, -1.18839]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-5.62367, -1.59283], [-5.75808, -1.60417], [-5.78594, -1.21258], [-5.66177, -1.20211]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-5.75808, -1.60417], [-5.89275, -1.61198], [-5.91035, -1.21979], [-5.78594, -1.21258]], y: [-0.35, 0.35], collide: 1}
      - {kind: poly, points: [[-4.87985, -1.46477], [-4.61127, -1.39019], [-4.92631, -1.07151], [-4.97462, -1.0838]], y: [-0.35, 0.35], collide: 1, color: "#b85c38"}
      - {kind: poly, points: [[-6.2037, 4.13228], [-6.70698, 3.38615], [-13.09057, 7.69193], [-12.58729, 8.43806]], y: [-0.3, 0.3]}   # the lever B
      - {kind: poly, points: [[-4.6586, 10.90123], [-4.42839, 12.05856], [-5.21695, 12.1781], [-5.34008, 11.00454]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-5.34008, 11.00454], [-5.21695, 12.1781], [-6.01314, 12.22483], [-6.02815, 11.04493]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-6.02815, 11.04493], [-6.01314, 12.22483], [-6.81026, 12.19837], [-6.71704, 11.02206]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-6.71704, 11.02206], [-6.81026, 12.19837], [-7.6016, 12.09894], [-7.40092, 10.93613]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-7.40092, 10.93613], [-7.6016, 12.09894], [-8.38049, 11.92738], [-8.07405, 10.78787]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-8.07405, 10.78787], [-8.38049, 11.92738], [-9.14038, 11.68513], [-8.73075, 10.57851]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-8.73075, 10.57851], [-9.14038, 11.68513], [-9.87485, 11.37423], [-9.36549, 10.30983]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-9.36549, 10.30983], [-9.87485, 11.37423], [-10.57772, 10.99731], [-9.97292, 9.98409]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-9.97292, 9.98409], [-10.57772, 10.99731], [-11.24308, 10.55753], [-10.54793, 9.60402]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-10.54793, 9.60402], [-11.24308, 10.55753], [-11.86531, 10.0586], [-11.08567, 9.17284]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-11.08567, 9.17284], [-11.86531, 10.0586], [-12.43918, 9.50472], [-11.58162, 8.69417]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-11.58162, 8.69417], [-12.43918, 9.50472], [-12.95985, 8.90056], [-12.03159, 8.17205]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-12.03159, 8.17205], [-12.95985, 8.90056], [-13.42294, 8.25121], [-12.43179, 7.61088]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-12.43179, 7.61088], [-13.42294, 8.25121], [-13.82454, 7.56214], [-12.77886, 7.01537]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-12.77886, 7.01537], [-13.82454, 7.56214], [-14.16128, 6.83915], [-13.06987, 6.39056]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.06987, 6.39056], [-14.16128, 6.83915], [-14.43031, 6.08833], [-13.30237, 5.74169]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.30237, 5.74169], [-14.43031, 6.08833], [-14.62937, 5.31601], [-13.47441, 5.07424]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.47441, 5.07424], [-14.62937, 5.31601], [-14.75679, 4.52869], [-13.58452, 4.39383]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.58452, 4.39383], [-14.75679, 4.52869], [-14.81148, 3.733], [-13.63179, 3.70619]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.63179, 3.70619], [-14.81148, 3.733], [-14.793, 2.93566], [-13.61581, 3.01711]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.61581, 3.01711], [-14.793, 2.93566], [-14.70149, 2.14336], [-13.53673, 2.3324]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.53673, 2.3324], [-14.70149, 2.14336], [-14.53772, 1.36279], [-13.3952, 1.65783]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.3952, 1.65783], [-14.53772, 1.36279], [-14.30308, 0.60053], [-13.19242, 0.99907]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.19242, 0.99907], [-14.30308, 0.60053], [-13.99954, -0.13702], [-12.9301, 0.36167]], y: [-0.3, 0.3]}
      - {kind: poly, points: [[-13.55706, 8.00875], [-13.85629, 7.46892], [-14.25425, 7.92671], [-14.15618, 8.10364]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-6.47801, 10.48725], [-6.67986, 10.47402], [-6.92416, 11.02923], [-6.30827, 11.0696]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-13.98392, 7.20725], [-14.22509, 6.6391], [-14.66871, 7.05279], [-14.58967, 7.23899]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-7.38236, 10.38153], [-7.58075, 10.34207], [-7.89543, 10.86064], [-7.29008, 10.98105]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-14.32466, 6.36552], [-14.50512, 5.77528], [-14.98955, 6.14033], [-14.93041, 6.33377]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-8.26517, 10.15868], [-8.45672, 10.09366], [-8.83639, 10.56672], [-8.25194, 10.76512]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-14.57555, 5.49278], [-14.69332, 4.88691], [-15.21326, 5.19933], [-15.17466, 5.39789]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-9.11134, 9.8225], [-9.29277, 9.73304], [-9.73094, 10.15249], [-9.17738, 10.42548]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-14.73384, 4.59861], [-14.78763, 3.98374], [-15.33738, 4.2401], [-15.31975, 4.44161]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-9.9064, 9.37876], [-10.07459, 9.26637], [-10.56377, 9.62505], [-10.05057, 9.96795]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-14.79779, 3.69278], [-14.78702, 3.07566], [-15.36055, 3.27315], [-15.36408, 3.4754]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-10.63673, 8.83503], [-10.78882, 8.70165], [-11.32062, 8.99341], [-10.85658, 9.40037]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-14.76671, 2.78523], [-14.69149, 2.17262], [-15.28253, 2.30907], [-15.30718, 2.50985]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-11.28984, 8.20062], [-11.42322, 8.04854], [-11.98856, 8.26839], [-11.5816, 8.73243]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-14.64094, 1.88591], [-14.50209, 1.28451], [-15.10415, 1.35844], [-15.14966, 1.55554]], y: [-0.3, 0.3], collide: 1}
      - {kind: poly, points: [[-11.85456, 7.4864], [-11.96695, 7.31821], [-12.55614, 7.46238], [-12.21324, 7.97558]], y: [-0.3, 0.3], collide: 1}
  - id: bal1
    shape: part
    pos: [-16.55125, 0, 5.00103]
    density: 8500
    friction: 0.1
    color: "#c9b27a"
    pieces:
      - {kind: poly, points: [[-15.43558, 4.53259], [-15.34969, 5.1438], [-14.81411, 4.85902], [-14.84226, 4.65871]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-15.37332, 5.27783], [-15.66308, 5.82279], [-15.0624, 5.90721], [-14.96744, 5.7286]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-15.76098, 5.91733], [-16.31573, 6.1879], [-15.87939, 6.60927], [-15.69758, 6.52059]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-16.4505, 6.20684], [-17.05833, 6.09966], [-16.953, 6.69703], [-16.75379, 6.73216]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-17.1785, 6.03577], [-17.60725, 5.59179], [-17.87316, 6.13698], [-17.73264, 6.28249]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-17.66691, 5.46946], [-17.75281, 4.85826], [-18.28839, 5.14303], [-18.26024, 5.34335]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-17.72918, 4.72423], [-17.43942, 4.17926], [-18.04009, 4.09484], [-18.13506, 4.27345]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-17.34152, 4.08472], [-16.78677, 3.81415], [-17.22311, 3.39279], [-17.40492, 3.48146]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-16.652, 3.79521], [-16.04416, 3.90239], [-16.1495, 3.30503], [-16.34871, 3.2699]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-15.924, 3.96629], [-15.49525, 4.41027], [-15.22934, 3.86508], [-15.36986, 3.71957]], y: [-0.4, 0.4], collide: 2}
      - {kind: disc, center: [-16.55125, 5.00103], radius: 1.15, y: [-0.4, 0.4]}   # the pinion's core
      - {kind: disc, center: [-16.55125, 5.00103], radius: 7.0, inner: 6.55, y: [0.7, 1.0], color: "#d9c58f"}   # the balance's rim
      - {kind: rod, from: [-23.25125, 0.85, 5.00103], to: [-9.85125, 0.85, 5.00103], radius: 0.18, color: "#d9c58f"}   # its arm
      - {kind: rod, from: [-16.55125, -0.6, 5.00103], to: [-16.55125, 1.3, 5.00103], radius: 0.22, color: "#8f8a80"}   # its staff
  - id: bal2
    shape: part
    pos: [-9.10873, 0, 8.70571]
    density: 8500
    friction: 0.1
    color: "#c9b27a"
    pieces:
      - {kind: poly, points: [[-9.27647, 9.61345], [-9.81099, 9.30485], [-9.91632, 9.90221], [-9.74113, 10.00335]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-9.86921, 9.22897], [-10.02895, 8.63279], [-10.52584, 8.98071], [-10.47348, 9.1761]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-10.01647, 8.53797], [-9.70787, 8.00345], [-10.30523, 7.89811], [-10.40637, 8.0733]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-9.63199, 7.94522], [-9.03581, 7.78548], [-9.38373, 7.2886], [-9.57912, 7.34095]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-8.94099, 7.79796], [-8.40647, 8.10657], [-8.30113, 7.5092], [-8.47632, 7.40806]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-8.34824, 8.18244], [-8.1885, 8.77862], [-7.69162, 8.4307], [-7.74397, 8.23531]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-8.20098, 8.87345], [-8.50959, 9.40797], [-7.91222, 9.5133], [-7.81108, 9.33811]], y: [-0.4, 0.4], collide: 2}
      - {kind: poly, points: [[-8.58546, 9.46619], [-9.18164, 9.62594], [-8.83372, 10.12282], [-8.63833, 10.07046]], y: [-0.4, 0.4], collide: 2}
      - {kind: disc, center: [-9.10873, 8.70571], radius: 0.85, y: [-0.4, 0.4]}   # the pinion's core
      - {kind: disc, center: [-9.10873, 8.70571], radius: 7.0, inner: 6.55, y: [1.5, 1.8], color: "#d9c58f"}   # the balance's rim
      - {kind: rod, from: [-15.80873, 1.65, 8.70571], to: [-2.40873, 1.65, 8.70571], radius: 0.18, color: "#d9c58f"}   # its arm
      - {kind: rod, from: [-9.10873, -0.6, 8.70571], to: [-9.10873, 2.1, 8.70571], radius: 0.22, color: "#8f8a80"}   # its staff
  - id: plate
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: disc, center: [-6.12373, 3.53554], radius: 0.18, y: [-0.8, 0.6], color: "#8f8a80"}
joints:
  - {id: j_wheel, type: hinge, body: wheel, axis: [0, 1, 0], damping: 0.00002}   # the escape-wheel; - : counter-clockwise (its way)
  - {id: j_anc, type: hinge, body: anchor, axis: [0, 1, 0], damping: 0.0002}   # the anchor A and lever B
  - {id: j_b1, type: hinge, body: bal1, axis: [0, 1, 0], damping: 2e-05, stiffness: 0.012}   # the balance on the segment's outer teeth, on its hair-spring
  - {id: j_b2, type: hinge, body: bal2, axis: [0, 1, 0], damping: 2e-05, stiffness: 0.012}   # the balance on the inner teeth, on its hair-spring
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_wheel, kind: torque, torque: -0.02, max_torque: 0.05}
checks:
  - {type: advance, joint: j_wheel, beat: j_b1, expect: -0.10472, tol: 0.05, settle_s: 2, window_s: 9.5}   # half a tooth (2 pi / 30 / 2) each beat of the balances
  - {type: period, joint: j_b1, expect_s: 0.93, tol: 0.05, settle_s: 2, window_s: 9.5}
  - {type: amplitude, joint: j_b1, min: 0.35, max: 0.8, settle_s: 4, window_s: 7.5}
  - {type: follow, out: j_b1, in: j_anc, expect: -6.0, tol: 0.7, settle_s: 2, window_s: 9.5}   # outer pitch radius 9 over pinion 1.5 (the shake in the teeth takes a little)
  - {type: follow, out: j_b2, in: j_anc, expect: 6.0, tol: 0.7, settle_s: 2, window_s: 9.5}   # inner pitch radius 7.2 over pinion 1.2, the other way
  - {type: follow, out: j_b2, in: j_b1, expect: -1.0, tol: 0.05, settle_s: 2, window_s: 9.5}   # the two balances always swing opposite ways
  - {type: penetration, max: 0.0005, settle_s: 1}
camera: {target: [-9, 0, 2], position: [-9, -49, 2], fov: 34}
display:
  output: j_b1
  swing: j_b1
  labels: {j_wheel: "Escape-wheel (mainspring)", j_anc: "Anchor A and lever B", j_b1: "Balance (outer teeth)", j_b2: "Balance (inner teeth)"}
  proof: {label: "Pallets out of contact", sub: "nothing makes good the balances' losses, so their swing dies away, and the mainspring spins the wheel freely"}

