I am currently building a model of the NREL 5 MW offshore wind turbine on Matlab.
To reduce my long computational times I am trying to implement parallel computing.
However, MoorDyn does not seem to work.
My code runs perfectly when using standard “for” loops but when I change these to “Parfor” loops (parallel computing) the console window for MoorDyn appears empty and MoorDyn does not initialize, however, it does not report a failure to initialize.
Any help regarding this would be very much appreciated.
I will attach a similar loop below which represents the issue:
parfor i = 1:3
[notfound,warnings] = loadlibrary('MoorDyn','MoorDyn'); % load MoorDyn DLL
mooring_status = calllib('MoorDyn','LinesInit',zeros(6,1),zeros(6,1)); % initialize MoorDyn
if mooring_status ~= 0
error('MoorDyn unable to load');
disp('MoorDyn loaded successfully');
I haven’t used Matlab in a long time and am not familiar with its parallel computing abilities, but you’re probably experiencing a fundamental limitation of the version of MoorDyn that you’re using. It looks like you’re using a relatively recent version of the C++ one, though I can’t guess exactly how recent from the information you provided. MoorDyn in C++ was previously set up assuming it would only be called once. In the last handful of months, an external developer made some changes that I believe would make it more robust for parallel use. However, that hasn’t been confirmed yet to my knowledge. Also, it’s hard to tell exactly how Matlab handles DLLs and there’s a chance that the issue is actually related to Matlab’s memory handling when working with DLLs in this parallel way. (I’m just guessing - if you have knowledge/experience about that please let me know.)
All this being said, if you are modeling the coupled dynamics of a floating wind turbine in Matlab, I would be very surprised if MoorDyn was your computation time bottleneck. I would bet that running a single instance of MoorDyn would be a much smaller computation expense than most other parts of the code.
Let me know if you’re still working on this and have follow-up questions or observations. I’m hoping that we will be able to make some long-awaited fixes to the C++ version of MoorDyn in the months ahead.
Thanks very much for your response,
You are right that MoorDyn was not the part of the code causing the bottleneck, however MoorDyn was required to be run in parallel to allow the other parts of the code to also run in parallel.
I was using the 2017 version of MoorDyn and have since updated it to the 2021 version.
It seems to have resolved the issue with MoorDyn however there are more issues arising from Dot indexing which has nothing to do with MoorDyn so I’m not sure if it is 100% working.
Thanks very much for your help and I will let you know if I get any further with this.