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.
 
 
 
 
 
 

237 lines
12 KiB

  1. subroutine Kick_Expansion ! is called in subroutine CirculationCodeSelect
  2. Use GeoElements_FluidModule
  3. USE CMudPropertiesVariables
  4. USE MudSystemVARIABLES
  5. use SimulationVariables !@@@
  6. use SimulationVariables
  7. use SimulationVariables !@
  8. !use CTanks !@use ConfigurationVariables, TripTankVolume2 => data%Equipments%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  9. USE sROP_Other_Variables
  10. USE sROP_Variables
  11. USE CReservoirVariables
  12. use KickVARIABLESModule
  13. implicit none
  14. real(8) ExpansionVolume
  15. !write(*,*) 'Kick Expansion'
  16. ExpansionVolume= GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - data%State%MudSystem%KickNumber + 1) * 7.48
  17. IF ( data%State%MudSystem%Kickexpansion_DueToMudLost ) ExpansionVolume = ((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline)
  18. !============================== kick zire mate bashad ==============================
  19. if (data%State%MudSystem%Op_KickLoc > 0 .and. data%State%MudSystem%Ann_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then
  20. !write(*,*) 'expansion (1)'
  21. data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc)+ ExpansionVolume
  22. !if (data%State%MUD(4)%Q > 0.) then
  23. !
  24. ! if (abs(ChokeLine_Density%Array(1)-Ann_Density%Last())< DensityMixTol) then
  25. ! ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1) + ExpansionVolume
  26. ! else
  27. ! call ChokeLine_Density%AddToFirst (Ann_Density%Last())
  28. ! call ChokeLine_MudDischarged_Volume%AddToFirst (ExpansionVolume) ! farz kardam ke hameye hajm ro ba yek density ezafe konim
  29. ! call ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0)
  30. ! call ChokeLine_Mud_Forehead_section%AddToFirst (1)
  31. ! call ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0)
  32. ! call ChokeLine_Mud_Backhead_section%AddToFirst (1)
  33. ! call ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  34. ! call ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  35. ! call ChokeLine_MudOrKick%AddToFirst (Ann_MudOrKick%Last())
  36. ! endif
  37. !
  38. !endif
  39. endif
  40. !========================================================================================
  41. !============================= foreheade dar fazaye annulus bashad ===========================
  42. ! agar kick be entehaye annulus reside bashe, expansion ra emaal nemikonim
  43. if (data%State%MudSystem%Ann_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then
  44. !write(*,*) 'expansion (2)'
  45. !if ( sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc)) + ExpansionVolume > sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ) then ! agar khast az mate rad kone
  46. ! ExpansionVolume= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc))
  47. !endif
  48. data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc)+ ExpansionVolume
  49. !if (data%State%MUD(4)%Q > 0.) then
  50. !
  51. !
  52. ! if (abs(ChokeLine_Density%Array(1)-Ann_Density%Last())< DensityMixTol) then
  53. ! ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1) + ExpansionVolume
  54. ! else
  55. ! call ChokeLine_Density%AddToFirst (Ann_Density%Last())
  56. ! call ChokeLine_MudDischarged_Volume%AddToFirst (ExpansionVolume) ! farz kardam ke hameye hajm ro ba yek density ezafe konim
  57. ! call ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0)
  58. ! call ChokeLine_Mud_Forehead_section%AddToFirst (1)
  59. ! call ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0)
  60. ! call ChokeLine_Mud_Backhead_section%AddToFirst (1)
  61. ! call ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  62. ! call ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  63. ! call ChokeLine_MudOrKick%AddToFirst (Ann_MudOrKick%Last())
  64. ! endif
  65. !
  66. !endif
  67. endif
  68. !========================================================================================
  69. !=============================== foreheade dar choke line bashad =============================
  70. if (data%State%MudSystem%ChokeLine_KickLoc > 0 .and. data%State%MudSystem%Ann_KickLoc==0) then
  71. data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc)+ ExpansionVolume
  72. endif
  73. !========================================================================================
  74. !write(*,*) 'Expansion======0'
  75. ! !do imud=1, Ann_MudDischarged_Volume%Length()
  76. ! ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud)
  77. ! !enddo
  78. !
  79. ! do imud=1, Op_MudDischarged_Volume%Length()
  80. ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud)
  81. ! enddo
  82. !write(*,*) '0======expansion'
  83. end subroutine Kick_Expansion
  84. subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect
  85. Use GeoElements_FluidModule
  86. USE CMudPropertiesVariables
  87. USE MudSystemVARIABLES
  88. use SimulationVariables !@@@
  89. use SimulationVariables
  90. use SimulationVariables !@
  91. !use CTanks !@use ConfigurationVariables, TripTankVolume2 => data%Equipments%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  92. USE sROP_Other_Variables
  93. USE sROP_Variables
  94. USE CReservoirVariables
  95. use KickVARIABLESModule
  96. USE CError
  97. implicit none
  98. integer jelement, jmud, jsection,ielement,i
  99. integer jopelement,jopmud,jopsection
  100. real(8) ContractionVolume
  101. !*********************************************************
  102. ! contraction is always with pump flow
  103. !*********************************************************
  104. !write(*,*) 'Kick Contraction'
  105. !data%State%MUD(2)%Q= data%Equipments%MPumps%Total_Pump_GPM
  106. data%State%MudSystem%StringFlowRate= data%State%MUD(2)%Q
  107. data%State%MudSystem%AnnulusFlowRate= data%State%MUD(2)%Q
  108. if (data%State%MudSystem%NewPipeFilling == 0) then
  109. data%State%MudSystem%StringFlowRate= 0.
  110. data%State%MudSystem%AnnulusFlowRate= 0.
  111. endif
  112. !if (WellHeadIsOpen) then
  113. ContractionVolume= - GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - data%State%MudSystem%KickNumber + 1) * 7.48
  114. !else
  115. !ContractionVolume = (data%State%MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe
  116. if (data%State%MudSystem%KickNumber == 1 .and. data%State%MudSystem%WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline + data%State%MudSystem%DeltaVolumePipe
  117. !endif
  118. !**************************************************************************************************************************************************************************
  119. ! pump mud is added in "pump&TripIn" code
  120. IF (data%State%MudSystem%Op_KickLoc > 0 .and. data%State%MudSystem%Ann_KickLoc == 0) then ! All of kick is under bit (iloc == 1)
  121. data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc) - ( ContractionVolume )
  122. ELSE IF (data%State%MudSystem%Op_KickLoc == 0 .AND. data%State%MudSystem%Ann_KickLoc > 0 .AND. data%State%MudSystem%ChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1)
  123. data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc) - ( ContractionVolume )
  124. ELSE IF (data%State%MudSystem%Ann_KickLoc == 0 .AND. data%State%MudSystem%ChokeLine_KickLoc > 0) THEN ! kick is in chokeline only
  125. data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc) - ( ContractionVolume )
  126. ELSE IF (data%State%MudSystem%Op_KickLoc > 0 .AND. data%State%MudSystem%Ann_KickLoc > 0) THEN ! Kick is around bit (iloc==2)
  127. if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) > ContractionVolume ) then
  128. data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) - ( ContractionVolume )
  129. elseif (data%State%MudSystem%Op_MudDischarged_Volume%Last() > ContractionVolume ) then
  130. data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_MudDischarged_Volume%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_MudDischarged_Volume%Length()) - ( ContractionVolume )
  131. else
  132. Call ErrorStop ('kick contraction error 1')
  133. endif
  134. ELSE IF (data%State%MudSystem%Ann_KickLoc > 0 .AND. data%State%MudSystem%ChokeLine_KickLoc > 0) THEN
  135. if (data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then
  136. data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1) = data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume )
  137. elseif (data%State%MudSystem%Ann_MudDischarged_Volume%Last() > ContractionVolume ) then
  138. data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length())= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length()) - ( ContractionVolume )
  139. else
  140. Call ErrorStop ('kick contraction error 2')
  141. endif
  142. endif
  143. ! write(*,*) 'contract======0'
  144. !! !do imud=1, Ann_MudDischarged_Volume%Length()
  145. !! ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud)
  146. !! !enddo
  147. !!
  148. ! do imud=1, Op_MudDischarged_Volume%Length()
  149. ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud)
  150. ! enddo
  151. !write(*,*) '0======contract'
  152. end subroutine Kick_Contraction