diff --git a/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 b/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 index 220331d..c7102df 100644 --- a/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 @@ -5,7 +5,7 @@ module CIrIbopPermission subroutine Evaluate_IrIbopPermission() use TD_DrillStemComponents - use CStudentStationVariables, only: FillupHeadInstallation + use CStudentStationVariables!, only: StudentStation%FillupHeadInstallation implicit none @@ -20,7 +20,7 @@ module CIrIbopPermission Get_NearFloorConnection() >= 3 .and. Get_NearFloorConnection() <= 10 .and.& Get_JointConnectionPossible() == .false. .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& - FillupHeadInstallation == .false.) then + StudentStation%FillupHeadInstallation == .false.) then call Set_IrIbopPermission(.true.) return diff --git a/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 b/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 index 0706422..3ff1e30 100644 --- a/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 @@ -5,7 +5,7 @@ module CIrSafetyValvePermission subroutine Evaluate_IrSafetyValvePermission() use TD_DrillStemComponents - use CStudentStationVariables, only: FillupHeadInstallation + use CStudentStationVariables!!, only: StudentStation%FillupHeadInstallation implicit none @@ -23,7 +23,7 @@ module CIrSafetyValvePermission (Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 10.0) .and.& Get_JointConnectionPossible() == .false. .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& - FillupHeadInstallation == .false.) then + StudentStation%FillupHeadInstallation == .false.) then call Set_IrSafetyValvePermission(.true.) return diff --git a/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 index 9cc822d..8e334ab 100644 --- a/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 @@ -4,7 +4,7 @@ module CBucketEnum contains subroutine Evaluate_MudBucket() - use CStudentStationVariables, only: MudBoxInstallation + use CStudentStationVariables!, only: StudentStation%MudBoxInstallation implicit none @@ -25,9 +25,9 @@ module CBucketEnum if (Get_MudBucket() == MUD_BUCKET_INSTALL) then - MudBoxInstallation = .true. + StudentStation%MudBoxInstallation = .true. else if (Get_MudBucket() == MUD_BUCKET_REMOVE) then - MudBoxInstallation = .false. + StudentStation%MudBoxInstallation = .false. endif end subroutine diff --git a/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 index 89e1ea5..8360f24 100644 --- a/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 @@ -4,7 +4,7 @@ module CHeadEnum contains subroutine Evaluate_FillupHead() - use CStudentStationVariables, only: FillupHeadInstallation + use CStudentStationVariables!, only: StudentStation%FillupHeadInstallation implicit none @@ -27,9 +27,9 @@ module CHeadEnum if (Get_FillupHead() == FILLUP_HEAD_INSTALL) then - FillupHeadInstallation = .true. + StudentStation%FillupHeadInstallation = .true. else if (Get_FillupHead() == FILLUP_HEAD_REMOVE) then - FillupHeadInstallation = .false. + StudentStation%FillupHeadInstallation = .false. endif end subroutine @@ -37,7 +37,7 @@ module CHeadEnum ! subroutine Subscribe_FillupHead() ! use CStudentStationVariables ! implicit none - ! call OnFillupHeadInstallationPress%Add(ButtonPress_FillupHeadInstallation) + ! call OnStudentStation%FillupHeadInstallationPress%Add(ButtonPress_StudentStation%FillupHeadInstallation) ! call OnFillupHeadRemovePress%Add(ButtonPress_FillupHeadRemove) ! end subroutine @@ -50,7 +50,7 @@ module CHeadEnum if (Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST - print*, 'ButtonPress_FillupHeadInstallation=TopDrive' + print*, 'ButtonPress_StudentStation%FillupHeadInstallation=TopDrive' #endif @@ -72,7 +72,7 @@ module CHeadEnum if (Hoisting%DriveType == Kelly_DriveType) then #ifdef OST - print*, 'ButtonPress_FillupHeadInstallation=Kelly' + print*, 'ButtonPress_StudentStation%FillupHeadInstallation=Kelly' #endif diff --git a/CSharp/Problems/CGaugesProblemsVariables.f90 b/CSharp/Problems/CGaugesProblemsVariables.f90 index b372575..c73202a 100644 --- a/CSharp/Problems/CGaugesProblemsVariables.f90 +++ b/CSharp/Problems/CGaugesProblemsVariables.f90 @@ -210,8 +210,8 @@ module CGaugesProblemsVariables implicit none integer, intent (in) :: status ! if(associated(StandPipePressurePtr)) call StandPipePressurePtr(status) - if(status == Clear_StatusType) StandPipePressure_DataDisplayMalf = 0 - if(status == Executed_StatusType) StandPipePressure_DataDisplayMalf = 1 + if(status == Clear_StatusType) MudSystem%StandPipePressure_DataDisplayMalf = 0 + if(status == Executed_StatusType) MudSystem%StandPipePressure_DataDisplayMalf = 1 endsubroutine subroutine ChangeCasingPressure(status) @@ -254,8 +254,8 @@ module CGaugesProblemsVariables implicit none integer, intent (in) :: status ! if(associated(TripTankPtr)) call TripTankPtr(status) - if(status == Clear_StatusType) TripTankPressure_DataDisplayMalf = 0 - if(status == Executed_StatusType) TripTankPressure_DataDisplayMalf = 1 + if(status == Clear_StatusType) MudSystem%TripTankPressure_DataDisplayMalf = 0 + if(status == Executed_StatusType) MudSystem%TripTankPressure_DataDisplayMalf = 1 endsubroutine subroutine ChangePitGainLoss(status) @@ -263,8 +263,8 @@ module CGaugesProblemsVariables implicit none integer, intent (in) :: status ! if(associated(PitGainLossPtr)) call PitGainLossPtr(status) - if(status == Clear_StatusType) PitGainLossGaugeMalf = 0 - if(status == Executed_StatusType) PitGainLossGaugeMalf = 1 + if(status == Clear_StatusType) MudSystem%PitGainLossGaugeMalf = 0 + if(status == Executed_StatusType) MudSystem%PitGainLossGaugeMalf = 1 endsubroutine subroutine ChangeMudTankVolume(status) @@ -341,8 +341,8 @@ module CGaugesProblemsVariables implicit none integer, intent (in) :: status ! if(associated(StandPipe1Ptr)) call StandPipe1Ptr(status) - if(status == Clear_StatusType) StandPipeGauge1Malf = 0 - if(status == Executed_StatusType) StandPipeGauge1Malf = 1 + if(status == Clear_StatusType) MudSystem%StandPipeGauge1Malf = 0 + if(status == Executed_StatusType) MudSystem%StandPipeGauge1Malf = 1 endsubroutine subroutine ChangeStandPipe2(status) @@ -350,8 +350,8 @@ module CGaugesProblemsVariables implicit none integer, intent (in) :: status ! if(associated(StandPipe2Ptr)) call StandPipe2Ptr(status) - if(status == Clear_StatusType) StandPipeGauge2Malf = 0 - if(status == Executed_StatusType) StandPipeGauge2Malf = 1 + if(status == Clear_StatusType) MudSystem%StandPipeGauge2Malf = 0 + if(status == Executed_StatusType) MudSystem%StandPipeGauge2Malf = 1 endsubroutine subroutine ChangeDrillPipePressure(status) @@ -359,8 +359,8 @@ module CGaugesProblemsVariables implicit none integer, intent (in) :: status ! if(associated(DrillPipePressurePtr)) call DrillPipePressurePtr(status) - if(status == Clear_StatusType) DrillPipePressureMalf = 0 - if(status == Executed_StatusType) DrillPipePressureMalf = 1 + if(status == Clear_StatusType) MudSystem%DrillPipePressureMalf = 0 + if(status == Executed_StatusType) MudSystem%DrillPipePressureMalf = 1 endsubroutine subroutine ChangeChokePosition(status) diff --git a/CSharp/StudentStation/CStudentStation.f90 b/CSharp/StudentStation/CStudentStation.f90 deleted file mode 100644 index 729f367..0000000 --- a/CSharp/StudentStation/CStudentStation.f90 +++ /dev/null @@ -1,98 +0,0 @@ -module CStudentStation - use CStudentStationVariables - use CManifolds - implicit none - public - contains - - ! Input routines - subroutine SetFillupHeadInstallation(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetFillupHeadInstallation - !DEC$ ATTRIBUTES ALIAS: 'SetFillupHeadInstallation' :: SetFillupHeadInstallation - implicit none - logical, intent(in) :: v - FillupHeadInstallation = v - if(v)then - call OnFillupHeadInstallationPress%RunAll() - else - call OnFillupHeadRemovePress%RunAll() - endif -#ifdef deb - print*, 'FillupHeadInstallation=', FillupHeadInstallation -#endif - end subroutine - - subroutine SetMudBoxInstallation(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudBoxInstallation - !DEC$ ATTRIBUTES ALIAS: 'SetMudBoxInstallation' :: SetMudBoxInstallation - implicit none - logical, intent(in) :: v - MudBoxInstallation = v - if(v)then - call OnMudBoxInstallationPress%RunAll() - else - call OnMudBoxRemovePress%RunAll() - endif -#ifdef deb - print*, 'MudBoxInstallation=', MudBoxInstallation -#endif - end subroutine - - - subroutine SetTapSelector(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTapSelector - !DEC$ ATTRIBUTES ALIAS: 'SetTapSelector' :: SetTapSelector - implicit none - logical, intent(in) :: v - TapSelector = v -#ifdef deb - print*, 'TapSelector=', TapSelector -#endif - end subroutine - - - subroutine SetPitGainLossZero(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPitGainLossZero - !DEC$ ATTRIBUTES ALIAS: 'SetPitGainLossZero' :: SetPitGainLossZero - implicit none - logical, intent(in) :: v - PitGainLossZero = v -#ifdef deb - print*, 'PitGainLossZero=', PitGainLossZero -#endif - end subroutine - - - - - - - - - - ! Output routines - logical function GetFillupHeadInstallation() - !DEC$ ATTRIBUTES DLLEXPORT :: GetFillupHeadInstallation - !DEC$ ATTRIBUTES ALIAS: 'GetFillupHeadInstallation' :: GetFillupHeadInstallation - implicit none - GetFillupHeadInstallation = FillupHeadInstallation - !GetFillupHeadInstallation = .true. - end function - - logical function GetMudBoxInstallation() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMudBoxInstallation - !DEC$ ATTRIBUTES ALIAS: 'GetMudBoxInstallation' :: GetMudBoxInstallation - implicit none - GetMudBoxInstallation = MudBoxInstallation - !GetMudBoxInstallation = .true. - end function - - !logical function GetTapSelector() - !!DEC$ ATTRIBUTES DLLEXPORT :: GetTapSelector - !!DEC$ ATTRIBUTES ALIAS: 'GetTapSelector' :: GetTapSelector - ! implicit none - ! GetTapSelector = TapSelector - !end function - - -end module CStudentStation \ No newline at end of file diff --git a/CSharp/StudentStation/CStudentStationVariables.f90 b/CSharp/StudentStation/CStudentStationVariables.f90 index 37f354f..23ec1e3 100644 --- a/CSharp/StudentStation/CStudentStationVariables.f90 +++ b/CSharp/StudentStation/CStudentStationVariables.f90 @@ -4,17 +4,22 @@ module CStudentStationVariables public ! Input vars - logical :: FillupHeadInstallation - type(VoidEventHandlerCollection) :: OnFillupHeadInstallationPress - type(VoidEventHandlerCollection) :: OnFillupHeadRemovePress + type StudentStationType + logical :: FillupHeadInstallation + logical :: PitGainLossZero + logical :: MudBoxInstallation + logical :: TapSelector + end type StudentStationType + type(StudentStationType)::StudentStation + ! type(VoidEventHandlerCollection) :: OnStudentStation%FillupHeadInstallationPress + ! type(VoidEventHandlerCollection) :: OnFillupHeadRemovePress - logical :: MudBoxInstallation - type(VoidEventHandlerCollection) :: OnMudBoxInstallationPress - type(VoidEventHandlerCollection) :: OnMudBoxRemovePress + ! type(VoidEventHandlerCollection) :: OnMudBoxInstallationPress + ! type(VoidEventHandlerCollection) :: + - logical :: TapSelector - logical :: PitGainLossZero + ! Output vars contains diff --git a/Data Structures.txt b/Data Structures.txt index 8f16725..02e83b7 100644 --- a/Data Structures.txt +++ b/Data Structures.txt @@ -89,5 +89,5 @@ Equipments: AirDrivenPump AirPumpLine CHOOKE (previously exists) - MudSystem:......... + MudSystem: \ No newline at end of file diff --git a/Equipments/MudSystem/Circulation_Code_Select.f90 b/Equipments/MudSystem/Circulation_Code_Select.f90 index 8b0bd6f..078e280 100644 --- a/Equipments/MudSystem/Circulation_Code_Select.f90 +++ b/Equipments/MudSystem/Circulation_Code_Select.f90 @@ -15,11 +15,11 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver implicit none - Integer i + Integer i,KickNumber !NewInfluxNumber = NoGasPocket - MudSystemDotFlow_timeCounter= MudSystemDotFlow_timeCounter+1 + MudSystem%Flow_timeCounter= MudSystem%Flow_timeCounter+1 !if (ChokePanelStrokeResetSwitch == 1) then ! Flow_timeCounter= 0 @@ -35,7 +35,7 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver !=================================================================== - MudSystemDotiLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data) + MudSystem%iLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data) !KickMigration_2SideBit= .false. Call Set_FlowPipeDisconnect(.false.) Call Set_FlowKellyDisconnect(.false.) @@ -60,99 +60,90 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver - IF ( MudSystemDotNewInfluxNumber > 0 ) THEN + IF ( MudSystem%NewInfluxNumber > 0 ) THEN !write(*,*) 'KickOffBottom , ROP=' , KickOffBottom , Rate_of_Penetration call Kick_Migration endif ! ============================ must be after migration ============================== - DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystemDotNewInfluxNumber + DO KickNumber= MudSystem%NewInfluxNumber-NoGasPocket+1 , MudSystem%NewInfluxNumber ! FINDING NEW KICK LOCATIONS: - MudSystemDotAnn_KickLoc= 0 - MudSystemDotOp_KickLoc= 0 - MudSystemDotChokeLine_KickLoc= 0 + MudSystem%Ann_KickLoc= 0 + MudSystem%Op_KickLoc= 0 + MudSystem%ChokeLine_KickLoc= 0 - do i = 1, Ann_MudOrKick%Length () - if (Ann_MudOrKick%Array(i) == MudSystemDotKickNumber) then - MudSystemDotAnn_KickLoc = i + do i = 1, MudSystem%Ann_MudOrKick%Length () + if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then + MudSystem%Ann_KickLoc = i exit endif end do - do i = 1, Op_MudOrKick%Length () - if (Op_MudOrKick%Array(i) == MudSystemDotKickNumber) then - MudSystemDotOp_KickLoc = i + do i = 1, MudSystem%Op_MudOrKick%Length () + if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then + MudSystem%Op_KickLoc = i exit endif end do - do i = 1, ChokeLine_MudOrKick%Length () - if (ChokeLine_MudOrKick%Array(i) == MudSystemDotKickNumber) then - MudSystemDotChokeLine_KickLoc = i + do i = 1, MudSystem%ChokeLine_MudOrKick%Length () + if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then + MudSystem%ChokeLine_KickLoc = i exit endif end do -! ============================ must be after migration-end =========================== + ! ============================ must be after migration-end =========================== - IF (ALLOCATED(GasPocketWeight%Array) .and. MudSystemDotKickNumber == MudSystemDotNewInfluxNumber .AND. NOT(KickOffBottom) .AND. WellHeadIsOpen) THEN + IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == MudSystem%NewInfluxNumber .AND. NOT(KickOffBottom) .AND. MudSystem%WellHeadIsOpen) THEN - cycle - - ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN - - if (((GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) > 0.0 .AND. WellHeadIsOpen) .or. MudSystemDotKickexpansion_DueToMudLost) ) call Kick_Expansion + cycle + + ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN - if ((GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) < 0.0 ) .OR. WellHeadIsOpen == .FALSE.) CALL Kick_Contraction + if (((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) > 0.0 .AND. MudSystem%WellHeadIsOpen) .or. MudSystem%Kickexpansion_DueToMudLost) ) call Kick_Expansion + + if ((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. MudSystem%WellHeadIsOpen == .FALSE.) CALL Kick_Contraction - ENDIF - - - ENDDO - + ENDIF + ENDDO + MudSystem%KickNumber = KickNumber + + MudSystem%LostInTripOutIsDone= .false. + if( MudSystem%DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then + !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp + call Pump_and_TripIn + elseif (MudSystem%DeltaVolumeOp < 0.0) then + ! when we have Utube and tripping out simultaneously, it uses "TripOut_and_Pump" subroutine, and then Utube code is done + ! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in + call TripOut_and_Pump + endif - - MudSystemDotLostInTripOutIsDone= .false. - - if( MudSystemDotDeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then - !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - call Pump_and_TripIn - elseif (MudSystemDotDeltaVolumeOp < 0.0) then - ! when we have Utube and tripping out simultaneously, it uses "TripOut_and_Pump" subroutine, and then Utube code is done - ! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in - call TripOut_and_Pump - endif - - WellOutletDensity= Ann_Density%Last() ! (ppg) used in MudSystem + MudSystem%WellOutletDensity= MudSystem%Ann_Density%Last() ! (ppg) used in MudSystem - if (MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18 - call ChokeLineMud - endif - + if (MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18 + call ChokeLineMud + endif - call Choke_GasSound - !WRITE(*,*) 'CIRCU-Ann_Saved_MudDischarged_Volume' , Ann_Saved_MudDischarged_Volume + call Choke_GasSound -! ****Utube is called in Plot Subroutine**** + !WRITE(*,*) 'CIRCU-Ann_Saved_MudDischarged_Volume' , Ann_Saved_MudDischarged_Volume - Call Instructor_CirculationMud_Edit + !****Utube is called in Plot Subroutine**** + + Call Instructor_CirculationMud_Edit - call PlotFinalMudElements - - MudChecked= .true. - MudSystemDotUtubePossibility= .true. - - - !WRITE(*,*) '***********************************************************************' - - - + call PlotFinalMudElements + + MudSystem%MudChecked= .true. + MudSystem%UtubePossibility= .true. + !WRITE(*,*) '***********************************************************************' end subroutine CirculationCodeSelect \ No newline at end of file diff --git a/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 b/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 index 4e7fd65..d865d2b 100644 --- a/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 +++ b/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 @@ -3,99 +3,96 @@ subroutine DEALLOCATE_ARRAYS_NormalCirculation() ! is called in module Fluid implicit none -if(allocated(MudSystemDotXstart_PipeSection)) deallocate(MudSystemDotXstart_PipeSection) -if(allocated(MudSystemDotXend_PipeSection)) deallocate(MudSystemDotXend_PipeSection) -if(allocated(MudSystemDotPipeSection_VolumeCapacity)) deallocate(MudSystemDotPipeSection_VolumeCapacity) -if(allocated(MudSystemDotArea_PipeSectionFt)) deallocate(MudSystemDotArea_PipeSectionFt) -if(allocated(MudSystemDotOD_PipeSectionInch)) deallocate(MudSystemDotOD_PipeSectionInch) -if(allocated(MudSystemDotID_PipeSectionInch)) deallocate(MudSystemDotID_PipeSectionInch) -if(allocated(MudSystemDotXstart_OpSection)) deallocate(MudSystemDotXstart_OpSection) -if(allocated(MudSystemDotXend_OpSection)) deallocate(MudSystemDotXend_OpSection) -if(allocated(MudSystemDotArea_OpSectionFt)) deallocate(MudSystemDotArea_OpSectionFt) -if(allocated(MudSystemDotOD_OpSectionInch)) deallocate(MudSystemDotOD_OpSectionInch) -if(allocated(MudSystemDotID_OpSectionInch)) deallocate(MudSystemDotID_OpSectionInch) -if(allocated(MudSystemDotOpSection_VolumeCapacity)) deallocate(MudSystemDotOpSection_VolumeCapacity) -if(allocated(MudSystemDotGeoTypeOp)) deallocate(MudSystemDotGeoTypeOp) -if(allocated(MudSystemDotGeoType)) deallocate(MudSystemDotGeoType) +if(allocated(MudSystem%Xstart_PipeSection)) deallocate(MudSystem%Xstart_PipeSection) +if(allocated(MudSystem%Xend_PipeSection)) deallocate(MudSystem%Xend_PipeSection) +if(allocated(MudSystem%PipeSection_VolumeCapacity)) deallocate(MudSystem%PipeSection_VolumeCapacity) +if(allocated(MudSystem%Area_PipeSectionFt)) deallocate(MudSystem%Area_PipeSectionFt) +if(allocated(MudSystem%OD_PipeSectionInch)) deallocate(MudSystem%OD_PipeSectionInch) +if(allocated(MudSystem%ID_PipeSectionInch)) deallocate(MudSystem%ID_PipeSectionInch) +if(allocated(MudSystem%Xstart_OpSection)) deallocate(MudSystem%Xstart_OpSection) +if(allocated(MudSystem%Xend_OpSection)) deallocate(MudSystem%Xend_OpSection) +if(allocated(MudSystem%Area_OpSectionFt)) deallocate(MudSystem%Area_OpSectionFt) +if(allocated(MudSystem%OD_OpSectionInch)) deallocate(MudSystem%OD_OpSectionInch) +if(allocated(MudSystem%ID_OpSectionInch)) deallocate(MudSystem%ID_OpSectionInch) +if(allocated(MudSystem%OpSection_VolumeCapacity)) deallocate(MudSystem%OpSection_VolumeCapacity) +if(allocated(MudSystem%GeoTypeOp)) deallocate(MudSystem%GeoTypeOp) +if(allocated(MudSystem%GeoType)) deallocate(MudSystem%GeoType) - call MudSystemDotHz_MudDischarged_Volume%Empty() - call MudSystemDotHz_Mud_Backhead_X%Empty() - call Hz_Mud_Backhead_section%Empty() - call MudSystemDotHz_Mud_Forehead_X%Empty() - call Hz_Mud_Forehead_section%Empty() - call MudSystemDotHz_Density%Empty() - call MudSystemDotHz_RemainedVolume_in_LastSection%Empty() - call MudSystemDotHz_EmptyVolume_inBackheadLocation%Empty() - call Hz_MudOrKick%Empty() + call MudSystem%Hz_MudDischarged_Volume%Empty() + call MudSystem%Hz_Mud_Backhead_X%Empty() + call MudSystem%Hz_Mud_Backhead_section%Empty() + call MudSystem%Hz_Mud_Forehead_X%Empty() + call MudSystem%Hz_Mud_Forehead_section%Empty() + call MudSystem%Hz_Density%Empty() + call MudSystem%Hz_RemainedVolume_in_LastSection%Empty() + call MudSystem%Hz_EmptyVolume_inBackheadLocation%Empty() + call MudSystem%Hz_MudOrKick%Empty() - call MudSystemDotSt_MudDischarged_Volume%Empty() - call MudSystemDotSt_Mud_Backhead_X%Empty() - call St_Mud_Backhead_section%Empty() - call MudSystemDotSt_Mud_Forehead_X%Empty() - call St_Mud_Forehead_section%Empty() - call St_Density%Empty() - call MudSystemDotSt_RemainedVolume_in_LastSection%Empty() - call MudSystemDotSt_EmptyVolume_inBackheadLocation%Empty() - call St_MudOrKick%Empty() + call MudSystem%St_MudDischarged_Volume%Empty() + call MudSystem%St_Mud_Backhead_X%Empty() + call MudSystem%St_Mud_Backhead_section%Empty() + call MudSystem%St_Mud_Forehead_X%Empty() + call MudSystem%St_Mud_Forehead_section%Empty() + call MudSystem%St_Density%Empty() + call MudSystem%St_RemainedVolume_in_LastSection%Empty() + call MudSystem%St_EmptyVolume_inBackheadLocation%Empty() + call MudSystem%St_MudOrKick%Empty() - call MudSystemDotAnn_MudDischarged_Volume%Empty() - call Ann_Mud_Backhead_X%Empty() - call Ann_Mud_Backhead_section%Empty() - call Ann_Mud_Forehead_X%Empty() - call Ann_Mud_Forehead_section%Empty() - call Ann_Density%Empty() - call Ann_RemainedVolume_in_LastSection%Empty() - call Ann_EmptyVolume_inBackheadLocation%Empty() - call Ann_MudOrKick%Empty() - call Ann_CuttingMud%Empty() + call MudSystem%Ann_MudDischarged_Volume%Empty() + call MudSystem%Ann_Mud_Backhead_X%Empty() + call MudSystem%Ann_Mud_Backhead_section%Empty() + call MudSystem%Ann_Mud_Forehead_X%Empty() + call MudSystem%Ann_Mud_Forehead_section%Empty() + call MudSystem%Ann_Density%Empty() + call MudSystem%Ann_RemainedVolume_in_LastSection%Empty() + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Empty() + call MudSystem%Ann_MudOrKick%Empty() + call MudSystem%Ann_CuttingMud%Empty() - call MudSystemDotOp_MudDischarged_Volume%Empty() - call MudSystemDotOp_Mud_Backhead_X%Empty() - call Op_Mud_Backhead_section%Empty() - call MudSystemDotOp_Mud_Forehead_X%Empty() - call Op_Mud_Forehead_section%Empty() - call MudSystemDotOp_Density%Empty() - call MudSystemDotOp_RemainedVolume_in_LastSection%Empty() - call MudSystemDotOp_EmptyVolume_inBackheadLocation%Empty() - call Op_MudOrKick%Empty() + call MudSystem%Op_MudDischarged_Volume%Empty() + call MudSystem%Op_Mud_Backhead_X%Empty() + call MudSystem%Op_Mud_Backhead_section%Empty() + call MudSystem%Op_Mud_Forehead_X%Empty() + call MudSystem%Op_Mud_Forehead_section%Empty() + call MudSystem%Op_Density%Empty() + call MudSystem%Op_RemainedVolume_in_LastSection%Empty() + call MudSystem%Op_EmptyVolume_inBackheadLocation%Empty() + call MudSystem%Op_MudOrKick%Empty() - call MudSystemDotChokeLine_MudDischarged_Volume%Empty() - call MudSystemDotChokeLine_Mud_Backhead_X%Empty() - call ChokeLine_Mud_Backhead_section%Empty() - call MudSystemDotChokeLine_Mud_Forehead_X%Empty() - call ChokeLine_Mud_Forehead_section%Empty() - call MudSystemDotChokeLine_Density%Empty() - call MudSystemDotChokeLine_RemainedVolume_in_LastSection%Empty() - call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Empty() - call ChokeLine_MudOrKick%Empty() + call MudSystem%ChokeLine_MudDischarged_Volume%Empty() + call MudSystem%ChokeLine_Mud_Backhead_X%Empty() + call MudSystem%ChokeLine_Mud_Backhead_section%Empty() + call MudSystem%ChokeLine_Mud_Forehead_X%Empty() + call MudSystem%ChokeLine_Mud_Forehead_section%Empty() + call MudSystem%ChokeLine_Density%Empty() + call MudSystem%ChokeLine_RemainedVolume_in_LastSection%Empty() + call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Empty() + call MudSystem%ChokeLine_MudOrKick%Empty() - call Xend_MudElement%Empty() - call Xstart_MudElement%Empty() - call TVDend_MudElement%Empty() - call TVDstart_MudElement%Empty() - call Density_MudElement%Empty() - call MudGeoType%Empty() - call PipeID_MudElement%Empty() - call PipeOD_MudElement%Empty() - call MudType_MudElement%Empty() + call MudSystem%Xend_MudElement%Empty() + call MudSystem%Xstart_MudElement%Empty() + call MudSystem%TVDend_MudElement%Empty() + call MudSystem%TVDstart_MudElement%Empty() + call MudSystem%Density_MudElement%Empty() + call MudSystem%MudGeoType%Empty() + call MudSystem%PipeID_MudElement%Empty() + call MudSystem%PipeOD_MudElement%Empty() + call MudSystem%MudType_MudElement%Empty() - call Xend_OpMudElement%Empty() - call Xstart_OpMudElement%Empty() - call TVDend_OpMudElement%Empty() - call TVDstart_OPMudElement%Empty() - call Density_OpMudElement%Empty() - call PipeID_OpMudElement%Empty() - call PipeOD_OpMudElement%Empty() - call MudTypeOp_MudElement%Empty() - - - + call MudSystem%Xend_OpMudElement%Empty() + call MudSystem%Xstart_OpMudElement%Empty() + call MudSystem%TVDend_OpMudElement%Empty() + call MudSystem%TVDstart_OpMudElement%Empty() + call MudSystem%Density_OpMudElement%Empty() + call MudSystem%PipeID_OpMudElement%Empty() + call MudSystem%PipeOD_OpMudElement%Empty() + call MudSystem%MudTypeOp_MudElement%Empty() end subroutine @@ -107,16 +104,16 @@ subroutine RemoveAnnulusMudArrays(ilocal) INTEGER :: ilocal - call MudSystemDotAnn_MudDischarged_Volume%Remove (ilocal) - call Ann_Mud_Backhead_X%Remove (ilocal) - call Ann_Mud_Backhead_section%Remove (ilocal) - call Ann_Mud_Forehead_X%Remove (ilocal) - call Ann_Mud_Forehead_section%Remove (ilocal) - call Ann_Density%Remove (ilocal) - call Ann_RemainedVolume_in_LastSection%Remove (ilocal) - call Ann_EmptyVolume_inBackheadLocation%Remove (ilocal) - call Ann_MudOrKick%Remove (ilocal) - call Ann_CuttingMud%Remove (ilocal) + call MudSystem%Ann_MudDischarged_Volume%Remove (ilocal) + call MudSystem%Ann_Mud_Backhead_X%Remove (ilocal) + call MudSystem%Ann_Mud_Backhead_section%Remove (ilocal) + call MudSystem%Ann_Mud_Forehead_X%Remove (ilocal) + call MudSystem%Ann_Mud_Forehead_section%Remove (ilocal) + call MudSystem%Ann_Density%Remove (ilocal) + call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (ilocal) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (ilocal) + call MudSystem%Ann_MudOrKick%Remove (ilocal) + call MudSystem%Ann_CuttingMud%Remove (ilocal) @@ -130,15 +127,15 @@ subroutine RemoveStringMudArrays(ilocal) INTEGER :: ilocal - call MudSystemDotSt_MudDischarged_Volume%Remove (ilocal) - call MudSystemDotSt_Mud_Backhead_X%Remove (ilocal) - call St_Mud_Backhead_section%Remove (ilocal) - call MudSystemDotSt_Mud_Forehead_X%Remove (ilocal) - call St_Mud_Forehead_section%Remove (ilocal) - call St_Density%Remove (ilocal) - call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (ilocal) - call St_MudOrKick%Remove (ilocal) + call MudSystem%St_MudDischarged_Volume%Remove (ilocal) + call MudSystem%St_Mud_Backhead_X%Remove (ilocal) + call MudSystem%St_Mud_Backhead_section%Remove (ilocal) + call MudSystem%St_Mud_Forehead_X%Remove (ilocal) + call MudSystem%St_Mud_Forehead_section%Remove (ilocal) + call MudSystem%St_Density%Remove (ilocal) + call MudSystem%St_RemainedVolume_in_LastSection%Remove (ilocal) + call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (ilocal) + call MudSystem%St_MudOrKick%Remove (ilocal) @@ -152,15 +149,15 @@ subroutine RemoveOpMudArrays(ilocal) INTEGER :: ilocal - call MudSystemDotOp_MudDischarged_Volume%Remove (ilocal) - call MudSystemDotOp_Mud_Backhead_X%Remove (ilocal) - call Op_Mud_Backhead_section%Remove (ilocal) - call MudSystemDotOp_Mud_Forehead_X%Remove (ilocal) - call Op_Mud_Forehead_section%Remove (ilocal) - call MudSystemDotOp_Density%Remove (ilocal) - call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (ilocal) - call Op_MudOrKick%Remove (ilocal) + call MudSystem%Op_MudDischarged_Volume%Remove (ilocal) + call MudSystem%Op_Mud_Backhead_X%Remove (ilocal) + call MudSystem%Op_Mud_Backhead_section%Remove (ilocal) + call MudSystem%Op_Mud_Forehead_X%Remove (ilocal) + call MudSystem%Op_Mud_Forehead_section%Remove (ilocal) + call MudSystem%Op_Density%Remove (ilocal) + call MudSystem%Op_RemainedVolume_in_LastSection%Remove (ilocal) + call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (ilocal) + call MudSystem%Op_MudOrKick%Remove (ilocal) @@ -173,15 +170,15 @@ subroutine RemoveHzMudArrays(ilocal) INTEGER :: ilocal - call MudSystemDotHz_MudDischarged_Volume%Remove (ilocal) - call MudSystemDotHz_Mud_Backhead_X%Remove (ilocal) - call Hz_Mud_Backhead_section%Remove (ilocal) - call MudSystemDotHz_Mud_Forehead_X%Remove (ilocal) - call Hz_Mud_Forehead_section%Remove (ilocal) - call MudSystemDotHz_Density%Remove (ilocal) - call MudSystemDotHz_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystemDotHz_EmptyVolume_inBackheadLocation%Remove (ilocal) - call Hz_MudOrKick%Remove (ilocal) + call MudSystem%Hz_MudDischarged_Volume%Remove (ilocal) + call MudSystem%Hz_Mud_Backhead_X%Remove (ilocal) + call MudSystem%Hz_Mud_Backhead_section%Remove (ilocal) + call MudSystem%Hz_Mud_Forehead_X%Remove (ilocal) + call MudSystem%Hz_Mud_Forehead_section%Remove (ilocal) + call MudSystem%Hz_Density%Remove (ilocal) + call MudSystem%Hz_RemainedVolume_in_LastSection%Remove (ilocal) + call MudSystem%Hz_EmptyVolume_inBackheadLocation%Remove (ilocal) + call MudSystem%Hz_MudOrKick%Remove (ilocal) diff --git a/Equipments/MudSystem/Disconnecting_Pipe.f90 b/Equipments/MudSystem/Disconnecting_Pipe.f90 index d4644fc..d1c03a8 100644 --- a/Equipments/MudSystem/Disconnecting_Pipe.f90 +++ b/Equipments/MudSystem/Disconnecting_Pipe.f90 @@ -21,7 +21,7 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect !TD_RemoveVolume= TD_RemoveVolume* 7.48051948 ! ft^3 to gal - ExcessMudVolume= sum(MudSystemDotSt_MudDischarged_Volume%Array(:)) - sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts)) + ExcessMudVolume= sum(MudSystem%St_MudDischarged_Volume%Array(:)) - sum(MudSystem%PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) ! ======if(ExcessMudVolume <= 0.) No Modification Needed Because Removed Pipe was Empty===== @@ -31,9 +31,9 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect if (ExcessMudVolume > 0.) then if ( Manifold%Valve(53)%Status == .true. ) then - MudBucketVolume= ExcessMudVolume + MudSystem%MudBucketVolume= ExcessMudVolume else - MudBucketVolume= 0.0 + MudSystem%MudBucketVolume= 0.0 endif @@ -62,36 +62,36 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect ExcessMudVolume_Remained= ExcessMudVolume ! ft^3 to gal - MudSystemDotimud=1 + imud=1 Do - if(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) < ExcessMudVolume_Remained) then - ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) - call MudSystemDotSt_MudDischarged_Volume%Remove (MudSystemDotimud) - call MudSystemDotSt_Mud_Backhead_X%Remove (MudSystemDotimud) - call St_Mud_Backhead_section%Remove (MudSystemDotimud) - call MudSystemDotSt_Mud_Forehead_X%Remove (MudSystemDotimud) - call St_Mud_Forehead_section%Remove (MudSystemDotimud) - call St_Density%Remove (MudSystemDotimud) - call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) - call St_MudOrKick%Remove (MudSystemDotimud) + if(MudSystem%St_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then + ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystem%St_MudDischarged_Volume%Array(imud) + call MudSystem%St_MudDischarged_Volume%Remove (imud) + call MudSystem%St_Mud_Backhead_X%Remove (imud) + call MudSystem%St_Mud_Backhead_section%Remove (imud) + call MudSystem%St_Mud_Forehead_X%Remove (imud) + call MudSystem%St_Mud_Forehead_section%Remove (imud) + call MudSystem%St_Density%Remove (imud) + call MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) + call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) + call MudSystem%St_MudOrKick%Remove (imud) - elseif(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) > ExcessMudVolume_Remained) then - MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- ExcessMudVolume_Remained + elseif(MudSystem%St_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then + MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained exit else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) - call MudSystemDotSt_MudDischarged_Volume%Remove (MudSystemDotimud) - call MudSystemDotSt_Mud_Backhead_X%Remove (MudSystemDotimud) - call St_Mud_Backhead_section%Remove (MudSystemDotimud) - call MudSystemDotSt_Mud_Forehead_X%Remove (MudSystemDotimud) - call St_Mud_Forehead_section%Remove (MudSystemDotimud) - call St_Density%Remove (MudSystemDotimud) - call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) - call St_MudOrKick%Remove (MudSystemDotimud) + call MudSystem%St_MudDischarged_Volume%Remove (imud) + call MudSystem%St_Mud_Backhead_X%Remove (imud) + call MudSystem%St_Mud_Backhead_section%Remove (imud) + call MudSystem%St_Mud_Forehead_X%Remove (imud) + call MudSystem%St_Mud_Forehead_section%Remove (imud) + call MudSystem%St_Density%Remove (imud) + call MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) + call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) + call MudSystem%St_MudOrKick%Remove (imud) exit endif diff --git a/Equipments/MudSystem/Elements_Creation.f90 b/Equipments/MudSystem/Elements_Creation.f90 index d2bd1fe..962e883 100644 --- a/Equipments/MudSystem/Elements_Creation.f90 +++ b/Equipments/MudSystem/Elements_Creation.f90 @@ -19,53 +19,53 @@ subroutine ElementsCreation ! is called in subroutine Fluid_Flow_Solver implicit none integer jelement, jmud, jsection,ielement,i - integer jopelement,jopmud,jopsection + integer jopelement,jopmud,jopsection,iisection,isection,OpSection !===========================================================WELL============================================================ !===========================================================WELL============================================================ - if(allocated(MudSystemDotXstart_PipeSection)) deallocate(MudSystemDotXstart_PipeSection) - if(allocated(MudSystemDotXend_PipeSection)) deallocate(MudSystemDotXend_PipeSection) - if(allocated(MudSystemDotPipeSection_VolumeCapacity)) deallocate(MudSystemDotPipeSection_VolumeCapacity) - if(allocated(MudSystemDotArea_PipeSectionFt)) deallocate(MudSystemDotArea_PipeSectionFt) - if(allocated(MudSystemDotGeoType)) deallocate(MudSystemDotGeoType) - if(allocated(MudSystemDotOD_PipeSectionInch)) deallocate(MudSystemDotOD_PipeSectionInch) - if(allocated(MudSystemDotID_PipeSectionInch)) deallocate(MudSystemDotID_PipeSectionInch) - if(allocated(MudSystemDotAngle_PipeSection)) deallocate(MudSystemDotAngle_PipeSection) - - if(allocated(MudSystemDotXstart_OpSection)) deallocate(MudSystemDotXstart_OpSection) - if(allocated(MudSystemDotXend_OpSection)) deallocate(MudSystemDotXend_OpSection) - if(allocated(MudSystemDotOpSection_VolumeCapacity)) deallocate(MudSystemDotOpSection_VolumeCapacity) - if(allocated(MudSystemDotArea_OpSectionFt)) deallocate(MudSystemDotArea_OpSectionFt) - if(allocated(MudSystemDotGeoTypeOp)) deallocate(MudSystemDotGeoTypeOp) - if(allocated(MudSystemDotOD_OpSectionInch)) deallocate(MudSystemDotOD_OpSectionInch) - if(allocated(MudSystemDotID_OpSectionInch)) deallocate(MudSystemDotID_OpSectionInch) - if(allocated(MudSystemDotAngle_OpSection)) deallocate(MudSystemDotAngle_OpSection) + if(allocated(MudSystem%Xstart_PipeSection)) deallocate(MudSystem%Xstart_PipeSection) + if(allocated(MudSystem%Xend_PipeSection)) deallocate(MudSystem%Xend_PipeSection) + if(allocated(MudSystem%PipeSection_VolumeCapacity)) deallocate(MudSystem%PipeSection_VolumeCapacity) + if(allocated(MudSystem%Area_PipeSectionFt)) deallocate(MudSystem%Area_PipeSectionFt) + if(allocated(MudSystem%GeoType)) deallocate(MudSystem%GeoType) + if(allocated(MudSystem%OD_PipeSectionInch)) deallocate(MudSystem%OD_PipeSectionInch) + if(allocated(MudSystem%ID_PipeSectionInch)) deallocate(MudSystem%ID_PipeSectionInch) + if(allocated(MudSystem%Angle_PipeSection)) deallocate(MudSystem%Angle_PipeSection) + + if(allocated(MudSystem%Xstart_OpSection)) deallocate(MudSystem%Xstart_OpSection) + if(allocated(MudSystem%Xend_OpSection)) deallocate(MudSystem%Xend_OpSection) + if(allocated(MudSystem%OpSection_VolumeCapacity)) deallocate(MudSystem%OpSection_VolumeCapacity) + if(allocated(MudSystem%Area_OpSectionFt)) deallocate(MudSystem%Area_OpSectionFt) + if(allocated(MudSystem%GeoTypeOp)) deallocate(MudSystem%GeoTypeOp) + if(allocated(MudSystem%OD_OpSectionInch)) deallocate(MudSystem%OD_OpSectionInch) + if(allocated(MudSystem%ID_OpSectionInch)) deallocate(MudSystem%ID_OpSectionInch) + if(allocated(MudSystem%Angle_OpSection)) deallocate(MudSystem%Angle_OpSection) -ALLOCATE (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystemDotXend_PipeSection(F_StringIntervalCounts+F_AnnulusIntervalCounts) & - ,MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystemDotArea_PipeSectionFt(F_StringIntervalCounts+F_AnnulusIntervalCounts), & - MudSystemDotGeoType(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystemDotOD_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystemDotID_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts)) +ALLOCATE (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystem%Xend_PipeSection(F_StringIntervalCounts+F_AnnulusIntervalCounts) & + ,MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystem%Area_PipeSectionFt(F_StringIntervalCounts+F_AnnulusIntervalCounts), & + MudSystem%GeoType(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystem%OD_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts),MudSystem%ID_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts)) -ALLOCATE (MudSystemDotXstart_OpSection(F_BottomHoleIntervalCounts),MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts) & - ,MudSystemDotOpSection_VolumeCapacity(F_BottomHoleIntervalCounts),MudSystemDotArea_OpSectionFt(F_BottomHoleIntervalCounts), & - MudSystemDotGeoTypeOp(F_BottomHoleIntervalCounts),MudSystemDotOD_OpSectionInch(F_BottomHoleIntervalCounts),MudSystemDotID_OpSectionInch(F_BottomHoleIntervalCounts)) +ALLOCATE (MudSystem%Xstart_OpSection(F_BottomHoleIntervalCounts),MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts) & + ,MudSystem%OpSection_VolumeCapacity(F_BottomHoleIntervalCounts),MudSystem%Area_OpSectionFt(F_BottomHoleIntervalCounts), & + MudSystem%GeoTypeOp(F_BottomHoleIntervalCounts),MudSystem%OD_OpSectionInch(F_BottomHoleIntervalCounts),MudSystem%ID_OpSectionInch(F_BottomHoleIntervalCounts)) - MudSystemDotOpSection=0 - MudSystemDotisection=0 + MudSystem%OpSection=0 + MudSystem%isection=0 - DO MudSystemDotiisection=1, F_IntervalsTotalCounts - IF (F_Interval(MudSystemDotiisection)%GeoType == 1) THEN - MudSystemDotOpSection= MudSystemDotOpSection+1 - MudSystemDotXstart_OpSection(MudSystemDotOpSection)= (F_Interval(MudSystemDotiisection)%StartDepth) - MudSystemDotXend_OpSection(MudSystemDotOpSection)= (F_Interval(MudSystemDotiisection)%EndDepth) - MudSystemDotArea_OpSectionFt(MudSystemDotOpSection)= PII*((F_Interval(MudSystemDotiisection)%OD/12.0d0)**2-(F_Interval(MudSystemDotiisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) - MudSystemDotOD_OpSectionInch(MudSystemDotOpSection)= (F_Interval(MudSystemDotiisection)%OD) - MudSystemDotID_OpSectionInch(MudSystemDotOpSection)= (F_Interval(MudSystemDotiisection)%ID) !REAL(F_Interval(iisection)%Volume) - MudSystemDotGeoTypeOp(MudSystemDotOpSection)= F_Interval(MudSystemDotiisection)%GeoType ! niaz nist ehtemalan + DO iisection=1, F_IntervalsTotalCounts + IF (F_Interval(iisection)%GeoType == 1) THEN + MudSystem%OpSection= MudSystem%OpSection+1 + MudSystem%Xstart_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%StartDepth) + MudSystem%Xend_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%EndDepth) + MudSystem%Area_OpSectionFt(MudSystem%OpSection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) + MudSystem%OD_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%OD) + MudSystem%ID_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%ID) !REAL(F_Interval(iisection)%Volume) + MudSystem%GeoTypeOp(MudSystem%OpSection)= F_Interval(iisection)%GeoType ! niaz nist ehtemalan !Angle_OpSection(OpSection)= F_Interval(iisection)%Angle !write(*,*) 'iisection=' , iisection !write(*,*) 'StartDepth=' , F_Interval(iisection)%StartDepth @@ -73,17 +73,17 @@ ALLOCATE (MudSystemDotXstart_OpSection(F_BottomHoleIntervalCounts),MudSystemDotX !write(*,*) 'OD=' , F_Interval(iisection)%OD !write(*,*) 'ID=' , F_Interval(iisection)%ID ELSE - MudSystemDotisection= MudSystemDotisection+1 - MudSystemDotXstart_PipeSection(MudSystemDotisection)= (F_Interval(MudSystemDotiisection)%StartDepth) + MudSystem%isection= MudSystem%isection+1 + MudSystem%Xstart_PipeSection(MudSystem%isection)= (F_Interval(iisection)%StartDepth) !write(*,*) 'F_Interval(iisection)%StartDepth=' , F_Interval(iisection)%StartDepth - MudSystemDotXend_PipeSection(MudSystemDotisection)= (F_Interval(MudSystemDotiisection)%EndDepth) + MudSystem%Xend_PipeSection(MudSystem%isection)= (F_Interval(iisection)%EndDepth) !write(*,*) 'F_Interval(iisection)%EndDepth=' , F_Interval(iisection)%EndDepth - MudSystemDotOD_PipeSectionInch(MudSystemDotisection)= (F_Interval(MudSystemDotiisection)%OD) - MudSystemDotArea_PipeSectionFt(MudSystemDotisection)= PII*((F_Interval(MudSystemDotiisection)%OD/12.0d0)**2-(F_Interval(MudSystemDotiisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) - MudSystemDotID_PipeSectionInch(MudSystemDotisection)= (F_Interval(MudSystemDotiisection)%ID) + MudSystem%OD_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%OD) + MudSystem%Area_PipeSectionFt(MudSystem%isection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) + MudSystem%ID_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%ID) !PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948 !REAL(F_Interval(iisection)%Volume) ! (gal) - MudSystemDotGeoType(MudSystemDotisection)= F_Interval(MudSystemDotiisection)%GeoType + MudSystem%GeoType(MudSystem%isection)= F_Interval(iisection)%GeoType !Angle_PipeSection(isection)= F_Interval(iisection)%Angle ENDIF @@ -91,107 +91,107 @@ ALLOCATE (MudSystemDotXstart_OpSection(F_BottomHoleIntervalCounts),MudSystemDotX - call Xstart_MudElement%Empty() - call Xstart_MudElement%Add(MudSystemDotXstart_PipeSection(1)) + call MudSystem%Xstart_MudElement%Empty() + call MudSystem%Xstart_MudElement%Add(MudSystem%Xstart_PipeSection(1)) - call Xstart_OpMudElement%Empty() - call Xstart_OpMudElement%Add(MudSystemDotXstart_OpSection(1)) + call MudSystem%Xstart_OpMudElement%Empty() + call MudSystem%Xstart_OpMudElement%Add(MudSystem%Xstart_OpSection(1)) - call TVDstart_MudElement%Empty() - call TVD_Calculator(MudSystemDotXstart_PipeSection(1),MudSystemDotMudCircVerticalDepth) - call TVDstart_MudElement%Add(MudSystemDotMudCircVerticalDepth) + call MudSystem%TVDstart_MudElement%Empty() + call TVD_Calculator(MudSystem%Xstart_PipeSection(1),MudSystem%MudCircVerticalDepth) + call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) - call TVDstart_OPMudElement%Empty() - call TVD_Calculator(MudSystemDotXstart_OpSection(1),MudSystemDotMudCircVerticalDepth) - call TVDstart_OPMudElement%Add(MudSystemDotMudCircVerticalDepth) + call MudSystem%TVDstart_OpMudElement%Empty() + call TVD_Calculator(MudSystem%Xstart_OpSection(1),MudSystem%MudCircVerticalDepth) + call MudSystem%TVDstart_OpMudElement%Add(MudSystem%MudCircVerticalDepth) - MudSystemDotNoPipeSections= MudSystemDotisection ! sections in string and annulus(GeoType 0 & 2) + MudSystem%NoPipeSections= MudSystem%isection ! sections in string and annulus(GeoType 0 & 2) - DO MudSystemDotOpSection= 1,F_BottomHoleIntervalCounts - MudSystemDotOpSection_VolumeCapacity(MudSystemDotOpSection)= MudSystemDotArea_OpSectionFt(MudSystemDotOpSection)* ABS(MudSystemDotXend_OpSection(MudSystemDotOpSection)-MudSystemDotXstart_OpSection(MudSystemDotOpSection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) + DO OpSection= 1,F_BottomHoleIntervalCounts + MudSystem%OpSection_VolumeCapacity(OpSection)= MudSystem%Area_OpSectionFt(OpSection)* ABS(MudSystem%Xend_OpSection(OpSection)-MudSystem%Xstart_OpSection(OpSection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) ENDDO - - DO MudSystemDotisection= 1,MudSystemDotNoPipeSections - MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection)= MudSystemDotArea_PipeSectionFt(MudSystemDotisection)* ABS(MudSystemDotXend_PipeSection(MudSystemDotisection)-MudSystemDotXstart_PipeSection(MudSystemDotisection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) ! (gal) + MudSystem%OpSection=OpSection + DO isection= 1,MudSystem%NoPipeSections + MudSystem%PipeSection_VolumeCapacity(isection)= MudSystem%Area_PipeSectionFt(isection)* ABS(MudSystem%Xend_PipeSection(isection)-MudSystem%Xstart_PipeSection(isection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) ! (gal) ENDDO - + MudSystem%isection = isection !types: Mud= 0 Kick=1 !=========================================== - if (MudSystemDotFirstMudSet==0) then - call MudSystemDotHz_MudDischarged_Volume%AddToFirst(MudSystemDotPipeSection_VolumeCapacity(1)) !startup initial - call MudSystemDotHz_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(1)) - call Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotHz_Mud_Forehead_X%AddToFirst (MudSystemDotXend_PipeSection(1)) - call Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotHz_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystemDotHz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotHz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Hz_MudOrKick%AddToFirst (0) + if (MudSystem%FirstMudSet==0) then + call MudSystem%Hz_MudDischarged_Volume%AddToFirst(MudSystem%PipeSection_VolumeCapacity(1)) !startup initial + call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) + call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) + call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(1)) + call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) + call MudSystem%Hz_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Hz_MudOrKick%AddToFirst (0) - call MudSystemDotSt_MudDischarged_Volume%AddToFirst(sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts))) !startup initial - call MudSystemDotSt_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddToFirst (2) - call MudSystemDotSt_Mud_Forehead_X%AddToFirst (MudSystemDotXend_PipeSection(F_StringIntervalCounts)) - call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) - call St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call St_MudOrKick%AddToFirst (0) + call MudSystem%St_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(2:F_StringIntervalCounts))) !startup initial + call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(F_StringIntervalCounts)) + call MudSystem%St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) + call MudSystem%St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%St_MudOrKick%AddToFirst (0) - call MudSystemDotAnn_MudDischarged_Volume%AddToFirst(sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections))) - call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections)) - call Ann_Mud_Forehead_section%AddToFirst (MudSystemDotNoPipeSections) - call Ann_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Ann_MudOrKick%AddToFirst (0) - call Ann_CuttingMud%AddToFirst (0) + call MudSystem%Ann_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections))) + call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) + call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%NoPipeSections) + call MudSystem%Ann_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Ann_MudOrKick%AddToFirst (0) + call MudSystem%Ann_CuttingMud%AddToFirst (0) - MudSystemDotOldPosition= MudSystemDotXend_PipeSection(F_StringIntervalCounts) + MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_StringIntervalCounts) - MudSystemDotOldAnnulusCapacity= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) + MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) - call MudSystemDotChokeLine_MudDischarged_Volume%AddToFirst(MudSystemDotChokeLine_VolumeCapacity) - call MudSystemDotChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength) - call ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotChokeLine_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystemDotChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call ChokeLine_MudOrKick%AddToFirst (0) + call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst(MudSystem%ChokeLine_VolumeCapacity) + call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength) + call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call MudSystem%ChokeLine_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts))) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_OpSection(1)) - call Op_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts)) - call Op_Mud_Forehead_section%AddToFirst (F_BottomHoleIntervalCounts) - call MudSystemDotOp_Density%AddToFirst (MudProperties%ActiveDensity) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts))) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (1) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts)) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (F_BottomHoleIntervalCounts) + call MudSystem%Op_Density%AddToFirst (MudProperties%ActiveDensity) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) !F_StringIntervalCountsOld= F_StringIntervalCounts ! is used for adding new pipe to string - MudSystemDotF_StringIntervalCounts_Old= F_StringIntervalCounts ! is used for adding new pipe to string + MudSystem%F_StringIntervalCounts_Old= F_StringIntervalCounts ! is used for adding new pipe to string - MudSystemDotFirstMudSet= 1 + MudSystem%FirstMudSet= 1 endif @@ -201,16 +201,16 @@ ALLOCATE (MudSystemDotXstart_OpSection(F_BottomHoleIntervalCounts),MudSystemDotX !DeltaVolumeOp < 0 : Trip out - MudSystemDotDeltaVolumeOp= ((MudSystemDotXend_PipeSection(F_StringIntervalCounts)-MudSystemDotOldPosition)*PII*((MudSystemDotOD_PipeSectionInch(F_StringIntervalCounts+1)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal ! D(in) - MudSystemDotDeltaVolumeOp = INT(MudSystemDotDeltaVolumeOp * 100000.d0) / 100000.d0 + MudSystem%DeltaVolumeOp= ((MudSystem%Xend_PipeSection(F_StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%OD_PipeSectionInch(F_StringIntervalCounts+1)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal ! D(in) + MudSystem%DeltaVolumeOp = INT(MudSystem%DeltaVolumeOp * 100000.d0) / 100000.d0 - MudSystemDotDeltaVolumePipe= ((MudSystemDotXend_PipeSection(F_StringIntervalCounts)-MudSystemDotOldPosition)*PII*((MudSystemDotID_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal - MudSystemDotDeltaVolumePipe = INT(MudSystemDotDeltaVolumePipe * 100000.d0) / 100000.d0 + MudSystem%DeltaVolumePipe= ((MudSystem%Xend_PipeSection(F_StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%ID_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal + MudSystem%DeltaVolumePipe = INT(MudSystem%DeltaVolumePipe * 100000.d0) / 100000.d0 !DeltaVolumeAnnulusCapacity= ((Xend_PipeSection(F_StringIntervalCounts)-OldPosition))*Area_PipeSectionFt(NoPipeSections)* 7.48051948d0! ft^3 to gal - DrillStringSpeed = (MudSystemDotXend_PipeSection(F_StringIntervalCounts)-MudSystemDotOldPosition) / 0.1 + DrillStringSpeed = (MudSystem%Xend_PipeSection(F_StringIntervalCounts)-MudSystem%OldPosition) / 0.1 - MudSystemDotDeltaVolumeAnnulusCapacity= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) - MudSystemDotOldAnnulusCapacity + MudSystem%DeltaVolumeAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%OldAnnulusCapacity !write(*,*) 'DeltaVolumeAnnulusCapacity= ' , DeltaVolumeAnnulusCapacity @@ -224,32 +224,32 @@ ALLOCATE (MudSystemDotXstart_OpSection(F_BottomHoleIntervalCounts),MudSystemDotX - MudSystemDotOldAnnulusCapacity= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) + MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystemDotOldPosition= MudSystemDotXend_PipeSection(F_StringIntervalCounts) + MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_StringIntervalCounts) ! Needed for trip in or out: - if (MudSystemDotHz_Mud_Backhead_X%Length() == 0) then + if (MudSystem%Hz_Mud_Backhead_X%Length() == 0) then CALL ErrorStop('Hz_Mud_Backhead_X Length is 0') endif - MudSystemDotHz_Mud_Backhead_X%Array(1)= MudSystemDotXstart_PipeSection(1) - Hz_Mud_Backhead_section%Array(1)= 1 + MudSystem%Hz_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(1) + MudSystem%Hz_Mud_Backhead_section%Array(1)= 1 - MudSystemDotAddedElementsToString = F_StringIntervalCounts - MudSystemDotF_StringIntervalCounts_Old - MudSystemDotSt_Mud_Backhead_X%Array(1)= MudSystemDotXstart_PipeSection(2) - St_Mud_Backhead_section%Array(1)= 2 - Ann_Mud_Backhead_X%Array(1)= MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1) - Ann_Mud_Backhead_section%Array(1)= F_StringIntervalCounts+1 - MudSystemDotOp_Mud_Backhead_X%Array(1)= MudSystemDotXstart_OpSection(1) - Op_Mud_Backhead_section%Array(1)= 1 - MudSystemDotChokeLine_Mud_Backhead_X%Array(1)= 0. - ChokeLine_Mud_Backhead_section%Array(1)= 1 + MudSystem%AddedElementsToString = F_StringIntervalCounts - MudSystem%F_StringIntervalCounts_Old + MudSystem%St_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(2) + MudSystem%St_Mud_Backhead_section%Array(1)= 2 + MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1) + MudSystem%Ann_Mud_Backhead_section%Array(1)= F_StringIntervalCounts+1 + MudSystem%Op_Mud_Backhead_X%Array(1)= MudSystem%Xstart_OpSection(1) + MudSystem%Op_Mud_Backhead_section%Array(1)= 1 + MudSystem%ChokeLine_Mud_Backhead_X%Array(1)= 0. + MudSystem%ChokeLine_Mud_Backhead_section%Array(1)= 1 - MudSystemDotF_StringIntervalCounts_Old= F_StringIntervalCounts + MudSystem%F_StringIntervalCounts_Old= F_StringIntervalCounts !write(*,*) 'Xstart_PipeSection(2)' , Xstart_PipeSection(2) !write(*,*) 'Xend_PipeSection(1)' , Xend_PipeSection(1) diff --git a/Equipments/MudSystem/FillingWell_By_BellNipple.f90 b/Equipments/MudSystem/FillingWell_By_BellNipple.f90 index 1b50414..ab15d2e 100644 --- a/Equipments/MudSystem/FillingWell_By_BellNipple.f90 +++ b/Equipments/MudSystem/FillingWell_By_BellNipple.f90 @@ -26,7 +26,7 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo - if (Ann_MudOrKick%Last() == 104) then ! Last Element is air we must observe: Ann_Mud_Forehead_X%Last()=0.0 + if (MudSystem%Ann_MudOrKick%Last() == 104) then ! Last Element is air we must observe: Ann_Mud_Forehead_X%Last()=0.0 write(*,*) 'FillingWell_By_BellNipple-Last Element is air' @@ -35,40 +35,40 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo - FillingDensity= BellNippleDensity + FillingDensity= MudSystem%BellNippleDensity !**************************** - if ( MudSystemDotAnn_MudDischarged_Volume%Last() > (((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi mimune + if ( MudSystem%Ann_MudDischarged_Volume%Last() > (((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline)) then ! air baghi mimune - kloc= MudSystemDotAnn_MudDischarged_Volume%Length()-1 + kloc= MudSystem%Ann_MudDischarged_Volume%Length()-1 - deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline + deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length()) - deltaV + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length()) - deltaV !========================ANNULUS ENTRANCE==================== - if (ABS(Ann_Density%Array(kloc) - FillingDensity) >= MudSystemDotDensityMixTol) then ! new mud is pumped - call Ann_Density%AddTo (kloc, FillingDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (kloc, 0.0d0) - call Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0) - call Ann_Mud_Forehead_section%AddTo (kloc, 1) - call Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0) - call Ann_Mud_Backhead_section%AddTo (kloc, MudSystemDotNoPipeSections) - call Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0) - call Ann_MudOrKick%AddTo (kloc, 0) - call Ann_CuttingMud%AddTo (kloc,0) + if (ABS(MudSystem%Ann_Density%Array(kloc) - FillingDensity) >= MudSystem%DensityMixTol) then ! new mud is pumped + call MudSystem%Ann_Density%AddTo (kloc, FillingDensity) + call MudSystem%Ann_MudDischarged_Volume%AddTo (kloc, 0.0d0) + call MudSystem%Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0) + call MudSystem%Ann_Mud_Forehead_section%AddTo (kloc, 1) + call MudSystem%Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0) + call MudSystem%Ann_Mud_Backhead_section%AddTo (kloc, MudSystem%NoPipeSections) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (kloc, 0) + call MudSystem%Ann_CuttingMud%AddTo (kloc,0) !AnnulusSuctionDensity_Old= Hz_Density_Utube endif !========================ANNULUS==================== - MudSystemDotAnn_MudDischarged_Volume%Array(kloc)= MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+ deltaV !(gal) + MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+ deltaV !(gal) @@ -77,37 +77,37 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo - kloc= MudSystemDotAnn_MudDischarged_Volume%Length()-1 + kloc= MudSystem%Ann_MudDischarged_Volume%Length()-1 - deltaV= MudSystemDotAnn_MudDischarged_Volume%Last() + deltaV= MudSystem%Ann_MudDischarged_Volume%Last() - if (ABS(Ann_Density%Array(kloc)-FillingDensity)< MudSystemDotDensityMixTol .and. Ann_CuttingMud%Array(kloc)==0) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)< 42.) ) then ! 1-Pockets are Merged - Ann_Density%Array(kloc)= (Ann_Density%Array(kloc)*MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+deltaV) - MudSystemDotAnn_MudDischarged_Volume%Array(kloc)= MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+deltaV - Ann_Mud_Forehead_X%Array(kloc)= MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections) - Ann_Mud_Forehead_section%Array(kloc)= MudSystemDotNoPipeSections + if (ABS(MudSystem%Ann_Density%Array(kloc)-FillingDensity)< MudSystem%DensityMixTol .and. MudSystem%Ann_CuttingMud%Array(kloc)==0) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)< 42.) ) then ! 1-Pockets are Merged + MudSystem%Ann_Density%Array(kloc)= (MudSystem%Ann_Density%Array(kloc)*MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) + MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV + MudSystem%Ann_Mud_Forehead_X%Array(kloc)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) + MudSystem%Ann_Mud_Forehead_section%Array(kloc)= MudSystem%NoPipeSections !Ann_Mud_Backhead_X%Array(kloc)= no change !Ann_Mud_Backhead_section%Array(kloc)= no change - Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) - Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) + MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) - call MudSystemDotAnn_MudDischarged_Volume%Remove (kloc+1) - call Ann_Mud_Backhead_X%Remove (kloc+1) - call Ann_Mud_Backhead_section%Remove (kloc+1) - call Ann_Mud_Forehead_X%Remove (kloc+1) - call Ann_Mud_Forehead_section%Remove (kloc+1) - call Ann_Density%Remove (kloc+1) - call Ann_RemainedVolume_in_LastSection%Remove (kloc+1) - call Ann_EmptyVolume_inBackheadLocation%Remove (kloc+1) - call Ann_MudOrKick%Remove (kloc+1) - call Ann_CuttingMud%Remove (kloc+1) + call MudSystem%Ann_MudDischarged_Volume%Remove (kloc+1) + call MudSystem%Ann_Mud_Backhead_X%Remove (kloc+1) + call MudSystem%Ann_Mud_Backhead_section%Remove (kloc+1) + call MudSystem%Ann_Mud_Forehead_X%Remove (kloc+1) + call MudSystem%Ann_Mud_Forehead_section%Remove (kloc+1) + call MudSystem%Ann_Density%Remove (kloc+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (kloc+1) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (kloc+1) + call MudSystem%Ann_MudOrKick%Remove (kloc+1) + call MudSystem%Ann_CuttingMud%Remove (kloc+1) else ! 2-Merging conditions are not meeted, so new pocket== air is replaced with filling mud - Ann_Density%Array(kloc+1) =FillingDensity - Ann_MudOrKick%Array(kloc+1)= 0 + MudSystem%Ann_Density%Array(kloc+1) =FillingDensity + MudSystem%Ann_MudOrKick%Array(kloc+1)= 0 endif @@ -129,9 +129,9 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo !write(*,*) '*Ann_MudOrKick%Last()=' , Ann_MudOrKick%Last() - deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline + deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline - kloc= MudSystemDotAnn_MudDischarged_Volume%Length() + kloc= MudSystem%Ann_MudDischarged_Volume%Length() @@ -139,37 +139,37 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo !========================ANNULUS ENTRANCE==================== - if (ABS(Ann_Density%Last() - FillingDensity) >= MudSystemDotDensityMixTol .or. Ann_CuttingMud%Last()==1) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)>42.) ) then ! new mud is pumped - Xposition= Ann_Mud_Forehead_X%Last() - SectionPosition= Ann_Mud_Forehead_section%Last() - call Ann_Density%Add (FillingDensity) - call MudSystemDotAnn_MudDischarged_Volume%Add (0.0d0) - call Ann_Mud_Forehead_X%Add (Xposition) - call Ann_Mud_Forehead_section%Add (SectionPosition) - call Ann_Mud_Backhead_X%Add (Xposition) - call Ann_Mud_Backhead_section%Add (SectionPosition) - call Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call Ann_MudOrKick%Add (0) - call Ann_CuttingMud%Add (0) + if (ABS(MudSystem%Ann_Density%Last() - FillingDensity) >= MudSystem%DensityMixTol .or. MudSystem%Ann_CuttingMud%Last()==1) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)>42.) ) then ! new mud is pumped + Xposition= MudSystem%Ann_Mud_Forehead_X%Last() + SectionPosition= MudSystem%Ann_Mud_Forehead_section%Last() + call MudSystem%Ann_Density%Add (FillingDensity) + call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) + call MudSystem%Ann_Mud_Forehead_X%Add (Xposition) + call MudSystem%Ann_Mud_Forehead_section%Add (SectionPosition) + call MudSystem%Ann_Mud_Backhead_X%Add (Xposition) + call MudSystem%Ann_Mud_Backhead_section%Add (SectionPosition) + call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) + call MudSystem%Ann_MudOrKick%Add (0) + call MudSystem%Ann_CuttingMud%Add (0) !AnnulusSuctionDensity_Old= Hz_Density_Utube !endif !========================ANNULUS==================== - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())+ deltaV !(gal) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())+ deltaV !(gal) else ! Merged with last Mud - Ann_Density%Array(kloc)= (Ann_Density%Array(kloc)*MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+deltaV) - MudSystemDotAnn_MudDischarged_Volume%Array(kloc)= MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+deltaV + MudSystem%Ann_Density%Array(kloc)= (MudSystem%Ann_Density%Array(kloc)*MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) + MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV !Ann_Mud_Forehead_X%Array(kloc)= Xend_PipeSection(NoPipeSections) !Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections !Ann_Mud_Backhead_X%Array(kloc)= no change !Ann_Mud_Backhead_section%Array(kloc)= no change - Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) - Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) + MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) endif diff --git a/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 b/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 index 3c2df1a..208b8d1 100644 --- a/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 +++ b/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 @@ -12,25 +12,24 @@ subroutine Kick_Expansion ! is called in subroutine CirculationCodeSelect USE KickVARIABLES - implicit none - real(8) ExpansionVolume - - - !write(*,*) 'Kick Expansion' + implicit none + real(8) ExpansionVolume + + !write(*,*) 'Kick Expansion' -ExpansionVolume= GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) * 7.48 + ExpansionVolume= GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - MudSystem%KickNumber + 1) * 7.48 -IF ( MudSystemDotKickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) +IF ( MudSystem%Kickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !============================== kick zire mate bashad ============================== - if (MudSystemDotOp_KickLoc > 0 .and. MudSystemDotAnn_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then + if (MudSystem%Op_KickLoc > 0 .and. MudSystem%Ann_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then !write(*,*) 'expansion (1)' - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc)+ ExpansionVolume + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)+ ExpansionVolume !if (MUD(4)%Q > 0.) then @@ -58,14 +57,14 @@ IF ( MudSystemDotKickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystemDot !============================= foreheade dar fazaye annulus bashad =========================== ! agar kick be entehaye annulus reside bashe, expansion ra emaal nemikonim - if (MudSystemDotAnn_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then + if (MudSystem%Ann_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then !write(*,*) 'expansion (2)' !if ( sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc)) + ExpansionVolume > sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ) then ! agar khast az mate rad kone ! ExpansionVolume= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc)) !endif - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc)+ ExpansionVolume + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)+ ExpansionVolume !if (MUD(4)%Q > 0.) then ! @@ -95,9 +94,9 @@ IF ( MudSystemDotKickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystemDot !=============================== foreheade dar choke line bashad ============================= - if (MudSystemDotChokeLine_KickLoc > 0 .and. MudSystemDotAnn_KickLoc==0) then + if (MudSystem%ChokeLine_KickLoc > 0 .and. MudSystem%Ann_KickLoc==0) then - MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc)= MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc)+ ExpansionVolume + MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)= MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)+ ExpansionVolume endif @@ -152,12 +151,12 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect !write(*,*) 'Kick Contraction' !MUD(2)%Q= MPumps%Total_Pump_GPM - StringFlowRate= MUD(2)%Q - AnnulusFlowRate= MUD(2)%Q + MudSystem%StringFlowRate= MUD(2)%Q + MudSystem%AnnulusFlowRate= MUD(2)%Q - if (MudSystemDotNewPipeFilling == 0) then - MudSystemDotStringFlowRate= 0. - MudSystemDotAnnulusFlowRate= 0. + if (MudSystem%NewPipeFilling == 0) then + MudSystem%StringFlowRate= 0. + MudSystem%AnnulusFlowRate= 0. endif @@ -165,10 +164,10 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect !if (WellHeadIsOpen) then - ContractionVolume= - GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) * 7.48 + ContractionVolume= - GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - MudSystem%KickNumber + 1) * 7.48 !else - !ContractionVolume = (StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe - if (MudSystemDotKickNumber == 1 .and. WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline + MudSystemDotDeltaVolumePipe + !ContractionVolume = (MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe + if (MudSystem%KickNumber == 1 .and. MudSystem%WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline + MudSystem%DeltaVolumePipe !endif @@ -176,43 +175,43 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect ! pump mud is added in "pump&TripIn" code - IF (MudSystemDotOp_KickLoc > 0 .and. MudSystemDotAnn_KickLoc == 0) then ! All of kick is under bit (iloc == 1) + IF (MudSystem%Op_KickLoc > 0 .and. MudSystem%Ann_KickLoc == 0) then ! All of kick is under bit (iloc == 1) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc) - ( ContractionVolume ) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc) - ( ContractionVolume ) - ELSE IF (MudSystemDotOp_KickLoc == 0 .AND. MudSystemDotAnn_KickLoc > 0 .AND. MudSystemDotChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1) + ELSE IF (MudSystem%Op_KickLoc == 0 .AND. MudSystem%Ann_KickLoc > 0 .AND. MudSystem%ChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc) - ( ContractionVolume ) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc) - ( ContractionVolume ) - ELSE IF (MudSystemDotAnn_KickLoc == 0 .AND. MudSystemDotChokeLine_KickLoc > 0) THEN ! kick is in chokeline only + ELSE IF (MudSystem%Ann_KickLoc == 0 .AND. MudSystem%ChokeLine_KickLoc > 0) THEN ! kick is in chokeline only - MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc)= MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc) - ( ContractionVolume ) + MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)= MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc) - ( ContractionVolume ) - ELSE IF (MudSystemDotOp_KickLoc > 0 .AND. MudSystemDotAnn_KickLoc > 0) THEN ! Kick is around bit (iloc==2) + ELSE IF (MudSystem%Op_KickLoc > 0 .AND. MudSystem%Ann_KickLoc > 0) THEN ! Kick is around bit (iloc==2) - if (MudSystemDotAnn_MudDischarged_Volume%Array(1) > ContractionVolume ) then + if (MudSystem%Ann_MudDischarged_Volume%Array(1) > ContractionVolume ) then - MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) - ( ContractionVolume ) + MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - ( ContractionVolume ) - elseif (MudSystemDotOp_MudDischarged_Volume%Last() > ContractionVolume ) then + elseif (MudSystem%Op_MudDischarged_Volume%Last() > ContractionVolume ) then - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_MudDischarged_Volume%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_MudDischarged_Volume%Length()) - ( ContractionVolume ) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_MudDischarged_Volume%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_MudDischarged_Volume%Length()) - ( ContractionVolume ) else Call ErrorStop ('kick contraction error 1') endif - ELSE IF (MudSystemDotAnn_KickLoc > 0 .AND. MudSystemDotChokeLine_KickLoc > 0) THEN + ELSE IF (MudSystem%Ann_KickLoc > 0 .AND. MudSystem%ChokeLine_KickLoc > 0) THEN - if (MudSystemDotChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then + if (MudSystem%ChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then - MudSystemDotChokeLine_MudDischarged_Volume%Array(1) = MudSystemDotChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume ) + MudSystem%ChokeLine_MudDischarged_Volume%Array(1) = MudSystem%ChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume ) - elseif (MudSystemDotAnn_MudDischarged_Volume%Last() > ContractionVolume ) then + elseif (MudSystem%Ann_MudDischarged_Volume%Last() > ContractionVolume ) then - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length()) - ( ContractionVolume ) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length()) - ( ContractionVolume ) else Call ErrorStop ('kick contraction error 2') diff --git a/Equipments/MudSystem/Kick_Influx.f90 b/Equipments/MudSystem/Kick_Influx.f90 index 765057d..62ede68 100644 --- a/Equipments/MudSystem/Kick_Influx.f90 +++ b/Equipments/MudSystem/Kick_Influx.f90 @@ -22,27 +22,27 @@ subroutine Kick_Influx ! is called in subroutine CirculationCodeSelect !=================== Bottom Hole Kick Influx ENTRANCE(due to Kick) =================== - MudSystemDotKick_Density= 2 - MudSystemDotNewInflux_Density= MudSystemDotKick_Density + MudSystem%Kick_Density= 2 + MudSystem%NewInflux_Density= MudSystem%Kick_Density - if ( MudSystemDotNewInfluxElementCreated==0 ) then ! new kick is pumped- (it is set to zero in sheykh subroutine after a new kick influx) - call MudSystemDotOp_Density%AddToFirst (MudSystemDotNewInflux_Density) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_OpSection(1)) - call Op_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_OpSection(1)) - call Op_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (MudSystemDotNewInfluxNumber) ! KickNumber= NewInfluxNumber + if ( MudSystem%NewInfluxElementCreated==0 ) then ! new kick is pumped- (it is set to zero in sheykh subroutine after a new kick influx) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewInflux_Density) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (0.0d0) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (1) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (1) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (MudSystem%NewInfluxNumber) ! KickNumber= NewInfluxNumber - MudSystemDotNewInfluxElementCreated= 1 + MudSystem%NewInfluxElementCreated= 1 endif - MudSystemDotOp_MudDischarged_Volume%Array(1)= MudSystemDotOp_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.0d0)*DeltaT_Mudline) !(gal) due to KickFlux + MudSystem%Op_MudDischarged_Volume%Array(1)= MudSystem%Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) due to KickFlux !write(*,*) 'kick volume ok=' , Op_MudDischarged_Volume%Array(1) @@ -79,13 +79,13 @@ subroutine Instructor_CirculationMud_Edit ! is called in subroutine Circulat - if ( DownHole%AnnDrillMud == .true. .and. (Rate_of_Penetration>0. .and. MudSystemDotDeltaVolumeOp>0.0) ) then + if ( DownHole%AnnDrillMud == .true. .and. (Rate_of_Penetration>0. .and. MudSystem%DeltaVolumeOp>0.0) ) then - do MudSystemDotimud= 1, Ann_Density%Length() + do imud= 1, MudSystem%Ann_Density%Length() - if ( Ann_MudOrKick%Array(MudSystemDotimud) == 0 ) then - Ann_Density%Array(MudSystemDotimud)= (St_Density%Last() * MudSystemDotAnnulusFlowRate + 141.4296E-4*Rate_of_Penetration*Diameter_of_Bit**2)/(MudSystemDotAnnulusFlowRate+6.7995E-4*Rate_of_Penetration*Diameter_of_Bit**2) - Ann_CuttingMud%Array(MudSystemDotimud)= 1 + if ( MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then + MudSystem%Ann_Density%Array(imud)= (MudSystem%St_Density%Last() * MudSystem%AnnulusFlowRate + 141.4296E-4*Rate_of_Penetration*Diameter_of_Bit**2)/(MudSystem%AnnulusFlowRate+6.7995E-4*Rate_of_Penetration*Diameter_of_Bit**2) + MudSystem%Ann_CuttingMud%Array(imud)= 1 endif enddo @@ -95,18 +95,18 @@ subroutine Instructor_CirculationMud_Edit ! is called in subroutine Circulat if ( DownHole%AnnCirculateMud == .true. ) then - do MudSystemDotimud= 1, Ann_Density%Length() + do imud= 1, MudSystem%Ann_Density%Length() - if ( Ann_MudOrKick%Array(MudSystemDotimud) == 0 ) then - Ann_Density%Array(MudSystemDotimud)= ActiveTankDensity - Ann_CuttingMud%Array(MudSystemDotimud)= 0 + if ( MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then + MudSystem%Ann_Density%Array(imud)= MudSystem%ActiveTankDensity + MudSystem%Ann_CuttingMud%Array(imud)= 0 endif enddo - do MudSystemDotimud= 1, St_Density%Length() + do imud= 1, MudSystem%St_Density%Length() - St_Density%Array(MudSystemDotimud)= ActiveTankDensity + MudSystem%St_Density%Array(imud)= MudSystem%ActiveTankDensity enddo @@ -138,28 +138,28 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect implicit none - MudSystemDotShoeLost= .false. - MudSystemDotKickexpansion_DueToMudLost= .false. + MudSystem%ShoeLost= .false. + MudSystem%Kickexpansion_DueToMudLost= .false. - MudSystemDotShoeMudPressure= PressureGauges(5) + MudSystem%ShoeMudPressure= PressureGauges(5) - MudSystemDotUGBOSuccessionCounter = MudSystemDotUGBOSuccessionCounter + 1 + MudSystem%UGBOSuccessionCounter = MudSystem%UGBOSuccessionCounter + 1 !write(*,*) 'check point 1' - if (Shoe%InactiveFracture == .FALSE. .AND. ((MudSystemDotShoeMudPressure >= MudSystemDotFormationLostPressure) .or. MudSystemDotShoeFractured )) then + if (Shoe%InactiveFracture == .FALSE. .AND. ((MudSystem%ShoeMudPressure >= MudSystem%FormationLostPressure) .or. MudSystem%ShoeFractured )) then !write(*,*) 'check point 2 ,UGBOSuccessionCounter' , UGBOSuccessionCounter ! if ShoeFractured changed to true , then time counter is not needed more - if ( MudSystemDotUGBOSuccessionCounter /= MudSystemDotUGBOSuccessionCounterOld+1 .and. MudSystemDotShoeFractured==.false. ) then - MudSystemDotUGBOSuccessionCounter = 0 ! also in starup - MudSystemDotUGBOSuccessionCounterOld = 0 ! also in starup + if ( MudSystem%UGBOSuccessionCounter /= MudSystem%UGBOSuccessionCounterOld+1 .and. MudSystem%ShoeFractured==.false. ) then + MudSystem%UGBOSuccessionCounter = 0 ! also in starup + MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup return else - MudSystemDotUGBOSuccessionCounterOld= MudSystemDotUGBOSuccessionCounter + MudSystem%UGBOSuccessionCounterOld= MudSystem%UGBOSuccessionCounter endif - if ( MudSystemDotUGBOSuccessionCounter < 10 .and. MudSystemDotShoeFractured==.false.) then + if ( MudSystem%UGBOSuccessionCounter < 10 .and. MudSystem%ShoeFractured==.false.) then return endif @@ -167,30 +167,30 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect - MudSystemDotShoeFractured= .true. + MudSystem%ShoeFractured= .true. - MudSystemDotShoeMudViscosity= MAX(MudSystemDotShoeMudViscosity, 12.d0) + MudSystem%ShoeMudViscosity= MAX(MudSystem%ShoeMudViscosity, 12.d0) !write(*,*) 'ShoeMudDensity , ShoeMudViscosity' , ShoeMudDensity , ShoeMudViscosity - MudSystemDotShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * MudSystemDotShoeMudDensity / & - (MudSystemDotShoeMudViscosity * LOG(10000.d0)) + MudSystem%ShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * MudSystem%ShoeMudDensity / & + (MudSystem%ShoeMudViscosity * LOG(10000.d0)) !write(*,*) 'lost parameters 1' , ShoeMudPressure , FormationLostPressure - MudSystemDotQlost = MAX( (MudSystemDotShoeLostCoef * (MudSystemDotShoeMudPressure - (MudSystemDotFormationLostPressure/2.0))) , 0.d0 ) - if (MudSystemDotQlost > 0.0) then - MudSystemDotShoeLost= .true. + MudSystem%Qlost = MAX( (MudSystem%ShoeLostCoef * (MudSystem%ShoeMudPressure - (MudSystem%FormationLostPressure/2.0))) , 0.d0 ) + if (MudSystem%Qlost > 0.0) then + MudSystem%ShoeLost= .true. else - MudSystemDotShoeLost= .false. + MudSystem%ShoeLost= .false. endif !write(*,*) 'Qlost=' , Qlost, ShoeMudPressure, FormationLostPressure call Activate_UndergroundBlowout() - do MudSystemDotimud= 1, Ann_Mud_Forehead_X%Length() + do imud= 1, MudSystem%Ann_Mud_Forehead_X%Length() - IF ( MudSystemDotShoeLost .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(MudSystemDotimud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(MudSystemDotimud) & - .and. Ann_MudOrKick%Array(MudSystemDotimud) == 0 .and. WellHeadIsOpen == .FALSE. ) then + IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) & + .and. MudSystem%Ann_MudOrKick%Array(imud) == 0 .and. MudSystem%WellHeadIsOpen == .FALSE. ) then - MudSystemDotKickexpansion_DueToMudLost= .true. + MudSystem%Kickexpansion_DueToMudLost= .true. write(*,*) 'Kickexpansion_DueToMudLost' EXIT @@ -204,7 +204,7 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect endif - if (UndergroundBlowout == .false.) MudSystemDotShoeLost= .false. + if (UndergroundBlowout == .false.) MudSystem%ShoeLost= .false. diff --git a/Equipments/MudSystem/Kick_Migration.f90 b/Equipments/MudSystem/Kick_Migration.f90 index f818bd2..c45be05 100644 --- a/Equipments/MudSystem/Kick_Migration.f90 +++ b/Equipments/MudSystem/Kick_Migration.f90 @@ -14,21 +14,21 @@ subroutine Kick_Migration ! is called in subroutine CirculationCodeSelect implicit none - integer jelement, jmud, jsection,ielement,i + integer jelement, jmud, jsection,ielement,i,kickNumber integer jopelement,jopmud,jopsection,CuttingValue !MUD(2)%Q= MPumps%Total_Pump_GPM - !StringFlowRate= MUD(2)%Q - !AnnulusFlowRate= MUD(2)%Q + !MudSystem%StringFlowRate= MUD(2)%Q + !MudSystem%AnnulusFlowRate= MUD(2)%Q ! !if (NewPipeFilling == 0) then - ! StringFlowRate= 0. - ! AnnulusFlowRate= 0. + ! MudSystem%StringFlowRate= 0. + ! MudSystem%AnnulusFlowRate= 0. !endif - !StringFlowRateFinal= StringFlowRate - !AnnulusFlowRateFinal= AnnulusFlowRate + !StringFlowRateFinal= MudSystem%StringFlowRate + !AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate @@ -39,42 +39,37 @@ subroutine Kick_Migration ! is called in subroutine CirculationCodeSelect !FirstSetKickMigration !write(*,*) 'NewInfluxNumber=' , NewInfluxNumber -DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystemDotNewInfluxNumber - !write(*,*) 'KickNumber=' , KickNumber - - if (KickFlux .AND. NOT(KickOffBottom) .and. MudSystemDotKickNumber == MudSystemDotNewInfluxNumber) cycle - - if ( MudSystemDotKickNumber == Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called - +DO KickNumber= MudSystem%NewInfluxNumber-NoGasPocket+1 , MudSystem%NewInfluxNumber + !write(*,*) 'KickNumber=' , KickNumber + if (KickFlux .AND. NOT(KickOffBottom) .and. KickNumber == MudSystem%NewInfluxNumber) cycle + if ( KickNumber == MudSystem%Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called !write(*,*) 'Migration will be done for,KickNumber=' ,KickNumber -!=================== Bottom Hole ENTRANCE(due to Kick) =================== - - !KickDx= (AutoMigrationRate/60.)*DeltaT_Mudline !3600 (ft/min)= 6 ft set in start up - - - MudSystemDotOp_KickLoc= 0 - MudSystemDotAnn_KickLoc= 0 - MudSystemDotChokeLine_KickLoc= 0 - + !=================== Bottom Hole ENTRANCE(due to Kick) =================== + !KickDx= (AutoMigrationRate/60.)*DeltaT_Mudline !3600 (ft/min)= 6 ft set in start up + + + MudSystem%Op_KickLoc= 0 + MudSystem%Ann_KickLoc= 0 + MudSystem%ChokeLine_KickLoc= 0 - do i = 1, Op_MudOrKick%Length () - if (Op_MudOrKick%Array(i) == MudSystemDotKickNumber) then - MudSystemDotOp_KickLoc = i + do i = 1, MudSystem%Op_MudOrKick%Length () + if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then + MudSystem%Op_KickLoc = i exit endif end do - do i = 1, Ann_MudOrKick%Length () - if (Ann_MudOrKick%Array(i) == MudSystemDotKickNumber) then - MudSystemDotAnn_KickLoc = i + do i = 1, MudSystem%Ann_MudOrKick%Length () + if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then + MudSystem%Ann_KickLoc = i exit endif end do - do i = 1, ChokeLine_MudOrKick%Length () - if (ChokeLine_MudOrKick%Array(i) == MudSystemDotKickNumber) then - MudSystemDotChokeLine_KickLoc = i + do i = 1, MudSystem%ChokeLine_MudOrKick%Length () + if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then + MudSystem%ChokeLine_KickLoc = i exit endif end do @@ -93,114 +88,114 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !============================== foreheade kick be mate reside bashad *3 ============================== - if (MudSystemDotOp_KickLoc == Op_MudOrKick%Length () .and. MudSystemDotAnn_KickLoc==0 ) then +if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann_KickLoc==0 ) then !write(*,*) '****3' - MudSystemDotiLoc= 2 + MudSystem%iLoc= 2 - MudSystemDotKickDv= MudSystemDotArea_OpSectionFt(Op_Mud_Forehead_section%Array(MudSystemDotOp_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal + MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - MudSystemDotMinKickDv= min( MudSystemDotKickDv,MudSystemDotAnn_MudDischarged_Volume%Array (1), MudSystemDotOp_MudDischarged_Volume%Last () ) + MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (1), MudSystem%Op_MudDischarged_Volume%Last () ) - NewDensity= Ann_Density%Array (1) - MudSystemDotNewVolume= MudSystemDotMinKickDv + MudSystem%NewDensity= MudSystem%Ann_Density%Array (1) + MudSystem%NewVolume= MudSystem%MinKickDv - if ( MudSystemDotMinKickDv == MudSystemDotKickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund + if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund - MudSystemDotAnn_MudDischarged_Volume%Array (1)= MudSystemDotAnn_MudDischarged_Volume%Array (1) - MudSystemDotMinKickDv + MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv - call Ann_Density%AddToFirst (MudSystemDotOp_Density%Last()) - call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotMinKickDv) - call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Ann_MudOrKick%AddToFirst (MudSystemDotKickNumber) - call Ann_CuttingMud%AddToFirst (0) + call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last()) + call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv) + call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) + call MudSystem%Ann_CuttingMud%AddToFirst (0) - MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv + MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! backheade kick zire mate bashad - if (MudSystemDotOp_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then + if (MudSystem%Op_KickLoc > 1) then + !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) + call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == NewDensity + else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume + MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1=============================== !write(*,*) '****3-1' - call MudSystemDotOp_Density%AddToFirst (NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) endif - elseif ( MudSystemDotMinKickDv == MudSystemDotAnn_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund + elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund - Ann_Density%Array(1)= MudSystemDotOp_Density%Last() - Ann_MudOrKick%Array(1)= MudSystemDotKickNumber + MudSystem%Ann_Density%Array(1)= MudSystem%Op_Density%Last() + MudSystem%Ann_MudOrKick%Array(1)= KickNumber - MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv + MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! backheade kick zire mate bashad - if (MudSystemDotOp_KickLoc > 1) then + if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) + call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == NewDensity + else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume + MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume endif @@ -208,88 +203,88 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !write(*,*) '****3-2' - call MudSystemDotOp_Density%AddToFirst (NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) endif ! - elseif ( MudSystemDotMinKickDv == MudSystemDotOp_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod + elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod - MudSystemDotAnn_MudDischarged_Volume%Array (1)= MudSystemDotAnn_MudDischarged_Volume%Array (1) - MudSystemDotMinKickDv + MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv - call Ann_Density%AddToFirst (MudSystemDotOp_Density%Last()) - call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotMinKickDv) - call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Ann_MudOrKick%AddToFirst (MudSystemDotKickNumber) - call Ann_CuttingMud%AddToFirst (0) + call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last()) + call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv) + call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) + call MudSystem%Ann_CuttingMud%AddToFirst (0) - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_MudDischarged_Volume%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_Mud_Backhead_X%Remove (MudSystemDotOp_KickLoc) - call Op_Mud_Backhead_section%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_Mud_Forehead_X%Remove (MudSystemDotOp_KickLoc) - call Op_Mud_Forehead_section%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_Density%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (MudSystemDotOp_KickLoc) - call Op_MudOrKick%Remove (MudSystemDotOp_KickLoc) + call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc) ! backheade kick zire mate bashad - if (MudSystemDotOp_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then + if (MudSystem%Op_KickLoc > 1) then + !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) + call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == NewDensity + else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume + MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3=============================== !write(*,*) '****3-3' - call MudSystemDotOp_Density%AddToFirst (NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) endif @@ -306,7 +301,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !============================== foreheade kick be mate reside bashad *3 with pump ============================== -! if (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 .and. AnnulusFlowRate /= 0.0 ) then +! if (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 .and. MudSystem%AnnulusFlowRate /= 0.0 ) then ! write(*,*) '****3 with pump' ! ! KickMigration_2SideBit= .true. @@ -316,7 +311,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! !!farz mikonam baraye in yek iteration kick az OP hazf nemishavad va hajme aan bishtar az pump flow ast ! -! KickDv= ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) +! KickDv= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! ! call Ann_Density%AddToFirst (Kick_Density) ! call Ann_MudDischarged_Volume%AddToFirst (KickDv) @@ -332,20 +327,20 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! ! ! -! !if ( ((AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad +! !if ( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad ! ! -! ! KickDv= ((AnnulusFlowRate/60.)*DeltaT_Mudline) +! ! KickDv= ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) ! ! ! ! ! BackHead: -! if ( Op_Density%Array (Op_KickLoc-1) /= St_Density%Last() ) then +! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! -! call Op_Density%AddTo (Op_KickLoc,St_Density%Last()) +! call Op_Density%AddTo (Op_KickLocMudSystem%St_Density%Last()) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,KickDv) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -356,7 +351,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! -! else !Op_Density%Array (imudKick-1) == NewDensity +! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + KickDv ! @@ -371,87 +366,87 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !============================= tamame kick zire mate bashad *1 ================================ - if ( MudSystemDotOp_KickLoc>0 .and. MudSystemDotOp_KickLoc < Op_MudOrKick%Length () ) then + if ( MudSystem%Op_KickLoc>0 .and. MudSystem%Op_KickLoc < MudSystem%Op_MudOrKick%Length () ) then !write(*,*) '****1' !iloc= 1 - MudSystemDotKickDv= MudSystemDotArea_OpSectionFt(Op_Mud_Forehead_section%Array(MudSystemDotOp_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal + MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - if ( MudSystemDotKickDv < MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) ) then !eleman bala sari baghi mimund + if ( MudSystem%KickDv < MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) ) then !eleman bala sari baghi mimund !write(*,*) 'cond 11111111111111' - MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) - MudSystemDotKickDv + MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) - MudSystem%KickDv - NewDensity= MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc+1) - MudSystemDotNewVolume= MudSystemDotKickDv + MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1) + MudSystem%NewVolume= MudSystem%KickDv else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund ! write(*,*) 'cond 22222222222222222' - MudSystemDotKickDv= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) + MudSystem%KickDv= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) - MudSystemDotNewVolume= MudSystemDotKickDv - NewDensity= MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc+1) + MudSystem%NewVolume= MudSystem%KickDv + MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1) - call MudSystemDotOp_MudDischarged_Volume%Remove (MudSystemDotOp_KickLoc+1) - call MudSystemDotOp_Mud_Backhead_X%Remove (MudSystemDotOp_KickLoc+1) - call Op_Mud_Backhead_section%Remove (MudSystemDotOp_KickLoc+1) - call MudSystemDotOp_Mud_Forehead_X%Remove (MudSystemDotOp_KickLoc+1) - call Op_Mud_Forehead_section%Remove (MudSystemDotOp_KickLoc+1) - call MudSystemDotOp_Density%Remove (MudSystemDotOp_KickLoc+1) - call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (MudSystemDotOp_KickLoc+1) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (MudSystemDotOp_KickLoc+1) - call Op_MudOrKick%Remove (MudSystemDotOp_KickLoc+1) + call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc+1) + call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc+1) endif ! backheade kick zire mate bashad - if (MudSystemDotOp_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then + if (MudSystem%Op_KickLoc > 1) then + !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) + call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - else !Op_Density%Array (Op_KickLoc-1) == NewDensity + else !Op_Density%Array (Op_KickLoc-1) == MudSystem%NewDensity - MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume + MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1=============================== !write(*,*) '****5-1' - call MudSystemDotOp_Density%AddToFirst (NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) endif @@ -465,65 +460,65 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !=========================== tamame kick balaye mate bashad *2 ================================== - if ( MudSystemDotAnn_KickLoc > 0 .and. MudSystemDotOp_KickLoc==0 ) then + if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc==0 ) then !write(*,*) '****2' !iloc= 1 - MudSystemDotKickDv= MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotAnn_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal + MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - NewDensity= Ann_Density%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotNewVolume= MudSystemDotKickDv - CuttingValue= Ann_CuttingMud%Array (MudSystemDotAnn_KickLoc+1) + MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1) + MudSystem%NewVolume= MudSystem%KickDv + CuttingValue= MudSystem%Ann_CuttingMud%Array (MudSystem%Ann_KickLoc+1) - if ( MudSystemDotKickDv < MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) ) then !eleman bala sari baghi mimund + if ( MudSystem%KickDv < MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then !eleman bala sari baghi mimund - MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotKickDv + MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%KickDv else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund - MudSystemDotKickDv= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotNewVolume= MudSystemDotKickDv + MudSystem%KickDv= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) + MudSystem%NewVolume= MudSystem%KickDv - call MudSystemDotAnn_MudDischarged_Volume%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Backhead_X%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Backhead_section%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Forehead_X%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Forehead_section%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Density%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_RemainedVolume_in_LastSection%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_EmptyVolume_inBackheadLocation%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_MudOrKick%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_CuttingMud%Remove (MudSystemDotAnn_KickLoc+1) + call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1) endif ! backheade kick balaye mate bashad - if (MudSystemDotAnn_KickLoc > 1) then - !if ( Ann_Density%Array (Ann_KickLoc-1) /= NewDensity ) then + if (MudSystem%Ann_KickLoc > 1) then + !if ( Ann_Density%Array (Ann_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(Ann_Density%Array (MudSystemDotAnn_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - MudSystemDotOld_KickBackHead_X= Ann_Mud_Backhead_X%Array (MudSystemDotAnn_KickLoc) - MudSystemDotOld_KickBackHead_Section= Ann_Mud_Backhead_section%Array (MudSystemDotAnn_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc) - call Ann_Density%AddTo (MudSystemDotAnn_KickLoc,NewDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotNewVolume) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_X) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_Section) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_X) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_Section) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotAnn_KickLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotAnn_KickLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotAnn_KickLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotAnn_KickLoc,0) + call MudSystem%Ann_Density%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewDensity) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewVolume) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%Ann_KickLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Ann_KickLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%Ann_KickLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%Ann_KickLoc,0) - else !Op_Density%Array (imudKick-1) == NewDensity + else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - Ann_Density%Array(MudSystemDotAnn_KickLoc-1)= (Ann_Density%Array(MudSystemDotAnn_KickLoc-1)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1) + MudSystemDotNewVolume + MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)= (MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1) + MudSystem%NewVolume endif @@ -531,20 +526,20 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem else !if Ann_KickLoc == 1 *6 =============================== !write(*,*) '****6' - MudSystemDotOld_KickBackHead_X= Ann_Mud_Backhead_X%Array (MudSystemDotAnn_KickLoc) - MudSystemDotOld_KickBackHead_Section= Ann_Mud_Backhead_section%Array (MudSystemDotAnn_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc) - call Ann_Density%AddToFirst (NewDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Ann_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Ann_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Ann_MudOrKick%AddToFirst (0) - call Ann_CuttingMud%AddToFirst (CuttingValue) + call MudSystem%Ann_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Ann_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Ann_MudOrKick%AddToFirst (0) + call MudSystem%Ann_CuttingMud%AddToFirst (CuttingValue) endif @@ -560,208 +555,208 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !============================== kick 2 tarafe mate bashad *4 ============================== - if ( MudSystemDotAnn_KickLoc > 0 .and. MudSystemDotOp_KickLoc > 0 ) then + if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc > 0 ) then !write(*,*) '****4' - MudSystemDotiLoc= 2 + MudSystem%iLoc= 2 - MudSystemDotKickDv= MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotAnn_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal + MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - MudSystemDotMinKickDv= min( MudSystemDotKickDv,MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1), MudSystemDotOp_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick + MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1), MudSystem%Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick - NewDensity= Ann_Density%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotNewVolume= MudSystemDotMinKickDv + MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1) + MudSystem%NewVolume= MudSystem%MinKickDv - if ( MudSystemDotMinKickDv == MudSystemDotKickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund + if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund !write(*,*) '****4----1' - MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotMinKickDv + MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv - MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1 + MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 - MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! Op_KickLoc= last + MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last ! backheade kick zire mate bashad - if ( MudSystemDotOp_KickLoc>1) then + if ( MudSystem%Op_KickLoc>1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) + call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) else ! merge - MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume + MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== !write(*,*) '****5-2' - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_Density%AddToFirst (NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) endif - elseif ( MudSystemDotMinKickDv == MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) ) then ! eleman bala sari baghi nemimund + elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund !write(*,*) '****4----2' - call MudSystemDotAnn_MudDischarged_Volume%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Backhead_X%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Backhead_section%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Forehead_X%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Mud_Forehead_section%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_Density%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_RemainedVolume_in_LastSection%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_EmptyVolume_inBackheadLocation%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_MudOrKick%Remove (MudSystemDotAnn_KickLoc+1) - call Ann_CuttingMud%Remove (MudSystemDotAnn_KickLoc+1) + call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1) + call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1) - MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1 + MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 - MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! Op_KickLoc= last + MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last ! backheade kick zire mate bashad - if (MudSystemDotOp_KickLoc > 1) then + if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) + call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == NewDensity - MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume + else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_Density%AddToFirst (NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) endif - elseif ( MudSystemDotMinKickDv == MudSystemDotOp_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod + elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod !write(*,*) '****4----3' - MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotMinKickDv + MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv - MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1 + MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 - MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) - MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) + MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) + MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - call MudSystemDotOp_MudDischarged_Volume%Remove (MudSystemDotOp_KickLoc) ! Op_KickLoc= last - call MudSystemDotOp_Mud_Backhead_X%Remove (MudSystemDotOp_KickLoc) - call Op_Mud_Backhead_section%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_Mud_Forehead_X%Remove (MudSystemDotOp_KickLoc) - call Op_Mud_Forehead_section%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_Density%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (MudSystemDotOp_KickLoc) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (MudSystemDotOp_KickLoc) - call Op_MudOrKick%Remove (MudSystemDotOp_KickLoc) + call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc) ! Op_KickLoc= last + call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc) + call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc) ! backheade kick zire mate bashad - if (MudSystemDotOp_KickLoc > 1) then + if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) - call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) + call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == NewDensity - MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume + else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - call MudSystemDotOp_Density%AddToFirst (NewDensity) - call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) - call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) - call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Op_MudOrKick%AddToFirst (0) + call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) + call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) + call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) + call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) + call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Op_MudOrKick%AddToFirst (0) endif - MudSystemDotiLoc= 1 ! ok + MudSystem%iLoc= 1 ! ok endif @@ -775,7 +770,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !============================== kick 2 tarafe mate bashad *4 with pump ============================== ! - !if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 .and. AnnulusFlowRate /= 0.0 ) then + !if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 .and. MudSystem%AnnulusFlowRate /= 0.0 ) then ! write(*,*) '****4 with pump' ! ! KickMigration_2SideBit= .true. @@ -788,13 +783,13 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! !MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick ! ! - ! !NewDensity= Ann_Density%Array (Ann_KickLoc+1) + ! !MudSystem%NewDensity= Ann_Density%Array (Ann_KickLoc+1) ! !NewVolume= MinKickDv ! ! - ! if ( ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad---tu in halat aslan kari be elemane balaiye kick tuye Ann nadarim + ! if ( ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad---tu in halat aslan kari be elemane balaiye kick tuye Ann nadarim ! !WRITE(*,*) '*****sorate pump bishtar az kick*******' - ! MinKickDv= ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! dar asl maxKickDv ast + ! MinKickDv= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! dar asl maxKickDv ast ! ! ! @@ -814,13 +809,13 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! backheade kick zire mate bashad ! if ( Op_KickLoc>1) then ! - ! if ( Op_Density%Array (Op_KickLoc-1) /= St_Density%Last() ) then + ! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! - ! call Op_Density%AddTo (Op_KickLoc,St_Density%Last()) + ! call Op_Density%AddTo (Op_KickLocMudSystem%St_Density%Last()) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,MinKickDv) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -831,7 +826,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! - ! else !Op_Density%Array (imudKick-1) == NewDensity + ! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume ! @@ -845,7 +840,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! !Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst (St_Density%Last()) + ! call Op_Density%AddToFirst MudSystem%St_Density%Last()) ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -865,7 +860,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! write(*,*) '****4----3 with pump a' ! ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) + ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline)-MinKickDv + ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) + ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)-MinKickDv ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! @@ -883,13 +878,13 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! - ! if ( Op_Density%Array (Op_KickLoc-1) /= St_Density%Last() ) then + ! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then ! ! ! !Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! !Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! - ! call Op_Density%AddTo (Op_KickLoc,St_Density%Last()) + ! call Op_Density%AddTo (Op_KickLocMudSystem%St_Density%Last()) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,MinKickDv) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -901,7 +896,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! ! - ! else !Op_Density%Array (imudKick-1) == NewDensity + ! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity ! ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + MinKickDv @@ -915,7 +910,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst (St_Density%Last()) + ! call Op_Density%AddToFirst MudSystem%St_Density%Last()) ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -928,12 +923,12 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! endif ! ! - ! endif ! ende 2 halat ke kick tuye Op baghi bemune ya namune- dar halati ke ((AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) ! sorate pump bishtar az kick bashad + ! endif ! ende 2 halat ke kick tuye Op baghi bemune ya namune- dar halati ke ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) ! sorate pump bishtar az kick bashad ! ! ! ! - ! else !if( ((AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) then ! sorate pump kamtar az kick bashad + ! else !if( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) then ! sorate pump kamtar az kick bashad ! !WRITE(*,*) '*****sorate pump kamtar az kick*******' ! ! @@ -948,18 +943,18 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund ! !write(*,*) '****4----1 with pump' - ! !write(*,*) 'St_Density%Last()=' , St_Density%Last() - ! !write(*,*) '((AnnulusFlowRate/60.)*DeltaT_Mudline)=' , ((AnnulusFlowRate/60.)*DeltaT_Mudline) + ! !write(*,*) MudSystem%St_Density%Last()=' ,MudSystem%St_Density%Last() + ! !write(*,*) '((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)=' , ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) ! !write(*,*) 'Ann_Density%Array(Ann_KickLoc+1)=' , Ann_Density%Array(Ann_KickLoc+1) - ! !write(*,*) '(MinKickDv-((AnnulusFlowRate/60.)*DeltaT_Mudline))=' , (MinKickDv-((AnnulusFlowRate/60.)*DeltaT_Mudline)) + ! !write(*,*) '(MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline))=' , (MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)) ! ! - ! NewDensity= (St_Density%Last()*((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & - ! / (((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + (MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) + ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & + ! / (((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + (MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) ! NewVolume= MinKickDv ! ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - (MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline)) + ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - (MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)) ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! @@ -971,14 +966,14 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then + ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! - ! call Op_Density%AddTo (Op_KickLoc,NewDensity) + ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -992,7 +987,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*NewDensity) / & + ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! @@ -1005,7 +1000,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst (NewDensity) + ! call Op_Density%AddToFirst (MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -1022,8 +1017,8 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! elseif ( MinKickDv == Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund ! write(*,*) '****4----2 with pump' ! - ! NewDensity= (St_Density%Last()*((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & - ! / (((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)) + ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & + ! / (((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)) ! NewVolume= MinKickDv ! ! call RemoveAnnulusMudArrays(Ann_KickLoc+1) @@ -1035,13 +1030,13 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then + ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! - ! call Op_Density%AddTo (Op_KickLoc,NewDensity) + ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -1055,7 +1050,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*NewDensity) / & + ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! @@ -1068,7 +1063,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst (NewDensity) + ! call Op_Density%AddToFirst (MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -1084,7 +1079,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! elseif ( MinKickDv == Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod ! write(*,*) '****4----3 with pump b' ! - ! NewDensity= St_Density%Last() + ! MudSystem%NewDensity=MudSystem%St_Density%Last() ! NewVolume= MinKickDv ! ! @@ -1111,13 +1106,13 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then + ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! !write(*,*) 'pointer 3' ! ! ! ! - ! call Op_Density%AddTo (Op_KickLoc,NewDensity) + ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -1132,7 +1127,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*NewDensity) / & + ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! endif @@ -1144,7 +1139,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! !write(*,*) 'pointer 6' ! ! - ! call Op_Density%AddToFirst (NewDensity) + ! call Op_Density%AddToFirst (MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -1162,7 +1157,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem ! ! ! - ! endif !( ((AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) ! sorate pump kamtar az kick bashad + ! endif !( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) ! sorate pump kamtar az kick bashad ! ! ! @@ -1172,7 +1167,7 @@ DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystem !======================================================================================== ENDDO ! KickNumber= 1, NewInfluxNumber - +MudSystem%KickNumber = kickNumber !write(*,*) 'c)Ann_MudDischarged_Volume%Array(:)=' , sum(Ann_MudDischarged_Volume%Array(:)) diff --git a/Equipments/MudSystem/MudSystem.f90 b/Equipments/MudSystem/MudSystem.f90 index 8edfe06..fe355e2 100644 --- a/Equipments/MudSystem/MudSystem.f90 +++ b/Equipments/MudSystem/MudSystem.f90 @@ -1,4 +1,4 @@ -module MudSystem +module MudSystemModule USE MudSystemVARIABLES USE PressureDisplayVARIABLES @@ -13,7 +13,7 @@ module MudSystem use CError use CLog1 USE CDataDisplayConsoleVariables - use CStudentStationVariables , PitGainLossReset=>PitGainLossZero + use CStudentStationVariables! , PitGainLossReset=>PitGainLossZero implicit none @@ -217,7 +217,7 @@ module MudSystem !================================================ !============BellNippleToPits-FullWell============== - if(MudSystemDotFirstMudSet== 1 ) then !.and. WellisNOTFull== .false.) then ! Well Must Be Full !Ann_Mud_Forehead_X%Last()==AboveAnnularHeight .and. Ann_Density%Last()/=0.0) + if(MudSystem%FirstMudSet== 1 ) then !.and. WellisNOTFull== .false.) then ! Well Must Be Full !Ann_Mud_Forehead_X%Last()==AboveAnnularHeight .and. Ann_Density%Last()/=0.0) if(condition4) then j3=j3+1 B71=1 @@ -309,18 +309,18 @@ module MudSystem !============BellNippleToWell-NonFullWell============== - if(condition16 .and. MudSystemDotFirstMudSet== 1 .and. BellNippleVolume > 0.0001 .and. MudSystemDotWellisNOTFull) then + if(condition16 .and. MudSystem%FirstMudSet== 1 .and. MudSystem%BellNippleVolume > 0.0001 .and. MudSystem%WellisNOTFull) then write(*,*) 'MUD(7)%Q=' , MUD(7)%Q - write(*,*) 'BellNippleVolume=' , BellNippleVolume + write(*,*) 'BellNippleVolume=' , MudSystem%BellNippleVolume - write(*,*) 'MudVolume_InjectedFromAnn-WellToBellNipple=' , MudVolume_InjectedFromAnn + write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn - write(*,*) 'int:::=' , (Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) - write(*,*) 'Ann_Mud_Forehead_X%Last()=' , Ann_Mud_Forehead_X%Last() + write(*,*) 'int:::=' , (MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) + write(*,*) 'Ann_Mud_Forehead_X%Last()=' , MudSystem%Ann_Mud_Forehead_X%Last() write(*,*) 'AboveAnnularHeight=' , BopStackSpecification%AboveAnnularHeight - write(*,*) 'Ann_Density%Last()=' , Ann_Density%Last() + write(*,*) 'Ann_Density%Last()=' , MudSystem%Ann_Density%Last() CALL ErrorStop('error stop1') j11=j11+1 @@ -430,14 +430,14 @@ module MudSystem !write(*,*) 'condition32===' , condition32 !============MudPump1HasNoPath=================== - if(condition32Final) then + if(MudSystem%condition32Final) then !write(*,*) 'MudPump1HasNoPath' Mp1_NoPath = 1 endif !================================================ !============MudPump2HasNoPath=================== - if(condition33Final) then + if(MudSystem%condition33Final) then !write(*,*) 'MudPump2HasNoPath' Mp2_NoPath = 1 endif @@ -445,7 +445,7 @@ module MudSystem !============CementPumpHasNoPath=================== - if(condition34Final) then + if(MudSystem%condition34Final) then Cp_NoPath = 1 endif !================================================ @@ -592,9 +592,9 @@ module MudSystem endif if (j20>0) then - WellToChokeLineGauge= .true. + MudSystem%WellToChokeLineGauge= .true. else - WellToChokeLineGauge= .false. + MudSystem%WellToChokeLineGauge= .false. endif !================================================ @@ -613,9 +613,9 @@ module MudSystem endif if (j21>0) then - ChokeLineGaugeToTanks= .true. + MudSystem%ChokeLineGaugeToTanks= .true. else - ChokeLineGaugeToTanks= .false. + MudSystem%ChokeLineGaugeToTanks= .false. endif !================================================ @@ -638,9 +638,9 @@ module MudSystem implicit none Integer I - MudSystemDotMudSys_timeCounter = MudSystemDotMudSys_timeCounter + 1 + MudSystem%MudSys_timeCounter = MudSystem%MudSys_timeCounter + 1 if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystemDotMudSys_timeCounter= 0 + MudSystem%MudSys_timeCounter= 0 endif !WRITE (*,*) 'MudSys_timeCounter', MudSys_timeCounter @@ -657,14 +657,14 @@ module MudSystem !ReserveTankVolume= ReserveMudVolumeGal ! update from student input !ReserveTankDensity= ReserveDensity ! update from student input if (j7 > 0) then !ActiveTankToDump - ActiveTankDensity= 0. - ActiveTankVolume= 0. + MudSystem%ActiveTankDensity= 0. + MudSystem%ActiveTankVolume= 0. endif if (j8 > 0) then !TripTankToDump - TripTankDensityCalc= 0. - TripTankVolumeCalc= 0. + MudSystem%TripTankDensityCalc= 0. + MudSystem%TripTankVolumeCalc= 0. endif !=========================================================================================================================== !=========================================================================================================================== @@ -680,15 +680,15 @@ module MudSystem if (j2 /= 0 .or. j12/= 0) then - ActiveTankDensity = (ActiveTankDensity*ActiveTankVolume+ Mp1Coef*Mp1Density*(PUMP(1)%Flow_Rate*DeltaT_Mudline/60.) + Mp2Coef*Mp2Density*(PUMP(2)%Flow_Rate*DeltaT_Mudline/60.))/ & - (ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*DeltaT_Mudline/60.)) + MudSystem%ActiveTankDensity = (MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume+ Mp1Coef*MudSystem%Mp1Density*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*MudSystem%Mp2Density*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))/ & + (MudSystem%ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)) - ActiveTankVolume= ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*DeltaT_Mudline/60. + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60. !write(*,*) 'active by j15' endif - ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif @@ -699,10 +699,10 @@ module MudSystem if (j13>0) CpCoef= 1.0 - CementTankDensityCalc= (CementTankDensityCalc*CementTankVolumeCalc+ CpCoef*Mp3Density*(PUMP(3)%Flow_Rate*DeltaT_Mudline/60.) ) / & - (CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*DeltaT_Mudline/60.)) + MudSystem%CementTankDensityCalc= (MudSystem%CementTankDensityCalc*MudSystem%CementTankVolumeCalc+ CpCoef*MudSystem%Mp3Density*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) ) / & + (MudSystem%CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)) - CementTankVolumeCalc= CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*DeltaT_Mudline/60.) + MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) endif @@ -710,15 +710,15 @@ module MudSystem !=========================================================================================================================== !=========================================================================================================================== ! DUMP Path - PumpsDumpVolume= PumpsDumpVolume+ (jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate) *DeltaT_Mudline/60. - PumpsDumpFlowRate= jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate + MudSystem%PumpsDumpVolume= MudSystem%PumpsDumpVolume+ (jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate) *MudSystem%DeltaT_Mudline/60. + MudSystem%PumpsDumpFlowRate= jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate - if (Hoisting%DriveType==1 .and. PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then + if (Hoisting%DriveType==1 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then !write(*,*) 'Set_FlowFromKelly(.TRUE.)' call Activate_PumpWithKellyDisconnected() !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate - CALL Set_FlowFromKelly(min(PumpsDumpFlowRate/6.,100.)) ! .TRUE. before + CALL Set_FlowFromKelly(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before elseif (Hoisting%DriveType==1) then call Deactivate_PumpWithKellyDisconnected() CALL Set_FlowFromKelly(0.0) ! .FALSE. before @@ -728,10 +728,10 @@ module MudSystem !write(*,*) 'DumpFromFillupHead_Pump1=' , DumpFromFillupHead_Pump1 - if (Hoisting%DriveType==0 .and. PumpsDumpFlowRate > 0.0 .and. (DumpFromTopDrive_Pump1 .or. DumpFromTopDrive_Pump2 .or. DumpFromTopDrive_Pump3)) then + if (Hoisting%DriveType==0 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromTopDrive_Pump1 .or. DumpFromTopDrive_Pump2 .or. DumpFromTopDrive_Pump3)) then !write(*,*) 'Set_FlowFromKelly(.TRUE.)' call Activate_PumpWithTopdriveDisconnected() - CALL Set_FlowFromKelly(min(PumpsDumpFlowRate/6.,100.)) ! .TRUE. before + CALL Set_FlowFromKelly(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before elseif (Hoisting%DriveType==0) then call Deactivate_PumpWithTopdriveDisconnected() CALL Set_FlowFromKelly(0.0) ! .FALSE. before @@ -741,10 +741,10 @@ module MudSystem - if (PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then + if (MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then !call Activate_PumpWithKellyDisconnected() - CALL Set_FlowFromFillupHead(min(PumpsDumpFlowRate/6.,100.)) ! .TRUE. before + CALL Set_FlowFromFillupHead(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before else !call Deactivate_PumpWithKellyDisconnected() CALL Set_FlowFromFillupHead(0.0) ! .FALSE. before @@ -884,18 +884,18 @@ module MudSystem if (PumpPressure1 >= MaxWorkingPressure1 .and. MP1_Q > 0.0) then write(*,*) 'mp1,if=' , PumpPressure1 , MaxWorkingPressure1 , MP1_Q - MudSystemDotPump1BlownCount = MudSystemDotPump1BlownCount + 1 + MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1 !if (Pump1BlownStarted == .FALSE.) then ! write(*,*) 'if (Pump1BlownStarted == .FALSE. ) then' ! Pump1BlownInTimeStep = SimulationTime + BlownThresholdInSecond ! Pump1BlownStarted = .TRUE. !endif !write(*,*) 'SimulationTime===', SimulationTime, Pump1BlownInTimeStep - if(PumpsSpecification%MudPump1ReliefValveIsSet .and. MudSystemDotPump1BlownCount >= BlownThreshold) then + if(PumpsSpecification%MudPump1ReliefValveIsSet .and. MudSystem%Pump1BlownCount >= BlownThreshold) then write(*,*) 'valve 65 open, BLOWN' call ChangeValve(65, .TRUE.) PumpToManifoldCompressedMudVol= 0.0 - MudSystemDotPump1BlownCount = 0 + MudSystem%Pump1BlownCount = 0 !Pump1BlownStarted = .FALSE. !else ! write(*,*) 'PumpPressure1= 6000 psi' @@ -917,17 +917,17 @@ module MudSystem if(PumpPressure2 >= MaxWorkingPressure2 .and. MP2_Q > 0.0 ) then write(*,*) 'mp2,if=' , PumpPressure2 , MaxWorkingPressure2 , MP2_Q - MudSystemDotPump2BlownCount = MudSystemDotPump2BlownCount + 1 + MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1 !if (Pump2BlownStarted == .FALSE. ) then ! Pump2BlownInTimeStep = SimulationTime + BlownThresholdInSecond ! Pump2BlownStarted = .TRUE. !endif !if (MudPump2ReliefValveIsSet .and. SimulationTime >= Pump2BlownInTimeStep .and. Pump2BlownStarted) then - if (PumpsSpecification%MudPump2ReliefValveIsSet .and. MudSystemDotPump2BlownCount >= BlownThreshold) then + if (PumpsSpecification%MudPump2ReliefValveIsSet .and. MudSystem%Pump2BlownCount >= BlownThreshold) then write(*,*) 'valve 66 open, BLOWN' call ChangeValve(66, .TRUE.) PumpToManifoldCompressedMudVol= 0.0 - MudSystemDotPump2BlownCount = 0 + MudSystem%Pump2BlownCount = 0 !Pump2BlownInTimeStep = 0 !Pump2BlownStarted = .FALSE. !else @@ -942,12 +942,12 @@ module MudSystem !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array)))) .and. MP3_Q > 0.0 ) then if(PumpPressure3 >= MaxWorkingPressure3 .and. MP3_Q > 0.0 ) then - MudSystemDotPump3BlownCount = MudSystemDotPump3BlownCount + 1 - if (PumpsSpecification%CementPumpReliefValveIsSet .and. MudSystemDotPump3BlownCount >= BlownThreshold) then + MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1 + if (PumpsSpecification%CementPumpReliefValveIsSet .and. MudSystem%Pump3BlownCount >= BlownThreshold) then !write(*,*) 'valve 67 open, BLOWN' call ChangeValve(67, .TRUE.) PumpToManifoldCompressedMudVol= 0.0 - MudSystemDotPump3BlownCount = 0 + MudSystem%Pump3BlownCount = 0 !else ! PumpPressure3= 6000. !psi endif @@ -959,13 +959,13 @@ module MudSystem !write(*,*) '3)PumpPressure1=' , PumpPressure1 if (PumpPressure1>= 6000.) then - MudSystemDotPump1BlownCount = MudSystemDotPump1BlownCount + 1 - if(MudSystemDotPump1BlownCount >= BlownThreshold) then + MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1 + if(MudSystem%Pump1BlownCount >= BlownThreshold) then call ChangeValve(65, .TRUE.) PumpToManifoldCompressedMudVol= 0.0 call Activate_Pump1Failure() - Pump1OffFailure= .true. - MudSystemDotPump1BlownCount = 0 + MudSystem%Pump1OffFailure= .true. + MudSystem%Pump1BlownCount = 0 endif !else !Pump1BlownInTimeStep = 0 @@ -973,13 +973,13 @@ module MudSystem endif if (PumpPressure2>= 6000.) then - MudSystemDotPump2BlownCount = MudSystemDotPump2BlownCount + 1 - if(MudSystemDotPump2BlownCount >= BlownThreshold) then + MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1 + if(MudSystem%Pump2BlownCount >= BlownThreshold) then call ChangeValve(66, .TRUE.) PumpToManifoldCompressedMudVol= 0.0 call Activate_Pump2Failure() - Pump2OffFailure= .true. - MudSystemDotPump2BlownCount = 0 + MudSystem%Pump2OffFailure= .true. + MudSystem%Pump2BlownCount = 0 endif !else !Pump2BlownInTimeStep = 0 @@ -987,13 +987,13 @@ module MudSystem endif if (PumpPressure3>= 6000.) then - MudSystemDotPump3BlownCount = MudSystemDotPump3BlownCount + 1 - if(MudSystemDotPump3BlownCount >= BlownThreshold) then + MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1 + if(MudSystem%Pump3BlownCount >= BlownThreshold) then call ChangeValve(67, .TRUE.) PumpToManifoldCompressedMudVol= 0.0 call Activate_Pump3Failure() - Pump3OffFailure= .true. - MudSystemDotPump3BlownCount = 0 + MudSystem%Pump3OffFailure= .true. + MudSystem%Pump3BlownCount = 0 endif !else !Pump3BlownInTimeStep = 0 @@ -1007,7 +1007,7 @@ module MudSystem !MUD(7)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline - MUD(7)%Q= ( MudVolume_InjectedFromAnn + MudSystemDotAnn_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud + MUD(7)%Q= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud if (j4 > 0) then @@ -1025,10 +1025,10 @@ module MudSystem !!AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in !write(*,*) 'MUD(7)%Q=' , MUD(7)%Q - !write(*,*) 'MudVolume_InjectedFromAnn-WellToBellNipple=' , MudVolume_InjectedFromAnn + !write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn !write(*,*) 'Ann_Kick_Saved_Volume=' , Ann_Kick_Saved_Volume - sys_total_injected= sys_total_injected+ MudVolume_InjectedFromAnn + sys_total_injected= sys_total_injected+ MudSystem%MudVolume_InjectedFromAnn if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then @@ -1044,20 +1044,20 @@ module MudSystem !WellOutletDensity= Ann_Density%Last() ! (ppg) <<< in CirculationCodeSelect Code - if ((BellNippleVolume+((MUD(7)%Q/60.)*DeltaT_Mudline)) /= 0.0) then + if ((MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)) /= 0.0) then - BellNippleDensity= ((BellNippleDensity*BellNippleVolume)+(WellOutletDensity*(MUD(7)%Q/60.)*DeltaT_Mudline))/(BellNippleVolume+((MUD(7)%Q/60.)*DeltaT_Mudline)) + MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%WellOutletDensity*(MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)) else - BellNippleDensity= 0.0 + MudSystem%BellNippleDensity= 0.0 endif !IF (WellisNOTFull== .false.) THEN ! well must be full to do this order - BellNippleVolume= BellNippleVolume+ ((MUD(7)%Q/60.)*DeltaT_Mudline) + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline) !ENDIF - VolumeToBellNipple= VolumeToBellNipple + BellNippleVolume + VolumeToBellNipple= VolumeToBellNipple + MudSystem%BellNippleVolume !write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple !write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q @@ -1069,9 +1069,9 @@ module MudSystem endif if (j9 > 0) then - WellToPitsOpen= .true. + MudSystem%WellToPitsOpen= .true. else - WellToPitsOpen= .false. + MudSystem%WellToPitsOpen= .false. endif @@ -1084,9 +1084,9 @@ module MudSystem !MudBucketVolume= 0. !MudBucketDensity= 0. ! MudBucketVolume gets value in DisconnectingPipe subroutine - BellNippleVolume= BellNippleVolume+ MudBucketVolume - BellNippleDensity= ActiveTankDensity - MudBucketVolume= 0. + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ MudSystem%MudBucketVolume + MudSystem%BellNippleDensity= MudSystem%ActiveTankDensity + MudSystem%MudBucketVolume= 0. endif !=========================================================================================================================== @@ -1098,7 +1098,7 @@ module MudSystem MUD(6)%Q= 300. ! constant flow rate(gpm) - TripTankVolumeCalc= TripTankVolumeCalc - ((MUD(6)%Q/60.)*DeltaT_Mudline) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc - ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) !write(*,*) 'ActiveTankVolume before=', ActiveTankVolume @@ -1106,28 +1106,28 @@ module MudSystem if (j6 == 1 .and. D71==1) then !write(*,*) 'add to active' - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(TripTankDensityCalc*(MUD(6)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((MUD(6)%Q/60.)*DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ ((MUD(6)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) !write(*,*) 'ActiveTankVolume after=', ActiveTankVolume endif if (j6 == 1 .and. D80==1) then - BellNippleDensity= ((BellNippleDensity*BellNippleVolume)+(TripTankDensityCalc*(MUD(6)%Q/60.)*DeltaT_Mudline))/(BellNippleVolume+((MUD(6)%Q/60.)*DeltaT_Mudline)) - BellNippleVolume= BellNippleVolume+ ((MUD(6)%Q/60.)*DeltaT_Mudline) + MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) endif if (j6 == 2) then - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((0.5*MUD(6)%Q/60.)*DeltaT_Mudline)) - BellNippleDensity= ((BellNippleDensity*BellNippleVolume)+(TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*DeltaT_Mudline))/(BellNippleVolume+((0.5*MUD(6)%Q/60.)*DeltaT_Mudline)) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*DeltaT_Mudline) - BellNippleVolume= BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) endif - ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif @@ -1151,23 +1151,23 @@ module MudSystem !Well to BellNipple: BellNippleVolume !MudBucket to BellNipple: BellNippleVolume !TripTnak to BellNipple: BellNippleVolume - MUD(3)%Q = (BellNippleVolume/DeltaT_Mudline)*60.d0 ! (gpm) + MUD(3)%Q = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60.d0 ! (gpm) !write(*,*) 'BellNippleVolume in j3 =' , BellNippleVolume !write(*,*) 'MUD(3)%Q =' , MUD(3)%Q - call Set_FlowRate(real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8)) ! for unity display - unityreturn = real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8) + call Set_FlowRate(real(100.*min(MUD(3)%Q,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8)) ! for unity display + unityreturn = real(100.*min(MUD(3)%Q,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8) !write(*,*) 'unity return=' , real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8) - if (MUD(3)%Q > PedalMeter .and. B78==0) then - BellNippleDumpVolume= BellNippleDumpVolume + ((MUD(3)%Q/60.)*DeltaT_Mudline - (PedalMeter/60.)*DeltaT_Mudline) + if (MUD(3)%Q > MudSystem%PedalMeter .and. B78==0) then + MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume + ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline - (MudSystem%PedalMeter/60.)*MudSystem%DeltaT_Mudline) !BellNippleDumpRate= MUD(3)%Q - PedalMeter @@ -1179,41 +1179,41 @@ module MudSystem !write(*,*) 'VolumeToActive*******=' , VolumeToActive - active_before= ActiveTankVolume + active_before= MudSystem%ActiveTankVolume - BellNippleVolume= BellNippleVolume- ((MUD(3)%Q/60.)*DeltaT_Mudline) ! to be 0. + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) ! to be 0. - if ( BellNippleDensity > 1.0) then + if ( MudSystem%BellNippleDensity > 1.0) then if (j3 == 1 .and. B71==1) then !(volumes in galon) - MUD(3)%Q = min(MUD(3)%Q , PedalMeter) + MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) !write(*,*) 'MUD(3)%Q=' , MUD(3)%Q IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(BellNippleDensity*(MUD(3)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((MUD(3)%Q/60.)*DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ ((MUD(3)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) !write(*,*) 'active increase bell 1=' , ((MUD(3)%Q/60.)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity > ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN - ActiveTankVolume= ActiveTankVolume+ ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed cutting density = 20.8 ppg + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg !write(*,*) 'active increase bell 2=' , ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity < 5.0) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN - ActiveTankVolume= ActiveTankVolume+ ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg !write(*,*) 'active increase bell 3=' , ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < BellNippleDensity .and. BellNippleDensity <= ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN !write(*,*) ' Auto true 3' - ActiveTankVolume= ActiveTankVolume+ ((MUD(3)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) !write(*,*) 'active increase bell 4=' , ((MUD(3)%Q/60.d0)*DeltaT_Mudline) ENDIF @@ -1221,33 +1221,33 @@ module MudSystem if (j3 == 1 .and. B77==1) then - MUD(3)%Q = min(MUD(3)%Q , PedalMeter) + MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(BellNippleDensity*(MUD(3)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+((MUD(3)%Q/60.)*DeltaT_Mudline)) - TripTankVolumeCalc= TripTankVolumeCalc+ (MUD(3)%Q/60.)*DeltaT_Mudline + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline - ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity > ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity < 5.0) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN - AddedVolumeToTank= ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < BellNippleDensity .and. BellNippleDensity <= ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((MUD(3)%Q/60.d0)*DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank ENDIF @@ -1256,7 +1256,7 @@ module MudSystem if (j3 == 1 .and. B78==1) then - BellNippleDumpVolume= BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*DeltaT_Mudline + MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline !BellNippleDumpRate= MUD(3)%Q @@ -1266,40 +1266,40 @@ module MudSystem if (j3 == 2) then !78 is not allowded in this position - MUD(3)%Q = min(MUD(3)%Q , PedalMeter) + MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(BellNippleDensity*(0.5*MUD(3)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((0.5*MUD(3)%Q/60.)*DeltaT_Mudline)) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(BellNippleDensity*(0.5*MUD(3)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+((0.5*MUD(3)%Q/60.)*DeltaT_Mudline)) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ ((0.5*MUD(3)%Q/60.)*DeltaT_Mudline) - TripTankVolumeCalc= TripTankVolumeCalc+ ((0.5*MUD(3)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity > ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < BellNippleDensity .and. BellNippleDensity <= ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((MUD(3)%Q/60.d0)*DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank ENDIF @@ -1309,7 +1309,7 @@ module MudSystem endif !( BellNippleDensity > 1.0) then - active_after= ActiveTankVolume + active_after= MudSystem%ActiveTankVolume active_increase = active_after - active_before @@ -1325,12 +1325,12 @@ module MudSystem !write(*,*) 'ReturnFlowRate=MUD(3)%Q= after' , MUD(3)%Q - ReturnFlowRate = MUD(3)%Q + MudSystem%ReturnFlowRate = MUD(3)%Q - TripTankVolumeCalc = min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + MudSystem%TripTankVolumeCalc = min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - ActiveTankVolume = min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal - MudProperties%ActiveSettledContentsGal) + MudSystem%ActiveTankVolume = min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal - MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped !write(*,*) 'BellNippleDensity=' , BellNippleDensity @@ -1354,9 +1354,9 @@ module MudSystem - if (j11 > 0 .and. MudChecked== .true.) then !BellNippleToWell-NonFullWell ( FillingWell_By_BellNipple subroutine is called for this state ) + if (j11 > 0 .and. MudSystem%MudChecked== .true.) then !BellNippleToWell-NonFullWell ( FillingWell_By_BellNipple subroutine is called for this state ) !write(*,*) 'j11 is open' - MudChecked= .false. !to be sure that well is not full after arranging muds + MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds !WellToPitsOpen = .TRUE. !BellNipple flow rate= sum flow rate (well+ mudbucket+ triptank) @@ -1365,11 +1365,11 @@ module MudSystem !MudBucket to BellNipple: BellNippleVolume !TripTnak to BellNipple: BellNippleVolume - MUD(8)%Q = (BellNippleVolume/DeltaT_Mudline)*60. + MUD(8)%Q = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60. !write(*,*) 'MUD(8)%Q=' , MUD(8)%Q - BellNippleVolume= BellNippleVolume- ((MUD(8)%Q/60.)*DeltaT_Mudline) ! to be 0. + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(8)%Q/60.)*MudSystem%DeltaT_Mudline) ! to be 0. !write(*,*) 'BellNippleVolume-2nd Mode=' , BellNippleVolume !BellNippleDensity @@ -1394,14 +1394,14 @@ module MudSystem !WRITE (*,*) 'choke condition', j4, ChokeLineNOTFull - if (j4 > 0 .and. MudSystemDotChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26) + if (j4 > 0 .and. MudSystem%ChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26) !write(*,*) 'j4 is open' !write(*,*) 'active by j4' !MUD(4)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline - MUD(4)%Q= ( MudVolume_InjectedFromAnn + MudSystemDotAnn_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud + MUD(4)%Q= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud !if ( WellisNOTFull== .true. ) MUD(4)%Q= 0.0 @@ -1415,7 +1415,7 @@ module MudSystem !call Log_1('MUD(4)%Q=', MUD(4)%Q) - ChokeOutletDensity= MudSystemDotChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code + MudSystem%ChokeOutletDensity= MudSystem%ChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code !MudWeightOut2= ChokeOutletDensity !for drillwatch display @@ -1430,36 +1430,36 @@ module MudSystem !C71: Active Tank C77: Trip Tank C78: ChokeManifoldDump - if ( BellNippleDensity > 1.0) then + if ( MudSystem%BellNippleDensity > 1.0) then ! IN ALL CONDITIONS EFFECT OF 78 IS COMPUTED BY RealJ4 if (C71==1 .and. C77==0) then !(volumes in galon) RealJ4: 1 OR 2(IF 78 IS OPEN) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) !write(*,*) 'active increase choke1=' , (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity > ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN - ActiveTankVolume= ActiveTankVolume+ ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed cutting density = 20.8 ppg - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) !write(*,*) 'active increase choke2=' , ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity < 5.0) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity < 5.0) THEN - ActiveTankVolume= ActiveTankVolume+ ((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) !write(*,*) 'active increase choke3=' ,((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ChokeOutletDensity .and. ChokeOutletDensity <= ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN !write(*,*) ' Auto true 3' - ActiveTankVolume= ActiveTankVolume+ (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) !write(*,*) 'active increase choke4=' , (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) @@ -1472,38 +1472,38 @@ module MudSystem if (C77==1 .and. C71==0) then !RealJ4: 1 OR 2(IF 78 IS OPEN) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)) - TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity > ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity < 5.0) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity < 5.0) THEN - AddedVolumeToTank= ((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ChokeOutletDensity .and. ChokeOutletDensity <= ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ENDIF @@ -1514,44 +1514,44 @@ module MudSystem if (C71==1 .and. C77==1) then !RealJ4: 2 OR 3(IF 78 IS OPEN) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) - TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity > ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ChokeOutletDensity .and. ChokeOutletDensity <= ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN AddedVolumeToTank= ((1.d0/RealJ4)*MUD(4)%Q/60.d0) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank - TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ENDIF @@ -1562,7 +1562,7 @@ module MudSystem if (C71==0 .and. C77==0 .and. C78==1) then !RealJ4: 1 ! autodensity niaz nadarad - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) endif @@ -1571,10 +1571,10 @@ module MudSystem endif ! if ( BellNippleDensity > 1.0) then - TripTankVolumeCalc=min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif @@ -1583,16 +1583,16 @@ module MudSystem - if (j4 == 0 .or. MudSystemDotChokeLineNOTFull== .true.) then + if (j4 == 0 .or. MudSystem%ChokeLineNOTFull== .true.) then !Pressure_BeforeChokes=0.0 ! for normal circulation input MUD(4)%Q=0.0 ! for CirculationCodeSelect input. endif if (j4 > 0) then - WellToChokeManifoldOpen= .true. + MudSystem%WellToChokeManifoldOpen= .true. else - WellToChokeManifoldOpen= .false. + MudSystem%WellToChokeManifoldOpen= .false. endif !=========================================================================================================================== @@ -1620,7 +1620,7 @@ module MudSystem Denominator_a= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*PUMP(3)%Flow_Rate) if (Denominator_a /= 0.) then - Density_Ch= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*Mp3Density*PUMP(3)%Flow_Rate)/ & + MudSystem%Density_Ch= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & Denominator_a !write(*,*) 'Density_Ch=' , Density_Ch ! @@ -1638,40 +1638,40 @@ module MudSystem if (M71==1 .and. M77==0) then !(volumes in galon) RealJ18: 1 OR 2(IF 78 IS OPEN) ! autodensity niaz nadarad - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) endif if (M77==1 .and. M71==0) then !RealJ18: 1 OR 2(IF 78 IS OPEN) ! autodensity niaz nadarad - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)) - TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) endif if (M71==1 .and. M77==1) then !RealJ18: 2 OR 3(IF 78 IS OPEN) ! autodensity niaz nadarad - ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)) + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - ActiveTankVolume= ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) - TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) endif if (M71==0 .and. M77==0 .and. M78==1) then !RealJ18: 1 ! autodensity niaz nadarad - ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline) + MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) endif @@ -1682,10 +1682,10 @@ module MudSystem - TripTankVolumeCalc=min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif @@ -1699,7 +1699,7 @@ module MudSystem !=========================================================================================================================== !=========================================================================================================================== - if (j5 > 0 .and. (ActiveTankVolume/ActiveTankFloorArea) > (TripTankVolumeCalc/TripTankFloorArea)) then !ActiveTankToTripTank + if (j5 > 0 .and. (MudSystem%ActiveTankVolume/MudSystem%ActiveTankFloorArea) > (MudSystem%TripTankVolumeCalc/MudSystem%TripTankFloorArea)) then !ActiveTankToTripTank ! second condition is for Utube flow !write(*,*) 'j5 is open' @@ -1707,14 +1707,14 @@ module MudSystem MUD(5)%Q= 300. ! constant flow rate(gpm) - ActiveTankVolume= ActiveTankVolume - ((MUD(5)%Q/60.)*DeltaT_Mudline) - TripTankVolumeCalc= TripTankVolumeCalc + ((MUD(5)%Q/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume - ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc + ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline) - TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*(MUD(5)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+((MUD(5)%Q/60.)*DeltaT_Mudline)) + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*(MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline)) - TripTankVolumeCalc=min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50, excess value(TripTankVolumeCalc-50) is dumped endif @@ -1730,16 +1730,16 @@ module MudSystem if (K79 == 1) then - PressureGauge75= PressureGauges(1) !String to Gauge75 + MudSystem%PressureGauge75= PressureGauges(1) !String to Gauge75 elseif (K82 == 1 .and. k83 == 0 .and. k84 == 0 .and. k78 == 0) then - PressureGauge75= PumpPressure1 + MudSystem%PressureGauge75= PumpPressure1 elseif (K82 == 0 .and. k83 == 1 .and. k84 == 0 .and. k78 == 0) then - PressureGauge75= PumpPressure2 + MudSystem%PressureGauge75= PumpPressure2 elseif (K82 == 0 .and. k83 == 0 .and. k84 == 1 .and. k78 == 0) then - PressureGauge75= PumpPressure3 + MudSystem%PressureGauge75= PumpPressure3 elseif (K82 == 0 .and. k83 == 0 .and. k84 == 0 .and. k78 == 1) then - PressureGauge75= 0. + MudSystem%PressureGauge75= 0. endif !if (K82 == 1) PressureGauge75= PumpPressure1 !Pump1 to Gauge75' @@ -1750,7 +1750,7 @@ module MudSystem endif - StandPipeManifold%StandPipeGauge1= (1 - StandPipeGauge1Malf) * PressureGauge75 ! for STManifold Display + StandPipeManifold%StandPipeGauge1= (1 - MudSystem%StandPipeGauge1Malf) * MudSystem%PressureGauge75 ! for STManifold Display !write(*,*) 'PressureGauge75=' , PressureGauge75 !P1toSt= jj2*(1-H82)*(1-DumpPump1)*G82 !P2toSt= jj12*(1-H83)*(1-DumpPump2)*G83 @@ -1762,16 +1762,16 @@ module MudSystem if (L79 == 1) then - PressureGauge76= PressureGauges(1) !String to Gauge76 + MudSystem%PressureGauge76= PressureGauges(1) !String to Gauge76 elseif (L82 == 1 .and. L83 == 0 .and. L84 == 0 .and. L78 == 0) then - PressureGauge76= PumpPressure1 + MudSystem%PressureGauge76= PumpPressure1 elseif (L82 == 0 .and. L83 == 1 .and. L84 == 0 .and. L78 == 0) then - PressureGauge76= PumpPressure2 + MudSystem%PressureGauge76= PumpPressure2 elseif (L82 == 0 .and. L83 == 0 .and. L84 == 1 .and. L78 == 0) then - PressureGauge76= PumpPressure3 + MudSystem%PressureGauge76= PumpPressure3 elseif (L82 == 0 .and. L83 == 0 .and. L84 == 0 .and. L78 == 1) then - PressureGauge76= 0. + MudSystem%PressureGauge76= 0. endif @@ -1782,7 +1782,7 @@ module MudSystem !if (L78 == 1) PressureGauge76= 0. !Dump to Gauge76 endif - StandPipeManifold%StandPipeGauge2= (1 - StandPipeGauge2Malf) * PressureGauge76 ! for STManifold Display + StandPipeManifold%StandPipeGauge2= (1 - MudSystem%StandPipeGauge2Malf) * MudSystem%PressureGauge76 ! for STManifold Display !=========================================================================================================================== !=========================================================================================================================== ! @@ -1805,13 +1805,13 @@ module MudSystem !write(*,*) 'TapSelector=' , TapSelector - if (TapSelector == .false.) then + if (StudentStation%TapSelector == .false.) then - DrillingWatch%PumpPressure= PressureGauge75 !for DrillWatch Display - CALL Set_StandPipePressure(real((1-DrillPipePressureMalf)*PressureGauge75 , 8)) !for Data Display Console + DrillingWatch%PumpPressure= MudSystem%PressureGauge75 !for DrillWatch Display + CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%PressureGauge75 , 8)) !for Data Display Console else - DrillingWatch%PumpPressure= PressureGauge76 !for DrillWatch Display - CALL Set_StandPipePressure(real((1-DrillPipePressureMalf)*PressureGauge76 , 8)) !for Data Display Console + DrillingWatch%PumpPressure= MudSystem%PressureGauge76 !for DrillWatch Display + CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%PressureGauge76 , 8)) !for Data Display Console endif !=========================================================================================================================== @@ -1826,20 +1826,20 @@ module MudSystem RealJ2= real(j2) - if (A71==1 .and. (ActiveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (A71==1 .and. (MudSystem%ActiveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then A71= 0 RealJ2= RealJ2-1 write(*,*) 'ActiveTank Level Warning' call Activate_ActiveTankUnderVolume() endif - if (A72==1 .and. (ReserveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (A72==1 .and. (MudSystem%ReserveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then A72= 0 RealJ2= RealJ2-1 write(*,*) 'ReserveTank Level Warning' endif - if (A71==3 .and. (CementTankVolumeCalc-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (A71==3 .and. (MudSystem%CementTankVolumeCalc-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then A73= 0 RealJ2= RealJ2-1 write(*,*) 'CementTank Level Warning' @@ -1848,11 +1848,11 @@ module MudSystem if(RealJ2> 0.0) then - ActiveTankVolume= ActiveTankVolume- A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline) - ReserveTankVolume= ReserveTankVolume- A72*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline) - CementTankVolumeCalc= CementTankVolumeCalc- A73*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- A72*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- A73*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) !write(*,*) 'Active-decline=' , A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline) - total_decrease= total_decrease+ A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline) + total_decrease= total_decrease+ A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then total_decrease= 0. @@ -1860,7 +1860,7 @@ module MudSystem !write(*,*) 'total_decrease=' , total_decrease - Mp1Density= (A71*ActiveTankDensity+A72*ReserveTankDensity+A73*CementTankDensityCalc)/RealJ2 + MudSystem%Mp1Density= (A71*MudSystem%ActiveTankDensity+A72*MudSystem%ReserveTankDensity+A73*MudSystem%CementTankDensityCalc)/RealJ2 else write(*,*) 'stop' endif @@ -1881,19 +1881,19 @@ module MudSystem RealJ12= real(J12) - if (E71==1 .and. (ActiveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (E71==1 .and. (MudSystem%ActiveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then E71= 0 RealJ12= RealJ12-1 write(*,*) 'ActiveTank Level Warning' endif - if (E72==1 .and. (ReserveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (E72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then E72= 0 RealJ12= RealJ12-1 write(*,*) 'ReserveTank Level Warning' endif - if (E71==3 .and. (CementTankVolumeCalc-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (E71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then E73= 0 RealJ12= RealJ12-1 write(*,*) 'CementTank Level Warning' @@ -1902,13 +1902,13 @@ module MudSystem if(RealJ12> 0.0) then - ActiveTankVolume= ActiveTankVolume- E71*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline) - ReserveTankVolume= ReserveTankVolume- E72*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline) - CementTankVolumeCalc= CementTankVolumeCalc- E73*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- E71*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- E72*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- E73*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - Mp2Density= (E71*ActiveTankDensity+E72*ReserveTankDensity+E73*CementTankDensityCalc)/RealJ12 + MudSystem%Mp2Density= (E71*MudSystem%ActiveTankDensity+E72*MudSystem%ReserveTankDensity+E73*MudSystem%CementTankDensityCalc)/RealJ12 else write(*,*) 'stop' endif @@ -1929,19 +1929,19 @@ module MudSystem RealJ13= real(J13) - if (F71==1 .and. (ActiveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (F71==1 .and. (MudSystem%ActiveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then F71= 0 RealJ13= RealJ13-1 write(*,*) 'ActiveTank Level Warning' endif - if (F72==1 .and. (ReserveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (F72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then F72= 0 RealJ13= RealJ13-1 write(*,*) 'ReserveTank Level Warning' endif - if (F71==3 .and. (CementTankVolumeCalc-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then + if (F71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then F73= 0 RealJ13= RealJ13-1 write(*,*) 'CementTank Level Warning' @@ -1950,12 +1950,12 @@ module MudSystem if(RealJ13> 0.0) then - ActiveTankVolume= ActiveTankVolume- F71*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline) - ReserveTankVolume= ReserveTankVolume- F72*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline) - CementTankVolumeCalc= CementTankVolumeCalc- F73*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- F71*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- F72*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- F73*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - Mp3Density= (F71*ActiveTankDensity+F72*ReserveTankDensity+F73*CementTankDensityCalc)/RealJ13 + MudSystem%Mp3Density= (F71*MudSystem%ActiveTankDensity+F72*MudSystem%ReserveTankDensity+F73*MudSystem%CementTankDensityCalc)/RealJ13 else write(*,*) 'stop' endif @@ -2008,13 +2008,13 @@ module MudSystem Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*PUMP(3)%Flow_Rate) if (Denominator /= 0.) then - Suction_Density_MudSystem= (jj2*(1.-H82)*(1.-DumpPump1)*G82*Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*Mp3Density*PUMP(3)%Flow_Rate)/ & + MudSystem%Suction_Density_MudSystem= (jj2*(1.-H82)*(1.-DumpPump1)*G82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & Denominator endif - CompressedMudDensity= Suction_Density_MudSystem + MudSystem%CompressedMudDensity= MudSystem%Suction_Density_MudSystem - DrillingWatch%MudWeightIn= Suction_Density_MudSystem !for drillwatch display + DrillingWatch%MudWeightIn= MudSystem%Suction_Density_MudSystem !for drillwatch display MUD(2)%Q= jj2*(1-H82)*(1-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*G84*PUMP(3)%Flow_Rate @@ -2043,9 +2043,9 @@ module MudSystem !=========================================================================================================================== !=========================================================================================================================== - if (j19 > 0 .and. MudChecked== .true.) then !PumpsToWell_KillLine Suction_Density_PumpsToWell is used for Mud Circulation Code + if (j19 > 0 .and. MudSystem%MudChecked== .true.) then !PumpsToWell_KillLine Suction_Density_PumpsToWell is used for Mud Circulation Code !write(*,*) 'j19 is open' - MudChecked= .false. !to be sure that well is not full after arranging muds + MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> @@ -2082,7 +2082,7 @@ module MudSystem Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*N82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*PUMP(3)%Flow_Rate) if (Denominator /= 0.) then - Suction_Density_PumpsToWell= (jj2*(1.-H82)*(1.-DumpPump1)*N82*Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*Mp3Density*PUMP(3)%Flow_Rate)/ & + MudSystem%Suction_Density_PumpsToWell= (jj2*(1.-H82)*(1.-DumpPump1)*N82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & Denominator endif @@ -2129,10 +2129,10 @@ module MudSystem !!====================================================================== - if ( WellToChokeManifoldOpen .or. WellToPitsOpen) then - WellHeadIsOpen= .true. + if ( MudSystem%WellToChokeManifoldOpen .or. MudSystem%WellToPitsOpen) then + MudSystem%WellHeadIsOpen= .true. else - WellHeadIsOpen= .false. + MudSystem%WellHeadIsOpen= .false. endif @@ -2151,8 +2151,8 @@ module MudSystem IF (Manifold%Valve(67)%Status == .TRUE.) call Activate_Pump3PopOffValveBlown() !Pump2PopOffValveBlown= .TRUE. - IF (ActiveTankVolume >= (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)) THEN - ActiveTankVolume = (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + IF (MudSystem%ActiveTankVolume >= (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)) THEN + MudSystem%ActiveTankVolume = (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) call Activate_ActiveTankOverflow() ELSE call Deactivate_ActiveTankOverflow() @@ -2166,11 +2166,11 @@ module MudSystem !write(*,*) 'ReserveTankVolume=' , real(ReserveTankVolume) - call Set_ActiveMudVolume_StudentStation(real(ActiveTankVolume/42.,8)) ! 42: gal to bbl - call Set_ActiveDensity_StudentStation(real(ActiveTankDensity,8)) - call Set_ReserveMudVolume_StudentStation(real(ReserveTankVolume/42.,8)) ! 42: gal to bbl - call Set_ReserveDensity_StudentStation(real(ReserveTankDensity,8)) - DrillingWatch%KillMudVolume= ReserveTankVolume/42. ! for DrillWatch + call Set_ActiveMudVolume_StudentStation(real(MudSystem%ActiveTankVolume/42.,8)) ! 42: gal to bbl + call Set_ActiveDensity_StudentStation(real(MudSystem%ActiveTankDensity,8)) + call Set_ReserveMudVolume_StudentStation(real(MudSystem%ReserveTankVolume/42.,8)) ! 42: gal to bbl + call Set_ReserveDensity_StudentStation(real(MudSystem%ReserveTankDensity,8)) + DrillingWatch%KillMudVolume= MudSystem%ReserveTankVolume/42. ! for DrillWatch !PitGainLose= @@ -2180,20 +2180,20 @@ module MudSystem IF (DataDisplayConsole%TotalStrokeCounterResetSwitch == 1) then !for drilling data display - TotalStrokesPump1=0. - TotalStrokesPump2=0. + MudSystem%TotalStrokesPump1=0. + MudSystem%TotalStrokesPump2=0. ENDIF - TotalStrokesPump1=TotalStrokesPump1+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline !for drilling data display - TotalStrokesPump2=TotalStrokesPump2+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline !for drilling data display - GraphTotalStrokes=GraphTotalStrokes+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline + MudSystem%TotalStrokesPump1=MudSystem%TotalStrokesPump1+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display + MudSystem%TotalStrokesPump2=MudSystem%TotalStrokesPump2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display + MudSystem%GraphTotalStrokes=MudSystem%GraphTotalStrokes+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline - MPumps%Total_Stroke_Counter_For_Plot = MPumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * DeltaT_Mudline + MPumps%Total_Stroke_Counter_For_Plot = MPumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * MudSystem%DeltaT_Mudline CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot)) - DataDisplayConsole%TotalStrokeCounter= real(nint(TotalStrokesPump1+TotalStrokesPump2)) !for drilling data display + DataDisplayConsole%TotalStrokeCounter= real(nint(MudSystem%TotalStrokesPump1+MudSystem%TotalStrokesPump2)) !for drilling data display !=========================================================================== ! MUD PUMP STROKES @@ -2218,8 +2218,8 @@ module MudSystem !write(*,*) 'b)))' , ChokePanelStrokeResetSwitch - Choke%TotalStrokes1= Choke%TotalStrokes1+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline - Choke%TotalStrokes2= Choke%TotalStrokes2+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline + Choke%TotalStrokes1= Choke%TotalStrokes1+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline + Choke%TotalStrokes2= Choke%TotalStrokes2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline @@ -2242,25 +2242,25 @@ module MudSystem !!====================================================================== - DrillingWatch%PitVolume= ActiveTankVolume/42.d0 !(bbl) For DrillWatch Display + DrillingWatch%PitVolume= MudSystem%ActiveTankVolume/42.d0 !(bbl) For DrillWatch Display !write(*,*) 'PitVolume,ActiveTankVolume=' ,PitVolume,ActiveTankVolume - MudTank1_vol= ActiveTankVolume/3. ! (gal) - MudTank2_vol= ActiveTankVolume/3. ! (gal) - MudTank3_vol= ActiveTankVolume/3. ! (gal) - MudTank4_vol= TripTankVolumeCalc + MudSystem%MudTank1_vol= MudSystem%ActiveTankVolume/3. ! (gal) + MudSystem%MudTank2_vol= MudSystem%ActiveTankVolume/3. ! (gal) + MudSystem%MudTank3_vol= MudSystem%ActiveTankVolume/3. ! (gal) + MudSystem%MudTank4_vol= MudSystem%TripTankVolumeCalc IF (DataDisplayConsole%MVTPowerSwitch==1) THEN - DataDisplayConsole%MudTanksVolumeGauge= (1 - MudTanksVolumeGaugeMalf) *((MudTank1_vol*DataDisplayConsole%MudTank1Switch)+(MudTank2_vol*DataDisplayConsole%MudTank2Switch)+ & - (MudTank3_vol*DataDisplayConsole%MudTank3Switch)+(MudTank4_vol*DataDisplayConsole%MudTank4Switch)+ActiveTankSettled) !(gal) + DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%MudTanksVolumeGaugeMalf) *((MudSystem%MudTank1_vol*DataDisplayConsole%MudTank1Switch)+(MudSystem%MudTank2_vol*DataDisplayConsole%MudTank2Switch)+ & + (MudSystem%MudTank3_vol*DataDisplayConsole%MudTank3Switch)+(MudSystem%MudTank4_vol*DataDisplayConsole%MudTank4Switch)+MudSystem%ActiveTankSettled) !(gal) ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN - DataDisplayConsole%MudTanksVolumeGauge= (1 - MudTanksVolumeGaugeMalf) *0. + DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%MudTanksVolumeGaugeMalf) *0. ENDIF !!====================================================================== @@ -2335,16 +2335,16 @@ module MudSystem - DrillingWatch%PercentFlow= (ReturnFlowRate/PedalMeter) *100. !(percent) ! for DrillWatch display + DrillingWatch%PercentFlow= (MudSystem%ReturnFlowRate/MudSystem%PedalMeter) *100. !(percent) ! for DrillWatch display if (abs(DrillingWatch%PercentFlow - unityreturn) > 1.0) then - write(*,*) 'PercentFlow,ReturnFlowRate,PedalMeter=' , DrillingWatch%PercentFlow,ReturnFlowRate,PedalMeter + write(*,*) 'PercentFlow,ReturnFlowRate,PedalMeter=' , DrillingWatch%PercentFlow,MudSystem%ReturnFlowRate,MudSystem%PedalMeter write(*,*) 'unityreturn=' , unityreturn endif ! ReturnFlowRate=800. set in startup as initial value - ReturnFlowPercent= (ReturnFlowRate/PedalMeter) *100. !(percent) + MudSystem%ReturnFlowPercent= (MudSystem%ReturnFlowRate/MudSystem%PedalMeter) *100. !(percent) !write(*,*) 'ReturnFlowPercent,ReturnFlowRate=' , ReturnFlowPercent,ReturnFlowRate ! if ReturnFlowRate>PedalMeter, excess value(ReturnFlowRate-PedalMeter) is dumped in the code before @@ -2353,7 +2353,7 @@ module MudSystem !! DRILL WATCH !!====================================================================== - DrillingWatch%PitGainLose= ((ActiveTankVolume/42.) - RefrencePitVolume_DrillWatch) ! DrillWatch + DrillingWatch%PitGainLose= ((MudSystem%ActiveTankVolume/42.) - MudSystem%RefrencePitVolume_DrillWatch) ! DrillWatch !write(*,*) 'PitGainLose galon' , PitGainLose*42. @@ -2379,14 +2379,14 @@ module MudSystem ! endif - if (PitGainLossReset) then + if (StudentStation%PitGainLossZero) then DrillingWatch%PitGainLose= 0.d0 !DrillWatch - RefrencePitVolume_DrillWatch= ActiveTankVolume/42. !(bbl) !DrillWatch + MudSystem%RefrencePitVolume_DrillWatch= MudSystem%ActiveTankVolume/42. !(bbl) !DrillWatch !********************************************* DataDisplayConsole%PitGainLossGauge= 0. !MFF Indicator - RefrencePitVolume= ActiveTankVolume/42. !(bbl) !MFF Indicator + MudSystem%RefrencePitVolume= MudSystem%ActiveTankVolume/42. !(bbl) !MFF Indicator endif @@ -2406,41 +2406,41 @@ module MudSystem !====================TotalStrokes Reset and Calculate====================== if (DataDisplayConsole%MFFIResetTotalStrokes == 1) then IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN - TotalStrokes1MFFI =0. + MudSystem%TotalStrokes1MFFI =0. elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN - TotalStrokes2MFFI =0. + MudSystem%TotalStrokes2MFFI =0. else - TotalStrokes1MFFI =0. - TotalStrokes2MFFI =0. + MudSystem%TotalStrokes1MFFI =0. + MudSystem%TotalStrokes2MFFI =0. endif endif - TotalStrokes1MFFI= TotalStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline - TotalStrokes2MFFI= TotalStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline + MudSystem%TotalStrokes1MFFI= MudSystem%TotalStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline + MudSystem%TotalStrokes2MFFI= MudSystem%TotalStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline !==================FillStrokes Reset and Calculate========================= if (DataDisplayConsole%MFFIResetFillCounter == 1) then IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN - TotalFillStrokes1MFFI =0. + MudSystem%TotalFillStrokes1MFFI =0. elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN - TotalFillStrokes2MFFI =0. + MudSystem%TotalFillStrokes2MFFI =0. else - TotalFillStrokes1MFFI =0. - TotalFillStrokes2MFFI =0. + MudSystem%TotalFillStrokes1MFFI =0. + MudSystem%TotalFillStrokes2MFFI =0. endif endif - TotalFillStrokes1MFFI= TotalFillStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline - TotalFillStrokes2MFFI= TotalFillStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline + MudSystem%TotalFillStrokes1MFFI= MudSystem%TotalFillStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline + MudSystem%TotalFillStrokes2MFFI= MudSystem%TotalFillStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline !=================================================================== if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(TotalStrokes1MFFI)) !TotalStroke LED + DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI)) !TotalStroke LED elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(TotalStrokes2MFFI)) !TotalStroke LED + DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes2MFFI)) !TotalStroke LED elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(TotalStrokes1MFFI+TotalStrokes2MFFI)) !TotalStroke LED + DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI+MudSystem%TotalStrokes2MFFI)) !TotalStroke LED endif @@ -2454,19 +2454,19 @@ module MudSystem endif ELSE ! (MFFIFillSPMSelectorSwitch== .true.) then !(fill mode) - if (ReturnFlowRate== 0) then + if (MudSystem%ReturnFlowRate== 0) then if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = real(nint(TotalFillStrokes1MFFI)) !Fill or SPM LED + DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes1MFFI)) !Fill or SPM LED elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = real(nint(TotalFillStrokes2MFFI)) !Fill or SPM LED + DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= real(nint(TotalFillStrokes1MFFI+TotalFillStrokes2MFFI)) !Fill or SPM LED + DataDisplayConsole%FillStrokeCounter= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED endif - TotalFilledStrokesBy1MFFI = real(nint(TotalFillStrokes1MFFI))! for values=fix on LED after the well filled - TotalFilledStrokesBy2MFFI = real(nint(TotalFillStrokes2MFFI))! for values=fix on LED after the well filled - TotalFilledStrokesBy1and2MFFI= real(nint(TotalFillStrokes1MFFI+TotalFillStrokes2MFFI))! for values=fix on LED after the well filled + MudSystem%TotalFilledStrokesBy1MFFI = real(nint(MudSystem%TotalFillStrokes1MFFI))! for values=fix on LED after the well filled + MudSystem%TotalFilledStrokesBy2MFFI = real(nint(MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled + MudSystem%TotalFilledStrokesBy1and2MFFI= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled @@ -2474,11 +2474,11 @@ module MudSystem ! these values=fix on LED after the well filled if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = TotalFilledStrokesBy1MFFI !Fill or SPM LED + DataDisplayConsole%FillStrokeCounter = MudSystem%TotalFilledStrokesBy1MFFI !Fill or SPM LED elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = TotalFilledStrokesBy2MFFI !Fill or SPM LED + DataDisplayConsole%FillStrokeCounter = MudSystem%TotalFilledStrokesBy2MFFI !Fill or SPM LED elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= TotalFilledStrokesBy1and2MFFI !Fill or SPM LED + DataDisplayConsole%FillStrokeCounter= MudSystem%TotalFilledStrokesBy1and2MFFI !Fill or SPM LED endif endif @@ -2492,7 +2492,7 @@ module MudSystem - if (ReturnFlowRate>0) then + if (MudSystem%ReturnFlowRate>0) then DataDisplayConsole%MFFIPumpLED=1 !(Returns Lamp) else DataDisplayConsole%MFFIPumpLED=0 !(Returns Lamp) @@ -2502,20 +2502,20 @@ module MudSystem IF (DataDisplayConsole%MFFISetAlarmSwitch==0) THEN - DataDisplayConsole%ReturnMudFlowGauge= (1 - ReturnMudFlowGaugeMalf)*ReturnFlowPercent !(percent) + DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%ReturnFlowPercent !(percent) ELSEIF (DataDisplayConsole%MFFISetAlarmSwitch==-1) THEN - MFFI_MinPercent_Allowded=DataDisplayConsole%MFFISetAlarmLowKnob - DataDisplayConsole%ReturnMudFlowGauge= (1 - ReturnMudFlowGaugeMalf)*MFFI_MinPercent_Allowded + MudSystem%MFFI_MinPercent_Allowded=DataDisplayConsole%MFFISetAlarmLowKnob + DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MinPercent_Allowded ELSE !(MFFISetAlarmSwitch==1) - MFFI_MaxPercent_Allowded=DataDisplayConsole%MFFISetAlarmHighKnob - DataDisplayConsole%ReturnMudFlowGauge= (1 - ReturnMudFlowGaugeMalf)*MFFI_MaxPercent_Allowded + MudSystem%MFFI_MaxPercent_Allowded=DataDisplayConsole%MFFISetAlarmHighKnob + DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MaxPercent_Allowded ENDIF - IF (ReturnFlowPercentMFFI_MaxPercent_Allowded) THEN + IF (MudSystem%ReturnFlowPercentMudSystem%MFFI_MaxPercent_Allowded) THEN !write(*,*) 'alarm return:' , ReturnFlowRate DataDisplayConsole%MFFIAlarmLED = 2 !(blinking) IF (DataDisplayConsole%MFFIHornSwitch) THEN @@ -2565,28 +2565,28 @@ module MudSystem !! TRIP TANK PANEL DISPLAY VALUES !!====================================================================== - Tank%TripTankVolume = TripTankVolumeCalc/42. !(Drill Watch display) - Tank%TripTankDensity= TripTankDensityCalc !(display) + Tank%TripTankVolume = MudSystem%TripTankVolumeCalc/42. !(Drill Watch display) + Tank%TripTankDensity= MudSystem%TripTankDensityCalc !(display) IF (DataDisplayConsole%TripTankPowerSwitch==1 ) THEN !.and. IsPortable==.false. IF (DataDisplayConsole%TripTankSetAlarmSwitch==0) THEN - DataDisplayConsole%TripTankGauge= (1 - TripTankPressure_DataDisplayMalf) * TripTankVolumeCalc ! (gal) + DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTankVolumeCalc ! (gal) ELSEIF (DataDisplayConsole%TripTankSetAlarmSwitch==-1) THEN - TripTank_MinVol_Allowded= DataDisplayConsole%TripTankSetAlarmLow/2. ! 2: because knob input is 0-100 but gauge is 0-50 - DataDisplayConsole%TripTankGauge= (1 - TripTankPressure_DataDisplayMalf) * TripTank_MinVol_Allowded + MudSystem%TripTank_MinVol_Allowded= DataDisplayConsole%TripTankSetAlarmLow/2. ! 2: because knob input is 0-100 but gauge is 0-50 + DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MinVol_Allowded ELSE !(TripTankSetAlarmSwitch==1) - TripTank_MaxVol_Allowded= DataDisplayConsole%TripTankSetAlarmHigh/2. ! 2: because knob input is 0-100 but gauge is 0-50 - DataDisplayConsole%TripTankGauge= (1 - TripTankPressure_DataDisplayMalf) * TripTank_MaxVol_Allowded + MudSystem%TripTank_MaxVol_Allowded= DataDisplayConsole%TripTankSetAlarmHigh/2. ! 2: because knob input is 0-100 but gauge is 0-50 + DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MaxVol_Allowded ENDIF - IF ((TripTankVolumeCalc < TripTank_MinVol_Allowded) .OR. (TripTankVolumeCalc > TripTank_MaxVol_Allowded)) THEN + IF ((MudSystem%TripTankVolumeCalc < MudSystem%TripTank_MinVol_Allowded) .OR. (MudSystem%TripTankVolumeCalc > MudSystem%TripTank_MaxVol_Allowded)) THEN DataDisplayConsole%TripTankAlarmLED = 2 !(blinking) IF (DataDisplayConsole%TripTankHornSwitch) THEN DataDisplayConsole%Buzzer1= .true. @@ -2652,7 +2652,7 @@ module MudSystem implicit none real(8), intent (in) :: v !call Log_4('ActiveMudVolumeChanged=', v) - ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! update from student input + MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! update from student input end subroutine subroutine ActiveDensityChanged(v) @@ -2660,7 +2660,7 @@ module MudSystem implicit none real(8), intent (in) :: v !call Log_4('ActiveDensityChanged=', v) - ActiveTankDensity= MudProperties%ActiveDensity ! update from student input + MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! update from student input end subroutine subroutine ReserveMudVolumeChanged(v) @@ -2668,7 +2668,7 @@ module MudSystem implicit none real(8), intent (in) :: v !call Log_4('ReserveMudVolumeChanged=', v) - ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! update from student input + MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! update from student input end subroutine subroutine ReserveDensityChanged(v) @@ -2676,7 +2676,7 @@ module MudSystem implicit none real(8), intent (in) :: v !call Log_4('ReserveDensityChanged=', v) - ReserveTankDensity= MudProperties%ReserveDensity ! update from student input + MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! update from student input end subroutine subroutine SetupMudSystem() @@ -3138,7 +3138,7 @@ module MudSystem !Mp1_NoPath= 0 condition32 = .false. endif - condition32Final = condition32 + MudSystem%condition32Final = condition32 !================================================ @@ -3148,7 +3148,7 @@ module MudSystem !Mp2_NoPath= 0 condition33 = .false. endif - condition33Final= condition33 + MudSystem%condition33Final= condition33 !================================================ @@ -3157,7 +3157,7 @@ module MudSystem !Cp_NoPath= 1 condition34 = .false. endif - condition34Final = condition34 + MudSystem%condition34Final = condition34 !================================================ @@ -3461,18 +3461,7 @@ module MudSystem endif !================================================ - - - - - - - - - + end subroutine - - - -end module MudSystem \ No newline at end of file +end module MudSystemModule \ No newline at end of file diff --git a/Equipments/MudSystem/MudSystemMain.f90 b/Equipments/MudSystem/MudSystemMain.f90 index b4853bf..26ea1d8 100644 --- a/Equipments/MudSystem/MudSystemMain.f90 +++ b/Equipments/MudSystem/MudSystemMain.f90 @@ -5,7 +5,7 @@ module MudSystemMain ! subroutine MudSystem_Setup() ! ! use CSimulationVariables - ! use MudSystem + ! use MudSystemModule ! implicit none ! call SetupMudSystem() ! call OnSimulationStop%Add(MudSystem_Stop) @@ -27,7 +27,7 @@ module MudSystemMain end subroutine MudSystem_Start subroutine MudSystem_Step - use MudSystem + use MudSystemModule use CManifolds implicit none !print* , 'MudSystem_Step' @@ -41,7 +41,7 @@ module MudSystemMain ! subroutine MudSystemMainBody ! ! use CSimulationVariables - ! use MudSystem + ! use MudSystemModule ! implicit none ! INTEGER :: MudDuration diff --git a/Equipments/MudSystem/MudSystemStartup.f90 b/Equipments/MudSystem/MudSystemStartup.f90 index 84fa317..3ecc160 100644 --- a/Equipments/MudSystem/MudSystemStartup.f90 +++ b/Equipments/MudSystem/MudSystemStartup.f90 @@ -20,88 +20,88 @@ !Pump2BlownStarted = .FALSE. !Pump3BlownStarted = .FALSE. - MudSystemDotPump1BlownCount = 0 - MudSystemDotPump2BlownCount = 0 - MudSystemDotPump3BlownCount = 0 + MudSystem%Pump1BlownCount = 0 + MudSystem%Pump2BlownCount = 0 + MudSystem%Pump3BlownCount = 0 -MudSystemDotDeltaWellCap=0. -MudSystemDotWellCapOld = 0. -MudSystemDotAnnCapOld=0. -MudSystemDotDeltaAnnCap=0. +MudSystem%DeltaWellCap=0. +MudSystem%WellCapOld = 0. +MudSystem%AnnCapOld=0. +MudSystem%DeltaAnnCap=0. MPumps%Total_Stroke_Counter_For_Plot = 0.0 - DeltaT_Mudline=0.1 !second + MudSystem%DeltaT_Mudline=0.1 !second Call Set_FlowKellyDisconnect(.false.) Call Set_FlowPipeDisconnect(.false.) !HZ_ADD= 0.d0 -MudSystemDotFlow_timeCounter= 0 -MudSystemDotMudSys_timeCounter= 0 -MudSystemDotFluidFlowCounter = 0 +MudSystem%Flow_timeCounter= 0 +MudSystem%MudSys_timeCounter= 0 +MudSystem%FluidFlowCounter = 0 !======================================================================== ! MUD CIRCULATION STARTUP !======================================================================== - MudSystemDotFormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth - MudSystemDotShoeFractured= .false. + MudSystem%FormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth + MudSystem%ShoeFractured= .false. - MudSystemDotUGBOSuccessionCounter = 0 ! also in starup - MudSystemDotUGBOSuccessionCounterOld = 0 ! also in starup + MudSystem%UGBOSuccessionCounter = 0 ! also in starup + MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup - MudSystemDotChokeLineFlowRate= 0.0 - MudSystemDotStringFlowRate= 0.0 - MudSystemDotAnnulusFlowRate= 0.0 + MudSystem%ChokeLineFlowRate= 0.0 + MudSystem%StringFlowRate= 0.0 + MudSystem%AnnulusFlowRate= 0.0 - MudVolume_InjectedFromAnn= 0.D0 - MudSystemDotMudVolume_InjectedToBH= 0.D0 + MudSystem%MudVolume_InjectedFromAnn= 0.D0 + MudSystem%MudVolume_InjectedToBH= 0.D0 - MudSystemDotDensityMixTol= 0.1 !(ppg) - MudSystemDotCuttingDensityMixTol= 0.5 - MudSystemDotNewPipeFilling= 1 - MudSystemDotUtubeFilling= 1 - MudSystemDotUtubeEmptyVolume= 0.0 + MudSystem%DensityMixTol= 0.1 !(ppg) + MudSystem%CuttingDensityMixTol= 0.5 + MudSystem%NewPipeFilling= 1 + MudSystem%UtubeFilling= 1 + MudSystem%UtubeEmptyVolume= 0.0 - MudSystemDotUtubeMode1Activated= .false. - MudSystemDotUtubeMode2Activated= .false. - MudSystemDotUtubePossibility= .false. + MudSystem%UtubeMode1Activated= .false. + MudSystem%UtubeMode2Activated= .false. + MudSystem%UtubePossibility= .false. !KickMigration_2SideBit = .FALSE. - MudSystemDotKickDx= (Reservoir%AutoMigrationRate/3600.)*DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline + MudSystem%KickDx= (Reservoir%AutoMigrationRate/3600.)*MudSystem%DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline - MudSystemDotNewInfluxElementCreated= 0 - MudSystemDotNewInfluxNumber= 0 + MudSystem%NewInfluxElementCreated= 0 + MudSystem%NewInfluxNumber= 0 !KickVolumeinAnnulus= 0.0 - MudSystemDotKickDeltaVinAnnulus= 0.0 + MudSystem%KickDeltaVinAnnulus= 0.0 GasKickPumpFlowRate= 0.0 - MudSystemDotFirstMudSet= 0 - MudSystemDotFirstSetUtube1=0 - MudSystemDotFirstSetUtube2=0 - MudSystemDotSuctionMud=1 - MudSystemDotImudCount= 1 - MudSystemDotimud=1 - MudSystemDotiLoc= 1 ! for Kick - - Suction_Density_MudSystem= MudProperties%ActiveDensity - SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - StringDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + MudSystem%FirstMudSet= 0 + MudSystem%FirstSetUtube1=0 + MudSystem%FirstSetUtube2=0 + MudSystem%SuctionMud=1 + MudSystem%ImudCount= 1 + imud=1 + MudSystem%iLoc= 1 ! for Kick + + MudSystem%Suction_Density_MudSystem= MudProperties%ActiveDensity + MudSystem%SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + MudSystem%StringDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + MudSystem%AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + MudSystem%ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystemDotTotalAddedVolume= 0. + MudSystem%TotalAddedVolume= 0. - MudSystemDotxx=0. + MudSystem%xx=0. @@ -134,121 +134,121 @@ MudSystemDotFluidFlowCounter = 0 !MPumps%Total_Pump_GPM=10. ! Initial Value MUD%Q=0. ! Initial Value - Q_flow32=0. - Q_flow33=0. - Q_flow34=0. - Q_flow35=0. + MudSystem%Q_flow32=0. + MudSystem%Q_flow33=0. + MudSystem%Q_flow34=0. + MudSystem%Q_flow35=0. - DeltaT_Mudline=0.1 !second + MudSystem%DeltaT_Mudline=0.1 !second GasKickPumpFlowRate= 0. - BellNippleVolume= 0. - BellNippleDensity= 0. - MudBucketVolume= 0. - MudBucketDensity= 0. - BellNippleDumpVolume= 0. + MudSystem%BellNippleVolume= 0. + MudSystem%BellNippleDensity= 0. + MudSystem%MudBucketVolume= 0. + MudSystem%MudBucketDensity= 0. + MudSystem%BellNippleDumpVolume= 0. !BellNippleDumpRate= 0. !BellNippleToPitsRate= 0.0 - MudChecked= .true. + MudSystem%MudChecked= .true. - condition32Final= .TRUE. - condition33Final= .TRUE. - condition34Final= .TRUE. + MudSystem%condition32Final= .TRUE. + MudSystem%condition33Final= .TRUE. + MudSystem%condition34Final= .TRUE. -PressureGauge75= 0.0 -PressureGauge76 = 0.0 +MudSystem%PressureGauge75= 0.0 +MudSystem%PressureGauge76 = 0.0 !!====================================================================== !! TRIP TANK !!====================================================================== - TripTank_MinVol_Allowded= 50.*42. !(bbl to gal, initial value) - TripTank_MaxVol_Allowded= 50. *42. !(bbl to gal, initial value) + MudSystem%TripTank_MinVol_Allowded= 50.*42. !(bbl to gal, initial value) + MudSystem%TripTank_MaxVol_Allowded= 50. *42. !(bbl to gal, initial value) -ActiveTankFloorArea= (MudProperties%ActiveTotalTankCapacityGal) / (7.48051948*100./12.) ! (ft^2) - Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 -TripTankFloorArea= (50.*42.) / (7.48051948*100./12.) ! (ft^2) - 50.*42.=Trip Tank Capacity in BBl*42= Gal , Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 +MudSystem%ActiveTankFloorArea= (MudProperties%ActiveTotalTankCapacityGal) / (7.48051948*100./12.) ! (ft^2) - Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 +MudSystem%TripTankFloorArea= (50.*42.) / (7.48051948*100./12.) ! (ft^2) - 50.*42.=Trip Tank Capacity in BBl*42= Gal , Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 -TripTank_Vol= MudProperties%InitialTripTankMudVolumeGal !(gal) -TripTank_Dens= 1. +MudSystem%TripTank_Vol= MudProperties%InitialTripTankMudVolumeGal !(gal) +MudSystem%TripTank_Dens= 1. DataDisplayConsole%TripTankGauge=0. -ReturnToTrip_Q= 1. -ActiveToTrip_Q= 1. +MudSystem%ReturnToTrip_Q= 1. +MudSystem%ActiveToTrip_Q= 1. -TripTankPump_Q= .8 +MudSystem%TripTankPump_Q= .8 -ReturnToTrip_Dens=1.0 ! ppg(lbm/gal) -ActiveToTrip_Dens=1.0 +MudSystem%ReturnToTrip_Dens=1.0 ! ppg(lbm/gal) +MudSystem%ActiveToTrip_Dens=1.0 !!====================================================================== !! MUD VOLUME TOTALIZER !!====================================================================== -Mp1Density= 0.0 !(VALVE82) -Mp2Density= 0.0 !(VALVE83) -Mp3Density= 0.0 !(VALVE84) +MudSystem%Mp1Density= 0.0 !(VALVE82) +MudSystem%Mp2Density= 0.0 !(VALVE83) +MudSystem%Mp3Density= 0.0 !(VALVE84) -ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! initial volume (gal) -ReserveTankDensity= MudProperties%ReserveDensity ! initial +MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! initial volume (gal) +MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! initial -CementTankVolumeCalc= Tank%CementTankVolume !movaghat--- initial volume (gal) -CementTankDensityCalc= Tank%CementTankDensity !movaghat--- initial +MudSystem%CementTankVolumeCalc= Tank%CementTankVolume !movaghat--- initial volume (gal) +MudSystem%CementTankDensityCalc= Tank%CementTankDensity !movaghat--- initial -PumpsDumpVolume=0.0 -PumpsDumpFlowRate= 0.0 +MudSystem%PumpsDumpVolume=0.0 +MudSystem%PumpsDumpFlowRate= 0.0 -ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! initial volume (gal) -RefrencePitVolume= ActiveTankVolume/42. !(bbl) -RefrencePitVolume_DrillWatch= ActiveTankVolume/42. !(bbl) +MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! initial volume (gal) +MudSystem%RefrencePitVolume= MudSystem%ActiveTankVolume/42. !(bbl) +MudSystem%RefrencePitVolume_DrillWatch= MudSystem%ActiveTankVolume/42. !(bbl) -MVT_MinVol_Allowded= 0. -MVT_MaxVol_Allowded= 0. +MudSystem%MVT_MinVol_Allowded= 0. +MudSystem%MVT_MaxVol_Allowded= 0. -MudTank1_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudTank2_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudTank3_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -ActiveTankSettled= MudProperties%ActiveSettledContentsGal ! (gal) -MudTank4_vol= MudProperties%InitialTripTankMudVolumeGal ! (gal) +MudSystem%MudTank1_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) +MudSystem%MudTank2_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) +MudSystem%MudTank3_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) +MudSystem%ActiveTankSettled= MudProperties%ActiveSettledContentsGal ! (gal) +MudSystem%MudTank4_vol= MudProperties%InitialTripTankMudVolumeGal ! (gal) -TripTankVolumeCalc= MudProperties%InitialTripTankMudVolumeGal ! initial volume (gal) -ActiveTankDensity= MudProperties%ActiveDensity ! initial(ppg) -TripTankDensityCalc= Tank%TripTankDensity ! initial(ppg) +MudSystem%TripTankVolumeCalc= MudProperties%InitialTripTankMudVolumeGal ! initial volume (gal) +MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! initial(ppg) +MudSystem%TripTankDensityCalc= Tank%TripTankDensity ! initial(ppg) -ChokeManifoldDumpVolume= 0.0 +MudSystem%ChokeManifoldDumpVolume= 0.0 -PitGainLossZero= 0. -PitGainLossZero_Old= PitGainLossZero -MVTCoarseKnob_Old= DataDisplayConsole%MVTCoarseKnob -MVTFineKnob_Old= DataDisplayConsole%MVTFineKnob -FirstSet_Time= .true. +MudSystem%PitGainLossZero= 0. +MudSystem%PitGainLossZero_Old= MudSystem%PitGainLossZero +MudSystem%MVTCoarseKnob_Old= DataDisplayConsole%MVTCoarseKnob +MudSystem%MVTFineKnob_Old= DataDisplayConsole%MVTFineKnob +MudSystem%FirstSet_Time= .true. -PedalMeter= MudProperties%PedalFlowMeter !1600. !(gpm) -ReturnFlowRate=0. +MudSystem%PedalMeter= MudProperties%PedalFlowMeter !1600. !(gpm) +MudSystem%ReturnFlowRate=0. - TotalStrokes1MFFI =0. - TotalStrokes2MFFI =0. + MudSystem%TotalStrokes1MFFI =0. + MudSystem%TotalStrokes2MFFI =0. - TotalStrokesPump1=0. - TotalStrokesPump2=0. - GraphTotalStrokes=0. + MudSystem%TotalStrokesPump1=0. + MudSystem%TotalStrokesPump2=0. + MudSystem%GraphTotalStrokes=0. Choke%TotalStrokes1 =0. @@ -284,71 +284,71 @@ INTEGER I ! MUDLINE MINOR LOSSES INPUT !=========================================================================== -NO_MudMinors=4 +MudSystem%NO_MudMinors=4 -ALLOCATE (MudMinors(NO_MudMinors,4)) +ALLOCATE (MudSystem%MudMinors(MudSystem%NO_MudMinors,4)) ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION -MudMinors(1,1)= PumpsSpecification%MudPump1Output -MudMinors(1,2:4)= (/1.5*8., 0., 0./) !elbow (MLnumber=1,,PumpsToString) -MudMinors(2,1)= PumpsSpecification%MudPump1Output -MudMinors(2,2:4)= (/1.5*6., 0., 0./) !elbow (MLnumber=2,,STGaugeToString) -MudMinors(3,1:4)= (/0., 0., 0., 0./) !elbow (MLnumber=3,,WellToPits) -MudMinors(4,1)= BopStackSpecification%ChokeLineId -MudMinors(4,2:4)= (/1.5*7., 0., 0./) !elbow (MLnumber=4,,WellToChokeManifold) +MudSystem%MudMinors(1,1)= PumpsSpecification%MudPump1Output +MudSystem%MudMinors(1,2:4)= (/1.5*8., 0., 0./) !elbow (MLnumber=1,,PumpsToString) +MudSystem%MudMinors(2,1)= PumpsSpecification%MudPump1Output +MudSystem%MudMinors(2,2:4)= (/1.5*6., 0., 0./) !elbow (MLnumber=2,,STGaugeToString) +MudSystem%MudMinors(3,1:4)= (/0., 0., 0., 0./) !elbow (MLnumber=3,,WellToPits) +MudSystem%MudMinors(4,1)= BopStackSpecification%ChokeLineId +MudSystem%MudMinors(4,2:4)= (/1.5*7., 0., 0./) !elbow (MLnumber=4,,WellToChokeManifold) -ALLOCATE (MINORDIAMETER_MUDLINE(NO_MudMinors),AREAMINOR_MUDLINE(NO_MudMinors),LF_MUDLINE(NO_MudMinors),CV_MUDLINE(NO_MudMinors) & - ,NOTE_MUDLINE(NO_MudMinors)) +ALLOCATE (MudSystem%MINORDIAMETER_MUDLINE(MudSystem%NO_MudMinors),MudSystem%AREAMINOR_MUDLINE(MudSystem%NO_MudMinors),MudSystem%LF_MUDLINE(MudSystem%NO_MudMinors),MudSystem%CV_MUDLINE(MudSystem%NO_MudMinors) & + ,MudSystem%NOTE_MUDLINE(MudSystem%NO_MudMinors)) -DO I=1,NO_MudMinors - MINORDIAMETER_MUDLINE(I)=MudMinors(I,1) - LF_MUDLINE(I)=MudMinors(I,2) - CV_MUDLINE(I)=MudMinors(I,3) - NOTE_MUDLINE(I)=MudMinors(I,4) +DO I=1,MudSystem%NO_MudMinors + MudSystem%MINORDIAMETER_MUDLINE(I)=MudSystem%MudMinors(I,1) + MudSystem%LF_MUDLINE(I)=MudSystem%MudMinors(I,2) + MudSystem%CV_MUDLINE(I)=MudSystem%MudMinors(I,3) + MudSystem%NOTE_MUDLINE(I)=MudSystem%MudMinors(I,4) - AREAMINOR_MUDLINE(I)=PII*(MINORDIAMETER_MUDLINE(I)*0.0254)**2/4. !D(in), AREA(m^2) + MudSystem%AREAMINOR_MUDLINE(I)=PII*(MudSystem%MINORDIAMETER_MUDLINE(I)*0.0254)**2/4. !D(in), AREA(m^2) ENDDO !=========================================================================== ! MUDLINE PIPNING LOSSES INPUT !=========================================================================== -NO_PIPINGSMUDLINE=4 +MudSystem%NO_PIPINGSMUDLINE=4 -ALLOCATE (PIPINGS_MUDLINE(NO_PIPINGSMUDLINE,3)) +ALLOCATE (MudSystem%PIPINGS_MUDLINE(MudSystem%NO_PIPINGSMUDLINE,3)) ! ID(INCH) L(FEET) ROUGHNESS(MM)=e DESCRIPTION -PIPINGS_MUDLINE(1,1)= PumpsSpecification%MudPump1Output -PIPINGS_MUDLINE(1,2:3)= (/265., 0.03/) !(MLnumber=1,,PumpsToString) -PIPINGS_MUDLINE(2,1)= PumpsSpecification%MudPump1Output -PIPINGS_MUDLINE(2,2:3)= (/100., 0.03/) !(MLnumber=2,,STGaugeToString) -PIPINGS_MUDLINE(3,1:3)= (/0., 0., 0./) !(MLnumber=3,,WellToPits) -PIPINGS_MUDLINE(4,1)= BopStackSpecification%ChokeLineId -PIPINGS_MUDLINE(4,2)= BopStackSpecification%ChokeLineLength -PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold) +MudSystem%PIPINGS_MUDLINE(1,1)= PumpsSpecification%MudPump1Output +MudSystem%PIPINGS_MUDLINE(1,2:3)= (/265., 0.03/) !(MLnumber=1,,PumpsToString) +MudSystem%PIPINGS_MUDLINE(2,1)= PumpsSpecification%MudPump1Output +MudSystem%PIPINGS_MUDLINE(2,2:3)= (/100., 0.03/) !(MLnumber=2,,STGaugeToString) +MudSystem%PIPINGS_MUDLINE(3,1:3)= (/0., 0., 0./) !(MLnumber=3,,WellToPits) +MudSystem%PIPINGS_MUDLINE(4,1)= BopStackSpecification%ChokeLineId +MudSystem%PIPINGS_MUDLINE(4,2)= BopStackSpecification%ChokeLineLength +MudSystem%PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold) -MudSystemDotArea_ChokeLineFt= PII*((BopStackSpecification%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2) -MudSystemDotChokeLine_VolumeCapacity= MudSystemDotArea_ChokeLineFt* BopStackSpecification%ChokeLineLength* 7.48051948 ! (gal) +MudSystem%Area_ChokeLineFt= PII*((BopStackSpecification%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2) +MudSystem%ChokeLine_VolumeCapacity= MudSystem%Area_ChokeLineFt* BopStackSpecification%ChokeLineLength* 7.48051948 ! (gal) - ALLOCATE (DIAM_MUDLINE_INCH(NO_PIPINGSMUDLINE), & - AREA_MUDLINE(NO_PIPINGSMUDLINE),LENGT_MUDLINE(NO_PIPINGSMUDLINE),ROUGHNESS_MUDLINE(NO_PIPINGSMUDLINE),RELROUGH_MUDLINE(NO_PIPINGSMUDLINE)) + ALLOCATE (MudSystem%DIAM_MUDLINE_INCH(MudSystem%NO_PIPINGSMUDLINE), & + MudSystem%AREA_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%LENGT_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%ROUGHNESS_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%RELROUGH_MUDLINE(MudSystem%NO_PIPINGSMUDLINE)) -DO I=1,NO_PIPINGSMUDLINE - DIAM_MUDLINE_INCH(I)=PIPINGS_MUDLINE(I,1) - LENGT_MUDLINE(I)=PIPINGS_MUDLINE(I,2) - ROUGHNESS_MUDLINE(I)=PIPINGS_MUDLINE(I,3) +DO I=1,MudSystem%NO_PIPINGSMUDLINE + MudSystem%DIAM_MUDLINE_INCH(I)=MudSystem%PIPINGS_MUDLINE(I,1) + MudSystem%LENGT_MUDLINE(I)=MudSystem%PIPINGS_MUDLINE(I,2) + MudSystem%ROUGHNESS_MUDLINE(I)=MudSystem%PIPINGS_MUDLINE(I,3) - AREA_MUDLINE(I)=PII*(DIAM_MUDLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m^2) - RELROUGH_MUDLINE(I)=ROUGHNESS_MUDLINE(I)/(DIAM_MUDLINE_INCH(I)*25.4) !e/D + MudSystem%AREA_MUDLINE(I)=PII*(MudSystem%DIAM_MUDLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m^2) + MudSystem%RELROUGH_MUDLINE(I)=MudSystem%ROUGHNESS_MUDLINE(I)/(MudSystem%DIAM_MUDLINE_INCH(I)*25.4) !e/D !DIAM_MUDLINE_MM(I)=DIAM_MUDLINE_MM(I)*.001 ! (m) - LENGT_MUDLINE(I)=LENGT_MUDLINE(I)*.3048 ! (m) + MudSystem%LENGT_MUDLINE(I)=MudSystem%LENGT_MUDLINE(I)*.3048 ! (m) ENDDO @@ -357,11 +357,11 @@ ENDDO !=========================================================================== ! Height are in (meter) -Pumps_Height= 0. -STpipeGauge_Height= 2. !(m) -Pits_Height= 1. !(m) -ChokeManifold_Height= 1.*0.3048 !(ft to meter) -WellChokeExit_Height= BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight +MudSystem%Pumps_Height= 0. +MudSystem%STpipeGauge_Height= 2. !(m) +MudSystem%Pits_Height= 1. !(m) +MudSystem%ChokeManifold_Height= 1.*0.3048 !(ft to meter) +MudSystem%WellChokeExit_Height= BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight @@ -389,40 +389,40 @@ WellChokeExit_Height= BopStackSpecification%GroundLevel-BopStackSpecification%Ki !===============================PIPE LOSS=================================== - MUD(MLnumber)%Re_MUDline=MUD(MLnumber)%Q*6.30902e-5*DIAM_MUDLINE_INCH(MLnumber)*0.0254/(AREA_MUDLINE(MLnumber)*MUD(MLnumber)%nu) !<<<<<< nu: DOROST SHAVAD.ALAN DAR STARTUP SET SHODE + MUD(MLnumber)%Re_MUDline=MUD(MLnumber)%Q*6.30902e-5*MudSystem%DIAM_MUDLINE_INCH(MLnumber)*0.0254/(MudSystem%AREA_MUDLINE(MLnumber)*MUD(MLnumber)%nu) !<<<<<< nu: DOROST SHAVAD.ALAN DAR STARTUP SET SHODE !write(*,*) 'MUD(MLnumber)%Re_MUDline=' , MUD(MLnumber)%Re_MUDline ! Q*6.30902e-5 for (gpm) to (m^3/sec) if ( MUD(MLnumber)%Re_MUDline0.8 .or. Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26) - MudSystemDotChokeLineNOTFull= .true. +if ((MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%KillHeight)>0.8 .or. MudSystem%Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26) + MudSystem%ChokeLineNOTFull= .true. else - MudSystemDotChokeLineNOTFull= .false. + MudSystem%ChokeLineNOTFull= .false. endif - - !========================================================= jmud= 1 @@ -64,33 +62,33 @@ endif - call Xend_MudElement%Empty() - call TVDend_MudElement%Empty() - call Density_MudElement%Empty() - call MudGeoType%Empty() - call PipeID_MudElement%Empty() - call PipeOD_MudElement%Empty() + call MudSystem%Xend_MudElement%Empty() + call MudSystem%TVDend_MudElement%Empty() + call MudSystem%Density_MudElement%Empty() + call MudSystem%MudGeoType%Empty() + call MudSystem%PipeID_MudElement%Empty() + call MudSystem%PipeOD_MudElement%Empty() !call Angle_MudElement%Empty() - call MudType_MudElement%Empty() + call MudSystem%MudType_MudElement%Empty() - DO WHILE(jmud <= MudSystemDotHz_Mud_Forehead_X%Length() .and. jsection<=1) + DO WHILE(jmud <= MudSystem%Hz_Mud_Forehead_X%Length() .and. jsection<=1) jelement= jelement+1 - TrueMinValue= min(MudSystemDotHz_Mud_Forehead_X%Array(jmud), MudSystemDotXend_PipeSection(jsection)) + MudSystem%TrueMinValue= min(MudSystem%Hz_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) - call Xend_MudElement%Add(TrueMinValue) - call TVD_Calculator(TrueMinValue,MudSystemDotMudCircVerticalDepth) - call TVDend_MudElement%Add(MudSystemDotMudCircVerticalDepth) - call Density_MudElement%Add(MudSystemDotHz_Density%Array(jmud)) - call PipeID_MudElement%Add(MudSystemDotID_PipeSectionInch(jsection)) - call PipeOD_MudElement%Add(MudSystemDotOD_PipeSectionInch(jsection)) + call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) + call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) + call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) + call MudSystem%Density_MudElement%Add(MudSystem%Hz_Density%Array(jmud)) + call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) + call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudType_MudElement%Add(Hz_MudOrKick%Array(jmud)) + call MudSystem%MudType_MudElement%Add(MudSystem%Hz_MudOrKick%Array(jmud)) - if (Xend_MudElement%Array(jelement)== MudSystemDotHz_Mud_Forehead_X%Array(jmud)) then + if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%Hz_Mud_Forehead_X%Array(jmud)) then jmud= jmud+1 else jsection= jsection+1 @@ -98,7 +96,7 @@ endif ENDDO - MudSystemDotNoHorizontalMudElements= jelement + MudSystem%NoHorizontalMudElements= jelement @@ -106,22 +104,22 @@ endif jmud= 1 jsection= 2 - DO WHILE(jmud <= MudSystemDotSt_Mud_Forehead_X%Length() .and. jsection<=F_StringIntervalCounts) + DO WHILE(jmud <= MudSystem%St_Mud_Forehead_X%Length() .and. jsection<=F_StringIntervalCounts) jelement= jelement+1 - TrueMinValue= min(MudSystemDotSt_Mud_Forehead_X%Array(jmud), MudSystemDotXend_PipeSection(jsection)) + MudSystem%TrueMinValue= min(MudSystem%St_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) - call Xend_MudElement%Add(TrueMinValue) - call TVD_Calculator(TrueMinValue,MudSystemDotMudCircVerticalDepth) - call TVDend_MudElement%Add(MudSystemDotMudCircVerticalDepth) - call Density_MudElement%Add(St_Density%Array(jmud)) - call PipeID_MudElement%Add(MudSystemDotID_PipeSectionInch(jsection)) - call PipeOD_MudElement%Add(MudSystemDotOD_PipeSectionInch(jsection)) + call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) + call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) + call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) + call MudSystem%Density_MudElement%Add(MudSystem%St_Density%Array(jmud)) + call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) + call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudType_MudElement%Add(St_MudOrKick%Array(jmud)) + call MudSystem%MudType_MudElement%Add(MudSystem%St_MudOrKick%Array(jmud)) - if (Xend_MudElement%Array(jelement)== MudSystemDotSt_Mud_Forehead_X%Array(jmud)) then + if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%St_Mud_Forehead_X%Array(jmud)) then jmud= jmud+1 else jsection= jsection+1 @@ -129,7 +127,7 @@ endif ENDDO - MudSystemDotNoStringMudElements= jelement- MudSystemDotNoHorizontalMudElements + MudSystem%NoStringMudElements= jelement- MudSystem%NoHorizontalMudElements @@ -137,22 +135,22 @@ endif jmud= 1 jsection= F_StringIntervalCounts+1 - DO WHILE(jmud<= Ann_Mud_Forehead_X%Length() .and. jsection<=MudSystemDotNoPipeSections) + DO WHILE(jmud<= MudSystem%Ann_Mud_Forehead_X%Length() .and. jsection<=MudSystem%NoPipeSections) jelement= jelement+1 - TrueMinValue= max(Ann_Mud_Forehead_X%Array(jmud), MudSystemDotXend_PipeSection(jsection)) + MudSystem%TrueMinValue= max(MudSystem%Ann_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) - call Xend_MudElement%Add(TrueMinValue) - call TVD_Calculator(TrueMinValue,MudSystemDotMudCircVerticalDepth) - call TVDend_MudElement%Add(MudSystemDotMudCircVerticalDepth) - call Density_MudElement%Add(Ann_Density%Array(jmud)) - call PipeID_MudElement%Add(MudSystemDotID_PipeSectionInch(jsection)) - call PipeOD_MudElement%Add(MudSystemDotOD_PipeSectionInch(jsection)) + call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) + call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) + call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) + call MudSystem%Density_MudElement%Add(MudSystem%Ann_Density%Array(jmud)) + call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) + call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudType_MudElement%Add(Ann_MudOrKick%Array(jmud)) + call MudSystem%MudType_MudElement%Add(MudSystem%Ann_MudOrKick%Array(jmud)) - if (Xend_MudElement%Array(jelement)== Ann_Mud_Forehead_X%Array(jmud)) then + if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%Ann_Mud_Forehead_X%Array(jmud)) then jmud= jmud+1 else jsection= jsection+1 @@ -160,41 +158,41 @@ endif ENDDO - do i= 2, Xend_MudElement%Length() - if ( i== MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements+1) then - call Xstart_MudElement%Add (Ann_Mud_Backhead_X%Array(1)) ! start of annulus - call TVD_Calculator(Ann_Mud_Backhead_X%Array(1),MudSystemDotMudCircVerticalDepth) - call TVDstart_MudElement%Add(MudSystemDotMudCircVerticalDepth) - elseif ( i== MudSystemDotNoHorizontalMudElements+1 ) then - call Xstart_MudElement%Add (MudSystemDotSt_Mud_Backhead_X%Array(1)) ! start of stirng - call TVD_Calculator(MudSystemDotSt_Mud_Backhead_X%Array(1),MudSystemDotMudCircVerticalDepth) - call TVDstart_MudElement%Add(MudSystemDotMudCircVerticalDepth) + do i= 2, MudSystem%Xend_MudElement%Length() + if ( i== MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+1) then + call MudSystem%Xstart_MudElement%Add (MudSystem%Ann_Mud_Backhead_X%Array(1)) ! start of annulus + call TVD_Calculator(MudSystem%Ann_Mud_Backhead_X%Array(1),MudSystem%MudCircVerticalDepth) + call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) + elseif ( i== MudSystem%NoHorizontalMudElements+1 ) then + call MudSystem%Xstart_MudElement%Add (MudSystem%St_Mud_Backhead_X%Array(1)) ! start of stirng + call TVD_Calculator(MudSystem%St_Mud_Backhead_X%Array(1),MudSystem%MudCircVerticalDepth) + call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) else - call Xstart_MudElement%Add(Xend_MudElement%Array(i-1)) ! normal calculation - call TVDstart_MudElement%Add(TVDend_MudElement%Array(i-1)) ! normal calculation + call MudSystem%Xstart_MudElement%Add(MudSystem%Xend_MudElement%Array(i-1)) ! normal calculation + call MudSystem%TVDstart_MudElement%Add(MudSystem%TVDend_MudElement%Array(i-1)) ! normal calculation endif enddo - MudSystemDotNoCasingMudElements = jelement- MudSystemDotNoStringMudElements- MudSystemDotNoHorizontalMudElements + MudSystem%NoCasingMudElements = jelement- MudSystem%NoStringMudElements- MudSystem%NoHorizontalMudElements !=========================For Torque and Drag======================== - if (allocated(MudSystemDotTDXstart_MudElementArray)) deallocate(MudSystemDotTDXstart_MudElementArray) - allocate(MudSystemDotTDXstart_MudElementArray(MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements+MudSystemDotNoCasingMudElements)) - if (allocated(MudSystemDotTDXend_MudElementArray)) deallocate(MudSystemDotTDXend_MudElementArray) - allocate(MudSystemDotTDXend_MudElementArray(MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements+MudSystemDotNoCasingMudElements)) - if (allocated(MudSystemDotTDDensity_MudElementArray)) deallocate(MudSystemDotTDDensity_MudElementArray) - allocate(MudSystemDotTDDensity_MudElementArray(MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements+MudSystemDotNoCasingMudElements)) + if (allocated(MudSystem%TDXstart_MudElementArray)) deallocate(MudSystem%TDXstart_MudElementArray) + allocate(MudSystem%TDXstart_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) + if (allocated(MudSystem%TDXend_MudElementArray)) deallocate(MudSystem%TDXend_MudElementArray) + allocate(MudSystem%TDXend_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) + if (allocated(MudSystem%TDDensity_MudElementArray)) deallocate(MudSystem%TDDensity_MudElementArray) + allocate(MudSystem%TDDensity_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) - MudSystemDotTDNoHorizontalMudElements= MudSystemDotNoHorizontalMudElements - MudSystemDotTDNoStringMudElements= MudSystemDotNoStringMudElements - MudSystemDotTDNoCasingMudElements= MudSystemDotNoCasingMudElements + MudSystem%TDNoHorizontalMudElements= MudSystem%NoHorizontalMudElements + MudSystem%TDNoStringMudElements= MudSystem%NoStringMudElements + MudSystem%TDNoCasingMudElements= MudSystem%NoCasingMudElements - MudSystemDotTDXstart_MudElementArray(:) = Xstart_MudElement%Array(:) - MudSystemDotTDXend_MudElementArray(:) = Xend_MudElement%Array(:) - MudSystemDotTDDensity_MudElementArray(:) = Density_MudElement%Array(:) + MudSystem%TDXstart_MudElementArray(:) = MudSystem%Xstart_MudElement%Array(:) + MudSystem%TDXend_MudElementArray(:) = MudSystem%Xend_MudElement%Array(:) + MudSystem%TDDensity_MudElementArray(:) = MudSystem%Density_MudElement%Array(:) !===================================================================== @@ -212,31 +210,31 @@ endif jopelement= 0 ! number of final mud elements - call Xend_OpMudElement%Empty() - call TVDend_OpMudElement%Empty() - call Density_OpMudElement%Empty() - call PipeID_OpMudElement%Empty() - call PipeOD_OpMudElement%Empty() + call MudSystem%Xend_OpMudElement%Empty() + call MudSystem%TVDend_OpMudElement%Empty() + call MudSystem%Density_OpMudElement%Empty() + call MudSystem%PipeID_OpMudElement%Empty() + call MudSystem%PipeOD_OpMudElement%Empty() !call Angle_OpMudElement%Empty() - call MudTypeOp_MudElement%Empty() + call MudSystem%MudTypeOp_MudElement%Empty() - DO WHILE(jopmud<= MudSystemDotOp_Mud_Forehead_X%Length() .and. jopsection<=F_BottomHoleIntervalCounts) + DO WHILE(jopmud<= MudSystem%Op_Mud_Forehead_X%Length() .and. jopsection<=F_BottomHoleIntervalCounts) jopelement= jopelement+1 - TrueMinValue= max(MudSystemDotOp_Mud_Forehead_X%Array(jopmud), MudSystemDotXend_OpSection(jopsection)) - call Xend_OpMudElement%Add(TrueMinValue) - call TVD_Calculator(TrueMinValue,MudSystemDotMudCircVerticalDepth) - call TVDend_OpMudElement%Add(MudSystemDotMudCircVerticalDepth) - call Density_OpMudElement%Add(MudSystemDotOp_Density%Array(jopmud)) - call PipeID_OpMudElement%Add(MudSystemDotID_OpSectionInch(jopsection)) - call PipeOD_OpMudElement%Add(MudSystemDotOD_OpSectionInch(jopsection)) + MudSystem%TrueMinValue= max(MudSystem%Op_Mud_Forehead_X%Array(jopmud), MudSystem%Xend_OpSection(jopsection)) + call MudSystem%Xend_OpMudElement%Add(MudSystem%TrueMinValue) + call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) + call MudSystem%TVDend_OpMudElement%Add(MudSystem%MudCircVerticalDepth) + call MudSystem%Density_OpMudElement%Add(MudSystem%Op_Density%Array(jopmud)) + call MudSystem%PipeID_OpMudElement%Add(MudSystem%ID_OpSectionInch(jopsection)) + call MudSystem%PipeOD_OpMudElement%Add(MudSystem%OD_OpSectionInch(jopsection)) !call Angle_MudElement%Add(Angle_PipeSection(jopsection)) - call MudTypeOp_MudElement%Add(Op_MudOrKick%Array(jopmud)) + call MudSystem%MudTypeOp_MudElement%Add(MudSystem%Op_MudOrKick%Array(jopmud)) - if (Xend_OpMudElement%Array(jopelement)== MudSystemDotOp_Mud_Forehead_X%Array(jopmud)) then + if (MudSystem%Xend_OpMudElement%Array(jopelement)== MudSystem%Op_Mud_Forehead_X%Array(jopmud)) then jopmud= jopmud+1 else jopsection= jopsection+1 @@ -244,34 +242,34 @@ endif ENDDO - do i= 2, Xend_OpMudElement%Length() - call Xstart_OpMudElement%Add(Xend_OpMudElement%Array(i-1)) - call TVDstart_OpMudElement%Add(TVDend_OpMudElement%Array(i-1)) + do i= 2, MudSystem%Xend_OpMudElement%Length() + call MudSystem%Xstart_OpMudElement%Add(MudSystem%Xend_OpMudElement%Array(i-1)) + call MudSystem%TVDstart_OpMudElement%Add(MudSystem%TVDend_OpMudElement%Array(i-1)) enddo - MudSystemDotNoBottomHoleMudElements = jopelement + MudSystem%NoBottomHoleMudElements = jopelement !================================================================ - if(allocated(StringMudElement)) deallocate(StringMudElement) - allocate(StringMudElement(MudSystemDotNoStringMudElements)) + if(allocated(MudSystem%StringMudElement)) deallocate(MudSystem%StringMudElement) + allocate(MudSystem%StringMudElement(MudSystem%NoStringMudElements)) - if(allocated(CasingMudElement)) deallocate(CasingMudElement) - allocate(CasingMudElement(MudSystemDotNoCasingMudElements+MudSystemDotNoBottomHoleMudElements)) + if(allocated(MudSystem%CasingMudElement)) deallocate(MudSystem%CasingMudElement) + allocate(MudSystem%CasingMudElement(MudSystem%NoCasingMudElements+MudSystem%NoBottomHoleMudElements)) - MudSystemDotistring=0 - MudSystemDoticasing=0 + MudSystem%istring=0 + MudSystem%icasing=0 - MudSystemDotBitMudDensity= Density_MudElement%Array(MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements) ! (for ROP module) + MudSystem%BitMudDensity= MudSystem%Density_MudElement%Array(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements) ! (for ROP module) !================================================================ !============================ UTUBE ============================= !IF (UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadIsOpen) THEN - IF (MudSystemDotUtubePossibility== .true. .and. TD_FluidStringConnectionMode==0 .and. WellHeadIsOpen .AND. NoGasPocket == 0) THEN + IF (MudSystem%UtubePossibility== .true. .and. TD_FluidStringConnectionMode==0 .and. MudSystem%WellHeadIsOpen .AND. NoGasPocket == 0) THEN CALL WellPressureDataTransfer !WRITE (*,*) ' U-Tube Done 1' CALL Utube @@ -294,17 +292,17 @@ endif !enddo - IF (ANY(IEEE_Is_NaN(MudSystemDotOp_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystemDotOp_MudDischarged_Volume%Array(:) <= 0.0)) THEN - do i = 1 , Op_MudOrKick%Length() - write(*,555) i,'Op_Volume(i), type=' ,MudSystemDotOp_MudDischarged_Volume%Array(i) , Op_MudOrKick%Array(i) , MudSystemDotOp_Density%Array(i) + IF (ANY(IEEE_Is_NaN(MudSystem%Op_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystem%Op_MudDischarged_Volume%Array(:) <= 0.0)) THEN + do i = 1 , MudSystem%Op_MudOrKick%Length() + write(*,555) i,'Op_Volume(i), type=' ,MudSystem%Op_MudDischarged_Volume%Array(i) , MudSystem%Op_MudOrKick%Array(i) , MudSystem%Op_Density%Array(i) end do call ErrorStop('NaN in Op Volume-Plot or Op Volume <=0') END IF - IF (ANY(IEEE_Is_NaN(MudSystemDotAnn_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystemDotAnn_MudDischarged_Volume%Array(:) <= 0.0)) THEN - do i = 1 , Ann_MudOrKick%Length() - write(*,555) i,'Ann_Volume(i), type=' ,MudSystemDotAnn_MudDischarged_Volume%Array(i) , Ann_MudOrKick%Array(i) , Ann_Density%Array(i) + IF (ANY(IEEE_Is_NaN(MudSystem%Ann_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystem%Ann_MudDischarged_Volume%Array(:) <= 0.0)) THEN + do i = 1 , MudSystem%Ann_MudOrKick%Length() + write(*,555) i,'Ann_Volume(i), type=' ,MudSystem%Ann_MudDischarged_Volume%Array(i) , MudSystem%Ann_MudOrKick%Array(i) , MudSystem%Ann_Density%Array(i) end do call ErrorStop('NaN in Ann Volume-Plot or Ann Volume <=0') END IF @@ -318,74 +316,74 @@ endif 555 FORMAT(I3,5X,A42,(f12.5),5X,I3,5X,(f12.5)) - MudSystemDotNoStringMudElementsForPlot= MudSystemDotNoStringMudElements + MudSystem%NoStringMudElementsForPlot= MudSystem%NoStringMudElements ! 1-Horizontal Mud Elements are not shown !write(*,333) 'Horiz:', 1,'Xstart\=', Xstart_MudElement%Array(1), 'Xend=' , Xend_MudElement%Array(1), 'Density=' , Density_MudElement%Array(1), 'MudType=' , MudType_MudElement%Array(1) - do i=MudSystemDotNoHorizontalMudElements+1, MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements ! 2-string elements - if (Xend_MudElement%Array(i) <= 0.0) then - MudSystemDotNoStringMudElementsForPlot= MudSystemDotNoStringMudElementsForPlot-1 + do i=MudSystem%NoHorizontalMudElements+1, MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements ! 2-string elements + if (MudSystem%Xend_MudElement%Array(i) <= 0.0) then + MudSystem%NoStringMudElementsForPlot= MudSystem%NoStringMudElementsForPlot-1 cycle endif - MudSystemDotistring= MudSystemDotistring+1 - StringMudElement(MudSystemDotistring)%StartMd = Xstart_MudElement%Array(i) - StringMudElement(MudSystemDotistring)%EndMd = Xend_MudElement%Array(i) + MudSystem%istring= MudSystem%istring+1 + MudSystem%StringMudElement(MudSystem%istring)%StartMd = MudSystem%Xstart_MudElement%Array(i) + MudSystem%StringMudElement(MudSystem%istring)%EndMd = MudSystem%Xend_MudElement%Array(i) !StringMudElement(istring)%Id = PipeID_MudElement%Array(i) !StringMudElement(istring)%Od = PipeOD_MudElement%Array(i) - StringMudElement(MudSystemDotistring)%Density = Density_MudElement%Array(i) + MudSystem%StringMudElement(MudSystem%istring)%Density = MudSystem%Density_MudElement%Array(i) - if (MudType_MudElement%Array(i) == 104) then - MudType_MudElement%Array(i)= 4 ! air - elseif (MudType_MudElement%Array(i) > 0 .and. MudType_MudElement%Array(i) < 100) then ! all kicks - MudType_MudElement%Array(i)= 1 ! gas kick + if (MudSystem%MudType_MudElement%Array(i) == 104) then + MudSystem%MudType_MudElement%Array(i)= 4 ! air + elseif (MudSystem%MudType_MudElement%Array(i) > 0 .and. MudSystem%MudType_MudElement%Array(i) < 100) then ! all kicks + MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick endif - StringMudElement(MudSystemDotistring)%MudType = MudType_MudElement%Array(i) + MudSystem%StringMudElement(MudSystem%istring)%MudType = MudSystem%MudType_MudElement%Array(i) !write(*,333) 'STRING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i) enddo - do i=Xend_MudElement%Length(), MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements+1 , -1 ! 3-casing elements - MudSystemDoticasing= MudSystemDoticasing+1 - CasingMudElement(MudSystemDoticasing)%StartMd = Xend_MudElement%Array(i) - CasingMudElement(MudSystemDoticasing)%EndMd = Xstart_MudElement%Array(i) + do i=MudSystem%Xend_MudElement%Length(), MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+1 , -1 ! 3-casing elements + MudSystem%icasing= MudSystem%icasing+1 + MudSystem%CasingMudElement(MudSystem%icasing)%StartMd = MudSystem%Xend_MudElement%Array(i) + MudSystem%CasingMudElement(MudSystem%icasing)%EndMd = MudSystem%Xstart_MudElement%Array(i) !CasingMudElement(icasing)%Id = PipeID_MudElement%Array(i) !CasingMudElement(icasing)%Od = PipeOD_MudElement%Array(i) !write(*,333) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i) !call Log_1(temp1) !write(*,444) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i) - CasingMudElement(MudSystemDoticasing)%Density = Density_MudElement%Array(i) + MudSystem%CasingMudElement(MudSystem%icasing)%Density = MudSystem%Density_MudElement%Array(i) - if (MudType_MudElement%Array(i) == 104) then - MudType_MudElement%Array(i)= 4 ! air - elseif (MudType_MudElement%Array(i) > 0 .and. MudType_MudElement%Array(i) < 100) then - MudType_MudElement%Array(i)= 1 ! gas kick + if (MudSystem%MudType_MudElement%Array(i) == 104) then + MudSystem%MudType_MudElement%Array(i)= 4 ! air + elseif (MudSystem%MudType_MudElement%Array(i) > 0 .and. MudSystem%MudType_MudElement%Array(i) < 100) then + MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick endif - CasingMudElement(MudSystemDoticasing)%MudType = MudType_MudElement%Array(i) + MudSystem%CasingMudElement(MudSystem%icasing)%MudType = MudSystem%MudType_MudElement%Array(i) enddo - do i= MudSystemDotNoBottomHoleMudElements, 1 , -1 ! 4-open hole elements - MudSystemDoticasing= MudSystemDoticasing+1 - CasingMudElement(MudSystemDoticasing)%StartMd = Xend_OpMudElement%Array(i) - CasingMudElement(MudSystemDoticasing)%EndMd = Xstart_OpMudElement%Array(i) + do i= MudSystem%NoBottomHoleMudElements, 1 , -1 ! 4-open hole elements + MudSystem%icasing= MudSystem%icasing+1 + MudSystem%CasingMudElement(MudSystem%icasing)%StartMd = MudSystem%Xend_OpMudElement%Array(i) + MudSystem%CasingMudElement(MudSystem%icasing)%EndMd = MudSystem%Xstart_OpMudElement%Array(i) !CasingMudElement(icasing)%Id = PipeID_OpMudElement%Array(i) !CasingMudElement(icasing)%Od = PipeOD_OpMudElement%Array(i) !write(*,333) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'Density=' , Density_OpMudElement%Array(i), 'MudType=' , MudTypeOp_MudElement%Array(i) !call Log_1(temp2) !write(*,444) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i) - CasingMudElement(MudSystemDoticasing)%Density = Density_OpMudElement%Array(i) + MudSystem%CasingMudElement(MudSystem%icasing)%Density = MudSystem%Density_OpMudElement%Array(i) - if (MudTypeOp_MudElement%Array(i) == 104) then - MudTypeOp_MudElement%Array(i)= 4 ! air - elseif (MudTypeOp_MudElement%Array(i) > 0 .and. MudTypeOp_MudElement%Array(i) < 100) then - MudTypeOp_MudElement%Array(i)= 1 ! gas kick + if (MudSystem%MudTypeOp_MudElement%Array(i) == 104) then + MudSystem%MudTypeOp_MudElement%Array(i)= 4 ! air + elseif (MudSystem%MudTypeOp_MudElement%Array(i) > 0 .and. MudSystem%MudTypeOp_MudElement%Array(i) < 100) then + MudSystem%MudTypeOp_MudElement%Array(i)= 1 ! gas kick endif - CasingMudElement(MudSystemDoticasing)%MudType = MudTypeOp_MudElement%Array(i) + MudSystem%CasingMudElement(MudSystem%icasing)%MudType = MudSystem%MudTypeOp_MudElement%Array(i) enddo @@ -398,8 +396,8 @@ endif ! shomare gozari be tartib HZ mud, ST mud, Casing ! shomare gzari OpenHole jodagane ast az 1 - call SetStringFluids(MudSystemDotNoStringMudElementsForPlot, StringMudElement) !for data display in string - call SetAnnalusFluids(MudSystemDotNoCasingMudElements+MudSystemDotNoBottomHoleMudElements, CasingMudElement) !for data display in casing + call SetStringFluids(MudSystem%NoStringMudElementsForPlot, MudSystem%StringMudElement) !for data display in string + call SetAnnalusFluids(MudSystem%NoCasingMudElements+MudSystem%NoBottomHoleMudElements, MudSystem%CasingMudElement) !for data display in casing !=========================================================================================================================== diff --git a/Equipments/MudSystem/Pump_and_Trip_In.f90 b/Equipments/MudSystem/Pump_and_Trip_In.f90 index 2bb3397..818959f 100644 --- a/Equipments/MudSystem/Pump_and_Trip_In.f90 +++ b/Equipments/MudSystem/Pump_and_Trip_In.f90 @@ -24,8 +24,8 @@ integer i,ii,AddLocation !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystemDotStringFlowRate= MUD(2)%Q - MudSystemDotAnnulusFlowRate= MUD(2)%Q + MudSystem%StringFlowRate= MUD(2)%Q + MudSystem%AnnulusFlowRate= MUD(2)%Q !write(*,*) 'Trip In' @@ -33,87 +33,87 @@ integer i,ii,AddLocation !========================Horizontal PIPE ENTRANCE================= - if (ABS(SuctionDensity_Old - Suction_Density_MudSystem) >= MudSystemDotDensityMixTol) then ! new mud is pumped + if (ABS(MudSystem%SuctionDensity_Old - MudSystem%Suction_Density_MudSystem) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystemDotHz_Density%AddToFirst (Suction_Density_MudSystem) - call MudSystemDotHz_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystemDotHz_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(1)) - call Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotHz_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(1)) - call Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotHz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotHz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Hz_MudOrKick%AddToFirst (0) + call MudSystem%Hz_Density%AddToFirst (MudSystem%Suction_Density_MudSystem) + call MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) + call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) + call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) + call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) + call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) + call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Hz_MudOrKick%AddToFirst (0) - SuctionDensity_Old= Suction_Density_MudSystem + MudSystem%SuctionDensity_Old= MudSystem%Suction_Density_MudSystem endif !========================Horizontal PIPE STRING================= - MudSystemDotHz_MudDischarged_Volume%Array(1)= MudSystemDotHz_MudDischarged_Volume%Array(1)+ ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) !(gal) + MudSystem%Hz_MudDischarged_Volume%Array(1)= MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - MudSystemDottotal_add = MudSystemDottotal_add + ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) + MudSystem%total_add = MudSystem%total_add + ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystemDottotal_add= 0. + MudSystem%total_add= 0. endif !write(*,*) ' total decrease(add to HZ)=' , total_add - !write(*,*) ' add to HZ=' , ((StringFlowRate/60.0d0)*DeltaT_Mudline) + !write(*,*) ' add to HZ=' , ((MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotHz_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%Hz_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotHz_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud-1) - Hz_Mud_Backhead_section%Array(MudSystemDotimud)= Hz_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Hz_Mud_Backhead_X%Array(imud)= MudSystem%Hz_Mud_Forehead_X%Array(imud-1) + MudSystem%Hz_Mud_Backhead_section%Array(imud)= MudSystem%Hz_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotHz_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(Hz_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))- MudSystem%Hz_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Hz_Mud_Forehead_section%Array(MudSystemDotimud)= Hz_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotHz_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(Hz_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Hz_MudDischarged_Volume%Array(imud) <= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%Hz_Mud_Backhead_section%Array(imud) + MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Hz_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) else - MudSystemDotisection= Hz_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 + MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > 1) then ! (horizontal pipe exit) - MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(1) - Hz_Mud_Forehead_section%Array(MudSystemDotimud)= 1 + if (MudSystem%isection > 1) then ! (horizontal pipe exit) + MudSystem%Hz_MudDischarged_Volume%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(1) + MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 - if (MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveHzMudArrays(MudSystemDotimud) + if (MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call RemoveHzMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Hz_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Hz_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -130,7 +130,7 @@ MudSystemDotimud=0 !if (UtubeMode1Activated== .true.) then ! StringUpdate == .true. ! ! - ! !StringDensity_Old= St_Density%Array(2) + ! !StringDensity_Old=MudSystem%St_Density%Array(2) ! ! write(*,*) 'StringDensity_Old=' , StringDensity_Old ! @@ -156,25 +156,25 @@ MudSystemDotimud=0 !========================New Pipe Filling================= !if (F_StringIntervalCounts > F_StringIntervalCountsOld) then ! StringUpdate == .true. - if (MudSystemDotAddedElementsToString > 0) then ! StringUpdate == .true. + if (MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. !NoPipeAdded= F_StringIntervalCounts - F_StringIntervalCountsOld - MudSystemDotNewPipeFilling=0 + MudSystem%NewPipeFilling=0 - IF (St_MudOrKick%First() == 104) then - MudSystemDotSt_MudDischarged_Volume%Array(1) = MudSystemDotSt_MudDischarged_Volume%Array(1) + sum(MudSystemDotPipeSection_VolumeCapacity(2:1+MudSystemDotAddedElementsToString)) ! new pipe is filled by air + IF (MudSystem%St_MudOrKick%First() == 104) then + MudSystem%St_MudDischarged_Volume%Array(1) = MudSystem%St_MudDischarged_Volume%Array(1) + sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString)) ! new pipe is filled by air else - call St_Density%AddToFirst (0.d0) - call MudSystemDotSt_MudDischarged_Volume%AddToFirst (sum(MudSystemDotPipeSection_VolumeCapacity(2:1+MudSystemDotAddedElementsToString))) - call MudSystemDotSt_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Forehead_section%AddToFirst (2) - call MudSystemDotSt_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddToFirst (2) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddToFirst (0.d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) - call St_MudOrKick%AddToFirst (104) + call MudSystem%St_Density%AddToFirst (0.d0) + call MudSystem%St_MudDischarged_Volume%AddToFirst (sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString))) + call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) + call MudSystem%St_MudOrKick%AddToFirst (104) endif endif @@ -183,46 +183,46 @@ MudSystemDotimud=0 - if (MudSystemDotNewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) + if (MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) - MudSystemDotLackageMudVolume= MudSystemDotSt_MudDischarged_Volume%Array(1) ! = Air element + MudSystem%LackageMudVolume= MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element - write(*,*) 'LackageMudVolume=' , MudSystemDotLackageMudVolume + write(*,*) 'LackageMudVolume=' , MudSystem%LackageMudVolume - if (ABS(St_Density%Array(2) - MudSystemDotHz_Density%Last()) >= MudSystemDotDensityMixTol) then ! new mud is pumped - call St_Density%AddTo (2,MudSystemDotHz_Density%Last()) - call MudSystemDotSt_MudDischarged_Volume%AddTo (2, 0.d0) - call MudSystemDotSt_Mud_Forehead_X%AddTo (2,MudSystemDotXstart_PipeSection(2)) - call St_Mud_Forehead_section%AddTo (2 , 2) - call MudSystemDotSt_Mud_Backhead_X%AddTo (2,MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddTo (2 ,2) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddTo (2,0.d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) - call St_MudOrKick%AddTo (2,0) + if (ABS(MudSystem%St_Density%Array(2) - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped + call MudSystem%St_Density%AddTo (2,MudSystem%Hz_Density%Last()) + call MudSystem%St_MudDischarged_Volume%AddTo (2, 0.d0) + call MudSystem%St_Mud_Forehead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) + call MudSystem%St_Mud_Backhead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) + call MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) + call MudSystem%St_MudOrKick%AddTo (2,0) !StringDensity_Old= Hz_Density%Last() endif - MudSystemDotSt_MudDischarged_Volume%Array(2)= MudSystemDotSt_MudDischarged_Volume%Array(2)+ min( ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline), MudSystemDotLackageMudVolume) !(gal) + MudSystem%St_MudDischarged_Volume%Array(2)= MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) !(gal) - MudSystemDotSt_MudDischarged_Volume%Array(1)= MudSystemDotSt_MudDischarged_Volume%Array(1)- min( ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline), MudSystemDotLackageMudVolume) ! air(gal) + MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)- min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) ! air(gal) !LackageMudVolumeAfterFilling= sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) - sum(St_MudDischarged_Volume%Array(:)) - MudSystemDotLackageMudVolumeAfterFilling= MudSystemDotSt_MudDischarged_Volume%Array(1) ! last time it should be zero + MudSystem%LackageMudVolumeAfterFilling= MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero - if (MudSystemDotLackageMudVolumeAfterFilling == 0.) then - MudSystemDotNewPipeFilling= 1 + if (MudSystem%LackageMudVolumeAfterFilling == 0.) then + MudSystem%NewPipeFilling= 1 call RemoveStringMudArrays(1) - MudSystemDotSt_Mud_Backhead_X%Array(1) = MudSystemDotXstart_PipeSection(2) - St_Mud_Backhead_section%Array(1) = 2 + MudSystem%St_Mud_Backhead_X%Array(1) = MudSystem%Xstart_PipeSection(2) + MudSystem%St_Mud_Backhead_section%Array(1) = 2 endif endif @@ -232,71 +232,71 @@ MudSystemDotimud=0 - if (MudSystemDotNewPipeFilling == 0) then - MudSystemDotStringFlowRate= 0. - MudSystemDotAnnulusFlowRate= 0. + if (MudSystem%NewPipeFilling == 0) then + MudSystem%StringFlowRate= 0. + MudSystem%AnnulusFlowRate= 0. endif - MudSystemDotStringFlowRateFinal= MudSystemDotStringFlowRate - MudSystemDotAnnulusFlowRateFinal= MudSystemDotAnnulusFlowRate + MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate + MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate !========================STRING ENTRANCE================= - if (MudSystemDotStringFlowRateFinal > 0.0 .and. ABS(St_Density%First() - MudSystemDotHz_Density%Last()) >= MudSystemDotDensityMixTol) then ! new mud is pumped - call St_Density%AddToFirst (MudSystemDotHz_Density%Last()) - call MudSystemDotSt_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystemDotSt_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Forehead_section%AddToFirst (2) - call MudSystemDotSt_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddToFirst (2) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call St_MudOrKick%AddToFirst (0) + if (MudSystem%StringFlowRateFinal > 0.0 .and. ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped + call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density%Last()) + call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) + call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%St_MudOrKick%AddToFirst (0) !StringDensity_Old= Hz_Density%Last() endif - MudSystemDotSt_MudDischarged_Volume%Array(1)= MudSystemDotSt_MudDischarged_Volume%Array(1)+ ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) !(gal) + MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) !=============== save String Mud data=========== - MudSystemDotStMudVolumeSum= 0.d0 + MudSystem%StMudVolumeSum= 0.d0 !St_MudSaved_Density= 0.d0 - MudSystemDotSt_Saved_MudDischarged_Volume= 0.d0 + MudSystem%St_Saved_MudDischarged_Volume= 0.d0 !Saved_St_MudOrKick= 0 !Ann_to_Choke_2mud= .false. - do MudSystemDotimud=1, MudSystemDotSt_MudDischarged_Volume%Length() + do imud=1, MudSystem%St_MudDischarged_Volume%Length() - MudSystemDotStMudVolumeSum = MudSystemDotStMudVolumeSum + MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) + MudSystem%StMudVolumeSum = MudSystem%StMudVolumeSum + MudSystem%St_MudDischarged_Volume%Array(imud) - if ( MudSystemDotStMudVolumeSum > sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts)) ) then + if ( MudSystem%StMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) ) then !IF (St_MudOrKick%Array(imud) == 0) THEN - MudSystemDotSt_MudSaved_Density = St_Density%Array(MudSystemDotimud) - MudSystemDotSt_Saved_MudDischarged_Volume = MudSystemDotStMudVolumeSum - sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts)) + MudSystem%St_MudSaved_Density =MudSystem%St_Density%Array(imud) + MudSystem%St_Saved_MudDischarged_Volume = MudSystem%StMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = StMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ! Saved_St_MudOrKick= St_MudOrKick%Array (imud) - ! St_KickSaved_Density= St_Density%Array(imud) + ! St_KickSaved_Density=MudSystem%St_Density%Array(imud) !END IF - do ii= MudSystemDotimud + 1, MudSystemDotSt_MudDischarged_Volume%Length() + do ii= imud + 1, MudSystem%St_MudDischarged_Volume%Length() !IF (St_MudOrKick%Array(ii) == 0) THEN - MudSystemDotSt_MudSaved_Density = ((MudSystemDotSt_MudSaved_Density * MudSystemDotSt_Saved_MudDischarged_Volume) + (St_Density%Array(ii) * MudSystemDotSt_MudDischarged_Volume%Array(ii))) / (MudSystemDotSt_Saved_MudDischarged_Volume + MudSystemDotSt_MudDischarged_Volume%Array(ii)) - MudSystemDotSt_Saved_MudDischarged_Volume = MudSystemDotSt_Saved_MudDischarged_Volume + MudSystemDotSt_MudDischarged_Volume%Array(ii) + MudSystem%St_MudSaved_Density = ((MudSystem%St_MudSaved_Density * MudSystem%St_Saved_MudDischarged_Volume) + (MudSystem%St_Density%Array(ii) * MudSystem%St_MudDischarged_Volume%Array(ii))) / (MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii)) + MudSystem%St_Saved_MudDischarged_Volume = MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = St_Kick_Saved_Volume + St_MudDischarged_Volume%Array(ii) ! Saved_St_MudOrKick= St_MudOrKick%Array (ii) - ! St_KickSaved_Density= St_Density%Array(ii) + ! St_KickSaved_Density=MudSystem%St_Density%Array(ii) !END IF enddo @@ -307,30 +307,30 @@ MudSystemDotimud=0 endif enddo -MudSystemDotSt_Saved_MudDischarged_Volume_Final = MudSystemDotSt_Saved_MudDischarged_Volume +MudSystem%St_Saved_MudDischarged_Volume_Final = MudSystem%St_Saved_MudDischarged_Volume -IF (WellHeadIsOpen) MudSystemDotMudVolume_InjectedToBH = MudSystemDotSt_Saved_MudDischarged_Volume_Final +IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final !====================================================================== !========================STRING================= -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotSt_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%St_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud-1) - St_Mud_Backhead_section%Array(MudSystemDotimud)= St_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) + MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(St_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal !write(*,*) 'St_Mud_Backhead_section%Array(1)=' , St_Mud_Backhead_section%Array(1) @@ -340,38 +340,38 @@ MudSystemDotimud=0 !write(*,*) 'St_Mud_Backhead_X%Array(1)=' , St_Mud_Backhead_X%Array(1) - if ( MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - St_Mud_Forehead_section%Array(MudSystemDotimud)= St_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(St_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) + MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= St_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > F_StringIntervalCounts) then ! last pipe section(string exit) F_StringIntervalCounts includes Horizontal line - MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(F_StringIntervalCounts) - St_Mud_Forehead_section%Array(MudSystemDotimud)= F_StringIntervalCounts + if (MudSystem%isection > F_StringIntervalCounts) then ! last pipe section(string exit) F_StringIntervalCounts includes Horizontal line + MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_StringIntervalCounts) + MudSystem%St_Mud_Forehead_section%Array(imud)= F_StringIntervalCounts - if (MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(MudSystemDotimud) + if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call RemoveStringMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - St_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -402,49 +402,49 @@ MudSystemDotimud=0 !========================STRING END================= - IF (Op_MudOrKick%Last() /= 0 .and. Op_MudOrKick%Last()==Ann_MudOrKick%First()) MudSystemDotiLoc=2 ! it may be 1,2,3 or more, all of them are kick + IF (MudSystem%Op_MudOrKick%Last() /= 0 .and. MudSystem%Op_MudOrKick%Last()==MudSystem%Ann_MudOrKick%First()) MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick !write(*,*) ' iloc (b): ' , iloc !=============================Add PumpFlowRate to Bottom Hole ============================== - !if ( AnnulusFlowRate>0.0 ) then - if ( MudSystemDotMudVolume_InjectedToBH > 0.0 ) then + !if ( MudSystem%AnnulusFlowRate>0.0 ) then + if ( MudSystem%MudVolume_InjectedToBH > 0.0 ) then if (KickOffBottom) then ! (kickOffBottom = F) means kick is next to the bottom hole and usually kick is entering the - AddLocation= MudSystemDotOp_Density%Length()-MudSystemDotiLoc+1+1 ! well, thus pumped mud should be placed above the kick + AddLocation= MudSystem%Op_Density%Length()-MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick else - AddLocation= MudSystemDotOp_Density%Length()+1 + AddLocation= MudSystem%Op_Density%Length()+1 endif !write(*,*) 'AddLocation====' , AddLocation if ( AddLocation== 0) CALL ErrorStop ('AddLocation=0') - if ( ABS(St_Density%Last() - MudSystemDotOp_Density%Array(AddLocation-1)) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%St_Density%Last() - MudSystem%Op_Density%Array(AddLocation-1)) >= MudSystem%DensityMixTol ) then !write(*,*) 'new pocket**' - !write(*,*) 'St_Density%Last()=' , St_Density%Last() + !write(*,*) MudSystem%St_Density%Last()=' ,MudSystem%St_Density%Last() !write(*,*) 'Op_Density%Array(AddLocation-1)=' , Op_Density%Array(AddLocation-1) - call MudSystemDotOp_Density% AddTo (AddLocation,St_Density%Last()) - !call Op_MudDischarged_Volume%AddTo (AddLocation,((AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - call MudSystemDotOp_MudDischarged_Volume%AddTo (AddLocation,MudSystemDotMudVolume_InjectedToBH) - call MudSystemDotOp_Mud_Forehead_X%AddTo (AddLocation,MudSystemDotXstart_OpSection(1)) - call Op_Mud_Forehead_section%AddTo (AddLocation,1) - call MudSystemDotOp_Mud_Backhead_X%AddTo (AddLocation,MudSystemDotXstart_OpSection(1)) - call Op_Mud_Backhead_section%AddTo (AddLocation,1) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) - call Op_MudOrKick%AddTo (AddLocation,0) + call MudSystem%Op_Density% AddTo (AddLocation,MudSystem%St_Density%Last()) + !call Op_MudDischarged_Volume%AddTo (AddLocation,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + call MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,MudSystem%MudVolume_InjectedToBH) + call MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) + call MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) + call MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) + call MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (AddLocation,0) else !write(*,*) 'merge**' !write(*,*) 'density before=' , Op_Density%Array(AddLocation-1) - !write(*,*) 'St_Density%Last() for mix=' , St_Density%Last() + !write(*,*) MudSystem%St_Density%Last() for mix=' ,MudSystem%St_Density%Last() - !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)+St_Density%Last()*((AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((AnnulusFlowRate/60.d0)*DeltaT_Mudline) + !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Density%Array(AddLocation-1)= (MudSystemDotOp_Density%Array(AddLocation-1)*MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1)+St_Density%Last()*MudSystemDotMudVolume_InjectedToBH)/(MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1)+MudSystemDotMudVolume_InjectedToBH) - MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1)= MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1) + MudSystemDotMudVolume_InjectedToBH + MudSystem%Op_Density%Array(AddLocation-1)= (MudSystem%Op_Density%Array(AddLocation-1)*MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*MudSystem%MudVolume_InjectedToBH)/(MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%MudVolume_InjectedToBH) + MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + MudSystem%MudVolume_InjectedToBH !write(*,*) 'density after=' , Op_Density%Array(AddLocation-1) endif @@ -456,12 +456,12 @@ MudSystemDotimud=0 !=============== save OP Mud data to transfer to the annulus enterance due to tripin or kick - MudSystemDotOpMudVolumeSum= 0.d0 + MudSystem%OpMudVolumeSum= 0.d0 !Op_MudSaved_Density= 0.d0 !Op_KickSaved_Density= 0.d0 - MudSystemDotOp_Saved_MudDischarged_Volume= 0.d0 - MudSystemDotOp_Kick_Saved_Volume= 0.d0 - MudSystemDotSaved_Op_MudOrKick= 0 + MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 + MudSystem%Op_Kick_Saved_Volume= 0.d0 + MudSystem%Saved_Op_MudOrKick= 0 @@ -469,34 +469,34 @@ MudSystemDotimud=0 !write(*,*) 'Op_MudDischarged_Volume%Length()===' , Op_MudDischarged_Volume%Length() ! - do MudSystemDotimud=1, MudSystemDotOp_MudDischarged_Volume%Length() + do imud=1, MudSystem%Op_MudDischarged_Volume%Length() !write(*,*) 'imud, Op_MudDischarged_Volume%Array(imud)=' , imud,Op_MudDischarged_Volume%Array(imud) - MudSystemDotOpMudVolumeSum= MudSystemDotOpMudVolumeSum + MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud) + MudSystem%OpMudVolumeSum= MudSystem%OpMudVolumeSum + MudSystem%Op_MudDischarged_Volume%Array(imud) - if ( MudSystemDotOpMudVolumeSum > sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then + if ( MudSystem%OpMudVolumeSum > sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then - IF (Op_MudOrKick%Array(MudSystemDotimud) == 0) THEN - MudSystemDotOp_MudSaved_Density = MudSystemDotOp_Density%Array(MudSystemDotimud) - MudSystemDotOp_Saved_MudDischarged_Volume = MudSystemDotOpMudVolumeSum - sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) + IF (MudSystem%Op_MudOrKick%Array(imud) == 0) THEN + MudSystem%Op_MudSaved_Density = MudSystem%Op_Density%Array(imud) + MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ELSE - MudSystemDotOp_Kick_Saved_Volume = MudSystemDotOpMudVolumeSum - sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) + MudSystem%Op_Kick_Saved_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) !write(*,*) 'cond 1- Op_MudOrKick%Array (imud),Op_Density%Array(imud):' ,Op_MudOrKick%Array (imud),Op_Density%Array(imud) - MudSystemDotSaved_Op_MudOrKick= Op_MudOrKick%Array (MudSystemDotimud) - MudSystemDotOp_KickSaved_Density= MudSystemDotOp_Density%Array(MudSystemDotimud) - MudSystemDotiLoc= 2 + MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (imud) + MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(imud) + MudSystem%iLoc= 2 END IF - do ii= MudSystemDotimud + 1, MudSystemDotOp_MudDischarged_Volume%Length() - IF (Op_MudOrKick%Array(ii) == 0) THEN - MudSystemDotOp_MudSaved_Density = ((MudSystemDotOp_MudSaved_Density * MudSystemDotOp_Saved_MudDischarged_Volume) + (MudSystemDotOp_Density%Array(ii) * MudSystemDotOp_MudDischarged_Volume%Array(ii))) / (MudSystemDotOp_Saved_MudDischarged_Volume + MudSystemDotOp_MudDischarged_Volume%Array(ii)) - MudSystemDotOp_Saved_MudDischarged_Volume = MudSystemDotOp_Saved_MudDischarged_Volume + MudSystemDotOp_MudDischarged_Volume%Array(ii) + do ii= imud + 1, MudSystem%Op_MudDischarged_Volume%Length() + IF (MudSystem%Op_MudOrKick%Array(ii) == 0) THEN + MudSystem%Op_MudSaved_Density = ((MudSystem%Op_MudSaved_Density * MudSystem%Op_Saved_MudDischarged_Volume) + (MudSystem%Op_Density%Array(ii) * MudSystem%Op_MudDischarged_Volume%Array(ii))) / (MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii)) + MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) ELSE - MudSystemDotOp_Kick_Saved_Volume = MudSystemDotOp_Kick_Saved_Volume + MudSystemDotOp_MudDischarged_Volume%Array(ii) + MudSystem%Op_Kick_Saved_Volume = MudSystem%Op_Kick_Saved_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) !write(*,*) 'cond 2- Op_MudOrKick%Array (ii),Op_Density%Array(ii):' ,Op_MudOrKick%Array (ii),Op_Density%Array(ii) - MudSystemDotSaved_Op_MudOrKick= Op_MudOrKick%Array (ii) - MudSystemDotOp_KickSaved_Density= MudSystemDotOp_Density%Array(ii) - MudSystemDotiLoc= 2 + MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (ii) + MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(ii) + MudSystem%iLoc= 2 END IF enddo @@ -517,8 +517,8 @@ MudSystemDotimud=0 !if (iLoc == 1) then - MudSystemDotMudSection= F_StringIntervalCounts+1 - MudSystemDotBackheadX= MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1) + MudSystem%MudSection= F_StringIntervalCounts+1 + MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1) !elseif (iLoc == 2) then ! MudSection= Kick_Forehead_section ! BackheadX= Kick_Forehead_X @@ -527,8 +527,8 @@ MudSystemDotimud=0 !========================ANNULUS ENTRANCE==================== !if (KickMigration_2SideBit == .FALSE.) then ! because its effect is applied in Migration Code ! !write(*,*) 'iloc=====' , iLoc bejaye Rate_of_Penetration ==0. in bude: DeltaVolumeOp == 0.0 - ! if (ABS(AnnulusSuctionDensity_Old-St_Density%Last()) >= DensityMixTol .OR. (DeltaVolumeOp == 0.0 .and. ABS(Ann_Density%Array(iLoc)-St_Density%Last())>=DensityMixTol .and. AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped - ! call Ann_Density%AddTo (iLoc,St_Density%Last()) + ! if (ABS(AnnulusSuctionDensity_OldMudSystem%St_Density%Last()) >= DensityMixTol .OR. (DeltaVolumeOp == 0.0 .and. ABS(Ann_Density%Array(iLoc)MudSystem%St_Density%Last())>=DensityMixTol .and. MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped + ! call Ann_Density%AddTo (iLocMudSystem%St_Density%Last()) ! call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0) ! call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) ! call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection) @@ -540,12 +540,12 @@ MudSystemDotimud=0 ! call Ann_CuttingMud%AddTo (iLoc,0) ! !write(*,*) 'c) annLength=' , Ann_Density%Length() ! - ! AnnulusSuctionDensity_Old= St_Density%Last() + ! AnnulusSuctionDensity_Old=MudSystem%St_Density%Last() ! ! MudIsChanged= .true. ! endif ! - ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((AnnulusFlowRate/60.d0)*DeltaT_Mudline) !(gal) + ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) !(gal) ! !endif @@ -554,8 +554,8 @@ MudSystemDotimud=0 - Ann_Mud_Backhead_section%Array(1)= MudSystemDotMudSection !it is needed to be updated for a condition that one pipe is removed from Annulus due to trip out - Ann_Mud_Backhead_X%Array(1)= MudSystemDotBackheadX + MudSystem%Ann_Mud_Backhead_section%Array(1)= MudSystem%MudSection !it is needed to be updated for a condition that one pipe is removed from Annulus due to trip out + MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%BackheadX @@ -589,56 +589,56 @@ MudSystemDotimud=0 !endif - if (MudSystemDotOp_Kick_Saved_Volume > 0.0 .and. Ann_MudOrKick%First() == 0) then + if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then write(*,*) 'Kick influx enters Annulus' - call Ann_Density%AddToFirst (MudSystemDotOp_KickSaved_Density) - call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotOp_Kick_Saved_Volume) - call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Ann_MudOrKick%AddToFirst (MudSystemDotSaved_Op_MudOrKick) !<<<<<<<< - call Ann_CuttingMud%AddToFirst (0) - elseif (MudSystemDotOp_Kick_Saved_Volume > 0.0 .and. Ann_MudOrKick%First() /= 0) then - MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) + MudSystemDotOp_Kick_Saved_Volume + call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) + call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) + call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< + call MudSystem%Ann_CuttingMud%AddToFirst (0) + elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then + MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume endif - if (MudSystemDotOp_Saved_MudDischarged_Volume> 0.0) then - NewDensity= MudSystemDotOp_MudSaved_Density - MudSystemDotNewVolume= MudSystemDotOp_Saved_MudDischarged_Volume + if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then + MudSystem%NewDensity= MudSystem%Op_MudSaved_Density + MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume !write(*,*) 'NewVolume=' , NewVolume !write(*,*) 'iloc=' , iloc,'Ann_MudDischarged_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - if ((Rate_of_Penetration==0 .and. abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotDensityMixTol) & - .or. (Rate_of_Penetration>0. .and. Ann_CuttingMud%Array(MudSystemDotiLoc)==1 .and. abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotCuttingDensityMixTol) & - .or. (Rate_of_Penetration>0. .and. Ann_CuttingMud%Array(MudSystemDotiLoc)==0 .and. MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc) < 42.) ) then ! 1-Pockets are Merged + if ((Rate_of_Penetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & + .or. (Rate_of_Penetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & + .or. (Rate_of_Penetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - Ann_Density%Array(MudSystemDotiLoc)= (Ann_Density%Array(MudSystemDotiLoc)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume - Ann_Mud_Forehead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Forehead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_Mud_Backhead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Backhead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotiLoc)= (0.0d0) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotiLoc)= (0.0d0) + MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) else ! 2-Merging conditions are not meeted, so new pocket - call Ann_Density%AddTo (MudSystemDotiLoc,NewDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotiLoc,MudSystemDotNewVolume) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotiLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotiLoc,0) + call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) !write(*,*) 'd) annLength=' , Ann_Density%Length() !write(*,*) 'new' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) @@ -651,7 +651,7 @@ MudSystemDotimud=0 !========================Drilling Mode======================== - if (Rate_of_Penetration>0. .and. MudSystemDotDeltaVolumeOp>0.0) then ! trip in mode(loole paeen) DrillingMode== .true. + if (Rate_of_Penetration>0. .and. MudSystem%DeltaVolumeOp>0.0) then ! trip in mode(loole paeen) DrillingMode== .true. !write(*,*) 'Drilling Mode' !if ( MudIsChanged== .true. ) then @@ -660,78 +660,78 @@ MudSystemDotimud=0 !write(*,*) 'before' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - !NewDensity= (St_Density%Last() * AnnulusFlowRate + 141.4296E-4*Rate_of_Penetration*Diameter_of_Bit**2)/(AnnulusFlowRate+6.7995E-4*Rate_of_Penetration*Diameter_of_Bit**2) + !MudSystem%NewDensity= MudSystem%St_Density%Last() * MudSystem%AnnulusFlowRate + 141.4296E-4*Rate_of_Penetration*Diameter_of_Bit**2)/(MudSystem%AnnulusFlowRate+6.7995E-4*Rate_of_Penetration*Diameter_of_Bit**2) - NewDensity= St_Density%Last() + MudSystem%NewDensity=MudSystem%St_Density%Last() - !NewVolume= ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp + !NewVolume= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp !!! Density in ppg, flow rate in gpm, ROP in ft/s, bit diameter in inch - do MudSystemDotimud=1, MudSystemDotOp_MudDischarged_Volume%Length() - if ( Op_MudOrKick%Array(MudSystemDotimud) == 0 ) then - MudSystemDotOp_Density%Array(MudSystemDotimud)= NewDensity + do imud=1, MudSystem%Op_MudDischarged_Volume%Length() + if ( MudSystem%Op_MudOrKick%Array(imud) == 0 ) then + MudSystem%Op_Density%Array(imud)= MudSystem%NewDensity endif enddo - if (MudSystemDotOp_Kick_Saved_Volume > 0.0 .and. Ann_MudOrKick%First() == 0) then + if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then write(*,*) 'Kick influx enters Annulus first time' !write(*,*) 'Saved_Op_MudOrKick=',Saved_Op_MudOrKick - call Ann_Density%AddToFirst (MudSystemDotOp_KickSaved_Density) - call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotOp_Kick_Saved_Volume) - call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Ann_MudOrKick%AddToFirst (MudSystemDotSaved_Op_MudOrKick) !<<<<<<<< - call Ann_CuttingMud%AddToFirst (0) - elseif (MudSystemDotOp_Kick_Saved_Volume > 0.0 .and. Ann_MudOrKick%First() /= 0) then - MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) + MudSystemDotOp_Kick_Saved_Volume + call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) + call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) + call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< + call MudSystem%Ann_CuttingMud%AddToFirst (0) + elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then + MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume endif - if (MudSystemDotOp_Saved_MudDischarged_Volume> 0.0) then + if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then !write(*,*) 'Op_Saved_Mud added' - NewDensity= NewDensity !(drilling density) - MudSystemDotNewVolume= MudSystemDotOp_Saved_MudDischarged_Volume + MudSystemDotDeltaVolumeOp ! (DeltaVolumeOp: for Cuttings Volume) + MudSystem%NewDensity= MudSystem%NewDensity !(drilling density) + MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%DeltaVolumeOp ! (DeltaVolumeOp: for Cuttings Volume) !write(*,*) 'NewVolume=' , NewVolume !write(*,*) 'iloc=' , iloc,'Ann_MudDischarged_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - if ( (Ann_CuttingMud%Array(MudSystemDotiLoc)==1 .and. abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotCuttingDensityMixTol ) & - .or. (Ann_CuttingMud%Array(MudSystemDotiLoc)==0 .and. MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc) < 42.) ) then ! 1-Pockets are Merged + if ( (MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol ) & + .or. (MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - Ann_Density%Array(MudSystemDotiLoc)= (Ann_Density%Array(MudSystemDotiLoc)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume - Ann_Mud_Forehead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Forehead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_Mud_Backhead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Backhead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotiLoc)= (0.0d0) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotiLoc)= (0.0d0) - Ann_CuttingMud%Array(MudSystemDotiLoc)= 1 + MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)= 1 !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) else ! 2-Merging conditions are not meeted, so new pocket - !write(*,*) 'before e) ', iloc, Ann_Density%Array(iLoc),NewDensity + !write(*,*) 'before e) ', iloc, Ann_Density%Array(iLoc),MudSystem%NewDensity !write(*,*) 'before e) Ann_MudDischarged_Volume%Array(iLoc)=' , Ann_MudDischarged_Volume%Array(iLoc) - call Ann_Density%AddTo (MudSystemDotiLoc,NewDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotiLoc,MudSystemDotNewVolume) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotiLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotiLoc,1) ! 1= cutting 0= mud + call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,1) ! 1= cutting 0= mud !write(*,*) 'new' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) !write(*,*) 'e) annLength=' , Ann_Density%Length() @@ -757,52 +757,52 @@ MudSystemDotimud=0 ! !write(*,*) '==after add to ann' - MudSystemDotNewVolume= ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Saved_MudDischarged_Volume + MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume - if (MudSystemDotiLoc==2 .and. Op_MudOrKick%Last()==0 .and. MudSystemDotNewVolume > 0.d0 ) then ! for avoid kick separation + if (MudSystem%iLoc==2 .and. MudSystem%Op_MudOrKick%Last()==0 .and. MudSystem%NewVolume > 0.d0 ) then ! for avoid kick separation !write(*,*) 'avoid kick separation' - NewDensity= MudSystemDotOp_MudSaved_Density + MudSystem%NewDensity= MudSystem%Op_MudSaved_Density - call RemoveOpMudArrays(MudSystemDotOp_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann - if ( MudSystemDotAnn_MudDischarged_Volume%Array(1) > ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline)- MudSystemDotOp_Saved_MudDischarged_Volume) then! 1st in Ann = kick + call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann + if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)- MudSystem%Op_Saved_MudDischarged_Volume) then! 1st in Ann = kick !write(*,*) 'mode1' - MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) - (((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) -MudSystemDotOp_Saved_MudDischarged_Volume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())+ (((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Saved_MudDischarged_Volume) !kick + MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) -MudSystem%Op_Saved_MudDischarged_Volume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) !kick else call RemoveAnnulusMudArrays(1) !kick is removed - MudSystemDotiLoc= 1 - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())+ (((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Saved_MudDischarged_Volume) + MudSystem%iLoc= 1 + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) !write(*,*) 'mode2' ! including a little expand endif - if ((Rate_of_Penetration==0 .and. abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotDensityMixTol) & - .or. (Rate_of_Penetration>0. .and. Ann_CuttingMud%Array(MudSystemDotiLoc)==1 .and. abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotCuttingDensityMixTol) & - .or. (Rate_of_Penetration>0. .and. Ann_CuttingMud%Array(MudSystemDotiLoc)==0 .and. MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc) < 42.) ) then ! 1-Pockets are Merged + if ((Rate_of_Penetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & + .or. (Rate_of_Penetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & + .or. (Rate_of_Penetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - Ann_Density%Array(MudSystemDotiLoc)= (Ann_Density%Array(MudSystemDotiLoc)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume - Ann_Mud_Forehead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Forehead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_Mud_Backhead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Backhead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotiLoc)= (0.0d0) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotiLoc)= (0.0d0) + MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket - call Ann_Density%AddTo (MudSystemDotiLoc,NewDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotiLoc,MudSystemDotNewVolume) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotiLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotiLoc,0) + call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) !write(*,*) 'd) annLength=' , Ann_Density%Length() endif @@ -810,26 +810,26 @@ MudSystemDotimud=0 endif !=================================================================== - if( Op_MudOrKick%Last() == 1 .and. Ann_MudOrKick%First() == 0 ) then + if( MudSystem%Op_MudOrKick%Last() == 1 .and. MudSystem%Ann_MudOrKick%First() == 0 ) then write(*,*) '***error2****==' - write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , MudSystemDotOp_Kick_Saved_Volume,MudSystemDotOp_Saved_MudDischarged_Volume + write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , MudSystem%Op_Kick_Saved_Volume,MudSystem%Op_Saved_MudDischarged_Volume write(*,*) 'after add to ann==' - do MudSystemDotimud=1, MudSystemDotOp_MudDischarged_Volume%Length() - write(*,*) 'Op:', MudSystemDotimud, MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud), MudSystemDotOp_Density%Array(MudSystemDotimud) ,Op_MudOrKick%Array(MudSystemDotimud) + do imud=1, MudSystem%Op_MudDischarged_Volume%Length() + write(*,*) 'Op:', imud, MudSystem%Op_MudDischarged_Volume%Array(imud), MudSystem%Op_Density%Array(imud) ,MudSystem%Op_MudOrKick%Array(imud) enddo - do MudSystemDotimud=1, MudSystemDotAnn_MudDischarged_Volume%Length() - write(*,*) 'Ann:', MudSystemDotimud, MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud), Ann_Density%Array(MudSystemDotimud) ,Ann_MudOrKick%Array(MudSystemDotimud) + do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() + write(*,*) 'Ann:', imud, MudSystem%Ann_MudDischarged_Volume%Array(imud), MudSystem%Ann_Density%Array(imud) ,MudSystem%Ann_MudOrKick%Array(imud) enddo write(*,*) '==after add to ann' - write(*,*) 'NewVolume,Op_MudOrKick%Last=' , MudSystemDotNewVolume,Op_MudOrKick%Last() + write(*,*) 'NewVolume,Op_MudOrKick%Last=' , MudSystem%NewVolume,MudSystem%Op_MudOrKick%Last() write(*,*) '==***error2****' endif @@ -839,41 +839,41 @@ MudSystemDotimud=0 !=============== save Ann Mud data to transfer to the ChokeLine enterance - MudSystemDotAnnMudVolumeSum= 0.d0 + MudSystem%AnnMudVolumeSum= 0.d0 !Ann_MudSaved_Density= 0.d0 !Ann_KickSaved_Density= 0.d0 - MudSystemDotAnn_Saved_MudDischarged_Volume= 0.d0 - MudSystemDotAnn_Kick_Saved_Volume= 0.d0 - MudSystemDotSaved_Ann_MudOrKick= 0 - MudSystemDotAnn_to_Choke_2mud= .false. + MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 + MudSystem%Ann_Kick_Saved_Volume= 0.d0 + MudSystem%Saved_Ann_MudOrKick= 0 + MudSystem%Ann_to_Choke_2mud= .false. - do MudSystemDotimud=1, MudSystemDotAnn_MudDischarged_Volume%Length() + do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - MudSystemDotAnnMudVolumeSum= MudSystemDotAnnMudVolumeSum + MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) + MudSystem%AnnMudVolumeSum= MudSystem%AnnMudVolumeSum + MudSystem%Ann_MudDischarged_Volume%Array(imud) - if ( MudSystemDotAnnMudVolumeSum > sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) ) then + if ( MudSystem%AnnMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) ) then - IF (Ann_MudOrKick%Array(MudSystemDotimud) == 0) THEN - MudSystemDotAnn_MudSaved_Density = Ann_Density%Array(MudSystemDotimud) - MudSystemDotAnn_Saved_MudDischarged_Volume = MudSystemDotAnnMudVolumeSum - sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) - ELSEIF (Ann_MudOrKick%Array(MudSystemDotimud) > 0 .AND. Ann_MudOrKick%Array(MudSystemDotimud) <100) THEN ! 104= AIR - MudSystemDotAnn_Kick_Saved_Volume = MudSystemDotAnnMudVolumeSum - sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) - MudSystemDotSaved_Ann_MudOrKick= Ann_MudOrKick%Array (MudSystemDotimud) - MudSystemDotAnn_KickSaved_Density= Ann_Density%Array(MudSystemDotimud) + IF (MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN + MudSystem%Ann_MudSaved_Density = MudSystem%Ann_Density%Array(imud) + MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) + ELSEIF (MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR + MudSystem%Ann_Kick_Saved_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) + MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (imud) + MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(imud) END IF - do ii= MudSystemDotimud + 1, MudSystemDotAnn_MudDischarged_Volume%Length() - IF (Ann_MudOrKick%Array(ii) == 0) THEN - MudSystemDotAnn_MudSaved_Density = ((MudSystemDotAnn_MudSaved_Density * MudSystemDotAnn_Saved_MudDischarged_Volume) + (Ann_Density%Array(ii) * MudSystemDotAnn_MudDischarged_Volume%Array(ii))) / (MudSystemDotAnn_Saved_MudDischarged_Volume + MudSystemDotAnn_MudDischarged_Volume%Array(ii)) - MudSystemDotAnn_Saved_MudDischarged_Volume = MudSystemDotAnn_Saved_MudDischarged_Volume + MudSystemDotAnn_MudDischarged_Volume%Array(ii) - MudSystemDotAnn_to_Choke_2mud= .true. - ELSEIF (Ann_MudOrKick%Array(ii) > 0 .AND. Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystemDotAnn_Kick_Saved_Volume = MudSystemDotAnn_Kick_Saved_Volume + MudSystemDotAnn_MudDischarged_Volume%Array(ii) - MudSystemDotSaved_Ann_MudOrKick= Ann_MudOrKick%Array (ii) - MudSystemDotAnn_KickSaved_Density= Ann_Density%Array(ii) + do ii= imud + 1, MudSystem%Ann_MudDischarged_Volume%Length() + IF (MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN + MudSystem%Ann_MudSaved_Density = ((MudSystem%Ann_MudSaved_Density * MudSystem%Ann_Saved_MudDischarged_Volume) + (MudSystem%Ann_Density%Array(ii) * MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii)) + MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) + MudSystem%Ann_to_Choke_2mud= .true. + ELSEIF (MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR + MudSystem%Ann_Kick_Saved_Volume = MudSystem%Ann_Kick_Saved_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) + MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (ii) + MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(ii) END IF enddo @@ -884,24 +884,24 @@ MudSystemDotimud=0 endif enddo -MudSystemDotAnn_Saved_MudDischarged_Volume_Final= MudSystemDotAnn_Saved_MudDischarged_Volume !+ Ann_Kick_Saved_Volume -MudSystemDotAnn_Kick_Saved_Volume_Final= MudSystemDotAnn_Kick_Saved_Volume -IF (WellHeadIsOpen) MudVolume_InjectedFromAnn = MudSystemDotAnn_Saved_MudDischarged_Volume_Final -((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) -!WRITE (*,*) 'MudVolume_InjectedFromAnn=', MudVolume_InjectedFromAnn +MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume !+ Ann_Kick_Saved_Volume +MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume +IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final -((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) +!WRITE (*,*) 'MudSystem%MudVolume_InjectedFromAnn=', MudSystem%MudVolume_InjectedFromAnn !====================================================================== !write(*,*) 'c)Ann_Mud sum=' , sum(Ann_MudDischarged_Volume%Array(:)) !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) !write(*,*) 'Ann_Saved_Mud=' , Ann_Saved_MudDischarged_Volume - MudSystemDottotal_injected = MudSystemDottotal_injected + MudVolume_InjectedFromAnn + MudSystem%total_injected = MudSystem%total_injected + MudSystem%MudVolume_InjectedFromAnn if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystemDottotal_injected= 0. + MudSystem%total_injected= 0. endif !write(*,*) ' total injected-tripin =' , total_injected - !write(*,*) 'injected-tripin =' , MudVolume_InjectedFromAnn + !write(*,*) 'injected-tripin =' , MudSystem%MudVolume_InjectedFromAnn @@ -911,26 +911,26 @@ IF (WellHeadIsOpen) MudVolume_InjectedFromAnn = MudSystemDotAnn_Saved_MudD !MudIsChanged= .false. -MudSystemDotimud= 0 +imud= 0 - do while (MudSystemDotimud < Ann_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 + do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= Ann_Mud_Forehead_X%Array(MudSystemDotimud-1) - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= Ann_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) + MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) endif ! <<< Fracture Shoe Lost - IF ( MudSystemDotShoeLost .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(MudSystemDotimud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(MudSystemDotimud) ) then + IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)-((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) !(gal) - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) < 0.0) then + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(MudSystemDotimud) - MudSystemDotimud= MudSystemDotimud-1 + call RemoveAnnulusMudArrays(imud) + imud= imud-1 cycle endif @@ -938,48 +938,48 @@ MudSystemDotimud= 0 ! Fracture Shoe Lost >>> - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))- Ann_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(Ann_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) <= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= Ann_Mud_Backhead_section%Array(MudSystemDotimud) - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= Ann_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(Ann_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= Ann_Mud_Backhead_section%Array(MudSystemDotimud)+1 - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > MudSystemDotNoPipeSections) then ! last pipe section(well exit) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections) - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotNoPipeSections + if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well + if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well !write(*,*) 'remove******' - call RemoveAnnulusMudArrays(MudSystemDotimud) + call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystemDotxx= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -1002,8 +1002,8 @@ MudSystemDotimud= 0 enddo - if (Ann_Mud_Forehead_X%Last() < MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections)) then - Ann_Mud_Forehead_X%Array(Ann_Mud_Forehead_X%Length()) = MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections) ! for error preventing + if (MudSystem%Ann_Mud_Forehead_X%Last() < MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) then + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length()) = MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) ! for error preventing endif !========================ANNULUS END================= @@ -1021,60 +1021,60 @@ MudSystemDotimud= 0 !========================Bottom Hole================= -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotOp_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud-1) - Op_Mud_Backhead_section%Array(MudSystemDotimud)= Op_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) + MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif !write(*,*) 'imud**=' , imud - MudSystemDotDirectionCoef= (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal !write(*,*) ' Op_EmptyVolume_inBackheadLocation%Array(1) =' , Op_EmptyVolume_inBackheadLocation%Array(1) - if ( MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(1) < 0.0) CALL ErrorStop1 ('Negative Empty volume') + if ( MudSystem%Op_EmptyVolume_inBackheadLocation%Array(1) < 0.0) CALL ErrorStop1 ('Negative Empty volume') - if ( MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= Op_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= Op_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) + if (MudSystem%isection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) !if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts) - Op_Mud_Forehead_section%Array(MudSystemDotimud)= F_BottomHoleIntervalCounts + MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts) + MudSystem%Op_Mud_Forehead_section%Array(imud)= F_BottomHoleIntervalCounts - if (MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveOpMudArrays(MudSystemDotimud) + if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call RemoveOpMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_OpSection(MudSystemDotisection)- MudSystemDotXstart_OpSection(MudSystemDotisection)))+ MudSystemDotXstart_OpSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) exit else - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -1083,13 +1083,13 @@ MudSystemDotimud=0 endif ! for OP remove: - if (MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)== MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts)) then - MudSystemDottotalLength = MudSystemDotOp_MudDischarged_Volume%Length() - do while(MudSystemDotimud < MudSystemDottotalLength) + if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts)) then + MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() + do while(imud < MudSystem%totalLength) !imud = imud + 1 - call RemoveOpMudArrays(MudSystemDottotalLength) - MudSystemDottotalLength = MudSystemDottotalLength - 1 + call RemoveOpMudArrays(MudSystem%totalLength) + MudSystem%totalLength = MudSystem%totalLength - 1 enddo @@ -1146,7 +1146,7 @@ MudSystemDotimud=0 ! write(*,*) 'after sorting st==' ! ! do imud=1, st_MudDischarged_Volume%Length() - ! write(*,*) 'st-plot:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud),St_Density%Array(imud) + ! write(*,*) 'st-plot:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud)MudSystem%St_Density%Array(imud) ! enddo ! !write(*,*) '==after sorting st' @@ -1154,7 +1154,7 @@ MudSystemDotimud=0 - !write(*,*) '**Ann_Kick_Saved_Final,Mud_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudVolume_InjectedFromAnn + !write(*,*) '**Ann_Kick_Saved_Final,Mud_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn end subroutine Pump_and_TripIn @@ -1207,7 +1207,7 @@ MudSystemDotimud=0 - !write(*,*) 'Ann_Kick_Saved_Volume_Final,MudVolume_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudVolume_InjectedFromAnn + !write(*,*) 'Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn !write(*,*) 'begining chokeline==' @@ -1217,17 +1217,17 @@ MudSystemDotimud=0 - MudSystemDotChokeLineFlowRate = MUD(4)%Q + MudSystem%ChokeLineFlowRate = MUD(4)%Q !WRITE (*,*) 'MUD(4)%Q', MUD(4)%Q - if (MudSystemDotNewPipeFilling == 0) then ! .or. UtubeFilling==0) then - MudSystemDotChokeLineFlowRate= 0. + if (MudSystem%NewPipeFilling == 0) then ! .or. UtubeFilling==0) then + MudSystem%ChokeLineFlowRate= 0. endif - do MudSystemDotimud=1, MudSystemDotChokeLine_MudDischarged_Volume%Length()-2 - if ( ChokeLine_MudOrKick%Array(MudSystemDotimud) ==1 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+1) ==0 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+2) ==1 ) then + do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 1' error_occured = 1 endif @@ -1244,32 +1244,32 @@ MudSystemDotimud=0 !========================CHOKE LINE ENTRANCE================= !if ( Ann_Kick_Saved_Volume > 0.0 .and. ( Ann_Saved_MudDischarged_Volume-((Qlost/60.0d0)*DeltaT_Mudline) ) == 0.0 ) then - if ( MudSystemDotAnn_Kick_Saved_Volume > 1.0e-5 .and. ( MudVolume_InjectedFromAnn ) <= 1.0e-5 ) then + if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( MudSystem%MudVolume_InjectedFromAnn ) <= 1.0e-5 ) then !WRITE (*,*) 'only kick enters to chokeline, Casing pressure = ', PressureGauges(2) - if (ChokeLine_MudOrKick%First() == 0) then - call MudSystemDotChokeLine_Density%AddToFirst (MudSystemDotAnn_KickSaved_Density) - call MudSystemDotChokeLine_MudDischarged_Volume%AddToFirst (0.d0) - call MudSystemDotChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call ChokeLine_MudOrKick%AddToFirst (MudSystemDotSaved_Ann_MudOrKick) + if (MudSystem%ChokeLine_MudOrKick%First() == 0) then + call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_KickSaved_Density) + call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.d0) + call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%ChokeLine_MudOrKick%AddToFirst (MudSystem%Saved_Ann_MudOrKick) - ChokeLineDensity_Old= MudSystemDotAnn_KickSaved_Density + MudSystem%ChokeLineDensity_Old= MudSystem%Ann_KickSaved_Density endif - MudSystemDotChokeLine_MudDischarged_Volume%Array(1)= MudSystemDotChokeLine_MudDischarged_Volume%Array(1)+ MudSystemDotAnn_Kick_Saved_Volume !(gal) + MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ MudSystem%Ann_Kick_Saved_Volume !(gal) endif - do MudSystemDotimud=1, MudSystemDotChokeLine_MudDischarged_Volume%Length()-2 - if ( ChokeLine_MudOrKick%Array(MudSystemDotimud) ==1 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+1) ==0 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+2) ==1 ) then + do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 2' error_occured = 1 @@ -1280,27 +1280,27 @@ MudSystemDotimud=0 !if ( Ann_Kick_Saved_Volume == 0.0 .and. ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 ) then - if ( MudSystemDotAnn_Kick_Saved_Volume <= 1.0e-5 .and. MudVolume_InjectedFromAnn > 1.0e-5 ) then + if ( MudSystem%Ann_Kick_Saved_Volume <= 1.0e-5 .and. MudSystem%MudVolume_InjectedFromAnn > 1.0e-5 ) then !WRITE (*,*) 'only mud enters to chokeline' - if ((MudSystemDotAnn_to_Choke_2mud == .false. .and. ABS(ChokeLineDensity_Old - MudSystemDotAnn_MudSaved_Density) >= MudSystemDotDensityMixTol) .or. ChokeLine_MudOrKick%First() /= 0) then ! new mud is pumped - call MudSystemDotChokeLine_Density%AddToFirst (MudSystemDotAnn_MudSaved_Density) - call MudSystemDotChokeLine_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystemDotChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call ChokeLine_MudOrKick%AddToFirst (0) + if ((MudSystem%Ann_to_Choke_2mud == .false. .and. ABS(MudSystem%ChokeLineDensity_Old - MudSystem%Ann_MudSaved_Density) >= MudSystem%DensityMixTol) .or. MudSystem%ChokeLine_MudOrKick%First() /= 0) then ! new mud is pumped + call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_MudSaved_Density) + call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - ChokeLineDensity_Old= MudSystemDotAnn_MudSaved_Density + MudSystem%ChokeLineDensity_Old= MudSystem%Ann_MudSaved_Density endif !ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1)+ (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) !(gal) - MudSystemDotChokeLine_MudDischarged_Volume%Array(1)= MudSystemDotChokeLine_MudDischarged_Volume%Array(1)+ (MudVolume_InjectedFromAnn) !(gal) + MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ (MudSystem%MudVolume_InjectedFromAnn) !(gal) @@ -1308,8 +1308,8 @@ MudSystemDotimud=0 - do MudSystemDotimud=1, MudSystemDotChokeLine_MudDischarged_Volume%Length()-2 - if ( ChokeLine_MudOrKick%Array(MudSystemDotimud) ==1 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+1) ==0 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+2) ==1 ) then + do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 3' error_occured = 1 @@ -1318,60 +1318,60 @@ MudSystemDotimud=0 !if ( Ann_Kick_Saved_Volume > 0.0 .and. (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 .and. ChokeLine_MudOrKick%First() /= 0 ) then - if ( MudSystemDotAnn_Kick_Saved_Volume > 1.0e-5 .and. (MudVolume_InjectedFromAnn) > 1.0e-5 .and. ChokeLine_MudOrKick%First() /= 0 ) then + if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. (MudSystem%MudVolume_InjectedFromAnn) > 1.0e-5 .and. MudSystem%ChokeLine_MudOrKick%First() /= 0 ) then WRITE (*,*) 'Kick Enters Choke line Last Time' - MudSystemDotChokeLine_MudDischarged_Volume%Array(1)= MudSystemDotChokeLine_MudDischarged_Volume%Array(1)+ MudSystemDotAnn_Kick_Saved_Volume !(gal) + MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ MudSystem%Ann_Kick_Saved_Volume !(gal) - call MudSystemDotChokeLine_Density%AddToFirst (MudSystemDotAnn_MudSaved_Density) + call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_MudSaved_Density) !call ChokeLine_MudDischarged_Volume%AddToFirst (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) - call MudSystemDotChokeLine_MudDischarged_Volume%AddToFirst (MudVolume_InjectedFromAnn) - call MudSystemDotChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call ChokeLine_MudOrKick%AddToFirst (0) + call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (MudSystem%MudVolume_InjectedFromAnn) + call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - ChokeLineDensity_Old= MudSystemDotAnn_MudSaved_Density + MudSystem%ChokeLineDensity_Old= MudSystem%Ann_MudSaved_Density !ELSE if ( Ann_Kick_Saved_Volume > 0.0 .and. ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 .and. ChokeLine_MudOrKick%First() == 0 ) then - ELSE if ( MudSystemDotAnn_Kick_Saved_Volume > 1.0e-5 .and. ( MudVolume_InjectedFromAnn ) > 1.0e-5 .and. ChokeLine_MudOrKick%First() == 0 ) then + ELSE if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( MudSystem%MudVolume_InjectedFromAnn ) > 1.0e-5 .and. MudSystem%ChokeLine_MudOrKick%First() == 0 ) then WRITE (*,*) 'Kick Enters Choke line First Time' !ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1)+ ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) !(gal) - MudSystemDotChokeLine_MudDischarged_Volume%Array(1)= MudSystemDotChokeLine_MudDischarged_Volume%Array(1)+ ( MudVolume_InjectedFromAnn ) !(gal) + MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ ( MudSystem%MudVolume_InjectedFromAnn ) !(gal) - call MudSystemDotChokeLine_Density%AddToFirst (MudSystemDotAnn_KickSaved_Density) - call MudSystemDotChokeLine_MudDischarged_Volume%AddToFirst (MudSystemDotAnn_Kick_Saved_Volume) - call MudSystemDotChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call ChokeLine_MudOrKick%AddToFirst (MudSystemDotSaved_Ann_MudOrKick) + call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_KickSaved_Density) + call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (MudSystem%Ann_Kick_Saved_Volume) + call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%ChokeLine_MudOrKick%AddToFirst (MudSystem%Saved_Ann_MudOrKick) - ChokeLineDensity_Old= MudSystemDotAnn_KickSaved_Density + MudSystem%ChokeLineDensity_Old= MudSystem%Ann_KickSaved_Density endif - do MudSystemDotimud=1, MudSystemDotChokeLine_MudDischarged_Volume%Length()-2 - if ( ChokeLine_MudOrKick%Array(MudSystemDotimud) ==1 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+1) ==0 .and. ChokeLine_MudOrKick%Array(MudSystemDotimud+2) ==1 ) then + do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 4' error_occured = 1 @@ -1380,8 +1380,8 @@ MudSystemDotimud=0 if (error_occured == 1) then - do MudSystemDotimud=1, MudSystemDotChokeLine_MudDischarged_Volume%Length() - write(*,*) 'ChokeLine:', MudSystemDotimud, MudSystemDotChokeLine_Density%Array(MudSystemDotimud) ,ChokeLine_MudOrKick%Array(MudSystemDotimud) + do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length() + write(*,*) 'ChokeLine:', imud, MudSystem%ChokeLine_Density%Array(imud) ,MudSystem%ChokeLine_MudOrKick%Array(imud) enddo endif @@ -1402,40 +1402,40 @@ MudSystemDotimud=0 !=============== save Choke Mud data========================== - MudSystemDotChokeMudVolumeSum= 0.d0 + MudSystem%ChokeMudVolumeSum= 0.d0 !Ann_MudSaved_Density= 0.d0 !Ann_KickSaved_Density= 0.d0 - MudSystemDotChoke_Saved_MudDischarged_Volume= 0.d0 - MudSystemDotChoke_Kick_Saved_Volume= 0.d0 - MudSystemDotSaved_Choke_MudOrKick= 0 + MudSystem%Choke_Saved_MudDischarged_Volume= 0.d0 + MudSystem%Choke_Kick_Saved_Volume= 0.d0 + MudSystem%Saved_Choke_MudOrKick= 0 - do MudSystemDotimud=1, MudSystemDotChokeLine_MudDischarged_Volume%Length() + do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length() - MudSystemDotChokeMudVolumeSum= MudSystemDotChokeMudVolumeSum + MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotimud) + MudSystem%ChokeMudVolumeSum= MudSystem%ChokeMudVolumeSum + MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) - if ( MudSystemDotChokeMudVolumeSum > MudSystemDotChokeLine_VolumeCapacity ) then + if ( MudSystem%ChokeMudVolumeSum > MudSystem%ChokeLine_VolumeCapacity ) then - IF (ChokeLine_MudOrKick%Array(MudSystemDotimud) == 0) THEN - MudSystemDotChoke_MudSaved_Density = MudSystemDotChokeLine_Density%Array(MudSystemDotimud) - MudSystemDotChoke_Saved_MudDischarged_Volume = MudSystemDotChokeMudVolumeSum - MudSystemDotChokeLine_VolumeCapacity - ELSEIF (ChokeLine_MudOrKick%Array(MudSystemDotimud) > 0 .AND. ChokeLine_MudOrKick%Array(MudSystemDotimud) <100) THEN ! 104= AIR - MudSystemDotChoke_Kick_Saved_Volume = MudSystemDotChokeMudVolumeSum - MudSystemDotChokeLine_VolumeCapacity - MudSystemDotSaved_Choke_MudOrKick= ChokeLine_MudOrKick%Array (MudSystemDotimud) - MudSystemDotChoke_KickSaved_Density= MudSystemDotChokeLine_Density%Array(MudSystemDotimud) + IF (MudSystem%ChokeLine_MudOrKick%Array(imud) == 0) THEN + MudSystem%Choke_MudSaved_Density = MudSystem%ChokeLine_Density%Array(imud) + MudSystem%Choke_Saved_MudDischarged_Volume = MudSystem%ChokeMudVolumeSum - MudSystem%ChokeLine_VolumeCapacity + ELSEIF (MudSystem%ChokeLine_MudOrKick%Array(imud) > 0 .AND. MudSystem%ChokeLine_MudOrKick%Array(imud) <100) THEN ! 104= AIR + MudSystem%Choke_Kick_Saved_Volume = MudSystem%ChokeMudVolumeSum - MudSystem%ChokeLine_VolumeCapacity + MudSystem%Saved_Choke_MudOrKick= MudSystem%ChokeLine_MudOrKick%Array (imud) + MudSystem%Choke_KickSaved_Density= MudSystem%ChokeLine_Density%Array(imud) END IF - do ii= MudSystemDotimud + 1, MudSystemDotChokeLine_MudDischarged_Volume%Length() - - IF (ChokeLine_MudOrKick%Array(ii) == 0) THEN - MudSystemDotChoke_MudSaved_Density = ((MudSystemDotChoke_MudSaved_Density * MudSystemDotChoke_Saved_MudDischarged_Volume) + (MudSystemDotChokeLine_Density%Array(ii) * MudSystemDotChokeLine_MudDischarged_Volume%Array(ii))) / (MudSystemDotChoke_Saved_MudDischarged_Volume + MudSystemDotChokeLine_MudDischarged_Volume%Array(ii)) - MudSystemDotChoke_Saved_MudDischarged_Volume = MudSystemDotChoke_Saved_MudDischarged_Volume + MudSystemDotChokeLine_MudDischarged_Volume%Array(ii) - ELSEIF (ChokeLine_MudOrKick%Array(ii) > 0 .AND. ChokeLine_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystemDotChoke_Kick_Saved_Volume = MudSystemDotChoke_Kick_Saved_Volume + MudSystemDotChokeLine_MudDischarged_Volume%Array(ii) - MudSystemDotSaved_Choke_MudOrKick= ChokeLine_MudOrKick%Array (ii) - MudSystemDotChoke_KickSaved_Density= MudSystemDotChokeLine_Density%Array(ii) + do ii= imud + 1, MudSystem%ChokeLine_MudDischarged_Volume%Length() + + IF (MudSystem%ChokeLine_MudOrKick%Array(ii) == 0) THEN + MudSystem%Choke_MudSaved_Density = ((MudSystem%Choke_MudSaved_Density * MudSystem%Choke_Saved_MudDischarged_Volume) + (MudSystem%ChokeLine_Density%Array(ii) * MudSystem%ChokeLine_MudDischarged_Volume%Array(ii))) / (MudSystem%Choke_Saved_MudDischarged_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii)) + MudSystem%Choke_Saved_MudDischarged_Volume = MudSystem%Choke_Saved_MudDischarged_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) + ELSEIF (MudSystem%ChokeLine_MudOrKick%Array(ii) > 0 .AND. MudSystem%ChokeLine_MudOrKick%Array(ii) <100) THEN ! 104= AIR + MudSystem%Choke_Kick_Saved_Volume = MudSystem%Choke_Kick_Saved_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) + MudSystem%Saved_Choke_MudOrKick= MudSystem%ChokeLine_MudOrKick%Array (ii) + MudSystem%Choke_KickSaved_Density= MudSystem%ChokeLine_Density%Array(ii) END IF enddo @@ -1446,8 +1446,8 @@ MudSystemDotimud=0 endif enddo -MudSystemDotChoke_Saved_MudDischarged_Volume_Final= MudSystemDotChoke_Saved_MudDischarged_Volume !+ Choke_Kick_Saved_Volume -MudSystemDotChoke_Kick_Saved_Volume_Final= MudSystemDotChoke_Kick_Saved_Volume +MudSystem%Choke_Saved_MudDischarged_Volume_Final= MudSystem%Choke_Saved_MudDischarged_Volume !+ Choke_Kick_Saved_Volume +MudSystem%Choke_Kick_Saved_Volume_Final= MudSystem%Choke_Kick_Saved_Volume !====================================================================== @@ -1466,13 +1466,13 @@ MudSystemDotChoke_Kick_Saved_Volume_Final= MudSystemDotChoke_Kick_Saved_Volume !========================Choke Line================= -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotChokeLine_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%ChokeLine_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotChokeLine_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotChokeLine_Mud_Forehead_X%Array(MudSystemDotimud-1) - ChokeLine_Mud_Backhead_section%Array(MudSystemDotimud)= ChokeLine_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)= MudSystem%ChokeLine_Mud_Forehead_X%Array(imud-1) + MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)= MudSystem%ChokeLine_Mud_Forehead_section%Array(imud-1) endif @@ -1481,49 +1481,49 @@ MudSystemDotimud=0 ! +1 for string , -1 for annulus - MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= (BopStackSpecification%ChokeLineLength- MudSystemDotChokeLine_Mud_Backhead_X%Array(MudSystemDotimud))* MudSystemDotArea_ChokeLineFt !(ft^3) + MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= (BopStackSpecification%ChokeLineLength- MudSystem%ChokeLine_Mud_Backhead_X%Array(imud))* MudSystem%Area_ChokeLineFt !(ft^3) - MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - ChokeLine_Mud_Forehead_section%Array(MudSystemDotimud)= ChokeLine_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotChokeLine_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotChokeLine_Mud_Backhead_X%Array(MudSystemDotimud)+ (MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_ChokeLineFt + if ( MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) <= MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= MudSystem%ChokeLine_Mud_Backhead_section%Array(imud) + MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)+ (MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_ChokeLineFt ! 7.48 is for gal to ft^3 else - MudSystemDotisection= ChokeLine_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotChokeLine_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)+1 + MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > 1) then ! last pipe section(Chokeline exit) - MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotChokeLine_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotChokeLine_Mud_Forehead_X%Array(MudSystemDotimud)= BopStackSpecification%ChokeLineLength - ChokeLine_Mud_Forehead_section%Array(MudSystemDotimud)= 1 - if (MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string - call MudSystemDotChokeLine_MudDischarged_Volume%Remove (MudSystemDotimud) - call MudSystemDotChokeLine_Mud_Backhead_X%Remove (MudSystemDotimud) - call ChokeLine_Mud_Backhead_section%Remove (MudSystemDotimud) - call MudSystemDotChokeLine_Mud_Forehead_X%Remove (MudSystemDotimud) - call ChokeLine_Mud_Forehead_section%Remove (MudSystemDotimud) - call MudSystemDotChokeLine_Density%Remove (MudSystemDotimud) - call MudSystemDotChokeLine_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) - call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) - call ChokeLine_MudOrKick%Remove (MudSystemDotimud) + if (MudSystem%isection > 1) then ! last pipe section(Chokeline exit) + MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)= MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud) + MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= BopStackSpecification%ChokeLineLength + MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= 1 + if (MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call MudSystem%ChokeLine_MudDischarged_Volume%Remove (imud) + call MudSystem%ChokeLine_Mud_Backhead_X%Remove (imud) + call MudSystem%ChokeLine_Mud_Backhead_section%Remove (imud) + call MudSystem%ChokeLine_Mud_Forehead_X%Remove (imud) + call MudSystem%ChokeLine_Mud_Forehead_section%Remove (imud) + call MudSystem%ChokeLine_Density%Remove (imud) + call MudSystem%ChokeLine_RemainedVolume_in_LastSection%Remove (imud) + call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Remove (imud) + call MudSystem%ChokeLine_MudOrKick%Remove (imud) endif exit endif - MudSystemDotxx= MudSystemDotChokeLine_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotChokeLine_VolumeCapacity !(gal) + MudSystem%xx= MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%ChokeLine_VolumeCapacity !(gal) - if (MudSystemDotxx<= 1.0) then - ChokeLine_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotChokeLine_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotxx * BopStackSpecification%ChokeLineLength + if (MudSystem%xx<= 1.0) then + MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= MudSystem%xx * BopStackSpecification%ChokeLineLength exit else - MudSystemDotChokeLine_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotChokeLine_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotChokeLine_VolumeCapacity - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)- MudSystem%ChokeLine_VolumeCapacity + MudSystem%isection= MudSystem%isection+ 1 endif @@ -1539,17 +1539,17 @@ MudSystemDotimud=0 ! write(*,*) 'b)ChokeLine:', imud, ChokeLine_MudDischarged_Volume%Array(imud) ,ChokeLine_MudOrKick%Array(imud) !enddo - ChokeOutletDensity= MudSystemDotChokeLine_Density%Last() ! used in MudSystem + MudSystem%ChokeOutletDensity= MudSystem%ChokeLine_Density%Last() ! used in MudSystem - do i=1, ChokeLine_MudOrKick%Length() + do i=1, MudSystem%ChokeLine_MudOrKick%Length() !write(*,555) i,'Choke_Volume(i), type=' ,ChokeLine_MudDischarged_Volume%Array(i),ChokeLine_MudOrKick%Array(i) - IF (IEEE_Is_NaN(MudSystemDotChokeLine_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in Choke Volume-Plot') - IF (MudSystemDotChokeLine_MudDischarged_Volume%Array(i)<=0.) call ErrorStop('Choke Volume= <=0' , MudSystemDotChokeLine_MudDischarged_Volume%Array(i)) + IF (IEEE_Is_NaN(MudSystem%ChokeLine_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in Choke Volume-Plot') + IF (MudSystem%ChokeLine_MudDischarged_Volume%Array(i)<=0.) call ErrorStop('Choke Volume= <=0' , MudSystem%ChokeLine_MudDischarged_Volume%Array(i)) enddo 555 FORMAT(I3,5X,A42,(f12.5),5X,I3) @@ -1606,22 +1606,22 @@ use CSounds - if ( ChokeLine_MudOrKick%Last() > 0 .AND. WellToChokeManifoldOpen == .true.) then + if ( MudSystem%ChokeLine_MudOrKick%Last() > 0 .AND. MudSystem%WellToChokeManifoldOpen == .true.) then !WellToChokeManifoldWasOpen - MudSystemDotSoundGasThroughChoke = 100 !100:chon dar adadhaye kamtar az 100 seda ghaat mishavad. eslah shavad.5.8.98 !int (min(ChokeLineFlowRate/2. , 100.)) - print* , 'SoundGasThroughChoke1=', MudSystemDotSoundGasThroughChoke + MudSystem%SoundGasThroughChoke = 100 !100:chon dar adadhaye kamtar az 100 seda ghaat mishavad. eslah shavad.5.8.98 !int (min(ChokeLineFlowRate/2. , 100.)) + print* , 'SoundGasThroughChoke1=', MudSystem%SoundGasThroughChoke !WRITE (*,*) 'WellToChokeManifoldWasOpen-Sound', WellToChokeManifoldWasOpen - WRITE (*,*) 'WellToChokeManifoldOpen', WellToChokeManifoldOpen + WRITE (*,*) 'WellToChokeManifoldOpen', MudSystem%WellToChokeManifoldOpen else - MudSystemDotSoundGasThroughChoke = 0 - print* , 'SoundGasThroughChoke2=', MudSystemDotSoundGasThroughChoke + MudSystem%SoundGasThroughChoke = 0 + print* , 'SoundGasThroughChoke2=', MudSystem%SoundGasThroughChoke endif !print* , 'SoundGasThroughChoke3=', SoundGasThroughChoke - call SetSoundGasThroughChoke(MudSystemDotSoundGasThroughChoke) + call SetSoundGasThroughChoke(MudSystem%SoundGasThroughChoke) end subroutine Choke_GasSound \ No newline at end of file diff --git a/Equipments/MudSystem/Trip_Out_andPump.f90 b/Equipments/MudSystem/Trip_Out_andPump.f90 index d6dd7e5..82ed19e 100644 --- a/Equipments/MudSystem/Trip_Out_andPump.f90 +++ b/Equipments/MudSystem/Trip_Out_andPump.f90 @@ -25,8 +25,8 @@ Real(8) ExcessMudVolume_Remained,SavedDensityForOp !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystemDotStringFlowRate= MUD(2)%Q - MudSystemDotAnnulusFlowRate= MUD(2)%Q + MudSystem%StringFlowRate= MUD(2)%Q + MudSystem%AnnulusFlowRate= MUD(2)%Q !write(*,*) 'MUD(2)%Q=====' , MUD(2)%Q @@ -48,90 +48,90 @@ Real(8) ExcessMudVolume_Remained,SavedDensityForOp !========================Horizontal PIPE ENTRANCE================= - if (ABS(SuctionDensity_Old - Suction_Density_MudSystem) >= MudSystemDotDensityMixTol) then ! new mud is pumped + if (ABS(MudSystem%SuctionDensity_Old - MudSystem%Suction_Density_MudSystem) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystemDotHz_Density%AddToFirst (Suction_Density_MudSystem) - call MudSystemDotHz_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystemDotHz_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(1)) - call Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystemDotHz_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(1)) - call Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystemDotHz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotHz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Hz_MudOrKick%AddToFirst (0) + call MudSystem%Hz_Density%AddToFirst (MudSystem%Suction_Density_MudSystem) + call MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) + call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) + call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) + call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) + call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) + call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Hz_MudOrKick%AddToFirst (0) - SuctionDensity_Old= Suction_Density_MudSystem + MudSystem%SuctionDensity_Old= MudSystem%Suction_Density_MudSystem endif !========================Horizontal PIPE STRING================= - MudSystemDotHz_MudDischarged_Volume%Array(1)= MudSystemDotHz_MudDischarged_Volume%Array(1)+ ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) !(gal) + MudSystem%Hz_MudDischarged_Volume%Array(1)= MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - MudSystemDottotal_add = MudSystemDottotal_add + ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) + MudSystem%total_add = MudSystem%total_add + ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystemDottotal_add= 0. + MudSystem%total_add= 0. endif !write(*,*) ' total decrease(add to HZ)=' , total_add - !write(*,*) ' add to HZ=' , ((StringFlowRate/60.0d0)*DeltaT_Mudline) + !write(*,*) ' add to HZ=' , ((MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotHz_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%Hz_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotHz_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud-1) - Hz_Mud_Backhead_section%Array(MudSystemDotimud)= Hz_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Hz_Mud_Backhead_X%Array(imud)= MudSystem%Hz_Mud_Forehead_X%Array(imud-1) + MudSystem%Hz_Mud_Backhead_section%Array(imud)= MudSystem%Hz_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(Hz_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotHz_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(Hz_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))- MudSystem%Hz_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Hz_Mud_Forehead_section%Array(MudSystemDotimud)= Hz_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotHz_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(Hz_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Hz_MudDischarged_Volume%Array(imud) <= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%Hz_Mud_Backhead_section%Array(imud) + MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Hz_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) else - MudSystemDotisection= Hz_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotHz_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 + MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > 1) then ! (horizontal pipe exit) - MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(1) - Hz_Mud_Forehead_section%Array(MudSystemDotimud)= 1 + if (MudSystem%isection > 1) then ! (horizontal pipe exit) + MudSystem%Hz_MudDischarged_Volume%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(1) + MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 - if (MudSystemDotHz_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveHzMudArrays(MudSystemDotimud) + if (MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call RemoveHzMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Hz_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotHz_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Hz_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotHz_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -148,7 +148,7 @@ MudSystemDotimud=0 !if (UtubeMode1Activated== .true.) then ! StringUpdate == .true. ! - ! StringDensity_Old= St_Density%Array(2) + ! StringDensity_Old= MudSystem%St_Density%Array(2) ! ! UtubeMode1Activated= .false. !endif @@ -158,14 +158,14 @@ MudSystemDotimud=0 !========================Utube2 Removing from Annulus================= - if (MudSystemDotUtubeMode2Activated== .true.) then ! StringUpdate == .true. - MudSystemDotTotalAddedVolume=0. + if (MudSystem%UtubeMode2Activated== .true.) then ! StringUpdate == .true. + MudSystem%TotalAddedVolume=0. - if (Ann_MudOrKick%Last() == 104) then !movaghati. albate age merge anjam shode bashe moshkeli nist - call RemoveAnnulusMudArrays(Ann_MudOrKick%Length()) + if (MudSystem%Ann_MudOrKick%Last() == 104) then !movaghati. albate age merge anjam shode bashe moshkeli nist + call RemoveAnnulusMudArrays(MudSystem%Ann_MudOrKick%Length()) endif - MudSystemDotUtubeMode2Activated= .false. + MudSystem%UtubeMode2Activated= .false. endif @@ -173,25 +173,25 @@ MudSystemDotimud=0 !========================New Pipe Filling================= - if (MudSystemDotAddedElementsToString > 0) then ! StringUpdate == .true. + if (MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. !NoPipeAdded= F_StringIntervalCounts - F_StringIntervalCountsOld - MudSystemDotNewPipeFilling=0 + MudSystem%NewPipeFilling=0 - IF (St_MudOrKick%First() == 104) then - MudSystemDotSt_MudDischarged_Volume%Array(1) = MudSystemDotSt_MudDischarged_Volume%Array(1) + sum(MudSystemDotPipeSection_VolumeCapacity(2:1+MudSystemDotAddedElementsToString)) ! new pipe is filled by air + IF (MudSystem%St_MudOrKick%First() == 104) then + MudSystem%St_MudDischarged_Volume%Array(1) = MudSystem%St_MudDischarged_Volume%Array(1) + sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString)) ! new pipe is filled by air else - call St_Density%AddToFirst (0.d0) - call MudSystemDotSt_MudDischarged_Volume%AddToFirst (sum(MudSystemDotPipeSection_VolumeCapacity(2:1+MudSystemDotAddedElementsToString))) - call MudSystemDotSt_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Forehead_section%AddToFirst (2) - call MudSystemDotSt_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddToFirst (2) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddToFirst (0.d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) - call St_MudOrKick%AddToFirst (104) + call MudSystem%St_Density%AddToFirst (0.d0) + call MudSystem%St_MudDischarged_Volume%AddToFirst (sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString))) + call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) + call MudSystem%St_MudOrKick%AddToFirst (104) endif endif @@ -200,46 +200,46 @@ MudSystemDotimud=0 - if (MudSystemDotNewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) + if (MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) - MudSystemDotLackageMudVolume= MudSystemDotSt_MudDischarged_Volume%Array(1) ! = Air element + MudSystem%LackageMudVolume= MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element !write(*,*) 'LackageMudVolume=' , LackageMudVolume - if (ABS(St_Density%Array(2) - MudSystemDotHz_Density%Last()) >= MudSystemDotDensityMixTol) then ! new mud is pumped - call St_Density%AddTo (2,MudSystemDotHz_Density%Last()) - call MudSystemDotSt_MudDischarged_Volume%AddTo (2,0.d0) - call MudSystemDotSt_Mud_Forehead_X%AddTo (2,MudSystemDotXstart_PipeSection(2)) - call St_Mud_Forehead_section%AddTo (2 , 2) - call MudSystemDotSt_Mud_Backhead_X%AddTo (2,MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddTo (2 ,2) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddTo (2,0.d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) - call St_MudOrKick%AddTo (2,0) + if (ABS(MudSystem%St_Density%Array(2) - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped + call MudSystem%St_Density%AddTo (2,MudSystem%Hz_Density%Last()) + call MudSystem%St_MudDischarged_Volume%AddTo (2,0.d0) + call MudSystem%St_Mud_Forehead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) + call MudSystem%St_Mud_Backhead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) + call MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) + call MudSystem%St_MudOrKick%AddTo (2,0) !StringDensity_Old= Hz_Density%Last() endif - MudSystemDotSt_MudDischarged_Volume%Array(2)= MudSystemDotSt_MudDischarged_Volume%Array(2)+ min( ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline), MudSystemDotLackageMudVolume) !(gal) + MudSystem%St_MudDischarged_Volume%Array(2)= MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) !(gal) - MudSystemDotSt_MudDischarged_Volume%Array(1)= MudSystemDotSt_MudDischarged_Volume%Array(1)- min( ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline), MudSystemDotLackageMudVolume) ! air(gal) + MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)- min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) ! air(gal) !LackageMudVolumeAfterFilling= sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) - sum(St_MudDischarged_Volume%Array(:)) - MudSystemDotLackageMudVolumeAfterFilling= MudSystemDotSt_MudDischarged_Volume%Array(1) ! last time it should be zero + MudSystem%LackageMudVolumeAfterFilling= MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero - if (MudSystemDotLackageMudVolumeAfterFilling == 0.) then - MudSystemDotNewPipeFilling= 1 + if (MudSystem%LackageMudVolumeAfterFilling == 0.) then + MudSystem%NewPipeFilling= 1 call RemoveStringMudArrays(1) - MudSystemDotSt_Mud_Backhead_X%Array(1) = MudSystemDotXstart_PipeSection(2) - St_Mud_Backhead_section%Array(1) = 2 + MudSystem%St_Mud_Backhead_X%Array(1) = MudSystem%Xstart_PipeSection(2) + MudSystem%St_Mud_Backhead_section%Array(1) = 2 endif endif @@ -247,63 +247,60 @@ MudSystemDotimud=0 !========================New Pipe Filling End================= - if (MudSystemDotNewPipeFilling == 0) then - MudSystemDotStringFlowRate= 0. - MudSystemDotAnnulusFlowRate= 0. + if (MudSystem%NewPipeFilling == 0) then + MudSystem%StringFlowRate= 0. + MudSystem%AnnulusFlowRate= 0. endif - MudSystemDotStringFlowRateFinal= MudSystemDotStringFlowRate - MudSystemDotAnnulusFlowRateFinal= MudSystemDotAnnulusFlowRate + MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate + MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate !========================STRING ENTRANCE================= - if (MudSystemDotStringFlowRateFinal > 0.0 .and. ABS(St_Density%First() - MudSystemDotHz_Density%Last()) >= MudSystemDotDensityMixTol) then ! new mud is pumped + if (MudSystem%StringFlowRateFinal > 0.0 .and. ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped !if (ABS(StringDensity_Old - Hz_Density%Last()) >= DensityMixTol) then ! new mud is pumped - call St_Density%AddToFirst (MudSystemDotHz_Density%Last()) - call MudSystemDotSt_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystemDotSt_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Forehead_section%AddToFirst (2) - call MudSystemDotSt_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddToFirst (2) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call St_MudOrKick%AddToFirst (0) + call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density%Last()) + call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) + call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%St_MudOrKick%AddToFirst (0) !StringDensity_Old= Hz_Density%Last() endif - MudSystemDotSt_MudDischarged_Volume%Array(1)= MudSystemDotSt_MudDischarged_Volume%Array(1)+ ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) !(gal) + MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) !=============== save String Mud data=========== - MudSystemDotStMudVolumeSum= 0.d0 + MudSystem%StMudVolumeSum= 0.d0 !St_MudSaved_Density= 0.d0 - MudSystemDotSt_Saved_MudDischarged_Volume= 0.d0 + MudSystem%St_Saved_MudDischarged_Volume= 0.d0 !Saved_St_MudOrKick= 0 !Ann_to_Choke_2mud= .false. - do MudSystemDotimud=1, MudSystemDotSt_MudDischarged_Volume%Length() - - MudSystemDotStMudVolumeSum= MudSystemDotStMudVolumeSum + MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) - - if ( MudSystemDotStMudVolumeSum > sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts)) ) then - + do imud=1, MudSystem%St_MudDischarged_Volume%Length() + MudSystem%StMudVolumeSum= MudSystem%StMudVolumeSum + MudSystem%St_MudDischarged_Volume%Array(imud) + if ( MudSystem%StMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) ) then !IF (St_MudOrKick%Array(imud) == 0) THEN - MudSystemDotSt_MudSaved_Density = St_Density%Array(MudSystemDotimud) - MudSystemDotSt_Saved_MudDischarged_Volume = MudSystemDotStMudVolumeSum - sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts)) + MudSystem%St_MudSaved_Density = MudSystem%St_Density%Array(imud) + MudSystem%St_Saved_MudDischarged_Volume = MudSystem%StMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = StMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ! Saved_St_MudOrKick= St_MudOrKick%Array (imud) - ! St_KickSaved_Density= St_Density%Array(imud) + ! St_KickSaved_Density= MudSystem%St_Density%Array(imud) !END IF - do ii= MudSystemDotimud + 1, MudSystemDotSt_MudDischarged_Volume%Length() + do ii= imud + 1, MudSystem%St_MudDischarged_Volume%Length() !IF (St_MudOrKick%Array(ii) == 0) THEN - MudSystemDotSt_MudSaved_Density = ((MudSystemDotSt_MudSaved_Density * MudSystemDotSt_Saved_MudDischarged_Volume) + (St_Density%Array(ii) * MudSystemDotSt_MudDischarged_Volume%Array(ii))) / (MudSystemDotSt_Saved_MudDischarged_Volume + MudSystemDotSt_MudDischarged_Volume%Array(ii)) - MudSystemDotSt_Saved_MudDischarged_Volume = MudSystemDotSt_Saved_MudDischarged_Volume + MudSystemDotSt_MudDischarged_Volume%Array(ii) + MudSystem%St_MudSaved_Density = ((MudSystem%St_MudSaved_Density * MudSystem%St_Saved_MudDischarged_Volume) + (MudSystem%St_Density%Array(ii) * MudSystem%St_MudDischarged_Volume%Array(ii))) / (MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii)) + MudSystem%St_Saved_MudDischarged_Volume = MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = St_Kick_Saved_Volume + St_MudDischarged_Volume%Array(ii) ! Saved_St_MudOrKick= St_MudOrKick%Array (ii) - ! St_KickSaved_Density= St_Density%Array(ii) + ! St_KickSaved_Density= MudSystem%St_Density%Array(ii) !END IF enddo @@ -314,65 +311,65 @@ MudSystemDotimud=0 endif enddo -MudSystemDotSt_Saved_MudDischarged_Volume_Final= MudSystemDotSt_Saved_MudDischarged_Volume +MudSystem%St_Saved_MudDischarged_Volume_Final= MudSystem%St_Saved_MudDischarged_Volume -IF (WellHeadIsOpen) MudSystemDotMudVolume_InjectedToBH = MudSystemDotSt_Saved_MudDischarged_Volume_Final +IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final !====================================================================== !========================STRING================= -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotSt_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%St_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud-1) - St_Mud_Backhead_section%Array(MudSystemDotimud)= St_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) + MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(St_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - St_Mud_Forehead_section%Array(MudSystemDotimud)= St_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(St_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) + MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= St_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > F_StringIntervalCounts) then ! last pipe section(string exit) - MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(F_StringIntervalCounts) - St_Mud_Forehead_section%Array(MudSystemDotimud)= F_StringIntervalCounts + if (MudSystem%isection > F_StringIntervalCounts) then ! last pipe section(string exit) + MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_StringIntervalCounts) + MudSystem%St_Mud_Forehead_section%Array(imud)= F_StringIntervalCounts - if (MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(MudSystemDotimud) + if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call RemoveStringMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - St_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -402,17 +399,17 @@ MudSystemDotimud=0 iloc_changedTo2 = 0 - IF (Op_MudOrKick%Last() /= 0 .and. Op_MudOrKick%Last()==Ann_MudOrKick%First()) then - MudSystemDotiLoc=2 ! it may be 1,2,3 or more, all of them are kick + IF (MudSystem%Op_MudOrKick%Last() /= 0 .and. MudSystem%Op_MudOrKick%Last()==MudSystem%Ann_MudOrKick%First()) then + MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick iloc_changedTo2= 1 endif iloc_edited= 0 - !write(*,*) sum(Op_MudDischarged_Volume%Array(:)) , ((AnnulusFlowRate/60.d0)*DeltaT_Mudline) , Ann_MudDischarged_Volume%First() , sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - if (MudSystemDotiLoc==2 .and. sum(MudSystemDotOp_MudDischarged_Volume%Array(:))+((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline)+MudSystemDotAnn_MudDischarged_Volume%First() < sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then - MudSystemDotiLoc = 1 + !write(*,*) sum(Op_MudDischarged_Volume%Array(:)) , ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) , Ann_MudDischarged_Volume%First() , sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) + if (MudSystem%iLoc==2 .and. sum(MudSystem%Op_MudDischarged_Volume%Array(:))+((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)+MudSystem%Ann_MudDischarged_Volume%First() < sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then + MudSystem%iLoc = 1 iloc_edited = 1 !write(*,*) 'hellooooooo' endif @@ -426,45 +423,45 @@ MudSystemDotimud=0 !=============================Add PumpFlowRate to Bottom Hole ============================== - !if ( AnnulusFlowRate>0.0 ) then - if ( MudSystemDotMudVolume_InjectedToBH > 0.0 ) then + !if ( MudSystem%AnnulusFlowRate>0.0 ) then + if ( MudSystem%MudVolume_InjectedToBH > 0.0 ) then if (KickOffBottom) then ! (kickOffBottom = F) means kick is next to the bottom hole and usually kick is entering the - AddLocation= MudSystemDotOp_Density%Length()-MudSystemDotiLoc+1+1 ! well, thus pumped mud should be placed above the kick + AddLocation= MudSystem%Op_Density%Length()-MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick else - AddLocation= MudSystemDotOp_Density%Length()+1 + AddLocation= MudSystem%Op_Density%Length()+1 endif !write(*,*) 'AddLocation====' , AddLocation if ( AddLocation== 0) CALL ErrorStop ('AddLocation=0') - if ( ABS(St_Density%Last() - MudSystemDotOp_Density%Array(AddLocation-1)) >= MudSystemDotDensityMixTol ) then + if ( ABS(MudSystem%St_Density%Last() - MudSystem%Op_Density%Array(AddLocation-1)) >= MudSystem%DensityMixTol ) then !write(*,*) 'new pocket**' - !write(*,*) 'St_Density%Last()=' , St_Density%Last() + !write(*,*) 'MudSystem%St_Density%Last()=' , MudSystem%St_Density%Last() !write(*,*) 'Op_Density%Array(AddLocation-1)=' , Op_Density%Array(AddLocation-1) - call MudSystemDotOp_Density% AddTo (AddLocation,St_Density%Last()) - !call Op_MudDischarged_Volume%AddTo (AddLocation,((AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - call MudSystemDotOp_MudDischarged_Volume%AddTo (AddLocation,MudSystemDotMudVolume_InjectedToBH) - call MudSystemDotOp_Mud_Forehead_X%AddTo (AddLocation,MudSystemDotXstart_OpSection(1)) - call Op_Mud_Forehead_section%AddTo (AddLocation,1) - call MudSystemDotOp_Mud_Backhead_X%AddTo (AddLocation,MudSystemDotXstart_OpSection(1)) - call Op_Mud_Backhead_section%AddTo (AddLocation,1) - call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) - call Op_MudOrKick%AddTo (AddLocation,0) + call MudSystem%Op_Density% AddTo (AddLocation,MudSystem%St_Density%Last()) + !call Op_MudDischarged_Volume%AddTo (AddLocation,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + call MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,MudSystem%MudVolume_InjectedToBH) + call MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) + call MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) + call MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) + call MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) + call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) + call MudSystem%Op_MudOrKick%AddTo (AddLocation,0) else !write(*,*) 'merge**' !write(*,*) 'density before=' , Op_Density%Array(AddLocation-1) - !write(*,*) 'St_Density%Last() for mix=' , St_Density%Last() + !write(*,*) 'MudSystem%St_Density%Last() for mix=' , MudSystem%St_Density%Last() - !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)+St_Density%Last()*((AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((AnnulusFlowRate/60.d0)*DeltaT_Mudline) + !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Density%Array(AddLocation-1)= (MudSystemDotOp_Density%Array(AddLocation-1)*MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1)+St_Density%Last()*MudSystemDotMudVolume_InjectedToBH)/(MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1)+MudSystemDotMudVolume_InjectedToBH) - MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1)= MudSystemDotOp_MudDischarged_Volume%Array(AddLocation-1) + MudSystemDotMudVolume_InjectedToBH + MudSystem%Op_Density%Array(AddLocation-1)= (MudSystem%Op_Density%Array(AddLocation-1)*MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*MudSystem%MudVolume_InjectedToBH)/(MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%MudVolume_InjectedToBH) + MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + MudSystem%MudVolume_InjectedToBH !write(*,*) 'density after=' , Op_Density%Array(AddLocation-1) endif @@ -491,44 +488,44 @@ MudSystemDotimud=0 !=============== save OP Mud data to transfer to the annulus enterance due to tripin or kick - MudSystemDotOpMudVolumeSum= 0.d0 + MudSystem%OpMudVolumeSum= 0.d0 !Op_MudSaved_Density= 0.d0 !Op_KickSaved_Density= 0.d0 - MudSystemDotOp_Saved_MudDischarged_Volume= 0.d0 - MudSystemDotOp_Kick_Saved_Volume= 0.d0 - MudSystemDotSaved_Op_MudOrKick= 0 - MudSystemDotOp_NeededVolume_ToFill= 0.d0 + MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 + MudSystem%Op_Kick_Saved_Volume= 0.d0 + MudSystem%Saved_Op_MudOrKick= 0 + MudSystem%Op_NeededVolume_ToFill= 0.d0 - do MudSystemDotimud=1, MudSystemDotOp_MudDischarged_Volume%Length() + do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - MudSystemDotOpMudVolumeSum= MudSystemDotOpMudVolumeSum + MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud) + MudSystem%OpMudVolumeSum= MudSystem%OpMudVolumeSum + MudSystem%Op_MudDischarged_Volume%Array(imud) - if ( MudSystemDotOpMudVolumeSum > sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then !1st mode + if ( MudSystem%OpMudVolumeSum > sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then !1st mode - IF (Op_MudOrKick%Array(MudSystemDotimud) == 0) THEN - MudSystemDotOp_MudSaved_Density = MudSystemDotOp_Density%Array(MudSystemDotimud) - MudSystemDotOp_Saved_MudDischarged_Volume = MudSystemDotOpMudVolumeSum - sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) + IF (MudSystem%Op_MudOrKick%Array(imud) == 0) THEN + MudSystem%Op_MudSaved_Density = MudSystem%Op_Density%Array(imud) + MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ELSE - MudSystemDotOp_Kick_Saved_Volume = MudSystemDotOpMudVolumeSum - sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - MudSystemDotSaved_Op_MudOrKick= Op_MudOrKick%Array (MudSystemDotimud) - MudSystemDotOp_KickSaved_Density= MudSystemDotOp_Density%Array(MudSystemDotimud) - MudSystemDotiLoc= 2 + MudSystem%Op_Kick_Saved_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) + MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (imud) + MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(imud) + MudSystem%iLoc= 2 iloc_changedTo2= 2 END IF - do ii= MudSystemDotimud + 1, MudSystemDotOp_MudDischarged_Volume%Length() - IF (Op_MudOrKick%Array(ii) == 0) THEN - MudSystemDotOp_MudSaved_Density = ((MudSystemDotOp_MudSaved_Density * MudSystemDotOp_Saved_MudDischarged_Volume) + (MudSystemDotOp_Density%Array(ii) * MudSystemDotOp_MudDischarged_Volume%Array(ii))) / (MudSystemDotOp_Saved_MudDischarged_Volume + MudSystemDotOp_MudDischarged_Volume%Array(ii)) - MudSystemDotOp_Saved_MudDischarged_Volume = MudSystemDotOp_Saved_MudDischarged_Volume + MudSystemDotOp_MudDischarged_Volume%Array(ii) + do ii= imud + 1, MudSystem%Op_MudDischarged_Volume%Length() + IF (MudSystem%Op_MudOrKick%Array(ii) == 0) THEN + MudSystem%Op_MudSaved_Density = ((MudSystem%Op_MudSaved_Density * MudSystem%Op_Saved_MudDischarged_Volume) + (MudSystem%Op_Density%Array(ii) * MudSystem%Op_MudDischarged_Volume%Array(ii))) / (MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii)) + MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) ELSE - MudSystemDotOp_Kick_Saved_Volume = MudSystemDotOp_Kick_Saved_Volume + MudSystemDotOp_MudDischarged_Volume%Array(ii) - MudSystemDotSaved_Op_MudOrKick= Op_MudOrKick%Array (ii) - MudSystemDotOp_KickSaved_Density= MudSystemDotOp_Density%Array(ii) - MudSystemDotiLoc= 2 + MudSystem%Op_Kick_Saved_Volume = MudSystem%Op_Kick_Saved_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) + MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (ii) + MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(ii) + MudSystem%iLoc= 2 iloc_changedTo2= 3 END IF enddo @@ -539,9 +536,9 @@ MudSystemDotimud=0 enddo - if ( sum(MudSystemDotOp_MudDischarged_Volume%Array(:)) < sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then !2nd & 3rd mode + if ( sum(MudSystem%Op_MudDischarged_Volume%Array(:)) < sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) ) then !2nd & 3rd mode - MudSystemDotOp_NeededVolume_ToFill= sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - sum(MudSystemDotOp_MudDischarged_Volume%Array(:)) + MudSystem%Op_NeededVolume_ToFill= sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - sum(MudSystem%Op_MudDischarged_Volume%Array(:)) endif @@ -566,52 +563,52 @@ MudSystemDotimud=0 - if ( (MudSystemDotOp_Kick_Saved_Volume > 0.0 .or. MudSystemDotOp_Saved_MudDischarged_Volume> 0.0) .or. & ! 1st Mode-Pump flow is more than trip out so fluid Level in Annulus Increases - (MudSystemDotOp_NeededVolume_ToFill < ABS(MudSystemDotDeltaVolumeAnnulusCapacity)) ) then !3rd Mode-fluid Level in Annulus Increases + if ( (MudSystem%Op_Kick_Saved_Volume > 0.0 .or. MudSystem%Op_Saved_MudDischarged_Volume> 0.0) .or. & ! 1st Mode-Pump flow is more than trip out so fluid Level in Annulus Increases + (MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity)) ) then !3rd Mode-fluid Level in Annulus Increases !if ( Op_Kick_Saved_Volume > 0.0 .or. Op_Saved_MudDischarged_Volume> 0.0 ) write(*,*) 'trip out 1st mode' - if ( MudSystemDotOp_NeededVolume_ToFill > 0.0 .and. MudSystemDotOp_NeededVolume_ToFill < ABS(MudSystemDotDeltaVolumeAnnulusCapacity) ) then + if ( MudSystem%Op_NeededVolume_ToFill > 0.0 .and. MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity) ) then ! write(*,*) 'trip out 3rd mode' - MudSystemDotNewVolume= 0.d0 ! for condition iloc=1 + MudSystem%NewVolume= 0.d0 ! for condition iloc=1 - SavedDensityForOp= Ann_Density%Array(1) + SavedDensityForOp= MudSystem%Ann_Density%Array(1) - ExcessMudVolume_Remained= MudSystemDotOp_NeededVolume_ToFill + ExcessMudVolume_Remained= MudSystem%Op_NeededVolume_ToFill - MudSystemDotimud=1 + imud=1 Do - if(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) < ExcessMudVolume_Remained) then - ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) - call MudSystemDotAnn_MudDischarged_Volume%Remove (MudSystemDotimud) - call Ann_Mud_Backhead_X%Remove (MudSystemDotimud) - call Ann_Mud_Backhead_section%Remove (MudSystemDotimud) - call Ann_Mud_Forehead_X%Remove (MudSystemDotimud) - call Ann_Mud_Forehead_section%Remove (MudSystemDotimud) - call Ann_Density%Remove (MudSystemDotimud) - call Ann_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) - call Ann_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) - call Ann_MudOrKick%Remove (MudSystemDotimud) + if(MudSystem%Ann_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then + ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystem%Ann_MudDischarged_Volume%Array(imud) + call MudSystem%Ann_MudDischarged_Volume%Remove (imud) + call MudSystem%Ann_Mud_Backhead_X%Remove (imud) + call MudSystem%Ann_Mud_Backhead_section%Remove (imud) + call MudSystem%Ann_Mud_Forehead_X%Remove (imud) + call MudSystem%Ann_Mud_Forehead_section%Remove (imud) + call MudSystem%Ann_Density%Remove (imud) + call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) + call MudSystem%Ann_MudOrKick%Remove (imud) - elseif(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) > ExcessMudVolume_Remained) then - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- ExcessMudVolume_Remained + elseif(MudSystem%Ann_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained exit else !(Ann_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) - call MudSystemDotAnn_MudDischarged_Volume%Remove (MudSystemDotimud) - call Ann_Mud_Backhead_X%Remove (MudSystemDotimud) - call Ann_Mud_Backhead_section%Remove (MudSystemDotimud) - call Ann_Mud_Forehead_X%Remove (MudSystemDotimud) - call Ann_Mud_Forehead_section%Remove (MudSystemDotimud) - call Ann_Density%Remove (MudSystemDotimud) - call Ann_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) - call Ann_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) - call Ann_MudOrKick%Remove (MudSystemDotimud) + call MudSystem%Ann_MudDischarged_Volume%Remove (imud) + call MudSystem%Ann_Mud_Backhead_X%Remove (imud) + call MudSystem%Ann_Mud_Backhead_section%Remove (imud) + call MudSystem%Ann_Mud_Forehead_X%Remove (imud) + call MudSystem%Ann_Mud_Forehead_section%Remove (imud) + call MudSystem%Ann_Density%Remove (imud) + call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) + call MudSystem%Ann_MudOrKick%Remove (imud) exit endif @@ -629,11 +626,11 @@ MudSystemDotimud=0 endif - ! (AnnulusFlowRate/60.)*DeltaT_Mudline) - DeltaVolumeOp will be added to annulus + ! (MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) - DeltaVolumeOp will be added to annulus !if (iLoc == 1) then - MudSystemDotMudSection= F_StringIntervalCounts+1 - MudSystemDotBackheadX= MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1) + MudSystem%MudSection= F_StringIntervalCounts+1 + MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1) !elseif (iLoc == 2) then ! MudSection= Kick_Forehead_section ! BackheadX= Kick_Forehead_X @@ -641,8 +638,8 @@ MudSystemDotimud=0 !========================ANNULUS ENTRANCE==================== !if (KickMigration_2SideBit == .FALSE.) then - ! if ( ABS(AnnulusSuctionDensity_Old - St_Density%Last()) >= DensityMixTol ) then ! new mud is pumped - ! call Ann_Density%AddTo (iLoc,St_Density%Last()) + ! if ( ABS(AnnulusSuctionDensity_Old - MudSystem%St_Density%Last()) >= DensityMixTol ) then ! new mud is pumped + ! call Ann_Density%AddTo (iLoc,MudSystem%St_Density%Last()) ! call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0) ! call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) ! call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection) @@ -653,20 +650,20 @@ MudSystemDotimud=0 ! call Ann_MudOrKick%AddTo (iLoc,0) ! call Ann_CuttingMud%AddTo (iLoc,0) ! - ! AnnulusSuctionDensity_Old= St_Density%Last() + ! AnnulusSuctionDensity_Old= MudSystem%St_Density%Last() ! ! MudIsChanged= .true. ! endif ! - ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) - ((2-iloc)*ABS(DeltaVolumePipe)) !(gal) + ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) - ((2-iloc)*ABS(DeltaVolumePipe)) !(gal) ! !endif - Ann_Mud_Backhead_section%Array(1)= MudSystemDotMudSection !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) - Ann_Mud_Backhead_X%Array(1)= MudSystemDotBackheadX + MudSystem%Ann_Mud_Backhead_section%Array(1)= MudSystem%MudSection !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) + MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%BackheadX @@ -678,67 +675,67 @@ MudSystemDotimud=0 !write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume - if (MudSystemDotOp_Kick_Saved_Volume > 0.0 .and. Ann_MudOrKick%First() == 0) then !1st Mode + if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then !1st Mode write(*,*) 'Kick influx enters Annulus' - call Ann_Density%AddToFirst (MudSystemDotOp_KickSaved_Density) - call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotOp_Kick_Saved_Volume) - call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) - call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call Ann_MudOrKick%AddToFirst (MudSystemDotSaved_Op_MudOrKick) !<<<<<<<< - call Ann_CuttingMud%AddToFirst (0) - elseif (MudSystemDotOp_Kick_Saved_Volume > 0.0 .and. Ann_MudOrKick%First() /= 0) then - MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) + MudSystemDotOp_Kick_Saved_Volume + call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) + call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) + call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1)) + call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< + call MudSystem%Ann_CuttingMud%AddToFirst (0) + elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then + MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume endif - if ( MudSystemDotOp_NeededVolume_ToFill > 0.0 .and. (MudSystemDotOp_NeededVolume_ToFill < ABS(MudSystemDotDeltaVolumeAnnulusCapacity)) .and. Op_MudOrKick%Last() == 0 .and. (MudSystemDotiLoc==2 .or. iloc_edited==1)) then !3rd Mode + if ( MudSystem%Op_NeededVolume_ToFill > 0.0 .and. (MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity)) .and. MudSystem%Op_MudOrKick%Last() == 0 .and. (MudSystem%iLoc==2 .or. iloc_edited==1)) then !3rd Mode !write(*,*) 'checkpoint 0' !! for avoid kick separation -Op_MudOrKick%Last() == 0: because of pump - MudSystemDotNewVolume= ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) ! =volume that should be added to iloc=2 in Ann - call RemoveOpMudArrays(MudSystemDotOp_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann in %%1 section - if ( MudSystemDotAnn_MudDischarged_Volume%Array(1) > ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) ) then! 1st in Ann = kick ,, we expect: ((AnnulusFlowRate/60.d0)*DeltaT_Mudline)= OpMudVolLast - MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) - ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())+ ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) ! kick + MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ! =volume that should be added to iloc=2 in Ann + call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann in %%1 section + if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ) then! 1st in Ann = kick ,, we expect: ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)= OpMudVolLast + MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ! kick else call RemoveAnnulusMudArrays(1) !kick is removed - MudSystemDotiLoc= 1 - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())+ ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) + MudSystem%iLoc= 1 + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) write(*,*) 'little expand' ! including a little expand endif endif - if (MudSystemDotOp_Saved_MudDischarged_Volume> 0.0) then !1st Mode - NewDensity= MudSystemDotOp_MudSaved_Density - !write(*,*) 'iloc,...' , iloc,((AnnulusFlowRate/60.d0)*DeltaT_Mudline),Op_Saved_MudDischarged_Volume - if (MudSystemDotiLoc==1) then + if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then !1st Mode + MudSystem%NewDensity= MudSystem%Op_MudSaved_Density + !write(*,*) 'iloc,...' , iloc,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline),Op_Saved_MudDischarged_Volume + if (MudSystem%iLoc==1) then !write(*,*) 'checkpoint 1' - MudSystemDotNewVolume= MudSystemDotOp_Saved_MudDischarged_Volume - elseif (real(((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline)) - real(MudSystemDotOp_Saved_MudDischarged_Volume) > 0.d0 ) then ! for avoid kick separation + MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume + elseif (real(((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)) - real(MudSystem%Op_Saved_MudDischarged_Volume) > 0.d0 ) then ! for avoid kick separation !write(*,*) 'checkpoint 2' - MudSystemDotNewVolume= ((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) !- Op_Saved_MudDischarged_Volume - call RemoveOpMudArrays(MudSystemDotOp_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann - if ( MudSystemDotAnn_MudDischarged_Volume%Array(1) > (((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Saved_MudDischarged_Volume) ) then! 1st in Ann = kick - MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) - (((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Saved_MudDischarged_Volume) - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())+ (((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Saved_MudDischarged_Volume) !kick + MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) !- Op_Saved_MudDischarged_Volume + call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann + if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) ) then! 1st in Ann = kick + MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) !kick else call RemoveAnnulusMudArrays(1) !kick is removed - MudSystemDotiLoc =1 - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_Density%Length())+ (((MudSystemDotAnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystemDotOp_Saved_MudDischarged_Volume) + MudSystem%iLoc =1 + MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) write(*,*) 'little expand' ! including a little expand endif - else ! iloc==2 , ((AnnulusFlowRate/60.d0)*DeltaT_Mudline) == Op_Saved_MudDischarged_Volume + else ! iloc==2 , ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) == Op_Saved_MudDischarged_Volume !write(*,*) 'checkpoint 3' - MudSystemDotNewVolume= MudSystemDotOp_Saved_MudDischarged_Volume ! it is normal mode + MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume ! it is normal mode endif @@ -747,23 +744,23 @@ MudSystemDotimud=0 !write(*,*) 'NewVolume=' ,NewVolume - if( Ann_Density%Length() == 1 .and. MudSystemDotiLoc ==2 ) then + if( MudSystem%Ann_Density%Length() == 1 .and. MudSystem%iLoc ==2 ) then write(*,*) '***errorb****==' write(*,*) 'iloc_edited=' , iloc_edited write(*,*) 'iloc_changedTo2=' , iloc_changedTo2 - write(*,*) 'Op_Capacity===' , sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) + write(*,*) 'Op_Capacity===' , sum(MudSystem%OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - WRITE (*,*) 'Op_Saved_MudDischarged_Volume, Op_Kick_Saved_Volume',MudSystemDotOp_Saved_MudDischarged_Volume, MudSystemDotOp_Kick_Saved_Volume + WRITE (*,*) 'Op_Saved_MudDischarged_Volume, Op_Kick_Saved_Volume',MudSystem%Op_Saved_MudDischarged_Volume, MudSystem%Op_Kick_Saved_Volume - do MudSystemDotimud=1, MudSystemDotOp_MudDischarged_Volume%Length() - write(*,*) 'Op:', MudSystemDotimud, MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud), MudSystemDotOp_Density%Array(MudSystemDotimud) ,Op_MudOrKick%Array(MudSystemDotimud) + do imud=1, MudSystem%Op_MudDischarged_Volume%Length() + write(*,*) 'Op:', imud, MudSystem%Op_MudDischarged_Volume%Array(imud), MudSystem%Op_Density%Array(imud) ,MudSystem%Op_MudOrKick%Array(imud) enddo - do MudSystemDotimud=1, MudSystemDotAnn_MudDischarged_Volume%Length() - write(*,*) 'Ann:', MudSystemDotimud, MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud), Ann_Density%Array(MudSystemDotimud) ,Ann_MudOrKick%Array(MudSystemDotimud) + do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() + write(*,*) 'Ann:', imud, MudSystem%Ann_MudDischarged_Volume%Array(imud), MudSystem%Ann_Density%Array(imud) ,MudSystem%Ann_MudOrKick%Array(imud) enddo @@ -775,31 +772,31 @@ MudSystemDotimud=0 - if ((Rate_of_Penetration==0 .and. abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotDensityMixTol) & !%%1 section - .or. (Rate_of_Penetration>0. .and. Ann_CuttingMud%Array(MudSystemDotiLoc)==1 .and. abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotCuttingDensityMixTol) & - .or. (Rate_of_Penetration>0. .and. Ann_CuttingMud%Array(MudSystemDotiLoc)==0 .and. MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc) < 42.) ) then ! 1-Pockets are Merged + if ((Rate_of_Penetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & !%%1 section + .or. (Rate_of_Penetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & + .or. (Rate_of_Penetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged !write(*,*) '%%1 section a)' - Ann_Density%Array(MudSystemDotiLoc)= (Ann_Density%Array(MudSystemDotiLoc)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume - Ann_Mud_Forehead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Forehead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_Mud_Backhead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Backhead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotiLoc)= (0.0d0) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotiLoc)= (0.0d0) + MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket !write(*,*) '%%1 section b)' - call Ann_Density%AddTo (MudSystemDotiLoc,NewDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotiLoc,MudSystemDotNewVolume) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotiLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotiLoc,0) + call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) !write(*,*) 'd) annLength=' , Ann_Density%Length() endif @@ -829,41 +826,41 @@ MudSystemDotimud=0 !write(*,*) '2======no' !=============== save Ann Mud data to transfer to the ChokeLine enterance - MudSystemDotAnnMudVolumeSum= 0.d0 + MudSystem%AnnMudVolumeSum= 0.d0 !Ann_MudSaved_Density= 0.d0 !Ann_KickSaved_Density= 0.d0 - MudSystemDotAnn_Saved_MudDischarged_Volume= 0.d0 - MudSystemDotAnn_Kick_Saved_Volume= 0.d0 - MudSystemDotSaved_Ann_MudOrKick= 0 - MudSystemDotAnn_to_Choke_2mud= .false. + MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 + MudSystem%Ann_Kick_Saved_Volume= 0.d0 + MudSystem%Saved_Ann_MudOrKick= 0 + MudSystem%Ann_to_Choke_2mud= .false. - do MudSystemDotimud=1, MudSystemDotAnn_MudDischarged_Volume%Length() + do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - MudSystemDotAnnMudVolumeSum= MudSystemDotAnnMudVolumeSum + MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) + MudSystem%AnnMudVolumeSum= MudSystem%AnnMudVolumeSum + MudSystem%Ann_MudDischarged_Volume%Array(imud) - if ( MudSystemDotAnnMudVolumeSum > sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) ) then + if ( MudSystem%AnnMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) ) then - IF (Ann_MudOrKick%Array(MudSystemDotimud) == 0) THEN - MudSystemDotAnn_MudSaved_Density = Ann_Density%Array(MudSystemDotimud) - MudSystemDotAnn_Saved_MudDischarged_Volume = MudSystemDotAnnMudVolumeSum - sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) - ELSEIF (Ann_MudOrKick%Array(MudSystemDotimud) > 0 .AND. Ann_MudOrKick%Array(MudSystemDotimud) <100) THEN ! 104= AIR - MudSystemDotAnn_Kick_Saved_Volume = MudSystemDotAnnMudVolumeSum - sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) - MudSystemDotSaved_Ann_MudOrKick= Ann_MudOrKick%Array (MudSystemDotimud) - MudSystemDotAnn_KickSaved_Density= Ann_Density%Array(MudSystemDotimud) + IF (MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN + MudSystem%Ann_MudSaved_Density = MudSystem%Ann_Density%Array(imud) + MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) + ELSEIF (MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR + MudSystem%Ann_Kick_Saved_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystem%NoPipeSections)) + MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (imud) + MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(imud) END IF - do ii= MudSystemDotimud + 1, MudSystemDotAnn_MudDischarged_Volume%Length() - IF (Ann_MudOrKick%Array(ii) == 0) THEN - MudSystemDotAnn_MudSaved_Density = ((MudSystemDotAnn_MudSaved_Density * MudSystemDotAnn_Saved_MudDischarged_Volume) + (Ann_Density%Array(ii) * MudSystemDotAnn_MudDischarged_Volume%Array(ii))) / (MudSystemDotAnn_Saved_MudDischarged_Volume + MudSystemDotAnn_MudDischarged_Volume%Array(ii)) - MudSystemDotAnn_Saved_MudDischarged_Volume = MudSystemDotAnn_Saved_MudDischarged_Volume + MudSystemDotAnn_MudDischarged_Volume%Array(ii) - MudSystemDotAnn_to_Choke_2mud= .true. - ELSEIF (Ann_MudOrKick%Array(ii) > 0 .AND. Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystemDotAnn_Kick_Saved_Volume = MudSystemDotAnn_Kick_Saved_Volume + MudSystemDotAnn_MudDischarged_Volume%Array(ii) - MudSystemDotSaved_Ann_MudOrKick= Ann_MudOrKick%Array (ii) - MudSystemDotAnn_KickSaved_Density= Ann_Density%Array(ii) + do ii= imud + 1, MudSystem%Ann_MudDischarged_Volume%Length() + IF (MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN + MudSystem%Ann_MudSaved_Density = ((MudSystem%Ann_MudSaved_Density * MudSystem%Ann_Saved_MudDischarged_Volume) + (MudSystem%Ann_Density%Array(ii) * MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii)) + MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) + MudSystem%Ann_to_Choke_2mud= .true. + ELSEIF (MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR + MudSystem%Ann_Kick_Saved_Volume = MudSystem%Ann_Kick_Saved_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) + MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (ii) + MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(ii) END IF enddo @@ -873,12 +870,12 @@ MudSystemDotimud=0 enddo -MudSystemDotAnn_Saved_MudDischarged_Volume_Final= MudSystemDotAnn_Saved_MudDischarged_Volume -MudSystemDotAnn_Kick_Saved_Volume_Final= MudSystemDotAnn_Kick_Saved_Volume +MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume +MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) !write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) -IF (WellHeadIsOpen) MudVolume_InjectedFromAnn = MudSystemDotAnn_Saved_MudDischarged_Volume_Final-((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) +IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !NoGasPocket !write(*,*) 'Ann_Saved_Mud_Vol,Ann_Kick_Saved_Vol=' , Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume @@ -890,62 +887,62 @@ IF (WellHeadIsOpen) MudVolume_InjectedFromAnn = MudSystemDotAnn_Saved_MudD !MudIsChanged= .false. -MudSystemDotimud= 0 +imud= 0 - do while (MudSystemDotimud < Ann_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 + do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= Ann_Mud_Forehead_X%Array(MudSystemDotimud-1) - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= Ann_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) + MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) endif ! write(*,*) 'imud==' , imud !write(*,*) '***)Ann_Mud_Backhead_section(imud)= ' , Ann_Mud_Backhead_section%Array(imud), Ann_density%Array(imud) - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))- Ann_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(Ann_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) <= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= Ann_Mud_Backhead_section%Array(MudSystemDotimud) - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= Ann_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(Ann_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= Ann_Mud_Backhead_section%Array(MudSystemDotimud)+1 - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > MudSystemDotNoPipeSections) then ! last pipe section(well exit) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections) - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotNoPipeSections + if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(MudSystemDotimud) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystemDotxx= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -955,8 +952,8 @@ MudSystemDotimud= 0 enddo - if (Ann_Mud_Forehead_X%Last() < MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections)) then - Ann_Mud_Forehead_X%Array(Ann_Mud_Forehead_X%Length()) = MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections) ! for error preventing + if (MudSystem%Ann_Mud_Forehead_X%Last() < MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) then + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length()) = MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) ! for error preventing endif !========================ANNULUS END================= @@ -968,70 +965,70 @@ MudSystemDotimud= 0 !========================Tripping Out- 2nd Mode==================== - elseif ( MudSystemDotOp_NeededVolume_ToFill > ABS(MudSystemDotDeltaVolumeAnnulusCapacity) ) then !pump is off or Pump flow is less than trip out so fluid Level in Annulus decreases + elseif ( MudSystem%Op_NeededVolume_ToFill > ABS(MudSystem%DeltaVolumeAnnulusCapacity) ) then !pump is off or Pump flow is less than trip out so fluid Level in Annulus decreases !write(*,*) 'trip out 2nd mode' - SavedDensityForOp= Ann_Density%Array(1) + SavedDensityForOp= MudSystem%Ann_Density%Array(1) !========================ANNULUS ENTRANCE==================== ! <<< SIMILAR TO UTUBE 2 >>> - if ( Ann_Density%Last() /= 0.0 ) then ! new mud is pumped - call Ann_Density%Add (0.0d0) - call MudSystemDotAnn_MudDischarged_Volume%Add (0.0d0) - call Ann_Mud_Forehead_X%Add (MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections)) - call Ann_Mud_Forehead_section%Add (MudSystemDotNoPipeSections) - call Ann_Mud_Backhead_X%Add (MudSystemDotXstart_PipeSection(MudSystemDotNoPipeSections)) - call Ann_Mud_Backhead_section%Add (MudSystemDotNoPipeSections) - call Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call Ann_MudOrKick%Add (104) - call Ann_CuttingMud%Add (0) + if ( MudSystem%Ann_Density%Last() /= 0.0 ) then ! new mud is pumped + call MudSystem%Ann_Density%Add (0.0d0) + call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) + call MudSystem%Ann_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) + call MudSystem%Ann_Mud_Forehead_section%Add (MudSystem%NoPipeSections) + call MudSystem%Ann_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(MudSystem%NoPipeSections)) + call MudSystem%Ann_Mud_Backhead_section%Add (MudSystem%NoPipeSections) + call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) + call MudSystem%Ann_MudOrKick%Add (104) + call MudSystem%Ann_CuttingMud%Add (0) !AnnulusSuctionDensity_Old= Hz_Density%Last() endif - Ann_Mud_Forehead_section%Array(Ann_Mud_Forehead_section%Length())= MudSystemDotNoPipeSections !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) - Ann_Mud_Forehead_X%Array(Ann_Mud_Forehead_X%Length())= MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections) + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_Mud_Forehead_section%Length())= MudSystem%NoPipeSections !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length())= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Last()+ (MudSystemDotOp_NeededVolume_ToFill - ABS(MudSystemDotDeltaVolumeAnnulusCapacity)) ! Op_NeededVolume_ToFill !ABS(DeltaVolumePipe) - ((AnnulusFlowRate/60.)*DeltaT_Mudline) !(gal) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Last()+ (MudSystem%Op_NeededVolume_ToFill - ABS(MudSystem%DeltaVolumeAnnulusCapacity)) ! Op_NeededVolume_ToFill !ABS(DeltaVolumePipe) - ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) !(gal) !=================================================================== - if ( (MudSystemDotiLoc==2 .or. iloc_edited==1) .and. Op_MudOrKick%Last()==0 ) then ! for avoid kick separation + if ( (MudSystem%iLoc==2 .or. iloc_edited==1) .and. MudSystem%Op_MudOrKick%Last()==0 ) then ! for avoid kick separation !write(*,*) 'here mud should be removed from Op last' - if (abs(Ann_Density%Array(MudSystemDotiLoc)-MudSystemDotOp_Density%Last())< MudSystemDotDensityMixTol) then + if (abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%Op_Density%Last())< MudSystem%DensityMixTol) then - Ann_Density%Array(MudSystemDotiLoc)= (Ann_Density%Array(MudSystemDotiLoc)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotOp_Density%Last()*MudSystemDotOp_MudDischarged_Volume%Last())/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotOp_MudDischarged_Volume%Last()) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotOp_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) - Ann_Mud_Forehead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Forehead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_Mud_Backhead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Backhead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotiLoc)= (0.0d0) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotiLoc)= (0.0d0) + MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_Density%Last()*MudSystem%Op_MudDischarged_Volume%Last())/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_MudDischarged_Volume%Last()) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) else ! 2-Merging conditions are not meeted, so new pocket - call Ann_Density%AddTo (MudSystemDotiLoc,MudSystemDotOp_Density%Last()) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotiLoc,MudSystemDotOp_MudDischarged_Volume%Last()) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotiLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotiLoc,0) + call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%Op_Density%Last()) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%Op_MudDischarged_Volume%Last()) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) endif - MudSystemDotOp_NeededVolume_ToFill= MudSystemDotOp_NeededVolume_ToFill + MudSystemDotOp_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) + MudSystem%Op_NeededVolume_ToFill= MudSystem%Op_NeededVolume_ToFill + MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) - call RemoveOpMudArrays(Op_MudOrKick%Length()) + call RemoveOpMudArrays(MudSystem%Op_MudOrKick%Length()) endif @@ -1042,8 +1039,8 @@ MudSystemDotimud= 0 !AnnMudVolumeSum= 0.d0 !!Ann_MudSaved_Density= 0.d0 !!Ann_KickSaved_Density= 0.d0 - MudSystemDotAnn_Saved_MudDischarged_Volume= 0.d0 - MudSystemDotAnn_Kick_Saved_Volume= 0.d0 + MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 + MudSystem%Ann_Kick_Saved_Volume= 0.d0 !Saved_Ann_MudOrKick= 0 !Ann_to_Choke_2mud= .false. @@ -1102,8 +1099,8 @@ MudSystemDotimud= 0 -MudSystemDotAnn_Saved_MudDischarged_Volume_Final= MudSystemDotAnn_Saved_MudDischarged_Volume -MudSystemDotAnn_Kick_Saved_Volume_Final= MudSystemDotAnn_Kick_Saved_Volume +MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume +MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) !write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) @@ -1111,7 +1108,7 @@ MudSystemDotAnn_Kick_Saved_Volume_Final= MudSystemDotAnn_Kick_Saved_Volume -IF (WellHeadIsOpen) MudVolume_InjectedFromAnn = MudSystemDotAnn_Saved_MudDischarged_Volume_Final-((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) +IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !! NoGasPocket > 0 .AND. !write(*,*) 'Ann_Saved_Mud_Vol,Ann_Kick_Saved_Vol=' , Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume @@ -1123,28 +1120,28 @@ IF (WellHeadIsOpen) MudVolume_InjectedFromAnn = MudSystemDotAnn_Saved_MudD ! <<< SIMILAR TO UTUBE 2 >>> !write(*,*) Ann_MudOrKick%Last(), 'DeltaVolumePipe , after volume=' ,ABS(DeltaVolumePipe), Ann_MudDischarged_Volume%Last() -MudSystemDotimud= Ann_Mud_Forehead_X%Length() + 1 +imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 - do while (MudSystemDotimud > 1) - MudSystemDotimud = MudSystemDotimud - 1 + do while (imud > 1) + imud = imud - 1 - if (MudSystemDotimud< Ann_Mud_Forehead_X%Length()) then - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= Ann_Mud_Backhead_X%Array(MudSystemDotimud+1) - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= Ann_Mud_Backhead_section%Array(MudSystemDotimud+1) + if (imud< MudSystem%Ann_Mud_Forehead_X%Length()) then + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud+1) + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud+1) endif ! <<< Fracture Shoe Lost - IF ( MudSystemDotShoeLost .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(MudSystemDotimud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(MudSystemDotimud) ) then + IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)-((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) !(gal) - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) < 0.0) then + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(MudSystemDotimud) - MudSystemDotimud= MudSystemDotimud-1 + call RemoveAnnulusMudArrays(imud) + imud= imud-1 cycle endif - MudSystemDotLostInTripOutIsDone= .true. + MudSystem%LostInTripOutIsDone= .true. ENDIF ! Fracture Shoe Lost >>> @@ -1157,46 +1154,46 @@ MudSystemDotimud= Ann_Mud_Forehead_X%Length() + 1 !write(*,*) 'a)imud,Ann_Mud_Forehead_section=',imud,Ann_Mud_Forehead_section%Array(imud) - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) ! +1 for string , -1 for annulus !write(*,*) 'b)imud,Forehead_X,Xstart_PipeSection=',imud,Ann_Mud_Forehead_X%Array(imud),Xstart_PipeSection(Ann_Mud_Forehead_section%Array(imud)) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (Ann_Mud_Forehead_X%Array(MudSystemDotimud)- MudSystemDotXstart_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud)))* & - MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotimud)) !(ft^3) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & + MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) <= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= Ann_Mud_Forehead_section%Array(MudSystemDotimud) - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= Ann_Mud_Forehead_X%Array(MudSystemDotimud)- MudSystemDotDirectionCoef*(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotimud)) + if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud) + MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystemDotisection= Ann_Mud_Forehead_section%Array(MudSystemDotimud)-1 - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection < F_StringIntervalCounts+1) then ! last pipe section(well exit) F_StringIntervalCounts+1 is the first section in Annulus - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1) - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= F_StringIntervalCounts+1 + if (MudSystem%isection < F_StringIntervalCounts+1) then ! last pipe section(well exit) F_StringIntervalCounts+1 is the first section in Annulus + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1) + MudSystem%Ann_Mud_Backhead_section%Array(imud)= F_StringIntervalCounts+1 - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(MudSystemDotimud) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystemDotxx= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= MudSystemDotisection - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXstart_PipeSection(MudSystemDotisection)- MudSystemDotXend_PipeSection(MudSystemDotisection)))+ MudSystemDotXend_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%isection + MudSystem%Ann_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) exit else - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection- 1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection- 1 endif @@ -1220,28 +1217,28 @@ MudSystemDotimud= Ann_Mud_Forehead_X%Length() + 1 !======================== Bottom Hole Entrance ========================== !if (iloc == 1) then - if ( MudSystemDotOp_NeededVolume_ToFill > 0.0 ) then ! it is needed for 2nd & 3rd mode + if ( MudSystem%Op_NeededVolume_ToFill > 0.0 ) then ! it is needed for 2nd & 3rd mode !write(*,*) 'op add for 2nd & 3rd mode done' - if ( ABS(MudSystemDotOp_Density%Last() - SavedDensityForOp ) >= MudSystemDotDensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Last()>42.) ) then ! 1-Merging conditions are not meeted, so new pocket + if ( ABS(MudSystem%Op_Density%Last() - SavedDensityForOp ) >= MudSystem%DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Last()>42.) ) then ! 1-Merging conditions are not meeted, so new pocket - call MudSystemDotOp_Density%Add (SavedDensityForOp) - call MudSystemDotOp_MudDischarged_Volume%Add (MudSystemDotOp_NeededVolume_ToFill) - call MudSystemDotOp_Mud_Forehead_X%Add (0.0d0) - call Op_Mud_Forehead_section%Add (1) - call MudSystemDotOp_Mud_Backhead_X%Add (0.0d0) - call Op_Mud_Backhead_section%Add (1) - call MudSystemDotOp_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%Add (0.0d0) - call Op_MudOrKick%Add (Ann_MudOrKick%Array(1)) + call MudSystem%Op_Density%Add (SavedDensityForOp) + call MudSystem%Op_MudDischarged_Volume%Add (MudSystem%Op_NeededVolume_ToFill) + call MudSystem%Op_Mud_Forehead_X%Add (0.0d0) + call MudSystem%Op_Mud_Forehead_section%Add (1) + call MudSystem%Op_Mud_Backhead_X%Add (0.0d0) + call MudSystem%Op_Mud_Backhead_section%Add (1) + call MudSystem%Op_RemainedVolume_in_LastSection%Add (0.0d0) + call MudSystem%Op_EmptyVolume_inBackheadLocation%Add (0.0d0) + call MudSystem%Op_MudOrKick%Add (MudSystem%Ann_MudOrKick%Array(1)) else ! 2-Pockets are Merged - MudSystemDotOp_Density%Array (MudSystemDotOp_Density%Length())= (SavedDensityForOp*MudSystemDotOp_NeededVolume_ToFill+MudSystemDotOp_Density%Last()*MudSystemDotOp_MudDischarged_Volume%Last())/(MudSystemDotOp_MudDischarged_Volume%Last()+MudSystemDotOp_NeededVolume_ToFill) - MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_Density%Length())= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_Density%Length()) + MudSystemDotOp_NeededVolume_ToFill - MudSystemDotOp_RemainedVolume_in_LastSection%Array (MudSystemDotOp_Density%Length())= 0.0 - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array (MudSystemDotOp_Density%Length())= 0.0 + MudSystem%Op_Density%Array (MudSystem%Op_Density%Length())= (SavedDensityForOp*MudSystem%Op_NeededVolume_ToFill+MudSystem%Op_Density%Last()*MudSystem%Op_MudDischarged_Volume%Last())/(MudSystem%Op_MudDischarged_Volume%Last()+MudSystem%Op_NeededVolume_ToFill) + MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_Density%Length()) + MudSystem%Op_NeededVolume_ToFill + MudSystem%Op_RemainedVolume_in_LastSection%Array (MudSystem%Op_Density%Length())= 0.0 + MudSystem%Op_EmptyVolume_inBackheadLocation%Array (MudSystem%Op_Density%Length())= 0.0 endif @@ -1252,68 +1249,68 @@ MudSystemDotimud= Ann_Mud_Forehead_X%Length() + 1 !============================= Bottom Hole ============================== -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotOp_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud-1) - Op_Mud_Backhead_section%Array(MudSystemDotimud)= Op_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) + MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= Op_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystemDotisection= Op_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) + if (MudSystem%isection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) !if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts) - Op_Mud_Forehead_section%Array(MudSystemDotimud)= F_BottomHoleIntervalCounts + MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts) + MudSystem%Op_Mud_Forehead_section%Array(imud)= F_BottomHoleIntervalCounts - if (MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call MudSystemDotOp_MudDischarged_Volume%Remove (MudSystemDotimud) - call MudSystemDotOp_Mud_Backhead_X%Remove (MudSystemDotimud) - call Op_Mud_Backhead_section%Remove (MudSystemDotimud) - call MudSystemDotOp_Mud_Forehead_X%Remove (MudSystemDotimud) - call Op_Mud_Forehead_section%Remove (MudSystemDotimud) - call MudSystemDotOp_Density%Remove (MudSystemDotimud) - call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) - call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) - call Op_MudOrKick%Remove (MudSystemDotimud) + if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call MudSystem%Op_MudDischarged_Volume%Remove (imud) + call MudSystem%Op_Mud_Backhead_X%Remove (imud) + call MudSystem%Op_Mud_Backhead_section%Remove (imud) + call MudSystem%Op_Mud_Forehead_X%Remove (imud) + call MudSystem%Op_Mud_Forehead_section%Remove (imud) + call MudSystem%Op_Density%Remove (imud) + call MudSystem%Op_RemainedVolume_in_LastSection%Remove (imud) + call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (imud) + call MudSystem%Op_MudOrKick%Remove (imud) endif exit endif - MudSystemDotxx= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_OpSection(MudSystemDotisection)- MudSystemDotXstart_OpSection(MudSystemDotisection)))+ MudSystemDotXstart_OpSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) exit else - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -1345,15 +1342,15 @@ MudSystemDotimud=0 !========================================================= - MudSystemDottotal_injected = MudSystemDottotal_injected + MudVolume_InjectedFromAnn + MudSystem%total_injected = MudSystem%total_injected + MudSystem%MudVolume_InjectedFromAnn if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystemDottotal_injected= 0. + MudSystem%total_injected= 0. endif - !write(*,*) ' MudVolume_InjectedFromAnn =' , MudVolume_InjectedFromAnn + !write(*,*) ' MudSystem%MudVolume_InjectedFromAnn =' , MudSystem%MudVolume_InjectedFromAnn !write(*,*) ' total injected-tripout =' , total_injected - !write(*,*) ' injected-tripout =' , MudVolume_InjectedFromAnn + !write(*,*) ' injected-tripout =' , MudSystem%MudVolume_InjectedFromAnn diff --git a/Equipments/MudSystem/Utube1_and_Trip_In.f90 b/Equipments/MudSystem/Utube1_and_Trip_In.f90 index 76c183e..96cfe67 100644 --- a/Equipments/MudSystem/Utube1_and_Trip_In.f90 +++ b/Equipments/MudSystem/Utube1_and_Trip_In.f90 @@ -16,22 +16,22 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect write(*,*) 'Utube1 code' !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystemDotUtubeMode1Activated= .true. + MudSystem%UtubeMode1Activated= .true. !write(*,*) 'QUTubeInput=' , QUTubeInput !Qinput=5000. - MudSystemDotStringFlowRate= QUTubeInput ! (gpm) - MudSystemDotAnnulusFlowRate= QUTubeInput - MudSystemDotStringFlowRateFinal= MudSystemDotStringFlowRate - MudSystemDotAnnulusFlowRateFinal= MudSystemDotAnnulusFlowRate + MudSystem%StringFlowRate= QUTubeInput ! (gpm) + MudSystem%AnnulusFlowRate= QUTubeInput + MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate + MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate !=========================================== - if (MudSystemDotFirstSetUtube1==0) then + if (MudSystem%FirstSetUtube1==0) then ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial ! call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) ! call St_Mud_Backhead_section%AddToFirst (1) ! call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts)) ! call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) - ! call St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) + ! call MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) ! call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! @@ -46,10 +46,10 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect !Hz_Density%Array(:)= 0.0 !commented !Hz_MudOrKick%Array(:)= 104 !commented - MudSystemDotHz_Density_Utube= 0.0 - MudSystemDotHz_MudOrKick_Utube= 104 + MudSystem%Hz_Density_Utube= 0.0 + MudSystem%Hz_MudOrKick_Utube= 104 - MudSystemDotFirstSetUtube1= 1 + MudSystem%FirstSetUtube1= 1 endif @@ -77,7 +77,7 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect !commented -! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((StringFlowRate/60.)*DeltaT_Mudline) !(gal) +! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) ! !imud=0 ! do while (imud < Hz_Mud_Forehead_X%Length()) @@ -152,80 +152,80 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect !========================Horizontal PIPE END================= !========================STRING ENTRANCE================= - !write(*,*) 'a) St_Density%Length()=' , St_Density%Length() + !write(*,*) 'a) MudSystem%St_Density%Length()=' , MudSystem%St_Density%Length() - if (ABS(St_Density%First() - MudSystemDotHz_Density_Utube) >= MudSystemDotDensityMixTol) then ! new mud is pumped - call St_Density%AddToFirst (MudSystemDotHz_Density_Utube) - call MudSystemDotSt_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystemDotSt_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Forehead_section%AddToFirst (2) - call MudSystemDotSt_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(2)) - call St_Mud_Backhead_section%AddToFirst (2) - call MudSystemDotSt_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call St_MudOrKick%AddToFirst (MudSystemDotHz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 + if (ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density_Utube) >= MudSystem%DensityMixTol) then ! new mud is pumped + call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density_Utube) + call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) + call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) + call MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call MudSystem%St_MudOrKick%AddToFirst (MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 !StringDensity_Old= Hz_Density_Utube endif - !write(*,*) 'b) St_Density%Length()=' , St_Density%Length() - !write(*,*) 'b) St_Density%Array(1)=' , St_Density%Array(1) + !write(*,*) 'b) MudSystem%St_Density%Length()=' , MudSystem%St_Density%Length() + !write(*,*) 'b) MudSystem%St_Density%Array(1)=' , MudSystem%St_Density%Array(1) !write(*,*) 'b) St_MudOrKick%Array(1)=' , St_MudOrKick%Array(1) !========================STRING================= - !WRITE (*,*) 'Utube1 StringFlowRate', StringFlowRate - MudSystemDotSt_MudDischarged_Volume%Array(1)= MudSystemDotSt_MudDischarged_Volume%Array(1)+ ((MudSystemDotStringFlowRate/60.d0)*DeltaT_Mudline) !(gal) + !WRITE (*,*) 'Utube1 MudSystem%StringFlowRate', MudSystem%StringFlowRate + MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.d0)*MudSystem%DeltaT_Mudline) !(gal) -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotSt_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%St_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud-1) - St_Mud_Backhead_section%Array(MudSystemDotimud)= St_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) + MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(St_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(St_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - St_Mud_Forehead_section%Array(MudSystemDotimud)= St_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(St_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) + MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= St_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > F_StringIntervalCounts) then ! last pipe section(string exit) F_StringIntervalCounts includes Horizontal line - MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(F_StringIntervalCounts) - St_Mud_Forehead_section%Array(MudSystemDotimud)= F_StringIntervalCounts + if (MudSystem%isection > F_StringIntervalCounts) then ! last pipe section(string exit) F_StringIntervalCounts includes Horizontal line + MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_StringIntervalCounts) + MudSystem%St_Mud_Forehead_section%Array(imud)= F_StringIntervalCounts - if (MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(MudSystemDotimud) + if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call RemoveStringMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - St_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -259,60 +259,60 @@ MudSystemDotimud=0 !============================= Bottom Hole ============================== !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotOp_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud-1) - Op_Mud_Backhead_section%Array(MudSystemDotimud)= Op_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) + MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= Op_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= Op_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) - if( MudSystemDotimud==1) MudSystemDotKickDeltaVinAnnulus= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud) ! Kick enters Annulus space - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts) - Op_Mud_Forehead_section%Array(MudSystemDotimud)= F_BottomHoleIntervalCounts + if (MudSystem%isection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) + if( imud==1) MudSystem%KickDeltaVinAnnulus= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space + MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts) + MudSystem%Op_Mud_Forehead_section%Array(imud)= F_BottomHoleIntervalCounts - if (MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveOpMudArrays(MudSystemDotimud) + if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call RemoveOpMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_OpSection(MudSystemDotisection)- MudSystemDotXstart_OpSection(MudSystemDotisection)))+ MudSystemDotXstart_OpSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) exit else - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -321,13 +321,13 @@ MudSystemDotimud=0 endif - if (MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)== MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts)) then - MudSystemDottotalLength = MudSystemDotOp_MudDischarged_Volume%Length() - do while(MudSystemDotimud < MudSystemDottotalLength) + if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts)) then + MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() + do while(imud < MudSystem%totalLength) !imud = imud + 1 - call RemoveOpMudArrays(MudSystemDottotalLength) - MudSystemDottotalLength = MudSystemDottotalLength - 1 + call RemoveOpMudArrays(MudSystem%totalLength) + MudSystem%totalLength = MudSystem%totalLength - 1 enddo @@ -352,81 +352,81 @@ MudSystemDotimud=0 ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(2)' , Op_Mud_Forehead_X%Array(2) !========================Bottom Hole END================= - if (MudSystemDotiLoc == 1) then - MudSystemDotMudSection= F_StringIntervalCounts+1 - MudSystemDotBackheadX= MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1) - elseif (MudSystemDotiLoc == 2) then - MudSystemDotMudSection= MudSystemDotKick_Forehead_section - MudSystemDotBackheadX= MudSystemDotKick_Forehead_X + if (MudSystem%iLoc == 1) then + MudSystem%MudSection= F_StringIntervalCounts+1 + MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1) + elseif (MudSystem%iLoc == 2) then + MudSystem%MudSection= MudSystem%Kick_Forehead_section + MudSystem%BackheadX= MudSystem%Kick_Forehead_X endif !========================ANNULUS ENTRANCE==================== !write(*,*) 'iloc=====' , iLoc - if ((ABS(AnnulusSuctionDensity_Old - St_Density%Last()) >= MudSystemDotDensityMixTol) .OR. (MudSystemDotDeltaVolumeOp == 0.0 .and. ABS(Ann_Density%Array(MudSystemDotiLoc)-St_Density%Last())>=MudSystemDotDensityMixTol .and. MudSystemDotAnnulusFlowRate/=0.0d0) ) then ! new mud is pumped - call Ann_Density%AddTo (MudSystemDotiLoc,St_Density%Last()) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotiLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotiLoc,0) + if ((ABS(MudSystem%AnnulusSuctionDensity_Old - MudSystem%St_Density%Last()) >= MudSystem%DensityMixTol) .OR. (MudSystem%DeltaVolumeOp == 0.0 .and. ABS(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%St_Density%Last())>=MudSystem%DensityMixTol .and. MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped + call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%St_Density%Last()) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) - AnnulusSuctionDensity_Old= St_Density%Last() + MudSystem%AnnulusSuctionDensity_Old= MudSystem%St_Density%Last() - MudSystemDotMudIsChanged= .true. + MudSystem%MudIsChanged= .true. endif - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+ ((MudSystemDotAnnulusFlowRate/60.0d0)*DeltaT_Mudline) !(gal) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+ ((MudSystem%AnnulusFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) !========================Tripping In==================== !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - if (MudSystemDotDeltaVolumeOp > 0.0 .and. MudSystemDotMudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) + if (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) !write(*,*) 'Tripping In' - NewDensity= (St_Density%Last()*((MudSystemDotAnnulusFlowRate/60.)*DeltaT_Mudline)+MudSystemDotOp_Density%Last()*MudSystemDotDeltaVolumeOp)/(((MudSystemDotAnnulusFlowRate/60.0d0)*DeltaT_Mudline)+MudSystemDotDeltaVolumeOp) - MudSystemDotNewVolume= ((MudSystemDotAnnulusFlowRate/60.)*DeltaT_Mudline)+MudSystemDotDeltaVolumeOp + MudSystem%NewDensity= (MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline)+MudSystem%Op_Density%Last()*MudSystem%DeltaVolumeOp)/(((MudSystem%AnnulusFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp) + MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp !write(*,*) 'Ann_MudDischarged_Volume%Array(1)=', Ann_MudDischarged_Volume%Array(1), 'NewVolume=', NewVolume - if (abs(Ann_Density%Array(MudSystemDotiLoc)-NewDensity)< MudSystemDotDensityMixTol) then ! 1-Pockets are Merged - (ROP is 0) - Ann_Density%Array(MudSystemDotiLoc)= (Ann_Density%Array(MudSystemDotiLoc)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotNewVolume) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+MudSystemDotDeltaVolumeOp - Ann_Mud_Forehead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Forehead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_Mud_Backhead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Backhead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotiLoc)= (0.0d0) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotiLoc)= (0.0d0) + if (abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) then ! 1-Pockets are Merged - (ROP is 0) + MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%DeltaVolumeOp + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket - call Ann_Density%AddTo (MudSystemDotiLoc,NewDensity) - call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotiLoc,MudSystemDotNewVolume) - call Ann_Mud_Forehead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Forehead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_Mud_Backhead_X%AddTo (MudSystemDotiLoc,MudSystemDotBackheadX) - call Ann_Mud_Backhead_section%AddTo (MudSystemDotiLoc,MudSystemDotMudSection) - call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotiLoc,0.0d0) - call Ann_MudOrKick%AddTo (MudSystemDotiLoc,0) - call Ann_CuttingMud%AddTo (MudSystemDotiLoc,0) + call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) + call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) + call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) + call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) + call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) + call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) + call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) endif - elseif (MudSystemDotDeltaVolumeOp > 0.0 .and. MudSystemDotMudIsChanged== .true. .and. Rate_of_Penetration==0.) then - Ann_Density%Array(MudSystemDotiLoc)= NewDensity - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotNewVolume - Ann_Mud_Forehead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Forehead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_Mud_Backhead_X%Array(MudSystemDotiLoc)= MudSystemDotBackheadX - Ann_Mud_Backhead_section%Array(MudSystemDotiLoc)= MudSystemDotMudSection - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotiLoc)= (0.0d0) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotiLoc)= (0.0d0) + elseif (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .true. .and. Rate_of_Penetration==0.) then + MudSystem%Ann_Density%Array(MudSystem%iLoc)= MudSystem%NewDensity + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%NewVolume + MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX + MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection + MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) endif @@ -435,27 +435,27 @@ MudSystemDotimud=0 !======================== ANNULUS ==================== - MudSystemDotMudIsChanged= .false. + MudSystem%MudIsChanged= .false. -MudSystemDotimud= 0 +imud= 0 - do while (MudSystemDotimud < Ann_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 + do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= Ann_Mud_Forehead_X%Array(MudSystemDotimud-1) - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= Ann_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) + MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) endif ! <<< Fracture Shoe Lost - IF ( MudSystemDotShoeLost .and. MudSystemDotLostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(MudSystemDotimud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(MudSystemDotimud) ) then + IF ( MudSystem%ShoeLost .and. MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)-((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) !(gal) - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) < 0.0) then + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(MudSystemDotimud) - MudSystemDotimud= MudSystemDotimud-1 + call RemoveAnnulusMudArrays(imud) + imud= imud-1 cycle endif ENDIF @@ -468,48 +468,48 @@ MudSystemDotimud= 0 - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_PipeSection(Ann_Mud_Backhead_section%Array(MudSystemDotimud))- Ann_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_PipeSectionFt(Ann_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) <= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= Ann_Mud_Backhead_section%Array(MudSystemDotimud) - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= Ann_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(Ann_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystemDotisection= Ann_Mud_Backhead_section%Array(MudSystemDotimud)+1 - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > MudSystemDotNoPipeSections) then ! last pipe section(well exit) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections) - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotNoPipeSections + if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(MudSystemDotimud) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystemDotxx= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_PipeSection(MudSystemDotisection)- MudSystemDotXstart_PipeSection(MudSystemDotisection)))+ MudSystemDotXstart_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) exit else - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -521,8 +521,8 @@ MudSystemDotimud= 0 !========================ANNULUS END================= !if ( WellisNOTFull == .false. ) then - ! write(*,*) 'AnnulusFlowRate==' , AnnulusFlowRate - ! call Set_FlowRate(real(100.*min(AnnulusFlowRate,PedalMeter)/(PedalMeter/10.), 8)) + ! write(*,*) 'MudSystem%AnnulusFlowRate==' , MudSystem%AnnulusFlowRate + ! call Set_FlowRate(real(100.*min(MudSystem%AnnulusFlowRate,PedalMeter)/(PedalMeter/10.), 8)) ! ! !endif diff --git a/Equipments/MudSystem/Utube2_and_Trip_In.f90 b/Equipments/MudSystem/Utube2_and_Trip_In.f90 index 2d1923f..7004e67 100644 --- a/Equipments/MudSystem/Utube2_and_Trip_In.f90 +++ b/Equipments/MudSystem/Utube2_and_Trip_In.f90 @@ -16,22 +16,22 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystemDotUtubeMode2Activated= .true. + MudSystem%UtubeMode2Activated= .true. write(*,*) 'QUtubeOutput=' , QUtubeOutput !QUTubeInput=5000. - MudSystemDotStringFlowRate= QUtubeOutput ! (gpm) - MudSystemDotAnnulusFlowRate= QUtubeOutput - MudSystemDotStringFlowRateFinal= MudSystemDotStringFlowRate - MudSystemDotAnnulusFlowRateFinal= MudSystemDotAnnulusFlowRate + MudSystem%StringFlowRate= QUtubeOutput ! (gpm) + MudSystem%AnnulusFlowRate= QUtubeOutput + MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate + MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate !=========================================== - if (MudSystemDotFirstSetUtube2==0) then + if (MudSystem%FirstSetUtube2==0) then ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial ! call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) ! call St_Mud_Backhead_section%AddToFirst (1) ! call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts)) ! call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) - ! call St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) + ! call MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) ! call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! @@ -46,10 +46,10 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !Hz_Density%Array(:)= 0.0 !Hz_MudOrKick%Array(:)= 104 - MudSystemDotHz_Density_Utube= 0.0 - MudSystemDotHz_MudOrKick_Utube= 104 + MudSystem%Hz_Density_Utube= 0.0 + MudSystem%Hz_MudOrKick_Utube= 104 - MudSystemDotFirstSetUtube2= 1 + MudSystem%FirstSetUtube2= 1 endif @@ -79,7 +79,7 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !commented -! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((StringFlowRate/60.)*DeltaT_Mudline) !(gal) +! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) ! !imud=0 ! do while (imud < Hz_Mud_Forehead_X%Length()) @@ -154,90 +154,90 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !========================ANNULUS ENTRANCE==================== - if (ABS(AnnulusSuctionDensity_Old - MudSystemDotHz_Density_Utube) >= MudSystemDotDensityMixTol ) then ! new mud is pumped - call Ann_Density%Add (MudSystemDotHz_Density_Utube) - call MudSystemDotAnn_MudDischarged_Volume%Add (0.0d0) - call Ann_Mud_Forehead_X%Add (MudSystemDotXend_PipeSection(MudSystemDotNoPipeSections)) - call Ann_Mud_Forehead_section%Add (MudSystemDotNoPipeSections) - call Ann_Mud_Backhead_X%Add (MudSystemDotXstart_PipeSection(MudSystemDotNoPipeSections)) - call Ann_Mud_Backhead_section%Add (MudSystemDotNoPipeSections) - call Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call Ann_MudOrKick%Add (MudSystemDotHz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 - call Ann_CuttingMud%Add (0) + if (ABS(MudSystem%AnnulusSuctionDensity_Old - MudSystem%Hz_Density_Utube) >= MudSystem%DensityMixTol ) then ! new mud is pumped + call MudSystem%Ann_Density%Add (MudSystem%Hz_Density_Utube) + call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) + call MudSystem%Ann_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) + call MudSystem%Ann_Mud_Forehead_section%Add (MudSystem%NoPipeSections) + call MudSystem%Ann_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(MudSystem%NoPipeSections)) + call MudSystem%Ann_Mud_Backhead_section%Add (MudSystem%NoPipeSections) + call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) + call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) + call MudSystem%Ann_MudOrKick%Add (MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 + call MudSystem%Ann_CuttingMud%Add (0) - AnnulusSuctionDensity_Old= MudSystemDotHz_Density_Utube + MudSystem%AnnulusSuctionDensity_Old= MudSystem%Hz_Density_Utube endif !========================ANNULUS==================== - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Last()+ ((MudSystemDotAnnulusFlowRate/60.)*DeltaT_Mudline) !(gal) + MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Last()+ ((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline) !(gal) -MudSystemDotimud= Ann_Mud_Forehead_X%Length() + 1 +imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 - do while (MudSystemDotimud > 1) - MudSystemDotimud = MudSystemDotimud - 1 + do while (imud > 1) + imud = imud - 1 - if (MudSystemDotimud< Ann_Mud_Forehead_X%Length()) then - Ann_Mud_Forehead_X%Array(MudSystemDotimud)= Ann_Mud_Backhead_X%Array(MudSystemDotimud+1) - Ann_Mud_Forehead_section%Array(MudSystemDotimud)= Ann_Mud_Backhead_section%Array(MudSystemDotimud+1) + if (imud< MudSystem%Ann_Mud_Forehead_X%Length()) then + MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud+1) + MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud+1) endif ! <<< Fracture Shoe Lost - IF ( MudSystemDotShoeLost .and. MudSystemDotLostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(MudSystemDotimud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(MudSystemDotimud) ) then + IF ( MudSystem%ShoeLost .and. MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)-((MudSystemDotQlost/60.0d0)*DeltaT_Mudline) !(gal) - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) < 0.0) then + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(MudSystemDotimud) - MudSystemDotimud= MudSystemDotimud-1 + call RemoveAnnulusMudArrays(imud) + imud= imud-1 cycle endif ENDIF ! Fracture Shoe Lost >>> - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) ! +1 for string , -1 for annulus - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (Ann_Mud_Forehead_X%Array(MudSystemDotimud)- MudSystemDotXstart_PipeSection(Ann_Mud_Forehead_section%Array(MudSystemDotimud)))* & - MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotimud)) !(ft^3) - Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & + MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) + MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud) <= Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= Ann_Mud_Forehead_section%Array(MudSystemDotimud) - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= Ann_Mud_Forehead_X%Array(MudSystemDotimud)- MudSystemDotDirectionCoef*(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotimud)) + if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud) + MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystemDotisection= Ann_Mud_Forehead_section%Array(MudSystemDotimud)-1 - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection < F_StringIntervalCounts+1) then ! last pipe section(well exit) F_StringIntervalCounts+1 is the first section in Annulus - MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1) - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= F_StringIntervalCounts+1 + if (MudSystem%isection < F_StringIntervalCounts+1) then ! last pipe section(well exit) F_StringIntervalCounts+1 is the first section in Annulus + MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(F_StringIntervalCounts+1) + MudSystem%Ann_Mud_Backhead_section%Array(imud)= F_StringIntervalCounts+1 - if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(MudSystemDotimud) + if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystemDotxx= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Ann_Mud_Backhead_section%Array(MudSystemDotimud)= MudSystemDotisection - Ann_Mud_Backhead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXstart_PipeSection(MudSystemDotisection)- MudSystemDotXend_PipeSection(MudSystemDotisection)))+ MudSystemDotXend_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%isection + MudSystem%Ann_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) exit else - Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection- 1 + MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection- 1 endif @@ -271,60 +271,60 @@ MudSystemDotimud= Ann_Mud_Forehead_X%Length() + 1 !============================= Bottom Hole ============================== !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux -MudSystemDotimud=0 - do while (MudSystemDotimud < MudSystemDotOp_Mud_Forehead_X%Length()) - MudSystemDotimud = MudSystemDotimud + 1 +imud=0 + do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + imud = imud + 1 - if (MudSystemDotimud> 1) then - MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud-1) - Op_Mud_Backhead_section%Array(MudSystemDotimud)= Op_Mud_Forehead_section%Array(MudSystemDotimud-1) + if (imud> 1) then + MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) + MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))-MudSystemDotXstart_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotXend_OpSection(Op_Mud_Backhead_section%Array(MudSystemDotimud))- MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud))* & - MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & + MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= Op_Mud_Backhead_section%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotOp_Mud_Backhead_X%Array(MudSystemDotimud)+ MudSystemDotDirectionCoef*(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_OpSectionFt(Op_Mud_Backhead_section%Array(MudSystemDotimud)) + if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystemDotisection= Op_Mud_Backhead_section%Array(MudSystemDotimud)+1 - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) - if( MudSystemDotimud==1) MudSystemDotKickDeltaVinAnnulus= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud) ! Kick enters Annulus space - MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts) - Op_Mud_Forehead_section%Array(MudSystemDotimud)= F_BottomHoleIntervalCounts + if (MudSystem%isection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) + if( imud==1) MudSystem%KickDeltaVinAnnulus= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space + MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts) + MudSystem%Op_Mud_Forehead_section%Array(imud)= F_BottomHoleIntervalCounts - if (MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveOpMudArrays(MudSystemDotimud) + if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call RemoveOpMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - Op_Mud_Forehead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXend_OpSection(MudSystemDotisection)- MudSystemDotXstart_OpSection(MudSystemDotisection)))+ MudSystemDotXstart_OpSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection + MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) exit else - MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection+ 1 + MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection+ 1 endif @@ -332,13 +332,13 @@ MudSystemDotimud=0 endif - if (MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)== MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts)) then - MudSystemDottotalLength = MudSystemDotOp_MudDischarged_Volume%Length() - do while(MudSystemDotimud < MudSystemDottotalLength) + if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_BottomHoleIntervalCounts)) then + MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() + do while(imud < MudSystem%totalLength) !imud = imud + 1 - call RemoveOpMudArrays(MudSystemDottotalLength) - MudSystemDottotalLength = MudSystemDottotalLength - 1 + call RemoveOpMudArrays(MudSystem%totalLength) + MudSystem%totalLength = MudSystem%totalLength - 1 enddo @@ -375,70 +375,70 @@ MudSystemDotimud=0 !========================STRING ENTRANCE================= - if ((ABS(St_Density%Last() - Ann_Density%First()) >= MudSystemDotDensityMixTol) .OR. (MudSystemDotDeltaVolumeOp == 0.0 .and. St_Density%Last() /= Ann_Density%Array(1) .and. MudSystemDotStringFlowRate/=0.0d0)) then ! new mud is pumped + if ((ABS(MudSystem%St_Density%Last() - MudSystem%Ann_Density%First()) >= MudSystem%DensityMixTol) .OR. (MudSystem%DeltaVolumeOp == 0.0 .and. MudSystem%St_Density%Last() /= MudSystem%Ann_Density%Array(1) .and. MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped - !if ((ABS(StringDensity_Old - Ann_Density%First()) >= DensityMixTol) .OR. (DeltaVolumeOp == 0.0 .and. St_Density%Last() /= Ann_Density%Array(1) .and. StringFlowRate/=0.0d0)) then ! new mud is pumped - call St_Density%Add (Ann_Density%First()) - call MudSystemDotSt_MudDischarged_Volume%Add (0.0d0) - call MudSystemDotSt_Mud_Forehead_X%Add (MudSystemDotXend_PipeSection(F_StringIntervalCounts)) - call St_Mud_Forehead_section%Add (F_StringIntervalCounts) - call MudSystemDotSt_Mud_Backhead_X%Add (MudSystemDotXstart_PipeSection(F_StringIntervalCounts)) - call St_Mud_Backhead_section%Add (F_StringIntervalCounts) - call MudSystemDotSt_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%Add (0.0d0) - call St_MudOrKick%Add (0) + !if ((ABS(StringDensity_Old - Ann_Density%First()) >= DensityMixTol) .OR. (DeltaVolumeOp == 0.0 .and. MudSystem%St_Density%Last() /= Ann_Density%Array(1) .and. MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped + call MudSystem%St_Density%Add (MudSystem%Ann_Density%First()) + call MudSystem%St_MudDischarged_Volume%Add (0.0d0) + call MudSystem%St_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(F_StringIntervalCounts)) + call MudSystem%St_Mud_Forehead_section%Add (F_StringIntervalCounts) + call MudSystem%St_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(F_StringIntervalCounts)) + call MudSystem%St_Mud_Backhead_section%Add (F_StringIntervalCounts) + call MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) + call MudSystem%St_MudOrKick%Add (0) !StringDensity_Old= Ann_Density%First() - MudSystemDotMudIsChanged= .true. + MudSystem%MudIsChanged= .true. endif - MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotSt_MudDischarged_Volume%Length())= MudSystemDotSt_MudDischarged_Volume%Last()+ ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) !(gal) + MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_MudDischarged_Volume%Length())= MudSystem%St_MudDischarged_Volume%Last()+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) !========================Tripping In==================== !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp -write(*,*) 'DeltaVolumeOp=' , MudSystemDotDeltaVolumeOp - if (MudSystemDotDeltaVolumeOp > 0.0 .and. MudSystemDotMudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) +write(*,*) 'DeltaVolumeOp=' , MudSystem%DeltaVolumeOp + if (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) !write(*,*) 'Tripping In' - NewDensity= (Ann_Density%First()*((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline)+MudSystemDotOp_Density%Last()*MudSystemDotDeltaVolumeOp)/(((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline)+MudSystemDotDeltaVolumeOp) - MudSystemDotNewVolume= ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline)+MudSystemDotDeltaVolumeOp + MudSystem%NewDensity= (MudSystem%Ann_Density%First()*((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%Op_Density%Last()*MudSystem%DeltaVolumeOp)/(((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp) + MudSystem%NewVolume= ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp !write(*,*) 'St_MudDischarged_Volume%Last()=', St_MudDischarged_Volume%Last(), 'NewVolume=', NewVolume - if (abs(St_Density%Last()-NewDensity)< MudSystemDotDensityMixTol) then ! .OR. (St_MudDischarged_Volume%Last()< 42.) ) then !+ NewVolume)< 42.) then ! 1-Pockets are Merged - St_Density%Array(St_Density%Length())= (St_Density%Last()*MudSystemDotSt_MudDischarged_Volume%Last()+NewDensity*MudSystemDotNewVolume)/(MudSystemDotSt_MudDischarged_Volume%Last()+MudSystemDotNewVolume) - MudSystemDotSt_MudDischarged_Volume%Array(St_Density%Length())= MudSystemDotSt_MudDischarged_Volume%Last()+MudSystemDotDeltaVolumeOp - MudSystemDotSt_Mud_Forehead_X%Array(St_Density%Length())= (MudSystemDotXend_PipeSection(F_StringIntervalCounts)) - St_Mud_Forehead_section%Array(St_Density%Length())= (F_StringIntervalCounts) - MudSystemDotSt_Mud_Backhead_X%Array(St_Density%Length())= (MudSystemDotXstart_PipeSection(F_StringIntervalCounts)) - St_Mud_Backhead_section%Array(St_Density%Length())= (F_StringIntervalCounts) - MudSystemDotSt_RemainedVolume_in_LastSection%Array(St_Density%Length())= (0.0d0) - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(St_Density%Length())= (0.0d0) + if (abs(MudSystem%St_Density%Last()-MudSystem%NewDensity)< MudSystem%DensityMixTol) then ! .OR. (St_MudDischarged_Volume%Last()< 42.) ) then !+ NewVolume)< 42.) then ! 1-Pockets are Merged + MudSystem%St_Density%Array(MudSystem%St_Density%Length())= (MudSystem%St_Density%Last()*MudSystem%St_MudDischarged_Volume%Last()+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%St_MudDischarged_Volume%Last()+MudSystem%NewVolume) + MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_Density%Length())= MudSystem%St_MudDischarged_Volume%Last()+MudSystem%DeltaVolumeOp + MudSystem%St_Mud_Forehead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xend_PipeSection(F_StringIntervalCounts)) + MudSystem%St_Mud_Forehead_section%Array(MudSystem%St_Density%Length())= (F_StringIntervalCounts) + MudSystem%St_Mud_Backhead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xstart_PipeSection(F_StringIntervalCounts)) + MudSystem%St_Mud_Backhead_section%Array(MudSystem%St_Density%Length())= (F_StringIntervalCounts) + MudSystem%St_RemainedVolume_in_LastSection%Array(MudSystem%St_Density%Length())= (0.0d0) + MudSystem%St_EmptyVolume_inBackheadLocation%Array(MudSystem%St_Density%Length())= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket - call St_Density%Add (NewDensity) - call MudSystemDotSt_MudDischarged_Volume%Add (MudSystemDotNewVolume) - call MudSystemDotSt_Mud_Forehead_X%Add (MudSystemDotXend_PipeSection(F_StringIntervalCounts)) - call St_Mud_Forehead_section%Add (F_StringIntervalCounts) - call MudSystemDotSt_Mud_Backhead_X%Add (MudSystemDotXstart_PipeSection(F_StringIntervalCounts)) - call St_Mud_Backhead_section%Add (F_StringIntervalCounts) - call MudSystemDotSt_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystemDotSt_EmptyVolume_inBackheadLocation%Add (0.0d0) - call St_MudOrKick%Add (0) + call MudSystem%St_Density%Add (MudSystem%NewDensity) + call MudSystem%St_MudDischarged_Volume%Add (MudSystem%NewVolume) + call MudSystem%St_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(F_StringIntervalCounts)) + call MudSystem%St_Mud_Forehead_section%Add (F_StringIntervalCounts) + call MudSystem%St_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(F_StringIntervalCounts)) + call MudSystem%St_Mud_Backhead_section%Add (F_StringIntervalCounts) + call MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) + call MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) + call MudSystem%St_MudOrKick%Add (0) endif - elseif (MudSystemDotDeltaVolumeOp > 0.0 .and. MudSystemDotMudIsChanged== .true.) then - St_Density%Array(St_Density%Length())= NewDensity - MudSystemDotSt_MudDischarged_Volume%Array(St_Density%Length())= MudSystemDotNewVolume - MudSystemDotSt_Mud_Forehead_X%Array(St_Density%Length())= (MudSystemDotXend_PipeSection(F_StringIntervalCounts)) - St_Mud_Forehead_section%Array(St_Density%Length())= (F_StringIntervalCounts) - MudSystemDotSt_Mud_Backhead_X%Array(St_Density%Length())= (MudSystemDotXstart_PipeSection(F_StringIntervalCounts)) - St_Mud_Backhead_section%Array(St_Density%Length())= (F_StringIntervalCounts) - MudSystemDotSt_RemainedVolume_in_LastSection%Array(St_Density%Length())= (0.0d0) - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(St_Density%Length())= (0.0d0) + elseif (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .true.) then + MudSystem%St_Density%Array(MudSystem%St_Density%Length())= MudSystem%NewDensity + MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_Density%Length())= MudSystem%NewVolume + MudSystem%St_Mud_Forehead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xend_PipeSection(F_StringIntervalCounts)) + MudSystem%St_Mud_Forehead_section%Array(MudSystem%St_Density%Length())= (F_StringIntervalCounts) + MudSystem%St_Mud_Backhead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xstart_PipeSection(F_StringIntervalCounts)) + MudSystem%St_Mud_Backhead_section%Array(MudSystem%St_Density%Length())= (F_StringIntervalCounts) + MudSystem%St_RemainedVolume_in_LastSection%Array(MudSystem%St_Density%Length())= (0.0d0) + MudSystem%St_EmptyVolume_inBackheadLocation%Array(MudSystem%St_Density%Length())= (0.0d0) endif @@ -447,60 +447,60 @@ write(*,*) 'DeltaVolumeOp=' , MudSystemDotDeltaVolumeOp !======================== STRING ==================== - MudSystemDotMudIsChanged= .false. + MudSystem%MudIsChanged= .false. - MudSystemDotimud= MudSystemDotSt_Mud_Forehead_X%Length() + 1 + imud= MudSystem%St_Mud_Forehead_X%Length() + 1 - do while (MudSystemDotimud > 1) - MudSystemDotimud = MudSystemDotimud - 1 + do while (imud > 1) + imud = imud - 1 - if (MudSystemDotimud< MudSystemDotSt_Mud_Forehead_X%Length()) then - MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud+1) - St_Mud_Forehead_section%Array(MudSystemDotimud)= St_Mud_Backhead_section%Array(MudSystemDotimud+1) + if (imud< MudSystem%St_Mud_Forehead_X%Length()) then + MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud+1) + MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud+1) endif - MudSystemDotDirectionCoef= (MudSystemDotXend_PipeSection(St_Mud_Forehead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Forehead_section%Array(MudSystemDotimud))) & - / ABS(MudSystemDotXend_PipeSection(St_Mud_Forehead_section%Array(MudSystemDotimud))-MudSystemDotXstart_PipeSection(St_Mud_Forehead_section%Array(MudSystemDotimud))) + MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))) & + / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotDirectionCoef* (MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)- MudSystemDotXstart_PipeSection(St_Mud_Forehead_section%Array(MudSystemDotimud)))* & - MudSystemDotArea_PipeSectionFt(St_Mud_Backhead_section%Array(MudSystemDotimud)) !(ft^3) - MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)* 7.48051948d0 ! ft^3 to gal + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%St_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud)))* & + MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) <= MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)) then - St_Mud_Backhead_section%Array(MudSystemDotimud)= St_Mud_Forehead_section%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotSt_Mud_Forehead_X%Array(MudSystemDotimud)- MudSystemDotDirectionCoef*(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)/7.48051948d0)/MudSystemDotArea_PipeSectionFt(St_Mud_Forehead_section%Array(MudSystemDotimud)) + if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud) + MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Forehead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystemDotisection= St_Mud_Backhead_section%Array(MudSystemDotimud)-1 - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud) + MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)-1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystemDotisection < 1) then ! last pipe section(string exit) - MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud) - MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)= MudSystemDotXstart_PipeSection(2) - St_Mud_Backhead_section%Array(MudSystemDotimud)= 2 + if (MudSystem%isection < 1) then ! last pipe section(string exit) + MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(2) + MudSystem%St_Mud_Backhead_section%Array(imud)= 2 - if (MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(MudSystemDotimud) + if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call RemoveStringMudArrays(imud) endif exit endif - MudSystemDotxx= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal) + MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - if (MudSystemDotxx<= 1.0) then - St_Mud_Backhead_section%Array(MudSystemDotimud)= MudSystemDotisection - MudSystemDotSt_Mud_Backhead_X%Array(MudSystemDotimud)= (MudSystemDotxx * (MudSystemDotXstart_PipeSection(MudSystemDotisection)- MudSystemDotXend_PipeSection(MudSystemDotisection)))+ MudSystemDotXend_PipeSection(MudSystemDotisection) + if (MudSystem%xx<= 1.0) then + MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%isection + MudSystem%St_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) exit else - MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) - MudSystemDotisection= MudSystemDotisection- 1 + MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) + MudSystem%isection= MudSystem%isection- 1 endif diff --git a/Equipments/Pumps/Pumps_Inputs.f90 b/Equipments/Pumps/Pumps_Inputs.f90 index 104ce36..12046dc 100644 --- a/Equipments/Pumps/Pumps_Inputs.f90 +++ b/Equipments/Pumps/Pumps_Inputs.f90 @@ -2,7 +2,7 @@ subroutine Pumps_Inputs Use CDrillingConsoleVariables Use Pumps_VARIABLES - Use MudSystem + use MudSystemModule IMPLICIT NONE diff --git a/Equipments/Pumps/Pumps_Outputs.f90 b/Equipments/Pumps/Pumps_Outputs.f90 index ff07bb8..3de430a 100644 --- a/Equipments/Pumps/Pumps_Outputs.f90 +++ b/Equipments/Pumps/Pumps_Outputs.f90 @@ -3,9 +3,9 @@ subroutine Pumps_Outputs Use CDataDisplayConsoleVariables Use CSimulationVariables Use Pumps_VARIABLES - Use MudSystem + use MudSystemModule Use CDrillWatchVariables - + Use CSounds IMPLICIT NONE diff --git a/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 b/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 index 573f203..a7330df 100644 --- a/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 +++ b/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 @@ -15,7 +15,7 @@ SUBROUTINE PressureAnnAndOHDistribution USE CMudPropertiesVariables USE TD_WellGeometry USE CReservoirVariables - USE MudSystem + use MudSystemModule USE CHOKEVARIABLES USE CChokeManifoldVariables USE VARIABLES @@ -42,24 +42,24 @@ IF (WellHeadOpen .OR. NoGasPocket == 0) THEN !! (mud circulation is normal we j = OpenholeFirstEl - 1 !!!!!!!!!!!!!!!!!!!!!!!!! flowrates due to external sources like pump and tripping - !WRITE (*,*) 'StringFlowRate', StringFlowRate + !WRITE (*,*) 'MudSystem%StringFlowRate', MudSystem%StringFlowRate FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = (ClingingFactor * FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%Area + FlowEl(StringFirstEl)%Area) * DrillStringSpeed * ConvMintoSec * Convft3toUSgal ! flowrate in annulus due to tripping - FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate + REAL(MudSystemDotMudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump + FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate + REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump !WRITE (*,*) 'Drillstring speed (ft/s)' , FlowEl(j)%FlowRate !IF (NoWellToChokeEl > 0) THEN ! flowrate in choke line - ! FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + 1 : NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%FlowRate = AnnulusFlowRate + (DeltaVolumePipe * ConvMinToSec / dt) + ! FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + 1 : NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%FlowRate = MudSystem%AnnulusFlowRate + (DeltaVolumePipe * ConvMinToSec / dt) !END IF - IF (MudSystemDotShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation + IF (MudSystem%ShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation !WRITE (*,*) ' SHoe fractured', PressureGauges(5), FlowEl(ShoeFlowElNo)%FlowRate IF (ShoeFlowElNo > AnnulusLastEl) THEN ! shoe is in openhole - FlowEl(ShoeFlowElNo : NumbEl)%FlowRate = - MudSystemDotQlost - FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate - MudSystemDotQlost + FlowEl(ShoeFlowElNo : NumbEl)%FlowRate = - MudSystem%Qlost + FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost ELSE ! shoe is in annulus - FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate - MudSystemDotQlost + FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost END IF END IF @@ -141,14 +141,14 @@ IF (WellHeadOpen .OR. NoGasPocket == 0) THEN !! (mud circulation is normal we IF (FlowEl(OpenholeFirstEl - 1)%FlowRate < 0.0) THEN WRITE (*,*) ' Negative choke flowrate' - FlowEl(OpenholeFirstEl - 1)%FlowRate = MAX((REAL(MudSystemDotMudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0) + FlowEl(OpenholeFirstEl - 1)%FlowRate = MAX((REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0) END IF !Kchoke = ChokeDensity / ((2. * 89158.0) * (0.26 * 0.61 * TotalOpenChokeArea)**2) - deltaPchoke = (Kchoke * FlowEl(OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(OpenholeFirstEl - 1)%FlowRate)) * 1.d0 + MudSystem%deltaPchoke = (Kchoke * FlowEl(OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(OpenholeFirstEl - 1)%FlowRate)) * 1.d0 !WRITE (*,*) '**deltaPchoke , Kchoke, choke flowrate' , deltaPchoke , Kchoke, FlowEl(i)%FlowRate !WRITE (*,*) '**TotalOpenChokeArea , Total Open Choke Area Percent' , TotalOpenChokeArea , TotalOpenChokeArea / 4.0 * ChokeAreaFullyOpen - IF (deltaPchoke < 0.d0) deltaPchoke = 0.d0 - BackPressure = REAL(deltaPchoke) + IF (MudSystem%deltaPchoke < 0.d0) MudSystem%deltaPchoke = 0.d0 + BackPressure = REAL(MudSystem%deltaPchoke) !WRITE (*,*) ' Choke inlet FlowRate, Density, pressure' , FlowEl(j)%FlowRate, FlowEl(j)%Density, FlowEl(j)%StartPress !WRITE (*,*) ' Choke outlet Density' , FlowEl(i)%Density !WRITE (*,*) ' deltaPchoke , choke flowrate' , deltaPchoke , FlowEl(i)%FlowRate @@ -319,7 +319,7 @@ END IF !!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !IF (ChokeKroneckerDelta == 1) THEN - ! WRITE (*,*) ' ChokeLine flowrate' , FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%FlowRate , stringflowrate + ! WRITE (*,*) ' ChokeLine flowrate' , FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%FlowRate , MudSystem%StringFlowRate ! !i = NoHorizontalEl + NoStringEl + NoAnnulusEl ! !j = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl ! !WRITE (*,*) ' Well Outlet and Chokeline Outlet Pressure' , FlowEl(i)%EndPress, FlowEl(j)%EndPress diff --git a/FluidFlow/Fluid_Flow_Solver.f90 b/FluidFlow/Fluid_Flow_Solver.f90 index c340812..7a42dcd 100644 --- a/FluidFlow/Fluid_Flow_Solver.f90 +++ b/FluidFlow/Fluid_Flow_Solver.f90 @@ -21,7 +21,7 @@ subroutine Fluid_Flow_Solver !WRITE (*,*) ' fluid flow pointer 2' - MudSystemDotFluidFlowCounter = MudSystemDotFluidFlowCounter + 1 + MudSystem%FluidFlowCounter = MudSystem%FluidFlowCounter + 1 call CirculationCodeSelect diff --git a/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 b/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 index 200dea1..a3990bf 100644 --- a/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 +++ b/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 @@ -48,14 +48,14 @@ SUBROUTINE PressureHorizAndStringDistribution BitPressLoss = 0.0 WellHeadWasOpen = WellHeadOpen - WellToChokeManifoldWasOpen = WellToChokeManifoldOpen + WellToChokeManifoldWasOpen = MudSystem%WellToChokeManifoldOpen KickWasExitingThroughChoke = .FALSE. - IF (MudSystemDotUtubeMode1Activated .OR. FloatValveWasOpen == .FALSE.) THEN ! Horizontal line flow rate + IF (MudSystem%UtubeMode1Activated .OR. FloatValveWasOpen == .FALSE.) THEN ! Horizontal line flow rate FlowEl(1 : NoHorizontalEl)%FlowRate = 0.0 ELSE ! connection and line is open - FlowEl(1 : NoHorizontalEl)%FlowRate = MudSystemDotStringFlowRate ! pump flow rate [gpm] + FlowEl(1 : NoHorizontalEl)%FlowRate = MudSystem%StringFlowRate ! pump flow rate [gpm] END IF !WRITE (*,*) 'a)A/B P Bit', StaticHeadOnBit , FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) @@ -87,15 +87,15 @@ SUBROUTINE PressureHorizAndStringDistribution ELSE ! No gas pocket, wellhead is closed and mud is compressed based on volume pumped into annulus AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * AnnMudVol) - AnnCompressedMudVol = AnnCompressedMudVol + REAL(MudSystemDotAnn_Saved_MudDischarged_Volume_Final) !!!!!!!!! - AnnCompressedMudVol = MAX((AnnCompressedMudVol - REAL(MudSystemDotQlost / ConvMinToSec / dt)) , 0.0) + AnnCompressedMudVol = AnnCompressedMudVol + REAL(MudSystem%Ann_Saved_MudDischarged_Volume_Final) !!!!!!!!! + AnnCompressedMudVol = MAX((AnnCompressedMudVol - REAL(MudSystem%Qlost / ConvMinToSec / dt)) , 0.0) AnnDeltaPDueToCompressibility = AnnCompressedMudVol / (MudCompressibility * AnnMudVol) END IF - IF (FloatValveIn == .FALSE. .OR. NoGasPocket == 0 .OR. (FloatValveWasOpen .AND. REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol)) THEN ! float valve remains open + IF (FloatValveIn == .FALSE. .OR. NoGasPocket == 0 .OR. (FloatValveWasOpen .AND. REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol)) THEN ! float valve remains open FloatValveOpen = .TRUE. - FlowEl(StringFirstEl : StringLastEl)%FlowRate = REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) / dt * ConvMinToSec !StringFlowRate ! String flow rate pump flow rate [gpm] + FlowEl(StringFirstEl : StringLastEl)%FlowRate = REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) / dt * ConvMinToSec !MudSystem%StringFlowRate ! String flow rate pump flow rate [gpm] !!!!!!!!!!!!!!! Calculating frictional pressure loss IF (WellHeadOpen) THEN @@ -114,41 +114,41 @@ SUBROUTINE PressureHorizAndStringDistribution !IF (ABS(MudVolume_InjectedToBH - St_Saved_MudDischarged_Volume_Final)> PumpMinDischargedVol) WRITE (*,*) 'Injected to BH & St Saved Mud', MudVolume_InjectedToBH , St_Saved_MudDischarged_Volume_Final IF (BitTotallyPluged) THEN - MudSystemDotMudVolume_InjectedToBH = 0.d0 - StCompressedMudVol = StCompressedMudVol + REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) + MudSystem%MudVolume_InjectedToBH = 0.d0 + StCompressedMudVol = StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility ELSE IF (WellHeadOpen .OR. NoGasPocket > 0) THEN - IF (REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN + IF (REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN - MudSystemDotMudVolume_InjectedToBH = MudSystemDotSt_Saved_MudDischarged_Volume_Final + MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final !WRITE (*,*) 'MudVolume_InjectedToBH,BitTrue', MudVolume_InjectedToBH !IF (BitTrue .AND. UtubeMode1Activated == .FALSE.) THEN IF (BitTrue) THEN - BitPressLoss = KBit * (MudSystemDotMudVolume_InjectedToBH * ConvMinToSec / dt)**2 + BitPressLoss = KBit * (MudSystem%MudVolume_InjectedToBH * ConvMinToSec / dt)**2 !WRITE (*,*) 'BitPressLoss', BitPressLoss END IF StCompressedMudVol = BitPressLoss / StDeltaPtoDeltaVCompressibility ELSE - MudSystemDotMudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility + SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & + MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility + SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & / StDeltaPtoDeltaVCompressibility ) * 1.d0)) - MudSystemDotMudVolume_InjectedToBH = MIN(MudSystemDotMudVolume_InjectedToBH , StCompressedMudVol) - StCompressedMudVol = StCompressedMudVol - MudSystemDotMudVolume_InjectedToBH + MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , StCompressedMudVol) + StCompressedMudVol = StCompressedMudVol - MudSystem%MudVolume_InjectedToBH END IF StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) ELSE ! IF (NoGasPocket == 0 .AND. WellHeadOpen == .FALSE.) THEN - StCompressedMudVol = StCompressedMudVol + REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) + StCompressedMudVol = StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility - MudSystemDotMudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & + MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & / (StDeltaPtoDeltaVCompressibility + AnnDeltaPtoDeltaVCompressibility)) * 1.d0) - MudSystemDotMudVolume_InjectedToBH = MIN(MudSystemDotMudVolume_InjectedToBH , StCompressedMudVol) - StCompressedMudVol = StCompressedMudVol - REAL(MudSystemDotMudVolume_InjectedToBH) + MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , StCompressedMudVol) + StCompressedMudVol = StCompressedMudVol - REAL(MudSystem%MudVolume_InjectedToBH) StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) FlowEl(AnnulusFirstEl : NumbEl)%StartPress = FlowEl(AnnulusFirstEl : NumbEl)%StartPress + StDeltaPDueToCompressibility FlowEl(AnnulusFirstEl : NumbEl)%EndPress = FlowEl(AnnulusFirstEl : NumbEl)%EndPress + StDeltaPDueToCompressibility @@ -182,14 +182,14 @@ SUBROUTINE PressureHorizAndStringDistribution !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open and remains open - ELSE IF (REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) < PumpMinDischargedVol) THEN ! NoGasPocket > 0 + ELSE IF (REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) < PumpMinDischargedVol) THEN ! NoGasPocket > 0 FloatValveOpen = FloatValveWasOpen ! remains in its former status IF (FloatValveOpen) THEN PressAboveFloatValve = MAX(FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(StringFirstEl)%Density * FlowEl(StringFirstEl)%StartTVD) ELSE PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility - MudSystemDotMudVolume_InjectedToBH = 0.d0 + MudSystem%MudVolume_InjectedToBH = 0.d0 END IF @@ -204,12 +204,12 @@ SUBROUTINE PressureHorizAndStringDistribution END IF IF (FloatValveOpen) THEN - MudSystemDotMudVolume_InjectedToBH = MAX( 0.d0 , 0.1 * REAL((PressAboveFloatValve - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & + MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , 0.1 * REAL((PressAboveFloatValve - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & / StDeltaPtoDeltaVCompressibility ) * 1.d0) - MudSystemDotMudVolume_InjectedToBH = MIN(MudSystemDotMudVolume_InjectedToBH , StCompressedMudVol) + MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , StCompressedMudVol) !WRITE (*,*) 'MudVolume_InjectedToBH (No Pump)', MudVolume_InjectedToBH - StCompressedMudVol = StCompressedMudVol - MudSystemDotMudVolume_InjectedToBH + StCompressedMudVol = StCompressedMudVol - MudSystem%MudVolume_InjectedToBH StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) !WRITE (*,*) 'StDeltaPDueToCompressibility(No Pump)', StDeltaPDueToCompressibility @@ -251,11 +251,11 @@ SUBROUTINE PressureHorizAndStringDistribution !WRITE (*,*) ' AnnCompressedMudVol, AnnDeltaPDueToCompressibility',AnnCompressedMudVol, AnnDeltaPDueToCompressibility !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open (close) and maybe remains open (close) or maybe closed - ELSE IF(FloatValveWasOpen == .FALSE. .AND. REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN + ELSE IF(FloatValveWasOpen == .FALSE. .AND. REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN FloatValveOpen = .FALSE. - MudSystemDotMudVolume_InjectedToBH = 0.d0 + MudSystem%MudVolume_InjectedToBH = 0.d0 - StCompressedMudVol = StCompressedMudVol + REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) + StCompressedMudVol = StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility @@ -284,7 +284,7 @@ SUBROUTINE PressureHorizAndStringDistribution END IF - IF ((MudSystemDotUtubePossibility == .TRUE. .AND. Get_KellyConnection() /= KELLY_CONNECTION_STRING) .OR. MudSystemDotNewPipeFilling == 0) THEN + IF ((MudSystem%UtubePossibility == .TRUE. .AND. Get_KellyConnection() /= KELLY_CONNECTION_STRING) .OR. MudSystem%NewPipeFilling == 0) THEN FlowEl(NoHorizontalEl)%EndPress = 0.0 ELSE IF (WellHeadOpen == .FALSE.) THEN FlowEl(NoHorizontalEl)%EndPress = FlowEl(StringFirstEl)%StartPress - 0.052 * FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD @@ -335,32 +335,32 @@ SUBROUTINE PressureHorizAndStringDistribution !END IF - IF (MudSystemDotUtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadOpen) THEN - MudSystemDotMudVolume_InjectedToBH = 0.d0 - MudVolume_InjectedFromAnn = 0.d0 + IF (MudSystem%UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadOpen) THEN + MudSystem%MudVolume_InjectedToBH = 0.d0 + MudSystem%MudVolume_InjectedFromAnn = 0.d0 !ELSE ! ! IF (FloatValveOpen .AND. WellHeadOpen .AND. NoGasPocket == 0) THEN ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility - FloatValveMinOpenPressure) / StDeltaPtoDeltaVCompressibility) * 1.d0) - ! !MudVolume_InjectedFromAnn = Ann_Saved_MudDischarged_Volume_Final !REAL((AnnDeltaPDueToCompressibility - BackPressure) / AnnDeltaPtoDeltaVCompressibility) * 1.d0 + ! !MudSystem%MudVolume_InjectedFromAnn = Ann_Saved_MudDischarged_Volume_Final !REAL((AnnDeltaPDueToCompressibility - BackPressure) / AnnDeltaPtoDeltaVCompressibility) * 1.d0 ! !WRITE (*,*) 'Pressure above/under bit', FlowEl(NoHorizontalEl + NoStringEl)%EndPress, FlowEl(1 + NoHorizontalEl + NoStringEl)%StartPress ! IF (MudVolume_InjectedToBH <= 0) MudVolume_InjectedToBH = 0.d0 - ! !IF (MudVolume_InjectedFromAnn <= 0) MudVolume_InjectedFromAnn = 0.d0 + ! !IF (MudSystem%MudVolume_InjectedFromAnn <= 0) MudSystem%MudVolume_InjectedFromAnn = 0.d0 ! ELSE IF (FloatValveOpen .AND. WellHeadOpen == .FALSE. .AND. NoGasPocket == 0) THEN ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((PressAboveFloatValve + StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - PressBelowFloatValve - FloatValveMinOpenPressure) & ! / (StDeltaPtoDeltaVCompressibility - AnnDeltaPtoDeltaVCompressibility)) * 1.d0) - ! MudVolume_InjectedFromAnn = 0.d0 + ! MudSystem%MudVolume_InjectedFromAnn = 0.d0 ! ELSE IF (FloatValveOpen .AND. WellHeadOpen .AND. NoGasPocket > 0) THEN ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((PressAboveFloatValve + StDeltaPDueToCompressibility - PressBelowFloatValve - FloatValveMinOpenPressure) / StDeltaPtoDeltaVCompressibility) * 1.d0) - ! ! MudVolume_InjectedFromAnn = REAL(Ann_Saved_MudDischarged_Volume_Final) * 1.d0 + ! ! MudSystem%MudVolume_InjectedFromAnn = REAL(Ann_Saved_MudDischarged_Volume_Final) * 1.d0 ! ELSE IF (FloatValveOpen .AND. WellHeadOpen == .FALSE. .AND. NoGasPocket > 0) THEN ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((PressAboveFloatValve + StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - PressBelowFloatValve - FloatValveMinOpenPressure) & ! / (StDeltaPtoDeltaVCompressibility - AnnDeltaPtoDeltaVCompressibility)) * 1.d0) - ! MudVolume_InjectedFromAnn = 0.d0 + ! MudSystem%MudVolume_InjectedFromAnn = 0.d0 ! END IF !StCompressedMudVol = MAX(StCompressedMudVol - REAL(MudVolume_InjectedToBH) , 0.0) - !AnnCompressedMudVol = MAX(AnnCompressedMudVol - REAL(MudVolume_InjectedFromAnn) , 0.0) + !AnnCompressedMudVol = MAX(AnnCompressedMudVol - REAL(MudSystem%MudVolume_InjectedFromAnn) , 0.0) !StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) !AnnDeltaPDueToCompressibility = AnnCompressedMudVol / (MudCompressibility * AnnMudVol) END IF @@ -370,9 +370,9 @@ SUBROUTINE PressureHorizAndStringDistribution !MudVolume_InjectedToBH = St_Saved_MudDischarged_Volume_Final !WRITE (*,*) 'CompMudVol, DeltaP, MudVolumeInjected' !WRITE (*,*) StCompressedMudVol, StDeltaPDueToCompressibility, REAL(MudVolume_InjectedToBH) - !WRITE (*,*) AnnCompressedMudVol, AnnDeltaPDueToCompressibility, REAL(MudVolume_InjectedFromAnn) + !WRITE (*,*) AnnCompressedMudVol, AnnDeltaPDueToCompressibility, REAL(MudSystem%MudVolume_InjectedFromAnn) !WRITE (*,*) 'Press above/Below Float valve ', FlowEl(NoHorizontalEl + NoStringEl)%EndPress , FlowEl(NoHorizontalEl + NoStringEl + 1)%StartPress - !write(*,*) 'MudVolume_InjectedFromAnn***=' , MudVolume_InjectedFromAnn, Ann_Saved_MudDischarged_Volume_Final + !write(*,*) 'MudSystem%MudVolume_InjectedFromAnn***=' , MudSystem%MudVolume_InjectedFromAnn, Ann_Saved_MudDischarged_Volume_Final 110 FORMAT (I6 , 4X , F6.2 , 7X , F4.2 , 3X , F4.1 , 2X , F4.2) @@ -394,7 +394,7 @@ SUBROUTINE PressureHorizAndStringDistribution i = i + 1 IF (i > NoHorizontalEl) EXIT END DO - CALL PumpPressureDelay%AddToFirst(REAL(FlowEl(i)%StartPress - 0.052 * (STpipeGauge_Height / Convfttom) * FlowEl(i)%Density + (FlowEl(i)%StartX + 170) * FlowEl(i)%dPdLFric)) + CALL PumpPressureDelay%AddToFirst(REAL(FlowEl(i)%StartPress - 0.052 * (MudSystem%STpipeGauge_Height / Convfttom) * FlowEl(i)%Density + (FlowEl(i)%StartX + 170) * FlowEl(i)%dPdLFric)) CALL PumpPressureDelay%Remove(PressureTimeStepDelay(1) + 1) !IF (ANY(PUMP(:)%PowerFailMalf == 1)) PumpPressureDelay%Array(1 : PressureTimeStepDelay(1) / 2) = 0.0 !seyyed goft vaghti pumpfailure mishavad feshar dasti 0 nashavad, be in dalil in khat comment shod. @@ -426,7 +426,7 @@ SUBROUTINE PressureHorizAndStringDistribution !!! in normal mode changes in choke position immidiately observes in casing pressure !! but when pumps off due to failure, casing pressure will drop after a delay time - IF (WellToChokeManifoldOpen .OR. WellToChokeLineGauge) THEN + IF (MudSystem%WellToChokeManifoldOpen .OR. MudSystem%WellToChokeLineGauge) THEN !WRITE (*,*) 'Here 1' CALL CasingPressureDelay%AddToFirst(FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%EndPress) CALL CasingPressureDelay%Remove(PressureTimeStepDelay(1) + 1) @@ -538,8 +538,8 @@ SUBROUTINE PressureHorizAndStringDistribution !IF (PressureGauges(5) >= FormationLostPressure) WRITE (*,*) 'Near Shoe Flowrate', FlowEl(ShoeFlowElNo)%FlowRate - MudSystemDotShoeMudViscosity = FlowEl(ShoeFlowElNo)%MuEff - MudSystemDotShoeMudDensity = FlowEl(ShoeFlowElNo)%Density + MudSystem%ShoeMudViscosity = FlowEl(ShoeFlowElNo)%MuEff + MudSystem%ShoeMudDensity = FlowEl(ShoeFlowElNo)%Density !WRITE (*,*) 'Drillstring speed (ft/s)' , DrillStringSpeed !WRITE (*,*) 'shoe mud speed ', FlowEl(ShoeFlowElNo - 1)%vel @@ -584,7 +584,7 @@ SUBROUTINE PressureHorizAndStringDistribution !WRITE (*,*) ' Kick Iteration', KickIteration - !WRITE (*,*) ' Kchoke, Q =', Kchoke, FlowEl(j)%Flowrate !, REAL((DeltaVolumePipe * ConvMinToSec / dt) + StringFlowRate) + !WRITE (*,*) ' Kchoke, Q =', Kchoke, FlowEl(j)%Flowrate !, REAL((DeltaVolumePipe * ConvMinToSec / dt) + MudSystem%StringFlowRate) !DO l = NoHorizontalEl + NoStringEl + 1 , NumbEl ! WRITE (*,*) 'El No, Fric Press Loss, density , Q', l, FlowEl(l)%FricPressLoss, FlowEl(l)%StaticPressDiff, FlowEl(l)%Density, FlowEl(l)%Flowrate !END DO diff --git a/FluidFlow/Well_Pressure_Data_Transfer.f90 b/FluidFlow/Well_Pressure_Data_Transfer.f90 index 9cd0487..6a45571 100644 --- a/FluidFlow/Well_Pressure_Data_Transfer.f90 +++ b/FluidFlow/Well_Pressure_Data_Transfer.f90 @@ -15,7 +15,7 @@ SUBROUTINE WellPressureDataTransfer !! which causes acceleration or decceleration of flow USE FricPressDropVars - USE MudSystem + use MudSystemModule USE MudSystemVARIABLES USE GeoElements_FluidModule USE Fluid_Flow_Startup_Vars @@ -74,7 +74,7 @@ SUBROUTINE WellPressureDataTransfer ChokeKroneckerDelta = 0 - IF (WelltoPitsOpen == .FALSE. .AND. WellToChokeManifoldOpen == .FALSE.) THEN + IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN WellHeadOpen = .FALSE. !WRITE (*,*) ' Well Head is closed ' @@ -82,18 +82,18 @@ SUBROUTINE WellPressureDataTransfer WellHeadOpen = .TRUE. END IF - IF (WelltoPitsOpen == .FALSE. .AND. WellToChokeManifoldOpen) ChokeKroneckerDelta = 1 + IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen) ChokeKroneckerDelta = 1 !WRITE (*,*) ' WelltoPitsOpen=' , WelltoPitsOpen, 'WellToChokeManifoldOpen= ' , WellToChokeManifoldOpen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - NoHorizontalEl = MudSystemDotNoHorizontalMudElements - NoStringEl = MudSystemDotNoStringMudElements - NoAnnulusEl = MudSystemDotNoCasingMudElements + NoHorizontalEl = MudSystem%NoHorizontalMudElements + NoStringEl = MudSystem%NoStringMudElements + NoAnnulusEl = MudSystem%NoCasingMudElements NoWellToChokeEl = 0 - IF (ChokeKroneckerDelta == 1) NoWellToChokeEl = MudSystemDotChokeLine_Density%Length() - NoOpenHoleEl = MudSystemDotNoBottomHoleMudElements + IF (ChokeKroneckerDelta == 1) NoWellToChokeEl = MudSystem%ChokeLine_Density%Length() + NoOpenHoleEl = MudSystem%NoBottomHoleMudElements NumbEl = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl + NoOpenHoleEl !WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl IF(ALLOCATED(FlowEl)) DEALLOCATE(FlowEl) @@ -103,21 +103,21 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!!!!!!!!!! Horizontal line !WRITE (*,*) 'H', NoHorizontalEl DO i = 1 , NoHorizontalEl - FlowEl(i)%StartX = Xstart_MudElement%Array(i) - FlowEl(i)%EndX = Xend_MudElement%Array(i) + FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) + FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) FlowEl(i)%StartTVD = 0.d0 FlowEl(i)%EndTVD = 0.d0 FlowEl(i)%Id = 0.0 - FlowEl(i)%Od = PipeOD_MudElement%Array(i) - FlowEl(i)%density = Density_MudElement%Array(i) + FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) + FlowEl(i)%density = MudSystem%Density_MudElement%Array(i) FlowEl(i)%Dhyd = FlowEl(i)%Od FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = 0.d0 FlowEl(i)%Volume = PI / 4.0 * FlowEl(i)%Od**2 * REAL(FlowEl(i)%Length) / Convfttoinch**2 - IF (MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudType_MudElement%Array(i) == 4) THEN + ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -139,19 +139,19 @@ SUBROUTINE WellPressureDataTransfer StringLastEl = NoHorizontalEl + NoStringEl DO i = NoHorizontalEl + 1 , NoHorizontalEl + NoStringEl !WRITE (*,*) 'ST , i' , i - FlowEl(i)%StartX = Xstart_MudElement%Array(i) + FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) !WRITE (*,*) 'StartX', FlowEl(i)%StartX - FlowEl(i)%EndX = Xend_MudElement%Array(i) + FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) !WRITE (*,*) 'EndX', FlowEl(i)%EndX - FlowEl(i)%StartTVD = TVDstart_MudElement%Array(i) + FlowEl(i)%StartTVD = MudSystem%TVDstart_MudElement%Array(i) !WRITE (*,*) 'StartTVD', FlowEl(i)%StartTVD - FlowEl(i)%EndTVD = TVDend_MudElement%Array(i) + FlowEl(i)%EndTVD = MudSystem%TVDend_MudElement%Array(i) !WRITE (*,*) 'EndTVD', FlowEl(i)%EndTVD FlowEl(i)%Id = 0.0 !WRITE (*,*) 'Id', FlowEl(i)%Id - FlowEl(i)%Od = PipeOD_MudElement%Array(i) + FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) !WRITE (*,*) 'Od', FlowEl(i)%Od - FlowEl(i)%Density = Density_MudElement%Array(i) + FlowEl(i)%Density = MudSystem%Density_MudElement%Array(i) !WRITE (*,*) 'Density', FlowEl(i)%Density @@ -162,9 +162,9 @@ SUBROUTINE WellPressureDataTransfer !WRITE (*,*) 'DepthDiff', FlowEl(i)%DepthDiff FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudType_MudElement%Array(i) == 4) THEN + ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -190,22 +190,22 @@ SUBROUTINE WellPressureDataTransfer AnnulusFirstEl = NoHorizontalEl + NoStringEl + 1 AnnulusLastEl = NoHorizontalEl + NoStringEl + NoAnnulusEl DO i = NoHorizontalEl + NoStringEl + 1 , NoHorizontalEl + NoStringEl + NoAnnulusEl - FlowEl(i)%StartX = Xstart_MudElement%Array(i) - FlowEl(i)%EndX = Xend_MudElement%Array(i) - FlowEl(i)%StartTVD = TVDstart_MudElement%Array(i) - FlowEl(i)%EndTVD = TVDend_MudElement%Array(i) - FlowEl(i)%Id = PipeID_MudElement%Array(i) - FlowEl(i)%Od = PipeOD_MudElement%Array(i) - FlowEl(i)%Density = Density_MudElement%Array(i) + FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) + FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) + FlowEl(i)%StartTVD = MudSystem%TVDstart_MudElement%Array(i) + FlowEl(i)%EndTVD = MudSystem%TVDend_MudElement%Array(i) + FlowEl(i)%Id = MudSystem%PipeID_MudElement%Array(i) + FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) + FlowEl(i)%Density = MudSystem%Density_MudElement%Array(i) FlowEl(i)%Dhyd = FlowEl(i)%Od - FlowEl(i)%Id FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = ABS(FlowEl(i)%StartTVD - FlowEl(i)%EndTVD) FlowEl(i)%Area = PI / 4.0 * (FlowEl(i)%Od**2 - FlowEl(i)%Id**2) / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudType_MudElement%Array(i) == 4) THEN + ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -230,21 +230,21 @@ SUBROUTINE WellPressureDataTransfer !ChokeLastEl = OpenholeFirstEl - 1 j = 1 DO i = NoHorizontalEl + NoStringEl + NoAnnulusEl + 1 , NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWelltoChokeEl - FlowEl(i)%StartX = MudSystemDotChokeLine_Mud_Backhead_X%Array(j) - FlowEl(i)%EndX = MudSystemDotChokeLine_Mud_Forehead_X%Array(j) + FlowEl(i)%StartX = MudSystem%ChokeLine_Mud_Backhead_X%Array(j) + FlowEl(i)%EndX = MudSystem%ChokeLine_Mud_Forehead_X%Array(j) FlowEl(i)%StartTVD = 0.d0 FlowEl(i)%EndTVD = 0.d0 FlowEl(i)%Id = 0.0 FlowEl(i)%Od = BopStackSpecification%ChokeLineId - FlowEl(i)%density = MudSystemDotChokeLine_Density%Array(j) + FlowEl(i)%density = MudSystem%ChokeLine_Density%Array(j) FlowEl(i)%Dhyd = FlowEl(i)%Od FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = 0.d0 FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (ChokeLine_MudOrKick%Array(j) == 0 .OR. ChokeLine_MudOrKick%Array(j) == 4) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air - FlowEl(i)%MaterialType = ChokeLine_MudOrKick%Array(j) + IF (MudSystem%ChokeLine_MudOrKick%Array(j) == 0 .OR. MudSystem%ChokeLine_MudOrKick%Array(j) == 4) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + FlowEl(i)%MaterialType = MudSystem%ChokeLine_MudOrKick%Array(j) ELSE FlowEl(i)%MaterialType = 1 END IF @@ -266,23 +266,23 @@ SUBROUTINE WellPressureDataTransfer OpenholeFirstEl = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWelltoChokeEl + 1 j = 1 DO i = OpenholeFirstEl , NumbEl ! = NoHorizontalEl + NoStringEl + NoCasingEl + NoOpenHoleEl - FlowEl(i)%StartX = Xstart_OpMudElement%Array(j) - FlowEl(i)%EndX = Xend_OpMudElement%Array(j) - FlowEl(i)%StartTVD = TVDstart_OpMudElement%Array(j) - FlowEl(i)%EndTVD = TVDend_OpMudElement%Array(j) + FlowEl(i)%StartX = MudSystem%Xstart_OpMudElement%Array(j) + FlowEl(i)%EndX = MudSystem%Xend_OpMudElement%Array(j) + FlowEl(i)%StartTVD = MudSystem%TVDstart_OpMudElement%Array(j) + FlowEl(i)%EndTVD = MudSystem%TVDend_OpMudElement%Array(j) FlowEl(i)%Id = 0.0 - FlowEl(i)%Od = PipeOD_OpMudElement%Array(j) - FlowEl(i)%density = Density_OpMudElement%Array(j) - FlowEl(i)%MaterialType = MudTypeOP_MudElement%Array(j) ! = 0 for mud, = 1 for gas kick, = 4 for air + FlowEl(i)%Od = MudSystem%PipeOD_OpMudElement%Array(j) + FlowEl(i)%density = MudSystem%Density_OpMudElement%Array(j) + FlowEl(i)%MaterialType = MudSystem%MudTypeOp_MudElement%Array(j) ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%Dhyd = FlowEl(i)%Od FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = ABS(FlowEl(i)%StartTVD - FlowEl(i)%EndTVD) FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudTypeOp_MudElement%Array(j) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (MudSystem%MudTypeOp_MudElement%Array(j) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudTypeOp_MudElement%Array(j) == 4) THEN + ELSE IF (MudSystem%MudTypeOp_MudElement%Array(j) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -341,24 +341,24 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - OpenArea32 = ((ChokeManifold%LeftManualChoke * (1.0 - ManChoke1Plug * REAL(ChokeProblems%ManualChoke1PluggedPercent)) / 100.0) + 0.5 * ManChoke1Washout) * Choke%ChokeAreaFullyOpen - OpenArea33 = CHOOKE(1)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(1)%PercentClose) * ChokeAreaFullyOpen - OpenArea34 = CHOOKE(2)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(2)%PercentClose) * ChokeAreaFullyOpen - OpenArea35 = ((ChokeManifold%RightManualChoke * (1.0 - ManChoke2Plug * REAL(ChokeProblems%ManualChoke2PluggedPercent)) / 100.0) + 0.5 * ManChoke2Washout) * Choke%ChokeAreaFullyOpen + MudSystem%OpenArea32 = ((ChokeManifold%LeftManualChoke * (1.0 - ManChoke1Plug * REAL(ChokeProblems%ManualChoke1PluggedPercent)) / 100.0) + 0.5 * ManChoke1Washout) * Choke%ChokeAreaFullyOpen + MudSystem%OpenArea33 = CHOOKE(1)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(1)%PercentClose) * ChokeAreaFullyOpen + MudSystem%OpenArea34 = CHOOKE(2)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(2)%PercentClose) * ChokeAreaFullyOpen + MudSystem%OpenArea35 = ((ChokeManifold%RightManualChoke * (1.0 - ManChoke2Plug * REAL(ChokeProblems%ManualChoke2PluggedPercent)) / 100.0) + 0.5 * ManChoke2Washout) * Choke%ChokeAreaFullyOpen !write(*,*) 'OpenArea32=' , OpenArea32, active32, ManChoke1Plug, ManualChoke1PluggedPercent, ManChoke1Washout !write(*,*) 'OpenArea33=' , OpenArea33, active33 !write(*,*) 'OpenArea34=' , OpenArea34, active34, !HydraulicChoke2PluggedPercent !write(*,*) 'OpenArea35=' , OpenArea35, active35, ManChoke2Plug, ManualChoke2PluggedPercent, ManChoke2Washout - InstantaneousTotalOpenChokeArea = OpenArea32 * active32 + OpenArea33 * active33 + OpenArea34 * active34 + OpenArea35 * active35 + ChokeBypassArea * active29 + InstantaneousTotalOpenChokeArea = MudSystem%OpenArea32 * active32 + MudSystem%OpenArea33 * active33 + MudSystem%OpenArea34 * active34 + MudSystem%OpenArea35 * active35 + ChokeBypassArea * active29 OldTotalOpenChokeArea = TotalOpenChokeArea !WRITE (*,*) 'Instantaneous / Old TotalOpenChokeArea', InstantaneousTotalOpenChokeArea, OldTotalOpenChokeArea IF (OldTotalOpenChokeArea <= 0.01 * Choke%ChokeAreaFullyOpen) OldTotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen IF (InstantaneousTotalOpenChokeArea <= 0.01 * Choke%ChokeAreaFullyOpen) THEN - WellToChokeManifoldOpen = .FALSE. + MudSystem%WellToChokeManifoldOpen = .FALSE. OldTotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen !WRITE (*,*) ' Choke Controler Here 2' - ELSE IF (InstantaneousTotalOpenChokeArea > 0.5 * Choke%ChokeAreaFullyOpen .OR. WelltoPitsOpen) THEN + ELSE IF (InstantaneousTotalOpenChokeArea > 0.5 * Choke%ChokeAreaFullyOpen .OR. MudSystem%WellToPitsOpen) THEN ! mud flows through well to bell nipple, or choke is rather open TotalOpenChokeArea = InstantaneousTotalOpenChokeArea !WRITE (*,*) ' Choke Controler Here 1' @@ -386,7 +386,7 @@ SUBROUTINE WellPressureDataTransfer ChokeKroneckerDelta = 0 !WRITE (*,*) ' WelltoPitsOpen = ', WelltoPitsOpen !WRITE (*,*) ' WellToChokeManifoldOpen = ', WellToChokeManifoldOpen - IF (WelltoPitsOpen == .FALSE. .AND. WellToChokeManifoldOpen == .FALSE.) THEN + IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN !WRITE (*,*) ' WelltoPitsOpen = ', WelltoPitsOpen !WRITE (*,*) ' WellToChokeManifoldOpen = ', WellToChokeManifoldOpen @@ -396,21 +396,21 @@ SUBROUTINE WellPressureDataTransfer WellHeadOpen = .TRUE. END IF - IF (WelltoPitsOpen == .FALSE. .AND. WellToChokeManifoldOpen) ChokeKroneckerDelta = 1 + IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen) ChokeKroneckerDelta = 1 !WRITE (*,*) ' WelltoPitsOpen=' , WelltoPitsOpen, 'WellToChokeManifoldOpen= ' , WellToChokeManifoldOpen !WRITE (*,*) 'WellToChokeOpen , WellToChokeWasOpen', WellToChokeManifoldOpen, WellToChokeManifoldWasOpen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IF (NoGasPocket > 0) THEN !IF (NoWelltoChokeEl > 0 .AND. (FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .OR. KickWasExitingThroughChoke) .AND. WellHeadOpen) THEN - IF (MudSystemDotChoke_Kick_Saved_Volume_Final > 0.d0) THEN + IF (MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0) THEN !WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', Choke_Kick_Saved_Volume_Final, (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal) - ExitMass = REAL(MudSystemDotChoke_Kick_Saved_Volume_Final / (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal)) * GasPocketWeight%Array(NoGasPocket) + ExitMass = REAL(MudSystem%Choke_Kick_Saved_Volume_Final / (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal)) * GasPocketWeight%Array(NoGasPocket) !IF (NoGasPocket > 1) ExitMass = ExitMass + (SUM(GasPocketDeltaVol%Array(1 : NoGasPocket - 1)) / GasPocketNewVol%Array(NoGasPocket)) * GasPocketWeight%Array(NoGasPocket) - !WRITE (*,*) 'Total Exit mass=' , ExitMass !, DeltaVolumePipe, StringFlowRate * dt / ConvMinToSec + !WRITE (*,*) 'Total Exit mass=' , ExitMass !, DeltaVolumePipe, MudSystem%StringFlowRate * dt / ConvMinToSec IF (FlowEl(OpenholeFirstEl - 1)%MaterialType /= 1) THEN CALL RemoveGasPocket(NoGasPocket) - WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', MudSystemDotChoke_Kick_Saved_Volume_Final + WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', MudSystem%Choke_Kick_Saved_Volume_Final END IF END IF @@ -604,9 +604,9 @@ SUBROUTINE GasPocketFlowElementTransformer i = OpenholeFirstEl - 1 !WRITE (*,*) 'MaterialType, NoWelltoChokeEl', FlowEl(i)%MaterialType , NoWelltoChokeEl !IF (NoWelltoChokeEl > 0 .AND. FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .AND. WellHeadOpen) THEN ! kick is last element in choke line and does not exit. - IF (MudSystemDotChoke_Kick_Saved_Volume_Final > 0.d0 .AND. WellHeadOpen) THEN + IF (MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0 .AND. WellHeadOpen) THEN WRITE (*,*) 'Kick is exiting through the choke' - !ExitMass = GasPocketDensity%Array(NoGasPocket) * (SUM(GasPocketFlowInduced%Array(:)) + (DeltaVolumePipe * ConvMinToSec / dt) + StringFlowRate) / ConvMinToSec * dt + !ExitMass = GasPocketDensity%Array(NoGasPocket) * (SUM(GasPocketFlowInduced%Array(:)) + (DeltaVolumePipe * ConvMinToSec / dt) + MudSystem%StringFlowRate) / ConvMinToSec * dt GasPocketWeight%Array(NoGasPocket) = GasPocketweight%Array(NoGasPocket) - ExitMass IF (GasPocketWeight%Array(NoGasPocket) > 0.0) THEN GasPocketOldPress%Array(NoGasPocket) = GasPocketWeight%Array(NoGasPocket) * GasType(KickGasType)%GasConstant * & diff --git a/FluidFlow/kick/Formation_Information.f90 b/FluidFlow/kick/Formation_Information.f90 index 6e02075..ecdbcb3 100644 --- a/FluidFlow/kick/Formation_Information.f90 +++ b/FluidFlow/kick/Formation_Information.f90 @@ -76,7 +76,7 @@ SUBROUTINE FormationInformationCalculator end if !PermeabilityExposedHeight = KickFormLength * FormationPermeability - DownHole%PermeabilityExposedHeight = MudSystemDotFluidFlowCounter - MudSystemDotMudSys_timeCounter + DownHole%PermeabilityExposedHeight = MudSystem%FluidFlowCounter - MudSystem%MudSys_timeCounter !==================================================== ! Reservoir Data !==================================================== diff --git a/FluidFlow/kick/Gas_Kick_Calculator.f90 b/FluidFlow/kick/Gas_Kick_Calculator.f90 index 99420e8..bd8df89 100644 --- a/FluidFlow/kick/Gas_Kick_Calculator.f90 +++ b/FluidFlow/kick/Gas_Kick_Calculator.f90 @@ -399,9 +399,9 @@ SUBROUTINE NewGasKick WRITE (*,*) ' New Influx 1' NoGasPocket = 1 - MudSystemDotNewInfluxNumber = MudSystemDotNewInfluxNumber + 1 + MudSystem%NewInfluxNumber = MudSystem%NewInfluxNumber + 1 - MudSystemDotNewInfluxElementCreated = 0 + MudSystem%NewInfluxElementCreated = 0 KickOffBottom = .FALSE. @@ -477,9 +477,9 @@ SUBROUTINE NewGasKick NoGasPocket = NoGasPocket + 1 - MudSystemDotNewInfluxNumber = MudSystemDotNewInfluxNumber + 1 + MudSystem%NewInfluxNumber = MudSystem%NewInfluxNumber + 1 - MudSystemDotNewInfluxElementCreated = 0 + MudSystem%NewInfluxElementCreated = 0 KickOffBottom = .FALSE. CALL GasPocketOldPress%AddToFirst((BottomHolePress + StandardPress) * 1.d0) diff --git a/Rop/JetImpactForce.f90 b/Rop/JetImpactForce.f90 index c0b68a1..3efa920 100644 --- a/Rop/JetImpactForce.f90 +++ b/Rop/JetImpactForce.f90 @@ -15,7 +15,7 @@ subroutine JetImpactForce - Bit_Flowrate = MudSystemDotStringFlowRateFinal ![gpm] + Bit_Flowrate = MudSystem%StringFlowRateFinal ![gpm] !print*, 'Bit_Flowrate=' , Bit_Flowrate !check :: Mud_Density [ppg] ?????????? diff --git a/Rop/ROP_MainCalculation.f90 b/Rop/ROP_MainCalculation.f90 index 478a92e..4697512 100644 --- a/Rop/ROP_MainCalculation.f90 +++ b/Rop/ROP_MainCalculation.f90 @@ -84,12 +84,12 @@ subroutine ROP_MainCalculation Critical_Weight_on_Bit = (Formation%Formations(FormationNumber)%ThresholdWeight/5.d0)-(.06d0*(Formation%Formations(FormationNumber)%ThresholdWeight-10.d0)) ! unit : [klb/in] (Typical Range: 0 to 10 ----> 0.6 to 2) !IF (ALLOCATED(FlowEl)) THEN ! Mud_Viscosity = FlowEl(NoHorizontalEl + NoStringEl)%mueff !13.5 [cP] - Mud_Density = MudSystemDotBitMudDensity ! [ppg] + Mud_Density = MudSystem%BitMudDensity ! [ppg] !ELSE Mud_Viscosity = 13.5 ! [cP] !Mud_Density = 9.2 ! [ppg] !END IF - Mud_Flowrate = MudSystemDotStringFlowRateFinal ! [gpm] + Mud_Flowrate = MudSystem%StringFlowRateFinal ! [gpm] Reynolds_Number = Mud_Flowrate*Mud_Density/(Mud_Viscosity*Number_of_Bit_Nozzles*Diameter_of_Bit_Nozzle) ! unit : [dimensionless] (Typical Range: 0.1 to 1000.0) ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$ End of Variable Initialization $$$$$**$$$$$**$$$$$**$$$$$**$$$$$ diff --git a/SimulationCore2.vfproj b/SimulationCore2.vfproj index 76193a2..f890186 100644 --- a/SimulationCore2.vfproj +++ b/SimulationCore2.vfproj @@ -230,7 +230,6 @@ -