Skip to content

Commit

Permalink
Merge pull request #8 from frp09/dev
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
frp09 authored Jan 24, 2024
2 parents e9704c5 + 711e5a6 commit fd7e005
Show file tree
Hide file tree
Showing 125 changed files with 1,406 additions and 1,014 deletions.
82 changes: 82 additions & 0 deletions Matlab-toolbox/runFAST_batch.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

% -------------------------------------------------------------------------
% This script runs multiple FAST simulation with UNICO Simulink controller.
% The Parallel computing toolbox must be installed to use this function
% runFAST_batch runs the simulations for all fst files in the directory
% fast.FAST_directory

clear;
[this_dir,~,~] = fileparts(mfilename('fullpath'));

input_file = ['C:\Users\utente\Desktop\TEST_UNICO_dev\Test_cases\UNIFI_SRWT_simulink\StepTest' ...
'\discon.in']; % Controller input file

fast.FAST_SFuncDir = 'C:\Users\utente\Desktop\TEST_UNICO_dev\Test_cases\openfast-3.5'; % Path to SFunction. Compile FAST for use with simulink & mex using openfast docs
fast.FAST_directory = ['D:\Controller_TORQUE\Simulink\Test_cases'...
'\StepTest']; % Path to fst directory files

simu.SimModel = fullfile('C:\Users\utente\Desktop\UNICO_dev_test\simulink', ...
'UNICO_simulink.slx'); % Path to simulink model

[filepath,simu.SimModel,ext] = fileparts(simu.SimModel);
cd(filepath) % the working directory must be the same as the simulink model to make the parallel simulations work

addpath(genpath('C:\Users\utente\Desktop\TEST_UNICO_dev\Matlab-toolbox')); % Import OpenFAST Matlab toolbox and ROSCO controller toolbox
% OpenFAST Matlab toolbox (https://github.com/OpenFAST/matlab-toolbox/tree/
% main) and ROSCO toolbox (https://github.com/NREL/ROSCO/tree/main/ROSCO_to
% olbox) are distributed under Apache 2.0 license. The toolbox distributed
% with the UNICO controller is adapted from the ROSCO and OpenFAST matlab
% toolboxes.
list_fst=dir(strcat(fast.FAST_directory,'\*.fst')); %returns list of fst files


%% Simulink Setup

addpath(fast.FAST_SFuncDir);

%% Read FAST Files & Load UNICO Params from DISCON.IN
for i =1:length(list_fst)

fast.FAST_InputFile = list_fst(i).name; % FAST input file (ext=.fst) get all fst files from directory

[Param,Cx] = ReadWrite_FAST(fast);

% Simulation Parameters
simu.TMax = Param.FP.Val{contains(Param.FP.Label,'TMax')};
simu.dt = Param.FP.Val{contains(Param.FP.Label,'DT')};

%% Premake OutList for Simulink

OutList = {'Time'};
OutList = [OutList;
Param.IWP.OutList;
Param.EDP.OutList;
Param.ADP.OutList;
Param.SvDP.OutList;
];

for iOut = 2:length(OutList)
OutList{iOut} = OutList{iOut}(2:end-1); %strip "s
end
% simu.TMax = 1;


%% Exectute FAST


Control.DT = simu.dt;

% Using Simulink/S_Func
FAST_InputFileName = [fast.FAST_directory,filesep,fast.FAST_InputFile];
TMax = simu.TMax;

SimulinkModel = simu.SimModel;
simIn = Simulink.SimulationInput(SimulinkModel); %create simulink input file for sbatch
job = batchsim(simIn,"TransferBaseWorkspaceVariables","on"); %launch batch simulation. The variables from the workspace are loaded into the sbatch function, as it requires the inputs


end




2 changes: 1 addition & 1 deletion Src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Contents:
- **UNICO_simulink.slx** : Simulink project of the UNICO controller. This controller can be coupled to OpenFAST
using the OpenFAST SFunction. An example is provided in "matlab-toolbox/runFAST.m"To run the example, download the
OpenFAST v3.5.0 SFunction, that is available at: https://github.com/OpenFAST/openfast/releases/tag/v3.5.0
OpenFAST v3.5.0 SFunction (files: FAST_SFunc.mexw64, OpenFAST-Simulink_x64.dll), that is available at: https://github.com/OpenFAST/openfast/releases/tag/v3.5.0

- **dll_controller** : In this folder a dynamic library version (.dll) of the UNICO controller is stored.
The .dll can be used in wind turbine simulation tools that support Bladed-style control interfaces. It was
Expand Down
Binary file modified Src/UNICO_oldSFunction/UNICO_simulink.slx
Binary file not shown.
Binary file modified Src/UNICO_simulink.slx
Binary file not shown.
Binary file modified Src/dll_controller/DISCON.dll
Binary file not shown.
Binary file modified Src/dll_controller/DISCON.exp
Binary file not shown.
Binary file modified Src/dll_controller/Parameters_UNICO.mat
Binary file not shown.
Binary file modified Src/dll_controller/UNICO.slx
Binary file not shown.
Binary file modified Src/dll_controller/UNICO.slxc
Binary file not shown.
Loading

0 comments on commit fd7e005

Please sign in to comment.