• https://me.yahoo.com
COST (GBP)
3.00
0.00
0

# Dispersion

viewed 2340 times and licensed 45 times
Uses a linear dispersion relationship to compute wave-frequency from wave-number
Controller: CodeCogs

C++

## K To W

 doublek_to_w( double k double depth = 0 double gravity = 9.8066 )
This function solves the linear dispersion equation, $\inline&space;&space;w^2&space;=&space;g&space;k&space;tanh(k&space;d)$, to obtain wave-frequency from a given wave-number, using a very simple rearrangement
$w&space;=&space;\sqrt&space;{&space;g&space;k&space;tanh(k&space;d)&space;}$
where w is wave-frequency, k is wave-number and g is gravity. In deep water (represented with d<=0), this solution reduces to
$w&space;=&space;\sqrt&space;{&space;g&space;k&space;}$

The opposite of this function is dispersion_w

### Parameters

 k ($\inline&space;2\;\mathrm{\pi/m}$) is wave-number. [rad/m] depth the depth of the water to mean sea level. A value of zero or less corresponds to deep water. [m] gravity (default 9.8066). [m/s2]

### Returns

wave-frequency ($\inline&space;&space;2\;\mathrm{\pi/s}$). [rad/s]
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.

## K To W

 doublek_to_w( double a double k double depth = 0 double gravity = 9.8066 )
This function solves a 2nd order dispersion relationship to more accurately compute the relationship between wave-frequency and wave-number for the specified wave amplitude a. The solution is based on work by Dalrymple, who derived:
$w^2&space;=&space;g&space;k&space;(1&space;+&space;f_1&space;\epsilon^2&space;D)&space;tanh(k&space;d&space;+&space;f_2&space;\epsilon)$

In deep water(represented with d<=0), this solution reduces to
$w&space;=&space;\sqrt&space;{&space;g&space;k&space;}$
As in the linear dispersion relationship.

Example:
##### Example - Second order Wave Number to Wave Frequency
Problem
Compute the second order Wave Number from Wave Frequency in water of depth 2m.
Workings
#include <stdio.h>
#include <codecogs/engineering/fluid_mechanics/waves/dispersion.h>
using namespace Engineering::Fluid_Mechanics::Waves;

int main()
{
double amp=3;  // 3 meters
printf("   k         w ");
for(double k=0.01; k<1;k+=0.1)
{
printf("\n %.6lf", k);
double w=k_to_w(amp,k,2);
printf("  %.3lf", w);
}
}

### Parameters

 a amplitude of component with wavenumber k. [m] k wave-number of component ($\inline&space;2\;\mathrm{\pi/m}$). [rad/m] depth the depth of the water to mean sea level. A value of zero or less corresponds to deep water. [m] gravity (default $\inline&space;9.8066\;\mathrm{m/s^2}$). [m/s2]

### Returns

wave-frequency ($\inline&space;2\;\mathrm{\pi/s}$). [rad/s]
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.

## W To K

 doublew_to_k( double w double depth = 0 double gravity = 9.8066 )
Finds the wave-number associated with a particular wave-frequency, using this 1st order dispersion equation, $\inline&space;w^2&space;=&space;g&space;k&space;tanh(k&space;d)$ to obtain wave-number from a given wave-frequency.

In Deep water, this equations reduces to $\inline&space;w^2&space;=&space;g&space;k$, which can obviously solved directly.

For shallow water, an iterative approach must be used. For each iteration, we calculate the residual error:
$\epsilon&space;=&space;\frac{w^2}{g}&space;-&space;&space;k&space;tanh(k&space;d)$
where w is wave-frequency, k is wave-number and g is gravity.

We then seek to minimise ε using the first derivative $\inline&space;\partial&space;\epsilon&space;/&space;\partial&space;k$.

This convergence of this error function is fairly rapid, with poorest conversion, 8 iterations in water 2m deep (for 6dp precision) occurring when w is small i.e. w<=0.1. When w=1.5 only 4 iterations are needed, while w>3.5 needs only 2 iterations. Shallow water naturally requires more iteration. If your doing many calculation in either shallow water or very long wave periods (>30s), then you might want to consider fine tuning this function.

This relationship can me use to move from the wave-period ($\inline&space;&space;2\pi&space;/&space;w$) to the wave-length ($\inline&space;2\pi/k$) of a water wave. This is also shown graphically in the following figure:
There is an error with your graph parameters for w_to_k with options w=0:4 depth=1:5:3

Error Message:Function w_to_k failed. Ensure that: Invalid C++

The opposite of this function is dispersion_k

Example:
[metric]
##### Example - First order conversion of Wave Frequency to Wave Number
Problem
Compute Wave Frequency from Wave Number in water of depth 2m.
Workings
#include <stdio.h>
#include <codecogs/engineering/fluid_mechanics/waves/dispersion.h>
using namespace Engineering::Fluid_Mechanics::Waves;

int main()
{
printf("   k         w  recalculated k");
for(double k=0.01; k<1;k+=0.1)
{
printf("\n %.6lf", k);
double w=k_to_w(k,2);
double k2=k_to_k(w,2);
printf("  %.3lf  %.6lf", w, k2);
}
return 0;
}
Solution
k         w  recalculated k
0.010000  0.044  0.010000
0.110000  0.483  0.110000
0.210000  0.904  0.210000
0.310000  1.294  0.310000
0.410000  1.648  0.410000
0.510000  1.962  0.510000
0.610000  2.241  0.610000
0.710000  2.489  0.710000
0.810000  2.710  0.810000
0.910000  2.910  0.910000

### Parameters

 w ($\inline&space;2\;\mathrm{\pi/s}$) is wave-frequency, usually written using $\inline&space;\omega$ (omega). depth (m) define the depth of the water to mean sea level. A value of zero or less corresponds to deep water. gravity (default $\inline&space;9.8066\;\mathrm{m/s^2}$).

### Returns

wave-number ($\inline&space;2\;\mathrm{\pi/m}$).
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.