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.

Plot_Final_Mud_Elements.i90 25 KiB

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