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.
 
 
 
 
 
 

136 lines
9.3 KiB

  1. # 1 "/home/admin/SimulationCore2/Equipments/ChokeControl/CHOKE.f90"
  2. module ChokeModule
  3. USE CHOKEVARIABLES
  4. use SimulationVariables
  5. USE CChokeProblemsVariables
  6. USE MudSystemVARIABLES
  7. use CChokeManifold
  8. contains
  9. ! function CHOKE_MainBody1 result(CHNUMBER)
  10. ! implicit none
  11. ! INTEGER CHNUMBER
  12. ! IF(data%Equipments%ChokeControlPanel%ChokeSelectorSwitch== 1) THEN
  13. ! data%Equipments%ChokeControlPanel%Choke1LED=1
  14. ! data%Equipments%ChokeControlPanel%Choke2LED=0
  15. ! CHNUMBER=1
  16. ! ELSE
  17. ! data%Equipments%ChokeControlPanel%Choke2LED=1
  18. ! data%Equipments%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(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)
  25. ! if (data%Equipments%ChokeControlPanel%ChokeControlLever == 1.0) then
  26. ! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .true.
  27. ! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .false.
  28. ! endif
  29. ! if (data%Equipments%ChokeControlPanel%ChokeControlLever == -1.0) then
  30. ! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .true.
  31. ! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .false.
  32. ! endif
  33. ! data%State%AirPumpLine%TIME=data%State%AirPumpLine%TIME+data%State%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 (data%Equipments%ChokeControlPanel%Choke1LED==1) THEN
  42. data%Equipments%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%CHOOKE(1)%PercentClose*10 ! display monitor
  43. ELSE ! Choke2LED==1
  44. data%Equipments%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%CHOOKE(2)%PercentClose*10 ! display monitor
  45. ENDIF
  46. ! =================== calculating Area
  47. ! AreaChoke=0.5
  48. ! .91 >> 9 percent clearance
  49. 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)
  50. data%State%CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(data%State%CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2
  51. !write(*,*) 'data%State%CHOOKE(1)%AreaChoke= ' , data%State%CHOOKE(1)%AreaChoke
  52. data%State%Choke%HydraulicChoke1WashoutCoef= data%State%Choke%HydraulicChoke1WashoutCoef * data%State%CHOOKE(1)%WashoutMalf
  53. 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
  54. data%State%Choke%HydraulicChoke2WashoutCoef= data%State%Choke%HydraulicChoke2WashoutCoef * data%State%CHOOKE(2)%WashoutMalf
  55. 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
  56. !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef
  57. IF (data%State%CHOOKE(1)%PlugMalf == 1) THEN
  58. data%State%Choke%Present_HydraulicChoke1Plug= data%State%Choke%Present_HydraulicChoke1Plug * data%State%CHOOKE(1)%PlugMalf
  59. ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  60. ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent
  61. !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent
  62. if ( (data%problems%ChokeProblems%HydraulicChoke1PluggedPercent - data%State%Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then
  63. data%State%Choke%DeltaPlug1Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke1PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke1Plug
  64. data%State%Choke%Plug1TimeCounter = 0
  65. !write(*,*) 'DeltaPlug1Percent, Present_HydraulicChoke1Plug = ' ,DeltaPlug1Percent , Present_HydraulicChoke1Plug
  66. endif
  67. data%State%Choke%Plug1TimeCounter= data%State%Choke%Plug1TimeCounter + 1
  68. data%State%Choke%HydraulicChoke1PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke1PluggedPercent
  69. if (data%State%Choke%Plug1TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800
  70. 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
  71. endif
  72. !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug
  73. ENDIF
  74. IF (data%State%CHOOKE(2)%PlugMalf == 1) THEN
  75. data%State%Choke%Present_HydraulicChoke2Plug= data%State%Choke%Present_HydraulicChoke2Plug * data%State%CHOOKE(2)%PlugMalf
  76. ! integer: HydraulicChoke2PluggedPercent,HydraulicChoke2PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  77. ! real: Present_HydraulicChoke2Plug,DeltaPlug2Percent
  78. if ( (data%problems%ChokeProblems%HydraulicChoke2PluggedPercent - data%State%Choke%HydraulicChoke2PluggedPercent_Old) /= 0 ) then
  79. data%State%Choke%DeltaPlug2Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke2PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke2Plug
  80. data%State%Choke%Plug2TimeCounter = 0
  81. endif
  82. data%State%Choke%Plug2TimeCounter= data%State%Choke%Plug2TimeCounter + 1
  83. data%State%Choke%HydraulicChoke2PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke2PluggedPercent
  84. if (data%State%Choke%Plug2TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800
  85. 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
  86. endif
  87. ENDIF
  88. ! fully open area is 123/64 in^2 = 0.01334635 ft^2
  89. 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
  90. !write(*,*) 'data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke=' ,data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke
  91. 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
  92. 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
  93. 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
  94. !write(*,*) 'data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke=' ,data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke
  95. data%State%CHOOKE(1)%AreaChokeFinal= data%State%CHOOKE(1)%AreaChoke
  96. data%State%CHOOKE(2)%AreaChokeFinal= data%State%CHOOKE(2)%AreaChoke
  97. ! 144: ft^2 to in^2
  98. CALL SetHydraulicChock1(100 - nint((data%State%CHOOKE(1)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  99. CALL SetHydraulicChock2(100 - nint((data%State%CHOOKE(2)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  100. !write(*,*) 'data%State%CHOOKE(1)%PercentClose=' , data%State%CHOOKE(1)%PercentClose ! close percent 0 to 100
  101. !write(*,*) 'ChokePosition=' , ChokePosition ! close position 0 to 10 for display
  102. !write(*,*) 'data%State%CHOOKE(1)%AreaChokeFinal=' , data%State%CHOOKE(1)%AreaChokeFinal ! Open Area (in^2) with clearance
  103. !write(*,*) '(ChokeAreaFullyOpen/144.)=' , (ChokeAreaFullyOpen/144.)
  104. !write(*,*) 'valve value=' , 100 - nint((data%State%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= data%State%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