In this post, giving briefs about of basic Regular Wave and simulation by using python matplotlib and numpy.

Basics of Animation


This article uses the SI unit system as the unit of measurement.

Regular Wave

In marine hydrodynamics, a “regular wave” refers to a wave with a consistent and predictable pattern of oscillation.

Regular waves can be represented mathematically using sine or cosine functions.

\zeta = \zeta_0 ~ cos(\omega t - k x + \phi)

\phi is the phase angle characterizes the uncertainty of the real sea.


In marine hydrodynamics, dispersion refers to the phenomenon where waves of different wavelengths and frequencies travel at different speeds. This causes the wave components to spread out or disperse over time and distance.

\omega^2 = g ~ k ~ tanh(kd)

Velocity Vectors of Particles

Velocity Vectors can be calculated for x, y, z axis. In this post, we use x and z axis (2D).

\nabla \phi = V(u, \nu, \omega)

u = \frac {\omega ~ \zeta_0} {sinh(kd)} ~ cosh(k(d + z)) ~ cos(\omega t - kx)

\omega = - \frac {\omega ~ \zeta_0} {sinh(kd)} ~ sinh(k(d + z)) ~ sin(\omega t - kx)

Code Space

In this part, theoretical parts are tried to be reinforced by writing code.

Modules and Setup

Note: Seaborn is not default package in conda environment. Needs to install

$ pip install seaborn

Seaborn provides more aesthetic plots and customizations.Add the following codes below to set seaborn theme.

Initial Values

There are some pre-defined initial values.

\lambda = 100 ~~ [m]

d = 40 ~~ [m]

H = 2 ~~ [m]

\phi = 0 ~~ [rad]

A = H / 2 ~~ [m]

k = 2 \pi / \lambda ~~ [m^{-1}]

In this section, we defined a 1m amplituded a regular sea wave that have 100 metre wavelength. Depth is nearly 40 meters. Phi(phase angle) is 0.


omega (w)is calculated by using dispersion relation with pre-defined k(number of wave) and d(water depth).

Regular Wave

Regular wave created by range at x ∈ (0, 100) meters.

Plot of Initial Wave

In this section wave visualized by using current plot data.

Velocity Vectors

This section we calculated velocities for x & z axises.

Speed calculated by using formula |v| = \sqrt {u^2 + w^2}

Plots of Velocity Vectors

Wave and velocity vectors and plotted.


In this section, steps following are applied sequentially

  • Defined some initial values (depth, wavelenght, amplitude).
  • Calculated omega(w) by using dispersion formula.
  • Created regular wave by using this initial values and omega(w).
  • Velocity magnitudes calculated
  • Speed calculated by u and w velocity vectors.
  • Regular wave plotted
  • Velocity vectors plotted by Quiver graph
  • Speed and colorbar imported
  • Plot prettified.


Charts animated by using matplotlib FuncAnimation.


You can access the animation codebase on github repository on link below.


In this Animation, wave animated by time. Wave and velocity vectors calculated every time is updated

ibrahim tunc
ibrahim tunc
Articles: 13

Leave a Reply

Your email address will not be published. Required fields are marked *