############################################################################################
############################################################################################
## Function to create Nasmyth spectrum
############################################################################################
###########################################################################################
## created by Marcus Klaus, Swedish University of Agricultural Sciences (SLU), Umeå, Sweden
## contact: marcus.klaus@slu.se
## last update: 2026/04/30
###########################################################################################

## INPUTS: 
# k... wavenumber (rad/m)
# epsilon... turbulent kinetic energy dissipation rate (m2/s3)
# nu...kinematic viscosity (m²/s)
# alpha...scaling factor (unitless)

## OUTPUTS;
# E... Nasmyth spectrum (m2/s2 per rad/m)

## References
# Oakey, N.S. (1982): Determination of the rate of dissipation of turbulent energy from
# simultaneous temperature and velocity shear microstructure measurements. Journal of Physical Oceanography 12:256-271
###########################################################################################

CreateNasmythSpectrum <- function(k, epsilon, nu = 1.5e-6,alpha) {
  k_eta <- (epsilon / nu^3)^(1/4)
  
  E <- alpha * epsilon^(2/3) * k^(-5/3) * exp(-5.2 * (k / k_eta))
  return(E)
}
