Skip to content

Commit

Permalink
Resolve conflicts between variable hydro and GBM (WEC-Sim#1317)
Browse files Browse the repository at this point in the history
* fix linearDamping expansion in GBM

* fix linearDamping expansion in GBM v2

* prevent GBM and variable hydro together

* update MoorDyn README based on one in WEC-Sim/MoorDyn repo

* prevent user defined Fexc and VH together

* fixed user defined functions

* fix GBM and VH compatibility
  • Loading branch information
akeeste authored Sep 11, 2024
1 parent 1f81ce4 commit d2e5ce4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/functions/initializeWecSim.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
dragBodLogic = zeros(length(body(1,:)),1);
for ii = 1:length(body(1,:))
body(ii).setNumber(ii);
body(ii).checkInputs(simu.explorer, simu.stateSpace, simu.FIR);
body(ii).checkInputs(simu.explorer, simu.stateSpace, simu.FIR, waves.typeNum);
if body(ii).nonHydro==0
if numNonHydroBodies > 0 || numDragBodies > 0
error('All hydro bodies must be specified before any drag or non-hydro bodies.')
Expand Down
2 changes: 1 addition & 1 deletion source/functions/moorDyn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ along with MoorDyn. If not, see <http://www.gnu.org/licenses/>.

---------------------- More Information -------------------------

More information about MoorDyn is now available at <moordyn.readthedocs.io> -- including the User's Guide, source code, and examples.
More information about MoorDyn is now available at [moordyn.readthedocs.io](https://moordyn.readthedocs.io/en/latest/) -- including the User's Guide, source code, and examples.

For information about MoorDyn's formulation and some validation
results, see M. Hall and A. Goupee, ìValidation of a lumped-mass
Expand Down
Binary file modified source/lib/WEC-Sim/WECSim_Lib_Body_Elements.slx
Binary file not shown.
21 changes: 16 additions & 5 deletions source/objects/bodyClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'angle', 0) % (`structure`) Defines the initial displacement of the body. ``displacement`` (`1x3 float vector`) is defined as the initial displacement of the body center of gravity (COG) [m] in the following format [x y z], Default = [``0 0 0``]. ``axis`` (`1x3 float vector`) is defined as the axis of rotation in the following format [x y z], Default = [``0 1 0``]. ``angle`` (`float`) is defined as the initial angular displacement of the body COG [rad], Default = ``0``.
largeXYDisplacement (1,1) struct = struct(... %
'option', 0) %
linearDamping (6,6,:) {mustBeNumeric} = zeros(6) % (`6x6 float matrix`) Defines linear damping coefficient matrix. Create a 3D matrix (6x6xn) for variable hydrodynamics. Default = ``zeros(6)``.
linearDamping {mustBeNumeric} = zeros(6) % (`6x6 float matrix`) Defines linear damping coefficient matrix. Create a 3D matrix (6x6xn) for variable hydrodynamics. Default = ``zeros(6)``.
mass (1,:) = [] % (`float`) Translational inertia or mass [kg]. Defined by the user or specify 'equilibrium' to set the mass equal to the fluid density times displaced volume. Default = ``[]``.
meanDrift (1,1) {mustBeInteger} = 0 % (`integer`) Flag for mean drift force, Options: 0 (no), 1 (yes, from control surface) or 2 (yes, from momentum conservation). Default = ``0``.
morisonElement (1,1) struct = struct(... % (`structure`) Defines the Morison Element properties connected to the body.
Expand Down Expand Up @@ -132,7 +132,7 @@

end

function checkInputs(obj, explorer, stateSpace, FIR)
function checkInputs(obj, explorer, stateSpace, FIR, typeNum)
% This method checks WEC-Sim user inputs for each body and generates error messages if parameters are not properly defined for the bodyClass

% Check struct inputs:
Expand Down Expand Up @@ -302,6 +302,9 @@ function checkInputs(obj, explorer, stateSpace, FIR)
if FIR == 1
error('The FIR filter radiation force method is not compatible with variable hydrodynamics.');
end
if typeNum >= 30
error('The user defined wave excitation force is not compatible with variable hydrodynamics.');
end
end
elseif obj.nonHydro>0
% This method checks WEC-Sim user inputs for each drag or non-hydro
Expand Down Expand Up @@ -354,6 +357,9 @@ function loadHydroData(obj, hydroData, iH)
obj.dofEnd = hydroData.properties.dofEnd;
obj.gbmDOF = obj.dof-6;
end
if obj.dof > 6 && obj.variableHydro.option == 1
error('Variable hydro is not compatible with Generalized body modes.');
end
end

function nonHydroForcePre(obj,rho)
Expand Down Expand Up @@ -403,13 +409,18 @@ function hydroForcePre(obj, waves, simu, iH)
% obj.linearDamping = [obj.linearDamping zeros(1,obj.dof-length(obj.linearDamping))];
tmp0 = obj.linearDamping;
tmp1 = size(obj.linearDamping);
obj.linearDamping = zeros(obj.dof, obj.dof, tmp1(3));
obj.linearDamping(1:tmp1(1),1:tmp1(2),:) = tmp0;
if ndims(tmp0) > 2
obj.linearDamping = zeros(obj.dof, obj.dof, tmp1(3));
obj.linearDamping(1:tmp1(1),1:tmp1(2),:) = tmp0;
else
obj.linearDamping = zeros(obj.dof);
obj.linearDamping(1:tmp1(1),1:tmp1(2)) = tmp0;
end

for i = 1:length(obj.quadDrag)
tmp0 = obj.quadDrag(i).drag;
tmp1 = size(obj.quadDrag(i).drag);
obj.quadDrag(i).drag = zeros (obj.dof);
obj.quadDrag(i).drag = zeros(obj.dof);
obj.quadDrag(i).drag(1:tmp1(1),1:tmp1(2)) = tmp0;

obj.quadDrag(i).cd = [obj.quadDrag(i).cd zeros(1,obj.dof-length(obj.quadDrag(i).cd))];
Expand Down

0 comments on commit d2e5ce4

Please sign in to comment.