Results 1 to 2 of 2

Math Help - Numerical solutions to the transport equation

  1. #1
    Junior Member
    Joined
    Apr 2010
    Posts
    25
    Thanks
    5

    Numerical solutions to the transport equation

    Hi everyone,

    I have an assignment from my professor for 3 weeks from now. It is about solving the transport equation, u_t+c*u_x=0, using numerical schemes in matlab. Unfortunately, I have never used matlab before and the lecturer has only gone over very basic techniques in the lecture. Is there anyone out there who has done this before and could offer me some advice as to how I would go about doing this? Thanks
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Junior Member
    Joined
    Apr 2010
    Posts
    25
    Thanks
    5

    Re: Numerical solutions to the transport equation

    ok, a more simple question, can anyone out there make a 3d plot/mesh of u,x and t from this code? :

    clear all
    clc
    clf
    % First set the initial parameters.
    p=0; % start of computational domain
    q=100; % end of computational domain
    v=1; % water speed
    N=101; % number of grid points
    dx=(q-p)/(N-1); % spatial step size
    x = p: dx : q; % vector of grid points
    u0=zeros(1,N); % vector of initial u values filled with zeros
    for i=1:N
    u0(i)=finitial(x(i)-0); % initial conditions
    end
    %
    dt=0.3; % fixed time step
    ntimesteps=200; % number of time steps
    r =v*dt/dx;
    %
    u=zeros(1,N); % define correct sized numerical solution array
    exact=zeros(1,N); % define correct sized exact solution array
    %
    % Begin the time marching algorithm
    %
    for n=1:ntimesteps
    t=n*dt; % current time for outputted solution
    for i=1:N
    exact(i)=finitial(x(i)-v*t); % exact solution at time t
    end
    u0=[u0(1) u0]; % insert ghost value (appropriate to numerial scheme)
    for i=2:N+1
    u(i)=u0(i)-r*(u0(i)-u0(i-1)); % backward difference algorithm
    end
    plot(x,u(2:N+1),'r',x,exact,'k') % plot (omitting ghost values) of numerical and exact solutions
    xlabel('x')
    ylabel('concentration u')
    title('comparison of solutions to du/dt + v du/dx = 0, + numerical (FOU), o analytical')
    pause(0.03) % pause in seconds between plots
    u0=u(2:N+1); % copy solution to initial conditions for next iteration
    u=[]; % empty the solution vector (actually it will be overwritten)
    end
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. combining advective reactive transport equation for two solutes
    Posted in the Differential Equations Forum
    Replies: 2
    Last Post: October 13th 2010, 03:01 PM
  2. Numerical Solutions in Diffy Q with Matlab
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: March 8th 2010, 10:27 AM
  3. numerical solutions/uniqueness of a D.E
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: March 9th 2009, 06:06 AM
  4. Replies: 2
    Last Post: January 8th 2008, 02:33 PM
  5. Replies: 0
    Last Post: July 19th 2007, 07:50 AM

Search Tags


/mathhelpforum @mathhelpforum