Simulation Core
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

321 wiersze
15 KiB

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