Closed ryancoe closed 4 years ago
I'm going to switch this to a draft while we're updating it.
OK so this does not appear to fix #4. I added two tests to +WecOptLib\+tests\+unit\RM3DeviceModelTest.m
called testPSNoConverge
and testPSConverge
where one uses the damping fix and the other doesn't and testPSConverge
errors. Interestingly the first test in that file also fails.
Back to you!
Hang on, that's probably my fault! I didn't test the exit flag properly. One sec.
OK, so after I check the value of the exitflag (doh), it seems like your expected failure case doesn't actually fail. Have I done something else wrong? Maybe it's sensitive to S?
OK, so after I check the value of the exitflag (doh), it seems like your expected failure case doesn't actually fail. Have I done something else wrong? Maybe it's sensitive to S?
Yes, a sensitivity to S
(specifically to the frequencies at which we run NEMOH
) is definitely likely. The frequencies that would be evaluated in a case has been updated by 1e2866a141e5db629e00328504d5aa52704142a4 (#129) and probably a few other times since that specific problem case was noted in #4...
My thinking is we should complete this PR, but keep an eye on this (your addition of the error check on the exitflag
with 65164f6be7a25248da04ecf9c2aee8e818791c3b should allow us to do so).
Seems OK to me. Comment out the failing test so we can reuse later if needed?
So, I pushed that update. It's interesting because on the second run of the PS controller with the stored NEMOH result the output is about 3% less (I added a relative tolerance of 5% to make it pass). It's likely this is a bug somewhere.
Further to that this number it's producing: 6.556208812689474e+09
is too big right? So, I'm not sure this is working, but we are not capturing why it's not working.
Further to that this number it's producing:
6.556208812689474e+09
is too big right? So, I'm not sure this is working, but we are not capturing why it's not working.
this sounds like an unconverged case... can you point me to a specific test case and/or MWE?
It's the same test as before, but it's now in toolbox/+WecOptLib/+tests/+unit/+models/RM3DeviceModelParametricPSTest.m
.
It's being run in the getPower
method and then the value of that run is being checked in test_runParametric
. I just copied the value it was producing to expSol
, but I didn't really think about it.
Note, this test is being run with the negative damping fix and it's not throwing an error in toolbox/+WecOptLib/+models/+RM3/getPSPhasePower.m
(line 66) so there must be something we are not checking.
Having played around with the optimiser for a bit, I think it's a red herring. I think it's worth looking at the start of the chain and seeing if the NEMOH results are sound. @ryancoe do you have any advice on how best to check the quality of the NEMOH model?
I would plot out the added mass, damping, and excitation. I would also plot out the frequency dependent power.
Is it worth thinking about having something similar to SeaState that will do this automatically?
yes, definitely!
OK, so I can see what is happening now between the CC and P controllers. I can also say that this happens due to Zi going negative for those frequencies (in the RM3 example) which produces negative (non useful) power. This happens because Z_c^2 > Z_3 Z_9 which gives negative Zi in equation 24 of Falnes 1999. Why this occurs, I don't understand, as yet. It's not the negative damping, as this still happens when it's corrected.
Right, I think it's something to do with the friction term. If I reduce it to Bf = max(B33) * 0.01;
(from 0.1), then you get the better behaviour:
This doesn't fix the PS problem, but I wonder if it's a related issue.
EDIT: Having re-read the top, it's not surprising that the friction is playing a part.
@ryancoe, do you think the friction should be applied per frequency, rather than as a scalar?
@ryancoe, one other question regarding the damping. For the RM3 case we use values that are not on the diagonal for the coupled coefficients, i.e. B_39 and B_93. Should the negative values in these modes be zeroed as well?
@H0R5E - Definitely something fishy going on here... some thoughts from our discussion:
To get to the bottom of this, I think we need to directly calculate the power from CC
, in the same way that is done for the WaveBot
. The following line currently used in the RM3
code is actually a calculation of the upper bound of power.
https://github.com/SNL-WaterPower/WecOptTool/blob/15cc8170cd6e3a9f3a025b0ad1aa14f25488689f/examples/RM3/simulateDevice.m#L160
whereas theWaveBot
code is actually using complex conjugate control:
https://github.com/SNL-WaterPower/WecOptTool/blob/15cc8170cd6e3a9f3a025b0ad1aa14f25488689f/examples/WaveBot/simulateDevice.m#L128
The following should be true:
myPerf.Zpto = conj(dynModel.Zi);
% velocity
myPerf.u = dynModel.F0 ./ (myPerf.Zpto + dynModel.Zi);
% position
myPerf.pos = myPerf.u ./ (1i * dynModel.w);
% PTO force
myPerf.Fpto = -1 * myPerf.Zpto .* myPerf.u;
% power
myPerf.pow = 0.5 * myPerf.Fpto .* conj(myPerf.u); % this is the power from complex conjugate control
Pub = abs(dynModel.F0) ./ (8 * real(dynModel.Zi)); % this is the theoretical upper bound
assert(abs(myPerf.pow - Pub) < 1e12) % these two should be equal to within roundoff errors
Also, you should be able to show that the P
and CC
(Pub
) are all the same at resonance:
[~,idx_w0] = min(abs(imag(Zi)))
w0 = w(idx_w0)
So, I checked the tests @ryancoe suggested, but they were fine, which suggests the controllers are implemented correctly (perhaps the damping control is more verbose than necessary).
I think I have found evidence that the NEMOH result is unphysical in the coupled damping vector B39. If you look at the graph of the scalar geometry case (1x), the parameter has values -B33 < B39 < -B99, which looks pretty reasonable.
For the buggy parametric case B39 >> B33 >> B99, which doesn't feel physical to me. Does that seem like a reasonable assessment? Is -B33 < B39 < -B99 (or the equivalent), something we can use to check the NEMOH results?
I decided to plot the meshes to see if there was anything obviously wrong, and the top of the plate mesh looks bizarre. It's covered in degenerate (or overlapping?) panels (the bottom is fine), so I wonder if this is causing the issue?
OK, here is a list of the pertinent changes in this PR:
WecOptTool.Hydrodynamics
class to take standardised output of solvers and do stuff. Currently it fixes any negative damping found on the diagonal of the B matrix.plotMesh
which can plot the mesh structures generated by the AxiMesh
class. An example of its usage has been added to the RM3/optimization.m example.The only query I have from this (which is unrelated to the damping issue) is the relationship between wave amplitude and spectral density, which is used in a few places in the code. Is there some reference for this somewhere? I was wondering if it is missing a factor of pi?
@ryancoe can you review this, please?
Test results:
Tests all passing on macOS
: test_results.pdf
Tests still passing after my attempts to break it: test_results.pdf
I think we need to put a little more effort into preparing the commit messages for the merged pull requests. I don't think you would have a clue what was added from the default commit message that was generated from this one.
Agreed, I only recently understood how this works with squash and merge
Added rule 10 to the DevOps Rule Book
Description
Nemoh
is well known to have issues with irregular frequencies (see discussion in #35). This can create cases where there is negative radiation damping at certain frequencies (which is not physical for diagonal elements). If the sum of the radiation damping and friction are less than zero, this can create stability issues and is believed to be the source of the convergence problems noted in #4.This PR adds a function (
checkNemoh
) to look for negative values in the diagonal radiation damping terms in thehydro
structure produced bygetNemoh
.checkNemoh
sets values less than 0 to 0 and returns a tracking of where negative values were found.Fixes #4
test_results.pdf
Checklist:
example.m
has been modified, the content / line numbers indocs\user\example.rst
are still valid or have been fixed