My simulation doesn't take into account the different height of the Faraday waves?

4 次查看(过去 30 天)
Could you please tell me why the following plot doesn't give a correct plotting of the different heights of the Faraday waves? Thanks a lot!
% Define physical parameters
g = 9.81; % acceleration due to gravity
d = 0.1; % fluid depth
omega = 0.1; % forcing frequency
% Define grid parameters
Nx = 100; % number of x grid points
Ny = 100; % number of y grid points
Lx = 1; % length of x dimension
Ly = 1; % length of y dimension
dx = Lx/Nx; % grid spacing in x direction
dy = Ly/Ny; % grid spacing in y direction
[x, y] = meshgrid(dx/2:dx:Lx-dx/2, dy/2:dy:Ly-dy/2); % grid
% Define initial conditions
u = zeros(Nx, Ny); % x-velocity
v = zeros(Nx, Ny); % y-velocity
h = zeros(Nx, Ny); % surface height
% Define forcing function
F = @(t) 0.1*sin(omega*t);
% Define time-stepping parameters
dt = 0.001; % time step
tmax = 10; % maximum time
t = 0:dt:tmax; % time vector
% Perform time-stepping
for ii = 1:length(t)
% Loop through grid points, updating surface height and velocities
for jj = 1:Nx
for kk = 1:Ny
% Calculate acceleration using equations of motion
a_x = -g*h(jj,kk)*sin(h(jj,kk)) - g/2*(u(jj,kk)^2 + v(jj,kk)^2) + F(t(ii));
a_y = -g*h(jj,kk)*sin(h(jj,kk)) - g/2*(u(jj,kk)^2 + v(jj,kk)^2) + F(t(ii));
% Update velocities
u(jj,kk) = u(jj,kk) + a_x*dt;
v(jj,kk) = v(jj,kk) + a_y*dt;
% Update surface height
h(jj,kk) = h(jj,kk) + dt*(u(jj,kk)*v(jj,kk) - g/2*h(jj,kk)^2);
end
end
end
% Plot results
figure;
mesh(x, y, h);
xlabel('x');
ylabel('y');
zlabel('surface height');

采纳的回答

VBBV
VBBV 2023-1-7
% Define physical parameters
g = 9.81; % acceleration due to gravity
d = 0.1; % fluid depth
omega = 0.1; % forcing frequency
% Define grid parameters
Nx = 100; % number of x grid points
Ny = 100; % number of y grid points
Lx = 1; % length of x dimension
Ly = 1; % length of y dimension
dx = Lx/Nx; % grid spacing in x direction
dy = Ly/Ny; % grid spacing in y direction
[x, y] = meshgrid(dx/2:dx:Lx-dx/2, dy/2:dy:Ly-dy/2); % grid
% Define initial conditions
u = zeros(Nx, Ny); % x-velocity
v = zeros(Nx, Ny); % y-velocity
h = zeros(Nx, Ny); % surface height
% Define forcing function
F = @(t) 0.1*sin(omega*t);
% Define time-stepping parameters
dt = 0.1; % time step
tmax = 1; % maximum time
t = 0:dt:tmax; % time vector
% Perform time-stepping
for ii = 1:length(t)
% Loop through grid points, updating surface height and velocities
for jj = 1:Nx-1
for kk = 1:Ny-1
% Calculate acceleration using equations of motion
a_x = -g*h(jj,kk)*sin(h(jj,kk)) - g/2*(u(jj,kk)^2 + v(jj,kk)^2) + F(t(ii));
a_y = -g*h(jj,kk)*sin(h(jj,kk)) - g/2*(u(jj,kk)^2 + v(jj,kk)^2) + F(t(ii));
% Update velocities
u(jj+1,kk+1) = u(jj,kk) + a_x*dt;
v(jj+1,kk+1) = v(jj,kk) + a_y*dt;
% Update surface height
h(jj+1,kk+1) = h(jj,kk) + dt*(u(jj,kk)*v(jj,kk) - g/2*h(jj,kk)^2);
end
end
nexttile
mesh(x, y, h);
xlabel('x');
ylabel('y');
zlabel('h');
title(sprintf('t=%0.1ds',t(ii))); % at different times
%view(45,90)
end
  2 个评论
VBBV
VBBV 2023-1-7
编辑:VBBV 2023-1-7
update the velocities at each dependent grid step, as
u(jj+1,kk+1) = u(jj,kk) + a_x*dt;
v(jj+1,kk+1) = v(jj,kk) + a_y*dt;
% Update surface height
h(jj+1,kk+1) = h(jj,kk) + dt*(u(jj,kk)*v(jj,kk) - g/2*h(jj,kk)^2);
it seems you were trying to compute wave heights at discrete time steps independently

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Thermal Analysis 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by