Skip to content

Conversation

@kmruehl
Copy link
Collaborator

@kmruehl kmruehl commented Aug 26, 2021

This PR builds on #667 with a different approach using referenced subsystems.

Updates include:

  • Split WEC-Sim Library into sub-libraries for each class, e.g. Body, PTO, Constraint, Mooring, Frame
  • Converted all linked library blocks into referenced subsystems, e.g. Non-Linear Hydro, B2B, Morison Element, etc
  • Saved each referenced subsystem as light blue so they are easier to identify in the future
  • Updated WEC-Sim library to R2020a to be consistent with WEC-Sim CI tests MATLAB Build Status

To Do:

  • @yuyihsiang can you verify that I included all of the linked library blocks?
  • @kmruehl look into accelerator and rapid-accelerator mode regarding, "Does not have code generation capability."
  • @kmruehl figure out why R2020a tests are failing, even though library is saved in R2020a and local tests are passing --> MATLAB bug in R2020a
  • @kmruehl convert library class blocks to sub-library blocks and update forwarding table
  • @kmruehl resolve issue with B2B subsystem

@kmruehl kmruehl added Feature new feature request SCM source code mangagement and warnings labels Aug 26, 2021
@kmruehl kmruehl requested review from akeeste and yuyihsiang August 26, 2021 23:23
@kmruehl kmruehl marked this pull request as ready for review August 26, 2021 23:30
@yuyihsiang
Copy link
Contributor

yuyihsiang commented Aug 30, 2021

I got an error when running the GBM case with the library.

Error using wecSim (line 44)
Error evaluating 'StopFcn' callback of Frames block (mask) 'GBM/Global Reference Frame'.
Callback string is 'run('wecSimStopFunction')'
Caused by:
Error using wecSim (line 44)
wecSimStopFunction not found.

It seems that the 'wecSimStopFunction.m' does not exist in dev.

--Yi-Hsiang

@akeeste
Copy link
Contributor

akeeste commented Aug 30, 2021

@kmruehl
I have tried debugging this PR in R2020a, but I cannot find the issue. Whenever I run or save a model from Simulink, MATLAB crashes. All the error message relate to internal Simulink issues that I cannot debug easily. I can keep looking at this, but am a bit stuck on how to go about this.

Also, I completed a preliminary study on how the referenced subsystems affect the accelerator mode speed. I ran 30 OSWEC cases total (5 for each of the 3 modes in dev and this PR). The referenced subsystems seem to slow things down by approximately 20%.

Maybe it is worthwhile to switch back to the non-backwards compatible change using the Open Callback? Can we use the WECSim_Lib.slx/Library Properties/Forwarding Table to maintain backwards compatibility? It looks like this table has been used for changes in the past.

@kmruehl
Copy link
Collaborator Author

kmruehl commented Aug 30, 2021

I got an error when running the GBM case with the library.

Error using wecSim (line 44)
Error evaluating 'StopFcn' callback of Frames block (mask) 'GBM/Global Reference Frame'.
Callback string is 'run('wecSimStopFunction')'
Caused by:
Error using wecSim (line 44)
wecSimStopFunction not found.

It seems that the 'wecSimStopFunction.m' does not exist in dev.

--Yi-Hsiang

@yuyihsiang this issue should be resolved with 29f2af6 can you try GBM again?

It is fine now.

@kmruehl
Copy link
Collaborator Author

kmruehl commented Aug 30, 2021

I have tried debugging this PR in R2020a, but I cannot find the issue. Whenever I run or save a model from Simulink, MATLAB crashes. All the error message relate to internal Simulink issues that I cannot debug easily. I can keep looking at this, but am a bit stuck on how to go about this.

@akeeste I've also been trying to debug the referenced subsystems issues in 2020a with no luck. It looks like there is a bug that was resolved in 2020b. The referenced subsystem feature was added in 2019b but not fully functional until 2020b.

@kmruehl
Copy link
Collaborator Author

kmruehl commented Aug 30, 2021

Also, I completed a preliminary study on how the referenced subsystems affect the accelerator mode speed. I ran 30 OSWEC cases total (5 for each of the 3 modes in dev and this PR). The referenced subsystems seem to slow things down by approximately 20%.

Good to know, thanks for looking into this.

Maybe it is worthwhile to switch back to the non-backwards compatible change using the Open Callback? Can we use the WECSim_Lib.slx/Library Properties/Forwarding Table to maintain backwards compatibility? It looks like this table has been used for changes in the past.

I'll convert these files from referenced subsystems to sub-libraries with a forwarding table:

  • Body_Elements.slx
  • Constraints.slx
  • Frames.slx
  • Moorings.slx
  • PTOs.slx
  • WECSim_Lib.slx

But the sub-libraries did not fully resolve the library issues because they cannot be used for the linked library blocks between Rigid Bodies (Hydro, Non-Hydro and Drag) and Flex body:

  • Additional_Linear_Damping_Force_Calculation.slx
  • B2B_Subsystem.slx
  • Morison_Element_and_Viscous_Damping_Force_Calculation.slx
  • Net_Buoyancy_Force.slx
  • Nonlinear_Wave_Elevation.slx
  • Wave_Radiation_Forces_Calculation.slx

I think the solution will have to be a combination of sub-libraries and referenced libraries, which hopefully will not reduce speed by 20%, but TBD

@kmruehl
Copy link
Collaborator Author

kmruehl commented Aug 30, 2021

@akeeste and @yuyihsiang this is ready for another review. Also, all tests are passing, even R2020a: https://github.com/WEC-Sim/WEC-Sim/pull/688/checks

@kmruehl
Copy link
Collaborator Author

kmruehl commented Aug 30, 2021

WEC-Sim tests are passing, but the WEC-Sim_Applications B2B tests fail

 Failed to evaluate mask initialization commands.
        Error using wecSim (line 44)
        Block 'RM3/Spar//Plate/Hydrodynamic Body/B2B Subsystem/B2B Subsystem/B2B/CrossCoupling'
        is inside a Subsystem Reference block 'RM3/Spar//Plate/Hydrodynamic Body/B2B Subsystem'.
        Incorrect to modify contents of a Subsystem Reference block using callback code.

refer to forum discussion about this issue.

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.

@kmruehl I think this is a great improvement to our workflow and will be very helpful in merging many library PRs at once. I'm glad you found a way to make it backwards compatible; that was my main concern with the previous method.

My only suggestion is to add a few more Referenced subsystems for items that can be linked together:

  • Create Structure or Motion Sensor subsystem to replace the following:
    • WECSim_Lib_Body/Rigid Body/Hydrodynamic Body/Structure
    • WECSim_Lib_Body/Rigid Body/Non-Hydro Body/Structure
    • WECSim_Lib_Body/Flex Body/Structure
  • Create Wave Diffraction and Excitation Force Calculation subsystem to replace the following:
    • WECSim_Lib_Body/Rigid Body/Hydrodynamic Body/Wave Diffraction and Excitation Force Calculation
    • WECSim_Lib_Body/Flex Body/Wave Diffraction and Excitation Force Calculation
  • Add Net_Buoyancy_Force subsystem to replace:
    • WECSim_Lib_Body/Flex Body/Hydrostatic Restoring Force Calculation/Hydrostatic Restoring Force Calculation/Linear and Nonlinear Restoring Force Variant Subsystem/Linear Hydrostatic Restoring Force /Net Buoyancy Force

I think these three items will cover any old links and prevent code duplication in the library.

@kmruehl
Copy link
Collaborator Author

kmruehl commented Sep 28, 2021

This PR is partially covered by #712 to include sub-libraries for the following blocks:

  • cables
  • ptos
  • constraints

@kmruehl
Copy link
Collaborator Author

kmruehl commented Sep 28, 2021

This PR is partially covered by #714 to include sub-library for the following block:

  • frames

@kmruehl kmruehl marked this pull request as draft September 30, 2021 20:16
@kmruehl kmruehl closed this Oct 12, 2021
@kmruehl kmruehl force-pushed the feature_referencedsubsystem branch from 584e126 to ee02bb5 Compare October 12, 2021 22:00
@kmruehl kmruehl added Library updates to the WEC-Sim Library and removed Feature new feature request labels Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Library updates to the WEC-Sim Library SCM source code mangagement and warnings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants