Skip to content

Conversation

@jtgrasb
Copy link
Contributor

@jtgrasb jtgrasb commented Oct 2, 2024

This PR is a for #1328 and attempts to resolve the merge conflicts.

dforbush2 and others added 30 commits June 28, 2023 11:37
@jtgrasb jtgrasb mentioned this pull request Nov 21, 2024
@dforbush2
Copy link
Contributor

Sorry Jeff. Lets talk to Adam and see what changes were made. we may be able to add them to this PR. Apologies I didn't realize this was waiting on me for a merge.

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Nov 21, 2024

No problem. I thought I had left a comment for you to review it, but I guess I didn't

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Nov 25, 2024

To do:

  1. Pull in latest dev branch and resolve conflicts, using body elements library from dev.
  2. Re-add full directional spectrum variant subsystem to the body elements library.
  3. Test full directional spectrum functionality and edit PR if necessary.

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Nov 26, 2024

@dforbush2 I've resolved the conflicts but haven't reviewed this PR yet. Could you send me the scripts you were using to test out the feature?

@dforbush2
Copy link
Contributor

@jtgrasb you can use the input data 'fullDirWave.mat' I have sent via email. These are (frequency, amplitude, direction, spread) as specified. You will need an input file with
waves = waveClass('spectrumImportFullDir');
waves.spectrumFile = ('fullWaveDir.mat');
waves.freqDepDirection.directions = fullDirWave(:,3);
waves.freqDepDirection.spreads = fullDirWave(:,4);
waves.freqDepDirection.dirRes =10 ; % for example
waves.freqDepDirection.nbins=10; % for example
waves.freqDepDirection.spreadRange=2; % for example

I recommend the Pioneer as a test case.

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Nov 27, 2024

Thanks @dforbush2. I tried the full directional spectrum with the pioneer example and I am getting some errors. I resolved some of them, but looks like there's some variable size issues, so if you could take a look at some point in the next couple weeks, that would be great.
image

Here's a zip for the test case: pioneerTest.zip

@dforbush2
Copy link
Contributor

@jtgrasb this is good to go! HOWEVER: at this time it will not work with non-linear hydro. That will require another variant subsystem and library change, and I think is best reserved for a future PR.

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Dec 10, 2024

This looks great and functionality seems to work well! A few questions/suggestions:

  1. Looks like this doesn't work with wave markers either. Is that intentional? Since spectrum import works with the wave markers, we should be able to get this working with wave markers, right?
  2. Can you add the Simulink variant variables (e.g. sv_fullDirIrregularWaves_b*) to the clear line in stopWecSim?

@dforbush2
Copy link
Contributor

dforbush2 commented Dec 10, 2024 via email

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Dec 10, 2024

It doesn't produce an error, it just doesn't plot the wave markers. There's a line in initializeWecSim where the visualization is only on if typeNum is less than 30:
image

@dforbush2
Copy link
Contributor

dforbush2 commented Dec 10, 2024 via email

@dforbush2
Copy link
Contributor

dforbush2 commented Dec 11, 2024

@jtgrasb tested on pioneer and everything works. This is ready to merge, but please give the docs a read and make sure it is clear enough. This shouldn't prevent a merge at this time, I can fix docs later, but worth some more eyes.

@jtgrasb jtgrasb merged commit a8b9dc0 into WEC-Sim:dev Dec 11, 2024
10 checks passed
@akeeste akeeste mentioned this pull request Jan 16, 2025
6 tasks
Comment on lines +938 to +973
if obj.yaw.option ==1 && length(BEMdir)<3 || std(diff(BEMdir))>5 || max(boundDiff)>15
warning(['Passive yaw is not recommended without BEM data spanning a full yaw rotation -180 to 180 dg.' newline ...
'Please inspect BEM data for gaps'])
clear BEMdir boundDiff
clear boundDiff
end
if ~isempty(dirBins)
BEMdir=wrapTo180(BEMdir-180);
boundDiff(1)=abs(min(dirBins,[],'all') - BEMdir(1)); boundDiff(2)=min(abs(max(dirBins,[],'all') - BEMdir(end)),...
abs(max(dirBins,[],'all')-180-BEMdir(1)));
[obj.hydroForce.(hfName).fExt.qDofGrd,null,obj.hydroForce.(hfName).fExt.qWGrd]=ndgrid([1:nDOF],dirBins(1,:),wv); % this is necessary for nd interpolation; query grids be same size as dirBins.
if length(BEMdir)<3 || max(boundDiff)>15
warning(['BEM directions do not cover the directional spread bins or are too coarse to define spread bin distribution.' newline ...
'Re-run with more bins']);
clear boundDiff BEMdir
end
end
[sortedDir,idx]=sort(wrapTo180(obj.hydroData(iH).simulation_parameters.direction));
[hdofGRD,hdirGRD,hwGRD]=ndgrid(1:6,sortedDir, obj.hydroData(iH).simulation_parameters.w);
[obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd]=ndgrid(1:6,...
[hdofGRD,hdirGRD,hwGRD]=ndgrid([1:nDOF],sortedDir, obj.hydroData(iH).simulation_parameters.w);
if (max(sortedDir) - min(sortedDir)) < 360
warning('Full directional wave spectra requires full 360 dg BEM. You do not have that. Attempting to fix via spline extrapolation. Ideally preprocess BEM')
if min(sortedDir) > -180
sortedDir2=zeros(1,length(sortedDir)+1);
sortedDir2(2:end)=sortedDir;
sortedDir2(1)=-180;
sortedDir=sortedDir2;
clear sortedDir2;
end
if max(sortedDir) < 180
sortedDir2=zeros(1,length(sortedDir2+1));
sortedDir2(1:end-1)=sortedDir;
sortedDir2(end)=-180;
sortedDir=sortedDir2;
clear sortedDir2;
end

end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wave direction binning

Comment on lines +974 to +981
[obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd]=ndgrid([1:nDOF],...
sortedDir,wv);
obj.hydroForce.(hfName).fExt.fEHRE=interpn(hdofGRD,hdirGRD,hwGRD,obj.hydroData(iH).hydro_coeffs.excitation.re(:,idx,:),...
obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd)*rho*g;
obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd,'spline')*rho*g;
obj.hydroForce.(hfName).fExt.fEHIM=interpn(hdofGRD,hdirGRD,hwGRD,obj.hydroData(iH).hydro_coeffs.excitation.im(:,idx,:),...
obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd)*rho*g;
obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd,'spline')*rho*g;
obj.hydroForce.(hfName).fExt.fEHMD=interpn(hdofGRD,hdirGRD,hwGRD,obj.hydroData(iH).hydro_coeffs.mean_drift(:,idx,:)...
,obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd)*rho*g;
,obj.hydroForce.(hfName).fExt.dofGrd,obj.hydroForce.(hfName).fExt.dirGrd,obj.hydroForce.(hfName).fExt.wGrd,'spline')*rho*g;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grid interpolation becomes spline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Wave Class Wave Classs (waveClass.m)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Developer Issue]: Aligning wave spread function with IEC standards

4 participants