6

cfd1-pt7

Embed Size (px)

DESCRIPTION

compuational fluid dynamics

Citation preview

  • School of Mechanical Aerospace and Civil Engineering

    Contents:

    Introduction to CFDNumerical solution of equationsFinite difference methodsFinite volume methodsPressure-velocity couplingSolving sets of linear equationsUnsteady problemsTurbulence and other physical modellingBody-fitted coordinate systems

    Reading:J. Ferziger, M. Peric, Computational Methods for FluidDynamicsH.K. Versteeg, W. Malalasekara, An Introduction to Com-putational Fluid Dynamics: The Finite Volume MethodS.V. Patankar, Numerical Heat Transfer and Fluid FlowNotes: http://cfd.mace.manchester.ac.uk/tmcfd

    - People - T. Craft - Online Teaching Material

    Unsteady Problems

    T. J. CraftGeorge Begg Building, C41

    - p. 2

    OverviewIn considering the discretization of fluid flow problems so far we have considered onlysteady-state situations.

    This has meant we have only discretized spatial derivatives.

    In this lecture we consider how to handle unsteady flow problems, and any additionalcomplications this might introduce.

    The Navier-Stokes momentum equations (for incompressible flow) now becomeUi

    t+

    (UiUj)

    xj= 1

    P

    xi+

    xj

    Ui

    xj

    (1)

    When considering how to discretize the time derivatives, we need to recognise a majordifference between space and time coordinates.

    Most real fluid flow problems are (at least to some extent) elliptic in nature meaning thatany forcing introduced has an effect in all directions.However, the time dependence is purely parabolic any forcing affects only the future,never the past.

    To reflect this, solution methods tend to advance in time in a marching manner.

    Initial values are provided at time t = 0 and the solution method proceeds by advancing intime in a step-by-step manner.

    - p. 3

    Explicit vs. Implicit TreatmentsWe consider the generic time-dependent problem

    t= f(t, (t)) (2)

    Integrating with respect to time, over one time step, givesZ t+t

    t

    tdt =

    Z t+tt

    f(t, (t)) dt (3)

    or

    (n+1) = (n) +

    Z t+tt

    f(t, (t)) dt (4)

    where the superscript (n) denotes a quantity evaluated at time t, and (n+ 1) at time t+t.

    The problem is then how to approximate the integral on the right hand side.

    If we approximate the integral using the value of f at the initial time, t, then we obtain

    (n+1) = (n) + f(t, (n))t (5)

    This is a fully explicit method. Once we have values at time step n, equation (5) can beapplied in a simple explicit fashion to obtain the value of at time step n+ 1.

    - p. 4

    If the integral is approximated using the value of the integrand at the final time, t+t, thenwe have

    (n+1) = (n) + f(t+t, (n+1))t (6)

    This is a fully implicit method. It cannot be solved in a simple pointwise fashion, since valuesof (n+1) appear on both the left and right hand sides. In a general case it will thus oftenrequire an iterative solution procedure to obtain (n+1).

    Another alternative is to approximate the integral using a weighted average of the initial andfinal values of f .

    In the case of an equally weighted average the integral is evaluated using the trapezium rule:

    (n+1) = (n) +t

    2

    f(t, (n)) + f(t+t, (n+1)

    (7)

    Again, this is an implicit scheme, and will typically require an iterative procedure to obtain(n+1).

  • - p. 5

    Accuracy of Temporal SchemesBy expanding as a Taylor series expansion about time t we can examine the accuracy ofthe fully explicit scheme:

    (t+t) = (t) + t

    t

    t

    +(t)2

    2!

    2

    t2

    t

    +O((t)3)

    = (t) + t f(t, (t)) +O((t)2)

    Hence we have(n+1) = (n) +tf(t, (n)) +O((t)2) (8)

    From this we can see that equation (5) shows a truncation error proportional to (t)2 over asingle time step.

    However, the number of time steps that must be performed for a given simulated time isproportional to 1/t.

    Hence the total error associated with use of the scheme is proportional to t, and thescheme is referred to as first order accurate.

    The fully implicit scheme of equation (6) can also be shown to be first order accurate.

    - p. 6

    The trapezium approximation of equation (7) can be shown to be second order accurate,since

    (t+t) = (t+t/2) +t

    2

    t

    t+t/2

    +(t)2/4

    2!

    2

    t2

    t+t/2

    +O((t)3) (9)

    (t) = (t+t/2) t2

    t

    t+t/2

    +(t)2/4

    2!

    2

    t2

    t+t/2

    +O((t)3) (10)

    Hence

    (n+1) = (n+1/2) +t

    2f(t+t/2, (n+1/2)) +

    (t)2/4

    2!

    2

    t2

    t+t/2

    +O((t)3) (11)

    (n) = (n+1/2) t2f(t+t/2, (n+1/2)) +

    (t)2/4

    2!

    2

    t2

    t+t/2

    +O((t)3) (12)

    Combining these expansions gives

    (n+1) (n) = t f(t+t/2, (n+1/2)) +O((t)3) (13)

    The truncation error over a single time step is thus proportional to (t)3, so over a fixed timeintegration the scheme is second order.

    - p. 7

    Stability of Temporal SchemesAnother important issue with temporal discretization schemes is that of stability.

    Explicit schemes in particular are prone to instabilities if too large a time step is employed.

    To see why this should be, consider a 1-D spatial,time dependent problem, dominated byconvective effects.

    The flow conditions at some point xi influence anincreasingly wide region of the flow as timeprogresses.

    Equally, we can identify a region of the flow thathas an influence on conditions at the point xi atany time t.

    x i x

    t

    InfluenceZone of

    t

    x

    Zone ofdependence

    x i

    In a fully explicit scheme, since the value of at time t(n) is determined purely from itsvalues at time t(n1), we need to ensure that the spatial stencil does contain all the relevantflow information at time t(n1).

    - p. 8

    For example, if a 3-point spatial stencil wasemployed, then for the problem shown in thefigure this would cover the zone of dependenceat time tt, so the scheme could be expectedto be stable. t-2 t

    t- t

    x

    t

    If, however, a time step of 2t were taken, not all the relevant flow information at timet 2t would be included in the discretization, and the scheme would likely be unstable.

    Hence stability often imposes a limit on the time step that can be used in a calculation.

    An examination of the stability of different schemes will be covered in the following sectionswhen applying them to unsteady convection/diffusion problems.

  • - p. 9

    Time Stepping for Steady Problems

    In some cases the solution to a steady flow problem is obtained by introducing a timederivative term and solving the unsteady problem, marching the solution to a steady state.

    In such cases the accuracy of the time discretization is not crucial (since the time derivativewill be zero at the end of the calculation), and one typically wants to take rather large timesteps.

    The stability of the scheme is therefore particularly important in these cases, since thetime-step size that can be applied may well be limited by this, rather than by accuracyconsiderations.

    In a solution procedure such as the above, the time-stepping is effectively playing a similarrole to under-relaxation, which was considered earlier in the context of solving steady-stateproblems in a segregated fashion.

    - p. 10

    The Explicit Euler SchemeFor simplicity we consider the time dependent convection/diffusion problem for somevariable :

    t+

    xj(Uj) =

    xj

    xj

    (14)

    The explicit Euler method is obtained by moving all terms except /t to the right handside and applying the fully explicit formulation examined earlier:

    t=

    xj(Uj) +

    xj

    xj

    f(t, (t)) (15)

    If we consider the 1-D problem with constant velocity U and diffusivity then the differentialequation becomes

    t= U

    x+

    2

    x2(16)

    Using central differences to approximate spatial derivatives then leads to

    (n+1)i =

    (n)i +t

    24U

    0@(n)i+1 (n)i1

    2x

    1A+

    0@(n)i+1 2(n)i + (n)i1

    (x)2

    1A35 (17)

    Given initial conditions the calculation can then proceed, evaluating (n+1)i in a simplepointwise manner.

    - p. 11

    Stability AnalysisAs indicated earlier, the stability of a temporal discretization is often an important issue,particularly with explicit schemes.

    Broadly, we interpret a stable scheme to be one that leads to a bounded solution if theoriginal differential equation would have done so.

    A method that is frequently used to explore stability issues is the Von-Neumann stabilityanalysis.

    If one assumes there are no forcing terms, then the discretized equation for can be writtenin the form

    (n+1) = A(n) (18)

    If we further assume that the eigenvectors of A form a basis, then can be written in termsof these:

    (n) =X

    k

    (n)k ak (19)

    where ak are the eigenvectors of A and (n)k the associated coefficients.

    The difference between solutions for at successive time steps (using some appropriatenorm) is then

    ||(n+1) (n)|| = ||X

    k

    (n+1)k

    (n)k

    ak|| (20)

    - p. 12

    Using the discretized equation to relate this difference to that at the previous timestep leadsto

    ||(n+1)(n)|| = ||A((n)(n1))|| = ||AX

    k

    ((n)k

    (n1)k )ak|| = ||

    Xk

    k((n)k

    (n1)k )ak||

    (21)where k is the eigenvalue corresponding to eigenvector ak

    Hence the difference between the solutions at successive timesteps gets smaller(corresponding to a stable solution) if all the eigenvalues of the matrix A are less than unity.

    For the simplified problem being considered, on a uniform grid, the eigenvectors can beexpressed as combinations of Fourier modes with sines and cosines.

    Hence to analyse stability we consider as being represented by a combination of Fouriermodes of the form

    (n)j =

    Xk

    nk exp(ikjx) (22)

    where i =1, the index j denotes the spatial position and superscript (n) the time level.

    We then examine whether the (complex) coefficient k associated with the Fourier mode k isless than or greater than unity in magnitude.

  • - p. 13

    Substituting the form n exp(ikjx) into the discretized equation (17) leads to

    n+1 = n1 Ut

    exp(ikx) exp(ikx)

    2x

    + t

    exp(ikx) 2 + exp(ikx)

    (x)2

    (23)

    or

    = 1 Ut2x

    [exp(ikx) exp(ikx)] + t(x)2

    [exp(ikx) + exp(ikx) 2] (24)

    = 1 iUtx

    sin(kx) +2t

    (x)2[cos(kx) 1] (25)

    The magnitude of (or rather 2) is thus given by

    2 =

    1 +

    2t

    (x)2[cos(kx) 1]

    2+

    Ut

    xsin(kx)

    2(26)

    Two limiting cases can be considered:

    When there is no diffusion.

    When there is no convection.

    - p. 14

    In the absence of diffusion, we have

    2 = 1 +

    Ut

    xsin(kx)

    2(27)

    so || is always greater than unity and the scheme is unconditionally unstable!

    In the absence of convection we have

    2 =

    1 +

    2t

    (x)2[cos(kx) 1]

    2(28)

    The maximum value of 2 thus occurs when cos(kx) = 1, when we have

    2 =

    1 4 t

    (x)2

    2(29)

    Thus || < 1 provided that t/(x)2 < 1/2, and the scheme is conditionally stable.

    - p. 15

    Another way of examining stability and boundedness is to write the discretized equation as

    (n+1)i =

    1 2t

    (x)2

    (n)i +

    t

    (x)2 Ut

    2x

    (n)i+1 +

    t

    (x)2+

    Ut

    2x

    (n)i1 (30)

    Suppose that represents some scalar quantity that cannot physically be negative.

    If any of the coefficients associated with (n)i , (n)i+1 or

    (n)i1 take a negative value then it is

    possible that (n+1)i could become negative, leading to an unbounded solution.

    To ensure all coefficients are positive requires

    1 2t(x)2

    > 0 ort

    (x)2< 1/2 and t

    (x)2 Ut

    2x> 0 or

    Ux

    < 2

    The first of these conditions is the same as found by the Von-Neumann analysis.

    The second is that the cell Peclet number (met in earlier lectures) should be less than 2.Note that this is the condition found earlier to be sufficient for the centred convection schemeto be bounded.

    The restriction t/(x)2 < 1/2 can impose a rather serious constraint on the time step forpractical calculations. If the grid spacing is halved, for example, the time step has to bereduced by a factor of four.

    - p. 16

    Upwinding Convection TermsIf we retain the explicit Euler time discretization, but now use the first order upwind schemeto discretize the convective terms, the discretized equation for the above unsteadyconvection/diffusion problem (assuming U > 0) becomes

    (n+1)i =

    (n)i Ut

    0@(n)i (n)i1

    x

    1A+ t

    0@(n)i+1 2(n)i + (n)i1

    (x)2

    1A (31)

    or(n+1)i =

    1 2t

    (x)2 Ut

    x

    (n)i +

    t

    (x)2(n)i+1 +

    t

    (x)2+

    Ut

    x

    (n)i1 (32)

    To ensure the coefficients remain positive, we now need

    1 2t(x)2

    Utx

    > 0 or t