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.

TD_DrillStemConfiguration.f90 11 KiB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. subroutine TD_DrillStemConfiguration
  2. Use CStringConfigurationVariables
  3. Use CNearFloorConnection
  4. Use CDataDisplayConsoleVariables
  5. Use CDrillWatchVariables
  6. Use COperationConditionEnumVariables
  7. Use CKellyConnectionEnumVariables
  8. Use TD_DrillStemComponents
  9. Use TD_WellElements
  10. Use TD_WellGeometry
  11. Use TD_StringConnectionData
  12. Use sROP_Variables
  13. implicit none
  14. Integer :: i , j , k , kk , TD_Status
  15. !====================================================
  16. ! Drill Stem Components Data Modification
  17. !====================================================
  18. !=====> Drill Stem Total Length&Weight Calculation
  19. TD_DrillStemTotalLength = 0.0d0
  20. TD_DrillStemTotalLengthIni = 0.0d0
  21. TD_DrillStemTotalWeight = 0.0d0
  22. Do i= 1,TD_DrillStemComponentsNumbs
  23. TD_DrillStemTotalLength = TD_DrillStemTotalLength+TD_DrillStems(i)%Length
  24. TD_DrillStemTotalLengthIni = TD_DrillStemTotalLengthIni+TD_DrillStems(i)%LengthIni
  25. TD_DrillStemTotalWeight = TD_DrillStemTotalWeight+TD_DrillStems(i)%Weight
  26. End Do
  27. !=====> Top&Down Depth Calculation Of Initial Drill Stem Components (Graphic)
  28. TD_DrillStems(1)%DownDepth = TD_DrillStemTotalLength-TD_ConnectionHeight
  29. TD_DrillStemBottom = TD_DrillStems(1)%DownDepth
  30. if ( TD_DrillStems(1)%DownDepth>=TD_WellTotalLength ) then
  31. !if ( TD_HookHeight>=TD_HookHeightOld .and. Rate_of_Penetration==0. ) then
  32. ! TD_GRigidConnectionHeight = TD_GRigidConnectionHeight
  33. !else
  34. TD_GRigidConnectionHeight = TD_GRigidConnectionHeight-(TD_WellTotalLength-TD_DrillStems(1)%DownDepthIniG)
  35. TD_DrillStems(1)%DownDepthIniG = TD_WellTotalLength !???????????
  36. ! !TD_GRigidConnectionHeight = TD_GRigidConnectionHeight
  37. !end if
  38. else
  39. TD_GRigidConnectionHeight = TD_ConnectionHeight
  40. TD_DrillStems(1)%DownDepthIniG = TD_DrillStemTotalLengthIni-TD_GRigidConnectionHeight
  41. end if
  42. !TD_DrillStems(1)%DownDepthIniG = TD_DrillStemTotalLengthIni-TD_GRigidConnectionHeight
  43. !if ( TD_DrillStems(1)%DownDepthIniG>TD_WellTotalLength ) then
  44. ! TD_GRigidConnectionHeight = TD_GRigidConnectionHeight+(TD_DrillStems(1)%DownDepthIniG-TD_WellTotalLength)
  45. ! TD_DrillStems(1)%DownDepthIniG = TD_WellTotalLength !???????????
  46. !end if
  47. TD_DrillStems(1)%TopDepthIniG = TD_DrillStems(1)%DownDepthIniG-TD_DrillStems(1)%LengthIni
  48. Do i = 2,TD_DrillStemComponentsNumbs
  49. TD_DrillStems(i)%TopDepthIniG = TD_DrillStems(i-1)%TopDepthIniG-TD_DrillStems(i)%LengthIni
  50. TD_DrillStems(i)%DownDepthIniG = TD_DrillStems(i-1)%DownDepthIniG-TD_DrillStems(i-1)%LengthIni
  51. End Do
  52. !=====> Top&Down Depth Calculation Of Initial Drill Stem Components (for fluid module)
  53. if ( TD_DrillStems(1)%DownDepthIniG>=(TD_WellTotalLength-.1d0) ) then
  54. TD_RigidConnectionHeight = TD_GRigidConnectionHeight+(.1d0-(TD_WellTotalLength-TD_DrillStems(1)%DownDepthIniG))
  55. else
  56. TD_RigidConnectionHeight = TD_GRigidConnectionHeight
  57. end if
  58. TD_DrillStems(1)%DownDepthIni = TD_DrillStemTotalLengthIni-TD_RigidConnectionHeight
  59. TD_DrillStems(1)%TopDepthIni = TD_DrillStems(1)%DownDepthIni-TD_DrillStems(1)%LengthIni
  60. Do i = 2,TD_DrillStemComponentsNumbs
  61. TD_DrillStems(i)%TopDepthIni = TD_DrillStems(i-1)%TopDepthIni-TD_DrillStems(i)%LengthIni
  62. TD_DrillStems(i)%DownDepthIni = TD_DrillStems(i-1)%DownDepthIni-TD_DrillStems(i-1)%LengthIni
  63. End Do
  64. !=====> Top&Down Depth Calculation Of Drill Stem Components
  65. TD_DrillStems(1)%TopDepth = TD_DrillStemTotalLength-TD_DrillStems(1)%Length-TD_GRigidConnectionHeight
  66. TD_DrillStems(1)%DownDepth = TD_DrillStemTotalLength-TD_GRigidConnectionHeight
  67. Do i = 2,TD_DrillStemComponentsNumbs
  68. TD_DrillStems(i)%TopDepth = TD_DrillStems(i-1)%TopDepth-TD_DrillStems(i)%Length
  69. TD_DrillStems(i)%DownDepth = TD_DrillStems(i-1)%DownDepth-TD_DrillStems(i-1)%Length
  70. End Do
  71. !TD_DrillStemBottom = TD_DrillStems(1)%DownDepth
  72. !=====> Hole Type & Inclination Determination Of Drill Stem Components
  73. Do i = 1,TD_DrillStemComponentsNumbs
  74. if (TD_DrillStems(i)%TopDepth .ge. 0.d0) then
  75. Do j = 1,TD_WellIntervalsCount
  76. if (TD_DrillStems(i)%TopDepth>TD_WellGeo(j)%TopDepth .and. TD_DrillStems(i)%TopDepth<TD_WellGeo(j)%DownDepth) then
  77. TD_DrillStems(i)%HoleType = TD_WellGeo(j)%HoleType
  78. if (TD_DrillStems(i)%HoleType == 1) then
  79. TD_DrillStems(i)%StartAngle = TD_WellGeo(j)%StartAngle+(((TD_DrillStems(i)%TopDepth-TD_WellGeo(j)%TopDepth)/TD_WellGeo(j)%RCurvature)) ![rad]
  80. TD_DrillStems(i)%EndAngle = TD_WellGeo(j)%StartAngle+(((TD_DrillStems(i)%DownDepth-TD_WellGeo(j)%TopDepth)/TD_WellGeo(j)%RCurvature))
  81. TD_DrillStems(i)%RCurvature = TD_WellGeo(j)%RCurvature
  82. else if (TD_DrillStems(i)%HoleType == 2) then
  83. TD_DrillStems(i)%StartAngle = TD_WellGeo(j)%StartAngle-(((TD_DrillStems(i)%TopDepth-TD_WellGeo(j)%TopDepth)/TD_WellGeo(j)%RCurvature))
  84. TD_DrillStems(i)%EndAngle = TD_WellGeo(j)%StartAngle-(((TD_DrillStems(i)%DownDepth-TD_WellGeo(j)%TopDepth)/TD_WellGeo(j)%RCurvature))
  85. TD_DrillStems(i)%RCurvature = TD_WellGeo(j)%RCurvature
  86. else
  87. TD_DrillStems(i)%StartAngle = TD_WellGeo(j)%EndAngle !Straight
  88. TD_DrillStems(i)%EndAngle = TD_DrillStems(i)%StartAngle
  89. end if
  90. end if
  91. End Do
  92. else
  93. TD_DrillStems(i)%HoleType = 0 !Straight
  94. TD_DrillStems(i)%StartAngle = 0.0d0
  95. TD_DrillStems(i)%EndAngle = 0.0d0
  96. end if
  97. End Do
  98. !=====> Hole(Well) Diameter Determination Of Drill Stem Components
  99. Do i = 1,TD_DrillStemComponentsNumbs
  100. If (TD_DrillStems(i)%TopDepth>TD_Casing(1)%TopDepth .and. TD_DrillStems(i)%TopDepth<TD_Casing(1)%DownDepth) then
  101. TD_DrillStems(i)%HoleDiameter = TD_Casing(1)%Id
  102. Else if (TD_Liner(1)%Length/=0.d0 .and. TD_DrillStems(i)%TopDepth>TD_Liner(1)%TopDepth .and. TD_DrillStems(i)%TopDepth<TD_Liner(1)%DownDepth) then
  103. TD_DrillStems(i)%HoleDiameter = TD_Liner(1)%Id
  104. Else if (TD_OpenHole(1)%Length/=0.d0 .and. TD_DrillStems(i)%TopDepth>TD_OpenHole(1)%TopDepth .and. TD_DrillStems(i)%TopDepth<TD_OpenHole(1)%DownDepth) then
  105. TD_DrillStems(i)%HoleDiameter = TD_OpenHole(1)%Id
  106. Else if (TD_ROPHole(1)%Length/=0.d0 .and. TD_DrillStems(i)%TopDepth>TD_ROPHole(1)%TopDepth .and. TD_DrillStems(i)%TopDepth<TD_ROPHole(1)%DownDepth) then
  107. TD_DrillStems(i)%HoleDiameter = TD_ROPHole(1)%Id !????????? check
  108. End If
  109. !=====> Viscosity Correction Coefficient Calculation
  110. if (TD_DrillStems(i)%HoleType == 1 .or. TD_DrillStems(i)%HoleType == 2) then
  111. TD_DrillStems(i)%MudVisCorrectCoef = (2.0d0/pi)*atan(sqrt(TD_DrillStems(i)%HoleDiameter**2-(TD_DrillStems(i)%Od**2)) &
  112. / (TD_DrillStems(i)%Od))*(4.0d0/pi-1.0d0) + 1.0d0
  113. else if (TD_DrillStems(i)%HoleType == 0) then
  114. TD_DrillStems(i)%MudVisCorrectCoef = 1.d0
  115. end if
  116. End Do
  117. !=====> Out_of_Well Length Of DrillStem
  118. if (TD_DrillStems(TD_DrillStemComponentsNumbs)%TopDepth<0.) then
  119. TD_OutOfWellLength = abs(TD_DrillStems(TD_DrillStemComponentsNumbs)%TopDepth)
  120. else
  121. TD_OutOfWellLength = 0.d0
  122. end if
  123. !=====> Near Floor Connection
  124. Do i = TD_DrillStemComponentsNumbs, 1, -1
  125. if ( TD_DrillStems(i)%TopDepth<=0.d0 ) then
  126. TD_NearFloorConnectionNo = i
  127. TD_NearFloorConnectionHeight = abs(TD_DrillStems(i)%TopDepth)
  128. end if
  129. if (TD_DrillStems(i)%TopDepth>0.d0) then
  130. exit
  131. end if
  132. End Do
  133. Call Set_NearFloorConnection(real(TD_NearFloorConnectionHeight))
  134. !=====> Graphic Output
  135. kk = 0
  136. k = 0
  137. Do i= 1,TD_StringConfigurationCount
  138. k = k+1
  139. if ( TD_DrillStems(k)%DownDepthIniG>0.d0 ) then
  140. kk = kk+1
  141. if (TD_DrillStems(k+TD_DrillStem(i)%Numbs-1)%TopDepthIniG<=0.d0) then
  142. exit
  143. end if
  144. k = k+TD_DrillStem(i)%Numbs-1
  145. end if
  146. End Do
  147. if (allocated(G_StringElement)) deallocate(G_StringElement)
  148. allocate(G_StringElement(kk))
  149. k = 0
  150. Do i= 1,kk
  151. G_StringElement(kk-i+1)%Id = TD_DrillStem(i)%Id
  152. G_StringElement(kk-i+1)%Od = TD_DrillStem(i)%Od
  153. if ( TD_DrillStem(i)%ComponentType>4 ) then
  154. G_StringElement(kk-i+1)%ComponentType = 3
  155. else
  156. G_StringElement(kk-i+1)%ComponentType = TD_DrillStem(i)%ComponentType
  157. end if
  158. G_StringElement(kk-i+1)%TopDepth = TD_DrillStems(k+TD_DrillStem(i)%Numbs)%TopDepthIniG
  159. G_StringElement(kk-i+1)%DownDepth = TD_DrillStems(k+1)%DownDepthIniG
  160. k = k+TD_DrillStem(i)%Numbs
  161. End Do
  162. if (G_StringElement(1)%TopDepth<=0.d0) then
  163. G_StringElement(1)%TopDepth = 0.d0
  164. end if
  165. Call SetString(kk, G_StringElement)
  166. if(TD_DrillStems(1)%DownDepth<0.d0) then
  167. BitPosition = TD_DrillStems(1)%DownDepth
  168. else
  169. BitPosition = G_StringElement(kk)%DownDepth !???????????
  170. !if ( G_StringElement(kk)%DownDepth>TD_WellTotalLength ) then
  171. ! BitPosition = TD_WellTotalLength !???????????
  172. !end if
  173. end if
  174. !print*, 'kk=' , kk
  175. !Do i=1,kk
  176. ! print*, 'Number/' , 'downDepth/' , 'topDepth/'
  177. ! print*, 'ID/' , 'OD/' , 'Type/'
  178. ! print*, i , G_StringElement(i)%DownDepth , G_StringElement(i)%TopDepth
  179. ! print*, G_StringElement(i)%Id , G_StringElement(i)%Od , G_StringElement(i)%ComponentType
  180. !End Do
  181. !print*, 'Top Joint Height before=' , TD_TopJointHeight
  182. !=====> Top Joint Height
  183. if ( Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then
  184. TD_TopJointHeight = abs(TD_DrillStems(TD_DrillStemComponentsNumbs-1)%TopDepth)
  185. !print*, 'TopDepth1=' , TD_DrillStems(TD_DrillStemComponentsNumbs-1)%TopDepth
  186. !print*, 'numb1=' , TD_DrillStemComponentsNumbs-1
  187. !print*, 'TD_TopJointHeight1=' , TD_TopJointHeight
  188. else
  189. TD_TopJointHeight = abs(TD_DrillStems(TD_DrillStemComponentsNumbs)%TopDepth)
  190. !print*, 'TopDepth2=' , TD_DrillStems(TD_DrillStemComponentsNumbs)%TopDepth
  191. !print*, 'numb2=' , TD_DrillStemComponentsNumbs
  192. !print*, 'TD_TopJointHeight2=' , TD_TopJointHeight
  193. end if
  194. !print*, 'TD_DrillStemComponentsNumbs_=' , TD_DrillStemComponentsNumbs
  195. !print*, 'TD_TopJointHeight_=' , TD_TopJointHeight
  196. !Print*, 'TD_ConnectionHeight_=' , TD_ConnectionHeight
  197. !Print*, 'TD_StringConnectionMode_=' , TD_StringConnectionMode
  198. !
  199. !print*, 'Top Joint Height after=' , TD_TopJointHeight
  200. end subroutine