Simulation Core
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

142 linhas
9.6 KiB

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