Computational hydraulics

2,194 views
2,060 views

Published on

Published in: Technology, Business
2 Comments
1 Like
Statistics
Notes
No Downloads
Views
Total views
2,194
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
127
Comments
2
Likes
1
Embeds 0
No embeds

No notes for slide

Computational hydraulics

  1. 1. Computational Hydraulics Prof. M.S.Mohan Kumar Department of Civil Engineering
  2. 2. Introduction to Hydraulics of Open Channels Module 1 3 lectures
  3. 3. Topics to be coveredBasic ConceptsConservation LawsCritical FlowsUniform FlowsGradually Varied FlowsRapidly Varied FlowsUnsteady Flows
  4. 4. Basic ConceptsOpen Channel flows deal with flow of water in open channelsPressure is atmospheric at the water surface and thepressure is equal to the depth of water at any sectionPressure head is the ratio of pressure and the specific weightof waterElevation head or the datum head is the height of thesection under consideration above a datumVelocity head (=v2/2g) is due to the average velocity of flowin that vertical section
  5. 5. Basic Concepts Cont… Total head =p/γ + v2/2g + z Pressure head = p/γ Velocity head =v2/2g Datum head = z The flow of water in an open channel is mainly due to headgradient and gravity Open Channels are mainly used to transport water forirrigation, industry and domestic water supply
  6. 6. Conservation LawsThe main conservation laws used in open channels are Conservation Laws Conservation of Mass Conservation of Momentum Conservation of Energy
  7. 7. Conservation of MassConservation of MassIn any control volume consisting of the fluid ( water) underconsideration, the net change of mass in the control volumedue to inflow and out flow is equal to the the net rate ofchange of mass in the control volume This leads to the classical continuity equation balancing theinflow, out flow and the storage change in the controlvolume. Since we are considering only water which is treated asincompressible, the density effect can be ignored
  8. 8. Conservation of Momentum and energyConservation of MomentumThis law states that the rate of change of momentum in thecontrol volume is equal to the net forces acting on thecontrol volume Since the water under consideration is moving, it is actedupon by external forces Essentially this leads to the Newton’s second lawConservation of EnergyThis law states that neither the energy can be created ordestroyed. It only changes its form.
  9. 9. Conservation of Energy Mainly in open channels the energy will be in the form of potential energyand kinetic energy Potential energy is due to the elevation of the water parcel while thekinetic energy is due to its movement In the context of open channel flow the total energy due these factorsbetween any two sections is conserved This conservation of energy principle leads to the classical Bernoulli’sequationP/γ + v2/2g + z = Constant When used between two sections this equation has to account for theenergy loss between the two sections which is due to the resistance to theflow by the bed shear etc.
  10. 10. Types of Open Channel FlowsDepending on the Froude number (Fr) the flow in an openchannel is classified as Sub critical flow, Super Criticalflow, and Critical flow, where Froude number can be definedas F = V r gy Open channel flow Sub-critical flow Sub- Critical flow Super critical flow Fr<1 Fr=1 Fr>1
  11. 11. Types of Open Channel Flow Cont... Open Channel Flow Unsteady Steady Varied Uniform Varied Gradually Gradually Rapidly Rapidly
  12. 12. Types of Open Channel Flow Cont… Steady FlowFlow is said to be steady when discharge does notchange along the course of the channel flow Unsteady FlowFlow is said to be unsteady when the dischargechanges with time Uniform FlowFlow is said to be uniform when both the depth anddischarge is same at any two sections of the channel
  13. 13. Types of Open Channel Cont… Gradually Varied FlowFlow is said to be gradually varied when ever thedepth changes gradually along the channel Rapidly varied flowWhenever the flow depth changes rapidly along thechannel the flow is termed rapidly varied flow Spatially varied flowWhenever the depth of flow changes gradually dueto change in discharge the flow is termed spatiallyvaried flow
  14. 14. Types of Open Channel Flow cont… Unsteady FlowWhenever the discharge and depth of flow changeswith time, the flow is termed unsteady flow Types of possible flow Steady uniform flow Steady non-uniform flow Unsteady non-uniform flow kinematic wave diffusion wave dynamic wave
  15. 15. DefinitionsSpecific EnergyIt is defined as the energy acquired by the water at asection due to its depth and the velocity with which itis flowing Specific Energy E is given by, E = y + v2/2gWhere y is the depth of flow at that sectionand v is the average velocity of flow Specific energy is minimum at criticalcondition
  16. 16. DefinitionsSpecific ForceIt is defined as the sum of the momentum of the flow passing through the channel section per unit time per unit weight of water and the force per unit weight of water F = Q2/gA +yA The specific forces of two sections are equal provided that the external forces and the weight effect of water in the reach between the two sections can be ignored. At the critical state of flow the specific force is a minimum for the given discharge.
  17. 17. Critical FlowFlow is critical when the specific energy is minimum.Also whenever the flow changes from sub critical tosuper critical or vice versa the flow has to gothrough critical condition figure is shown in next slide Sub-critical flow-the depth of flow will be higherwhereas the velocity will be lower. Super-critical flow-the depth of flow will be lowerbut the velocity will be higher Critical flow: Flow over a free over-fall
  18. 18. Specific energy diagram E=yDepth of water Surface (y) E-y curve 1 Emin y1 C Alternate Depths c 2 y 45° 2 Critical Depth Specific Energy (E) y Specific Energy Curve for a given discharge
  19. 19. Characteristics of Critical Flow Specific Energy (E = y+Q2/2gA2) is minimum For Specific energy to be a minimum dE/dy = 0 dE Q 2 dA = 1− 3 ⋅ dy gA dy However, dA=Tdy, where T is the width of thechannel at the water surface, then applying dE/dy =0, will result in following Q 2Tc Ac Q2 Ac VC2 =1 = 2 = gAc 3 Tc gAc Tc g
  20. 20. Characteristics of Critical FlowFor a rectangular channel Ac /Tc=ycFollowing the derivation for a rectangular channel, Vc Fr = =1 gy cThe same principle is valid for trapezoidal and othercross sectionsCritical flow condition defines an unique relationshipbetween depth and discharge which is very useful in thedesign of flow measurement structures
  21. 21. Uniform Flows This is one of the most important concept in open channelflows The most important equation for uniform flow is Manning’sequation given by 1 2 / 3 1/ 2 V= R S nWhere R = the hydraulic radius = A/P P = wetted perimeter = f(y, S0)Y = depth of the channel bedS0 = bed slope (same as the energy slope, Sf)n = the Manning’s dimensional empirical constant
  22. 22. Uniform Flows Energy Grade Line 2V12/2g 1 1 hf Sf v22/2gy1 Control Volume y2 So 1z1 z2 Datum Steady Uniform Flow in an Open Channel
  23. 23. Uniform Flow Example : Flow in an open channel This concept is used in most of the open channel flow design The uniform flow means that there is no acceleration to theflow leading to the weight component of the flow beingbalanced by the resistance offered by the bed shear In terms of discharge the Manning’s equation is given by 1 Q = AR 2 / 3 S 1/ 2 n
  24. 24. Uniform Flow This is a non linear equation in y the depth of flow for whichmost of the computations will be made Derivation of uniform flow equation is given below, whereW sin θ = weight component of the fluid mass in thedirection of flow τ0 = bed shear stress P∆x = surface area of the channel
  25. 25. Uniform FlowThe force balance equation can be written as W sin θ − τ 0 P∆x = 0Or γA∆x sin θ − τ 0 P∆x = 0 AOr τ 0 = γ sin θ PNow A/P is the hydraulic radius, R, and sinθ isthe slope of the channel S0
  26. 26. Uniform FlowThe shear stress can be expressed as τ 0 = c f ρ (V 2 / 2)Where cf is resistance coefficient, V is the meanvelocity ρ is the mass densityTherefore the previous equation can be written as V2 2gOr cf ρ = γRS 0 V = RS 0 = C RS 0 2 cfwhere C is Chezy’s constantFor Manning’s equation 1.49 1 / 6 C= R n
  27. 27. Gradually Varied FlowFlow is said to be gradually varied whenever the depth offlow changed gradually The governing equation for gradually varied flow is given by dy S 0 − S f = dx 1 − Fr 2 Where the variation of depth y with the channel distance xis shown to be a function of bed slope S0, Friction Slope Sfand the flow Froude number Fr. This is a non linear equation with the depth varying as anon linear function
  28. 28. Gradually Varied Flow Energy-grade line (slope = Sf) v2/2g Water surface (slope = Sw) y Channel bottom (slope = So) z Datum Total head at a channel section
  29. 29. Gradually Varied FlowDerivation of gradually varied flow is as follows… The conservation of energy at two sections of a reach of length ∆x, can be written as 2 2 V1 V2 y1 + + S 0 ∆x = y 2 + + S f ∆x 2g 2g Now, let ∆y = y − y and V2 2 V1 2 d ⎛ V 2 ⎞ 2 1 − = ⎜⎜ ⎟∆x ⎟ 2g 2g dx ⎝ 2 g ⎠Then the above equation becomes d ⎛V 2 ⎞ ∆y = S 0 ∆x − S f ∆x − ⎜ ⎜ 2 g ⎟∆x ⎟ dx ⎝ ⎠
  30. 30. Gradually Varied FlowDividing through ∆x and taking the limit as ∆xapproaches zero gives us dy d ⎛ V 2 ⎞ + ⎜ ⎜ 2g ⎟ = S0 − S f ⎟ dx dx ⎝ ⎠After simplification, dy S0 − S f = ( ) dx 1 + d V 2 / 2 g / dyFurther simplification can be done in terms ofFroude number d ⎛V 2 ⎞ d ⎛ Q2 ⎞ ⎜ ⎜ 2 g ⎟ = dy ⎜ 2 gA 2 ⎟ ⎜ ⎟ ⎟ dy ⎝ ⎠ ⎝ ⎠
  31. 31. Gradually Varied FlowAfter differentiating the right side of the previousequation, d ⎛ V ⎞ − 2Q dA 2 2 ⎜ 2 g ⎟ = 2 gA 3 ⋅ dy ⎜ ⎟ dy ⎝ ⎠But dA/dy=T, and A/T=D, therefore, d ⎛V 2 ⎞ − Q2 ⎜ ⎟= = − Fr 2 dy ⎜ 2 g ⎟ gA 2 D ⎝ ⎠Finally the general differential equation can bewritten as dy S 0 − S f = dx 1 − Fr 2
  32. 32. Gradually Varied Flow Numerical integration of the gradually varied flow equationwill give the water surface profile along the channel Depending on the depth of flow where it lies when comparedwith the normal depth and the critical depth along with thebed slope compared with the friction slope different types ofprofiles are formed such as M (mild), C (critical), S (steep)profiles. All these have real examples. M (mild)-If the slope is so small that the normal depth(Uniform flow depth) is greater than critical depth for thegiven discharge, then the slope of the channel is mild.
  33. 33. Gradually Varied FlowC (critical)-if the slope’s normal depth equals its criticaldepth, then we call it a critical slope, denoted by CS (steep)-if the channel slope is so steep that a normaldepth less than critical is produced, then the channel issteep, and water surface profile designated as S
  34. 34. Rapidly Varied Flow This flow has very pronounced curvature of the streamlines It is such that pressure distribution cannot be assumed to be hydrostatic The rapid variation in flow regime often take place in short span When rapidly varied flow occurs in a sudden-transition structure, the physical characteristics of the flow are basically fixed by the boundary geometry of the structure as well as by the state of the flowExamples: Channel expansion and cannel contraction Sharp crested weirs Broad crested weirs
  35. 35. Unsteady flowsWhen the flow conditions vary with respect to time, we callit unsteady flows.Some terminologies used for the analysis of unsteady flowsare defined below:Wave: it is defined as a temporal or spatial variation of flowdepth and rate of discharge.Wave length: it is the distance between two adjacent wavecrests or troughAmplitude: it is the height between the maximum waterlevel and the still water level
  36. 36. Unsteady flows definitionsWave celerity (c): relative velocity of a wave with respectto fluid in which it is flowing with VAbsolute wave velocity (Vw): velocity with respect tofixed reference as given below Vw = V ± cPlus sign if the wave is traveling in the flow direction andminus for if the wave is traveling in the direction opposite toflowFor shallow water waves c = gy0 where y0=undisturbedflow depth.
  37. 37. Unsteady flows examplesUnsteady flows occur due to following reasons:1. Surges in power canals or tunnels2. Surges in upstream or downstream channels produced by starting or stopping of pumps and opening and closing of control gates3. Waves in navigation channels produced by the operation of navigation locks4. Flood waves in streams, rivers, and drainage channels due to rainstorms and snowmelt5. Tides in estuaries, bays and inlets
  38. 38. Unsteady flowsUnsteady flow commonly encountered in an open channelsand deals with translatory waves. Translatory waves is agravity wave that propagates in an open channel andresults in appreciable displacement of the water particles ina direction parallel to the flowFor purpose of analytical discussion, unsteady flow isclassified into two types, namely, gradually varied andrapidly varied unsteady flowIn gradually varied flow the curvature of the wave profile ismild, and the change in depth is gradualIn the rapidly varied flow the curvature of the wave profileis very large and so the surface of the profile may becomevirtually discontinuous.
  39. 39. Unsteady flows cont…Continuity equation for unsteady flow in an openchannel ∂V ∂y ∂y D +V + =0 ∂x ∂x ∂tFor a rectangular channel of infinite width, may bewritten ∂q ∂y + =0 ∂x ∂tWhen the channel is to feed laterally with asupplementary discharge of q’ per unit length, forinstance, into an area that is being flooded over adike
  40. 40. Unsteady flows cont…The equation ∂Q ∂A + + q = 0 ∂x ∂tThe general dynamic equation for graduallyvaried unsteady flow is given by: ∂y αV ∂V 1 ∂V + + =0 ∂x g ∂x g ∂t
  41. 41. Review of Hydraulics of Pipe Flows Module2 3 lectures
  42. 42. ContentsGeneral introductionEnergy equationHead loss equationsHead discharge relationshipsPipe transients flows throughpipe networksSolving pipe network problems
  43. 43. General IntroductionPipe flows are mainly due to pressure difference betweentwo sectionsHere also the total head is made up of pressure head, datumhead and velocity headThe principle of continuity, energy, momentum is also usedin this type of flow.For example, to design a pipe, we use the continuity andenergy equations to obtain the required pipe diameterThen applying the momentum equation, we get the forcesacting on bends for a given discharge
  44. 44. General introductionIn the design and operation of a pipeline, the mainconsiderations are head losses, forces and stressesacting on the pipe material, and discharge.Head loss for a given discharge relates to flowefficiency; i.e an optimum size of pipe will yield theleast overall cost of installation and operation forthe desired discharge.Choosing a small pipe results in low initial costs,however, subsequent costs may be excessivelylarge because of high energy cost from large headlosses
  45. 45. Energy equation The design of conduit should be such that it needs least cost for a given discharge The hydraulic aspect of the problem require applying the one dimensional steady flow form of the energy equation: p1 V12 p2 2 V2 + α1 + z1 + h p = + α2 + z2 + ht + hL γ 2g γ 2gWhere p/γ =pressure head αV2/2g =velocity head z =elevation head hp=head supplied by a pump ht =head supplied to a turbine hL =head loss between 1 and 2
  46. 46. Energy equation Energy Grade Line Hydraulic Grade Line z2 v2/2g p/y hp z1 z Pump z=0 DatumThe Schematic representation of the energy equation
  47. 47. Energy equationVelocity head In αV2/2g, the velocity V is the mean velocity in the conduit at a given section and is obtained by V=Q/A, where Q is the discharge, and A is the cross-sectional area of the conduit. The kinetic energy correction factor is given by α, and it is defines as, where u=velocity at any point in the section 3 ∫ u dA α= A V 3A α has minimum value of unity when the velocity is uniform across the section
  48. 48. Energy equation cont…Velocity head cont… α has values greater than unity depending on the degree of velocity variation across a section For laminar flow in a pipe, velocity distribution is parabolic across the section of the pipe, and α has value of 2.0 However, if the flow is turbulent, as is the usual case for water flow through the large conduits, the velocity is fairly uniform over most of the conduit section, and α has value near unity (typically: 1.04< α < 1.06). Therefore, in hydraulic engineering for ease of application in pipe flow, the value of α is usually assumed to be unity, and the velocity head is then simply V2/2g.
  49. 49. Energy equation cont…Pump or turbine head The head supplied by a pump is directly related to the power supplied to the flow as given below P = Qγh p Likewise if head is supplied to turbine, the power supplied to the turbine will be P = Qγht These two equations represents the power supplied directly or power taken out directly from the flow
  50. 50. Energy equation cont…Head-loss term The head loss term hL accounts for the conversion of mechanical energy to internal energy (heat), when this conversion occurs, the internal energy is not readily converted back to useful mechanical energy, therefore it is called head loss Head loss results from viscous resistance to flow (friction) at the conduit wall or from the viscous dissipation of turbulence usually occurring with separated flow, such as in bends, fittings or outlet works.
  51. 51. Head loss calculationHead loss is due to friction between the fluid andthe pipe wall and turbulence within the fluidThe rate of head loss depend on roughnesselement size apart from velocity and pipe diameterFurther the head loss also depends on whether thepipe is hydraulically smooth, rough or somewherein betweenIn water distribution system , head loss is also dueto bends, valves and changes in pipe diameter
  52. 52. Head loss calculationHead loss for steady flow through a straight pipe: τ 0 A w = ∆ pA r ∆p = 4Lτ 0 / D τ 0 = fρ V 2 / 8 ∆p L V2 h = = f γ D 2gThis is known as Darcy-Weisbach equationh/L=S, is slope of the hydraulic and energy gradelines for a pipe of constant diameter
  53. 53. Head loss calculationHead loss in laminar flow: 32Vµ Hagen-Poiseuille equation gives S= D 2 ρg Combining above with Darcy-Weisbach equation, gives f 64 µ f = ρVD Also we can write in terms of Reynolds number 64 f = Nr This relation is valid for Nr<1000
  54. 54. Head loss calculationHead loss in turbulent flow: In turbulent flow, the friction factor is a function of both Reynolds number and pipe roughness As the roughness size or the velocity increases, flow is wholly rough and f depends on the relative roughness Where graphical determination of the friction factor is acceptable, it is possible to use a Moody diagram. This diagram gives the friction factor over a wide range of Reynolds numbers for laminar flow and smooth, transition, and rough turbulent flow
  55. 55. Head loss calculation The quantities shown in Moody Diagram are dimensionless so they can be used with any system of units Moody’s diagram can be followed from any reference bookMINOR LOSSES Energy losses caused by valves, bends and changes in pipe diameter This is smaller than friction losses in straight sections of pipe and for all practical purposes ignored Minor losses are significant in valves and fittings, which creates turbulence in excess of that produced in a straight pipe
  56. 56. Head loss calculationMinor losses can be expressed in three ways:1. A minor loss coefficient K may be used to give head loss as a function of velocity head, V2 h=K 2g2. Minor losses may be expressed in terms of the equivalent length of straight pipe, or as pipe diameters (L/D) which produces the same head loss. 2 LV h= f D 2g
  57. 57. Head loss calculation1. A flow coefficient Cv which gives a flow that will pass through the valve at a pressure drop of 1psi may be specified. Given the flow coefficient the head loss can be calculated as 18.5 × 106 D 4V 2 h= 2 Cv 2 gThe flow coefficient can be related to the minor loss coefficient by 18.5 × 106 D 2 K= 2 Cv
  58. 58. Energy Equation for Flow in pipesEnergy equation for pipe flow P V12 P2 V22 z1 + 1 + = z2 + + + hL ρg 2 g ρg 2 gThe energy equation represents elevation, pressure, and velocity formsof energy. The energy equation for a fluid moving in a closed conduit iswritten between two locations at a distance (length) L apart. Energylosses for flow through ducts and pipes consist of major losses andminor losses.Minor Loss Calculations for Fluid Flow V2 hm = K 2gMinor losses are due to fittings such as valves and elbows
  59. 59. Major Loss Calculation for Fluid Flow Using Darcy-Weisbach Friction Loss Equation Major losses are due to friction between the moving fluid and the inside walls of the duct. The Darcy-Weisbach method is generally considered more accurate than the Hazen-Williams method. Additionally, the Darcy-Weisbach method is valid for any liquid or gas. Moody Friction Factor Calculator
  60. 60. Major Loss Calculation in pipesUsing Hazen-Williams Friction Loss EquationHazen-Williams is only valid for water at ordinarytemperatures (40 to 75oF). The Hazen-Williams method isvery popular, especially among civil engineers, since itsfriction coefficient (C) is not a function of velocity or duct(pipe) diameter. Hazen-Williams is simpler than Darcy-Weisbach for calculations where one can solve for flow-rate, velocity, or diameter
  61. 61. Transient flow through long pipesIntermediate flow while changing from onesteady state to another is called transientflowThis occurs due to design or operatingerrors or equipment malfunction.This transient state pressure causes lots ofdamage to the network systemPressure rise in a close conduit caused by aninstantaneous change in flow velocity
  62. 62. Transient flow through long pipesIf the flow velocity at a point does vary with time, the flowis unsteadyWhen the flow conditions are changed from one steadystate to another, the intermediate stage flow is referred toas transient flowThe terms fluid transients and hydraulic transients are usedin practiceThe different flow conditions in a piping system arediscussed as below:
  63. 63. Transient flow through long pipesConsider a pipe length of length LWater is flowing from a constant level upstream reservoirto a valve at downstreamAssume valve is instantaneously closed at time t=t0 fromthe full open position to half open position.This reduces the flow velocity through the valve, therebyincreasing the pressure at the valve
  64. 64. Transient flow through long pipes The increased pressure will produce a pressure wave that will travel back and forth in the pipeline until it is dissipated because of friction and flow conditions have become steady again This time when the flow conditions have become steady again, let us call it t1. So the flow regimes can be categorized into1. Steady flow for t<t02. Transient flow for t0<t<t13. Steady flow for t>t1
  65. 65. Transient flow through long pipesTransient-state pressures are sometimes reduced to thevapor pressure of a liquid that results in separating theliquid column at that section; this is referred to as liquid-column separationIf the flow conditions are repeated after a fixed timeinterval, the flow is called periodic flow, and the timeinterval at which the conditions are repeated is calledperiodThe analysis of transient state conditions in closed conduitsmay be classified into two categories: lumped-systemapproach and distributed system approach
  66. 66. Transient flow through long pipesIn the lumped system approach the conduit wallsare assumed rigid and the liquid in the conduit isassumed incompressible, so that it behaves like arigid mass, other way flow variables are functionsof time only.In the distributed system approach the liquid isassumed slightly compressibleTherefore flow velocity vary along the length of theconduit in addition to the variation in time
  67. 67. Transient flow through long pipesFlow establishment The 1D form of momentum equation for a control volume that is fixed in space and does not change shape may be written as d 2 2 ∑F = ∫ ρ VAdx + ( ρAV ) out − ( ρ AV ) in dt If the liquid is assumed incompressible and the pipe is rigid, then at any instant the velocity along the pipe will be same, ( ρ AV 2 ) in = ( ρ AV 2 ) out
  68. 68. Transient flow through long pipes Substituting for all the forces acting on the control volume d pA + γAL sin α − τ 0πDL = (V ρ AL ) dtWhere p =γ(h-V2/2g)α=pipe slopeD=pipe diameterL=pipe lengthγ =specific weight of fluidτ0=shear stress at the pipe wall
  69. 69. Transient flow through long pipesFrictional force is replaced by γhfA, and H0=h+Lsin α and hffrom Darcy-weisbach friction equationThe resulting equation yields: fL V 2 V 2 L dV H0 − − = . D 2g 2g g dtWhen the flow is fully established, dV/dt=0.The final velocity V0 will be such that ⎡ fL ⎤ V0 2 H 0 = ⎢1 + ⎣ D ⎥ 2g ⎦We use the above relationship to get the time for flow toestablish 2 LD dV dt = . D + fL V02 − V 2
  70. 70. Transient flow through long pipesChange in pressure due to rapid flow changes When the flow changes are rapid, the fluid compressibility is needed to taken into account Changes are not instantaneous throughout the system, rather pressure waves move back and forth in the piping system. Pipe walls to be rigid and the liquid to be slightly compressible
  71. 71. Transient flows through long pipesAssume that the flow velocity at the downstreamend is changed from V to V+∆V, thereby changingthe pressure from p to p+∆pThe change in pressure will produce a pressurewave that will propagate in the upstream directionThe speed of the wave be aThe unsteady flow situation can be transformed intosteady flow by assuming the velocity referencesystem move with the pressure wave
  72. 72. Transient flows through long pipesUsing momentum equation with control volume approach tosolve for ∆pThe system is now steady, the momentum equation nowyield pA − ( p + ∆p) A = (V + a + ∆V )( ρ + ∆ρ )(V + a + ∆V ) A − (V + a ) ρ (V + a ) ABy simplifying and discarding terms of higher order, thisequation becomes ( − ∆p = 2 ρV∆V + 2 ρ∆Va + ∆ρ V 2 + 2Va + a 2 )The general form of the equation for conservation of massfor one-dimensional flows may be written as x2 d 0 = ∫ ρAdx + (ρVA)out − (ρVA)in dt x1
  73. 73. Transient flows through long pipesFor a steady flow first term on the right hand side is zero, then we obtain 0 = (ρ + ∆ρ )(V + a + ∆V )A − ρ (V + a )ASimplifying this equation, We have ρ∆V ∆ρ = − V +aWe may approximate (V+a) as a, because V<<a ρ∆V ∆ρ = − aSince ∆p = ρg∆H we can write as a ∆H = − ∆V gNote: change in pressure head due to an instantaneous change in flowvelocity is approximately 100 times the change in the flow velocity
  74. 74. Introduction to Numerical Analysis and Its Role inComputational Hydraulics Module 3 2 lectures
  75. 75. ContentsNumerical computingComputer arithmeticParallel processingExamples of problemsneeding numericaltreatment
  76. 76. What is computational hydraulics?It is one of the many fields of science in which theapplication of computers gives rise to a new wayof working, which is intermediate between purelytheoretical and experimental.The hydraulics that is reformulated to suit digitalmachine processes, is called computationalhydraulicsIt is concerned with simulation of the flow ofwater, together with its consequences, usingnumerical methods on computers
  77. 77. What is computational hydraulics?There is not a great deal of difference withcomputational hydrodynamics or computationalfluid dynamics, but these terms are too muchrestricted to the fluid as such.It seems to be typical of practical problems inhydraulics that they are rarely directed to the flowby itself, but rather to some consequences of it,such as forces on obstacles, transport of heat,sedimentation of a channel or decay of a pollutant.
  78. 78. Why numerical computingThe higher mathematics can be treated by this methodWhen there is no analytical solution, numerical analysiscan deal such physical problemsExample: y = sin (x), has no closed form solution.The following integral gives the length of one arch of theabove curve π ∫ 0 1 + cos 2 ( x ) dxNumerical analysis can compute the length of this curve bystandard methods that apply to essentially any integrandNumerical computing helps in finding effective and efficientapproximations of functions
  79. 79. Why Numerical computing?linearization of non linear equationsSolves for a large system of linear equationsDeals the ordinary differential equations of anyorder and complexityNumerical solution of Partial differentialequations are of great importance in solvingphysical world problemsSolution of initial and boundary value problemsand estimates the eigen values andeigenvectors.Fit curves to data by a variety of methods
  80. 80. Computer arithmeticNumerical method is tedious and repetitive arithmetic,which is not possible to solve without the help of computer.On the other hand Numerical analysis is an approximation,which leads towards some degree of errorsThe errors caused by Numerical treatment are defined interms of following:Truncation error : the ex can be approximated throughcubic polynomial as shown below x x2 x3 p3 ( x ) = 1 + + + 1! 2! 3!ex is an infinitely long series as given below and the error isdue to the truncation of the series ∞ xn e = p3 ( x) + ∑ x n = 4 n!
  81. 81. Computer arithmetic• Round-off error : digital computers always use floating point numbers of fixed word length; the true values are not expressed exactly by such representations. Such error due to this computer imperfection is round-off error.• Error in original data : any physical problem is represented through mathematical expressions which have some coefficients that are imperfectly known.• Blunders : computing machines make mistakes very infrequently, but since humans are involved in programming, operation, input preparation, and output interpretation, blunders or gross errors do occur more frequently than we like to admit.• Propagated error : propagated error is the error caused in the succeeding steps due to the occurrence of error in the earlier step, such error is in addition to the local errors. If the errors magnified continuously as the method continues, eventually they will overshadow the true value, destroying its validity, we call such a method unstable. For stable method (which is desired)– errors made at early points die out as the method continues.
  82. 82. Parallel processingIt is a computing method that can only beperformed on systems containing two or moreprocessors operating simultaneously. Parallelprocessing uses several processors, all working ondifferent aspects of the same program at the sametime, in order to share the computational loadFor extremely large scale problems (short termweather forecasting, simulation to predictaerodynamics performance, image processing,artificial intelligence, multiphase flow in groundwater regime etc), this speeds up the computationadequately.
  83. 83. Parallel processingMost computers have just one CPU, butsome models have several. There are evencomputers with thousands of CPUs. Withsingle-CPU computers, it is possible toperform parallel processing by connectingthe computers in a network. However, thistype of parallel processing requires verysophisticated software called distributedprocessing software.Note that parallel processing differs frommultitasking, in which a single CPU executesseveral programs at once.
  84. 84. Parallel processingTypes of parallel processing job: In general there are three types of parallel computing jobs Parallel task Parametric sweep Task flowParallel taskA parallel task can take a number of forms, depending on the application and the software that supports it. For a Message Passing Interface (MPI) application, a parallel task usually consists of a single executable running concurrently on multiple processors, with communication between the processes.
  85. 85. Parallel processingParametric SweepA parametric sweep consists of multiple instances of the same program, usually serial, running concurrently, with input supplied by an input file and output directed to an output file. There is no communication or interdependency among the tasks. Typically, the parallelization is performed exclusively (or almost exclusively) by the scheduler, based on the fact that all the tasks are in the same job.Task flow A task flow job is one in which a set of unlike tasks are executed in a prescribed order, usually because one task depends on the result of another task.
  86. 86. Introduction to numerical analysisAny physical problem in hydraulics is representedthrough a set of differential equations.These equations describe the very fundamentallaws of conservation of mass and momentum interms of the partial derivatives of dependentvariables.For any practical purpose we need to know thevalues of these variables instead of the values oftheir derivatives.
  87. 87. Introduction to numerical analysisThese variables are obtained from integrating thoseODEs/PDEs.Because of the presence of nonlinear terms a closed formsolution of these equations is not obtainable, except forsome very simplified casesTherefore they need to be analyzed numerically, for whichseveral numerical methods are availableGenerally the PDEs we deal in the computational hydraulicsis categorized as elliptic, parabolic and hyperbolic equations
  88. 88. Introduction to numerical analysisThe following methods have been used for numerical integration of the ODEs Euler method Modified Euler method Runge-Kutta method Predictor-Corrector method
  89. 89. Introduction to numerical analysisThe following methods have been used for numerical integration of the PDEs Characteristics method Finite difference method Finite element method Finite volume method Spectral method Boundary element method
  90. 90. Problems needing numerical treatmentComputation of normal depthComputation of water-surface profilesContaminant transport in streams throughan advection-dispersion processSteady state Ground water flow systemUnsteady state ground water flow systemFlows in pipe networkComputation of kinematic and dynamicwave equations
  91. 91. Solution of System ofLinear and Non Linear Equations Module 4 (4 lectures)
  92. 92. ContentsSet of linear equationsMatrix notationMethod ofsolution:direct anditerativePathology of linearsystemsSolution of nonlinearsystems :Picard andNewton techniques
  93. 93. Sets of linear equationsReal world problems are presented through a set ofsimultaneous equations F1 ( x1, x2 ,..., xn ) = 0 F2 ( x1, x2 ,..., xn ) = 0 . . . Fn ( x1, x2 ,..., xn ) = 0Solving a set of simultaneous linear equations needsseveral efficient techniquesWe need to represent the set of equations through matrixalgebra
  94. 94. Matrix notationMatrix : a rectangular array (n x m) of numbers ⎡ a11 a12 . . . a1m ⎤ ⎢a21 a22 . . . a2 m ⎥ ⎢ . ⎥ [ ] A = aij = ⎢ . ⎢ . . ⎥ ⎥ ⎢ . . ⎥ ⎢ an1 an 2 . . . anm ⎥ ⎣ ⎦ nxmMatrix Addition:C = A+B = [aij+ bij] = [cij], where cij = aij + bijMatrix Multiplication:AB = C = [aij][bij] = [cij], where m cij = ∑ aik bkj i = 1,2,..., n, j = 1,2,..., r. k =1
  95. 95. Matrix notation cont…*AB ≠ BA kA = C, where cij = kaijA general relation for Ax = b is No.ofcols. bi = ∑ aik xk , i = 1,2,..., No.ofrows k =1
  96. 96. Matrix notation cont…Matrix multiplication gives set of linear equations as:a11x1+ a12x2+…+ a1nxn = b1,a21x1+ a22x2+…+ a2nxn = b2,. . .. . .. . .an1x1+ an2x2+…+ annxn = bn,In simple matrix notation we can write:Ax = b, where ⎡ a11 a12 . . . a1m ⎤ ⎡ x1 ⎤ ⎡ b1 ⎤ ⎢a21 a22 . . . a2 m ⎥ ⎢ x2 ⎥ ⎢b2 ⎥ ⎢ . ⎥ ⎢ . ⎥ ⎢.⎥ A=⎢ . ⎥, x = ⎢ ⎥, b = ⎢ ⎥, ⎢ . . ⎥ ⎢ . . ⎥ ⎢ . ⎥ ⎢.⎥ ⎢ an1 an 2 . . . anm ⎥ ⎢ . ⎥ ⎢.⎥ ⎣ ⎦ ⎢ xn ⎥ ⎣ ⎦ ⎢bn ⎥ ⎣ ⎦
  97. 97. Matrix notation cont…Diagonal matrix ( only diagonal elements of asquare matrix are nonzero and all off-diagonalelements are zero)Identity matrix ( diagonal matrix with alldiagonal elements unity and all off-diagonalelements are zero)The order 4 identity matrix is shown below ⎡1 0 0 0⎤ ⎢0 1 0 0⎥ = I . ⎢0 0 1 0⎥ 4 ⎢0 ⎣ 0 0 1⎥ ⎦
  98. 98. Matrix notation cont…Lower triangular matrix: ⎡a 0 0⎤if all the elements above the L = ⎢b d 0⎥ ⎢c e ⎣ f⎥ ⎦diagonal are zeroUpper triangular matrix: ⎡a b c⎤ U = ⎢0 d e⎥if all the elements below the ⎢0 0 f⎥ ⎣ ⎦diagonal are zeroTri-diagonal matrix: if ⎡a b 0 0 0⎤nonzero elements only on ⎢c d e 0 0⎥the diagonal and in the T = ⎢0 f g h 0⎥ ⎢0 0 i j k⎥position adjacent to the ⎢0 ⎣ 0 0 l m⎥ ⎦diagonal
  99. 99. Matrix notation cont…Transpose of a matrix A Examples(AT): Rows are written ascolumns or vis a versa.Determinant of a square ⎡3 −1 4⎤ A = ⎢ 0 2 − 3⎥matrix A is given by: ⎢1 1 2⎥ ⎣ ⎦ ⎡a a ⎤ ⎡ 3 0 1⎤ A = ⎢ 11 12 ⎥ T ⎣a21 a22 ⎦ A = ⎢− 1 2 1⎥ ⎢ 4 − 3 2⎥ ⎣ ⎦ det( A) = a11a22 − a21a12
  100. 100. Matrix notation cont…Characteristic polynomial pA(λ) and eigenvaluesλ of a matrix:Note: eigenvalues are most important in appliedmathematicsFor a square matrix A: we define pA(λ) as pA(λ) = ⏐A - λI⏐ = det(A - λI).If we set pA(λ) = 0, solve for the roots, we geteigenvalues of AIf A is n x n, then pA(λ) is polynomial of degreenEigenvector w is a nonzero vector such thatAw= λw, i.e., (A - λI)w=0
  101. 101. Methods of solution of set of equationsDirect methods are those that provide the solution in a finite and pre- determinable number of operations using an algorithm that is often relatively complicated. These methods are useful in linear system of equations.Direct methods of solutionGaussian elimination method 4 x1 − 2 x 2 + x 3 = 15 − 3 x1 − x 2 + 4 x 3 = 8 x1 − x 2 + 3 x 3 = 13Step1: Using Matrix notation we can represent the set of equations as ⎡ 4 −2 1⎤ ⎢ ⎥ ⎡ x1 ⎤ ⎡15 ⎤ ⎢− 3 −1 4 ⎥ ⎢ x2 ⎥ = ⎢ 8 ⎥ ⎢ ⎥ ⎢ x 3 ⎥ ⎢13 ⎥ ⎣ 1 −1 3⎦ ⎣ ⎦ ⎣ ⎦
  102. 102. Methods of solution cont…Step2: The Augmented coefficient matrix with the right-hand sidevector ⎡ 4 −2 1 M 15 ⎤ A Mb = ⎢ − 3 −1 4 M 8⎥ ⎢ 1 ⎣ −1 3 M 13⎥⎦Step3: Transform the augmented matrix into Upper triangular form ⎡ 4 −2 1 15 ⎤ ⎡ 4 −2 1 15 ⎤ ⎢− 3 −1 4 8⎥ , 3R1 + 4 R2 → ⎢ 0 − 10 19 77 ⎥ ⎢ 1 −1 3 13⎥ (−1) R1 + 4 R3 → ⎢ 0 ⎣ −2 11 37 ⎥ ⎦ ⎣ ⎦ ⎡ 4 −2 1 15⎤ ⎢ 0 − 10 19 77⎥ 2 R2 − 10 R3 → ⎢ ⎣ 0 0 − 72 − 216⎥ ⎦Step4: The array in the upper triangular matrix represents theequations which after Back-substitution gives the solution the valuesof x1,x2,x3
  103. 103. Method of solution cont… During the triangularization step, if a zero isencountered on the diagonal, we can not usethat row to eliminate coefficients below thatzero element, in that case we perform theelementary row operations we begin with the previous augmentedmatrix in a large set of equations multiplicationswill give very large and unwieldy numbers tooverflow the computers register memory, wewill therefore eliminate ai1/a11 times the firstequation from the i th equation
  104. 104. Method of solution cont…to guard against the zero in diagonal elements,rearrange the equations so as to put thecoefficient of largest magnitude on the diagonal ateach step. This is called Pivoting. The diagonalelements resulted are called pivot elements.Partial pivoting , which places a coefficient oflarger magnitude on the diagonal by rowinterchanges only, will guarantee a nonzero divisorif there is a solution of the set of equations.The round-off error (chopping as well as rounding)may cause large effects. In certain cases thecoefficients sensitive to round off error, are calledill-conditioned matrix.
  105. 105. Method of solution cont…LU decomposition of A if the coefficient matrix A can be decomposed into lower and upper triangular matrix then we write: A=L*U, usually we get L*U=A’, where A’ is the permutation of the rows of A due to row interchange from pivoting Now we get det(L*U)= det(L)*det(U)=det(U) Then det(A)=det(U)Gauss-Jordan method In this method, the elements above the diagonal are made zero at the same time zeros are created below the diagonal
  106. 106. Method of solution cont…Usually diagonal elements are made unity,at the same time reduction is performed,this transforms the coefficient matrix intoan identity matrix and the column of theright hand side transforms to solutionvectorPivoting is normally employed to preservethe arithmetic accuracy
  107. 107. Method of solution cont…Example:Gauss-Jordan method Consider the augmented matrix as ⎡0 2 0 1 0 ⎤ ⎢2 2 3 2 − 2⎥ ⎢4 − 3 0 1 − 7⎥ ⎢6 1 − 6 − 5 6 ⎥ ⎣ ⎦ Step1: Interchanging rows one and four, dividing the first row by 6, and reducing the first column gives ⎡1 0.16667 − 1 − 0.83335 1 ⎤ ⎢0 1.66670 5 3.66670 − 4 ⎥ ⎢ ⎥ ⎢0 − 3.66670 4 4.33340 − 11⎥ ⎢ ⎥ ⎣ 0 2 0 1 0 ⎦
  108. 108. Method of solution cont…Step2: Interchanging rows 2 and 3, dividing the2nd row by –3.6667, and reducing the secondcolumn gives ⎡1 0 − 1.5000 − 1.20001.4000 ⎤ ⎢0 1 2.9999 2.2000− 2.4000 ⎥ ⎢ ⎥ ⎢0 0 15.0000 12.4000 − 19.8000⎥ ⎢ ⎥ ⎣0 0 − 5.9998 − 3.4000 4.8000 ⎦Step3: We divide the 3rd row by 15.000 andmake the other elements in the third columninto zeros
  109. 109. Method of solution cont… ⎡1 0 0 0.04000 − 0.58000⎤ ⎢0 1 0 − 0.27993 1.55990 ⎥ ⎢ ⎥ ⎢0 0 1 0.82667 − 1.32000 ⎥ ⎢ ⎥ ⎣0 0 0 1.55990 − 3.11970⎦Step4: now divide the 4th row by 1.5599 and create zerosabove the diagonal in the fourth column ⎡1 0 0 0 − 0.49999⎤ ⎢0 1 0 0 1.00010 ⎥ ⎢ ⎥ ⎢0 0 1 0 0.33326 ⎥ ⎢ ⎥ ⎣0 0 0 1 − 1.99990 ⎦
  110. 110. Method of solution cont…Other direct methods of solutionCholesky reduction (Doolittle’s method) Transforms the coefficient matrix,A, into the product of two matrices, L and U, where U has ones on its main diagonal.Then LU=A can be written as⎡ l11 0 0 0 ⎤ ⎡1 u12 u13 u14 ⎤ ⎡ a11 a12 a13 a14 ⎤⎢l21 l22 0 0 ⎥ ⎢0 1 u23 u24 ⎥ ⎢a21 a22 a23 a24 ⎥⎢l ⎥ ⎢0 0 ⎥ = ⎢a a34 ⎥⎢ 31 l32 l33 0 ⎥⎢ 1 u34 ⎥ ⎢ 31 a32 a33 ⎥⎢l41 l32⎣ l43 l44 ⎥ ⎢0 0 ⎦⎣ 0 1 ⎥ ⎢a41 a42 ⎦ ⎣ a43 a44 ⎥ ⎦
  111. 111. Method of solution cont…The general formula for getting theelements of L and U corresponding to thecoefficient matrix for n simultaneousequation can be written as j −1 lij = aij − ∑ lik ukj j ≤ i, i = 1,2,..., n li1 = ai1 k =1 j −1 aij − ∑ lik ukj a1 j a1 j uij = k =1 i ≤ j, j = 2,3,..., n. u1 j = = l11 a11 lii
  112. 112. Method of solution cont…Iterative methods consists of repeated application of an algorithm that is usually relatively simpleIterative method of solution coefficient matrix is sparse matrix ( has many zeros), this method is rapid and preferred over direct methods, applicable to sets of nonlinear equations Reduces computer memory requirements Reduces round-off error in the solutions computed by direct methods
  113. 113. Method of solution cont…Two types of iterative methods: These methods aremainly useful in nonlinear system of equations. Iterative Methods Point iterative method Block iterative method Jacobi method Gauss-Siedel Method Gauss- Successive over-relaxation method over-
  114. 114. Methods of solution cont…Jacobi method Rearrange the set of equations to solve for the variable with the largest coefficientExample: 6 x1 − 2 x2 + x3 = 11, x1 + 2 x2 − 5 x3 = −1, − 2 x1 + 7 x2 + 2 x3 = 5. x1 = 1.8333 + 0.3333x2 − 0.1667 x3 x2 = 0.7143 + 0.2857 x1 − 0.2857 x3 x3 = 0.2000 + 0.2000 x1 + 0.4000 x2 Some initial guess to the values of the variables Get the new set of values of the variables
  115. 115. Methods of solution cont…Jacobi method cont… The new set of values are substituted in the right hand sides of the set of equations to get the next approximation and the process is repeated till the convergence is reached Thus the set of equations can be written as x1n +1) = 1.8333 + 0.3333x2n) − 0.1667 x3n) ( ( ( x2n +1) = 0.7143 + 0.2857 x1n) − 0.2857 x3n) ( ( ( x3n +1) = 0.2000 + 0.2000 x1n) + 0.4000 x2n) ( ( (
  116. 116. Methods of solution cont…Gauss-Siedel method Rearrange the equations such that each diagonal entry is larger in magnitude than the sum of the magnitudes of the other coefficients in that row (diagonally dominant) Make initial guess of all unknowns Then Solve each equation for unknown, the iteration will converge for any starting guess values Repeat the process till the convergence is reached
  117. 117. Methods of solution cont…Gauss-Siedel method cont… For any equation Ax=c we can write ⎡ ⎤ 1 ⎢ n ⎥ xi = ⎢ci − ∑ aij x j ⎥, aii ⎢ i = 1,2,..., n j =1 ⎥ ⎢ ⎣ j ≠i ⎥ ⎦ In this method the latest value of the xi are used in the calculation of further xi
  118. 118. Methods of solution cont…Successive over-relaxation method This method rate of convergence can be improved by providing accelerators For any equation Ax=c we can write ~ k +1 = 1 ⎡c − i −1 a x k +1 − n a x k ⎤, ⎢ i ∑ ij j xi ∑ ij j ⎥ aii ⎢ ⎣ j =1 j =i +1 ⎥ ⎦ xik +1 = xik + w( ~ik +1 − xik ) x i = 1,2,..., n
  119. 119. Methods of solution cont…Successive over-relaxation method cont… Where ~ik +1 determined using standard x Gauss-Siedel algorithm k=iteration level, w=acceleration parameter (>1) Another form k +1 k w i −1 k +1 n xi = (1 − w) xi + (ci − ∑ aij x j − ∑ aij x k ) j aii j =1 j =i +1
  120. 120. Methods of solution cont…Successive over-relaxation method cont..Where 1<w<2: SOR method 0<w<1: weighted average Gauss Siedel method Previous value may be needed in nonlinear problems It is difficult to estimate w
  121. 121. Matrix Inversion Sometimes the problem of solving the linear algebraic system is loosely referred to as matrix inversion Matrix inversion means, given a square matrix [A] with nonzero determinant, finding a second matrix [A-1] having the property that [A-1][A]=[I], [I] is the identity matrix[A]x=cx= [A-1]c[A-1][A]=[I]=[A][A-1]
  122. 122. Pathology of linear systemsAny physical problem modeled by a set of linearequationsRound-off errors give imperfect prediction ofphysical quantities, but assures the existence ofsolutionArbitrary set of equations may not assure uniquesolution, such situation termed as “pathological”Number of related equations less than the numberof unknowns, no unique solution, otherwise uniquesolution
  123. 123. Pathology of linear systems cont… Redundant equations (infinity of values ofunknowns) x + y = 3, 2x + 2y = 6 Inconsistent equations (no solution) x + y = 3, 2x + 2y = 7 Singular matrix (n x n system, no unique solution) Nonsingular matrix, coefficient matrix can betriangularized without having zeros on the diagonalChecking inconsistency, redundancy and singularity ofset of equations: Rank of coefficient matrix (rank less than n givesinconsistent, redundant and singular system)
  124. 124. Solution of nonlinear systems Most of the real world systems are nonlinear and the representative system of algebraic equation are also nonlinear Theoretically many efficient solution methods are available for linear equations, consequently the efforts are put to first transform any nonlinear system into linear system There are various methods available for linearizationMethod of iteration Nonlinear system, example: x 2 + y 2 = 4; e x + y = 1 Assume x=f(x,y), y=g(x,y) Initial guess for both x and y Unknowns on the left hand side are computed iteratively. Most recently computed values are used in evaluating right hand side
  125. 125. Solution of nonlinear systemsSufficient condition for convergence of thisprocedure is ∂f ∂f ∂g ∂g + <1 + <1 ∂x ∂y ∂x ∂yIn an interval about the root that includes the initialguessThis method depends on the arrangement of x andy i.e how x=f(x,y), and y=g(x,y) are writtenDepending on this arrangement, the method mayconverge or diverge
  126. 126. Solution of nonlinear systemsThe method of iteration can be generalized to nnonlinear equations with n unknowns. In this case,the equations are arranged as x1 = f1 ( x1, x2 ,..., xn ) x2 = f 2 ( x1, x2 ,..., xn ) . . . xn = f n ( x1, x2 ,..., xn )A sufficient condition for the iterative process toconverge is n ∂f i ∑ < 1, j =1 ∂x j
  127. 127. Newton technique of linearizationLinear approximation of the function using a tangent to thecurveInitial estimate x0 not too far from the rootMove along the tangent to its intersection with x-axis, andtake that as the next approximationContinue till x-values are sufficiently close or function valueis sufficiently near to zeroNewton’s algorithm is widely used because, at least in thenear neighborhood of a root, it is more rapidly convergentthan any of the other methods.Method is quadratically convergent, error of each stepapproaches a constant K times the square of the error ofthe previous step.
  128. 128. Newton technique of linearizationThe number of decimal places of accuracy doubles at eachiterationProblem with this method is that of finding of f’(x).First derivative f’(x) can be written as f ( x0 ) f ( x0 ) tan θ = f ( x) = , x1 = x0 − . x0 − x1 f ( x0 )We continue the calculation by computing f ( x1 ) x2 = x1 − . f ( x1 )In more general form, f ( xn ) xn +1 = xn − , n = 0,1,2,... f ( xn )
  129. 129. Newton-Raphson methodF(x,y)=0, G(x,y)=0Expand the equation, using Taylor series about xn and yn F ( xn + h, yn + k ) = 0 = F ( xn , yn ) + Fx ( xn , yn )h + Fy ( xn , yn )k G ( x n + h, y n + k ) = 0 = G ( x n , y n ) + G x ( x n , y n ) h + G y ( x n , y n ) k h = xn +1 − xn , k = yn +1 − ynSolving for h and k GFy − FGY FG x − GFx h= ; k= FxG y − G x Fy FxG y − G x FyAssume initial guess for xn,ynCompute functions, derivatives and xn,yn, h and k, Repeat procedure
  130. 130. Newton-Raphson method For n nonlinear equationFi ( x1 + ∆x1, x2 + ∆x2 + ... + xn + ∆xn ) = 0 ∂Fi ∂Fi ∂Fi= Fi ( x1, x2 ,..., xn) + ∆x1 + ∆x2 + ... + ∆xn , ∂x1 ∂x2 ∂xn i = 1,2,3,..., n∂F1 ∂F ∂F ∆x1 + 1 ∆x2 + ... + 1 ∆xn = − F1 ( x1, x2 ,..., xn)∂x1 ∂x2 ∂xn∂F2 ∂F ∂F ∆x1 + 2 ∆x2 + ... + 2 ∆xn = − F2 ( x1, x2 ,..., xn)∂x1 ∂x2 ∂xn . . .∂Fn ∂F ∂F ∆x1 + n ∆x2 + ... + n ∆xn = − Fn ( x1, x2 ,..., xn)∂x1 ∂x2 ∂xn
  131. 131. Picard’s technique of linearizationNonlinear equation is linearized through: Picard’s technique of linearization Newton technique of linearization The Picards method is one of the most commonly used scheme to solve the set of nonlinear differential equations. The Picards method usually provide rapid convergence. A distinct advantage of the Picards scheme is the simplicity and less computational effort per iteration than more sophisticated methods like Newton- Raphson method.
  132. 132. Picard’s technique of linearizationThe general (parabolic type) equation for flow in atwo dimensional, anisotropic non-homogeneousaquifer system is given by the following equation ∂ ⎡ ∂h ⎤ ∂ ⎡ ∂h ⎤ ∂h Tx ⎥ + ⎢ ∂x ⎢Ty ⎥ =S + Q p − Rr − Rs − Q1 ∂x ⎣ ⎦ ∂y ⎣ ∂y ⎦ ∂tUsing the finite difference approximation at atypical interior node, the above ground waterequation reduces toBi, j hi, j −1 + Di, j hi −1, j + Ei, j hi, j + Fi, j hi +1, j + H i, j hi, j +1 = Ri, j
  133. 133. Picard’s technique of linearizationWhere [T yi , j + T yi , j +1 ] Bi, j = − 2∆y 2 [Txi , j + Txi −1, j ] Di, j = − 2∆x 2 [Txi , j + Txi +1, j ] Fi, j = − 2∆x 2 [T yi , j + T yi , j +1 ] H i, j = − 2∆y 2
  134. 134. Picard’s technique of linearization Si , j Ei, j = −( Bi, j + Di, j + Fi, j + H i, j ) + ∆t Si, j h0i , j Ri, j = − (Q ) pi , j + ( R) ri , j + ( R ) si , j ∆tThe Picard’s linearized form of the aboveequation is given by B n +1, mi, j h n +1, m +1i, j −1 + D n +1, mi, j hi −1, j + E n +1, mi, j hi, j + F n +1, mi, j hi +1, j + H n +1, mi, j hi, j +1 = R n +1, mi, j
  135. 135. Solution of Manning’s equation by Newton’s techniqueChannel flow is given by the following equation 1 1/ 2 2 / 3 Q = So AR nThere is no general analytical solution to Manning’s equationfor determining the flow depth, given the flow rate as theflow area A and hydraulic radius R may be complicatedfunctions of the flow depth itself..Newton’s technique can be iteratively used to give thenumerical solutionAssume at iteration j the flow depth yj is selected and theflow rate Qj is computed from above equation, using thearea and hydraulic radius corresponding to yj
  136. 136. Manning’s equation by Newton’s techniqueThis Qj is compared with the actual flow QThe selection of y is done, so that the error f (y j) = Qj − QIs negligibly smallThe gradient of f w.r.t y is df dQ j = dy j dy jQ is a constant
  137. 137. Manning’s equation by Newton’s techniqueAssuming Manning’s n constant ⎛ df ⎞ ⎜ dy ⎟ ⎝ ⎠j 1 1 d ⎜ ⎟ = So / 2 n dy ( ) A j R2 / 3 j 1 1 / 2 ⎛ 2 AR −1 / 3 dR ⎞ 2 / 3 dA ⎟ = So ⎜ +R n ⎜ 3 dy dy ⎟ ⎝ ⎠j 1 1/ 2 2 / 3 ⎛ 2 dR 1 dA ⎞ = So A j R j ⎜ ⎜ 3R dy + A dy ⎟ ⎟ n ⎝ ⎠j ⎛ 2 dR 1 dA ⎞ = Qj⎜ ⎜ 3R dy + A dy ⎟ ⎟ ⎝ ⎠jThe subscript j outside the parenthesis indicates that the contents areevaluated for y=yj
  138. 138. Manning’s equation by Newton’s techniqueNow the Newton’s method is as follows ⎛ df ⎞ 0 − f ( y) j ⎜ ⎟ = ⎜ dy ⎟ ⎝ ⎠ j y j +1 − y j f (y j) y j +1 = y j − (df / dy ) jIterations are continued until there is no significant changein y, and this will happen when the error f(y) is very close tozero
  139. 139. Manning’s equation by Newton’s techniqueNewton’s method equation for solving Manning’s equation: 1− Q/Qj y j +1 = y j − ⎛ 2 dR 1 dA ⎞ ⎜ ⎟ ⎜ 3R dy + A dy ⎟ ⎝ ⎠jFor a rectangular channel A=Bwy, R=Bwy/(Bw+2y) where Bwis the channel width, after the manipulation, the aboveequation can be written as 1− Q/Qj y j +1 = y j − ⎛ 5 Bw + 6 y j ⎞ ⎜ ⎟ ⎜ 3 y j ( Bw + 2 y j ) ⎟ ⎝ ⎠j
  140. 140. Assignments1. Solve the following set of equations by Gauss elimination: x1 + x2 + x3 = 3 2 x1 + 3x2 + x3 = 6 x1 − x2 − x3 = −3Is row interchange necessary for the above equations?2. Solve the system 9 x + 4 y + z = −17, x − 2 y − 6 z = 14, x + 6 y = 4,a. Using the Gauss-Jacobi methodb. Using the Gauss-Siedel method. How much faster is the convergence than in part (a).?
  141. 141. Assignments3. Solve the following system by Newton’s method to obtain the solution near (2.5,0.2,1.6) x2 + y2 + z 2 = 9 xyz = 1 x + y − z2 = 04. Beginning with (0,0,0), use relaxation to solve the system 6 x1 − 3 x2 + x3 = 11 2 x1 + x2 − 8 x3 = −15 x1 − 7 x2 + x3 = 10
  142. 142. Assignments5. Find the roots of the equation to 4 significant digits using Newton-Raphson method x − 4x +1 = 0 36. Solve the following simultaneous nonlinear equations using Newton-Raphson method. Use starting values x0 = 2, y0 = 0. x2 + y2 = 4 xy = 1
  143. 143. Numerical Differentiationand Numerical Integration Module 5 3 lectures
  144. 144. ContentsDerivatives and integralsIntegration formulasTrapezoidal ruleSimpson’s ruleNewton’s Coats formulaGaussian-QuadratureMultiple integrals
  145. 145. DerivativesDerivatives from difference tables We use the divided difference table to estimate values for derivatives. Interpolating polynomial of degree n that fits at points p0,p1,…,pn in terms of divided differences, f ( x) = Pn ( x) + error = f [ x0 ] + f [ x0 , x1 ]( x − x0 ) + f [ x0 , x1, x 2]( x − x0 )( x − x1 ) + ... + f [ x0 , x1,..., xn ] ∏( x − xi ) + error Now we should get a polynomial that approximates the derivative,f’(x), by differentiating it Pn ( x) = f [ x0 , x1 ] + f [ x0 , x1, x2 ][( x − x1) + ( x − x0 )] n −1 ( x − x )( x − x )...( x − x + ... + f [ x0 , x1,...xn ] ∑ 0 1 n −1 ) i =0 ( x − xi )
  146. 146. Derivatives continuedTo get the error term for the above approximation, wehave to differentiate the error term for Pn(x), the error termfor Pn(x): f ( n +1) (ξ ) Error = ( x − x0 )( x − x1)...( x − xn ) . (n + 1)! ξError of the approximation to f’(x), when x=xi, is ⎡ ⎤ ⎢ n ⎥ f ( n +1) (ξ ) Error = ⎢ ∏ ( xi − x j )⎥ , ξ in [x,x0,xn]. ⎢ j =0 ⎥ (n + 1)! ⎢ j ≠i ⎣ ⎥ ⎦Error is not zero even when x is a tabulated value, in factthe error of the derivative is less at some x-values betweenthe points
  147. 147. Derivatives continuedEvenly spaced data When the data are evenly spaced, we can use a table of function differences to construct the interpolating polynomial. ( x − xi ) We use in terms of: s= h s ( s − 1) 2 s ( s − 1)( s − 2) 3 Pn ( s ) = f i + s∆f i + ∆ fi + ∆ fi 2! 3! n −1 ∆n f i + ... + ∏ ( s − j ) + error ; j =0 n! ⎡ n ⎤ f ( n +1) (ξ ) Error = ⎢ ∏ ( s − j )⎥ , ⎢ j =0 ⎥ (n + 1)! ξ in [x,x0,xn]. ⎣ ⎦
  148. 148. Derivatives continuedThe derivative of Pn(s) should approximate f’(x) d d ds Pn ( s ) = Pn ( s ) dx ds dx ⎡ ⎧ ⎫ ⎤ 1⎢ n ⎪ j −1 j −1 ⎪ ⎪ ∆ j fi ⎥ ⎪ = ⎢∆fi + ∑ ⎨ ∑ ∏ ( s − l )⎬ ⎥. h⎢ j = 2 ⎪k = 0 l = 0 ⎪ j! ⎥ ⎢ ⎪ ⎩ l ≠k ⎪ ⎭ ⎥ ⎣ ⎦ ds d ( x − xi ) 1Where = = dx dx h h (−1) n h n ( n +1)When x=xi, s=0 Error = f (ξ ), ξ in [x1,…, xn]. n +1
  149. 149. Derivatives continuedSimpler formulasForward difference approximation For an estimate of f’(xi), we get 1 1 1 1 f ( x) = [∆f i − ∆2 f i + ∆3 fi − ... ± ∆n fi ] x = xi h 2 3 n With one term, linearly interpolating, using a polynomial of degree 1, we have (error is O(h)) 1 1 " f ( xi ) = [∆f i ] − hf (ξ ), h 2 With two terms, using a polynomial of degree 2, we have (error is O(h2)) 1⎡ 1 ⎤ 1 f ( xi ) = ∆f i − ∆2 f i ⎥ + h 2 f (3) (ξ ), h⎢ ⎣ 2 ⎦ 3
  150. 150. Derivatives cont…Central difference approximation Assume we use a second degree polynomial that matches the difference table at xi,xi+1 and xi+2 but evaluate it for f’(xi+1), using s=1, then 1⎡ 1 2 ⎤ f ( xi +1) = ⎢∆fi + ∆ fi ⎥ + O(h 2 ), h⎣ 2 ⎦ Or in terms of the f - values we can write 1⎡ 1 ⎤ f ( xi +1 ) = ( f i +1 − fi ) + ( fi + 2 − 2 fi +1 + fi )⎥ + error h⎢ ⎣ 2 ⎦ 1 fi + 2 − fi = + error , h 2 1 error = − h 2 f (3) (ξ ) = O(h 2 ) 6
  151. 151. Derivatives cont…Higher-Order Derivatives We can develop formulas for derivatives of higher order based on evenly spaced data Difference operator: ∆f ( xi ) = ∆f i = f i +1 − f i Stepping operator : Ef i = f i +1 Or : E n fi = fi + n Relation between E and ∆: E=1+ ∆ Differentiation operator: D( f ) = df / dx, D n ( f ) = d n / dx n ( f ) Let us start with fi + s = E s fi , where s = ( x − xi ) / h d d Dfi + s = f ( xi + s ) = ( E s fi ) dx dx 1 d 1 = ( E f i ) = (ln E ) E s f i s h ds h
  152. 152. Derivatives cont… 1If s=0, we get D= ln(1 + ∆ ) hBy expanding for ln(1+∆), we get f’i and f”i 1⎛ 1 1 1 ⎞ f i = ⎜ ∆fi − ∆2 f i + ∆3 f i − ∆4 f i + ... ⎟, h⎝ 2 3 4 ⎠ 1 ⎛ 2 11 4 5 ⎞ f i" = ⎜ ∆ f i − ∆3 f i + ∆ fi − ∆5 f i + ... ⎟, 2⎝ 12 6 ⎠ hDivided differencesCentral-difference formulaExtrapolation techniquesSecond-derivative computationsRichardson extrapolations
  153. 153. Integration formulas The strategy for developing integration formula is similar to that for numerical differentiation Polynomial is passed through the points defined by the function Then integrate this polynomial approximation to the function. This allows to integrate a function at known valuesNewton-Cotes integration b b ∫ f ( x)dx = ∫ Pn ( xs )dx a aThe polynomial approximation of f(x) leads to an error given as: b⎛ s ⎞ n +1 ( n +1) Error = ∫ ⎜ ⎟h f (ξ )dx ⎜ ⎟ a ⎝ n + 1⎠
  154. 154. Newton-Cotes integration formulasTo develop the Newton-Cotes formulas, change thevariable of integration from x to s. Also dx = hdsFor any f(x), assume a polynomial Pn(xs) of degree 1 i.en=1 x1 x1 ∫ f ( x)dx = ∫ ( f 0 + s∆f 0 )dx x0 x0 s =1 = h ∫ ( f 0 + s∆f 0 )ds s =0 1 2⎤ s 1 = hf 0 s ]1 + h∆f 0 0 ⎥ = h( f 0 + ∆f 0 ) 2⎥ 2 ⎦0 h h = [2 f 0 + ( f1 − f 0 )] = ( f 0 + f1 ) 2 2
  155. 155. Newton-Cotes integration formula cont...Error in the above integration can be given as x1 s ( s − 1) 1 s2 − s Error = ∫ h f (ξ )dx = h3 f " (ξ1 ) ∫ 2 " ds x0 2 0 2 1 ⎛ s 3 s 2 ⎞⎤ 3 " = h f (ξ1 )⎜ − ⎟⎥ = − 1 h3 f " (ξ ), ⎜ 6 1 4 ⎟⎥ 12 ⎝ ⎠⎦ 0Higher degree leads complexity
  156. 156. Newton-Cotes integration formula cont...The basic Newton-Cotes formula for n=1,2,3 i.e forlinear, quadratic and cubic polynomialapproximations respectively are given below: x1 h 1 ∫ f ( x)dx = ( f 0 + f1 ) − h3 f " (ξ ) x0 2 12 x2 h 1 5 iv ∫ f ( x)dx = ( f 0 + 4 f1 + f 2 ) − h f (ξ ), x0 3 90 x3 3h 3 5 iv ∫ f ( x)dx = ( f 0 + 3 f1 + 3 f 2 + f 3 ) − h f (ξ ). x0 8 80
  157. 157. Trapezoidal and Simpson’s ruleTrapezoidal rule-a composite formula Approximating f(x) on (x0,x1) by a straight lineRomberg integration Improve accuracy of trapezoidal ruleSimpson’s rule Newton-Cotes formulas based on quadratic and cubic interpolating polynomials are Simpson’s rules 1 Quadratic- Simpson’s 3 rule 3 Cubic- Simpson’s 8 rule
  158. 158. Trapezoidal and Simpson’s rule cont…Trapezoidal rule-a composite formula The first of the Newton-Cotes formulas, based on approximating f(x) on (x0,x1) by a straight line, is trapezoidal rule xi +1 f ( xi ) + f ( xi +1 ) h ∫ f ( x)dx = (∆x) = ( f i + f i +1 ), xi 2 2 For [a,b] subdivided into n subintervals of size h, b n h h ∫ f ( x)dx = ∑ ( f i + f i +1 ) = ( f1 + f 2 + f 2 + f 3 + ... + f n + f n +1 ); a i =12 2 b h ∫ f ( x)dx = ( f1 + 2 f 2 + 2 f 3 + ... + 2 f n + f n +1 ). a 2
  159. 159. Trapezoidal and Simpson’s rule cont… f(x) x1 = a x2 x3 x4 x5 xn+1 = b x Trapezoidal Rule
  160. 160. Trapezoidal and Simpson’s rule cont…Trapezoidal rule-a composite formula cont… 1 3 " Local error =− h f (ξ1 ), x0 < ξ1 < x1 12 Global error 1 3 " = − h [ f (ξ1 ) + f " (ξ 2 ) + ... + f " (ξ n )], 12 If we assume that f”(x) is continuous on (a,b), there is some value of x in (a,b), say x=ξ, at which the value of the sum in above equation is equal to n.f”(ξ), since nh=b-a, the global error becomes Global error 1 3 " −(b − a ) 2 " = − h nf (ξ ) = h f (ξ ) = O(h 2 ). 12 12 The error is of 2nd order in this case
  161. 161. Romberg IntegrationWe can improve the accuracy of trapezoidal ruleintegral by a technique that is similar toRichardson extrapolation, this technique is knownas Romberg integrationTrapezoidal method has an error of O(h2), we cancombine two estimate of the integral that have h-values in a 2:1 ratio by 1Better estimate=more accurate + (more 2n − 1accurate-less accurate)
  162. 162. Trapezoidal and Simpson’s ruleSimpson’s rule The composite Newton-Cotes formulas based on quadratic and cubic interpolating polynomials are known as Simpson’s rule 1Quadratic- Simpson’s 3 rule The second degree Newton-Cotes formula integrates a quadratic over two intervals of equal width, h h f ( x)dx = [ f0 + 4 f1 + f 2 ]. 3 This formula has a local error of O(h5): 1 5 ( 4) Error = − h f (ξ ) 90
  163. 163. Trapezoidal and Simpson’s ruleQuadratic- Simpson’s 1 3 rule cont… For [a,b] subdivided into n (even) subintervals of size h, h f ( x)dx = [ f (a ) + 4 f1 + 2 f 2 + 4 f 3 + 2 f 4 + ... + 4 f n −1 + f (b)]. 3 With an error of (b − a ) 4 ( 4) Error = − h f (ξ ) 180 We can see that the error is of 4 th order The denominator changes to 180, because we integrate over pairs of panels, meaning that the local rule is applied n/2 times
  164. 164. Trapezoidal and Simpson’s ruleCubic- Simpson’s 3 8 rule The composite rule based on fitting four points with a cubic leads to Simpson’s 3 rule 8 For n=3 from Newton’s Cotes formula we get 3h f ( x)dx = [ f0 + 3 f1 + 3 f 2 + f3 ]. 8 3 5 ( 4) Error = − h f (ξ ) 80 The local order of error is same as 1/3 rd rule, except the coefficient is larger
  165. 165. Trapezoidal and Simpson’s ruleCubic- Simpson’s 3 8 rule cont… To get the composite rule for [a,b] subdivided into n (n divisible by 3) subintervals of size h, 3h f ( x)dx = [ f (a ) + 3 f1 + 3 f 2 + 2 f 3 + 3 f 4 + 3 f 5 + 2 f 6 8 + ... + 2 f n −3 + 3 f n − 2 + 3 f n −1 + f (b)] With an error of (b − a ) 4 ( 4) Error = − h f (ξ ) 80
  166. 166. Extension of Simpson’s rule to Unequally spaced points When f(x) is a constant, a straight line, or a second degree polynomial ∆x2 ∫ f ( x)dx = w1 f1 + w2 f 2 + w3 f 3 − ∆x1 The functions f(x)=1, f(x)=x, f(x)=x2, are used to establish w1, w2, w3
  167. 167. Gaussian quadrature Other formulas based on predetermined evenly spaced x values Now unknowns: 3 x-values and 3 weights; total 6 unknowns For this a polynomial of degree 5 is needed to interpolate These formulas are Gaussian-quadrature formulas Applied when f(x) is explicitly known Example: a simple case of a two term formula containing four unknown parameters 1 f (t ) = af (t ) +bf (t ). ∫ −1 1 2 (b − a )t + b + a ⎛b−a⎞ x= dx = ⎜ ⎟dt If we let 2 so that ⎝ 2 ⎠ thenb 1 b − a ⎛ (b − a )t + b + a ⎞∫a f ( x)dx = ∫1 f ⎜ 2 − ⎝ 2 ⎟ ⎠
  168. 168. Multiple integralsWeighted sum of certain functional values with one variableheld constantAdd the weighted sum of these sumsIf function known at the nodes of a rectangular grid, weuse these values b ⎛d ⎞ d ⎛b ⎞ ∫∫ A f ( x , y ) d A = ∫ ⎜ ∫ f ( x , y ) dy ⎟dx = ∫ ⎜ ∫ f ( x , y ) dx ⎟dy ⎜ a ⎝ c ⎟ ⎠ ⎜ c ⎝ a ⎟ ⎠Newton-Cotes formulas are a convenient m n ∫ f ( x, y )dxdy = ∑ v j ∑ wi f ij j =1 i =1 ∆y ∆x = 3 2
  169. 169. Multiple integralsDouble integration by numerical meansreduces to a double summation of weightedfunction values 1 n ∫ f ( x)dx = ∑ ai f ( xi ). −1 i =1 1 1 1 n n n ∫ ∫ ∫ f ( x, y, z )dxdydz = ∑ ∑ ∑ ai a j ak f ( xi , yi , z k ). −1 −1 −1 i =1 j =1 k =1
  170. 170. Assignments1. Use the Taylor series method to derive expressions for f‘(x) and f ‘‘(x) and their error terms using f-values that precede f0. ( These are called backward-difference formulas.)2. Evaluate the following integrals by(i) Gauss method with 6 points(ii) Trapezoidal rule with 20 points(iii) Simpson’s rule with 10 pointsCompare the results. Is it preferable to integrate backwards or forwards? 5 1 ∫ ∫ x 3e x −1dx 2(a) e − x dx (b) 0 0
  171. 171. Assignments3. Compute the integral of f(x)=sin(x)/x between x=0 and x=1 using Simpson’s 1/3 rule with h=0.5 and then with h=0.25. from these two results, extrapolate to get a better result. What is the order of the error after the extrapolation? Compare your answer with the true answer.4. Integrate the following over the region defined by the portion of a unit circle that lies in the first quadrant. Integrate first with respect to x holding y constant, using h=0.25. subdivide the vertical lines into four panels. ∫∫ cos( x) sin(2 y)dxdya. Use the trapezoidal ruleb. Use Simpson’s 1/3 rule

×