pipe_flow_rate.nbt 569 B

1234567891011121314151617
  1. # This script calculates and prints the flow rate in a pipe
  2. # using the Hagen-Poiseuille equation. It assumes the dynamic
  3. # viscosity of water and allows for inputs of pipe radius,
  4. # pipe length, and pressure difference.
  5. let μ_water: DynamicViscosity = 1 mPa·s
  6. fn flow_rate(radius: Length, length: Length, Δp: Pressure) -> FlowRate =
  7. π × radius^4 × Δp / (8 μ_water × length)
  8. let pipe_radius = 1 cm
  9. let pipe_length = 10 m
  10. let Δp = 0.1 bar
  11. let Q = flow_rate(pipe_radius, pipe_length, Δp)
  12. print("Flow rate: {Q -> L/s}")
  13. assert_eq(Q, 3.93 L/s, 0.01 L/s)