% SSGW: Steady Surface Gravity Waves.
% Computation of irrotational 2D periodic surface pure gravity waves
% of arbitrary length in arbitrary depth.
% MANDATORY INPUT PARAMETERS:
% kd = k*d : relative depth (wavenumber "k" times mean water depth "d").
% kH2 = k*H/2 : steepness (half the total wave height "H" times the wavenumber "k").
% OPTIONAL INPUT PARAMETERS:
% N : number of positive Fourier modes (default, N=2048).
% tol : tolerance (default, tol=1e-14).
% OUTPUT PARAMETERS:
% zs = complex abscissas at the free surface (at the computational nodes).
% ws = complex velocity at the free surface (at the computational nodes) in
% the frame of reference moving with the wave.
% PP = Physical Parameters: PP(1)=depth, PP(2)=wavenumber, PP(3)=waveheight,
% PP(4)=celerity c_e, PP(5)=celerity c_s, PP(6)=Bernoulli constant,
% PP(7)=crest height, PP(8)=trough height, PP(9)=impulse,
% PP(10)=potential energy, PP(11)=kinetic energy, PP(12)=radiation stress,
% PP(13)=momentum flux, PP(14)=energy flux, PP(15)=group velocity.
% NOTE 1: This program computes waves of arbitrary length for all heights
% up to about 99% of the maximum one. It is not designed to compute (near)
% limiting waves.
% NOTE 2: The output quantities are dimensionless with the following scaling:
% In deep water: rho = g = k = 1.
% In finite depth: rho = g = d = 1.
% EXAMPLE 1. To compute a wave of steepness kH2=0.3 in infinite depth:
% EXAMPLE 2. To compute a cnoidal wave with height-over-depth=0.5 and
% Hd=0.5; Ld=100; kd=2*pi/Ld; kH2=pi*Hd/Ld; [zs,ws,PP]=SSGW(kd,kH2);
% EXAMPLE 3. For steep and long waves, the default number of Fourier modes
% must be increased. For instance, in order to compute a cnoidal wave with
% height-over-depth=0.7 and length-over-depth=10000:
% Hd=0.7; Ld=10000; kd=2*pi/Ld; kH2=pi*Hd/Ld; [zs,ws,PP]=SSGW(kd,kH2,2^19);
% Edit the m-file for more details.
% For details of the algorithm and the notations, read:
% Clamond, D. & Dutykh, D. 2018. Accurate fast computation of steady
% two-dimensional surface gravity waves in arbitrary depth.
% J. Fluid Mech. 844, pp. 491-518.
% This m-file was written with the purpose of clarity. The notations closely
% match those of the paper above.
% Authors: D. Clamond & D. Dutykh.
% Version: 2017-02-08.
% Revision: 2018-05-31.
Didier Clamond (2020). Surface Gravity Waves (https://www.mathworks.com/matlabcentral/fileexchange/61499-surface-gravity-waves), MATLAB Central File Exchange. Retrieved .
* Updated reference.