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.
 
 
 
 
 
 

134 line
9.8 KiB

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