Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/run-tests-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
Passive_Yaw,
PTO-Sim,
Radiation_Force_Options,
RM3_PTO_Extension,
Wave_Markers,
WECCCOMP,
Write_Custom_h5]
Expand Down
9 changes: 9 additions & 0 deletions RM3_PTO_Extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# RM3 PTO Extension

**Author:** Allison File

**Version:** WEC-Sim v6.0

**Geometry:** Two-Body Point Absorber

Examples setting [PTO Extension] (https://wec-sim.github.io/WEC-Sim/master/user/advanced_features.html#constraint-and-pto-features) feature for both the float and spar bodies for the [RM3] (https://wec-sim.github.io/WEC-Sim/master/user/tutorials.html#two-body-point-absorber-rm3) geometry.
64 changes: 64 additions & 0 deletions RM3_PTO_Extension/TestRM3PTOExtension.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
classdef TestRM3PTOExtension < matlab.unittest.TestCase

properties
OriginalDefault
testDir
h5Dir = '../_Common_Input_Files/RM3/hydroData/'
h5Name = 'rm3.h5'
outName = 'rm3.out'
end

methods (Access = 'public')
function obj = TestRM3PTOExtension
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 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 testRM3_PTO_Extension_float(testCase)
cd('float')
wecSim
cd(testCase.testDir)
end
function testRM3_PTO_Extension_spar(testCase)
cd('spar')
wecSim
cd(testCase.testDir)
end
end
end
7 changes: 7 additions & 0 deletions RM3_PTO_Extension/float/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# RM3 PTO Extension for Float Body

This folder highlights the default model setup in which the PTO extension feature can be utilized to define the PTO mechanism as the float for the RM3 model.

To define the extension value for this scenario, follow the instructions oulined in the pto extension section of the constraint and pto features found at https://wec-sim.github.io/WEC-Sim/master/user/advanced_features.html#constraint-and-pto-features.

Set the 'pto.extension.PositionTargetSpecify' to 1 and set the 'pto.extension.PositionTargetValue' to the desired value within the wecSimInputFile.m.
Binary file added RM3_PTO_Extension/float/RM3.slx
Binary file not shown.
25 changes: 25 additions & 0 deletions RM3_PTO_Extension/float/userDefinedFunctions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%Example of user input MATLAB file for post processing

%Plot waves
waves.plotElevation(simu.rampTime);
try
waves.plotSpectrum();
catch
end

%Plot heave response for body 1
output.plotResponse(1,3);

%Plot heave response for body 2
output.plotResponse(2,3);

%Plot heave forces for body 1
output.plotForces(1,3);

%Plot heave forces for body 2
output.plotForces(2,3);

%Save waves and response as video
% output.saveViz(simu,body,waves,...
% 'timesPerFrame',5,'axisLimits',[-150 150 -150 150 -50 20],...
% 'startEndTime',[100 125]);
81 changes: 81 additions & 0 deletions RM3_PTO_Extension/float/wecSimInputFile.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
%% Simulation Data
simu = simulationClass(); % Initialize Simulation Class
simu.simMechanicsFile = 'RM3.slx'; % Specify Simulink Model File
simu.mode = 'normal'; % Specify Simulation Mode ('normal','accelerator','rapid-accelerator')
simu.explorer = 'on'; % Turn SimMechanics Explorer (on/off)
simu.startTime = 0; % Simulation Start Time [s]
simu.rampTime = 0; % Wave Ramp Time [s]
simu.endTime = 30; % Simulation End Time [s]
simu.solver = 'ode4'; % simu.solver = 'ode4' for fixed step & simu.solver = 'ode45' for variable step
simu.dt = 0.1; % Simulation time-step [s]

%% Wave Information
% % noWaveCIC, no waves with radiation CIC
waves = waveClass('noWaveCIC'); % Initialize Wave Class and Specify Type

% % Regular Waves
% waves = waveClass('regular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Wave Height [m]
% waves.period = 8; % Wave Period [s]

% % Regular Waves with CIC
% waves = waveClass('regularCIC'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Wave Height [m]
% waves.period = 8; % Wave Period [s]

% % Irregular Waves using PM Spectrum
% waves = waveClass('irregular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Significant Wave Height [m]
% waves.period = 8; % Peak Period [s]
% waves.spectrumType = 'PM'; % Specify Wave Spectrum Type
% waves.direction=[0];

% % Irregular Waves using JS Spectrum with Equal Energy and Seeded Phase
% waves = waveClass('irregular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Significant Wave Height [m]
% waves.period = 8; % Peak Period [s]
% waves.spectrumType = 'JS'; % Specify Wave Spectrum Type
% waves.bem.option = 'EqualEnergy'; % Uses 'EqualEnergy' bins (default)
% waves.phaseSeed = 1; % Phase is seeded so eta is the same

% % Irregular Waves using PM Spectrum with Traditional and State Space
% waves = waveClass('irregular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Significant Wave Height [m]
% waves.period = 8; % Peak Period [s]
% waves.spectrumType = 'PM'; % Specify Wave Spectrum Type
% simu.stateSpace = 1; % Turn on State Space
% waves.bem.option = 'Traditional'; % Uses 1000 frequnecies

% % Irregular Waves with imported spectrum
% waves = waveClass('spectrumImport'); % Create the Wave Variable and Specify Type
% waves.spectrumFile = 'spectrumData.mat'; % Name of User-Defined Spectrum File [:,2] = [f, Sf]

% % Waves with imported wave elevation time-history
% waves = waveClass('elevationImport'); % Create the Wave Variable and Specify Type
% waves.elevationFile = 'elevationData.mat'; % Name of User-Defined Time-Series File [:,2] = [time, eta]

%% Body Data
% Float
body(1) = bodyClass('../../_Common_Input_Files/RM3/hydroData/rm3.h5');
body(1).geometryFile = '../../_Common_Input_Files/RM3/geometry/float.stl';
body(1).mass = 'equilibrium';
body(1).inertia = [20907301 21306090.66 37085481.11]; % Moment of Inertia [kg*m^2]

% Spar/Plate
body(2) = bodyClass('../../_Common_Input_Files/RM3/hydroData/rm3.h5');
body(2).geometryFile = '../../_Common_Input_Files/RM3/geometry/plate.stl';
body(2).mass = 'equilibrium';
body(2).inertia = [94419614.57 94407091.24 28542224.82];

%% PTO and Constraint Parameters
% Floating (3DOF) Joint
constraint(1) = constraintClass('Constraint1'); % Initialize Constraint Class for Constraint1
constraint(1).location = [0 0 0]; % Constraint Location [m]

% Translational PTO
pto(1) = ptoClass('PTO1'); % Initialize PTO Class for PTO1
pto(1).stiffness = 0; % PTO Stiffness [N/m]
pto(1).damping = 0; % PTO Damping [N/(m/s)]
pto(1).location = [0 0 0]; % PTO Location [m]
pto(1).extension.PositionTargetSpecify = 1; % Initialize PTO Extension
pto(1).extension.PositionTargetValue = 5; % PTO Extension [m]
9 changes: 9 additions & 0 deletions RM3_PTO_Extension/spar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# RM3 PTO Extension for Spar Body

This file specifies the steps that need to be taken to define the PTO mechanism as the spar for the model. This can be utilized as a reference and modified for WEC design that possess similar characteristics, specifically with a higher DOF that allows movement for different system bodies.

The steps are as follows:

1. Edit only one of the two Rigid Transform (Position) blocks within the floating 3DOF constraint library block, temporarily unlocking the library to have editing access.
2. For both Rigid Transform (Position) blocks, the Translation Offset option is defined as 'constraint.initial.displacement+constraint.location.' Switch one of these to [0 0 pto.extension.PositionTargetValue]. This value will be defined within the wecSimInputFile.m
3. Follow the instructions as outlined in the pto extension section of the constraint and pto features found at https://wec-sim.github.io/WEC-Sim/master/user/advanced_features.html#constraint-and-pto-features. Set the 'pto.extension.PositionTargetSpecify' to 1 and set the 'pto.extension.PositionTargetValue' within the wecSimInputFile.m.
Binary file added RM3_PTO_Extension/spar/RM3.slx
Binary file not shown.
25 changes: 25 additions & 0 deletions RM3_PTO_Extension/spar/userDefinedFunctions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%Example of user input MATLAB file for post processing

%Plot waves
waves.plotElevation(simu.rampTime);
try
waves.plotSpectrum();
catch
end

%Plot heave response for body 1
output.plotResponse(1,3);

%Plot heave response for body 2
output.plotResponse(2,3);

%Plot heave forces for body 1
output.plotForces(1,3);

%Plot heave forces for body 2
output.plotForces(2,3);

%Save waves and response as video
% output.saveViz(simu,body,waves,...
% 'timesPerFrame',5,'axisLimits',[-150 150 -150 150 -50 20],...
% 'startEndTime',[100 125]);
81 changes: 81 additions & 0 deletions RM3_PTO_Extension/spar/wecSimInputFile.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
%% Simulation Data
simu = simulationClass(); % Initialize Simulation Class
simu.simMechanicsFile = 'RM3.slx'; % Specify Simulink Model File
simu.mode = 'normal'; % Specify Simulation Mode ('normal','accelerator','rapid-accelerator')
simu.explorer = 'on'; % Turn SimMechanics Explorer (on/off)
simu.startTime = 0; % Simulation Start Time [s]
simu.rampTime = 0; % Wave Ramp Time [s]
simu.endTime = 30; % Simulation End Time [s]
simu.solver = 'ode4'; % simu.solver = 'ode4' for fixed step & simu.solver = 'ode45' for variable step
simu.dt = 0.1; % Simulation time-step [s]

%% Wave Information
% % noWaveCIC, no waves with radiation CIC
waves = waveClass('noWaveCIC'); % Initialize Wave Class and Specify Type

% % Regular Waves
% waves = waveClass('regular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Wave Height [m]
% waves.period = 8; % Wave Period [s]

% % Regular Waves with CIC
% waves = waveClass('regularCIC'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Wave Height [m]
% waves.period = 8; % Wave Period [s]

% % Irregular Waves using PM Spectrum
% waves = waveClass('irregular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Significant Wave Height [m]
% waves.period = 8; % Peak Period [s]
% waves.spectrumType = 'PM'; % Specify Wave Spectrum Type
% waves.direction=[0];

% % Irregular Waves using JS Spectrum with Equal Energy and Seeded Phase
% waves = waveClass('irregular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Significant Wave Height [m]
% waves.period = 8; % Peak Period [s]
% waves.spectrumType = 'JS'; % Specify Wave Spectrum Type
% waves.bem.option = 'EqualEnergy'; % Uses 'EqualEnergy' bins (default)
% waves.phaseSeed = 1; % Phase is seeded so eta is the same

% % Irregular Waves using PM Spectrum with Traditional and State Space
% waves = waveClass('irregular'); % Initialize Wave Class and Specify Type
% waves.height = 2.5; % Significant Wave Height [m]
% waves.period = 8; % Peak Period [s]
% waves.spectrumType = 'PM'; % Specify Wave Spectrum Type
% simu.stateSpace = 1; % Turn on State Space
% waves.bem.option = 'Traditional'; % Uses 1000 frequnecies

% % Irregular Waves with imported spectrum
% waves = waveClass('spectrumImport'); % Create the Wave Variable and Specify Type
% waves.spectrumFile = 'spectrumData.mat'; % Name of User-Defined Spectrum File [:,2] = [f, Sf]

% % Waves with imported wave elevation time-history
% waves = waveClass('elevationImport'); % Create the Wave Variable and Specify Type
% waves.elevationFile = 'elevationData.mat'; % Name of User-Defined Time-Series File [:,2] = [time, eta]

%% Body Data
% Float
body(1) = bodyClass('../../_Common_Input_Files/RM3/hydroData/rm3.h5');
body(1).geometryFile = '../../_Common_Input_Files/RM3/geometry/float.stl';
body(1).mass = 'equilibrium';
body(1).inertia = [20907301 21306090.66 37085481.11]; % Moment of Inertia [kg*m^2]

% Spar/Plate
body(2) = bodyClass('../../_Common_Input_Files/RM3/hydroData/rm3.h5');
body(2).geometryFile = '../../_Common_Input_Files/RM3/geometry/plate.stl';
body(2).mass = 'equilibrium';
body(2).inertia = [94419614.57 94407091.24 28542224.82];

%% PTO and Constraint Parameters
% Floating (3DOF) Joint
constraint(1) = constraintClass('Constraint1'); % Initialize Constraint Class for Constraint1
constraint(1).location = [0 0 0]; % Constraint Location [m]

% Translational PTO
pto(1) = ptoClass('PTO1'); % Initialize PTO Class for PTO1
pto(1).stiffness = 0; % PTO Stiffness [N/m]
pto(1).damping = 0; % PTO Damping [N/(m/s)]
pto(1).location = [0 0 0]; % PTO Location [m]
pto(1).extension.PositionTargetSpecify = 1; % Initialize PTO Extension
pto(1).extension.PositionTargetValue = 5; % PTO Extension [m]