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.
 
 
 
 
 
 

284 regels
11 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 = 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. else
  68. Call DWFixModeMotion
  69. end if
  70. return
  71. end if
  72. !====================================================
  73. ! Floor Collision (Min_Hook_Height)
  74. !====================================================
  75. 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
  76. if ( FloorCollision_Status==0 .and. data%State%Drawworks%motion==-1 ) then
  77. FloorCollision_Status = 1
  78. data%State%Drawworks%FloorCollision = .true.
  79. data%State%Drawworks%SoundFloorCollision = .true.
  80. else
  81. data%State%Drawworks%SoundFloorCollision = .false.
  82. end if
  83. if ( data%State%Drawworks%motion==1 .and. data%State%Drawworks%FloorCollision==.false. ) then
  84. data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  85. else
  86. Call DWFixModeMotion
  87. end if
  88. return
  89. end if
  90. !====================================================
  91. ! Crown Warning
  92. !====================================================
  93. 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
  94. if ( data%State%Drawworks%motion==-1 ) then
  95. data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  96. else
  97. Call DWFixModeMotion
  98. end if
  99. return
  100. end if
  101. !====================================================
  102. ! Floor Warning
  103. !====================================================
  104. 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
  105. if ( data%State%Drawworks%motion==1 ) then
  106. data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  107. else
  108. Call DWFixModeMotion
  109. end if
  110. return
  111. end if
  112. !====================================================
  113. ! ELEVATOR CONNECTION STRING (SLIPS SET , No Motion)
  114. !====================================================
  115. 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
  116. Call DWFixModeMotion
  117. return
  118. end if
  119. 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
  120. Call DWFixModeMotion
  121. return
  122. end if
  123. !====================================================
  124. ! RAM & ToolJoint Collision (Top of RAM)
  125. !====================================================
  126. Do j = 2,4 !startup problem ???????
  127. if ( data%State%Drawworks%TDBOPElementNo(j)/=0 ) then
  128. 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
  129. if ( data%State%Drawworks%motion==1 ) then
  130. data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  131. else
  132. Call DWFixModeMotion
  133. end if
  134. return
  135. end if
  136. end if
  137. End Do
  138. !====================================================
  139. ! RAM & ToolJoint Collision (Bottom of RAM)
  140. !====================================================
  141. Do j = 2,4
  142. if ( data%State%Drawworks%TDBOPElementNo(j)/=0 ) then
  143. 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
  144. if ( data%State%Drawworks%motion==-1 ) then
  145. data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  146. else
  147. Call DWFixModeMotion
  148. end if
  149. return
  150. end if
  151. end if
  152. End Do
  153. !====================================================
  154. ! TopDrive (TdsStemIn)
  155. !====================================================
  156. if ( (data%State%Drawworks%DriveType==0) .and. (Get_TdsStemIn()) .and. Get_Slips() == SLIPS_SET_END ) then
  157. if ( data%State%Drawworks%motion==1 ) then
  158. data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  159. else
  160. Call DWFixModeMotion
  161. end if
  162. return
  163. end if
  164. !=====> BottomHole ROP Condition
  165. 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
  166. if ( data%State%Drawworks%StringIsBottomOfWell==0 ) then
  167. data%State%Drawworks%Hook_Height_final = data%State%Drawworks%Hook_Height_final+(data%State%Drawworks%TDDrillStemBottom-(data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax))
  168. data%State%Drawworks%StringIsBottomOfWell = 1
  169. end if
  170. Call DWFixModeMotion
  171. return
  172. else
  173. data%State%Drawworks%StringIsBottomOfWell = 0
  174. end if
  175. data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft]
  176. data%State%Drawworks%HookHeight_graph_output = 0.1189d0*((3.280839895d0*data%State%Drawworks%Hook_Height)-28.d0)-2.6d0 ![ft]
  177. end subroutine Drawworks_Solver