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.
 
 
 
 
 
 

318 lines
11 KiB

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