Energy-Pathways-Group / GLOceanKit

Tools for physical oceanography in Matlab and Objective-C
21 stars 11 forks source link

internal wave model with arbitrary strat fails to initialize with GM #60

Closed nlbeaird closed 1 year ago

nlbeaird commented 1 year ago

Hi, this is a wonderful package and resource, thank you! I'm not sure if you are still maintaining the matlab/internalwavemodel component, but if so I have a question. I was trying to use it with the default README quick start and am getting an error when I combine exponential/ arbitrary stratification with the GM initialization. It looks like internalmodes may have moved past internalwavemodel. just curious if you have an idea of a a quick fix or if there is something obvious I am doing wrong. Thanks!

aspectRatio = 8;
Lx = 100e3;
Ly = aspectRatio*100e3;
Lz = 5000;
Nx = 64;

Ny = aspectRatio*64;
Nz = 65; % 2^n + 1 grid points, to match the Winters model, but 2^n ok too.
latitude = 31;
[rho, ~, zIn] = InternalModes.StratificationProfileWithName('exponential');
z = linspace(min(zIn),max(zIn),100)';
maxModes = 32;
wavemodel = InternalWaveModelArbitraryStratification([Lx, Ly, Lz], [Nx, Ny, Nz], rho, z, maxModes, latitude);
wavemodel.InitializeWithGMSpectrum(1.0);

the error reads:

One or more output arguments not assigned during call to "varargout".

Error in InternalWaveModelArbitraryStratification/ComputeModesForK2UniqueIndex (line 321)

            [F,G,h,~,F2_,N2G2_,G2_] = self.internalModes.ModesAtWavenumber(sqrt(kk));

Error in InternalWaveModelArbitraryStratification/ComputeModesForNonzeroWavenumbers (line 214)

                self.ComputeModesForK2UniqueIndex(index);

Error in InternalWaveModelArbitraryStratification/InitializeWithSpectralFunction (line 181)

            self.ComputeModesForNonzeroWavenumbers( 1 );

Error in InternalWaveModel/InitializeWithGMSpectrum (line 798)

            [GM3Dint,GM3Dext] = self.InitializeWithSpectralFunction(GM2D_int,varargin{:});

Error in nlb_test2 (line 25)

wavemodel.InitializeWithGMSpectrum(1.0);
JeffreyEarly commented 1 year ago

Hi Nick---yes, you are correct that the code moved past, in fact, we are nearly finished with a major refactor that is on the integrator-tracer-floats-refactor branch. The model is now called the `Wave Vortex Model' and we are starting put documentation online at wavevortexmodel.org.

The refactor will be done by the end of the calendar year (hopefully sooner). If you look in the GLOceanKit/Matlab/WaveVortexModel/Examples folder you'll find some of the examples have been updated to work with the new code. Documentation takes a while, but I'll be prioritizing a better Users Guide and examples.

So anyway, you're welcome to poke around with the new code now, or hold off a bit longer. I will only promise not to break the API once I pull it back to the main branch :-)

nlbeaird commented 1 year ago

Hi Jeff, Thanks so much for the quick response! Thanks for the pointer to the refactor, I'll poke around a bit. Excited to see this and looking forward to using it! I appreciate all the hard work!