# No. 22, Different arrangements of pulleys (Brown 1868, plate VII, fig. 22).
#
# "19, 20, 21 and 22. Are different arrangements of pulleys. The following rule applies to these
# pulleys: - In a system of pulleys where each pulley is embraced by a cord attached at one end to a
# fixed point and at the other to the center of the movable pulley, the effect of the whole will be =
# the number 2, multiplied by itself as many times as there are movable pulleys in the system."
#
# The plate: a ceiling carrying three eyes on the left (one per movable pulley's cord) and a hook on
# the right that carries the fixed pulley F. Three movable pulleys rise in a stair to the right - P1,
# P2, P3 - each pulled up in the bight of its own cord, weight W hung on P1's centre hook. Each cord
# runs from a ceiling eye, down the left side of "its" pulley, under it, straight up again, and is
# made fast to an eye on the next pulley above (cord 3 goes up over F and down to the hand on the
# right). The pulleys are staggered exactly one diameter, 14 cm, right for each stage, so every
# strand hangs plumb and the cords pass clear of the pulleys below them on the outer sides.
#
#   Reading the stair, as the hand hauls rope down at v (the eye ends and F are fixed):
#     cord 3: the two strands at P3 shorten 2 v3 between them and the hand end lengthens v:
#       P3 rises v/2. The tied end of cord 2 rides on P3, so cord 2 shortens 2 v2 as its bight-side
#       strands see it, while its tied end rises v/2: P2 rises v/4. Cord 1 does the same for P1:
#       P1 and the weight on its hook rise v/8. That is Brown's rule: 2 v 2 v 2 = 8.
#   Forces in a steady lift (massless cords, sheaves turn freely on their pins, strands plumb):
#     T1 = (W + w1)/2, T2 = (T1 + w2)/2, T3 = (T2 + w3)/2, and the hand pulls T3.
#     With W = 20 and w = 1.5 kg per movable block-sheave pair: T1 = 10.75 g, T2 = 6.125 g,
#     T3 = 3.8125 g = 37.4 N, and the driver on the plumb guide bears T3 less the hand's own
#     0.4 kg weight: 33.5 N. F is fixed, so the hand strand carries its own tension as the pull.
#
# Only the hand is actuated: a slide hanging plumb on the hand rope, driven at a constant 2 cm/s.
# All three ropes are real ropes - chains of round hemp links lying in the sheaves' grooves, their
# eyes pinned to the bodies they are made fast to - so every force is contact and friction, and the
# travel is what the reeving gives. Each sheave grooves exactly one rope.
units: cm
number: 22
slug: different-arrangements-of-pulleys
name: Different Arrangements of Pulleys (fourth)
brown: "19, 20, 21 and 22. Are different arrangements of pulleys. The following rule applies to these pulleys:—In a system of pulleys where each pulley is embraced by a cord attached at one end to a fixed point and at the other to the center of the movable pulley, the effect of the whole will be = the number 2, multiplied by itself as many times as there are movable pulleys in the system."
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 50, duration_s: 2.4}
bodies:
  # The ceiling: three cord eyes plus the hook that carries the fixed pulley F.
  - id: beam
    shape: frame
    color: "#cdc0a4"
    rods:
      - {from: [42.5, 0, 91], to: [42.5, 0, 78.5], radius: 0.45}              # F's hook
      - {from: [40.7, 0, 78.8], to: [44.3, 0, 78.8], radius: 0.55}            # its beak
    boxes: [{pos: [20, 0, 84], size: [38, 1.6, 1.4]}]
  # The three eyes the cords are made fast to (fixed parts, so the ropes can be pinned to them).
  - {id: eye1, shape: part, pos: [-7, 0, 80], fixed: true, mass: 0.3, color: "#8f8a80",
     pieces: [{kind: rod, from: [0, 0, 2.9], to: [0, 0, -0.6], radius: 0.5, collide: 0},
              {kind: rod, from: [0, -1.6, -1.4], to: [0, 1.6, -1.4], radius: 0.55, collide: 0}]}
  - {id: eye2, shape: part, pos: [7, 0, 80], fixed: true, mass: 0.3, color: "#8f8a80",
     pieces: [{kind: rod, from: [0, 0, 2.9], to: [0, 0, -0.6], radius: 0.5, collide: 0},
              {kind: rod, from: [0, -1.6, -1.4], to: [0, 1.6, -1.4], radius: 0.55, collide: 0}]}
  - {id: eye3, shape: part, pos: [21, 0, 80], fixed: true, mass: 0.3, color: "#8f8a80",
     pieces: [{kind: rod, from: [0, 0, 2.9], to: [0, 0, -0.6], radius: 0.5, collide: 0},
              {kind: rod, from: [0, -1.6, -1.4], to: [0, 1.6, -1.4], radius: 0.55, collide: 0}]}
  # P1, P2, P3: the three movable blocks, each a shell with an eye below (hook on P1 for the weight,
  # a seizing eye on P2 and P3 for the cord from the pulley beneath). Every strand is plumb and the
  # eyes sit 7.5 cm out, under the rims' outer edges, so the strands cannot foul the sheaves.
  - id: block_1
    shape: part
    pos: [0, 0, 20]
    mass: 0.3
    friction: 0.4
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [0, 0, 17.4], to: [0, 0, 10.2], radius: 0.8, collide: 0}      # the hook's shank
      - {kind: rod, from: [-1.4, 0, 10.8], to: [1.2, 0, 9.4], radius: 0.8, collide: 0}  # its curve
  - {id: sheave_1, shape: pulley, radius: 7, width: 3.0, pos: [0, 0, 20], mount: block_1, mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  - id: block_2
    shape: part
    pos: [14, 0, 40]
    mass: 0.3
    friction: 0.4
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [12, 0, 37.4], to: [7, 0, 35], radius: 0.7, collide: 0}       # its seizing eye
  - {id: sheave_2, shape: pulley, radius: 7, width: 3.0, pos: [14, 0, 40], mount: block_2, mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  - id: block_3
    shape: part
    pos: [28, 0, 60]
    mass: 0.3
    friction: 0.4
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [26, 0, 57.4], to: [21, 0, 55], radius: 0.7, collide: 0}      # its seizing eye
  - {id: sheave_3, shape: pulley, radius: 7, width: 3.0, pos: [28, 0, 60], mount: block_3, mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  # F: the fixed pulley on the ceiling hook (solid, as Brown draws it).
  - {id: pulley_f, shape: pulley, radius: 7, width: 3.2, pos: [42.5, 0, 74], mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  # The hand hanging on the hand rope at its lower end, on a plumb guide so the force the joint
  # measures is the pull itself.
  - id: hand
    shape: grip
    pos: [49.4, 0, 22]
    mass: 0.4
    color: "#c9bda2"
    rods:
      - {from: [48.3, 0, 23.1], to: [50.5, 0, 20.9], radius: 2.0}        # the fist
      - {from: [49.3, 0, 25.6], to: [49.2, 0, 27.6], radius: 1.5}        # the wrist
      - {from: [49.2, 0, 27.6], to: [49.8, 0, 31.5], radius: 1.2}        # the forearm
  # The weight hung on P1's hook.
  - id: load
    shape: part
    pos: [0, 0, 4]
    mass: 20
    friction: 0.4
    color: "#4a4038"
    pieces:
      - {kind: poly, points: [[-8, 0], [8, 0], [8, 8], [-8, 8]], y: [-5, 5], collide: 0}     # the block
      - {kind: rod, from: [0, 0, 8], to: [0, 0, 9.8], radius: 0.75, collide: 0}         # its eye's shank, on P1's hook
pins:
  # P1's hook: the weight hangs on the block, as the plate draws it.
  - {id: hook, a: block_1, b: load, at: [0, 0, 9.4]}
joints:
  - {id: j_f, type: hinge, body: pulley_f, axis: [0, 1, 0], damping: 0.02}          # F turns on its hook
  - {id: j_s1, type: hinge, body: sheave_1, axis: [0, 1, 0], damping: 0.02}         # P1's wheel on its axle
  - {id: j_s2, type: hinge, body: sheave_2, axis: [0, 1, 0], damping: 0.02}         # P2's wheel on its axle
  - {id: j_s3, type: hinge, body: sheave_3, axis: [0, 1, 0], damping: 0.02}         # P3's wheel on its axle
  # The three blocks hang plumb (every strand leaves them plumb, so they cannot swing).
  - {id: j_b1, type: slide, body: block_1, axis: [0, 0, 1], range: [-8, 2]}
  - {id: j_b2, type: slide, body: block_2, axis: [0, 0, 1], range: [-1, 4]}
  - {id: j_b3, type: slide, body: block_3, axis: [0, 0, 1], range: [-2, 6]}
  - {id: j_load, type: slide, body: load, axis: [0, 0, 1], range: [-6, 6]}  # on P1's hook pin
  # The hand's guide, plumb on the hand rope, so downward haul is the positive pull.
  - {id: j_hand, type: slide, body: hand, axis: [0, 0, -1], range: [-2, 8]}
cords:
  # Cord 1: made fast at eye1, down P1's left side, under it, up its right side, seized to
  # block 2's eye (7 cm out, under the rim: the strand hangs plumb on the pin).
  - id: cord1
    from: {body: eye1, at: [-7, 0, 78.6]}
    to: {body: block_2, at: [7, 0, 35]}
    over: [sheave_1]
    under: [sheave_1]
    links: 50
    thickness: 0.8
    density: 1400          # hemp
    stiffness: 200000      # N/m per link (2 cm links): 200 N stretches one link 1.3 mm
    pretension: 105.0      # N, T1 = (W + w1)/2, what it carries in a steady lift
    damping: 3000          # N s/m per link: hemp's own internal friction, so a cord does not ring
    bend_damping: 0.05     # hemp does not whip: the links are damped as they go round the sheaves
    joint_armature: 0.00002
    friction: 0.5          # hemp on a wooden sheave
  # Cord 2: made fast at eye2, down P2's left, under it, up its right, seized to block 3's eye.
  - id: cord2
    from: {body: eye2, at: [7, 0, 78.6]}
    to: {body: block_3, at: [21, 0, 55]}
    over: [sheave_2]
    under: [sheave_2]
    links: 40
    thickness: 0.8
    density: 1400
    stiffness: 200000
    pretension: 60.0       # N, T2 = (T1 + w2)/2
    damping: 3000          # N s/m per link: hemp's own internal friction, so a cord does not ring
    bend_damping: 0.05
    joint_armature: 0.00002
    friction: 0.5
  # Cord 3: made fast at eye3, down P3's left, under it, up its right, over the fixed F, down to
  # the hand at the lower right.
  - id: cord3
    from: {body: eye3, at: [21, 0, 78.6]}
    to: {body: hand, at: [49.4, 0, 24]}
    over: [sheave_3, pulley_f]
    under: [sheave_3]
    links: 65
    thickness: 0.8
    density: 1400
    stiffness: 200000
    pretension: 37.4       # N, T3 = (T2 + w3)/2
    damping: 3000          # N s/m per link: hemp's own internal friction, so a cord does not ring
    bend_damping: 0.05
    joint_armature: 0.00002
    friction: 0.5
# The ropes lie on the sheaves under a few hundred newtons, so their contact has to be stiff.
contact: {solref: [0.0005, 1], solimp: [0.98, 0.999, 0.0001], margin: 0}
driver: {joint: j_hand, kind: velocity, speed: 2, kv: 60000, max_torque: 45}
checks:
  # Brown's purchase: the weight rises at 1/8 of the hand's speed of haul (see the header), and each
  # stage halves: P3 at 1/2, P2 at 1/4, P1 and its hooking-load at 1/8.
  - {type: ratio, out: j_b3, in: j_hand, expect: 0.5, tol: 0.015, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_b2, in: j_hand, expect: 0.25, tol: 0.01, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_b1, in: j_hand, expect: 0.125, tol: 0.006, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_load, in: j_hand, expect: 0.125, tol: 0.006, settle_s: 1.2, window_s: 1.0}
  # Every sheave rolls on its rope at the speed its strands pass it, over R + rope radius = 0.074 m,
  # in rad per metre of hand. Each movable pulley hangs in a bight whose fixed strand stands still,
  # so the rope runs past it at its own rise: P1 v/8, P2 v/4, P3 v/2, giving 1.689, 3.378 and 6.757.
  # The fixed F carries the hand's own speed: 13.51.
  - {type: ratio, out: j_s1, in: j_hand, expect: -1.689, tol: 0.1, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_s2, in: j_hand, expect: -3.378, tol: 0.2, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_s3, in: j_hand, expect: -6.757, tol: 0.4, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_f, in: j_hand, expect: 13.51, tol: 0.8, settle_s: 1.2, window_s: 1.0}
  # Brown's "power": the strike of the hand in a steady lift is T3 - the hand's own weight along its
  # guide: 37.4 - 3.9 = 33.5 N (2^3 in W plus each block's weight as the header works it).
  - {type: force, expect: 33.5, tol: 2.5, settle_s: 1.2, window_s: 1.0}
  # And the weight is seen to rise, at 0.25 cm/s while P3 climbs at 1.
  - {type: position, joint: j_load, min: 0.2, max: 1.5, settle_s: 1.2, window_s: 1.0}
  - {type: penetration, max: 0.0005, settle_s: 1.2}
camera: {target: [22, 0, 29], position: [30, -235, 35], fov: 30}   # the plate's view: all three pulleys
display:
  output: j_b1
  labels: {j_hand: Hand hauling the rope (driver), j_b1: Lowest pulley carrying the weight, j_b2: Middle pulley, j_b3: Top pulley, j_f: Fixed pulley}
  expect: {default: 0.117}
