question about running in MATLAB

Dear Jason,

I wrote a for loop program in MATLAB to call OpenFAST to find a optimal value for the controller. But when the loop times exceeds 450, MATLAB will close by itself without any warning(MATLAB will automatically exit). But when I tune the loop times less than 450, the program will work well and give me an answer. So I wonder if the source code of OpenFAST has a limit on the times of calls.

Best regards.

Dear Zhiheng.Liu,

There should not be a limit to the number of times OpenFAST can be called.

Can you clarify how you are calling OpenFAST? Is it through a system call to the binary executable or you are you calling the OpenFAST S-Function through Simulink? Is memory usage on your computer increasing over time as you run more and more simulations?

Best regards,

Dear Jason,

I called OpenFAST through the s-function in the Simulink, when the loop times increased, the memory usage almost stayed the same. Because I called the Simulink in the sub function, I think the memory will be freed after the sub function call, so the memory will not increase as the loop times increase. So I have no idea why the MATLAB will close by itself.

Best regards.

Dear Zhiheng,

How are you stopping the simulation before starting the next one? The following forum topic discussed a possible memory leak in the S-Function when stopped improperly: http://forums.nrel.gov/t/question-about-running-fast-8-in-simulink/1783/4.

Best regards,

Dear Jason,

I just used “sim” instruction to call OpenFAST through Simulink. here is the code I wrote in the sub function:

[code]function f=BAS_PID1(x)
k1 = 1;
k2 = 0.08;
k3 = 0.03;
sim(‘C:\Users\msi\Desktop\fuzzga\OPENFASTGAtest.slx’);
for i=1:1:12000
wind(i,:slight_smile: = OutData(i,2);
mx(i,:slight_smile: = OutData(i,5);
my(i,:slight_smile: = OutData(i,6);
mz(i,:slight_smile: = OutData(i,7);
end

mtimx1 = mtimxcal(mx);
mtimy1 = mtimxcal(my);
mtimz1 = mtimxcal(mz);
delmx1 = delmxcal(wind,mx);
delmy1 = delmxcal(wind,my);
delmz1 = delmxcal(wind,mz);
error = abse.Data(12000,1);

f = k1*(mtimx1+mtimy1+mtimz1)+k2*(delmx1+delmy1+delmz1)+k3*error

clear OutData Time DT OutList;

end[/code]
I think the close of OpenFAST is done by the Simulink.

Best regards.

Dear Zhiheng,

I’m not sure. Are you sure that it is OpenFAST that is causing the problem? What if your for loop does nothing more than call the SIM() function?

If it is OpenFAST that is the problem which version of OpenFAST are you using and how did you compile the S-Function?

Best regards,

Dear Jason,

I am not sure where the problem is. But I have changed the other model(not OpenFAST model,just a simple second order system) to test my code, the program ran well and gave me an answer.

I use version 2.4.0, and I found 3.0.0 in the github. I downloaded it from github, but when I ran 3.0.0, Simulink threw out an error, the test cases which can be used in 2.4.0 can’t not be used in the 3.0.0, So where can I find the cases which can be used in the 3.0.0 ?

Best regards.

Dear Zhiheng,

Are you referring to the r-test (what was formerly called the CertTest in FAST v8)? The r-test or OpenFAST v3.0.0 is available here: github.com/OpenFAST/r-test/releases.

Best regards,