Simulation Core
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

232 linhas
12 KiB

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