Simulated height of Faraday waves remains constant
Mostra commenti meno recenti
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
Più risposte (0)
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

