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.

Drawworks_Solver.i90 12 KiB

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