Skip to content

Dimensionless Numbers

Module Reference

Dimensionless numbers and related engineering calculations for fluid mechanics.

All inputs use SI units.

as_float_array

as_float_array(value: ArrayLike, name: str) -> np.ndarray

Convert input to a finite floating-point array.

Source code in src/fluidmec/core/_validation.py
13
14
15
16
17
18
19
20
21
22
23
24
def as_float_array(
    value: ArrayLike,
    name: str,
) -> np.ndarray:
    """Convert input to a finite floating-point array."""

    array = np.asarray(value, dtype=float)

    if not np.all(np.isfinite(array)):
        raise ValueError(f"{name} must be finite.")

    return array

format_output

format_output(result: ArrayLike) -> float | np.ndarray

Return a Python float for scalar results.

Source code in src/fluidmec/core/_validation.py
69
70
71
72
73
74
75
76
77
78
79
def format_output(
    result: ArrayLike,
) -> float | np.ndarray:
    """Return a Python float for scalar results."""

    result = np.asarray(result, dtype=float)

    if result.ndim == 0:
        return float(result)

    return result

validate_non_negative

validate_non_negative(value: ArrayLike, name: str) -> np.ndarray

Validate non-negative numerical inputs.

Source code in src/fluidmec/core/_validation.py
41
42
43
44
45
46
47
48
49
50
51
52
def validate_non_negative(
    value: ArrayLike,
    name: str,
) -> np.ndarray:
    """Validate non-negative numerical inputs."""

    array = as_float_array(value, name)

    if np.any(array < 0):
        raise ValueError(f"{name} must be non-negative.")

    return array

validate_non_zero

validate_non_zero(value: ArrayLike, name: str) -> np.ndarray

Validate non-zero numerical inputs.

Source code in src/fluidmec/core/_validation.py
55
56
57
58
59
60
61
62
63
64
65
66
def validate_non_zero(
    value: ArrayLike,
    name: str,
) -> np.ndarray:
    """Validate non-zero numerical inputs."""

    array = as_float_array(value, name)

    if np.any(array == 0):
        raise ValueError(f"{name} must be non-zero.")

    return array

validate_positive

validate_positive(value: ArrayLike, name: str) -> np.ndarray

Validate strictly positive numerical inputs.

Source code in src/fluidmec/core/_validation.py
27
28
29
30
31
32
33
34
35
36
37
38
def validate_positive(
    value: ArrayLike,
    name: str,
) -> np.ndarray:
    """Validate strictly positive numerical inputs."""

    array = as_float_array(value, name)

    if np.any(array <= 0):
        raise ValueError(f"{name} must be positive.")

    return array

reynolds_number

reynolds_number(velocity: ArrayLike, length: ArrayLike, kinematic_viscosity: ArrayLike) -> float | np.ndarray

Calculate Reynolds number.

Re = abs(U) * L / nu

Parameters:

Name Type Description Default
velocity ArrayLike

Characteristic velocity in m/s.

required
length ArrayLike

Characteristic length in m.

required
kinematic_viscosity ArrayLike

Kinematic viscosity in m²/s.

required
Source code in src/fluidmec/core/dimensionless.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def reynolds_number(
    velocity: ArrayLike,
    length: ArrayLike,
    kinematic_viscosity: ArrayLike,
) -> float | np.ndarray:
    """
    Calculate Reynolds number.

    Re = abs(U) * L / nu

    Parameters
    ----------
    velocity : ArrayLike
        Characteristic velocity in m/s.
    length : ArrayLike
        Characteristic length in m.
    kinematic_viscosity : ArrayLike
        Kinematic viscosity in m²/s.
    """

    velocity = as_float_array(velocity, "Velocity")
    length = validate_positive(length, "Length")

    nu = validate_positive(
        kinematic_viscosity,
        "Kinematic viscosity",
    )

    return format_output(np.abs(velocity) * length / nu)

froude_number

froude_number(velocity: ArrayLike, length: ArrayLike, gravity: float = 9.81) -> float | np.ndarray

Calculate Froude number.

Fr = abs(U) / sqrt(g * L)

Velocity in m/s, length in m, gravity in m/s².

Source code in src/fluidmec/core/dimensionless.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def froude_number(
    velocity: ArrayLike,
    length: ArrayLike,
    gravity: float = 9.81,
) -> float | np.ndarray:
    """
    Calculate Froude number.

    Fr = abs(U) / sqrt(g * L)

    Velocity in m/s, length in m,
    gravity in m/s².
    """

    velocity = as_float_array(velocity, "Velocity")
    length = validate_positive(length, "Length")
    gravity = validate_positive(gravity, "Gravity")

    return format_output(np.abs(velocity) / np.sqrt(gravity * length))

richardson_number

richardson_number(velocity: ArrayLike, length: ArrayLike, reduced_gravity: ArrayLike) -> float | np.ndarray

Calculate bulk Richardson number.

Ri = g_prime * L / U²

Velocity in m/s, length in m, reduced gravity in m/s².

Source code in src/fluidmec/core/dimensionless.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def richardson_number(
    velocity: ArrayLike,
    length: ArrayLike,
    reduced_gravity: ArrayLike,
) -> float | np.ndarray:
    """
    Calculate bulk Richardson number.

    Ri = g_prime * L / U²

    Velocity in m/s, length in m,
    reduced gravity in m/s².
    """

    velocity = validate_non_zero(velocity, "Velocity")

    length = validate_positive(length, "Length")

    reduced_gravity = as_float_array(reduced_gravity, "Reduced gravity")

    return format_output(reduced_gravity * length / velocity**2)

gradient_richardson_number

gradient_richardson_number(density_gradient: ArrayLike, velocity_gradient: ArrayLike, reference_density: float = 1000.0, gravity: float = 9.81) -> float | np.ndarray

Calculate gradient Richardson number.

Ri_g = -(g / rho0) * (drho/dz) / (du/dz)²

Density gradient in kg/m⁴. Velocity gradient in s⁻¹. Reference density in kg/m³. Gravity in m/s².

The vertical coordinate is positive upwards.

Source code in src/fluidmec/core/dimensionless.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
def gradient_richardson_number(
    density_gradient: ArrayLike,
    velocity_gradient: ArrayLike,
    reference_density: float = 1000.0,
    gravity: float = 9.81,
) -> float | np.ndarray:
    """
    Calculate gradient Richardson number.

    Ri_g = -(g / rho0) * (drho/dz) / (du/dz)²

    Density gradient in kg/m⁴.
    Velocity gradient in s⁻¹.
    Reference density in kg/m³.
    Gravity in m/s².

    The vertical coordinate is positive upwards.
    """

    density_gradient = as_float_array(density_gradient, "Density gradient")

    velocity_gradient = validate_non_zero(velocity_gradient, "Velocity gradient")

    reference_density = validate_positive(reference_density, "Reference density")

    gravity = validate_positive(gravity, "Gravity")

    n_squared = -gravity * density_gradient / reference_density

    return format_output(n_squared / velocity_gradient**2)

weber_number

weber_number(density: ArrayLike, velocity: ArrayLike, length: ArrayLike, surface_tension: ArrayLike) -> float | np.ndarray

Calculate Weber number.

We = rho * U² * L / sigma

Density in kg/m³, velocity in m/s, length in m, surface tension in N/m.

Source code in src/fluidmec/core/dimensionless.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def weber_number(
    density: ArrayLike,
    velocity: ArrayLike,
    length: ArrayLike,
    surface_tension: ArrayLike,
) -> float | np.ndarray:
    """
    Calculate Weber number.

    We = rho * U² * L / sigma

    Density in kg/m³, velocity in m/s,
    length in m, surface tension in N/m.
    """

    density = validate_positive(density, "Density")
    velocity = as_float_array(velocity, "Velocity")
    length = validate_positive(length, "Length")

    surface_tension = validate_positive(surface_tension, "Surface tension")

    return format_output(density * velocity**2 * length / surface_tension)

strouhal_number

strouhal_number(frequency: ArrayLike, length: ArrayLike, velocity: ArrayLike) -> float | np.ndarray

Calculate Strouhal number.

St = f * L / abs(U)

Frequency in Hz, length in m, velocity in m/s.

Source code in src/fluidmec/core/dimensionless.py
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
def strouhal_number(
    frequency: ArrayLike,
    length: ArrayLike,
    velocity: ArrayLike,
) -> float | np.ndarray:
    """
    Calculate Strouhal number.

    St = f * L / abs(U)

    Frequency in Hz, length in m,
    velocity in m/s.
    """

    frequency = validate_non_negative(frequency, "Frequency")

    length = validate_positive(length, "Length")

    velocity = validate_non_zero(velocity, "Velocity")

    return format_output(frequency * length / np.abs(velocity))

vortex_shedding_frequency

vortex_shedding_frequency(strouhal: ArrayLike, velocity: ArrayLike, length: ArrayLike) -> float | np.ndarray

Calculate vortex shedding frequency in Hz.

f = St * abs(U) / L

Strouhal number must be appropriate for the geometry and flow regime.

Source code in src/fluidmec/core/dimensionless.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
def vortex_shedding_frequency(
    strouhal: ArrayLike,
    velocity: ArrayLike,
    length: ArrayLike,
) -> float | np.ndarray:
    """
    Calculate vortex shedding frequency in Hz.

    f = St * abs(U) / L

    Strouhal number must be appropriate for
    the geometry and flow regime.
    """

    strouhal = validate_non_negative(strouhal, "Strouhal number")

    velocity = as_float_array(velocity, "Velocity")
    length = validate_positive(length, "Length")

    return format_output(strouhal * np.abs(velocity) / length)

keulegan_carpenter_number

keulegan_carpenter_number(velocity: ArrayLike, period: ArrayLike, length: ArrayLike) -> float | np.ndarray

Calculate Keulegan-Carpenter number.

KC = abs(U) * T / L

Velocity in m/s, period in s, characteristic length in m.

Source code in src/fluidmec/core/dimensionless.py
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
def keulegan_carpenter_number(
    velocity: ArrayLike,
    period: ArrayLike,
    length: ArrayLike,
) -> float | np.ndarray:
    """
    Calculate Keulegan-Carpenter number.

    KC = abs(U) * T / L

    Velocity in m/s, period in s,
    characteristic length in m.
    """

    velocity = as_float_array(velocity, "Velocity")
    period = validate_positive(period, "Period")
    length = validate_positive(length, "Length")

    return format_output(np.abs(velocity) * period / length)

oscillatory_frequency_parameter

oscillatory_frequency_parameter(length: ArrayLike, period: ArrayLike, kinematic_viscosity: ArrayLike) -> float | np.ndarray

Calculate oscillatory frequency parameter.

beta = L² / (nu * T)

Length in m, period in s, kinematic viscosity in m²/s.

Source code in src/fluidmec/core/dimensionless.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
def oscillatory_frequency_parameter(
    length: ArrayLike,
    period: ArrayLike,
    kinematic_viscosity: ArrayLike,
) -> float | np.ndarray:
    """
    Calculate oscillatory frequency parameter.

    beta = L² / (nu * T)

    Length in m, period in s,
    kinematic viscosity in m²/s.
    """

    length = validate_positive(length, "Length")
    period = validate_positive(period, "Period")

    nu = validate_positive(
        kinematic_viscosity,
        "Kinematic viscosity",
    )

    return format_output(length**2 / (nu * period))