chrisjc
New member
- Dec 1, 2012
- 13
Hi
Im having problems with a numerical solution to these equations, and i think it relates more to the process of iterative solutions rather than to the fluid theory. For some initial values a convergent solution is found, but often the Darcy frictional headloss equation returns a value greater than the initial head meaning that the next iteration results in an error since the solution to velocity in terms of head is complex.
Given: head, diameter of the pipe, length of pipe, and roughness i employ the following procedure in an attempt to derive frictional headloss and velocity:
' HEAD LOSS
Function HeadLoss(h, d, l, k) As Double
Dim hf, ff, v, vg
vg = 0.001 ' Inital guess for velocity
Do
re = Reynolds(vg, d) ' Calculate Reynolds number
ff = ff_haaland(k, d, re) ' Calculate friction factor
hf = hf_darcy(ff, l, vg, d) ' Calculate frictional head loss
v = Sqr(2 * 9.81 * (h - hf)) ' Calculate velocity *** ERROR if hf >= h ***
If Abs(v - vg) > 0.00001 Then ' If calculated v is different from vg recalculate with v
vg = v
Else
HeadLoss = hf
Exit Do
End If
Loop
End Function
I guess incrementing the velocity guess by a small amount on each iteration until the calculated velocity equals the guessed velocity but i thought the above method should solve it in less iterations. I'm not sure if i'm going about this in the right way any ideas?
Thanks
Chris
Im having problems with a numerical solution to these equations, and i think it relates more to the process of iterative solutions rather than to the fluid theory. For some initial values a convergent solution is found, but often the Darcy frictional headloss equation returns a value greater than the initial head meaning that the next iteration results in an error since the solution to velocity in terms of head is complex.
Given: head, diameter of the pipe, length of pipe, and roughness i employ the following procedure in an attempt to derive frictional headloss and velocity:
' HEAD LOSS
Function HeadLoss(h, d, l, k) As Double
Dim hf, ff, v, vg
vg = 0.001 ' Inital guess for velocity
Do
re = Reynolds(vg, d) ' Calculate Reynolds number
ff = ff_haaland(k, d, re) ' Calculate friction factor
hf = hf_darcy(ff, l, vg, d) ' Calculate frictional head loss
v = Sqr(2 * 9.81 * (h - hf)) ' Calculate velocity *** ERROR if hf >= h ***
If Abs(v - vg) > 0.00001 Then ' If calculated v is different from vg recalculate with v
vg = v
Else
HeadLoss = hf
Exit Do
End If
Loop
End Function
I guess incrementing the velocity guess by a small amount on each iteration until the calculated velocity equals the guessed velocity but i thought the above method should solve it in less iterations. I'm not sure if i'm going about this in the right way any ideas?
Thanks
Chris