SNL-WaterPower / WecOptTool-MATLAB

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

Validate PS against CC #13

Closed ryancoe closed 4 years ago

ryancoe commented 5 years ago

@gbacelli has done this before, so more to verify the code, we need to see that pseudo-spectral control approaches complex conjugate control as the limits are expanded.

ryancoe commented 5 years ago

@zmorrell-sand - Can you create a script and make changes to existing code in order to do the following:

  1. Set up a Bretschneider sea state with the following: S = bretschneider([],[8,10],0);
  2. In RM3_getPow, make optional arguments for delta_Zmax and delta_Fmax (current hardcoded on lines 58 and 59 of RM3_getPow). These arguments should only be considered when controlType is set to PS.
  3. Run a loop to consider two cases:
    1. Simulate increasing delta_Zmax: pow(ii,1) = RM3_getPow(S,'PS','scalar',1,delta_Zmax); for delta_Zmax = 1:1:20
    2. Simulate increasing delta_Fmax: pow(ii,2) = RM3_getPow(S,'PS','scalar',1,delta_Fmax); for delta_Fmax = ? (to fill in ?, play around with this a bit; can use SNL-WaterPower/WecOptTool_old#19 for guidance)
  4. In both cases, as delta_Zmax and delta_Fmax increase, you should see the power value asymptote. In fact, the result should asymptote such that at large values of delta_Zmax and delta_Fmax, P_lim = pow(end,1) = pow(end,2) and this should also be roughly equal to RM3_getPow(S,'CC','scalar',1) (i.e., the PS controller should approach the CC controller when constraints are large)
zmorrell-sand commented 5 years ago

@ryancoe Here are the graphs of the asymptotic approach of deltaFmax and deltaZmax. I only evaluated deltaFmax from 6 to 14, hence the strange shape.
asymptotesFandZmax

ryancoe commented 5 years ago

@zmorrell-sand - Can you please confirm that the PS mode gives the same result now as it did for f5e63405a53894febcfb597ddb1d8fb35cd33051?

zmorrell-sand commented 5 years ago

@ryancoe Here are the asymptotic values that are given by the three different functions (RM3_getPow('CC') = bench_cc, RM3_getPow('PS') = asymptotebig, RM3_ps = oldPSCode)

bench_cc = -5.737286e+06
asymptotebig = -2.737691e+06
oldPSCode = -5.475385e+05

I used 1e10, 1e10 for the large values to check for asymptotic behavior.

ryancoe commented 5 years ago

@zmorrell-sand - Looks like I introduced a bug to the PS at some point between then and now. Perhaps you can write a script to help find the point at which this changed?

zmorrell-sand commented 5 years ago

@ryancoe That might be doable. Do we know which value is correct?

ryancoe commented 5 years ago

Neither... :) Still want to know when it changed

@gbacelli - We may need your input on this.

zmorrell-sand commented 5 years ago

@ryancoe Here is a screenshot of the various asymptotes that are given by the program, labeled by date. It should be noted that the value output has not changed at the very least since April 15. It should also be noted that in no case has the output of PS == CC. Capture

ryancoe commented 5 years ago

@gbacelli - Here's an MWE that you can use to debug the PS

S = bretschneider([],[8,10],0);
S.ph = rand(length(S.w),1)* 2 * pi;
bigZ = 1e2;
Fs = logspace(5,15,5);
parfor ii = 1:length(Fs)
    pow(ii) = RM3_getPow(S,'PS','scalar',1,bigZ,Fs(ii))
end

%%

CCpow = RM3_getPow(S,'CC','scalar',1);

%%

figure
semilogx(Fs,pow,'.-')
hold on
semilogx(xlim,CCpow*ones(2,1),'r')
grid on
xlabel('F_{max}')
ylabel('P')
legend('PS','CC')
ryancoe commented 5 years ago

@gbacelli completed this week untitled