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.
 
 
 
 
 
 

250 satır
11 KiB

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