Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 15 Advection – Diffusion Equation and its numerical resolution.

Similar presentations


Presentation on theme: "Lecture 15 Advection – Diffusion Equation and its numerical resolution."— Presentation transcript:

1 Lecture 15 Advection – Diffusion Equation and its numerical resolution

2 Objectivos This chapter aims to present resolution methods for the Advection-Diffusion Equation in a 1D system and its application to predict the evolution of properties in a River involving heat and/or mass transfer. The Chapter gives continuity to the problem of diffusion solved in Fluid Mechanics using knowledge about heat transfer acquired in TEM and is based on the same VBA code. It is an introduction to the work to be done in the Environmental Modelling course.

3 Program of this Chapter Reassessment of the finite-volume approach to quantify the conservation principle “The rate of accumulation inside a control volume is equal to the entrance minus the leaving rates, plus production minus consumption”. Assessment of the numerical difficulties of advection. Upwind, central differences and “Quick” methods for advection. Numerical diffusion. Time discretization and stability: Explicit, implicit and semi- implicit methods (Crank-Nicholson). Courant and Diffusion numbers. Deduction of the algebraic equations from differential equations, using Taylor series. Accuracy and truncation error.

4 Processes Rate of accumulation: Fluxes: – Advective: – Diffusive: – Why the sign“-” before the integrals?

5 Fluxes The Flux of a Property is the amount of property that crosses a Area per unit of time. The Property flows by Advection when the average velocity of the molecules along that Area is not null, i.e. when there is net velocity The property flows by diffusion if there is interaction between fluid parcels (molecules or eddies) at a scale not described by the velocity.

6 Convection or diffusion? At small scale is convection At large scale is Diffusion

7 Diffusion Molecular diffusivity exists when interaction is between individual molecules (collisions can transfer heat and momentum, position change will transfer also mass). The spatial scale is the free movement of a molecule and the velocity is the molecule velocity. Turbulent diffusivity is identical to molecular diffusion but is due to interaction between eddies. The spatial scale is the length of the movement of a eddy during is life time and the velocity is its velocity. It is much more effective than molecular diffusivity because it can involve millions of molecules. It always involve momentum, heat and mass diffusion associated (it exists only in fluids). Subgrid diffusivity is the one to consider in numerical models. It is identical to others, but the spatial scale is the model grid size since this is the length of velocity averaging.

8 Location of the variables on the control-volume: advective e diffusive Fluxes across faces

9 Applying the conservation principle “The rate of accumulation inside a control volume is equal to the entrance minus the leaving rates, plus production minus consumption”. If there is transport only the equation is: Shrinking dt and the volume to zero: If the volume was constant and the areas were uniform (a non-deformable cube) one would have got: In 3D: If Diffusivity uniform If incompressible Lagrangian: control volumes moves with flow

10 Upwind for concentration on the face If the velocity is positive (rightwards flow): In particular case of constant volume, discharge and cross section area (1D channel with the same cross section and flow everywhere:

11 Rearranging the equation Using 3 vectors to store the coefficients that relate the new (at time t+dt) with values at time t in the point and in the neighbouring points one can write:

12 Explicit, Upwind, Cr = 1, Dif=0 In this table each line represents a time instant (the first is the initial solution) and each column displays the solution in one point. The right column is the summation of the solution along one line (i.e. is the total mass). Cr=(Space run during a time step)/(spatial step) Cr=1, means one cell per time step

13 Explicit, Upwind, Cr= 0.5, Dif=0 The patch spreads! This means that there is diffusion. This diffusion is not physical because we have imposed null diffusivity. It is numerical diffusion! Why? Because we have violated the definition of concentration that assume it is uniform inside the volume. How can it be managed? Using a finer grid

14 How did this happen? t0001000000 t0+Δt000.5 00000 t0+2Δt000.250.50.250000 t0+3Δt000.1250.375 0.125 The model is stable: errors appear and vanish in time. The model has numerical diffusion because the concentration decays. A fine grid is required (at least 100 computation points to describe a patch)

15 Explicit, Upwind, Cr=2 t0001000000 t0+Δt00200000 t0+2Δt00+1-440000 t0+3Δt0010-168 The model is unstable: errors appear and grow. why? Because in an explicit formulation Cr≤1 is required. In fact the coefficients multiplying the concentrations on the second equation member must be non-negative (can be null or positive).

16 Instabilities and numerical diffusion are consequences of physical principles’ violation Numerical diffusion happened because the algorithm assumes uniform concentration inside the control volume. If this is not true, the consequence is numerical diffusion. The coefficients multiplying the variables cannot be negative. If they are negative, it means that the larger is the property in that point, the smaller it is the new value in the calculating point. This is physically impossible. Advection and diffusion transport material from one point to the neighboring points and thus, when the property increases in one point, in a neighbor it can only increase (or nothing happens if there is no velocity or no diffusivity connecting the two points. When Cr>1 the Ci coefficient gets negative. When Cr>1, the volume leaving a computation cell (a finite-volume) during a time interval is larger than the volume contained in the cell and consequently the amount remaining inside the cell can get negative (if what is entering is not enough to compensate). ( See Patankar, Fluid Flow )

17 Stability Condition Stability Condition:

18 2nd lecture on Advection - Diffusion Central Differences. Implicit Method. QUICK Method

19 Average Values would be another option to calculate the concentration on the volume faces => This would generate a method named Central Differences

20 Explicit Central Differences The equation can again be written in the form:

21 1D explicit central differences Courant=1 The Model is unstable. Why? Because one of the coefficients is always negative if there is no diffusion. This happens because we have violated the transportive property of Advection. How to manage it?

22 Why are Central Differences unstable? The coefficients multiplying the variables cannot be negative. If they are negative, it means that the larger is the property in that point, the smaller it is the new value in the calculating point. This is physically impossible. Advection and diffusion transport material from one point to the neighboring points and thus, when the property increases in one point, in a neighbor it can only increase (or nothing happens if there is no velocity or no diffusivity connecting the two points. Adding diffusivity one can get positive coefficients….

23 Stability conditions for Explicit Central- Differences Why do we get stability adding some diffusion? Why do the system get unstable if too much diffusion is added?

24 Interpretation of Central differences Why are central differences unstable without diffusion? – Resp: They violate the transportive property. A downstream point learns about the concentration upstream when the average is used to compute the value of the property on the surface of the control volume. As a consequence if the downstream value is large compared with the upstream value one can obtain a value at the interface large enough to empty (or make negative) the new upstream value. This always happens when the upstream value is null and the downstream value is not. Why can diffusion stabilize the method? – Resp: Because diffusion transports properties against the gradient. If the concentration downstream is higher than upstream it generates an upstream flux. If this flux is larger than the advective flux, it means that advection is transporting something that came from downstream and this physically meaningful. – Diffusion can’t however be so strong that would empty the downstream cell. So there is a limitation to the value of the diffusion number.

25 More issues Can Central diferences be used when advection is the dominant process? – Resp: No. The grid Reynolds number is limited by 2. If diffusion is dominant is better to use central diferences or upwind? – IN this c ase central diferences are better because they have second order precision and thus generate more accurate results. What if the algorithm was implicit? Would it be stable? – Resp: Yes, but it could generate negative concentrations that could be problematic in ecological models since they woud transform sources into sinks and vice-versa. In the implicit calculation the values used to compute fluxes are the values at t+dt. As a consequence the values at the interface must reamin positive. This means that negative values tend to be small. And if the method was upwind implicit? – Resp: In this case the method would be unconditionally stable and concentrations would never get negative. The method uses the new values to compute fluxes and thus, if a value would become negative the flux would be reversed (would enter instead of leaving) and thus the concentration can never get negative…..

26 Other methods for advection Upwind: what is passing through a face is what is upstream. Central-Differences: what is passing through a face is the average between both sides. What if one have adjusted a 2 nd order polynomial, using 3 points? One would get the QUICK: (Quadratic Upstream Interpolation for Convective Kinematics) method: This method has 3 rd order precision. It has more stability issues than the upstream method, but less than the central differences. Can not be applied along the boundaries and in particular situations when the downstream information plays a major role in the solution. Finally what is the best method? There is no absolute best.

27 Implicit Method In this case the Independent Term is just the concentration at time t.

28 Why are implicit methods unconditionally stable? UPWIND – The explicit method the amount that leaves a cell is physically limited by what is inside the cell at time “t”, i.e. the Courant number is limited by “1”. In the implicit method what leave the cell is what will be there at time “t+dt” and thus there is no limitation. If there would be nothing in the cell, nothing would leave. – In the explicit method if one removes from one cell more than what is inside, the concentration can become negative. – In the implicit method what is leaving the cell is a function of what would be there at the end of the time step and consequently the new value can never be negative. – What about the central-differences? In this case, even implicit methods can generate negative concentrations, but the values are bounded by the positive concentrations in the neighboring cells.

29 Why are central implicit diferences more stable than explicit ones? Because in the explicit method what leaves the cell is what is there at time “t” while in the implicit method is what it will be there at time “t+dt”. In the explicit case one can get very low negative values when the courant number is large, while in the implicit method the average value computed at the interface will always be positive and consequently the negative values are bounded by this condition.

30 Graphical visualization of the Differences between explicit and implicit methods t c t1t1+Δt Explicit Method Implicit Method Errors are of the same magnitude. When one error is for excess (positive) the other is negative. The more accurate calculation is the average of both (Semi-implicit)

31 Semi-implicit Method (Crank – Nicholson) Explicit Method: Implicit Method: Semi-implicit Method (Crank – Nicholson): Requires twice the number of calculations, but is more accurate. Is very conveniente in 2D and 3D models.

32 Final Remarks To solve an equation numerically one has to: Get algebraic equations relating the new value at a grid point with values at the neighboring points Organize that equation into a standard form in order to easy the development of a software able to solve different formulations. Use as much capacity of abstraction as possible in order to produce tools as generic as possible.

33 Summary The rationale used to obtain the algebraic equations was based on the direct application of the conservation principle to a finite volume, assuming that it is small enough to guarantee that the average value is representative of each point of the volume and that the properties over each face can be assumed as uniforms and also that the time step is small enough to assume that its value does not change over the time step. Could we get the same result starting from the differential equations?

34 4th Lecture on Advection - Diffusion Séries de Taylor Series to obtain the algebraic equations.

35 Equation Forms Written as the flux divergence: Where the 1st term of the 2nd member is the o symetric of the flux divergence, i.e. what is entering minus what is leaving. In the conventional form: The rate of accumulation is equal to what flow in minus what flow out plus production minus consumption:

36 Taylor Series They are the basis of the finite – difference methods that are of the same family as the finite-volumes. The finite Elements/boundary elements are the other big family of numerical methods.

37 What is a Taylor Series representing? t1t1+Δt ΔtΔt ΔcΔc Others derivatives ΔcΔc 1st Derivative: Δc/ Δt t c

38 How to use Taylor series to compute derivatives? Explicit Method: The derivative is computed at the left “at t” having 1st order accuracy. This means that ignored derivatives are multiplied by The truncation error is proportional to meaning that the truncation error increase linearly with the time step (in fact the time step divided by the period being simulated). To be computed at the left means “art the left of the time interval, i.e. at time “t”. As a consequence all the derivatives (i.e. all equation terms) are calculated at time “t”.

39 If the calculation was done at the right of the time step Implicit Method: IN this case the derivative is computed at “t+dt” and has also 1st order truncation error. Explicit and implicit method have the same truncation error, although the latter is more stable.

40 To compute the derivative at the centre of the time interval, one can compute the values at the extremes as a function of that: Subtracting one from the other: This method has second order truncation error. It means that it would generate the exact solution in a parabolic evolution. Ignored derivatives are multiplied by

41 What does a Taylor series represent? t c t1t1+Δt ΔtΔt ΔcΔc Other Derivatives 1st Derivative: Δc/ Δt Implicit method Explicit method Central Difference Method

42 Spatial Derivatives Derivative at the right, downwind Method, if the velocity is positive In this method the spatial derivative at a point is computed using information at the computing point and at its right. We will see further down that this method is fine when the velocity is negative, but it creates problems when the velocity is positive because it violates the transportive property of advection.

43 Spatial Derivatives Derivative at the left: “upwind method” if velocity is positive and downwind is it is negative. This method respects the transportive property when the velocity is positive but tot when it is negative. The best combination is to use this method when the velocity is positive and the derivative at the right when the velocity is negative.

44 Substrating one equation from the other one gets: Central Differences

45 2ª Derivative Adding:

46 4th Lecture of Advection - Diffusion Algebraic Equations. Truncation error, Initial Conditions And Boundary Conditions.

47 Algebraic Equations They are Obtained subtracting the derivatives by the algebraic approximations: Explicit, central differences. 2 nd order accuracy in space first in time. Semi-implicit (Crank-Nicholson) spatial central differences. 2 nd order accuracy in space and time. What do we pay for second order accuracy in time?

48 How to obtain values at time (t+Δt/2) ? Calculating the average….. Adding the equations! Replacing in the previous equations, one gets the equations to be solved.

49 Explicit Upwind 1 st order accuracy in space and time for advection. Second for diffusion in space. This equation can re reorganized as:

50 Generic Form of the Equation Explicit, upwind: Courant and Diffusion numbers K=1=> implicit. K=0 => Explicit, k=0.5=> Crank-Nicholson:

51 About calculation accuracy In implicit and explicit methods derivatives are calculated at the extremes of the time interval. As a consequence these methods ignore all derivatives but the first and consequently they are first order accurate. The Taylor series terms ignored are multiplied by When the derivative is computed at the centre of the time interval, the second derivative is still accounted and the method is second order accurate. The ignored derivatives are multiplied by But >1 and thus it seems that the higher is the accuracy, the larger is the coefficient multiplying the terms ignored. Why is this so?

52 Why does accuracy increase with the exponent of ? Because the terms ignored are of the form: The denominator of the derivative is proportional to the time step with exponent “n” and the coefficient multiplying the derivative is proportional to half of the time step with exponent (n-1). As a consequence the whole term is proportional to The higher is “n” smaller is the term neglected. This result is consistent with the idea that derivatives loose importance as their order increases.

53 Boundary and initial conditions Initial conditions are often not importante because natural systems are dissipative and open, i.e. they Exchange through open boundaries. For the same reason boundary conditions are very importante. How do they appear? CiCi C i-1 C i+1

54 Boundary Conditions Diffusion: – The calculation of the diffusive terms across a surface require the knowledge of diffusivity over the surface and of the value on the other side of the surface. When they are not know, the best solution is usually to consider null flux. – Diffusion involves a second derivative and thus requires a boundary condition all over the boundary. Advecction: – When the flow enters into the domain it is imperative to know the properties being advected. If not known the simulation can make sense only if the source/sink terms inside the domain are the main responsible for the values of the properties. – Because it involves a 1 st derivative advection requires only one boundary condition (at the entrance) if upwind discretization is used.

55 Heat Transport In case of heat bottom fluxes are usually less important than fluxes across the free surface and across the open boundaries and can be neglected. Fluxes across the free surface control the eat budget and have to be computed (radiation, sensitive and latent heat).

56 5th Lecture on Advection - Diffusion Free surface fluxes.

57 Free surface boundary condition Depend on the property being studied In case od gases and vapours require the knowledge of the partial pressure in the atmosphere. In case of heat require the incident radiation (solar and diffuse) and the heat flux radiated by the water. Latent and sensitive heat fluxes require the knowledge of atmospheric moisture and temperature.

58 Sensible Heat Flux Depends on the air and water temperatures and of the convection coefficient, which is a function of the turbulence generated by the wind. Several correlations to compute the convection coefficient have been publish in the literature, e.g. Where u is the wind speed (m/s) and h is (w/(m 2 k)

59 Latent heat Flux Depends on the water temperature and air relative humidity, and on the wind speed (interface turbulence). Several empirical correlations have been proposed in the literature and some have been seen in other chapters of this course. The following correlation relates the sensible heat convection coefficient (in Wm -2 K -1 ) with the evaporated volume coefficient (in m/s): Where

60 Solar Radiation Consult (e.g.): Brock, T. D. (1981) - Calculating solar radiation for ecological studies. Ecological Modelling.


Download ppt "Lecture 15 Advection – Diffusion Equation and its numerical resolution."

Similar presentations


Ads by Google