Simulation Core
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

248 строки
13 KiB

  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. ! if(print_log) 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. !if(print_log) 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. !if(print_log) print*, 'AnnalusFluids(',i,')%StartMd=', AnnalusFluids(i)%StartMd
  75. data%Equipments%DownHole%AnnalusFluids(i + offset)%EndMd = item%EndMd
  76. !if(print_log) print*, 'AnnalusFluids(',i,')%EndMd=', AnnalusFluids(i)%EndMd
  77. data%Equipments%DownHole%AnnalusFluids(i + offset)%Density = item%Density
  78. !if(print_log) print*, 'AnnalusFluids(',i,')%Density=', AnnalusFluids(i)%Density
  79. data%Equipments%DownHole%AnnalusFluids(i + offset)%MudType = item%MudType
  80. !if(print_log) print*, 'AnnalusFluids(',i,')%MudType=', AnnalusFluids(i)%MudType
  81. !if(print_log) print*, '----------------------------'
  82. end do
  83. !if(print_log) 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. ! if(print_log) 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. !if(print_log) print*, '============START-ST============'
  128. !if(print_log) 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. !if(print_log) print*, 'StringFluids(i)%StartMd=', StringFluids(i)%StartMd
  134. data%Equipments%DownHole%StringFluids(i + offset)%EndMd = item%EndMd
  135. !if(print_log) 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. !if(print_log) print*, '----------------------------'
  139. end do
  140. !!if(item%StartMd < 0) StringFluids(1)%StartMd = 0
  141. !!if(print_log) 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. !if(print_log) 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. !if(print_log) print*, 'item%ComponentType=', item%ComponentType
  188. !if(print_log) print*, 'String(i)%ComponentType=', String(i)%ComponentType
  189. !if(print_log) print*, 'String(i)%StartMd=', String(i)%StartMd
  190. !if(print_log) print*, 'String(i)%EndMd=', String(i)%EndMd
  191. !if(print_log) 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. !!if(print_log) 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