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.
 
 
 
 
 
 

419 lines
25 KiB

  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/MudSystem/Plot_Final_Mud_Elements.f90"
  2. subroutine PlotFinalMudElements ! is called in subroutine CirculationCodeSelect
  3. Use GeoElements_FluidModule
  4. USE CMudPropertiesVariables
  5. USE MudSystemVARIABLES
  6. use SimulationVariables !@@@
  7. use SimulationVariables
  8. Use TD_StringConnectionData
  9. USE CHOKEVARIABLES
  10. !use ConfigurationVariables !@
  11. !use CDataDisplayConsole
  12. !@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure
  13. !use CManifolds
  14. use SimulationVariables !@
  15. USE CHOKEVARIABLES
  16. !use ConfigurationVariables !@
  17. !use CChokeManifoldVariables
  18. use SimulationVariables
  19. !use CTanks
  20. !@use ConfigurationVariables, TripTankVolume2 => data%Equipments%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  21. USE sROP_Other_Variables
  22. USE sROP_Variables
  23. use KickVARIABLESModule
  24. use OperationScenariosModule
  25. use UTUBEVARSModule
  26. use DownHoleModule
  27. use CLog1
  28. Use CError
  29. Use , intrinsic :: IEEE_Arithmetic
  30. implicit none
  31. integer jelement, jmud, jsection,ielement,i
  32. integer jopelement,jopmud,jopsection
  33. character(len=120) :: temp1, temp2
  34. if (data%Equipments%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
  35. write(*,*) 'well cap=' , sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts))
  36. data%State%MudSystem%DeltaWellCap= sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) - data%State%MudSystem%WellCapOld
  37. data%State%MudSystem%WellCapOld= sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts))
  38. write(*,*) 'cap_reset,DeltaWellCap=' , data%State%MudSystem%DeltaWellCap
  39. endif
  40. !========================ANNULUS END=================
  41. if ((data%State%MudSystem%Ann_Mud_Forehead_X%Last() - data%Configuration%BopStack%AboveAnnularHeight) > 0.8 .or. data%State%MudSystem%Ann_Density%Last()==0.0) then ! for Line (BellNippleToWell-NonFullWell)
  42. data%State%MudSystem%WellisNOTFull= .true.
  43. else
  44. data%State%MudSystem%WellisNOTFull= .false.
  45. endif
  46. !WRITE(*,*) 'Ann_Mud_Forehead_X%Last() , KillHeight', Ann_Mud_Forehead_X%Last() , KillHeight
  47. if ((data%State%MudSystem%Ann_Mud_Forehead_X%Last() - data%Configuration%BopStack%KillHeight)>0.8 .or. data%State%MudSystem%Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26)
  48. data%State%MudSystem%ChokeLineNOTFull= .true.
  49. else
  50. data%State%MudSystem%ChokeLineNOTFull= .false.
  51. endif
  52. !=========================================================
  53. jmud= 1
  54. jsection= 1
  55. jelement= 0 ! number of final mud elements
  56. call data%State%MudSystem%Xend_MudElement%Empty()
  57. call data%State%MudSystem%TVDend_MudElement%Empty()
  58. call data%State%MudSystem%Density_MudElement%Empty()
  59. call data%State%MudSystem%MudGeoType%Empty()
  60. call data%State%MudSystem%PipeID_MudElement%Empty()
  61. call data%State%MudSystem%PipeOD_MudElement%Empty()
  62. !call Angle_MudElement%Empty()
  63. call data%State%MudSystem%MudType_MudElement%Empty()
  64. DO WHILE(jmud <= data%State%MudSystem%Hz_Mud_Forehead_X%Length() .and. jsection<=1)
  65. jelement= jelement+1
  66. data%State%MudSystem%TrueMinValue= min(data%State%MudSystem%Hz_Mud_Forehead_X%Array(jmud), data%State%MudSystem%Xend_PipeSection(jsection))
  67. call data%State%MudSystem%Xend_MudElement%Add(data%State%MudSystem%TrueMinValue)
  68. call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth)
  69. call data%State%MudSystem%TVDend_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth)
  70. call data%State%MudSystem%Density_MudElement%Add(data%State%MudSystem%Hz_Density%Array(jmud))
  71. call data%State%MudSystem%PipeID_MudElement%Add(data%State%MudSystem%ID_PipeSectionInch(jsection))
  72. call data%State%MudSystem%PipeOD_MudElement%Add(data%State%MudSystem%OD_PipeSectionInch(jsection))
  73. !call Angle_MudElement%Add(Angle_PipeSection(jsection))
  74. call data%State%MudSystem%MudType_MudElement%Add(data%State%MudSystem%Hz_MudOrKick%Array(jmud))
  75. if (data%State%MudSystem%Xend_MudElement%Array(jelement)== data%State%MudSystem%Hz_Mud_Forehead_X%Array(jmud)) then
  76. jmud= jmud+1
  77. else
  78. jsection= jsection+1
  79. endif
  80. ENDDO
  81. data%State%MudSystem%NoHorizontalMudElements= jelement
  82. jmud= 1
  83. jsection= 2
  84. DO WHILE(jmud <= data%State%MudSystem%St_Mud_Forehead_X%Length() .and. jsection<=data%State%F_Counts%StringIntervalCounts)
  85. jelement= jelement+1
  86. data%State%MudSystem%TrueMinValue= min(data%State%MudSystem%St_Mud_Forehead_X%Array(jmud), data%State%MudSystem%Xend_PipeSection(jsection))
  87. call data%State%MudSystem%Xend_MudElement%Add(data%State%MudSystem%TrueMinValue)
  88. call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth)
  89. call data%State%MudSystem%TVDend_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth)
  90. call data%State%MudSystem%Density_MudElement%Add(data%State%MudSystem%St_Density%Array(jmud))
  91. call data%State%MudSystem%PipeID_MudElement%Add(data%State%MudSystem%ID_PipeSectionInch(jsection))
  92. call data%State%MudSystem%PipeOD_MudElement%Add(data%State%MudSystem%OD_PipeSectionInch(jsection))
  93. !call Angle_MudElement%Add(Angle_PipeSection(jsection))
  94. call data%State%MudSystem%MudType_MudElement%Add(data%State%MudSystem%St_MudOrKick%Array(jmud))
  95. if (data%State%MudSystem%Xend_MudElement%Array(jelement)== data%State%MudSystem%St_Mud_Forehead_X%Array(jmud)) then
  96. jmud= jmud+1
  97. else
  98. jsection= jsection+1
  99. endif
  100. ENDDO
  101. data%State%MudSystem%NoStringMudElements= jelement- data%State%MudSystem%NoHorizontalMudElements
  102. jmud= 1
  103. jsection= data%State%F_Counts%StringIntervalCounts+1
  104. DO WHILE(jmud<= data%State%MudSystem%Ann_Mud_Forehead_X%Length() .and. jsection<=data%State%MudSystem%NoPipeSections)
  105. jelement= jelement+1
  106. data%State%MudSystem%TrueMinValue= max(data%State%MudSystem%Ann_Mud_Forehead_X%Array(jmud), data%State%MudSystem%Xend_PipeSection(jsection))
  107. call data%State%MudSystem%Xend_MudElement%Add(data%State%MudSystem%TrueMinValue)
  108. call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth)
  109. call data%State%MudSystem%TVDend_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth)
  110. call data%State%MudSystem%Density_MudElement%Add(data%State%MudSystem%Ann_Density%Array(jmud))
  111. call data%State%MudSystem%PipeID_MudElement%Add(data%State%MudSystem%ID_PipeSectionInch(jsection))
  112. call data%State%MudSystem%PipeOD_MudElement%Add(data%State%MudSystem%OD_PipeSectionInch(jsection))
  113. !call Angle_MudElement%Add(Angle_PipeSection(jsection))
  114. call data%State%MudSystem%MudType_MudElement%Add(data%State%MudSystem%Ann_MudOrKick%Array(jmud))
  115. if (data%State%MudSystem%Xend_MudElement%Array(jelement)== data%State%MudSystem%Ann_Mud_Forehead_X%Array(jmud)) then
  116. jmud= jmud+1
  117. else
  118. jsection= jsection+1
  119. endif
  120. ENDDO
  121. do i= 2, data%State%MudSystem%Xend_MudElement%Length()
  122. if ( i== data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+1) then
  123. call data%State%MudSystem%Xstart_MudElement%Add (data%State%MudSystem%Ann_Mud_Backhead_X%Array(1)) ! start of annulus
  124. call TVD_Calculator(data%State%MudSystem%Ann_Mud_Backhead_X%Array(1),data%State%MudSystem%MudCircVerticalDepth)
  125. call data%State%MudSystem%TVDstart_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth)
  126. elseif ( i== data%State%MudSystem%NoHorizontalMudElements+1 ) then
  127. call data%State%MudSystem%Xstart_MudElement%Add (data%State%MudSystem%St_Mud_Backhead_X%Array(1)) ! start of stirng
  128. call TVD_Calculator(data%State%MudSystem%St_Mud_Backhead_X%Array(1),data%State%MudSystem%MudCircVerticalDepth)
  129. call data%State%MudSystem%TVDstart_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth)
  130. else
  131. call data%State%MudSystem%Xstart_MudElement%Add(data%State%MudSystem%Xend_MudElement%Array(i-1)) ! normal calculation
  132. call data%State%MudSystem%TVDstart_MudElement%Add(data%State%MudSystem%TVDend_MudElement%Array(i-1)) ! normal calculation
  133. endif
  134. enddo
  135. data%State%MudSystem%NoCasingMudElements = jelement- data%State%MudSystem%NoStringMudElements- data%State%MudSystem%NoHorizontalMudElements
  136. !=========================For Torque and Drag========================
  137. if (allocated(data%State%MudSystem%TDXstart_MudElementArray)) deallocate(data%State%MudSystem%TDXstart_MudElementArray)
  138. allocate(data%State%MudSystem%TDXstart_MudElementArray(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+data%State%MudSystem%NoCasingMudElements))
  139. if (allocated(data%State%MudSystem%TDXend_MudElementArray)) deallocate(data%State%MudSystem%TDXend_MudElementArray)
  140. allocate(data%State%MudSystem%TDXend_MudElementArray(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+data%State%MudSystem%NoCasingMudElements))
  141. if (allocated(data%State%MudSystem%TDDensity_MudElementArray)) deallocate(data%State%MudSystem%TDDensity_MudElementArray)
  142. allocate(data%State%MudSystem%TDDensity_MudElementArray(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+data%State%MudSystem%NoCasingMudElements))
  143. data%State%MudSystem%TDNoHorizontalMudElements= data%State%MudSystem%NoHorizontalMudElements
  144. data%State%MudSystem%TDNoStringMudElements= data%State%MudSystem%NoStringMudElements
  145. data%State%MudSystem%TDNoCasingMudElements= data%State%MudSystem%NoCasingMudElements
  146. data%State%MudSystem%TDXstart_MudElementArray(:) = data%State%MudSystem%Xstart_MudElement%Array(:)
  147. data%State%MudSystem%TDXend_MudElementArray(:) = data%State%MudSystem%Xend_MudElement%Array(:)
  148. data%State%MudSystem%TDDensity_MudElementArray(:) = data%State%MudSystem%Density_MudElement%Array(:)
  149. !=====================================================================
  150. !do i=NoHorizontalMudElements+1, NoHorizontalMudElements+NoStringMudElements ! 2-string elements
  151. ! write(*,333) 'STRING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i)
  152. !enddo
  153. !================================================================
  154. ! Open Hole Mud Elements
  155. jopmud= 1
  156. jopsection= 1
  157. jopelement= 0 ! number of final mud elements
  158. call data%State%MudSystem%Xend_OpMudElement%Empty()
  159. call data%State%MudSystem%TVDend_OpMudElement%Empty()
  160. call data%State%MudSystem%Density_OpMudElement%Empty()
  161. call data%State%MudSystem%PipeID_OpMudElement%Empty()
  162. call data%State%MudSystem%PipeOD_OpMudElement%Empty()
  163. !call Angle_OpMudElement%Empty()
  164. call data%State%MudSystem%MudTypeOp_MudElement%Empty()
  165. DO WHILE(jopmud<= data%State%MudSystem%Op_Mud_Forehead_X%Length() .and. jopsection<=data%State%F_Counts%BottomHoleIntervalCounts)
  166. jopelement= jopelement+1
  167. data%State%MudSystem%TrueMinValue= max(data%State%MudSystem%Op_Mud_Forehead_X%Array(jopmud), data%State%MudSystem%Xend_OpSection(jopsection))
  168. call data%State%MudSystem%Xend_OpMudElement%Add(data%State%MudSystem%TrueMinValue)
  169. call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth)
  170. call data%State%MudSystem%TVDend_OpMudElement%Add(data%State%MudSystem%MudCircVerticalDepth)
  171. call data%State%MudSystem%Density_OpMudElement%Add(data%State%MudSystem%Op_Density%Array(jopmud))
  172. call data%State%MudSystem%PipeID_OpMudElement%Add(data%State%MudSystem%ID_OpSectionInch(jopsection))
  173. call data%State%MudSystem%PipeOD_OpMudElement%Add(data%State%MudSystem%OD_OpSectionInch(jopsection))
  174. !call Angle_MudElement%Add(Angle_PipeSection(jopsection))
  175. call data%State%MudSystem%MudTypeOp_MudElement%Add(data%State%MudSystem%Op_MudOrKick%Array(jopmud))
  176. if (data%State%MudSystem%Xend_OpMudElement%Array(jopelement)== data%State%MudSystem%Op_Mud_Forehead_X%Array(jopmud)) then
  177. jopmud= jopmud+1
  178. else
  179. jopsection= jopsection+1
  180. endif
  181. ENDDO
  182. do i= 2, data%State%MudSystem%Xend_OpMudElement%Length()
  183. call data%State%MudSystem%Xstart_OpMudElement%Add(data%State%MudSystem%Xend_OpMudElement%Array(i-1))
  184. call data%State%MudSystem%TVDstart_OpMudElement%Add(data%State%MudSystem%TVDend_OpMudElement%Array(i-1))
  185. enddo
  186. data%State%MudSystem%NoBottomHoleMudElements = jopelement
  187. !================================================================
  188. if(allocated(data%State%MudSystem%StringMudElement)) deallocate(data%State%MudSystem%StringMudElement)
  189. allocate(data%State%MudSystem%StringMudElement(data%State%MudSystem%NoStringMudElements))
  190. if(allocated(data%State%MudSystem%CasingMudElement)) deallocate(data%State%MudSystem%CasingMudElement)
  191. allocate(data%State%MudSystem%CasingMudElement(data%State%MudSystem%NoCasingMudElements+data%State%MudSystem%NoBottomHoleMudElements))
  192. data%State%MudSystem%istring=0
  193. data%State%MudSystem%icasing=0
  194. data%State%MudSystem%BitMudDensity= data%State%MudSystem%Density_MudElement%Array(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements) ! (for ROP module)
  195. !================================================================
  196. !============================ UTUBE =============================
  197. !IF (UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadIsOpen) THEN
  198. IF (data%State%MudSystem%UtubePossibility== .true. .and. data%State%TD_StConn%FluidStringConnectionMode==0 .and. data%State%MudSystem%WellHeadIsOpen .AND. KickVARIABLES%NoGasPocket == 0) THEN
  199. CALL WellPressureDataTransfer
  200. !WRITE (*,*) ' U-Tube Done 1'
  201. CALL Utube
  202. !WRITE (*,*) ' U-Tube Done 2'
  203. if (UTUBEVARS%QUtubeInput> 0.0) call Utube1_and_TripIn
  204. if (UTUBEVARS%QUtubeOutput> 0.0) call Utube2_and_TripIn
  205. END IF
  206. !========================== UTUBE- end =========================
  207. ! do imud=1, st_MudDischarged_Volume%Length()
  208. ! write(*,*) 'st-plot:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud)
  209. !enddo
  210. !==================== Display ========================
  211. !do i=1, St_MudOrKick%Length()
  212. ! write(*,555) i,'St_Volume(i), type=' ,St_MudDischarged_Volume%Array(i),St_MudOrKick%Array(i)
  213. !
  214. ! IF (IEEE_Is_NaN(St_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in St Volume-Plot')
  215. ! IF (St_MudDischarged_Volume%Array(i)<0.) call ErrorStop('St Volume <0' , St_MudDischarged_Volume%Array(i))
  216. !enddo
  217. IF (ANY(IEEE_Is_NaN(data%State%MudSystem%Op_MudDischarged_Volume%Array(:))) .OR. ANY(data%State%MudSystem%Op_MudDischarged_Volume%Array(:) <= 0.0)) THEN
  218. do i = 1 , data%State%MudSystem%Op_MudOrKick%Length()
  219. write(*,555) i,'Op_Volume(i), type=' ,data%State%MudSystem%Op_MudDischarged_Volume%Array(i) , data%State%MudSystem%Op_MudOrKick%Array(i) , data%State%MudSystem%Op_Density%Array(i)
  220. end do
  221. call ErrorStop('NaN in Op Volume-Plot or Op Volume <=0')
  222. END IF
  223. IF (ANY(IEEE_Is_NaN(data%State%MudSystem%Ann_MudDischarged_Volume%Array(:))) .OR. ANY(data%State%MudSystem%Ann_MudDischarged_Volume%Array(:) <= 0.0)) THEN
  224. do i = 1 , data%State%MudSystem%Ann_MudOrKick%Length()
  225. write(*,555) i,'Ann_Volume(i), type=' ,data%State%MudSystem%Ann_MudDischarged_Volume%Array(i) , data%State%MudSystem%Ann_MudOrKick%Array(i) , data%State%MudSystem%Ann_Density%Array(i)
  226. end do
  227. call ErrorStop('NaN in Ann Volume-Plot or Ann Volume <=0')
  228. END IF
  229. !do i=1, Ann_MudOrKick%Length()
  230. ! !write(*,555) i,'Ann_Volume(i), type=' ,Ann_MudDischarged_Volume%Array(i),Ann_MudOrKick%Array(i),Ann_Density%Array(i)
  231. !
  232. ! IF (IEEE_Is_NaN(Ann_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in Ann Volume-Plot')
  233. ! IF (Ann_MudDischarged_Volume%Array(i)<=0.) call ErrorStop('Ann Volume <=0' , Ann_MudDischarged_Volume%Array(i))
  234. !enddo
  235. 555 FORMAT(I3,5X,A42,(f12.5),5X,I3,5X,(f12.5))
  236. data%State%MudSystem%NoStringMudElementsForPlot= data%State%MudSystem%NoStringMudElements
  237. ! 1-Horizontal Mud Elements are not shown
  238. !write(*,333) 'Horiz:', 1,'Xstart\=', Xstart_MudElement%Array(1), 'Xend=' , Xend_MudElement%Array(1), 'Density=' , Density_MudElement%Array(1), 'MudType=' , MudType_MudElement%Array(1)
  239. do i=data%State%MudSystem%NoHorizontalMudElements+1, data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements ! 2-string elements
  240. if (data%State%MudSystem%Xend_MudElement%Array(i) <= 0.0) then
  241. data%State%MudSystem%NoStringMudElementsForPlot= data%State%MudSystem%NoStringMudElementsForPlot-1
  242. cycle
  243. endif
  244. data%State%MudSystem%istring= data%State%MudSystem%istring+1
  245. data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%StartMd = data%State%MudSystem%Xstart_MudElement%Array(i)
  246. data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%EndMd = data%State%MudSystem%Xend_MudElement%Array(i)
  247. !StringMudElement(istring)%Id = PipeID_MudElement%Array(i)
  248. !StringMudElement(istring)%Od = PipeOD_MudElement%Array(i)
  249. data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%Density = data%State%MudSystem%Density_MudElement%Array(i)
  250. if (data%State%MudSystem%MudType_MudElement%Array(i) == 104) then
  251. data%State%MudSystem%MudType_MudElement%Array(i)= 4 ! air
  252. elseif (data%State%MudSystem%MudType_MudElement%Array(i) > 0 .and. data%State%MudSystem%MudType_MudElement%Array(i) < 100) then ! all kicks
  253. data%State%MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick
  254. endif
  255. data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%MudType = data%State%MudSystem%MudType_MudElement%Array(i)
  256. !write(*,333) 'STRING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i)
  257. enddo
  258. do i=data%State%MudSystem%Xend_MudElement%Length(), data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+1 , -1 ! 3-casing elements
  259. data%State%MudSystem%icasing= data%State%MudSystem%icasing+1
  260. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%StartMd = data%State%MudSystem%Xend_MudElement%Array(i)
  261. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%EndMd = data%State%MudSystem%Xstart_MudElement%Array(i)
  262. !CasingMudElement(icasing)%Id = PipeID_MudElement%Array(i)
  263. !CasingMudElement(icasing)%Od = PipeOD_MudElement%Array(i)
  264. !write(*,333) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i)
  265. !call Log_1(temp1)
  266. !write(*,444) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i)
  267. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%Density = data%State%MudSystem%Density_MudElement%Array(i)
  268. if (data%State%MudSystem%MudType_MudElement%Array(i) == 104) then
  269. data%State%MudSystem%MudType_MudElement%Array(i)= 4 ! air
  270. elseif (data%State%MudSystem%MudType_MudElement%Array(i) > 0 .and. data%State%MudSystem%MudType_MudElement%Array(i) < 100) then
  271. data%State%MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick
  272. endif
  273. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%MudType = data%State%MudSystem%MudType_MudElement%Array(i)
  274. enddo
  275. do i= data%State%MudSystem%NoBottomHoleMudElements, 1 , -1 ! 4-open hole elements
  276. data%State%MudSystem%icasing= data%State%MudSystem%icasing+1
  277. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%StartMd = data%State%MudSystem%Xend_OpMudElement%Array(i)
  278. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%EndMd = data%State%MudSystem%Xstart_OpMudElement%Array(i)
  279. !CasingMudElement(icasing)%Id = PipeID_OpMudElement%Array(i)
  280. !CasingMudElement(icasing)%Od = PipeOD_OpMudElement%Array(i)
  281. !write(*,333) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'Density=' , Density_OpMudElement%Array(i), 'MudType=' , MudTypeOp_MudElement%Array(i)
  282. !call Log_1(temp2)
  283. !write(*,444) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i)
  284. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%Density = data%State%MudSystem%Density_OpMudElement%Array(i)
  285. if (data%State%MudSystem%MudTypeOp_MudElement%Array(i) == 104) then
  286. data%State%MudSystem%MudTypeOp_MudElement%Array(i)= 4 ! air
  287. elseif (data%State%MudSystem%MudTypeOp_MudElement%Array(i) > 0 .and. data%State%MudSystem%MudTypeOp_MudElement%Array(i) < 100) then
  288. data%State%MudSystem%MudTypeOp_MudElement%Array(i)= 1 ! gas kick
  289. endif
  290. data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%MudType = data%State%MudSystem%MudTypeOp_MudElement%Array(i)
  291. enddo
  292. 333 FORMAT(A10,I3,5X,A8,(f12.5),5X,A8,(f12.5),5X,A8,(f12.5),5X,A8,I3)
  293. 444 FORMAT(A10,I2,5X,A8,(f12.3),5X,A8,(f12.3),5X,A8,(f12.3),5X,A8,(f12.3))
  294. ! shomare gozari be tartib HZ mud, ST mud, Casing
  295. ! shomare gzari OpenHole jodagane ast az 1
  296. call SetStringFluids(data%State%MudSystem%NoStringMudElementsForPlot, data%State%MudSystem%StringMudElement) !for data display in string
  297. call SetAnnalusFluids(data%State%MudSystem%NoCasingMudElements+data%State%MudSystem%NoBottomHoleMudElements, data%State%MudSystem%CasingMudElement) !for data display in casing
  298. !===========================================================================================================================
  299. !===========================================================================================================================
  300. end subroutine PlotFinalMudElements