Effacer les filtres
Effacer les filtres

Finite difference method Boundary conditions

1 vue (au cours des 30 derniers jours)
Parthiban C
Parthiban C le 17 Fév 2019
Modifié(e) : Parthiban C le 17 Fév 2019
How to set the boundary conditions and initial conditions for the problem mentioned below?. I tried the below mentioned code. But it seems it's not correct.
% Simulation of a 1-D Linear Convection model by a time march (Finite
...Difference Method)
% Numerical scheme used is a first order upwind in both space and time
%%
clc;
clear;
%Specifying Parameters
xr=1; % Space(x) right side limit
xl=0; % Space(x) left side limit
dx=0.05;%Width of space step
x=xl:dx:xr;%Range of x (0,1) and specifying the grid points
nx=length(x);%Number of steps in space(x)
tr=20; % time(t) right side limit
tl=0; % time(t) left side limit
dt=0.04;%Width of each time step
t=tl:dt:tr;
nt=length(t);
a=1.0;
for i=1:nx
u(i,1)=(sin(pi*x(i)))^40;%%%Initial conditions
end
for x=1:nx-1
for t=1:nt-1
u(x,t+1)=u(x,t)+(dt/dx)*(u(x+1,t)-u(x,t));
u(end,t)=u(1,t);%%%Boundary conditions
end
end

Réponses (0)

Catégories

En savoir plus sur Signal Generation and Preprocessing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by