File:Method of lines.gif

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(840 × 631 pixels, file size: 818 KB, MIME type: image/gif, looped, 100 frames, 5.0 s)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
English: Method of lines - the example, which shows the origin of the name of method.

Solid line represents an analytical solution, and lines show evolution in time of numerical solution by means of method of lines. For details see: Schiesser, W. E. (1991) The Numerical Method of Lines, Academic Press ISBN: 0-12-624130-9.

Click full resolution to see an animation.

The source code:

function mol
u = @(t,x)0.5./sqrt(4*t+1)*(exp(3*(2*x+1)/(4*t+1))+2).*exp(-(x+2).^2/(4*t+1));
M = 40;
N = 100;
x = linspace(-5,5,M+1);
y0 = 0.5*exp(-(x-1).^2)+exp(-(x+2).^2);
[t,y] = ode45(@dmol,linspace(0,0.5,N),y0(2:end));
y = [zeros(N,1) y];

hold on
for tt=1:numel(t)
    cla
    stem(x,y(tt,:),'k')
    plot(x,u(t(tt),x),'k')
    text(0.8,0.8,['t = ' num2str(t(tt)) 's']);
    ylim([0 1])
    xlabel('x')
    ylabel('u(x,t)')
    drawnow   
end

    function dy=dmol(~,y)
        dx = 10/M;
        y0 = 0;
        for m=M:-1:1
            if m==1
                dy(m,1) = (y(m+1)-2*y(m)+y0)/(dx^2);
            elseif m==M
                dy(m,1) = 0;
            else
                dy(m,1) = (y(m+1)-2*y(m)+y(m-1))/(dx^2);
            end
        end
    end %dmol function

end %mol function
Polski: Metoda linii - przykład, który przedstawia pochodzenie nazwy metody. Kliknij Pełna rozdzielczość żeby zobaczyć animację.
Date
Source Own work
Author Grzegorz Knor

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current10:50, 23 July 2013Thumbnail for version as of 10:50, 23 July 2013840 × 631 (818 KB)Gknor (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: