# No. 501 (Brown 1868): "Mercurial barometer. Longer leg of bent tube, against which is marked the scale of inches, is closed at top, and
# shorter one is open to the atmosphere ... Column of mercury in longer leg, from which the air has been extracted, is held up by the
# pressure of air on the surface of that in the shorter leg, and rises or falls as the pressure of the atmosphere varies."
# Model (cm, gravity on, Brown's front view). The mercury is lumped vessels (src/fluid/vessels.c, liquid rho 13560, voiding only at
# 0 Pa absolute: a Torricelli vacuum): the long leg (closed, no air over its mercury), the bend, and the short leg (its mouth in the
# air), each a chamber joined by orifices; every surface drawn is the vessels' own, and the column stands at whatever height the air
# on the short leg holds up (76.2 cm at 101325 Pa). The weather is the input, and Brown does not draw it: here the short leg's mouth is in
# a closed jar whose air a plunger, worked by a hand lever (the only drive), compresses and rarefies by about 10 kPa either way.
# Generator: opencode-runs/fluidgen/gen501.py.
number: 501
slug: mercurial-barometer
name: Mercurial barometer
brown: "Mercurial barometer. Longer leg of bent tube, against which is marked the scale of inches, is closed at top, and shorter one is open to the atmosphere, or merely covered with some porous material. Column of mercury in longer leg, from which the air has been extracted, is held up by the pressure of air on the surface of that in the shorter leg, and rises or falls as the pressure of the atmosphere varies. The old-fashioned weather-glass is composed of a similar tube attached to the back of a dial, and a float inserted into the shorter leg of the tube, and geared by a rack and pinion, or cord and pulley, with the spindle of the pointer."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 50, duration_s: 10, floor: false}
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#d6cdb8"
    pieces:
      - {kind: rod, from: [2.18, 0.0, 1.0], to: [2.18, 0.0, 95.0], radius: 0.1, collide: 0, color: "#9fb4bf"}
      - {kind: rod, from: [3.82, 0.0, 1.0], to: [3.82, 0.0, 95.0], radius: 0.1, collide: 0, color: "#9fb4bf"}
      - {kind: rod, from: [-3.82, 0.0, 1.0], to: [-3.82, 0.0, 12.5], radius: 0.1, collide: 0, color: "#9fb4bf"}
      - {kind: rod, from: [-2.18, 0.0, 1.0], to: [-2.18, 0.0, 12.5], radius: 0.1, collide: 0, color: "#9fb4bf"}
      - {kind: rod, from: [2.18, 0.0, 95.0], to: [3.82, 0.0, 95.0], radius: 0.12, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-2.18, 0.0, 1.0], to: [-2.1057, 0.0, 0.43577], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-2.1057, 0.0, 0.43577], to: [-1.8879, 0.0, -0.09], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-1.8879, 0.0, -0.09], to: [-1.5415, 0.0, -0.54149], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-1.5415, 0.0, -0.54149], to: [-1.09, 0.0, -0.88794], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-1.09, 0.0, -0.88794], to: [-0.56423, 0.0, -1.1057], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-0.56423, 0.0, -1.1057], to: [-4.0046e-16, 0.0, -1.18], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-4.0046e-16, 0.0, -1.18], to: [0.56423, 0.0, -1.1057], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [0.56423, 0.0, -1.1057], to: [1.09, 0.0, -0.88794], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [1.09, 0.0, -0.88794], to: [1.5415, 0.0, -0.54149], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [1.5415, 0.0, -0.54149], to: [1.8879, 0.0, -0.09], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [1.8879, 0.0, -0.09], to: [2.1057, 0.0, 0.43577], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [2.1057, 0.0, 0.43577], to: [2.18, 0.0, 1.0], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-3.82, 0.0, 1.0], to: [-3.6898, 0.0, 0.011311], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-3.6898, 0.0, 0.011311], to: [-3.3082, 0.0, -0.91], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-3.3082, 0.0, -0.91], to: [-2.7011, 0.0, -1.7011], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-2.7011, 0.0, -1.7011], to: [-1.91, 0.0, -2.3082], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-1.91, 0.0, -2.3082], to: [-0.98869, 0.0, -2.6898], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-0.98869, 0.0, -2.6898], to: [-7.0172e-16, 0.0, -2.82], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [-7.0172e-16, 0.0, -2.82], to: [0.98869, 0.0, -2.6898], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [0.98869, 0.0, -2.6898], to: [1.91, 0.0, -2.3082], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [1.91, 0.0, -2.3082], to: [2.7011, 0.0, -1.7011], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [2.7011, 0.0, -1.7011], to: [3.3082, 0.0, -0.91], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [3.3082, 0.0, -0.91], to: [3.6898, 0.0, 0.011311], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: rod, from: [3.6898, 0.0, 0.011311], to: [3.82, 0.0, 1.0], radius: 0.1, collide: 0, capsule: true, color: "#9fb4bf"}
      - {kind: poly, points: [[4.2, 77.58], [9.5, 77.58], [9.5, 89.01], [4.2, 89.01]], y: [0.7, 1.1], collide: 0, color: "#b9a27a"}
      - {kind: rod, from: [4.2, 0.6, 78.85], to: [6.6, 0.6, 78.85], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 79.485], to: [5.4, 0.6, 79.485], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 80.12], to: [5.4, 0.6, 80.12], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 80.755], to: [5.4, 0.6, 80.755], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 81.39], to: [6.6, 0.6, 81.39], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 82.025], to: [5.4, 0.6, 82.025], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 82.66], to: [5.4, 0.6, 82.66], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 83.295], to: [5.4, 0.6, 83.295], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 83.93], to: [6.6, 0.6, 83.93], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 84.565], to: [5.4, 0.6, 84.565], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 85.2], to: [5.4, 0.6, 85.2], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 85.835], to: [5.4, 0.6, 85.835], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 86.47], to: [6.6, 0.6, 86.47], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 87.105], to: [5.4, 0.6, 87.105], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 87.74], to: [5.4, 0.6, 87.74], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 88.375], to: [5.4, 0.6, 88.375], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [4.2, 0.6, 89.01], to: [6.6, 0.6, 89.01], radius: 0.07, collide: 0, color: "#2b2620"}
      - {kind: poly, points: [[-9.9088, 7.0], [-2.0912, 7.0], [-2.0912, 21.0], [-9.9088, 21.0]], y: [3.9088, 4.1588], collide: 0, color: "#c9d6dc"}
      - {kind: poly, points: [[-10.159, 6.6], [-9.9088, 6.6], [-9.9088, 21.4], [-10.159, 21.4]], y: [-3.9088, 3.9088], collide: 0, color: "#9fb4bf"}
      - {kind: poly, points: [[-2.0912, 6.6], [-1.8412, 6.6], [-1.8412, 21.4], [-2.0912, 21.4]], y: [-3.9088, 3.9088], collide: 0, color: "#9fb4bf"}
      - {kind: poly, points: [[-10.159, 6.4], [-1.8412, 6.4], [-1.8412, 7.0], [-10.159, 7.0]], y: [-3.9088, 3.9088], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-10.159, 21.0], [-7.6, 21.0], [-7.6, 21.5], [-10.159, 21.5]], y: [-3.9088, 3.9088], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-4.4, 21.0], [-1.8412, 21.0], [-1.8412, 21.5], [-4.4, 21.5]], y: [-3.9088, 3.9088], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-7.6, 21.0], [-4.4, 21.0], [-4.4, 38.0], [-7.6, 38.0]], y: [1.6, 1.9], collide: 0, color: "#8b7d66"}
      - {kind: poly, points: [[-7.9, 21.0], [-7.6, 21.0], [-7.6, 38.0], [-7.9, 38.0]], y: [-1.6, 1.6], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-4.4, 21.0], [-4.1, 21.0], [-4.1, 38.0], [-4.4, 38.0]], y: [-1.6, 1.6], collide: 0, color: "#6d675c"}
      - {kind: rod, from: [-25.0, 0.9, -3.0], to: [-25.0, 0.9, 48.0], radius: 0.45, collide: 0, color: "#6d675c"}
      - {kind: rod, from: [1.5, 0.9, -3.0], to: [1.5, 0.9, 95.0], radius: 0.4, collide: 0, color: "#b9a27a"}
      - {kind: rod, from: [1.5, 0.9, 20.0], to: [3.0, 0.9, 20.0], radius: 0.25, collide: 0, color: "#6d675c"}
      - {kind: rod, from: [1.5, 0.9, 60.0], to: [3.0, 0.9, 60.0], radius: 0.25, collide: 0, color: "#6d675c"}
      - {kind: rod, from: [1.5, 0.9, 90.0], to: [3.0, 0.9, 90.0], radius: 0.25, collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-31.0, -3.5], [22.0, -3.5], [22.0, -2.5], [-31.0, -2.5]], y: [-4.0, 4.0], collide: 0, color: "#8b7d66"}
  - id: lever
    shape: part
    pos: [-25.0, 0, 48]
    mass: 0.12
    color: "#5f5a52"
    pieces:
      - {kind: rod, from: [-37.0, -0.6, 48.6], to: [-25.0, -0.6, 48.0], radius: 0.42, collide: 0, capsule: true}
      - {kind: rod, from: [-25.0, -0.6, 48.0], to: [-6.0, -0.6, 48.0], radius: 0.42, collide: 0, capsule: true}
      - {kind: rod, from: [-25.0, -1.2, 48.0], to: [-25.0, 0.2, 48.0], radius: 0.6, collide: 0}
      - {kind: rod, from: [-6.0, -1.2, 48.0], to: [-6.0, 0.2, 48.0], radius: 0.45, collide: 0}
  - id: plunger
    shape: part
    pos: [-6.0, 0, 26.0]
    mass: 0.05
    color: "#8a8478"
    pieces:
      - {kind: disc, center: [-6.0, 26.5], radius: 1.57, y: [-1.6, 1.6], collide: 0, color: "#4f3b28"}
      - {kind: rod, from: [-6.0, 0.0, 27.0], to: [-6.0, 0.0, 40.0], radius: 0.3, collide: 0}
  - id: crod
    shape: part
    mount: plunger
    pos: [-6.0, 0, 40]
    mass: 0.01
    color: "#6d675c"
    pieces:
      - {kind: rod, from: [-6.0, -0.6, 40.0], to: [-6.0, -0.6, 48.0], radius: 0.3, collide: 0, capsule: true}
joints:
  - {id: j_lever, type: hinge, body: lever, axis: [0, 1, 0], damping: 0.002}   # the hand's lever (the only drive)
  - {id: j_p, type: slide, body: plunger, axis: [0, 0, 1], range: [-12, 12], damping: 0.01, frictionloss: 25}   # the plunger in its packing
  - {id: j_c, type: hinge, body: crod, axis: [0, 1, 0], damping: 0.0005}
pins:
  - {id: p_L, a: lever, b: crod, at: [-6.0, 0, 48]}
vessels:
  substeps: 8
  liquid: {rho: 13560, void: -101325, color: "#7e858c"}
  nodes:
    - {id: jar, kind: chamber, fixed: 7.0, sections: [[7.0, 48.0], [21.0, 8.0425]], volume: 712.21, water: 0}   # air only, its top the plunger's face
    - {id: long, kind: chamber, fixed: 5, sections: [[5, 1.5394]], volume: 138.54, water: 123.41, p: -101325, K: 2000000,
       draw: {sections: [[[2.3, 5], [3.7, 5], [3.7, 95.0], [2.3, 95.0]]], y: [-0.7, 0.7]}}   # no air over it
    - {id: bend, kind: chamber, fixed: -2, sections: [[-2, 3.8319]], volume: 26.823, water: 26.823, K: 2000000,
       draw: {sections: [[[2.3, 1.0], [3.7, 1.0], [3.7, 5.0], [2.3, 5.0]], [[-3.7, 1.0], [-2.3, 1.0], [-2.3, 5.0], [-3.7, 5.0]], [[-2.3, 1.0], [-3.7, 1.0], [-3.2043, -0.85], [-1.9919, -0.15]], [[-1.9919, -0.15], [-3.2043, -0.85], [-1.85, -2.2043], [-1.15, -0.99186]], [[-1.15, -0.99186], [-1.85, -2.2043], [-6.7968e-16, -2.7], [-4.225e-16, -1.3]], [[-4.225e-16, -1.3], [-6.7968e-16, -2.7], [1.85, -2.2043], [1.15, -0.99186]], [[1.15, -0.99186], [1.85, -2.2043], [3.2043, -0.85], [1.9919, -0.15]], [[1.9919, -0.15], [3.2043, -0.85], [3.7, 1.0], [2.3, 1.0]]], y: [-0.7, 0.7]}}
    - {id: short, kind: chamber, fixed: 5, sections: [[5, 1.5394]], volume: 11.545, water: 6.1575, K: 2000000,
       draw: {sections: [[[-3.7, 5], [-2.3, 5], [-2.3, 12.5], [-3.7, 12.5]]], y: [-0.7, 0.7]}}   # its mouth open in the jar
  links:
    - {id: mouth, from: jar, to: short, area: 1.5394, cd: 0.62, z: 8.0, zTo: 12.3}   # the jar's air on the short leg's mercury
    - {id: bendL, from: bend, to: long, area: 1.5394, cd: 0.8, z: 5, zTo: 5}
    - {id: bendS, from: bend, to: short, area: 1.5394, cd: 0.8, z: 5, zTo: 5}
  pistons:
    - {node: jar, joint: j_p, area: 8.0425, sign: 1}
driver: {joint: j_lever, kind: velocity, rpm: 0, swing: {amplitude: 0.35, hz: 0.2}, kv: 2000, max_torque: 40}
checks:
  - {type: amplitude, joint: j_p, min: 0.04, max: 0.09, settle_s: 1.0, window_s: 8}
  - {type: penetration, max: 0.003}
camera: {target: [-7.5, 0, 21.6], position: [-7.5, -300, 24.6], fov: 28.8}
display:
  output: j_p
  labels: {j_lever: "Pump lever (driver)", j_p: "Plunger", j_c: "Connecting rod"}
