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_RemoveComponents.f90 15 KiB

1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. subroutine TD_RemoveComponents
  2. Use CStringConfigurationVariables
  3. use UnitySignalVariables
  4. ! Use CStringUpdateVariables
  5. ! Use CSafetyValveEnumVariables
  6. ! Use CIbopEnumVariables
  7. ! Use COperationConditionEnumVariables
  8. ! Use CKellyConnectionEnumVariables
  9. ! Use CElevatorConnectionEnumVariables
  10. Use COperationScenariosVariables
  11. ! Use CTdsConnectionModesEnumVariables
  12. ! Use CTdsElevatorModesEnumVariables
  13. Use CHoistingVariables
  14. Use TD_DrillStemComponents
  15. Use TD_WellGeometry
  16. Use TD_GeneralData
  17. Use TD_StringConnectionData
  18. implicit none
  19. integer :: i , TD_NumOfRemovedComponents
  20. !====================================================
  21. ! Remove Safety Valve & Kelly (OPERATION_DRILL)
  22. !====================================================
  23. if ( Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING ) then
  24. TD_KellyNewRemove = 1
  25. else
  26. TD_KellyNewRemove = 0
  27. TD_KellyOldRemove = 0
  28. end if
  29. if ( Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. TD_KellyNewRemove/=TD_KellyOldRemove ) then
  30. !print* , 'Remove Safety Valve & Kelly='
  31. TD_NumOfRemovedComponents = 1
  32. Do i= TD_DrillStemComponentsNumbs , (TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents+1) , -1
  33. TD_DrillStems(i)%ComponentType = 0 !????????????
  34. TD_DrillStems(i)%Id = 0.
  35. TD_DrillStems(i)%Od = 0.
  36. TD_DrillStems(i)%Area = 0.
  37. TD_DrillStems(i)%RtoolJoint = 0.
  38. TD_DrillStems(i)%ToolJointRange = 0.
  39. TD_DrillStems(i)%Length = 0.
  40. TD_DrillStems(i)%LengthIni = 0.
  41. TD_DrillStems(i)%WeightperLength = 0.
  42. TD_DrillStems(i)%Weight = 0.
  43. End Do
  44. TD_DrillStemComponentsNumbs = TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents
  45. i = TD_StringConfigurationCount
  46. if ( TD_DrillStem(i)%Numbs>1 ) then
  47. TD_DrillStem(i)%ComponentType = 6
  48. TD_DrillStem(i)%Numbs = TD_DrillStem(i)%Numbs-1
  49. TD_DrillStem(i)%Id = TD_DrillStem(i)%Id ![ft]
  50. TD_DrillStem(i)%Od = TD_DrillStem(i)%Od ![ft]
  51. TD_DrillStem(i)%Length = TD_DrillStem(i)%Length ![ft]
  52. TD_DrillStem(i)%WeightperLength = TD_DrillStem(i)%WeightperLength
  53. TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length
  54. TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength
  55. TD_StringConfigurationCount = TD_StringConfigurationCount
  56. else if ( TD_DrillStem(i)%Numbs==1 ) then
  57. TD_DrillStem(i)%ComponentType = 6
  58. TD_DrillStem(i)%Numbs = 0
  59. TD_DrillStem(i)%Id = 0.
  60. TD_DrillStem(i)%Od = 0.
  61. TD_DrillStem(i)%Length = 0.
  62. TD_DrillStem(i)%WeightperLength = 0.
  63. TD_DrillStem(i)%TotalLength = 0.
  64. TD_DrillStem(i)%TotalWeight = 0.
  65. TD_StringConfigurationCount = TD_StringConfigurationCount-1
  66. end if
  67. TD_KellyOldRemove = TD_KellyNewRemove
  68. !print* , 'Remove Safety Valve & Kelly (OPERATION_DRILL)'
  69. end if
  70. !====================================================
  71. ! Remove Single
  72. !====================================================
  73. if ( Get_StringUpdate() == STRING_UPDATE_REMOVE_SINGLE ) then
  74. !print* , 'STRING_UPDATE_REMOVE_SINGLE='
  75. TD_NumOfRemovedComponents = 1
  76. Do i= TD_DrillStemComponentsNumbs , (TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents+1) , -1
  77. TD_DrillStems(i)%ComponentType = 0 !????????????
  78. TD_DrillStems(i)%Id = 0.
  79. TD_DrillStems(i)%Od = 0.
  80. TD_DrillStems(i)%Area = 0.
  81. TD_DrillStems(i)%RtoolJoint = 0.
  82. TD_DrillStems(i)%ToolJointRange = 0.
  83. TD_DrillStems(i)%Length = 0.
  84. TD_DrillStems(i)%LengthIni = 0.
  85. TD_DrillStems(i)%WeightperLength = 0.
  86. TD_DrillStems(i)%Weight = 0.
  87. End Do
  88. TD_DrillStemComponentsNumbs = TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents
  89. i = TD_StringConfigurationCount
  90. if ( TD_DrillStem(i)%Numbs>1 ) then
  91. TD_DrillStem(i)%ComponentType = 3
  92. TD_DrillStem(i)%Numbs = TD_DrillStem(i)%Numbs-1
  93. TD_DrillStem(i)%Id = TD_DrillStem(i)%Id ![ft]
  94. TD_DrillStem(i)%Od = TD_DrillStem(i)%Od ![ft]
  95. TD_DrillStem(i)%Length = TD_DrillStem(i)%Length
  96. TD_DrillStem(i)%WeightperLength = TD_DrillStem(i)%WeightperLength
  97. TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length
  98. TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength
  99. TD_StringConfigurationCount = TD_StringConfigurationCount
  100. else if ( TD_DrillStem(i)%Numbs==1 ) then
  101. TD_DrillStem(i)%ComponentType = 3
  102. TD_DrillStem(i)%Numbs = 0
  103. TD_DrillStem(i)%Id = 0.
  104. TD_DrillStem(i)%Od = 0.
  105. TD_DrillStem(i)%Length = 0.
  106. TD_DrillStem(i)%WeightperLength = 0.
  107. TD_DrillStem(i)%TotalLength = 0.
  108. TD_DrillStem(i)%TotalWeight = 0.
  109. TD_StringConfigurationCount = TD_StringConfigurationCount-1
  110. end if
  111. Call Set_StringUpdate(STRING_UPDATE_NEUTRAL)
  112. !print* , 'Remove Single'
  113. end if
  114. !====================================================
  115. ! Remove Stand
  116. !====================================================
  117. if ( Get_StringUpdate() == STRING_UPDATE_REMOVE_STAND ) then
  118. TD_NumOfRemovedComponents = 3
  119. Do i= TD_DrillStemComponentsNumbs , (TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents+1) , -1
  120. TD_DrillStems(i)%ComponentType = 0 !????????????
  121. TD_DrillStems(i)%Id = 0.
  122. TD_DrillStems(i)%Od = 0.
  123. TD_DrillStems(i)%Area = 0.
  124. TD_DrillStems(i)%RtoolJoint = 0.
  125. TD_DrillStems(i)%ToolJointRange = 0.
  126. TD_DrillStems(i)%Length = 0.
  127. TD_DrillStems(i)%LengthIni = 0.
  128. TD_DrillStems(i)%WeightperLength = 0.
  129. TD_DrillStems(i)%Weight = 0.
  130. End Do
  131. TD_DrillStemComponentsNumbs = TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents
  132. i = TD_StringConfigurationCount
  133. if ( TD_DrillStem(i)%Numbs>3 ) then
  134. TD_DrillStem(i)%ComponentType = 3
  135. TD_DrillStem(i)%Numbs = TD_DrillStem(i)%Numbs-3
  136. TD_DrillStem(i)%Id = TD_DrillStem(i)%Id ![ft]
  137. TD_DrillStem(i)%Od = TD_DrillStem(i)%Od ![ft]
  138. TD_DrillStem(i)%Length = TD_DrillStem(i)%Length
  139. TD_DrillStem(i)%WeightperLength = TD_DrillStem(i)%WeightperLength
  140. TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length
  141. TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength
  142. TD_StringConfigurationCount = TD_StringConfigurationCount
  143. else if ( TD_DrillStem(i)%Numbs==3 ) then
  144. TD_DrillStem(i)%ComponentType = 3
  145. TD_DrillStem(i)%Numbs = 0
  146. TD_DrillStem(i)%Id = 0.
  147. TD_DrillStem(i)%Od = 0.
  148. TD_DrillStem(i)%Length = 0.
  149. TD_DrillStem(i)%WeightperLength = 0.
  150. TD_DrillStem(i)%TotalLength = 0.
  151. TD_DrillStem(i)%TotalWeight = 0.
  152. TD_StringConfigurationCount = TD_StringConfigurationCount-1
  153. end if
  154. Call Set_StringUpdate(STRING_UPDATE_NEUTRAL)
  155. !print* , 'Remove Stand'
  156. end if
  157. !====================================================
  158. ! Remove IBOP
  159. !====================================================
  160. !if ( Get_Ibop() == IBOP_REMOVE ) then
  161. ! TD_IBOPNewRemove = 1
  162. !else
  163. ! TD_IBOPNewRemove = 0
  164. ! TD_IBOPOldRemove = 0
  165. !end if
  166. if ( Get_Ibop() == IBOP_REMOVE .and. TD_IBOPOldRemove==0 ) then
  167. TD_NumOfRemovedComponents = 1
  168. Do i= TD_DrillStemComponentsNumbs , (TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents+1) , -1
  169. TD_DrillStems(i)%ComponentType = 0 !????????????
  170. TD_DrillStems(i)%Id = 0.
  171. TD_DrillStems(i)%Od = 0.
  172. TD_DrillStems(i)%Area = 0.
  173. TD_DrillStems(i)%RtoolJoint = 0.
  174. TD_DrillStems(i)%ToolJointRange = 0.
  175. TD_DrillStems(i)%Length = 0.
  176. TD_DrillStems(i)%LengthIni = 0.
  177. TD_DrillStems(i)%WeightperLength = 0.
  178. TD_DrillStems(i)%Weight = 0.
  179. End Do
  180. TD_DrillStemComponentsNumbs = TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents
  181. i = TD_StringConfigurationCount
  182. if ( TD_DrillStem(i)%Numbs>1 ) then
  183. TD_DrillStem(i)%ComponentType = 5
  184. TD_DrillStem(i)%Numbs = TD_DrillStem(i)%Numbs-1
  185. TD_DrillStem(i)%Id = TD_DrillStem(i)%Id ![ft]
  186. TD_DrillStem(i)%Od = TD_DrillStem(i)%Od ![ft]
  187. TD_DrillStem(i)%Length = TD_DrillStem(i)%Length ![ft]
  188. TD_DrillStem(i)%WeightperLength = TD_DrillStem(i)%WeightperLength
  189. TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length
  190. TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength
  191. TD_StringConfigurationCount = TD_StringConfigurationCount
  192. else if ( TD_DrillStem(i)%Numbs==1 ) then
  193. TD_DrillStem(i)%ComponentType = 5
  194. TD_DrillStem(i)%Numbs = 0
  195. TD_DrillStem(i)%Id = 0.
  196. TD_DrillStem(i)%Od = 0.
  197. TD_DrillStem(i)%Length = 0.
  198. TD_DrillStem(i)%WeightperLength = 0.
  199. TD_DrillStem(i)%TotalLength = 0.
  200. TD_DrillStem(i)%TotalWeight = 0.
  201. TD_StringConfigurationCount = TD_StringConfigurationCount-1
  202. end if
  203. !TD_IBOPOldRemove = TD_IBOPNewRemove
  204. if ( Get_ElevatorConnection() /= ELEVATOR_CONNECTION_STRING .or. (Get_TdsConnectionModes()/=TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()/=TDS_ELEVATOR_CONNECTION_STRING) ) then
  205. TD_ConnectionHeight = TD_ConnectionHeight-TD_IBOPLength
  206. end if
  207. !print* , 'Remove IBOP'
  208. end if
  209. if ( Get_Ibop() == IBOP_REMOVE ) then
  210. TD_IBOPOldRemove = 1
  211. else
  212. TD_IBOPOldRemove = 0
  213. end if
  214. !====================================================
  215. ! Remove Safety Valve (OPERATION_TRIP)
  216. !====================================================
  217. !if ( TD_OldOperationCondition==1 .and. TD_KellyDriveTypeMode==1 .and. Get_SafetyValve() == SAFETY_VALVE_REMOVE ) then
  218. ! TD_SafetyValveNewRemove = 1
  219. !else
  220. ! TD_SafetyValveNewRemove = 0
  221. ! TD_SafetyValveOldRemove = 0
  222. !end if
  223. !print* , 'Get_SafetyValve()=' , Get_SafetyValve()
  224. if ( TD_KellyDriveTypeMode/=0 .and. TD_OldOperationCondition/=0 .and. Get_SafetyValve() == SAFETY_VALVE_REMOVE .and. TD_SafetyValveOldRemove==0 ) then
  225. TD_NumOfRemovedComponents = 1
  226. Do i= TD_DrillStemComponentsNumbs , (TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents+1) , -1
  227. TD_DrillStems(i)%ComponentType = 0 !????????????
  228. TD_DrillStems(i)%Id = 0.
  229. TD_DrillStems(i)%Od = 0.
  230. TD_DrillStems(i)%Area = 0.
  231. TD_DrillStems(i)%RtoolJoint = 0.
  232. TD_DrillStems(i)%ToolJointRange = 0.
  233. TD_DrillStems(i)%Length = 0.
  234. TD_DrillStems(i)%LengthIni = 0.
  235. TD_DrillStems(i)%WeightperLength = 0.
  236. TD_DrillStems(i)%Weight = 0.
  237. End Do
  238. TD_DrillStemComponentsNumbs = TD_DrillStemComponentsNumbs-TD_NumOfRemovedComponents
  239. i = TD_StringConfigurationCount
  240. if ( TD_DrillStem(i)%Numbs>1 ) then
  241. TD_DrillStem(i)%ComponentType = 7
  242. TD_DrillStem(i)%Numbs = TD_DrillStem(i)%Numbs-1
  243. TD_DrillStem(i)%Id = TD_DrillStem(i)%Id ![ft]
  244. TD_DrillStem(i)%Od = TD_DrillStem(i)%Od ![ft]
  245. TD_DrillStem(i)%Length = TD_DrillStem(i)%Length ![ft]
  246. TD_DrillStem(i)%WeightperLength = TD_DrillStem(i)%WeightperLength
  247. TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length
  248. TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength
  249. TD_StringConfigurationCount = TD_StringConfigurationCount
  250. else if ( TD_DrillStem(i)%Numbs==1 ) then
  251. TD_DrillStem(i)%ComponentType = 7
  252. TD_DrillStem(i)%Numbs = 0
  253. TD_DrillStem(i)%Id = 0.
  254. TD_DrillStem(i)%Od = 0.
  255. TD_DrillStem(i)%Length = 0.
  256. TD_DrillStem(i)%WeightperLength = 0.
  257. TD_DrillStem(i)%TotalLength = 0.
  258. TD_DrillStem(i)%TotalWeight = 0.
  259. TD_StringConfigurationCount = TD_StringConfigurationCount-1
  260. end if
  261. !print* , 'Get_OperationCondition()=' , Get_OperationCondition()
  262. !print* , 'TD_OldOperationCondition=' , TD_OldOperationCondition
  263. !print* , 'TD_SafetyValveNewRemove=' , TD_SafetyValveNewRemove
  264. !print* , 'TD_SafetyValveOldRemove=' , TD_SafetyValveOldRemove
  265. !TD_SafetyValveOldRemove = TD_SafetyValveNewRemove
  266. if ( Get_ElevatorConnection() /= ELEVATOR_CONNECTION_STRING .or. (Get_TdsConnectionModes()/=TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()/=TDS_ELEVATOR_CONNECTION_STRING) ) then
  267. TD_ConnectionHeight = TD_ConnectionHeight-TD_SafetyValveLength
  268. end if
  269. end if
  270. if ( Get_SafetyValve() == SAFETY_VALVE_REMOVE ) then
  271. TD_SafetyValveOldRemove = 1
  272. else
  273. TD_SafetyValveOldRemove = 0
  274. end if
  275. if ( TD_KellyDriveTypeMode==1 ) then
  276. TD_OldOperationCondition = 1
  277. else
  278. TD_OldOperationCondition = 0
  279. end if
  280. !print* , 'TD_KellyDriveTypeMode2=' , TD_KellyDriveTypeMode
  281. !print* , 'TD_OldOperationCondition2=' , TD_OldOperationCondition
  282. !print* , 'TD_SafetyValveNewRemove2=' , TD_SafetyValveNewRemove
  283. !print* , 'TD_SafetyValveOldRemove2=' , TD_SafetyValveOldRemove
  284. end subroutine