Hello,
I try to use the matlab toolbox in order to call OpenFast from MATLAB.
First, I run the example (I have changed the path of openfast.exe & the .fst file) but it gives me an error.
The figure below shows the error i obtain.
Does anyone encounter the same problem ?
Best Regards,
Riad
Dear @Riad.Elhamoud,
I don’t see that you’ve shared the code you are using to call OpenFAST from MATLAB; please clarify.
Best regards,
1 Like
Dear @Jason.Jonkman ,
Thank you for your reply. You can find below the code that i am using (i put the code in bold and sorry it is messy: it contains a lot of comments):
**%% Documentation **
% Example script to run a set of FAST simulations using FAST exe.
%
**% NOTE: This script is only an example. **
% The example data is suitable for a given version of OpenFAST and might need to be adapted
**% **
% Adapt this script to your need, by calling the different subfunctions presented.
%
%% Initialization
restoredefaultpath;
addpath(genpath(“C:\Users\1oRs5\Desktop\these_dr_rabih\thèse_dr_rabih\MDOF_calcul\matlab-openfast-toolbox\matlab-toolbox-main\Utilities”)); % TODO adapt me
%% Parameters
FASTexe=“C:\Users\1oRs5\Desktop\openfast\openfast_x64.exe”;
% FASTexe = ‘…/…/_ExampleData/openfast3.0_x64s.exe’; % path to an OpenFAST executable
OUText = ‘.outb’; % Output extension
FSTfilenames=“C:\Users\1oRs5\Desktop\openfast\r-test-061441958a2eef7f494d69ee097f8ec050d5a129\glue-codes\openfast\5MW_OC3Spar_DLL_WTurb_WavesIrr\5MW_OC3Spar_DLL_WTurb_WavesIrr.fst”;
% FSTfilenames={ % path to OpenFAST input files
% ‘…/…/_ExampleData/5MW_Land_Simulations/Main_5MW_Land_8mps.fst’,
% ‘…/…/_ExampleData/5MW_Land_Simulations/Main_5MW_Land_10mps.fst’,
% };
**%% Run FAST an all fst files **
runFAST(FSTfilenames, FASTexe); %, ‘flag’,‘-VTKLin’);
%% List of output files
OUTfilenames = cellfun(@(s)strrep(s,‘.fst’,OUText), FSTfilenames, ‘UniformOutput’,false);
for i = 1:length(OUTfilenames)
** if ~exist(OUTfilenames{i},‘file’)**
** warning(‘Simulation failed: %s’, FSTfilenames{i})**
** end**
end
Best Regards,
Riad
Try putting your input filename in a cell array, i.e.:
FSTfilenames={“C:\Users\1oRs5\Desktop\openfast\r-test-061441958a2eef7f494d69ee097f8ec050d5a129\glue-codes\openfast\5MW_OC3Spar_DLL_WTurb_WavesIrr\5MW_OC3Spar_DLL_WTurb_WavesIrr.fst”};
Best regards,
Thank you for your reply !
I tried your suggestion but unfortunately, it does not work ![:frowning: :frowning:](https://emoji.discourse-cdn.com/twitter/frowning.png?v=12)
I ran through Mathworks forums: i left FSTfilenames without brackets and i make changes in runCommands
I replace the commented expression by the expression right below (i add brackets). But, always, i have an error.
Best Regards,
Riad
To debug, you can remove the semicolon ;
from line 25 (where you set sCmd
) in the runCommands.m
function. It might be better to debug what commands are getting generated in runFAST.m
so that you can see what command and filenames are being sent to runCommands
.
![image](https://europe1.discourse-cdn.com/nrel/original/2X/3/3640a3bc837dc64b74988e5c6651b95ea8d2d6fb.png)
However, I suspect the problem is that you have used double quotes " "
instead of single quotes ' '
in creating the cell array of FSTfilenames
. The double quotes creates a string object instead of a character array. (Notice that the example uses the form FSTfilenames={'…/…/_ExampleData/5MW_Land_Simulations/Main_5MW_Land_10mps.fst'}
1 Like
Dear @Bonnie.Jonkman and community,
The function runFAST.m in the matlab toolbox : matlab-toolbox/Utilities/runFAST.m at main · OpenFAST/matlab-toolbox · GitHub should be modified. In its current syntax, it does not work when i try to execute it using MATLAB R2021a.
In the function, line 47 which is:
sCmd= [FASTexe ’ ’ opts.flag ’ ’ FASTfile];
should be replaced by:
sCmd= strcat(FASTexe," “,opts.flag,” ",FASTfile);
After the modification, it works for me. Here a screen capture:
Best Regards,
Riad
Dear @Riad.Elhamoud,
Thanks for sharing. I’m not sure why the original calculation of sCmd
does not work (what does the calculation set sCmd
to?), but if the new calculation solves the problem; great!
Best regards,
1 Like