mandeep singh cfd

Upload: anonymous-uohuag

Post on 08-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Mandeep Singh cfd

    1/19

    [Project#04:1D Wave

    Equation]

    [MAE]

    [542]

    [EngineeringApplicationsofComputationalFluidDynamics][ 19th April

    2011]

    Submittedby

    MandeepSingh

    Person#37212672

  • 8/7/2019 Mandeep Singh cfd

    2/19

    2|P a g e

    Contents1 Introduction.................................................................................................................................... 3

    2 Problemdefinition/Problemstatement....................................................................................... 3

    3 MethodofSolution:....................................................................................................................... 5

    4 Discussionofresults....................................................................................................................... 6

    4.1 Case1.Usingthevalueofc=0.6,x=0.025,t=1............................................................... 6

    4.2 Case2.Usingthevalueofc=0.3,x=0.025,t=1............................................................... 8

    4.3 Case3.Usingthevalueofc=0.6,x=0.01,t=1................................................................. 9

    5 ConclusionandDiscussion............................................................................................................ 11

    6 Appendix....................................................................................................................................... 13

    6.1 MatlabCode.......................................................................................................................... 13

    7 References.................................................................................................................................... 19

  • 8/7/2019 Mandeep Singh cfd

    3/19

    3|P a g e

    1 Introduction

    Waveequation: It isabasemodelfortheHyperbolicequations.Hyperbolicpartial

    differentialequationshavetimederivativeintheequation.Someofthemethodsto

    solve this equation in time marching are Lax Wendroff, Upwind , Lax Wendroff

    method with flux limiter method using control volume like smooth limiter and

    superbee limiter andmidpoint leapfrogmethodsaresomeofexplicitmethods

    forexploringthe wavepropagation.

    The

    1D

    linear

    wave

    equation

    is

    given

    by

    equation

    0x

    u

    t

    u=

    +

    a

    (1)

    Whereuisthescalarfunctionsatisfyingthewaveequationandxisthespace

    domain.aisthespeedofpropagation.

    2

    Problemdefinition

    /

    Problem

    statement

    In this project we need to solve the given wave equation for periodic boundary

    condition.ThedomainlengthL=1.

    PeriodicBoundaryconditionsforthegivenproblemaregivenasfollows:

    Lxx

    xLx

    txutxu

    txutxu

    ==

    ==

    =

    +=+

    |),(|),(

    |),(|),(

    0

    0

    Thevalueofa=1.Weneedtoanalyzetwoinitialcondition,Heavisidesharpstep

    function,whereinitialconditionisgivenasuo(x)=1H(x 0.5),whereHisthe

    Heavisidefunction.

  • 8/7/2019 Mandeep Singh cfd

    4/19

    4|P a g e

    Weneed todevelop a computeralgorithm to solve the givenhyperbolicequation

    using

    the

    Lax

    Lax

    Wendroff

    method

    without

    flux

    limiter,

    Upwind

    Method

    ,

    Lax

    wendroffwithFluxlimiter(superbeeandsmooth).

    Weneedtoanalyzethesystemusingthefollowingvariationinthesystem

    S. No Condition to Explore Initial Condition Parameter given

    1 ComparingLaxWendroffwithoutlimiter,

    Upwindmethod,LaxWendroffwithsmoothlimiter,LaxWendroffwith

    superbeelimiter,analytical

    uo(x)=1H(x 0.5) c=0.6, t=1.0,

    x=0.025

    2 ComparingLaxWendroffwithoutlimiter,

    Upwindmethod,LaxWendroffwith

    smoothlimiter,LaxWendroffwith

    superbeelimiter,analytical

    uo(x)=1H(x 0.5) c=0.3, t=1.0,

    x=0.025

    3 ComparingLaxWendroffwithoutlimiter,

    Upwindmethod,LaxWendroffwith

    smoothlimiter,LaxWendroffwithsuperbeelimiter,analytical

    uo(x)=1H(x 0.5) c=0.6, t=1.0,

    x=0.01

  • 8/7/2019 Mandeep Singh cfd

    5/19

    5|P a g e

    3 MethodofSolution:

    In thisprojectwearegiven the followingalgorithms for theLaxWendroffmethod

    andupwindmethodforwhichthefluxlimitervalueareassignedtocalculatethewe

    willusethetwoalgorithmsgiveni.e.,LaxandLaxWendroffforgettingthenumerical

    solutionforthegivenequation.LaxAlgorithmisgivenbytheequation:

    x

    tFFuu

    n

    i

    n

    i

    n

    i

    n

    i

    = ++

    +

    2

    1

    2

    11

    2

    1

    1

    2

    12

    )1(+

    +

    +

    =

    i

    n

    i

    n

    in

    i

    n

    i

    uucaauF

    2

    1

    1

    1

    2

    12

    )1(

    =

    i

    n

    i

    n

    in

    i

    n

    i

    uucaauF

    n

    i

    n

    i

    n

    i

    n

    in

    i uu

    uu

    =

    +

    +1

    1

    2

    1

    n

    i

    n

    i

    n

    i

    n

    in

    i uu

    uu

    1

    21

    2

    1

    =

    Wherecisthecourantnumbergivenbytheequationc=a t/x, isthefluxlimiter

    whichisthefunctionof.

  • 8/7/2019 Mandeep Singh cfd

    6/19

    6|P a g e

    ForLaxWendroffmethodwithoutlimiter, =1,forupwindmethod =0,forLax

    Wendroffwith smooth limiter()= (||+ )/(1+||) ,and forLaxWendroffwith

    smoothlimiter()=max(0,min(1,2),min(,2))

    4 Discussionofresults

    4.1 Case1.Usingthevalueofc=0.6,x=0.025,t=1For all themethodsusing thedefinedparameters in case 1,we get the following

    solutioncomparingallthemethodsasshowninthefigure1.

    Figure1(Figureshowingthesolutionforthewaveequationforthevariousmethodsatc=0.6,Deltax=0.025)

  • 8/7/2019 Mandeep Singh cfd

    7/19

    7|P a g e

    From the figure 1, we can observe that the solution for the wave propagation

    function is mapped best through the superbee function with least diffusion error

    when compared to the other methods. The smooth limiter follows the superbee

    method, with the second best solution for the wave equation with the give

    parameters.WecanstillseealargeamountofdispersionerrorintheLaxWendroff

    withoutlimiterwhichcreateanerrorof20%atcertainnodalsolutions.Thisisdueto

    theodd spatialderivative in the truncation error that causesdispersion. Thishigh

    orderconvectiontendstodistorttheshapeofthepropertydistributioninspaceand

    causeswigglesinthesolution.Fortheupwindscheme,which ishighlydissipativein

    nature,gives the leastaccurateapproximation to thewaveequation.For instance,

    suppose at length L = 0.1,upwind scheme gives 18% error in the solution.At the

    sameinstanceLaxWendroffwithoutlimitergivesanderrorof6%.TheLaxWendroff

    withsmooth limitergivesanerrorofaround3%andtheLaxWendroffgivesalmost

    negligibleerroratthegivenlocation.

  • 8/7/2019 Mandeep Singh cfd

    8/19

    8|P a g e

    4.2 Case2.Usingthevalueofc=0.3,x=0.025,t=1For the value of c = 0.3, we get the following solution as shown in the figure 2.

    Figure2(Figureshowingthesolutionforthewaveequationforthevariousmethodsatc=0.3,Deltax=0.025)

    Forthegivenconditionoftheparameters,wefindthattheinaccuracyoftheallthe

    methods increases. Still the solutions from Lax Wendroff with smooth limiter and

    superbee limiterarecomparable.TheLaxWendroffwithno flux limitersuffers the

    dispersionerror in the solution. For the LaxWendroffwithno flux limiterwe can

    observe thaat location0.35, thediffusionerror increases to22%which is greater

    thantheformercasewherethediffusionerrorwas20%.Thisisduetothefacethat

    thevalueofchasbeendecreasedto0.3from0.6.AtDomainlengthL=0.02,wecan

    observe a wiggle growing up for the Lax Wendroff method without limiter. The

    diffusionerrorintheupwindschemehasincreasedby4%fromtheearliercase.Still

    theLaxWendroffwiththesuperbeelimitergivesthebestresultswhencomparedto

  • 8/7/2019 Mandeep Singh cfd

    9/19

    9|P a g e

    other followed by smooth limiter method. Both Lax Wendroff superbee and Lax

    Wendroffsmooth limitergivesmorestablesolutionwith leastdiffusionerror inthe

    solution.Alsonoshiftingwasobservedforthesuperbee.

    4.3 Case3.Usingthevalueofc=0.6,x=0.01,t=1

    Incase3weraisedthevalueofcagainto0.6comparedto0.3incase2i.e.,equalto

    case 1. But at the same time we have decreases the space stepx to 0.01. By

    decreasing the valueofx from 0.025 to 0.01 we can clearly see a considerable

    enhancementinthesolutionasshowninFig.3.

  • 8/7/2019 Mandeep Singh cfd

    10/19

    10|P a g e

    Figure3(Figureshowingthesolutionforthewaveequationforthevariousmethodsatc=0.6,Deltax=0.01)

    Incase3,weasshowninfigure3.WecansseestilltheLaxWendroffmethodwith

    superbee gives the best approximation followed by the smooth limiter. The Lax

    Wendroffwithout limiterstillowes thedispersiveerror in thesolutionwithalmost

    sameamountofashighas20%atsomenodes.Theupwindschemeerrorhasalso

    reducedandapproximatestheprofileofthesolution.Hencebydecreasingthevalue

    ofx from0.025to0.01,solutionsforallmethodsimprovedexceptforthe caseof

    LaxWendroffwithnolimiter,wherewestillgetthewigglesofsameintensityasfor

    thecase1and2.

  • 8/7/2019 Mandeep Singh cfd

    11/19

    11|P a g e

    5 ConclusionandDiscussionInthisprojectwestudiedthebehavioroftheLaxWendroff fluxlimiterschemes.We

    observedthattheaccuracyforthelaxwendroffmethodusingthesuperbeemethod

    isquitestablewithrespecttodiffusionerrorandconsiderablyaccurate.Itisfollowed

    bytheLaxWendroffmethodwithsmoothlimiter,whichwascomparativelyaccurate

    thantheupwindandtheLaxWendroffwithnolimiter.FluxLimitersareusedinhigh

    resolutionschemeswhichavoidthewigglesinthesolution.Thesewigglesoccurdue

    tosharpchanges inthewavepropagation ,anydiscontinuitiesorshock.Hencewe

    haveobservednowigglesfortheLaxWendroffmethodwithsuperbeeandsmooth

    limiterandatthesametimemaintainingconsiderableaccuracyevenatlowvalueof

    c(courantnumber).Theupwind schemewas found tobequitedissipative.TheLax

    Wendroff method have quite sensitive behavior for the abrupt changes in the

    boundary.Forthisreasonweobservedhighdispersiveerrorduringthesolutionfor

    theHeavisideboundarycondition.Themainreasonforthisdifferent behaviorinthe

    two methods is because of the dispersive leading truncation error in the Lax

    Wendroffmethod.Flux limiters (slope limiters) ,asobserved,avoided thespurious

    oscillations (wiggles) that were otherwise occurring in Lax Wendroff scheme with

    high order spatial discretisation schemes due to shocks, discontinuities or sharp

    changes in the solution domain. Hence use of flux limiters, together with an

    appropriateschememakesthesolutiontotalvariationdiminishing(TVD).Wecansay

    that the superbee scheme was the best among the all other scheme for this

    heavyside step functions wave. But at the same time , it is known to suffer

    sharpening of the slopes when approximating the smooth curves like sinusoidal

    waves.

  • 8/7/2019 Mandeep Singh cfd

    12/19

    12|P a g e

    TheswebyTVDplotshowsthefluxlimiterareaforthevariousmethods(figure4).Itis

    plottedusingthevaluesofvaryingthevaluesof forvariousmethods.

    Figure4(swebyplotforcomparisonofTVDandnonTVDschemes)

    The Superbee limiter applies the minimum limiting and maximum steepening

    possible to remain TVD. It is known to suffer from excessive sharpening of

    slopesasa result. ThevanLeer(Laxwendroffwithsmooth limiter) limiterchartsa

    careful compromise path through the Sweby TVD region. Lax Wendroff without

    limiter runs forconstantwith thevalueof=1.HenceLinearnonTVD limiters like

    upwind , Lax Wendroff have a constant same slope. The superbee and the

    smooth(vanleer)nonlinearsecondorderTVDlimiterhavevaryingslopes.

  • 8/7/2019 Mandeep Singh cfd

    13/19

    13|P a g e

    6 Appendix6.1 MatlabCode

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Name : Mandeep Singh %% Project 4 (1-D Wave Equation using Non linear Methods) %% Assigned: 04/05/11 Due: 04/19/11 %% MAE 542 Engineering Applications of Computational Fluid Dynamics %% Flux Limited Lax Wendroff method %% for solving 1D Wave Equation contrl volume method %% Associated file : Myinput.m %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%------------------------------------------------------------------%

    % given% Equation du/dt + a (du/dx) = 0% Wave velocity a = 1% given the initial boundary condition% and uo= 1 - H(x-0.5)

    %%clear allclose allclc%% Inputs:t=myinput('Please Enter maximum time for iternation(t=1):',1);dt=myinput('Please Enter time step dt(dt=0.015):',0.015);

    dx=myinput('Please Enter the value of space step dx(dx=0.025):',0.025);L=myinput('Please Enter the lenght (L=1):',1);a=myinput('Please Enter the value of waves speed a(a=1):',1);

    nt=((t/dt)+1);%Time steps number

    nx= (L/dx)+1;%Space steps number

    x=0:dx:L;

    for i =1:length(x)uo(i)= 1-heaviside(x(i)-0.5);end%initial boundary conditionuo(:,1)=0.5;uo(:,end)=0.5;u=zeros(nx,nt);%Initializing the

    % lax method

    c=a*dt/dx;

  • 8/7/2019 Mandeep Singh cfd

    14/19

    14|P a g e

    % Lax Wendroff Method without limiterUA=zeros(nx,nt);UB=zeros(nx,nt);

    UC=zeros(nx,nt);UD=zeros(nx,nt);UA(:,1)=uo;UB(:,1)=uo;UC(:,1)=uo;UD(:,1)=uo;

    %% ------------------------------------------------------------------------%% Case A ; phi = 1%% ----------------

    for i=1:nt %0:length(t)for j=1:nx %0:length(x)

    if j==1||j==nxphi1=1;phi2=1;Fplus(j,i)=a*UA(j,i)+((a*(1-c)/2)*(UA(2,i)-UA(j,i)))*phi1;Fminus(j,i)=a*UA(nx-1,i)+(a*(1-c)/2)*(UA(j,i)-UA(nx-1,i))*phi2;UA(j,i+1)=UA(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    elsephi1=1;

    phi2=1;Fplus(j,i)=a*UA(j,i)+((a*(1-c)/2)*(UA(j+1,i)-UA(j,i)))*phi1;Fminus(j,i)=a*UA(j-1,i)+(a*(1-c)/2)*(UA(j,i)-UA(j-1,i))*phi2;UA(j,i+1)=UA(j,i)-(Fplus(j,i)*phi1-Fminus(j,i)*phi2)*(dt/dx);

    endend

    end

    %% ------------------------------------------------------------------------%% ------------------------------------------------------------------------%% Case B ; phi = 0%% ----------------for i=1:nt %0:length(t)

    for j=1:nx %0:length(x)if j==1||j==nx

    phi1=0;phi2=0;Fplus(j,i)=a*UB(j,i)+((a*(1-c)/2)*(UB(2,i)-UB(j,i)))*phi1;Fminus(j,i)=a*UB(nx-1,i)+(a*(1-c)/2)*(UB(j,i)-UB(nx-1,i))*phi2;UB(j,i+1)=UB(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    elsephi1=0;

    phi2=0;

  • 8/7/2019 Mandeep Singh cfd

    15/19

    15|P a g e

    Fplus(j,i)=a*UB(j,i)+((a*(1-c)/2)*(UB(j+1,i)-UB(j,i)))*phi1;Fminus(j,i)=a*UB(j-1,i)+(a*(1-c)/2)*(UB(j,i)-UB(j-1,i))*phi2;UB(j,i+1)=UB(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    endend

    end

    %% ------------------------------------------------------------------------%% ------------------------------------------------------------------------%% Case C%% ------

    for i=1:nt %0:length(t)for j=1:nx %0:length(x)if j==1||j==nx

    theta1(j,i)=(UC(j,i)-UC(nx-1,i))/((UC(2,i)-UC(j,i))+10^-5);theta2(j,i)=(UC(nx-1,i)-UC(nx-2,i))/((UC(j,i)-UC(nx-1,i))+10^-5);

    phi1(j,i)=((abs(theta1(j,i))+theta1(j,i))/(1+abs(theta1(j,i))));phi2(j,i)=((abs(theta2(j,i))+theta2(j,i))/(1+abs(theta2(j,i))));

    Fplus(j,i)=a*UC(j,i)+((a*(1-c)/2)*(UC(2,i)-UC(j,i)))*phi1(j,i);Fminus(j,i)=a*UC(nx-1,i)+(a*(1-c)/2)*(UC(j,i)-UC(nx-1,i))*phi2(j,i);UC(j,i+1)=UC(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    elseif j==2

    theta1(j,i)=(UC(j,i)-UC(j-1,i))/((UC(j+1,i)-UC(j,i))+10^-5);theta2(j,i)=(UC(j-1,i)-UC(nx,i))/((UC(j,i)-UC(j-1,i))+10^-5);

    phi1(j,i)=((abs(theta1(j,i))+theta1(j,i))/(1+abs(theta1(j,i))));phi2(j,i)=((abs(theta2(j,i))+theta2(j,i))/(1+abs(theta2(j,i))));

    Fplus(j,i)=a*UC(j,i)+((a*(1-c)/2)*(UC(j+1,i)-UC(j,i)))*phi1(j,i);Fminus(j,i)=a*UC(j-1,i)+(a*(1-c)/2)*(UC(j,i)-UC(j-1,i))*phi2(j,i);UC(j,i+1)=UC(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    else

    theta1(j,i)=(UC(j,i)-UC(j-1,i))/((UC(j+1,i)-UC(j,i))+10^-5);theta2(j,i)=(UC(j-1,i)-UC(j-2,i))/((UC(j,i)-UC(j-1,i))+10^-5);

    phi1(j,i)=((abs(theta1(j,i))+theta1(j,i))/(1+abs(theta1(j,i))));

    phi2(j,i)=((abs(theta2(j,i))+theta2(j,i))/(1+abs(theta2(j,i))));

    Fplus(j,i)=a*UC(j,i)+((a*(1-c)/2)*(UC(j+1,i)-UC(j,i)))*phi1(j,i);Fminus(j,i)=a*UC(j-1,i)+(a*(1-c)/2)*(UC(j,i)-UC(j-1,i))*phi2(j,i);

  • 8/7/2019 Mandeep Singh cfd

    16/19

    16|P a g e

    UC(j,i+1)=UC(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    endend

    end

    %% ------------------------------------------------------------------------%% ------------------------------------------------------------------------%% Case D

    for i=1:nt %0:length(t)for j=1:nx %0:length(x)if j==1||j==nx

    theta1(j,i)=(UD(j,i)-UD(nx-1,i))/((UD(2,i)-UD(j,i))+10^-10);theta2(j,i)=(UD(nx-1,i)-UD(nx-2,i))/((UD(j,i)-UD(nx-1,i))+10^-10);

    jp1=max(min(theta1(j,i),2),min(1,2*theta1(j,i)));phi1=max(0, jp1);

    jp2=max(min(theta2(j,i),2),min(1,2*theta2(j,i)));phi2=max(0, jp2);

    Fplus(j,i)=a*UD(j,i)+((a*(1-c)/2)*(UD(2,i)-UD(j,i)))*phi1;Fminus(j,i)=a*UD(nx-1,i)+(a*(1-c)/2)*(UD(j,i)-UD(nx-1,i))*phi2;UD(j,i+1)=UD(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    elseif j==2

    theta1(j,i)=(UD(j,i)-UD(j-1,i))/((UD(j+1,i)-UD(j,i))+10^-10);theta2(j,i)=(UD(j-1,i)-UD(nx,i))/((UD(j,i)-UD(j-1,i))+10^-10);

    jp1=max(min(theta1(j,i),2),min(1,2*theta1(j,i)));phi1=max(0, jp1);

    jp2=max(min(theta2(j,i),2),min(1,2*theta2(j,i)));phi2=max(0, jp2);

    Fplus(j,i)=a*UD(j,i)+((a*(1-c)/2)*(UD(j+1,i)-UD(j,i)))*phi1;Fminus(j,i)=a*UD(j-1,i)+(a*(1-c)/2)*(UD(j,i)-UD(j-1,i))*phi2;UD(j,i+1)=UD(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    else

    theta1(j,i)=(UD(j,i)-UD(j-1,i))/((UD(j+1,i)-UD(j,i))+10^-10);theta2(j,i)=(UD(j-1,i)-UD(j-2,i))/((UD(j,i)-UD(j-1,i))+10^-10);

    jp1=max(min(theta1(j,i),2),min(1,2*theta1(j,i)));

  • 8/7/2019 Mandeep Singh cfd

    17/19

    17|P a g e

    phi1=max(0, jp1);

    jp2=max(min(theta2(j,i),2),min(1,2*theta2(j,i)));phi2=max(0, jp2);

    Fplus(j,i)=a*UD(j,i)+((a*(1-c)/2)*(UD(j+1,i)-UD(j,i)))*phi1;Fminus(j,i)=a*UD(j-1,i)+(a*(1-c)/2)*(UD(j,i)-UD(j-1,i))*phi2;UD(j,i+1)=UD(j,i)-(Fplus(j,i)-Fminus(j,i))*(dt/dx);

    endend

    end

    %% ------%% ------------------------------------------------------------------------%% ------------------------------------------------------------------------

    for i=1:nxif i==1||i==nx||i==(nx+1)/2

    uanal(i) = 0.5elseif i > 1 && i

  • 8/7/2019 Mandeep Singh cfd

    18/19

  • 8/7/2019 Mandeep Singh cfd

    19/19

    19|P a g e

    7 References1. Lecture

    notes

    by

    Prof.

    Desjardin

    2. Hoffman&Chian,ComputationalFluidDynamicsVolI

    3. NumericalMethods