Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Frictional_Press_Drop_Calc.f90 12 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. SUBROUTINE FricPressDrop(iloc)
  2. !! Record of revisions
  3. !! Date Programmer Discription of change
  4. !! ------ ------------ -----------------------
  5. !! 1396/07/23 Sheikh Original code
  6. !!
  7. USE FricPressDropVarsModule
  8. USE CMudPropertiesVariables
  9. USE Fluid_Flow_Startup_Vars
  10. USE CError
  11. IMPLICIT NONE
  12. INTEGER :: iloc
  13. REAL :: TauZero
  14. TauZero = 12.0
  15. !ActiveRheologyModel = Herschel_Bulkley_RheologyModel
  16. ! 0 = Power Law , 1 = Bingham Plastic , 2 = Newtonian
  17. !TotFricPressLoss = 0.0
  18. FlowEl(iloc)%alpha = 1 ! assume that all elements have annulus geometry
  19. FlowEl(iloc)%dPdLfric = 0.0
  20. FlowEl(iloc)%f = 0.0
  21. FlowEl(iloc)%FlowRate = ABS(FlowEl(iloc)%FlowRate)
  22. IF ((FlowEl(iloc)%FlowRate >= PressFlowrateTolerance) &
  23. .AND. (FlowEl(iloc)%MaterialType /= 1) & ! not gas kick
  24. .AND. (ABS(FlowEl(iloc)%Length) >= PressLengthTolerance) &
  25. .AND. (FlowEl(iloc)%MaterialType /= 4)) THEN ! not air
  26. IF (FlowEl(iloc)%Id==0) THEN
  27. FlowEl(iloc)%alpha = 0
  28. END IF
  29. FlowEl(iloc)%muPlastic = FlowEl(iloc)%Theta600 - FlowEl(iloc)%Theta300 ! cp
  30. FlowEl(iloc)%YieldP = 2.0 * FlowEl(iloc)%Theta300 - FlowEl(iloc)%Theta600 ! lbf/100ft**2
  31. FlowEl(iloc)%nIndex = 3.32 * log10(FlowEl(iloc)%Theta600 / FlowEl(iloc)%Theta300)
  32. FlowEl(iloc)%kIndex = 510.0 * FlowEl(iloc)%Theta300 / (511.0**FlowEl(iloc)%nIndex) ! rabete fv2
  33. IF (MudProperties%ActiveRheologyModel == Herschel_Bulkley_RheologyModel .AND. FlowEl(iloc)%alpha == 0) THEN
  34. FlowEl(iloc)%kIndex = 1.066 * FlowEl(iloc)%Theta300 / (511.0**FlowEl(iloc)%nIndex)
  35. ELSE IF (MudProperties%ActiveRheologyModel == Herschel_Bulkley_RheologyModel .AND. FlowEl(iloc)%alpha == 1) THEN
  36. FlowEl(iloc)%nIndex = 3.32 * log10((FlowEl(iloc)%Theta600 - TauZero) / (FlowEl(iloc)%Theta300 - TauZero))
  37. FlowEl(iloc)%kIndex = 1.066 * (FlowEl(iloc)%Theta300 - TauZero) / (511.0**FlowEl(iloc)%nIndex)
  38. END IF
  39. ! Calculating velocity
  40. FlowEl(iloc)%vel = 0.408 * FlowEl(iloc)%FlowRate / (FlowEl(iloc)%Od**2 - FlowEl(iloc)%Id**2) ! velocity in ft/s
  41. !FlowEl(iloc)%vel = 24.51 * FlowEl(iloc)%FlowRate / (FlowEl(iloc)%Od**2 - FlowEl(iloc)%Id**2) ! velocity in ft/min
  42. !IF (FlowModel == Bingham_RheologyModel) THEN ! Bingham Plastic
  43. ! FlowEl(iloc)%Gf = (2. + FlowEl(iloc)%alpha) / 2.
  44. !ELSE IF (FlowModel == PowerLow_RheologyModel) THEN
  45. ! FlowEl(iloc)%Gf = ((3. - FlowEl(iloc)%alpha) * FlowEl(iloc)%nIndex + 1.) / FlowEl(iloc)%nIndex / (4. - FlowEl(iloc)%alpha) * (2. + FlowEl(iloc)%alpha) / 2.
  46. !END IF
  47. !FlowEl(iloc)%gammaW = 1.6 * FlowEl(iloc)%Gf * FlowEl(iloc)%vel / FlowEl(iloc)%Dhyd
  48. !IF (FlowModel == Bingham_RheologyModel) THEN ! Bingham Plastic
  49. ! FlowEl(iloc)%tauW = 1.067 * ((4. - FlowEl(iloc)%alpha) / (3. - FlowEl(iloc)%alpha) * FlowEl(iloc)%YieldP + FlowEl(iloc)%muPlastic * FlowEl(iloc)%gammaW)
  50. ! !FlowEl(iloc)%tauW = 1.067*(FlowEl(iloc)%YieldP+FlowEl(iloc)%muPlastic*FlowEl(iloc)%gammaW)
  51. !ELSE IF (FlowModel == PowerLow_RheologyModel) THEN ! Power law
  52. ! FlowEl(iloc)%tauW = 1.067 * FlowEl(iloc)%kIndex * FlowEl(iloc)%gammaW**FlowEl(iloc)%nIndex
  53. !END IF
  54. ! Calculating effective or apparent viscosity
  55. IF (MudProperties%ActiveRheologyModel == Bingham_RheologyModel) THEN ! Bingham Plastic
  56. FlowEl(iloc)%mueff = FlowEl(iloc)%muPlastic + 5. * FlowEl(iloc)%YieldP * FlowEl(iloc)%Dhyd / FlowEl(iloc)%vel
  57. !write(*,*) 'pointer1' , FlowEl(iloc)%muPlastic , FlowEl(iloc)%YieldP , FlowEl(iloc)%Dhyd , FlowEl(iloc)%vel
  58. ELSE IF (MudProperties%ActiveRheologyModel == PowerLaw_RheologyModel .OR. MudProperties%ActiveRheologyModel == Herschel_Bulkley_RheologyModel) THEN ! Power Law
  59. FlowEl(iloc)%Gf = ((3. - FlowEl(iloc)%alpha) * FlowEl(iloc)%nIndex + 1.0) / FlowEl(iloc)%nIndex / (4.0 - FlowEl(iloc)%alpha) * (2.0 + FlowEl(iloc)%alpha) / 2.0
  60. FlowEl(iloc)%mueff = (FlowEl(iloc)%kIndex) / (1. + FlowEl(iloc)%alpha / 2.) * ((96. * FlowEl(iloc)%vel / FlowEl(iloc)%Dhyd)**(FlowEl(iloc)%nIndex - 1)) * FlowEl(iloc)%Gf**FlowEl(iloc)%nIndex
  61. !write(*,*) 'pointer2' , FlowEl(iloc)%kIndex ,FlowEl(iloc)%alpha , FlowEl(iloc)%vel ,FlowEl(iloc)%Dhyd,FlowEl(iloc)%nIndex ,FlowEl(iloc)%Gf ,FlowEl(iloc)%nIndex
  62. END IF
  63. FlowEl(iloc)%gammaW = 96.0 * FlowEl(iloc)%Gf * FlowEl(iloc)%vel / FlowEl(iloc)%Dhyd
  64. FlowEl(iloc)%tauW = ((4.0 - FlowEl(iloc)%alpha) / (3.0 - FlowEl(iloc)%alpha))**FlowEl(iloc)%nIndex * TauZero + FlowEl(iloc)%kIndex * FlowEl(iloc)%gammaW**FlowEl(iloc)%nIndex
  65. ! Calculating Reynolds number
  66. IF (FlowEl(iloc)%Od == FlowEl(iloc)%Dhyd) THEN
  67. FlowEl(iloc)%GenRe = 928. * FlowEl(iloc)%density * FlowEl(iloc)%vel * FlowEl(iloc)%Dhyd / FlowEl(iloc)%mueff
  68. ELSE
  69. FlowEl(iloc)%GenRe = 757. * FlowEl(iloc)%density * FlowEl(iloc)%vel * FlowEl(iloc)%Dhyd / FlowEl(iloc)%mueff
  70. END IF
  71. !FlowEl(iloc)%GenRe = 2997 * FlowEl(iloc)%density * FlowEl(iloc)%vel**2 / 19.36 / FlowEl(iloc)%tauW
  72. ! Calculating friction factor
  73. IF (MudProperties%ActiveRheologyModel == Bingham_RheologyModel) THEN ! Bingham Plastic
  74. IF (FlowEl(iloc)%GenRe <= 2000.0) THEN ! laminar regime
  75. FlowEl(iloc)%f = 16.0 / FlowEl(iloc)%GenRe
  76. ELSE IF (FlowEl(iloc)%GenRe >= 4000.0) THEN ! turbulent regime
  77. FlowEl(iloc)%a = 0.0791
  78. FlowEl(iloc)%b = 0.25
  79. FlowEl(iloc)%f = FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b
  80. ELSE !! transition from laminar to turbulent regime
  81. FlowEl(iloc)%a = 0.0791
  82. FlowEl(iloc)%b = 0.25
  83. FlowEl(iloc)%f = (4000.0 - FlowEl(iloc)%GenRe) / 2000.0 * 16. / FlowEl(iloc)%GenRe &
  84. + (FlowEl(iloc)%GenRe - 2000.0) / 2000.0 * FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b
  85. END IF
  86. ELSE IF (MudProperties%ActiveRheologyModel == PowerLaw_RheologyModel) THEN ! Power law
  87. FlowEl(iloc)%ReCritLam = 3470. - 1370. * FlowEl(iloc)%nIndex
  88. FlowEl(iloc)%ReCritTurb = 4270. - 1370. * FlowEl(iloc)%nIndex
  89. IF (FlowEl(iloc)%GenRe <= FlowEl(iloc)%ReCritLam) THEN ! laminar regime
  90. FlowEl(iloc)%f = 16.0 / FlowEl(iloc)%GenRe / (1 - 0.184 * FlowEl(iloc)%alpha)
  91. ELSE IF (FlowEl(iloc)%GenRe >= FlowEl(iloc)%ReCritTurb) THEN ! turbulent regime
  92. FlowEl(iloc)%a = (log10(FlowEl(iloc)%nIndex) + 3.93) / 50.
  93. FlowEl(iloc)%b = (1.75 - log10(FlowEl(iloc)%nIndex)) / 7.
  94. FlowEl(iloc)%f = FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b
  95. ELSE
  96. FlowEl(iloc)%a = (log10(FlowEl(iloc)%nIndex) + 3.93) / 50.
  97. FlowEl(iloc)%b = (1.75 - log10(FlowEl(iloc)%nIndex)) / 7.
  98. FlowEl(iloc)%f = (FlowEl(iloc)%ReCritTurb - FlowEl(iloc)%GenRe) / 800.0 * 16. / FlowEl(iloc)%GenRe &
  99. + (FlowEl(iloc)%GenRe - FlowEl(iloc)%ReCritLam) / 800.0 * FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b
  100. END IF
  101. END IF
  102. !WRITE (*,*) 'fric press drop', iloc
  103. !WRITE (*,*) 'Length', ABS(REAL(FlowEl(iloc)%Length))
  104. !WRITE (*,*) 'FlowRate', FlowEl(iloc)%FlowRate
  105. !WRITE (*,*) 'Theta600 , Theta300', FlowEl(iloc)%Theta600 , FlowEl(iloc)%Theta300
  106. !WRITE (*,*) 'Dhyd', FlowEl(iloc)%Dhyd
  107. !WRITE (*,*) 'GenRe', FlowEl(iloc)%GenRe
  108. !WRITE (*,*) 'f', FlowEl(iloc)%f
  109. END IF
  110. ! Frictional pressure loss gradient calculation
  111. ! FlowEl(iloc)%dPdLfric = 1.076 * FlowEl(iloc)%f * FlowEl(iloc)%vel**2 * FlowEl(iloc)%density / 10**5 / FlowEl(iloc)%Dhyd
  112. FlowEl(iloc)%dPdLfric = FlowEl(iloc)%f * (FlowEl(iloc)%vel)**2 * FlowEl(iloc)%density / 25.81 / FlowEl(iloc)%Dhyd
  113. FlowEl(iloc)%FricPressLoss = FlowEl(iloc)%dPdLfric * ABS(REAL(FlowEl(iloc)%Length))
  114. IF (FlowEl(iloc)%FrictionDirection == -1) THEN
  115. FlowEl(iloc)%FlowRate = - FlowEl(iloc)%FlowRate
  116. FlowEl(iloc)%dPdLfric = - FlowEl(iloc)%dPdLfric
  117. FlowEl(iloc)%FricPressLoss = - FlowEl(iloc)%FricPressLoss
  118. END IF
  119. !END DO
  120. END SUBROUTINE FricPressDrop
  121. SUBROUTINE PartialDerivativeFricToFlowRate(iloc)
  122. USE FricPressDropVarsModule
  123. USE CMudPropertiesVariables
  124. USE Fluid_Flow_Startup_Vars
  125. use KickVARIABLESModule
  126. USE CError
  127. IMPLICIT NONE
  128. INTEGER :: iloc
  129. FlowEl(iloc)%FricToQPartialDiff = 0.0
  130. !FlowEl(iloc)%FlowRate = ABS(FlowEl(iloc)%FlowRate)
  131. IF ((ABS(FlowEl(iloc)%FlowRate) >= PressFlowrateTolerance) &
  132. .AND. (FlowEl(iloc)%MaterialType /= 1) & ! not gas kick
  133. .AND. (ABS(FlowEl(iloc)%Length) >= PressLengthTolerance) &
  134. .AND. (FlowEl(iloc)%MaterialType /= 4)) THEN ! not air
  135. IF (MudProperties%ActiveRheologyModel == PowerLaw_RheologyModel) THEN ! Power law
  136. !IF (FlowEl(iloc)%Flowrate == 0.0) THEN
  137. ! FlowEl(iloc)%Flowrate = 10.0
  138. ! CALL FricPressDrop(iloc)
  139. !END IF
  140. IF (FlowEl(iloc)%GenRe <= FlowEl(iloc)%ReCritLam) THEN ! laminar flow
  141. FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate * FlowEl(iloc)%nIndex
  142. ELSE IF (FlowEl(iloc)%GenRe >= FlowEl(iloc)%ReCritTurb) THEN ! turbulent flow
  143. FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate &
  144. * (2. - FlowEl(iloc)%b * (2. - FlowEl(iloc)%nIndex))
  145. ELSE ! transition from laminar to turbulent
  146. FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate &
  147. * (2. + (2. - FlowEl(iloc)%nIndex) &
  148. * ((FlowEl(iloc)%a * FlowEl(iloc)%GenRe**(1. - FlowEl(iloc)%b) - 16.) / 800. / FlowEl(iloc)%f - 1.))
  149. END IF
  150. ELSE IF (MudProperties%ActiveRheologyModel == Bingham_RheologyModel) THEN ! Bingham Plastic
  151. IF (FlowEl(iloc)%GenRe <= 2000.0 .OR. FlowEl(iloc)%f == 0.0) THEN ! laminar flow if f = 0.0, we have no flow in first time flowing
  152. FlowEl(iloc)%FricToQPartialDiff = (16. * FlowEl(iloc)%muPlastic * REAL(FlowEl(iloc)%Length) * 2.224 * (10.)**(-3)) &
  153. / (25.81 * 928. * (1 - 0.184 * FlowEl(iloc)%alpha) * FlowEl(iloc)%Dhyd**2 * FlowEl(iloc)%Area)
  154. ELSE IF (FlowEl(iloc)%GenRe >= 4000.0) THEN ! turbulent flow
  155. FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate &
  156. * (2. - FlowEl(iloc)%b * (2. - FlowEl(iloc)%muPlastic / FlowEl(iloc)%mueff))
  157. ELSE ! transition from laminar to turbulent
  158. FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate &
  159. * (2. + (2. - FlowEl(iloc)%muPlastic / FlowEl(iloc)%mueff) &
  160. * ((FlowEl(iloc)%a * FlowEl(iloc)%GenRe**(1. - FlowEl(iloc)%b) - 16.) / 2000. / FlowEl(iloc)%f - 1.))
  161. END IF
  162. END IF
  163. END IF
  164. IF (FlowEl(iloc)%FricToQPartialDiff < 0.0) THEN
  165. !WRITE (*,*) ' iloc, Re, FricPressLoss, FricToQPartialDiff' , iloc, FlowEl(iloc)%GenRe, FlowEl(iloc)%FricPressLoss, FlowEl(iloc)%FricToQPartialDiff
  166. !CALL ERRORSTOP('Error in Calculating FricToQPartialDiff')
  167. END IF
  168. END SUBROUTINE PartialDerivativeFricToFlowRate