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.

MeshGeneration_FluidModule.f90 20 KiB

1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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_StringConfigurationCount = StringConfigurationCount !???????????
  24. StringConfigCount = TD_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_PreCount ) then
  64. if ( TD_PreElementLength>TD_ElementLength ) then
  65. TD_RemoveVolume = (TD_PreElementLength-TD_ElementLength)*((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0) ![ft^3]
  66. else
  67. TD_RemoveVolume = 0.d0
  68. end if
  69. else if ( StringConfigCount<TD_PreCount ) then
  70. TD_RemoveVolume = TD_PreElementVolume
  71. else
  72. TD_RemoveVolume = 0.d0
  73. end if
  74. TD_PreCount = StringConfigCount
  75. TD_PreElementVolume = TD_ElementLength*(((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0)) ![ft^3]
  76. TD_PreElementLength = TD_ElementLength
  77. !print*, 'TD_RemoveVolume=' , TD_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_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_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(MD)) Deallocate(MD)
  159. Allocate (MD(jj))
  160. MD = 0.0d0
  161. Do ii=1,jj
  162. MD(ii)=A(1)
  163. do kk = 2,jj
  164. if (A(KK)>MD(ii)) then
  165. MD(ii) = A(kk)
  166. k=kk
  167. end if
  168. end do
  169. !!MD(ii) = MAXVAL(A)
  170. !!kk = MAXLOC(A)
  171. !!A(kk) = 0.0d0
  172. A(k) = 0.0d0
  173. End Do
  174. !print*, 'MD=' , MD
  175. !====================================================
  176. ! Geometrical Intervals Configuration (for fluid module)
  177. !====================================================
  178. if (allocated(F_Interval)) Deallocate(F_Interval)
  179. Allocate (F_Interval(jj-1+StringConfigCount+1))
  180. !F_Interval = 0.0d0
  181. F_IntervalsTotalCounts = jj-1+StringConfigCount+1
  182. !=========> String Intervals Configuration
  183. ! pump output
  184. ii = 1
  185. F_Interval(ii)%Number = ii
  186. F_Interval(ii)%GeoType = 0
  187. F_Interval(ii)%EndDepth = F_String(StringConfigCount)%TopDepth
  188. F_Interval(ii)%StartDepth = F_String(StringConfigCount)%TopDepth-265.d0
  189. F_Interval(ii)%ID = 0.0d0
  190. F_Interval(ii)%OD = dmax1(PumpsSpecification%MudPump1Output,PumpsSpecification%MudPump2Output) !???????????
  191. F_Interval(ii)%HydDiameter = F_Interval(ii)%OD ![inch]
  192. F_Interval(ii)%Volume = ((pi*((F_Interval(ii)%OD/12.d0)**2))/4.d0) &
  193. *(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
  194. Do ii=2,StringConfigCount+1
  195. F_Interval(ii)%Number = ii
  196. F_Interval(ii)%GeoType = 0
  197. F_Interval(ii)%EndDepth = F_String(StringConfigCount+1-ii+1)%DownDepth
  198. F_Interval(ii)%StartDepth = F_String(StringConfigCount+1-ii+1)%TopDepth
  199. F_Interval(ii)%ID = 0.0d0
  200. F_Interval(ii)%OD = F_String(StringConfigCount+1-ii+1)%ID
  201. F_Interval(ii)%HydDiameter = F_Interval(ii)%OD
  202. F_Interval(ii)%Volume = ((pi*((F_Interval(ii)%OD/12.d0)**2))/4.d0) &
  203. *(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
  204. End Do
  205. F_StringIntervalCounts = StringConfigCount+1
  206. !if (F_String(1)%ElType==0) then !bit
  207. ! !F_Interval(StringConfigCount)%Number = ii
  208. ! F_Interval(StringConfigCount)%EndDepth = F_String(1)%DownDepth
  209. ! F_Interval(StringConfigCount)%StartDepth = F_String(1)%TopDepth
  210. ! F_Interval(StringConfigCount)%ID = 0.0d0
  211. ! F_Interval(StringConfigCount)%OD = F_String(1)%OD
  212. ! F_Interval(StringConfigCount)%HydDiameter = F_Interval(StringConfigCount)%OD
  213. ! F_Interval(StringConfigCount)%Volume = ((pi*((F_Interval(StringConfigCount)%OD/12.)**2))/4.)*(F_Interval(StringConfigCount)%EndDepth-F_Interval(StringConfigCount)%StartDepth)*7.48051948
  214. !end if
  215. !=========> Annulus Intervals Configuration
  216. F_BottomHoleIntervalCounts = 0
  217. F_AnnulusIntervalCounts = 0
  218. Do ii=(StringConfigCount+2),(jj-1+StringConfigCount+1)
  219. F_Interval(ii)%Number = ii
  220. F_Interval(ii)%StartDepth = MD(ii-StringConfigCount-1)
  221. F_Interval(ii)%EndDepth = MD(ii+1-StringConfigCount-1)
  222. if (F_Interval(ii)%EndDepth>=F_Interval(StringConfigCount+1)%EndDepth) then
  223. F_Interval(ii)%GeoType = 1
  224. F_BottomHoleIntervalCounts = F_BottomHoleIntervalCounts+1
  225. else
  226. F_Interval(ii)%GeoType = 2
  227. F_AnnulusIntervalCounts = F_AnnulusIntervalCounts+1
  228. end if
  229. End Do
  230. !====================================================
  231. ! Diameter Calculation of Annulus Intervals
  232. !====================================================
  233. !=========> OD
  234. m = 1
  235. Do ii = (StringConfigCount+2),F_IntervalsTotalCounts
  236. do kk = m,4
  237. if (F_Interval(ii)%StartDepth<=OD_Annulus(kk)%StartMD .and. F_Interval(ii)%EndDepth>=OD_Annulus(kk)%EndMD) then
  238. F_Interval(ii)%OD = OD_Annulus(kk)%ODValue
  239. m = kk
  240. exit
  241. end if
  242. end do
  243. End Do
  244. !=========> ID
  245. m = 1
  246. Do ii = (StringConfigCount+2),F_IntervalsTotalCounts
  247. do kk = m,StringConfigCount
  248. if (F_Interval(ii)%StartDepth<=F_String(kk)%DownDepth .and. F_Interval(ii)%EndDepth>=F_String(kk)%TopDepth) then
  249. F_Interval(ii)%ID = F_String(kk)%OD
  250. m = kk
  251. exit
  252. else
  253. F_Interval(ii)%ID = 0.0d0
  254. end if
  255. end do
  256. F_Interval(ii)%HydDiameter = F_Interval(ii)%OD-F_Interval(ii)%ID
  257. F_Interval(ii)%Volume = ((pi*(((F_Interval(ii)%OD/12.d0)**2)-((F_Interval(ii)%ID/12.d0)**2)))/4.d0) &
  258. *abs(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
  259. End Do
  260. !print*, 'StringConfigCount=' , StringConfigCount
  261. !print*, 'F_IntervalsTotalCounts=' , F_IntervalsTotalCounts
  262. !print*, 'F_StringIntervalCounts=' , F_StringIntervalCounts
  263. !print*, 'F_BottomHoleIntervalCounts=' , F_BottomHoleIntervalCounts
  264. !print*, 'F_AnnulusIntervalCounts=' , F_AnnulusIntervalCounts
  265. !Do ii=1,(F_IntervalsTotalCounts)
  266. ! print*, 'Number/' , 'StartDepth/' , 'EndDepth/'
  267. ! print*, 'ID/' , 'OD/' , 'GeoType/'
  268. ! print*, 'HydDiameter/' , 'Volume/'
  269. ! print*, F_Interval(ii)%Number , F_Interval(ii)%StartDepth , F_Interval(ii)%EndDepth
  270. ! print*, F_Interval(ii)%ID , F_Interval(ii)%OD , F_Interval(ii)%GeoType
  271. ! print*, F_Interval(ii)%HydDiameter , F_Interval(ii)%Volume
  272. !End Do
  273. !====================================================
  274. ! TVD Calculation of Geo Intervals
  275. !====================================================
  276. !=========> Out of Well Intervals
  277. F_Interval(1)%StartTVD = 0.0d0 !??????????????
  278. F_Interval(1)%EndTVD = -TD_ConnectionHeight
  279. F_Interval(1)%StartAngle = 0.d0 !???????????????????????
  280. F_Interval(1)%EndAngle = 0.d0 !???????????????????????
  281. OutOfWellIntervalCounts = 1
  282. Do ii= 2 , StringConfigCount+1
  283. if ( F_Interval(ii)%StartDepth<=0.d0 ) then
  284. F_Interval(ii)%StartTVD = F_Interval(ii)%StartDepth
  285. F_Interval(ii)%StartAngle = 0.0d0
  286. end if
  287. if ( F_Interval(ii)%EndDepth<=0.d0 ) then
  288. F_Interval(ii)%EndTVD = F_Interval(ii)%EndDepth
  289. F_Interval(ii)%EndAngle = 0.0d0
  290. OutOfWellIntervalCounts = OutOfWellIntervalCounts+1
  291. end if
  292. End Do
  293. !=========>
  294. if (allocated(TVD)) Deallocate(TVD)
  295. Allocate (TVD(jj))
  296. if (allocated(Angle)) Deallocate(Angle)
  297. Allocate (Angle(jj))
  298. TVD(1) = TD_WellTotalVerticalLength !?????
  299. !print*, 'TD_WellTotalVerticalLength=' ,TD_WellTotalVerticalLength
  300. TVD(jj) = BopStackSpecification%AboveAnnularHeight ! WellHead[ft] !0.d0 ????????????????
  301. k = 1
  302. mm = 0.d0
  303. nn = 0.d0
  304. EndAngle = TD_WellGeo(1)%StartAngle !???????????????
  305. Angle(jj) = EndAngle
  306. Do ii = jj-1,1,-1 !???1or2
  307. do kk = k, TD_WellIntervalsCount
  308. StartAngle = EndAngle
  309. if ( MD(ii)>TD_WellGeo(kk)%TopDepth ) then
  310. if ( MD(ii)>TD_WellGeo(kk)%DownDepth ) then
  311. dl = TD_WellGeo(kk)%DownDepth-nn ![ft]
  312. nn = TD_WellGeo(kk)%DownDepth
  313. if ( TD_WellGeo(kk)%HoleType==0 ) then
  314. EndAngle = StartAngle
  315. !print*, 'StartAngle1=' ,ii , kk, StartAngle
  316. !print*, 'EndAngle1=' ,ii , kk, EndAngle
  317. TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) ![ft]
  318. Angle(ii) = EndAngle
  319. !print*, 'TVD(ii)1=' ,ii , kk, TVD(ii)
  320. else if ( TD_WellGeo(kk)%HoleType==1 ) then
  321. EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !?????????????????
  322. !print*, 'StartAngle2=' ,ii , kk, StartAngle
  323. !print*, 'EndAngle2=' ,ii , kk, EndAngle
  324. 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)))
  325. !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  326. Angle(ii) = EndAngle
  327. !print*, 'TVD(ii)2=' , ii , kk, TVD(ii)
  328. else if ( TD_WellGeo(kk)%HoleType==2 ) then
  329. EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !?????????????????
  330. !print*, 'StartAngle22=' ,ii , kk, StartAngle
  331. !print*, 'EndAngle22=' ,ii , kk, EndAngle
  332. 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)))
  333. !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  334. Angle(ii) = EndAngle
  335. !print*, 'TVD(ii)22=' , ii , kk, TVD(ii)
  336. end if
  337. mm = TVD(ii)
  338. else
  339. dl = MD(ii)-nn
  340. nn = MD(ii)
  341. if ( TD_WellGeo(kk)%HoleType==0 ) then
  342. EndAngle = StartAngle
  343. !print*, 'StartAngle3=' ,ii , kk, StartAngle
  344. !print*, 'EndAngle3=' ,ii , kk, EndAngle
  345. TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle))
  346. Angle(ii) = EndAngle
  347. !print*, 'TVD(ii)3=' ,ii , kk, TVD(ii)
  348. else if ( TD_WellGeo(kk)%HoleType==1 ) then
  349. EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !???????????????????
  350. !print*, 'StartAngle4=' ,ii , kk, StartAngle
  351. !print*, 'EndAngle4=' ,ii , kk, EndAngle
  352. 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)))
  353. Angle(ii) = EndAngle
  354. !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  355. !print*, 'mm=' ,mm
  356. !print*, 'TVD(ii)4=' ,ii , kk, TVD(ii)
  357. else if ( TD_WellGeo(kk)%HoleType==2 ) then
  358. EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !???????????????????
  359. !print*, 'StartAngle44=' ,ii , kk, StartAngle
  360. !print*, 'EndAngle44=' ,ii , kk, EndAngle
  361. 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)))
  362. Angle(ii) = EndAngle
  363. !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
  364. !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)))
  365. !print*, 'TVD(ii)44=' ,ii , kk, TVD(ii)
  366. end if
  367. mm = TVD(ii)
  368. k = kk
  369. exit
  370. end if
  371. end if
  372. end do
  373. End Do
  374. !if (OutOfWellIntervalCounts==1) then
  375. ! s = 2
  376. !else
  377. ! s = OutOfWellIntervalCounts
  378. !end if
  379. !
  380. Do ii = (OutOfWellIntervalCounts+1),F_IntervalsTotalCounts
  381. do kk = jj,1,-1
  382. if ( F_Interval(ii)%StartDepth==MD(kk) ) then
  383. F_Interval(ii)%StartTVD = TVD(kk) ![ft]
  384. F_Interval(ii)%StartAngle = Angle(kk) ![rad]
  385. end if
  386. if ( F_Interval(ii)%EndDepth==MD(kk) ) then
  387. F_Interval(ii)%EndTVD = TVD(kk) ![ft]
  388. F_Interval(ii)%EndAngle = Angle(kk) ![rad]
  389. end if
  390. end do
  391. End Do
  392. !Do ii=1,(F_IntervalsTotalCounts)
  393. ! print*, 'F_Interval(ii)%StartTVD=' , ii , F_Interval(ii)%StartTVD
  394. ! print*, 'F_Interval(ii)%EndTVD=' , ii , F_Interval(ii)%EndTVD
  395. ! print*, 'F_Interval(ii)%StartAngle=' , ii , F_Interval(ii)%StartAngle
  396. ! print*, 'F_Interval(ii)%EndAngle=' , ii , F_Interval(ii)%EndAngle
  397. !end do
  398. !
  399. !
  400. !Do ii=1,TD_WellIntervalsCount
  401. ! print*, 'TD_WellGeo(kk)%TopDepth=' , ii , TD_WellGeo(ii)%TopDepth
  402. ! print*, 'TD_WellGeo(kk)%DownDepth=' , ii , TD_WellGeo(ii)%DownDepth
  403. ! print*, 'TD_WellGeo(kk)%HoleType=' , ii , TD_WellGeo(ii)%HoleType
  404. ! print*, 'TD_WellGeo(kk)%RCurvature=' , ii , TD_WellGeo(ii)%RCurvature
  405. ! print*, 'TD_WellGeo(kk)%EndAngle=' , ii , TD_WellGeo(ii)%EndAngle
  406. ! print*, 'TD_WellGeo(kk)%StartAngle=' , ii , TD_WellGeo(ii)%StartAngle
  407. !end do
  408. end subroutine