# No. 16, Spanish Barton (Brown 1868, p. 3).
#
# "16 and 17. Are what are known as Spanish bartons."
#
# Laid out as the plate draws it (1 unit = 1 cm; the plate is 47 cm wide here and every distance is
# taken off it). A fixed sheave A hangs on a hook from the ceiling. Two blocks hang below: B on the
# right, and C at the bottom left with the weight on its hook. The plate draws two ropes:
#
#   * the FALL, a single rope whose standing end is hooked to an eye in the ceiling on the left. It
#     runs straight down, goes UNDER C, rises again on C's right, passes OVER B (the plate draws its
#     two strands tangent at B's left and right, so the rope lies on the top of B) and comes down
#     past B's right as the hauling part, where the hand takes it;
#   * the STROP, from C's eye up over the fixed sheave A and down to B's eye. It is what ties the
#     two blocks together, so they cannot move one way without the other: C rises exactly as far as
#     B falls.
#
# The reeving, counted from the plate: the load hangs in the bight of the fall between C and B, and B
# is pressed down by the fall's two strands while the strop carries it up. So the weight is carried by
# four parts of rope (two on C, two on B) and the hand's four parts of fall buy one part of rise:
# the advantage is 4 to 1, and Brown's "power" is a quarter of the weight.
#
# Nothing is driven but the hand: a slide joint in a guide along the fall, hauled at a constant
# 6 cm/s, which is the one actuator. Everything else is contact and friction: the fall is a chain of
# 46 round hemp links riding on C's and B's rims, its two eyes pinned to the ceiling and to the hand;
# the strop is a second chain of 24 links over A, its eyes pinned to the two blocks. Each sheave is
# free on its own pin as well as on its guide, so the rope grips its rim as it does on a real block;
# each block's hook is an arm hung free on the same pin, carrying the strop's pull at the eye as the plate
# draws it. Nothing couples the hand to the weight except the two ropes.
number: 16
slug: spanish-barton
name: Spanish Barton
plate: [16, 17]
brown: "16 and 17. Are what are known as Spanish bartons."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 60, duration_s: 4}
bodies:
  # The ceiling, the eye the fall's standing end is hooked to (left), and the hook A hangs on.
  - id: ceiling
    shape: part
    pos: [0, 0, 0]
    fixed: true
    density: 700
    color: "#c6b99c"
    pieces:
      - {kind: poly, points: [[-18.2, 86.0], [25.0, 86.0], [25.0, 88.3], [-18.2, 88.3]], y: [-0.8, 0.8], collide: 0}
      - {kind: rod, from: [-8.1, 0, 86.0], to: [-8.1, 0, 83.3], radius: 0.3, collide: 0, color: "#8f8a80"}   # the eye's stem
      - {kind: disc, center: [-8.1, 82.8], radius: 0.62, inner: 0.3, y: [-0.42, 0.42], collide: 1, color: "#8f8a80"}
      - {kind: rod, from: [7.2, 0, 86.0], to: [7.29, 0, 70.6], radius: 0.32, collide: 0, color: "#8f8a80"}    # A's strap
      - {kind: rod, from: [6.3, 0, 84.8], to: [8.2, 0, 84.8], radius: 0.28, collide: 1, color: "#8f8a80"}     # its hook
  # A: the fixed sheave, hung in the ceiling's hook and free to turn on its axle.
  - {id: sheave_a, shape: pulley, radius: 7.34, width: 3.0, pos: [7.29, 0, 70.25], mass: 0.9, spokes: 0, hub: 1.5, flange: 0.5, color: "#e6dcc6"}
  # B: the upper moving block, pressed down by the fall and carried up by the strop. Each sheave is
  # free on its own pin as well as on its guide (`spin`), so the fall grips its rim as on a real block
  # instead of sliding on it; the hook below is a separate arm on the same pin, so the strop's pull
  # (which the plate takes at the eye, above the sheave) is not a torque on the sheave.
  - {id: block_b, shape: pulley, radius: 7.47, width: 3.0, pos: [12.42, 0, 47.34], mass: 0.8, spokes: 0, hub: 1.5, flange: 0.5, spin: {damping: 0.005, frictionloss: 0.02}, color: "#e6dcc6"}
  - id: hook_b
    shape: lever
    pos: [12.42, 0, 47.34]
    mount: block_b
    mass: 0.15
    color: "#8f8a80"
    rods:
      - {from: [13.14, 0, 56.9], to: [12.42, 0, 47.5], radius: 0.3}   # the arm up to the eye
      - {from: [12.8, 0, 57.06], to: [13.5, 0, 57.06], radius: 0.26} # the eye's bar
  # C: the lower moving block, with the weight on its hook, as the plate has it.
  - {id: block_c, shape: pulley, radius: 7.38, width: 3.0, pos: [0, 0, 26.82], mass: 1.0, spokes: 0, hub: 1.5, flange: 0.5, spin: {damping: 0.005, frictionloss: 0.02}, color: "#e6dcc6"}
  - id: hook_c
    shape: lever
    pos: [0, 0, 26.82]
    mount: block_c
    mass: 0.15
    color: "#8f8a80"
    rods:
      - {from: [-0.9, 0, 37.6], to: [-0.63, 0, 12.9], radius: 0.3}   # the eye above and the stud below
      - {from: [-1.25, 0, 37.8], to: [-0.55, 0, 37.8], radius: 0.26} # the eye's bar
  # The weight: the squared block Brown hangs on C's hook, on a vertical guide so it stays plumb.
  - id: load
    shape: part
    pos: [-0.63, 0, 7.2]
    mass: 20
    color: "#9c8460"
    pieces:
      - {kind: poly, points: [[-8.28, 1.8], [7.02, 1.8], [7.02, 12.6], [-8.28, 12.6]], y: [-2.6, 2.6], collide: 0}
      - {kind: poly, points: [[-5.2, 2.4], [-4.3, 2.4], [-4.3, 12.0], [-5.2, 12.0]], y: [2.6, 2.75], collide: 0, color: "#7d6845"}
      - {kind: poly, points: [[-1.4, 2.4], [-0.5, 2.4], [-0.5, 12.0], [-1.4, 12.0]], y: [2.6, 2.75], collide: 0, color: "#7d6845"}

  # The hand, hauling the fall down at a constant 6 cm/s.
  - id: hand
    shape: grip
    pos: [19.62, 0, 37.8]
    mass: 0.9
    color: "#c9bda2"
    rods:
      - {from: [19.62, 0, 36.2], to: [19.62, 0, 39.4], radius: 1.9}     # the fist closed on the rope
      - {from: [19.62, 0, 34.8], to: [19.62, 0, 36.2], radius: 1.5}     # the cuff
      - {from: [19.62, 0, 32.4], to: [19.62, 0, 34.8], radius: 1.2}     # the forearm
pins:
  - {id: p_load, a: hook_c, b: load, at: [-0.63, 0, 13.0]}    # the weight on C's stud
joints:
  - {id: j_a, type: hinge, body: sheave_a, axis: [0, 1, 0], damping: 0.6, frictionloss: 0.4}    # A's axle in the ceiling hook
  # Each block's hook is an arm hung on its sheave's pin, free to turn there (a hook rides the pin
  # the sheave turns on, so it must not turn with the sheave): it carries the strop's pull at the eye,
  # as the plate draws it, and hangs along that pull while the sheave runs round under it.
  - {id: j_hook_b, type: hinge, body: hook_b, axis: [0, 1, 0], damping: 0.002}
  - {id: j_hook_c, type: hinge, body: hook_c, axis: [0, 1, 0], damping: 0.002}
  - {id: j_b, type: slide, body: block_b, axis: [0, 0, 1], range: [-33, 1]}    # B falls as C rises
  - {id: j_c, type: slide, body: block_c, axis: [0, 0, 1], range: [-1, 27]}
  - {id: j_load, type: slide, body: load, axis: [0, 0, 1], range: [-1, 27]}
  - {id: j_hand, type: slide, body: hand, axis: [0, 0, -1], range: [-1, 43]}  # the fall is hauled downwards
cords:
  # The fall: hooked to the ceiling at the left, under C, over B, down to the hand.
  - id: fall
    from: {body: ceiling, at: [-8.1, 0, 82.8]}
    over: [block_c, block_b]
    under: [block_c]        # the rope goes under C, and over B
    to: {body: hand, at: [19.62, 0, 37.8]}
    links: 46
    thickness: 1.1
    density: 1400           # hemp
    stiffness: 400000       # N/m per link: a rope is nearly inextensible
    pretension: 50          # N, about the pull it carries in a steady lift, so it starts taut
    damping: 12
    friction: 0.5           # hemp on a wooden sheave
  # The strop: C's eye over the fixed sheave A, down to B's eye. Its pull is what the fall's two
  # strands on B press against, so it carries 2T + B's weight (about 110 N in a steady lift).
  - id: strop
    from: {body: hook_c, at: [-0.9, 0, 37.8]}
    over: [sheave_a]
    to: {body: hook_b, at: [13.14, 0, 57.06]}
    links: 24
    thickness: 1.0
    density: 1400
    stiffness: 400000
    pretension: 110
    damping: 12
    friction: 0.5
# The rope lies on the sheaves under the whole load, so its contact has to be stiff: the links press
# into the rims, and the hand's pull then works against that.
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: 600}
checks:
  # Four parts of rope carry the weight, so the hand's four parts of fall buy one part of rise: the
  # load climbs at a quarter of the hand's haul. The hand's guide points down the haul and the
  # load's up the lift, so the ratio of their speeds is positive.
  - {type: ratio, out: j_load, in: j_hand, expect: 0.25, tol: 0.02, settle_s: 1.0, window_s: 2.0}
  # B is tied to C by the strop, so it falls exactly as fast as the load rises.
  - {type: ratio, out: j_b, in: j_hand, expect: -0.25, tol: 0.02, settle_s: 1.0, window_s: 2.0}
  # Every sheave rolls on the rope, at the rate its falls set. With the load rising at u = v/4: the
  # fall's standing part is at rest, so C rolls up it (ω R = u); the strop runs at u over A; and B,
  # sinking at u between a part rising at 2u and the hauling part falling at 4u, turns at 3u / R. Per
  # metre of haul, with R = sheave + 0.4 cm: A 3.23, C −3.21 (the fall under it), B 9.53 rad.
  - {type: ratio, out: j_a, in: j_hand, expect: 3.23, tol: 0.25, settle_s: 1.0, window_s: 2.0}
  - {type: ratio, out: block_c_spin, in: j_hand, expect: -3.21, tol: 0.3, settle_s: 1.0, window_s: 2.0}
  - {type: ratio, out: block_b_spin, in: j_hand, expect: 9.53, tol: 0.7, settle_s: 1.0, window_s: 2.0}
  # Brown's "power", a quarter: C and its load (21.15 kg) hang on two parts of fall and the strop, and
  # B (0.95 kg) is the strop's pull less two parts of fall, so the fall carries (W_C − W_B)/4 = 49.5 N;
  # the hand's own 0.9 kg pulls 8.8 N of that down its guide, so the driver pulls 40.7 N. The model's
  # few newtons more are the bearings' friction.
  - {type: force, expect: 40.7, tol: 4, settle_s: 1.0, window_s: 2.0}
  # And the weight is seen to rise, at about a centimetre a second.
  - {type: position, joint: j_load, min: 0.8, max: 4.6, settle_s: 1.0, window_s: 2.0}
  - {type: penetration, max: 0.0005, settle_s: 1.0}
camera: {target: [5, 0, 41], position: [26, -188, 45], fov: 33}   # the plate's view, ceiling to weight
display:
  output: j_load
  labels:
    j_hand: Hand hauling the fall (driver)
    j_load: Weight on C's hook
    j_c: Block C, rising
    j_b: Block B, falling
    j_a: Fixed sheave A, turned by the strop
  expect: {default: 0.25}