|
| 1 | +""" |
| 2 | +Title : computing the Reynolds number to find |
| 3 | + out the type of flow (laminar or turbulent) |
| 4 | +
|
| 5 | +Reynolds number is a dimensionless quantity that is used to determine |
| 6 | +the type of flow pattern as laminar or turbulent while flowing through a |
| 7 | +pipe. Reynolds number is defined by the ratio of inertial forces to that of |
| 8 | +viscous forces. |
| 9 | +
|
| 10 | +R = Inertial Forces / Viscous Forces |
| 11 | +R = (ρ * V * D)/μ |
| 12 | +
|
| 13 | +where : |
| 14 | +ρ = Density of fluid (in Kg/m^3) |
| 15 | +D = Diameter of pipe through which fluid flows (in m) |
| 16 | +V = Velocity of flow of the fluid (in m/s) |
| 17 | +μ = Viscosity of the fluid (in Ns/m^2) |
| 18 | +
|
| 19 | +If the Reynolds number calculated is high (greater than 2000), then the |
| 20 | +flow through the pipe is said to be turbulent. If Reynolds number is low |
| 21 | +(less than 2000), the flow is said to be laminar. Numerically, these are |
| 22 | +acceptable values, although in general the laminar and turbulent flows |
| 23 | +are classified according to a range. Laminar flow falls below Reynolds |
| 24 | +number of 1100 and turbulent falls in a range greater than 2200. |
| 25 | +Laminar flow is the type of flow in which the fluid travels smoothly in |
| 26 | +regular paths. Conversely, turbulent flow isn't smooth and follows an |
| 27 | +irregular path with lots of mixing. |
| 28 | +
|
| 29 | +Reference : https://byjus.com/physics/reynolds-number/ |
| 30 | +""" |
| 31 | + |
| 32 | + |
| 33 | +def reynolds_number( |
| 34 | + density: float, velocity: float, diameter: float, viscosity: float |
| 35 | +) -> float: |
| 36 | + """ |
| 37 | + >>> reynolds_number(900, 2.5, 0.05, 0.4) |
| 38 | + 281.25 |
| 39 | + >>> reynolds_number(450, 3.86, 0.078, 0.23) |
| 40 | + 589.0695652173912 |
| 41 | + >>> reynolds_number(234, -4.5, 0.3, 0.44) |
| 42 | + 717.9545454545454 |
| 43 | + >>> reynolds_number(-90, 2, 0.045, 1) |
| 44 | + Traceback (most recent call last): |
| 45 | + ... |
| 46 | + ValueError: please ensure that density, diameter and viscosity are positive |
| 47 | + >>> reynolds_number(0, 2, -0.4, -2) |
| 48 | + Traceback (most recent call last): |
| 49 | + ... |
| 50 | + ValueError: please ensure that density, diameter and viscosity are positive |
| 51 | + """ |
| 52 | + |
| 53 | + if density <= 0 or diameter <= 0 or viscosity <= 0: |
| 54 | + raise ValueError( |
| 55 | + "please ensure that density, diameter and viscosity are positive" |
| 56 | + ) |
| 57 | + return (density * abs(velocity) * diameter) / viscosity |
| 58 | + |
| 59 | + |
| 60 | +if __name__ == "__main__": |
| 61 | + import doctest |
| 62 | + |
| 63 | + doctest.testmod() |
0 commit comments