API

SpectralWaves.ProblemType
Problem(ℓ::Real, d::Real, ℐ::Integer, t::AbstractRange{Real}; O = 4, M_s = 0, M_b = 0, static_bottom = true)

Construct an IBV Problem object corresponding to a fluid domain of length and depth d with harmonics and N time steps.

Output is a Problem object with fields:

  • is the fluid domain length (m),
  • d is the water depth (m),
  • is the number of harmonics,
  • t is the time range,
  • Δt is the time step (s),
  • N is the number of time steps,
  • O is the order of the time-stepping scheme,
  • κ are wave numbers (rad/m),
  • η̂ are free-surface elevation amplitudes (m),
  • η̇ are free-surface vertical velocity amplitudes (m/s),
  • β̂ are bottom-surface elevation amplitudes (m),
  • β̇ are bottom-surface vertical velocity amplitudes (m/s),
  • ϕ̂ are flat-bottom velocity potential amplitudes (m²/s),
  • ϕ̇ are flat-bottom acceleration potential amplitudes (m²/s²),
  • ψ̂ are uneven-bottom velocity potential amplitudes (m²/s),
  • ψ̇ are uneven-bottom acceleration potential amplitudes (m²/s²),
  • are surface pressure head amplitudes (m),
  • χ is wavemaker paddle displacement (m),
  • ξ is wavemaker paddle velocity (m/s),
  • ζ is wavemaker paddle acceleration (m/s²),
  • 𝒯 are hyperbolic tangent lookup values,
  • 𝒮 are hyperbolic secant lookup values,
  • static_bottom is a boolean flag to indicate if the bottom is static.
source
SpectralWaves.absolute_errorMethod
absolute_error(a::Vector{<:Number}, b::Vector{<:Number})

Compute absolute error between vectors a and b.

Examples

julia> a = [1, 2]; b = [1, 1]; absolute_error(a, b)
1.0
source
SpectralWaves.bottom_bump!Function
bottom_bump!(p::Problem, h, λ, x₀ = 0)

Calculate β̂ coefficients of a problem p for a bottom bump of height h and characteristic length λ at a position x₀.

source
SpectralWaves.bottom_vector!Method
bottom_vector!(p::Problem, x::AbstractRange{<:Real}, β::Vector{<:Real})

Calculate β̂ coefficients of a wave problem p for a bottom profile β(x).

source
SpectralWaves.convolution_powerMethod
convolution_power(a::Vector{<:Number}, n::Integer)

Compute convolution n-th power of vector a.

Examples

julia> a = [1, 2, 3]; convolution_power(a, 3)
7-element Vector{Int64}:
  1
  6
 21
 44
 63
 54
 27
source
SpectralWaves.convolution_rangeMethod
convolution_range(m::Integral, M::Integral, n::Integer)

Compute range r of indices of a central part of convolution vector corresponding to the m-th order of convolution, where M is the maximum order of convolution, N is the length of convolution vector corresponding to the M-th order of convolution, and is the number of harmonics.

Examples

julia> m = 1; M = 3; ℐ = 5; c_range = convolution_range(m, M, ℐ)
11:31
source
SpectralWaves.convolveMethod
convolve(a::Vector{Ta}, b::Vector{Tb}) where {Ta<:Number, Tb<:Number}

Compute direct convolution of vectors a and b.

Examples

julia> a = [1, 2]; b = [1, 1]; convolve(a, b)
3-element Vector{Int64}:
 1
 3
 2
source
SpectralWaves.convolve_dspMethod
convolve_dsp(a::Vector{Ta}, b::Vector{Tb}) where {Ta<:Number, Tb<:Number}

Compute direct convolution of vectors a and b using DSP package.

Examples

julia> a = [1, 2]; b = [1, 1]; convolve(a, b)
3-element Vector{Int64}:
 1
 3
 2
source
SpectralWaves.factorial_lookupMethod
factorial_lookup(n::Integer)

Compute lookup table for factorials of numbers from 0 to n.

Examples

julia> factorial_lookup(3)
4-element Vector{Float64}:
  1.0
  1.0
  2.0
  6.0
source
SpectralWaves.fourier_transformMethod
fourier_transform(f::Vector{<:Number}, ω::Real, x::AbstractRange{<:Real})

Compute f̂(ω) using function values f at points x.

Examples

julia> f = [-1, 0, 1, 0, -1]; ω = 1; x = range(-π, π, length = 5);
julia> fourier_transform(f, ω, x)
0.5 + 0.0im
source
SpectralWaves.general_errorMethod
general_error(a::Vector{<:Number}, b::Vector{<:Number})

Compute a general error between vectors a and b as a relative_error(a, b) or an absolute_error(a, b) for norm(a) not equal or equal to 0, respectively.

source
SpectralWaves.init_nonlinear_bottom_boundary_conditionMethod
init_nonlinear_bottom_boundary_condition(κ, 𝒯, 𝒮, ℐ, M)

Initialize expansion coefficients for nonlinear bottom boundary conditions for eigenvalues κ, hyperbolic tangent 𝒯 and secant 𝒮 values, number of harmonics and order of nonlinear expansion M.

Output is a tuple (Ψ̂′, Ψ̂″, Ψ̃′, Ψ̃″), where:

  • Ψ̂′ are surface-potential-amplitude dependent expansion coefficients and
  • Ψ̂″ are bottom-potential-amplitude dependent expansion coefficients for computing bottom velocity potential amplitudes and its vertical gradients,
  • Ψ̃′ are surface-potential-amplitude dependent expansion coefficients and
  • Ψ̃″ are bottom-potential-amplitude dependent expansion coefficients for computing bottom horizontal velocity potential amplitudes and its vertical gradients.
source
SpectralWaves.init_nonlinear_surface_boundary_conditionMethod
init_nonlinear_surface_boundary_condition(κ, 𝒯, 𝒮, ℐ, M)

Initialize expansion coefficients for nonlinear free-surface boundary conditions for eigenvalues κ, hyperbolic tangent 𝒯 and secant 𝒮 values, number of harmonics and order of nonlinear expansion M.

Output is a tuple (Φ̇′, Φ̇″, Φ̂′, Φ̂″, Φ̃′, Φ̃″), where:

  • Φ̇′ are surface-potential-amplitude dependent expansion coefficients and
  • Φ̇″ are bottom-potential-amplitude dependent expansion coefficients for computing

surface acceleration potential amplitudes and its vertical gradients,

  • Φ̂′ are surface-potential-amplitude dependent expansion coefficients and
  • Φ̂″ are bottom-potential-amplitude dependent expansion coefficients for computing

surface velocity potential amplitudes and its vertical gradients,

  • Φ̃′ are surface-potential-amplitude dependent expansion coefficients and
  • Φ̃″ are bottom-potential-amplitude dependent expansion coefficients for computing

surface horizontal velocity potential amplitudes and its vertical gradients.

source
SpectralWaves.inverse_fourier_transformMethod
inverse_fourier_transform(f̂::Vector{<:Number}, ω::AbstractRange{<:Real}, x::Real)

Compute f(x) using expansion amplitudes and eigenvalues ω.

Examples

julia> f̂ = [0.5, 0, 0.5]; ω = -1:1; x = π; inverse_fourier_transform(f̂, ω, x)
-1.0
source
SpectralWaves.linear_wavemaker!Method
linear_wavemaker!(p::Problem, H, L, t₀)

Calculate wavemaker paddle displacement χ, velocity ξ, and acceleration ζ for a train of linear waves of height H and period T and a number of ramped periods nT₀.

source
SpectralWaves.moving_bottom_bump!Function
moving_bottom_bump!(p::Problem, h, λ, u, x₀ = 0)

Calculate β̂ coefficients of a wave problem p for a moving bottom bump of height h, characteristic length λ, and velocity u at initial position x₀.

source
SpectralWaves.moving_pressure_bump!Function
moving_pressure_bump!(p::Problem, h, λ, u, x₀ = 0)

Calculate coefficients of a problem p for a moving pressure bump of height h, characteristic length λ, and velocity u at initial position x₀.

source
SpectralWaves.nonlinear_dfsbc_correctionMethod
nonlinear_dfsbc_correction(η̂, ϕ̂, ϕ̇, ψ̂, ψ̇, Φ̇′, Φ̇″, Φ̂′, Φ̂″, Φ̃′, Φ̃″, κ′, ℐ, F, M, ξ, ζ, ℓ, d)

Calculate nonlinear correction δϕ̇ to dynamic free-surface boundary condition.

source
SpectralWaves.nonlinear_kfsbc_correctionMethod
nonlinear_kfsbc_correction(η̂, ϕ̂, ψ̂, Φ̂′, Φ̂″, Φ̃′, Φ̃″, κ, κ′, ℐ, F, M)

Calculate nonlinear correction δη̇ to kinematic free-surface boundary condition.

source
SpectralWaves.relative_errorMethod
relative_error(a::Vector{<:Number}, b::Vector{<:Number})

Compute relative error between vectors a and b.

Examples

julia> a = [2, 2]; b = [1, 1]; relative_error(a, b)
0.5
source
SpectralWaves.solve_problem!Method
solve_problem!(p::Problem; msg_flag = true)

Calculate solution coefficients η̂, η̇, ϕ̂, ϕ̇, ψ̂, ψ̇ of the wave problem.

Modified in-place variables:

  • η̂ are free-surface elevation potential amplitudes (m),
  • η̇ are free-surface vertical velocity amplitudes (m/s),
  • ϕ̂ are flat-bottom velocity potential amplitudes (m²/s),
  • ϕ̇ are flat-bottom acceleration potential amplitudes (m²/s²),
  • ψ̂ are uneven-bottom velocity potential amplitudes (m²/s),
  • ψ̇ are uneven-bottom acceleration potential amplitudes (m²/s²),

Input variables:

  • β̂ are bottom-surface elevation amplitudes (m),
  • β̇ are bottom-surface vertical velocity amplitudes (m/s),
  • are surface pressure head amplitudes (m),
  • κ are wave numbers (rad/m),
  • 𝒯 are hyperbolic tangent lookup values,
  • 𝒮 are hyperbolic secant lookup values,
  • is the number of harmonics,
  • M_s is the order of nonlinear free-surface boundary condition,
  • M_b is the order of nonlinear bottom boundary condition,
  • Δt is the time step (s),
  • O is the order of the time-stepping scheme,
  • N is the number of time steps,
  • χ is wavemaker paddle displacement (m),
  • ξ is wavemaker paddle velocity (m/s),
  • ζ is wavemaker paddle acceleration (m/s²),
  • is the fluid domain length (m),
  • d is the water depth (m).

Keyword arguments:

  • static_bottom is a boolean flag to indicate whether the bottom is static,
  • msg_flag is a boolean flag to indicate whether to print progress messages.
source
SpectralWaves.surface_bump!Function
surface_bump!(p::Problem, h, λ, x₀ = 0)

Calculate η̂ coefficients of a problem p for a surface bump of height h and characteristic length λ at position x₀.

source
SpectralWaves.time_integration_coeffsMethod
time_integration_coeffs(O::Integer)

Calculate Adams-Bashforth-Moulton time-stepping scheme coefficients for a given order O.

Output is a tuple of two vectors with Adams-Bashforth and Adams-Moulton coefficients, respectively.

source
SpectralWaves.toeplitzMethod
toeplitz(a::Vector{T}) where T

Transform vector a to a Toeplitz matrix.

Examples

julia> a = [1, 2, 3]; toeplitz(a)
2×2 Matrix{Int64}:
 2  1
 3  2
source
SpectralWaves.update_bbc_sle!Method
update_bbc_sle!(A′, A″, Ψ̂′, Ψ̂″, Ψ̃′, Ψ̃″, w′, β̂, κ, κ′, ℐ, F, M)

Compute coefficients A′, A″, and w′ for the bottom boundary condition system of linear equations (SLE).

Modified in-place variables:

  • A′ are constant coefficients of the system of linear equations and
  • A″ are coefficients of the system of linear equations,
  • w′ are coefficients corresponding to the linear wavemaker term.
source
SpectralWaves.water_surfaceMethod
water_surface(p::Problem, x::Real, n::Integer)

Compute the water surface elevation η at position x and for time instant n.

source
SpectralWaves.water_velocityMethod
water_velocity(p::Problem, x::Real, z::Real, n::Integer, c::Symbol)

Compute the water velocity component u or w using the symbol :x or :z at position (x, z), and for time instant n.

source