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.
 
 
 
 
 
 

828 lines
39 KiB

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