Simulation Core
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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