Skip to content

Commit

Permalink
Multi wave class bug fix v2 (WEC-Sim#1373)
Browse files Browse the repository at this point in the history
* fixes a bug that happens when multiple waves are defined

* Adjusts the lin block version to 2020b

* reduce number of From blocks in exc force blocks, mask update respectively

* Allows QTF calculation for multiple wave instances

* revert change to rm3.h
5

---------

Co-authored-by: akeeste <[email protected]>
  • Loading branch information
MShabara and akeeste authored Dec 3, 2024
1 parent 2c12e29 commit bdad54a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/functions/initializeWecSim.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
for kk = 1:length(idx)
ii = idx(kk);
for iH = 1:length(body(ii).hydroData)
body(ii).hydroForcePre(waves(1), simu, iH);
body(ii).hydroForcePre(waves, simu, iH);
end
end
end; clear kk idx ii
Expand Down
Binary file modified source/lib/WEC-Sim/WECSim_Lib_Body_Elements.slx
Binary file not shown.
14 changes: 11 additions & 3 deletions source/objects/bodyClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,12 @@ function dragForcePre(obj,rho)
obj.dof = length(obj.quadDrag.drag);
end

function hydroForcePre(obj, waves, simu, iH)
function hydroForcePre(obj, waveObj, simu, iH)
% HydroForce Pre-processing calculations
% 1. Set the linear hydrodynamic restoring coefficient, viscous drag, and linear damping matrices
% 2. Set the wave excitation force
% 3. Loop through all included hydroData files
waves = waveObj(1);
w = waves.omega;
direction = waves.direction;
cicTime = simu.cicTime;
Expand Down Expand Up @@ -488,7 +489,7 @@ function hydroForcePre(obj, waves, simu, iH)
if ~isfield(obj.hydroData(iH).hydro_coeffs.excitation, 'QTFs')
error('QTF coefficients are not defined for the body object "%s"', obj.name);
else
obj.qtfExcitation(waveAmpTime, iH);
obj.qtfExcitation(waveObj, iH);
end
end
end
Expand Down Expand Up @@ -746,10 +747,17 @@ function noExcitation(obj, iH)
obj.hydroForce.(hfName).fExt.im=zeros(1,nDOF);
end

function qtfExcitation(obj, waveAmpTime, iH)
function qtfExcitation(obj, wavesObj, iH)
% second order excitation force
% Used by hydroForcePre
hfName = ['hf' num2str(iH)];

waveAmpTime(:,1) = wavesObj(1).waveAmpTime(:,1);
waveAmpTime(:,2) = wavesObj(1).waveAmpTime(:,2);

for iWaves = 2 : length(wavesObj)
waveAmpTime(:,2) = waveAmpTime(:,2) + wavesObj(iWaves).waveAmpTime(:,2);
end

F_max = 1 / (waveAmpTime(2,1) - waveAmpTime(1,1)); % Maximum samplng freq.
Amp_freq = fft(waveAmpTime(:,2));
Expand Down

0 comments on commit bdad54a

Please sign in to comment.