FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
marenv::wave::WaveEnergySpectrum Class Reference

Represents a wave field.

#include <WaveEnergySpectrum.h>

+ Inheritance diagram for marenv::wave::WaveEnergySpectrum:
+ Collaboration diagram for marenv::wave::WaveEnergySpectrum:

Classes

struct  SpectrumParameters
 The parameters defining a certain wave field. More...
 

Public Types

enum class  DirectionSpectrum { None = 0 , CosineSquared }
 Shape function for the direction spectrum. More...
 
enum class  DirectionBinning { Random , Sequential }
 Methods for realisation of direction spectrum. More...
 
enum class  FrequencyBinning { EqualEnergy , EqualSqrtEnergy }
 Methods for dividing a spectrum in discrete frequencies. More...
 

Public Member Functions

 WaveEnergySpectrum (const SpectrumParameters &spectrumParameters, int numWaves, uint32_t randomSeed)
 
std::shared_ptr< WaveComponents > GetWaveComponents ()
 

Protected Types

using NormalizedProbabilityDistribution = double(WaveEnergySpectrum::*)(const double)
 Defines the type of a normalized probability distribution function.
 

Protected Member Functions

void CalcWaveDirections (calc::LcgRandom &random)
 
double IntegrateSpectrum (double omegaLow, double omegaHigh, double step) const
 
double BinFrequency (double omegaLow, double omegaHigh, double step) const
 
std::vector< double > CalcBinEdges () const
 
void CalcWaveFrequencies ()
 
void CalcCalmSeaFrequencies ()
 Calculates the frequencies of a calm sea (Hs = 0): those of Hs = 1, with zero energy and amplitude.
 
double CosPower (double theta) const
 
double SpectralEnergy (double omega) const
 
double JONSWAP (double omega) const
 
double Issc (double omega) const
 

Protected Attributes

SpectrumParameters m_param
 Wave spectrum parameters.
 

Member Enumeration Documentation

◆ DirectionBinning

Enumerator
Random 

Random distribution according to the direction spectrum.

Sequential 

Higher energies in main direction.

◆ DirectionSpectrum

Enumerator
CosineSquared 

The function is of the form cos(theta)^n.

◆ FrequencyBinning

Enumerator
EqualEnergy 

Each wave component has the same energy.

EqualSqrtEnergy 

Each wave component has the same \( \int_{\omega_k}^{\omega_{k+1}} S(\omega)\, d\omega \).

Constructor & Destructor Documentation

◆ WaveEnergySpectrum()

marenv::wave::WaveEnergySpectrum::WaveEnergySpectrum ( const SpectrumParameters &  spectrumParameters,
int  numWaves,
uint32_t  randomSeed 
)

Constructor.

Parameters
[in]spectrumParametersSpectrum parameters.
[in]numWavesNumber of waves to construct from the spectrum.
[in]randomSeedThe random seed to use.
Exceptions
std::invalid_argumentfor a non-finite or negative Hs, a non-finite or non-positive T1, a non-finite Theta, frequency limits that are not finite with 0 <= lower < upper, and a negative numWaves (0 gives a sea state without components).
std::runtime_errorif the spectrum is NaN. Hs = 0 is legal: a calm sea, with the components of the frequency grid and zero amplitude.

Member Function Documentation

◆ BinFrequency()

double marenv::wave::WaveEnergySpectrum::BinFrequency ( double  omegaLow,
double  omegaHigh,
double  step 
) const
protected

Frequency of a bin: the energy-weighted mean \( \int \omega S(\omega)\, d\omega / \int S(\omega)\, d\omega \) over [omegaLow, omegaHigh] (owner ruling D50), both integrals by the same composite Simpson rule as IntegrateSpectrum().

Parameters
[in]omegaLowLower frequency limit of the bin.
[in]omegaHighUpper frequency limit of the bin.
[in]stepThe widest panel to use, as for IntegrateSpectrum().
Returns
The weighted mean frequency. A bin of zero width or zero energy has no weighting: the midpoint is returned.

◆ CalcBinEdges()

std::vector< double > marenv::wave::WaveEnergySpectrum::CalcBinEdges ( ) const
protected

The edges of the frequency bins for the binning mode: numWaves + 1 ascending values, the first and the last being the ends of the frequency range. Needs a spectrum with energy (Hs > 0).

◆ CalcWaveDirections()

void marenv::wave::WaveEnergySpectrum::CalcWaveDirections ( calc::LcgRandom &  random)
protected

Calculates wave directions according to the specified spectrum parameters.

Parameters
[in,out]randomThe generator of the whole spectrum. Directions and phases are drawn from it in turn, so the two are independent.

◆ CalcWaveFrequencies()

void marenv::wave::WaveEnergySpectrum::CalcWaveFrequencies ( )
protected

Calculates frequencies of each wave component.

The bins cover the whole cumulative distribution, from probability 0 to 1. The energy of a bin is the integral of the spectrum over the bin, so the energies add up to the spectrum energy \( m_0 \) over the frequency range and \( H_s = 4\sqrt{m_0} \) is realised for any number of components. The frequency of a bin is its energy-weighted mean frequency (BinFrequency()), for both binning modes; the wave number follows from it.

◆ CosPower()

double marenv::wave::WaveEnergySpectrum::CosPower ( double  theta) const
protected

Computes \( \cos^{\text{cosinePower}}(\theta) \)

Parameters
[in]thetaThe wave direction relative to the main direction.
Returns
The cosine power of theta;

◆ GetWaveComponents()

std::shared_ptr< WaveComponents > marenv::wave::WaveEnergySpectrum::GetWaveComponents ( )

Get all wave components.

Returns
All wave components.

◆ IntegrateSpectrum()

double marenv::wave::WaveEnergySpectrum::IntegrateSpectrum ( double  omegaLow,
double  omegaHigh,
double  step 
) const
protected

Integral of the spectrum over [omegaLow, omegaHigh] (Simpson's rule).

Parameters
[in]omegaLowLower frequency limit.
[in]omegaHighUpper frequency limit.
[in]stepThe widest panel to use.
Returns
The energy of the spectrum in the band, \( \int S(\omega)\, d\omega \).

◆ Issc()

double marenv::wave::WaveEnergySpectrum::Issc ( double  omega) const
protected

Calculates the ISSC spectrum energy for a wave frequency.

Parameters
[in]omegaThe wave frequency
Returns
The ISSC spectrum energy for the given wave frequency.

◆ JONSWAP()

double marenv::wave::WaveEnergySpectrum::JONSWAP ( double  omega) const
protected

Calculates the JONSWAP spectrum energy for a wave frequency.

Parameters
[in]omegaThe wave frequency
Returns
The ISSC JONSWAP energy for the given wave frequency.

◆ SpectralEnergy()

double marenv::wave::WaveEnergySpectrum::SpectralEnergy ( double  omega) const
protected

Calculates the spectrum energy for a wave frequency.

Parameters
[in]omegaThe wave frequency
Returns
The spectrum energy for the given wave frequency.

The documentation for this class was generated from the following file: