# No. 500 (Brown 1868): "Pressure gauge now most commonly used. Sometimes known as the 'Magdeburg gauge' ... The fluid whose pressure is
# to be measured acts upon a circular metal disk, A, generally corrugated, and the deflection of the disk under the pressure gives motion
# to a toothed sector, e, which gears with a pinion on the spindle of the pointer."
# Model (cm, gravity on): Brown's face view and section drawn as one, the dial behind and the works in front of it with the case cut away.
# The pressure is lumped vessels (src/fluid/vessels.c): a pump barrel's air (the only drive is the hand lever on its plunger) piped to the
# cell under A. A is a piston on that cell (50.3 cm^2) on its own spring (10000 N/m, standing at q = 0 under 20 kPa); a rod
# from its stud turns the sector e by its crank pin, and e's teeth (collision) turn the pinion and pointer against a light hairspring.
# The dial is graduated every 2.5 kPa (7.5 to 32.5) from a run of this model (a cubic; the pointer within 0.06 rad of it).
# Generator: opencode-runs/fluidgen/gen500.py (CAL=6.90129e-14,-4.2475e-09,0.000218627,-3.29345).
number: 500
slug: magdeburg-pressure-gauge
name: Magdeburg pressure gauge
brown: "Pressure gauge now most commonly used. Sometimes known as the “Magdeburg gauge,” from the name of the place where first manufactured. Face view and section. The fluid whose pressure is to be measured acts upon a circular metal disk, A, generally corrugated, and the deflection of the disk under the pressure gives motion to a toothed sector, e, which gears with a pinion on 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: disc, center: [0.0, 30.0], radius: 12.0, y: [1.0, 1.4], collide: 0, color: "#f1ece0"}
      - {kind: disc, center: [0.0, 30.0], radius: 12.8, y: [-3.6, 1.6], collide: 0, inner: 12.0, color: "#8f8a80"}
      - {kind: poly, points: [[-4.6, 10.0], [4.6, 10.0], [4.6, 10.5], [-4.6, 10.5]], y: [-4.0, 4.0], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-4.0, 10.5], [-4.6, 10.5], [-4.6, 12.8], [-4.0, 12.8]], y: [-4.0, 4.0], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[4.0, 10.5], [4.6, 10.5], [4.6, 12.8], [4.0, 12.8]], y: [-4.0, 4.0], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-4.0, 10.5], [4.0, 10.5], [4.0, 12.0], [-4.0, 12.0]], y: [3.7, 4.0], collide: 0, color: "#c9d6dc"}
      - {kind: poly, points: [[-0.5, 12.8], [0.5, 12.8], [0.5, 22.5], [-0.5, 22.5]], y: [0.0, 0.9], collide: 0, color: "#6d675c"}
      - {kind: rod, from: [0.0, -1.0, 22.5], to: [0.0, 1.0, 22.5], radius: 0.35, collide: 0, color: "#6d675c"}
      - {kind: rod, from: [0.0, -1.0, 30.0], to: [0.0, 1.0, 30.0], radius: 0.3, collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-1.0, 4.0], [1.0, 4.0], [1.0, 10.0], [-1.0, 10.0]], y: [-1.0, 1.0], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-2.2, 4.0], [2.2, 4.0], [2.2, 6.0], [-2.2, 6.0]], y: [-2.2, 2.2], collide: 0, color: "#7d776c"}
      - {kind: rod, from: [0.0, 0.0, 4.0], to: [0.0, 0.0, 2.0], radius: 0.35, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [0.0, 0.0, 2.0], to: [24.0, 0.0, 2.0], radius: 0.35, collide: 0, capsule: true, color: "#5f5a52"}
      - {kind: rod, from: [24.0, 0.0, 2.0], to: [24.0, 0.0, 0.2], radius: 0.35, collide: 0, capsule: true, color: "#5f5a52"}
      - {kind: rod, from: [-9.6703, 0.9, 27.085], to: [-10.149, 0.9, 26.941], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [-9.6436, 0.9, 31.044], to: [-10.538, 0.9, 31.141], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [-8.9526, 0.9, 34.676], to: [-9.3958, 0.9, 34.907], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [-6.5177, 0.9, 37.184], to: [-7.1225, 0.9, 37.85], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [-3.9183, 0.9, 39.309], to: [-4.1123, 0.9, 39.77], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [-0.65722, 0.9, 39.678], to: [-0.7182, 0.9, 40.576], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [2.6108, 0.9, 39.757], to: [2.74, 0.9, 40.24], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [5.4439, 0.9, 38.028], to: [5.949, 0.9, 38.773], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [8.1675, 0.9, 35.942], to: [8.5718, 0.9, 36.236], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [9.3618, 0.9, 32.539], to: [10.23, 0.9, 32.775], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: rod, from: [10.023, 0.9, 28.753], to: [10.519, 0.9, 28.691], radius: 0.09, collide: 0, color: "#2b2620"}
      - {kind: poly, points: [[22.4, 0.0], [25.6, 0.0], [25.6, 24.0], [22.4, 24.0]], y: [1.6, 1.9], collide: 0, color: "#8b7d66"}
      - {kind: poly, points: [[22.1, -0.4], [22.4, -0.4], [22.4, 24.0], [22.1, 24.0]], y: [-1.6, 1.6], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[25.6, -0.4], [25.9, -0.4], [25.9, 24.0], [25.6, 24.0]], y: [-1.6, 1.6], collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[22.1, -0.8], [25.9, -0.8], [25.9, 0.0], [22.1, 0.0]], y: [-1.6, 1.6], collide: 0, color: "#6d675c"}
      - {kind: rod, from: [36.0, 0.9, -3.0], to: [36.0, 0.9, 30.0], radius: 0.45, collide: 0, color: "#6d675c"}
      - {kind: poly, points: [[-14.0, -3.5], [42.0, -3.5], [42.0, -2.5], [-14.0, -2.5]], y: [-4.0, 4.0], collide: 0, color: "#8b7d66"}
  - id: disk
    shape: part
    pos: [0.0, 0, 12.0]
    mass: 0.02
    color: "#c9a35a"
    pieces:
      - {kind: poly, points: [[-3.95, 12.12], [-3.4563, 12.26], [-3.4563, 12.38], [-3.95, 12.24]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-3.4563, 12.26], [-2.9625, 11.98], [-2.9625, 12.1], [-3.4563, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-2.9625, 11.98], [-2.4688, 12.26], [-2.4688, 12.38], [-2.9625, 12.1]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-2.4688, 12.26], [-1.975, 11.98], [-1.975, 12.1], [-2.4688, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-1.975, 11.98], [-1.4813, 12.26], [-1.4813, 12.38], [-1.975, 12.1]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-1.4813, 12.26], [-0.9875, 11.98], [-0.9875, 12.1], [-1.4813, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-0.9875, 11.98], [-0.49375, 12.26], [-0.49375, 12.38], [-0.9875, 12.1]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-0.49375, 12.26], [0.0, 11.98], [0.0, 12.1], [-0.49375, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[0.0, 11.98], [0.49375, 12.26], [0.49375, 12.38], [0.0, 12.1]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[0.49375, 12.26], [0.9875, 11.98], [0.9875, 12.1], [0.49375, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[0.9875, 11.98], [1.4813, 12.26], [1.4813, 12.38], [0.9875, 12.1]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[1.4813, 12.26], [1.975, 11.98], [1.975, 12.1], [1.4813, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[1.975, 11.98], [2.4688, 12.26], [2.4688, 12.38], [1.975, 12.1]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[2.4688, 12.26], [2.9625, 11.98], [2.9625, 12.1], [2.4688, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[2.9625, 11.98], [3.4562, 12.26], [3.4562, 12.38], [2.9625, 12.1]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[3.4562, 12.26], [3.95, 12.12], [3.95, 12.24], [3.4562, 12.38]], y: [-3.95, 3.95], collide: 0, color: "#c9a35a"}
      - {kind: poly, points: [[-0.6, 12.0], [0.6, 12.0], [0.6, 12.35], [-0.6, 12.35]], y: [-0.6, 0.6], collide: 0, color: "#c9a35a"}
      - {kind: rod, from: [1.5, -1.6, 12.25], to: [1.5, -1.6, 12.8], radius: 0.3, collide: 0, color: "#6d675c"}
  - id: rod
    shape: part
    pos: [1.5, 0, 12.3]
    mount: disk
    mass: 0.002
    pieces:
      - {kind: rod, from: [1.5, -2.0, 12.3], to: [1.5, -2.0, 22.5], radius: 0.18, collide: 0, capsule: true, color: "#5f5a52"}
      - {kind: rod, from: [1.5, -2.2, 12.3], to: [1.5, -0.4, 12.3], radius: 0.22, collide: 0, color: "#6d675c"}
      - {kind: rod, from: [1.5, -2.2, 22.5], to: [1.5, -0.8, 22.5], radius: 0.22, collide: 0, color: "#6d675c"}
  - id: sector
    shape: part
    pos: [0.0, 0, 22.5]
    mass: 0.004
    friction: 0.1
    pieces:
      - {kind: poly, points: [[0.0, 22.5], [3.5996, 26.79], [0.0, 28.1], [-3.5996, 26.79]], y: [-1.5, -0.9], collide: 0, color: "#b8ad97"}
      - {kind: poly, points: [[0.0, 22.1], [1.5, 22.1], [1.5, 22.9], [0.0, 22.9]], y: [-1.5, -0.9], collide: 0, color: "#b8ad97"}
      - {kind: disc, center: [0.0, 22.5], radius: 0.7, y: [-1.6, -0.8], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[4.1653, 26.332], [3.8321, 26.665], [4.3775, 27.011], [4.5108, 26.878]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[3.5145, 26.936], [3.1333, 27.213], [3.618, 27.64], [3.7705, 27.529]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[2.7773, 27.432], [2.3574, 27.646], [2.7694, 28.143], [2.9373, 28.057]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[1.9716, 27.805], [1.5234, 27.951], [1.8525, 28.507], [2.0318, 28.448]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[1.1174, 28.049], [0.65192, 28.122], [0.8901, 28.722], [1.0763, 28.693]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[0.23562, 28.155], [-0.23562, 28.155], [-0.094248, 28.785], [0.094248, 28.785]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[-0.65192, 28.122], [-1.1174, 28.049], [-1.0763, 28.693], [-0.8901, 28.722]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[-1.5234, 27.951], [-1.9716, 27.805], [-2.0318, 28.448], [-1.8525, 28.507]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[-2.3574, 27.646], [-2.7773, 27.432], [-2.9373, 28.057], [-2.7694, 28.143]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[-3.1333, 27.213], [-3.5145, 26.936], [-3.7705, 27.529], [-3.618, 27.64]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
      - {kind: poly, points: [[-3.8321, 26.665], [-4.1653, 26.332], [-4.5108, 26.878], [-4.3775, 27.011]], y: [-1.5, -0.9], collide: 1, color: "#b8ad97"}
  - id: pinion
    shape: part
    pos: [0.0, 0, 30.0]
    mass: 0.003
    friction: 0.1
    pieces:
      - {kind: disc, center: [0.0, 30.0], radius: 1.175, y: [-1.6, -0.8], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[0.13283, 28.829], [0.581, 28.974], [0.64123, 28.331], [0.46196, 28.273]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[0.79592, 29.13], [1.0729, 29.512], [1.4995, 29.027], [1.3887, 28.875]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[1.155, 29.764], [1.155, 30.236], [1.785, 30.094], [1.785, 29.906]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[1.0729, 30.488], [0.79592, 30.87], [1.3887, 31.125], [1.4995, 30.973]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[0.581, 31.026], [0.13283, 31.171], [0.46196, 31.727], [0.64123, 31.669]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[-0.13283, 31.171], [-0.581, 31.026], [-0.64123, 31.669], [-0.46196, 31.727]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[-0.79592, 30.87], [-1.0729, 30.488], [-1.4995, 30.973], [-1.3887, 31.125]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[-1.155, 30.236], [-1.155, 29.764], [-1.785, 29.906], [-1.785, 30.094]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[-1.0729, 29.512], [-0.79592, 29.13], [-1.3887, 28.875], [-1.4995, 29.027]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[-0.581, 28.974], [-0.13283, 28.829], [-0.46196, 28.273], [-0.64123, 28.331]], y: [-1.5, -0.9], collide: 2, color: "#8f8a80"}
      - {kind: rod, from: [0.0, -3.0, 27.5], to: [0.0, -3.0, 40.2], radius: 0.16, collide: 0, capsule: true, color: "#2a2a2a"}
      - {kind: disc, center: [0.0, 30.0], radius: 0.55, y: [-3.3, -0.8], collide: 0, color: "#2a2a2a"}
  - id: lever
    shape: part
    pos: [36.0, 0, 30.0]
    mass: 0.12
    color: "#5f5a52"
    pieces:
      - {kind: rod, from: [48.0, -0.6, 30.6], to: [36.0, -0.6, 30.0], radius: 0.42, collide: 0, capsule: true}
      - {kind: rod, from: [36.0, -0.6, 30.0], to: [24.0, -0.6, 30.0], radius: 0.42, collide: 0, capsule: true}
      - {kind: rod, from: [36.0, -1.2, 30.0], to: [36.0, 0.2, 30.0], radius: 0.6, collide: 0}
      - {kind: rod, from: [24.0, -1.2, 30.0], to: [24.0, 0.2, 30.0], radius: 0.45, collide: 0}
  - id: plunger
    shape: part
    pos: [24.0, 0, 12.0]
    mass: 0.05
    color: "#8a8478"
    pieces:
      - {kind: disc, center: [24.0, 12.5], radius: 1.57, y: [-1.6, 1.6], collide: 0, color: "#4f3b28"}
      - {kind: rod, from: [24.0, 0.0, 13.0], to: [24.0, 0.0, 22.0], radius: 0.3, collide: 0}
  - id: crod
    shape: part
    pos: [24.0, 0, 22.0]
    mount: plunger
    mass: 0.01
    pieces:
      - {kind: rod, from: [24.0, -0.6, 22.0], to: [24.0, -0.6, 30.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: 40}   # the plunger in its packing
  - {id: j_c, type: hinge, body: crod, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_d, type: slide, body: disk, axis: [0, 0, 1], damping: 20, stiffness: 10000, springref: -1.0053, range: [-1.2, 1.2]}   # + : A rising
  - {id: j_r, type: hinge, body: rod, axis: [0, 1, 0], damping: 0.0001}
  - {id: j_s, type: hinge, body: sector, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_ptr, type: hinge, body: pinion, axis: [0, 1, 0], damping: 0.0002, stiffness: 0.0003, springref: -3}   # the hairspring, wound up so that it always takes up the teeth's backlash
pins:
  - {id: p_L, a: lever, b: crod, at: [24.0, 0, 30.0]}
  - {id: p_K, a: rod, b: sector, at: [1.5, 0, 22.5]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
vessels:
  substeps: 8
  nodes:
    - {id: pump, kind: chamber, fixed: 0.0, sections: [[0.0, 8.0425]], volume: 104.01, water: 0, p: 20000}   # the barrel's air under the plunger
    - {id: cell, kind: chamber, fixed: 0, sections: [[0, 50.265]], volume: 75.398, water: 0, p: 20000}   # the cell under A (plus A's sweep)
  links:
    - {id: stem, from: pump, to: cell, area: 0.05, cd: 0.62, z: 0.5, zTo: 0.5}
  pistons:
    - {node: pump, joint: j_p, area: 8.0425, sign: 1}
    - {node: cell, joint: j_d, area: 50.265, sign: 1}
driver: {joint: j_lever, kind: velocity, rpm: 0, swing: {amplitude: 0.45, hz: 0.2}, kv: 2000, max_torque: 40}
checks:
  - {type: amplitude, joint: j_p, min: 0.03, max: 0.06, settle_s: 1.0, window_s: 8}
  - {type: penetration, max: 0.003}
camera: {target: [11, 0, 17], position: [11, -300, 19], fov: 14}
display:
  output: j_ptr
  labels: {j_lever: "Pump lever (driver)", j_p: "Plunger", j_d: "Disk A", j_s: "Toothed sector", j_ptr: "Pinion and pointer"}
