Simulation Core
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

275 řádky
17 KiB

  1. subroutine ElementsCreation ! is called in subroutine Fluid_Flow_Solver
  2. Use GeoElements_FluidModule
  3. USE CMudPropertiesVariables
  4. USE MudSystemVARIABLES
  5. USE Pumps_VARIABLES
  6. !USE CHOKEVARIABLES
  7. !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure
  8. !use CManifolds
  9. use CDrillWatchVariables
  10. !use CHOKEVARIABLES
  11. !use CChokeManifoldVariables
  12. ! !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  13. USE sROP_Other_Variables
  14. USE sROP_Variables
  15. Use KickVariables
  16. use CError
  17. implicit none
  18. integer jelement, jmud, jsection,ielement,i
  19. integer jopelement,jopmud,jopsection,iisection,isection,OpSection
  20. !===========================================================WELL============================================================
  21. !===========================================================WELL============================================================
  22. if(allocated(MudSystem%Xstart_PipeSection)) deallocate(MudSystem%Xstart_PipeSection)
  23. if(allocated(MudSystem%Xend_PipeSection)) deallocate(MudSystem%Xend_PipeSection)
  24. if(allocated(MudSystem%PipeSection_VolumeCapacity)) deallocate(MudSystem%PipeSection_VolumeCapacity)
  25. if(allocated(MudSystem%Area_PipeSectionFt)) deallocate(MudSystem%Area_PipeSectionFt)
  26. if(allocated(MudSystem%GeoType)) deallocate(MudSystem%GeoType)
  27. if(allocated(MudSystem%OD_PipeSectionInch)) deallocate(MudSystem%OD_PipeSectionInch)
  28. if(allocated(MudSystem%ID_PipeSectionInch)) deallocate(MudSystem%ID_PipeSectionInch)
  29. if(allocated(MudSystem%Angle_PipeSection)) deallocate(MudSystem%Angle_PipeSection)
  30. if(allocated(MudSystem%Xstart_OpSection)) deallocate(MudSystem%Xstart_OpSection)
  31. if(allocated(MudSystem%Xend_OpSection)) deallocate(MudSystem%Xend_OpSection)
  32. if(allocated(MudSystem%OpSection_VolumeCapacity)) deallocate(MudSystem%OpSection_VolumeCapacity)
  33. if(allocated(MudSystem%Area_OpSectionFt)) deallocate(MudSystem%Area_OpSectionFt)
  34. if(allocated(MudSystem%GeoTypeOp)) deallocate(MudSystem%GeoTypeOp)
  35. if(allocated(MudSystem%OD_OpSectionInch)) deallocate(MudSystem%OD_OpSectionInch)
  36. if(allocated(MudSystem%ID_OpSectionInch)) deallocate(MudSystem%ID_OpSectionInch)
  37. if(allocated(MudSystem%Angle_OpSection)) deallocate(MudSystem%Angle_OpSection)
  38. ALLOCATE (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts) &
  39. ,MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%Area_PipeSectionFt(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts), &
  40. MudSystem%GeoType(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%OD_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%ID_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts))
  41. ALLOCATE (MudSystem%Xstart_OpSection(F_Counts%BottomHoleIntervalCounts),MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) &
  42. ,MudSystem%OpSection_VolumeCapacity(F_Counts%BottomHoleIntervalCounts),MudSystem%Area_OpSectionFt(F_Counts%BottomHoleIntervalCounts), &
  43. MudSystem%GeoTypeOp(F_Counts%BottomHoleIntervalCounts),MudSystem%OD_OpSectionInch(F_Counts%BottomHoleIntervalCounts),MudSystem%ID_OpSectionInch(F_Counts%BottomHoleIntervalCounts))
  44. MudSystem%OpSection=0
  45. MudSystem%isection=0
  46. DO iisection=1, F_Counts%IntervalsTotalCounts
  47. IF (F_Interval(iisection)%GeoType == 1) THEN
  48. MudSystem%OpSection= MudSystem%OpSection+1
  49. MudSystem%Xstart_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%StartDepth)
  50. MudSystem%Xend_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%EndDepth)
  51. MudSystem%Area_OpSectionFt(MudSystem%OpSection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2)
  52. MudSystem%OD_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%OD)
  53. MudSystem%ID_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%ID) !REAL(F_Interval(iisection)%Volume)
  54. MudSystem%GeoTypeOp(MudSystem%OpSection)= F_Interval(iisection)%GeoType ! niaz nist ehtemalan
  55. !Angle_OpSection(OpSection)= F_Interval(iisection)%Angle
  56. !write(*,*) 'iisection=' , iisection
  57. !write(*,*) 'StartDepth=' , F_Interval(iisection)%StartDepth
  58. !write(*,*) 'EndDepth=' , F_Interval(iisection)%EndDepth
  59. !write(*,*) 'OD=' , F_Interval(iisection)%OD
  60. !write(*,*) 'ID=' , F_Interval(iisection)%ID
  61. ELSE
  62. MudSystem%isection= MudSystem%isection+1
  63. MudSystem%Xstart_PipeSection(MudSystem%isection)= (F_Interval(iisection)%StartDepth)
  64. !write(*,*) 'F_Interval(iisection)%StartDepth=' , F_Interval(iisection)%StartDepth
  65. MudSystem%Xend_PipeSection(MudSystem%isection)= (F_Interval(iisection)%EndDepth)
  66. !write(*,*) 'F_Interval(iisection)%EndDepth=' , F_Interval(iisection)%EndDepth
  67. MudSystem%OD_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%OD)
  68. MudSystem%Area_PipeSectionFt(MudSystem%isection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2)
  69. MudSystem%ID_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%ID)
  70. !PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948 !REAL(F_Interval(iisection)%Volume) ! (gal)
  71. MudSystem%GeoType(MudSystem%isection)= F_Interval(iisection)%GeoType
  72. !Angle_PipeSection(isection)= F_Interval(iisection)%Angle
  73. ENDIF
  74. ENDDO
  75. call MudSystem%Xstart_MudElement%Empty()
  76. call MudSystem%Xstart_MudElement%Add(MudSystem%Xstart_PipeSection(1))
  77. call MudSystem%Xstart_OpMudElement%Empty()
  78. call MudSystem%Xstart_OpMudElement%Add(MudSystem%Xstart_OpSection(1))
  79. call MudSystem%TVDstart_MudElement%Empty()
  80. call TVD_Calculator(MudSystem%Xstart_PipeSection(1),MudSystem%MudCircVerticalDepth)
  81. call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth)
  82. call MudSystem%TVDstart_OpMudElement%Empty()
  83. call TVD_Calculator(MudSystem%Xstart_OpSection(1),MudSystem%MudCircVerticalDepth)
  84. call MudSystem%TVDstart_OpMudElement%Add(MudSystem%MudCircVerticalDepth)
  85. MudSystem%NoPipeSections= MudSystem%isection ! sections in string and annulus(GeoType 0 & 2)
  86. DO OpSection= 1,F_Counts%BottomHoleIntervalCounts
  87. MudSystem%OpSection_VolumeCapacity(OpSection)= MudSystem%Area_OpSectionFt(OpSection)* ABS(MudSystem%Xend_OpSection(OpSection)-MudSystem%Xstart_OpSection(OpSection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume)
  88. ENDDO
  89. MudSystem%OpSection=OpSection
  90. DO isection= 1,MudSystem%NoPipeSections
  91. MudSystem%PipeSection_VolumeCapacity(isection)= MudSystem%Area_PipeSectionFt(isection)* ABS(MudSystem%Xend_PipeSection(isection)-MudSystem%Xstart_PipeSection(isection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) ! (gal)
  92. ENDDO
  93. MudSystem%isection = isection
  94. !types: Mud= 0 Kick=1
  95. !===========================================
  96. if (MudSystem%FirstMudSet==0) then
  97. call MudSystem%Hz_MudDischarged_Volume%AddToFirst(MudSystem%PipeSection_VolumeCapacity(1)) !startup initial
  98. call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1))
  99. call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1)
  100. call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(1))
  101. call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1)
  102. call MudSystem%Hz_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
  103. call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  104. call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  105. call MudSystem%Hz_MudOrKick%AddToFirst (0)
  106. call MudSystem%St_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts))) !startup initial
  107. call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2))
  108. call MudSystem%St_Mud_Backhead_section%AddToFirst (2)
  109. call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts))
  110. call MudSystem%St_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts)
  111. call MudSystem%St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
  112. call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  113. call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  114. call MudSystem%St_MudOrKick%AddToFirst (0)
  115. call MudSystem%Ann_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)))
  116. call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1))
  117. call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1)
  118. call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections))
  119. call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%NoPipeSections)
  120. call MudSystem%Ann_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
  121. call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  122. call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  123. call MudSystem%Ann_MudOrKick%AddToFirst (0)
  124. call MudSystem%Ann_CuttingMud%AddToFirst (0)
  125. MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)
  126. MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections))
  127. call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst(MudSystem%ChokeLine_VolumeCapacity)
  128. call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0)
  129. call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1)
  130. call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength)
  131. call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1)
  132. call MudSystem%ChokeLine_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
  133. call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  134. call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  135. call MudSystem%ChokeLine_MudOrKick%AddToFirst (0)
  136. call MudSystem%Op_MudDischarged_Volume%AddToFirst (sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)))
  137. call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_OpSection(1))
  138. call MudSystem%Op_Mud_Backhead_section%AddToFirst (1)
  139. call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts))
  140. call MudSystem%Op_Mud_Forehead_section%AddToFirst (F_Counts%BottomHoleIntervalCounts)
  141. call MudSystem%Op_Density%AddToFirst (MudProperties%ActiveDensity)
  142. call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  143. call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  144. call MudSystem%Op_MudOrKick%AddToFirst (0)
  145. !F_StringIntervalCountsOld= F_StringIntervalCounts ! is used for adding new pipe to string
  146. MudSystem%F_StringIntervalCounts_Old= F_Counts%StringIntervalCounts ! is used for adding new pipe to string
  147. MudSystem%FirstMudSet= 1
  148. endif
  149. !===================== Trip Detection ================
  150. !DeltaVolumeOp > 0 : Trip in
  151. !DeltaVolumeOp < 0 : Trip out
  152. MudSystem%DeltaVolumeOp= ((MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%OD_PipeSectionInch(F_Counts%StringIntervalCounts+1)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal ! D(in)
  153. MudSystem%DeltaVolumeOp = INT(MudSystem%DeltaVolumeOp * 100000.d0) / 100000.d0
  154. MudSystem%DeltaVolumePipe= ((MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%ID_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal
  155. MudSystem%DeltaVolumePipe = INT(MudSystem%DeltaVolumePipe * 100000.d0) / 100000.d0
  156. !DeltaVolumeAnnulusCapacity= ((Xend_PipeSection(F_Counts%StringIntervalCounts)-OldPosition))*Area_PipeSectionFt(NoPipeSections)* 7.48051948d0! ft^3 to gal
  157. DrillStringSpeed = (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition) / 0.1
  158. MudSystem%DeltaVolumeAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%OldAnnulusCapacity
  159. !write(*,*) 'DeltaVolumeAnnulusCapacity= ' , DeltaVolumeAnnulusCapacity
  160. !write(*,*) 'DeltaVolumePipe=' , DeltaVolumePipe
  161. !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
  162. !
  163. !
  164. !write(*,*) 'Bit here=' , Xend_PipeSection(F_Counts%StringIntervalCounts)
  165. MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections))
  166. MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)
  167. ! Needed for trip in or out:
  168. if (MudSystem%Hz_Mud_Backhead_X%Length() == 0) then
  169. CALL ErrorStop('Hz_Mud_Backhead_X Length is 0')
  170. endif
  171. MudSystem%Hz_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(1)
  172. MudSystem%Hz_Mud_Backhead_section%Array(1)= 1
  173. MudSystem%AddedElementsToString = F_Counts%StringIntervalCounts - MudSystem%F_StringIntervalCounts_Old
  174. MudSystem%St_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(2)
  175. MudSystem%St_Mud_Backhead_section%Array(1)= 2
  176. MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)
  177. MudSystem%Ann_Mud_Backhead_section%Array(1)= F_Counts%StringIntervalCounts+1
  178. MudSystem%Op_Mud_Backhead_X%Array(1)= MudSystem%Xstart_OpSection(1)
  179. MudSystem%Op_Mud_Backhead_section%Array(1)= 1
  180. MudSystem%ChokeLine_Mud_Backhead_X%Array(1)= 0.
  181. MudSystem%ChokeLine_Mud_Backhead_section%Array(1)= 1
  182. MudSystem%F_StringIntervalCounts_Old= F_Counts%StringIntervalCounts
  183. !write(*,*) 'Xstart_PipeSection(2)' , Xstart_PipeSection(2)
  184. !write(*,*) 'Xend_PipeSection(1)' , Xend_PipeSection(1)
  185. !===================================================
  186. !
  187. !DeltaWellCap= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) + sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - WellCapOld
  188. !WellCapOld= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) + sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts))
  189. !write(*,*) 'DeltaWellCap=' , DeltaWellCap
  190. !
  191. !
  192. !
  193. !DeltaAnnCap= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - AnnCapOld
  194. !AnnCapOld= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections))
  195. !write(*,*) 'DeltaAnnCap=' , DeltaAnnCap
  196. end subroutine ElementsCreation