-
Notifications
You must be signed in to change notification settings - Fork 184
Run WEC-Sim from Simulink #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These functions are used as the Init and Stop functions of the Simulink file as well as all callbacks in the masked subsystem Parameters.
The system was designed to allow for the simulation to be ran from the Simulink file itself. This Simulink file contains a masked subsystem used to load input parameters for the simulation. There are two options for creating the parameters, load from input file or custom parameters.
Update allowing simulations ran from Simulink file #503
…-Sim into run_from_sim
Merge my updates into the new feature branch
jleonqu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the way you implemented this feature in Simulink, it is very convenient, easy to use, easy to understand, and very useful. Regarding MCR, I think it's not a big deal if you have to run the simulation with the command line, actually I prefer that way when I am running multiple simulations with the same model because for me it is easy to adjust the multiple runs using a Matlab script.
Just as a comment, the changes worked when I used Matlab 2020b, but they didn't work with Matlab 2021a (I had the same issue described in #546 ), which I think make sense, since #553 has not been merge into master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akeeste this should be ready for your final review. Here are my notes:
- updated docs to add Running from Simulink to advanced features and simplified workflow/examples
- changed
wecSimInitFunctiontowecSimInitialize - added to .gitignore
- added brief section on
wecSimFcnrelated to #598
@akeeste To Do:
- add custom WEC-Sim error if run from Simulink by hitting play and haven't executed
wecSimInitialize - open issue or project to see if we can run from Simulink by hitting play (and run executing
wecSimInitialize)
|
@kmruehl I am ready to merge. I added a few small fixes and created project board cards for the last two items: |
|
@akeeste thank you! I made a minor revision and now I'm merging into dev |
This PR expands upon @jhbates work (PR #512) and allows WEC-Sim to run from Simulink.
There are now five ways to run WEC-Sim (two additional):
If starting in Simulink (2,3 above), the user must run the new WEC-Sim pre-processing command 'wecSimInitFunction' prior to running every simulation. This extra step avoids a previously mentioned bug in R2020b. MCR and PCT can be used with the command line, but currently not when running WEC-Sim from Simulink. Regardless of the run method used, the WEC-Sim post-processing is run as the Global Reference Frame's stop function callback in Simulink.
Custom parameters may be set inside of the Simulink file using the mask for each WEC-Sim block. The masks currently contain most (but not every) options available in the text-based input. Whether the Simulink model runs an input file or uses custom parameters is determined by a single Global Reference Frame mask setting. This currently defaults to using an input file. Additionally, if custom parameters are used and WEC-Sim is run from Simulink then the mask parameters are written to a 'wecSimInputFile_simulinkCustomParameters.m' which is used for that simulation. To make initializing custom mask parameters easy, there is a button in the Global Reference Frame that prepopulates mask values using a previous input file.
New files
sim(simulinkModel)...)sim(simulinkModel)...)This PR passes all continuous integration tests and also works with the various application case tests in PR #508. It should have the same backwards compatibility as the current dev branch does.
@yuyihsiang Can you test this PR with wecSimPCT? I have tested with MCR but do not have the parallel computing toolbox installed.
@jleonqu I believe you looked at this work a bit previously. Can you take a look at this PR generally and let me know your suggestions?