# No. 261 (Brown 1868): "A combination movement, in which the weight, W, moves vertically with a reciprocating movement; the down-stroke being shorter than the up-stroke."
#
# Model (cm, gravity on, front view): the disk B (the one driven joint, 12 turns a minute clockwise) carries a crank pin 2 from its centre and a
# drum of radius 0.8 on which the cord D (0.5 thick) is lashed. The rod C joins the pin to the arm A, 10 from A's pivot G; A carries the pulley E
# (radius 2.5) 20 from G. D runs plumb up from the drum over E and down to the weight W, guided plumb. As B turns, A rocks on G and E rises and falls
# (twice what C gives A's eye), and W rises and falls twice as far as E, while the drum takes up 1.05 cm of cord a radian: W's strokes over the run
# +18.7, -12.5, +8.4 cm (up longer than down). Only the cord's contact on the drum and on E carries W; C is pinned to A.
# Generator: opencode-runs/batch11/gen261.py.
number: 261
slug: combination-weight-movement
name: A combination movement with a shorter down-stroke
brown: "A combination movement, in which the weight, W, moves vertically with a reciprocating movement; the down-stroke being shorter than the up-stroke. B is a revolving disk, carrying a drum which winds round itself the cord, D. An arm, C, is jointed to the disk and to the upper arm, A, so that when the disk revolves the arm, A, moves up and down, vibrating on the point, G. This arm carries with it the pulley, E. Suppose we detach the cord from the drum and tie it to a fixed point, and then move the arm, A, up and down, the weight, W, will move the same distance, and in addition the movement given to it by the cord, that is to say, the movement will be doubled. Now let us attach the cord to the drum and revolve the disk, B, and the weight will move vertically with the reciprocating motion, in which the down-stroke will be shorter than the up-stroke, because the drum is continually taking up the cord."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 80, duration_s: 6, floor: false}
bodies:
  - {id: disk_b, shape: assembly, pos: [16.2, 0, 0.0], color: "#e6dcc6"}
  - id: rod_c
    shape: part
    pos: [16.2, 0, -2.0]
    mount: disk_b
    mass: 0.2
    color: "#a89a7e"
    pieces:
      - {kind: rod, from: [16.2, -4.8, -2.0], to: [10.0, -4.8, 30.0], radius: 0.4, collide: 0}   # the rod C
      - {kind: rod, from: [16.2, -4.4, -2.0], to: [16.2, -5.2, -2.0], radius: 0.6, collide: 0, color: "#8f8a80"}   # its eye on the crank pin
  - id: arm_a
    shape: part
    pos: [0, 0, 30]
    mass: 0.4
    color: "#c9bda2"
    pieces:
      - {kind: poly, points: [[-1, 29.3], [20.8, 29.3], [20.8, 30.7], [-1, 30.7]], y: [-2.2, -1.6], collide: 0}   # the arm A, in front of E
      - {kind: poly, points: [[-1, 29.3], [20.8, 29.3], [20.8, 30.7], [-1, 30.7]], y: [1.6, 2.2], collide: 0}   # and behind
      - {kind: disc, center: [0, 30], radius: 1.2, inner: 0.4, y: [-2.4, 2.4], collide: 0}   # its boss on the pivot G
      - {kind: rod, from: [10, -4.9, 30], to: [10, -1.6, 30], radius: 0.35, collide: 0, color: "#8f8a80"}   # the rod's pin
  - {id: pul_e, shape: pulley, radius: 2.5, width: 1.6, pos: [20, 0, 30], mass: 0.2, spokes: 0, hub: 0.8, flange: 0.5, mount: arm_a, color: "#e6dcc6"}
  - {id: weight_w, shape: weight, pos: [22.75, 0, 0.5], mass: 0.5, size: [3.2, 3.2, 5.0], taper: 0.2, color: "#b9a179"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-4, -8], [27.75, -8], [27.75, -6.8], [-4, -6.8]], y: [-4, 4], collide: 0, color: "#b9b09c"}   # the bed
      - {kind: poly, points: [[-1.4, -6.8], [1.4, -6.8], [1.0, 30], [-1.0, 30]], y: [2.4, 3.4], collide: 0}   # the post of G
      - {kind: poly, points: [[14.6, -6.8], [17.8, -6.8], [17.2, 0], [15.2, 0]], y: [2.4, 3.4], collide: 0}   # B's standard
      - {kind: poly, points: [[24.75, -6.8], [25.35, -6.8], [25.35, 24], [24.75, 24]], y: [-0.6, 0.6], collide: 0, color: "#9d917a"}   # W's guide
joints:
  - {id: j_b, type: hinge, body: disk_b, axis: [0, 1, 0], damping: 0.01}   # the one driven joint; + : clockwise from the front
  - {id: j_c, type: hinge, body: rod_c, axis: [0, 1, 0], damping: 0.002}   # C on the crank pin
  - {id: j_a, type: hinge, body: arm_a, axis: [0, 1, 0], damping: 0.01}   # A on G
  - {id: j_e, type: hinge, body: pul_e, axis: [0, 1, 0], damping: 0.002}
  - {id: j_w, type: slide, body: weight_w, axis: [0, 0, 1], range: [-6, 22.6853], damping: 0.5}   # W in its guide; + : up
pins:
  - {"id": "pin_a", "a": "rod_c", "b": "arm_a", "at": [10, 0, 30]}
wheels:
  - {id: drum, body: disk_b, pos: [0, 0, 0], radius: 0.8, width: 1.4, rim_width: 1.0, mass: 0.3, spokes: 0, hub: 0.5, flange: 0.6}
  - {id: disk, body: disk_b, pos: [0, -4.0, 0], radius: 3.2, width: 0.6, mass: 0.8, spokes: 0, hub: 0.8, flange: 0, web: true, color: "#d9cfb6"}
shafts:
  - {id: axle, body: disk_b, from: [0, -4.4, 0], to: [0, 3.0, 0], radius: 0.4}
cords:
  - id: cord_d   # lashed to the drum's right side, plumb up over E, and down to W
    from: {body: disk_b, at: [17.25, 0, 0.0]}
    to: {body: weight_w, at: [22.75, 0, 3]}
    over: [pul_e]
    links: 80
    thickness: 0.5
    density: 1400
    stiffness: 40000
    pretension: 4.905
    damping: 12
    friction: 0.5
contact: {solref: [0.0006, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_b, kind: velocity, rpm: 12, kv: 40, max_torque: 10}
checks:
  - {type: follow, out: j_w, in: j_b, expect: 0.01053, tol: 0.00200, min_r2: 0.9, settle_s: 2.236, window_s: 0.25}   # at the arm's dead point: the drum's take-up alone
  - {type: follow, out: j_w, in: j_b, expect: 0.08885, tol: 0.00711, min_r2: 0.9, settle_s: 1.018, window_s: 0.25}   # mid up-stroke: twice E's rise plus the take-up
  - {type: follow, out: j_w, in: j_b, expect: -0.06787, tol: 0.00543, min_r2: 0.9, settle_s: 3.484, window_s: 0.25}   # mid down-stroke: twice E's fall less the take-up
  - {type: position, joint: j_w, min: -1.5, max: 20.1853, settle_s: 0.0, window_s: 6}
camera: {target: [12.5, 0, 4.2], position: [12.5, 128.0, 8.2], fov: 37.0}
display:
  output: j_w
  labels: {j_b: "Disk B (driver)", j_a: "Arm A", j_w: "Weight W"}
  proof: {label: "Cord cut", sub: "the disk turns but W drops"}

