Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/all-tests-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ jobs:
steps:
- run: echo "Triggered by WEC-Sim commit ${{ fromJSON(inputs.client_payload).sha }}"
- name: Check out repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
lfs: true
ref: ${{ fromJSON(inputs.client_payload).branch }}
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
uses: matlab-actions/setup-matlab@v3
with:
release: R2024b
- name: Get test target folder
uses: matlab-actions/run-command@v2
uses: matlab-actions/run-command@v3
with:
command: getTestTargets
- name: Save output
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/changed-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ jobs:
if: github.event_name != 'repository_dispatch'
steps:
- name: Check out repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
lfs: true
fetch-depth: 0
- name: Generate git diff
uses: GrantBirki/git-diff-action@v2
uses: GrantBirki/git-diff-action@v3
id: git-diff-action
with:
json_diff_file_output: diff.json
file_output_only: "true"
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
uses: matlab-actions/setup-matlab@v3
with:
release: R2024a
release: R2024b
- name: Get test target folder
uses: matlab-actions/run-command@v2
uses: matlab-actions/run-command@v3
with:
command: getTestTargets("diff.json")
- name: Save output
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/run-tests-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,26 @@ jobs:
os: [ubuntu-latest, windows-latest]
release: [R2024b]
include: ${{ fromJSON(inputs.include) }}
exclude:
- os: ubuntu-latest
folder: Mooring
- os: ubuntu-latest
folder: OWC
- os: ubuntu-latest
folder: Paraview_Visualization
name: "${{ matrix.folder }} - ${{ matrix.os }} - ${{ matrix.release }}"
timeout-minutes: 45
steps:
- name: Check out repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
lfs: true
ref: ${{ inputs.head_ref }}
repository: ${{ inputs.repository }}
- name: Checkout LFS objects
run: git lfs checkout
- name: Check out WEC-Sim
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
repository: WEC-Sim/WEC-Sim
ref: ${{ inputs.base_ref }}
path: './WEC-Sim'
- name: Check out MoorDyn
if: matrix.folder == 'Mooring' || matrix.folder == 'OWC' || matrix.folder == 'Paraview_Visualization'
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
repository: WEC-Sim/MoorDyn
path: './MoorDyn'
Expand All @@ -67,7 +60,7 @@ jobs:
shell: bash
working-directory: './MoorDyn'
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
uses: matlab-actions/setup-matlab@v3
with:
products: ${{ matrix.products }}
release: ${{ matrix.release }}
Expand All @@ -78,7 +71,7 @@ jobs:
Xvfb :99 &
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Install WEC-Sim, run tests and generate artifacts
uses: matlab-actions/run-command@v2
uses: matlab-actions/run-command@v3
with:
command: |
addpath(genpath('WEC-Sim/source'));
Expand Down
8 changes: 8 additions & 0 deletions Body-to-Body_Interactions/TestB2B.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ function killPlots (~)
end

methods(TestClassSetup)
function removeProjectFolder(~)
d = dir('**');
d = d([d.isdir]);
d = d(string({d.name})=="slprj");
for i = 1:length(d)
rmdir(fullfile(d(i).folder, d(i).name), 's')
end
end
function captureVisibility(testCase)
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
end
Expand Down
13 changes: 9 additions & 4 deletions Cable/TestCable.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ function killPlots (~)
end

methods(TestClassSetup)

function captureVisibility(testCase)
testCase.OriginalDefault = get(0, 'DefaultFigureVisible');
end

function removeProjectFolder(~)
d = dir('**');
d = d([d.isdir]);
d = d(string({d.name})=="slprj");
for i = 1:length(d)
rmdir(fullfile(d(i).folder, d(i).name), 's')
end
end
function runBemio(testCase)
cd(testCase.h5Dir);
if isfile(testCase.h5Name)
Expand All @@ -40,18 +46,17 @@ function runBemio(testCase)
end

methods(TestClassTeardown)

function checkVisibilityRestored(testCase)
set(0, 'DefaultFigureVisible', testCase.OriginalDefault);
testCase.assertEqual(get(0, 'DefaultFigureVisible'), ...
testCase.OriginalDefault);
end

end

methods(Test)
function testCable(testCase)
wecSim
close_system('MBARI_cable',0)
end
end

Expand Down
14 changes: 14 additions & 0 deletions Controls/TestControls.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ function killPlots (~)
function captureVisibility(testCase)
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
end
function removeProjectFolder(~)
d = dir('**');
d = d([d.isdir]);
d = d(string({d.name})=="slprj");
for i = 1:length(d)
rmdir(fullfile(d(i).folder, d(i).name), 's')
end
end
function runBemio(testCase)
cd(testCase.h5Dir);
if isfile(testCase.h5Name)
Expand Down Expand Up @@ -53,26 +61,32 @@ function checkVisibilityRestored(testCase)
function testPassive(testCase)
cd('Passive (P)')
wecSim
close_system('passive',0)
end
function testReactive(testCase)
cd('Reactive (PI)')
wecSim
close_system('reactive',0)
end
function testLatching(testCase)
cd('Latching')
wecSim
close_system('latchTime',0)
end
function testDeclutching(testCase)
cd('Declutching')
wecSim
close_system('declutch',0)
end
function testMPC(testCase)
cd('MPC')
wecSim
close_system('sphereMPC',0)
end
function testReactiveWithPTO(testCase)
cd('ReactiveWithPTO')
wecSim
close_system('reactiveWithPTO',0)
end
end
end
Binary file modified Desalination/OSWEC_RO.slx
Binary file not shown.
13 changes: 11 additions & 2 deletions Desalination/TestDesalination.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ function killPlots (~)
methods(TestClassSetup)
function captureVisibility(testCase)
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
end
end
function removeProjectFolder(~)
d = dir('**');
d = d([d.isdir]);
d = d(string({d.name})=="slprj");
for i = 1:length(d)
rmdir(fullfile(d(i).folder, d(i).name), 's')
end
end
function runBemio(testCase)
% Check for Simscape Fluids
assumeEqual(testCase, ...
Expand All @@ -38,7 +46,7 @@ function runBemio(testCase)
end
cd(testCase.testDir)
testCase.hasH5 = true;
end
end
end

methods(TestClassTeardown)
Expand All @@ -52,6 +60,7 @@ function checkVisibilityRestored(testCase)
methods(Test)
function testDesalination(testCase)
wecSim
close_system('OSWEC_RO',0)
end
end
end
4 changes: 3 additions & 1 deletion Desalination/wecSimInputFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
simu.solver = 'ode4'; %simu.solver = 'ode4' for fixed step & simu.solver = 'ode45' for variable step
simu.startTime = 0; % Simulation Start Time [s]
simu.rampTime = 50;
simu.endTime=300;
simu.endTime = 300;
simu.dt = 0.01; %Simulation time-step [s] for a convolution function in the radiation force calculation
simu.cicEndTime = 30;

Expand Down Expand Up @@ -54,6 +54,8 @@
constraint(4)= constraintClass('Constraint4'); % Initialize ConstraintClass
constraint(4).location = [0+0.9 0 -7];

inertiaBlock = 1e-3; % kg - small mass on follower side of PTO used to resolve degenerate mass errors

pto(1) = ptoClass('PTO1'); % Initialize ptoClass for PTO1
pto(1).stiffness = 0; % PTO Stiffness Coeff [Nm/rad]
pto(1).damping = 0; % PTO Damping Coeff [Nsm/rad]
Expand Down
13 changes: 11 additions & 2 deletions End_Stops/TestEndStops.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ function killPlots (~)
methods(TestClassSetup)
function captureVisibility(testCase)
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
end
end
function removeProjectFolder(~)
d = dir('**');
d = d([d.isdir]);
d = d(string({d.name})=="slprj");
for i = 1:length(d)
rmdir(fullfile(d(i).folder, d(i).name), 's')
end
end
function runBemio(testCase)
cd(testCase.h5Dir);
if isfile(testCase.h5Name)
Expand All @@ -34,7 +42,7 @@ function runBemio(testCase)
cd(testCase.testDir)
end
end

methods(TestClassTeardown)
function checkVisibilityRestored(testCase)
set(0,'DefaultFigureVisible',testCase.OriginalDefault);
Expand All @@ -46,6 +54,7 @@ function checkVisibilityRestored(testCase)
methods(Test)
function testEnd_Stops(testCase)
wecSim
close_system('RM3',0)
end
end
end
10 changes: 9 additions & 1 deletion Free_Decay/TestFreeDecay.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ function killPlots (~)
methods(TestClassSetup)
function captureVisibility(testCase)
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
end
end
function removeProjectFolder(~)
d = dir('**');
d = d([d.isdir]);
d = d(string({d.name})=="slprj");
for i = 1:length(d)
rmdir(fullfile(d(i).folder, d(i).name), 's')
end
end
function runBemio(testCase)
cd(testCase.h5Dir);
if isfile(testCase.h5Name)
Expand Down
Binary file added Full_Directional_Waves/OSWEC.slx
Binary file not shown.
66 changes: 66 additions & 0 deletions Full_Directional_Waves/TestFullDirectionalWaves.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
classdef TestFullDirectionalWaves < matlab.unittest.TestCase

properties
OriginalDefault
testDir
h5Dir = '../_Common_Input_Files/OSWEC/hydroData/'
h5Name = 'oswec.h5'
outName = 'oswec.out'
end

methods (Access = 'public')
function obj = TestFullDirectionalWaves
obj.testDir = fileparts(mfilename('fullpath'));
end
end

methods (TestMethodSetup)
function killPlots (~)
set(0,'DefaultFigureVisible','off');
end
end

methods(TestClassSetup)
function captureVisibility(testCase)
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
end
function removeProjectFolder(~)
d = dir('**');
d = d([d.isdir]);
d = d(string({d.name})=="slprj");
for i = 1:length(d)
rmdir(fullfile(d(i).folder, d(i).name), 's')
end
end
function runBemio(testCase)
cd(testCase.h5Dir);
if isfile(testCase.h5Name)
fprintf('runBemio skipped, *.h5 already exists\n')
else
bemio
end
cd(testCase.testDir)
end
end

methods(TestMethodTeardown)
function returnHome(testCase)
cd(testCase.testDir)
end
end

methods(TestClassTeardown)
function checkVisibilityRestored(testCase)
set(0,'DefaultFigureVisible',testCase.OriginalDefault);
testCase.assertEqual(get(0,'DefaultFigureVisible'), ...
testCase.OriginalDefault);
end
end

methods(Test)
function testFullDirectionalWaves(testCase)
wecSim
close_system('OSWEC',0)
end
end
end
Loading
Loading