Solves the linear water wave dispersion relationship using a Newton-Raphson iteration loop.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk), | intent(in) | :: | f | Intrinsic frequency [Hz] |
||
real(kind=rk), | intent(in), | optional | :: | depth | Mean water depth [m] |
|
real(kind=rk), | intent(in), | optional | :: | water_density | Water density [kg/m^3] |
|
real(kind=rk), | intent(in), | optional | :: | grav | Gravitational acceleration [m/s^2] |
|
real(kind=rk), | intent(in), | optional | :: | surface_tension | Surface tension [N/m] |
pure elemental function wavenumber(f,depth,water_density,grav,surface_tension)
!! Solves the linear water wave dispersion relationship using a
!! Newton-Raphson iteration loop.
real(kind=rk),intent(in) :: f
!! Intrinsic frequency [Hz]
real(kind=rk),optional,intent(in) :: depth
!! Mean water depth [m]
real(kind=rk),optional,intent(in) :: water_density
!! Water density [kg/m^3]
real(kind=rk),optional,intent(in) :: grav
!! Gravitational acceleration [m/s^2]
real(kind=rk),optional,intent(in) :: surface_tension
!! Surface tension [N/m]
real(kind=rk) :: wavenumber,dk,b,fnd,t
integer :: counter
associate(k => wavenumber)
fnd = twopi*f*sqrt(depth/grav)
k = fnd**2
b = surface_tension/(water_density*grav*depth**2)
counter = 1
dk = 2e-3_rk
newton_raphson: do
t = tanh(k)
dk = -(fnd**2-k*t*(1+b*k**2))&
/(3*b*k**2*t+t+k*(1+b*k**2)*(1-t**2))
k = k-dk
if(abs(dk) < eps .or. counter > 100)then
exit newton_raphson
endif
counter = counter+1
enddo newton_raphson
k = k / depth
endassociate
endfunction wavenumber