# No. 244 (Brown 1868): a dynamometer (Prony's brake). "A is a smoothly-turned pulley, secured on a shaft ... Two blocks of wood are fitted to
# this pulley ... so arranged that they may be made to bite or press upon the pulley by means of the screws and nuts on the top of the lever, D. ... At
# the end of the lever, D, is hung a scale, B, in which weights are placed. The two stops, C, C', are to maintain the lever as nearly as possible in a
# horizontal position."
#
# Model (cm, gravity on): the pulley A (radius 6) on the engine's shaft, turned at 120 rev/min by the motive power (the one driven joint, a velocity
# servo whose torque is what the brake measures). The lever D turns freely about the shaft's axis; its own block of wood lies on the pulley's top and the
# lower block hangs from it on the two screws, a slide in the lever with a spring for the screws' grip (the nuts' setting, turned by hand: slack, then
# screwed up at 1.5 s till the lever rises off C, and eased back at 2.4 s till it hangs level). The friction of both blocks on the turning pulley drags the lever round against the scale B (1.5 kg) hung 36 from the
# shaft's axis; with the screws set to balance it the lever floats between the stops C, C' and the shaft's torque is the weight's moment. A damper on
# the lever stands for the operator's steadying hand (the brake's dashpot). Generator: opencode-runs/batch11/gen244.py.
number: 244
slug: dynamometer
name: A dynamometer, or friction brake for measuring power
brown: "A dynamometer, or instrument used for ascertaining the amount of useful effect given out by any motive-power. ... The blocks or block and straps are so arranged that they may be made to bite or press upon the pulley by means of the screws and nuts on the top of the lever, D. ... At the end of the lever, D, is hung a scale, B, in which weights are placed."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 60, duration_s: 6.5}
bodies:
  - id: pulley
    shape: part
    pos: [0, 0, 0]
    mass: 4
    friction: 0.3
    color: "#d9cfba"
    pieces:
      - {kind: disc, center: [0, 0], radius: 6, y: [-1.6, 1.6], collide: 1}
      - {kind: rod, from: [0, -3.5, 0], to: [0, 6, 0], radius: 1.4, color: "#8f8a80"}   # the shaft
  - id: lever
    shape: part
    pos: [0, 0, 0]
    density: 700           # wood
    friction: 0.3
    color: "#c9b48e"
    pieces:
      - {kind: poly, points: [[-9, 7.5], [40, 7.5], [40, 9.5], [-9, 9.5]], y: [-2, 2], collide: 2}   # the lever D
      - {kind: poly, points: [[-4.5, 6], [4.5, 6], [4.5, 7.5], [-4.5, 7.5]], y: [-1.8, 1.8], collide: 2}   # its block of wood on the pulley
      - {kind: rod, from: [-6.5, 0, 9.5], to: [-6.5, 0, 11.2], radius: 0.55, color: "#8f8a80"}   # the nuts
      - {kind: rod, from: [6.5, 0, 9.5], to: [6.5, 0, 11.2], radius: 0.55, color: "#8f8a80"}
      - {kind: rod, from: [36, 0, 9.5], to: [36, 0, 10.8], radius: 0.5, color: "#8f8a80"}
      - {kind: disc, center: [36, 6.9], radius: 0.7, inner: 0.35, y: [-0.3, 0.3], color: "#8f8a80"}   # the eye
  - id: clamp
    shape: part
    pos: [0, 0, -6]
    mount: lever
    density: 700
    friction: 0.3
    color: "#c9b48e"
    pieces:
      - {kind: poly, points: [[-4.5, -7.6], [4.5, -7.6], [4.5, -6], [-4.5, -6]], y: [-1.8, 1.8], collide: 2}   # the lower block
      - {kind: poly, points: [[-7, -8.3], [7, -8.3], [7, -7.6], [-7, -7.6]], y: [-1.2, 1.2], color: "#8f8a80"}   # its iron strap
      - {kind: rod, from: [-6.5, 0, -8.3], to: [-6.5, 0, 9.5], radius: 0.35, color: "#8f8a80"}   # the screws, up through the lever
      - {kind: rod, from: [6.5, 0, -8.3], to: [6.5, 0, 9.5], radius: 0.35, color: "#8f8a80"}
  - id: scale
    shape: part
    pos: [36, 0, 6.9]
    mount: lever
    mass: 1.5
    color: "#b9a179"
    pieces:
      - {kind: poly, points: [[28, -21], [44, -21], [44, -20.3], [28, -20.3]], y: [-4, 4]}   # the scale B
      - {kind: rod, from: [36, 0, 6.9], to: [28.5, -3.5, -20.3], radius: 0.08, color: "#5c5244"}
      - {kind: rod, from: [36, 0, 6.9], to: [43.5, -3.5, -20.3], radius: 0.08, color: "#5c5244"}
      - {kind: rod, from: [36, 0, 6.9], to: [28.5, 3.5, -20.3], radius: 0.08, color: "#5c5244"}
      - {kind: rod, from: [36, 0, 6.9], to: [43.5, 3.5, -20.3], radius: 0.08, color: "#5c5244"}
      - {kind: rod, from: [35, 0, -20.3], to: [35, 0, -17.2], radius: 1.4, color: "#9c958a"}   # the weights
      - {kind: rod, from: [39.5, 0, -20.3], to: [39.5, 0, -18.4], radius: 0.9, color: "#9c958a"}
      - {kind: rod, from: [31, 0, -20.3], to: [31, 0, -19.5], radius: 1.0, color: "#9c958a"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#a89e8b"
    pieces:
      - {kind: poly, points: [[25, 5.5], [28, 5.5], [28, 6.7], [25, 6.7]], y: [-1.5, 1.5], collide: 1}   # the stop C
      - {kind: poly, points: [[25, 10.3], [28, 10.3], [28, 11.5], [25, 11.5]], y: [-1.5, 1.5], collide: 1}   # the stop C'
      - {kind: rod, from: [26.5, 2.5, 6.1], to: [26.5, 2.5, 10.9], radius: 0.5}   # their post
      - {kind: rod, from: [26.5, 1.5, 6.1], to: [26.5, 2.5, 6.1], radius: 0.4}
      - {kind: rod, from: [26.5, 1.5, 10.9], to: [26.5, 2.5, 10.9], radius: 0.4}
joints:
  - {id: j_shaft, type: hinge, body: pulley, axis: [0, -1, 0], damping: 0.001}   # the one driven joint; +: counter-clockwise as seen
  - {id: j_lever, type: hinge, body: lever, axis: [0, -1, 0], damping: 30}   # free about the shaft's axis; +: the scale's end up
  - {id: j_clamp, type: slide, body: clamp, axis: [0, 0, 1], range: [-1.5, 0.5], stiffness: 20000, springref: -0.4, damping: 200}   # the screws' grip
  - {id: j_scale, type: hinge, body: scale, axis: [0, 1, 0], damping: 0.02}   # the scale hangs on its eye
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_shaft, kind: velocity, rpm: 120, kv: 5, max_torque: 40}
hand:
  - {t: 1.5, springref: {j_clamp: 1.8}}   # screwed up: the lever rises off C
  - {t: 2.4, springref: {j_clamp: 1.6}}   # eased back till it hangs level
checks:
  - {type: turning, joint: j_shaft, direction: 1, min_mean: 11, slow: 0.5, min_fraction: 0.9, settle_s: 0.5, window_s: 6}
  - {type: position, joint: j_lever, min: -0.06, max: -0.02, settle_s: 0.6, window_s: 0.8}   # screws slack: the lever rests on C
  - {type: position, joint: j_lever, min: -0.025, max: 0.025, settle_s: 3.2, window_s: 3.2}   # screwed up: it floats between the stops
  - {type: force, expect: 5.7, tol: 0.3, settle_s: 3.2, window_s: 3.2}   # and the shaft's torque is the weight's moment (N·m)
  - {type: penetration, max: 0.002, settle_s: 0.5}
camera: {target: [15, 0, -4], position: [15, -150, 6], fov: 30}
display:
  output: j_lever
  labels: {j_shaft: "Pulley A on the engine's shaft (driver)", j_lever: "Lever D", j_clamp: "Lower block on the screws", j_scale: "Scale B"}

