|
1 | 1 | function S = pierson_moskowitz_spectrum(frequency, Tp, Hs) |
2 | 2 |
|
3 | 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
4 | | -% Calculates Pierson-Moskowitz Spectrum from Tucker and Pitt (2001) |
| 4 | +% Calculates Pierson-Moskowitz Spectrum from IEC TS 62600-2 ED2 Annex C.2 (2019) |
5 | 5 | % |
6 | 6 | % Parameters |
7 | 7 | % ------------ |
8 | | -% |
9 | | -% Frequency: float |
10 | | -% Wave frequency (Hz) |
| 8 | +% frequency: vector |
| 9 | +% Wave frequency [Hz] |
11 | 10 | % |
12 | 11 | % Tp: float |
13 | | -% Peak Period (s) |
| 12 | +% Peak period [s] |
14 | 13 | % |
15 | 14 | % Hs: float |
16 | | -% Significant wave height (m) |
17 | | -% |
| 15 | +% Significant wave height [m] |
18 | 16 | % |
19 | 17 | % Returns |
20 | 18 | % --------- |
21 | | -% S: structure |
22 | | -% |
23 | | -% S.spectrum=Spectral Density (m^2/Hz) |
24 | | -% |
25 | | -% S.type=String of the spectra type, i.e. (Pierson-Moskowitz 8.0s) |
26 | | -% |
27 | | -% S.frequency= frequency (Hz) |
| 19 | +% S: structure with fields |
| 20 | +% .spectrum = Spectral density [m^2/Hz] |
| 21 | +% .frequency = Frequency [Hz] |
| 22 | +% .type = 'Pierson-Moskowitz (Hs,Tp)' |
28 | 23 | % |
29 | 24 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
30 | 25 |
|
31 | | -if (isa(frequency,'py.numpy.ndarray') ~= 1) |
32 | | - frequency = py.numpy.array(frequency); |
| 26 | +arguments |
| 27 | + frequency {mustBeNumeric, mustBeFinite} |
| 28 | + Tp {mustBeNumeric, mustBeFinite, mustBePositive} |
| 29 | + Hs {mustBeNumeric, mustBeFinite, mustBePositive} |
33 | 30 | end |
34 | 31 |
|
35 | | -S_py = py.mhkit.wave.resource.pierson_moskowitz_spectrum(frequency, Tp, Hs); |
36 | | - |
37 | | -S_py = typecast_from_mhkit_python(S_py); |
| 32 | +% Use JONSWAP spectrum with gamma = 1 (equivalent to Pierson-Moskowitz) |
| 33 | +S_jonswap = jonswap_spectrum(frequency, Tp, Hs, 1); |
38 | 34 |
|
| 35 | +% Create output structure with Pierson-Moskowitz naming for backward compatibility |
39 | 36 | S = struct(); |
40 | | - |
41 | | -S.frequency = S_py.index.data; |
42 | | -S.spectrum = S_py.data; |
43 | | -S.type = S_py.columns{1}; |
| 37 | +S.frequency = S_jonswap.frequency; |
| 38 | +S.spectrum = S_jonswap.spectrum; |
| 39 | +S.type = sprintf('Pierson-Moskowitz (%.1fm,%.1fs)', Hs, Tp); |
0 commit comments