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.
 
 
 
 
 
 

316 lines
15 KiB

  1. # 1 "/home/admin/SimulationCore2/TorqueDrag/TD_DrillingSubs/TD_DrillStemConfiguration.f90"
  2. subroutine TD_DrillStemConfiguration
  3. Use CStringConfigurationVariables
  4. use SoftwareInputsVariables
  5. ! Use CNearFloorConnection
  6. use CDataDisplayConsole
  7. use SimulationVariables
  8. use SimulationVariables !@
  9. use UnitySignalVariables
  10. use UnitySignalsModule
  11. ! use UnitySignalsModuleVariables
  12. use OperationScenariosModule
  13. Use TD_DrillStemComponents
  14. use SimulationVariables !@
  15. use SimulationVariables !@
  16. Use TD_StringConnectionData
  17. Use sROP_Variables
  18. use DownHoleModule
  19. implicit none
  20. Integer :: i , j , k , kk
  21. !====================================================
  22. ! Drill Stem Components Data Modification
  23. !====================================================
  24. !=====> Drill Stem Total Length&Weight Calculation
  25. data%State%TD_String%DrillStemTotalLength = 0.0d0
  26. data%State%TD_String%DrillStemTotalLengthIni = 0.0d0
  27. data%State%TD_String%DrillStemTotalWeight = 0.0d0
  28. Do i= 1,data%State%TD_String%DrillStemComponentsNumbs
  29. data%State%TD_String%DrillStemTotalLength = data%State%TD_String%DrillStemTotalLength+data%State%TD_DrillStems(i)%Length
  30. data%State%TD_String%DrillStemTotalLengthIni = data%State%TD_String%DrillStemTotalLengthIni+data%State%TD_DrillStems(i)%LengthIni
  31. data%State%TD_String%DrillStemTotalWeight = data%State%TD_String%DrillStemTotalWeight+data%State%TD_DrillStems(i)%Weight
  32. End Do
  33. !=====> Top&Down Depth Calculation Of Initial Drill Stem Components (Graphic)
  34. data%State%TD_DrillStems(1)%DownDepth = data%State%TD_String%DrillStemTotalLength-data%State%TD_StConn%ConnectionHeight
  35. data%State%TD_String%DrillStemBottom = data%State%TD_DrillStems(1)%DownDepth
  36. if ( data%State%TD_DrillStems(1)%DownDepth>=data%State%TD_WellGeneral%WellTotalLength ) then
  37. !if ( data%State%TD_StConn%HookHeight>=data%State%TD_StConn%HookHeightOld .and. data%State%ROP_Bit%RateOfPenetration==0. ) then
  38. ! data%State%TD_StConn%GRigidConnectionHeight = data%State%TD_StConn%GRigidConnectionHeight
  39. !else
  40. data%State%TD_StConn%GRigidConnectionHeight = data%State%TD_StConn%GRigidConnectionHeight-(data%State%TD_WellGeneral%WellTotalLength-data%State%TD_DrillStems(1)%DownDepthIniG)
  41. data%State%TD_DrillStems(1)%DownDepthIniG = data%State%TD_WellGeneral%WellTotalLength !???????????
  42. ! !data%State%TD_StConn%GRigidConnectionHeight = data%State%TD_StConn%GRigidConnectionHeight
  43. !end if
  44. else
  45. data%State%TD_StConn%GRigidConnectionHeight = data%State%TD_StConn%ConnectionHeight
  46. data%State%TD_DrillStems(1)%DownDepthIniG = data%State%TD_String%DrillStemTotalLengthIni-data%State%TD_StConn%GRigidConnectionHeight
  47. end if
  48. !data%State%TD_DrillStems(1)%DownDepthIniG = data%State%TD_String%DrillStemTotalLengthIni-data%State%TD_StConn%GRigidConnectionHeight
  49. !if ( data%State%TD_DrillStems(1)%DownDepthIniG>data%State%TD_WellGeneral%WellTotalLength ) then
  50. ! data%State%TD_StConn%GRigidConnectionHeight = data%State%TD_StConn%GRigidConnectionHeight+(data%State%TD_DrillStems(1)%DownDepthIniG-data%State%TD_WellGeneral%WellTotalLength)
  51. ! data%State%TD_DrillStems(1)%DownDepthIniG = data%State%TD_WellGeneral%WellTotalLength !???????????
  52. !end if
  53. data%State%TD_DrillStems(1)%TopDepthIniG = data%State%TD_DrillStems(1)%DownDepthIniG-data%State%TD_DrillStems(1)%LengthIni
  54. Do i = 2,data%State%TD_String%DrillStemComponentsNumbs
  55. data%State%TD_DrillStems(i)%TopDepthIniG = data%State%TD_DrillStems(i-1)%TopDepthIniG-data%State%TD_DrillStems(i)%LengthIni
  56. data%State%TD_DrillStems(i)%DownDepthIniG = data%State%TD_DrillStems(i-1)%DownDepthIniG-data%State%TD_DrillStems(i-1)%LengthIni
  57. End Do
  58. !=====> Top&Down Depth Calculation Of Initial Drill Stem Components (for fluid module)
  59. if ( data%State%TD_DrillStems(1)%DownDepthIniG>=(data%State%TD_WellGeneral%WellTotalLength-.1d0) ) then
  60. data%State%TD_StConn%RigidConnectionHeight = data%State%TD_StConn%GRigidConnectionHeight+(.1d0-(data%State%TD_WellGeneral%WellTotalLength-data%State%TD_DrillStems(1)%DownDepthIniG))
  61. else
  62. data%State%TD_StConn%RigidConnectionHeight = data%State%TD_StConn%GRigidConnectionHeight
  63. end if
  64. data%State%TD_DrillStems(1)%DownDepthIni = data%State%TD_String%DrillStemTotalLengthIni-data%State%TD_StConn%RigidConnectionHeight
  65. data%State%TD_DrillStems(1)%TopDepthIni = data%State%TD_DrillStems(1)%DownDepthIni-data%State%TD_DrillStems(1)%LengthIni
  66. Do i = 2,data%State%TD_String%DrillStemComponentsNumbs
  67. data%State%TD_DrillStems(i)%TopDepthIni = data%State%TD_DrillStems(i-1)%TopDepthIni-data%State%TD_DrillStems(i)%LengthIni
  68. data%State%TD_DrillStems(i)%DownDepthIni = data%State%TD_DrillStems(i-1)%DownDepthIni-data%State%TD_DrillStems(i-1)%LengthIni
  69. End Do
  70. !=====> Top&Down Depth Calculation Of Drill Stem Components
  71. data%State%TD_DrillStems(1)%TopDepth = data%State%TD_String%DrillStemTotalLength-data%State%TD_DrillStems(1)%Length-data%State%TD_StConn%GRigidConnectionHeight
  72. data%State%TD_DrillStems(1)%DownDepth = data%State%TD_String%DrillStemTotalLength-data%State%TD_StConn%GRigidConnectionHeight
  73. Do i = 2,data%State%TD_String%DrillStemComponentsNumbs
  74. data%State%TD_DrillStems(i)%TopDepth = data%State%TD_DrillStems(i-1)%TopDepth-data%State%TD_DrillStems(i)%Length
  75. data%State%TD_DrillStems(i)%DownDepth = data%State%TD_DrillStems(i-1)%DownDepth-data%State%TD_DrillStems(i-1)%Length
  76. End Do
  77. !data%State%TD_String%DrillStemBottom = data%State%TD_DrillStems(1)%DownDepth
  78. !=====> Hole Type & Inclination Determination Of Drill Stem Components
  79. Do i = 1,data%State%TD_String%DrillStemComponentsNumbs
  80. if (data%State%TD_DrillStems(i)%TopDepth .ge. 0.d0) then
  81. Do j = 1,data%State%TD_WellGeneral%WellIntervalsCount
  82. if (data%State%TD_DrillStems(i)%TopDepth>data%State%TD_WellGeo(j)%TopDepth .and. data%State%TD_DrillStems(i)%TopDepth<data%State%TD_WellGeo(j)%DownDepth) then
  83. data%State%TD_DrillStems(i)%HoleType = data%State%TD_WellGeo(j)%HoleType
  84. if (data%State%TD_DrillStems(i)%HoleType == 1) then
  85. data%State%TD_DrillStems(i)%StartAngle = data%State%TD_WellGeo(j)%StartAngle+(((data%State%TD_DrillStems(i)%TopDepth-data%State%TD_WellGeo(j)%TopDepth)/data%State%TD_WellGeo(j)%RCurvature)) ![rad]
  86. data%State%TD_DrillStems(i)%EndAngle = data%State%TD_WellGeo(j)%StartAngle+(((data%State%TD_DrillStems(i)%DownDepth-data%State%TD_WellGeo(j)%TopDepth)/data%State%TD_WellGeo(j)%RCurvature))
  87. data%State%TD_DrillStems(i)%RCurvature = data%State%TD_WellGeo(j)%RCurvature
  88. else if (data%State%TD_DrillStems(i)%HoleType == 2) then
  89. data%State%TD_DrillStems(i)%StartAngle = data%State%TD_WellGeo(j)%StartAngle-(((data%State%TD_DrillStems(i)%TopDepth-data%State%TD_WellGeo(j)%TopDepth)/data%State%TD_WellGeo(j)%RCurvature))
  90. data%State%TD_DrillStems(i)%EndAngle = data%State%TD_WellGeo(j)%StartAngle-(((data%State%TD_DrillStems(i)%DownDepth-data%State%TD_WellGeo(j)%TopDepth)/data%State%TD_WellGeo(j)%RCurvature))
  91. data%State%TD_DrillStems(i)%RCurvature = data%State%TD_WellGeo(j)%RCurvature
  92. else
  93. data%State%TD_DrillStems(i)%StartAngle = data%State%TD_WellGeo(j)%EndAngle !Straight
  94. data%State%TD_DrillStems(i)%EndAngle = data%State%TD_DrillStems(i)%StartAngle
  95. end if
  96. end if
  97. End Do
  98. else
  99. data%State%TD_DrillStems(i)%HoleType = 0 !Straight
  100. data%State%TD_DrillStems(i)%StartAngle = 0.0d0
  101. data%State%TD_DrillStems(i)%EndAngle = 0.0d0
  102. end if
  103. End Do
  104. !=====> Hole(Well) Diameter Determination Of Drill Stem Components
  105. Do i = 1,data%State%TD_String%DrillStemComponentsNumbs
  106. If (data%State%TD_DrillStems(i)%TopDepth>data%State%TD_Casing(1)%TopDepth .and. data%State%TD_DrillStems(i)%TopDepth<data%State%TD_Casing(1)%DownDepth) then
  107. data%State%TD_DrillStems(i)%HoleDiameter = data%State%TD_Casing(1)%Id
  108. Else if (data%State%TD_Liner(1)%Length/=0.d0 .and. data%State%TD_DrillStems(i)%TopDepth>data%State%TD_Liner(1)%TopDepth .and. data%State%TD_DrillStems(i)%TopDepth<data%State%TD_Liner(1)%DownDepth) then
  109. data%State%TD_DrillStems(i)%HoleDiameter = data%State%TD_Liner(1)%Id
  110. Else if (data%State%TD_OpenHole(1)%Length/=0.d0 .and. data%State%TD_DrillStems(i)%TopDepth>data%State%TD_OpenHole(1)%TopDepth .and. data%State%TD_DrillStems(i)%TopDepth<data%State%TD_OpenHole(1)%DownDepth) then
  111. data%State%TD_DrillStems(i)%HoleDiameter = data%State%TD_OpenHole(1)%Id
  112. Else if (data%State%TD_ROPHole(1)%Length/=0.d0 .and. data%State%TD_DrillStems(i)%TopDepth>data%State%TD_ROPHole(1)%TopDepth .and. data%State%TD_DrillStems(i)%TopDepth<data%State%TD_ROPHole(1)%DownDepth) then
  113. data%State%TD_DrillStems(i)%HoleDiameter = data%State%TD_ROPHole(1)%Id !????????? check
  114. End If
  115. !=====> Viscosity Correction Coefficient Calculation
  116. if (data%State%TD_DrillStems(i)%HoleType == 1 .or. data%State%TD_DrillStems(i)%HoleType == 2) then
  117. data%State%TD_DrillStems(i)%MudVisCorrectCoef = (2.0d0/pi)*atan(sqrt(data%State%TD_DrillStems(i)%HoleDiameter**2-(data%State%TD_DrillStems(i)%Od**2)) &
  118. / (data%State%TD_DrillStems(i)%Od))*(4.0d0/pi-1.0d0) + 1.0d0
  119. else if (data%State%TD_DrillStems(i)%HoleType == 0) then
  120. data%State%TD_DrillStems(i)%MudVisCorrectCoef = 1.d0
  121. end if
  122. End Do
  123. !=====> Out_of_Well Length Of DrillStem
  124. if (data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%TopDepth<0.) then
  125. data%State%TD_String%OutOfWellLength = abs(data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%TopDepth)
  126. else
  127. data%State%TD_String%OutOfWellLength = 0.d0
  128. end if
  129. !=====> Near Floor Connection
  130. Do i = data%State%TD_String%DrillStemComponentsNumbs, 1, -1
  131. if ( data%State%TD_DrillStems(i)%TopDepth<=0.d0 ) then
  132. data%State%TD_String%NearFloorConnectionNo = i
  133. data%State%TD_String%NearFloorConnectionHeight = abs(data%State%TD_DrillStems(i)%TopDepth)
  134. end if
  135. if (data%State%TD_DrillStems(i)%TopDepth>0.d0) then
  136. exit
  137. end if
  138. End Do
  139. Call Set_NearFloorConnection(real(data%State%TD_String%NearFloorConnectionHeight))
  140. !=====> Graphic Output
  141. kk = 0
  142. k = 0
  143. Do i= 1,data%State%TD_String%StringConfigurationCount
  144. k = k+1
  145. if ( data%State%TD_DrillStems(k)%DownDepthIniG>0.d0 ) then
  146. kk = kk+1
  147. if (data%State%TD_DrillStems(k+data%State%TD_DrillStem(i)%Numbs-1)%TopDepthIniG<=0.d0) then
  148. exit
  149. end if
  150. k = k+data%State%TD_DrillStem(i)%Numbs-1
  151. end if
  152. End Do
  153. if (allocated(data%State%G_StringElement)) deallocate(data%State%G_StringElement)
  154. allocate(data%State%G_StringElement(kk))
  155. k = 0
  156. Do i= 1,kk
  157. data%State%G_StringElement(kk-i+1)%Id = data%State%TD_DrillStem(i)%Id
  158. data%State%G_StringElement(kk-i+1)%Od = data%State%TD_DrillStem(i)%Od
  159. if ( data%State%TD_DrillStem(i)%ComponentType>4 ) then
  160. data%State%G_StringElement(kk-i+1)%ComponentType = 3
  161. else
  162. data%State%G_StringElement(kk-i+1)%ComponentType = data%State%TD_DrillStem(i)%ComponentType
  163. end if
  164. data%State%G_StringElement(kk-i+1)%TopDepth = data%State%TD_DrillStems(k+data%State%TD_DrillStem(i)%Numbs)%TopDepthIniG
  165. data%State%G_StringElement(kk-i+1)%DownDepth = data%State%TD_DrillStems(k+1)%DownDepthIniG
  166. k = k+data%State%TD_DrillStem(i)%Numbs
  167. End Do
  168. if (data%State%G_StringElement(1)%TopDepth<=0.d0) then
  169. data%State%G_StringElement(1)%TopDepth = 0.d0
  170. end if
  171. Call SetString(kk, data%State%G_StringElement)
  172. if(data%State%TD_DrillStems(1)%DownDepth<0.d0) then
  173. data%Equipments%DrillingWatch%BitPosition = data%State%TD_DrillStems(1)%DownDepth
  174. else
  175. data%Equipments%DrillingWatch%BitPosition = data%State%G_StringElement(kk)%DownDepth !???????????
  176. !if ( data%State%G_StringElement(kk)%DownDepth>data%State%TD_WellGeneral%WellTotalLength ) then
  177. ! data%Equipments%DrillingWatch%BitPosition = data%State%TD_WellGeneral%WellTotalLength !???????????
  178. !end if
  179. end if
  180. !if(print_log) print*, 'kk=' , kk
  181. !Do i=1,kk
  182. ! if(print_log) print*, 'Number/' , 'downDepth/' , 'topDepth/'
  183. ! if(print_log) print*, 'ID/' , 'OD/' , 'Type/'
  184. ! if(print_log) print*, i , data%State%G_StringElement(i)%DownDepth , data%State%G_StringElement(i)%TopDepth
  185. ! if(print_log) print*, data%State%G_StringElement(i)%Id , data%State%G_StringElement(i)%Od , data%State%G_StringElement(i)%ComponentType
  186. !End Do
  187. !if(print_log) print*, 'Top Joint Height before=' , data%State%TD_String%TopJointHeight
  188. !=====> Top Joint Height
  189. if ( Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then
  190. data%State%TD_String%TopJointHeight = abs(data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs-1)%TopDepth)
  191. !if(print_log) print*, 'TopDepth1=' , data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs-1)%TopDepth
  192. !if(print_log) print*, 'numb1=' , data%State%TD_String%DrillStemComponentsNumbs-1
  193. !if(print_log) print*, 'data%State%TD_String%TopJointHeight=' , data%State%TD_String%TopJointHeight
  194. else
  195. data%State%TD_String%TopJointHeight = abs(data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%TopDepth)
  196. !if(print_log) print*, 'TopDepth2=' , data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%TopDepth
  197. !if(print_log) print*, 'numb2=' , data%State%TD_String%DrillStemComponentsNumbs
  198. !if(print_log) print*, 'data%State%TD_String%TopJointHeight2=' , data%State%TD_String%TopJointHeight
  199. end if
  200. !if(print_log) print*, 'data%State%TD_String%DrillStemComponentsNumbs=' , data%State%TD_String%DrillStemComponentsNumbs
  201. !if(print_log) print*, 'data%State%TD_String%TopJointHeight_=' , data%State%TD_String%TopJointHeight
  202. !if(print_log) print*, 'data%State%TD_StConn%ConnectionHeight_=' , data%State%TD_StConn%ConnectionHeight
  203. !if(print_log) print*, 'data%State%TD_StConn%StringConnectionMode_=' , data%State%TD_StConn%StringConnectionMode
  204. !
  205. !if(print_log) print*, 'Top Joint Height after=' , data%State%TD_String%TopJointHeight
  206. end subroutine