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.
 
 
 
 
 
 

361 lines
19 KiB

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