Skip to content
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

Add the control TMD to Simulink with S-function #761

Closed
salicto opened this issue May 20, 2021 · 17 comments
Closed

Add the control TMD to Simulink with S-function #761

salicto opened this issue May 20, 2021 · 17 comments

Comments

@salicto
Copy link

salicto commented May 20, 2021

Hello everyone,
I am looking to connect the TMD module with Simulink in order to develop a complete instrumentation and control system. I contacted Professor Lackner (he developed this module) but unfortunately he did not have the solution. So I ask the openfast user community if they have worked on this part.

Thank you in advance for any help you could give me,

Best Regards

Tom

@andrew-platt
Copy link
Collaborator

andrew-platt commented Jun 3, 2021

Hi Tom,

We have completed the passing of control signals from the Bladed controller interface to the StC module (formerly TMD) in the following pull request: #664.

If you need to pass the StC signals in from Simulink, you can follow the example for how the cable controls are passed to Simulink. You will need to expand the arrays on the C library (FAST_Library.h) and set the appropriate data handling in the FAST_Library.f90. Within ServoDyn, you will need to complete the passing of those signals through in the StCControl_CalcOutput routine in the ServoDyn.f90 (there are some details that are not complete in that routine and some logic may need updating -- the logic is slightly different for the StC controls than for the cable controls at present).

Regards

@salicto
Copy link
Author

salicto commented Jun 9, 2021

Hi Andrew,

Thank you for your comment, I will take a closer look at this module.

Regards,

@ALpadisa
Copy link

dear Andrew
Today, when I used matlab to run the file'openLoop.mdl' in'...\openfast-f-StrucCtrl_controls\glue-codes\simulink\examples', the following situation occurred, and I still can’t answer after consulting a lot of information , Here to ask you for advice

image

The file I run is "...\StC_test_OC4Semi\StC_test_OC4Semi.fst"
Regards,

@jjonkman
Copy link
Collaborator

Dear @ALpadisa,

From the error, it sounds like the version of your input file is incompatible with the version of OpenFAST you are running. Can you clarify from which branch of OpenFAST you compiled the source code and from which branch you obtained the input file(s)? Providing the full links to your files would help.

Best regards,

@ALpadisa
Copy link

ALpadisa commented Oct 1, 2021

Dear @jjonkman
I am very glad that you can reply to my news. The Openfast file I compiled comes from
https://github.com/andrew-platt/openfast/tree/f/StrucCtrl_controls
The input file comes from
https://github.com/openfast/r-test
My goal is to add TMD module in Simulink
Best regards,

@jjonkman
Copy link
Collaborator

jjonkman commented Oct 1, 2021

Dear @ALpadisa,

The input file format has changed between the version of OpenFAST you have compiled and the input files from the OpenFAST v3.0 r-test. I'll let @andrew-platt respond regarding where an input file compatible with the version of OpenFAST you are compiling can be found. Alternatively, you can modify the input files based on the errors you are receiving; reviewing the Echo files may help.

Best regards,

@andrew-platt
Copy link
Collaborator

Dear @ALpadisa,

There are some input file differences between the OpenFAST v3.0 and the f/StrucCtrl_controls branches. For the latter, the corresponding input files can be found in this branch for r-test: https://github.com/OpenFAST/r-test/tree/f/StrucCtrl_controls

Regards

@ALpadisa
Copy link

ALpadisa commented Oct 4, 2021

Dear Andrew,

Thank you very much for your reply, I will check it carefully!

Regards,

@jjonkman jjonkman closed this as completed Oct 4, 2021
@QAlexande
Copy link

dear @andrew-platt
Sorry to bother you ! How do I input an external force in simulink for this version of openFAST? Just like the picture below
image
Regards,

@salicto
Copy link
Author

salicto commented Oct 11, 2021

Dear @QAlexande ,

Did you manage to modify the source code and compile the openFast folder to add TMD control with simulink? I would be interested in your modifications because I have been trying for several weeks and I cannot generate an additional input on simulink.

Regards,

@QAlexande
Copy link

Dear @salicto
If you just want to realize TMD simulation through simulink, then the above message may be helpful to you, if you want an additional input, then this is also the question I am thinking about,I have not found a suitable method yet.
Regards,

@jjonkman
Copy link
Collaborator

Dear @QAlexande and @salicto,

The FAST S-Function input parameter NumAdditionalInputs offers a way to allow you to pass additional data (e.g., F_active) from Simulink to the FAST / OpenFAST library without recompiling the FAST S-Function. But using NumAdditionalInputs will require you to change the source code of and recompile the FAST library so as to make use of the new data that passed (i.e., transferring F_active from the glue code to the StC module, where you want to use the data).

Best regards,

@salicto
Copy link
Author

salicto commented Oct 11, 2021

Dear @jjonkman,

thank you for the help given. I failed to compile the changes made to add the controller to simulink. So I went through the folder shared by Andrew. I cloned the file and I compiled everything to check if without any change on my part it could work. But many errors appear. I compile OpenFast 2.4 very well. I am using visual studio 2017 and an Intel fortran compiler.

here the log build with error

Output-Build.txt
s

@jjonkman
Copy link
Collaborator

Dear @salicto,

Did you select the "Release_MATLAB" configuration in Visual Studio before compiling the OpenFAST library called by the S-Function?

Best regards,

@bjonkman
Copy link
Contributor

@salicto ,

You are currently building with the Release | Win32 configuration. The errors you are reporting result from Visual Studio not building the SysIVF.f90 file in the correct order, which comes from a problem with Visual Studio not correctly figuring out the file dependencies. Typically restarting Visual Studio fixes the issue.

Try closing Visual Studio and then rebuilding the OpenFAST solution using the Release_MATLAB | x64 configuration. Note that the Release_MATLAB configuration will use SysMatlabWindows.f90 instead of the SysIVF.f90 source file.

@QAlexande
Copy link

Dear @jjonkman
Thank you very much for replying to my email. If I want to modify the source code of Openfast, what information should I refer to? Can you give me some details?
Best regards,

@jjonkman
Copy link
Collaborator

Dear @QAlexande,

Well, there are general resources available to guide source-code development of OpenFAST, such as the Developer Documentation on readthedocs and the NWTC Programming Handbook describing the modularization framework.

I would also suggest reviewing the source code of the FAST / OpenFAST library to see how other inputs from Simulink are passed through and used within the source code. For example, the blade pitch commands from Simulink are stored in array m_FAST%ExternInput%BlPitchCom() in the OpenFAST glue code, which gets transferred as an input to ServoDyn in array u%ExternalBlPitchCom().

Best regards,

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

No branches or pull requests

6 participants