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

Compling OpenFAST with Simulink in VS error #11023 and LNK2019 #676

Closed
klitz06 opened this issue Mar 4, 2021 · 31 comments
Closed

Compling OpenFAST with Simulink in VS error #11023 and LNK2019 #676

klitz06 opened this issue Mar 4, 2021 · 31 comments

Comments

@klitz06
Copy link

klitz06 commented Mar 4, 2021

Hi ,
I am trying to build OpenFAST with simulink by choosing Release_Matlab mode with x64. I think errors that I am having is due to simulink linking as you can see from the errors. I am not sure about the warnings if they are problem for compiling or not.

1
2
3

I have changed the MATLAB libmex.lib location in simulink properties as written #638 (comment) in another post. It doesnt solve the problem unfortunately. Below you can see what i have installed in VS and Intel Fortran

4
5
6

@andrew-platt
Copy link
Collaborator

Visual studio is not finding the Matlab library that contains MEXPRINTF. You may need to tell visual studio where that is located.

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

Visual studio is not finding the Matlab library that contains MEXPRINTF. You may need to tell visual studio where that is located.

If you are talking about MATLAB path inside the properties I have changed it to my MATLAB path as I mentioned. If not how do I change it?
7

@andrew-platt
Copy link
Collaborator

Looking at your first output screenshot, it didn't find the MEXPRINTF during the compilation of openfast_x64.exe. I'm not sure VS should be building that one during the Release_Matlab build. @bjonkman , do we normally build openfsat_x64.exe with this? I would have thought all the preprocessor defs would render that executable useless.

It does look like it found the appropriate library for the OpenFAST-Simulink_x64.lib build. So I expect that one should work with simulink.

@andrew-platt
Copy link
Collaborator

@klitz06, which branch are you building?

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

I used " git clone https://github.com/openfast/openfast.git " to clone the repository. I dont know which one is it. How do I check it?

Edit:
git branch --show-current in git for windows tells me it is "main".

@andrew-platt
Copy link
Collaborator

git branch will show the available branches. It will show main and dev as the two options, and the one you built will be highlighted (or have a star next to it). I think main is the default one.

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

Yes it is main one.

@andrew-platt
Copy link
Collaborator

What happens if you try the create_FAST_SFunc.m script (after setting any paths necessary as mentioned in the script)? It should only be needing that OpenFAST-Simulink_x64.lib for linking to Simulink, and not the openfast_x64.exe.

The other warnings can be safely ignored (we mostly follow the Fortran 2008 standard, but only set VS to enforce the Fortran 2003 standard, so it flags stuff that isn't actually an issue).

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

I think it is succesfully created. I will try the examples and get back.

image

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

OK I tried to run Ren_Test01_SIG.m and this is the result:
image

I changed VSContrl = 4 and to see if it helps added LSSGagVxa to the ElastoDyn outputs. It didnt help.

@andrew-platt
Copy link
Collaborator

you may have to add the location of the SFunc to the matlab path. addpath(genpath(('../../../install')) from the examples directory.

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

I am sorry I couldn't understand what you want me to do. Do I just run it through command window?

@andrew-platt
Copy link
Collaborator

yes. I was thinking in the command window. but the error might be indicating a problem with the test itself.

Did you initialize the r-test submodule after cloning from github? git submodule update --init --recursive as outlined here: https://openfast.readthedocs.io/en/dev/source/testing/index.html

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

Yes I actually ran git clone --recursive https://github.com/openfast/openfast.git at the beginning of the process could it be the problem? Should I use the command you give?

@andrew-platt
Copy link
Collaborator

does <openfast git rootdir>/reg_tests/r-test/glue-codes/openfast/AWT_YFix_WSt/ exist?

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

Yes it exists. I can see the input files in the folder.

@andrew-platt
Copy link
Collaborator

I'm not sure then. I'm at a loss for ideas. Maybe someone else can comment on with what they ran into with this.

@klitz06
Copy link
Author

klitz06 commented Mar 4, 2021

Thank you for your help. Could be from my MATLAB installation? Because I did not install everything that comes with MATLAB.

Edit: Ofcourse Simulink is installed.

@andrew-platt
Copy link
Collaborator

so after some testing, I can reproduce the error you are seeing using MATLAB 2020b with simulink on a windows 10 VM. This was using the main branch of OpenFAST.

Screen Shot 2021-03-04 at 6 04 32 PM

I had forgotten to mention that there was a bugfix #641 for this problem. The bug description was given in #632. This fix has been merged to the dev branch, but has not made it into the main branch yet. My apologies for not remembering this earlier.

So could you try git checkout dev then git submodule update, then rebuild and try again?

@klitz06
Copy link
Author

klitz06 commented Mar 5, 2021

Now OpenFAST runs through MATLAB but now I have this error:

image

Edit: I didnt re-compile through VS after switching to dev branch. I will try it now.

@klitz06
Copy link
Author

klitz06 commented Mar 5, 2021

After downloading dev branch from scratch compilation completed without error. Same warnings are present and MATLAB example Test01 works. Other one didnt work due to not having DISCON.dll.

@klitz06
Copy link
Author

klitz06 commented Mar 5, 2021

Im using NREL 5MW as my base(tower and nacelle is same) and it works well with conda in WSL. When I want to try running my own designed WT through MATLAB with Run_OpenLoop.m I face some problems first:
image
Then I changed TwrShadow from True to 1, I passed this error although this will probably cause problems in next steps. After this I get the below error:
image

And I am stuck here. Is this related to my input files? Because I was able to run AWT_YFix_WSt through Run_OpenLoop.m. The reason I want to use MATLAB is because I will design a pitch controller otherwise I would use OpenFAST with conda in WSL.

@andrew-platt
Copy link
Collaborator

andrew-platt commented Mar 5, 2021

Yes. There was an input file change between v2.5.0 and the dev branch (we added another tower shadow model). The conda + WSL is using v2.5.0, but your compiled version is on the dev branch. You can do a git checkout main; git submodule update and recompile your local copy to get the v2.5.0 version, but as I recall from the conversation above, you won't get the error handling bugfix that is in the dev branch. So for your case, you probably want to stick with the dev branch and update the necessary input files.

This input file change is noted in the second table Modified in OpenFAST dev found here https://openfast.readthedocs.io/en/dev/source/user/api_change.html

@klitz06
Copy link
Author

klitz06 commented Mar 5, 2021

I have two more question. Are any test cases where pitch angle is controlled through simulink? And description of cases?

@jjonkman
Copy link
Collaborator

jjonkman commented Mar 6, 2021

Dear @klitz06,

There are no Simulink examples like that in the OpenFAST repo, but you may find the Simulink version of the ROSCO controller of interest: https://github.com/NREL/ROSCO_toolbox.

Best regards,

@klitz06
Copy link
Author

klitz06 commented Mar 6, 2021

Thank you.

@jjonkman jjonkman closed this as completed Mar 8, 2021
@LaurenceWETI
Copy link

Hello everyone,

I’ve got an error as AeroDyn trying to read TwrShadow, although the tower shadow switch is set to 0.

TwrShadow

Anyone familiar with such error?
Best regards.

@jjonkman
Copy link
Collaborator

Dear @LaurenceWETI,

As with any input file processing issue, I recommend enabling the Echo option to debug. Do you see any problems in your input file when comparing it with the corresponding Echo file?

Does setting TwrShadow = FALSE solve the problem?

Best regards,

@andrew-platt
Copy link
Collaborator

@LaurenceWETI

Version 2.5.0 that you are running uses a boolean flag for the TwrShadow input. As @jjonkman suggested, this should be either True or False

The version dev uses a switch with values of 0,1,2 with the addition of a second tower shadow model.

@LaurenceWETI
Copy link

Dear @jjonkman and @andrew-platt,

Thank you for your quick reply.
Setting TwrShadow to True or Flase solved the Problem in AeroDyn, but now ServoDyn has a problem with reading CompNTMD. I could not find this parameter in the input file of ErvoDyn.

ServoDyn

Do you have any idea how to solve this error?
Is there any instructions how to switch to the dev version, in order to use the tower shadow switch again?

Best regards,

@klitz06
Copy link
Author

klitz06 commented Mar 15, 2021

Yes, they changed that part in the servodyn files in dev branch. Here take a look at master branch of NREL 5mw link in the TUNED MASS DAMPER section of the file.

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

4 participants