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.
 
 
 
 
 
 

285 lines
12 KiB

  1. subroutine Drawworks_Solver
  2. Use CUnityInputs
  3. use UnitySignalVariables
  4. use UnitySignalsModule
  5. use SimulationVariables !@
  6. use OperationScenariosModule
  7. use OperationScenariosModule !!CElevator...
  8. use UnitySignalsModule
  9. ! Use CTdsElevatorModesEnumVariables
  10. use OperationScenariosModule
  11. IMPLICIT NONE
  12. Integer :: j
  13. Integer :: CrownCollision_Status , FloorCollision_Status , CrownWarning_Status , FloorWarning_Status
  14. !>>>>>>>>>>>>>>>>>>>> Speed <<<<<<<<<<<<<<<<<<<<<<<<
  15. data%State%Drawworks%N_Throtle = abs(data%State%Drawworks%Throttle) ![rpm]
  16. !data%State%Drawworks%N_Accelarator = (data%State%Drawworks%Acceleretor/100.d0)*965.d0 ![rpm]
  17. !IF (data%State%Drawworks%N_Throtle>data%State%Drawworks%N_Accelarator) THEN
  18. data%State%Drawworks%N_new = data%State%Drawworks%N_Throtle
  19. !ELSE
  20. ! data%State%Drawworks%N_new = data%State%Drawworks%N_Accelarator
  21. !END IF
  22. !========================== Drawworks Rate limit ==========================
  23. if (((data%State%Drawworks%N_new-data%State%Drawworks%N_old)/data%State%Drawworks%time_step)>data%State%Drawworks%RateChange) then
  24. data%State%Drawworks%Speed =(data%State%Drawworks%RateChange*data%State%Drawworks%time_step)+data%State%Drawworks%N_old ![rpm]
  25. else if (((data%State%Drawworks%N_old-data%State%Drawworks%N_new)/data%State%Drawworks%time_step)>data%State%Drawworks%RateChange) then
  26. data%State%Drawworks%Speed = (-data%State%Drawworks%RateChange*data%State%Drawworks%time_step)+data%State%Drawworks%N_old
  27. else
  28. data%State%Drawworks%Speed = data%State%Drawworks%N_new
  29. end if
  30. !=======================================================================
  31. !========================== Speed Correction ==========================
  32. !===> SLIPS SET , No Motion
  33. if ( data%State%Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then
  34. data%State%Drawworks%Speed = 0.d0
  35. end if
  36. if ( data%State%Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_SPINE .or. Get_TdsConnectionModes()==TDS_CONNECTION_STRING) ) then
  37. data%State%Drawworks%Speed = 0.d0
  38. end if
  39. !===> Closed BOP Rams , No Motion
  40. if ( data%State%Drawworks%ShearBopSituation==1 .and. (any(data%State%Drawworks%DrillModeCond==(/3,10,19,20,24/))) ) then
  41. data%State%Drawworks%Speed = 0.d0
  42. end if
  43. !=======================================================================
  44. Call Drawworks_Direction
  45. !====================================================
  46. ! Collision & Warning
  47. !====================================================
  48. if ( data%State%Drawworks%CrownCollision == .false. ) then
  49. CrownCollision_Status = 0
  50. end if
  51. if ( data%State%Drawworks%FloorCollision == .false. ) then
  52. FloorCollision_Status = 0
  53. end if
  54. ! !====================================================
  55. ! ! Crown Collision (Max_Hook_Height)
  56. ! !====================================================
  57. ! ?if ( ((3.280839895d0*data%State%Drawworks%Hook_Height)>=data%State%Drawworks%max_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then
  58. ! if ( CrownCollision_Status==0 .and. data%State%Drawworks%motion==1 ) then
  59. ! CrownCollision_Status = 1
  60. ! data%State%Drawworks%CrownCollision = .true.
  61. ! data%State%Drawworks%SoundCrownCollision = .true.
  62. ! else
  63. ! data%State%Drawworks%SoundCrownCollision = .false.
  64. ! end if
  65. ! if ( data%State%Drawworks%motion==-1 .and. data%State%Drawworks%CrownCollision==.false. ) then
  66. ! !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  67. ! data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  68. ! else
  69. ! Call DWFixModeMotion
  70. ! end if
  71. ! return
  72. ! end if
  73. ! !====================================================
  74. ! ! Floor Collision (Min_Hook_Height)
  75. ! !====================================================
  76. ! ?if ( ((3.280839895*data%State%Drawworks%Hook_Height)<=data%State%Drawworks%min_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then
  77. ! if ( FloorCollision_Status==0 .and. data%State%Drawworks%motion==-1 ) then
  78. ! FloorCollision_Status = 1
  79. ! data%State%Drawworks%FloorCollision = .true.
  80. ! data%State%Drawworks%SoundFloorCollision = .true.
  81. ! else
  82. ! data%State%Drawworks%SoundFloorCollision = .false.
  83. ! end if
  84. ! if ( data%State%Drawworks%motion==1 .and. data%State%Drawworks%FloorCollision==.false. ) then
  85. ! !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  86. ! data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  87. ! else
  88. ! Call DWFixModeMotion
  89. ! end if
  90. ! return
  91. ! end if
  92. ! !====================================================
  93. ! ! Crown Warning
  94. ! !====================================================
  95. ! ?if ( ((3.280839895*data%State%Drawworks%Hook_Height)>=data%State%Drawworks%max_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then
  96. ! if ( data%State%Drawworks%motion==-1 ) then
  97. ! !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  98. ! data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  99. ! else
  100. ! Call DWFixModeMotion
  101. ! end if
  102. ! return
  103. ! end if
  104. ! !====================================================
  105. ! ! Floor Warning
  106. ! !====================================================
  107. ! ?if ( ((3.280839895*data%State%Drawworks%Hook_Height)<=data%State%Drawworks%min_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then
  108. ! if ( data%State%Drawworks%motion==1 ) then
  109. ! !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  110. ! data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  111. ! else
  112. ! Call DWFixModeMotion
  113. ! end if
  114. ! return
  115. ! end if
  116. !====================================================
  117. ! ELEVATOR CONNECTION STRING (SLIPS SET , No Motion)
  118. !====================================================
  119. if ( data%State%Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and. data%State%Drawworks%motion/=-1 ) then
  120. Call DWFixModeMotion
  121. return
  122. end if
  123. if ( data%State%Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING) .and. data%State%Drawworks%motion/=-1 ) then
  124. Call DWFixModeMotion
  125. return
  126. end if
  127. !====================================================
  128. ! RAM & ToolJoint Collision (Top of RAM)
  129. !====================================================
  130. Do j = 2,4 !startup problem ???????
  131. if ( data%State%Drawworks%TDBOPElementNo(j)/=0 ) then
  132. if ( ((data%State%Drawworks%TDBOPHeight(j)-data%State%Drawworks%TDBOPThickness)<=(data%State%Drawworks%TDDrillStemsTopDepth(data%State%Drawworks%TDBOPElementNo(j))+data%State%Drawworks%TDDrillStemsToolJointRange(data%State%Drawworks%TDBOPElementNo(j)))) .and. ((data%State%Drawworks%TDBOPHeight(j)-data%State%Drawworks%TDBOPThickness)>data%State%Drawworks%TDDrillStemsTopDepth(data%State%Drawworks%TDBOPElementNo(j))) .and. (data%State%Drawworks%TDBOPRamDiam(j)<(2.d0*12.d0*data%State%Drawworks%TDDrillStemsRtoolJoint(data%State%Drawworks%TDBOPElementNo(j)))) ) then
  133. if ( data%State%Drawworks%motion==1 ) then
  134. !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  135. data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  136. else
  137. Call DWFixModeMotion
  138. end if
  139. return
  140. end if
  141. end if
  142. End Do
  143. !====================================================
  144. ! RAM & ToolJoint Collision (Bottom of RAM)
  145. !====================================================
  146. Do j = 2,4
  147. if ( data%State%Drawworks%TDBOPElementNo(j)/=0 ) then
  148. if ( ((data%State%Drawworks%TDBOPHeight(j)+data%State%Drawworks%TDBOPThickness)>=(data%State%Drawworks%TDDrillStemsDownDepth(data%State%Drawworks%TDBOPElementNo(j))-data%State%Drawworks%TDDrillStemsToolJointRange(data%State%Drawworks%TDBOPElementNo(j)))) .and. ((data%State%Drawworks%TDBOPHeight(j)+data%State%Drawworks%TDBOPThickness)<data%State%Drawworks%TDDrillStemsDownDepth(data%State%Drawworks%TDBOPElementNo(j))) .and. (data%State%Drawworks%TDBOPRamDiam(j)<(2.d0*12.d0*data%State%Drawworks%TDDrillStemsRtoolJoint(data%State%Drawworks%TDBOPElementNo(j)))) ) then
  149. if ( data%State%Drawworks%motion==-1 ) then
  150. !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  151. data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  152. else
  153. Call DWFixModeMotion
  154. end if
  155. return
  156. end if
  157. end if
  158. End Do
  159. !====================================================
  160. ! TopDrive (TdsStemIn)
  161. !====================================================
  162. if ( (data%State%Drawworks%DriveType==0) .and. (Get_TdsStemIn()) .and. Get_Slips() == SLIPS_SET_END ) then
  163. if ( data%State%Drawworks%motion==1 ) then
  164. !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  165. data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  166. else
  167. Call DWFixModeMotion
  168. end if
  169. return
  170. end if
  171. !=====> BottomHole ROP Condition
  172. if ( (int(data%State%Drawworks%TDDrillStemBottom*10000.d0)>=(int((data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax)*10000.d0))) .and. (data%State%Drawworks%motion==-1 .or. data%State%Drawworks%motion==0) ) then
  173. if ( data%State%Drawworks%StringIsBottomOfWell==0 ) then
  174. !?data%State%Drawworks%Hook_Height_final = data%State%Drawworks%Hook_Height_final+(data%State%Drawworks%TDDrillStemBottom-(data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax))
  175. data%State%Drawworks%HookLinearVelocity_final = (data%State%Drawworks%TDDrillStemBottom-(data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax))/data%State%Drawworks%time_step ![ft/s]
  176. data%State%Drawworks%StringIsBottomOfWell = 1
  177. end if
  178. Call DWFixModeMotion
  179. return
  180. else
  181. data%State%Drawworks%StringIsBottomOfWell = 0
  182. end if
  183. !data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  184. data%State%Drawworks%HookLinearVelocity_final = 3.280839895d0*data%State%Drawworks%HookLinearVelocity ![ft/s]
  185. data%State%Drawworks%HookHeight_graph_output = 0.1189d0*((3.280839895d0*data%State%Drawworks%Hook_Height)-28.d0)-2.6d0 ![ft]
  186. end subroutine Drawworks_Solver