Edit or run this notebook

HW 4 for CS 4220

You may (and probably should) talk about problems with the each other, with the TAs, and with me, providing attribution for any good ideas you might get. Your final write-up should be your own.

210 μs
278 μs
2.8 s

The Darcy friction coefficient f for turbulent flow in a pipe is defined in terms of the Colebrook-White equation for large Reynolds number Re (greater than 4000 or so):

1f=2log10(ϵ/Dh3.7+2.51Ref)

Here ϵ is the height of the surface roughness and Dh is the diameter of the pipe; we refer to ϵ/Dh as the roughness. If we let u=1/f, we can rewrite this as a fixed point equation

u=αlog(β+γu)

where α=2/log(10), β=(ϵ/Dh)/3.7, and γ=2.51/Re. Alternately, we can write this as the problem of finding a zero of

g(u)=u+αlog(β+γu).

In this problem, we consider the computation of u>0 (and hence f) for different values of the Reynolds number. We note that α, β, and γ, are all positive numbers that are less than one in this problem, and u=1/f must also be positive.

362 μs
darcy_params (generic function with 1 method)
460 μs
darcy_resid (generic function with 1 method)
505 μs

As a test case, we consider flow through a 10 cm pipe with roughness height of 0.1 mm (so the roughness factor is 103), and Reynolds numbers of 104, 105, and 106.

152 μs
  1. Note that 0<log(1+z)<z for z>0. Using properties of logs, show that for u>0, g(u)=u+αlog(β+γu) satisfies

u+αlog(β)g(u)(1+αγ/β)u+αlog(β)

1.3 ms

Answer:

850 μs
  1. Using the previous result, give an interval where g changes sign (so g(u)=0 is guaranteed to have a solution in this interval). Verify the sign change for our test setting with Reynolds number of 104.

185 μs

Answer:

144 μs
darcy_bounds (generic function with 1 method)
291 μs
test_darcy1 (generic function with 1 method)
14.1 ms

FAIL: Returned interval [1.0, 1.0] does not bracket (values -5.565874087171682 and -5.565874087171682)

30.3 μs
  1. Using the lower bound in the previous step as a starting guess, run the fixed point iteration uk+1=αlog(β+γuk) and plot |g(uk)| vs k on a semilog scale. Run the calculation for 100 steps for Reynolds numbers 104, 105, and 106. What do you observe about the convergence?

201 μs

Answer:

157 μs
  1. Subtract the fixed point equation from the fixed point iteration equation and use that log(1+z)=z+O(z2) to get an error iteration of the form

ek+1=αγβ+γuek+O(ek2).

169 μs

Answer:

997 μs
  1. Numerically verify that the rate of convergence from part 4 agrees with the rates of convergence seen in the part 3. You will want to use that if ek+1ρek, then ρ can be estimated from three successive iterates uk+1, uk, and uk1.

175 μs
ρ_darcy_fp (generic function with 1 method)
857 μs
ρ_darcy_est (generic function with 1 method)
839 μs
compare_ρ_darcy (generic function with 1 method)
1.2 ms

ρ = -0.13093207192511372; relative difference in estimate: 8.637548121685171

12.7 μs

ρ = -0.049681483020707885; relative difference in estimate: 21.128223619717375

11.9 μs

ρ = -0.007568843300858971; relative difference in estimate: 133.1205843813033

10.6 μs
  1. Write a Newton iteration for finding a zero of g (with the lower bound from part 2 as an initial guess). Plot the residuals on a semilog scale for Reynolds number 104 to illustrate quadratic convergence.

158 μs

Answer: Fill in Newton iteration is given below, then add the requested plot.

135 μs
darcy (generic function with 1 method)
1.6 ms
  1. Not a problem, but we can use the previous codes to show on a log-log plot the behavior of u and its upper and lower bounds for Reynolds numbers between 104 and 108.

166 μs
plot_bounds (generic function with 1 method)
2.2 ms
1.2 s
Loading...
ii