fork/numbat

git clone https://git.julia.blue/fork/numbat

David PeterString interpolation with arbitrary sub-expressions!c354c09

v1.8.0
569 B17 linesraw
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
6let μ_water: DynamicViscosity = 1 mPa·s
7
8fn flow_rate(radius: Length, length: Length, Δp: Pressure) -> FlowRate =
9    π × radius^4 × Δp / (8 μ_water × length)
10
11let pipe_radius = 1 cm
12let pipe_length = 10 m
13let Δp = 0.1 bar
14
15let Q = flow_rate(pipe_radius, pipe_length, Δp)
16print("Flow rate: {Q -> L/s}")
17assert_eq(Q, 3.93 L/s, 0.01 L/s)