Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated examples for OpenFAST-Simulink Interface #577

Merged
merged 3 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 9 additions & 29 deletions glue-codes/simulink/examples/Run_OpenLoop.m
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
% make sure the FASTv8\bin directory is in the MATLAB path
% make sure the OpenFAST directory where the FAST_SFunc.mex* file is located
% is in the MATLAB path (also make sure any other OpenFAST library files that
% are needed are on the MATLAB path)
% (relative path names are not recommended in addpath()):
% addpath('C:\Users\bjonkman\Documents\CAETools\FASTv8\bin');
% addpath('../../../build/bin'); % install location for Windows Visual Studio builds
% addpath(genpath('../../../install')); % cmake default install location

% these variables are defined in the OpenLoop model's FAST_SFunc block:
FAST_InputFileName = '../../../reg_tests/r-test/glue-codes/openfast/5MW_Land_DLL_WTurb/5MW_Land_DLL_WTurb.fst';
TMax = 60; % seconds

CertTest_Dir = '..\..\CertTest';

CertTest_TMax=[20, 20, 20, 70, 30, ...
35, 70, 20, 40, 25, ...
20, 20, 40, 0, 20, ...
20, 70, 60, 60, 60, ...
60, 60, 60, 60, 60, ...
20 ];

for iTest = [1:13 15:26]

%------------------------------------------------------------------
% Set up and run the Simulink OpenLoop model
%------------------------------------------------------------------

FileRoot = sprintf( 'Test%02.0f', iTest );

disp('***********************************************');
disp( ['FAST_SFunc certification test for ' FileRoot] );
disp('***********************************************');

FAST_InputFileName = [CertTest_Dir filesep FileRoot '.fst'];
TMax = CertTest_TMax(iTest);

sim('OpenLoop.mdl',[0,TMax]);

end
sim('OpenLoop.mdl',[0,TMax]);
19 changes: 10 additions & 9 deletions glue-codes/simulink/examples/Run_Test01_SIG.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
% make sure the FASTv8\bin directory is in the MATLAB path
% make sure the OpenFAST directory where the FAST_SFunc.mex* file is located
% is in the MATLAB path (also make sure any other OpenFAST library files that
% are needed are on the MATLAB path)
% (relative path names are not recommended in addpath()):
% cd ..\..\
% FASTv8_root_directory = pwd;
% cd Simulink\Samples
% addpath([ FASTv8_root_directory '\bin']);
% addpath('../../../build/bin'); % install location for Windows Visual Studio builds
% addpath(genpath('../../../install')); % cmake default install location


% Simple Induction Generator Example ======================================
% To model a simple induction generator in Simulink use model Test01_SIG.mdl.
% The following parameters duplicate those used in Certification Test #01.

% Change Test01.fst as follows:
% set VSContrl = 4 in ..\..\CertTest\AWT27\Test01_ServoDyn.dat
% Change AWT_YFix_WSt.fst (formerly Test01.fst) as follows:
% set VSContrl = 4 in ../../../reg_tests/r-test/glue-codes/openfast/AWT_YFix_WSt/AWT_YFix_WSt_ServoDyn.dat


GenEff = 100.0; % - Generator efficiency [ignored by the Thevenin and user-defined generator models] (%)
Expand All @@ -28,11 +28,12 @@


% parameters required for the S-Function block:
FAST_InputFileName = '..\..\CertTest\Test01.fst';
OpenFASTRoot = '../../../reg_tests/r-test/glue-codes/openfast/AWT_YFix_WSt/';
FAST_InputFileName = [ OpenFASTRoot 'AWT_YFix_WSt.fst' ];
TMax = 20;

% run the model
sim('Test01_SIG.mdl',[0,TMax]);

% look at results:
% PlotFASToutput({'../../CertTest/Test01.SFunc.out','../../CertTest/Test01.out'},{'SFunc','exe'});
% PlotFASToutput({[ OpenFASTRoot 'AWT_YFix_WSt.SFunc.out'],[ OpenFASTRoot 'windows-intel/AWT_YFix_WSt.out']},{'SFunc','exe'});
4 changes: 2 additions & 2 deletions glue-codes/simulink/src/create_FAST_SFunc.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
fprintf( 'Creating %s\n\n', [outDir filesep mexname '.' mexext] );

mex('-largeArrayDims', ...
... % '-v', ... %add this line for "verbose" output (for debugging)
['-L' libDir], ...
['-l' libName], ...
['-I' includeDir], ...
'-I../../../modules/supercontroller/src', ... % needed for visual studio builds to find "SuperController_Types.h"
'-I../../../modules/openfoam/src', ... % needed for visual studio builds to find "OpenFOAM_Types.h"
'-outdir', outDir, ...
'COMPFLAGS=$COMPFLAGS -MT -D', ...
['S_FUNCTION_NAME=' mexname], ...
['COMPFLAGS=$COMPFLAGS -MT -DS_FUNCTION_NAME=' mexname], ...
'-output', mexname, ...
'FAST_SFunc.c');
8 changes: 4 additions & 4 deletions vs-build/FASTlib/FASTlib.vfproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@
<Tool Name="VFPreBuildEventTool" CommandLine="call ..\CreateGitVersion.bat"/>
<Tool Name="VFPostBuildEventTool"/></Configuration>
<Configuration Name="Debug_Matlab|Win32" OutputDirectory="..\..\build\bin\" TargetName="$(ProjectName)_$(PlatformName)_Debug_Matlab" ConfigurationType="typeStaticLibrary">
<Tool Name="VFFortranCompilerTool" AdditionalOptions="/fpe-all:0" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" Preprocess="preprocessYes" PreprocessorDefinitions="COMPILE_SIMULINK;&quot;GIT_INCLUDE_FILE='$(ProjectDir)\..\gitVersionInfo.h'&quot;" StandardWarnings="standardWarningsF03" DisableSpecificDiagnostics="5268,5199" Traceback="true" BoundsCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDebug" UseMkl="mklSequential"/>
<Tool Name="VFLibrarianTool" AdditionalDependencies="$(OutDir)\MAP_$(PlatformName)_Debug.lib"/>
<Tool Name="VFFortranCompilerTool" AdditionalOptions="/fpe-all:0" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" Preprocess="preprocessYes" PreprocessorDefinitions="CONSOLE_FILE;COMPILE_SIMULINK;&quot;GIT_INCLUDE_FILE='$(ProjectDir)\..\gitVersionInfo.h'&quot;" StandardWarnings="standardWarningsF03" DisableSpecificDiagnostics="5268,5199" Traceback="true" BoundsCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDebug" UseMkl="mklSequential"/>
<Tool Name="VFLibrarianTool" AdditionalDependencies="$(OutDir)\MAP_$(PlatformName).lib"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool" CommandLine="call ..\CreateGitVersion.bat"/>
<Tool Name="VFPostBuildEventTool"/></Configuration>
<Configuration Name="Debug_Matlab|x64" OutputDirectory="..\..\build\bin\" TargetName="$(ProjectName)_$(PlatformName)_Debug_Matlab" ConfigurationType="typeStaticLibrary">
<Tool Name="VFFortranCompilerTool" AdditionalOptions="/fpe-all:0" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" Preprocess="preprocessYes" PreprocessorDefinitions="COMPILE_SIMULINK;&quot;GIT_INCLUDE_FILE='$(ProjectDir)\..\gitVersionInfo.h'&quot;" StandardWarnings="standardWarningsF03" DisableSpecificDiagnostics="5268,5199" Traceback="true" BoundsCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDebug" UseMkl="mklSequential"/>
<Tool Name="VFLibrarianTool" AdditionalDependencies="$(OutDir)\MAP_$(PlatformName)_Debug.lib"/>
<Tool Name="VFFortranCompilerTool" AdditionalOptions="/fpe-all:0" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" Preprocess="preprocessYes" PreprocessorDefinitions="CONSOLE_FILE;COMPILE_SIMULINK;&quot;GIT_INCLUDE_FILE='$(ProjectDir)\..\gitVersionInfo.h'&quot;" StandardWarnings="standardWarningsF03" DisableSpecificDiagnostics="5268,5199" Traceback="true" BoundsCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDebug" UseMkl="mklSequential"/>
<Tool Name="VFLibrarianTool" AdditionalDependencies="$(OutDir)\MAP_$(PlatformName).lib"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
<Tool Name="VFCustomBuildTool"/>
Expand Down