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