# No. 17, Spanish Barton (second) (Brown 1868, plate I).
#
# "16 and 17. Are what are known as Spanish bartons."
#
# The plate: a ceiling with an eye at the left and a hook at the right. A standing rope hangs from the
# eye, plumb down to the left of the movable sheave C, UNDER it, up to the fixed sheave A (hung on the
# hook), over its top, and down again on A's right, passing clear of B's rim and seized to a becket on
# B's shell, 10.8 cm from its axle. A second rope is seized to a becket on C's shell, runs up over B's
# sheave and out to the lower right, where the hand takes hold of it. The weight hangs under C's hook.
#
# Only the hand is actuated: a slide in a guide along the hauling strand, pulled at a constant 2 cm/s.
# Both ropes are real ropes -- chains of round hemp links lying on the sheaves' rims, with their eyes
# pinned to the bodies they are made fast to -- so every force in the machine is contact and friction,
# and the travel is what the reeving gives. Each sheave carries one rope only: the standing rope lies
# on C and A, the hauling rope on B, and the standing part passes outside B's rim to its becket.
#
#   Reading the reeving, as C rises 1 cm (the eye and A are fixed):
#     the standing rope: the eye->C strand shortens 1 (both hang plumb off C's left rim) and the C->A
#       strand shortens 1 (both hang plumb off C's right rim), so the A->B strand must lengthen 2:
#       block B SINKS 2 cm, its strand hanging on A's rim at 79 deg below horizontal.
#     the hauling rope: its C-side part shortens 3 cm (C up 1, B down 2), and that rope runs over B
#       to the hand side, which also sinks 2 with B: the hand hauls 3 + 2 = 5 cm for 1 cm of lift.
#       The strands lean a little in the plate's layout, but the measured travel is the plumb 5 to
#       within 1-2%.
#
# Both blocks are on vertical guides, as the plate draws them plumb. B would otherwise swing (the
# plate's hauling part leaves it at 57 deg while its becket strand comes down at 59 deg, and the two
# pull either side of it); C hangs from its own load. The guides do no work, so the travel is as above.
number: 17
slug: spanish-barton-2
name: Spanish Barton (second)
brown: "16 and 17. Are what are known as Spanish bartons."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 50, duration_s: 2.4}
bodies:
  # The ceiling, with the eye the standing rope is made fast to and the hook block A hangs on.
  - id: beam
    shape: frame
    color: "#cdc0a4"
    rods:
      - {from: [18.8, 0, 90], to: [18.8, 0, 77.2], radius: 0.45}              # A's hook
      - {from: [16.6, 0, 77.9], to: [21.0, 0, 77.9], radius: 0.55}            # its beak
    boxes: [{pos: [7, 0, 91], size: [23, 3.2, 1.0]}]
  # The eye in the ceiling the standing rope is made fast to (a fixed part, so the rope can be pinned
  # to it: a lashing round real iron).
  - id: eye
    shape: part
    pos: [-9.4, 0, 88.6]
    fixed: true
    mass: 0.3
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [0, 0, 1.4], to: [0, 0, -0.8], radius: 0.5, collide: 0}        # its shank
      - {kind: rod, from: [0, -1.6, -1.2], to: [0, 1.6, -1.2], radius: 0.55, collide: 0}  # its ring
  # A: the fixed sheave on the hook (solid, as Brown draws it: no spokes).
  - {id: pulley_a, shape: pulley, radius: 9, width: 3.2, pos: [18.8, 0, 75], mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  # B: the block that sinks as the weight rises, with the becket the standing rope is seized to on
  # its shell, 10.8 cm from the axle, so the standing part passes clear of the rim. Its sheave is a
  # separate body turning on the axle in the shell, as a block's wheel really is: a rope that had to
  # slide on a still sheave would lose a third of the pull to capstan friction.
  - id: block_b
    shape: part
    pos: [24.3, 0, 45.5]
    mass: 0.3
    friction: 0.4
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [34.45, 0, 49.2], to: [33.1, 0, 47.6], radius: 0.7, collide: 0}   # its becket
  - {id: sheave_b, shape: pulley, radius: 9, width: 3.0, pos: [24.3, 0, 45.5], mount: block_b, mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  # C: the movable block, the same way: shell on a vertical guide, sheave turning in it, the
  # hauling rope made fast to the becket on its shell at the axle's height, 13.5 cm out (clear of the
  # standing part, which leaves C's rim at 4.5 cm from it), weight below.
  - id: block_c
    shape: part
    pos: [0, 0, 20]
    mass: 0.3
    friction: 0.4
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [13.5, 0, 20], to: [11.0, 0, 16.8], radius: 0.7, collide: 0}            # its becket
      - {kind: rod, from: [0, 0, 20], 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_c, shape: pulley, radius: 9, width: 3.0, pos: [0, 0, 20], mount: block_c, mass: 1.2, spokes: 0, hub: 1.8, flange: 0.5, color: "#e6dcc6"}
  # The hand on the hauling strand: the drawn fist and sleeve, on a guide along the rope.
  - id: hand
    shape: grip
    pos: [41.5, 0, 18.7]
    mass: 0.4
    color: "#c9bda2"
    rods:
      - {from: [40.85, 0, 19.71], to: [42.15, 0, 17.69], radius: 2.0}        # the fist
      - {from: [40.71, 0, 21.04], to: [39.74, 0, 22.56], radius: 1.5}        # the cuff
      - {from: [39.96, 0, 22.95], to: [38.23, 0, 25.65], radius: 1.2}        # the forearm
  # The weight: the block of the plate, hung by C's hook.
  - id: load
    shape: part
    pos: [0, 0, 6]
    mass: 20
    friction: 0.4
    color: "#4a4038"
    pieces:
      - {kind: poly, points: [[-7.5, -3.0], [7.5, -3.0], [7.5, 7.0], [-7.5, 7.0]], y: [-5.0, 5.0], collide: 0}   # the block
      - {kind: rod, from: [0, 0, 7.0], to: [0, 0, 9.2], radius: 0.75, collide: 0}       # its eye's shank
pins:
  # C's hook: the weight hangs on the block, as the plate draws it.
  - {id: hook, a: block_c, b: load, at: [0, 0, 9.2]}
joints:
  - {id: j_a, type: hinge, body: pulley_a, axis: [0, 1, 0], damping: 0.02}          # A turns on its hook
  - {id: j_sb, type: hinge, body: sheave_b, axis: [0, 1, 0], damping: 0.02}         # B's wheel on its axle
  - {id: j_sc, type: hinge, body: sheave_c, axis: [0, 1, 0], damping: 0.02}         # C's wheel on its axle
  # The blocks hang plumb, as the plate draws them (B would otherwise swing: the hauling part leaves
  # it at 57 deg while the becket strand comes down at 59 deg, and the two pull either side of it).
  - {id: j_b, type: slide, body: block_b, axis: [0, 0, 1], range: [-24, 2], damping: 20}
  - {id: j_c, type: slide, body: block_c, axis: [0, 0, 1], range: [-4, 14], damping: 40}
  - {id: j_load, type: slide, body: load, axis: [0, 0, 1], range: [-4, 14], damping: 40}   # on C's hook pin
  # The hand's guide, along the hauling strand, so the force the joint measures is the pull itself.
  - id: j_hand
    type: slide
    body: hand
    axis: [0.2677, 0, -0.9635]
cords:
  # The standing rope: made fast at the ceiling eye, under C, over A, and seized to B's becket.
  - id: standing
    from: {body: eye, at: [-9.4, 0, 87.4]}
    to: {body: block_b, at: [34.45, 0, 49.2]}
    over: [sheave_c, pulley_a]
    under: [sheave_c]       # under C's bottom, over A's top; the same two rims sheaves C hangs on
    links: 60 
    thickness: 0.8
    density: 1400          # hemp
    stiffness: 200000      # N/m per link (3.6 cm links): 200 N stretches one link 1 mm
    pretension: 90.0 
    damping: 12
    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
  # The hauling rope: made fast at C's becket (the plate draws it leaving C at the axle's height),
  # up over B, and away down the right to the hand.
  - id: haul
    from: {body: block_c, at: [13.5, 0, 20]}
    to: {body: hand, at: [41.5, 0, 18.7]}
    over: [sheave_b]
    links: 26
    thickness: 0.8
    density: 1400
    stiffness: 200000
    pretension: 15         # N, a light pull so the rope starts nearly taut
    damping: 12
    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:
  # The purchase the reeving gives (see the header): with C up 1, B sinks 2 and the hand hauls 5, so the
  # load rises at 1/5 of the hand's speed and B sinks at 2/5. The strands lean a little in the plate's
  # layout, but the measured travel is the plumb book value to within 1-2% (C 0.198, B -0.407 over a
  # second of steady haul), so the plumb numbers are the expectation.
  - {type: ratio, out: j_c, in: j_hand, expect: 0.2, tol: 0.015, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_b, in: j_hand, expect: -0.4, tol: 0.02, settle_s: 1.2, window_s: 1.0}
  # Every sheave rolls on its rope, at the rate the strand speeds set (R = 9 + 0.4 cm), per metre of
  # haul: C rolls up the standing strand, which is at rest, at its own centre's speed (0.2/R = 2.13,
  # its top going to the left); the standing rope runs over A at C's 2 x 0.2 (4.26); and the hauling
  # rope runs over B at the rate its C strand shortens, C up 0.2 plus B down 0.4 (6.38).
  - {type: ratio, out: j_sc, in: j_hand, expect: -2.128, tol: 0.15, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_a, in: j_hand, expect: 4.255, tol: 0.3, settle_s: 1.2, window_s: 1.0}
  - {type: ratio, out: j_sb, in: j_hand, expect: 6.383, tol: 0.45, settle_s: 1.2, window_s: 1.0}
  # Brown's "power": the pull in a steady lift is (W_C - 2 W_B)/5, W_C being all that C lifts (the
  # 20 kg weight, C's shell and sheave: 21.5 kg) and B's 1.5 kg counted twice because it sinks twice as
  # fast: 36.3 N in the hauling rope, less the hand's own 0.4 kg pulling 3.8 N down its guide: 32.5 N.
  - {type: force, expect: 32.5, tol: 3.0, settle_s: 1.2, window_s: 1.0}
  # And the weight is seen to rise: it first settles about 2.6 cm as the two ropes take its weight,
  # then climbs at 0.4 cm/s.
  - {type: position, joint: j_load, min: -3.2, max: 0.5, settle_s: 1.2, window_s: 1.0}
  - {type: penetration, max: 0.002, settle_s: 1.2}
camera: {target: [12, 0, 43], position: [16, -250, 52], fov: 34}   # the plate's view: all three blocks
display:
  output: j_c
  labels: {j_hand: Hand hauling the rope (driver), j_c: Weight on the rising block, j_b: Block B sinking, j_a: Fixed block A}
  expect: {default: 0.187}