Skip to content

Commit

Permalink
Adaptive sine-taper SPOD
Browse files Browse the repository at this point in the history
  • Loading branch information
olivertschmidt authored Sep 14, 2024
1 parent 12d6d7d commit 48e0c1d
Show file tree
Hide file tree
Showing 4 changed files with 630 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ SPOD() is a Matlab implementation of the frequency domain form of proper orthogo
The large-eddy simulation data provided along with this example is a subset of the database of a Mach 0.9 turbulent jet described in [3] and was calculated using the unstructured flow solver Charles developed at Cascade Technologies. If you are using the database in your research or teaching, please include explicit mention of Brès et al. [3]. The test database consists of 5000 snapshots of the symmetric component (m=0) of a round turbulent jet.

`spod.m` is a stand-alone Matlab function with no toolbox dependencies. All other Matlab files contained in this repository are related to the six examples that demonstrate the functionality of the code (see file descriptions below). A physical interpretation of the results obtained from the examples can be found in [[4](https://arxiv.org/abs/1711.06296)]. The reference for the frequency-time analsyis is [[5](https://arxiv.org/abs/2011.03644)].

`spod_adaptive.m` is the adaptive sine-taper SPOD algorithm for broadband-tonal flows by Yeung & Schmidt [[7](https://arxiv.org/abs/2312.02385)]

## Download

### Using your browser
Expand All @@ -19,6 +22,7 @@ git clone https://github.com/SpectralPOD/spod_matlab.git
| File | Description |
| ------------- |:-------------|
| spod.m | Spectral proper orthogonal decomposition in Matlab |
| spod_adaptive.m | Adaptive sine-taper SPOD in Matlab |
| example_1.m | Inspect data and plot SPOD spectrum |
| example_2.m | Plot SPOD spectrum and inspect SPOD modes |
| example_3.m | Specify spectral estimation parameters and use weighted inner product |
Expand All @@ -28,6 +32,7 @@ git clone https://github.com/SpectralPOD/spod_matlab.git
| example_7_FTanalysis.m | Frequency-time analysis |
| example_8_invspod.m | Band-pass filtering using (inverse) SPOD |
| example_9_multitaperWelch | SPOD using Multitaper-Welch estimators |
| example_10_sineAdaptive | Adaptive SPOD example|
| tcoeffs.m | Time-continuous expansion coefficients via convolution |
| invspod.m | Inversion of SPOD using block-wise expansion coefficients |
| jet_data/getjet.m | Interfaces external data source with SPOD() (examples 4-5) |
Expand Down Expand Up @@ -125,3 +130,5 @@ the SPOD.
[5] Nekkanti, A. and Schmidt, O. T., *Frequency–time analysis, low-rank reconstruction and denoising of turbulent flows using SPOD* , J. of Fluid Mech. 926, A26, DOI 10.1017/jfm.2021.681, 2021

[6] Schmidt, O. T., *Spectral proper orthogonal decomposition using multitaper estimates*, Theor. Comput. Fluid Dyn., 1-14, DOI 10.1007/s00162-022-00626-x, https://rdcu.be/cUtP3, 2022

[7] Yeung, B. C. Y., Schmidt, O. T. *Adaptive spectral proper orthogonal decomposition of broadband-tonal flows*, Theor. Comput. Fluid Dyn. 38, 355–374, 2024, DOI 10.1007/s00162-024-00695-0
Binary file added cavity_data/cavityPIV.mat
Binary file not shown.
108 changes: 108 additions & 0 deletions example_10_sineAdaptive.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
%% EXAMPLE 10: Adaptive sine-taper SPOD.
% The time-resolved particle image velocimetry data provided along with
% this example are a subset of the database of a Mach 0.6 turbulent open
% cavity flow by Zhang et al. [1]. If you are using the database in your
% research or teaching, please include explicit mention of Zhang et al.
% [1]. The test database consists of 4000 snapshots of the streamwise
% velocity component of a turbulent open cavity flow. This is a canonical
% example of a mixed broadband-tonal turbulent flow, which requires sharp
% peak resolution at tonal frequencies and smooth spectrum estimates of
% broadband regions. If you are using this code for your research, please
% cite Yeung & Schmidt [2].
%
% References:
% [1] Zhang, Y., Cattafesta, L. N., and Ukeiley, L., Spectral analysis
% modal methods (SAMMs) using non-time-resolved PIV, Exp. Fluids 61, 226, 1–12, 2020,
% DOI 10.1007/s00348-020-03057-8
% [2] Yeung, B. C. Y., Schmidt, O. T. Adaptive spectral proper orthogonal decomposition
% of broadband-tonal flows, Theor. Comput. Fluid Dyn. 38, 355–374, 2024,
% DOI 10.1007/s00162-024-00695-0
%
% B. Yeung (byeung@ucsd.edu) and O. T. Schmidt (oschmidt@ucsd.edu)
% Last revision: 10-Sep-2024

clc, clear variables
addpath('utils')
load(fullfile('cavity_data','cavityPIV.mat'),'u','x','y','dt');

%% Standard Welch SPOD of the test database using one sine window.
% We manually specify a window length of 256 and an overlap
% of 128 snaphots. A sine function is automatically used as the window.

% SPOD using a sine window of length 256 and 128 snaphots overlap
nDFT = 256;
nOvlp = 128;
[L,P,f] = spod_adapt(u,nDFT,[],nOvlp,dt);

%% Plot the SPOD spectrum and some modes.
figure
loglog(f,L)
xlabel('frequency'), ylabel('SPOD mode energy'), title('Welch SPOD')

%% Multitaper SPOD using six sine windows.
% We can achieve higher frequency resolution and resolve down to lower
% minimum frequencies using six sine windows of length equal to the
% number of snapshots. Specify nWin as a vector of length 4000.
% Multitaper SPOD neither requires nor benefits from overlap, so we leave
% nOvlp empty.

% SPOD using six sine windows of length 4000 and 0 overlap
nWin = 6*ones(size(u,1),1);
[L,P,f] = spod_adapt(u,nWin,[],[],dt);

%% Plot the SPOD spectrum.
figure
loglog(f,L)
xlabel('frequency'), ylabel('SPOD mode energy'), title('multitaper SPOD')

%% Adaptive multitaper SPOD.
% To combine both sharp peak resolution and smooth spectrum estimates of
% broadband regions, we allow the window number to vary with frequency.
% The adaptive algorithm requires only a tolerance and determines the
% window number autonomously. No spectral estimation parameters
% are needed.

% SPOD using the adaptive algorithm with a tolerance of 1e-4
% Can take a long time to compute
clear opts
opts.adaptive = true;
opts.tol = 1e-4;
[L,P,f,~,nWin] = spod_adapt(u,[],[],[],dt,opts);

%% Plot the SPOD spectrum and window number.
figure
yyaxis left
loglog(f,L)
xlabel('frequency'), ylabel('SPOD mode energy'), title('adaptive multitaper SPOD')

yyaxis right
semilogx(f,nWin)
ylabel('number of windows')

%% Plot some SPOD modes (Rossiter modes)
figure
count = 1;
for fi = [470 770 1063]
for mi = [1 2]
subplot(3,2,count)
contourf(x,y,real(squeeze(P(fi,:,:,mi))),11,'edgecolor','none'), axis equal tight, clim(max(abs(clim))*[-1 1])
xlabel('x'), ylabel('y'), title(['f=' num2str(f(fi),'%.2f') ', mode ' num2str(mi) ', \lambda=' num2str(L(fi,mi),'%.2g')])
count = count + 1;
end
end

% %% Multitple SPOD using non-uniform window number.
% % If the (potentially non-uniform) window number is known a priori, e.g.,
% % based on physical knowledge, it can be provided directly. As an example,
% % we use the nWin computed previously to recover the same results as before.
%
% % SPOD using sine windows of length 4000, 0 overlap, and
% % frequency-dependent window number
% if length(nWin)<size(u,1), nWin(size(u,1)) = 0; end % zero-pad nWin to length 4000
% [L,P,f] = spod_adapt(u,nWin,[],[],dt);
%
% %% Plot the SPOD spectrum.
% % The spectrum should be identical to the previous figure.
% figure
% loglog(f,L)
% xlabel('frequency'), ylabel('SPOD mode energy'), title('multitaper SPOD with non-uniform window number')
Loading

0 comments on commit 48e0c1d

Please sign in to comment.