# No. 479 (Brown 1868): "Gasometer. The open-bottomed vessel, A, is arranged in the tank, B, of water, and partly counterbalanced by weights, C, C. Gas enters the gasometer by one and leaves it by the other of the two pipes inserted through the bottom of the tank. As gas enters, vessel, A, rises, and vice versa. The pressure is regulated by adding to or reducing the weights, C, C."
# Model (cm, gravity on, the tank and the gasometer cut away in half section, seen from in front). The gasometer A (34 cm inside,
# 6 kg) stands open below in the tank B of water and hangs by two chains over pulleys from the weights C, C (2 kg each), so
# what is left of its weight presses the gas at about 216 Pa. Gas comes from the works (600 Pa) up the left pipe through the
# tank's floor and goes out by the right pipe to the burners through a cock; a hand turns the cock open and shut (swung
# +-0.7 rad at 0.125 Hz, the only drive). A's inside is a lumped chamber (src/fluid/vessels.c) of water under gas, joined
# to the tank's water (an open chamber) under A's rim: the gas let in goes into the chamber's gas (fix-gas-into-chamber-air), its
# pressure lifts A against what the weights leave of its weight, and the water inside stands lower than outside by that pressure.
# While the cock is shut A rises as the gas comes in; open, more goes out than comes in and A sinks. Both waters are drawn from
# their levels. Generator: opencode-runs/water/gen479.py.
number: 479
slug: gasometer
name: Gasometer
brown: "Gasometer. The open-bottomed vessel, A, is arranged in the tank, B, of water, and partly counterbalanced by weights, C, C. Gas enters the gasometer by one and leaves it by the other of the two pipes inserted through the bottom of the tank. As gas enters, vessel, A, rises, and vice versa. The pressure is regulated by adding to or reducing the weights, C, C."
units: cm
sim:
  timestep: 0.0005
  integrator: implicitfast
  iterations: 60
  duration_s: 18
  floor: false
bodies:
  - id: bell
    shape: part
    pos: [0, 0, 56]
    mass: 6
    color: "#7d7a72"
    pieces:
      - {kind: loft, a: [[17, 0, 56], [16.4207, 4.3999, 56], [16.9037, 4.5293, 56], [17.5, 0, 56]], b: [[17, 0, 26], [16.4207, 4.3999, 26], [16.9037, 4.5293, 26], [17.5, 0, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[16.4207, 4.3999, 56], [14.7224, 8.5, 56], [15.1554, 8.75, 56], [16.9037, 4.5293, 56]], b: [[16.4207, 4.3999, 26], [14.7224, 8.5, 26], [15.1554, 8.75, 26], [16.9037, 4.5293, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[14.7224, 8.5, 56], [12.0208, 12.0208, 56], [12.3744, 12.3744, 56], [15.1554, 8.75, 56]], b: [[14.7224, 8.5, 26], [12.0208, 12.0208, 26], [12.3744, 12.3744, 26], [15.1554, 8.75, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[12.0208, 12.0208, 56], [8.5, 14.7224, 56], [8.75, 15.1554, 56], [12.3744, 12.3744, 56]], b: [[12.0208, 12.0208, 26], [8.5, 14.7224, 26], [8.75, 15.1554, 26], [12.3744, 12.3744, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[8.5, 14.7224, 56], [4.3999, 16.4207, 56], [4.5293, 16.9037, 56], [8.75, 15.1554, 56]], b: [[8.5, 14.7224, 26], [4.3999, 16.4207, 26], [4.5293, 16.9037, 26], [8.75, 15.1554, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[4.3999, 16.4207, 56], [0, 17, 56], [0, 17.5, 56], [4.5293, 16.9037, 56]], b: [[4.3999, 16.4207, 26], [0, 17, 26], [0, 17.5, 26], [4.5293, 16.9037, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[0, 17, 56], [-4.3999, 16.4207, 56], [-4.5293, 16.9037, 56], [0, 17.5, 56]], b: [[0, 17, 26], [-4.3999, 16.4207, 26], [-4.5293, 16.9037, 26], [0, 17.5, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-4.3999, 16.4207, 56], [-8.5, 14.7224, 56], [-8.75, 15.1554, 56], [-4.5293, 16.9037, 56]], b: [[-4.3999, 16.4207, 26], [-8.5, 14.7224, 26], [-8.75, 15.1554, 26], [-4.5293, 16.9037, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-8.5, 14.7224, 56], [-12.0208, 12.0208, 56], [-12.3744, 12.3744, 56], [-8.75, 15.1554, 56]], b: [[-8.5, 14.7224, 26], [-12.0208, 12.0208, 26], [-12.3744, 12.3744, 26], [-8.75, 15.1554, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-12.0208, 12.0208, 56], [-14.7224, 8.5, 56], [-15.1554, 8.75, 56], [-12.3744, 12.3744, 56]], b: [[-12.0208, 12.0208, 26], [-14.7224, 8.5, 26], [-15.1554, 8.75, 26], [-12.3744, 12.3744, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-14.7224, 8.5, 56], [-16.4207, 4.3999, 56], [-16.9037, 4.5293, 56], [-15.1554, 8.75, 56]], b: [[-14.7224, 8.5, 26], [-16.4207, 4.3999, 26], [-16.9037, 4.5293, 26], [-15.1554, 8.75, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-16.4207, 4.3999, 56], [-17, 0, 56], [-17.5, 0, 56], [-16.9037, 4.5293, 56]], b: [[-16.4207, 4.3999, 26], [-17, 0, 26], [-17.5, 0, 26], [-16.9037, 4.5293, 26]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-17.5, 0, 56.6], [17.5, 0, 56.6], [17.5, 17.5, 56.6], [-17.5, 17.5, 56.6]], b: [[-17.5, 0, 56], [17.5, 0, 56], [17.5, 17.5, 56], [-17.5, 17.5, 56]], collide: 0, color: "#7d7a72"}
      - {kind: rod, from: [-16, -0.6, 57.6], to: [-16, 0.6, 57.6], radius: 0.4, collide: 0, color: "#6d675c"}
      - {kind: rod, from: [16, -0.6, 57.6], to: [16, 0.6, 57.6], radius: 0.4, collide: 0, color: "#6d675c"}
  - id: cock
    shape: part
    pos: [34, 0, 5.5]
    mass: 0.3
    color: "#6d675c"
    pieces:
      - {kind: rod, from: [34, -2.2, 5.5], to: [34, -0.6, 5.5], radius: 0.8, collide: 0}
      - {kind: rod, from: [34, -2, 5.5], to: [34, -2, 13.5], radius: 0.45, capsule: true, collide: 0}
      - {kind: loft, a: [[33.2, -2.6, 15], [34.8, -2.6, 15], [34.8, -1.4, 15], [33.2, -1.4, 15]], b: [[33.2, -2.6, 13], [34.8, -2.6, 13], [34.8, -1.4, 13], [33.2, -1.4, 13]], collide: 0, color: "#6d675c"}
  - id: weight_l
    shape: part
    pos: [-27.2, 0, 50]
    mass: 2
    color: "#55524c"
    pieces:
      - {kind: rod, from: [-27.2, 0, 50], to: [-27.2, 0, 43], radius: 2, collide: 0}
      - {kind: rod, from: [-27.2, -0.5, 50.2], to: [-27.2, 0.5, 50.2], radius: 0.35, collide: 0}
  - id: weight_r
    shape: part
    pos: [27.2, 0, 50]
    mass: 2
    color: "#55524c"
    pieces:
      - {kind: rod, from: [27.2, 0, 50], to: [27.2, 0, 43], radius: 2, collide: 0}
      - {kind: rod, from: [27.2, -0.5, 50.2], to: [27.2, 0.5, 50.2], radius: 0.35, collide: 0}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#d6cdb8"
    pieces:
      - {kind: loft, a: [[-48, -10, 0], [48, -10, 0], [48, 24, 0], [-48, 24, 0]], b: [[-48, -10, -1.5], [48, -10, -1.5], [48, 24, -1.5], [-48, 24, -1.5]], collide: 0, color: "#8b7d66"}
      - {kind: loft, a: [[-21, 0, 3], [21, 0, 3], [21, 21, 3], [-21, 21, 3]], b: [[-21, 0, 0], [21, 0, 0], [21, 21, 0], [-21, 21, 0]], collide: 0, color: "#9a6a4f"}
      - {kind: loft, a: [[-21, 0, 9], [-15, 0, 9], [-15, 21, 9], [-21, 21, 9]], b: [[-21, 0, 3], [-15, 0, 3], [-15, 21, 3], [-21, 21, 3]], collide: 0, color: "#9a6a4f"}
      - {kind: loft, a: [[15, 0, 9], [21, 0, 9], [21, 21, 9], [15, 21, 9]], b: [[15, 0, 3], [21, 0, 3], [21, 21, 3], [15, 21, 3]], collide: 0, color: "#9a6a4f"}
      - {kind: loft, a: [[20, 0, 44], [19.3185, 5.1764, 44], [20.0913, 5.3834, 44], [20.8, 0, 44]], b: [[20, 0, 9], [19.3185, 5.1764, 9], [20.0913, 5.3834, 9], [20.8, 0, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[19.3185, 5.1764, 44], [17.3205, 10, 44], [18.0133, 10.4, 44], [20.0913, 5.3834, 44]], b: [[19.3185, 5.1764, 9], [17.3205, 10, 9], [18.0133, 10.4, 9], [20.0913, 5.3834, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[17.3205, 10, 44], [14.1421, 14.1421, 44], [14.7078, 14.7078, 44], [18.0133, 10.4, 44]], b: [[17.3205, 10, 9], [14.1421, 14.1421, 9], [14.7078, 14.7078, 9], [18.0133, 10.4, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[14.1421, 14.1421, 44], [10, 17.3205, 44], [10.4, 18.0133, 44], [14.7078, 14.7078, 44]], b: [[14.1421, 14.1421, 9], [10, 17.3205, 9], [10.4, 18.0133, 9], [14.7078, 14.7078, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[10, 17.3205, 44], [5.1764, 19.3185, 44], [5.3834, 20.0913, 44], [10.4, 18.0133, 44]], b: [[10, 17.3205, 9], [5.1764, 19.3185, 9], [5.3834, 20.0913, 9], [10.4, 18.0133, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[5.1764, 19.3185, 44], [0, 20, 44], [0, 20.8, 44], [5.3834, 20.0913, 44]], b: [[5.1764, 19.3185, 9], [0, 20, 9], [0, 20.8, 9], [5.3834, 20.0913, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[0, 20, 44], [-5.1764, 19.3185, 44], [-5.3834, 20.0913, 44], [0, 20.8, 44]], b: [[0, 20, 9], [-5.1764, 19.3185, 9], [-5.3834, 20.0913, 9], [0, 20.8, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-5.1764, 19.3185, 44], [-10, 17.3205, 44], [-10.4, 18.0133, 44], [-5.3834, 20.0913, 44]], b: [[-5.1764, 19.3185, 9], [-10, 17.3205, 9], [-10.4, 18.0133, 9], [-5.3834, 20.0913, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-10, 17.3205, 44], [-14.1421, 14.1421, 44], [-14.7078, 14.7078, 44], [-10.4, 18.0133, 44]], b: [[-10, 17.3205, 9], [-14.1421, 14.1421, 9], [-14.7078, 14.7078, 9], [-10.4, 18.0133, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-14.1421, 14.1421, 44], [-17.3205, 10, 44], [-18.0133, 10.4, 44], [-14.7078, 14.7078, 44]], b: [[-14.1421, 14.1421, 9], [-17.3205, 10, 9], [-18.0133, 10.4, 9], [-14.7078, 14.7078, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-17.3205, 10, 44], [-19.3185, 5.1764, 44], [-20.0913, 5.3834, 44], [-18.0133, 10.4, 44]], b: [[-17.3205, 10, 9], [-19.3185, 5.1764, 9], [-20.0913, 5.3834, 9], [-18.0133, 10.4, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-19.3185, 5.1764, 44], [-20, 0, 44], [-20.8, 0, 44], [-20.0913, 5.3834, 44]], b: [[-19.3185, 5.1764, 9], [-20, 0, 9], [-20.8, 0, 9], [-20.0913, 5.3834, 9]], collide: 0, color: "#7d7a72"}
      - {kind: loft, a: [[-20.8, 0, 10], [20.8, 0, 10], [20.8, 20.8, 10], [-20.8, 20.8, 10]], b: [[-20.8, 0, 9], [20.8, 0, 9], [20.8, 20.8, 9], [-20.8, 20.8, 9]], collide: 0, color: "#7d7a72"}
      - {kind: rod, from: [-7, 1.2, 5.5], to: [-7, 1.2, 41], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [-7, 1.2, 5.5], to: [-48, 1.2, 5.5], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [7, 1.2, 5.5], to: [7, 1.2, 41], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [7, 1.2, 5.5], to: [48, 1.2, 5.5], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: loft, a: [[-26.2, 3, 83.5], [-23.8, 3, 83.5], [-23.8, 5.5, 83.5], [-26.2, 5.5, 83.5]], b: [[-26.2, 3, 0], [-23.8, 3, 0], [-23.8, 5.5, 0], [-26.2, 5.5, 0]], collide: 0, color: "#8a6a45"}
      - {kind: loft, a: [[-22.8, -0.4, 82], [-22.9675, -0.4, 82.8419], [-23.4444, -0.4, 83.5556], [-24.1581, -0.4, 84.0325], [-25, -0.4, 84.2], [-25.8419, -0.4, 84.0325], [-26.5556, -0.4, 83.5556], [-27.0325, -0.4, 82.8419], [-27.2, -0.4, 82], [-27.0325, -0.4, 81.1581], [-26.5556, -0.4, 80.4444], [-25.8419, -0.4, 79.9675], [-25, -0.4, 79.8], [-24.1581, -0.4, 79.9675], [-23.4444, -0.4, 80.4444], [-22.9675, -0.4, 81.1581]], b: [[-22.8, 0.4, 82], [-22.9675, 0.4, 82.8419], [-23.4444, 0.4, 83.5556], [-24.1581, 0.4, 84.0325], [-25, 0.4, 84.2], [-25.8419, 0.4, 84.0325], [-26.5556, 0.4, 83.5556], [-27.0325, 0.4, 82.8419], [-27.2, 0.4, 82], [-27.0325, 0.4, 81.1581], [-26.5556, 0.4, 80.4444], [-25.8419, 0.4, 79.9675], [-25, 0.4, 79.8], [-24.1581, 0.4, 79.9675], [-23.4444, 0.4, 80.4444], [-22.9675, 0.4, 81.1581]], collide: 0, color: "#6d675c"}
      - {kind: rod, from: [-25, 0.4, 82], to: [-25, 3, 82], radius: 0.4, collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[23.8, 3, 83.5], [26.2, 3, 83.5], [26.2, 5.5, 83.5], [23.8, 5.5, 83.5]], b: [[23.8, 3, 0], [26.2, 3, 0], [26.2, 5.5, 0], [23.8, 5.5, 0]], collide: 0, color: "#8a6a45"}
      - {kind: loft, a: [[27.2, -0.4, 82], [27.0325, -0.4, 82.8419], [26.5556, -0.4, 83.5556], [25.8419, -0.4, 84.0325], [25, -0.4, 84.2], [24.1581, -0.4, 84.0325], [23.4444, -0.4, 83.5556], [22.9675, -0.4, 82.8419], [22.8, -0.4, 82], [22.9675, -0.4, 81.1581], [23.4444, -0.4, 80.4444], [24.1581, -0.4, 79.9675], [25, -0.4, 79.8], [25.8419, -0.4, 79.9675], [26.5556, -0.4, 80.4444], [27.0325, -0.4, 81.1581]], b: [[27.2, 0.4, 82], [27.0325, 0.4, 82.8419], [26.5556, 0.4, 83.5556], [25.8419, 0.4, 84.0325], [25, 0.4, 84.2], [24.1581, 0.4, 84.0325], [23.4444, 0.4, 83.5556], [22.9675, 0.4, 82.8419], [22.8, 0.4, 82], [22.9675, 0.4, 81.1581], [23.4444, 0.4, 80.4444], [24.1581, 0.4, 79.9675], [25, 0.4, 79.8], [25.8419, 0.4, 79.9675], [26.5556, 0.4, 80.4444], [27.0325, 0.4, 81.1581]], collide: 0, color: "#6d675c"}
      - {kind: rod, from: [25, 0.4, 82], to: [25, 3, 82], radius: 0.4, collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-26.2, 3, 85.5], [26.2, 3, 85.5], [26.2, 5.5, 85.5], [-26.2, 5.5, 85.5]], b: [[-26.2, 3, 83.5], [26.2, 3, 83.5], [26.2, 5.5, 83.5], [-26.2, 5.5, 83.5]], collide: 0, color: "#8a6a45"}
      - {kind: loft, a: [[32.4, -0.6, 7.4], [35.6, -0.6, 7.4], [35.6, 3, 7.4], [32.4, 3, 7.4]], b: [[32.4, -0.6, 3.6], [35.6, -0.6, 3.6], [35.6, 3, 3.6], [32.4, 3, 3.6]], collide: 0, color: "#6d675c"}
joints:
  - {id: j_a, type: slide, body: bell, axis: [0, 0, 1], range: [-12, 10], damping: 20}   # the gasometer A
  - {id: j_wl, type: slide, body: weight_l, axis: [0, 0, 1], range: [-40, 30], damping: 0.5}
  - {id: j_wr, type: slide, body: weight_r, axis: [0, 0, 1], range: [-40, 30], damping: 0.5}
  - {id: j_k, type: hinge, body: cock, axis: [0, 1, 0], damping: 0.01}   # the cock (the drive)
ropes:
  - {id: chain_l, from: {body: bell, at: [-16, 0, 57.6]}, over: {center: [-25, 0, 82], radius: 2.2, axis: y, side: [-25, 0, 86.2]}, to: {body: weight_l, at: [-27.2, 0, 50.2]}, width: 0.8, thickness: 0.8, color: "#3d3a36"}
  - {id: chain_r, from: {body: bell, at: [16, 0, 57.6]}, over: {center: [25, 0, 82], radius: 2.2, axis: y, side: [25, 0, 86.2]}, to: {body: weight_r, at: [27.2, 0, 50.2]}, width: 0.8, thickness: 0.8, color: "#3d3a36"}
vessels:
  substeps: 8
  nodes:
    - {id: works, kind: source, p: 600, gas: true, RT: 84100}
    - {id: burners, kind: source, p: 0, gas: true, RT: 84100}
    - {id: tank, kind: chamber, fixed: 10, moving: top, open: true, sections: [[10, 294.524]], volume: 10013.8, water: 8246.68, p: 0,
       draw: {sections: [[[-19.95, 10], [-17.6, 10], [-17.6, 44], [-19.95, 44]], [[17.6, 10], [19.95, 10], [19.95, 44], [17.6, 44]]], y: [0.1, 5]}}   # the tank's water outside A
    - {id: gasometer, kind: chamber, fixed: 10, moving: top, sections: [[10, 907.92]], volume: 41764.3, water: 25421.8, p: 0,
       draw: {sections: [[[-16.95, 10], [16.95, 10], [16.95, 76], [-16.95, 76]]], y: [0.1, 16.7]}}   # the water and gas under A
  links:
    - {id: rim, from: tank, to: gasometer, area: 40, cd: 0.62, z: 11, zTo: 11}   # the water under A's rim
    - {id: inlet, from: works, to: gasometer, area: 0.7, cd: 0.62, z: 0, zTo: 41}
    - {id: outlet, from: gasometer, to: burners, area: 1.6, cd: 0.62, z: 41, zTo: 0, open: {joint: j_k, q: [0.3, 0.8], frac: [0, 1]}}
  pistons:
    - {node: gasometer, joint: j_a, area: 907.92, sign: 1}
driver: {joint: j_k, kind: velocity, rpm: 0, swing: {amplitude: 0.7, hz: 0.125}, kv: 300, max_torque: 20}
checks:
  - {type: amplitude, joint: j_a, min: 0.012, max: 0.08, settle_s: 2, window_s: 16}
  - {type: penetration, max: 0.01}
camera: {target: [0, 0, 33], position: [0, -330, 39], fov: 21}
display:
  output: j_a
  labels: {j_a: "Gasometer A", j_wl: "Weight C", j_wr: "Weight C", j_k: "Cock (driver)"}
