OpenFAST / openfast

Main repository for the NREL-supported OpenFAST whole-turbine and FAST.Farm wind farm simulation codes.
http://openfast.readthedocs.io
Apache License 2.0
688 stars 457 forks source link

After compiling OpenFAST and running it in MATLAB, it crashes! #2172

Closed WS991106 closed 5 months ago

WS991106 commented 6 months ago

Dear @jjonkman ,

I've been learning about OpenFAST compilation recently, and after I compile it according to the guidebook on the official website, I open Run_OpenLoop inside Simulink, and then after writing the address of the .fst file and clicking OK, MATLAB just flashes and crashes straight away to the point that I can't see what's wrong, so I thought I'd come and ask you about it. The compiled file is attached.

Best regards, Wangshuai 1713878539749 1713878548886

jjonkman commented 6 months ago

Dear @WS991106,

I don't see the _FASTSFunc.mex64 file in your list (perhaps it is cut-off)? Have you compiled this yourself too?

Does the OpenFAST-Simulink interface work for you if you use the precompiled FAST_SFunc.mex64 and OpenFAST-Simulink_x64.dll binaries available through the NREL release of OpenFAST: https://github.com/OpenFAST/openfast/releases?

Best regards,

WS991106 commented 6 months ago

Dear @jjonkman ,

On my side it shows that it is inside the image, maybe it is cut-off, this thing is compiled by myself with create_FAST_SFunc.m. However, it is working fine for me with the pre-compiled file provided on the official website, so I don't know what the problem is. Then I also want to ask if the compilation process needs to recompile FAST_SFunc.mex64 and OpenFAST-Simulink_x64.dll if I want to do active mooring control to modify the underlying code?

Best regards, Wangshuai 1713930533003

jjonkman commented 6 months ago

Dear @WS991106,

I'm not sure what the issue is with the versions of the _FASTSFunc.mex64 and _OpenFAST-Simulinkx64.dll binaries that you compiled yourself. Did you change the source code in any way before compiling?

OpenFAST does not currently support a active mooring control though the Simulink interface (active mooring control through the controller DLL is standard), so, if you want that functionality, you'd have to modify the source code and recompile.

Best regards,

WS991106 commented 6 months ago

Dear @jjonkman ,

Before I compiled it there was no modification of the source code, it was all compiled and installed according to the files on Github, because after running Matlab is crashing directly without reporting errors, so it has been bothering me to know what the problem is.

I know OpenFAST doesn't know about active mooring control, I mean if I want to modify the source code when recompiling the FAST.sln file, do I have to build all the following five solutions or do I not need to rebuild OpenFAST-Simulink? If I don't need to rebuild OpenFAST-Simulink, I would like to use the github pre-compiled OpenFAST-Simulink_x64.dll file. 1714273321214(1)

Best regards,

bjonkman commented 6 months ago

If you modify any source files in the FASTlib or OpenFAST-Simulink projects, you will need to build the .dll file again (instead of using the file distributed with OpenFAST). There are a few different ways you can build the files for Simulink. Can you describe your process here, and include which versions of compilers and Matlab you are using?

WS991106 commented 6 months ago

Dear @bjonkman ,

Sorry for not replying to your message in time, what do I need to recompile if I want to change the code in the MoorDyn.f90 file? The compiler I am using is VS2019 and Matlab is 2022a.

Best regards,

WS991106 commented 5 months ago

Dear @bjonkman ,

My compilation process is as follows, could you please take a look to see if there is any error? I have set up the five solutions in the configuration manager as follows. 1715155087900

After that the solution is generated and it will show 5 successes, then I use Matlab to generate the FAST_SFunc.mex64 file. After success run Run_OpenLoop.m, it will just crash.

bjonkman commented 5 months ago

You should be using the Release_Matlab | x64 configuration that is already set in the Visual Studio files in the GitHub repo: image I would not build the OpenFAST-Simulink project in the Release | x64 configuration you are showing since there are a few differences in the FASTlib configurations for Release and Release_Matlab.

The only thing you may have to change in the Visual Studio setup files is the location of the Matlab libmex library, which will change depending on which version of Matlab you have installed: image

WS991106 commented 5 months ago

Dear @bjonkman

Thank you so much for your help, the Matlab crash problem has been solved, thank you very much indeed!

Best regards,