Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

515 lines
20 KiB

  1. subroutine MeshGeneration_FluidModule
  2. Use TD_DrillStemComponents
  3. Use TD_WellElements
  4. Use TD_WellGeometry
  5. Use TD_StringConnectionData
  6. Use GeoElements_FluidModule
  7. Use CPumpsVariables
  8. Use CStringConfigurationVariables
  9. Use CBopStackVariables
  10. !Use Drawworks_VARIABLES , only: Drawworks
  11. implicit none
  12. Integer :: ii , jj , semijj , kk , k , m , s
  13. Integer :: ElementsCount , StringConfigCount
  14. REAL(8) :: mm , nn , dl , StartAngle , EndAngle
  15. REAL(8) :: A(30) !?????????10
  16. REAL(8) :: TD_ElementLength
  17. A = 0.d0
  18. A(1) = BopStackSpecification%AboveAnnularHeight ! WellHead[ft]
  19. jj = 1
  20. !====================================================
  21. ! Mesh Generation of DrillStem Components
  22. !====================================================
  23. !TD_String%StringConfigurationCount = StringConfigurationCount !???????????
  24. StringConfigCount = TD_String%StringConfigurationCount
  25. if (allocated(F_String)) Deallocate(F_String)
  26. if (TD_DrillStem(1)%ComponentType==0) then
  27. Allocate (F_String(StringConfigCount-1))
  28. else
  29. Allocate (F_String(StringConfigCount))
  30. end if
  31. if (TD_DrillStem(1)%ComponentType==0) then
  32. ElementsCount = 1
  33. Do ii=1,(StringConfigCount-1)
  34. F_String(ii)%ID = TD_DrillStem(ii+1)%Id*12.d0 ![inch]
  35. F_String(ii)%OD = TD_DrillStem(ii+1)%Od*12.d0 ![inch]
  36. F_String(ii)%FirstElement = ElementsCount+1
  37. F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii+1)%Numbs-1)
  38. F_String(ii)%ElType = TD_DrillStem(ii+1)%ComponentType
  39. ElementsCount = F_String(ii)%LastElement
  40. End Do
  41. StringConfigCount = StringConfigCount-1
  42. else
  43. ElementsCount = 0
  44. Do ii=1,StringConfigCount
  45. F_String(ii)%ID = TD_DrillStem(ii)%Id*12.d0 ![inch]
  46. F_String(ii)%OD = TD_DrillStem(ii)%Od*12.d0 ![inch]
  47. F_String(ii)%FirstElement = ElementsCount+1
  48. F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii)%Numbs-1)
  49. F_String(ii)%ElType = TD_DrillStem(ii)%ComponentType
  50. ElementsCount = F_String(ii)%LastElement
  51. End Do
  52. end if
  53. Do ii=1,StringConfigCount
  54. F_String(ii)%TopDepth = TD_DrillStems(F_String(ii)%LastElement)%TopDepthIni ![ft]
  55. F_String(ii)%DownDepth = TD_DrillStems(F_String(ii)%FirstElement)%DownDepthIni ![ft]
  56. if (F_String(ii)%DownDepth>A(1)) then
  57. jj = jj+1
  58. A(jj) = F_String(ii)%DownDepth
  59. end if
  60. End Do
  61. !=========> Removed Volume Calculation in DrillStem
  62. TD_ElementLength = F_String(StringConfigCount)%DownDepth-F_String(StringConfigCount)%TopDepth
  63. if ( StringConfigCount==TD_Vol%PreCount ) then
  64. if ( TD_Vol%PreElementLength>TD_ElementLength ) then
  65. TD_Vol%RemoveVolume = (TD_Vol%PreElementLength-TD_ElementLength)*((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0) ![ft^3]
  66. else
  67. TD_Vol%RemoveVolume = 0.d0
  68. end if
  69. else if ( StringConfigCount<TD_Vol%PreCount ) then
  70. TD_Vol%RemoveVolume = TD_Vol%PreElementVolume
  71. else
  72. TD_Vol%RemoveVolume = 0.d0
  73. end if
  74. TD_Vol%PreCount = StringConfigCount
  75. TD_Vol%PreElementVolume = TD_ElementLength*(((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0)) ![ft^3]
  76. TD_Vol%PreElementLength = TD_ElementLength
  77. !print*, 'TD_Vol%RemoveVolume=' , TD_Vol%RemoveVolume
  78. !====================================================
  79. ! Mesh Generation of Annulus Components
  80. !====================================================
  81. if (TD_Casing(1)%Length>0.) then
  82. jj = jj+1
  83. A(jj) = TD_Casing(1)%DownDepth
  84. OD_Annulus(4)%StartMD = TD_Casing(1)%DownDepth ![ft]
  85. OD_Annulus(4)%EndMD = TD_Casing(1)%TopDepth ![ft]
  86. OD_Annulus(4)%ODValue = TD_Casing(1)%Id*12.d0 ![inch]
  87. !else
  88. ! OD_Annulus(4)%StartMD = 0. !????????????????????
  89. ! OD_Annulus(4)%EndMD = OD_Annulus(4)%StartMD !????????????????????
  90. ! OD_Annulus(4)%ODValue = TD_Casing(1)%Id !????????????????????
  91. end if
  92. if (TD_Liner(1)%Length>0.) then
  93. jj = jj+1
  94. A(jj) = TD_Liner(1)%DownDepth
  95. OD_Annulus(3)%StartMD = TD_Liner(1)%DownDepth ![ft]
  96. OD_Annulus(3)%EndMD = TD_Liner(1)%TopDepth ![ft]
  97. OD_Annulus(3)%ODValue = TD_Liner(1)%Id*12.d0 ![inch]
  98. else
  99. OD_Annulus(3)%StartMD = TD_Casing(1)%DownDepth !????????????????????
  100. OD_Annulus(3)%EndMD = OD_Annulus(3)%StartMD !????????????????????
  101. OD_Annulus(3)%ODValue = OD_Annulus(4)%ODValue !????????????????????
  102. end if
  103. if (TD_OpenHole(1)%Length>0.) then
  104. !jj = jj+1
  105. !A(jj) = TD_OpenHole(1)%DownDepth
  106. OD_Annulus(2)%StartMD = TD_OpenHole(1)%DownDepth ![ft]
  107. OD_Annulus(2)%EndMD = TD_OpenHole(1)%TopDepth ![ft]
  108. OD_Annulus(2)%ODValue = TD_OpenHole(1)%Id*12.d0 ![inch]
  109. do ii = 1,TD_WellGeneral%WellIntervalsCount-1
  110. if ( TD_WellGeo(ii)%DownDepth>TD_OpenHole(1)%TopDepth ) then
  111. jj = jj+1
  112. A(jj) = TD_WellGeo(ii)%DownDepth
  113. end if
  114. end do
  115. else
  116. OD_Annulus(2)%StartMD = TD_Liner(1)%DownDepth !??????????????
  117. OD_Annulus(2)%EndMD = OD_Annulus(2)%StartMD !??????????????
  118. OD_Annulus(2)%ODValue = OD_Annulus(3)%ODValue !??????????????
  119. end if
  120. if (TD_ROPHole(1)%Length>0.) then
  121. jj = jj+1
  122. A(jj) = TD_ROPHole(1)%DownDepth
  123. OD_Annulus(1)%StartMD = TD_ROPHole(1)%DownDepth ![ft]
  124. OD_Annulus(1)%EndMD = TD_ROPHole(1)%TopDepth ![ft]
  125. OD_Annulus(1)%ODValue = TD_ROPHole(1)%Id*12.d0 ![inch]
  126. else
  127. OD_Annulus(1)%StartMD = TD_OpenHole(1)%DownDepth !??????????????
  128. OD_Annulus(1)%EndMD = OD_Annulus(1)%StartMD !??????????????
  129. OD_Annulus(1)%ODValue = OD_Annulus(2)%ODValue !??????????????
  130. end if
  131. !print*, 'A(jj)2=' , A
  132. !====================================================
  133. ! Mesh Generation of Well
  134. !====================================================
  135. !Do ii=2,TD_WellGeneral%WellIntervalsCount-1
  136. ! jj = jj+1
  137. ! A(jj) = TD_WellGeo(ii)%TopDepth
  138. !End Do
  139. !print*, 'A(jj)3=' , A
  140. !print*, 'A=' , A
  141. !print*, 'jj=' , jj
  142. semijj = jj
  143. !print*, 'semijj=' , semijj
  144. Do ii=1,jj
  145. do kk = 1,jj
  146. if ( A(ii)==A(KK) .and. ii/=kk .and. A(KK)/=0. ) then !A(KK)/=0. ?????????????????
  147. !print*, 'indoA=' , semijj , ii , kk , A(KK) , A(ii)
  148. A(kk) = 0.d0
  149. semijj = semijj-1
  150. !print*, 'indoA2=' , semijj , ii , kk , A(KK) , A(ii)
  151. end if
  152. end do
  153. End Do
  154. !print*, 'semijj2=' , semijj
  155. jj = semijj
  156. !print*, 'jj2=' , jj
  157. !print*, 'AA=' , A
  158. if (allocated(TDGeo%MD)) Deallocate(TDGeo%MD)
  159. Allocate (TDGeo%MD(jj))
  160. TDGeo%MD = 0.0d0
  161. Do ii=1,jj
  162. TDGeo%MD(ii)=A(1)
  163. do kk = 2,jj
  164. if (A(KK)>TDGeo%MD(ii)) then
  165. TDGeo%MD(ii) = A(kk)
  166. k=kk
  167. end if
  168. end do
  169. !!TDGeo%MD(ii) = MAXVAL(A)
  170. !!kk = MAXLOC(A)
  171. !!A(kk) = 0.0d0
  172. A(k) = 0.0d0
  173. End Do
  174. !====================================================
  175. ! Geometrical Intervals Configuration (for fluid module)
  176. !====================================================
  177. if (allocated(F_Interval)) Deallocate(F_Interval)
  178. Allocate (F_Interval(jj-1+StringConfigCount+1))
  179. !F_Interval = 0.0d0
  180. F_Counts%IntervalsTotalCounts = jj-1+StringConfigCount+1
  181. !=========> String Intervals Configuration
  182. ! pump output
  183. ii = 1
  184. F_Interval(ii)%Number = ii
  185. F_Interval(ii)%GeoType = 0
  186. F_Interval(ii)%EndDepth = F_String(StringConfigCount)%TopDepth
  187. F_Interval(ii)%StartDepth = F_String(StringConfigCount)%TopDepth-265.d0
  188. F_Interval(ii)%ID = 0.0d0
  189. F_Interval(ii)%OD = dmax1(PumpsSpecification%MudPump1Output,PumpsSpecification%MudPump2Output) !???????????
  190. F_Interval(ii)%HydDiameter = F_Interval(ii)%OD ![inch]
  191. F_Interval(ii)%Volume = ((pi*((F_Interval(ii)%OD/12.d0)**2))/4.d0) &
  192. *(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
  193. Do ii=2,StringConfigCount+1
  194. F_Interval(ii)%Number = ii
  195. F_Interval(ii)%GeoType = 0
  196. F_Interval(ii)%EndDepth = F_String(StringConfigCount+1-ii+1)%DownDepth
  197. F_Interval(ii)%StartDepth = F_String(StringConfigCount+1-ii+1)%TopDepth
  198. F_Interval(ii)%ID = 0.0d0
  199. F_Interval(ii)%OD = F_String(StringConfigCount+1-ii+1)%ID
  200. F_Interval(ii)%HydDiameter = F_Interval(ii)%OD
  201. F_Interval(ii)%Volume = ((pi*((F_Interval(ii)%OD/12.d0)**2))/4.d0) &
  202. *(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
  203. End Do
  204. F_Counts%StringIntervalCounts = StringConfigCount+1
  205. !if (F_String(1)%ElType==0) then !bit
  206. ! !F_Interval(StringConfigCount)%Number = ii
  207. ! F_Interval(StringConfigCount)%EndDepth = F_String(1)%DownDepth
  208. ! F_Interval(StringConfigCount)%StartDepth = F_String(1)%TopDepth
  209. ! F_Interval(StringConfigCount)%ID = 0.0d0
  210. ! F_Interval(StringConfigCount)%OD = F_String(1)%OD
  211. ! F_Interval(StringConfigCount)%HydDiameter = F_Interval(StringConfigCount)%OD
  212. ! F_Interval(StringConfigCount)%Volume = ((pi*((F_Interval(StringConfigCount)%OD/12.)**2))/4.)*(F_Interval(StringConfigCount)%EndDepth-F_Interval(StringConfigCount)%StartDepth)*7.48051948
  213. !end if
  214. !=========> Annulus Intervals Configuration
  215. F_Counts%BottomHoleIntervalCounts = 0
  216. F_Counts%AnnulusIntervalCounts = 0
  217. Do ii=(StringConfigCount+2),(jj-1+StringConfigCount+1)
  218. F_Interval(ii)%Number = ii
  219. F_Interval(ii)%StartDepth = TDGeo%MD(ii-StringConfigCount-1)
  220. F_Interval(ii)%EndDepth = TDGeo%MD(ii+1-StringConfigCount-1)
  221. if (F_Interval(ii)%EndDepth>=F_Interval(StringConfigCount+1)%EndDepth) then
  222. F_Interval(ii)%GeoType = 1
  223. F_Counts%BottomHoleIntervalCounts = F_Counts%BottomHoleIntervalCounts+1
  224. else
  225. F_Interval(ii)%GeoType = 2
  226. F_Counts%AnnulusIntervalCounts = F_Counts%AnnulusIntervalCounts+1
  227. end if
  228. End Do
  229. !====================================================
  230. ! Diameter Calculation of Annulus Intervals
  231. !====================================================
  232. !=========> OD
  233. m = 1
  234. Do ii = (StringConfigCount+2),F_Counts%IntervalsTotalCounts
  235. do kk = m,4
  236. if (F_Interval(ii)%StartDepth<=OD_Annulus(kk)%StartMD .and. F_Interval(ii)%EndDepth>=OD_Annulus(kk)%EndMD) then
  237. F_Interval(ii)%OD = OD_Annulus(kk)%ODValue
  238. m = kk
  239. exit
  240. end if
  241. end do
  242. End Do
  243. !=========> ID
  244. m = 1
  245. Do ii = (StringConfigCount+2),F_Counts%IntervalsTotalCounts
  246. do kk = m,StringConfigCount
  247. if (F_Interval(ii)%StartDepth<=F_String(kk)%DownDepth .and. F_Interval(ii)%EndDepth>=F_String(kk)%TopDepth) then
  248. F_Interval(ii)%ID = F_String(kk)%OD
  249. m = kk
  250. exit
  251. else
  252. F_Interval(ii)%ID = 0.0d0
  253. end if
  254. end do
  255. F_Interval(ii)%HydDiameter = F_Interval(ii)%OD-F_Interval(ii)%ID
  256. F_Interval(ii)%Volume = ((pi*(((F_Interval(ii)%OD/12.d0)**2)-((F_Interval(ii)%ID/12.d0)**2)))/4.d0) &
  257. *abs(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
  258. End Do
  259. !print*, 'StringConfigCount=' , StringConfigCount
  260. !print*, 'F_Counts%IntervalsTotalCounts=' , F_Counts%IntervalsTotalCounts
  261. !print*, 'F_Counts%StringIntervalCounts=' , F_Counts%StringIntervalCounts
  262. !print*, 'F_Counts%BottomHoleIntervalCounts=' , F_Counts%BottomHoleIntervalCounts
  263. !print*, 'F_Counts%AnnulusIntervalCounts=' , F_Counts%AnnulusIntervalCounts
  264. !Do ii=1,(F_Counts%IntervalsTotalCounts)
  265. ! print*, 'Number/' , 'StartDepth/' , 'EndDepth/'
  266. ! print*, 'ID/' , 'OD/' , 'GeoType/'
  267. ! print*, 'HydDiameter/' , 'Volume/'
  268. ! print*, F_Interval(ii)%Number , F_Interval(ii)%StartDepth , F_Interval(ii)%EndDepth
  269. ! print*, F_Interval(ii)%ID , F_Interval(ii)%OD , F_Interval(ii)%GeoType
  270. ! print*, F_Interval(ii)%HydDiameter , F_Interval(ii)%Volume
  271. !End Do
  272. !====================================================
  273. ! TVD Calculation of Geo Intervals
  274. !====================================================
  275. !=========> Out of Well Intervals
  276. F_Interval(1)%StartTVD = 0.0d0 !??????????????
  277. F_Interval(1)%EndTVD = -TD_StConn%ConnectionHeight
  278. F_Interval(1)%StartAngle = 0.d0 !???????????????????????
  279. F_Interval(1)%EndAngle = 0.d0 !???????????????????????
  280. F_Counts%OutOfWellIntervalCounts = 1
  281. Do ii= 2 , StringConfigCount+1
  282. if ( F_Interval(ii)%StartDepth<=0.d0 ) then
  283. F_Interval(ii)%StartTVD = F_Interval(ii)%StartDepth
  284. F_Interval(ii)%StartAngle = 0.0d0
  285. end if
  286. if ( F_Interval(ii)%EndDepth<=0.d0 ) then
  287. F_Interval(ii)%EndTVD = F_Interval(ii)%EndDepth
  288. F_Interval(ii)%EndAngle = 0.0d0
  289. F_Counts%OutOfWellIntervalCounts = F_Counts%OutOfWellIntervalCounts+1
  290. end if
  291. End Do
  292. !=========>
  293. if (allocated(TDGeo%TVD)) Deallocate(TDGeo%TVD)
  294. Allocate (TDGeo%TVD(jj))
  295. if (allocated(TDGeo%Angle)) Deallocate(TDGeo%Angle)
  296. Allocate (TDGeo%Angle(jj))
  297. TDGeo%TVD(1) = TD_WellGeneral%WellTotalVerticalLength !?????
  298. !print*, 'TD_WellGeneral%WellTotalVerticalLength=' ,TD_WellGeneral%WellTotalVerticalLength
  299. TDGeo%TVD(jj) = BopStackSpecification%AboveAnnularHeight ! WellHead[ft] !0.d0 ????????????????
  300. k = 1
  301. mm = 0.d0
  302. nn = 0.d0
  303. EndAngle = TD_WellGeo(1)%StartAngle !???????????????
  304. TDGeo%Angle(jj) = EndAngle
  305. Do ii = jj-1,1,-1 !???1or2
  306. do kk = k, TD_WellGeneral%WellIntervalsCount
  307. StartAngle = EndAngle
  308. if ( TDGeo%MD(ii)>TD_WellGeo(kk)%TopDepth ) then
  309. if ( TDGeo%MD(ii)>TD_WellGeo(kk)%DownDepth ) then
  310. dl = TD_WellGeo(kk)%DownDepth-nn ![ft]
  311. nn = TD_WellGeo(kk)%DownDepth
  312. if ( TD_WellGeo(kk)%HoleType==0 ) then
  313. EndAngle = StartAngle
  314. !print*, 'StartAngle1=' ,ii , kk, StartAngle
  315. !print*, 'EndAngle1=' ,ii , kk, EndAngle
  316. TDGeo%TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) ![ft]
  317. TDGeo%Angle(ii) = EndAngle
  318. !print*, 'TDGeo%TVD(ii)1=' ,ii , kk, TDGeo%TVD(ii)
  319. else if ( TD_WellGeo(kk)%HoleType==1 ) then
  320. EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !?????????????????
  321. !print*, 'StartAngle2=' ,ii , kk, StartAngle
  322. !print*, 'EndAngle2=' ,ii , kk, EndAngle
  323. TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle)))
  324. !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  325. TDGeo%Angle(ii) = EndAngle
  326. !print*, 'TDGeo%TVD(ii)2=' , ii , kk, TDGeo%TVD(ii)
  327. else if ( TD_WellGeo(kk)%HoleType==2 ) then
  328. EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !?????????????????
  329. !print*, 'StartAngle22=' ,ii , kk, StartAngle
  330. !print*, 'EndAngle22=' ,ii , kk, EndAngle
  331. TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle)))
  332. !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  333. TDGeo%Angle(ii) = EndAngle
  334. !print*, 'TDGeo%TVD(ii)22=' , ii , kk, TDGeo%TVD(ii)
  335. end if
  336. mm = TDGeo%TVD(ii)
  337. else
  338. dl = TDGeo%MD(ii)-nn
  339. nn = TDGeo%MD(ii)
  340. if ( TD_WellGeo(kk)%HoleType==0 ) then
  341. EndAngle = StartAngle
  342. !print*, 'StartAngle3=' ,ii , kk, StartAngle
  343. !print*, 'EndAngle3=' ,ii , kk, EndAngle
  344. TDGeo%TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle))
  345. TDGeo%Angle(ii) = EndAngle
  346. !print*, 'TDGeo%TVD(ii)3=' ,ii , kk, TDGeo%TVD(ii)
  347. else if ( TD_WellGeo(kk)%HoleType==1 ) then
  348. EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !???????????????????
  349. !print*, 'StartAngle4=' ,ii , kk, StartAngle
  350. !print*, 'EndAngle4=' ,ii , kk, EndAngle
  351. TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle)))
  352. TDGeo%Angle(ii) = EndAngle
  353. !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  354. !print*, 'mm=' ,mm
  355. !print*, 'TDGeo%TVD(ii)4=' ,ii , kk, TDGeo%TVD(ii)
  356. else if ( TD_WellGeo(kk)%HoleType==2 ) then
  357. EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !???????????????????
  358. !print*, 'StartAngle44=' ,ii , kk, StartAngle
  359. !print*, 'EndAngle44=' ,ii , kk, EndAngle
  360. TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle)))
  361. TDGeo%Angle(ii) = EndAngle
  362. !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  363. !print*, 'mm=' ,mm , (TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle)))
  364. !print*, 'TDGeo%TVD(ii)44=' ,ii , kk, TDGeo%TVD(ii)
  365. end if
  366. mm = TDGeo%TVD(ii)
  367. k = kk
  368. exit
  369. end if
  370. end if
  371. end do
  372. End Do
  373. !if (F_Counts%OutOfWellIntervalCounts==1) then
  374. ! s = 2
  375. !else
  376. ! s = F_Counts%OutOfWellIntervalCounts
  377. !end if
  378. !
  379. Do ii = (F_Counts%OutOfWellIntervalCounts+1),F_Counts%IntervalsTotalCounts
  380. do kk = jj,1,-1
  381. if ( F_Interval(ii)%StartDepth==TDGeo%MD(kk) ) then
  382. F_Interval(ii)%StartTVD = TDGeo%TVD(kk) ![ft]
  383. F_Interval(ii)%StartAngle = TDGeo%Angle(kk) ![rad]
  384. end if
  385. if ( F_Interval(ii)%EndDepth==TDGeo%MD(kk) ) then
  386. F_Interval(ii)%EndTVD = TDGeo%TVD(kk) ![ft]
  387. F_Interval(ii)%EndAngle = TDGeo%Angle(kk) ![rad]
  388. end if
  389. end do
  390. End Do
  391. !Do ii=1,(F_Counts%IntervalsTotalCounts)
  392. ! print*, 'F_Interval(ii)%StartTVD=' , ii , F_Interval(ii)%StartTVD
  393. ! print*, 'F_Interval(ii)%EndTVD=' , ii , F_Interval(ii)%EndTVD
  394. ! print*, 'F_Interval(ii)%StartAngle=' , ii , F_Interval(ii)%StartAngle
  395. ! print*, 'F_Interval(ii)%EndAngle=' , ii , F_Interval(ii)%EndAngle
  396. !end do
  397. !
  398. !
  399. !Do ii=1,TD_WellGeneral%WellIntervalsCount
  400. ! print*, 'TD_WellGeo(kk)%TopDepth=' , ii , TD_WellGeo(ii)%TopDepth
  401. ! print*, 'TD_WellGeo(kk)%DownDepth=' , ii , TD_WellGeo(ii)%DownDepth
  402. ! print*, 'TD_WellGeo(kk)%HoleType=' , ii , TD_WellGeo(ii)%HoleType
  403. ! print*, 'TD_WellGeo(kk)%RCurvature=' , ii , TD_WellGeo(ii)%RCurvature
  404. ! print*, 'TD_WellGeo(kk)%EndAngle=' , ii , TD_WellGeo(ii)%EndAngle
  405. ! print*, 'TD_WellGeo(kk)%StartAngle=' , ii , TD_WellGeo(ii)%StartAngle
  406. !end do
  407. end subroutine