# No. 126 (Brown 1868): "A bell-crank lever, used for changing the direction of any force."
#
# Model (cm, gravity on): a bell-crank lever on a pivot, with a horizontal arm 10.0 cm long and a downward arm 8.0 cm long. The hand (the one driven joint, a schedule of 2 cm each way at 0.5 Hz) pulls a rope horizontally from the lower arm's end;
# the upper arm's end is tied to a rope that runs up, over a fixed pulley, and down to a 2 kg weight. Pulling to the right turns the crank, the upper arm descends, and the weight is raised; letting the rope go back lets the weight draw the crank round again.
# The ropes are real cords, the pulley grips them by friction alone, and nothing else drives the weight. The weight's rise is 1.25 times the hand's pull, the arms' ratio, to first order.
# Generator: opencode-runs/batch10/gen126.py.
number: 126
slug: bell-crank-lever
name: A bell-crank lever changing a pull's direction
brown: "A bell-crank lever, used for changing the direction of any force."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 60, duration_s: 4.0, floor: false}
bodies:
  - {id: pulley, shape: pulley, radius: 7.0, width: 3.2, pos: [0, 0, 34.0], mass: 0.8, spokes: 0, hub: 1.6, flange: 0.5, color: "#e6dcc6"}
  - {id: bag, shape: weight, pos: [-7.4, 0, 14.0], mass: 2.0, size: [4.4, 4.4, 8.0], taper: 0.34, color: "#b9a179"}
  - id: crank
    shape: part
    pos: [17.4, 0, 0]
    mass: 0.3
    color: "#a89d89"
    pieces:
      - {kind: poly, points: [[7.4, 0.8], [17.4, 0.8], [17.4, -0.8], [7.4, -0.8]], y: [-1.2, -0.4]}
      - {kind: poly, points: [[18.2, 0.0], [18.2, -8.0], [16.6, -8.0], [16.6, 0.0]], y: [-1.2, -0.4]}
      - {kind: disc, center: [7.4, 0.0], radius: 1.2, inner: 0.35, y: [-1.2, -0.4]}
      - {kind: disc, center: [17.4, -8.0], radius: 1.2, inner: 0.35, y: [-1.2, -0.4]}
      - {kind: disc, center: [17.4, 0.0], radius: 1.5, inner: 0.35, y: [-1.2, -0.4]}
  - id: hand
    shape: part
    pos: [30.0, 0, -8.0]
    mass: 0.6
    color: "#c9bda2"
    pieces:
      - {kind: poly, points: [[30.0, -9.1], [37.0, -9.7], [37.0, -6.3], [30.0, -6.9]], y: [-1.4, -0.4]}   # the fist closed on the rope
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, 1.0, 34.0], to: [0, 3.0, 34.0], radius: 0.7, color: "#8f8a80"}   # the pulley's axle
      - {kind: rod, from: [17.4, 0.4, 0], to: [17.4, 2.4, 0], radius: 0.7, color: "#8f8a80"}   # the crank's pivot
joints:
  - {id: j_pulley, type: hinge, body: pulley, axis: [0, 1, 0], damping: 0.01}
  - {id: j_bag, type: slide, body: bag, axis: [0, 0, 1], range: [-12, 14], damping: 3.0}   # the weight hangs plumb; + : up
  - {id: j_crank, type: hinge, body: crank, axis: [0, 1, 0], damping: 0.02}   # + : clockwise (the hand pulling to the right turns it the other way)
  - {id: j_hand, type: slide, body: hand, axis: [1, 0, 0], damping: 0.1}   # the hand's pull: + : to the right
cords:
  - id: rope_up   # the weight, up over the pulley (clockwise), and down to the crank's upper arm
    from: {body: bag, at: [-7.4, 0, 23.6]}
    to: {body: crank, at: [7.4, 0, 0]}
    over: [pulley]
    links: 40
    thickness: 0.8
    density: 1400
    stiffness: 40000.0
    pretension: 19.62
    damping: 12.0
    friction: 0.5
  - id: rope_pull   # from the crank's lower arm to the hand
    from: {body: crank, at: [17.4, 0, -8.0]}
    to: {body: hand, at: [30.0, 0, -8.0]}
    over: []
    links: 16
    thickness: 0.8
    density: 1400
    stiffness: 40000.0
    pretension: 24.525
    damping: 12.0
    friction: 0.5
contact: {solref: [0.0006, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_hand, kind: velocity, rpm: 0, swing: {amplitude: 0.015, hz: 0.5}, kv: 60000.0, max_torque: 600.0}
checks:
  # a bell-crank turns a horizontal pull into a vertical lift: the weight rises A/B = 10/8 = 1.25 cm per cm of the hand's pull (the rope's stretch under the load adds a little)
  - {type: follow, out: j_bag, in: j_hand, expect: 1.27, tol: 0.05, min_r2: 0.995, settle_s: 0.5, window_s: 3.5}
  - {type: position, joint: j_bag, min: -2.7, max: 2.7, settle_s: 0.0, window_s: 4}
  - {type: position, joint: j_hand, min: -2.3, max: 2.3, settle_s: 0.0, window_s: 4}
camera: {target: [10.8, 0, 15.0], position: [10.8, -118.0, 15.0], fov: 34}
display:
  output: j_bag
  labels: {j_hand: "Hand (driver)", j_bag: "Weight", j_crank: "Bell-crank"}
  proof: {label: "Rope not gripping the pulley", sub: "the hand pulls but the weight does not rise"}

