Skip to content

Conversation

@dforbush2
Copy link
Contributor

@dforbush2 dforbush2 commented Jun 2, 2022

This is the initial pull request for the wave excitation correction for large XY displacement project. The wave excitation force is calculated with respect to a body's instantaneous X,Y position, not just the force at 0,0. It is appropriate to model bodies for which large lateral displacements are expected, particularly where wave phase between multiple bodies is important.

Files Changed:
bodyClass: added 1 new structure "largeXYDisplacement" with 2 fields: "option" (1 or 0 boolean to turn on/off) and "threshold" (float, in m: how far the body can translate before an excitation phase correction will be recalculated).
body block wave excitation: added phase arguments to regular waves. Added matlab function block calling calcPhaseDisp to all body/wave excitation calculation methods except no wave and user defined elevation, and the displacement input to all methods for which it did not already exist. The sum of phase from waves.phase and the displacement phase correction is passed to the excitation force calculation.

Files Added:
functions/simulink/ model/calcDispPhase.m: the excitation phase calculating function (see comments for I/O description)

To test: the RM3 example works, just add the following where appropriate in the input file

body(1).largeXYDisplacement.option=1;
body(1).largeXYDisplacement.threshold=1;
body(2).largeXYDisplacement.option=1;
body(2).largeXYDisplacement.threshold=1;

@dforbush2
Copy link
Contributor Author

DO NOT MERGE YET. See issue #876

@dforbush2
Copy link
Contributor Author

I have also tried using persistent variables in the same way as the radiation convolution integral. Again, this is giving an error, even though it appears to operate the exact same way as the convolution integral block.

MATLAB Function3 uses constructs that are invalid when the block specifies or inherits a continuous sample time. Invalid constructs include using global variables, writing to initialized persistent variables, calling exported functions, or using coder.extrinsic. For help on persistent variables, see the documentation.

@dforbush2
Copy link
Contributor Author

Because of the unresolved issues in the items above, and their apparent dependency on MATLAB/Simulink version, I have removed the threshold for re-calculation. If the largeXYDisplacement option is enabled, it will calculate a phase correction at every time step. This is a single additional matrix multiplication: for irregular waves, a few timing tests with the RM3 example showed no significant difference in run time with and without this option enabled. This is not ideal, but removes the need for feedback loops or persistent variables in the MATLAB function.

Still need to address failed tests and add documentation.

@kmruehl kmruehl changed the title initial commit largeXYDispOption DRAFT: initial commit largeXYDispOption Jun 15, 2022
@dforbush2 dforbush2 changed the title DRAFT: initial commit largeXYDispOption initial commit largeXYDispOption Jun 17, 2022
@dforbush2
Copy link
Contributor Author

All checks now passing. Need docs, but otherwise ready for merge!

@jtgrasb jtgrasb self-requested a review June 29, 2022 15:10
@kmruehl kmruehl added the Body Class Body Class (bodyClass.m) label Jun 29, 2022
Copy link
Contributor

@jtgrasb jtgrasb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reviewed this and looks good. I also tested it with the mean drift application and there is clear difference between the case without the displacement calc and with the displacement calc, which can be seen when plotting/saving the visualization. The displacement calc accounts for the x translation and the body motion appears to be much more in phase with the waves as it translates. Docs look fine too. Except for the 2 small comments, looks ready to merge to me.

@jtgrasb jtgrasb merged commit 22f3ff2 into WEC-Sim:dev Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Body Class Body Class (bodyClass.m)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants