Simulation Core
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

DownHole.f90 9.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. module DownHoleModule
  2. use SimulationVariables
  3. contains
  4. subroutine SetAnnalusFluids(count, array)
  5. implicit none
  6. integer, intent(in) :: count
  7. integer :: i, offset
  8. type(CFluid), intent(inout), target :: array(count)
  9. type(CFluid), pointer :: item
  10. DownHole%AnnalusFluidsCount = count
  11. print*, 'AnnalusFluidsCount = ', count
  12. if(size(DownHole%AnnalusFluids) > 0) then
  13. deallocate(DownHole%AnnalusFluids)
  14. end if
  15. if(count > 0) then
  16. offset = 0;
  17. item => array(1)
  18. if(item%StartMd > 0) then
  19. DownHole%AnnalusFluidsCount = DownHole%AnnalusFluidsCount + 1
  20. offset = 1;
  21. allocate(DownHole%AnnalusFluids(DownHole%AnnalusFluidsCount))
  22. DownHole%AnnalusFluids(1)%StartMd = 0
  23. DownHole%AnnalusFluids(1)%EndMd = item%StartMd
  24. DownHole%AnnalusFluids(1)%Density = 0
  25. DownHole%AnnalusFluids(1)%MudType = FLUID_NO_MUD
  26. endif
  27. !if(associated(AnnalusMudCountPtr)) then
  28. ! call AnnalusMudCountPtr(AnnalusFluidsCount)
  29. !end if
  30. if(.not.allocated(DownHole%AnnalusFluids))allocate(DownHole%AnnalusFluids(DownHole%AnnalusFluidsCount))
  31. !print*, '============START-AN============'
  32. if(item%StartMd < 0) DownHole%AnnalusFluids(1)%StartMd = 0
  33. do i = 1, count
  34. item => array(i)
  35. DownHole%AnnalusFluids(i + offset)%StartMd = item%StartMd
  36. if(i==1) DownHole%AnnalusFluids(i)%StartMd = 0
  37. !print*, 'AnnalusFluids(',i,')%StartMd=', AnnalusFluids(i)%StartMd
  38. DownHole%AnnalusFluids(i + offset)%EndMd = item%EndMd
  39. !print*, 'AnnalusFluids(',i,')%EndMd=', AnnalusFluids(i)%EndMd
  40. DownHole%AnnalusFluids(i + offset)%Density = item%Density
  41. !print*, 'AnnalusFluids(',i,')%Density=', AnnalusFluids(i)%Density
  42. DownHole%AnnalusFluids(i + offset)%MudType = item%MudType
  43. !print*, 'AnnalusFluids(',i,')%MudType=', AnnalusFluids(i)%MudType
  44. !print*, '----------------------------'
  45. end do
  46. !print*, '============END-AN============'
  47. !if(associated(AnnalusMudArrayPtr)) then
  48. ! !AnnalusFluidsPtr => AnnalusFluids
  49. ! call AnnalusMudArrayPtr(AnnalusFluids)
  50. !end if
  51. end if
  52. end subroutine SetAnnalusFluids
  53. subroutine SetStringFluids(count, array)
  54. implicit none
  55. integer, intent(in) :: count
  56. integer :: i, offset !, startArr
  57. type(CFluid), intent(inout), target :: array(count)
  58. type(CFluid), pointer :: item
  59. DownHole%StringFluidsCount = count
  60. print*, 'StringFluidsCount = ', count
  61. if(size(DownHole%StringFluids) > 0) then
  62. deallocate(DownHole%StringFluids)
  63. end if
  64. !startArr = 1
  65. if(count > 0) then
  66. offset = 0;
  67. item => array(1)
  68. !
  69. !if(item%StartMd <= 0 .and. item%EndMd <= 0) then
  70. ! StringFluidsCount = StringFluidsCount - 1
  71. ! count = count - 1
  72. ! offset = offset + 1
  73. ! startArr = startArr + 1
  74. !endif
  75. !
  76. !if(count <= 0) return
  77. if(item%StartMd > 0) then
  78. DownHole%StringFluidsCount = DownHole%StringFluidsCount + 1
  79. offset = offset + 1
  80. allocate(DownHole%StringFluids(DownHole%StringFluidsCount))
  81. DownHole%StringFluids(1)%StartMd = 0
  82. DownHole%StringFluids(1)%EndMd = item%StartMd
  83. DownHole%StringFluids(1)%Density = 0
  84. DownHole%StringFluids(1)%MudType = FLUID_NO_MUD
  85. endif
  86. !if(associated(StringMudCountPtr)) then
  87. ! call StringMudCountPtr(count)
  88. !end if
  89. if(.not.allocated(DownHole%StringFluids))allocate(DownHole%StringFluids(DownHole%StringFluidsCount))
  90. !print*, '============START-ST============'
  91. !print*, 'count=', count
  92. do i = 1, count
  93. item => array(i)
  94. DownHole%StringFluids(i + offset)%StartMd = item%StartMd
  95. if(i==1) DownHole%StringFluids(i)%StartMd = 0
  96. !print*, 'StringFluids(i)%StartMd=', StringFluids(i)%StartMd
  97. DownHole%StringFluids(i + offset)%EndMd = item%EndMd
  98. !print*, 'StringFluids(i)%EndMd=', StringFluids(i)%EndMd
  99. DownHole%StringFluids(i + offset)%Density = item%Density
  100. DownHole%StringFluids(i + offset)%MudType = item%MudType
  101. !print*, '----------------------------'
  102. end do
  103. !!if(item%StartMd < 0) StringFluids(1)%StartMd = 0
  104. !!print*, '============END-ST============'
  105. !if(associated(StringMudArrayPtr)) then
  106. ! call StringMudArrayPtr(StringFluids)
  107. !end if
  108. end if
  109. end subroutine SetStringFluids
  110. subroutine SetString(count, array)
  111. use CLog3
  112. implicit none
  113. integer, intent(in) :: count
  114. integer :: i !, j
  115. type(CStringComponents), intent(inout), target :: array(count)
  116. type(CStringComponents), pointer :: item
  117. DownHole%StringCount = count
  118. if(size(DownHole%String) > 0) then
  119. deallocate(DownHole%String)
  120. end if
  121. if(count > 0) then
  122. !if(associated(StringComponentCountPtr)) then
  123. ! call StringComponentCountPtr(count)
  124. !end if
  125. allocate(DownHole%String(count))
  126. !j = 0
  127. !print*, '============CMP-ST============'
  128. !call Log_3( '============CMP-ST============')
  129. !do i = count, 1, -1
  130. do i = 1, count
  131. item => array(i)
  132. !String(i)%Length = item%Length
  133. !String(i)%TopDepth = item%TopDepth
  134. !String(i)%DownDepth = item%DownDepth
  135. !String(i)%Od = item%Od
  136. !String(i)%Id = item%Id
  137. DownHole%String(i)%ComponentType= item%ComponentType
  138. !j = j + 1
  139. DownHole%String(i)%StartMd = item%TopDepth
  140. DownHole%String(i)%EndMd = item%DownDepth
  141. DownHole%String(i)%ComponentType=0
  142. !if(item%ComponentType > 4 ) then
  143. ! String(i)%ComponentType=0
  144. ! String(i)%StartMd = 0
  145. !endif
  146. if(item%ComponentType == 3) DownHole%String(i)%ComponentType=0
  147. if(item%ComponentType == 4) DownHole%String(i)%ComponentType=1
  148. if(item%ComponentType == 2) DownHole%String(i)%ComponentType=2
  149. if(item%ComponentType == 1) DownHole%String(i)%ComponentType=3
  150. !print*, 'item%ComponentType=', item%ComponentType
  151. !print*, 'String(i)%ComponentType=', String(i)%ComponentType
  152. !print*, 'String(i)%StartMd=', String(i)%StartMd
  153. !print*, 'String(i)%EndMd=', String(i)%EndMd
  154. !print*, '----------------------------'
  155. !call Log_3( 'item%ComponentType=', item%ComponentType)
  156. !call Log_3( 'String(i)%ComponentType=', String(i)%ComponentType)
  157. !call Log_3( 'String(i)%StartMd=', String(i)%StartMd)
  158. !call Log_3( 'String(i)%EndMd=', String(i)%EndMd)
  159. !call Log_3( '----------------------------')
  160. end do
  161. !!print*, '============CMP-ST============'
  162. !!call Log_3( '============CMP-ST============')
  163. !if(associated(StringComponentArrayPtr)) then
  164. ! call StringComponentArrayPtr(String)
  165. !end if
  166. end if
  167. end subroutine SetString
  168. subroutine SetBopElements(array)
  169. use CLog4
  170. implicit none
  171. integer, parameter :: count = 4
  172. integer :: i = 1 !, j
  173. type(CBopElement), intent(inout), target :: array(count)
  174. type(CBopElement), pointer :: item
  175. if(size(DownHole%BopElements) > 0) deallocate(DownHole%BopElements)
  176. allocate(DownHole%BopElements(count))
  177. do i = 1, count
  178. item => array(i)
  179. !call Log_4('item%ElementStart', item%ElementStart)
  180. !call Log_4('item%ElementEnd', item%ElementEnd)
  181. !call Log_4('item%ElementType', item%ElementType)
  182. !call Log_4('=====================================================')
  183. DownHole%BopElements(i)%ElementStart = item%ElementStart
  184. DownHole%BopElements(i)%ElementEnd = item%ElementEnd
  185. DownHole%BopElements(i)%ElementType = item%ElementType
  186. end do
  187. !if(associated(BopElementsPtr)) call BopElementsPtr(BopElements)
  188. end subroutine SetBopElements
  189. end module DownHoleModule