Skip to content

Linear Airy Wave Theory

The Airy module implements first-order, finite-depth surface gravity wave fields.

Coordinate convention

  • x: horizontal position, positive in the direction of propagation.
  • z: vertical position, positive upwards.
  • z = 0: still-water level.
  • z = -h: horizontal impermeable seabed.
  • t: time in seconds.

All dimensional quantities use SI units.

Governing equations

For incompressible, irrotational flow, the velocity potential satisfies Laplace's equation:

\[ \frac{\partial^2\phi}{\partial x^2} + \frac{\partial^2\phi}{\partial z^2}=0 \]

Wave phase

\[ \theta=kx-\omega t+\theta_0 \]

Surface elevation

\[ \eta=a\cos\theta \]

where wave amplitude is half the wave height.

Dispersion relation

\[ \omega^2=gk\tanh(kh) \]

The period-based functions reuse the existing Fluidmec dispersion solver.

Velocity potential

\[ \phi= \frac{ga}{\omega} \frac{\cosh[k(z+h)]}{\cosh(kh)} \sin\theta \]

The velocity convention is

\[ u=\frac{\partial\phi}{\partial x}, \qquad w=\frac{\partial\phi}{\partial z} \]

Stream function

\[ \psi= \frac{ga}{\omega} \frac{\sinh[k(z+h)]}{\cosh(kh)} \cos\theta \]

The stream function convention is

\[ u=\frac{\partial\psi}{\partial z}, \qquad w=-\frac{\partial\psi}{\partial x} \]

The stream function is zero at the seabed.

Instantaneous streamlines are not equivalent to particle trajectories in unsteady flow.

Boundary conditions

Impermeable seabed

\[ \frac{\partial\phi}{\partial z}=0 \quad\text{at }z=-h \]

Dynamic free-surface condition

\[ \frac{\partial\phi}{\partial t}+g\eta=0 \quad\text{at }z=0 \]

Kinematic free-surface condition

\[ \frac{\partial\eta}{\partial t} = \frac{\partial\phi}{\partial z} \quad\text{at }z=0 \]

Numerical stability

Direct evaluation of hyperbolic functions can overflow for large dimensionless water depths.

Fluidmec uses the equivalent exponential forms:

\[ C(z)= e^{kz} \frac{1+e^{-2k(z+h)}}{1+e^{-2kh}} \]
\[ S(z)= e^{kz} \frac{1-e^{-2k(z+h)}}{1+e^{-2kh}} \]

NumPy expm1 reduces cancellation near the seabed.

These formulations are valid within the mean water column, where exponential arguments remain non-positive.

Symbols and units

Symbol Description SI unit
a Wave amplitude m
h Water depth m
x Horizontal coordinate m
z Vertical coordinate m
t Time s
k Wave number rad/m
omega Angular frequency rad/s
eta Surface elevation m
phi Velocity potential m²/s
psi Stream function m²/s

Basic example

from fluidmec.waves import (
    surface_elevation_from_period,
    velocity_potential_from_period,
    stream_function_from_period,
)

a = 1.0
T = 8.0
h = 20.0
x = 10.0
z = -5.0
t = 0.0

eta = surface_elevation_from_period(a, x, t, T, h)

phi = velocity_potential_from_period(
    a, x, z, t, T, h
)

psi = stream_function_from_period(
    a, x, z, t, T, h
)

print(eta, phi, psi)

Vectorised spatial wave fields

import numpy as np

from fluidmec.waves import (
    solve_wave_number,
    velocity_potential,
    stream_function,
)

a = 1.0
T = 8.0
h = 20.0

k = solve_wave_number(T, h)

x = np.linspace(0.0, 200.0, 500)
z = np.linspace(-h, 0.0, 100)

xx, zz = np.meshgrid(x, z)

phi = velocity_potential(a, xx, zz, 0.0, k, h)
psi = stream_function(a, xx, zz, 0.0, k, h)

print(phi.shape)
print(psi.shape)

Both fields have shape (100, 500).

Assumptions and limitations

  • Small-amplitude linear gravity waves.
  • Incompressible, inviscid and irrotational fluid.
  • Constant water depth.
  • Horizontal impermeable seabed.
  • No background current.
  • Negligible surface tension and dissipation.
  • Two-dimensional progressive waves.
  • Free-surface conditions linearised at z = 0.
  • Potential and stream-function calculations are restricted to the mean water column.
  • Wave breaking, nonlinear harmonics and mean mass transport are not represented.
  • Extreme dimensional inputs may exceed the supported floating-point range.
  • Applicability of linear theory must be assessed separately.

Scientific validation

The test suite includes:

  • Analytical wave phase and surface elevation.
  • Spatial and temporal periodicity.
  • Stable depth attenuation calculations.
  • Deep-water limiting solutions.
  • Laplace equation residuals.
  • Dynamic and kinematic boundary conditions.
  • Impermeable seabed validation.
  • Potential and stream-function consistency.
  • NumPy broadcasting and input validation.

Finite-difference residuals depend on the chosen spatial and temporal discretisation.

Visualisation

Run the example script to generate a high-resolution scientific dashboard.

python examples/airy_wave_example.py

To additionally generate an animated GIF:

python examples/airy_wave_example.py --animate

Output files are saved in the project outputs directory.

API Reference

Linear Airy wave theory for finite-depth surface gravity waves.

Coordinate convention

x : Horizontal position, positive in the propagation direction. z : Vertical position, positive upwards. z = 0 : Still-water level. z = -h : Impermeable horizontal seabed.

Governing equations

theta = kx - omegat + phase_offset

eta = a*cos(theta)

phi = (ga/omega)C(z)*sin(theta)

psi = (ga/omega)S(z)*cos(theta)

C(z) = cosh(k(z+h))/cosh(kh)

S(z) = sinh(k(z+h))/cosh(kh)

omega**2 = gktanh(k*h)

Velocity convention

u = d(phi)/dx = d(psi)/dz w = d(phi)/dz = -d(psi)/dx

Assumptions
  • Linear, small-amplitude surface gravity waves.
  • Two-dimensional progressive wave propagation.
  • Incompressible, inviscid and irrotational fluid.
  • Constant water depth and horizontal impermeable seabed.
  • No background current.
  • Negligible surface tension and dissipation.
  • Free-surface boundary conditions linearised at z = 0.

All dimensional inputs and outputs use SI units. Angles are expressed in radians.

The functions support NumPy broadcasting. They do not independently establish whether linear theory is appropriate for a particular wave amplitude or environmental condition.

References

Dean, R. G. and Dalrymple, R. A. (1991). Water Wave Mechanics for Engineers and Scientists. World Scientific.

ENGINEERING_GRAVITY module-attribute

ENGINEERING_GRAVITY: Final[float] = 9.81

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_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

dispersion_angular_frequency

dispersion_angular_frequency(wave_number: ArrayLike, depth: ArrayLike, gravity: ArrayLike = ENGINEERING_GRAVITY) -> float | np.ndarray

Calculate angular frequency from the dispersion relation.

Parameters:

Name Type Description Default
wave_number array_like

Wave-number magnitude k, in rad/m. Positive.

required
depth array_like

Still-water depth h, in metres. Positive.

required
gravity array_like

Gravitational acceleration, in m/s^2.

ENGINEERING_GRAVITY

Returns:

Type Description
float or ndarray

Angular frequency omega, in rad/s.

Notes

Equation:

omega = sqrt(g*k*tanh(k*h))

Assumes linear surface gravity waves.

Source code in src/fluidmec/waves/dispersion.py
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
def dispersion_angular_frequency(
    wave_number: ArrayLike,
    depth: ArrayLike,
    gravity: ArrayLike = ENGINEERING_GRAVITY,
) -> float | np.ndarray:
    """Calculate angular frequency from the dispersion relation.

    Parameters
    ----------
    wave_number : array_like
        Wave-number magnitude k, in rad/m. Positive.
    depth : array_like
        Still-water depth h, in metres. Positive.
    gravity : array_like, optional
        Gravitational acceleration, in m/s^2.

    Returns
    -------
    float or numpy.ndarray
        Angular frequency omega, in rad/s.

    Notes
    -----
    Equation:

        omega = sqrt(g*k*tanh(k*h))

    Assumes linear surface gravity waves.
    """
    k = validate_positive(wave_number, "Wave number")
    h = validate_positive(depth, "Water depth")
    g = validate_positive(gravity, "Gravity")

    omega = np.sqrt(g * k * np.tanh(k * h))

    return format_output(omega)

solve_wave_number

solve_wave_number(period: ArrayLike, depth: ArrayLike, gravity: ArrayLike = ENGINEERING_GRAVITY, *, method: str = 'newton', tolerance: float = 1e-10, max_iterations: int = 100) -> float | np.ndarray

Solve the linear wave dispersion relation for k.

Parameters:

Name Type Description Default
period array_like

Wave period T, in seconds. Positive.

required
depth array_like

Still-water depth h, in metres. Positive.

required
gravity array_like

Gravitational acceleration g, in m/s^2.

ENGINEERING_GRAVITY
method (newton, bisection)

Safeguarded Newton-Raphson or bisection.

"newton"
tolerance float

Relative dimensionless residual tolerance. Must be between zero and one, exclusive.

1e-10
max_iterations int

Maximum number of solver evaluations.

100

Returns:

Type Description
float or ndarray

Positive wave-number magnitude k, in rad/m.

Raises:

Type Description
ValueError

If physical inputs or solver options are invalid.

RuntimeError

If the solver does not converge.

Notes

Solves:

x*tanh(x) = mu

where x = kh and mu = omega**2h/g.

Convergence criterion:

abs(x*tanh(x) - mu) / mu <= tolerance

Newton steps outside the root bracket are replaced by bisection steps.

Supports NumPy broadcasting. Every array element must converge before the function returns.

The result is based on linear gravity wave theory, without current or surface tension.

Source code in src/fluidmec/waves/dispersion.py
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
def solve_wave_number(
    period: ArrayLike,
    depth: ArrayLike,
    gravity: ArrayLike = ENGINEERING_GRAVITY,
    *,
    method: str = "newton",
    tolerance: float = 1e-10,
    max_iterations: int = 100,
) -> float | np.ndarray:
    """Solve the linear wave dispersion relation for k.

    Parameters
    ----------
    period : array_like
        Wave period T, in seconds. Positive.
    depth : array_like
        Still-water depth h, in metres. Positive.
    gravity : array_like, optional
        Gravitational acceleration g, in m/s^2.
    method : {"newton", "bisection"}, optional
        Safeguarded Newton-Raphson or bisection.
    tolerance : float, optional
        Relative dimensionless residual tolerance.
        Must be between zero and one, exclusive.
    max_iterations : int, optional
        Maximum number of solver evaluations.

    Returns
    -------
    float or numpy.ndarray
        Positive wave-number magnitude k, in rad/m.

    Raises
    ------
    ValueError
        If physical inputs or solver options are invalid.
    RuntimeError
        If the solver does not converge.

    Notes
    -----
    Solves:

        x*tanh(x) = mu

    where x = k*h and mu = omega**2*h/g.

    Convergence criterion:

        abs(x*tanh(x) - mu) / mu <= tolerance

    Newton steps outside the root bracket are replaced
    by bisection steps.

    Supports NumPy broadcasting. Every array element must
    converge before the function returns.

    The result is based on linear gravity wave theory,
    without current or surface tension.
    """
    tolerance = _validate_solver_options(
        method,
        tolerance,
        max_iterations,
    )

    period = validate_positive(period, "Wave period")
    depth = validate_positive(depth, "Water depth")
    gravity = validate_positive(gravity, "Gravity")

    period, depth, gravity = np.broadcast_arrays(
        period,
        depth,
        gravity,
    )

    omega = 2.0 * np.pi / period

    with np.errstate(
        over="ignore",
        under="ignore",
        invalid="ignore",
    ):
        mu = omega**2 * depth / gravity

    if np.any(~np.isfinite(mu)) or np.any(mu <= 0):
        raise ValueError("Inputs exceed the supported numerical range.")

    # The limiting solutions are:
    # Deep water: x = mu
    # Shallow water: x = sqrt(mu)
    #
    # Twice the larger limiting value provides an
    # upper bracket for ordinary positive inputs.
    estimate = np.maximum(mu, np.sqrt(mu))

    lower = np.zeros_like(mu)
    upper = 2.0 * estimate

    if np.any(~np.isfinite(upper)):
        raise ValueError("Unable to construct a finite root bracket.")

    if np.any(_dimensionless_residual(upper, mu) < 0):
        raise RuntimeError("Unable to bracket the dispersion root.")

    x = estimate.copy()

    for _ in range(max_iterations):
        residual = _dimensionless_residual(x, mu)

        converged = np.abs(residual) / mu <= tolerance

        if np.all(converged):
            result = x / depth

            if np.any(~np.isfinite(result)) or np.any(result <= 0):
                raise ValueError("Wave number exceeds numerical range.")

            return format_output(result)

        active = ~converged

        lower = np.where(
            active & (residual < 0),
            x,
            lower,
        )

        upper = np.where(
            active & (residual > 0),
            x,
            upper,
        )

        midpoint = lower + 0.5 * (upper - lower)

        if method == "newton":
            derivative = _dimensionless_derivative(x)

            with np.errstate(
                divide="ignore",
                invalid="ignore",
                over="ignore",
            ):
                candidate = x - residual / derivative

            valid_step = (
                np.isfinite(candidate) & (candidate > lower) & (candidate < upper)
            )

            next_x = np.where(
                valid_step,
                candidate,
                midpoint,
            )

        else:
            next_x = midpoint

        # Preserve array elements that have converged.
        x = np.where(active, next_x, x)

    raise RuntimeError(
        f"Wave dispersion solver did not converge within {max_iterations} iterations."
    )

angular_frequency

angular_frequency(period: ArrayLike) -> float | np.ndarray

Calculate angular wave frequency.

Parameters:

Name Type Description Default
period array_like

Wave period T, in seconds. Must be strictly positive.

required

Returns:

Type Description
float or ndarray

Angular frequency omega, in radians per second.

Notes

Equation: omega = 2 * pi / T.

Angular frequency measures the temporal rate of change of wave phase.

Source code in src/fluidmec/waves/parameters.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
def angular_frequency(
    period: ArrayLike,
) -> float | np.ndarray:
    """Calculate angular wave frequency.

    Parameters
    ----------
    period : array_like
        Wave period T, in seconds.
        Must be strictly positive.

    Returns
    -------
    float or numpy.ndarray
        Angular frequency omega, in radians per second.

    Notes
    -----
    Equation: omega = 2 * pi / T.

    Angular frequency measures the temporal rate of change
    of wave phase.
    """
    period = validate_positive(period, "Wave period")

    return format_output(2.0 * np.pi / period)

_validate_vertical_coordinates

_validate_vertical_coordinates(z: ArrayLike, depth: ArrayLike) -> tuple[np.ndarray, np.ndarray]

Validate coordinates within the mean water column.

Source code in src/fluidmec/waves/airy.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def _validate_vertical_coordinates(
    z: ArrayLike,
    depth: ArrayLike,
) -> tuple[np.ndarray, np.ndarray]:
    """Validate coordinates within the mean water column."""
    z = as_float_array(z, "Vertical coordinate")
    h = validate_positive(depth, "Water depth")

    z, h = np.broadcast_arrays(z, h)

    if np.any(z > 0.0) or np.any(z < -h):
        raise ValueError("Vertical coordinate must satisfy -depth <= z <= 0.")

    return z, h

_finite_result

_finite_result(result: ArrayLike, name: str) -> float | np.ndarray

Reject non-finite calculated results.

Source code in src/fluidmec/waves/airy.py
89
90
91
92
93
94
95
96
97
98
99
def _finite_result(
    result: ArrayLike,
    name: str,
) -> float | np.ndarray:
    """Reject non-finite calculated results."""
    result = np.asarray(result, dtype=float)

    if not np.all(np.isfinite(result)):
        raise ValueError(f"{name} exceeds the supported numerical range.")

    return format_output(result)

wave_phase

wave_phase(x: ArrayLike, time: ArrayLike, wave_number: ArrayLike, angular_frequency: ArrayLike, phase_offset: ArrayLike = 0.0) -> float | np.ndarray

Calculate the phase of a progressive sinusoidal wave.

Parameters:

Name Type Description Default
x array_like

Horizontal position in metres.

required
time array_like

Time in seconds.

required
wave_number array_like

Positive wave-number magnitude in rad/m.

required
angular_frequency array_like

Positive angular frequency in rad/s.

required
phase_offset array_like

Initial phase offset in radians.

0.0

Returns:

Type Description
float or ndarray

Unwrapped wave phase in radians.

Notes

Equation:

theta = k*x - omega*t + phase_offset

Positive k and omega describe propagation in the positive x direction.

This general phase function does not independently enforce the gravity-wave dispersion relation.

Source code in src/fluidmec/waves/airy.py
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def wave_phase(
    x: ArrayLike,
    time: ArrayLike,
    wave_number: ArrayLike,
    angular_frequency: ArrayLike,
    phase_offset: ArrayLike = 0.0,
) -> float | np.ndarray:
    """Calculate the phase of a progressive sinusoidal wave.

    Parameters
    ----------
    x : array_like
        Horizontal position in metres.
    time : array_like
        Time in seconds.
    wave_number : array_like
        Positive wave-number magnitude in rad/m.
    angular_frequency : array_like
        Positive angular frequency in rad/s.
    phase_offset : array_like, optional
        Initial phase offset in radians.

    Returns
    -------
    float or numpy.ndarray
        Unwrapped wave phase in radians.

    Notes
    -----
    Equation:

        theta = k*x - omega*t + phase_offset

    Positive k and omega describe propagation in the
    positive x direction.

    This general phase function does not independently
    enforce the gravity-wave dispersion relation.
    """
    x = as_float_array(x, "Horizontal position")
    t = as_float_array(time, "Time")
    k = validate_positive(wave_number, "Wave number")
    omega = validate_positive(
        angular_frequency,
        "Angular frequency",
    )
    offset = as_float_array(phase_offset, "Phase offset")

    with np.errstate(over="ignore", invalid="ignore"):
        result = k * x - omega * t + offset

    return _finite_result(result, "Wave phase")

surface_elevation

surface_elevation(amplitude: ArrayLike, x: ArrayLike, time: ArrayLike, wave_number: ArrayLike, angular_frequency: ArrayLike, phase_offset: ArrayLike = 0.0) -> float | np.ndarray

Calculate sinusoidal free-surface elevation.

Parameters:

Name Type Description Default
amplitude array_like

Non-negative wave amplitude in metres. Wave amplitude equals half the wave height.

required
x array_like

Horizontal position in metres.

required
time array_like

Time in seconds.

required
wave_number array_like

Positive wave number in rad/m.

required
angular_frequency array_like

Positive angular frequency in rad/s.

required
phase_offset array_like

Initial phase offset in radians.

0.0

Returns:

Type Description
float or ndarray

Surface elevation relative to still water, in metres.

Notes

Equation:

eta = a*cos(k*x - omega*t + phase_offset)

The wave-number and frequency inputs must be physically consistent for gravity-wave applications.

Source code in src/fluidmec/waves/airy.py
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
def surface_elevation(
    amplitude: ArrayLike,
    x: ArrayLike,
    time: ArrayLike,
    wave_number: ArrayLike,
    angular_frequency: ArrayLike,
    phase_offset: ArrayLike = 0.0,
) -> float | np.ndarray:
    """Calculate sinusoidal free-surface elevation.

    Parameters
    ----------
    amplitude : array_like
        Non-negative wave amplitude in metres.
        Wave amplitude equals half the wave height.
    x : array_like
        Horizontal position in metres.
    time : array_like
        Time in seconds.
    wave_number : array_like
        Positive wave number in rad/m.
    angular_frequency : array_like
        Positive angular frequency in rad/s.
    phase_offset : array_like, optional
        Initial phase offset in radians.

    Returns
    -------
    float or numpy.ndarray
        Surface elevation relative to still water, in metres.

    Notes
    -----
    Equation:

        eta = a*cos(k*x - omega*t + phase_offset)

    The wave-number and frequency inputs must be
    physically consistent for gravity-wave applications.
    """
    a = validate_non_negative(amplitude, "Wave amplitude")

    theta = wave_phase(
        x,
        time,
        wave_number,
        angular_frequency,
        phase_offset,
    )

    return format_output(a * np.cos(theta))

surface_elevation_from_period

surface_elevation_from_period(amplitude: ArrayLike, x: ArrayLike, time: ArrayLike, period: ArrayLike, depth: ArrayLike, gravity: ArrayLike = ENGINEERING_GRAVITY, *, phase_offset: ArrayLike = 0.0, method: str = 'newton', tolerance: float = 1e-10, max_iterations: int = 100) -> float | np.ndarray

Calculate finite-depth surface elevation from period.

Parameters:

Name Type Description Default
amplitude array_like

Non-negative wave amplitude in metres.

required
x array_like

Horizontal position in metres.

required
time array_like

Time in seconds.

required
period array_like

Positive wave period in seconds.

required
depth array_like

Positive still-water depth in metres.

required
gravity array_like

Positive gravitational acceleration in m/s^2.

ENGINEERING_GRAVITY
phase_offset array_like

Initial phase in radians.

0.0
method (newton, bisection)

Dispersion solver method.

"newton"
tolerance float

Relative dispersion residual tolerance.

1e-10
max_iterations int

Maximum dispersion solver evaluations.

100

Returns:

Type Description
float or ndarray

Surface elevation in metres.

Notes

Wave number is obtained from the finite-depth linear dispersion relation.

Source code in src/fluidmec/waves/airy.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
def surface_elevation_from_period(
    amplitude: ArrayLike,
    x: ArrayLike,
    time: ArrayLike,
    period: ArrayLike,
    depth: ArrayLike,
    gravity: ArrayLike = ENGINEERING_GRAVITY,
    *,
    phase_offset: ArrayLike = 0.0,
    method: str = "newton",
    tolerance: float = 1e-10,
    max_iterations: int = 100,
) -> float | np.ndarray:
    """Calculate finite-depth surface elevation from period.

    Parameters
    ----------
    amplitude : array_like
        Non-negative wave amplitude in metres.
    x : array_like
        Horizontal position in metres.
    time : array_like
        Time in seconds.
    period : array_like
        Positive wave period in seconds.
    depth : array_like
        Positive still-water depth in metres.
    gravity : array_like, optional
        Positive gravitational acceleration in m/s^2.
    phase_offset : array_like, optional
        Initial phase in radians.
    method : {"newton", "bisection"}, optional
        Dispersion solver method.
    tolerance : float, optional
        Relative dispersion residual tolerance.
    max_iterations : int, optional
        Maximum dispersion solver evaluations.

    Returns
    -------
    float or numpy.ndarray
        Surface elevation in metres.

    Notes
    -----
    Wave number is obtained from the finite-depth
    linear dispersion relation.
    """
    k = solve_wave_number(
        period,
        depth,
        gravity,
        method=method,
        tolerance=tolerance,
        max_iterations=max_iterations,
    )

    omega = angular_frequency(period)

    return surface_elevation(
        amplitude,
        x,
        time,
        k,
        omega,
        phase_offset,
    )

cosh_depth_factor

cosh_depth_factor(wave_number: ArrayLike, z: ArrayLike, depth: ArrayLike) -> float | np.ndarray

Calculate the stable hyperbolic cosine depth factor.

Parameters:

Name Type Description Default
wave_number array_like

Positive wave number in rad/m.

required
z array_like

Vertical coordinate in metres, satisfying -h <= z <= 0.

required
depth array_like

Positive still-water depth in metres.

required

Returns:

Type Description
float or ndarray

Dimensionless cosine depth attenuation factor.

Notes

Governing expression:

C = cosh(k*(z+h))/cosh(k*h)

Stable exponential formulation:

C = exp(k*z)*(1 + exp(-2*k*(z+h)))
    / (1 + exp(-2*k*h))

All exponential arguments are non-positive within the mean water column.

At z = 0, C = 1.

Source code in src/fluidmec/waves/airy.py
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
def cosh_depth_factor(
    wave_number: ArrayLike,
    z: ArrayLike,
    depth: ArrayLike,
) -> float | np.ndarray:
    """Calculate the stable hyperbolic cosine depth factor.

    Parameters
    ----------
    wave_number : array_like
        Positive wave number in rad/m.
    z : array_like
        Vertical coordinate in metres, satisfying -h <= z <= 0.
    depth : array_like
        Positive still-water depth in metres.

    Returns
    -------
    float or numpy.ndarray
        Dimensionless cosine depth attenuation factor.

    Notes
    -----
    Governing expression:

        C = cosh(k*(z+h))/cosh(k*h)

    Stable exponential formulation:

        C = exp(k*z)*(1 + exp(-2*k*(z+h)))
            / (1 + exp(-2*k*h))

    All exponential arguments are non-positive within
    the mean water column.

    At z = 0, C = 1.
    """
    k = validate_positive(wave_number, "Wave number")
    z, h = _validate_vertical_coordinates(z, depth)

    with np.errstate(over="ignore", under="ignore"):
        q = k * (z + h)
        b = k * h

        numerator = 1.0 + np.exp(-2.0 * q)
        denominator = 1.0 + np.exp(-2.0 * b)

        result = np.exp(k * z) * numerator / denominator

    return _finite_result(result, "Cosine depth factor")

sinh_depth_factor

sinh_depth_factor(wave_number: ArrayLike, z: ArrayLike, depth: ArrayLike) -> float | np.ndarray

Calculate the stable hyperbolic sine depth factor.

Parameters:

Name Type Description Default
wave_number array_like

Positive wave number in rad/m.

required
z array_like

Vertical coordinate in metres, satisfying -h <= z <= 0.

required
depth array_like

Positive still-water depth in metres.

required

Returns:

Type Description
float or ndarray

Dimensionless sine depth attenuation factor.

Notes

Governing expression:

S = sinh(k*(z+h))/cosh(k*h)

Stable exponential formulation:

S = exp(k*z)*(1 - exp(-2*k*(z+h)))
    / (1 + exp(-2*k*h))

NumPy expm1 is used to reduce cancellation close to the seabed.

At z = -h, S = 0. At z = 0, S = tanh(k*h).

Source code in src/fluidmec/waves/airy.py
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
def sinh_depth_factor(
    wave_number: ArrayLike,
    z: ArrayLike,
    depth: ArrayLike,
) -> float | np.ndarray:
    """Calculate the stable hyperbolic sine depth factor.

    Parameters
    ----------
    wave_number : array_like
        Positive wave number in rad/m.
    z : array_like
        Vertical coordinate in metres, satisfying -h <= z <= 0.
    depth : array_like
        Positive still-water depth in metres.

    Returns
    -------
    float or numpy.ndarray
        Dimensionless sine depth attenuation factor.

    Notes
    -----
    Governing expression:

        S = sinh(k*(z+h))/cosh(k*h)

    Stable exponential formulation:

        S = exp(k*z)*(1 - exp(-2*k*(z+h)))
            / (1 + exp(-2*k*h))

    NumPy expm1 is used to reduce cancellation
    close to the seabed.

    At z = -h, S = 0.
    At z = 0, S = tanh(k*h).
    """
    k = validate_positive(wave_number, "Wave number")
    z, h = _validate_vertical_coordinates(z, depth)

    with np.errstate(over="ignore", under="ignore"):
        q = k * (z + h)
        b = k * h

        numerator = -np.expm1(-2.0 * q)
        denominator = 1.0 + np.exp(-2.0 * b)

        result = np.exp(k * z) * numerator / denominator

    return _finite_result(result, "Sine depth factor")

velocity_potential

velocity_potential(amplitude: ArrayLike, x: ArrayLike, z: ArrayLike, time: ArrayLike, wave_number: ArrayLike, depth: ArrayLike, gravity: ArrayLike = ENGINEERING_GRAVITY, *, phase_offset: ArrayLike = 0.0) -> float | np.ndarray

Calculate the finite-depth Airy wave velocity potential.

Parameters:

Name Type Description Default
amplitude array_like

Non-negative wave amplitude in metres.

required
x array_like

Horizontal position in metres.

required
z array_like

Vertical position in metres, within -h <= z <= 0.

required
time array_like

Time in seconds.

required
wave_number array_like

Positive wave number in rad/m.

required
depth array_like

Positive still-water depth in metres.

required
gravity array_like

Positive gravitational acceleration in m/s^2.

ENGINEERING_GRAVITY
phase_offset array_like

Initial phase in radians.

0.0

Returns:

Type Description
float or ndarray

Velocity potential in m^2/s.

Notes

Equation:

phi = (g*a/omega)*C(z)*sin(theta)

where omega satisfies the linear dispersion relation.

The potential convention is u = d(phi)/dx and w = d(phi)/dz.

Assumes linear, inviscid, irrotational gravity waves without background current.

Source code in src/fluidmec/waves/airy.py
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
def velocity_potential(
    amplitude: ArrayLike,
    x: ArrayLike,
    z: ArrayLike,
    time: ArrayLike,
    wave_number: ArrayLike,
    depth: ArrayLike,
    gravity: ArrayLike = ENGINEERING_GRAVITY,
    *,
    phase_offset: ArrayLike = 0.0,
) -> float | np.ndarray:
    """Calculate the finite-depth Airy wave velocity potential.

    Parameters
    ----------
    amplitude : array_like
        Non-negative wave amplitude in metres.
    x : array_like
        Horizontal position in metres.
    z : array_like
        Vertical position in metres, within -h <= z <= 0.
    time : array_like
        Time in seconds.
    wave_number : array_like
        Positive wave number in rad/m.
    depth : array_like
        Positive still-water depth in metres.
    gravity : array_like, optional
        Positive gravitational acceleration in m/s^2.
    phase_offset : array_like, optional
        Initial phase in radians.

    Returns
    -------
    float or numpy.ndarray
        Velocity potential in m^2/s.

    Notes
    -----
    Equation:

        phi = (g*a/omega)*C(z)*sin(theta)

    where omega satisfies the linear dispersion relation.

    The potential convention is u = d(phi)/dx
    and w = d(phi)/dz.

    Assumes linear, inviscid, irrotational gravity waves
    without background current.
    """
    a = validate_non_negative(amplitude, "Wave amplitude")
    g = validate_positive(gravity, "Gravity")

    omega = dispersion_angular_frequency(
        wave_number,
        depth,
        g,
    )

    omega = validate_positive(omega, "Angular frequency")

    theta = wave_phase(
        x,
        time,
        wave_number,
        omega,
        phase_offset,
    )

    c = cosh_depth_factor(wave_number, z, depth)

    with np.errstate(over="ignore", invalid="ignore"):
        result = (g * a / omega) * c * np.sin(theta)

    return _finite_result(result, "Velocity potential")

velocity_potential_from_period

velocity_potential_from_period(amplitude: ArrayLike, x: ArrayLike, z: ArrayLike, time: ArrayLike, period: ArrayLike, depth: ArrayLike, gravity: ArrayLike = ENGINEERING_GRAVITY, *, phase_offset: ArrayLike = 0.0, method: str = 'newton', tolerance: float = 1e-10, max_iterations: int = 100) -> float | np.ndarray

Calculate the Airy velocity potential from wave period.

Parameters:

Name Type Description Default
amplitude array_like

Non-negative wave amplitude in metres.

required
x array_like

Horizontal and vertical coordinates in metres. Vertical coordinates must satisfy -h <= z <= 0.

required
z array_like

Horizontal and vertical coordinates in metres. Vertical coordinates must satisfy -h <= z <= 0.

required
time array_like

Time in seconds.

required
period array_like

Positive wave period in seconds.

required
depth array_like

Positive still-water depth in metres.

required
gravity array_like

Gravitational acceleration in m/s^2.

ENGINEERING_GRAVITY
phase_offset array_like

Initial phase in radians.

0.0
method (newton, bisection)

Dispersion solver method.

"newton"
tolerance float

Relative dispersion residual tolerance.

1e-10
max_iterations int

Maximum dispersion solver evaluations.

100

Returns:

Type Description
float or ndarray

Velocity potential in m^2/s.

Notes

Uses the dispersion solver to determine wave number. The angular frequency in the potential is evaluated from the resulting wave number.

Source code in src/fluidmec/waves/airy.py
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
def velocity_potential_from_period(
    amplitude: ArrayLike,
    x: ArrayLike,
    z: ArrayLike,
    time: ArrayLike,
    period: ArrayLike,
    depth: ArrayLike,
    gravity: ArrayLike = ENGINEERING_GRAVITY,
    *,
    phase_offset: ArrayLike = 0.0,
    method: str = "newton",
    tolerance: float = 1e-10,
    max_iterations: int = 100,
) -> float | np.ndarray:
    """Calculate the Airy velocity potential from wave period.

    Parameters
    ----------
    amplitude : array_like
        Non-negative wave amplitude in metres.
    x, z : array_like
        Horizontal and vertical coordinates in metres.
        Vertical coordinates must satisfy -h <= z <= 0.
    time : array_like
        Time in seconds.
    period : array_like
        Positive wave period in seconds.
    depth : array_like
        Positive still-water depth in metres.
    gravity : array_like, optional
        Gravitational acceleration in m/s^2.
    phase_offset : array_like, optional
        Initial phase in radians.
    method : {"newton", "bisection"}, optional
        Dispersion solver method.
    tolerance : float, optional
        Relative dispersion residual tolerance.
    max_iterations : int, optional
        Maximum dispersion solver evaluations.

    Returns
    -------
    float or numpy.ndarray
        Velocity potential in m^2/s.

    Notes
    -----
    Uses the dispersion solver to determine wave number.
    The angular frequency in the potential is evaluated
    from the resulting wave number.
    """
    k = solve_wave_number(
        period,
        depth,
        gravity,
        method=method,
        tolerance=tolerance,
        max_iterations=max_iterations,
    )

    return velocity_potential(
        amplitude,
        x,
        z,
        time,
        k,
        depth,
        gravity,
        phase_offset=phase_offset,
    )

stream_function

stream_function(amplitude: ArrayLike, x: ArrayLike, z: ArrayLike, time: ArrayLike, wave_number: ArrayLike, depth: ArrayLike, gravity: ArrayLike = ENGINEERING_GRAVITY, *, phase_offset: ArrayLike = 0.0) -> float | np.ndarray

Calculate the finite-depth Airy wave stream function.

Parameters:

Name Type Description Default
amplitude array_like

Non-negative wave amplitude in metres.

required
x array_like

Horizontal position in metres.

required
z array_like

Vertical position in metres, within -h <= z <= 0.

required
time array_like

Time in seconds.

required
wave_number array_like

Positive wave number in rad/m.

required
depth array_like

Positive still-water depth in metres.

required
gravity array_like

Gravitational acceleration in m/s^2.

ENGINEERING_GRAVITY
phase_offset array_like

Initial phase in radians.

0.0

Returns:

Type Description
float or ndarray

Stream function in m^2/s.

Notes

Equation:

psi = (g*a/omega)*S(z)*cos(theta)

Convention:

u = d(psi)/dz
w = -d(psi)/dx

The stream function is zero at the seabed. Instantaneous streamlines are not particle trajectories in this unsteady flow.

Source code in src/fluidmec/waves/airy.py
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
def stream_function(
    amplitude: ArrayLike,
    x: ArrayLike,
    z: ArrayLike,
    time: ArrayLike,
    wave_number: ArrayLike,
    depth: ArrayLike,
    gravity: ArrayLike = ENGINEERING_GRAVITY,
    *,
    phase_offset: ArrayLike = 0.0,
) -> float | np.ndarray:
    """Calculate the finite-depth Airy wave stream function.

    Parameters
    ----------
    amplitude : array_like
        Non-negative wave amplitude in metres.
    x : array_like
        Horizontal position in metres.
    z : array_like
        Vertical position in metres, within -h <= z <= 0.
    time : array_like
        Time in seconds.
    wave_number : array_like
        Positive wave number in rad/m.
    depth : array_like
        Positive still-water depth in metres.
    gravity : array_like, optional
        Gravitational acceleration in m/s^2.
    phase_offset : array_like, optional
        Initial phase in radians.

    Returns
    -------
    float or numpy.ndarray
        Stream function in m^2/s.

    Notes
    -----
    Equation:

        psi = (g*a/omega)*S(z)*cos(theta)

    Convention:

        u = d(psi)/dz
        w = -d(psi)/dx

    The stream function is zero at the seabed.
    Instantaneous streamlines are not particle trajectories
    in this unsteady flow.
    """
    a = validate_non_negative(amplitude, "Wave amplitude")
    g = validate_positive(gravity, "Gravity")

    omega = dispersion_angular_frequency(
        wave_number,
        depth,
        g,
    )

    omega = validate_positive(omega, "Angular frequency")

    theta = wave_phase(
        x,
        time,
        wave_number,
        omega,
        phase_offset,
    )

    s = sinh_depth_factor(wave_number, z, depth)

    with np.errstate(over="ignore", invalid="ignore"):
        result = (g * a / omega) * s * np.cos(theta)

    return _finite_result(result, "Stream function")

stream_function_from_period

stream_function_from_period(amplitude: ArrayLike, x: ArrayLike, z: ArrayLike, time: ArrayLike, period: ArrayLike, depth: ArrayLike, gravity: ArrayLike = ENGINEERING_GRAVITY, *, phase_offset: ArrayLike = 0.0, method: str = 'newton', tolerance: float = 1e-10, max_iterations: int = 100) -> float | np.ndarray

Calculate the Airy stream function from wave period.

Parameters:

Name Type Description Default
amplitude array_like

Non-negative wave amplitude in metres.

required
x array_like

Horizontal and vertical coordinates in metres. Vertical coordinates must satisfy -h <= z <= 0.

required
z array_like

Horizontal and vertical coordinates in metres. Vertical coordinates must satisfy -h <= z <= 0.

required
time array_like

Time in seconds.

required
period array_like

Positive wave period in seconds.

required
depth array_like

Positive still-water depth in metres.

required
gravity array_like

Gravitational acceleration in m/s^2.

ENGINEERING_GRAVITY
phase_offset array_like

Initial phase in radians.

0.0
method (newton, bisection)

Dispersion solver method.

"newton"
tolerance float

Relative dispersion residual tolerance.

1e-10
max_iterations int

Maximum dispersion solver evaluations.

100

Returns:

Type Description
float or ndarray

Stream function in m^2/s.

Notes

Uses the finite-depth dispersion solver.

Source code in src/fluidmec/waves/airy.py
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
def stream_function_from_period(
    amplitude: ArrayLike,
    x: ArrayLike,
    z: ArrayLike,
    time: ArrayLike,
    period: ArrayLike,
    depth: ArrayLike,
    gravity: ArrayLike = ENGINEERING_GRAVITY,
    *,
    phase_offset: ArrayLike = 0.0,
    method: str = "newton",
    tolerance: float = 1e-10,
    max_iterations: int = 100,
) -> float | np.ndarray:
    """Calculate the Airy stream function from wave period.

    Parameters
    ----------
    amplitude : array_like
        Non-negative wave amplitude in metres.
    x, z : array_like
        Horizontal and vertical coordinates in metres.
        Vertical coordinates must satisfy -h <= z <= 0.
    time : array_like
        Time in seconds.
    period : array_like
        Positive wave period in seconds.
    depth : array_like
        Positive still-water depth in metres.
    gravity : array_like, optional
        Gravitational acceleration in m/s^2.
    phase_offset : array_like, optional
        Initial phase in radians.
    method : {"newton", "bisection"}, optional
        Dispersion solver method.
    tolerance : float, optional
        Relative dispersion residual tolerance.
    max_iterations : int, optional
        Maximum dispersion solver evaluations.

    Returns
    -------
    float or numpy.ndarray
        Stream function in m^2/s.

    Notes
    -----
    Uses the finite-depth dispersion solver.
    """
    k = solve_wave_number(
        period,
        depth,
        gravity,
        method=method,
        tolerance=tolerance,
        max_iterations=max_iterations,
    )

    return stream_function(
        amplitude,
        x,
        z,
        time,
        k,
        depth,
        gravity,
        phase_offset=phase_offset,
    )

surface_elevation_time_derivative

surface_elevation_time_derivative(amplitude: ArrayLike, x: ArrayLike, time: ArrayLike, wave_number: ArrayLike, angular_frequency: ArrayLike, phase_offset: ArrayLike = 0.0) -> float | np.ndarray

Calculate the time derivative of surface elevation.

Parameters:

Name Type Description Default
amplitude array_like

Non-negative wave amplitude in metres.

required
x array_like

Horizontal position in metres.

required
time array_like

Time in seconds.

required
wave_number array_like

Positive wave number in rad/m.

required
angular_frequency array_like

Positive angular frequency in rad/s.

required
phase_offset array_like

Initial phase in radians.

0.0

Returns:

Type Description
float or ndarray

Surface elevation time derivative in m/s.

Notes

Equation:

d(eta)/dt = a*omega*sin(theta)

Under the linear kinematic free-surface condition, this equals vertical fluid velocity evaluated at z = 0.

Source code in src/fluidmec/waves/airy.py
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
def surface_elevation_time_derivative(
    amplitude: ArrayLike,
    x: ArrayLike,
    time: ArrayLike,
    wave_number: ArrayLike,
    angular_frequency: ArrayLike,
    phase_offset: ArrayLike = 0.0,
) -> float | np.ndarray:
    """Calculate the time derivative of surface elevation.

    Parameters
    ----------
    amplitude : array_like
        Non-negative wave amplitude in metres.
    x : array_like
        Horizontal position in metres.
    time : array_like
        Time in seconds.
    wave_number : array_like
        Positive wave number in rad/m.
    angular_frequency : array_like
        Positive angular frequency in rad/s.
    phase_offset : array_like, optional
        Initial phase in radians.

    Returns
    -------
    float or numpy.ndarray
        Surface elevation time derivative in m/s.

    Notes
    -----
    Equation:

        d(eta)/dt = a*omega*sin(theta)

    Under the linear kinematic free-surface condition,
    this equals vertical fluid velocity evaluated at z = 0.
    """
    a = validate_non_negative(amplitude, "Wave amplitude")

    omega = validate_positive(
        angular_frequency,
        "Angular frequency",
    )

    theta = wave_phase(
        x,
        time,
        wave_number,
        omega,
        phase_offset,
    )

    with np.errstate(over="ignore", invalid="ignore"):
        result = a * omega * np.sin(theta)

    return _finite_result(
        result,
        "Surface elevation time derivative",
    )

References

Dean, R. G. and Dalrymple, R. A. (1991). Water Wave Mechanics for Engineers and Scientists. World Scientific.