# No. 129 (Brown 1868): "Chinese windlass. This embraces the same principles as the micrometer screw 111. The movement of the pulley in every revolution of the windlass is equal to half the difference between the larger and smaller circumferences of the windlass barrel."
#
# Model (cm, gravity on): a barrel of two drums on one shaft (7.0 and 4.0 cm radius, each turning in its own rope plane, locked together by a pin through both) is turned by hand, the one driven joint, 1.2 rad each way at 0.15 Hz.
# One rope is tied to the top of the large drum and winds on it; the other is tied to the top of the small drum and winds the other way; both run down to a movable pulley (5.5 cm radius, a sheave
# on either side of its block, locked together by a pin) and are seized to the bottom of it, the pulley hanging with a 5 kg weight. The ropes are real cords. As the barrel turns one way the large drum
# takes in 7.0 cm of rope to the radian and the small gives out 4.0; the loop lengthens by 3.0 cm to the radian and the pulley falls half as much, 1.5 cm to the radian,
# 9.4 cm a turn: half the difference of the circumferences. Generator: opencode-runs/batch10/gen129.py.
number: 129
slug: chinese-windlass
name: A Chinese windlass raising a pulley
brown: "Chinese windlass. This embraces the same principles as the micrometer screw 111. The movement of the pulley in every revolution of the windlass is equal to half the difference between the larger and smaller circumferences of the windlass barrel."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 60, duration_s: 8.0, floor: false}
bodies:
  - {id: frame, shape: part, pos: [0, 0, 50.0], fixed: true, color: "#cdc0a4", pieces: [
      {kind: poly, points: [[-16, 60.0], [16, 60.0], [16, 61.4], [-16, 61.4]], y: [-6, 6], collide: 0},
      {kind: poly, points: [[-0.9, 50.0], [0.9, 50.0], [0.9, 60.0], [-0.9, 60.0]], y: [-6.8, -5.4], collide: 0},
      {kind: poly, points: [[-0.9, 50.0], [0.9, 50.0], [0.9, 60.0], [-0.9, 60.0]], y: [5.4, 6.8], collide: 0}]}
  - {id: barrel, shape: assembly, pos: [0, 0, 50.0], color: "#e6dcc6"}
  - id: block
    shape: part
    pos: [1.5, 0, 28.0]
    mass: 0.6
    color: "#b8ac92"
    pieces:
      - {kind: rod, from: [1.5, -5.800000000000001, 28.0], to: [1.5, 5.800000000000001, 28.0], radius: 0.4, collide: 0}
      - {kind: rod, from: [1.5, -5.800000000000001, 28.0], to: [1.5, -5.800000000000001, 17.5], radius: 0.35, collide: 0}
      - {kind: rod, from: [1.5, 5.800000000000001, 28.0], to: [1.5, 5.800000000000001, 17.5], radius: 0.35, collide: 0}
      - {kind: rod, from: [1.5, -5.800000000000001, 17.5], to: [1.5, 5.800000000000001, 17.5], radius: 0.35, collide: 0}
  - {id: sheave_a, shape: pulley, radius: 5.5, width: 2.0, pos: [1.5, -3.6, 28.0], mass: 0.7, spokes: 0, hub: 1.2, flange: 0.5, color: "#e6dcc6", mount: block}
  - {id: sheave_b, shape: pulley, radius: 5.5, width: 2.0, pos: [1.5, 3.6, 28.0], mass: 0.7, spokes: 0, hub: 1.2, flange: 0.5, color: "#e6dcc6", mount: block}
  - {id: bag, shape: weight, pos: [1.5, 0, 14.0], mass: 5.0, size: [4.4, 4.4, 5.0], taper: 0.34, color: "#b9a179", mount: block}
joints:
  - {id: j_a, type: hinge, body: barrel, axis: [0, 1, 0], damping: 0.01}   # the barrel, turned by hand: the one driven joint; + : clockwise
  - {id: j_block, type: slide, body: block, axis: [0, 0, 1], damping: 0.05, range: [-14, 14]}   # + : up
  - {id: j_sa, type: hinge, body: sheave_a, axis: [0, 1, 0], damping: 0.01}
  - {id: j_sb, type: hinge, body: sheave_b, axis: [0, 1, 0], damping: 0.01}
pins:
  - {id: pin_sheave, a: sheave_a, b: sheave_b, at: [3.5, 0, 28.0]}   # and so is the pulley
wheels:
  - {id: drum_a, body: barrel, pos: [0, -3.6, 0], radius: 7.0, width: 2.0, rim_width: 1.4, mass: 1.5, spokes: 0, hub: 1.0, flange: 0.6}
  - {id: drum_b, body: barrel, pos: [0, 3.6, 0], radius: 4.0, width: 2.0, rim_width: 1.4, mass: 1.0, spokes: 0, hub: 1.0, flange: 0.6}
shafts:
  - {id: axle, body: barrel, from: [0, -6.8, 0], to: [0, 6.8, 0], radius: 0.5}
cords:
  - id: rope_a
    from: {body: barrel, at: [-4.4165, -3.6, 56.3075]}
    to: {body: sheave_a, at: [-0.6205, -3.6, 22.1739]}
    over: [drum_a, sheave_a]
    links: 36
    thickness: 0.8
    density: 1400
    stiffness: 40000.0
    pretension: 29.43
    damping: 12.0
    friction: 0.5
  - id: rope_b
    from: {body: barrel, at: [2.6958, 3.6, 53.85]}
    to: {body: sheave_b, at: [3.6205, 3.6, 22.1739]}
    over: [drum_b, sheave_b]
    under: [drum_b, sheave_b]
    links: 36
    thickness: 0.8
    density: 1400
    stiffness: 40000.0
    pretension: 29.43
    damping: 12.0
    friction: 0.5
contact: {solref: [0.0006, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_a, kind: velocity, rpm: 0, swing: {amplitude: 1.2, hz: 0.15}, kv: 20.0, max_torque: 50}
checks:
  - {type: follow, out: j_block, in: j_a, expect: -0.01500, tol: 0.0012, min_r2: 0.99, settle_s: 1.0, window_s: 6.5}   # the pulley falls half the difference of the radii to the radian
  - {type: follow, out: j_sa, in: j_a, expect: 1.0, tol: 0.06, min_r2: 0.99, settle_s: 1.0, window_s: 6.5}   # and turns once for each turn of the barrel
  - {type: position, joint: j_block, min: -9.0, max: 3.0, settle_s: 0.0, window_s: 8}
camera: {target: [0, 0, 30.0], position: [0, -150.0, 30.0], fov: 34}
display:
  output: j_block
  labels: {j_a: "Windlass (driver)", j_block: "Movable pulley"}
  proof: {label: "Ropes not gripping", sub: "the windlass turns but the pulley stands"}

