# No. 23, A contrivance for transmitting rotary motion to a movable pulley (Brown 1868, p. 3).
#
# "The pulley at the bottom of the figure is the movable one; if this pulley were raised or depressed,
# the belt would be slackened or tightened accordingly. In order to keep a uniform tension on the
# belt, a pulley, A, carried in a frame sliding between guides (not shown), hangs from a rope passing
# over the two guide-pulleys, B, B, and is acted upon by the balance weight, C, in such manner as to
# produce the desired result."
#
# Layout from the plate (1 unit = 1 cm, the driver r 8 = 40 px of the engraving): the large driving
# pulley at the left, the movable pulley at the bottom right of it, and the tension pulley A above
# between them; A hangs in a yoke frame from a rope that goes plumb up over guide pulley B, across to
# the other B and down to the balance weight C. The belt is a closed loop through all three pulleys
# on the convex hull of them, exactly as the plate draws it: down the driver's right side, under the
# movable pulley, up from it to A, over A's top and back to the driver.
#
# Fully physical: only the driver is motor-driven. The belt is a closed chain of elastic leather
# links that turns the movable pulley by friction alone (its bearing brake is the load). A rides a
# vertical guide and hangs in a real rope over B, B to C on its own vertical guide: C's weight is
# what keeps the tension up. A, the pulleys and C balance so that the belt tension settles at
# T = (W_C - W_A)/(sin a + sin b), the vertical pull of the belt's two strands on A - it is set by
# C, not by the belt's path, so when the movable pulley is raised or lowered (variants `raised` and
# `low`, a screwed collar on its slide) A moves and C moves the other way and the tension, and with
# it the driven ratio, does not change.
number: 23
slug: a-contrivance-for-transmitting-rotary-motion-to-a-movable-pulley
name: A contrivance for transmitting rotary motion to a movable pulley
brown: "The pulley at the bottom of the figure is the movable one; if this pulley were raised or depressed, the belt would be slackened or tightened accordingly. In order to keep a uniform tension on the belt, a pulley, A, carried in a frame sliding between guides (not shown), hangs from a rope passing over the two guide-pulleys, B, B, and is acted upon by the balance weight, C, in such manner as to produce the desired result."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 25, duration_s: 2.8}
bodies:
  - {id: driver, shape: pulley, radius: 8, width: 4, pos: [0, 0, 12], mass: 3.0, spokes: 4, hub: 2.4}
  # The movable pulley: driven by the belt; its slide carries a screwed collar at any height (a stiff
  # spring with the collar's ref: 0 = the drawing's position, the `raised` variant 6 cm up).
  - {id: movable, shape: pulley, radius: 5.5, width: 3.6, pos: [43, 0, -7], mass: 1.2, spokes: 4, hub: 1.5,
     spin: {damping: 0.002, frictionloss: 0.06}, color: "#e6dcc6"}
  # A's yoke frame: the straps ride a vertical guide, and A itself turns in it on its axle.
  - id: Aframe
    shape: part
    pos: [34, 0, 16]
    mass: 0.25
    color: "#8f8a80"
    pieces:
      # the yoke: two straps just outside the wheel's face, from a bearing boss below up to the eye
      - {kind: disc, center: [34, 14.9], radius: 2.1, inner: 1.7, y: [1.7, 2.3], collide: 0}
      - {kind: disc, center: [34, 14.9], radius: 2.1, inner: 1.7, y: [-2.3, -1.7], collide: 0}
      - {kind: rod, from: [34, 2.0, 14.9], to: [34, 2.0, 21.2], radius: 0.34, collide: 0}
      - {kind: rod, from: [34, -2.0, 14.9], to: [34, -2.0, 21.2], radius: 0.34, collide: 0}
      - {kind: disc, center: [34, 21.2], radius: 0.9, inner: 0.42, y: [-2.0, 2.0], collide: 0}
  # A itself, turning in the yoke.
  - {id: A, shape: pulley, radius: 4.5, width: 3.2, pos: [34, 0, 16], mass: 0.6, spokes: 0, hub: 1.5, flange: 0.5, mount: Aframe, color: "#e6dcc6"}
  # The two guide pulleys B, hung on the jib; the rope passes over them in the drawing's plane.
  - {id: B1, shape: pulley, radius: 2, width: 2, pos: [34, 0, 28], mass: 0.8, spokes: 0, hub: 0.8, flange: 0.4, color: "#e6dcc6"}
  - {id: B2, shape: pulley, radius: 2, width: 2, pos: [51, 0, 28], mass: 0.8, spokes: 0, hub: 0.8, flange: 0.4, color: "#e6dcc6"}
  # The jib: a rail above the guide pulleys, carried on two stems, drawing their hangers.
  - id: jib
    shape: part
    fixed: true
    pos: [0, 0, 0]
    color: "#cdc0a4"
    pieces:
      - {kind: poly, points: [[30.0, 31.4], [56.8, 31.4], [56.8, 32.4], [30.0, 32.4]], y: [-3.4, -2.6], collide: 0}
      - {kind: rod, from: [34, -2.4, 31.4], to: [34, -2.4, 28.4], radius: 0.34, collide: 0}
      - {kind: disc, center: [34, 28.4], radius: 0.8, inner: 0.42, y: [-2.6, -2.0], collide: 0}
      - {kind: rod, from: [51, -2.4, 31.4], to: [51, -2.4, 28.4], radius: 0.34, collide: 0}
      - {kind: disc, center: [51, 28.4], radius: 0.8, inner: 0.42, y: [-2.6, -2.0], collide: 0}
  # The balance weight C on its own vertical guide.
  - {id: weight_C, shape: weight, pos: [53, 0, 12], mass: 9.0, size: [4, 4, 7], taper: 0.22, color: "#b98f67"}
joints:
  - {id: j_driver, type: hinge, body: driver, axis: [0, 1, 0], damping: 0.002}
  - {id: j_A, type: slide, body: Aframe, axis: [0, 0, 1], range: [-6, 12], damping: 40}
  - {id: j_Ap, type: hinge, body: A, axis: [0, 1, 0], damping: 0.001}
  - {id: j_B1, type: hinge, body: B1, axis: [0, 1, 0], damping: 0.01}
  - {id: j_B2, type: hinge, body: B2, axis: [0, 1, 0], damping: 0.01}
  - {id: j_C, type: slide, body: weight_C, axis: [0, 0, 1], range: [-13, 4], damping: 60}
  - {id: j_movable, type: slide, body: movable, axis: [0, 0, 1], range: [-4, 8], stiffness: 8000, springref: 0, damping: 80}
belts:
  - id: belt
    around: [driver, movable, A]
    links: 52
    thickness: 0.4
    width: 3.2
    density: 950
    stiffness: 100000     # N/m per link
    damping: 2
    pretension: 84        # N: the tension C's weight holds it at in steady running (5.0 cm of stretch)
    friction: 0.6         # leather on iron
cords:
  # The rope: A's yoke eye plumb up over B1, across to B2 and down to C's hook.
  - id: rope
    from: {body: Aframe, at: [34, 0, 21.2]}
    to: {body: weight_C, at: [53, 0, 15.5]}
    over: [B1, B2]
    links: 34
    thickness: 0.8
    density: 1400          # hemp
    stiffness: 400000      # N/m per link: a rope is nearly inextensible
    pretension: 88         # N, what it carries in steady running: C's full weight (88.3 N)
    damping: 600
    friction: 0.5          # hemp on sheaves
contact: {solref: [0.0006, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_driver, kind: velocity, rpm: 30, kv: 4, max_torque: 8}
# Passive configurations: the same machine with the movable pulley screwed higher on its slide.
variants:
  - id: low
    note: "the movable pulley at the drawing's position (collar ref 0), the belt as the plate shows it"
    springref: {j_movable: 0}
  - id: raised
    note: "the movable pulley 6 cm up its slide: the belt path is shorter, so A rises and C falls, the tension staying the same"
    springref: {j_movable: 6}
variant: low
checks:
  # The driven ratio is the radii at the belt's pitch line (half its 0.4 thickness out): the movable
  # pulley turns (8 + 0.2)/(5.5 + 0.2) = 1.4386 times as fast, the same way, less a little creep
  # (the load is the movable pulley's own bearing brake, 0.06 N·m).
  - {type: ratio, out: movable_spin, in: j_driver, expect: 1.4386, tol: 0.045, settle_s: 1.2, window_s: 1.5}
  # A and C settle on C's weight: A rises 1.5 units above its drawn mark (the belt carries the
  # strands' vertical pull), C stands 1.1 units lower for the same reason. The per-variant
  # equilibria are in test_movements.py.
  - {type: position, joint: j_A, min: 0.9, max: 2.3, settle_s: 1.4, window_s: 1.4}
  - {type: position, joint: j_C, min: -2.1, max: -0.4, settle_s: 1.4, window_s: 1.4}
  - {type: belt_on, belt: belt, max_radial_dev: 2.2, max_lateral: 0.5, duration_s: 2.8}
  - {type: penetration, max: 0.0014, settle_s: 1.2}
camera: {target: [27, 0, 10], position: [60, -165, 26], fov: 30}
display:
  output: movable_spin
  labels: {j_driver: Driving pulley, j_movable: Movable pulley (driven), j_A: Tension pulley A, j_B1: Guide pulley B, j_B2: Guide pulley B, j_C: Balance weight C}
  expect: {default: 1.4386, low: 1.4386, raised: 1.4386}
