Example: MHKiT-MATLAB Wave Module

The following example runs an application of the MHHKiT wave module to 1) generate a capture length matrix, 2) calculate MAEP, and 3) plot the scatter diagrams.

Generating Example Data

For demonstration purposes, this example uses synthetic data generated from statistical distributions. The data includes significant wave height, peak period, power, and omnidirectional wave flux. In a real application, the user would provide these values.
% generating an array of 1,000,000 values to represent significant wave
% height
Hm0 = normrnd(5.5,1.3,1000000,1);
% generating 1,000,000 values for peak period, assumng normal distribution
Te = normrnd(4.5,0.7,1000000,1);
% generating 1,000,000 random power values
Power = randi([40,200], 1000000,1);
% generating 1,000,000 random omnidirectional wave flux values
J = randi([8,300], 1000000,1);

Capture Length Matrices

The following operations create capture length matrices, as specified by the IEC/TS 62600-100. But first, we need to calculate capture length and define bin centers. The mean capture length matrix is printed below. Keep in mind that this data has been artificially generated, so it may not be representative of what a real-world scatter diagram would look like.
% calculating capture length with power and wave flux in vectors
L = capture_length(Power,J);
% Need to set our Hm0 and Te bins for the capture length matrix
Hm0_bins = -0.5:0.5:max(fix(Hm0))+0.5; % Input is min, max, and n indecies for vector
Hm0_bins = Hm0_bins+0.25 ;
Te_bins = 0:1:max(fix(Te));
Te_bins = Te_bins+0.5;
% Calculate the necessary capture length matrices for each statistic based
% on IEC/TS 62600-100
clmat.mean = capture_length_matrix(Hm0,Te,L,"mean",Hm0_bins,Te_bins);
clmat.std = capture_length_matrix(Hm0,Te,L,"std",Hm0_bins,Te_bins);
clmat.count = capture_length_matrix(Hm0,Te,L,"count",Hm0_bins,Te_bins);
clmat.min = capture_length_matrix(Hm0,Te,L,"min",Hm0_bins,Te_bins);
clmat.max = capture_length_matrix(Hm0,Te,L,"max",Hm0_bins,Te_bins);
% Calculate the frequency matrix for convenience
clmat.freq = capture_length_matrix(Hm0,Te,L,"frequency",Hm0_bins,Te_bins);
Let's see what the data in the mean matrix looks like. Keep in mind that this data has been artificially generated, so it may not be representative of what a real-world scatter diagram would look like.
disp(clmat.mean.values)
NaN NaN NaN 19.0000 1.7879 8.4975 NaN NaN NaN NaN NaN 3.0322 2.1127 2.3552 NaN NaN NaN NaN NaN 1.7528 1.1072 1.6614 2.0119 NaN NaN NaN 0.7038 1.4921 1.4292 1.7240 2.1052 NaN NaN NaN 1.4579 1.3802 1.4733 1.5313 1.8722 NaN NaN 2.8333 1.3627 1.5111 1.5392 1.6235 1.5302 0.6176 NaN NaN 1.5816 1.5108 1.5291 1.4842 1.5272 0.6229 NaN 0.8355 1.4946 1.4957 1.5209 1.5212 1.4292 0.7503 NaN 1.4596 1.7102 1.4908 1.5176 1.4902 1.4210 2.5268 NaN 1.4174 1.4937 1.5189 1.5151 1.5467 1.4772 0.7576 NaN 1.6774 1.6325 1.5263 1.5242 1.5247 1.5700 2.1025 NaN 1.2595 1.5645 1.5008 1.5037 1.5054 1.5882 1.4783 NaN 1.3435 1.5184 1.5141 1.5137 1.4786 1.5314 1.0524 NaN 1.2514 1.4919 1.5015 1.5117 1.5117 1.5105 0.8809 NaN 2.1265 1.5925 1.5081 1.4896 1.5258 1.5990 2.6813 NaN 1.7564 1.5211 1.5678 1.5189 1.5002 1.4978 0.5893 NaN 0.8527 1.4759 1.5135 1.5206 1.4777 1.7034 1.7208 NaN 0.9014 1.3839 1.4898 1.5253 1.5006 1.4987 0.8752 NaN NaN 1.6058 1.4969 1.4989 1.5017 1.3030 0.3682 NaN NaN 1.7277 1.4811 1.4960 1.4994 1.1112 NaN NaN NaN 4.0545 1.3019 1.5544 1.5397 3.4298 NaN NaN NaN 1.0630 1.5541 1.5609 0.9971 0.4476 NaN NaN NaN 1.6591 1.2586 1.2862 2.0408 0.4510 NaN NaN NaN NaN 3.8222 1.6363 1.8704 0.4824 NaN NaN NaN NaN 1.5833 0.7107 0.7381 NaN NaN

Power Matrices

As specified in IEC/TS 62600-100, the power matrix is generated from the capture length matrix and wave energy flux matrix, as shown below
% Create wave energy flux matrix using mean
jmat = wave_energy_flux_matrix(Hm0,Te,J,"mean",Hm0_bins,Te_bins);
% Create power matrix using mean
avg_power_mat = power_matrix(clmat.mean, jmat);
% Create power matrix using standard deviation
std_power_mat = power_matrix(clmat.std, jmat);
The capture_length_matrix function can also be used as an arbitrary scatter plot generator. To do this, simply pass a different array in the place of capture length (L). For example, while not specified by the IEC standards, if the user doesn't have the omnidirectional wave flux, the average power matrix could hypothetically be generated in the following manner:
avgpowmat_not_standard = capture_length_matrix(Hm0,Te,Power,'mean',Hm0_bins,Te_bins);

MAEP

There are two ways to calculate mean annual energy production (MEAP). One is from capture length and wave energy flux matrices, the other is from time series data, as shown below.
% Calcaulte maep from timeseries
maep_timeseries = mean_annual_energy_production_timeseries(L,J)
maep_timeseries = 1.0518e+06
% Calcaulte maep from matrix
maep_matrix = mean_annual_energy_production_matrix(clmat.mean, jmat , clmat.freq)
maep_matrix = 2.0408e+06

Graphics

The graphics function plot_matrix can be used to visualize results. It is important to note that the plotting function assumes the step size between bins to be linear.
% Plot the capture length matrix
p1 = plot_matrix(clmat.mean,"Capture Length");