SNL-WaterPower / WecOptTool-MATLAB

WEC Design Optimization Toolbox
GNU General Public License v3.0
12 stars 9 forks source link

Frequency vector precision #145

Open ryancoe opened 4 years ago

ryancoe commented 4 years ago

I noticed a funny behavior when working on a case study with a regular wave where energy was bleeding into additional frequencies. After hunting down every other potential source, I found that the frequencies coming back from Nemoh were very slightly (something close to machine epsilon) different from those requested in the calibration file (Nemoh.cal). I haven't dug too much deeper, but I guess this is probably something with either the I/O that we're using with Nemoh of the precision that Nemoh operates at.

>> S.w - b(3).hydro.w

ans =

   1.0e-14 *

         0
   -0.0111
   -0.0222
   -0.0222
   -0.0222
   -0.0444
   -0.0444
   -0.0444
   -0.0444
   -0.0444
   -0.0444
   -0.0444
         0
   -0.0888
         0
         0
   -0.0888
         0
   -0.0888
   -0.0888
   -0.0888
         0
         0
   -0.0888
   -0.0888
         0
   -0.1776
   -0.1776
   -0.1776
         0
         0
   -0.1776
   -0.1776
   -0.1776
         0
   -0.1776
   -0.1776
   -0.1776
   -0.1776
   -0.1776
   -0.1776
         0
   -0.1776
         0
         0
   -0.1776
   -0.1776
   -0.1776
   -0.1776
   -0.1776

With linear interpolation

image

With nearest interpolation

image

My somewhat dirty, but I believe justifiable, fix was to add an option for using nearest interpolation instead of the default linear (f6381c6de2e3f55c142da6e223b08eb46264a552). While not a big deal, I just thought I'd make a note...