Skip to content

Commit

Permalink
Bug fixes for WEC-Sim Applications (WEC-Sim#49)
Browse files Browse the repository at this point in the history
* update mostIO - remove clear calls, convert to functions, remove turbsim exe

* add multiple wave headings test and standardize naming

* use backwards compatible optional parameter definition in nexttile call

* make call to tiledlayout backwards compatible

* updating dev tests to run on windows

* updating dev tests to run on windows with 2023a

* remove processed turbsim file so that mostIO is tested

* make paths OS-agnostic

* updating desal test to run on windows with 2023a

* running on windows and desal test on 2023a

* one last attempt to resolve windows test failure

* reverting to Linux and removing MoorDyn tests

* fix capitalization for paths in linux, macOS

* only running tests on latest version of MATLAB

---------

Co-authored-by: kmruehl <[email protected]>
  • Loading branch information
akeeste and kmruehl authored Oct 18, 2023
1 parent 21da360 commit 27ff16e
Show file tree
Hide file tree
Showing 25 changed files with 80 additions and 111 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/run-tests-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ jobs:
strategy:
fail-fast: false
matrix:
release: [R2020b, latest]
release: [latest]
folder: [Body-to-Body_Interactions,
Cable,
Controls,
Desalination,
End_Stops,
Free_Decay,
Generalized_Body_Modes,
Mean_Drift,
Mooring,
Morison_Element,
MOST,
Multiple_Condition_Runs,
Multiple_Wave_Headings,
Nonhydro_Body,
Nonlinear_Hydro,
Paraview_Visualization,
Passive_Yaw,
PTO-Sim,
Radiation_Force_Options,
Expand All @@ -46,14 +46,13 @@ jobs:
Write_Custom_h5]
include:
- products: Simulink Simscape Simscape_Multibody
- release: latest
folder: Desalination
- folder: Desalination
products: Simulink Simscape Simscape_Multibody Simscape_Fluids
- folder: Controls
products: Simulink Simscape Simscape_Multibody Control_System_Toolbox Optimization_Toolbox System_Identification_Toolbox Statistics_and_Machine_Learning_Toolbox Symbolic_Math_Toolbox
- folder: WECCCOMP
products: Simulink Simscape Simscape_Multibody Control_System_Toolbox Optimization_Toolbox System_Identification_Toolbox Statistics_and_Machine_Learning_Toolbox
name: ${{ matrix.folder }} on MATLAB ${{ matrix.release }}
name: ${{ matrix.folder }} MATLAB ${{ matrix.release }} on Linux
steps:
- name: Check out repository (repository dispatch)
uses: actions/checkout@v2
Expand Down Expand Up @@ -104,4 +103,4 @@ jobs:
- name: Run tests and generate artifacts
uses: matlab-actions/run-command@v1
with:
command: results = wecSimAppTest("${{ matrix.folder }}"), assertSuccess(results);
command: results = wecSimAppTest("${{ matrix.folder }}"), assertSuccess(results);
8 changes: 2 additions & 6 deletions MOST/hydroData/bemio.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
clear all
close all
clc
foldernemoh = 'VolturnUS15MW_nemoh';

hydro = struct();
hydro = readNEMOH(hydro,[pwd,filesep,foldernemoh,filesep]);
hydro = readNEMOH(hydro,fullfile('VolturnUS15MW_nemoh'));
hydro = radiationIRF(hydro,90,201,201,[],[]);
hydro = radiationIRFSS(hydro,[],[]);
hydro = excitationIRF(hydro,90,[],[],[],[]);
writeBEMIOH5(hydro)
writeBEMIOH5(hydro)
11 changes: 4 additions & 7 deletions MOST/mostData/mooring/Create_Mooring_Matrix.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to compute mooring look-up table %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INITIALIZATION
close all
clearvars -except testCase
function moor_matrix = Create_Mooring_Matrix()
%% Function to compute mooring look-up table
%% SETTINGS
if 1
%% Line
Expand Down Expand Up @@ -73,8 +69,9 @@

%% SAVE
save('Mooring_VolturnUS15MW','moor_matrix');
%% FUNCTIONS
end

%% FUNCTIONS
function moor_matrix = moor_matrix_6dof(moor_matrix,Data_moor)

HV_out=zeros(Data_moor.number_lines,2);
Expand Down
18 changes: 7 additions & 11 deletions MOST/mostData/mostIO.m
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to pre-process all required inputs for WEC-Sim+MOST %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Initialization
clearvars -except testCase
close all
clc
%% TurbSim Data
cd turbSim
run_turbsim
Wind = run_turbsim();
cd ..

%% Mooring Data
cd mooring
Create_Mooring_Matrix
moor_matrix = Create_Mooring_Matrix();
cd ..

%% Turbine Data
cd windTurbine
cd turbine_properties
WTproperties
BladeData
WTcomponents = WTproperties();
bladedata = BladeData();
cd ..
cd control
Steady_States
Controller
[BEM_data, SS] = Steady_States();
[BEM_data, Ctrl] = Controller();
cd ..
cd aeroloads
AeroLoads
[BEM_data, aeroloads] = AeroLoads();
cd ..
cd ..
Binary file removed MOST/mostData/turbSim/TurbSim64.exe
Binary file not shown.
Binary file removed MOST/mostData/turbSim/WIND_11mps.mat
Binary file not shown.
42 changes: 20 additions & 22 deletions MOST/mostData/turbSim/run_turbsim.m
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to create wind input file %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INITIALIZATION
clearvars -except testCase
function Wind = run_turbsim()
%% Function to create wind input file

%% SETTINGS
WINDvector=[11]; % how many velocities of the wind to put
filename_Turbsim='Turbsim_inputfile.txt'; % name of the input file for turbsim
deleteOut=false; % check if temporary outputs of Turbsim must be deleted
%% TURBSIM
for V_i=1:length(WINDvector)
fileID = fopen(filename_Turbsim,'r');
raw1 = textscan(fileID, '%s',Delimiter='%\n');
raw1 = raw1{1,1};
raw1{37,1} = [num2str(WINDvector(V_i)) ' URef - Mean (total) wind speed at the reference height [m/s] (or "default" for JET wind profile)'];
writecell((raw1),['WIND_' num2str(WINDvector(V_i)) 'mps.txt'],'QuoteStrings',false)
fclose('all');
system(['.\TurbSim64.exe WIND_',num2str(WINDvector(V_i)),'mps.txt']);
WINDvector = [11]; % wind velocities to run in TurbSim
filename_Turbsim = 'Turbsim_inputfile.txt'; % name of the input file for turbsim
deleteOut = false; % check if temporary outputs of Turbsim must be deleted
turbSimInstalled = false; % Set to true if the TurbSim64.exe executable is installed in this directory

%% TURBSIM - OPTIONAL
if isfile('TurbSim64.exe')
for V_i=1:length(WINDvector)
fileID = fopen(filename_Turbsim,'r');
raw1 = textscan(fileID, '%s',Delimiter='%\n');
raw1 = raw1{1,1};
raw1{37,1} = [num2str(WINDvector(V_i)) ' URef - Mean (total) wind speed at the reference height [m/s] (or "default" for JET wind profile)'];
writecell((raw1),['WIND_' num2str(WINDvector(V_i)) 'mps.txt'],'QuoteStrings',false)
fclose('all');
system(['./TurbSim64.exe WIND_',num2str(WINDvector(V_i)),'mps.txt']);
end
end

%% SAVE
Expand All @@ -35,8 +37,4 @@
delete([FileName '.txt']);
end
end





end
9 changes: 3 additions & 6 deletions MOST/mostData/windTurbine/aeroloads/AeroLoads.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to compute aeroloads look-up table %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INITIALIZATION
clearvars -except testCase
function [BEM_data, aeroloads] = AeroLoads()
%% Function to compute aeroloads look-up table
%% SETTINGS
if 1
%% Look up table settings
Expand Down Expand Up @@ -88,9 +85,9 @@
%% SAVE
save('Aeroloads_IEA15MW','aeroloads')

end

%% FUNCTIONS

function F_aero = BEM(v_wind_rel,omega,bladepitch,data)

pntm=[0 0 0].*data.r;
Expand Down
10 changes: 4 additions & 6 deletions MOST/mostData/windTurbine/control/Controller.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to compute controls data %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INITIALIZATION
clearvars -except testCase
function [BEM_data, Ctrl] = Controller()
%% Function to compute controls data
%% SETTINGS
if 1
%% Plot
Expand Down Expand Up @@ -242,8 +239,9 @@
%% SAVE
save("Control_IEA15MW","Ctrl")

%% FUNCTIONS
end

%% FUNCTIONS
function om_d = Omega_dot(C_gen,wind,omega,bladepitch,BEM_data,RotorInertia)

F_aero = BEM(wind,omega,bladepitch,BEM_data);
Expand Down
12 changes: 4 additions & 8 deletions MOST/mostData/windTurbine/control/Steady_States.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to compute control steady states %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INIT
clearvars -except testCase
close all
function [BEM_data, SS] = Steady_States()
%% Function to compute control steady states
%% SETTINGS
if 1
%% Plot
Expand All @@ -29,8 +25,6 @@
BEM_data.maxit2=50;
BEM_data.eps=1e-6;



end
%% DATA
if 1
Expand Down Expand Up @@ -164,6 +158,8 @@
%% SAVE
save('SteadyStates_IEA15MW','SteadyStates')

end

%% FUNCTIONS

function diff=find_rated(x,omega_rated_try,v_rated_try)
Expand Down
11 changes: 5 additions & 6 deletions MOST/mostData/windTurbine/turbine_properties/BladeData.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to create bladedata struct %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Initialization
clearvars -except testCase
load('Properties_IEA15MW')
function bladedata = BladeData()
%% Function to create bladedata struct
load('Properties_IEA15MW');

%% Blade
bladefile=importdata('BladeData/IEA-15-240-RWT_blade.dat',' ',6);
bladedata.radius=bladefile.data(:,1)+WTcomponents.hub.Rhub;
Expand All @@ -26,3 +24,4 @@
%% Save
save('Bladedata_IEA_15MW.mat','bladedata')

end
20 changes: 9 additions & 11 deletions MOST/mostData/windTurbine/turbine_properties/WTproperties.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script to create wind turbine properties struct %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Initialization
clearvars -except testCase
clc
function WTcomponents = WTproperties()
%% Function to create wind turbine properties struct
WTcomponents=struct;
%% Tower
WTcomponents.tower.mass= 1.4667e+06;
Expand Down Expand Up @@ -103,14 +99,16 @@


%% Geometry files
WTcomponents.geometryFileTower = 'geometry\IEA15MW_Tower.STEP';
WTcomponents.geometryFileNacelle = 'geometry\IEA15MW_Nacelle.STEP';
WTcomponents.geometryFileHub = 'geometry\IEA15MW_Hub.STEP';
WTcomponents.geometryFileBlade = 'geometry\IEA15MW_Blade.STEP';
WTcomponents.geometryFileTower = 'geometry/IEA15MW_Tower.STEP';
WTcomponents.geometryFileNacelle = 'geometry/IEA15MW_Nacelle.STEP';
WTcomponents.geometryFileHub = 'geometry/IEA15MW_Hub.STEP';
WTcomponents.geometryFileBlade = 'geometry/IEA15MW_Blade.STEP';
%% Save
save('Properties_IEA15MW','WTcomponents')
%% FUNCTIONS

end

%% FUNCTIONS
function [Rx] = Rx(phi)

Rx=[1 0 0;
Expand Down
9 changes: 2 additions & 7 deletions MOST/tests/TestMOST.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,8 @@ function runTurbulentTest(testCase)
function plotTests(testCase)
% Plot Old vs. New Comparison
if testCase.plotComparison == 1
% Constant
load('constant/constant.mat','constant');
plotTests(constant.newCase,constant.orgCase);

% Turbulent
load('turbulent/turbulent.mat','turbulent');
plotTests(turbulent.newCase,turbulent.orgCase);
plotTests(testCase.constant.newCase,testCase.constant.orgCase);
plotTests(testCase.turbulent.newCase,testCase.turbulent.orgCase);
end
end
function checkVisibilityRestored(testCase)
Expand Down
6 changes: 3 additions & 3 deletions MOST/tests/constant/wecSimInputFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

%% Body class (Platform)

body(1) = bodyClass('..\..\hydroData\VolturnUS15MW_nemoh.h5'); % Initialize bodyClass (giving hydro data file as input)
body(1).geometryFile = '..\..\geometry\VolturnUS15MW.STEP'; % Geometry File
body(1) = bodyClass('../../hydroData/VolturnUS15MW_nemoh.h5'); % Initialize bodyClass (giving hydro data file as input)
body(1).geometryFile = '../../geometry/VolturnUS15MW.STEP'; % Geometry File
body(1).mass = 17838000; % User-Defined mass [kg]
body(1).inertia = 1.0e+10*[1.2507 1.2507 2.3667]; % Moment of Inertia [kg-m^2]
body(1).quadDrag.drag = [9.23E+05 0.00E+00 0.00E+00 0.00E+00 -8.92E+06 0.00E+00 %AddBQuad - Additional quadratic drag(N/(m/s)^2, N/(rad/s)^2, N-m(m/s)^2, N-m/(rad/s)^2)
Expand All @@ -49,7 +49,7 @@

windTurbine(1) = windTurbineClass('IEA15MW'); % Initialize turbine size and Specify Type
windTurbine(1).control = 1; % Controltype: 0-->Baseline, 1-->ROSCO
windTurbine(1).aeroLoadsName = fullfile('..','..','mostData','windTurbine','aeroloads','aeroloads_IEA15MW.mat'); % Aeroloads filename
windTurbine(1).aeroLoadsName = fullfile('..','..','mostData','windTurbine','aeroloads','Aeroloads_IEA15MW.mat'); % Aeroloads filename
windTurbine(1).turbineName = fullfile('Properties_IEA15MW.mat'); % Windturbine properties filename
windTurbine(1).controlName = fullfile('..','..','mostData','windTurbine','control','Control_IEA15MW.mat'); % Controller filename
windTurbine(1).omega0 = 7.55*pi/30; % Initial value for rotor speed
Expand Down
6 changes: 3 additions & 3 deletions MOST/tests/turbulent/wecSimInputFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

%% Body class (Platform)

body(1) = bodyClass('..\..\hydroData\VolturnUS15MW_nemoh.h5'); % Initialize bodyClass (giving hydro data file as input)
body(1).geometryFile = '..\..\geometry\VolturnUS15MW.STEP'; % Geometry File
body(1) = bodyClass('../../hydroData/VolturnUS15MW_nemoh.h5'); % Initialize bodyClass (giving hydro data file as input)
body(1).geometryFile = '../../geometry/VolturnUS15MW.STEP'; % Geometry File
body(1).mass = 17838000; % User-Defined mass [kg]
body(1).inertia = 1.0e+10*[1.2507 1.2507 2.3667]; % Moment of Inertia [kg-m^2]
body(1).quadDrag.drag = [9.23E+05 0.00E+00 0.00E+00 0.00E+00 -8.92E+06 0.00E+00 %AddBQuad - Additional quadratic drag(N/(m/s)^2, N/(rad/s)^2, N-m(m/s)^2, N-m/(rad/s)^2)
Expand All @@ -49,7 +49,7 @@

windTurbine(1) = windTurbineClass('IEA15MW'); % Initialize turbine size and Specify Type
windTurbine(1).control = 1; % Controltype: 0-->Baseline, 1-->ROSCO
windTurbine(1).aeroLoadsName = fullfile('..','..','mostData','windTurbine','aeroloads','aeroloads_IEA15MW.mat'); % Aeroloads filename
windTurbine(1).aeroLoadsName = fullfile('..','..','mostData','windTurbine','aeroloads','Aeroloads_IEA15MW.mat'); % Aeroloads filename
windTurbine(1).turbineName = fullfile('Properties_IEA15MW.mat'); % Windturbine properties filename
windTurbine(1).controlName = fullfile('..','..','mostData','windTurbine','control','Control_IEA15MW.mat'); % Controller filename
windTurbine(1).omega0 = 7.55*pi/30; % Initial value for rotor speed
Expand Down
4 changes: 2 additions & 2 deletions MOST/wecSimInputFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

%% Body class (Platform)

body(1) = bodyClass('hydroData\VolturnUS15MW_nemoh.h5'); % Initialize bodyClass (giving hydro data file as input)
body(1).geometryFile = 'geometry\VolturnUS15MW.STEP'; % Geometry File
body(1) = bodyClass('hydroData/VolturnUS15MW_nemoh.h5'); % Initialize bodyClass (giving hydro data file as input)
body(1).geometryFile = 'geometry/VolturnUS15MW.STEP'; % Geometry File
body(1).mass = 17838000; % User-Defined mass [kg]
body(1).inertia = 1.0e+10*[1.2507 1.2507 2.3667]; % Moment of Inertia [kg-m^2]
body(1).quadDrag.drag = [9.23E+05 0.00E+00 0.00E+00 0.00E+00 -8.92E+06 0.00E+00 %AddBQuad - Additional quadratic drag(N/(m/s)^2, N/(rad/s)^2, N-m(m/s)^2, N-m/(rad/s)^2)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
classdef Test_NWaves < matlab.unittest.TestCase
classdef TestMultipleWaveHeadings < matlab.unittest.TestCase

properties
OriginalDefault
Expand All @@ -10,7 +10,7 @@


methods (Access = 'public')
function obj = Test_NWaves
function obj = TestMultipleWaveHeadings
obj.testDir = fileparts(mfilename('fullpath'));
end
end
Expand Down Expand Up @@ -48,7 +48,7 @@ function checkVisibilityRestored(testCase)
end

methods(Test)
function TestNWaves(testCase)
function testMultiple_Wave_Headings(testCase)
wecSim
end
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 27ff16e

Please sign in to comment.