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.
 
 
 
 
 
 

286 lines
11 KiB

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