# No. 463 (Brown 1868): Self-acting weir and scouring sluice. Two leaves turn on pivots below centers; upper leaf much larger than lower, and turns in direction of stream, while lower turns against it. Top edge of lower leaf overlaps bottom edge of upper one and is forced against it by pressure of water. In ordinary states of stream, counteracting pressures keep weir vertical and closed, as in the left-hand figure, and water flows through notch in upper leaf; but on water rising above ordinary level, pressure above from greater surface and leverage overcomes resistance below, upper leaf turns over, pushing back lower, reducing obstructions and opening at bed a passage to deposit.
# Model (cm, gravity on, Brown's section across the stream, which runs left to right). The lower leaf turns on a pivot 3.2 up its
# 9.1; the upper, 21 long, on one 4.5 up, its foot behind the lower leaf's top. Each leaf is pressed by the pond
# strip by strip (pistons at each 0.5 of height, src/fluid/vessels.c: the pressure there, its area and its arm about the pivot), so the
# pressure above a pivot turns a leaf's top downstream and below it the other way; the lower leaf's push on the upper leaf's foot is real
# contact. A river runs into the pond faster than the notch passes it, so the pond rises (the river is the only input; nothing drives the
# leaves). When the upper leaf's moment above its pivot outgrows the rest, it turns over, pushing the lower leaf's top back upstream; the
# water then runs over the upper leaf and out at the bed under the lower one, scouring, and the pond falls.
# Generator: opencode-runs/water/gen463.py.
number: 463
slug: self-acting-weir
name: "Self-acting weir and scouring sluice"
brown: "Self-acting weir and scouring sluice. Two leaves turn on pivots below centers; upper leaf much larger than lower, and turns in direction of stream, while lower turns against it. Top edge of lower leaf overlaps bottom edge of upper one and is forced against it by pressure of water. In ordinary states of stream, counteracting pressures keep weir vertical and closed, as in the left-hand figure, and water flows through notch in upper leaf; but on water rising above ordinary level, pressure above from greater surface and leverage overcomes resistance below, upper leaf turns over, pushing back lower, reducing obstructions and opening at bed a passage to deposit."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 60
  duration_s: 14
  floor: false
bodies:
  - id: upper
    shape: part
    pos: [0.65, 0, 11.5]
    mass: 0.06
    friction: 0.3
    color: "#a8875a"
    pieces:
      - {kind: loft, a: [[0.05, 3, 19.5], [1.25, 3, 19.5], [1.25, 3, 7], [0.05, 3, 7]], b: [[0.05, -3, 19.5], [1.25, -3, 19.5], [1.25, -3, 7], [0.05, -3, 7]], collide: 1, color: "#a8875a"}
      - {kind: loft, a: [[0.05, -0.7, 28], [1.25, -0.7, 28], [1.25, -0.7, 19.5], [0.05, -0.7, 19.5]], b: [[0.05, -3, 28], [1.25, -3, 28], [1.25, -3, 19.5], [0.05, -3, 19.5]], collide: 1, color: "#a8875a"}
      - {kind: loft, a: [[0.05, 3, 28], [1.25, 3, 28], [1.25, 3, 19.5], [0.05, 3, 19.5]], b: [[0.05, 0.7, 28], [1.25, 0.7, 28], [1.25, 0.7, 19.5], [0.05, 0.7, 19.5]], collide: 1, color: "#a8875a"}
      - {kind: rod, from: [0.65, -3.6, 11.5], to: [0.65, 3.6, 11.5], radius: 0.3, collide: 0, color: "#5e584e"}
  - id: lower
    shape: part
    pos: [-0.65, 0, 3.5]
    mass: 0.03
    friction: 0.3
    color: "#a8875a"
    pieces:
      - {kind: loft, a: [[-1.25, 3, 9.4], [-0.05, 3, 9.4], [-0.05, 3, 0.3], [-1.25, 3, 0.3]], b: [[-1.25, -3, 9.4], [-0.05, -3, 9.4], [-0.05, -3, 0.3], [-1.25, -3, 0.3]], collide: 2, color: "#a8875a"}
      - {kind: rod, from: [-0.65, -3.6, 3.5], to: [-0.65, 3.6, 3.5], radius: 0.3, collide: 0, color: "#5e584e"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#d6cdb8"
    pieces:
      - {kind: loft, a: [[-30, 4, 0], [30, 4, 0], [30, 4, -1.5], [-30, 4, -1.5]], b: [[-30, -4, 0], [30, -4, 0], [30, -4, -1.5], [-30, -4, -1.5]], collide: 0, color: "#9c9282"}
      - {kind: loft, a: [[-30, 10.2, 4], [30, 10.2, 4], [30, 10.2, 0], [-30, 10.2, 0]], b: [[-30, 9.6, 4], [30, 9.6, 4], [30, 9.6, 0], [-30, 9.6, 0]], collide: 0, color: "#9c9282"}
      - {kind: loft, a: [[0.35, 4.2, 11.5], [0.95, 4.2, 11.5], [0.95, 4.2, 4], [0.35, 4.2, 4]], b: [[0.35, 3.6, 11.5], [0.95, 3.6, 11.5], [0.95, 3.6, 4], [0.35, 3.6, 4]], collide: 0, color: "#7a6f60"}
      - {kind: loft, a: [[-0.95, 4.2, 3.5], [-0.35, 4.2, 3.5], [-0.35, 4.2, 0], [-0.95, 4.2, 0]], b: [[-0.95, 3.6, 3.5], [-0.35, 3.6, 3.5], [-0.35, 3.6, 0], [-0.95, 3.6, 0]], collide: 0, color: "#7a6f60"}
      - {kind: loft, a: [[1.3, 3, 0.8], [2.1, 3, 0.8], [2.1, 3, 0], [1.3, 3, 0]], b: [[1.3, -3, 0.8], [2.1, -3, 0.8], [2.1, -3, 0], [1.3, -3, 0]], collide: 0, color: "#7a6f60"}
joints:
  - {id: j_u, type: hinge, body: upper, axis: [0, 1, 0], range: [-0.02, 1.25], damping: 0.002}   # + turns its top downstream (clockwise as seen)
  - {id: j_l, type: hinge, body: lower, axis: [0, 1, 0], range: [-0.45, 0.05], damping: 0.002}    # - turns its top upstream
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
vessels:
  substeps: 4
  nodes:
    - {id: river, kind: source, head: 36}
    - {id: pond, kind: tank, area: 350, z: 0, level: 20, draw: {section: [[-30, 0], [-1.25, 0], [-1.25, 30], [-30, 30]], y: [-3, 9.1739]}}
    - {id: tail, kind: tank, area: 350, z: 0, level: 1.2, draw: {section: [[1.25, 0], [30, 0], [30, 8], [1.25, 8]], y: [-3, 9.1739]}}
    - {id: air, kind: source, p: 0}
  links:
    - {id: flood, from: river, to: pond, area: 2, cd: 0.62, z: 0}
    - {id: notch, from: pond, to: tail, area: 2.1, cd: 0.62, z: 19.5, zTo: 99, draw: {from: [1.25, 0, 19.9], fromBody: upper, to: [1.85, 0, 19.9], width: 1.0, flow: 0.1,
       fall: {dir: [1, 0, 0], floor: 1.5}}}   # through the notch
    - {id: over, from: pond, to: tail, area: 6, cd: 0.62, z: 19, zTo: 99, open: {joint: j_u, q: [0.15, 0.5], frac: [0, 1]},
       draw: {from: [0.65, 0, 28.4], fromBody: upper, to: [2.15, 0, 28.4], width: 1.4, flow: 0.4, fall: {dir: [1, 0, 0.2], floor: 1.5}}}   # over the leaf turned over
    - {id: scour, from: pond, to: tail, area: 8, cd: 0.62, z: 0.3, zTo: 99, open: {joint: j_l, q: [-0.4, -0.04], frac: [1, 0]},
       draw: {from: [-2.6, -3.4, 1.2], to: [6, -3.4, 0.9], via: [[-0.65, -3.4, 1.0], [2.4, -3.4, 1.2]], width: 0.9, flow: 0.4}}   # out at the bed, under the lower leaf
    - {id: weir, from: tail, to: air, area: 40, cd: 0.62, z: 1.0}
  pistons:
    - {node: pond, joint: j_u, area: 3, arm: 1.85, sign: -1, z: 9.65}
    - {node: pond, joint: j_u, area: 3, arm: 1.35, sign: -1, z: 10.15}
    - {node: pond, joint: j_u, area: 3, arm: 0.85, sign: -1, z: 10.65}
    - {node: pond, joint: j_u, area: 3, arm: 0.35, sign: -1, z: 11.15}
    - {node: pond, joint: j_u, area: 3, arm: 0.15, sign: 1, z: 11.65}
    - {node: pond, joint: j_u, area: 3, arm: 0.65, sign: 1, z: 12.15}
    - {node: pond, joint: j_u, area: 3, arm: 1.15, sign: 1, z: 12.65}
    - {node: pond, joint: j_u, area: 3, arm: 1.65, sign: 1, z: 13.15}
    - {node: pond, joint: j_u, area: 3, arm: 2.15, sign: 1, z: 13.65}
    - {node: pond, joint: j_u, area: 3, arm: 2.65, sign: 1, z: 14.15}
    - {node: pond, joint: j_u, area: 3, arm: 3.15, sign: 1, z: 14.65}
    - {node: pond, joint: j_u, area: 3, arm: 3.65, sign: 1, z: 15.15}
    - {node: pond, joint: j_u, area: 3, arm: 4.15, sign: 1, z: 15.65}
    - {node: pond, joint: j_u, area: 3, arm: 4.65, sign: 1, z: 16.15}
    - {node: pond, joint: j_u, area: 3, arm: 5.15, sign: 1, z: 16.65}
    - {node: pond, joint: j_u, area: 3, arm: 5.65, sign: 1, z: 17.15}
    - {node: pond, joint: j_u, area: 3, arm: 6.15, sign: 1, z: 17.65}
    - {node: pond, joint: j_u, area: 3, arm: 6.65, sign: 1, z: 18.15}
    - {node: pond, joint: j_u, area: 3, arm: 7.15, sign: 1, z: 18.65}
    - {node: pond, joint: j_u, area: 3, arm: 7.65, sign: 1, z: 19.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 8.15, sign: 1, z: 19.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 8.65, sign: 1, z: 20.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 9.15, sign: 1, z: 20.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 9.65, sign: 1, z: 21.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 10.15, sign: 1, z: 21.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 10.65, sign: 1, z: 22.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 11.15, sign: 1, z: 22.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 11.65, sign: 1, z: 23.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 12.15, sign: 1, z: 23.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 12.65, sign: 1, z: 24.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 13.15, sign: 1, z: 24.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 13.65, sign: 1, z: 25.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 14.15, sign: 1, z: 25.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 14.65, sign: 1, z: 26.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 15.15, sign: 1, z: 26.65}
    - {node: pond, joint: j_u, area: 2.3, arm: 15.65, sign: 1, z: 27.15}
    - {node: pond, joint: j_u, area: 2.3, arm: 16.15, sign: 1, z: 27.65}
    - {node: pond, joint: j_l, area: 3, arm: 2.95, sign: -1, z: 0.55}
    - {node: pond, joint: j_l, area: 3, arm: 2.45, sign: -1, z: 1.05}
    - {node: pond, joint: j_l, area: 3, arm: 1.95, sign: -1, z: 1.55}
    - {node: pond, joint: j_l, area: 3, arm: 1.45, sign: -1, z: 2.05}
    - {node: pond, joint: j_l, area: 3, arm: 0.95, sign: -1, z: 2.55}
    - {node: pond, joint: j_l, area: 3, arm: 0.45, sign: -1, z: 3.05}
    - {node: pond, joint: j_l, area: 3, arm: 0.55, sign: 1, z: 4.05}
    - {node: pond, joint: j_l, area: 3, arm: 1.05, sign: 1, z: 4.55}
    - {node: pond, joint: j_l, area: 3, arm: 1.55, sign: 1, z: 5.05}
    - {node: pond, joint: j_l, area: 3, arm: 2.05, sign: 1, z: 5.55}
    - {node: pond, joint: j_l, area: 3, arm: 2.55, sign: 1, z: 6.05}
    - {node: pond, joint: j_l, area: 3, arm: 3.05, sign: 1, z: 6.55}
    - {node: pond, joint: j_l, area: 3, arm: 3.55, sign: 1, z: 7.05}
    - {node: pond, joint: j_l, area: 3, arm: 4.05, sign: 1, z: 7.55}
    - {node: pond, joint: j_l, area: 3, arm: 4.55, sign: 1, z: 8.05}
    - {node: pond, joint: j_l, area: 3, arm: 5.05, sign: 1, z: 8.55}
    - {node: pond, joint: j_l, area: 3, arm: 5.55, sign: 1, z: 9.05}
driver: {joint: j_u, kind: torque, torque: 0, max_torque: 0.001}   # no hand on the leaves: the river is the only input
checks:
  - {type: position, joint: j_u, min: -0.03, max: 0.05, settle_s: 0.5, window_s: 1.5}
  - {type: position, joint: j_u, min: 0.35, max: 1.0, settle_s: 12, window_s: 1.5}
  - {type: position, joint: j_l, min: -0.46, max: -0.15, settle_s: 12, window_s: 1.5}
  - {type: penetration, max: 0.003}
camera: {target: [1, 0, 7.5], position: [1, -200, 10.5], fov: 16.5}
display:
  output: j_u
  labels: {j_u: "Upper leaf", j_l: "Lower leaf"}
