correct negative damping in BEM results#134
correct negative damping in BEM results#134rgcoe merged 35 commits intoSNL-WaterPower:masterfrom rgcoe:checkBemIrregFreqs
Conversation
currently checks for negative vals in diagonal FRFs
may need to further consider whether/how to pass a warning up to higher level functions and/or set debug/verbosity level across WecOptTool
| 'flagged for negative values']) | ||
| end | ||
|
|
||
| function testNegativeRadDampingKnownBad(testCase) |
There was a problem hiding this comment.
One thing that I have not yet rigorously checked is whether this PR resolves the convergence issues originally noted in #4. My own naivety is the limiting factor. We need to write a unit test case (or some snippet that we just call to test this PR ad-hoc) that does the following:
- Tries to find the power for known nonconvergent cases mentioned in noncoverged PS cases? #4 (
RM3_getPow(S, 'PS', 'parametric', [14.76, 15.71, 2.58, 37.27])) - Check that the PS problem does NOT converge when
checkNemohis not used (note that the application ofcheckNemohis currently hardcoded ingetNemoh) - Check that the PS problem does converged when
checkNemohis used.
@H0R5E - I would do this, but I don't quite know how yet with the toolbox/OOP structure, I can certainly finish it through if you'll get me started or point to a relevant example.
There was a problem hiding this comment.
I think the best way to deal with this is to break up getNemoh, so that the call to WEC_Sim.Read_NEMOH is in a different function (getHydro?), and remove the call to checkNemoh in there also. Then the assumption is that getNemoh (or whatever is a sensible name for the rest of the function) will take a checked (or not) WEC-SIM hydro object. Then you can test with or without checking.
I can do this for you, if you want, but I don't have push access to your fork and I don't think you clicked the allow edits from maintainers box, so you would need to grant me rights on your fork.
|
I'm going to switch this to a draft while we're updating it. |
This is done through the parametric geometry option, which takes an option called fixNegative, that defaults to true.
…to checkBemIrregFreqs # Conflicts: # toolbox/+WecOptLib/+nemoh/getNemoh.m
Doesn't seem to work.
|
OK so this does not appear to fix #4. I added two tests to 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? |
Yes, a sensitivity to My thinking is we should complete this PR, but keep an eye on this (your addition of the error check on the |
|
Seems OK to me. Comment out the failing test so we can reuse later if needed? |
our test case parameters for this do not currently create a non- convergent solution, so we must wait to find a set of parameters that result in such an error
| verifyError(testCase, test, "WecOptTool:getPSPhasePower:NoConvergence"); | ||
| end | ||
|
|
||
| function testPSConverge(testCase) |
There was a problem hiding this comment.
Should we be somehow performing an operation on testCase in testPSConverge (somehow explicitly pass to the testCase whether an error has occurred)?
There was a problem hiding this comment.
Well, the test passes if the case doesn't error, so you don't strictly have to check something. Checking its numerical value (again what it is producing now) would probably be useful so that we will see if it changes for some reason. I was just lazy putting it in so I could show you what was happening.
There was a problem hiding this comment.
You might consider replacing the case in RM3DeviceModelParametricCCTest with this one, so that we are not doing more NEMOH runs.
There was a problem hiding this comment.
My little brain cannot quite digest this... I guess my main hang up is that I understand how to reuse data within a single file (e.g., RM3DeviceModelParametricCCTest.m), but not how to share between files.
I also feel like the +tests directory could use some clean up. I don't understand where I should look between all of the files and how tests should be broken up between files. Is there a suggested structure for this?
There was a problem hiding this comment.
You can't share between files, I don't think, so anything you want to share should be in a single file.
The +unit package is getting a bit unruly for sure. We could add another package level below (it won't upset the testing system) for when there are several tests for one source file. Perhaps something else for our coding policy.
I'll fix these things, so you can see what I mean.
DeviceModel tests into new subpackage.
|
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: |
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 It's being run in the Note, this test is being run with the negative damping fix and it's not throwing an error in |
|
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? |
Use plotmesh in RM3/optimization.m example. Fix other descriptions of the mesh output throughout.
|
OK, here is a list of the pertinent changes in this PR:
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? |
| % Calculate wave amplitude | ||
| waveAmp = SS.getAmpSpectrum(w, interpMethod); | ||
| % TODO: Why times root(2) here? | ||
| waveAmpSS = sqrt(2 * SS.dw * SS.S); | ||
| waveAmp = interp1(SS.w, waveAmpSS, w, interpMethod, 'extrap'); | ||
|
|
There was a problem hiding this comment.
@ryancoe, I couldn't figure out this relationship between wave amplitude and spectral density. What is the root(2) doing in there and shouldn't there be a factor of pi, also?
There was a problem hiding this comment.
I believe it looks correct to me. You would need a 2pi if the frequency were in Hz.

https://ocw.mit.edu/courses/mechanical-engineering/2-019-design-of-ocean-systems-spring-2011/lecture-notes/MIT2_019S11_OWE.pdf
There was a problem hiding this comment.
Doesn't that indicate that A is sqrt(2 * S * dw) / 2? Unless amplitude is supposed to say wave height?
There was a problem hiding this comment.
Hmm, I think that half is incorrect in those note you posted. If you look at https://www.usna.edu/NAOE/_files/documents/Courses/EN455/EN455_Chapter3.pdf page 40, then it has the formula used in the code, and the derivation there makes sense to me.
There was a problem hiding this comment.
Yes, agreed. I was going to send you a photo from a textbook, but then decided to try to respect copyright rules and find something publicly available. Even MIT is wrong sometimes :)
|
Test results: |
|
Tests all passing on |
|
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
Nemohis 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 thehydrostructure produced bygetNemoh.checkNemohsets values less than 0 to 0 and returns a tracking of where negative values were found.Fixes #4
test_results.pdf
Checklist:
example.mhas been modified, the content / line numbers indocs\user\example.rstare still valid or have been fixed