MHKiT WEC-Sim Power Performance Example
This notebook demonstrates using the MHKiT wave module and WEC-Sim together to perform a resource characterization study in MHKiT, simulate representative cases with WEC-Sim, and visualize the results in MHKiT to estimate MAEP (Mean Annual Energy Production).
1. Characterize the available resource at a location
- See the PacWave example notebook
2. Write a WEC-Sim batch file for the given clusters
3. Simulate the device in WEC-Sim.
- Ensure that the spectra used in WEC-Sim is identical to the one used in MHKiT.
4. Load WEC-Sim batch results
5. Assess results and visualize quantities of interest
This example uses WEC-Sim to simulate the [Oscillating Surge Wave Energy Converter (OSWEC)](https://wec-sim.github.io/WEC-Sim/main/user/tutorials.html#oscillating-surge-wec-oswec), a flap-type device.
1. Characterize the available resource at a location
This example will use an abbreviated version of `PacWave_resource_characterization_example.ipynb`.
For full details on downloading, calculating, and visualizing the k-means clusters representation of the site's wave resouce, see that example.
We select the N=32 cluster as it's total energy flux is closet to the total energy flux of the site considering all wave conditions. We will load the PacWave example output, which can be easily saved after running the example with the command `results[32].to_csv("pacwave_cluster_32.csv")`. We will start this example by reading in that csv output and formatting it for WEC-Sim.
% Relative location and filename of simulated WEC-Sim data (run with mooring)
filename = './data/wave/pacwave_cluster_32.csv'
filename = './data/wave/pacwave_cluster_32.csv'
results = readtable(filename)
results = 32×6 table
| | Var1 | Te | Hm0 | weights | Tp | J |
|---|
| 1 | 0 | 7.9745 | 1.2540 | 0.0589 | 9.2943 | 6.0311e+03 |
|---|
| 2 | 1 | 10.7945 | 2.6414 | 0.0352 | 12.5810 | 3.7004e+04 |
|---|
| 3 | 2 | 6.9020 | 1.9531 | 0.0520 | 8.0443 | 1.2516e+04 |
|---|
| 4 | 3 | 12.6676 | 7.3101 | 0.0051 | 14.7641 | 3.6745e+05 |
|---|
| 5 | 4 | 12.8937 | 2.2623 | 0.0160 | 15.0276 | 3.6455e+04 |
|---|
| 6 | 5 | 10.5576 | 4.7543 | 0.0173 | 12.3049 | 1.1678e+05 |
|---|
| 7 | 6 | 8.7667 | 2.7394 | 0.0436 | 10.2176 | 3.1826e+04 |
|---|
| 8 | 7 | 6.5374 | 1.3056 | 0.0507 | 7.6194 | 5.2724e+03 |
|---|
| 9 | 8 | 9.6663 | 1.3407 | 0.0371 | 11.2661 | 8.4436e+03 |
|---|
| 10 | 9 | 12.7873 | 3.9204 | 0.0165 | 14.9036 | 1.0768e+05 |
|---|
| 11 | 10 | 11.6059 | 1.8210 | 0.0223 | 13.5267 | 1.9446e+04 |
|---|
| 12 | 11 | 7.5841 | 1.8787 | 0.0546 | 8.8393 | 1.2827e+04 |
|---|
| 13 | 12 | 10.1754 | 6.1339 | 0.0088 | 11.8595 | 1.8819e+05 |
|---|
| 14 | 13 | 9.3194 | 4.5874 | 0.0188 | 10.8617 | 9.5155e+04 |
|---|
| 15 | 14 | 7.2290 | 1.2567 | 0.0577 | 8.4254 | 5.4490e+03 |
|---|
| 16 | 15 | 5.6470 | 1.3391 | 0.0321 | 6.5815 | 4.7508e+03 |
|---|
| 17 | 16 | 7.6160 | 2.6346 | 0.0365 | 8.8764 | 2.5340e+04 |
|---|
| 18 | 17 | 9.4604 | 3.3811 | 0.0338 | 11.0261 | 5.2509e+04 |
|---|
| 19 | 18 | 16.0004 | 3.0442 | 0.0043 | 18.6485 | 8.7447e+04 |
|---|
| 20 | 19 | 10.5503 | 1.5636 | 0.0303 | 12.2964 | 1.2622e+04 |
|---|
| 21 | 20 | 11.8174 | 2.9829 | 0.0217 | 13.7732 | 5.3748e+04 |
|---|
| 22 | 21 | 12.1011 | 5.3057 | 0.0145 | 14.1039 | 1.7731e+05 |
|---|
| 23 | 22 | 10.4000 | 3.5883 | 0.0323 | 12.1213 | 6.5405e+04 |
|---|
| 24 | 23 | 9.1325 | 2.0116 | 0.0481 | 10.6440 | 1.7913e+04 |
|---|
| 25 | 24 | 9.8803 | 2.4629 | 0.0506 | 11.5155 | 2.9157e+04 |
|---|
| 26 | 25 | 8.3218 | 2.0031 | 0.0542 | 9.6991 | 1.6105e+04 |
|---|
| 27 | 26 | 6.1314 | 1.7944 | 0.0354 | 7.1461 | 9.2960e+03 |
|---|
| 28 | 27 | 11.4307 | 3.9799 | 0.0253 | 13.3225 | 9.0735e+04 |
|---|
| 29 | 28 | 14.2638 | 2.7817 | 0.0094 | 16.6245 | 6.6183e+04 |
|---|
| 30 | 29 | 13.7442 | 5.4652 | 0.0075 | 16.0188 | 2.4048e+05 |
|---|
| 31 | 30 | 8.7353 | 1.2706 | 0.0471 | 10.1809 | 6.8213e+03 |
|---|
| 32 | 31 | 8.3017 | 3.6768 | 0.0221 | 9.6757 | 5.4123e+04 |
|---|
2. Write a WEC-Sim batch file for the given clusters
WEC-Sim MCR (multiple condition run) files should contain a structure `mcr` that contains two variables: `header` and `cases`. Each column of `header` and `cases` denotes a variable and it's value respectively. Each row is distinct simulation. WEC-Sim defines waves using the significant wave height and peak period. We will isolate these values from the results of the cluster analysis and create a dictionary that is written to the `.mat` file.
mcr.header = {'waves.height','waves.period'};
mcr.cases = [results.Hm0 results.Tp]
mcr =
header: {'waves.height' 'waves.period'}
cases: [32×2 double]
save('mcr_mhkit.mat', 'mcr');
3. Simulate the device in WEC-Sim
Now that the MCR file is created, we need to go simulate WEC performance in these wave conditions using WEC-Sim. To recreate the data used in the next step, use the created MCR file with WEC-Sim's OSWEC example. For an accurate comparison to the power calculated in the resource characterization, we should ensure that the WEC-Sim cases use irregular JONSWAP wave spectra as in the PacWave example.
For convenience in this demonstration, we enforce OSWEC model stability in the extreme wave conditions by arbitrarily applying a large PTO stiffness and damping in the wecSimInputFile.m:
% pto(1).stiffness = 1e5;
To reduce the amount of extranenous data saved for this example, we limit the WEC-Sim output to the PTO's power output in the `userDefinedFunctions.m` script:
% nmcr = size(mcr.cases,1);
% iRampEnd = simu.rampTime./simu.dtOut + 1;
% power(imcr) = -mean(output.ptos(1).powerInternalMechanics(iRampEnd:end,5));
% save('mcr_mhkit_power.mat', 'power');
% bodies = output.bodies;
4. Load WEC-Sim batch results
Note that in this example we do not save the entire WEC-Sim `output` structure for each case. See the `wecsim_example.ipynb` for information on loading the WEC-Sim responseClass. Here, the output is one array of average power output that we will load and compare to the resource characterization.
Note that the power output [W] is significantly larger than the energy flux [W/m] due to the large width of the OSWEC.
% Relative location and filename of simulated WEC-Sim data (run with mooring)
filename = './data/wave/mcr_mhkit_power.mat';
% Load the WEC-Sim output data which contains the variable `power`.
results.Power = power'
results = 32×7 table
| | Var1 | Te | Hm0 | weights | Tp | J | Power |
|---|
| 1 | 0 | 7.9745 | 1.2540 | 0.0589 | 9.2943 | 6.0311e+03 | 6.8613e+04 |
|---|
| 2 | 1 | 10.7945 | 2.6414 | 0.0352 | 12.5810 | 3.7004e+04 | 3.8735e+05 |
|---|
| 3 | 2 | 6.9020 | 1.9531 | 0.0520 | 8.0443 | 1.2516e+04 | 1.9234e+05 |
|---|
| 4 | 3 | 12.6676 | 7.3101 | 0.0051 | 14.7641 | 3.6745e+05 | 1.9512e+06 |
|---|
| 5 | 4 | 12.8937 | 2.2623 | 0.0160 | 15.0276 | 3.6455e+04 | 3.1159e+05 |
|---|
| 6 | 5 | 10.5576 | 4.7543 | 0.0173 | 12.3049 | 1.1678e+05 | 8.4103e+05 |
|---|
| 7 | 6 | 8.7667 | 2.7394 | 0.0436 | 10.2176 | 3.1826e+04 | 3.3986e+05 |
|---|
| 8 | 7 | 6.5374 | 1.3056 | 0.0507 | 7.6194 | 5.2724e+03 | 8.3326e+04 |
|---|
| 9 | 8 | 9.6663 | 1.3407 | 0.0371 | 11.2661 | 8.4436e+03 | 6.9516e+04 |
|---|
| 10 | 9 | 12.7873 | 3.9204 | 0.0165 | 14.9036 | 1.0768e+05 | 5.0688e+05 |
|---|
| 11 | 10 | 11.6059 | 1.8210 | 0.0223 | 13.5267 | 1.9446e+04 | 1.6020e+05 |
|---|
| 12 | 11 | 7.5841 | 1.8787 | 0.0546 | 8.8393 | 1.2827e+04 | 2.1125e+05 |
|---|
| 13 | 12 | 10.1754 | 6.1339 | 0.0088 | 11.8595 | 1.8819e+05 | 2.4020e+06 |
|---|
| 14 | 13 | 9.3194 | 4.5874 | 0.0188 | 10.8617 | 9.5155e+04 | 1.0677e+06 |
|---|
| 15 | 14 | 7.2290 | 1.2567 | 0.0577 | 8.4254 | 5.4490e+03 | 6.4143e+04 |
|---|
| 16 | 15 | 5.6470 | 1.3391 | 0.0321 | 6.5815 | 4.7508e+03 | 7.3289e+04 |
|---|
| 17 | 16 | 7.6160 | 2.6346 | 0.0365 | 8.8764 | 2.5340e+04 | 3.6720e+05 |
|---|
| 18 | 17 | 9.4604 | 3.3811 | 0.0338 | 11.0261 | 5.2509e+04 | 4.0202e+05 |
|---|
| 19 | 18 | 16.0004 | 3.0442 | 0.0043 | 18.6485 | 8.7447e+04 | 2.4145e+05 |
|---|
| 20 | 19 | 10.5503 | 1.5636 | 0.0303 | 12.2964 | 1.2622e+04 | 1.3351e+05 |
|---|
| 21 | 20 | 11.8174 | 2.9829 | 0.0217 | 13.7732 | 5.3748e+04 | 3.5522e+05 |
|---|
| 22 | 21 | 12.1011 | 5.3057 | 0.0145 | 14.1039 | 1.7731e+05 | 1.3432e+06 |
|---|
| 23 | 22 | 10.4000 | 3.5883 | 0.0323 | 12.1213 | 6.5405e+04 | 7.3683e+05 |
|---|
| 24 | 23 | 9.1325 | 2.0116 | 0.0481 | 10.6440 | 1.7913e+04 | 1.9988e+05 |
|---|
| 25 | 24 | 9.8803 | 2.4629 | 0.0506 | 11.5155 | 2.9157e+04 | 2.7157e+05 |
|---|
| 26 | 25 | 8.3218 | 2.0031 | 0.0542 | 9.6991 | 1.6105e+04 | 2.3197e+05 |
|---|
| 27 | 26 | 6.1314 | 1.7944 | 0.0354 | 7.1461 | 9.2960e+03 | 1.4780e+05 |
|---|
| 28 | 27 | 11.4307 | 3.9799 | 0.0253 | 13.3225 | 9.0735e+04 | 9.3911e+05 |
|---|
| 29 | 28 | 14.2638 | 2.7817 | 0.0094 | 16.6245 | 6.6183e+04 | 2.0003e+05 |
|---|
| 30 | 29 | 13.7442 | 5.4652 | 0.0075 | 16.0188 | 2.4048e+05 | 8.6862e+05 |
|---|
| 31 | 30 | 8.7353 | 1.2706 | 0.0471 | 10.1809 | 6.8213e+03 | 8.5504e+04 |
|---|
| 32 | 31 | 8.3017 | 3.6768 | 0.0221 | 9.6757 | 5.4123e+04 | 7.5789e+05 |
|---|
5. Assess results and visualize quantities of interest
Now that we have loaded the OSWEC's modeled power, we can assess it's performance relative to the incoming wave and calculate the mean annual energy production (MAEP) using MHKiT.
results.CW = capture_length(results.Power, results.J)';
results.CWR = results.CW / oswec_width
results = 32×9 table
| | Var1 | Te | Hm0 | weights | Tp | J | Power | CW | CWR |
|---|
| 1 | 0 | 7.9745 | 1.2540 | 0.0589 | 9.2943 | 6.0311e+03 | 6.8613e+04 | 11.3765 | 0.6320 |
|---|
| 2 | 1 | 10.7945 | 2.6414 | 0.0352 | 12.5810 | 3.7004e+04 | 3.8735e+05 | 10.4677 | 0.5815 |
|---|
| 3 | 2 | 6.9020 | 1.9531 | 0.0520 | 8.0443 | 1.2516e+04 | 1.9234e+05 | 15.3673 | 0.8537 |
|---|
| 4 | 3 | 12.6676 | 7.3101 | 0.0051 | 14.7641 | 3.6745e+05 | 1.9512e+06 | 5.3100 | 0.2950 |
|---|
| 5 | 4 | 12.8937 | 2.2623 | 0.0160 | 15.0276 | 3.6455e+04 | 3.1159e+05 | 8.5471 | 0.4748 |
|---|
| 6 | 5 | 10.5576 | 4.7543 | 0.0173 | 12.3049 | 1.1678e+05 | 8.4103e+05 | 7.2015 | 0.4001 |
|---|
| 7 | 6 | 8.7667 | 2.7394 | 0.0436 | 10.2176 | 3.1826e+04 | 3.3986e+05 | 10.6787 | 0.5933 |
|---|
| 8 | 7 | 6.5374 | 1.3056 | 0.0507 | 7.6194 | 5.2724e+03 | 8.3326e+04 | 15.8041 | 0.8780 |
|---|
| 9 | 8 | 9.6663 | 1.3407 | 0.0371 | 11.2661 | 8.4436e+03 | 6.9516e+04 | 8.2329 | 0.4574 |
|---|
| 10 | 9 | 12.7873 | 3.9204 | 0.0165 | 14.9036 | 1.0768e+05 | 5.0688e+05 | 4.7073 | 0.2615 |
|---|
| 11 | 10 | 11.6059 | 1.8210 | 0.0223 | 13.5267 | 1.9446e+04 | 1.6020e+05 | 8.2380 | 0.4577 |
|---|
| 12 | 11 | 7.5841 | 1.8787 | 0.0546 | 8.8393 | 1.2827e+04 | 2.1125e+05 | 16.4688 | 0.9149 |
|---|
| 13 | 12 | 10.1754 | 6.1339 | 0.0088 | 11.8595 | 1.8819e+05 | 2.4020e+06 | 12.7638 | 0.7091 |
|---|
| 14 | 13 | 9.3194 | 4.5874 | 0.0188 | 10.8617 | 9.5155e+04 | 1.0677e+06 | 11.2208 | 0.6234 |
|---|
| 15 | 14 | 7.2290 | 1.2567 | 0.0577 | 8.4254 | 5.4490e+03 | 6.4143e+04 | 11.7714 | 0.6540 |
|---|
| 16 | 15 | 5.6470 | 1.3391 | 0.0321 | 6.5815 | 4.7508e+03 | 7.3289e+04 | 15.4266 | 0.8570 |
|---|
| 17 | 16 | 7.6160 | 2.6346 | 0.0365 | 8.8764 | 2.5340e+04 | 3.6720e+05 | 14.4910 | 0.8051 |
|---|
| 18 | 17 | 9.4604 | 3.3811 | 0.0338 | 11.0261 | 5.2509e+04 | 4.0202e+05 | 7.6563 | 0.4253 |
|---|
| 19 | 18 | 16.0004 | 3.0442 | 0.0043 | 18.6485 | 8.7447e+04 | 2.4145e+05 | 2.7611 | 0.1534 |
|---|
| 20 | 19 | 10.5503 | 1.5636 | 0.0303 | 12.2964 | 1.2622e+04 | 1.3351e+05 | 10.5770 | 0.5876 |
|---|
| 21 | 20 | 11.8174 | 2.9829 | 0.0217 | 13.7732 | 5.3748e+04 | 3.5522e+05 | 6.6090 | 0.3672 |
|---|
| 22 | 21 | 12.1011 | 5.3057 | 0.0145 | 14.1039 | 1.7731e+05 | 1.3432e+06 | 7.5758 | 0.4209 |
|---|
| 23 | 22 | 10.4000 | 3.5883 | 0.0323 | 12.1213 | 6.5405e+04 | 7.3683e+05 | 11.2656 | 0.6259 |
|---|
| 24 | 23 | 9.1325 | 2.0116 | 0.0481 | 10.6440 | 1.7913e+04 | 1.9988e+05 | 11.1581 | 0.6199 |
|---|
| 25 | 24 | 9.8803 | 2.4629 | 0.0506 | 11.5155 | 2.9157e+04 | 2.7157e+05 | 9.3141 | 0.5174 |
|---|
| 26 | 25 | 8.3218 | 2.0031 | 0.0542 | 9.6991 | 1.6105e+04 | 2.3197e+05 | 14.4037 | 0.8002 |
|---|
| 27 | 26 | 6.1314 | 1.7944 | 0.0354 | 7.1461 | 9.2960e+03 | 1.4780e+05 | 15.8999 | 0.8833 |
|---|
| 28 | 27 | 11.4307 | 3.9799 | 0.0253 | 13.3225 | 9.0735e+04 | 9.3911e+05 | 10.3501 | 0.5750 |
|---|
| 29 | 28 | 14.2638 | 2.7817 | 0.0094 | 16.6245 | 6.6183e+04 | 2.0003e+05 | 3.0224 | 0.1679 |
|---|
| 30 | 29 | 13.7442 | 5.4652 | 0.0075 | 16.0188 | 2.4048e+05 | 8.6862e+05 | 3.6121 | 0.2007 |
|---|
| 31 | 30 | 8.7353 | 1.2706 | 0.0471 | 10.1809 | 6.8213e+03 | 8.5504e+04 | 12.5348 | 0.6964 |
|---|
| 32 | 31 | 8.3017 | 3.6768 | 0.0221 | 9.6757 | 5.4123e+04 | 7.5789e+05 | 14.0031 | 0.7779 |
|---|
Calculate and display the mean annual energy production.
weights.values = results.weights;
MAEP = mean_annual_energy_production_matrix(CW, J, weights) / 1000 % kWh