subroutine TD_DrillStemConfiguration Use CStringConfigurationVariables use SoftwareInputsVariables ! Use CNearFloorConnection Use CDataDisplayConsoleVariables Use CDrillWatchVariables use UnitySignalVariables ! Use COperationConditionEnumVariables Use CKellyConnectionEnumVariables Use TD_DrillStemComponents Use TD_WellElements Use TD_WellGeometry Use TD_StringConnectionData Use sROP_Variables implicit none Integer :: i , j , k , kk , TD_Status !==================================================== ! Drill Stem Components Data Modification !==================================================== !=====> Drill Stem Total Length&Weight Calculation TD_String%DrillStemTotalLength = 0.0d0 TD_String%DrillStemTotalLengthIni = 0.0d0 TD_String%DrillStemTotalWeight = 0.0d0 Do i= 1,TD_String%DrillStemComponentsNumbs TD_String%DrillStemTotalLength = TD_String%DrillStemTotalLength+TD_DrillStems(i)%Length TD_String%DrillStemTotalLengthIni = TD_String%DrillStemTotalLengthIni+TD_DrillStems(i)%LengthIni TD_String%DrillStemTotalWeight = TD_String%DrillStemTotalWeight+TD_DrillStems(i)%Weight End Do !=====> Top&Down Depth Calculation Of Initial Drill Stem Components (Graphic) TD_DrillStems(1)%DownDepth = TD_String%DrillStemTotalLength-TD_StConn%ConnectionHeight TD_String%DrillStemBottom = TD_DrillStems(1)%DownDepth if ( TD_DrillStems(1)%DownDepth>=TD_WellGeneral%WellTotalLength ) then !if ( TD_StConn%HookHeight>=TD_StConn%HookHeightOld .and. ROP_Bit%RateOfPenetration==0. ) then ! TD_StConn%GRigidConnectionHeight = TD_StConn%GRigidConnectionHeight !else TD_StConn%GRigidConnectionHeight = TD_StConn%GRigidConnectionHeight-(TD_WellGeneral%WellTotalLength-TD_DrillStems(1)%DownDepthIniG) TD_DrillStems(1)%DownDepthIniG = TD_WellGeneral%WellTotalLength !??????????? ! !TD_StConn%GRigidConnectionHeight = TD_StConn%GRigidConnectionHeight !end if else TD_StConn%GRigidConnectionHeight = TD_StConn%ConnectionHeight TD_DrillStems(1)%DownDepthIniG = TD_String%DrillStemTotalLengthIni-TD_StConn%GRigidConnectionHeight end if !TD_DrillStems(1)%DownDepthIniG = TD_String%DrillStemTotalLengthIni-TD_StConn%GRigidConnectionHeight !if ( TD_DrillStems(1)%DownDepthIniG>TD_WellGeneral%WellTotalLength ) then ! TD_StConn%GRigidConnectionHeight = TD_StConn%GRigidConnectionHeight+(TD_DrillStems(1)%DownDepthIniG-TD_WellGeneral%WellTotalLength) ! TD_DrillStems(1)%DownDepthIniG = TD_WellGeneral%WellTotalLength !??????????? !end if TD_DrillStems(1)%TopDepthIniG = TD_DrillStems(1)%DownDepthIniG-TD_DrillStems(1)%LengthIni Do i = 2,TD_String%DrillStemComponentsNumbs TD_DrillStems(i)%TopDepthIniG = TD_DrillStems(i-1)%TopDepthIniG-TD_DrillStems(i)%LengthIni TD_DrillStems(i)%DownDepthIniG = TD_DrillStems(i-1)%DownDepthIniG-TD_DrillStems(i-1)%LengthIni End Do !=====> Top&Down Depth Calculation Of Initial Drill Stem Components (for fluid module) if ( TD_DrillStems(1)%DownDepthIniG>=(TD_WellGeneral%WellTotalLength-.1d0) ) then TD_StConn%RigidConnectionHeight = TD_StConn%GRigidConnectionHeight+(.1d0-(TD_WellGeneral%WellTotalLength-TD_DrillStems(1)%DownDepthIniG)) else TD_StConn%RigidConnectionHeight = TD_StConn%GRigidConnectionHeight end if TD_DrillStems(1)%DownDepthIni = TD_String%DrillStemTotalLengthIni-TD_StConn%RigidConnectionHeight TD_DrillStems(1)%TopDepthIni = TD_DrillStems(1)%DownDepthIni-TD_DrillStems(1)%LengthIni Do i = 2,TD_String%DrillStemComponentsNumbs TD_DrillStems(i)%TopDepthIni = TD_DrillStems(i-1)%TopDepthIni-TD_DrillStems(i)%LengthIni TD_DrillStems(i)%DownDepthIni = TD_DrillStems(i-1)%DownDepthIni-TD_DrillStems(i-1)%LengthIni End Do !=====> Top&Down Depth Calculation Of Drill Stem Components TD_DrillStems(1)%TopDepth = TD_String%DrillStemTotalLength-TD_DrillStems(1)%Length-TD_StConn%GRigidConnectionHeight TD_DrillStems(1)%DownDepth = TD_String%DrillStemTotalLength-TD_StConn%GRigidConnectionHeight Do i = 2,TD_String%DrillStemComponentsNumbs TD_DrillStems(i)%TopDepth = TD_DrillStems(i-1)%TopDepth-TD_DrillStems(i)%Length TD_DrillStems(i)%DownDepth = TD_DrillStems(i-1)%DownDepth-TD_DrillStems(i-1)%Length End Do !TD_String%DrillStemBottom = TD_DrillStems(1)%DownDepth !=====> Hole Type & Inclination Determination Of Drill Stem Components Do i = 1,TD_String%DrillStemComponentsNumbs if (TD_DrillStems(i)%TopDepth .ge. 0.d0) then Do j = 1,TD_WellGeneral%WellIntervalsCount if (TD_DrillStems(i)%TopDepth>TD_WellGeo(j)%TopDepth .and. TD_DrillStems(i)%TopDepth Hole(Well) Diameter Determination Of Drill Stem Components Do i = 1,TD_String%DrillStemComponentsNumbs If (TD_DrillStems(i)%TopDepth>TD_Casing(1)%TopDepth .and. TD_DrillStems(i)%TopDepthTD_Liner(1)%TopDepth .and. TD_DrillStems(i)%TopDepthTD_OpenHole(1)%TopDepth .and. TD_DrillStems(i)%TopDepthTD_ROPHole(1)%TopDepth .and. TD_DrillStems(i)%TopDepth Viscosity Correction Coefficient Calculation if (TD_DrillStems(i)%HoleType == 1 .or. TD_DrillStems(i)%HoleType == 2) then TD_DrillStems(i)%MudVisCorrectCoef = (2.0d0/pi)*atan(sqrt(TD_DrillStems(i)%HoleDiameter**2-(TD_DrillStems(i)%Od**2)) & / (TD_DrillStems(i)%Od))*(4.0d0/pi-1.0d0) + 1.0d0 else if (TD_DrillStems(i)%HoleType == 0) then TD_DrillStems(i)%MudVisCorrectCoef = 1.d0 end if End Do !=====> Out_of_Well Length Of DrillStem if (TD_DrillStems(TD_String%DrillStemComponentsNumbs)%TopDepth<0.) then TD_String%OutOfWellLength = abs(TD_DrillStems(TD_String%DrillStemComponentsNumbs)%TopDepth) else TD_String%OutOfWellLength = 0.d0 end if !=====> Near Floor Connection Do i = TD_String%DrillStemComponentsNumbs, 1, -1 if ( TD_DrillStems(i)%TopDepth<=0.d0 ) then TD_String%NearFloorConnectionNo = i TD_String%NearFloorConnectionHeight = abs(TD_DrillStems(i)%TopDepth) end if if (TD_DrillStems(i)%TopDepth>0.d0) then exit end if End Do Call Set_NearFloorConnection(real(TD_String%NearFloorConnectionHeight)) !=====> Graphic Output kk = 0 k = 0 Do i= 1,TD_String%StringConfigurationCount k = k+1 if ( TD_DrillStems(k)%DownDepthIniG>0.d0 ) then kk = kk+1 if (TD_DrillStems(k+TD_DrillStem(i)%Numbs-1)%TopDepthIniG<=0.d0) then exit end if k = k+TD_DrillStem(i)%Numbs-1 end if End Do if (allocated(G_StringElement)) deallocate(G_StringElement) allocate(G_StringElement(kk)) k = 0 Do i= 1,kk G_StringElement(kk-i+1)%Id = TD_DrillStem(i)%Id G_StringElement(kk-i+1)%Od = TD_DrillStem(i)%Od if ( TD_DrillStem(i)%ComponentType>4 ) then G_StringElement(kk-i+1)%ComponentType = 3 else G_StringElement(kk-i+1)%ComponentType = TD_DrillStem(i)%ComponentType end if G_StringElement(kk-i+1)%TopDepth = TD_DrillStems(k+TD_DrillStem(i)%Numbs)%TopDepthIniG G_StringElement(kk-i+1)%DownDepth = TD_DrillStems(k+1)%DownDepthIniG k = k+TD_DrillStem(i)%Numbs End Do if (G_StringElement(1)%TopDepth<=0.d0) then G_StringElement(1)%TopDepth = 0.d0 end if Call SetString(kk, G_StringElement) if(TD_DrillStems(1)%DownDepth<0.d0) then DrillingWatch%BitPosition = TD_DrillStems(1)%DownDepth else DrillingWatch%BitPosition = G_StringElement(kk)%DownDepth !??????????? !if ( G_StringElement(kk)%DownDepth>TD_WellGeneral%WellTotalLength ) then ! DrillingWatch%BitPosition = TD_WellGeneral%WellTotalLength !??????????? !end if end if !print*, 'kk=' , kk !Do i=1,kk ! print*, 'Number/' , 'downDepth/' , 'topDepth/' ! print*, 'ID/' , 'OD/' , 'Type/' ! print*, i , G_StringElement(i)%DownDepth , G_StringElement(i)%TopDepth ! print*, G_StringElement(i)%Id , G_StringElement(i)%Od , G_StringElement(i)%ComponentType !End Do !print*, 'Top Joint Height before=' , TD_String%TopJointHeight !=====> Top Joint Height if ( Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then TD_String%TopJointHeight = abs(TD_DrillStems(TD_String%DrillStemComponentsNumbs-1)%TopDepth) !print*, 'TopDepth1=' , TD_DrillStems(TD_String%DrillStemComponentsNumbs-1)%TopDepth !print*, 'numb1=' , TD_String%DrillStemComponentsNumbs-1 !print*, 'TD_String%TopJointHeight=' , TD_String%TopJointHeight else TD_String%TopJointHeight = abs(TD_DrillStems(TD_String%DrillStemComponentsNumbs)%TopDepth) !print*, 'TopDepth2=' , TD_DrillStems(TD_String%DrillStemComponentsNumbs)%TopDepth !print*, 'numb2=' , TD_String%DrillStemComponentsNumbs !print*, 'TD_String%TopJointHeight2=' , TD_String%TopJointHeight end if !print*, 'TD_String%DrillStemComponentsNumbs=' , TD_String%DrillStemComponentsNumbs !print*, 'TD_String%TopJointHeight_=' , TD_String%TopJointHeight !Print*, 'TD_StConn%ConnectionHeight_=' , TD_StConn%ConnectionHeight !Print*, 'TD_StConn%StringConnectionMode_=' , TD_StConn%StringConnectionMode ! !print*, 'Top Joint Height after=' , TD_String%TopJointHeight end subroutine