Root mean square of velocity fluctuations

14 ビュー (過去 30 日間)
Hussein Kokash
Hussein Kokash 2022 年 12 月 28 日
コメント済み: Star Strider 2022 年 12 月 28 日
Hello,
I am trying to calculate root mean square of velocity fluctuations in a 2D plane (x,y) coordinates with (U, V) velocity values.
Total number of points I have are 4489.
What am looking for is something like this:
Image reference: Lin, L. M., & Wu, Y. X. (2018). New interpretation of specific sign of Reynolds stress in the boundary layer on a flat plate. Theoretical and Applied Mechanics Letters, 8(6), 372-377.
I have tried the rms function:
clear all; clc; %close all;
path = pwd;
R = dir(fullfile(path,'data_2.txt'));
S = natsortfiles(R);
if iscell(S) == 0;
S = (S);
end
for k = 1:numel(S)
folder = S(k).folder;
filename = S(k).name;
F = fullfile(S(k).folder,S(k).name);
data = dlmread(F);
x = data(:,1); % x coordinate
y = data(:,2); % y coordinate
U(:,k) = data(:,4); % u velocity
V(:,k) = data(:,5); % v velocity
M_data = mean(V);
RMS_data = rms(V);
VrmsC = sqrt(mean(V.^2,2))/C; % RMS Velocity/C
figure
plot(y, V)
plot(xlim, [1 1]*M_data, 'LineWidth',1.5) plot(xlim, [1 1]*RMS_data, 'LineWidth',1.5)
plot(VrmsC, y, 'LineWidth',1.5)
plot (y, RMS_data)
end
But with no luck getting something similar to the figure above.
The data file is attached if needed.
Any thoughts how to do so?
Thank you

採用された回答

Star Strider
Star Strider 2022 年 12 月 28 日
The data are gridded, and actually for surfaces.
How do you want to calculate the RMS value of a surface?
data = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1245882/data_2.txt')
data = 4489×6
-0.0260 -0.1080 0.1000 0.3603 -0.2634 -0.0000 -0.0260 -0.1070 0.1000 0.4157 -0.2396 -0.0000 -0.0260 -0.1060 0.1000 0.4301 -0.2578 -0.0000 -0.0260 -0.1050 0.1000 0.4183 -0.2700 -0.0000 -0.0260 -0.1040 0.1000 0.3944 -0.2723 -0.0000 -0.0260 -0.1030 0.1000 0.3726 -0.2774 -0.0000 -0.0260 -0.1020 0.1000 0.3565 -0.2884 -0.0000 -0.0260 -0.1010 0.1000 0.3432 -0.3020 -0.0000 -0.0260 -0.1000 0.1000 0.3291 -0.3149 -0.0000 -0.0260 -0.0990 0.1000 0.3124 -0.3263 -0.0000
x = data(:,1); % x coordinate
y = data(:,2); % y coordinate
U = data(:,4); % u velocity
V = data(:,5); % v velocity
[Ux,ix] = unique(x);
Uix = unique(diff(ix))
Uix = 67
[Uy,iy] = unique(y);
N = Uix;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[X,Y] = ndgrid(xv,yv);
Um = reshape(U,Uix,[]);
Vm = reshape(V,Uix,[]);
RMS_U = sqrt(mean(Um.^2))
RMS_U = 1×67
0.2156 0.2281 0.2392 0.2515 0.2668 0.2857 0.3077 0.3329 0.3597 0.3886 0.4186 0.4489 0.4796 0.5088 0.5377 0.5653 0.5913 0.6162 0.6384 0.6596 0.6788 0.6961 0.7118 0.7248 0.7357 0.7442 0.7504 0.7547 0.7572 0.7583
RMS_V = sqrt(mean(Vm.^2))
RMS_V = 1×67
0.3592 0.3714 0.3846 0.4000 0.4175 0.4363 0.4547 0.4709 0.4832 0.4900 0.4903 0.4829 0.4676 0.4446 0.4149 0.3798 0.3405 0.2987 0.2565 0.2169 0.1850 0.1687 0.1751 0.2037 0.2472 0.2988 0.3537 0.4087 0.4624 0.5114
figure
plot(RMS_U, 'DisplayName','RMS(U)')
hold on
plot(RMS_V, 'DisplayName','RMS(V)')
hold off
grid
legend('Location','best')
figure
surfc(X,Y,Um)
grid on
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('U')
figure
surfc(X,Y,Vm)
grid on
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('V')
This calculates the RMS values by using the square root of the square of the column mean for each surface.
Experiment to get the result you want. See the documentation on mean to take the unweighted mean across the rows instead.
.
  2 件のコメント
Hussein Kokash
Hussein Kokash 2022 年 12 月 28 日
Hello Star Strider, thank you for the informative comment, I have tested it out and I was able to plot:
plot(RMS_U, yv, 'DisplayName','RMS(U)')
This is the results:
Exactly what I was looking for!
Thank you for your non-stop support, appreciate it.
Star Strider
Star Strider 2022 年 12 月 28 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by