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.
 
 
 
 
 
 

308 lines
17 KiB

  1. subroutine TD_AddComponents
  2. Use CStringConfigurationVariables
  3. use UnitySignalVariables
  4. use UnitySignalsModule
  5. use OperationScenariosModule!, only: Get_ElevatorConnection
  6. use CHoistingVariables
  7. use SimulationVariables
  8. Use TD_DrillStemComponents
  9. use SimulationVariables !@
  10. use SimulationVariables !@
  11. Use TD_StringConnectionData
  12. implicit none
  13. integer :: i , kk , TD_NumOfAddedComponents
  14. !====================================================
  15. ! Add Single
  16. !====================================================
  17. if ( Get_StringUpdate() == STRING_UPDATE_ADD_SINGLE ) then
  18. kk = 0
  19. Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1
  20. if (data%State%TD_DrillStems(i)%ComponentType==3) then
  21. kk = i
  22. exit
  23. end if
  24. End Do
  25. ! DrillStems Array:
  26. TD_NumOfAddedComponents = 1
  27. Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents)
  28. data%State%TD_DrillStems(i)%ComponentType = 3
  29. data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id
  30. data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%Od
  31. data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.d0
  32. data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(i)%Od*1.3d0/2.d0
  33. data%State%TD_DrillStems(i)%ToolJointRange = data%State%TD_String%ToolJointRange
  34. data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(kk)%LengthIni
  35. data%State%TD_DrillStems(i)%LengthIni = data%State%TD_DrillStems(kk)%LengthIni
  36. data%State%TD_DrillStems(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength
  37. data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length
  38. data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density
  39. data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule
  40. End Do
  41. data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents
  42. ! DrillStem Array:
  43. i = data%State%TD_String%StringConfigurationCount+1
  44. data%State%TD_DrillStem(i)%ComponentType = 3
  45. data%State%TD_DrillStem(i)%Numbs = 1
  46. data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft]
  47. data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%Od ! [ft]
  48. data%State%TD_DrillStem(i)%Length = data%State%TD_DrillStems(kk)%LengthIni
  49. data%State%TD_DrillStem(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength
  50. data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length
  51. data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength
  52. data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1
  53. Call Set_StringUpdate(STRING_UPDATE_NEUTRAL)
  54. end if
  55. !====================================================
  56. ! Add Stand
  57. !====================================================
  58. if ( Get_StringUpdate() == STRING_UPDATE_ADD_STAND ) then
  59. kk = 0
  60. Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1
  61. if (data%State%TD_DrillStems(i)%ComponentType==3) then
  62. kk = i
  63. exit
  64. end if
  65. End Do
  66. ! DrillStems Array:
  67. TD_NumOfAddedComponents = 3
  68. Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents)
  69. data%State%TD_DrillStems(i)%ComponentType = 3
  70. data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id
  71. data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%Od
  72. data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0
  73. data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(i)%Od*1.30d0/2.0d0
  74. data%State%TD_DrillStems(i)%ToolJointRange = data%State%TD_String%ToolJointRange
  75. data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(kk)%LengthIni
  76. data%State%TD_DrillStems(i)%LengthIni = data%State%TD_DrillStems(kk)%LengthIni
  77. data%State%TD_DrillStems(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength
  78. data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length
  79. data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density
  80. data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule
  81. End Do
  82. data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents
  83. ! DrillStem Array:
  84. i = data%State%TD_String%StringConfigurationCount+1
  85. data%State%TD_DrillStem(i)%ComponentType = 3
  86. data%State%TD_DrillStem(i)%Numbs = 3
  87. data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft]
  88. data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%Od ! [ft]
  89. data%State%TD_DrillStem(i)%Length = data%State%TD_DrillStems(kk)%LengthIni
  90. data%State%TD_DrillStem(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength
  91. data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length
  92. data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength
  93. data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1
  94. Call Set_StringUpdate(STRING_UPDATE_NEUTRAL)
  95. end if
  96. !====================================================
  97. ! Add IBOP
  98. !====================================================
  99. !if ( Get_Ibop()==IBOP_INSTALL ) then
  100. ! data%State%TD_Count%IBOPNewAdd = 1
  101. !else
  102. ! data%State%TD_Count%IBOPNewAdd = 0
  103. ! data%State%TD_Count%IBOPOldAdd = 0
  104. ! end if
  105. if ( Get_Ibop()==IBOP_INSTALL .and. data%State%TD_Count%IBOPOldAdd==0 ) then
  106. kk = 0
  107. Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1
  108. if (data%State%TD_DrillStems(i)%ComponentType==3) then
  109. kk = i
  110. exit
  111. end if
  112. End Do
  113. ! DrillStems Array:
  114. TD_NumOfAddedComponents = 1
  115. Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents)
  116. data%State%TD_DrillStems(i)%ComponentType = 5
  117. data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id
  118. data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint
  119. data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0
  120. data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(kk)%RtoolJoint
  121. data%State%TD_DrillStems(i)%ToolJointRange = 0.0d0
  122. data%State%TD_DrillStems(i)%Length = data%State%TD_StConn%IBOPLength ! [ft]
  123. data%State%TD_DrillStems(i)%LengthIni = data%State%TD_StConn%IBOPLength ! [ft]
  124. data%State%TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft]
  125. data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length
  126. data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density !????????????
  127. data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule !????????????
  128. End Do
  129. data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents
  130. ! DrillStem Array:
  131. i = data%State%TD_String%StringConfigurationCount+1
  132. data%State%TD_DrillStem(i)%ComponentType = 5
  133. data%State%TD_DrillStem(i)%Numbs = 1
  134. data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft]
  135. data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint ! [ft]
  136. data%State%TD_DrillStem(i)%Length = 1.540d0 ! [ft]
  137. data%State%TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft]
  138. data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length
  139. data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength
  140. data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1
  141. !data%State%TD_Count%IBOPOldAdd = data%State%TD_Count%IBOPNewAdd
  142. if ( Get_ElevatorConnection() /= ELEVATOR_CONNECTION_STRING .or. (Get_TdsConnectionModes()/=TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()/=TDS_ELEVATOR_CONNECTION_STRING) ) then
  143. data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+data%State%TD_DrillStem(i)%Length
  144. end if
  145. end if
  146. if ( Get_Ibop()==IBOP_INSTALL ) then
  147. data%State%TD_Count%IBOPOldAdd = 1
  148. else
  149. data%State%TD_Count%IBOPOldAdd = 0
  150. end if
  151. !====================================================
  152. ! Add Safety Valve & Kelly (OPERATION_DRILL)
  153. !====================================================
  154. if ( data%Configuration%Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then
  155. data%State%TD_Count%KellyNewAdd = 1
  156. else
  157. data%State%TD_Count%KellyNewAdd = 0
  158. data%State%TD_Count%KellyOldAdd = 0
  159. end if
  160. if ( data%Configuration%Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING .and. data%State%TD_Count%KellyNewAdd/=data%State%TD_Count%KellyOldAdd ) then
  161. ! DrillStems Array:
  162. TD_NumOfAddedComponents = 1
  163. Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents)
  164. data%State%TD_DrillStems(i)%ComponentType = 6
  165. data%State%TD_DrillStems(i)%Id = data%State%TD_StConn%KellyElementID ! [ft]
  166. data%State%TD_DrillStems(i)%Od = data%State%TD_StConn%KellyElementOD ! [ft]
  167. data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0
  168. data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(i)%Od*1.30d0/2.0d0
  169. data%State%TD_DrillStems(i)%ToolJointRange = 0.0d0
  170. data%State%TD_DrillStems(i)%Length = data%State%TD_StConn%KellyElementConst ! [ft]
  171. data%State%TD_DrillStems(i)%LengthIni = data%State%TD_StConn%KellyElementConst ! [ft]
  172. data%State%TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft]
  173. data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length
  174. data%State%TD_DrillStems(i)%Density = 7850.d0*0.06242796d0 ! [kg/m3]*0.06242796=[lb/ft3]
  175. data%State%TD_DrillStems(i)%ElasticModule = 200.0d9*0.02088543d0 ! [lb/ft2] !200GPa=29Mpsi (steel)
  176. End Do
  177. data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents
  178. ! DrillStem Array:
  179. i = data%State%TD_String%StringConfigurationCount+1
  180. data%State%TD_DrillStem(i)%ComponentType = 6
  181. data%State%TD_DrillStem(i)%Numbs = 1
  182. data%State%TD_DrillStem(i)%Id = 3.0d0/12.d0 ! [ft]
  183. data%State%TD_DrillStem(i)%Od = 5.90d0/12.d0 ! [ft]
  184. data%State%TD_DrillStem(i)%Length = data%State%TD_StConn%KellyElementConst ! [ft]
  185. data%State%TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft]
  186. data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length
  187. data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength
  188. data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1
  189. data%State%TD_Count%KellyOldAdd = data%State%TD_Count%KellyNewAdd
  190. end if
  191. !====================================================
  192. ! Add Safety Valve (OPERATION_TRIP)
  193. !====================================================
  194. !if ( Get_OperationCondition()==OPERATION_TRIP .and. Get_SafetyValve()==SAFETY_VALVE_INSTALL ) then
  195. ! data%State%TD_Count%SafetyValveNewAdd = 1
  196. !else
  197. ! data%State%TD_Count%SafetyValveNewAdd = 0
  198. ! data%State%TD_Count%SafetyValveOldAdd = 0
  199. !end if
  200. if ( data%State%TD_StConn%KellyDriveTypeMode/=0 .and. data%State%TD_StConn%OldOperationCondition/=0 .and. Get_SafetyValve()==SAFETY_VALVE_INSTALL .and. data%State%TD_Count%SafetyValveOldAdd==0 ) then
  201. kk = 0
  202. Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1
  203. if (data%State%TD_DrillStems(i)%ComponentType==3) then
  204. kk = i
  205. exit
  206. end if
  207. End Do
  208. ! DrillStems Array:
  209. TD_NumOfAddedComponents = 1
  210. Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents)
  211. data%State%TD_DrillStems(i)%ComponentType = 7
  212. data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id
  213. data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint
  214. data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0
  215. data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(kk)%RtoolJoint
  216. data%State%TD_DrillStems(i)%ToolJointRange = 0.0d0
  217. data%State%TD_DrillStems(i)%Length = data%State%TD_StConn%SafetyValveLength ! [ft]
  218. data%State%TD_DrillStems(i)%LengthIni = data%State%TD_StConn%SafetyValveLength ! [ft]
  219. data%State%TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft]
  220. data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length
  221. data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density !????????????
  222. data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule !????????????
  223. End Do
  224. data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents
  225. ! DrillStem Array:
  226. i = data%State%TD_String%StringConfigurationCount+1
  227. data%State%TD_DrillStem(i)%ComponentType = 7
  228. data%State%TD_DrillStem(i)%Numbs = 1
  229. data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft]
  230. data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint ! [ft]
  231. data%State%TD_DrillStem(i)%Length = 1.540d0 ! [ft]
  232. data%State%TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft]
  233. data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length
  234. data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength
  235. data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1
  236. !data%State%TD_Count%SafetyValveOldAdd = data%State%TD_Count%SafetyValveNewAdd
  237. if ( Get_ElevatorConnection() /= ELEVATOR_CONNECTION_STRING .or. (Get_TdsConnectionModes()/=TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()/=TDS_ELEVATOR_CONNECTION_STRING) ) then
  238. data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+data%State%TD_DrillStem(i)%Length
  239. end if
  240. end if
  241. if ( Get_SafetyValve()==SAFETY_VALVE_INSTALL ) then
  242. data%State%TD_Count%SafetyValveOldAdd = 1
  243. else
  244. data%State%TD_Count%SafetyValveOldAdd = 0
  245. end if
  246. end subroutine