Skip to content

Conversation

@dforbush2
Copy link
Contributor

Credit to @guangyaow on catching the error and proposing the fix.
This fix makes nonlinear froude krylov work for plane waves with non-zero directions. If the waves are not plane waves (e.g, there are a sum of wave trains from different directions) this will not work correctly. Capabilities will be expanded in a future PR.

Hotfix merge into master is intentional

dforbush2 and others added 30 commits March 15, 2022 13:53
…-Sim#1012)

When MoorDyn is used in WEC-Sim design, it is called as an external DLL executable library, and it runs on a separate console.exe under MATLAB's main process, with its separate process-ID(PID) in the windows task manager. The issue is related to the following scenarios on the Windows platform:
1>> if the lines data text file has an error in it.
2>> MoorDyn fails to converge.
3>> MoorDyn is launched, but the model has some other error.
Under such a scenario, MATLAB fails to terminate the MoorDyn Console and hangs instead, and either crash immediately or crashes if we press the close button on the MoorDyn console window. Either way, there seems to be no way the MATLAB session can recover from MoorDyn failure without crashing. It becomes a major issue if we are trying to tune mooring lines and want to try different lines configurations and stiffnesses, etc., to find an optimal mooring system because some configurations will not work, which will keep crashing MATLAB sessions during the test and trial.
The goal is for MoorDyn's failure not to crash the MATLAB session but instead MoorDyn dll execution to close and the MoorDyn console to close. I've found a solution to that.
For scenarios 1 and 2, the following Fix#01 seems to work on the Windows platform. And to cover scenario 3, an additional Fix#02 is needed.
Fix#01
In the MoorDyn block's 'InitFcn' call, making the following suggested changes check for MoorDyn Initialization failure and terminates the MoorDyn.dll console without crashing the MATLAB Session.
Fix#02
Suppose the MoorDyn console has been launched, but there is an error in the Simulink model. In that case, MATLAB throws an error and terminates the Simulink execution without terminating the MoorDyn console window. A try-catch statement in the wecsim file can address this issue. If a Simulink model error occurs, we can print the error and terminate the MoorDyn Console process.
* updates_docs_on_master

* incorporating_kelleys_minor_edits
Fixes function parsing error
Change the subscript of the pitch dof from 3,3 to 5,5 in ystring.
* Update readNEMOH.m for compatibility with NEMOH v3.0

* Removing line 374

This capability is within Dev, but not currently pulled over to Master. A separate PR was submitted to Dev for this fix.
@dforbush2 dforbush2 requested a review from salhus February 8, 2024 00:10
@dforbush2 dforbush2 marked this pull request as draft February 9, 2024 21:31
@dforbush2 dforbush2 marked this pull request as ready for review February 9, 2024 22:05
@dforbush2
Copy link
Contributor Author

dforbush2 commented Feb 9, 2024

This is ready to go. To avoid confusion for the reviewer note that:

  1. elv input is from waveElevation and is a vector that is equal in length to the center(:,3) from the STL file. This updates every time step. This elv already accounts for a non-zero wave direction to solve for wave elevation at [center(:,1), center(:,2)]. So Z= center(:,3)- elv accurately reflects the difference in height between the body panel in Z and the free surface at that same (x,y) point.
  2. For regular waves it is possible to re-use elv as the input since it is monochromatic. For irregular waves, the portion of the hydrostatic pressure equation for elevation must be recalculated because the check for deep water conditions happens every frequency. Recall that elv is elevation due to all frequency components at the points (center(:,1), center(:,2)): hence although it is a bit redundant to repeat this calculation here it is necessary.
  3. The whole nonFKForce only works with planar waves. UserDefinedEta and the multiple wave train feature added recently is the only way currently that a user could input non-planar waves. Please update documentation related to this latter feature to indicate that non-linear forcing will not work

@salhus
Copy link
Contributor

salhus commented Feb 12, 2024

Thanks for the PR @dforbush2 .

Putting a note here for future reference.
Non-planar waves / multi-wave headings need further development, to accommodate non-linear FK.

@salhus salhus merged commit fa5ac32 into WEC-Sim:master Feb 12, 2024
@guangyaow
Copy link

guangyaow commented Feb 12, 2024 via email

@salhus
Copy link
Contributor

salhus commented Feb 12, 2024

Hi @guangyaow,

Yes, you are right.
For a template for the .mat file please refer to the examples and you would find .mat files for an elevation import, and a spectra import.

Cheers,
sal

@akeeste
Copy link
Contributor

akeeste commented Sep 5, 2024

@salhus @dforbush2 Was there any change to the mask in this PR? I'm having issues merging library updates on my variableHydro branch. The latest library commit is this PR. I likely am missing a mask change.

Also please only squash and merge PRs into master/main/dev. The commit history on main is pretty messy now.

@dforbush2
Copy link
Contributor Author

To my knowledge there is not a mask change but there is a change to the noted library block to pull in wave direction to the function. This MAY have resulted in a subsequent mask change when multiple wave trains I.e. multiple possible wave directions were added, but I don’t think that had to happen here.

@akeeste
Copy link
Contributor

akeeste commented Sep 5, 2024

Thanks @dforbush2. I'll keep digging around for the issue on #1248

@akeeste
Copy link
Contributor

akeeste commented Sep 5, 2024

Made some progress--my issue on #1248 was coming from a mask and Run From Simulink + WEC-Sim GUI which is hard to track, but is unrelated to any library changes here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants