# No. 18, A combination of two fixed pulleys and one movable pulley (Brown 1868, plate 18).
#
# "Is a combination of two fixed pulleys and one movable pulley."
#
# The plate, read strand by strand. One block hangs by a hook from the ceiling and carries the two
# FIXED sheaves, one above the other on the same pin, so that the falls are plumb. A third, MOVABLE
# sheave hangs below them in a block with the weight on its hook. One rope, reeved as follows, and it
# is the only thing that holds the weight up:
#
#   free end (the hand's) -> over the top of the UPPER fixed sheave, leaving it at 10 o'clock, which
#   is where the plate shows the end resting against the rim;
#   -> down the right of the movable sheave, UNDER it, and up its left (one wrap of the movable
#      sheave, both falls plumb);
#   -> up to the MIDDLE fixed sheave and over the top of it;
#   -> down again and lashed to the top of the movable block (the knot the plate draws there).
#
# Three parts of rope hold the movable block: the fall down its right, the fall up its left, and the
# lashing at its top. Three equal tensions T, so the block is lifted by (2 + cos a)T, where a is the
# angle of the lashing off the vertical -- 8.9 deg here, because a taut rope leaves the middle sheave
# tangentially and must reach the block's centre: (2 + cos 8.9) = 2.988, i.e. Brown's three parts to
# within 0.4%. The hand therefore pulls at T = W/2.988 and the block rises at 1/2.988 of the speed the
# hand pulls. Both numbers are what the checks measure.
#
# Each sheave turns at the speed the rope runs on its rim (omega = u / (R + rope radius)), and the
# strands set u. The rope runs over the upper sheave at the hand's own speed v. The lashing shortens
# at v_b cos a, so the rope crosses the middle sheave that fast, which is about v/3. The movable sheave
# rises at v_b, so it sees its right fall coming down at v + v_b and its left fall leaving at
# v_b(1 + cos a), which is about 2v/3.
#
# The upper sheave is drawn larger than the other two, as in the plate. That is what lets the fall
# from its right side down to the movable sheave pass clear of the middle one.
#
# One liberty, stated here. The plate does not draw the rope's turn over the top of the middle
# sheave, because the strap crosses it there. A taut rope coming up to a fixed sheave must pass over
# it, and only then can the lashing come down to the middle of the block.
#
# Nothing is driven but the hand: a slide joint in a guide along the rope's own strand, pulled at a
# constant 6 cm/s. The rope is a real rope -- 120 round hemp links with a stretch joint at each, lying
# on the rims by friction, its eyes pinned to the hand and to the movable block -- so the load is
# carried by the rope's own tension and the sheaves are turned by the rope rubbing on them. Nothing
# couples the hand to the weight except that rope.
number: 18
slug: a-combination-of-two-fixed-pulleys-and-one-movable-pulley
name: A Combination of Two Fixed Pulleys and One Movable Pulley
brown: "Is a combination of two fixed pulleys and one movable pulley."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 60, duration_s: 2.4}
bodies:
  # The ceiling the block hangs from.
  - id: ceiling
    shape: frame
    color: "#cdc0a4"
    boxes: [{pos: [0, 0, 110.6], size: [17, 3, 1.2]}]
  # The fixed block: the hook on the ceiling and the strap that carries both fixed sheaves. The strap
  # is drawn in front of the sheaves' plane (y = -2.7), as the plate draws it crossing their faces,
  # so the rope, which lies in the plane y = 0, passes it untouched.
  - id: upblock
    shape: part
    fixed: true
    pos: [0, 0, 88]
    color: "#b8ac92"
    pieces:
      - {kind: rod, from: [0, -2.7, 109.4], to: [0, -2.7, 102.6], radius: 0.5, collide: 0}    # the hook's shank
      - {kind: rod, from: [-1.9, -2.7, 102.6], to: [1.9, -2.7, 102.6], radius: 0.45, collide: 0}  # the hook's bend
      - {kind: rod, from: [0, -2.7, 101.8], to: [0, -2.7, 88], radius: 0.55, collide: 0}      # the strap
      - {kind: disc, center: [0, 88], radius: 1.7, inner: 0.6, y: [-3.2, -2.2], collide: 0}   # the upper pin's end
      - {kind: rod, from: [0, -2.7, 88], to: [0, -2.7, 63], radius: 0.5, collide: 0}          # on to the middle pin
      - {kind: disc, center: [0, 63], radius: 1.7, inner: 0.6, y: [-3.2, -2.2], collide: 0}   # the middle pin's end
  # The two fixed sheaves, solid as the plate draws them, each free on its own pin.
  - {id: upper, shape: pulley, radius: 11.5, width: 3.0, pos: [0, 0, 88], mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  - {id: middle, shape: pulley, radius: 8, width: 3.0, pos: [0, 0, 63], mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  # The movable block: its two cheeks, the pin its sheave turns on, the hook the weight hangs by, and
  # the collar the rope's end is lashed into at the top. A vertical slide is its guide, as the plate
  # draws it plumb -- nothing but the rope holds it up.
  - id: block
    shape: part
    pos: [0, 0, 0]
    mass: 1.2
    color: "#b8ac92"
    pieces:
      - {kind: disc, center: [0, 0], radius: 9.4, inner: 2.2, y: [-2.3, -1.5], collide: 0}    # the near cheek
      - {kind: disc, center: [0, 0], radius: 9.4, inner: 2.2, y: [1.5, 2.3], collide: 0}      # the far cheek
      - {kind: rod, from: [0, -2.6, 0], to: [0, 2.6, 0], radius: 0.5, collide: 0}            # the pin
      - {kind: rod, from: [0, 0, 10.6], to: [0, 0, 7.9], radius: 0.75, collide: 0}          # the rope's end, entering
      - {kind: disc, center: [0, 7.9], radius: 1.5, y: [-1.0, 1.0], collide: 0}             # the lashing on the block
      - {kind: rod, from: [0, 0, -9.0], to: [0, 0, -14.2], radius: 0.55, collide: 0}        # the hook's shank
      - {kind: band, center: [0, -14.2], r: [1.3, 2.1], a: [3.2, 6.2], y: [-0.5, 0.5], slices: 6, collide: 0}  # its bend
  # The movable sheave, turning on the block's pin: free to roll on the rope rather than sliding on it.
  - {id: sheave, shape: pulley, radius: 8, width: 3.0, pos: [0, 0, 0], mass: 0.8, spokes: 0, hub: 1.6, flange: 0.5, color: "#e6dcc6", mount: block}
  # The weight: the squared block Brown hangs on the hook, drawn as the plate draws it.
  - id: load
    shape: part
    pos: [0, 0, -16]
    mass: 20
    color: "#b9a179"
    pieces:
      - {kind: poly, points: [[-7.6, -16], [7.6, -16], [7.6, -26], [-7.6, -26]], y: [-5, 5], collide: 0}
      - {kind: rod, from: [-7.6, 0, -16.6], to: [-7.6, 0, -25.4], radius: 0.5, collide: 0, color: "#9d8563"}
      - {kind: rod, from: [7.6, 0, -16.6], to: [7.6, 0, -25.4], radius: 0.5, collide: 0, color: "#9d8563"}
  # The hand, gripping the rope's free end where it leaves the upper sheave at 160 degrees, so its
  # guide is the rope's own strand, 20 degrees off the vertical.
  - id: hand
    shape: grip
    pos: [-18.67, 0, 71.48]
    mass: 0.9
    color: "#c9bda2"
    rods:
      - {from: [-18.16, 0, 72.89], to: [-19.18, 0, 70.07], radius: 2.0}      # the fist
      - {from: [-19.18, 0, 70.07], to: [-20.11, 0, 67.53], radius: 1.55}   # the cuff
      - {from: [-20.11, 0, 67.53], to: [-21.24, 0, 64.43], radius: 1.25}   # the forearm
pins:
  - {id: p_load, a: block, b: load, at: [0, 0, -16]}   # the weight on the block's hook
joints:
  - {id: j_upper, type: hinge, body: upper, axis: [0, 1, 0], damping: 0.01}    # each fixed sheave on its own pin
  - {id: j_middle, type: hinge, body: middle, axis: [0, 1, 0], damping: 0.01}
  - {id: j_block, type: slide, body: block, axis: [0, 0, 1], range: [-6, 10], damping: 0.5}  # the block's guide, plumb
  - {id: j_sheave, type: hinge, body: sheave, axis: [0, 1, 0], damping: 0.01}   # the sheave on the block's pin
  - {id: j_load, type: slide, body: load, axis: [0, 0, 1], range: [-4, 10]}     # the weight hangs plumb on the hook
  - {id: j_hand, type: slide, body: hand, axis: [-0.3420201, 0, -0.9396926], range: [-4, 16]}  # the hand's guide, along the rope
cords:
  # One rope, reeved as in the plate: from the hand over the upper sheave, down and under the movable
  # sheave, up and over the middle sheave, and down to the block, where it is lashed fast.
  #
  # `over` lists the sheaves in the order this rope meets them going from the hand to the block, and
  # each is wrapped in the same (clockwise) sense: over the top of the upper sheave, under the bottom of the
  # movable one, over the top of the middle one. (The sense flag is relative to the way along the
  # rope, so the pass UNDER the movable sheave is the same sense as the passes OVER the fixed ones;
  # No. 13's, whose rope is traversed the other way, needs `under:` for exactly that reason.)
  - id: rope
    from: {body: hand, at: [-18.67, 0, 71.48]}
    to: {body: block, at: [0, 0, 8.6]}
    over: [upper, sheave, middle]
    links: 120
    thickness: 0.8
    density: 1400          # hemp
    stiffness: 240000      # N/m per link (2.5 cm links): 72 N stretches the rope 3.6%; stiffer is unstable at this timestep
    pretension: 72         # N, the pull every part already carries under the weight: 215.8/2.988
    damping: 3000          # N s/m per link: hemp's own internal friction, so the rope does not ring like a spring
    friction: 0.5          # hemp on a wooden sheave
# The rope lies on three sheaves under the weight and rubs on all of them as it moves, so its contact
# has to be stiff: the links press a fraction of a millimetre into the rims, which the pull works against.
contact: {solref: [0.0005, 1], solimp: [0.98, 0.999, 0.0001], margin: 0}
driver: {joint: j_hand, kind: velocity, speed: 6, kv: 60000, max_torque: 200}
checks:
  # Three parts of rope hold the block, so it rises at 1/(2 + cos 8.9 deg) = 0.3347 of the speed the
  # hand pulls -- Brown's three parts to within 0.4%. The rope takes up its own stretch in the first
  # second, so the window is taken after that.
  - {type: ratio, out: j_block, in: j_hand, expect: 0.3347, tol: 0.012, settle_s: 1.2, window_s: 1.0}
  # Each sheave is turned only by the rope on its rim, at its strands' speed, in rad per metre of hand.
  # The upper sheave sees the hand's own speed: 1/(0.115 + 0.004) = 8.40. The middle one sees the
  # lashing's take-up, 0.3347 cos 8.9 deg = 0.3307, so 0.3307/0.084 = 3.94. The movable one sees its
  # falls run past it at 0.3347 (1 + cos 8.9 deg) = 0.6654, so 0.6654/0.084 = 7.92.
  - {type: ratio, out: j_upper, in: j_hand, expect: -8.403, tol: 0.5, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_middle, in: j_hand, expect: -3.937, tol: 0.3, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_sheave, in: j_hand, expect: -7.921, tol: 0.5, settle_s: 1.2, window_s: 1.0}
  # Brown's "power": the weight over three parts. The block and its sheave (1.2 + 0.8) and the
  # weight (20) hang on the rope, 215.8 N, and the rope takes (2 + cos 8.9) = 2.988 of it, so 72.2 N
  # in the rope; the hand's own 0.9 kg already pulls 8.3 N down its own strand (20 deg off the
  # vertical), so 63.9 N is the balance to expect.
  - {type: force, expect: 63.9, tol: 5, settle_s: 1.2, window_s: 1.0}
  # And the block is seen to rise: 6/2.988 = 2.0 cm/s once the rope has taken up.
  - {type: position, joint: j_block, min: 0.4, max: 9, settle_s: 1.2, window_s: 1.0}
  - {type: penetration, max: 0.0005, settle_s: 1.2}
camera: {target: [0, 0, 14], position: [35, -390, 24], fov: 30}   # the plate's view: ceiling, both fixed sheaves, the block, the weight
display:
  tiers:
    - {id: full, label: Full, ms: 6.3748}
    - {id: fine, label: Fine, links: [48], timestep: 0.0008, integrator: discrete, armature: 1.0e-7, ms: 0.8321}
    - {id: light, label: Lightest, links: [48], timestep: 0.0016, integrator: discrete, armature: 1.0e-7, ms: 0.924}
    - {id: friction, label: Friction model, timestep: 0.002, integrator: discrete, model: capstan, ms: 0.0234}
  output: j_block
  labels: {j_hand: Hand pulling the rope (driver), j_block: Movable block with the weight, j_upper: Upper fixed sheave, j_middle: Middle fixed sheave, j_sheave: Sheave turning in the block}
  expect: {default: 0.3347}
