Simulation Core
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

830 行
39 KiB

  1. subroutine TD_StringConnectionModes
  2. Use CHoistingVariables
  3. Use CDrillingConsoleVariables
  4. use UnitySignalVariables
  5. ! Use CKellyConnectionEnumVariables
  6. ! Use CElevatorConnectionEnumVariables
  7. ! Use CSlipsEnumVariables
  8. ! Use COperationConditionEnumVariables
  9. use SoftwareInputsVariables
  10. ! Use CZeroStringSpeed
  11. ! Use CTdsConnectionModesEnumVariables
  12. ! Use CTdsElevatorModesEnumVariables
  13. Use COperationScenariosVariables
  14. Use TD_DrillStemComponents
  15. Use TD_WellElements
  16. Use TD_WellGeometry
  17. Use TD_GeneralData
  18. Use TD_StringConnectionData
  19. Use Drawworks_VARIABLES!, only: Drawworks
  20. implicit none
  21. integer :: i , kk
  22. Real(8) :: LengthSum
  23. !!=====> Read Data
  24. !kk = 0
  25. !LengthSum = 0.d0
  26. !
  27. !Do i = TD_DrillStemComponentsNumbs , 1 , -1
  28. ! if (TD_DrillStems(i)%ComponentType==3) then
  29. ! kk = i
  30. ! exit
  31. ! else if (TD_DrillStems(i)%ComponentType==5 .or. TD_DrillStems(i)%ComponentType==7) then
  32. ! LengthSum = LengthSum+TD_DrillStems(i)%LengthIni
  33. ! end if
  34. !End Do
  35. !####C_Program -----> DriveType =
  36. ! = 0 TopDrive_DriveType
  37. ! = 1 Kelly_DriveType
  38. !####C_Program -----> TD_KellyDriveTypeMode =
  39. ! = 0 Drill Mode (Kelly)
  40. ! = 1 Trip Mode (Elevator)
  41. ! = 2 TopDrive Mode
  42. if ( Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL ) then
  43. TD_KellyDriveTypeMode = 0
  44. else if ( Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_TRIP ) then
  45. TD_KellyDriveTypeMode = 1
  46. else if ( Hoisting%DriveType==0 ) then
  47. TD_KellyDriveTypeMode = 2
  48. end if
  49. TD_HookHeight = DW_TDHookHeight ! unit: [ft]
  50. TD_ElevatorConst = 17.985 ! [ft] Elevator Length(14.84) ????????????????? adad ha daghigh shavand
  51. TD_ElevatorECG = OperationScenario%ECG ! [ft]
  52. TD_KellyConst = 63.280d0 ! [ft] Kelly Length(61.74) + Safety Valve Length(1.54)
  53. TD_KellyElementConst = 41.840d0 ! [ft] Kelly Element Length(40.3) + Safety Valve Length(1.54)
  54. TD_TDSLength = 24.08d0 !??????????????????? ! [ft]
  55. TD_TDSToolJointLength = 0.77d0 !??????????????????? ! [ft]
  56. TD_TDSElevatorLength = 26.837d0 !?????? ! TDS with Elevator Length [ft]
  57. TD_TDSElevatorToolLength= 0.859d0 !??????????????????? ! [ft]
  58. TD_TDSElevatorECG = 2.454 ! [ft]
  59. TD_NumOfCables = Hoisting%NumberOfLine
  60. TD_WeightTB = Hoisting%TravelingBlockWeight ! [lb]
  61. TD_WeightTD = Hoisting%TopDriveWeight ! [lb]
  62. TD_KellyWeight = Hoisting%KellyWeight ! [lb]
  63. !=====> Velocity Calculation
  64. TD_HookVelocity = (TD_HookHeight-TD_HookHeightOld)/TD_TimeStep ! [ft/s]
  65. !====================================================
  66. ! Add or Remove DrillStem Components
  67. !====================================================
  68. Call TD_AddComponents
  69. Call TD_RemoveComponents
  70. !=====> Read Data
  71. kk = 0
  72. LengthSum = 0.d0
  73. Do i = TD_DrillStemComponentsNumbs , 1 , -1
  74. if (TD_DrillStems(i)%ComponentType==3) then
  75. kk = i
  76. exit
  77. else if (TD_DrillStems(i)%ComponentType==5 .or. TD_DrillStems(i)%ComponentType==7) then
  78. LengthSum = LengthSum+TD_DrillStems(i)%LengthIni
  79. end if
  80. End Do
  81. !print*, 'kk' , kk
  82. !print*, 'TD_DrillStems(kk)%LengthIni0=' , TD_DrillStems(kk)%LengthIni
  83. !====================================================
  84. ! String Connection Mode Determination
  85. !====================================================
  86. !####TD_StringConnectionMode =
  87. ! = 0 Slips Set ???????
  88. ! = 1 Kelly Connected to String
  89. ! = 2 Kelly Nothing Connected
  90. ! = 3 Kelly Connected to Single
  91. ! = 4 Elevator Connected to String
  92. ! = 5 Elevator Nothing Connected
  93. ! = 6 Elevator Connected to Stand
  94. ! = 7 Elevator Connected to Single
  95. ! = 8 Elevator Latch String
  96. ! = 18 Elevator Latch Single
  97. ! = 19 Elevator Latch Stand
  98. ! = 9 TDS CONNECTION SPINE
  99. ! = 10 TDS CONNECTION STRING
  100. ! = 11 TDS CONNECTION NOTHING .and. TDS ELEVATOR LATCH STRING
  101. ! = 12 TDS CONNECTION NOTHING .and. TDS ELEVATOR CONNECTION STRING
  102. ! = 13 TDS CONNECTION NOTHING .and. TDS ELEVATOR CONNECTION NOTHING
  103. ! = 14 TDS CONNECTION NOTHING .and. TDS ELEVATOR CONNECTION STAND
  104. ! = 15 TDS CONNECTION NOTHING .and. TDS ELEVATOR CONNECTION SINGLE
  105. ! = 16 TDS CONNECTION NOTHING .and. TDS ELEVATOR LATCH SINGLE
  106. ! = 17 TDS CONNECTION NOTHING .and. TDS ELEVATOR LATCH STAND
  107. !if (TD_DlTouch<=0.) then ![ft]
  108. ! if(TD_HookVelocity<=0.) then
  109. ! TD_ConnectionHeight = TD_ConnectionHeight
  110. ! TD_StringVelocity = 0.0d0
  111. ! return
  112. ! end if
  113. !end if
  114. !=====> Connection Height Determination
  115. if ( TD_KellyDriveTypeMode==0 ) then
  116. if(Get_KellyConnection() == KELLY_CONNECTION_STRING) then
  117. TD_KellyNewStatus1 = 1
  118. else
  119. TD_KellyNewStatus1 = 0
  120. !TD_KellyOldStatus1 = 0
  121. end if
  122. if(Get_KellyConnection()==KELLY_CONNECTION_NOTHING) then
  123. TD_KellyNewStatus2 = 1
  124. else
  125. TD_KellyNewStatus2 = 0
  126. !TD_KellyOldStatus2 = 0
  127. end if
  128. if(Get_KellyConnection()==KELLY_CONNECTION_SINGLE) then
  129. TD_KellyNewStatus3 = 1
  130. else
  131. TD_KellyNewStatus3 = 0
  132. !TD_KellyOldStatus3 = 0
  133. end if
  134. if ( Get_KellyConnection() == KELLY_CONNECTION_STRING ) then
  135. TD_StringConnectionMode = 1
  136. !print*, 'TD_ConnectionHeight10=' , TD_ConnectionHeight
  137. !print*, 'TD_KellyElementConst1=' , TD_KellyElementConst
  138. !print*, 'TD_DrillStems(kk)%LengthIni1=' , TD_DrillStems(kk)%LengthIni
  139. if (TD_KellyOldStatus2==1 .and. TD_KellyNewStatus1/=TD_KellyOldStatus1) then
  140. TD_ConnectionHeight = TD_ConnectionHeight+TD_KellyElementConst
  141. TD_KellyOldStatus1 = TD_KellyNewStatus1
  142. TD_KellyOldStatus2 = 0
  143. else if (TD_KellyOldStatus3==1 .and. TD_KellyNewStatus1/=TD_KellyOldStatus1) then
  144. TD_ConnectionHeight = TD_ConnectionHeight+TD_KellyElementConst+30.d0 !TD_DrillStems(kk)%LengthIni
  145. TD_KellyOldStatus1 = TD_KellyNewStatus1
  146. TD_KellyOldStatus3 = 0
  147. end if
  148. !print*, 'TD_ConnectionHeight1=' , TD_ConnectionHeight
  149. if ( Get_Slips() == SLIPS_SET_END ) then
  150. !!if ( TD_HookVelocity>0. ) then
  151. !! Print*, '*** UnSet Slips ***' !?????????
  152. !!end if
  153. TD_KellyConnectionHeight = TD_HookHeight-(TD_KellyConst-TD_KellyElementConst) !?????????
  154. TD_ConnectionHeight = TD_ConnectionHeight
  155. TD_StringVelocity = 0.0d0
  156. else
  157. !if (TD_DlTouch<=0. .and. TD_HookVelocity<=0.) then
  158. ! TD_ConnectionHeight = TD_ConnectionHeight
  159. ! TD_StringVelocity = 0.0d0
  160. !else
  161. TD_KellyConnectionHeight = TD_HookHeight-(TD_KellyConst-TD_KellyElementConst) !??????????
  162. TD_ConnectionHeight = TD_KellyConnectionHeight
  163. TD_StringVelocity = TD_HookVelocity
  164. !end if
  165. end if
  166. else if ( Get_KellyConnection() == KELLY_CONNECTION_NOTHING ) then
  167. TD_StringConnectionMode = 2
  168. !print*, 'TD_ConnectionHeight20=' , TD_ConnectionHeight
  169. !print*, 'TD_KellyElementConst2=' , TD_KellyElementConst
  170. if (TD_KellyOldStatus1==1 .and. TD_KellyNewStatus2/=TD_KellyOldStatus2) then
  171. TD_ConnectionHeight = TD_ConnectionHeight-TD_KellyElementConst
  172. TD_KellyOldStatus2 = TD_KellyNewStatus2
  173. TD_KellyOldStatus1 = 0
  174. else if (TD_KellyOldStatus3==1 .and. TD_KellyNewStatus2/=TD_KellyOldStatus2) then
  175. TD_ConnectionHeight = TD_ConnectionHeight
  176. TD_KellyOldStatus2 = TD_KellyNewStatus2
  177. TD_KellyOldStatus3 = 0
  178. else if (TD_KellyOldStatus5==1 .and. TD_KellyNewStatus2/=TD_KellyOldStatus2) then
  179. TD_ConnectionHeight = TD_ConnectionHeight
  180. TD_KellyOldStatus2 = TD_KellyNewStatus2
  181. TD_KellyOldStatus5 = 0
  182. end if
  183. !print*, 'TD_ConnectionHeight2=' , TD_ConnectionHeight
  184. TD_KellyConnectionHeight = TD_HookHeight-TD_KellyConst
  185. TD_ConnectionHeight = TD_ConnectionHeight
  186. TD_StringVelocity = 0.0d0
  187. else if ( Get_KellyConnection() == KELLY_CONNECTION_SINGLE ) then
  188. !print*, 'KELLY_CONNECTION_SINGLE' , TD_ConnectionHeight
  189. TD_StringConnectionMode = 3
  190. !print*, 'TD_ConnectionHeight30=' , TD_ConnectionHeight
  191. !print*, 'TD_KellyElementConst3=' , TD_KellyElementConst
  192. !print*, 'TD_DrillStems(kk)%LengthIni3=' , TD_DrillStems(kk)%LengthIni
  193. if (TD_KellyOldStatus1==1 .and. TD_KellyNewStatus3/=TD_KellyOldStatus3) then
  194. !print*, 'KELLY_CONNECTION_SINGLE1' , TD_ConnectionHeight
  195. !print*, 'TD_KellyElementConst=' , TD_KellyElementConst
  196. !print*, 'TD_DrillStems(kk)%LengthIni=' , TD_DrillStems(kk)%LengthIni
  197. TD_ConnectionHeight = TD_ConnectionHeight-TD_KellyElementConst-30.d0 !TD_DrillStems(kk)%LengthIni
  198. TD_KellyOldStatus3 = TD_KellyNewStatus3
  199. TD_KellyOldStatus1 = 0
  200. else if (TD_KellyOldStatus2==1 .and. TD_KellyNewStatus3/=TD_KellyOldStatus3) then
  201. !print*, 'KELLY_CONNECTION_SINGLE2' , TD_ConnectionHeight
  202. TD_ConnectionHeight = TD_ConnectionHeight
  203. TD_KellyOldStatus3 = TD_KellyNewStatus3
  204. TD_KellyOldStatus2 = 0
  205. end if
  206. !print*, 'TD_ConnectionHeight3=' , TD_ConnectionHeight
  207. !print*, 'KELLY_CONNECTION_SINGLE3' , TD_ConnectionHeight
  208. TD_KellyConnectionHeight = TD_HookHeight-TD_KellyConst-TD_DrillStems(kk)%LengthIni
  209. TD_ConnectionHeight = TD_ConnectionHeight
  210. TD_StringVelocity = 0.0d0
  211. !print*, 'KELLY_CONNECTION_SINGLE4' , TD_ConnectionHeight
  212. end if
  213. !print*, 'KELLY_CONNECTION_SINGLE5' , TD_ConnectionHeight
  214. else if ( TD_KellyDriveTypeMode==1 ) then
  215. if(Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING) then
  216. TD_KellyNewStatus4 = 1
  217. else
  218. TD_KellyNewStatus4 = 0
  219. !TD_KellyOldStatus4 = 0
  220. end if
  221. if(Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING) then
  222. TD_KellyNewStatus5 = 1
  223. else
  224. TD_KellyNewStatus5 = 0
  225. !TD_KellyOldStatus5 = 0
  226. end if
  227. if(Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND) then
  228. TD_KellyNewStatus6 = 1
  229. else
  230. TD_KellyNewStatus6 = 0
  231. !TD_KellyOldStatus6 = 0
  232. end if
  233. if(Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) then
  234. TD_KellyNewStatus7 = 1
  235. else
  236. TD_KellyNewStatus7 = 0
  237. !TD_KellyOldStatus7 = 0
  238. end if
  239. if(Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) then
  240. TD_KellyNewStatus8 = 1
  241. else
  242. TD_KellyNewStatus8 = 0
  243. !TD_KellyOldStatus8 = 0
  244. end if
  245. if(Get_ElevatorConnection() == ELEVATOR_LATCH_SINGLE) then
  246. TD_KellyNewStatus18 = 1
  247. else
  248. TD_KellyNewStatus18 = 0
  249. !TD_KellyOldStatus18 = 0
  250. end if
  251. if(Get_ElevatorConnection() == ELEVATOR_LATCH_STAND) then
  252. TD_KellyNewStatus19 = 1
  253. else
  254. TD_KellyNewStatus19 = 0
  255. !TD_KellyOldStatus19 = 0
  256. end if
  257. if ( Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING ) then
  258. TD_StringConnectionMode = 4
  259. if (TD_KellyOldStatus5==1 .and. TD_KellyNewStatus4/=TD_KellyOldStatus4) then
  260. TD_ConnectionHeight = TD_ConnectionHeight
  261. TD_KellyOldStatus4 = TD_KellyNewStatus4
  262. TD_KellyOldStatus5 = 0
  263. else if (TD_KellyOldStatus6==1 .and. TD_KellyNewStatus4/=TD_KellyOldStatus4) then
  264. TD_ConnectionHeight = TD_ConnectionHeight+(3.d0*TD_DrillStems(kk)%LengthIni)
  265. TD_KellyOldStatus4 = TD_KellyNewStatus4
  266. TD_KellyOldStatus6 = 0
  267. else if (TD_KellyOldStatus7==1 .and. TD_KellyNewStatus4/=TD_KellyOldStatus4) then
  268. TD_ConnectionHeight = TD_ConnectionHeight+TD_DrillStems(kk)%LengthIni
  269. TD_KellyOldStatus4 = TD_KellyNewStatus4
  270. TD_KellyOldStatus7 = 0
  271. else if (TD_KellyOldStatus8==1 .and. TD_KellyNewStatus4/=TD_KellyOldStatus4) then
  272. TD_ConnectionHeight = TD_ConnectionHeight
  273. TD_KellyOldStatus4 = TD_KellyNewStatus4
  274. TD_KellyOldStatus8 = 0
  275. end if
  276. if ( Get_Slips() == SLIPS_SET_END ) then
  277. !if ( TD_HookVelocity>0. ) then
  278. ! Print*, '*** UnSet Slips ***' !???????????????????
  279. !end if
  280. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst !?????????????
  281. TD_ConnectionHeight = TD_ConnectionHeight
  282. TD_StringVelocity = 0.0d0
  283. else
  284. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst
  285. TD_ConnectionHeight = TD_HookHeight-TD_ElevatorConst+(LengthSum+TD_ElevatorECG) !(LengthSum+TD_DrillStems(kk)%ToolJointRange)
  286. TD_StringVelocity = TD_HookVelocity
  287. end if
  288. else if ( Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING ) then
  289. TD_StringConnectionMode = 5
  290. if (TD_KellyOldStatus4==1 .and. TD_KellyNewStatus5/=TD_KellyOldStatus5) then
  291. TD_ConnectionHeight = TD_ConnectionHeight
  292. TD_KellyOldStatus5 = TD_KellyNewStatus5
  293. TD_KellyOldStatus4 = 0
  294. else if (TD_KellyOldStatus6==1 .and. TD_KellyNewStatus5/=TD_KellyOldStatus5) then
  295. TD_ConnectionHeight = TD_ConnectionHeight
  296. TD_KellyOldStatus5 = TD_KellyNewStatus5
  297. TD_KellyOldStatus6 = 0
  298. else if (TD_KellyOldStatus7==1 .and. TD_KellyNewStatus5/=TD_KellyOldStatus5) then
  299. TD_ConnectionHeight = TD_ConnectionHeight
  300. TD_KellyOldStatus5 = TD_KellyNewStatus5
  301. TD_KellyOldStatus7 = 0
  302. else if (TD_KellyOldStatus8==1 .and. TD_KellyNewStatus5/=TD_KellyOldStatus5) then
  303. TD_ConnectionHeight = TD_ConnectionHeight
  304. TD_KellyOldStatus5 = TD_KellyNewStatus5
  305. TD_KellyOldStatus8 = 0
  306. else if (TD_KellyOldStatus2==1 .and. TD_KellyNewStatus5/=TD_KellyOldStatus5) then
  307. TD_ConnectionHeight = TD_ConnectionHeight
  308. TD_KellyOldStatus5 = TD_KellyNewStatus5
  309. TD_KellyOldStatus2 = 0
  310. end if
  311. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst
  312. TD_ConnectionHeight = TD_ConnectionHeight
  313. TD_StringVelocity = 0.0d0
  314. else if ( Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND ) then
  315. TD_StringConnectionMode = 6
  316. if (TD_KellyOldStatus4==1 .and. TD_KellyNewStatus6/=TD_KellyOldStatus6) then
  317. TD_ConnectionHeight = TD_ConnectionHeight-(3.*TD_DrillStems(kk)%LengthIni)
  318. TD_KellyOldStatus6 = TD_KellyNewStatus6
  319. TD_KellyOldStatus4 = 0
  320. else if (TD_KellyOldStatus5==1 .and. TD_KellyNewStatus6/=TD_KellyOldStatus6) then
  321. TD_ConnectionHeight = TD_ConnectionHeight
  322. TD_KellyOldStatus6 = TD_KellyNewStatus6
  323. TD_KellyOldStatus5 = 0
  324. else if (TD_KellyOldStatus7==1 .and. TD_KellyNewStatus6/=TD_KellyOldStatus6) then
  325. TD_ConnectionHeight = TD_ConnectionHeight
  326. TD_KellyOldStatus6 = TD_KellyNewStatus6
  327. TD_KellyOldStatus7 = 0
  328. else if (TD_KellyOldStatus8==1 .and. TD_KellyNewStatus6/=TD_KellyOldStatus6) then
  329. TD_ConnectionHeight = TD_ConnectionHeight
  330. TD_KellyOldStatus6 = TD_KellyNewStatus6
  331. TD_KellyOldStatus8 = 0
  332. end if
  333. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst-(3.*TD_DrillStems(kk)%LengthIni)
  334. TD_ConnectionHeight = TD_ConnectionHeight
  335. TD_StringVelocity = 0.0d0
  336. else if ( Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE ) then
  337. TD_StringConnectionMode = 7
  338. if (TD_KellyOldStatus4==1 .and. TD_KellyNewStatus7/=TD_KellyOldStatus7) then
  339. TD_ConnectionHeight = TD_ConnectionHeight-TD_DrillStems(kk)%LengthIni
  340. TD_KellyOldStatus7 = TD_KellyNewStatus7
  341. TD_KellyOldStatus4 = 0
  342. else if (TD_KellyOldStatus5==1 .and. TD_KellyNewStatus7/=TD_KellyOldStatus7) then
  343. TD_ConnectionHeight = TD_ConnectionHeight
  344. TD_KellyOldStatus7 = TD_KellyNewStatus7
  345. TD_KellyOldStatus5 = 0
  346. else if (TD_KellyOldStatus6==1 .and. TD_KellyNewStatus7/=TD_KellyOldStatus7) then
  347. TD_ConnectionHeight = TD_ConnectionHeight
  348. TD_KellyOldStatus7 = TD_KellyNewStatus7
  349. TD_KellyOldStatus6 = 0
  350. else if (TD_KellyOldStatus8==1 .and. TD_KellyNewStatus7/=TD_KellyOldStatus7) then
  351. TD_ConnectionHeight = TD_ConnectionHeight
  352. TD_KellyOldStatus7 = TD_KellyNewStatus7
  353. TD_KellyOldStatus8 = 0
  354. end if
  355. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst-TD_DrillStems(kk)%LengthIni
  356. TD_ConnectionHeight = TD_ConnectionHeight
  357. TD_StringVelocity = 0.0d0
  358. else if ( Get_ElevatorConnection() == ELEVATOR_LATCH_STRING ) then
  359. TD_StringConnectionMode = 8
  360. if (TD_KellyOldStatus4==1 .and. TD_KellyNewStatus8/=TD_KellyOldStatus8) then
  361. TD_ConnectionHeight = TD_ConnectionHeight
  362. TD_KellyOldStatus8 = TD_KellyNewStatus8
  363. TD_KellyOldStatus4 = 0
  364. else if (TD_KellyOldStatus5==1 .and. TD_KellyNewStatus8/=TD_KellyOldStatus8) then
  365. TD_ConnectionHeight = TD_ConnectionHeight
  366. TD_KellyOldStatus8 = TD_KellyNewStatus8
  367. TD_KellyOldStatus5 = 0
  368. else if (TD_KellyOldStatus6==1 .and. TD_KellyNewStatus8/=TD_KellyOldStatus8) then
  369. TD_ConnectionHeight = TD_ConnectionHeight
  370. TD_KellyOldStatus8 = TD_KellyNewStatus8
  371. TD_KellyOldStatus6 = 0
  372. else if (TD_KellyOldStatus7==1 .and. TD_KellyNewStatus8/=TD_KellyOldStatus8) then
  373. TD_ConnectionHeight = TD_ConnectionHeight
  374. TD_KellyOldStatus8 = TD_KellyNewStatus8
  375. TD_KellyOldStatus7 = 0
  376. end if
  377. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst
  378. TD_ConnectionHeight = TD_ConnectionHeight
  379. TD_StringVelocity = 0.0d0
  380. else if ( Get_ElevatorConnection() == ELEVATOR_LATCH_SINGLE ) then
  381. TD_StringConnectionMode = 18
  382. if (TD_KellyOldStatus5==1 .and. TD_KellyNewStatus18/=TD_KellyOldStatus18) then
  383. TD_ConnectionHeight = TD_ConnectionHeight
  384. TD_KellyOldStatus18 = TD_KellyNewStatus18
  385. TD_KellyOldStatus5 = 0
  386. else if (TD_KellyOldStatus7==1 .and. TD_KellyNewStatus18/=TD_KellyOldStatus18) then
  387. TD_ConnectionHeight = TD_ConnectionHeight
  388. TD_KellyOldStatus18 = TD_KellyNewStatus18
  389. TD_KellyOldStatus7 = 0
  390. else if (TD_KellyOldStatus8==1 .and. TD_KellyNewStatus18/=TD_KellyOldStatus18) then
  391. TD_ConnectionHeight = TD_ConnectionHeight
  392. TD_KellyOldStatus18 = TD_KellyNewStatus18
  393. TD_KellyOldStatus8 = 0
  394. end if
  395. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst
  396. TD_ConnectionHeight = TD_ConnectionHeight
  397. TD_StringVelocity = 0.0d0
  398. else if ( Get_ElevatorConnection() == ELEVATOR_LATCH_STAND ) then
  399. TD_StringConnectionMode = 19
  400. if (TD_KellyOldStatus5==1 .and. TD_KellyNewStatus19/=TD_KellyOldStatus19) then
  401. TD_ConnectionHeight = TD_ConnectionHeight
  402. TD_KellyOldStatus19 = TD_KellyNewStatus19
  403. TD_KellyOldStatus5 = 0
  404. else if (TD_KellyOldStatus6==1 .and. TD_KellyNewStatus19/=TD_KellyOldStatus19) then
  405. TD_ConnectionHeight = TD_ConnectionHeight
  406. TD_KellyOldStatus19 = TD_KellyNewStatus19
  407. TD_KellyOldStatus6 = 0
  408. else if (TD_KellyOldStatus8==1 .and. TD_KellyNewStatus19/=TD_KellyOldStatus19) then
  409. TD_ConnectionHeight = TD_ConnectionHeight
  410. TD_KellyOldStatus19 = TD_KellyNewStatus19
  411. TD_KellyOldStatus8 = 0
  412. end if
  413. TD_ElevatorHeight = TD_HookHeight-TD_ElevatorConst
  414. TD_ConnectionHeight = TD_ConnectionHeight
  415. TD_StringVelocity = 0.0d0
  416. end if
  417. else if ( TD_KellyDriveTypeMode==2 ) then
  418. if( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  419. TD_KellyNewStatus9 = 1
  420. else
  421. TD_KellyNewStatus9 = 0
  422. !TD_KellyOldStatus9 = 0
  423. end if
  424. if( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  425. TD_KellyNewStatus10 = 1
  426. else
  427. TD_KellyNewStatus10 = 0
  428. !TD_KellyOldStatus10 = 0
  429. end if
  430. if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STRING ) then
  431. TD_KellyNewStatus11 = 1
  432. else
  433. TD_KellyNewStatus11 = 0
  434. !TD_KellyOldStatus11 = 0
  435. end if
  436. if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING ) then
  437. TD_KellyNewStatus12 = 1
  438. else
  439. TD_KellyNewStatus12 = 0
  440. !TD_KellyOldStatus12 = 0
  441. end if
  442. if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then
  443. TD_KellyNewStatus13 = 1
  444. else
  445. TD_KellyNewStatus13 = 0
  446. !TD_KellyOldStatus13 = 0
  447. end if
  448. if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STAND ) then
  449. TD_KellyNewStatus14 = 1
  450. else
  451. TD_KellyNewStatus14 = 0
  452. !TD_KellyOldStatus14 = 0
  453. end if
  454. if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_SINGLE ) then
  455. TD_KellyNewStatus15 = 1
  456. else
  457. TD_KellyNewStatus15 = 0
  458. !TD_KellyOldStatus15 = 0
  459. end if
  460. if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_SINGLE ) then
  461. TD_KellyNewStatus16 = 1
  462. else
  463. TD_KellyNewStatus16 = 0
  464. !TD_KellyOldStatus16 = 0
  465. end if
  466. if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STAND ) then
  467. TD_KellyNewStatus17 = 1
  468. else
  469. TD_KellyNewStatus17 = 0
  470. !TD_KellyOldStatus17 = 0
  471. end if
  472. if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  473. TD_StringConnectionMode = 9
  474. if (TD_KellyOldStatus10==1 .and. TD_KellyNewStatus9/=TD_KellyOldStatus9) then
  475. TD_ConnectionHeight = TD_ConnectionHeight
  476. TD_KellyOldStatus9 = TD_KellyNewStatus9
  477. TD_KellyOldStatus10 = 0
  478. else if (TD_KellyOldStatus11==1 .and. TD_KellyNewStatus9/=TD_KellyOldStatus9) then
  479. TD_ConnectionHeight = TD_ConnectionHeight
  480. TD_KellyOldStatus9 = TD_KellyNewStatus9
  481. TD_KellyOldStatus11 = 0
  482. else if (TD_KellyOldStatus13==1 .and. TD_KellyNewStatus9/=TD_KellyOldStatus9) then
  483. TD_ConnectionHeight = TD_ConnectionHeight
  484. TD_KellyOldStatus9 = TD_KellyNewStatus9
  485. TD_KellyOldStatus13 = 0
  486. end if
  487. if ( Get_Slips() == SLIPS_SET_END ) then
  488. !if ( TD_HookVelocity>0. ) then
  489. ! Print*, '*** UnSet Slips ***' !???????????????????
  490. !end if
  491. TD_TDSHeight = TD_HookHeight-TD_TDSLength-TD_TDSToolJointLength !?????????????
  492. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  493. TD_ConnectionHeight = TD_ConnectionHeight
  494. TD_StringVelocity = 0.0d0
  495. else
  496. TD_TDSHeight = TD_HookHeight-TD_TDSLength-TD_TDSToolJointLength !?????????????
  497. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  498. TD_ConnectionHeight = TD_TDSHeight
  499. TD_StringVelocity = TD_HookVelocity
  500. end if
  501. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  502. TD_StringConnectionMode = 10
  503. if (TD_KellyOldStatus9==1 .and. TD_KellyNewStatus10/=TD_KellyOldStatus10) then
  504. TD_ConnectionHeight = TD_ConnectionHeight
  505. TD_KellyOldStatus10 = TD_KellyNewStatus10
  506. TD_KellyOldStatus9 = 0
  507. end if
  508. if ( Get_Slips() == SLIPS_SET_END ) then
  509. !if ( TD_HookVelocity>0. ) then
  510. ! Print*, '*** UnSet Slips ***' !???????????????????
  511. !end if
  512. TD_TDSHeight = TD_HookHeight-TD_TDSLength-TD_TDSToolJointLength !?????????????
  513. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  514. TD_ConnectionHeight = TD_ConnectionHeight
  515. TD_StringVelocity = 0.0d0
  516. else
  517. TD_TDSHeight = TD_HookHeight-TD_TDSLength-TD_TDSToolJointLength !?????????????
  518. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  519. TD_ConnectionHeight = TD_TDSHeight
  520. TD_StringVelocity = TD_HookVelocity
  521. end if
  522. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STRING ) then
  523. TD_StringConnectionMode = 11
  524. if (TD_KellyOldStatus9==1 .and. TD_KellyNewStatus11/=TD_KellyOldStatus11) then
  525. TD_ConnectionHeight = TD_ConnectionHeight
  526. TD_KellyOldStatus11 = TD_KellyNewStatus11
  527. TD_KellyOldStatus9 = 0
  528. else if (TD_KellyOldStatus12==1 .and. TD_KellyNewStatus11/=TD_KellyOldStatus11) then
  529. TD_ConnectionHeight = TD_ConnectionHeight
  530. TD_KellyOldStatus11 = TD_KellyNewStatus11
  531. TD_KellyOldStatus12 = 0
  532. else if (TD_KellyOldStatus13==1 .and. TD_KellyNewStatus11/=TD_KellyOldStatus11) then
  533. TD_ConnectionHeight = TD_ConnectionHeight
  534. TD_KellyOldStatus11 = TD_KellyNewStatus11
  535. TD_KellyOldStatus13 = 0
  536. else if (TD_KellyOldStatus16==1 .and. TD_KellyNewStatus11/=TD_KellyOldStatus11) then
  537. TD_ConnectionHeight = TD_ConnectionHeight+(TD_DrillStems(kk)%LengthIni)
  538. TD_KellyOldStatus11 = TD_KellyNewStatus11
  539. TD_KellyOldStatus16 = 0
  540. else if (TD_KellyOldStatus17==1 .and. TD_KellyNewStatus11/=TD_KellyOldStatus11) then
  541. TD_ConnectionHeight = TD_ConnectionHeight+(3.d0*TD_DrillStems(kk)%LengthIni)
  542. TD_KellyOldStatus11 = TD_KellyNewStatus11
  543. TD_KellyOldStatus17 = 0
  544. end if
  545. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  546. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  547. TD_ConnectionHeight = TD_ConnectionHeight
  548. TD_StringVelocity = 0.0d0
  549. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING ) then
  550. TD_StringConnectionMode = 12
  551. if (TD_KellyOldStatus11==1 .and. TD_KellyNewStatus12/=TD_KellyOldStatus12) then
  552. TD_ConnectionHeight = TD_ConnectionHeight
  553. TD_KellyOldStatus12 = TD_KellyNewStatus12
  554. TD_KellyOldStatus11 = 0
  555. else if (TD_KellyOldStatus14==1 .and. TD_KellyNewStatus12/=TD_KellyOldStatus12) then
  556. TD_ConnectionHeight = TD_ConnectionHeight+(3.d0*TD_DrillStems(kk)%LengthIni)
  557. TD_KellyOldStatus12 = TD_KellyNewStatus12
  558. TD_KellyOldStatus14 = 0
  559. else if (TD_KellyOldStatus15==1 .and. TD_KellyNewStatus12/=TD_KellyOldStatus12) then
  560. TD_ConnectionHeight = TD_ConnectionHeight+(TD_DrillStems(kk)%LengthIni)
  561. TD_KellyOldStatus12 = TD_KellyNewStatus12
  562. TD_KellyOldStatus15 = 0
  563. end if
  564. if ( Get_Slips() == SLIPS_SET_END ) then
  565. !if ( TD_HookVelocity>0. ) then
  566. ! Print*, '*** UnSet Slips ***' !???????????????????
  567. !end if
  568. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  569. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  570. TD_ConnectionHeight = TD_ConnectionHeight
  571. TD_StringVelocity = 0.0d0
  572. else
  573. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  574. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSLength-TD_TDSElevatorLength !?????????????
  575. TD_ConnectionHeight = TD_HookHeight-TD_TDSElevatorLength+(LengthSum+TD_TDSElevatorECG) !?????????????
  576. TD_StringVelocity = TD_HookVelocity
  577. end if
  578. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then
  579. TD_StringConnectionMode = 13
  580. if (TD_KellyOldStatus9==1 .and. TD_KellyNewStatus13/=TD_KellyOldStatus13) then
  581. TD_ConnectionHeight = TD_ConnectionHeight
  582. TD_KellyOldStatus13 = TD_KellyNewStatus13
  583. TD_KellyOldStatus9 = 0
  584. else if (TD_KellyOldStatus11==1 .and. TD_KellyNewStatus13/=TD_KellyOldStatus13) then
  585. TD_ConnectionHeight = TD_ConnectionHeight
  586. TD_KellyOldStatus13 = TD_KellyNewStatus13
  587. TD_KellyOldStatus11 = 0
  588. else if (TD_KellyOldStatus12==1 .and. TD_KellyNewStatus13/=TD_KellyOldStatus13) then
  589. TD_ConnectionHeight = TD_ConnectionHeight
  590. TD_KellyOldStatus13 = TD_KellyNewStatus13
  591. TD_KellyOldStatus12 = 0
  592. else if (TD_KellyOldStatus14==1 .and. TD_KellyNewStatus13/=TD_KellyOldStatus13) then
  593. TD_ConnectionHeight = TD_ConnectionHeight
  594. TD_KellyOldStatus13 = TD_KellyNewStatus13
  595. TD_KellyOldStatus14 = 0
  596. else if (TD_KellyOldStatus15==1 .and. TD_KellyNewStatus13/=TD_KellyOldStatus13) then
  597. TD_ConnectionHeight = TD_ConnectionHeight
  598. TD_KellyOldStatus13 = TD_KellyNewStatus13
  599. TD_KellyOldStatus15 = 0
  600. else if (TD_KellyOldStatus16==1 .and. TD_KellyNewStatus13/=TD_KellyOldStatus13) then
  601. TD_ConnectionHeight = TD_ConnectionHeight
  602. TD_KellyOldStatus13 = TD_KellyNewStatus13
  603. TD_KellyOldStatus16 = 0
  604. end if
  605. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  606. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  607. TD_ConnectionHeight = TD_ConnectionHeight
  608. TD_StringVelocity = 0.0d0
  609. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STAND ) then
  610. TD_StringConnectionMode = 14
  611. if (TD_KellyOldStatus12==1 .and. TD_KellyNewStatus14/=TD_KellyOldStatus14) then
  612. TD_ConnectionHeight = TD_ConnectionHeight-(3.d0*TD_DrillStems(kk)%LengthIni)
  613. TD_KellyOldStatus14 = TD_KellyNewStatus14
  614. TD_KellyOldStatus12 = 0
  615. else if (TD_KellyOldStatus13==1 .and. TD_KellyNewStatus14/=TD_KellyOldStatus14) then
  616. TD_ConnectionHeight = TD_ConnectionHeight
  617. TD_KellyOldStatus14 = TD_KellyNewStatus14
  618. TD_KellyOldStatus13 = 0
  619. else if (TD_KellyOldStatus17==1 .and. TD_KellyNewStatus14/=TD_KellyOldStatus14) then
  620. TD_ConnectionHeight = TD_ConnectionHeight
  621. TD_KellyOldStatus14 = TD_KellyNewStatus14
  622. TD_KellyOldStatus17 = 0
  623. end if
  624. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  625. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  626. TD_ConnectionHeight = TD_ConnectionHeight
  627. TD_StringVelocity = 0.0d0
  628. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_SINGLE ) then
  629. TD_StringConnectionMode = 15
  630. if (TD_KellyOldStatus12==1 .and. TD_KellyNewStatus15/=TD_KellyOldStatus15) then
  631. TD_ConnectionHeight = TD_ConnectionHeight-(TD_DrillStems(kk)%LengthIni)
  632. TD_KellyOldStatus15 = TD_KellyNewStatus15
  633. TD_KellyOldStatus12 = 0
  634. else if (TD_KellyOldStatus13==1 .and. TD_KellyNewStatus15/=TD_KellyOldStatus15) then
  635. TD_ConnectionHeight = TD_ConnectionHeight
  636. TD_KellyOldStatus15 = TD_KellyNewStatus15
  637. TD_KellyOldStatus13 = 0
  638. else if (TD_KellyOldStatus16==1 .and. TD_KellyNewStatus15/=TD_KellyOldStatus15) then
  639. TD_ConnectionHeight = TD_ConnectionHeight
  640. TD_KellyOldStatus15 = TD_KellyNewStatus15
  641. TD_KellyOldStatus16 = 0
  642. end if
  643. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  644. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  645. TD_ConnectionHeight = TD_ConnectionHeight
  646. TD_StringVelocity = 0.0d0
  647. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_SINGLE ) then
  648. TD_StringConnectionMode = 16
  649. if (TD_KellyOldStatus11==1 .and. TD_KellyNewStatus16/=TD_KellyOldStatus16) then
  650. TD_ConnectionHeight = TD_ConnectionHeight-(TD_DrillStems(kk)%LengthIni)
  651. TD_KellyOldStatus16 = TD_KellyNewStatus16
  652. TD_KellyOldStatus11 = 0
  653. else if (TD_KellyOldStatus13==1 .and. TD_KellyNewStatus16/=TD_KellyOldStatus16) then
  654. TD_ConnectionHeight = TD_ConnectionHeight
  655. TD_KellyOldStatus16 = TD_KellyNewStatus16
  656. TD_KellyOldStatus13 = 0
  657. else if (TD_KellyOldStatus15==1 .and. TD_KellyNewStatus16/=TD_KellyOldStatus16) then
  658. TD_ConnectionHeight = TD_ConnectionHeight
  659. TD_KellyOldStatus16 = TD_KellyNewStatus16
  660. TD_KellyOldStatus15 = 0
  661. end if
  662. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  663. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  664. TD_ConnectionHeight = TD_ConnectionHeight
  665. TD_StringVelocity = 0.0d0
  666. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STAND ) then
  667. TD_StringConnectionMode = 17
  668. if (TD_KellyOldStatus11==1 .and. TD_KellyNewStatus17/=TD_KellyOldStatus17) then
  669. TD_ConnectionHeight = TD_ConnectionHeight-(3.d0*TD_DrillStems(kk)%LengthIni)
  670. TD_KellyOldStatus17 = TD_KellyNewStatus17
  671. TD_KellyOldStatus11 = 0
  672. else if (TD_KellyOldStatus14==1 .and. TD_KellyNewStatus17/=TD_KellyOldStatus17) then
  673. TD_ConnectionHeight = TD_ConnectionHeight+(3.d0*TD_DrillStems(kk)%LengthIni)
  674. TD_KellyOldStatus17 = TD_KellyNewStatus17
  675. TD_KellyOldStatus14 = 0
  676. end if
  677. TD_TDSHeight = TD_HookHeight-TD_TDSLength !?????????????
  678. TD_TDSElevatorHeight = TD_HookHeight-TD_TDSElevatorLength !?????????????
  679. TD_ConnectionHeight = TD_ConnectionHeight
  680. TD_StringVelocity = 0.0d0
  681. end if
  682. end if
  683. !Print*, 'TD_StringConnectionMode=' , TD_StringConnectionMode
  684. !print* , 'TD_ConnectionHeight=' , TD_ConnectionHeight
  685. !Print*, 'TD_StringConnectionMode=' , TD_StringConnectionMode
  686. !print*, 'TD_DrillStemComponentsNumbs=' , TD_DrillStemComponentsNumbs
  687. !!Print*, 'TD_KellyNewStatus1=' , TD_KellyNewStatus1
  688. !Print*, 'TD_KellyOldStatus1=' , TD_KellyOldStatus1
  689. !Print*, 'TD_KellyNewStatus2=' , TD_KellyNewStatus2
  690. !Print*, 'TD_KellyOldStatus2=' , TD_KellyOldStatus2
  691. !Print*, 'TD_KellyNewStatus3=' , TD_KellyNewStatus3
  692. !Print*, 'TD_KellyOldStatus3=' , TD_KellyOldStatus3
  693. if ( (any(TD_StringConnectionMode==(/1,9,10/))) .or. DrillingConsole%CloseSafetyValve==.true. ) then !for fluid module
  694. TD_FluidStringConnectionMode = 1 !string is connected
  695. !else if ( (any(TD_StringConnectionMode==(/1,9,10/))) .or. CloseSafetyValve==.true. ) then
  696. !
  697. else
  698. TD_FluidStringConnectionMode = 0 !string is not connected
  699. end if
  700. !====================================================
  701. ! Zero String Speed
  702. !====================================================
  703. if ( abs(TD_StringVelocity)<=0.05d0 ) then ! [ft/s]
  704. TD_ZeroStringSpeed = 1
  705. Call Set_ZeroStringSpeed(.true.)
  706. else
  707. TD_ZeroStringSpeed = 0
  708. Call Set_ZeroStringSpeed(.false.)
  709. end if
  710. end subroutine