Skip to content

Commit 4ce0c88

Browse files
jtgrasbakeeste
andauthored
Add variable mass example (#90)
* add variable mass example * misc clean up and formatting * readme * add note on model version to readme * Update after review * Update, clean up, and add tests * remove clear * revert gitignore --------- Co-authored-by: akeeste <akeeste@sandia.gov>
1 parent 7cf01a1 commit 4ce0c88

17 files changed

Lines changed: 243643 additions & 10 deletions

Variable_Hydro/Passive_Yaw/TestVariableHydro.m renamed to Variable_Hydro/TestVariableHydro.m

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
properties
44
OriginalDefault
55
testDir
6-
h5Dir = fullfile("hydroData")
7-
h5Name = 'oswec_0.h5'
6+
h5DirPY = ['Passive_Yaw',filesep,'hydroData']
7+
h5NamePY = 'oswec_0.h5'
88
outName = 'oswec.out'
9+
h5DirVM = ['Variable_Mass',filesep,'hydroData']
10+
h5NameVM = 'draft1.h5'
11+
912
end
1013

11-
1214
methods (Access = 'public')
1315
function obj = TestVariableHydro
1416
obj.testDir = fileparts(mfilename('fullpath'));
@@ -27,9 +29,19 @@ function captureVisibility(testCase)
2729
testCase.OriginalDefault = get(0, 'DefaultFigureVisible');
2830
end
2931

30-
function runBemio(testCase)
31-
cd(testCase.h5Dir);
32-
if isfile(testCase.h5Name)
32+
function runBemioPY(testCase)
33+
cd(testCase.h5DirPY);
34+
if isfile(testCase.h5NamePY)
35+
fprintf('runBemio skipped, *.h5 already exists\n')
36+
else
37+
bemio
38+
end
39+
cd(testCase.testDir)
40+
end
41+
42+
function runBemioVM(testCase)
43+
cd(testCase.h5DirVM);
44+
if isfile(testCase.h5NameVM)
3345
fprintf('runBemio skipped, *.h5 already exists\n')
3446
else
3547
bemio
@@ -38,21 +50,30 @@ function runBemio(testCase)
3850
end
3951

4052
end
53+
54+
methods(TestMethodTeardown)
55+
function returnHome(testCase)
56+
cd(testCase.testDir)
57+
end
58+
end
4159

4260
methods(TestClassTeardown)
43-
4461
function checkVisibilityRestored(testCase)
4562
set(0, 'DefaultFigureVisible', testCase.OriginalDefault);
4663
testCase.assertEqual(get(0, 'DefaultFigureVisible'), ...
4764
testCase.OriginalDefault);
48-
end
49-
65+
end
5066
end
5167

5268
methods(Test)
53-
function testCable(testCase)
69+
function testPY(testCase)
70+
cd('Passive_Yaw')
5471
runCases
5572
end
73+
function testVM(testCase)
74+
cd('Variable_Mass')
75+
wecSim
76+
end
5677
end
5778

5879
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Variable Hydrodynamics Variable Mass
2+
3+
**Author:** Jeff Grasberger
4+
5+
**Geometry:** Sphere
6+
7+
**Original Version:** WEC-Sim v6.1
8+
9+
**Description**
10+
11+
This application demonstrates using WEC-Sim's variable hydrodynamics feature to model a sphere with a variable mass and draft.
12+
The sphere's mass is set-up to change instantaneously every 100 seconds, increasing the its draft.
13+
The existing model is simple but can be built upon to demonstrate any WEC that changes mass during a simulation.
14+
WEC-Sim by default does not support variable mass, so this model requires a broken library link to add the General Variable Mass block.
15+
To recreate (for future library updates): duplicate the changes within sphereVarMass/Float/Hydrodynamic Body/Structure
16+
R2021b or later is required because the Simulink model uses the "Create Diagonal Matrix" block which was only moved to standard Simulink in R2021b.
17+
18+
**Relevant Citation(s)**
19+
20+
Keester, A.; Ogden, D.; Husain, S.; Ruehl, K.; Pan, J.; Quiroga, J.; Grasberger, J.; Forbush, D.; Tom, N.; Housner, S.; Tran, T. (2023). Review of TEAMER Awards for WEC-Sim Support. Paper presented at 15th European Wave and Tidal Energy Conference (EWTEC 2023), Bilbao, Spain. https://doi.org/10.36688/ewtec-2023-261
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function body1_hydroForceIndex = calcIndex(time)
2+
3+
body1_hydroForceIndex = floor(time/100) + 1; % Increase the mass every 100 seconds
4+
5+
if body1_hydroForceIndex > 9
6+
body1_hydroForceIndex = 9; % restrict to 9 (# of hydrodata files)
7+
end
8+
9+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
close all
2+
3+
for ii = 1:9
4+
5+
hydro = struct();
6+
7+
outName = ['draft' num2str(ii) '.out'];
8+
9+
hydro = readWAMIT(hydro,outName,[]);
10+
hydro = radiationIRF(hydro,15,[],[],[],6);
11+
hydro = radiationIRFSS(hydro,[],[]);
12+
hydro = excitationIRF(hydro,15,[],[],[],[]);
13+
writeBEMIOH5(hydro)
14+
15+
end

Variable_Hydro/Variable_Mass/hydroData/draft1.out

Lines changed: 27048 additions & 0 deletions
Large diffs are not rendered by default.

Variable_Hydro/Variable_Mass/hydroData/draft2.out

Lines changed: 27048 additions & 0 deletions
Large diffs are not rendered by default.

Variable_Hydro/Variable_Mass/hydroData/draft3.out

Lines changed: 27048 additions & 0 deletions
Large diffs are not rendered by default.

Variable_Hydro/Variable_Mass/hydroData/draft4.out

Lines changed: 27048 additions & 0 deletions
Large diffs are not rendered by default.

Variable_Hydro/Variable_Mass/hydroData/draft5.out

Lines changed: 27048 additions & 0 deletions
Large diffs are not rendered by default.

Variable_Hydro/Variable_Mass/hydroData/draft6.out

Lines changed: 27048 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)