|
[Sponsors] |
May 22, 2014, 20:24 |
Lax Friedrich
|
#1 |
New Member
Umberto
Join Date: May 2014
Posts: 22
Rep Power: 11 |
Hello there!
This is my first post here so I apologize if my introduction is not correct. I'd like to ask clarifications concerning a Matlab code I wrote to analyze a square wave using Lax-Friedrich I do not understand why I have such big oscillations in the results, if not for too low value of Courant number Thanks in advance! %%Lax-Friedrich a=0.5; %wave speed deltax=0.1; deltat=0.005; c=a*deltat/deltax; %courant number X=-3:deltax:3; T=0:deltat:3; %initial conditions u=zeros(length(X),1); i=find(X==-0.5); j=find(X==0.5); u(i:j)=1; un=[]; for t=T [u]=laxfried(u,c); un=[un,u]; end figure plot(X,un(:,1),'g') hold on plot(X,un(:,100),'b') plot(X,un(:,150),'r') plot(X,un(:,200),'m') plot(X,un(:,300),'k') plot(X,un(:,500),'k') %%subroutine function function [unew]=laxfried(u,c) [m,n]=size(u); unew=zeros(m,n); for i=2:length(u)-1 unew(i)=-c*0.5*(u(i+1)-u(i-1))+0.5*(u(i+1)+u(i-1)); end |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
lax friedrich scheme for shock tube problem. | manukamin | Main CFD Forum | 3 | March 22, 2016 01:02 |
Difference Between the Oscillations of Lax Wendroff Method and that of Beam Warming | rizwanherl | OpenFOAM Programming & Development | 0 | June 8, 2010 16:08 |
Lax wendroff and Maccormack | prapanj | Main CFD Forum | 3 | November 20, 2007 13:18 |
Lax Friedrichs Flux Splitting | srikant srinivasan | Main CFD Forum | 1 | February 16, 2001 09:12 |
Difference between Lax and MacCormack methods on solutions of 1D problem. | AERO | Main CFD Forum | 2 | January 19, 2000 14:36 |