Skip to content

Conversation

@jtgrasb
Copy link
Contributor

@jtgrasb jtgrasb commented May 3, 2024

This PR fixes 2 bugs in the readAQWA.m script to resolve #1116 :

  1. The excitation phase in Ansys AQWA is given relative to the center of gravity of each body and a positive phase angle represents the excitation lagging behind the wave.

On the other hand, WEC-Sim follows WAMIT's standard, which is to define the excitation phase relative to the global origin and a positive phase angle meaning the excitation leading the wave.

The current readAQWA.m script negates the phase correctly to adjust to the discrepancy in leading/lagging, but does not take into account the difference in reference frames. Thus, WEC-Sim does not apply the correct excitation phase when using AQWA and a body is not located at the global origin. I updated the readAQWA.m script to adjust the phase of the excitation coefficients upon loading them into the hydro structure. This approach uses the equation (k is wave number, x and y are the coordinates of the body's cg, and $\beta$ is the wave direction):
$\Theta_{WAMIT} = -\Theta_{AQWA} - k [x cos(\beta) + y sin(\beta)]$

To demonstrate the difference, I used the example from PR #1191 and ran a 4 cylinder (locations: [-8, -8], [-8, 8], [8, -8], [8, 8]) case in both AQWA (blue, hydro_1) and Capytaine (orange, hydro_2) and compared the results. Before the updates in this PR, the excitation phase was significantly different, while after the updates in this PR, the results show much better match:

Before: After PR:

  1. The body-to-body elements of the added mass and radiation damping matrices were being read in backwards. When looking at the AH1 output file, each added mass and radiation damping matrix has 3 leading numbers (first 2 related to the body interactions and last number related to the frequency number). When outputting the AH1 descriptions, AQWA states that " 1 1" (i3,i3) means the force on structure 1 caused by the motions of structure 1. Thus, I interpret this as the 1st number representing the body on which the forces act and the 2nd number being the body causing the forces. When we load these values into WEC-Sim and turn on b2b, it is clear that the interactions are being read in backwards. From AQWA RM3 case, the force on body 1 from body 2 (frequency 1) should have elements:

But, with simu.b2b = 1, the body-body interaction terms for the force on body 1 from body 2 (frequency 1) are slightly different:

When looking at the opposite terms (force on body 2 from body 1) as well, it is clear that the interaction terms are backwards.

AQWA output:

WEC-Sim Forces:

To put it more plainly, readAQWA originally loaded the added mass and radiation damping terms as in eq. 7 below, while this PR corrects it to be as eq. 8.

image

Some additional useful references include this paper on a 2 body hinged raft WEC which uses WEC-Sim but demonstrates the two readAQWA.m updates which were needed to correct their results and issue #1116 where both issues are explained as well.

Thank you to @hachikoi1 and @meatballgithub for recognizing these issues and helping us solve them.

@jtgrasb jtgrasb added Bug bug in WEC-Sim source, high priority BEM/BEMIO related to BEMIO or BEM hydro data labels May 6, 2024
@kmruehl kmruehl added the B2B body-to-body interactions (simu.b2b = 1) label May 8, 2024
@jtgrasb jtgrasb requested a review from salhus May 17, 2024 20:02
@meatballgithub
Copy link

Thanks, this commit solves the issue in PR #1191 in a better way, and hopefully it will be merged soon.

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Jul 24, 2024

Hi @salhus, are you able to review this PR by next week? It'd be great to get it merged as soon as possible to resolve the bug.

@salhus salhus merged commit 7cbde2f into WEC-Sim:main Sep 3, 2024
kmruehl added a commit that referenced this pull request Sep 4, 2024
Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
kmruehl added a commit that referenced this pull request Sep 16, 2024
Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
dforbush2 added a commit that referenced this pull request Oct 30, 2024
* fix on pDis function call

* preliminary fix for issue #1288

* Update readAQWA.m (#1253)

* body mask fixes for #1346

* add warning when variable hydro turned on for drag or nonhydro bodies

* flex body - add missing mask lines, define h5 button callback

---------

Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>
akeeste added a commit that referenced this pull request Nov 4, 2024
* Fixing documentation inconsistency for PTO-Sim blocks (#1330)

* Fixing documentation inconsistency for PTO-Sim blocks

* Adding comments to nondimensional values for clarification

* update analytics implementation in docs re deprecation of analytics_id (#1342)

* Body block library update for bug fix #1346  (#1347)

* fix on pDis function call

* preliminary fix for issue #1288

* Update readAQWA.m (#1253)

* body mask fixes for #1346

* add warning when variable hydro turned on for drag or nonhydro bodies

* flex body - add missing mask lines, define h5 button callback

---------

Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>

* BIMIO to read NEMO QTF output files and do plots

* Fixes the plotQTF function when multiple hydro strctures are i/p

* Makes the body indecies start from 0 not from 1 to match the rest of NEMOH-BIMIO inputs for multibodies

* Fixes the bug in the bodyClass for the QTFs and variable hydro (#1351)

* fixes the bug in the bodyClass for the QTFs and variable hydro

* fix QTF block issue - dont make it an atomic systme

---------

Co-authored-by: akeeste <akeeste@sandia.gov>

* Update source/functions/BEMIO/QTFs/triToFullMatrix.m

Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>

* Update source/functions/BEMIO/QTFs/triToFullMatrix.m

Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>

* Update wecSimTest.m

Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>

* Update source/functions/BEMIO/QTFs/triToFullMatrix.m

Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>

* Update source/functions/BEMIO/plotBEMIO.m

Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>

* Update source/functions/BEMIO/QTFs/plotQTFs.m

Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>

* Update source/functions/BEMIO/QTFs/plotQTFs.m

Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>

---------

Co-authored-by: Jorge Leon <72461917+jleonqu@users.noreply.github.com>
Co-authored-by: Adam Keester <72414466+akeeste@users.noreply.github.com>
Co-authored-by: dforbush2 <dforbus@sandia.gov>
Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>
dforbush2 added a commit that referenced this pull request Feb 13, 2025
* fix on pDis function call

* preliminary fix for issue #1288

* Update readAQWA.m (#1253)

* body mask fixes for #1346

* add warning when variable hydro turned on for drag or nonhydro bodies

* flex body - add missing mask lines, define h5 button callback

* fix #1288 cleanup waveClass

* adding bodyClass, should match

---------

Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>
akeeste added a commit that referenced this pull request Mar 25, 2025
* updated the intro

* fixes a bug with the QTF interpolation function (#1396)

* fix #1288, cleanup waveclass (main) (#1417)

* fix on pDis function call

* preliminary fix for issue #1288

* Update readAQWA.m (#1253)

* body mask fixes for #1346

* add warning when variable hydro turned on for drag or nonhydro bodies

* flex body - add missing mask lines, define h5 button callback

* fix #1288 cleanup waveClass

* adding bodyClass, should match

---------

Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>

* Fix irregular wave elevation with multiple directions (#1403)

* Fix irregular wave elevation with multiple directions

* Updates the Ubuntu and Matlab versions (#1420)

* Updates the Ubuntu and Matlab versions

---------

Co-authored-by: Mohamed Shabara <84589678+MShabara@users.noreply.github.com>

* new body class constructor, no need for h5file

* removed disp used in debugging

* short check to ensure hydro struct provided is the right hydro struct

* cleaned up one comment

* rename hydrodata to hydroinput in body constructor

* move input checking to body.checkInputs()

* make body.hydroStruct a private variable

* make body.hydroStruct public and alphabetize

* clear body.hydroStruct once used

* brief documentation

* function to build body class hydro format struct from BEMIO format

* update hydro to hydroData function for other features

* fix bug in reading water depth, ex.irf.t and dofs

* make readH5ToStruct function identically to writeBEMIOH5 for GBM modes

* read GBM data and irf times correctly

* reference function in documentation

* update function docstring

---------

Co-authored-by: Shabara <mshabara@nrel.gov>
Co-authored-by: Mohamed Shabara <84589678+MShabara@users.noreply.github.com>
Co-authored-by: dforbush2 <dforbus@sandia.gov>
Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>
MShabara added a commit that referenced this pull request Mar 28, 2025
* updated the intro

* fixes a bug with the QTF interpolation function (#1396)

* fix #1288, cleanup waveclass (main) (#1417)

* fix on pDis function call

* preliminary fix for issue #1288

* Update readAQWA.m (#1253)

* body mask fixes for #1346

* add warning when variable hydro turned on for drag or nonhydro bodies

* flex body - add missing mask lines, define h5 button callback

* fix #1288 cleanup waveClass

* adding bodyClass, should match

---------

Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>

* Fix irregular wave elevation with multiple directions (#1403)

* Fix irregular wave elevation with multiple directions

* Updates the Ubuntu and Matlab versions (#1420)

* Updates the Ubuntu and Matlab versions

---------

Co-authored-by: Mohamed Shabara <84589678+MShabara@users.noreply.github.com>

* Enhances function flexibility

* Fix warnings

* change coercion for consistency with documentation

---------

Co-authored-by: Shabara <mshabara@nrel.gov>
Co-authored-by: Mohamed Shabara <84589678+MShabara@users.noreply.github.com>
Co-authored-by: dforbush2 <dforbus@sandia.gov>
Co-authored-by: jtgrasb <87095491+jtgrasb@users.noreply.github.com>
Co-authored-by: akeeste <akeeste@sandia.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B2B body-to-body interactions (simu.b2b = 1) BEM/BEMIO related to BEMIO or BEM hydro data Bug bug in WEC-Sim source, high priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Phase angle of wave excitation loads for offset body, and added mass and radiation damping matrix for multibodies in AQWA

4 participants