Simulation Core
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

DownHole.f90 12 KiB

1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. module DownHoleModule
  2. use SimulationVariables
  3. contains
  4. subroutine MudPropertiesToJson(parent)
  5. type(json_value),pointer :: parent
  6. type(json_core) :: json
  7. type(json_value),pointer :: p
  8. ! 1. create new node
  9. call json%create_object(p,'DownHole')
  10. ! 2. add member of data type to new node
  11. ! call json%add(p,"AnnalusFluidsCount",data%Equipments%DownHole%AnnalusFluidsCount)
  12. ! call json%add(p,"StringFluidsCount",data%Equipments%DownHole%StringFluidsCount)
  13. ! call json%add(p,"AnnalusFluids(:)",data%Equipments%DownHole%AnnalusFluids(:))
  14. ! call json%add(p,"StringFluids(:)",data%Equipments%DownHole%StringFluids(:))
  15. ! call json%add(p,"StringCount",data%Equipments%DownHole%StringCount)
  16. ! call json%add(p,"String(:)",data%Equipments%DownHole%String(:))
  17. ! call json%add(p,"BopElements(:)",data%Equipments%DownHole%BopElements(:))
  18. call json%add(p,"DrillPipePressure",data%Equipments%DownHole%DrillPipePressure)
  19. call json%add(p,"CasingPressure",data%Equipments%DownHole%CasingPressure)
  20. call json%add(p,"ShoePressure",data%Equipments%DownHole%ShoePressure)
  21. call json%add(p,"BottomHolePressure",data%Equipments%DownHole%BottomHolePressure)
  22. call json%add(p,"FormationPressure",data%Equipments%DownHole%FormationPressure)
  23. call json%add(p,"InfluxRate",data%Equipments%DownHole%InfluxRate)
  24. call json%add(p,"KickVolume",data%Equipments%DownHole%KickVolume)
  25. call json%add(p,"SecondKickVolume",data%Equipments%DownHole%SecondKickVolume)
  26. call json%add(p,"PermeabilityExposedHeight",data%Equipments%DownHole%PermeabilityExposedHeight)
  27. ! 3. add new node to parent
  28. call json%add(parent,p)
  29. end subroutine
  30. subroutine DownHoleFromJson(parent)
  31. use json_module,IK =>json_ik
  32. type(json_value),pointer :: parent
  33. type(json_core) :: json
  34. type(json_value),pointer :: p,pitems,pitem,pval,pbit
  35. call json%get(parent,'DownHole',p)
  36. call json%get(p,'AnnDrillMud',pval)
  37. call json%get(pval,data%Equipments%DownHole%AnnDrillMud)
  38. call json%get(p,'AnnCirculateMud',pval)
  39. call json%get(pval,data%Equipments%DownHole%AnnCirculateMud)
  40. end subroutine
  41. subroutine SetAnnalusFluids(count, array)
  42. implicit none
  43. integer, intent(in) :: count
  44. integer :: i, offset
  45. type(CFluid), intent(inout), target :: array(count)
  46. type(CFluid), pointer :: item
  47. data%Equipments%DownHole%AnnalusFluidsCount = count
  48. print*, 'AnnalusFluidsCount = ', count
  49. if(size(data%Equipments%DownHole%AnnalusFluids) > 0) then
  50. deallocate(data%Equipments%DownHole%AnnalusFluids)
  51. end if
  52. if(count > 0) then
  53. offset = 0;
  54. item => array(1)
  55. if(item%StartMd > 0) then
  56. data%Equipments%DownHole%AnnalusFluidsCount = data%Equipments%DownHole%AnnalusFluidsCount + 1
  57. offset = 1;
  58. allocate(data%Equipments%DownHole%AnnalusFluids(data%Equipments%DownHole%AnnalusFluidsCount))
  59. data%Equipments%DownHole%AnnalusFluids(1)%StartMd = 0
  60. data%Equipments%DownHole%AnnalusFluids(1)%EndMd = item%StartMd
  61. data%Equipments%DownHole%AnnalusFluids(1)%Density = 0
  62. data%Equipments%DownHole%AnnalusFluids(1)%MudType = FLUID_NO_MUD
  63. endif
  64. !if(associated(AnnalusMudCountPtr)) then
  65. ! call AnnalusMudCountPtr(AnnalusFluidsCount)
  66. !end if
  67. if(.not.allocated(data%Equipments%DownHole%AnnalusFluids))allocate(data%Equipments%DownHole%AnnalusFluids(data%Equipments%DownHole%AnnalusFluidsCount))
  68. !print*, '============START-AN============'
  69. if(item%StartMd < 0) data%Equipments%DownHole%AnnalusFluids(1)%StartMd = 0
  70. do i = 1, count
  71. item => array(i)
  72. data%Equipments%DownHole%AnnalusFluids(i + offset)%StartMd = item%StartMd
  73. if(i==1) data%Equipments%DownHole%AnnalusFluids(i)%StartMd = 0
  74. !print*, 'AnnalusFluids(',i,')%StartMd=', AnnalusFluids(i)%StartMd
  75. data%Equipments%DownHole%AnnalusFluids(i + offset)%EndMd = item%EndMd
  76. !print*, 'AnnalusFluids(',i,')%EndMd=', AnnalusFluids(i)%EndMd
  77. data%Equipments%DownHole%AnnalusFluids(i + offset)%Density = item%Density
  78. !print*, 'AnnalusFluids(',i,')%Density=', AnnalusFluids(i)%Density
  79. data%Equipments%DownHole%AnnalusFluids(i + offset)%MudType = item%MudType
  80. !print*, 'AnnalusFluids(',i,')%MudType=', AnnalusFluids(i)%MudType
  81. !print*, '----------------------------'
  82. end do
  83. !print*, '============END-AN============'
  84. !if(associated(AnnalusMudArrayPtr)) then
  85. ! !AnnalusFluidsPtr => AnnalusFluids
  86. ! call AnnalusMudArrayPtr(AnnalusFluids)
  87. !end if
  88. end if
  89. end subroutine SetAnnalusFluids
  90. subroutine SetStringFluids(count, array)
  91. implicit none
  92. integer, intent(in) :: count
  93. integer :: i, offset !, startArr
  94. type(CFluid), intent(inout), target :: array(count)
  95. type(CFluid), pointer :: item
  96. data%Equipments%DownHole%StringFluidsCount = count
  97. print*, 'StringFluidsCount = ', count
  98. if(size(data%Equipments%DownHole%StringFluids) > 0) then
  99. deallocate(data%Equipments%DownHole%StringFluids)
  100. end if
  101. !startArr = 1
  102. if(count > 0) then
  103. offset = 0;
  104. item => array(1)
  105. !
  106. !if(item%StartMd <= 0 .and. item%EndMd <= 0) then
  107. ! StringFluidsCount = StringFluidsCount - 1
  108. ! count = count - 1
  109. ! offset = offset + 1
  110. ! startArr = startArr + 1
  111. !endif
  112. !
  113. !if(count <= 0) return
  114. if(item%StartMd > 0) then
  115. data%Equipments%DownHole%StringFluidsCount = data%Equipments%DownHole%StringFluidsCount + 1
  116. offset = offset + 1
  117. allocate(data%Equipments%DownHole%StringFluids(data%Equipments%DownHole%StringFluidsCount))
  118. data%Equipments%DownHole%StringFluids(1)%StartMd = 0
  119. data%Equipments%DownHole%StringFluids(1)%EndMd = item%StartMd
  120. data%Equipments%DownHole%StringFluids(1)%Density = 0
  121. data%Equipments%DownHole%StringFluids(1)%MudType = FLUID_NO_MUD
  122. endif
  123. !if(associated(StringMudCountPtr)) then
  124. ! call StringMudCountPtr(count)
  125. !end if
  126. if(.not.allocated(data%Equipments%DownHole%StringFluids))allocate(data%Equipments%DownHole%StringFluids(data%Equipments%DownHole%StringFluidsCount))
  127. !print*, '============START-ST============'
  128. !print*, 'count=', count
  129. do i = 1, count
  130. item => array(i)
  131. data%Equipments%DownHole%StringFluids(i + offset)%StartMd = item%StartMd
  132. if(i==1) data%Equipments%DownHole%StringFluids(i)%StartMd = 0
  133. !print*, 'StringFluids(i)%StartMd=', StringFluids(i)%StartMd
  134. data%Equipments%DownHole%StringFluids(i + offset)%EndMd = item%EndMd
  135. !print*, 'StringFluids(i)%EndMd=', StringFluids(i)%EndMd
  136. data%Equipments%DownHole%StringFluids(i + offset)%Density = item%Density
  137. data%Equipments%DownHole%StringFluids(i + offset)%MudType = item%MudType
  138. !print*, '----------------------------'
  139. end do
  140. !!if(item%StartMd < 0) StringFluids(1)%StartMd = 0
  141. !!print*, '============END-ST============'
  142. !if(associated(StringMudArrayPtr)) then
  143. ! call StringMudArrayPtr(StringFluids)
  144. !end if
  145. end if
  146. end subroutine SetStringFluids
  147. subroutine SetString(count, array)
  148. use CLog3
  149. implicit none
  150. integer, intent(in) :: count
  151. integer :: i !, j
  152. type(CStringComponents), intent(inout), target :: array(count)
  153. type(CStringComponents), pointer :: item
  154. data%Equipments%DownHole%StringCount = count
  155. if(size(data%Equipments%DownHole%String) > 0) then
  156. deallocate(data%Equipments%DownHole%String)
  157. end if
  158. if(count > 0) then
  159. !if(associated(StringComponentCountPtr)) then
  160. ! call StringComponentCountPtr(count)
  161. !end if
  162. allocate(data%Equipments%DownHole%String(count))
  163. !j = 0
  164. !print*, '============CMP-ST============'
  165. !call Log_3( '============CMP-ST============')
  166. !do i = count, 1, -1
  167. do i = 1, count
  168. item => array(i)
  169. !String(i)%Length = item%Length
  170. !String(i)%TopDepth = item%TopDepth
  171. !String(i)%DownDepth = item%DownDepth
  172. !String(i)%Od = item%Od
  173. !String(i)%Id = item%Id
  174. data%Equipments%DownHole%String(i)%ComponentType= item%ComponentType
  175. !j = j + 1
  176. data%Equipments%DownHole%String(i)%StartMd = item%TopDepth
  177. data%Equipments%DownHole%String(i)%EndMd = item%DownDepth
  178. data%Equipments%DownHole%String(i)%ComponentType=0
  179. !if(item%ComponentType > 4 ) then
  180. ! String(i)%ComponentType=0
  181. ! String(i)%StartMd = 0
  182. !endif
  183. if(item%ComponentType == 3) data%Equipments%DownHole%String(i)%ComponentType=0
  184. if(item%ComponentType == 4) data%Equipments%DownHole%String(i)%ComponentType=1
  185. if(item%ComponentType == 2) data%Equipments%DownHole%String(i)%ComponentType=2
  186. if(item%ComponentType == 1) data%Equipments%DownHole%String(i)%ComponentType=3
  187. !print*, 'item%ComponentType=', item%ComponentType
  188. !print*, 'String(i)%ComponentType=', String(i)%ComponentType
  189. !print*, 'String(i)%StartMd=', String(i)%StartMd
  190. !print*, 'String(i)%EndMd=', String(i)%EndMd
  191. !print*, '----------------------------'
  192. !call Log_3( 'item%ComponentType=', item%ComponentType)
  193. !call Log_3( 'String(i)%ComponentType=', String(i)%ComponentType)
  194. !call Log_3( 'String(i)%StartMd=', String(i)%StartMd)
  195. !call Log_3( 'String(i)%EndMd=', String(i)%EndMd)
  196. !call Log_3( '----------------------------')
  197. end do
  198. !!print*, '============CMP-ST============'
  199. !!call Log_3( '============CMP-ST============')
  200. !if(associated(StringComponentArrayPtr)) then
  201. ! call StringComponentArrayPtr(String)
  202. !end if
  203. end if
  204. end subroutine SetString
  205. subroutine SetBopElements(array)
  206. use CLog4
  207. implicit none
  208. integer, parameter :: count = 4
  209. integer :: i = 1 !, j
  210. type(CBopElement), intent(inout), target :: array(count)
  211. type(CBopElement), pointer :: item
  212. if(size(data%Equipments%DownHole%BopElements) > 0) deallocate(data%Equipments%DownHole%BopElements)
  213. allocate(data%Equipments%DownHole%BopElements(count))
  214. do i = 1, count
  215. item => array(i)
  216. !call Log_4('item%ElementStart', item%ElementStart)
  217. !call Log_4('item%ElementEnd', item%ElementEnd)
  218. !call Log_4('item%ElementType', item%ElementType)
  219. !call Log_4('=====================================================')
  220. data%Equipments%DownHole%BopElements(i)%ElementStart = item%ElementStart
  221. data%Equipments%DownHole%BopElements(i)%ElementEnd = item%ElementEnd
  222. data%Equipments%DownHole%BopElements(i)%ElementType = item%ElementType
  223. end do
  224. !if(associated(BopElementsPtr)) call BopElementsPtr(BopElements)
  225. end subroutine SetBopElements
  226. end module DownHoleModule