Simulation Core
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

828 linhas
55 KiB

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