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.
 
 
 
 
 
 

207 lines
7.6 KiB

  1. module choke
  2. USE CHOKEVARIABLES
  3. !USE CDataDisplayConsoleVariables, CasingPressureDataDisplay=>CasingPressure!, StandPipePressureDataDisplay=>StandPipePressure
  4. USE CChokeProblemsVariables
  5. !use CChokeControlPanelVariables, StandPipePressureChoke=>StandPipePressure
  6. use MudSystemVARIABLES
  7. USE CChokeManifoldVariables
  8. contains
  9. subroutine CHOKE_MainBody
  10. implicit none
  11. Integer I
  12. INTEGER CHNUMBER
  13. ! time2=time2+0.1
  14. !===========================================================================
  15. !StandPipePressureChoke= STGauge_Pressure ! from module mud system
  16. ! CasingPressure = CasingPressureDataDisplay
  17. !===========================================================================
  18. !
  19. ! HYDRAULIC CHOKE CONTROL
  20. !
  21. !===========================================================================
  22. IF(ChokeSelectorSwitch== 1) THEN
  23. Choke1LED=1
  24. Choke2LED=0
  25. CHNUMBER=1
  26. ELSE
  27. Choke2LED=1
  28. Choke1LED=0
  29. CHNUMBER=2
  30. ENDIF
  31. if (ABS(ChokeControlLever)==1.0 .AND. ChokePanelRigAirSwitch == 1 .AND. (CHOOKE(1)%FailMalf==0 .OR. CHOOKE(2)%FailMalf==0)) then
  32. CALL PIPE_RAMS_CHOKE(CHNUMBER)
  33. end if
  34. IF (Choke1LED==1) THEN
  35. ChokePosition= (1 - GaugeChokePositionMailf) * CHOOKE(1)%PercentClose*10 ! display monitor
  36. ELSE ! Choke2LED==1
  37. ChokePosition= (1 - GaugeChokePositionMailf) * CHOOKE(2)%PercentClose*10 ! display monitor
  38. ENDIF
  39. ! =================== calculating Area
  40. ! AreaChoke=0.5
  41. ! .91 >> 9 percent clearance
  42. CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2)
  43. CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2
  44. !write(*,*) 'CHOOKE(1)%AreaChoke= ' , CHOOKE(1)%AreaChoke
  45. HydraulicChoke1WashoutCoef= HydraulicChoke1WashoutCoef * CHOOKE(1)%WashoutMalf
  46. HydraulicChoke1WashoutCoef= MIN( 0.5 , HydraulicChoke1WashoutCoef+ CHOOKE(1)%WashoutMalf*(0.5/(180.0/DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time
  47. HydraulicChoke2WashoutCoef= HydraulicChoke2WashoutCoef * CHOOKE(2)%WashoutMalf
  48. HydraulicChoke2WashoutCoef= MIN( 0.5 , HydraulicChoke2WashoutCoef+ CHOOKE(2)%WashoutMalf*(0.5/(180.0/DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time
  49. !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef
  50. IF (CHOOKE(1)%PlugMalf == 1) THEN
  51. Present_HydraulicChoke1Plug= Present_HydraulicChoke1Plug * CHOOKE(1)%PlugMalf
  52. ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  53. ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent
  54. !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent
  55. if ( (HydraulicChoke1PluggedPercent - HydraulicChoke1PluggedPercent_Old) /= 0) then
  56. DeltaPlug1Percent = (REAL(HydraulicChoke1PluggedPercent)/100.) - Present_HydraulicChoke1Plug
  57. Plug1TimeCounter = 0
  58. !write(*,*) 'DeltaPlug1Percent, Present_HydraulicChoke1Plug = ' ,DeltaPlug1Percent , Present_HydraulicChoke1Plug
  59. endif
  60. Plug1TimeCounter= Plug1TimeCounter + 1
  61. HydraulicChoke1PluggedPercent_Old= HydraulicChoke1PluggedPercent
  62. if (Plug1TimeCounter <= ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800
  63. Present_HydraulicChoke1Plug = Present_HydraulicChoke1Plug + CHOOKE(1)%PlugMalf* ((DeltaPlug1Percent / real(ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0
  64. endif
  65. !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug
  66. ENDIF
  67. IF (CHOOKE(2)%PlugMalf == 1) THEN
  68. Present_HydraulicChoke2Plug= Present_HydraulicChoke2Plug * CHOOKE(2)%PlugMalf
  69. ! integer: HydraulicChoke2PluggedPercent,HydraulicChoke2PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  70. ! real: Present_HydraulicChoke2Plug,DeltaPlug2Percent
  71. if ( (HydraulicChoke2PluggedPercent - HydraulicChoke2PluggedPercent_Old) /= 0 ) then
  72. DeltaPlug2Percent = (REAL(HydraulicChoke2PluggedPercent)/100.) - Present_HydraulicChoke2Plug
  73. Plug2TimeCounter = 0
  74. endif
  75. Plug2TimeCounter= Plug2TimeCounter + 1
  76. HydraulicChoke2PluggedPercent_Old= HydraulicChoke2PluggedPercent
  77. if (Plug2TimeCounter <= ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800
  78. Present_HydraulicChoke2Plug = Present_HydraulicChoke2Plug + CHOOKE(2)%PlugMalf *((DeltaPlug2Percent / real(ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 1800.0
  79. endif
  80. ENDIF
  81. ! fully open area is 123/64 in^2 = 0.01334635 ft^2
  82. CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke+(CHOOKE(1)%WashoutMalf*HydraulicChoke1WashoutCoef*ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  83. !write(*,*) 'CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke=' ,CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke
  84. CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke-(CHOOKE(1)%PlugMalf* Present_HydraulicChoke1Plug *CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup
  85. CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke+(CHOOKE(2)%WashoutMalf*HydraulicChoke2WashoutCoef*ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  86. CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke-(CHOOKE(2)%PlugMalf* Present_HydraulicChoke2Plug *CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup
  87. !write(*,*) 'CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke=' ,CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke
  88. CHOOKE(1)%AreaChokeFinal= CHOOKE(1)%AreaChoke
  89. CHOOKE(2)%AreaChokeFinal= CHOOKE(2)%AreaChoke
  90. ! 144: ft^2 to in^2
  91. CALL SetHydraulicChock1(100 - nint((CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  92. CALL SetHydraulicChock2(100 - nint((CHOOKE(2)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  93. !write(*,*) 'CHOOKE(1)%PercentClose=' , CHOOKE(1)%PercentClose ! close percent 0 to 100
  94. !write(*,*) 'ChokePosition=' , ChokePosition ! close position 0 to 10 for display
  95. !write(*,*) 'CHOOKE(1)%AreaChokeFinal=' , CHOOKE(1)%AreaChokeFinal ! Open Area (in^2) with clearance
  96. !write(*,*) '(ChokeAreaFullyOpen/144.)=' , (ChokeAreaFullyOpen/144.)
  97. !write(*,*) 'valve value=' , 100 - nint((CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100) ! percent close 0 to 100 with clearance
  98. !write(*,*) 'Valve(33)%Status=' , Valve(33)%Status ! T : open , F: close
  99. ! =================== calculating Area
  100. !AreaChoke= CHOOKE(1)%AreaChoke !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< badan moteghayer 1 ya 2 shavad
  101. ! write(*,*) 'AreaChoke:',AreaChoke
  102. !===========================================================================
  103. ! MUD PUMP STROKES
  104. ! & TOTAL STROKE- CHOKE CONTROL PANEL
  105. !===========================================================================
  106. !************************* IN MUD SYSTEM MODULE*************************
  107. end subroutine CHOKE_MainBody
  108. end module CHOKE