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 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