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.
 
 
 
 
 
 

135 line
8.4 KiB

  1. module ChokeModule
  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. ! function CHOKE_MainBody1 result(CHNUMBER)
  10. ! implicit none
  11. ! INTEGER CHNUMBER
  12. ! IF(ChokeControlPanel%ChokeSelectorSwitch== 1) THEN
  13. ! ChokeControlPanel%Choke1LED=1
  14. ! ChokeControlPanel%Choke2LED=0
  15. ! CHNUMBER=1
  16. ! ELSE
  17. ! ChokeControlPanel%Choke2LED=1
  18. ! ChokeControlPanel%Choke1LED=0
  19. ! CHNUMBER=2
  20. ! ENDIF
  21. ! end function CHOKE_MainBody1
  22. ! CALL PIPE_RAMS_CHOKE(CHNUMBER)
  23. ! subroutine Choke_innerLoop
  24. ! ! do while (ABS(ChokeControlPanel%ChokeControlLever)==1.0 .AND. ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. CHOOKE(CHNUMBER)%FailMalf==0 .AND. AirDrivenPump%ChokeAirFail==0)
  25. ! if (ChokeControlPanel%ChokeControlLever == 1.0) then
  26. ! CHOOKE(CHNUMBER)%ChokeIsClosing = .true.
  27. ! CHOOKE(CHNUMBER)%ChokeIsOpening = .false.
  28. ! endif
  29. ! if (ChokeControlPanel%ChokeControlLever == -1.0) then
  30. ! CHOOKE(CHNUMBER)%ChokeIsOpening = .true.
  31. ! CHOOKE(CHNUMBER)%ChokeIsClosing = .false.
  32. ! endif
  33. ! AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s)
  34. ! call airpump_code_CHOKE(CHNUMBER)
  35. ! ! call sleepqq(100)
  36. ! ! if (IsStopped == .true.) return
  37. ! ! enddo
  38. ! end if
  39. ! end subroutine Choke_innerLoop
  40. subroutine CHOKE_MainBody2
  41. IF (ChokeControlPanel%Choke1LED==1) THEN
  42. ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(1)%PercentClose*10 ! display monitor
  43. ELSE ! Choke2LED==1
  44. ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(2)%PercentClose*10 ! display monitor
  45. ENDIF
  46. ! =================== calculating Area
  47. ! AreaChoke=0.5
  48. ! .91 >> 9 percent clearance
  49. CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2)
  50. CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2
  51. !write(*,*) 'CHOOKE(1)%AreaChoke= ' , CHOOKE(1)%AreaChoke
  52. Choke%HydraulicChoke1WashoutCoef= Choke%HydraulicChoke1WashoutCoef * CHOOKE(1)%WashoutMalf
  53. Choke%HydraulicChoke1WashoutCoef= MIN( 0.5 , Choke%HydraulicChoke1WashoutCoef+ CHOOKE(1)%WashoutMalf*(0.5/(180.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time
  54. Choke%HydraulicChoke2WashoutCoef= Choke%HydraulicChoke2WashoutCoef * CHOOKE(2)%WashoutMalf
  55. Choke%HydraulicChoke2WashoutCoef= MIN( 0.5 , Choke%HydraulicChoke2WashoutCoef+ CHOOKE(2)%WashoutMalf*(0.5/(180.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time
  56. !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef
  57. IF (CHOOKE(1)%PlugMalf == 1) THEN
  58. Choke%Present_HydraulicChoke1Plug= Choke%Present_HydraulicChoke1Plug * CHOOKE(1)%PlugMalf
  59. ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  60. ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent
  61. !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent
  62. if ( (ChokeProblems%HydraulicChoke1PluggedPercent - Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then
  63. Choke%DeltaPlug1Percent = (REAL(ChokeProblems%HydraulicChoke1PluggedPercent)/100.) - Choke%Present_HydraulicChoke1Plug
  64. Choke%Plug1TimeCounter = 0
  65. !write(*,*) 'DeltaPlug1Percent, Present_HydraulicChoke1Plug = ' ,DeltaPlug1Percent , Present_HydraulicChoke1Plug
  66. endif
  67. Choke%Plug1TimeCounter= Choke%Plug1TimeCounter + 1
  68. Choke%HydraulicChoke1PluggedPercent_Old= ChokeProblems%HydraulicChoke1PluggedPercent
  69. if (Choke%Plug1TimeCounter <= Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800
  70. Choke%Present_HydraulicChoke1Plug = Choke%Present_HydraulicChoke1Plug + CHOOKE(1)%PlugMalf* ((Choke%DeltaPlug1Percent / real(Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0
  71. endif
  72. !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug
  73. ENDIF
  74. IF (CHOOKE(2)%PlugMalf == 1) THEN
  75. Choke%Present_HydraulicChoke2Plug= Choke%Present_HydraulicChoke2Plug * CHOOKE(2)%PlugMalf
  76. ! integer: HydraulicChoke2PluggedPercent,HydraulicChoke2PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  77. ! real: Present_HydraulicChoke2Plug,DeltaPlug2Percent
  78. if ( (ChokeProblems%HydraulicChoke2PluggedPercent - Choke%HydraulicChoke2PluggedPercent_Old) /= 0 ) then
  79. Choke%DeltaPlug2Percent = (REAL(ChokeProblems%HydraulicChoke2PluggedPercent)/100.) - Choke%Present_HydraulicChoke2Plug
  80. Choke%Plug2TimeCounter = 0
  81. endif
  82. Choke%Plug2TimeCounter= Choke%Plug2TimeCounter + 1
  83. Choke%HydraulicChoke2PluggedPercent_Old= ChokeProblems%HydraulicChoke2PluggedPercent
  84. if (Choke%Plug2TimeCounter <= Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800
  85. Choke%Present_HydraulicChoke2Plug = Choke%Present_HydraulicChoke2Plug + CHOOKE(2)%PlugMalf *((Choke%DeltaPlug2Percent / real(Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 1800.0
  86. endif
  87. ENDIF
  88. ! fully open area is 123/64 in^2 = 0.01334635 ft^2
  89. CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke+(CHOOKE(1)%WashoutMalf*Choke%HydraulicChoke1WashoutCoef*Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  90. !write(*,*) 'CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke=' ,CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke
  91. CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke-(CHOOKE(1)%PlugMalf* Choke%Present_HydraulicChoke1Plug *CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup
  92. CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke+(CHOOKE(2)%WashoutMalf*Choke%HydraulicChoke2WashoutCoef*Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  93. CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke-(CHOOKE(2)%PlugMalf* Choke%Present_HydraulicChoke2Plug *CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup
  94. !write(*,*) 'CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke=' ,CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke
  95. CHOOKE(1)%AreaChokeFinal= CHOOKE(1)%AreaChoke
  96. CHOOKE(2)%AreaChokeFinal= CHOOKE(2)%AreaChoke
  97. ! 144: ft^2 to in^2
  98. CALL SetHydraulicChock1(100 - nint((CHOOKE(1)%AreaChokeFinal/(Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  99. CALL SetHydraulicChock2(100 - nint((CHOOKE(2)%AreaChokeFinal/(Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  100. !write(*,*) 'CHOOKE(1)%PercentClose=' , CHOOKE(1)%PercentClose ! close percent 0 to 100
  101. !write(*,*) 'ChokePosition=' , ChokePosition ! close position 0 to 10 for display
  102. !write(*,*) 'CHOOKE(1)%AreaChokeFinal=' , CHOOKE(1)%AreaChokeFinal ! Open Area (in^2) with clearance
  103. !write(*,*) '(ChokeAreaFullyOpen/144.)=' , (ChokeAreaFullyOpen/144.)
  104. !write(*,*) 'valve value=' , 100 - nint((CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100) ! percent close 0 to 100 with clearance
  105. !write(*,*) 'Valve(33)%Status=' , Valve(33)%Status ! T : open , F: close
  106. ! =================== calculating Area
  107. !AreaChoke= CHOOKE(1)%AreaChoke !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< badan moteghayer 1 ya 2 shavad
  108. ! write(*,*) 'AreaChoke:',AreaChoke
  109. !===========================================================================
  110. ! MUD PUMP STROKES
  111. ! & TOTAL STROKE- CHOKE CONTROL PANEL
  112. !===========================================================================
  113. !************************* IN MUD SYSTEM MODULE*************************
  114. end subroutine CHOKE_MainBody2
  115. end module ChokeModule