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
672 stars 454 forks source link

About HydroDyn #1897

Open b100mmm opened 9 months ago

b100mmm commented 9 months ago

Dear guys, I would like to know how to call HydroDyn's dynamic link library in matlab. Or how to use HydroDyn alone in matlab.

Thanks!

jjonkman commented 9 months ago

Dear @b100mmm,

I'm not aware that NREL has compiled the standalone HydroDyn driver as a dynamic link library, although I'm sure that would be possible, similar to how we've compiled OpenFAST as a dynamic link library. I'm not sure what application you have in mind.

You can always call an executable like OpenFAST or the compiled standalone HydroDyn driver from MATLAB, e.g., using the runFAST.m script from the MATLAB Toolbox: https://github.com/OpenFAST/matlab-toolbox/blob/main/Utilities/runFAST.m.

Best regards,

andrew-platt commented 9 months ago

There is a HydroDyn interface library that can be compiled as a DLL (HydroDyn_C_Binding). However, this is not a full HydroDyn driver as it is designed to be interfaced with and called by some other code. There are some small Python examples of how this interface works (module level regression test examples which use the hydrodyn_library.py interface), but these are not complete codes.

Since the HydroDyn_C_Binding interface DLL uses a standard C bindings interface, it should in theory be possible to call directly from MATLAB (through a mex funtion interface on the MATLAB side). However, we do not provide any guidance or examples on how to do this as we do not have the resources to do so.

So your options for using HydroDyn directly with MATLAB are:

  1. develop the appropriate mex function interface and calling code in MATLAB (our apologies that we are unable to provide direct support for such an endeavor). If you do develop such a mex function and would like to contribute it to the OpenFAST community, we would be more than happy to include it as an example for other users (however, we may not be able to maintain it when interfaces are updated).
  2. Call the HydroDyn executable from MATLAB as mentioned by @jjonkman in the above comment.

Regards,

b100mmm commented 9 months ago

Thank you for your reply! Is the compiled standalone HydroDyn driver ‘HydroDynDriver_x64.exe’ in Releases? And I want to use HydroDyn module alone in matlab for hydrodynamic calculations. What should I do with this compiled standalone HydroDyn driver (if the compiled standalone HydroDyn driver is ‘HydroDynDriver_x64.exe’) in matlab?