# No. 481 (Brown 1868): "Wet gas meter. The stationary case, A, is filled with water up to above the center. The inner revolving drum is divided into four compartments, B, B, with inlets around the central pipe, a, which introduces the gas through one of the hollow journals of the drum. This pipe is turned up to admit the gas above the water, as indicated by the arrow near the center of the figure. As gas enters the compartments, B, B, one after another, it turns the drum in the direction of the arrow shown near its periphery, displacing the water from them. As the chambers pass over they fill with water again. The cubic contents of the compartments being known, and the number of the revolutions of the drum being registered by dial-work, the quantity of gas passing through the meter is registered."
# Model (cm, gravity on, seen from in front with the case's front plate taken off). The case A (34 cm) holds water to
# 3.5 cm over the drum's axis. The drum (28 cm, four compartments whose partitions slant from the hub to the rim) turns on
# its journals; the pipe a comes in through the back and the drum's hollow journal and turns up inside the hub over the water.
# The gas from the main (300 Pa gauge, the only input) fills the hub's gas space (`inlet`, a lumped gas vessel) and leaves the
# case's gas space over the water (`outlet`) for the burners. The drum is a displacer between them (add-vessel-displacers,
# add-gas-displacers): each radian carries volume/2pi of gas at the giver's density, the drum's ring over the water, 2.44
# litres a turn, and the gas's pressure, inlet over outlet, pushes it round by volume/2pi times their difference, against the
# water's drag and its journals (damping 0.11 N m s). So it turns as the gas goes through and the turns count the gas. The
# water is a still tank drawn to its level behind the partitions; the gas spaces are drawn by their pressure. The water's
# rise and fall inside each compartment is not drawn (lumped), and there is no dial-work. Generator: opencode-runs/water/gen481.py.
number: 481
slug: wet-gas-meter
name: Wet gas meter
brown: "Wet gas meter. The stationary case, A, is filled with water up to above the center. The inner revolving drum is divided into four compartments, B, B, with inlets around the central pipe, a, which introduces the gas through one of the hollow journals of the drum. This pipe is turned up to admit the gas above the water, as indicated by the arrow near the center of the figure. As gas enters the compartments, B, B, one after another, it turns the drum in the direction of the arrow shown near its periphery, displacing the water from them. As the chambers pass over they fill with water again. The cubic contents of the compartments being known, and the number of the revolutions of the drum being registered by dial-work, the quantity of gas passing through the meter is registered."
units: cm
sim:
  timestep: 0.001
  integrator: implicitfast
  iterations: 60
  duration_s: 14
  floor: false
bodies:
  - id: drum
    shape: part
    pos: [0, 6.5, 26]
    mass: 1.2
    color: "#a39e92"
    pieces:
      - {kind: band, center: [0, 26], r: [13.6, 14], a: [0, 6.2832], y: [1, 13], slices: 40, collide: 0, color: "#a39e92"}
      - {kind: band, center: [0, 26], r: [0, 14], a: [0, 6.2832], y: [12.6, 13], slices: 40, collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[3.7352, 1, 29.5244], [3.9322, 1, 33.0648], [3.5328, 1, 33.087], [3.3358, 1, 29.5466]], b: [[3.7352, 13, 29.5244], [3.9322, 13, 33.0648], [3.5328, 13, 33.087], [3.3358, 13, 29.5466]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[3.9144, 1, 33.1589], [2.2097, 1, 36.8945], [1.8458, 1, 36.7285], [3.5505, 1, 32.9929]], b: [[3.9144, 13, 33.1589], [2.2097, 13, 36.8945], [1.8458, 13, 36.7285], [3.5505, 13, 32.9929]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[2.1575, 1, 36.9636], [-1.4711, 1, 40.0603], [-1.7307, 1, 39.756], [1.8979, 1, 36.6594]], b: [[2.1575, 13, 36.9636], [-1.4711, 13, 40.0603], [-1.7307, 13, 39.756], [1.8979, 13, 36.6594]], collide: 0, color: "#a39e92"}
      - {kind: band, center: [0, 26], r: [4.7, 5], a: [0.9354, 1.9062], y: [1, 13], slices: 8, collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[-3.5244, 1, 29.7352], [-7.0648, 1, 29.9322], [-7.087, 1, 29.5328], [-3.5466, 1, 29.3358]], b: [[-3.5244, 13, 29.7352], [-7.0648, 13, 29.9322], [-7.087, 13, 29.5328], [-3.5466, 13, 29.3358]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[-7.1589, 1, 29.9144], [-10.8945, 1, 28.2097], [-10.7285, 1, 27.8458], [-6.9929, 1, 29.5505]], b: [[-7.1589, 13, 29.9144], [-10.8945, 13, 28.2097], [-10.7285, 13, 27.8458], [-6.9929, 13, 29.5505]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[-10.9636, 1, 28.1575], [-14.0603, 1, 24.5289], [-13.756, 1, 24.2693], [-10.6594, 1, 27.8979]], b: [[-10.9636, 13, 28.1575], [-14.0603, 13, 24.5289], [-13.756, 13, 24.2693], [-10.6594, 13, 27.8979]], collide: 0, color: "#a39e92"}
      - {kind: band, center: [0, 26], r: [4.7, 5], a: [2.5062, 3.477], y: [1, 13], slices: 8, collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[-3.7352, 1, 22.4756], [-3.9322, 1, 18.9352], [-3.5328, 1, 18.913], [-3.3358, 1, 22.4534]], b: [[-3.7352, 13, 22.4756], [-3.9322, 13, 18.9352], [-3.5328, 13, 18.913], [-3.3358, 13, 22.4534]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[-3.9144, 1, 18.8411], [-2.2097, 1, 15.1055], [-1.8458, 1, 15.2715], [-3.5505, 1, 19.0071]], b: [[-3.9144, 13, 18.8411], [-2.2097, 13, 15.1055], [-1.8458, 13, 15.2715], [-3.5505, 13, 19.0071]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[-2.1575, 1, 15.0364], [1.4711, 1, 11.9397], [1.7307, 1, 12.244], [-1.8979, 1, 15.3406]], b: [[-2.1575, 13, 15.0364], [1.4711, 13, 11.9397], [1.7307, 13, 12.244], [-1.8979, 13, 15.3406]], collide: 0, color: "#a39e92"}
      - {kind: band, center: [0, 26], r: [4.7, 5], a: [4.077, 5.0478], y: [1, 13], slices: 8, collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[3.5244, 1, 22.2648], [7.0648, 1, 22.0678], [7.087, 1, 22.4672], [3.5466, 1, 22.6642]], b: [[3.5244, 13, 22.2648], [7.0648, 13, 22.0678], [7.087, 13, 22.4672], [3.5466, 13, 22.6642]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[7.1589, 1, 22.0856], [10.8945, 1, 23.7903], [10.7285, 1, 24.1542], [6.9929, 1, 22.4495]], b: [[7.1589, 13, 22.0856], [10.8945, 13, 23.7903], [10.7285, 13, 24.1542], [6.9929, 13, 22.4495]], collide: 0, color: "#a39e92"}
      - {kind: loft, a: [[10.9636, 1, 23.8425], [14.0603, 1, 27.4711], [13.756, 1, 27.7307], [10.6594, 1, 24.1021]], b: [[10.9636, 13, 23.8425], [14.0603, 13, 27.4711], [13.756, 13, 27.7307], [10.6594, 13, 24.1021]], collide: 0, color: "#a39e92"}
      - {kind: band, center: [0, 26], r: [4.7, 5], a: [5.6478, 6.6186], y: [1, 13], slices: 8, collide: 0, color: "#a39e92"}
      - {kind: band, center: [0, 26], r: [1.4, 2.4], a: [0, 6.2832], y: [13, 15.5], slices: 16, collide: 0, color: "#6d675c"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#d6cdb8"
    pieces:
      - {kind: loft, a: [[-34, -10, 0], [34, -10, 0], [34, 24, 0], [-34, 24, 0]], b: [[-34, -10, -1.5], [34, -10, -1.5], [34, 24, -1.5], [-34, 24, -1.5]], collide: 0, color: "#8b7d66"}
      - {kind: loft, a: [[-15, 1, 11], [-11, 1, 11], [-11, 14, 11], [-15, 14, 11]], b: [[-15, 1, 0], [-11, 1, 0], [-11, 14, 0], [-15, 14, 0]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[11, 1, 11], [15, 1, 11], [15, 14, 11], [11, 14, 11]], b: [[11, 1, 0], [15, 1, 0], [15, 14, 0], [11, 14, 0]], collide: 0, color: "#6d675c"}
      - {kind: band, center: [0, 26], r: [17, 17.8], a: [0, 6.2832], y: [0, 14.6], slices: 48, collide: 0, color: "#7d7a72"}
      - {kind: band, center: [0, 26], r: [0, 17.8], a: [0, 6.2832], y: [14, 14.6], slices: 48, collide: 0, color: "#7d7a72"}
      - {kind: rod, from: [0, 23, 20], to: [0, 23, 26], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [0, 23, 26], to: [0, 6, 26], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [0, 6, 26], to: [0, 6, 30.3], radius: 0.9, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [0, 23, 20], to: [-32, 23, 20], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [0, 7, 43], to: [0, 7, 49], radius: 1, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [0, 7, 49], to: [30, 7, 49], radius: 1, collide: 0, color: "#5f5a52"}
joints:
  - {id: j_d, type: hinge, body: drum, axis: [0, 1, 0], damping: 0.11}   # + : the drum turns the way Brown's arrow shows
vessels:
  substeps: 8
  nodes:
    - {id: main, kind: source, p: 300, gas: true, RT: 84100}   # the gas main (the input)
    - {id: burners, kind: source, p: 0, gas: true, RT: 84100}
    - {id: inlet, kind: gas, volume: 600, p: 0, RT: 84100,
       draw: {sections: [[[4.6, 26.0], [3.9837, 28.3], [2.3, 29.9837], [0.0, 30.6], [-2.3, 29.9837], [-3.9837, 28.3], [-4.6, 26.0], [-3.9837, 23.7], [-2.3, 22.0163], [-0.0, 21.4], [2.3, 22.0163], [3.9837, 23.7]]], y: [1.2, 12.4], pref: 3000}}   # the gas in the hub and the compartment open to it
    - {id: outlet, kind: gas, volume: 7104.17, p: 0, RT: 84100,
       draw: {sections: [[[-16.335804759614124, 29.6], [16.335804759614124, 29.6], [15.0889, 33.1564], [13.1059, 36.3501], [10.4587, 39.0194], [7.2816, 41.0289], [3.7354, 42.2769], [-0.0, 42.7], [-3.7354, 42.2769], [-7.2816, 41.0289], [-10.4587, 39.0194], [-13.1059, 36.3501], [-15.0889, 33.1564]]], y: [4.2, 13.8], pref: 3000}}   # the case's gas over the water
    - {id: water, kind: tank, area: 333.2, z: 9, level: 16.8269,
       draw: {section: [[-16.1958, 31.0], [-16.9487, 25.7921], [-16.0682, 20.6042], [-13.6391, 15.9364], [-9.8956, 12.2384], [-5.1983, 9.8668], [-0.0, 9.05], [5.1983, 9.8668], [9.8956, 12.2384], [13.6391, 15.9364], [16.0682, 20.6042], [16.9487, 25.7921], [16.1958, 31.0]], y: [4.2, 14]}}   # the case's water (still), behind the partitions' front edges
  links:
    - {id: supply, from: main, to: inlet, area: 0.35, cd: 0.62}
    - {id: service, from: outlet, to: burners, area: 0.35, cd: 0.62}
  displacers:
    - {id: drum, joint: j_d, from: inlet, to: outlet, volume: 2442.23}
driver: {joint: j_d, kind: torque, torque: 0, max_torque: 0.001}   # no hand on the drum: the gas is the only input
checks:
  - {type: monotonic, joint: j_d, direction: 1, max_back: 0.05, settle_s: 1.0, window_s: 12}
  - {type: turning, joint: j_d, direction: 1, min_mean: 0.2, min_fraction: 0.9, settle_s: 2.0, window_s: 11}
camera: {target: [0, 0, 7], position: [0, -260, 15], fov: 21}
display:
  output: j_d
  labels: {j_d: "Drum"}
