|
- subroutine MeshGeneration_FluidModule
-
- Use TD_DrillStemComponents
- Use TD_WellElements
- Use TD_WellGeometry
- Use TD_StringConnectionData
- Use GeoElements_FluidModule
- Use CPumpsVariables
- Use CStringConfigurationVariables
- Use CBopStackVariables
- !Use Drawworks_VARIABLES , only: Drawworks
-
- implicit none
-
- Integer :: ii , jj , semijj , kk , k , m , s
- Integer :: ElementsCount , StringConfigCount
- REAL(8) :: mm , nn , dl , StartAngle , EndAngle
- REAL(8) :: A(30) !?????????10
- REAL(8) :: TD_ElementLength
-
-
-
-
- A = 0.d0
- A(1) = AboveAnnularHeight ! WellHead[ft]
- jj = 1
-
-
-
-
-
-
-
- !====================================================
- ! Mesh Generation of DrillStem Components
- !====================================================
-
- !TD_StringConfigurationCount = StringConfigurationCount !???????????
- StringConfigCount = TD_StringConfigurationCount
- if (allocated(F_String)) Deallocate(F_String)
- if (TD_DrillStem(1)%ComponentType==0) then
- Allocate (F_String(StringConfigCount-1))
- else
- Allocate (F_String(StringConfigCount))
- end if
-
-
- if (TD_DrillStem(1)%ComponentType==0) then
- ElementsCount = 1
- Do ii=1,(StringConfigCount-1)
- F_String(ii)%ID = TD_DrillStem(ii+1)%Id*12.d0 ![inch]
- F_String(ii)%OD = TD_DrillStem(ii+1)%Od*12.d0 ![inch]
- F_String(ii)%FirstElement = ElementsCount+1
- F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii+1)%Numbs-1)
- F_String(ii)%ElType = TD_DrillStem(ii+1)%ComponentType
- ElementsCount = F_String(ii)%LastElement
- End Do
- StringConfigCount = StringConfigCount-1
- else
- ElementsCount = 0
- Do ii=1,StringConfigCount
- F_String(ii)%ID = TD_DrillStem(ii)%Id*12.d0 ![inch]
- F_String(ii)%OD = TD_DrillStem(ii)%Od*12.d0 ![inch]
- F_String(ii)%FirstElement = ElementsCount+1
- F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii)%Numbs-1)
- F_String(ii)%ElType = TD_DrillStem(ii)%ComponentType
- ElementsCount = F_String(ii)%LastElement
- End Do
- end if
-
-
- Do ii=1,StringConfigCount
- F_String(ii)%TopDepth = TD_DrillStems(F_String(ii)%LastElement)%TopDepthIni ![ft]
- F_String(ii)%DownDepth = TD_DrillStems(F_String(ii)%FirstElement)%DownDepthIni ![ft]
-
- if (F_String(ii)%DownDepth>A(1)) then
- jj = jj+1
- A(jj) = F_String(ii)%DownDepth
- end if
- End Do
-
-
-
- !=========> Removed Volume Calculation in DrillStem
- TD_ElementLength = F_String(StringConfigCount)%DownDepth-F_String(StringConfigCount)%TopDepth
- if ( StringConfigCount==TD_PreCount ) then
- if ( TD_PreElementLength>TD_ElementLength ) then
- TD_RemoveVolume = (TD_PreElementLength-TD_ElementLength)*((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0) ![ft^3]
- else
- TD_RemoveVolume = 0.d0
- end if
- else if ( StringConfigCount<TD_PreCount ) then
- TD_RemoveVolume = TD_PreElementVolume
- else
- TD_RemoveVolume = 0.d0
- end if
- TD_PreCount = StringConfigCount
- TD_PreElementVolume = TD_ElementLength*(((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0)) ![ft^3]
- TD_PreElementLength = TD_ElementLength
-
-
- !print*, 'TD_RemoveVolume=' , TD_RemoveVolume
-
-
-
-
-
- !====================================================
- ! Mesh Generation of Annulus Components
- !====================================================
-
- if (TD_Casing(1)%Length>0.) then
- jj = jj+1
- A(jj) = TD_Casing(1)%DownDepth
- OD_Annulus(4)%StartMD = TD_Casing(1)%DownDepth ![ft]
- OD_Annulus(4)%EndMD = TD_Casing(1)%TopDepth ![ft]
- OD_Annulus(4)%ODValue = TD_Casing(1)%Id*12.d0 ![inch]
- !else
- ! OD_Annulus(4)%StartMD = 0. !????????????????????
- ! OD_Annulus(4)%EndMD = OD_Annulus(4)%StartMD !????????????????????
- ! OD_Annulus(4)%ODValue = TD_Casing(1)%Id !????????????????????
- end if
-
- if (TD_Liner(1)%Length>0.) then
- jj = jj+1
- A(jj) = TD_Liner(1)%DownDepth
- OD_Annulus(3)%StartMD = TD_Liner(1)%DownDepth ![ft]
- OD_Annulus(3)%EndMD = TD_Liner(1)%TopDepth ![ft]
- OD_Annulus(3)%ODValue = TD_Liner(1)%Id*12.d0 ![inch]
- else
- OD_Annulus(3)%StartMD = TD_Casing(1)%DownDepth !????????????????????
- OD_Annulus(3)%EndMD = OD_Annulus(3)%StartMD !????????????????????
- OD_Annulus(3)%ODValue = OD_Annulus(4)%ODValue !????????????????????
- end if
-
- if (TD_OpenHole(1)%Length>0.) then
- !jj = jj+1
- !A(jj) = TD_OpenHole(1)%DownDepth
- OD_Annulus(2)%StartMD = TD_OpenHole(1)%DownDepth ![ft]
- OD_Annulus(2)%EndMD = TD_OpenHole(1)%TopDepth ![ft]
- OD_Annulus(2)%ODValue = TD_OpenHole(1)%Id*12.d0 ![inch]
- do ii = 1,TD_WellIntervalsCount-1
- if ( TD_WellGeo(ii)%DownDepth>TD_OpenHole(1)%TopDepth ) then
- jj = jj+1
- A(jj) = TD_WellGeo(ii)%DownDepth
- end if
- end do
- else
- OD_Annulus(2)%StartMD = TD_Liner(1)%DownDepth !??????????????
- OD_Annulus(2)%EndMD = OD_Annulus(2)%StartMD !??????????????
- OD_Annulus(2)%ODValue = OD_Annulus(3)%ODValue !??????????????
- end if
-
- if (TD_ROPHole(1)%Length>0.) then
- jj = jj+1
- A(jj) = TD_ROPHole(1)%DownDepth
- OD_Annulus(1)%StartMD = TD_ROPHole(1)%DownDepth ![ft]
- OD_Annulus(1)%EndMD = TD_ROPHole(1)%TopDepth ![ft]
- OD_Annulus(1)%ODValue = TD_ROPHole(1)%Id*12.d0 ![inch]
- else
- OD_Annulus(1)%StartMD = TD_OpenHole(1)%DownDepth !??????????????
- OD_Annulus(1)%EndMD = OD_Annulus(1)%StartMD !??????????????
- OD_Annulus(1)%ODValue = OD_Annulus(2)%ODValue !??????????????
- end if
-
- !print*, 'A(jj)2=' , A
-
-
-
-
-
-
-
- !====================================================
- ! Mesh Generation of Well
- !====================================================
- !Do ii=2,TD_WellIntervalsCount-1
- ! jj = jj+1
- ! A(jj) = TD_WellGeo(ii)%TopDepth
- !End Do
-
-
- !print*, 'A(jj)3=' , A
-
- !print*, 'A=' , A
- !print*, 'jj=' , jj
-
- semijj = jj
- !print*, 'semijj=' , semijj
- Do ii=1,jj
- do kk = 1,jj
- if ( A(ii)==A(KK) .and. ii/=kk .and. A(KK)/=0. ) then !A(KK)/=0. ?????????????????
- !print*, 'indoA=' , semijj , ii , kk , A(KK) , A(ii)
- A(kk) = 0.d0
- semijj = semijj-1
- !print*, 'indoA2=' , semijj , ii , kk , A(KK) , A(ii)
- end if
- end do
- End Do
- !print*, 'semijj2=' , semijj
- jj = semijj
-
- !print*, 'jj2=' , jj
- !print*, 'AA=' , A
-
-
-
-
-
- if (allocated(MD)) Deallocate(MD)
- Allocate (MD(jj))
- MD = 0.0d0
- Do ii=1,jj
- MD(ii)=A(1)
- do kk = 2,jj
- if (A(KK)>MD(ii)) then
- MD(ii) = A(kk)
- k=kk
- end if
- end do
- !!MD(ii) = MAXVAL(A)
- !!kk = MAXLOC(A)
- !!A(kk) = 0.0d0
- A(k) = 0.0d0
- End Do
-
-
- !print*, 'MD=' , MD
-
-
-
-
-
-
- !====================================================
- ! Geometrical Intervals Configuration (for fluid module)
- !====================================================
-
- if (allocated(F_Interval)) Deallocate(F_Interval)
- Allocate (F_Interval(jj-1+StringConfigCount+1))
- !F_Interval = 0.0d0
- F_IntervalsTotalCounts = jj-1+StringConfigCount+1
-
- !=========> String Intervals Configuration
- ! pump output
- ii = 1
- F_Interval(ii)%Number = ii
- F_Interval(ii)%GeoType = 0
- F_Interval(ii)%EndDepth = F_String(StringConfigCount)%TopDepth
- F_Interval(ii)%StartDepth = F_String(StringConfigCount)%TopDepth-265.d0
- F_Interval(ii)%ID = 0.0d0
- F_Interval(ii)%OD = dmax1(MudPump1Output,MudPump2Output) !???????????
- F_Interval(ii)%HydDiameter = F_Interval(ii)%OD ![inch]
- F_Interval(ii)%Volume = ((pi*((F_Interval(ii)%OD/12.d0)**2))/4.d0) &
- *(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
-
-
- Do ii=2,StringConfigCount+1
- F_Interval(ii)%Number = ii
- F_Interval(ii)%GeoType = 0
- F_Interval(ii)%EndDepth = F_String(StringConfigCount+1-ii+1)%DownDepth
- F_Interval(ii)%StartDepth = F_String(StringConfigCount+1-ii+1)%TopDepth
- F_Interval(ii)%ID = 0.0d0
- F_Interval(ii)%OD = F_String(StringConfigCount+1-ii+1)%ID
- F_Interval(ii)%HydDiameter = F_Interval(ii)%OD
- F_Interval(ii)%Volume = ((pi*((F_Interval(ii)%OD/12.d0)**2))/4.d0) &
- *(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
- End Do
-
- F_StringIntervalCounts = StringConfigCount+1
-
- !if (F_String(1)%ElType==0) then !bit
- ! !F_Interval(StringConfigCount)%Number = ii
- ! F_Interval(StringConfigCount)%EndDepth = F_String(1)%DownDepth
- ! F_Interval(StringConfigCount)%StartDepth = F_String(1)%TopDepth
- ! F_Interval(StringConfigCount)%ID = 0.0d0
- ! F_Interval(StringConfigCount)%OD = F_String(1)%OD
- ! F_Interval(StringConfigCount)%HydDiameter = F_Interval(StringConfigCount)%OD
- ! F_Interval(StringConfigCount)%Volume = ((pi*((F_Interval(StringConfigCount)%OD/12.)**2))/4.)*(F_Interval(StringConfigCount)%EndDepth-F_Interval(StringConfigCount)%StartDepth)*7.48051948
- !end if
-
- !=========> Annulus Intervals Configuration
- F_BottomHoleIntervalCounts = 0
- F_AnnulusIntervalCounts = 0
- Do ii=(StringConfigCount+2),(jj-1+StringConfigCount+1)
- F_Interval(ii)%Number = ii
- F_Interval(ii)%StartDepth = MD(ii-StringConfigCount-1)
- F_Interval(ii)%EndDepth = MD(ii+1-StringConfigCount-1)
- if (F_Interval(ii)%EndDepth>=F_Interval(StringConfigCount+1)%EndDepth) then
- F_Interval(ii)%GeoType = 1
- F_BottomHoleIntervalCounts = F_BottomHoleIntervalCounts+1
- else
- F_Interval(ii)%GeoType = 2
- F_AnnulusIntervalCounts = F_AnnulusIntervalCounts+1
- end if
- End Do
-
-
-
-
-
-
-
-
-
-
-
-
- !====================================================
- ! Diameter Calculation of Annulus Intervals
- !====================================================
-
- !=========> OD
- m = 1
- Do ii = (StringConfigCount+2),F_IntervalsTotalCounts
- do kk = m,4
- if (F_Interval(ii)%StartDepth<=OD_Annulus(kk)%StartMD .and. F_Interval(ii)%EndDepth>=OD_Annulus(kk)%EndMD) then
- F_Interval(ii)%OD = OD_Annulus(kk)%ODValue
- m = kk
- exit
- end if
- end do
- End Do
-
-
-
- !=========> ID
- m = 1
- Do ii = (StringConfigCount+2),F_IntervalsTotalCounts
- do kk = m,StringConfigCount
- if (F_Interval(ii)%StartDepth<=F_String(kk)%DownDepth .and. F_Interval(ii)%EndDepth>=F_String(kk)%TopDepth) then
- F_Interval(ii)%ID = F_String(kk)%OD
- m = kk
- exit
- else
- F_Interval(ii)%ID = 0.0d0
- end if
- end do
- F_Interval(ii)%HydDiameter = F_Interval(ii)%OD-F_Interval(ii)%ID
- F_Interval(ii)%Volume = ((pi*(((F_Interval(ii)%OD/12.d0)**2)-((F_Interval(ii)%ID/12.d0)**2)))/4.d0) &
- *abs(F_Interval(ii)%EndDepth-F_Interval(ii)%StartDepth)*7.48051948d0 ![gal-us]
- End Do
-
-
- !print*, 'StringConfigCount=' , StringConfigCount
- !print*, 'F_IntervalsTotalCounts=' , F_IntervalsTotalCounts
- !print*, 'F_StringIntervalCounts=' , F_StringIntervalCounts
- !print*, 'F_BottomHoleIntervalCounts=' , F_BottomHoleIntervalCounts
- !print*, 'F_AnnulusIntervalCounts=' , F_AnnulusIntervalCounts
- !Do ii=1,(F_IntervalsTotalCounts)
- ! print*, 'Number/' , 'StartDepth/' , 'EndDepth/'
- ! print*, 'ID/' , 'OD/' , 'GeoType/'
- ! print*, 'HydDiameter/' , 'Volume/'
- ! print*, F_Interval(ii)%Number , F_Interval(ii)%StartDepth , F_Interval(ii)%EndDepth
- ! print*, F_Interval(ii)%ID , F_Interval(ii)%OD , F_Interval(ii)%GeoType
- ! print*, F_Interval(ii)%HydDiameter , F_Interval(ii)%Volume
- !End Do
-
-
-
-
-
-
-
- !====================================================
- ! TVD Calculation of Geo Intervals
- !====================================================
-
- !=========> Out of Well Intervals
- F_Interval(1)%StartTVD = 0.0d0 !??????????????
- F_Interval(1)%EndTVD = -TD_ConnectionHeight
- F_Interval(1)%StartAngle = 0.d0 !???????????????????????
- F_Interval(1)%EndAngle = 0.d0 !???????????????????????
- OutOfWellIntervalCounts = 1
- Do ii= 2 , StringConfigCount+1
- if ( F_Interval(ii)%StartDepth<=0.d0 ) then
- F_Interval(ii)%StartTVD = F_Interval(ii)%StartDepth
- F_Interval(ii)%StartAngle = 0.0d0
- end if
- if ( F_Interval(ii)%EndDepth<=0.d0 ) then
- F_Interval(ii)%EndTVD = F_Interval(ii)%EndDepth
- F_Interval(ii)%EndAngle = 0.0d0
- OutOfWellIntervalCounts = OutOfWellIntervalCounts+1
- end if
- End Do
-
-
- !=========>
- if (allocated(TVD)) Deallocate(TVD)
- Allocate (TVD(jj))
- if (allocated(Angle)) Deallocate(Angle)
- Allocate (Angle(jj))
- TVD(1) = TD_WellTotalVerticalLength !?????
- !print*, 'TD_WellTotalVerticalLength=' ,TD_WellTotalVerticalLength
- TVD(jj) = AboveAnnularHeight ! WellHead[ft] !0.d0 ????????????????
-
- k = 1
- mm = 0.d0
- nn = 0.d0
- EndAngle = TD_WellGeo(1)%StartAngle !???????????????
- Angle(jj) = EndAngle
- Do ii = jj-1,1,-1 !???1or2
- do kk = k, TD_WellIntervalsCount
- StartAngle = EndAngle
- if ( MD(ii)>TD_WellGeo(kk)%TopDepth ) then
- if ( MD(ii)>TD_WellGeo(kk)%DownDepth ) then
- dl = TD_WellGeo(kk)%DownDepth-nn ![ft]
- nn = TD_WellGeo(kk)%DownDepth
- if ( TD_WellGeo(kk)%HoleType==0 ) then
- EndAngle = StartAngle
- !print*, 'StartAngle1=' ,ii , kk, StartAngle
- !print*, 'EndAngle1=' ,ii , kk, EndAngle
- TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) ![ft]
- Angle(ii) = EndAngle
- !print*, 'TVD(ii)1=' ,ii , kk, TVD(ii)
- else if ( TD_WellGeo(kk)%HoleType==1 ) then
- EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !?????????????????
- !print*, 'StartAngle2=' ,ii , kk, StartAngle
- !print*, 'EndAngle2=' ,ii , kk, EndAngle
- 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)))
- !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
- Angle(ii) = EndAngle
- !print*, 'TVD(ii)2=' , ii , kk, TVD(ii)
- else if ( TD_WellGeo(kk)%HoleType==2 ) then
- EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !?????????????????
- !print*, 'StartAngle22=' ,ii , kk, StartAngle
- !print*, 'EndAngle22=' ,ii , kk, EndAngle
- 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)))
- !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
- Angle(ii) = EndAngle
- !print*, 'TVD(ii)22=' , ii , kk, TVD(ii)
- end if
- mm = TVD(ii)
- else
- dl = MD(ii)-nn
- nn = MD(ii)
- if ( TD_WellGeo(kk)%HoleType==0 ) then
- EndAngle = StartAngle
- !print*, 'StartAngle3=' ,ii , kk, StartAngle
- !print*, 'EndAngle3=' ,ii , kk, EndAngle
- TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle))
- Angle(ii) = EndAngle
- !print*, 'TVD(ii)3=' ,ii , kk, TVD(ii)
- else if ( TD_WellGeo(kk)%HoleType==1 ) then
- EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !???????????????????
- !print*, 'StartAngle4=' ,ii , kk, StartAngle
- !print*, 'EndAngle4=' ,ii , kk, EndAngle
- 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)))
- Angle(ii) = EndAngle
- !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
- !print*, 'mm=' ,mm
- !print*, 'TVD(ii)4=' ,ii , kk, TVD(ii)
- else if ( TD_WellGeo(kk)%HoleType==2 ) then
- EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !???????????????????
- !print*, 'StartAngle44=' ,ii , kk, StartAngle
- !print*, 'EndAngle44=' ,ii , kk, EndAngle
- 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)))
- Angle(ii) = EndAngle
- !TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle)))
- !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)))
- !print*, 'TVD(ii)44=' ,ii , kk, TVD(ii)
- end if
- mm = TVD(ii)
- k = kk
- exit
- end if
- end if
- end do
- End Do
-
-
-
- !if (OutOfWellIntervalCounts==1) then
- ! s = 2
- !else
- ! s = OutOfWellIntervalCounts
- !end if
- !
-
- Do ii = (OutOfWellIntervalCounts+1),F_IntervalsTotalCounts
- do kk = jj,1,-1
- if ( F_Interval(ii)%StartDepth==MD(kk) ) then
- F_Interval(ii)%StartTVD = TVD(kk) ![ft]
- F_Interval(ii)%StartAngle = Angle(kk) ![rad]
- end if
- if ( F_Interval(ii)%EndDepth==MD(kk) ) then
- F_Interval(ii)%EndTVD = TVD(kk) ![ft]
- F_Interval(ii)%EndAngle = Angle(kk) ![rad]
- end if
- end do
- End Do
-
-
-
- !Do ii=1,(F_IntervalsTotalCounts)
- ! print*, 'F_Interval(ii)%StartTVD=' , ii , F_Interval(ii)%StartTVD
- ! print*, 'F_Interval(ii)%EndTVD=' , ii , F_Interval(ii)%EndTVD
- ! print*, 'F_Interval(ii)%StartAngle=' , ii , F_Interval(ii)%StartAngle
- ! print*, 'F_Interval(ii)%EndAngle=' , ii , F_Interval(ii)%EndAngle
- !end do
- !
- !
- !Do ii=1,TD_WellIntervalsCount
- ! print*, 'TD_WellGeo(kk)%TopDepth=' , ii , TD_WellGeo(ii)%TopDepth
- ! print*, 'TD_WellGeo(kk)%DownDepth=' , ii , TD_WellGeo(ii)%DownDepth
- ! print*, 'TD_WellGeo(kk)%HoleType=' , ii , TD_WellGeo(ii)%HoleType
- ! print*, 'TD_WellGeo(kk)%RCurvature=' , ii , TD_WellGeo(ii)%RCurvature
- ! print*, 'TD_WellGeo(kk)%EndAngle=' , ii , TD_WellGeo(ii)%EndAngle
- ! print*, 'TD_WellGeo(kk)%StartAngle=' , ii , TD_WellGeo(ii)%StartAngle
- !end do
-
-
-
-
-
- end subroutine
|