Beginner to Simulink and FAST V7

This forum if for discussing controls. Questions about how to implement controls in FAST are more appropriate to the CAE Tools forum.

Moderator: Bonnie.Jonkman

Bonnie.Jonkman
Posts: 564
Joined: Thu Nov 10, 2005 10:51 am
Organization: Envision Energy USA
Location: Colorado
Location: Boulder, CO
Contact:

Re: Beginner to Simulink and FAST V7

Postby Bonnie.Jonkman » Tue Jun 28, 2016 9:51 am

Hi, David.

I do not have the files from Dr. Namik. The first error indicates that one or more arguments to dpoly are empty. It looks like the w_cut variable is undefined. The other error refers something called Model_Inputs that is undefined. So, I would guess that you are missing a MATLAB script that defines some variables (including w_cut and Model_Inputs) that are needed for the Simulink model you are running.
Bonnie Jonkman

Envision Energy USA, 2016-
National Renewable Energy Laboratory, 2003-2016

David.Kolodziej
Posts: 20
Joined: Thu Apr 21, 2016 7:02 am
Organization: RWTH Aachen
Location: Germany

Re: Beginner to Simulink and FAST V7

Postby David.Kolodziej » Wed Jun 29, 2016 1:01 am

Hi Bonnie.

"It looks like the w_cut variable is undefined. The other error refers something called Model_Inputs that is undefined. So, I would guess that you are missing a MATLAB script that defines some variables (including w_cut and Model_Inputs) that are needed for the Simulink model you are running."


That was my assumption as well! I also thought that the "Model_Inputs error" only occurs because the w_cut variable is missing, but I dont know that for sure. Or could it also be that there is some kind of error in the extraction of "Genspeed" fromthe Output list? When you say "missing a MATLAB script that defines some variables that are needed for the Simulink model", what exactly do you mean? I am confused because I couldnt find the variable w_cut in any of the UserGuides! Guessing only by the name of the variable, it sounds like it is some kind of cut-off/filter variable! But where exactly do I define those variables (w_cut and Model_Inputs)? Do I need an additional Matlab script for it or would I make additions to one of the existing ones (like source codes, Simsetup, Read_FAST_input)?

Just to see if there are any additional errors in the model I deleted the "speed filter" block from the simulink model and the "Model_Inputs" variable from InitFcn (in the Model Properties window). Then I get the following error:

Input array cannot hold the number of inputs.
Aborting program.
Error while obtaining sizes from MEX S-function 'FAST_SFunc' in 'NREL5MW_Baseline_06b_TMD/FAST Nonlinear Wind Turbine/S-Function'.
Caused by:
Closing program.


I compiled the Fast_Sfunc exactly how it is described in the the make_FAST_Sfunc, that´s why I dont understand why Simulink has a porblem obtaining the sizes! Where exactly do I define the number of inputs/the input array? And how do I know the number of Inputs I need to define?

Thank you very much in advance,

David

Audrey.Viala
Posts: 14
Joined: Mon Jun 13, 2016 7:20 am
Organization: Cranfield university
Location: France

Re: Beginner to Simulink and FAST V7

Postby Audrey.Viala » Wed Jun 29, 2016 6:53 am

Hi Bonnie,

Thank you for your answer. I am trying to compile FAST_Sfun using Make_FAST_SFun.m file and matlab 32 bits.
I followed the instructions in the matlab script. But I have the following error:

>> make_FAST_SFunc
-> Options file specified on command line
----------------------------------------------------------------
-> Options file = intelf12msvs2010shellopts.bat
MATLAB = C:\Program Files (x86)\MATLAB\R2014a32
-> COMPILER = ifort
-> Compiler flags:
COMPFLAGS = /assume:byterecl /traceback /real_size:64 /Qzero /Qsave
OPTIMFLAGS = /O2 /DNDEBUG
DEBUGFLAGS = /Z7
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:MEXFUNCTION /LIBPATH:"C:\Program Files (x86)\MATLAB\R2014a32\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /implib:"C:\Users\AUDREY~1\AppData\Local\Temp\mex_Ha1Z6v\templib.x" /MAP:"FAST_SFunc.mexw32.map" /NOLOGO /manifest /INCREMENTAL:NO
LINKDEBUGFLAGS = /debug /PDB:"FAST_SFunc.mexw32.pdb"
LINKFLAGSPOST =
Name directive = /out:"FAST_SFunc.mexw32"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------


--> ifort /assume:byterecl /traceback /real_size:64 /Qzero /Qsave /FoC:\Users\AUDREY~1\AppData\Local\Temp\mex_Ha1Z6v\DoubPrec.obj /O2 /DNDEBUG -DMX_COMPAT_32 "C:\Users\Audrey Viala\Desktop\Fast v7\Source\NWTC_LIB\Source\DoubPrec.f90"

Intel(R) Visual Fortran Compiler for applications running on IA-32, Version 16.0 Build 20160415
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.

ifort: error #10037: could not find 'link'

C:\PROGRA~2\MATLAB\R2014A32\BIN\MEX.PL: Error: Compile of 'C:\Users\Audrey Viala\Desktop\Fast v7\Source\NWTC_LIB\Source\DoubPrec.f90' failed.

Unable to complete successfully..


I suppose there is a problem with my paths but I am lost between compiler paths, FAST paths and matlab paths...
I have intel fortran compiler with visual studio 2015.I am using MATLAB R2014a 32 bits.
I am not sure about "LINKER=link"
Could you clarify this point for me please?

Thank you very much in advance.

Best regards,
Audrey

Bonnie.Jonkman
Posts: 564
Joined: Thu Nov 10, 2005 10:51 am
Organization: Envision Energy USA
Location: Colorado
Location: Boulder, CO
Contact:

Re: Beginner to Simulink and FAST V7

Postby Bonnie.Jonkman » Wed Jun 29, 2016 10:05 am

Hi, Audrey.

If the script can't find the link command, that means the path/include/lib variables in your options .bat file are not set properly. I have found the easiest way to fix this is to copy the variables that the Intel Command Prompt window sets for you.

Open the Intel command prompt (see FAST v7 compiling instructions for descriptions of where you can find this on your computer). In that command window that opens, change to a directory where you have write permissions, then type this:

Code: Select all

echo SET TmpPath=%PATH%; >> opts.out
echo SET TmpIncl=%INCLUDE%; >> opts.out
echo SET TmpLib=%LIB%; >> opts.out
This will append three lines to a file called opts.out (you can name it whatever you want, just make sure you don't overwrite anything important).
Open the opts.out file, copy those three lines, and then paste them into your FortranOptionsFile (the batch script specified in make_FAST_SFunc.m) before the three lines that start with

Code: Select all

SET PATH=
SET INCLUDE=
SET LIB=


Now, take a close look at the PATH, INCLUDE, and LIB variables specified in the FortranOptionsFile. Each entry in those lines is separated by a semicolon; Remove each entry in those three lines that doesn't contain the word "MATLAB". In my case, that leaves me with:

Code: Select all

SET PATH=%MATLAB_BIN%;
SET INCLUDE=
SET LIB=%MATLAB%\extern\lib\win32;


Then, I add the paths that the Intel Command Window gave me, so my final section of code will look something like this:

Code: Select all

SET TmpPath=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Progra...
SET TmpIncl=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 1...
SET TmpLib=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 12.0\V...

SET PATH=%MATLAB_BIN%;%TmpPath%;
SET INCLUDE=%TmpIncl%;
SET LIB=%MATLAB%\extern\lib\win32;%TmpLib%;
Note that I didn't copy the full TmpPath, TmpIncl, and TmpLib variables here because they are very long. You should obviously copy the full set of paths.
Bonnie Jonkman

Envision Energy USA, 2016-
National Renewable Energy Laboratory, 2003-2016

Bonnie.Jonkman
Posts: 564
Joined: Thu Nov 10, 2005 10:51 am
Organization: Envision Energy USA
Location: Colorado
Location: Boulder, CO
Contact:

Re: Beginner to Simulink and FAST V7

Postby Bonnie.Jonkman » Wed Jun 29, 2016 10:18 am

David,

You are using a model that was not developed at NREL, and our User's Guides will not cover details that are specific to other people's models. I have never seen the TMD model or the FAST-SC documentation, so I can only guess.

I have seen some models where the Simsetup.m file calls other Matlab scripts to set variables specific to the Simulink model being run. You probably could add these parameters to Simsetup.m, but it's also possible the missing Matlab script does other things, too.

The "Input array cannot hold the number of inputs" is generated in FASTGateway.f90 (FAST v7). The (NREL) FAST_SFunc assumes there are 2 Generator + 2 Yaw + NumBl blade pitch + 2*NDOF (q, qdot) inputs. If the number of inputs to the FAST_SFunc block in Simulink does not match those values, it aborts. Perhaps the version you are using is different, but that is what is in the code NREL distributes.
Bonnie Jonkman

Envision Energy USA, 2016-
National Renewable Energy Laboratory, 2003-2016

Audrey.Viala
Posts: 14
Joined: Mon Jun 13, 2016 7:20 am
Organization: Cranfield university
Location: France

Re: Beginner to Simulink and FAST V7

Postby Audrey.Viala » Thu Jun 30, 2016 8:23 am

Hi Bonnie!

Thank you so much for your help! I have succeded in compiling FAST_SFun mex file.
Now, I will try to use it in simulation to see if the problem with Matlab persists.

Best regards.
Audrey

Audrey.Viala
Posts: 14
Joined: Mon Jun 13, 2016 7:20 am
Organization: Cranfield university
Location: France

Re: Beginner to Simulink and FAST V7

Postby Audrey.Viala » Thu Jun 30, 2016 9:18 am

Hi Bonnie,

I have looked further the simulation with Simulink and FAST v7 and I have a small question.
Why the parameter "initialized" decrease from 1 to 0 after a simulation?

I have realized that after setting this parameter to 1 and run again a simulation, there is no problem whereas if I let this parameter with the 0 value Matlab is closed.
In the file "Read_FAST_Input.m we can read:

Code: Select all

Initialized = 1;                                    % Tells S-function if this script ran prior to simulation.  0 = no.

Is it the FAST_SFun which changes this parameter? And why? It seems causing some problems to run a second simulation without setting to 1 after the first one.

I don't know if I am very clear but I think it can be the origin of my issue with FAST v7 and Simulink simulation.

Regards,
Audrey

Bonnie.Jonkman
Posts: 564
Joined: Thu Nov 10, 2005 10:51 am
Organization: Envision Energy USA
Location: Colorado
Location: Boulder, CO
Contact:

Re: Beginner to Simulink and FAST V7

Postby Bonnie.Jonkman » Thu Jun 30, 2016 9:27 am

The FAST v7 S-Function does change the initialized variable to 0 after initialization. It also checks that it is 1 before it will run. The idea is to make sure you have called Read_FAST_Input.m in Matlab each time you start a model, which makes sure the variables in the Matlab workspace are consistent with the internal variables of the S-Function. If you are running the same model again (using the same, unchanged, FAST input file), it should be okay to reset the initialized variable to 1 without running Read_FAST_Input. The way it was developed, though, it assumes you use Simsetup.m each time you start a model.
Bonnie Jonkman

Envision Energy USA, 2016-
National Renewable Energy Laboratory, 2003-2016

Audrey.Viala
Posts: 14
Joined: Mon Jun 13, 2016 7:20 am
Organization: Cranfield university
Location: France

Re: Beginner to Simulink and FAST V7

Postby Audrey.Viala » Fri Jul 01, 2016 7:11 am

Hi Bonnie,

Thank you for your explanation.
With all your instructions I have compiled FAST_SFunc for both 32 and 64 bits.
However, when I try to use them, MATLAB is crashed.

I am trying to run a simulation with the NRELOffshrBsline5MW_OC3Hywind but it does not worked. I don't really understand what you said in another post: "FAST v7 as distributed does not run the 5MW models. The primary reason is that the Bladed-style DLL controller requires a separate compilation. If you want to run the 5MW model in Simulink, you'll have to recompile FAST_SFunc using the appropriate source files for the Bladed Interface. " from viewtopic.php?f=4&t=908&hilit=Read_FAST_input&start=15
1) How can I use the appropriate DLL file during the compilation?

I have tried to use the one available in the OC3 file: FAST_v7.02.00d-bjj_AeroDyn_v13.00.02a-bjj_BladedDLLInterface_OC3Hywind by remplacing the FAST bladed DLL but the FAST_SFUNC mex after compilation is the same.
2) How can I use the three following files included in the OC3 folder?
- FAST_v7.02.00d-bjj_AeroDyn_v13.00.02a-bjj_BladedDLLInterface_OC3Hywind
-DISCON.dll
- DISCON.f90

I feel desperate because I am not able to run a linearization of the OC3 model...
Thank you very much for your help.
Audrey

Mansour.Alkmim
Posts: 1
Joined: Wed Dec 14, 2016 12:25 pm
Organization: University of Brasília
Location: Brazil

Re: Beginner to Simulink and FAST V7

Postby Mansour.Alkmim » Wed Dec 14, 2016 4:56 pm

Dear Bonnie,

I have encountered the same problem as Audrey. I am using Matlab 2016b 64 bits. I have read the FAST v8 Interface to Simulink from README_FAST8 pdf and did as follows:

- created the FAST_SFunc.mexw64 using create_FAST_SFunc.m
- add %FAST_v8\bin to MATLAB path

then I tried running the two samples from %Simulink\Samples.

In both cases matlab crashes (with system error). The OpenLoop file gives the following error message:

Error using Run_OpenLoop (line 30)
Error while obtaining sizes from MEX S-function 'FAST_SFunc' in 'OpenLoop/FAST Nonlinear Wind Turbine/S-Function'.
Caused by:
Error using Run_OpenLoop (line 30)
FatalException

Sami.Khan
Posts: 5
Joined: Tue Feb 14, 2017 4:38 am
Organization: Fraunhofer IWES
Location: Germany

Re: Beginner to Simulink and FAST V7

Postby Sami.Khan » Thu Feb 23, 2017 5:56 am

Hello Everyone,

I am posting on this thread because I have a similar query and I am a beginner with Fast v7.
I am following a documentation from NREL "Simulation for Wind Turbines Generator - With Fast and Matlab-Simulink Module"
http://www.nrel.gov/docs/fy14osti/59195.pdf

During the time I was following the above documentation in the section 4.1.2 I took all the steps necessary to do interface the induction generator in to the Test01_Sig model, and also make the constant as it is in the documentation.

But when I am trying to run my simulation I get these errors. I don`t know what mistake I am doing.
Below is the error when I am trying to run the simulation

[img]
Untitled.png
[/img]


Below is the Simulink file related to it and also the m file

[img]
3.png
[/img]
[img]
2.png
[/img]

Regards,
Sami
Attachments
3.png
Simulink Induction Generator
3.png (149.18 KiB) Viewed 7135 times
Untitled.png
Error
Untitled.png (124.2 KiB) Viewed 7135 times
2.png
Test01 Sig
2.png (145.65 KiB) Viewed 7135 times

Jason.Jonkman
Posts: 4843
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Beginner to Simulink and FAST V7

Postby Jason.Jonkman » Thu Feb 23, 2017 7:22 am

Dear Sami,

Your error is regarding a Tmech, which is part of the induction generator model, not provided by NREL. I suggest that you contact the source of this induction generator model for help.

Best regards,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

Sami.Khan
Posts: 5
Joined: Tue Feb 14, 2017 4:38 am
Organization: Fraunhofer IWES
Location: Germany

Re: Beginner to Simulink and FAST V7

Postby Sami.Khan » Thu Feb 23, 2017 7:42 am

Dear Jason,

thanks for your quick reply the problem is solved. By completely deleting the tmech and put a constant of 0 instead of it.

Thanks anyways

Georgios.Gasparis
Posts: 9
Joined: Thu Sep 20, 2018 9:19 am
Organization: self
Location: Netherlands

Re: Beginner to Simulink and FAST V7

Postby Georgios.Gasparis » Fri Oct 12, 2018 10:47 am

Dear All,

I am an MSc student and I am trying to simulate the NREL 5.0 MW Baseline Wind Turbine, including torque and pitch control using Simulink. I have troubles in this procedure, since it is not so clear to me. As I understand, all the information about the controllers is in the DISCON.dll file that is also included in the .zip file found in http://wind.nrel.gov/public/jjonkman/NRELOffshrBsline5MW/. Please correct me if I am wrong.

In order to use these controllers I run Simsetup.m and then OpenLoop.mdl. I added in the same folder the files: FAST_SFunc.mexw64, FAST_Library_x64.dll and MAP_x64.dll from FAST v8. I initially used FAST_SFunc.mexw64 from v7.02, but OpenLoop.mdl gave me errors. Finally, after running OpenLoop.mdl, I derive the following error:

OpenLoop_Error.png
OpenLoop_Error.png (11.56 KiB) Viewed 4163 times

My questions are the following:

1) How can I solve this error?
2) Is any other way to use the information of the DISCON.dll apart from using Simulink?
2) Is it correct to use the files I mentioned before from FAST v8?
3) Since I am simply running the OpenLoop.mdl, should I change anything in it?

Thank you very much for your time!

Best regards,

Georgios

Jason.Jonkman
Posts: 4843
Joined: Thu Nov 03, 2005 4:38 pm
Location: Boulder, CO
Contact:

Re: Beginner to Simulink and FAST V7

Postby Jason.Jonkman » Fri Oct 12, 2018 2:27 pm

Dear Georgios,

You shouldn't need to change anything to run the OpenLoop.mdl. Are you running the OpenLoop.mdl distributed with FAST v8 or FAST v7? When you open the FAST_SFunc block in Simulink, do you see three S-Function parameters (FAST_InputFileName, TMax, 0), as shown in Figure 9 of the FAST v8 ReadMe file: https://wind.nrel.gov/nwtc/docs/README_FAST8.pdf (it should look just like Figure 9 if you are using the OpenLoop.mdl provided with FAST v8)?

Regardless, you don't need to use the Simulink interface at all if you want to use a controller implemented as a DISCON.dll. The Simulink interface is meant to be used for implementing the controller within Simulink. If you want to use a controller implemented as a DISCON.dll, I would suggest running the FAST executable instead.

Best regards,
Jason Jonkman, Ph.D.
Senior Engineer | National Wind Technology Center (NWTC)

National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway | Golden, CO 80401
+1 (303) 384 – 7026 | Fax: +1 (303) 384 – 6901
nwtc.nrel.gov


Return to “Controls”

Who is online

Users browsing this forum: No registered users and 1 guest