Beginner Guide for MATLAB Simulink and FAST

Dear Jason.Jonkman,

Yes, I want to learn how Openfast builds matlab interface. The main purpose is to know how to establish matlab interface for fast.farm. But I still don’t understand how Openfast for simulink works.

I follow the prompts in ‘Creat.m’ in matlab. First, I need to compile 0penFAST for Simulink to create a Dll. I found the Openfast-Simulink folder in the OpenFAST source folder, but there is only a file named “FAST_Library.f90” in it. Does this file need to be compiled?

Best regards,

Dear @Liye.Zhao,

Yes, you must first compile the OpenFAST library for Simulink before running the create_FAST_SFunc.m script. How do you normally compile OpenFAST? On Windows, I find compiling with Visual Studio is easiest (Installing Visual Studio is the hardest step). Once Visual Studio is installed, to compile the OpenFAST library for Simulink, open up the FAST.sln (in the vs-build/FAST directory), select the “Release_Matlab” configuration, and press “Build Solution”.

Best regards,

Dear Jason.Jonkman,

Thank you very much for your reply. I have compiled fast according to your prompt, but I have encountered the following problems:

5>------ All restarts have been started: Project: OpenFAST-Simulink, configuration: Release_Matlab x64 ------
5>Deleting intermediate files and output files for project ‘OpenFAST-Simulink’, configuration ‘Release_Matlab|x64’.
5>Compiling with Intel Fortran Compiler Classic 2021.1.1 [Intel(R) 64]…
5>FAST_Library.f90
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(40): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(72): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(89): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(185): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(249): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(331): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(404): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(417): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(459): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(513): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(645): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(670): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(783): warning #7025: This directive is not standard F2003.
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(86): warning #8809: An OPTIONAL or EXTERNAL dummy argument to a BIND(C) procedure is not interoperable. [TMAX]
5>E:\openfast-main\openfast-main\modules\openfast-library\src\FAST_Library.f90(86): warning #8809: An OPTIONAL or EXTERNAL dummy argument to a BIND(C) procedure is not interoperable. [INITINPARY]
5>Linking…
5>LINK: fatal error LNK1181: Failed to open the input file C:\Program Files\MATLAB\R2019b\extern\lib\win64\microsoft\libmex.lib
5 >
5>Build log written to “file://E:\openfast-main\openfast-main\vs-build\OpenFAST-Simulink\x64\Release_Matlab\BuildLog.htm”
5>OpenFAST-Simulink - 1 error(s), 15 warning(s)
= = = = = = = = = = all regenerated: three success, failure 1, skip 1

my MATLAB version is 2022b, how can I do?

Best regards,
Liye

Dear @Liye.Zhao,

It looks like a similar question regarding this LNK1181 error was asked and answered on our OpenFAST issues page–see: Build error · Issue #638 · OpenFAST/openfast · GitHub.

Best regards,

Dear Jason.Jonkman,
Thank you very much for your reply, it is very useful.

Best regards,
Liye

Hello, sorry if this is off topic or a very basic question, but is anyone using MATLAB/simulink as a grid/microgrid design tool? or interfacing with SCADA servers for operational deployment of simulink data to field devices? we have a campus of 275 facilities and are very interested in this product!

Hello,
Hope you are doing well.
I am a research student in vibration control of offshore structures, and I, too, am very new to the research topic and the OpenFAST software.
I have read the documents provided by the esteemed NREL core team, and I really appreciate their efforts in building this software. I would, however, like to request that you list out the steps to incorporate the structural control module in running the software.
The problem I am facing is that while I am able to run the FAST software using the basic test example structures as provided in the software, I am unable to understand the steps to incorporate structural control.
Could you please provide the steps using which I can do that or some kind of documentation that helps me to do that…?
I am really sorry for the inconvenience.

Thankyou in advance,
With best regards,
Shreyasee

Dear @Shreyasee.Sanjay,

You should identify the number of structural controllers (StCs) that you want and which components (blades, nacelle, tower, substructure) that you want to place these StCs. You should identify these in the STRUCTURAL CONTROL section of the ServoDyn input file. Each StC should get its own StC input file. The StC input file is documented here, along with the rest of the StC documentation: 4.2.12. Structural Control (SrvD) — OpenFAST v3.5.3 documentation.

Best regards,

Respected Dr. Jonkman,
Thank you so much for your prompt reply. I have changed the StC file in the ServoDyn folder and there are some errors I am encountering. I have the following queries regarding that,

  1. the 5MW_OC3_Spar folder I have does not have a ServoDyn folder but has the .StC file which I have tried to edit. I have attached the contents of the folder below (Fig 1). Could you please check if the contents are right…?
  2. I used the default values for structural control in .StC file and I obtained the data after running the software. then I tried to opt out of structural control by inputting “false” in the structural control file, but I saw that the program was getting aborted (Fig 2). Could you please tell me the things I can correct if I want to get the data without using structural control. I want to compare the displacement with and without structural control.

fig 1

fig 2

Thankyou so much for your time and patience in advance,
With best regards,
Shreyasee Sanjay

Dear @Shreyasee.Sanjay,

I’m not sure I understand your first question.

Regarding your second question, are you referring to StC_X_DOF, StC_Y_DOF, and StC_Z_DOF? These are only used when StC_DOF_MODE = 1, but you have selected StC_DOF_MODE = 2.

Best regards,

Respected Dr. Jonkman,

I am sorry for the confusion.

From the first question, I meant if I had missed downloading any file folders inside the case example “5MW_OC3_SPAR_LINEAR”

For the second question, I checked and cleared my mistake, and I am attaching a fresh copy of the code so far.

My issue still remains that I am getting the same results with and without structural control and I request you to guide me regarding that.

thanking you,
with best regards,
Shreyasee

Dear @Shreyasee.Sanjay,

If OpenFAST is not complaining about a missing file, you should have the files you need.

I’m not sure I really understand what you are comparing to answer your question. What inputs are you changing between the two simulations that you expect to produce different results?

Best regards,

Respected Dr. Jonkman,

I tried simulating the case examples using the default values as provided in the software. I got the results as well.

Though when I tried to change the code by disabling the structural controls. I am getting the same results as before.

I am considering the surge sway heave roll yaw and pitch movements of the platforms of the case examples to understand how the software works.

Thankyou and best regards,
Shreyasee Sanjay.

Dear @Shreyasee.Sanjay,

I’m sorry, but I still don’t understand what two simulations you are comparing that you expect to yield different results. Are you running a specific OpenFAST r-test example; if so, which one? And what are you changing in this model when you run it again and expect to get a different answer?

Best regards,

Respected Dr. Jonkman,
I am sorry, I should have clarified things better. I am new to this software and I am involved in the topic of vibration control on offshore structures for my research. I came across OpenFAST software during during the review process and I want to understand and use it better hence I am trying to learn the software.
I understood that there are different case examples already provided in the software and I simulated them in the MATLAB and Simulink environment and focused mainly in the heave, pitch, yaw, surge, roll and sway motions of the compliant platforms.
I got the data of displacements of the inbuilt case examples without modifications in code.

After that I wanted to disable structural controls and simulate the structures again to see how they respond. I am attaching a copy of the code I edited as a means to disable structural controls in the servodyn .dat file but I obtained the same results.

By “same results” I mean to say that there was no changes in the values of the platform movements for the above mentioned degrees of freedom. I am attaching the excel data of the same as an example.

As it can be seen, the data before and after diabling the structural controls (as far as I understood) is the same and I am not able to understand the mistake I am doing.

Hence, I request your valuable input on the mistakes I am making and also the following queries:

  1. If I donot edit any code in a particular case example and simulate the structure does it mean that the structural controls are being simulated by default…??
  2. How should the code be edited to enable or disable structural controls in the servodyn .dat file…??
  3. Should the servodyn .dat file be placed in some other folder so as to enable or disable the structural controls…?? Or is there a separate way to approach the structural controls…??

thankyou and regards,
Shreyasee Sanjay

Dear @Shreyasee.Sanjay,

Here are my responses:

  1. Structural control is not enabled by default.
  2. Different structural control options can be selected by editing the structural control input file.
  3. To enable structural control, you must define that in the ServoDyn input file (how many structural controllers you have and which component of the turbine (blades, nacelle, tower, substructure) they are placed). The location of the input files shouldn’t matter so long as the path to the directory of the input file is set when defining the input file names in the input files.

If you are changing the structural control input file and the OpenFAST simulation results are not changing, I would question if you are changing an input file that is even being used by the OpenFAST simulation. Is the structural control input file (name and path) you are changing referenced in the corresponding ServoDyn input file you are using?

I’m still not sure which OpenFAST r-test example you are using. Please state that.

Best regards,

Respected Dr. Jonkman,
I have tried using the OpenFAST R-test example for 5MW_OC3_Spar_Linear and 5MW_OC4Semi_Linear.

I have defined it in the servodyn input file. I attached the code for the servodyn input file where I changed all the values to “0” to disable the structural control. But it did not seem to work. Would you please check the code and suggest if it is right to edit it the way I have done it…?

“Is the structural control input file (name and path) you are changing referenced in the corresponding ServoDyn input file you are using?” could you please mention how I am supposed to correct it…??

Thankyou and regards,
Shreyasee Sanjay

Dear @Shreyasee.Sanjay,

Unless you changed this example, the OpenFAST r-test example 5MW_OC3Spar_Linear does not have ServoDyn enabled. Also, unless you changed this example, the OpenFAST r-test example 5MW_OC4Semi_Linear has ServoDyn enabled, but does not have structural control enabled because no structural controllers are defined in ServoDyn. As I expected, I would guess your problem is that you are changing a structural control input file that is not being used in your OpenFAST simulations.

Best regards,

Respected Dr. Jonkman,
Please suggest a way I can include the servodyn file that the system can use it properly.
Would you please also suggest a way to understand how and when the servodyn file is enabled or not for other r-test examples so I can obtain the required data.

Thankyou and regards,
Shreyasee Sanjay

Dear @Shreyasee.Sanjay,

ServoDyn is enabled/disabled through the CompServo switch in the OpenFAST primary (.fst) input file. Structural control is enabled/disabled through the inputs in the STRUCTURAL CONTROL section of the ServoDyn input file. See the input file documentation on OpenFAST readthedocs for more information: 4. User Documentation — OpenFAST v3.5.3 documentation.

Best regards,