Simulated height of Faraday waves remains constant

2 visualizzazioni (ultimi 30 giorni)
In the simulation of the Faraday waves (simulation of the wave height), I get a constant wave height when I use the following code. How can I plot the different heights of the waves correctly ? Thank you very much for your valuable help!
Here is the code:
***************************************************
% 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)
% Update surface height
h = h + dt*(u.*v - g/2*(h.^2));
% Update velocities
u = u + dt*(g*h - g/2*(u.^2 + v.^2)) + F(t(ii));
v = v + dt*(g*h - g/2*(u.^2 + v.^2)) + F(t(ii));
end
% Plot results
figure;
mesh(x, y, h);
xlabel('x');
ylabel('y');
zlabel('surface height');
*******************************************************

Risposta accettata

C B
C B il 11 Dic 2022
To modify the code to correctly simulate the time-varying nature of Faraday waves, you will need to update the surface height and velocities at each time step based on the equations of motion for the system. This can be done by adding a for loop to the code, which will iterate through each time step and calculate the updates to the surface height and velocities using the equations of motion.
Here is an example of how you can modify the code to correctly simulate the time-varying nature of Faraday waves:
% 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');
In this code, a for loop is added to iterate through each time step and each grid point in the x and y dimensions. At each grid point, the equations of motion are used to calculate the acceleration of the fluid, which is then used to update the velocities
  1 Commento
Thierry
Thierry il 11 Dic 2022
Dear Chetan,
Thank you very much for your quick answer. Unfortunately, when I run the code, I get no plotting of the height of the waves. Here is the plot attached. How can I visualize properly the wave heights on the plot? Thank you very much.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fluid Dynamics in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by