Skip to content

Conversation

@salhus
Copy link
Contributor

@salhus salhus commented Jun 7, 2023

This follows from #585
This PR implements an FIR filter to calculate the radiation forces. The user needs to set a flag simu.FIR = 1 to enable this implementation.
This PR uses automatic code generation to FIR filter blocks for each mode (both diagonal and off-diagonal terms) and works with body-2-body interactions enabled.
I have modified a line of code in the RM3 example that has the simu.FIR flag for easier review.

The PR still needs documentation.

@salhus salhus requested a review from akeeste June 7, 2023 14:25
@salhus salhus marked this pull request as draft June 7, 2023 14:25
@akeeste akeeste self-assigned this Jun 7, 2023
@akeeste akeeste added the Feature new feature request label Jun 7, 2023
Copy link
Contributor

@akeeste akeeste left a comment

Choose a reason for hiding this comment

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

Nice work @salhus!

There's a couple remaining items to fine tune this capability:

  • Update Line 3 in the FIR Filter Matrix mask to include body-to-body interactions. You might need to use body.total instead of length(body) because the highest level body block already defines body as body(1), body(2), etc
  • Add a short line of documentation in the comment at WECSim_Lib_Body_Elements/Rigid Body/Hydrodynamic Body/Wave Radiation Forces Calculation/SS CI and Constant-Damping-CoeVariant Subsystem to state what flag will turn on the FIR option, e.g. "If another wave type and simu.FIR == 1, use the FIR filter calculation"
  • Add advanced feature documentation
  • Add a WEC-Sim Application that compares the various radiation damping calculations. This will ensure this functionality is tested and would be a nice way to highlight the differences to users.

@@ -1,25 +1,25 @@
%Example of user input MATLAB file for post processing
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert to original version upon completion

@@ -1,20 +1,21 @@
%% Simulation Data
simu = simulationClass(); % Initialize Simulation Class
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert to original version upon completion

@salhus
Copy link
Contributor Author

salhus commented Aug 9, 2023

Hi Adam @akeeste ,
I added the rate transition blocks, and the sampling time to simu.cicDt.
I set the number of row blocks to 6 and wrapped a try statement when adding additional instances, so working on the block is easier. The row adding cannot be linked to body, since each body block will have their own index, and it will mess up the rest of the logic downstream. At this point I am deciding against enabling GBM.
Also, I would stick with length(body) instead of blody.total as body.total only counts hydrodynamic bodies.

image

In terms of development, I think this is done. The tests are passing.
I am only left with documentation.

cheers,
Sal

@akeeste
Copy link
Contributor

akeeste commented Aug 11, 2023

Hi @salhus

Thanks for those updates. I added a few more changes that I described above into PR salhus/WEC-Sim#11. Please review and merge that PR into your branch. I updated the rate transition blocks to specify use of simu.cicDt or else they will inherit the same time step as the rest of the simulation. I also updated the counting of DOFs and bodies in the library block so that the FIR setting can now be used with:

  • nonhydro bodies
  • B2B
  • GBM

Note that non-hydro bodies can't be used with B2B if they're included in the h5 file, but that is a larger issue already present in WEC-Sim. I also don't think this will work with B2B and GBM, but that is a niche case that can't be tested easily and I'm unsure if GBM+B2B is currently supported or not.

@salhus
Copy link
Contributor Author

salhus commented Aug 15, 2023

@akeeste
Hi Adam,
Thanks for those additions ! I merged your PR. Thanks for the changes to the class. And it seems to work for body.dof, since body.total would have not worked as intended.

So just to confirm with you the work is done, and I am moving on the documentation now.

Cheers,
Sal

@kmruehl kmruehl requested a review from nathanmtom September 20, 2023 14:43
@kmruehl kmruehl assigned nathanmtom and unassigned akeeste Sep 20, 2023
@salhus salhus marked this pull request as ready for review September 21, 2023 04:51
@nathanmtom
Copy link

@salhus Thanks for developing this feature as it provides an alternative to the primary CIC option and highlights how we can leverage automatic generation to auto build.

After completing my initial review, I believe you have responded to @akeeste requests expect for documentation and developing an applications to compare the three different approaches to the convolution integral calculation. We also should be adding a test case to ensure this feature is not broken in the future. I do need to run the WEC-Sim Applications Test with this branch to see if there are any further bugs to fix.

In terms of next steps the priority is documentation. Secondary is the applications and test case which can be added as a project board item and addressed in the next fiscal year. I'll be reviewing the N Waves PR next and if I have time I will try to assist with the applications and test case development.

@salhus
Copy link
Contributor Author

salhus commented Sep 22, 2023

@nathanmtom Thanks for reviewing the PR. I think I should be able to wrap-up the documentation by Monday. I have a PR on the applications repository for N-Wave PR and will add another PR that corresponds to this FIR PR tonight.

+------------------------------------------------+-------------------------------------------+
| *Radiation Force Calculation Approach* | *Time (s)* |
+------------------------------------------------+-------------------------------------------+
| No Convolution | 3.699 s |

Choose a reason for hiding this comment

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

@salhus Minor comment: can we call No Convolution "Constant Coefficients" as this is what the block is called in the Wave Radiation Forces Calculation Block.

Second when I run the simulation I get slightly different times, so I wanted to request we report normalized times. So No Convolution would be 1 and all other times would be referenced to that. I think there will be confusion if these numbers are not reproduced by users unfortunately there is a lot of factors impacting the final values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the docs.

  • done

.. _user-advanced-features-time-step:
FIR Filters

Choose a reason for hiding this comment

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

@salhus Minor comment can we spell out FIR and say "Finite Impulse Response (FIR)". Also on line 218 below write out fully the first time and then use FIR for the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense.

  • done.

@nathanmtom
Copy link

Thanks for updating the documentation @salhus. I have some minor requests on the documentation that I would appreciate you incorporating. Also if you can respond to @akeeste comments about reverting two files back to the original we should be ready for merging by end of this week. I'll respond with feedback on the applications case in that PR.

@salhus
Copy link
Contributor Author

salhus commented Sep 27, 2023

@nathanmtom ,
Thanks Nathan.
I updated the docs and restored the RM3 example to its original state.

@nathanmtom
Copy link

Thanks @salhus for addressing my comments for this PR. I accept your latest changes and all tests are passing except for the windows-latest which has been identified in issue #1128.

@nathanmtom nathanmtom merged commit 9cb6724 into WEC-Sim:dev Sep 27, 2023
@salhus
Copy link
Contributor Author

salhus commented Sep 27, 2023

@nathanmtom
Thanks Nathan for patiently going through it all!

@salhus salhus deleted the Fr-FIR-filter branch October 4, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature new feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants