# No. 290 (Brown 1868): "Another kind of pendulum escapement."
#
# Model (cm, gravity on), as Brown draws it: the pendulum hangs from its suspension C, 11 above the axis D of the escape-wheel, and is a ring K round the wheel, its rod
# going on below to the bob. Two pallets on the inside of the ring, A on the right and B on the left, reach in to 2.85 from D, so at rest each stands 0.15 into the path of the
# teeth (tips r 3, 5 teeth H, turning clockwise as Brown's arrow). As the pendulum swings the ring to and fro, the pallets go in and out of the teeth in turn: swung left,
# A stands in and a tooth coming down on the right lands on it; swung right, A comes out and lets the tooth go, and B, now in, catches a tooth coming up on the left; and so on.
# Each pallet's face slopes 30 degrees, outward toward the ring, so the tooth pushes the pallet out as it comes out: that is the pendulum's impulse (and, while the
# pallet goes on in, the recoil). The wheel goes half a tooth a beat. The only input is a constant torque on the wheel (the clock's weight). The pendulum (a hinge at C: Brown's
# suspension spring is drawn but not modelled) swings under gravity and is kept going only by the teeth pressing on the pallets. Generator: opencode-runs/batch12/gen290.py.
number: 290
slug: ring-pendulum-escapement
name: Another kind of pendulum escapement
brown: "Another kind of pendulum escapement."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 50, duration_s: 12, floor: false}
bodies:
  - id: wheel
    shape: part
    pos: [0, 0, 0]
    density: 8500
    friction: 0.1
    color: "#e6d7b0"
    pieces:
      - kind: wheel
        center: [0, 0]
        teeth: 5
        tooth: [[3.0, 0], [1.3, 0], [1.3, 1.15611]]   # one tooth H: its face radial, leading clockwise; its back sloped
        phase: 0.10472
        root: 1.35
        rim: 0.95
        hub: 0.4
        spokes: 3
        spoke_width: 0.3
        y: [-0.3, 0.3]
        collide: 2
      - {kind: disc, center: [0, 0], radius: 0.25, y: [-0.8, 0.9], color: "#8f8a80"}   # the axis D
  - id: pendulum
    shape: part
    pos: [0, 0, 11.0]
    density: 7800
    friction: 0.1
    color: "#9aa3ad"
    pieces:
      - {kind: disc, center: [0, 0], radius: 4.6, inner: 4.0, y: [-0.35, 0.35]}   # the ring K
      - {kind: poly, points: [[2.85, 0.0], [4.1, 0.72169], [4.1, -0.5], [2.85, -0.5]], y: [-0.35, 0.35], collide: 1, color: "#b85c38"}   # the pallet A
      - {kind: poly, points: [[-2.85, -0.0], [-4.1, -0.72169], [-4.1, 0.5], [-2.85, 0.5]], y: [-0.35, 0.35], collide: 1, color: "#b85c38"}   # the pallet B
      - {kind: rod, from: [0, 0, 4.5], to: [0, 0, 10.6], radius: 0.18, color: "#8f8a80"}   # the rod up to C
      - {kind: poly, points: [[-0.12, 10.6], [0.12, 10.6], [0.12, 12.6], [-0.12, 12.6]], y: [-0.3, 0.3], density: 100, color: "#5c5348"}   # the suspension spring C
      - {kind: rod, from: [0, 0, -4.5], to: [0, 0, -8.1], radius: 0.3, color: "#8f8a80"}   # the rod down to the bob
      - {kind: disc, center: [0, -9.5], radius: 1.6, y: [-0.6, 0.6], density: 8500, color: "#e6d7b0"}   # the bob
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.4, 12.6], [1.4, 12.6], [1.4, 13.6], [-1.4, 13.6]], y: [-0.8, 0.8]}   # the clamp of the suspension
      - {kind: poly, points: [[-1.0, -0.8], [1.0, -0.8], [1.0, 0.8], [-1.0, 0.8]], y: [0.9, 1.3]}   # the cock behind D
joints:
  - {id: j_wheel, type: hinge, body: wheel, axis: [0, 1, 0], damping: 0.00002}   # the escape-wheel; + : clockwise (its way)
  - {id: j_pend, type: hinge, body: pendulum, axis: [0, 1, 0], damping: 0.001}   # the pendulum at C (air and spring losses); + : swung left at the ring
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
# The clock's weight: a constant torque on the escape-wheel, clockwise. Nothing else is driven.
driver: {joint: j_wheel, kind: torque, torque: 0.004, max_torque: 0.05}
checks:
  # half a tooth (2 pi/5 / 2) per beat
  - {type: advance, joint: j_wheel, beat: j_pend, expect: 0.62832, tol: 0.03, settle_s: 4, window_s: 6}
  # the swing is kept up by the teeth alone
  - {type: amplitude, joint: j_pend, min: 0.04, max: 0.08, sustain: 0.9, settle_s: 4, window_s: 6}
  # the sloped faces make it a recoil escapement: the wheel turns back a little while each pallet goes on in, never more than this
  - {type: monotonic, joint: j_wheel, direction: 1, max_back: 0.1, settle_s: 2, window_s: 8}
  - {type: penetration, max: 0.0005, settle_s: 1}
camera: {target: [0, 0, -4.7], position: [0.0, -89.5, -4.7], fov: 30}
display:
  output: j_pend
  swing: j_pend
  labels: {j_wheel: "Escape-wheel D (weight)", j_pend: "Pendulum and ring K"}
  proof: {label: "Pallets out of contact", sub: "nothing makes good the pendulum's losses, so its swing dies away, and the weight spins the wheel freely"}

