Browse Source

in the middle of mudsystem

najafi
mahmood19227 1 year ago
parent
commit
91b93ce96c
24 changed files with 2068 additions and 2087 deletions
  1. +20
    -20
      Equipments/MudSystem/Circulation_Code_Select.f90
  2. +56
    -56
      Equipments/MudSystem/Deallocate_Normal_Circulation.f90
  3. +24
    -24
      Equipments/MudSystem/Disconnecting_Pipe.f90
  4. +100
    -100
      Equipments/MudSystem/Elements_Creation.f90
  5. +21
    -21
      Equipments/MudSystem/FillingWell_By_BellNipple.f90
  6. +31
    -31
      Equipments/MudSystem/Kick_Expansion_and_Contraction.f90
  7. +46
    -46
      Equipments/MudSystem/Kick_Influx.f90
  8. +306
    -306
      Equipments/MudSystem/Kick_Migration.f90
  9. +27
    -27
      Equipments/MudSystem/MudSystem.f90
  10. +41
    -41
      Equipments/MudSystem/MudSystemStartup.f90
  11. +47
    -66
      Equipments/MudSystem/MudSystem_Variables.f90
  12. +92
    -92
      Equipments/MudSystem/Plot_Final_Mud_Elements.f90
  13. +469
    -469
      Equipments/MudSystem/Pump_and_Trip_In.f90
  14. +421
    -421
      Equipments/MudSystem/Trip_Out_andPump.f90
  15. +164
    -164
      Equipments/MudSystem/Utube1_and_Trip_In.f90
  16. +145
    -145
      Equipments/MudSystem/Utube2_and_Trip_In.f90
  17. +6
    -6
      FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90
  18. +1
    -1
      FluidFlow/Fluid_Flow_Solver.f90
  19. +31
    -31
      FluidFlow/Horizontal_and_String_Pressure_Distribution.f90
  20. +12
    -12
      FluidFlow/Well_Pressure_Data_Transfer.f90
  21. +1
    -1
      FluidFlow/kick/Formation_Information.f90
  22. +4
    -4
      FluidFlow/kick/Gas_Kick_Calculator.f90
  23. +1
    -1
      Rop/JetImpactForce.f90
  24. +2
    -2
      Rop/ROP_MainCalculation.f90

+ 20
- 20
Equipments/MudSystem/Circulation_Code_Select.f90 View File

@@ -19,7 +19,7 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
!NewInfluxNumber = NoGasPocket !NewInfluxNumber = NoGasPocket
Flow_timeCounter= Flow_timeCounter+1
MudSystemDotFlow_timeCounter= MudSystemDotFlow_timeCounter+1
!if (ChokePanelStrokeResetSwitch == 1) then !if (ChokePanelStrokeResetSwitch == 1) then
! Flow_timeCounter= 0 ! Flow_timeCounter= 0
@@ -35,7 +35,7 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
!=================================================================== !===================================================================
iloc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data)
MudSystemDotiLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data)
!KickMigration_2SideBit= .false. !KickMigration_2SideBit= .false.
Call Set_FlowPipeDisconnect(.false.) Call Set_FlowPipeDisconnect(.false.)
Call Set_FlowKellyDisconnect(.false.) Call Set_FlowKellyDisconnect(.false.)
@@ -60,51 +60,51 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
IF ( NewInfluxNumber > 0 ) THEN
IF ( MudSystemDotNewInfluxNumber > 0 ) THEN
!write(*,*) 'KickOffBottom , ROP=' , KickOffBottom , Rate_of_Penetration !write(*,*) 'KickOffBottom , ROP=' , KickOffBottom , Rate_of_Penetration
call Kick_Migration call Kick_Migration
endif endif
! ============================ must be after migration ============================== ! ============================ must be after migration ==============================


DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystemDotNewInfluxNumber
! FINDING NEW KICK LOCATIONS: ! FINDING NEW KICK LOCATIONS:
Ann_KickLoc= 0
Op_KickLoc= 0
ChokeLine_KickLoc= 0
MudSystemDotAnn_KickLoc= 0
MudSystemDotOp_KickLoc= 0
MudSystemDotChokeLine_KickLoc= 0
do i = 1, Ann_MudOrKick%Length () do i = 1, Ann_MudOrKick%Length ()
if (Ann_MudOrKick%Array(i) == KickNumber) then
Ann_KickLoc = i
if (Ann_MudOrKick%Array(i) == MudSystemDotKickNumber) then
MudSystemDotAnn_KickLoc = i
exit exit
endif endif
end do end do


do i = 1, Op_MudOrKick%Length () do i = 1, Op_MudOrKick%Length ()
if (Op_MudOrKick%Array(i) == KickNumber) then
Op_KickLoc = i
if (Op_MudOrKick%Array(i) == MudSystemDotKickNumber) then
MudSystemDotOp_KickLoc = i
exit exit
endif endif
end do end do
do i = 1, ChokeLine_MudOrKick%Length () do i = 1, ChokeLine_MudOrKick%Length ()
if (ChokeLine_MudOrKick%Array(i) == KickNumber) then
ChokeLine_KickLoc = i
if (ChokeLine_MudOrKick%Array(i) == MudSystemDotKickNumber) then
MudSystemDotChokeLine_KickLoc = i
exit exit
endif endif
end do end do
! ============================ must be after migration-end =========================== ! ============================ must be after migration-end ===========================
IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == NewInfluxNumber .AND. NOT(KickOffBottom) .AND. WellHeadIsOpen) THEN
IF (ALLOCATED(GasPocketWeight%Array) .and. MudSystemDotKickNumber == MudSystemDotNewInfluxNumber .AND. NOT(KickOffBottom) .AND. WellHeadIsOpen) THEN


cycle cycle
ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN
if (((GasPocketDeltaVol%Array(NewInfluxNumber - KickNumber + 1) > 0.0 .AND. WellHeadIsOpen) .or. KickExpansion_DueToMudLost) ) call Kick_Expansion
if (((GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) > 0.0 .AND. WellHeadIsOpen) .or. MudSystemDotKickexpansion_DueToMudLost) ) call Kick_Expansion
if ((GasPocketDeltaVol%Array(NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. WellHeadIsOpen == .FALSE.) CALL Kick_Contraction
if ((GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) < 0.0 ) .OR. WellHeadIsOpen == .FALSE.) CALL Kick_Contraction


ENDIF ENDIF
@@ -114,12 +114,12 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
LostInTripOutIsDone= .false.
MudSystemDotLostInTripOutIsDone= .false.
if( DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then
if( MudSystemDotDeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then
!write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
call Pump_and_TripIn call Pump_and_TripIn
elseif (DeltaVolumeOp < 0.0) then
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 ! 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 ! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in
call TripOut_and_Pump call TripOut_and_Pump
@@ -147,7 +147,7 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
call PlotFinalMudElements call PlotFinalMudElements
MudChecked= .true. MudChecked= .true.
UtubePossibility= .true.
MudSystemDotUtubePossibility= .true.


!WRITE(*,*) '***********************************************************************' !WRITE(*,*) '***********************************************************************'


+ 56
- 56
Equipments/MudSystem/Deallocate_Normal_Circulation.f90 View File

@@ -3,45 +3,45 @@ subroutine DEALLOCATE_ARRAYS_NormalCirculation() ! is called in module Fluid
implicit none implicit none




if(allocated(Xstart_PipeSection)) deallocate(Xstart_PipeSection)
if(allocated(Xend_PipeSection)) deallocate(Xend_PipeSection)
if(allocated(PipeSection_VolumeCapacity)) deallocate(PipeSection_VolumeCapacity)
if(allocated(Area_PipeSectionFt)) deallocate(Area_PipeSectionFt)
if(allocated(OD_PipeSectionInch)) deallocate(OD_PipeSectionInch)
if(allocated(ID_PipeSectionInch)) deallocate(ID_PipeSectionInch)
if(allocated(Xstart_OpSection)) deallocate(Xstart_OpSection)
if(allocated(Xend_OpSection)) deallocate(Xend_OpSection)
if(allocated(Area_OpSectionFt)) deallocate(Area_OpSectionFt)
if(allocated(OD_OpSectionInch)) deallocate(OD_OpSectionInch)
if(allocated(ID_OpSectionInch)) deallocate(ID_OpSectionInch)
if(allocated(OpSection_VolumeCapacity)) deallocate(OpSection_VolumeCapacity)
if(allocated(GeoTypeOp)) deallocate(GeoTypeOp)
if(allocated(GeoType)) deallocate(GeoType)
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)




call Hz_MudDischarged_Volume%Empty()
call Hz_Mud_Backhead_X%Empty()
call MudSystemDotHz_MudDischarged_Volume%Empty()
call MudSystemDotHz_Mud_Backhead_X%Empty()
call Hz_Mud_Backhead_section%Empty() call Hz_Mud_Backhead_section%Empty()
call Hz_Mud_Forehead_X%Empty()
call MudSystemDotHz_Mud_Forehead_X%Empty()
call Hz_Mud_Forehead_section%Empty() call Hz_Mud_Forehead_section%Empty()
call Hz_Density%Empty()
call Hz_RemainedVolume_in_LastSection%Empty()
call Hz_EmptyVolume_inBackheadLocation%Empty()
call MudSystemDotHz_Density%Empty()
call MudSystemDotHz_RemainedVolume_in_LastSection%Empty()
call MudSystemDotHz_EmptyVolume_inBackheadLocation%Empty()
call Hz_MudOrKick%Empty() call Hz_MudOrKick%Empty()
call St_MudDischarged_Volume%Empty()
call St_Mud_Backhead_X%Empty()
call MudSystemDotSt_MudDischarged_Volume%Empty()
call MudSystemDotSt_Mud_Backhead_X%Empty()
call St_Mud_Backhead_section%Empty() call St_Mud_Backhead_section%Empty()
call St_Mud_Forehead_X%Empty()
call MudSystemDotSt_Mud_Forehead_X%Empty()
call St_Mud_Forehead_section%Empty() call St_Mud_Forehead_section%Empty()
call St_Density%Empty() call St_Density%Empty()
call St_RemainedVolume_in_LastSection%Empty()
call St_EmptyVolume_inBackheadLocation%Empty()
call MudSystemDotSt_RemainedVolume_in_LastSection%Empty()
call MudSystemDotSt_EmptyVolume_inBackheadLocation%Empty()
call St_MudOrKick%Empty() call St_MudOrKick%Empty()
call Ann_MudDischarged_Volume%Empty()
call MudSystemDotAnn_MudDischarged_Volume%Empty()
call Ann_Mud_Backhead_X%Empty() call Ann_Mud_Backhead_X%Empty()
call Ann_Mud_Backhead_section%Empty() call Ann_Mud_Backhead_section%Empty()
call Ann_Mud_Forehead_X%Empty() call Ann_Mud_Forehead_X%Empty()
@@ -53,25 +53,25 @@ if(allocated(GeoType)) deallocate(GeoType)
call Ann_CuttingMud%Empty() call Ann_CuttingMud%Empty()
call Op_MudDischarged_Volume%Empty()
call Op_Mud_Backhead_X%Empty()
call MudSystemDotOp_MudDischarged_Volume%Empty()
call MudSystemDotOp_Mud_Backhead_X%Empty()
call Op_Mud_Backhead_section%Empty() call Op_Mud_Backhead_section%Empty()
call Op_Mud_Forehead_X%Empty()
call MudSystemDotOp_Mud_Forehead_X%Empty()
call Op_Mud_Forehead_section%Empty() call Op_Mud_Forehead_section%Empty()
call Op_Density%Empty()
call Op_RemainedVolume_in_LastSection%Empty()
call Op_EmptyVolume_inBackheadLocation%Empty()
call MudSystemDotOp_Density%Empty()
call MudSystemDotOp_RemainedVolume_in_LastSection%Empty()
call MudSystemDotOp_EmptyVolume_inBackheadLocation%Empty()
call Op_MudOrKick%Empty() call Op_MudOrKick%Empty()


call ChokeLine_MudDischarged_Volume%Empty()
call ChokeLine_Mud_Backhead_X%Empty()
call MudSystemDotChokeLine_MudDischarged_Volume%Empty()
call MudSystemDotChokeLine_Mud_Backhead_X%Empty()
call ChokeLine_Mud_Backhead_section%Empty() call ChokeLine_Mud_Backhead_section%Empty()
call ChokeLine_Mud_Forehead_X%Empty()
call MudSystemDotChokeLine_Mud_Forehead_X%Empty()
call ChokeLine_Mud_Forehead_section%Empty() call ChokeLine_Mud_Forehead_section%Empty()
call ChokeLine_Density%Empty()
call ChokeLine_RemainedVolume_in_LastSection%Empty()
call ChokeLine_EmptyVolume_inBackheadLocation%Empty()
call MudSystemDotChokeLine_Density%Empty()
call MudSystemDotChokeLine_RemainedVolume_in_LastSection%Empty()
call MudSystemDotChokeLine_EmptyVolume_inBackheadLocation%Empty()
call ChokeLine_MudOrKick%Empty() call ChokeLine_MudOrKick%Empty()
@@ -107,7 +107,7 @@ subroutine RemoveAnnulusMudArrays(ilocal)
INTEGER :: ilocal INTEGER :: ilocal
call Ann_MudDischarged_Volume%Remove (ilocal)
call MudSystemDotAnn_MudDischarged_Volume%Remove (ilocal)
call Ann_Mud_Backhead_X%Remove (ilocal) call Ann_Mud_Backhead_X%Remove (ilocal)
call Ann_Mud_Backhead_section%Remove (ilocal) call Ann_Mud_Backhead_section%Remove (ilocal)
call Ann_Mud_Forehead_X%Remove (ilocal) call Ann_Mud_Forehead_X%Remove (ilocal)
@@ -130,14 +130,14 @@ subroutine RemoveStringMudArrays(ilocal)
INTEGER :: ilocal INTEGER :: ilocal
call St_MudDischarged_Volume%Remove (ilocal)
call St_Mud_Backhead_X%Remove (ilocal)
call MudSystemDotSt_MudDischarged_Volume%Remove (ilocal)
call MudSystemDotSt_Mud_Backhead_X%Remove (ilocal)
call St_Mud_Backhead_section%Remove (ilocal) call St_Mud_Backhead_section%Remove (ilocal)
call St_Mud_Forehead_X%Remove (ilocal)
call MudSystemDotSt_Mud_Forehead_X%Remove (ilocal)
call St_Mud_Forehead_section%Remove (ilocal) call St_Mud_Forehead_section%Remove (ilocal)
call St_Density%Remove (ilocal) call St_Density%Remove (ilocal)
call St_RemainedVolume_in_LastSection%Remove (ilocal)
call St_EmptyVolume_inBackheadLocation%Remove (ilocal)
call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (ilocal)
call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (ilocal)
call St_MudOrKick%Remove (ilocal) call St_MudOrKick%Remove (ilocal)
@@ -152,14 +152,14 @@ subroutine RemoveOpMudArrays(ilocal)
INTEGER :: ilocal INTEGER :: ilocal
call Op_MudDischarged_Volume%Remove (ilocal)
call Op_Mud_Backhead_X%Remove (ilocal)
call MudSystemDotOp_MudDischarged_Volume%Remove (ilocal)
call MudSystemDotOp_Mud_Backhead_X%Remove (ilocal)
call Op_Mud_Backhead_section%Remove (ilocal) call Op_Mud_Backhead_section%Remove (ilocal)
call Op_Mud_Forehead_X%Remove (ilocal)
call MudSystemDotOp_Mud_Forehead_X%Remove (ilocal)
call Op_Mud_Forehead_section%Remove (ilocal) call Op_Mud_Forehead_section%Remove (ilocal)
call Op_Density%Remove (ilocal)
call Op_RemainedVolume_in_LastSection%Remove (ilocal)
call Op_EmptyVolume_inBackheadLocation%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 Op_MudOrKick%Remove (ilocal)
@@ -173,14 +173,14 @@ subroutine RemoveHzMudArrays(ilocal)
INTEGER :: ilocal INTEGER :: ilocal
call Hz_MudDischarged_Volume%Remove (ilocal)
call Hz_Mud_Backhead_X%Remove (ilocal)
call MudSystemDotHz_MudDischarged_Volume%Remove (ilocal)
call MudSystemDotHz_Mud_Backhead_X%Remove (ilocal)
call Hz_Mud_Backhead_section%Remove (ilocal) call Hz_Mud_Backhead_section%Remove (ilocal)
call Hz_Mud_Forehead_X%Remove (ilocal)
call MudSystemDotHz_Mud_Forehead_X%Remove (ilocal)
call Hz_Mud_Forehead_section%Remove (ilocal) call Hz_Mud_Forehead_section%Remove (ilocal)
call Hz_Density%Remove (ilocal)
call Hz_RemainedVolume_in_LastSection%Remove (ilocal)
call Hz_EmptyVolume_inBackheadLocation%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 Hz_MudOrKick%Remove (ilocal)


+ 24
- 24
Equipments/MudSystem/Disconnecting_Pipe.f90 View File

@@ -21,7 +21,7 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect
!TD_RemoveVolume= TD_RemoveVolume* 7.48051948 ! ft^3 to gal !TD_RemoveVolume= TD_RemoveVolume* 7.48051948 ! ft^3 to gal


ExcessMudVolume= sum(St_MudDischarged_Volume%Array(:)) - sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts))
ExcessMudVolume= sum(MudSystemDotSt_MudDischarged_Volume%Array(:)) - sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts))
! ======if(ExcessMudVolume <= 0.) No Modification Needed Because Removed Pipe was Empty===== ! ======if(ExcessMudVolume <= 0.) No Modification Needed Because Removed Pipe was Empty=====
@@ -62,36 +62,36 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect
ExcessMudVolume_Remained= ExcessMudVolume ! ft^3 to gal ExcessMudVolume_Remained= ExcessMudVolume ! ft^3 to gal
imud=1
MudSystemDotimud=1
Do Do
if(St_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then
ExcessMudVolume_Remained= ExcessMudVolume_Remained- St_MudDischarged_Volume%Array(imud)
call St_MudDischarged_Volume%Remove (imud)
call St_Mud_Backhead_X%Remove (imud)
call St_Mud_Backhead_section%Remove (imud)
call St_Mud_Forehead_X%Remove (imud)
call St_Mud_Forehead_section%Remove (imud)
call St_Density%Remove (imud)
call St_RemainedVolume_in_LastSection%Remove (imud)
call St_EmptyVolume_inBackheadLocation%Remove (imud)
call St_MudOrKick%Remove (imud)
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)
elseif(St_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then
St_MudDischarged_Volume%Array(imud)= St_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained
elseif(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) > ExcessMudVolume_Remained) then
MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- ExcessMudVolume_Remained
exit exit
else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained)
call St_MudDischarged_Volume%Remove (imud)
call St_Mud_Backhead_X%Remove (imud)
call St_Mud_Backhead_section%Remove (imud)
call St_Mud_Forehead_X%Remove (imud)
call St_Mud_Forehead_section%Remove (imud)
call St_Density%Remove (imud)
call St_RemainedVolume_in_LastSection%Remove (imud)
call St_EmptyVolume_inBackheadLocation%Remove (imud)
call St_MudOrKick%Remove (imud)
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)
exit exit
endif endif


+ 100
- 100
Equipments/MudSystem/Elements_Creation.f90 View File

@@ -24,48 +24,48 @@ subroutine ElementsCreation ! is called in subroutine Fluid_Flow_Solver
!===========================================================WELL============================================================ !===========================================================WELL============================================================
!===========================================================WELL============================================================ !===========================================================WELL============================================================


if(allocated(Xstart_PipeSection)) deallocate(Xstart_PipeSection)
if(allocated(Xend_PipeSection)) deallocate(Xend_PipeSection)
if(allocated(PipeSection_VolumeCapacity)) deallocate(PipeSection_VolumeCapacity)
if(allocated(Area_PipeSectionFt)) deallocate(Area_PipeSectionFt)
if(allocated(GeoType)) deallocate(GeoType)
if(allocated(OD_PipeSectionInch)) deallocate(OD_PipeSectionInch)
if(allocated(ID_PipeSectionInch)) deallocate(ID_PipeSectionInch)
if(allocated(Angle_PipeSection)) deallocate(Angle_PipeSection)
if(allocated(Xstart_OpSection)) deallocate(Xstart_OpSection)
if(allocated(Xend_OpSection)) deallocate(Xend_OpSection)
if(allocated(OpSection_VolumeCapacity)) deallocate(OpSection_VolumeCapacity)
if(allocated(Area_OpSectionFt)) deallocate(Area_OpSectionFt)
if(allocated(GeoTypeOp)) deallocate(GeoTypeOp)
if(allocated(OD_OpSectionInch)) deallocate(OD_OpSectionInch)
if(allocated(ID_OpSectionInch)) deallocate(ID_OpSectionInch)
if(allocated(Angle_OpSection)) deallocate(Angle_OpSection)
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)




ALLOCATE (Xstart_PipeSection(F_StringIntervalCounts+F_AnnulusIntervalCounts),Xend_PipeSection(F_StringIntervalCounts+F_AnnulusIntervalCounts) &
,PipeSection_VolumeCapacity(F_StringIntervalCounts+F_AnnulusIntervalCounts),Area_PipeSectionFt(F_StringIntervalCounts+F_AnnulusIntervalCounts), &
GeoType(F_StringIntervalCounts+F_AnnulusIntervalCounts),OD_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts),ID_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts))
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 (Xstart_OpSection(F_BottomHoleIntervalCounts),Xend_OpSection(F_BottomHoleIntervalCounts) &
,OpSection_VolumeCapacity(F_BottomHoleIntervalCounts),Area_OpSectionFt(F_BottomHoleIntervalCounts), &
GeoTypeOp(F_BottomHoleIntervalCounts),OD_OpSectionInch(F_BottomHoleIntervalCounts),ID_OpSectionInch(F_BottomHoleIntervalCounts))
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))


OpSection=0
isection=0
MudSystemDotOpSection=0
MudSystemDotisection=0


DO iisection=1, F_IntervalsTotalCounts
IF (F_Interval(iisection)%GeoType == 1) THEN
OpSection= OpSection+1
Xstart_OpSection(OpSection)= (F_Interval(iisection)%StartDepth)
Xend_OpSection(OpSection)= (F_Interval(iisection)%EndDepth)
Area_OpSectionFt(OpSection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2)
OD_OpSectionInch(OpSection)= (F_Interval(iisection)%OD)
ID_OpSectionInch(OpSection)= (F_Interval(iisection)%ID) !REAL(F_Interval(iisection)%Volume)
GeoTypeOp(OpSection)= F_Interval(iisection)%GeoType ! niaz nist ehtemalan
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
!Angle_OpSection(OpSection)= F_Interval(iisection)%Angle !Angle_OpSection(OpSection)= F_Interval(iisection)%Angle
!write(*,*) 'iisection=' , iisection !write(*,*) 'iisection=' , iisection
!write(*,*) 'StartDepth=' , F_Interval(iisection)%StartDepth !write(*,*) 'StartDepth=' , F_Interval(iisection)%StartDepth
@@ -73,17 +73,17 @@ ALLOCATE (Xstart_OpSection(F_BottomHoleIntervalCounts),Xend_OpSection(F_BottomHo
!write(*,*) 'OD=' , F_Interval(iisection)%OD !write(*,*) 'OD=' , F_Interval(iisection)%OD
!write(*,*) 'ID=' , F_Interval(iisection)%ID !write(*,*) 'ID=' , F_Interval(iisection)%ID
ELSE ELSE
isection= isection+1
Xstart_PipeSection(isection)= (F_Interval(iisection)%StartDepth)
MudSystemDotisection= MudSystemDotisection+1
MudSystemDotXstart_PipeSection(MudSystemDotisection)= (F_Interval(MudSystemDotiisection)%StartDepth)
!write(*,*) 'F_Interval(iisection)%StartDepth=' , F_Interval(iisection)%StartDepth !write(*,*) 'F_Interval(iisection)%StartDepth=' , F_Interval(iisection)%StartDepth
Xend_PipeSection(isection)= (F_Interval(iisection)%EndDepth)
MudSystemDotXend_PipeSection(MudSystemDotisection)= (F_Interval(MudSystemDotiisection)%EndDepth)
!write(*,*) 'F_Interval(iisection)%EndDepth=' , F_Interval(iisection)%EndDepth !write(*,*) 'F_Interval(iisection)%EndDepth=' , F_Interval(iisection)%EndDepth
OD_PipeSectionInch(isection)= (F_Interval(iisection)%OD)
Area_PipeSectionFt(isection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2)
ID_PipeSectionInch(isection)= (F_Interval(iisection)%ID)
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)
!PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948 !REAL(F_Interval(iisection)%Volume) ! (gal) !PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948 !REAL(F_Interval(iisection)%Volume) ! (gal)
GeoType(isection)= F_Interval(iisection)%GeoType
MudSystemDotGeoType(MudSystemDotisection)= F_Interval(MudSystemDotiisection)%GeoType
!Angle_PipeSection(isection)= F_Interval(iisection)%Angle !Angle_PipeSection(isection)= F_Interval(iisection)%Angle
ENDIF ENDIF
@@ -92,33 +92,33 @@ ALLOCATE (Xstart_OpSection(F_BottomHoleIntervalCounts),Xend_OpSection(F_BottomHo


call Xstart_MudElement%Empty() call Xstart_MudElement%Empty()
call Xstart_MudElement%Add(Xstart_PipeSection(1))
call Xstart_MudElement%Add(MudSystemDotXstart_PipeSection(1))
call Xstart_OpMudElement%Empty() call Xstart_OpMudElement%Empty()
call Xstart_OpMudElement%Add(Xstart_OpSection(1))
call Xstart_OpMudElement%Add(MudSystemDotXstart_OpSection(1))
call TVDstart_MudElement%Empty() call TVDstart_MudElement%Empty()
call TVD_Calculator(Xstart_PipeSection(1),MudCircVerticalDepth)
call TVDstart_MudElement%Add(MudCircVerticalDepth)
call TVD_Calculator(MudSystemDotXstart_PipeSection(1),MudSystemDotMudCircVerticalDepth)
call TVDstart_MudElement%Add(MudSystemDotMudCircVerticalDepth)
call TVDstart_OPMudElement%Empty() call TVDstart_OPMudElement%Empty()
call TVD_Calculator(Xstart_OpSection(1),MudCircVerticalDepth)
call TVDstart_OPMudElement%Add(MudCircVerticalDepth)
call TVD_Calculator(MudSystemDotXstart_OpSection(1),MudSystemDotMudCircVerticalDepth)
call TVDstart_OPMudElement%Add(MudSystemDotMudCircVerticalDepth)
NoPipeSections= isection ! sections in string and annulus(GeoType 0 & 2)
MudSystemDotNoPipeSections= MudSystemDotisection ! sections in string and annulus(GeoType 0 & 2)


DO OpSection= 1,F_BottomHoleIntervalCounts
OpSection_VolumeCapacity(OpSection)= Area_OpSectionFt(OpSection)* ABS(Xend_OpSection(OpSection)-Xstart_OpSection(OpSection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume)
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)
ENDDO ENDDO
DO isection= 1,NoPipeSections
PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) ! (gal)
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)
ENDDO ENDDO
@@ -127,71 +127,71 @@ ALLOCATE (Xstart_OpSection(F_BottomHoleIntervalCounts),Xend_OpSection(F_BottomHo
!types: Mud= 0 Kick=1 !types: Mud= 0 Kick=1


!=========================================== !===========================================
if (FirstMudSet==0) then
call Hz_MudDischarged_Volume%AddToFirst(PipeSection_VolumeCapacity(1)) !startup initial
call Hz_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(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 Hz_Mud_Backhead_section%AddToFirst (1)
call Hz_Mud_Forehead_X%AddToFirst (Xend_PipeSection(1))
call MudSystemDotHz_Mud_Forehead_X%AddToFirst (MudSystemDotXend_PipeSection(1))
call Hz_Mud_Forehead_section%AddToFirst (1) call Hz_Mud_Forehead_section%AddToFirst (1)
call Hz_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
call Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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) call Hz_MudOrKick%AddToFirst (0)
call St_MudDischarged_Volume%AddToFirst(sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts))) !startup initial
call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(2))
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 St_Mud_Backhead_section%AddToFirst (2)
call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts))
call MudSystemDotSt_Mud_Forehead_X%AddToFirst (MudSystemDotXend_PipeSection(F_StringIntervalCounts))
call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts)
call St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) call St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call MudSystemDotSt_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call MudSystemDotSt_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call St_MudOrKick%AddToFirst (0) call St_MudOrKick%AddToFirst (0)
call Ann_MudDischarged_Volume%AddToFirst(sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)))
call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1))
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_Backhead_section%AddToFirst (F_StringIntervalCounts+1)
call Ann_Mud_Forehead_X%AddToFirst (Xend_PipeSection(NoPipeSections))
call Ann_Mud_Forehead_section%AddToFirst (NoPipeSections)
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_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call Ann_MudOrKick%AddToFirst (0) call Ann_MudOrKick%AddToFirst (0)
call Ann_CuttingMud%AddToFirst (0) call Ann_CuttingMud%AddToFirst (0)
OldPosition= Xend_PipeSection(F_StringIntervalCounts)
MudSystemDotOldPosition= MudSystemDotXend_PipeSection(F_StringIntervalCounts)
OldAnnulusCapacity= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections))
MudSystemDotOldAnnulusCapacity= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections))
call ChokeLine_MudDischarged_Volume%AddToFirst(ChokeLine_VolumeCapacity)
call ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0)
call MudSystemDotChokeLine_MudDischarged_Volume%AddToFirst(MudSystemDotChokeLine_VolumeCapacity)
call MudSystemDotChokeLine_Mud_Backhead_X%AddToFirst (0.0d0)
call ChokeLine_Mud_Backhead_section%AddToFirst (1) call ChokeLine_Mud_Backhead_section%AddToFirst (1)
call ChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength)
call MudSystemDotChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength)
call ChokeLine_Mud_Forehead_section%AddToFirst (1) call ChokeLine_Mud_Forehead_section%AddToFirst (1)
call ChokeLine_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg)
call ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 ChokeLine_MudOrKick%AddToFirst (0)


call Op_MudDischarged_Volume%AddToFirst (sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)))
call Op_Mud_Backhead_X%AddToFirst (Xstart_OpSection(1))
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 Op_Mud_Backhead_section%AddToFirst (1)
call Op_Mud_Forehead_X%AddToFirst (Xend_OpSection(F_BottomHoleIntervalCounts))
call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts))
call Op_Mud_Forehead_section%AddToFirst (F_BottomHoleIntervalCounts) call Op_Mud_Forehead_section%AddToFirst (F_BottomHoleIntervalCounts)
call Op_Density%AddToFirst (MudProperties%ActiveDensity)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
!F_StringIntervalCountsOld= F_StringIntervalCounts ! is used for adding new pipe to string !F_StringIntervalCountsOld= F_StringIntervalCounts ! is used for adding new pipe to string
F_StringIntervalCounts_Old= F_StringIntervalCounts ! is used for adding new pipe to string
MudSystemDotF_StringIntervalCounts_Old= F_StringIntervalCounts ! is used for adding new pipe to string
FirstMudSet= 1
MudSystemDotFirstMudSet= 1
endif endif


@@ -201,16 +201,16 @@ ALLOCATE (Xstart_OpSection(F_BottomHoleIntervalCounts),Xend_OpSection(F_BottomHo
!DeltaVolumeOp < 0 : Trip out !DeltaVolumeOp < 0 : Trip out




DeltaVolumeOp= ((Xend_PipeSection(F_StringIntervalCounts)-OldPosition)*PII*((OD_PipeSectionInch(F_StringIntervalCounts+1)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal ! D(in)
DeltaVolumeOp = INT(DeltaVolumeOp * 100000.d0) / 100000.d0
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
DeltaVolumePipe= ((Xend_PipeSection(F_StringIntervalCounts)-OldPosition)*PII*((ID_PipeSectionInch(F_StringIntervalCounts+F_AnnulusIntervalCounts)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal
DeltaVolumePipe = INT(DeltaVolumePipe * 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
!DeltaVolumeAnnulusCapacity= ((Xend_PipeSection(F_StringIntervalCounts)-OldPosition))*Area_PipeSectionFt(NoPipeSections)* 7.48051948d0! ft^3 to gal !DeltaVolumeAnnulusCapacity= ((Xend_PipeSection(F_StringIntervalCounts)-OldPosition))*Area_PipeSectionFt(NoPipeSections)* 7.48051948d0! ft^3 to gal
DrillStringSpeed = (Xend_PipeSection(F_StringIntervalCounts)-OldPosition) / 0.1
DrillStringSpeed = (MudSystemDotXend_PipeSection(F_StringIntervalCounts)-MudSystemDotOldPosition) / 0.1
DeltaVolumeAnnulusCapacity= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - OldAnnulusCapacity
MudSystemDotDeltaVolumeAnnulusCapacity= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) - MudSystemDotOldAnnulusCapacity
!write(*,*) 'DeltaVolumeAnnulusCapacity= ' , DeltaVolumeAnnulusCapacity !write(*,*) 'DeltaVolumeAnnulusCapacity= ' , DeltaVolumeAnnulusCapacity
@@ -224,32 +224,32 @@ ALLOCATE (Xstart_OpSection(F_BottomHoleIntervalCounts),Xend_OpSection(F_BottomHo
OldAnnulusCapacity= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections))
MudSystemDotOldAnnulusCapacity= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections))


OldPosition= Xend_PipeSection(F_StringIntervalCounts)
MudSystemDotOldPosition= MudSystemDotXend_PipeSection(F_StringIntervalCounts)
! Needed for trip in or out: ! Needed for trip in or out:
if (Hz_Mud_Backhead_X%Length() == 0) then
if (MudSystemDotHz_Mud_Backhead_X%Length() == 0) then
CALL ErrorStop('Hz_Mud_Backhead_X Length is 0') CALL ErrorStop('Hz_Mud_Backhead_X Length is 0')
endif endif
Hz_Mud_Backhead_X%Array(1)= Xstart_PipeSection(1)
MudSystemDotHz_Mud_Backhead_X%Array(1)= MudSystemDotXstart_PipeSection(1)
Hz_Mud_Backhead_section%Array(1)= 1 Hz_Mud_Backhead_section%Array(1)= 1
AddedElementsToString = F_StringIntervalCounts - F_StringIntervalCounts_Old
St_Mud_Backhead_X%Array(1)= Xstart_PipeSection(2)
MudSystemDotAddedElementsToString = F_StringIntervalCounts - MudSystemDotF_StringIntervalCounts_Old
MudSystemDotSt_Mud_Backhead_X%Array(1)= MudSystemDotXstart_PipeSection(2)
St_Mud_Backhead_section%Array(1)= 2 St_Mud_Backhead_section%Array(1)= 2
Ann_Mud_Backhead_X%Array(1)= Xstart_PipeSection(F_StringIntervalCounts+1)
Ann_Mud_Backhead_X%Array(1)= MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)
Ann_Mud_Backhead_section%Array(1)= F_StringIntervalCounts+1 Ann_Mud_Backhead_section%Array(1)= F_StringIntervalCounts+1
Op_Mud_Backhead_X%Array(1)= Xstart_OpSection(1)
MudSystemDotOp_Mud_Backhead_X%Array(1)= MudSystemDotXstart_OpSection(1)
Op_Mud_Backhead_section%Array(1)= 1 Op_Mud_Backhead_section%Array(1)= 1
ChokeLine_Mud_Backhead_X%Array(1)= 0.
MudSystemDotChokeLine_Mud_Backhead_X%Array(1)= 0.
ChokeLine_Mud_Backhead_section%Array(1)= 1 ChokeLine_Mud_Backhead_section%Array(1)= 1
F_StringIntervalCounts_Old= F_StringIntervalCounts
MudSystemDotF_StringIntervalCounts_Old= F_StringIntervalCounts
!write(*,*) 'Xstart_PipeSection(2)' , Xstart_PipeSection(2) !write(*,*) 'Xstart_PipeSection(2)' , Xstart_PipeSection(2)
!write(*,*) 'Xend_PipeSection(1)' , Xend_PipeSection(1) !write(*,*) 'Xend_PipeSection(1)' , Xend_PipeSection(1)




+ 21
- 21
Equipments/MudSystem/FillingWell_By_BellNipple.f90 View File

@@ -38,26 +38,26 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo
FillingDensity= BellNippleDensity FillingDensity= BellNippleDensity
!**************************** !****************************
if ( Ann_MudDischarged_Volume%Last() > (((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi mimune
if ( MudSystemDotAnn_MudDischarged_Volume%Last() > (((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi mimune
kloc= Ann_MudDischarged_Volume%Length()-1
kloc= MudSystemDotAnn_MudDischarged_Volume%Length()-1
deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline
Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())= Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length()) - deltaV
MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length()) - deltaV
!========================ANNULUS ENTRANCE==================== !========================ANNULUS ENTRANCE====================
if (ABS(Ann_Density%Array(kloc) - FillingDensity) >= DensityMixTol) then ! new mud is pumped
if (ABS(Ann_Density%Array(kloc) - FillingDensity) >= MudSystemDotDensityMixTol) then ! new mud is pumped
call Ann_Density%AddTo (kloc, FillingDensity) call Ann_Density%AddTo (kloc, FillingDensity)
call Ann_MudDischarged_Volume%AddTo (kloc, 0.0d0)
call MudSystemDotAnn_MudDischarged_Volume%AddTo (kloc, 0.0d0)
call Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0) call Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0)
call Ann_Mud_Forehead_section%AddTo (kloc, 1) call Ann_Mud_Forehead_section%AddTo (kloc, 1)
call Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0) call Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0)
call Ann_Mud_Backhead_section%AddTo (kloc, NoPipeSections)
call Ann_Mud_Backhead_section%AddTo (kloc, MudSystemDotNoPipeSections)
call Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0) call Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0)
call Ann_MudOrKick%AddTo (kloc, 0) call Ann_MudOrKick%AddTo (kloc, 0)
@@ -68,7 +68,7 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo
!========================ANNULUS==================== !========================ANNULUS====================


Ann_MudDischarged_Volume%Array(kloc)= Ann_MudDischarged_Volume%Array(kloc)+ deltaV !(gal)
MudSystemDotAnn_MudDischarged_Volume%Array(kloc)= MudSystemDotAnn_MudDischarged_Volume%Array(kloc)+ deltaV !(gal)
@@ -77,23 +77,23 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo
kloc= Ann_MudDischarged_Volume%Length()-1
kloc= MudSystemDotAnn_MudDischarged_Volume%Length()-1
deltaV= Ann_MudDischarged_Volume%Last()
deltaV= MudSystemDotAnn_MudDischarged_Volume%Last()
if (ABS(Ann_Density%Array(kloc)-FillingDensity)< DensityMixTol .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)*Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(Ann_MudDischarged_Volume%Array(kloc)+deltaV)
Ann_MudDischarged_Volume%Array(kloc)= Ann_MudDischarged_Volume%Array(kloc)+deltaV
Ann_Mud_Forehead_X%Array(kloc)= Xend_PipeSection(NoPipeSections)
Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections
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
!Ann_Mud_Backhead_X%Array(kloc)= no change !Ann_Mud_Backhead_X%Array(kloc)= no change
!Ann_Mud_Backhead_section%Array(kloc)= no change !Ann_Mud_Backhead_section%Array(kloc)= no change
Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0)
Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0)
call Ann_MudDischarged_Volume%Remove (kloc+1)
call MudSystemDotAnn_MudDischarged_Volume%Remove (kloc+1)
call Ann_Mud_Backhead_X%Remove (kloc+1) call Ann_Mud_Backhead_X%Remove (kloc+1)
call Ann_Mud_Backhead_section%Remove (kloc+1) call Ann_Mud_Backhead_section%Remove (kloc+1)
call Ann_Mud_Forehead_X%Remove (kloc+1) call Ann_Mud_Forehead_X%Remove (kloc+1)
@@ -131,7 +131,7 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo
deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline
kloc= Ann_MudDischarged_Volume%Length()
kloc= MudSystemDotAnn_MudDischarged_Volume%Length()


@@ -139,11 +139,11 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo
!========================ANNULUS ENTRANCE==================== !========================ANNULUS ENTRANCE====================
if (ABS(Ann_Density%Last() - FillingDensity) >= DensityMixTol .or. Ann_CuttingMud%Last()==1) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)>42.) ) then ! new mud is pumped
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() Xposition= Ann_Mud_Forehead_X%Last()
SectionPosition= Ann_Mud_Forehead_section%Last() SectionPosition= Ann_Mud_Forehead_section%Last()
call Ann_Density%Add (FillingDensity) call Ann_Density%Add (FillingDensity)
call Ann_MudDischarged_Volume%Add (0.0d0)
call MudSystemDotAnn_MudDischarged_Volume%Add (0.0d0)
call Ann_Mud_Forehead_X%Add (Xposition) call Ann_Mud_Forehead_X%Add (Xposition)
call Ann_Mud_Forehead_section%Add (SectionPosition) call Ann_Mud_Forehead_section%Add (SectionPosition)
call Ann_Mud_Backhead_X%Add (Xposition) call Ann_Mud_Backhead_X%Add (Xposition)
@@ -158,12 +158,12 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo
!========================ANNULUS==================== !========================ANNULUS====================


Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())= Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())+ deltaV !(gal)
MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())+ deltaV !(gal)
else ! Merged with last Mud else ! Merged with last Mud
Ann_Density%Array(kloc)= (Ann_Density%Array(kloc)*Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(Ann_MudDischarged_Volume%Array(kloc)+deltaV)
Ann_MudDischarged_Volume%Array(kloc)= Ann_MudDischarged_Volume%Array(kloc)+deltaV
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)= Xend_PipeSection(NoPipeSections) !Ann_Mud_Forehead_X%Array(kloc)= Xend_PipeSection(NoPipeSections)
!Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections !Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections
!Ann_Mud_Backhead_X%Array(kloc)= no change !Ann_Mud_Backhead_X%Array(kloc)= no change


+ 31
- 31
Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 View File

@@ -18,19 +18,19 @@ subroutine Kick_Expansion ! is called in subroutine CirculationCodeSelect
!write(*,*) 'Kick Expansion' !write(*,*) 'Kick Expansion'
ExpansionVolume= GasPocketDeltaVol%Array(NewInfluxNumber - KickNumber + 1) * 7.48
ExpansionVolume= GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) * 7.48


IF ( Kickexpansion_DueToMudLost ) ExpansionVolume = ((Qlost/60.0d0)*DeltaT_Mudline)
IF ( MudSystemDotKickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystemDotQlost/60.0d0)*DeltaT_Mudline)




!============================== kick zire mate bashad ============================== !============================== kick zire mate bashad ==============================


if (Op_KickLoc > 0 .and. Ann_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then
if (MudSystemDotOp_KickLoc > 0 .and. MudSystemDotAnn_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then
!write(*,*) 'expansion (1)' !write(*,*) 'expansion (1)'


Op_MudDischarged_Volume%Array(Op_KickLoc)= Op_MudDischarged_Volume%Array(Op_KickLoc)+ ExpansionVolume
MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc)+ ExpansionVolume


!if (MUD(4)%Q > 0.) then !if (MUD(4)%Q > 0.) then
@@ -58,14 +58,14 @@ IF ( Kickexpansion_DueToMudLost ) ExpansionVolume = ((Qlost/60.0d0)*DeltaT_Mud
!============================= foreheade dar fazaye annulus bashad =========================== !============================= foreheade dar fazaye annulus bashad ===========================
! agar kick be entehaye annulus reside bashe, expansion ra emaal nemikonim ! agar kick be entehaye annulus reside bashe, expansion ra emaal nemikonim
if (Ann_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then
if (MudSystemDotAnn_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then
!write(*,*) 'expansion (2)' !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 !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)) ! ExpansionVolume= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc))
!endif !endif
Ann_MudDischarged_Volume%Array(Ann_KickLoc)= Ann_MudDischarged_Volume%Array(Ann_KickLoc)+ ExpansionVolume
MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc)+ ExpansionVolume
!if (MUD(4)%Q > 0.) then !if (MUD(4)%Q > 0.) then
! !
@@ -95,9 +95,9 @@ IF ( Kickexpansion_DueToMudLost ) ExpansionVolume = ((Qlost/60.0d0)*DeltaT_Mud
!=============================== foreheade dar choke line bashad ============================= !=============================== foreheade dar choke line bashad =============================
if (ChokeLine_KickLoc > 0 .and. Ann_KickLoc==0) then
if (MudSystemDotChokeLine_KickLoc > 0 .and. MudSystemDotAnn_KickLoc==0) then
ChokeLine_MudDischarged_Volume%Array(ChokeLine_KickLoc)= ChokeLine_MudDischarged_Volume%Array(ChokeLine_KickLoc)+ ExpansionVolume
MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc)= MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc)+ ExpansionVolume
endif endif
@@ -152,12 +152,12 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect
!write(*,*) 'Kick Contraction' !write(*,*) 'Kick Contraction'


!MUD(2)%Q= total_pumps%Total_Pump_GPM !MUD(2)%Q= total_pumps%Total_Pump_GPM
StringFlowRate= MUD(2)%Q
AnnulusFlowRate= MUD(2)%Q
MudSystemDotStringFlowRate= MUD(2)%Q
MudSystemDotAnnulusFlowRate= MUD(2)%Q
if (NewPipeFilling == 0) then
StringFlowRate= 0.
AnnulusFlowRate= 0.
if (MudSystemDotNewPipeFilling == 0) then
MudSystemDotStringFlowRate= 0.
MudSystemDotAnnulusFlowRate= 0.
endif endif
@@ -165,10 +165,10 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect


!if (WellHeadIsOpen) then !if (WellHeadIsOpen) then
ContractionVolume= - GasPocketDeltaVol%Array(NewInfluxNumber - KickNumber + 1) * 7.48
ContractionVolume= - GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) * 7.48
!else !else
!ContractionVolume = (StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe !ContractionVolume = (StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe
if (KickNumber == 1 .and. WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe
if (MudSystemDotKickNumber == 1 .and. WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline + MudSystemDotDeltaVolumePipe
!endif !endif
@@ -176,43 +176,43 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect
! pump mud is added in "pump&TripIn" code ! pump mud is added in "pump&TripIn" code
IF (Op_KickLoc > 0 .and. Ann_KickLoc == 0) then ! All of kick is under bit (iloc == 1)
IF (MudSystemDotOp_KickLoc > 0 .and. MudSystemDotAnn_KickLoc == 0) then ! All of kick is under bit (iloc == 1)
Op_MudDischarged_Volume%Array(Op_KickLoc)= Op_MudDischarged_Volume%Array(Op_KickLoc) - ( ContractionVolume )
MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc) - ( ContractionVolume )
ELSE IF (Op_KickLoc == 0 .AND. Ann_KickLoc > 0 .AND. ChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1)
ELSE IF (MudSystemDotOp_KickLoc == 0 .AND. MudSystemDotAnn_KickLoc > 0 .AND. MudSystemDotChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1)
Ann_MudDischarged_Volume%Array(Ann_KickLoc)= Ann_MudDischarged_Volume%Array(Ann_KickLoc) - ( ContractionVolume )
MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc) - ( ContractionVolume )
ELSE IF (Ann_KickLoc == 0 .AND. ChokeLine_KickLoc > 0) THEN ! kick is in chokeline only
ELSE IF (MudSystemDotAnn_KickLoc == 0 .AND. MudSystemDotChokeLine_KickLoc > 0) THEN ! kick is in chokeline only
ChokeLine_MudDischarged_Volume%Array(ChokeLine_KickLoc)= ChokeLine_MudDischarged_Volume%Array(ChokeLine_KickLoc) - ( ContractionVolume )
MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc)= MudSystemDotChokeLine_MudDischarged_Volume%Array(MudSystemDotChokeLine_KickLoc) - ( ContractionVolume )
ELSE IF (Op_KickLoc > 0 .AND. Ann_KickLoc > 0) THEN ! Kick is around bit (iloc==2)
ELSE IF (MudSystemDotOp_KickLoc > 0 .AND. MudSystemDotAnn_KickLoc > 0) THEN ! Kick is around bit (iloc==2)
if (Ann_MudDischarged_Volume%Array(1) > ContractionVolume ) then
if (MudSystemDotAnn_MudDischarged_Volume%Array(1) > ContractionVolume ) then
Ann_MudDischarged_Volume%Array(1)= Ann_MudDischarged_Volume%Array(1) - ( ContractionVolume )
MudSystemDotAnn_MudDischarged_Volume%Array(1)= MudSystemDotAnn_MudDischarged_Volume%Array(1) - ( ContractionVolume )
elseif (Op_MudDischarged_Volume%Last() > ContractionVolume ) then
elseif (MudSystemDotOp_MudDischarged_Volume%Last() > ContractionVolume ) then
Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length())= Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()) - ( ContractionVolume )
MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_MudDischarged_Volume%Length())= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_MudDischarged_Volume%Length()) - ( ContractionVolume )
else else
Call ErrorStop ('kick contraction error 1') Call ErrorStop ('kick contraction error 1')
endif endif
ELSE IF (Ann_KickLoc > 0 .AND. ChokeLine_KickLoc > 0) THEN
ELSE IF (MudSystemDotAnn_KickLoc > 0 .AND. MudSystemDotChokeLine_KickLoc > 0) THEN
if (ChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then
if (MudSystemDotChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then
ChokeLine_MudDischarged_Volume%Array(1) = ChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume )
MudSystemDotChokeLine_MudDischarged_Volume%Array(1) = MudSystemDotChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume )
elseif (Ann_MudDischarged_Volume%Last() > ContractionVolume ) then
elseif (MudSystemDotAnn_MudDischarged_Volume%Last() > ContractionVolume ) then
Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())= Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length()) - ( ContractionVolume )
MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length()) - ( ContractionVolume )
else else
Call ErrorStop ('kick contraction error 2') Call ErrorStop ('kick contraction error 2')


+ 46
- 46
Equipments/MudSystem/Kick_Influx.f90 View File

@@ -22,27 +22,27 @@ subroutine Kick_Influx ! is called in subroutine CirculationCodeSelect


!=================== Bottom Hole Kick Influx ENTRANCE(due to Kick) =================== !=================== Bottom Hole Kick Influx ENTRANCE(due to Kick) ===================
Kick_Density= 2
NewInflux_Density= Kick_Density
MudSystemDotKick_Density= 2
MudSystemDotNewInflux_Density= MudSystemDotKick_Density
if ( NewInfluxElementCreated==0 ) then ! new kick is pumped- (it is set to zero in sheykh subroutine after a new kick influx)
call Op_Density%AddToFirst (NewInflux_Density)
call Op_MudDischarged_Volume%AddToFirst (0.0d0)
call Op_Mud_Forehead_X%AddToFirst (Xstart_OpSection(1))
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 Op_Mud_Forehead_section%AddToFirst (1)
call Op_Mud_Backhead_X%AddToFirst (Xstart_OpSection(1))
call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_OpSection(1))
call Op_Mud_Backhead_section%AddToFirst (1) call Op_Mud_Backhead_section%AddToFirst (1)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call Op_MudOrKick%AddToFirst (NewInfluxNumber) ! KickNumber= NewInfluxNumber
call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call Op_MudOrKick%AddToFirst (MudSystemDotNewInfluxNumber) ! KickNumber= NewInfluxNumber
NewInfluxElementCreated= 1
MudSystemDotNewInfluxElementCreated= 1
endif endif


Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.0d0)*DeltaT_Mudline) !(gal) due to KickFlux
MudSystemDotOp_MudDischarged_Volume%Array(1)= MudSystemDotOp_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.0d0)*DeltaT_Mudline) !(gal) due to KickFlux
!write(*,*) 'kick volume ok=' , Op_MudDischarged_Volume%Array(1) !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. DeltaVolumeOp>0.0) ) then
if ( DownHole%AnnDrillMud == .true. .and. (Rate_of_Penetration>0. .and. MudSystemDotDeltaVolumeOp>0.0) ) then
do imud= 1, Ann_Density%Length()
do MudSystemDotimud= 1, Ann_Density%Length()
if ( Ann_MudOrKick%Array(imud) == 0 ) then
Ann_Density%Array(imud)= (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)
Ann_CuttingMud%Array(imud)= 1
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
endif endif
enddo enddo
@@ -95,18 +95,18 @@ subroutine Instructor_CirculationMud_Edit ! is called in subroutine Circulat
if ( DownHole%AnnCirculateMud == .true. ) then if ( DownHole%AnnCirculateMud == .true. ) then
do imud= 1, Ann_Density%Length()
do MudSystemDotimud= 1, Ann_Density%Length()
if ( Ann_MudOrKick%Array(imud) == 0 ) then
Ann_Density%Array(imud)= ActiveTankDensity
Ann_CuttingMud%Array(imud)= 0
if ( Ann_MudOrKick%Array(MudSystemDotimud) == 0 ) then
Ann_Density%Array(MudSystemDotimud)= ActiveTankDensity
Ann_CuttingMud%Array(MudSystemDotimud)= 0
endif endif
enddo enddo
do imud= 1, St_Density%Length()
do MudSystemDotimud= 1, St_Density%Length()
St_Density%Array(imud)= ActiveTankDensity
St_Density%Array(MudSystemDotimud)= ActiveTankDensity
enddo enddo
@@ -138,28 +138,28 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect


implicit none implicit none
ShoeLost= .false.
Kickexpansion_DueToMudLost= .false.
MudSystemDotShoeLost= .false.
MudSystemDotKickexpansion_DueToMudLost= .false.
ShoeMudPressure= PressureGauges(5)
MudSystemDotShoeMudPressure= PressureGauges(5)
UGBOSuccessionCounter = UGBOSuccessionCounter + 1
MudSystemDotUGBOSuccessionCounter = MudSystemDotUGBOSuccessionCounter + 1
!write(*,*) 'check point 1' !write(*,*) 'check point 1'
if (Shoe%InactiveFracture == .FALSE. .AND. ((ShoeMudPressure >= FormationLostPressure) .or. ShoeFractured )) then
if (Shoe%InactiveFracture == .FALSE. .AND. ((MudSystemDotShoeMudPressure >= MudSystemDotFormationLostPressure) .or. MudSystemDotShoeFractured )) then
!write(*,*) 'check point 2 ,UGBOSuccessionCounter' , UGBOSuccessionCounter !write(*,*) 'check point 2 ,UGBOSuccessionCounter' , UGBOSuccessionCounter
! if ShoeFractured changed to true , then time counter is not needed more ! if ShoeFractured changed to true , then time counter is not needed more
if ( UGBOSuccessionCounter /= UGBOSuccessionCounterOld+1 .and. ShoeFractured==.false. ) then
UGBOSuccessionCounter = 0 ! also in starup
UGBOSuccessionCounterOld = 0 ! also in starup
if ( MudSystemDotUGBOSuccessionCounter /= MudSystemDotUGBOSuccessionCounterOld+1 .and. MudSystemDotShoeFractured==.false. ) then
MudSystemDotUGBOSuccessionCounter = 0 ! also in starup
MudSystemDotUGBOSuccessionCounterOld = 0 ! also in starup
return return
else else
UGBOSuccessionCounterOld= UGBOSuccessionCounter
MudSystemDotUGBOSuccessionCounterOld= MudSystemDotUGBOSuccessionCounter
endif endif


if ( UGBOSuccessionCounter < 10 .and. ShoeFractured==.false.) then
if ( MudSystemDotUGBOSuccessionCounter < 10 .and. MudSystemDotShoeFractured==.false.) then
return return
endif endif
@@ -167,30 +167,30 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect
ShoeFractured= .true.
MudSystemDotShoeFractured= .true.
ShoeMudViscosity= MAX(ShoeMudViscosity, 12.d0)
MudSystemDotShoeMudViscosity= MAX(MudSystemDotShoeMudViscosity, 12.d0)
!write(*,*) 'ShoeMudDensity , ShoeMudViscosity' , ShoeMudDensity , ShoeMudViscosity !write(*,*) 'ShoeMudDensity , ShoeMudViscosity' , ShoeMudDensity , ShoeMudViscosity
ShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * ShoeMudDensity / &
(ShoeMudViscosity * LOG(10000.d0))
MudSystemDotShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * MudSystemDotShoeMudDensity / &
(MudSystemDotShoeMudViscosity * LOG(10000.d0))
!write(*,*) 'lost parameters 1' , ShoeMudPressure , FormationLostPressure !write(*,*) 'lost parameters 1' , ShoeMudPressure , FormationLostPressure
Qlost = MAX( (ShoeLostCoef * (ShoeMudPressure - (FormationLostPressure/2.0))) , 0.d0 )
if (Qlost > 0.0) then
ShoeLost= .true.
MudSystemDotQlost = MAX( (MudSystemDotShoeLostCoef * (MudSystemDotShoeMudPressure - (MudSystemDotFormationLostPressure/2.0))) , 0.d0 )
if (MudSystemDotQlost > 0.0) then
MudSystemDotShoeLost= .true.
else else
ShoeLost= .false.
MudSystemDotShoeLost= .false.
endif endif
!write(*,*) 'Qlost=' , Qlost, ShoeMudPressure, FormationLostPressure !write(*,*) 'Qlost=' , Qlost, ShoeMudPressure, FormationLostPressure
call Activate_UndergroundBlowout() call Activate_UndergroundBlowout()
do imud= 1, Ann_Mud_Forehead_X%Length()
do MudSystemDotimud= 1, Ann_Mud_Forehead_X%Length()


IF ( ShoeLost .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(imud) &
.and. Ann_MudOrKick%Array(imud) == 0 .and. WellHeadIsOpen == .FALSE. ) then
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
Kickexpansion_DueToMudLost= .true.
MudSystemDotKickexpansion_DueToMudLost= .true.
write(*,*) 'Kickexpansion_DueToMudLost' write(*,*) 'Kickexpansion_DueToMudLost'
EXIT EXIT
@@ -204,7 +204,7 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect
endif endif
if (UndergroundBlowout == .false.) ShoeLost= .false.
if (UndergroundBlowout == .false.) MudSystemDotShoeLost= .false.


+ 306
- 306
Equipments/MudSystem/Kick_Migration.f90 View File

@@ -39,12 +39,12 @@ subroutine Kick_Migration ! is called in subroutine CirculationCodeSelect
!FirstSetKickMigration !FirstSetKickMigration
!write(*,*) 'NewInfluxNumber=' , NewInfluxNumber !write(*,*) 'NewInfluxNumber=' , NewInfluxNumber
DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystemDotNewInfluxNumber
!write(*,*) 'KickNumber=' , KickNumber !write(*,*) 'KickNumber=' , KickNumber
if (KickFlux .AND. NOT(KickOffBottom) .and. KickNumber == NewInfluxNumber) cycle
if (KickFlux .AND. NOT(KickOffBottom) .and. MudSystemDotKickNumber == MudSystemDotNewInfluxNumber) cycle
if ( KickNumber == Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called
if ( MudSystemDotKickNumber == Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called
!write(*,*) 'Migration will be done for,KickNumber=' ,KickNumber !write(*,*) 'Migration will be done for,KickNumber=' ,KickNumber


@@ -53,28 +53,28 @@ DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
!KickDx= (AutoMigrationRate/60.)*DeltaT_Mudline !3600 (ft/min)= 6 ft set in start up !KickDx= (AutoMigrationRate/60.)*DeltaT_Mudline !3600 (ft/min)= 6 ft set in start up
Op_KickLoc= 0
Ann_KickLoc= 0
ChokeLine_KickLoc= 0
MudSystemDotOp_KickLoc= 0
MudSystemDotAnn_KickLoc= 0
MudSystemDotChokeLine_KickLoc= 0


do i = 1, Op_MudOrKick%Length () do i = 1, Op_MudOrKick%Length ()
if (Op_MudOrKick%Array(i) == KickNumber) then
Op_KickLoc = i
if (Op_MudOrKick%Array(i) == MudSystemDotKickNumber) then
MudSystemDotOp_KickLoc = i
exit exit
endif endif
end do end do
do i = 1, Ann_MudOrKick%Length () do i = 1, Ann_MudOrKick%Length ()
if (Ann_MudOrKick%Array(i) == KickNumber) then
Ann_KickLoc = i
if (Ann_MudOrKick%Array(i) == MudSystemDotKickNumber) then
MudSystemDotAnn_KickLoc = i
exit exit
endif endif
end do end do
do i = 1, ChokeLine_MudOrKick%Length () do i = 1, ChokeLine_MudOrKick%Length ()
if (ChokeLine_MudOrKick%Array(i) == KickNumber) then
ChokeLine_KickLoc = i
if (ChokeLine_MudOrKick%Array(i) == MudSystemDotKickNumber) then
MudSystemDotChokeLine_KickLoc = i
exit exit
endif endif
end do end do
@@ -93,114 +93,114 @@ DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
!============================== foreheade kick be mate reside bashad *3 ============================== !============================== foreheade kick be mate reside bashad *3 ==============================
if (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 ) then
if (MudSystemDotOp_KickLoc == Op_MudOrKick%Length () .and. MudSystemDotAnn_KickLoc==0 ) then
!write(*,*) '****3' !write(*,*) '****3'
iloc= 2
MudSystemDotiLoc= 2
KickDv= Area_OpSectionFt(Op_Mud_Forehead_section%Array(Op_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal
MudSystemDotKickDv= MudSystemDotArea_OpSectionFt(Op_Mud_Forehead_section%Array(MudSystemDotOp_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal


MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (1), Op_MudDischarged_Volume%Last () )
MudSystemDotMinKickDv= min( MudSystemDotKickDv,MudSystemDotAnn_MudDischarged_Volume%Array (1), MudSystemDotOp_MudDischarged_Volume%Last () )
NewDensity= Ann_Density%Array (1) NewDensity= Ann_Density%Array (1)
NewVolume= MinKickDv
MudSystemDotNewVolume= MudSystemDotMinKickDv
if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund
if ( MudSystemDotMinKickDv == MudSystemDotKickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund
Ann_MudDischarged_Volume%Array (1)= Ann_MudDischarged_Volume%Array (1) - MinKickDv
MudSystemDotAnn_MudDischarged_Volume%Array (1)= MudSystemDotAnn_MudDischarged_Volume%Array (1) - MudSystemDotMinKickDv
call Ann_Density%AddToFirst (Op_Density%Last())
call Ann_MudDischarged_Volume%AddToFirst (MinKickDv)
call Ann_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1))
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_Forehead_section%AddToFirst (F_StringIntervalCounts+1)
call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(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_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1)
call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call Ann_MudOrKick%AddToFirst (KickNumber)
call Ann_MudOrKick%AddToFirst (MudSystemDotKickNumber)
call Ann_CuttingMud%AddToFirst (0) call Ann_CuttingMud%AddToFirst (0)
Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv
MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv
! backheade kick zire mate bashad ! backheade kick zire mate bashad
if (Op_KickLoc > 1) then
if (MudSystemDotOp_KickLoc > 1) then
!if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_Density%AddTo (Op_KickLoc,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)
call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0)
call Op_MudOrKick%AddTo (Op_KickLoc,0)
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)
else !Op_Density%Array (imudKick-1) == NewDensity else !Op_Density%Array (imudKick-1) == NewDensity
Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
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
endif endif
else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1=============================== else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1===============================
!write(*,*) '****3-1' !write(*,*) '****3-1'


call Op_Density%AddToFirst (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)
call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
endif endif
elseif ( MinKickDv == Ann_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund
elseif ( MudSystemDotMinKickDv == MudSystemDotAnn_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund


Ann_Density%Array(1)= Op_Density%Last()
Ann_MudOrKick%Array(1)= KickNumber
Ann_Density%Array(1)= MudSystemDotOp_Density%Last()
Ann_MudOrKick%Array(1)= MudSystemDotKickNumber
Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv
MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv
! backheade kick zire mate bashad ! backheade kick zire mate bashad
if (Op_KickLoc > 1) then
if (MudSystemDotOp_KickLoc > 1) then
!if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_Density%AddTo (Op_KickLoc,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)
call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0)
call Op_MudOrKick%AddTo (Op_KickLoc,0)
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)
else !Op_Density%Array (imudKick-1) == NewDensity else !Op_Density%Array (imudKick-1) == NewDensity
Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
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
endif endif
@@ -208,87 +208,87 @@ DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
!write(*,*) '****3-2' !write(*,*) '****3-2'


call Op_Density%AddToFirst (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)
call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
endif endif
! !
elseif ( MinKickDv == Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod
elseif ( MudSystemDotMinKickDv == MudSystemDotOp_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod
Ann_MudDischarged_Volume%Array (1)= Ann_MudDischarged_Volume%Array (1) - MinKickDv
MudSystemDotAnn_MudDischarged_Volume%Array (1)= MudSystemDotAnn_MudDischarged_Volume%Array (1) - MudSystemDotMinKickDv
call Ann_Density%AddToFirst (Op_Density%Last())
call Ann_MudDischarged_Volume%AddToFirst (MinKickDv)
call Ann_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1))
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_Forehead_section%AddToFirst (F_StringIntervalCounts+1)
call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(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_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1)
call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call Ann_MudOrKick%AddToFirst (KickNumber)
call Ann_MudOrKick%AddToFirst (MudSystemDotKickNumber)
call Ann_CuttingMud%AddToFirst (0) call Ann_CuttingMud%AddToFirst (0)
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_MudDischarged_Volume%Remove (Op_KickLoc)
call Op_Mud_Backhead_X%Remove (Op_KickLoc)
call Op_Mud_Backhead_section%Remove (Op_KickLoc)
call Op_Mud_Forehead_X%Remove (Op_KickLoc)
call Op_Mud_Forehead_section%Remove (Op_KickLoc)
call Op_Density%Remove (Op_KickLoc)
call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc)
call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc)
call Op_MudOrKick%Remove (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)
! backheade kick zire mate bashad ! backheade kick zire mate bashad
if (Op_KickLoc > 1) then
if (MudSystemDotOp_KickLoc > 1) then
!if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then
call Op_Density%AddTo (Op_KickLoc,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)
call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0)
call Op_MudOrKick%AddTo (Op_KickLoc,0)
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)
else !Op_Density%Array (imudKick-1) == NewDensity else !Op_Density%Array (imudKick-1) == NewDensity
Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
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
endif endif
else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3=============================== else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3===============================
!write(*,*) '****3-3' !write(*,*) '****3-3'


call Op_Density%AddToFirst (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)
call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
endif endif
@@ -371,86 +371,86 @@ DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
!============================= tamame kick zire mate bashad *1 ================================ !============================= tamame kick zire mate bashad *1 ================================
if ( Op_KickLoc>0 .and. Op_KickLoc < Op_MudOrKick%Length () ) then
if ( MudSystemDotOp_KickLoc>0 .and. MudSystemDotOp_KickLoc < Op_MudOrKick%Length () ) then
!write(*,*) '****1' !write(*,*) '****1'
!iloc= 1 !iloc= 1
KickDv= Area_OpSectionFt(Op_Mud_Forehead_section%Array(Op_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal
MudSystemDotKickDv= MudSystemDotArea_OpSectionFt(Op_Mud_Forehead_section%Array(MudSystemDotOp_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
if ( KickDv < Op_MudDischarged_Volume%Array (Op_KickLoc+1) ) then !eleman bala sari baghi mimund
if ( MudSystemDotKickDv < MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) ) then !eleman bala sari baghi mimund
!write(*,*) 'cond 11111111111111' !write(*,*) 'cond 11111111111111'
Op_MudDischarged_Volume%Array (Op_KickLoc+1)= Op_MudDischarged_Volume%Array (Op_KickLoc+1) - KickDv
MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) - MudSystemDotKickDv
NewDensity= Op_Density%Array (Op_KickLoc+1)
NewVolume= KickDv
NewDensity= MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc+1)
MudSystemDotNewVolume= MudSystemDotKickDv
else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund
! write(*,*) 'cond 22222222222222222' ! write(*,*) 'cond 22222222222222222'
KickDv= Op_MudDischarged_Volume%Array (Op_KickLoc+1)
MudSystemDotKickDv= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1)
NewVolume= KickDv
NewDensity= Op_Density%Array (Op_KickLoc+1)
MudSystemDotNewVolume= MudSystemDotKickDv
NewDensity= MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc+1)
call Op_MudDischarged_Volume%Remove (Op_KickLoc+1)
call Op_Mud_Backhead_X%Remove (Op_KickLoc+1)
call Op_Mud_Backhead_section%Remove (Op_KickLoc+1)
call Op_Mud_Forehead_X%Remove (Op_KickLoc+1)
call Op_Mud_Forehead_section%Remove (Op_KickLoc+1)
call Op_Density%Remove (Op_KickLoc+1)
call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc+1)
call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc+1)
call Op_MudOrKick%Remove (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)
endif endif
! backheade kick zire mate bashad ! backheade kick zire mate bashad
if (Op_KickLoc > 1) then
if (MudSystemDotOp_KickLoc > 1) then
!if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then


call Op_Density%AddTo (Op_KickLoc,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)
call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0)
call Op_MudOrKick%AddTo (Op_KickLoc,0)
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)
else !Op_Density%Array (Op_KickLoc-1) == NewDensity else !Op_Density%Array (Op_KickLoc-1) == NewDensity
Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
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
endif endif
else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1=============================== else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1===============================
!write(*,*) '****5-1' !write(*,*) '****5-1'


call Op_Density%AddToFirst (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)
call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
endif endif
@@ -465,65 +465,65 @@ DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
!=========================== tamame kick balaye mate bashad *2 ================================== !=========================== tamame kick balaye mate bashad *2 ==================================
if ( Ann_KickLoc > 0 .and. Op_KickLoc==0 ) then
if ( MudSystemDotAnn_KickLoc > 0 .and. MudSystemDotOp_KickLoc==0 ) then
!write(*,*) '****2' !write(*,*) '****2'
!iloc= 1 !iloc= 1
KickDv= Area_PipeSectionFt(Ann_Mud_Forehead_section%Array(Ann_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal
MudSystemDotKickDv= MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotAnn_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal
NewDensity= Ann_Density%Array (Ann_KickLoc+1)
NewVolume= KickDv
CuttingValue= Ann_CuttingMud%Array (Ann_KickLoc+1)
NewDensity= Ann_Density%Array (MudSystemDotAnn_KickLoc+1)
MudSystemDotNewVolume= MudSystemDotKickDv
CuttingValue= Ann_CuttingMud%Array (MudSystemDotAnn_KickLoc+1)
if ( KickDv < Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) ) then !eleman bala sari baghi mimund
if ( MudSystemDotKickDv < MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) ) then !eleman bala sari baghi mimund
Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - KickDv
MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotKickDv
else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund
KickDv= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)
NewVolume= KickDv
MudSystemDotKickDv= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)
MudSystemDotNewVolume= MudSystemDotKickDv
call Ann_MudDischarged_Volume%Remove (Ann_KickLoc+1)
call Ann_Mud_Backhead_X%Remove (Ann_KickLoc+1)
call Ann_Mud_Backhead_section%Remove (Ann_KickLoc+1)
call Ann_Mud_Forehead_X%Remove (Ann_KickLoc+1)
call Ann_Mud_Forehead_section%Remove (Ann_KickLoc+1)
call Ann_Density%Remove (Ann_KickLoc+1)
call Ann_RemainedVolume_in_LastSection%Remove (Ann_KickLoc+1)
call Ann_EmptyVolume_inBackheadLocation%Remove (Ann_KickLoc+1)
call Ann_MudOrKick%Remove (Ann_KickLoc+1)
call Ann_CuttingMud%Remove (Ann_KickLoc+1)
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)
endif endif


! backheade kick balaye mate bashad ! backheade kick balaye mate bashad
if (Ann_KIckLoc > 1) then
if (MudSystemDotAnn_KickLoc > 1) then
!if ( Ann_Density%Array (Ann_KickLoc-1) /= NewDensity ) then !if ( Ann_Density%Array (Ann_KickLoc-1) /= NewDensity ) then
if ( ABS(Ann_Density%Array (Ann_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(Ann_Density%Array (MudSystemDotAnn_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then
Old_KickBackHead_X= Ann_Mud_Backhead_X%Array (Ann_KickLoc)
Old_KickBackHead_Section= Ann_Mud_Backhead_section%Array (Ann_KickLoc)
MudSystemDotOld_KickBackHead_X= Ann_Mud_Backhead_X%Array (MudSystemDotAnn_KickLoc)
MudSystemDotOld_KickBackHead_Section= Ann_Mud_Backhead_section%Array (MudSystemDotAnn_KickLoc)
call Ann_Density%AddTo (Ann_KickLoc,NewDensity)
call Ann_MudDischarged_Volume%AddTo (Ann_KickLoc,NewVolume)
call Ann_Mud_Forehead_X%AddTo (Ann_KickLoc,Old_KickBackHead_X)
call Ann_Mud_Forehead_section%AddTo (Ann_KickLoc,Old_KickBackHead_Section)
call Ann_Mud_Backhead_X%AddTo (Ann_KickLoc,Old_KickBackHead_X)
call Ann_Mud_Backhead_section%AddTo (Ann_KickLoc,Old_KickBackHead_Section)
call Ann_RemainedVolume_in_LastSection%AddTo (Ann_KickLoc,0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddTo (Ann_KickLoc,0.0d0)
call Ann_MudOrKick%AddTo (Ann_KickLoc,0)
call Ann_CuttingMud%AddTo (Ann_KickLoc,0)
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)
else !Op_Density%Array (imudKick-1) == NewDensity else !Op_Density%Array (imudKick-1) == NewDensity


Ann_Density%Array(Ann_KickLoc-1)= (Ann_Density%Array(Ann_KickLoc-1)*Ann_MudDischarged_Volume%Array(Ann_KickLoc-1)+NewDensity*NewVolume)/(Ann_MudDischarged_Volume%Array(Ann_KickLoc-1)+NewVolume)
Ann_MudDischarged_Volume%Array(Ann_KickLoc-1)= Ann_MudDischarged_Volume%Array(Ann_KickLoc-1) + NewVolume
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
endif endif
@@ -531,16 +531,16 @@ DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
else !if Ann_KickLoc == 1 *6 =============================== else !if Ann_KickLoc == 1 *6 ===============================
!write(*,*) '****6' !write(*,*) '****6'
Old_KickBackHead_X= Ann_Mud_Backhead_X%Array (Ann_KickLoc)
Old_KickBackHead_Section= Ann_Mud_Backhead_section%Array (Ann_KickLoc)
MudSystemDotOld_KickBackHead_X= Ann_Mud_Backhead_X%Array (MudSystemDotAnn_KickLoc)
MudSystemDotOld_KickBackHead_Section= Ann_Mud_Backhead_section%Array (MudSystemDotAnn_KickLoc)
call Ann_Density%AddToFirst (NewDensity) call Ann_Density%AddToFirst (NewDensity)
call Ann_MudDischarged_Volume%AddToFirst (NewVolume)
call Ann_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X)
call Ann_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section)
call Ann_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Ann_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
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_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call Ann_MudOrKick%AddToFirst (0) call Ann_MudOrKick%AddToFirst (0)
@@ -560,208 +560,208 @@ DO KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
!============================== kick 2 tarafe mate bashad *4 ============================== !============================== kick 2 tarafe mate bashad *4 ==============================
if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 ) then
if ( MudSystemDotAnn_KickLoc > 0 .and. MudSystemDotOp_KickLoc > 0 ) then
!write(*,*) '****4' !write(*,*) '****4'
iloc= 2
MudSystemDotiLoc= 2
KickDv= Area_PipeSectionFt(Ann_Mud_Forehead_section%Array(Ann_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal
MudSystemDotKickDv= MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotAnn_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal
MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick
MudSystemDotMinKickDv= min( MudSystemDotKickDv,MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1), MudSystemDotOp_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick


NewDensity= Ann_Density%Array (Ann_KickLoc+1)
NewVolume= MinKickDv
NewDensity= Ann_Density%Array (MudSystemDotAnn_KickLoc+1)
MudSystemDotNewVolume= MudSystemDotMinKickDv
if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund
if ( MudSystemDotMinKickDv == MudSystemDotKickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund
!write(*,*) '****4----1' !write(*,*) '****4----1'


Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - MinKickDv
MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotMinKickDv
Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1
MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1
Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last
MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! Op_KickLoc= last
! backheade kick zire mate bashad ! backheade kick zire mate bashad
if ( Op_KickLoc>1) then
if ( MudSystemDotOp_KickLoc>1) then
!if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_Density%AddTo (Op_KickLoc,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)
call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0)
call Op_MudOrKick%AddTo (Op_KickLoc,0)
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)
else ! merge else ! merge


Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
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


endif endif
else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2===============================
!write(*,*) '****5-2' !write(*,*) '****5-2'
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_Density%AddToFirst (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)
call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
endif endif
elseif ( MinKickDv == Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund
elseif ( MudSystemDotMinKickDv == MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) ) then ! eleman bala sari baghi nemimund
!write(*,*) '****4----2' !write(*,*) '****4----2'
call Ann_MudDischarged_Volume%Remove (Ann_KickLoc+1)
call Ann_Mud_Backhead_X%Remove (Ann_KickLoc+1)
call Ann_Mud_Backhead_section%Remove (Ann_KickLoc+1)
call Ann_Mud_Forehead_X%Remove (Ann_KickLoc+1)
call Ann_Mud_Forehead_section%Remove (Ann_KickLoc+1)
call Ann_Density%Remove (Ann_KickLoc+1)
call Ann_RemainedVolume_in_LastSection%Remove (Ann_KickLoc+1)
call Ann_EmptyVolume_inBackheadLocation%Remove (Ann_KickLoc+1)
call Ann_MudOrKick%Remove (Ann_KickLoc+1)
call Ann_CuttingMud%Remove (Ann_KickLoc+1)
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)
Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1
MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1
Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last
MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! Op_KickLoc= last
! backheade kick zire mate bashad ! backheade kick zire mate bashad
if (Op_KickLoc > 1) then
if (MudSystemDotOp_KickLoc > 1) then
!if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_Density%AddTo (Op_KickLoc,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)
call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0)
call Op_MudOrKick%AddTo (Op_KickLoc,0)
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)
else !Op_Density%Array (imudKick-1) == NewDensity else !Op_Density%Array (imudKick-1) == NewDensity
Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
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
endif endif
else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2===============================
Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_Density%AddToFirst (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)
call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
endif endif
elseif ( MinKickDv == Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod
elseif ( MudSystemDotMinKickDv == MudSystemDotOp_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod
!write(*,*) '****4----3' !write(*,*) '****4----3'
Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - MinKickDv
MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotMinKickDv
Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1
MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1


Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc)
MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc)
call Op_MudDischarged_Volume%Remove (Op_KickLoc) ! Op_KickLoc= last
call Op_Mud_Backhead_X%Remove (Op_KickLoc)
call Op_Mud_Backhead_section%Remove (Op_KickLoc)
call Op_Mud_Forehead_X%Remove (Op_KickLoc)
call Op_Mud_Forehead_section%Remove (Op_KickLoc)
call Op_Density%Remove (Op_KickLoc)
call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc)
call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc)
call Op_MudOrKick%Remove (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)
! backheade kick zire mate bashad ! backheade kick zire mate bashad
if (Op_KickLoc > 1) then
if (MudSystemDotOp_KickLoc > 1) then
!if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then


call Op_Density%AddTo (Op_KickLoc,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)
call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0)
call Op_MudOrKick%AddTo (Op_KickLoc,0)
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)
else !Op_Density%Array (imudKick-1) == NewDensity else !Op_Density%Array (imudKick-1) == NewDensity
Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
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
endif endif
else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2===============================


call Op_Density%AddToFirst (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)
call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section)
call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
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 Op_MudOrKick%AddToFirst (0)
endif endif
iloc= 1 ! ok
MudSystemDotiLoc= 1 ! ok
endif endif




+ 27
- 27
Equipments/MudSystem/MudSystem.f90 View File

@@ -217,7 +217,7 @@ module MudSystem
!================================================ !================================================
!============BellNippleToPits-FullWell============== !============BellNippleToPits-FullWell==============
if(FirstMudSet== 1 ) then !.and. WellisNOTFull== .false.) then ! Well Must Be Full !Ann_Mud_Forehead_X%Last()==AboveAnnularHeight .and. Ann_Density%Last()/=0.0)
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(condition4) then if(condition4) then
j3=j3+1 j3=j3+1
B71=1 B71=1
@@ -309,7 +309,7 @@ module MudSystem
!============BellNippleToWell-NonFullWell============== !============BellNippleToWell-NonFullWell==============


if(condition16 .and. FirstMudSet== 1 .and. BellNippleVolume > 0.0001 .and. WellisNOTFull) then
if(condition16 .and. MudSystemDotFirstMudSet== 1 .and. BellNippleVolume > 0.0001 .and. MudSystemDotWellisNOTFull) then
write(*,*) 'MUD(7)%Q=' , MUD(7)%Q write(*,*) 'MUD(7)%Q=' , MUD(7)%Q
write(*,*) 'BellNippleVolume=' , BellNippleVolume write(*,*) 'BellNippleVolume=' , BellNippleVolume
@@ -638,9 +638,9 @@ module MudSystem
implicit none implicit none
Integer I Integer I


MudSys_timeCounter = MudSys_timeCounter + 1
MudSystemDotMudSys_timeCounter = MudSystemDotMudSys_timeCounter + 1
if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
MudSys_timeCounter= 0
MudSystemDotMudSys_timeCounter= 0
endif endif
!WRITE (*,*) 'MudSys_timeCounter', MudSys_timeCounter !WRITE (*,*) 'MudSys_timeCounter', MudSys_timeCounter
@@ -884,18 +884,18 @@ module MudSystem


if (PumpPressure1 >= MaxWorkingPressure1 .and. MP1_Q > 0.0) then if (PumpPressure1 >= MaxWorkingPressure1 .and. MP1_Q > 0.0) then
write(*,*) 'mp1,if=' , PumpPressure1 , MaxWorkingPressure1 , MP1_Q write(*,*) 'mp1,if=' , PumpPressure1 , MaxWorkingPressure1 , MP1_Q
Pump1BlownCount = Pump1BlownCount + 1
MudSystemDotPump1BlownCount = MudSystemDotPump1BlownCount + 1
!if (Pump1BlownStarted == .FALSE.) then !if (Pump1BlownStarted == .FALSE.) then
! write(*,*) 'if (Pump1BlownStarted == .FALSE. ) then' ! write(*,*) 'if (Pump1BlownStarted == .FALSE. ) then'
! Pump1BlownInTimeStep = SimulationTime + BlownThresholdInSecond ! Pump1BlownInTimeStep = SimulationTime + BlownThresholdInSecond
! Pump1BlownStarted = .TRUE. ! Pump1BlownStarted = .TRUE.
!endif !endif
!write(*,*) 'SimulationTime===', SimulationTime, Pump1BlownInTimeStep !write(*,*) 'SimulationTime===', SimulationTime, Pump1BlownInTimeStep
if(PumpsSpecification%MudPump1ReliefValveIsSet .and. Pump1BlownCount >= BlownThreshold) then
if(PumpsSpecification%MudPump1ReliefValveIsSet .and. MudSystemDotPump1BlownCount >= BlownThreshold) then
write(*,*) 'valve 65 open, BLOWN' write(*,*) 'valve 65 open, BLOWN'
call ChangeValve(65, .TRUE.) call ChangeValve(65, .TRUE.)
PumpToManifoldCompressedMudVol= 0.0 PumpToManifoldCompressedMudVol= 0.0
Pump1BlownCount = 0
MudSystemDotPump1BlownCount = 0
!Pump1BlownStarted = .FALSE. !Pump1BlownStarted = .FALSE.
!else !else
! write(*,*) 'PumpPressure1= 6000 psi' ! write(*,*) 'PumpPressure1= 6000 psi'
@@ -917,17 +917,17 @@ module MudSystem
if(PumpPressure2 >= MaxWorkingPressure2 .and. MP2_Q > 0.0 ) then if(PumpPressure2 >= MaxWorkingPressure2 .and. MP2_Q > 0.0 ) then


write(*,*) 'mp2,if=' , PumpPressure2 , MaxWorkingPressure2 , MP2_Q write(*,*) 'mp2,if=' , PumpPressure2 , MaxWorkingPressure2 , MP2_Q
Pump2BlownCount = Pump2BlownCount + 1
MudSystemDotPump2BlownCount = MudSystemDotPump2BlownCount + 1
!if (Pump2BlownStarted == .FALSE. ) then !if (Pump2BlownStarted == .FALSE. ) then
! Pump2BlownInTimeStep = SimulationTime + BlownThresholdInSecond ! Pump2BlownInTimeStep = SimulationTime + BlownThresholdInSecond
! Pump2BlownStarted = .TRUE. ! Pump2BlownStarted = .TRUE.
!endif !endif
!if (MudPump2ReliefValveIsSet .and. SimulationTime >= Pump2BlownInTimeStep .and. Pump2BlownStarted) then !if (MudPump2ReliefValveIsSet .and. SimulationTime >= Pump2BlownInTimeStep .and. Pump2BlownStarted) then
if (PumpsSpecification%MudPump2ReliefValveIsSet .and. Pump2BlownCount >= BlownThreshold) then
if (PumpsSpecification%MudPump2ReliefValveIsSet .and. MudSystemDotPump2BlownCount >= BlownThreshold) then
write(*,*) 'valve 66 open, BLOWN' write(*,*) 'valve 66 open, BLOWN'
call ChangeValve(66, .TRUE.) call ChangeValve(66, .TRUE.)
PumpToManifoldCompressedMudVol= 0.0 PumpToManifoldCompressedMudVol= 0.0
Pump2BlownCount = 0
MudSystemDotPump2BlownCount = 0
!Pump2BlownInTimeStep = 0 !Pump2BlownInTimeStep = 0
!Pump2BlownStarted = .FALSE. !Pump2BlownStarted = .FALSE.
!else !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 !.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 if(PumpPressure3 >= MaxWorkingPressure3 .and. MP3_Q > 0.0 ) then
Pump3BlownCount = Pump3BlownCount + 1
if (PumpsSpecification%CementPumpReliefValveIsSet .and. Pump3BlownCount >= BlownThreshold) then
MudSystemDotPump3BlownCount = MudSystemDotPump3BlownCount + 1
if (PumpsSpecification%CementPumpReliefValveIsSet .and. MudSystemDotPump3BlownCount >= BlownThreshold) then
!write(*,*) 'valve 67 open, BLOWN' !write(*,*) 'valve 67 open, BLOWN'
call ChangeValve(67, .TRUE.) call ChangeValve(67, .TRUE.)
PumpToManifoldCompressedMudVol= 0.0 PumpToManifoldCompressedMudVol= 0.0
Pump3BlownCount = 0
MudSystemDotPump3BlownCount = 0
!else !else
! PumpPressure3= 6000. !psi ! PumpPressure3= 6000. !psi
endif endif
@@ -959,13 +959,13 @@ module MudSystem
!write(*,*) '3)PumpPressure1=' , PumpPressure1 !write(*,*) '3)PumpPressure1=' , PumpPressure1
if (PumpPressure1>= 6000.) then if (PumpPressure1>= 6000.) then
Pump1BlownCount = Pump1BlownCount + 1
if(Pump1BlownCount >= BlownThreshold) then
MudSystemDotPump1BlownCount = MudSystemDotPump1BlownCount + 1
if(MudSystemDotPump1BlownCount >= BlownThreshold) then
call ChangeValve(65, .TRUE.) call ChangeValve(65, .TRUE.)
PumpToManifoldCompressedMudVol= 0.0 PumpToManifoldCompressedMudVol= 0.0
call Activate_Pump1Failure() call Activate_Pump1Failure()
Pump1OffFailure= .true. Pump1OffFailure= .true.
Pump1BlownCount = 0
MudSystemDotPump1BlownCount = 0
endif endif
!else !else
!Pump1BlownInTimeStep = 0 !Pump1BlownInTimeStep = 0
@@ -973,13 +973,13 @@ module MudSystem
endif endif
if (PumpPressure2>= 6000.) then if (PumpPressure2>= 6000.) then
Pump2BlownCount = Pump2BlownCount + 1
if(Pump2BlownCount >= BlownThreshold) then
MudSystemDotPump2BlownCount = MudSystemDotPump2BlownCount + 1
if(MudSystemDotPump2BlownCount >= BlownThreshold) then
call ChangeValve(66, .TRUE.) call ChangeValve(66, .TRUE.)
PumpToManifoldCompressedMudVol= 0.0 PumpToManifoldCompressedMudVol= 0.0
call Activate_Pump2Failure() call Activate_Pump2Failure()
Pump2OffFailure= .true. Pump2OffFailure= .true.
Pump2BlownCount = 0
MudSystemDotPump2BlownCount = 0
endif endif
!else !else
!Pump2BlownInTimeStep = 0 !Pump2BlownInTimeStep = 0
@@ -987,13 +987,13 @@ module MudSystem
endif endif
if (PumpPressure3>= 6000.) then if (PumpPressure3>= 6000.) then
Pump3BlownCount = Pump3BlownCount + 1
if(Pump3BlownCount >= BlownThreshold) then
MudSystemDotPump3BlownCount = MudSystemDotPump3BlownCount + 1
if(MudSystemDotPump3BlownCount >= BlownThreshold) then
call ChangeValve(67, .TRUE.) call ChangeValve(67, .TRUE.)
PumpToManifoldCompressedMudVol= 0.0 PumpToManifoldCompressedMudVol= 0.0
call Activate_Pump3Failure() call Activate_Pump3Failure()
Pump3OffFailure= .true. Pump3OffFailure= .true.
Pump3BlownCount = 0
MudSystemDotPump3BlownCount = 0
endif endif
!else !else
!Pump3BlownInTimeStep = 0 !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= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline
MUD(7)%Q= ( MudVolume_InjectedFromAnn + Ann_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud
MUD(7)%Q= ( MudVolume_InjectedFromAnn + MudSystemDotAnn_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud
if (j4 > 0) then if (j4 > 0) then
@@ -1394,14 +1394,14 @@ module MudSystem
!WRITE (*,*) 'choke condition', j4, ChokeLineNOTFull !WRITE (*,*) 'choke condition', j4, ChokeLineNOTFull
if (j4 > 0 .and. ChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26)
if (j4 > 0 .and. MudSystemDotChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26)
!write(*,*) 'j4 is open' !write(*,*) 'j4 is open'
!write(*,*) 'active by j4' !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= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline
MUD(4)%Q= ( MudVolume_InjectedFromAnn + Ann_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud
MUD(4)%Q= ( MudVolume_InjectedFromAnn + MudSystemDotAnn_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud
!if ( WellisNOTFull== .true. ) MUD(4)%Q= 0.0 !if ( WellisNOTFull== .true. ) MUD(4)%Q= 0.0
@@ -1415,7 +1415,7 @@ module MudSystem
!call Log_1('MUD(4)%Q=', MUD(4)%Q) !call Log_1('MUD(4)%Q=', MUD(4)%Q)
ChokeOutletDensity= ChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code
ChokeOutletDensity= MudSystemDotChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code
!MudWeightOut2= ChokeOutletDensity !for drillwatch display !MudWeightOut2= ChokeOutletDensity !for drillwatch display
@@ -1583,7 +1583,7 @@ module MudSystem
if (j4 == 0 .or. ChokeLineNOTFull== .true.) then
if (j4 == 0 .or. MudSystemDotChokeLineNOTFull== .true.) then
!Pressure_BeforeChokes=0.0 ! for normal circulation input !Pressure_BeforeChokes=0.0 ! for normal circulation input
MUD(4)%Q=0.0 ! for CirculationCodeSelect input. MUD(4)%Q=0.0 ! for CirculationCodeSelect input.
endif endif


+ 41
- 41
Equipments/MudSystem/MudSystemStartup.f90 View File

@@ -20,15 +20,15 @@
!Pump2BlownStarted = .FALSE. !Pump2BlownStarted = .FALSE.
!Pump3BlownStarted = .FALSE. !Pump3BlownStarted = .FALSE.
Pump1BlownCount = 0
Pump2BlownCount = 0
Pump3BlownCount = 0
MudSystemDotPump1BlownCount = 0
MudSystemDotPump2BlownCount = 0
MudSystemDotPump3BlownCount = 0
DeltaWellCap=0.
WellCapOld = 0.
AnnCapOld=0.
DeltaAnnCap=0.
MudSystemDotDeltaWellCap=0.
MudSystemDotWellCapOld = 0.
MudSystemDotAnnCapOld=0.
MudSystemDotDeltaAnnCap=0.
total_pumps%Total_Stroke_Counter_For_Plot = 0.0 total_pumps%Total_Stroke_Counter_For_Plot = 0.0
@@ -39,58 +39,58 @@ total_pumps%Total_Stroke_Counter_For_Plot = 0.0
Call Set_FlowPipeDisconnect(.false.) Call Set_FlowPipeDisconnect(.false.)
!HZ_ADD= 0.d0 !HZ_ADD= 0.d0
Flow_timeCounter= 0
MudSys_timeCounter= 0
FluidFlowCounter = 0
MudSystemDotFlow_timeCounter= 0
MudSystemDotMudSys_timeCounter= 0
MudSystemDotFluidFlowCounter = 0
!======================================================================== !========================================================================
! MUD CIRCULATION STARTUP ! MUD CIRCULATION STARTUP
!======================================================================== !========================================================================
FormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth
ShoeFractured= .false.
MudSystemDotFormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth
MudSystemDotShoeFractured= .false.
UGBOSuccessionCounter = 0 ! also in starup
UGBOSuccessionCounterOld = 0 ! also in starup
MudSystemDotUGBOSuccessionCounter = 0 ! also in starup
MudSystemDotUGBOSuccessionCounterOld = 0 ! also in starup
ChokeLineFlowRate= 0.0
StringFlowRate= 0.0
AnnulusFlowRate= 0.0
MudSystemDotChokeLineFlowRate= 0.0
MudSystemDotStringFlowRate= 0.0
MudSystemDotAnnulusFlowRate= 0.0
MudVolume_InjectedFromAnn= 0.D0 MudVolume_InjectedFromAnn= 0.D0
MudVolume_InjectedToBH= 0.D0
MudSystemDotMudVolume_InjectedToBH= 0.D0
DensityMixTol= 0.1 !(ppg)
CuttingDensityMixTol= 0.5
NewPipeFilling= 1
UtubeFilling= 1
UtubeEmptyVolume= 0.0
MudSystemDotDensityMixTol= 0.1 !(ppg)
MudSystemDotCuttingDensityMixTol= 0.5
MudSystemDotNewPipeFilling= 1
MudSystemDotUtubeFilling= 1
MudSystemDotUtubeEmptyVolume= 0.0
UtubeMode1Activated= .false.
UtubeMode2Activated= .false.
UtubePossibility= .false.
MudSystemDotUtubeMode1Activated= .false.
MudSystemDotUtubeMode2Activated= .false.
MudSystemDotUtubePossibility= .false.
!KickMigration_2SideBit = .FALSE. !KickMigration_2SideBit = .FALSE.
KickDx= (Reservoir%AutoMigrationRate/3600.)*DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline
MudSystemDotKickDx= (Reservoir%AutoMigrationRate/3600.)*DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline


NewInfluxElementCreated= 0
NewInfluxNumber= 0
MudSystemDotNewInfluxElementCreated= 0
MudSystemDotNewInfluxNumber= 0
!KickVolumeinAnnulus= 0.0 !KickVolumeinAnnulus= 0.0
KickDeltaVinAnnulus= 0.0
MudSystemDotKickDeltaVinAnnulus= 0.0
GasKickPumpFlowRate= 0.0 GasKickPumpFlowRate= 0.0
FirstMudSet= 0
FirstSetUtube1=0
FirstSetUtube2=0
SuctionMud=1
ImudCount= 1
imud=1
iLoc= 1 ! for Kick
MudSystemDotFirstMudSet= 0
MudSystemDotFirstSetUtube1=0
MudSystemDotFirstSetUtube2=0
MudSystemDotSuctionMud=1
MudSystemDotImudCount= 1
MudSystemDotimud=1
MudSystemDotiLoc= 1 ! for Kick


Suction_Density_MudSystem= MudProperties%ActiveDensity Suction_Density_MudSystem= MudProperties%ActiveDensity
SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg)
@@ -98,10 +98,10 @@ FluidFlowCounter = 0
AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg)
ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg) ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg)
TotalAddedVolume= 0.
MudSystemDotTotalAddedVolume= 0.




xx=0.
MudSystemDotxx=0.




@@ -331,8 +331,8 @@ PIPINGS_MUDLINE(4,1)= BopStackSpecification%ChokeLineId
PIPINGS_MUDLINE(4,2)= BopStackSpecification%ChokeLineLength PIPINGS_MUDLINE(4,2)= BopStackSpecification%ChokeLineLength
PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold) PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold)


Area_ChokeLineFt= PII*((BopStackSpecification%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2)
ChokeLine_VolumeCapacity= Area_ChokeLineFt* BopStackSpecification%ChokeLineLength* 7.48051948 ! (gal)
MudSystemDotArea_ChokeLineFt= PII*((BopStackSpecification%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2)
MudSystemDotChokeLine_VolumeCapacity= MudSystemDotArea_ChokeLineFt* BopStackSpecification%ChokeLineLength* 7.48051948 ! (gal)


ALLOCATE (DIAM_MUDLINE_INCH(NO_PIPINGSMUDLINE), & ALLOCATE (DIAM_MUDLINE_INCH(NO_PIPINGSMUDLINE), &
AREA_MUDLINE(NO_PIPINGSMUDLINE),LENGT_MUDLINE(NO_PIPINGSMUDLINE),ROUGHNESS_MUDLINE(NO_PIPINGSMUDLINE),RELROUGH_MUDLINE(NO_PIPINGSMUDLINE)) AREA_MUDLINE(NO_PIPINGSMUDLINE),LENGT_MUDLINE(NO_PIPINGSMUDLINE),ROUGHNESS_MUDLINE(NO_PIPINGSMUDLINE),RELROUGH_MUDLINE(NO_PIPINGSMUDLINE))


+ 47
- 66
Equipments/MudSystem/MudSystem_Variables.f90 View File

@@ -16,71 +16,69 @@ USE CReservoirVariables


IMPLICIT NONE IMPLICIT NONE


integer, parameter :: BlownThreshold = 10


! temporary varibales for solving pressure jerks -- 1399-11-09 ! temporary varibales for solving pressure jerks -- 1399-11-09
integer Pump1BlownCount, Pump2BlownCount, Pump3BlownCount
integer, parameter :: BlownThreshold = 10
integer MudSystemDotPump1BlownCount, MudSystemDotPump2BlownCount, MudSystemDotPump3BlownCount


!integer Pump1BlownInTimeStep, Pump2BlownInTimeStep, Pump3BlownInTimeStep !integer Pump1BlownInTimeStep, Pump2BlownInTimeStep, Pump3BlownInTimeStep
!logical Pump1BlownStarted, Pump2BlownStarted, Pump3BlownStarted !logical Pump1BlownStarted, Pump2BlownStarted, Pump3BlownStarted
!integer, parameter :: BlownThresholdInSecond = 5 !integer, parameter :: BlownThresholdInSecond = 5




real(8) total_add,total_injected
real(8) DeltaWellCap,WellCapOld,AnnCapOld,DeltaAnnCap

real(8) MudSystemDottotal_add,MudSystemDottotal_injected
real(8) MudSystemDotDeltaWellCap,MudSystemDotWellCapOld,MudSystemDotAnnCapOld,MudSystemDotDeltaAnnCap


!======================================================================== !========================================================================
! KICK VARIABLES ! KICK VARIABLES
!======================================================================== !========================================================================
REAL(8) KickDeltaVinAnnulus, KickVolumeinAnnulus
REAL(8) Kick_Forehead_X,Kick_RemainedVolume_in_LastSection,BackheadX,KickDv,KickDx,MinKickDv,Old_KickBackHead_X,Kick_Density
INTEGER NewInfluxElementCreated,Kick_Forehead_section,MudSection,Op_KickLoc,Ann_KickLoc,FirstSetKickMigration,Old_KickBackHead_Section
Integer iLoc,ChokeLine_KickLoc,KickNumber,NewInfluxNumber,SoundGasThroughChoke
REAL(8) MudSystemDotKickDeltaVinAnnulus, MudSystemDotKickVolumeinAnnulus
REAL(8) MudSystemDotKick_Forehead_X,MudSystemDotKick_RemainedVolume_in_LastSection,MudSystemDotBackheadX,MudSystemDotKickDv,MudSystemDotKickDx,MudSystemDotMinKickDv,MudSystemDotOld_KickBackHead_X,MudSystemDotKick_Density
INTEGER MudSystemDotNewInfluxElementCreated,MudSystemDotKick_Forehead_section,MudSystemDotMudSection,MudSystemDotOp_KickLoc,MudSystemDotAnn_KickLoc,MudSystemDotFirstSetKickMigration,MudSystemDotOld_KickBackHead_Section
Integer MudSystemDotiLoc,MudSystemDotChokeLine_KickLoc,MudSystemDotKickNumber,MudSystemDotNewInfluxNumber,MudSystemDotSoundGasThroughChoke


LOGICAL DrillingMode
LOGICAL MudSystemDotDrillingMode
!real(8) HZ_ADD !real(8) HZ_ADD
integer Flow_timeCounter,MudSys_timeCounter,FluidFlowCounter
integer MudSystemDotFlow_timeCounter,MudSystemDotMudSys_timeCounter,MudSystemDotFluidFlowCounter
!======================================================================== !========================================================================
! MUD CIRCULATION ! MUD CIRCULATION
!======================================================================== !========================================================================
REAL(8), ALLOCATABLE:: Xstart_PipeSection(:),Xend_PipeSection(:),PipeSection_VolumeCapacity(:),Area_PipeSectionFt(:),OD_PipeSectionInch(:),ID_PipeSectionInch(:),Angle_PipeSection(:)
REAL(8), ALLOCATABLE:: Xstart_OpSection(:),Xend_OpSection(:),Area_OpSectionFt(:),OD_OpSectionInch(:),ID_OpSectionInch(:),OpSection_VolumeCapacity(:),GeoTypeOp(:),Angle_OpSection(:)
REAL(8), ALLOCATABLE:: TDXstart_MudElementArray(:) , TDXend_MudElementArray(:) , TDDensity_MudElementArray(:)

INTEGER, ALLOCATABLE:: GeoType(:)
real(8) StMudVolumeSum,St_MudSaved_Density,St_Saved_MudDischarged_Volume,St_Saved_MudDischarged_Volume_Final,MudVolume_InjectedToBH,MudVolume_InjectedFromAnn
real BitMudDensity
REAL(8) xx,TrueMinValue,NewVolume,UtubeEmptyVolume,NewDensity, MudCircVerticalDepth
REAL DirectionCoef
INTEGER isection,OpSection,imud,SuctionMud,NoStringMudElements,ImudCount,NoCasingMudElements,NoHorizontalMudElements,AddedElementsToString
Integer TDNoHorizontalMudElements, TDNoStringMudElements, TDNoCasingMudElements
Integer istring,icasing,iisection,NoPipeSections,FirstMudSet
INTEGER NoBottomHoleMudElements,NoStringMudElementsForPlot,F_StringIntervalCounts_Old
INTEGER FirstSetUtube1,FirstSetUtube2,FirstAdded,NewPipeFilling,Hz_MudOrKick_Utube,UtubeFilling,totalLength
REAL(8) DeltaVolumeOp,DeltaVTemp,OldPosition,StringFlowRate,StringFlowRateFinal,AnnulusFlowRateFinal,TD_RemoveVolume_Remained,DeltaVolumePipe,DeltaVolumeAnnulusCapacity
REAL AnnulusFlowRate,ChokeLineFlowRate
Logical:: UtubePossibility,MudIsChanged,AddedPipe,UtubeMode1Activated,UtubeMode2Activated,WellisNOTFull,ChokeLineNOTFull
Logical:: ShoeLost,ShoeFractured,Kickexpansion_DueToMudLost,LostInTripOutIsDone
Integer UGBOSuccessionCounter, UGBOSuccessionCounterOld
REAL(8) Area_ChokeLineFt, ChokeLine_VolumeCapacity,TotalAddedVolume,LackageMudVolumeAfterFilling, LackageMudVolume, NewInflux_Density
real(8) DensityMixTol,Hz_Density_Utube,CuttingDensityMixTol,Op_Kick_Saved_Volume,Op_MudSaved_Density,Op_KickSaved_Density,Op_Saved_MudDischarged_Volume,OpMudVolumeSum,Op_NeededVolume_ToFill
real(8) Choke_Kick_Saved_Volume,Choke_Saved_MudDischarged_Volume,Choke_KickSaved_Density,Choke_MudSaved_Density,ChokeMudVolumeSum
integer Saved_Op_MudOrKick,Saved_Ann_MudOrKick,Saved_Choke_MudOrKick
real(8) Choke_Saved_MudDischarged_Volume_Final,Choke_Kick_Saved_Volume_Final
real(8) Qlost,FormationLostPressure,ShoeMudPressure,ShoeLostCoef, ShoeMudViscosity, ShoeMudDensity ,OldAnnulusCapacity
logical:: Ann_to_Choke_2mud
real(8) AnnMudVolumeSum,Ann_MudSaved_Density,Ann_KickSaved_Density,Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume,Ann_Saved_MudDischarged_Volume_Final, Ann_Kick_Saved_Volume_Final
type(DynamicDoubleArrayType) :: Hz_MudDischarged_Volume,Hz_Mud_Backhead_X,Hz_Mud_Forehead_X,Hz_Density,Hz_RemainedVolume_in_LastSection,Hz_EmptyVolume_inBackheadLocation, &
Op_MudDischarged_Volume,Op_Mud_Backhead_X,Op_Mud_Forehead_X,Op_Density,Op_RemainedVolume_in_LastSection,Op_EmptyVolume_inBackheadLocation

type(DynamicDoubleArrayType) :: ChokeLine_MudDischarged_Volume,ChokeLine_Mud_Backhead_X,ChokeLine_Mud_Forehead_X,ChokeLine_Density,ChokeLine_RemainedVolume_in_LastSection, &
ChokeLine_EmptyVolume_inBackheadLocation


type(DynamicDoubleArrayType) :: St_MudDischarged_Volume,St_Mud_Backhead_X,St_Mud_Forehead_X,St_Density,St_RemainedVolume_in_LastSection, &
St_EmptyVolume_inBackheadLocation,Ann_MudDischarged_Volume,Ann_Mud_Backhead_X,Ann_Mud_Forehead_X, &
REAL(8), ALLOCATABLE:: MudSystemDotXstart_PipeSection(:),MudSystemDotXend_PipeSection(:),MudSystemDotPipeSection_VolumeCapacity(:),MudSystemDotArea_PipeSectionFt(:),MudSystemDotOD_PipeSectionInch(:),MudSystemDotID_PipeSectionInch(:),MudSystemDotAngle_PipeSection(:)
REAL(8), ALLOCATABLE:: MudSystemDotXstart_OpSection(:),MudSystemDotXend_OpSection(:),MudSystemDotArea_OpSectionFt(:),MudSystemDotOD_OpSectionInch(:),MudSystemDotID_OpSectionInch(:),MudSystemDotOpSection_VolumeCapacity(:),MudSystemDotGeoTypeOp(:),MudSystemDotAngle_OpSection(:)
REAL(8), ALLOCATABLE:: MudSystemDotTDXstart_MudElementArray(:) , MudSystemDotTDXend_MudElementArray(:) , MudSystemDotTDDensity_MudElementArray(:)

INTEGER, ALLOCATABLE:: MudSystemDotGeoType(:)
real(8) MudSystemDotStMudVolumeSum,MudSystemDotSt_MudSaved_Density,MudSystemDotSt_Saved_MudDischarged_Volume,MudSystemDotSt_Saved_MudDischarged_Volume_Final,MudSystemDotMudVolume_InjectedToBH,MudSystemDotMudVolume_Injec2tedFromAnn
real MudSystemDotBitMudDensity
REAL(8) MudSystemDotxx,MudSystemDotNewVolume,MudSystemDotUtubeEmptyVolume,MudSystemDotNe2wDensity, MudSystemDotMudCircVerticalDepth
! ,TrueMinValue
REAL MudSystemDotDirectionCoef
INTEGER MudSystemDotisection,MudSystemDotOpSection,MudSystemDotimud,MudSystemDotSuctionMud,MudSystemDotNoStringMudElements,MudSystemDotImudCount,MudSystemDotNoCasingMudElements,MudSystemDotNoHorizontalMudElements,MudSystemDotAddedElementsToString
Integer MudSystemDotTDNoHorizontalMudElements, MudSystemDotTDNoStringMudElements, MudSystemDotTDNoCasingMudElements
Integer MudSystemDotistring,MudSystemDoticasing,MudSystemDotiisection,MudSystemDotNoPipeSections,MudSystemDotFirstMudSet
INTEGER MudSystemDotNoBottomHoleMudElements,MudSystemDotNoStringMudElementsForPlot,MudSystemDotF_StringIntervalCounts_Old
INTEGER MudSystemDotFirstSetUtube1,MudSystemDotFirstSetUtube2,MudSystemDotFirstAdded,MudSystemDotNewPipeFilling,MudSystemDotHz_MudOrKick_Utube,MudSystemDotUtubeFilling,MudSystemDottotalLength
REAL(8) MudSystemDotDeltaVolumeOp,MudSystemDotDeltaVTemp,MudSystemDotOldPosition,MudSystemDotStringFlowRate,MudSystemDotStringFlowRateFinal,MudSystemDotAnnulusFlowRateFinal,MudSystemDotTD_RemoveVolume_Remained,MudSystemDotDeltaVolumePipe,MudSystemDotDeltaVolumeAnnulusCapacity
REAL MudSystemDotAnnulusFlowRate,MudSystemDotChokeLineFlowRate
Logical:: MudSystemDotUtubePossibility,MudSystemDotMudIsChanged,MudSystemDotAddedPipe,MudSystemDotUtubeMode1Activated,MudSystemDotUtubeMode2Activated,MudSystemDotWellisNOTFull,MudSystemDotChokeLineNOTFull
Logical:: MudSystemDotShoeLost,MudSystemDotShoeFractured,MudSystemDotKickexpansion_DueToMudLost,MudSystemDotLostInTripOutIsDone
Integer MudSystemDotUGBOSuccessionCounter, MudSystemDotUGBOSuccessionCounterOld
REAL(8) MudSystemDotArea_ChokeLineFt, MudSystemDotChokeLine_VolumeCapacity,MudSystemDotTotalAddedVolume,MudSystemDotLackageMudVolumeAfterFilling, MudSystemDotLackageMudVolume, MudSystemDotNewInflux_Density
real(8) MudSystemDotDensityMixTol,MudSystemDotHz_Density_Utube,MudSystemDotCuttingDensityMixTol,MudSystemDotOp_Kick_Saved_Volume,MudSystemDotOp_MudSaved_Density,MudSystemDotOp_KickSaved_Density,MudSystemDotOp_Saved_MudDischarged_Volume,MudSystemDotOpMudVolumeSum,MudSystemDotOp_NeededVolume_ToFill
real(8) MudSystemDotChoke_Kick_Saved_Volume,MudSystemDotChoke_Saved_MudDischarged_Volume,MudSystemDotChoke_KickSaved_Density,MudSystemDotChoke_MudSaved_Density,MudSystemDotChokeMudVolumeSum
integer MudSystemDotSaved_Op_MudOrKick,MudSystemDotSaved_Ann_MudOrKick,MudSystemDotSaved_Choke_MudOrKick
real(8) MudSystemDotChoke_Saved_MudDischarged_Volume_Final,MudSystemDotChoke_Kick_Saved_Volume_Final
real(8) MudSystemDotQlost,MudSystemDotFormationLostPressure,MudSystemDotShoeMudPressure,MudSystemDotShoeLostCoef, MudSystemDotShoeMudViscosity, MudSystemDotShoeMudDensity ,MudSystemDotOldAnnulusCapacity
logical:: MudSystemDotAnn_to_Choke_2mud
real(8) MudSystemDotAnnMudVolumeSum,MudSystemDotAnn_MudSaved_Density,MudSystemDotAnn_KickSaved_Density,MudSystemDotAnn_Saved_MudDischarged_Volume,MudSystemDotAnn_Kick_Saved_Volume,MudSystemDotAnn_Saved_MudDischarged_Volume_Final, MudSystemDotAnn_Kick_Saved_Volume_Final
type(DynamicDoubleArrayType) :: MudSystemDotHz_MudDischarged_Volume,MudSystemDotHz_Mud_Backhead_X,MudSystemDotHz_Mud_Forehead_X,MudSystemDotHz_Density,MudSystemDotHz_RemainedVolume_in_LastSection,MudSystemDotHz_EmptyVolume_inBackheadLocation, &
MudSystemDotOp_MudDischarged_Volume,MudSystemDotOp_Mud_Backhead_X,MudSystemDotOp_Mud_Forehead_X,MudSystemDotOp_Density,MudSystemDotOp_RemainedVolume_in_LastSection,MudSystemDotOp_EmptyVolume_inBackheadLocation

type(DynamicDoubleArrayType) :: MudSystemDotChokeLine_MudDischarged_Volume,MudSystemDotChokeLine_Mud_Backhead_X,MudSystemDotChokeLine_Mud_Forehead_X,MudSystemDotChokeLine_Density,MudSystemDotChokeLine_RemainedVolume_in_LastSection, &
MudSystemDotChokeLine_EmptyVolume_inBackheadLocation


type(DynamicDoubleArrayType) :: MudSystemDotSt_MudDischarged_Volume,MudSystemDotSt_Mud_Backhead_X,MudSystemDotSt_Mud_Forehead_X,St_Density,MudSystemDotSt_RemainedVolume_in_LastSection, &
MudSystemDotSt_EmptyVolume_inBackheadLocation,MudSystemDotAnn_MudDischarged_Volume,Ann_Mud_Backhead_X,Ann_Mud_Forehead_X, &
Ann_Density,Ann_RemainedVolume_in_LastSection,Ann_EmptyVolume_inBackheadLocation Ann_Density,Ann_RemainedVolume_in_LastSection,Ann_EmptyVolume_inBackheadLocation
type(DynamicIntegerArrayType) :: St_Mud_Backhead_section,St_Mud_Forehead_section,Ann_Mud_Backhead_section,Ann_Mud_Forehead_section,MudGeoType,Hz_Mud_Backhead_section,Hz_Mud_Forehead_section, & type(DynamicIntegerArrayType) :: St_Mud_Backhead_section,St_Mud_Forehead_section,Ann_Mud_Backhead_section,Ann_Mud_Forehead_section,MudGeoType,Hz_Mud_Backhead_section,Hz_Mud_Forehead_section, &
@@ -206,23 +204,6 @@ logical Pump1OffFailure,Pump2OffFailure,Pump3OffFailure,ChokeLineGaugeToTanks,We
END TYPE MUD_TypeVars2D END TYPE MUD_TypeVars2D
TYPE(MUD_TypeVars2D) :: MUDS TYPE(MUD_TypeVars2D) :: MUDS
! 1 : MLnumber=1,,PumpsToString
! 2 : MLnumber=2,,STGaugeToString
! 3 : MLnumber=3,,WellToPits










END MODULE END MODULE




+ 92
- 92
Equipments/MudSystem/Plot_Final_Mud_Elements.f90 View File

@@ -31,10 +31,10 @@ subroutine PlotFinalMudElements ! is called in subroutine CirculationCodeSel
if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
write(*,*) 'well cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) + sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts))
DeltaWellCap= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) + sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - WellCapOld
WellCapOld= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) + sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts))
write(*,*) 'cap_reset,DeltaWellCap=' , DeltaWellCap
write(*,*) 'well cap=' , sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) + sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts))
MudSystemDotDeltaWellCap= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) + sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - MudSystemDotWellCapOld
MudSystemDotWellCapOld= sum(MudSystemDotPipeSection_VolumeCapacity(F_StringIntervalCounts+1:MudSystemDotNoPipeSections)) + sum(MudSystemDotOpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts))
write(*,*) 'cap_reset,DeltaWellCap=' , MudSystemDotDeltaWellCap
endif endif
@@ -42,16 +42,16 @@ subroutine PlotFinalMudElements ! is called in subroutine CirculationCodeSel


!========================ANNULUS END================= !========================ANNULUS END=================
if ((Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) > 0.8 .or. Ann_Density%Last()==0.0) then ! for Line (BellNippleToWell-NonFullWell) if ((Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) > 0.8 .or. Ann_Density%Last()==0.0) then ! for Line (BellNippleToWell-NonFullWell)
WellisNOTFull= .true.
MudSystemDotWellisNOTFull= .true.
else else
WellisNOTFull= .false.
MudSystemDotWellisNOTFull= .false.
endif endif


!WRITE(*,*) 'Ann_Mud_Forehead_X%Last() , KillHeight', Ann_Mud_Forehead_X%Last() , KillHeight !WRITE(*,*) 'Ann_Mud_Forehead_X%Last() , KillHeight', Ann_Mud_Forehead_X%Last() , KillHeight
if ((Ann_Mud_Forehead_X%Last() - BopStackSpecification%KillHeight)>0.8 .or. Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26) if ((Ann_Mud_Forehead_X%Last() - BopStackSpecification%KillHeight)>0.8 .or. Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26)
ChokeLineNOTFull= .true.
MudSystemDotChokeLineNOTFull= .true.
else else
ChokeLineNOTFull= .false.
MudSystemDotChokeLineNOTFull= .false.
endif endif




@@ -75,22 +75,22 @@ endif


DO WHILE(jmud <= Hz_Mud_Forehead_X%Length() .and. jsection<=1)
DO WHILE(jmud <= MudSystemDotHz_Mud_Forehead_X%Length() .and. jsection<=1)
jelement= jelement+1 jelement= jelement+1
TrueMinValue= min(Hz_Mud_Forehead_X%Array(jmud), Xend_PipeSection(jsection))
TrueMinValue= min(MudSystemDotHz_Mud_Forehead_X%Array(jmud), MudSystemDotXend_PipeSection(jsection))


call Xend_MudElement%Add(TrueMinValue) call Xend_MudElement%Add(TrueMinValue)
call TVD_Calculator(TrueMinValue,MudCircVerticalDepth)
call TVDend_MudElement%Add(MudCircVerticalDepth)
call Density_MudElement%Add(Hz_Density%Array(jmud))
call PipeID_MudElement%Add(ID_PipeSectionInch(jsection))
call PipeOD_MudElement%Add(OD_PipeSectionInch(jsection))
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 Angle_MudElement%Add(Angle_PipeSection(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection))
call MudType_MudElement%Add(Hz_MudOrKick%Array(jmud)) call MudType_MudElement%Add(Hz_MudOrKick%Array(jmud))
if (Xend_MudElement%Array(jelement)== Hz_Mud_Forehead_X%Array(jmud)) then
if (Xend_MudElement%Array(jelement)== MudSystemDotHz_Mud_Forehead_X%Array(jmud)) then
jmud= jmud+1 jmud= jmud+1
else else
jsection= jsection+1 jsection= jsection+1
@@ -98,7 +98,7 @@ endif
ENDDO ENDDO
NoHorizontalMudElements= jelement
MudSystemDotNoHorizontalMudElements= jelement


@@ -106,22 +106,22 @@ endif
jmud= 1 jmud= 1
jsection= 2 jsection= 2
DO WHILE(jmud <= St_Mud_Forehead_X%Length() .and. jsection<=F_StringIntervalCounts)
DO WHILE(jmud <= MudSystemDotSt_Mud_Forehead_X%Length() .and. jsection<=F_StringIntervalCounts)
jelement= jelement+1 jelement= jelement+1
TrueMinValue= min(St_Mud_Forehead_X%Array(jmud), Xend_PipeSection(jsection))
TrueMinValue= min(MudSystemDotSt_Mud_Forehead_X%Array(jmud), MudSystemDotXend_PipeSection(jsection))


call Xend_MudElement%Add(TrueMinValue) call Xend_MudElement%Add(TrueMinValue)
call TVD_Calculator(TrueMinValue,MudCircVerticalDepth)
call TVDend_MudElement%Add(MudCircVerticalDepth)
call TVD_Calculator(TrueMinValue,MudSystemDotMudCircVerticalDepth)
call TVDend_MudElement%Add(MudSystemDotMudCircVerticalDepth)
call Density_MudElement%Add(St_Density%Array(jmud)) call Density_MudElement%Add(St_Density%Array(jmud))
call PipeID_MudElement%Add(ID_PipeSectionInch(jsection))
call PipeOD_MudElement%Add(OD_PipeSectionInch(jsection))
call PipeID_MudElement%Add(MudSystemDotID_PipeSectionInch(jsection))
call PipeOD_MudElement%Add(MudSystemDotOD_PipeSectionInch(jsection))
!call Angle_MudElement%Add(Angle_PipeSection(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection))
call MudType_MudElement%Add(St_MudOrKick%Array(jmud)) call MudType_MudElement%Add(St_MudOrKick%Array(jmud))
if (Xend_MudElement%Array(jelement)== St_Mud_Forehead_X%Array(jmud)) then
if (Xend_MudElement%Array(jelement)== MudSystemDotSt_Mud_Forehead_X%Array(jmud)) then
jmud= jmud+1 jmud= jmud+1
else else
jsection= jsection+1 jsection= jsection+1
@@ -129,7 +129,7 @@ endif
ENDDO ENDDO


NoStringMudElements= jelement- NoHorizontalMudElements
MudSystemDotNoStringMudElements= jelement- MudSystemDotNoHorizontalMudElements


@@ -137,17 +137,17 @@ endif
jmud= 1 jmud= 1
jsection= F_StringIntervalCounts+1 jsection= F_StringIntervalCounts+1
DO WHILE(jmud<= Ann_Mud_Forehead_X%Length() .and. jsection<=NoPipeSections)
DO WHILE(jmud<= Ann_Mud_Forehead_X%Length() .and. jsection<=MudSystemDotNoPipeSections)
jelement= jelement+1 jelement= jelement+1
TrueMinValue= max(Ann_Mud_Forehead_X%Array(jmud), Xend_PipeSection(jsection))
TrueMinValue= max(Ann_Mud_Forehead_X%Array(jmud), MudSystemDotXend_PipeSection(jsection))


call Xend_MudElement%Add(TrueMinValue) call Xend_MudElement%Add(TrueMinValue)
call TVD_Calculator(TrueMinValue,MudCircVerticalDepth)
call TVDend_MudElement%Add(MudCircVerticalDepth)
call TVD_Calculator(TrueMinValue,MudSystemDotMudCircVerticalDepth)
call TVDend_MudElement%Add(MudSystemDotMudCircVerticalDepth)
call Density_MudElement%Add(Ann_Density%Array(jmud)) call Density_MudElement%Add(Ann_Density%Array(jmud))
call PipeID_MudElement%Add(ID_PipeSectionInch(jsection))
call PipeOD_MudElement%Add(OD_PipeSectionInch(jsection))
call PipeID_MudElement%Add(MudSystemDotID_PipeSectionInch(jsection))
call PipeOD_MudElement%Add(MudSystemDotOD_PipeSectionInch(jsection))
!call Angle_MudElement%Add(Angle_PipeSection(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection))
call MudType_MudElement%Add(Ann_MudOrKick%Array(jmud)) call MudType_MudElement%Add(Ann_MudOrKick%Array(jmud))
@@ -161,14 +161,14 @@ endif
ENDDO ENDDO
do i= 2, Xend_MudElement%Length() do i= 2, Xend_MudElement%Length()
if ( i== NoHorizontalMudElements+NoStringMudElements+1) then
if ( i== MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements+1) then
call Xstart_MudElement%Add (Ann_Mud_Backhead_X%Array(1)) ! start of annulus call Xstart_MudElement%Add (Ann_Mud_Backhead_X%Array(1)) ! start of annulus
call TVD_Calculator(Ann_Mud_Backhead_X%Array(1),MudCircVerticalDepth)
call TVDstart_MudElement%Add(MudCircVerticalDepth)
elseif ( i== NoHorizontalMudElements+1 ) then
call Xstart_MudElement%Add (St_Mud_Backhead_X%Array(1)) ! start of stirng
call TVD_Calculator(St_Mud_Backhead_X%Array(1),MudCircVerticalDepth)
call TVDstart_MudElement%Add(MudCircVerticalDepth)
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)
else else
call Xstart_MudElement%Add(Xend_MudElement%Array(i-1)) ! normal calculation call Xstart_MudElement%Add(Xend_MudElement%Array(i-1)) ! normal calculation
call TVDstart_MudElement%Add(TVDend_MudElement%Array(i-1)) ! normal calculation call TVDstart_MudElement%Add(TVDend_MudElement%Array(i-1)) ! normal calculation
@@ -176,25 +176,25 @@ endif
enddo enddo


NoCasingMudElements = jelement- NoStringMudElements- NoHorizontalMudElements
MudSystemDotNoCasingMudElements = jelement- MudSystemDotNoStringMudElements- MudSystemDotNoHorizontalMudElements
!=========================For Torque and Drag======================== !=========================For Torque and Drag========================
if (allocated(TDXstart_MudElementArray)) deallocate(TDXstart_MudElementArray)
allocate(TDXstart_MudElementArray(NoHorizontalMudElements+NoStringMudElements+NoCasingMudElements))
if (allocated(TDXend_MudElementArray)) deallocate(TDXend_MudElementArray)
allocate(TDXend_MudElementArray(NoHorizontalMudElements+NoStringMudElements+NoCasingMudElements))
if (allocated(TDDensity_MudElementArray)) deallocate(TDDensity_MudElementArray)
allocate(TDDensity_MudElementArray(NoHorizontalMudElements+NoStringMudElements+NoCasingMudElements))
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))
TDNoHorizontalMudElements= NoHorizontalMudElements
TDNoStringMudElements= NoStringMudElements
TDNoCasingMudElements= NoCasingMudElements
MudSystemDotTDNoHorizontalMudElements= MudSystemDotNoHorizontalMudElements
MudSystemDotTDNoStringMudElements= MudSystemDotNoStringMudElements
MudSystemDotTDNoCasingMudElements= MudSystemDotNoCasingMudElements


TDXstart_MudElementArray(:) = Xstart_MudElement%Array(:)
TDXend_MudElementArray(:) = Xend_MudElement%Array(:)
TDDensity_MudElementArray(:) = Density_MudElement%Array(:)
MudSystemDotTDXstart_MudElementArray(:) = Xstart_MudElement%Array(:)
MudSystemDotTDXend_MudElementArray(:) = Xend_MudElement%Array(:)
MudSystemDotTDDensity_MudElementArray(:) = Density_MudElement%Array(:)
!===================================================================== !=====================================================================
@@ -222,21 +222,21 @@ endif


DO WHILE(jopmud<= Op_Mud_Forehead_X%Length() .and. jopsection<=F_BottomHoleIntervalCounts)
DO WHILE(jopmud<= MudSystemDotOp_Mud_Forehead_X%Length() .and. jopsection<=F_BottomHoleIntervalCounts)
jopelement= jopelement+1 jopelement= jopelement+1
TrueMinValue= max(Op_Mud_Forehead_X%Array(jopmud), Xend_OpSection(jopsection))
TrueMinValue= max(MudSystemDotOp_Mud_Forehead_X%Array(jopmud), MudSystemDotXend_OpSection(jopsection))
call Xend_OpMudElement%Add(TrueMinValue) call Xend_OpMudElement%Add(TrueMinValue)
call TVD_Calculator(TrueMinValue,MudCircVerticalDepth)
call TVDend_OpMudElement%Add(MudCircVerticalDepth)
call Density_OpMudElement%Add(Op_Density%Array(jopmud))
call PipeID_OpMudElement%Add(ID_OpSectionInch(jopsection))
call PipeOD_OpMudElement%Add(OD_OpSectionInch(jopsection))
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))
!call Angle_MudElement%Add(Angle_PipeSection(jopsection)) !call Angle_MudElement%Add(Angle_PipeSection(jopsection))
call MudTypeOp_MudElement%Add(Op_MudOrKick%Array(jopmud)) call MudTypeOp_MudElement%Add(Op_MudOrKick%Array(jopmud))
if (Xend_OpMudElement%Array(jopelement)== Op_Mud_Forehead_X%Array(jopmud)) then
if (Xend_OpMudElement%Array(jopelement)== MudSystemDotOp_Mud_Forehead_X%Array(jopmud)) then
jopmud= jopmud+1 jopmud= jopmud+1
else else
jopsection= jopsection+1 jopsection= jopsection+1
@@ -249,7 +249,7 @@ endif
call TVDstart_OpMudElement%Add(TVDend_OpMudElement%Array(i-1)) call TVDstart_OpMudElement%Add(TVDend_OpMudElement%Array(i-1))
enddo enddo


NoBottomHoleMudElements = jopelement
MudSystemDotNoBottomHoleMudElements = jopelement
!================================================================ !================================================================
@@ -257,21 +257,21 @@ endif
if(allocated(StringMudElement)) deallocate(StringMudElement) if(allocated(StringMudElement)) deallocate(StringMudElement)
allocate(StringMudElement(NoStringMudElements))
allocate(StringMudElement(MudSystemDotNoStringMudElements))
if(allocated(CasingMudElement)) deallocate(CasingMudElement) if(allocated(CasingMudElement)) deallocate(CasingMudElement)
allocate(CasingMudElement(NoCasingMudElements+NoBottomHoleMudElements))
allocate(CasingMudElement(MudSystemDotNoCasingMudElements+MudSystemDotNoBottomHoleMudElements))
istring=0
icasing=0
MudSystemDotistring=0
MudSystemDoticasing=0
BitMudDensity= Density_MudElement%Array(NoHorizontalMudElements+NoStringMudElements) ! (for ROP module)
MudSystemDotBitMudDensity= Density_MudElement%Array(MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements) ! (for ROP module)
!================================================================ !================================================================
!============================ UTUBE ============================= !============================ UTUBE =============================
!IF (UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadIsOpen) THEN !IF (UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadIsOpen) THEN
IF (UtubePossibility== .true. .and. TD_FluidStringConnectionMode==0 .and. WellHeadIsOpen .AND. NoGasPocket == 0) THEN
IF (MudSystemDotUtubePossibility== .true. .and. TD_FluidStringConnectionMode==0 .and. WellHeadIsOpen .AND. NoGasPocket == 0) THEN
CALL WellPressureDataTransfer CALL WellPressureDataTransfer
!WRITE (*,*) ' U-Tube Done 1' !WRITE (*,*) ' U-Tube Done 1'
CALL Utube CALL Utube
@@ -294,17 +294,17 @@ endif
!enddo !enddo
IF (ANY(IEEE_Is_NaN(Op_MudDischarged_Volume%Array(:))) .OR. ANY(Op_MudDischarged_Volume%Array(:) <= 0.0)) THEN
IF (ANY(IEEE_Is_NaN(MudSystemDotOp_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystemDotOp_MudDischarged_Volume%Array(:) <= 0.0)) THEN
do i = 1 , Op_MudOrKick%Length() do i = 1 , Op_MudOrKick%Length()
write(*,555) i,'Op_Volume(i), type=' ,Op_MudDischarged_Volume%Array(i) , Op_MudOrKick%Array(i) , Op_Density%Array(i)
write(*,555) i,'Op_Volume(i), type=' ,MudSystemDotOp_MudDischarged_Volume%Array(i) , Op_MudOrKick%Array(i) , MudSystemDotOp_Density%Array(i)
end do end do
call ErrorStop('NaN in Op Volume-Plot or Op Volume <=0') call ErrorStop('NaN in Op Volume-Plot or Op Volume <=0')
END IF END IF
IF (ANY(IEEE_Is_NaN(Ann_MudDischarged_Volume%Array(:))) .OR. ANY(Ann_MudDischarged_Volume%Array(:) <= 0.0)) THEN
IF (ANY(IEEE_Is_NaN(MudSystemDotAnn_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystemDotAnn_MudDischarged_Volume%Array(:) <= 0.0)) THEN
do i = 1 , Ann_MudOrKick%Length() do i = 1 , Ann_MudOrKick%Length()
write(*,555) i,'Ann_Volume(i), type=' ,Ann_MudDischarged_Volume%Array(i) , Ann_MudOrKick%Array(i) , Ann_Density%Array(i)
write(*,555) i,'Ann_Volume(i), type=' ,MudSystemDotAnn_MudDischarged_Volume%Array(i) , Ann_MudOrKick%Array(i) , Ann_Density%Array(i)
end do end do
call ErrorStop('NaN in Ann Volume-Plot or Ann Volume <=0') call ErrorStop('NaN in Ann Volume-Plot or Ann Volume <=0')
END IF END IF
@@ -318,22 +318,22 @@ endif
555 FORMAT(I3,5X,A42,(f12.5),5X,I3,5X,(f12.5)) 555 FORMAT(I3,5X,A42,(f12.5),5X,I3,5X,(f12.5))
NoStringMudElementsForPlot= NoStringMudElements
MudSystemDotNoStringMudElementsForPlot= MudSystemDotNoStringMudElements
! 1-Horizontal Mud Elements are not shown ! 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) !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=NoHorizontalMudElements+1, NoHorizontalMudElements+NoStringMudElements ! 2-string elements
do i=MudSystemDotNoHorizontalMudElements+1, MudSystemDotNoHorizontalMudElements+MudSystemDotNoStringMudElements ! 2-string elements
if (Xend_MudElement%Array(i) <= 0.0) then if (Xend_MudElement%Array(i) <= 0.0) then
NoStringMudElementsForPlot= NoStringMudElementsForPlot-1
MudSystemDotNoStringMudElementsForPlot= MudSystemDotNoStringMudElementsForPlot-1
cycle cycle
endif endif
istring= istring+1
StringMudElement(istring)%StartMd = Xstart_MudElement%Array(i)
StringMudElement(istring)%EndMd = Xend_MudElement%Array(i)
MudSystemDotistring= MudSystemDotistring+1
StringMudElement(MudSystemDotistring)%StartMd = Xstart_MudElement%Array(i)
StringMudElement(MudSystemDotistring)%EndMd = Xend_MudElement%Array(i)
!StringMudElement(istring)%Id = PipeID_MudElement%Array(i) !StringMudElement(istring)%Id = PipeID_MudElement%Array(i)
!StringMudElement(istring)%Od = PipeOD_MudElement%Array(i) !StringMudElement(istring)%Od = PipeOD_MudElement%Array(i)
StringMudElement(istring)%Density = Density_MudElement%Array(i)
StringMudElement(MudSystemDotistring)%Density = Density_MudElement%Array(i)


if (MudType_MudElement%Array(i) == 104) then if (MudType_MudElement%Array(i) == 104) then
MudType_MudElement%Array(i)= 4 ! air MudType_MudElement%Array(i)= 4 ! air
@@ -341,22 +341,22 @@ endif
MudType_MudElement%Array(i)= 1 ! gas kick MudType_MudElement%Array(i)= 1 ! gas kick
endif endif


StringMudElement(istring)%MudType = MudType_MudElement%Array(i)
StringMudElement(MudSystemDotistring)%MudType = 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) !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 enddo


do i=Xend_MudElement%Length(), NoHorizontalMudElements+NoStringMudElements+1 , -1 ! 3-casing elements
icasing= icasing+1
CasingMudElement(icasing)%StartMd = Xend_MudElement%Array(i)
CasingMudElement(icasing)%EndMd = Xstart_MudElement%Array(i)
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)
!CasingMudElement(icasing)%Id = PipeID_MudElement%Array(i) !CasingMudElement(icasing)%Id = PipeID_MudElement%Array(i)
!CasingMudElement(icasing)%Od = PipeOD_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) !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) !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) !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(icasing)%Density = Density_MudElement%Array(i)
CasingMudElement(MudSystemDoticasing)%Density = Density_MudElement%Array(i)
if (MudType_MudElement%Array(i) == 104) then if (MudType_MudElement%Array(i) == 104) then
MudType_MudElement%Array(i)= 4 ! air MudType_MudElement%Array(i)= 4 ! air
@@ -364,20 +364,20 @@ endif
MudType_MudElement%Array(i)= 1 ! gas kick MudType_MudElement%Array(i)= 1 ! gas kick
endif endif
CasingMudElement(icasing)%MudType = MudType_MudElement%Array(i)
CasingMudElement(MudSystemDoticasing)%MudType = MudType_MudElement%Array(i)
enddo enddo
do i= NoBottomHoleMudElements, 1 , -1 ! 4-open hole elements
icasing= icasing+1
CasingMudElement(icasing)%StartMd = Xend_OpMudElement%Array(i)
CasingMudElement(icasing)%EndMd = Xstart_OpMudElement%Array(i)
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)
!CasingMudElement(icasing)%Id = PipeID_OpMudElement%Array(i) !CasingMudElement(icasing)%Id = PipeID_OpMudElement%Array(i)
!CasingMudElement(icasing)%Od = PipeOD_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) !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) !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) !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(icasing)%Density = Density_OpMudElement%Array(i)
CasingMudElement(MudSystemDoticasing)%Density = Density_OpMudElement%Array(i)
if (MudTypeOp_MudElement%Array(i) == 104) then if (MudTypeOp_MudElement%Array(i) == 104) then
MudTypeOp_MudElement%Array(i)= 4 ! air MudTypeOp_MudElement%Array(i)= 4 ! air
@@ -385,7 +385,7 @@ endif
MudTypeOp_MudElement%Array(i)= 1 ! gas kick MudTypeOp_MudElement%Array(i)= 1 ! gas kick
endif endif
CasingMudElement(icasing)%MudType = MudTypeOp_MudElement%Array(i)
CasingMudElement(MudSystemDoticasing)%MudType = MudTypeOp_MudElement%Array(i)
enddo enddo


@@ -398,8 +398,8 @@ endif
! shomare gozari be tartib HZ mud, ST mud, Casing ! shomare gozari be tartib HZ mud, ST mud, Casing
! shomare gzari OpenHole jodagane ast az 1 ! shomare gzari OpenHole jodagane ast az 1
call SetStringFluids(NoStringMudElementsForPlot, StringMudElement) !for data display in string
call SetAnnalusFluids(NoCasingMudElements+NoBottomHoleMudElements, CasingMudElement) !for data display in casing
call SetStringFluids(MudSystemDotNoStringMudElementsForPlot, StringMudElement) !for data display in string
call SetAnnalusFluids(MudSystemDotNoCasingMudElements+MudSystemDotNoBottomHoleMudElements, CasingMudElement) !for data display in casing




!=========================================================================================================================== !===========================================================================================================================


+ 469
- 469
Equipments/MudSystem/Pump_and_Trip_In.f90
File diff suppressed because it is too large
View File


+ 421
- 421
Equipments/MudSystem/Trip_Out_andPump.f90
File diff suppressed because it is too large
View File


+ 164
- 164
Equipments/MudSystem/Utube1_and_Trip_In.f90 View File

@@ -16,16 +16,16 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect
write(*,*) 'Utube1 code' write(*,*) 'Utube1 code'
!===========================================================WELL============================================================ !===========================================================WELL============================================================
!===========================================================WELL============================================================ !===========================================================WELL============================================================
UtubeMode1Activated= .true.
MudSystemDotUtubeMode1Activated= .true.
!write(*,*) 'QUTubeInput=' , QUTubeInput !write(*,*) 'QUTubeInput=' , QUTubeInput
!Qinput=5000. !Qinput=5000.
StringFlowRate= QUTubeInput ! (gpm)
AnnulusFlowRate= QUTubeInput
StringFlowRateFinal= StringFlowRate
AnnulusFlowRateFinal= AnnulusFlowRate
MudSystemDotStringFlowRate= QUTubeInput ! (gpm)
MudSystemDotAnnulusFlowRate= QUTubeInput
MudSystemDotStringFlowRateFinal= MudSystemDotStringFlowRate
MudSystemDotAnnulusFlowRateFinal= MudSystemDotAnnulusFlowRate
!=========================================== !===========================================
if (FirstSetUtube1==0) then
if (MudSystemDotFirstSetUtube1==0) then
! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial ! 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_X%AddToFirst (Xstart_PipeSection(1))
! call St_Mud_Backhead_section%AddToFirst (1) ! call St_Mud_Backhead_section%AddToFirst (1)
@@ -46,10 +46,10 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect
!Hz_Density%Array(:)= 0.0 !commented !Hz_Density%Array(:)= 0.0 !commented
!Hz_MudOrKick%Array(:)= 104 !commented !Hz_MudOrKick%Array(:)= 104 !commented
Hz_Density_Utube= 0.0
Hz_MudOrKick_Utube= 104
MudSystemDotHz_Density_Utube= 0.0
MudSystemDotHz_MudOrKick_Utube= 104
FirstSetUtube1= 1
MudSystemDotFirstSetUtube1= 1
endif endif


@@ -154,16 +154,16 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect
!========================STRING ENTRANCE================= !========================STRING ENTRANCE=================
!write(*,*) 'a) St_Density%Length()=' , St_Density%Length() !write(*,*) 'a) St_Density%Length()=' , St_Density%Length()
if (ABS(St_Density%First() - Hz_Density_Utube) >= DensityMixTol) then ! new mud is pumped
call St_Density%AddToFirst (Hz_Density_Utube)
call St_MudDischarged_Volume%AddToFirst (0.0d0)
call St_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(2))
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 St_Mud_Forehead_section%AddToFirst (2)
call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(2))
call MudSystemDotSt_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(2))
call St_Mud_Backhead_section%AddToFirst (2) call St_Mud_Backhead_section%AddToFirst (2)
call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
call St_MudOrKick%AddToFirst (Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104
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
!StringDensity_Old= Hz_Density_Utube !StringDensity_Old= Hz_Density_Utube
endif endif
@@ -174,58 +174,58 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect


!========================STRING================= !========================STRING=================
!WRITE (*,*) 'Utube1 StringFlowRate', StringFlowRate !WRITE (*,*) 'Utube1 StringFlowRate', StringFlowRate
St_MudDischarged_Volume%Array(1)= St_MudDischarged_Volume%Array(1)+ ((StringFlowRate/60.d0)*DeltaT_Mudline) !(gal)
MudSystemDotSt_MudDischarged_Volume%Array(1)= MudSystemDotSt_MudDischarged_Volume%Array(1)+ ((MudSystemDotStringFlowRate/60.d0)*DeltaT_Mudline) !(gal)
imud=0
do while (imud < St_Mud_Forehead_X%Length())
imud = imud + 1
MudSystemDotimud=0
do while (MudSystemDotimud < MudSystemDotSt_Mud_Forehead_X%Length())
MudSystemDotimud = MudSystemDotimud + 1
if (imud> 1) then
St_Mud_Backhead_X%Array(imud)= St_Mud_Forehead_X%Array(imud-1)
St_Mud_Backhead_section%Array(imud)= St_Mud_Forehead_section%Array(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)
endif endif
DirectionCoef= (Xend_PipeSection(St_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(St_Mud_Backhead_section%Array(imud))) &
/ ABS(Xend_PipeSection(St_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(St_Mud_Backhead_section%Array(imud)))
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)))
! +1 for string , -1 for annulus ! +1 for string , -1 for annulus
St_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_PipeSection(St_Mud_Backhead_section%Array(imud))- St_Mud_Backhead_X%Array(imud))* &
Area_PipeSectionFt(St_Mud_Backhead_section%Array(imud)) !(ft^3)
St_EmptyVolume_inBackheadLocation%Array(imud)= St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal
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


if ( St_MudDischarged_Volume%Array(imud) <= St_EmptyVolume_inBackheadLocation%Array(imud)) then
St_Mud_Forehead_section%Array(imud)= St_Mud_Backhead_section%Array(imud)
St_Mud_Forehead_X%Array(imud)= St_Mud_Backhead_X%Array(imud)+ DirectionCoef*(St_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_PipeSectionFt(St_Mud_Backhead_section%Array(imud))
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))
! 7.48 is for gal to ft^3 ! 7.48 is for gal to ft^3
else else
isection= St_Mud_Backhead_section%Array(imud)+1
St_RemainedVolume_in_LastSection%Array(imud)= St_MudDischarged_Volume%Array(imud)- St_EmptyVolume_inBackheadLocation%Array(imud)
MudSystemDotisection= St_Mud_Backhead_section%Array(MudSystemDotimud)+1
MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)
do do
if (isection > F_StringIntervalCounts) then ! last pipe section(string exit) F_StringIntervalCounts includes Horizontal line
St_MudDischarged_Volume%Array(imud)= St_MudDischarged_Volume%Array(imud)- St_RemainedVolume_in_LastSection%Array(imud)
St_Mud_Forehead_X%Array(imud)= Xend_PipeSection(F_StringIntervalCounts)
St_Mud_Forehead_section%Array(imud)= F_StringIntervalCounts
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 (St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string
call RemoveStringMudArrays(imud)
if (MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string
call RemoveStringMudArrays(MudSystemDotimud)
endif endif
exit exit
endif endif
xx= St_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal)
MudSystemDotxx= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal)
if (xx<= 1.0) then
St_Mud_Forehead_section%Array(imud)= isection
St_Mud_Forehead_X%Array(imud)= (xx * (Xend_PipeSection(isection)- Xstart_PipeSection(isection)))+ Xstart_PipeSection(isection)
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)
exit exit
else else
St_RemainedVolume_in_LastSection%Array(imud)= St_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection)
isection= isection+ 1
MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection)
MudSystemDotisection= MudSystemDotisection+ 1
endif endif
@@ -259,60 +259,60 @@ imud=0
!============================= Bottom Hole ============================== !============================= Bottom Hole ==============================
!Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux
imud=0
do while (imud < Op_Mud_Forehead_X%Length())
imud = imud + 1
MudSystemDotimud=0
do while (MudSystemDotimud < MudSystemDotOp_Mud_Forehead_X%Length())
MudSystemDotimud = MudSystemDotimud + 1
if (imud> 1) then
Op_Mud_Backhead_X%Array(imud)= Op_Mud_Forehead_X%Array(imud-1)
Op_Mud_Backhead_section%Array(imud)= Op_Mud_Forehead_section%Array(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)
endif endif
DirectionCoef= (Xend_OpSection(Op_Mud_Backhead_section%Array(imud))-Xstart_OpSection(Op_Mud_Backhead_section%Array(imud))) &
/ ABS(Xend_OpSection(Op_Mud_Backhead_section%Array(imud))-Xstart_OpSection(Op_Mud_Backhead_section%Array(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)))
! +1 for string , -1 for annulus ! +1 for string , -1 for annulus
Op_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_OpSection(Op_Mud_Backhead_section%Array(imud))- Op_Mud_Backhead_X%Array(imud))* &
Area_OpSectionFt(Op_Mud_Backhead_section%Array(imud)) !(ft^3)
Op_EmptyVolume_inBackheadLocation%Array(imud)= Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal
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
if ( Op_MudDischarged_Volume%Array(imud) <= Op_EmptyVolume_inBackheadLocation%Array(imud)) then
Op_Mud_Forehead_section%Array(imud)= Op_Mud_Backhead_section%Array(imud)
Op_Mud_Forehead_X%Array(imud)= Op_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_OpSectionFt(Op_Mud_Backhead_section%Array(imud))
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))
! 7.48 is for gal to ft^3 ! 7.48 is for gal to ft^3
else else
isection= Op_Mud_Backhead_section%Array(imud)+1
Op_RemainedVolume_in_LastSection%Array(imud)= Op_MudDischarged_Volume%Array(imud)- Op_EmptyVolume_inBackheadLocation%Array(imud)
MudSystemDotisection= Op_Mud_Backhead_section%Array(MudSystemDotimud)+1
MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)
do do
if (isection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit)
if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space
Op_MudDischarged_Volume%Array(imud)= Op_MudDischarged_Volume%Array(imud)- Op_RemainedVolume_in_LastSection%Array(imud)
Op_Mud_Forehead_X%Array(imud)= Xend_OpSection(F_BottomHoleIntervalCounts)
Op_Mud_Forehead_section%Array(imud)= F_BottomHoleIntervalCounts
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 (Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveOpMudArrays(imud)
if (MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveOpMudArrays(MudSystemDotimud)
endif endif
exit exit
endif endif
xx= Op_RemainedVolume_in_LastSection%Array(imud)/ OpSection_VolumeCapacity(isection) !(gal)
MudSystemDotxx= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) !(gal)
if (xx<= 1.0) then
Op_Mud_Forehead_section%Array(imud)= isection
Op_Mud_Forehead_X%Array(imud)= (xx * (Xend_OpSection(isection)- Xstart_OpSection(isection)))+ Xstart_OpSection(isection)
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)
exit exit
else else
Op_RemainedVolume_in_LastSection%Array(imud)= Op_RemainedVolume_in_LastSection%Array(imud)- OpSection_VolumeCapacity(isection)
isection= isection+ 1
MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection)
MudSystemDotisection= MudSystemDotisection+ 1
endif endif


@@ -321,13 +321,13 @@ imud=0
endif endif
if (Op_Mud_Forehead_X%Array(imud)== Xend_OpSection(F_BottomHoleIntervalCounts)) then
totalLength = Op_MudDischarged_Volume%Length()
do while(imud < totalLength)
if (MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)== MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts)) then
MudSystemDottotalLength = MudSystemDotOp_MudDischarged_Volume%Length()
do while(MudSystemDotimud < MudSystemDottotalLength)
!imud = imud + 1 !imud = imud + 1
call RemoveOpMudArrays(totalLength)
totalLength = totalLength - 1
call RemoveOpMudArrays(MudSystemDottotalLength)
MudSystemDottotalLength = MudSystemDottotalLength - 1


enddo enddo
@@ -352,81 +352,81 @@ imud=0
! WRITE(*,*) 'Op_Mud_Forehead_X%Array(2)' , Op_Mud_Forehead_X%Array(2) ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(2)' , Op_Mud_Forehead_X%Array(2)
!========================Bottom Hole END================= !========================Bottom Hole END=================
if (iLoc == 1) then
MudSection= F_StringIntervalCounts+1
BackheadX= Xstart_PipeSection(F_StringIntervalCounts+1)
elseif (iLoc == 2) then
MudSection= Kick_Forehead_section
BackheadX= Kick_Forehead_X
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
endif endif
!========================ANNULUS ENTRANCE==================== !========================ANNULUS ENTRANCE====================
!write(*,*) 'iloc=====' , iLoc !write(*,*) 'iloc=====' , iLoc
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())
call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0)
call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX)
call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection)
call Ann_Mud_Backhead_X%AddTo (iLoc,BackheadX)
call Ann_Mud_Backhead_section%AddTo (iLoc,MudSection)
call Ann_RemainedVolume_in_LastSection%AddTo (iLoc,0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddTo (iLoc,0.0d0)
call Ann_MudOrKick%AddTo (iLoc,0)
call Ann_CuttingMud%AddTo (iloc,0)
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)
AnnulusSuctionDensity_Old= St_Density%Last() AnnulusSuctionDensity_Old= St_Density%Last()
MudIsChanged= .true.
MudSystemDotMudIsChanged= .true.
endif endif


Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) !(gal)
MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotiLoc)+ ((MudSystemDotAnnulusFlowRate/60.0d0)*DeltaT_Mudline) !(gal)
!========================Tripping In==================== !========================Tripping In====================
!write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
if (DeltaVolumeOp > 0.0 .and. MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen)
if (MudSystemDotDeltaVolumeOp > 0.0 .and. MudSystemDotMudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen)
!write(*,*) 'Tripping In' !write(*,*) 'Tripping In'
NewDensity= (St_Density%Last()*((AnnulusFlowRate/60.)*DeltaT_Mudline)+Op_Density%Last()*DeltaVolumeOp)/(((AnnulusFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp)
NewVolume= ((AnnulusFlowRate/60.)*DeltaT_Mudline)+DeltaVolumeOp
NewDensity= (St_Density%Last()*((MudSystemDotAnnulusFlowRate/60.)*DeltaT_Mudline)+MudSystemDotOp_Density%Last()*MudSystemDotDeltaVolumeOp)/(((MudSystemDotAnnulusFlowRate/60.0d0)*DeltaT_Mudline)+MudSystemDotDeltaVolumeOp)
MudSystemDotNewVolume= ((MudSystemDotAnnulusFlowRate/60.)*DeltaT_Mudline)+MudSystemDotDeltaVolumeOp
!write(*,*) 'Ann_MudDischarged_Volume%Array(1)=', Ann_MudDischarged_Volume%Array(1), 'NewVolume=', NewVolume !write(*,*) 'Ann_MudDischarged_Volume%Array(1)=', Ann_MudDischarged_Volume%Array(1), 'NewVolume=', NewVolume
if (abs(Ann_Density%Array(iLoc)-NewDensity)< DensityMixTol) then ! 1-Pockets are Merged - (ROP is 0)
Ann_Density%Array(iLoc)= (Ann_Density%Array(iLoc)*Ann_MudDischarged_Volume%Array(iLoc)+NewDensity*NewVolume)/(Ann_MudDischarged_Volume%Array(iLoc)+NewVolume)
Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+DeltaVolumeOp
Ann_Mud_Forehead_X%Array(iLoc)= BackheadX
Ann_Mud_Forehead_section%Array(iLoc)= MudSection
Ann_Mud_Backhead_X%Array(iLoc)= BackheadX
Ann_Mud_Backhead_section%Array(iLoc)= MudSection
Ann_RemainedVolume_in_LastSection%Array(iLoc)= (0.0d0)
Ann_EmptyVolume_inBackheadLocation%Array(iLoc)= (0.0d0)
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)
else ! 2-Merging conditions are not meeted, so new pocket else ! 2-Merging conditions are not meeted, so new pocket
call Ann_Density%AddTo (iLoc,NewDensity)
call Ann_MudDischarged_Volume%AddTo (iLoc,NewVolume)
call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX)
call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection)
call Ann_Mud_Backhead_X%AddTo (iLoc,BackheadX)
call Ann_Mud_Backhead_section%AddTo (iLoc,MudSection)
call Ann_RemainedVolume_in_LastSection%AddTo (iLoc,0.0d0)
call Ann_EmptyVolume_inBackheadLocation%AddTo (iLoc,0.0d0)
call Ann_MudOrKick%AddTo (iLoc,0)
call Ann_CuttingMud%AddTo (iLoc,0)
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)
endif endif
elseif (DeltaVolumeOp > 0.0 .and. MudIsChanged== .true. .and. Rate_of_Penetration==0.) then
Ann_Density%Array(iLoc)= NewDensity
Ann_MudDischarged_Volume%Array(iLoc)= NewVolume
Ann_Mud_Forehead_X%Array(iLoc)= BackheadX
Ann_Mud_Forehead_section%Array(iLoc)= MudSection
Ann_Mud_Backhead_X%Array(iLoc)= BackheadX
Ann_Mud_Backhead_section%Array(iLoc)= MudSection
Ann_RemainedVolume_in_LastSection%Array(iLoc)= (0.0d0)
Ann_EmptyVolume_inBackheadLocation%Array(iLoc)= (0.0d0)
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)
endif endif


@@ -435,27 +435,27 @@ imud=0
!======================== ANNULUS ==================== !======================== ANNULUS ====================
MudIsChanged= .false.
MudSystemDotMudIsChanged= .false.
imud= 0
MudSystemDotimud= 0


do while (imud < Ann_Mud_Forehead_X%Length())
imud = imud + 1
do while (MudSystemDotimud < Ann_Mud_Forehead_X%Length())
MudSystemDotimud = MudSystemDotimud + 1
if (imud> 1) then
Ann_Mud_Backhead_X%Array(imud)= Ann_Mud_Forehead_X%Array(imud-1)
Ann_Mud_Backhead_section%Array(imud)= Ann_Mud_Forehead_section%Array(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)
endif endif
! <<< Fracture Shoe Lost ! <<< Fracture Shoe Lost
IF ( ShoeLost .and. LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(imud) ) then
IF ( MudSystemDotShoeLost .and. MudSystemDotLostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(MudSystemDotimud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(MudSystemDotimud) ) then
!write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline)
Ann_MudDischarged_Volume%Array(imud)= Ann_MudDischarged_Volume%Array(imud)-((Qlost/60.0d0)*DeltaT_Mudline) !(gal)
if (Ann_MudDischarged_Volume%Array(imud) < 0.0) then
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
!write(*,*) 'mud is removed by shoe lost, imud=' , imud !write(*,*) 'mud is removed by shoe lost, imud=' , imud
call RemoveAnnulusMudArrays(imud)
imud= imud-1
call RemoveAnnulusMudArrays(MudSystemDotimud)
MudSystemDotimud= MudSystemDotimud-1
cycle cycle
endif endif
ENDIF ENDIF
@@ -468,48 +468,48 @@ imud= 0
DirectionCoef= (Xend_PipeSection(Ann_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Ann_Mud_Backhead_section%Array(imud))) &
/ ABS(Xend_PipeSection(Ann_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Ann_Mud_Backhead_section%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)))
! +1 for string , -1 for annulus ! +1 for string , -1 for annulus
Ann_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_PipeSection(Ann_Mud_Backhead_section%Array(imud))- Ann_Mud_Backhead_X%Array(imud))* &
Area_PipeSectionFt(Ann_Mud_Backhead_section%Array(imud)) !(ft^3)
Ann_EmptyVolume_inBackheadLocation%Array(imud)= Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal
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
if ( Ann_MudDischarged_Volume%Array(imud) <= Ann_EmptyVolume_inBackheadLocation%Array(imud)) then
Ann_Mud_Forehead_section%Array(imud)= Ann_Mud_Backhead_section%Array(imud)
Ann_Mud_Forehead_X%Array(imud)= Ann_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_PipeSectionFt(Ann_Mud_Backhead_section%Array(imud))
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))
! 7.48 is for gal to ft^3 ! 7.48 is for gal to ft^3
else else
isection= Ann_Mud_Backhead_section%Array(imud)+1
Ann_RemainedVolume_in_LastSection%Array(imud)= Ann_MudDischarged_Volume%Array(imud)- Ann_EmptyVolume_inBackheadLocation%Array(imud)
MudSystemDotisection= Ann_Mud_Backhead_section%Array(MudSystemDotimud)+1
Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)
do do
if (isection > NoPipeSections) then ! last pipe section(well exit)
Ann_MudDischarged_Volume%Array(imud)= Ann_MudDischarged_Volume%Array(imud)- Ann_RemainedVolume_in_LastSection%Array(imud)
Ann_Mud_Forehead_X%Array(imud)= Xend_PipeSection(NoPipeSections)
Ann_Mud_Forehead_section%Array(imud)= NoPipeSections
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 (Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveAnnulusMudArrays(imud)
if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveAnnulusMudArrays(MudSystemDotimud)
endif endif
exit exit
endif endif
xx= Ann_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal)
MudSystemDotxx= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal)
if (xx<= 1.0) then
Ann_Mud_Forehead_section%Array(imud)= isection
Ann_Mud_Forehead_X%Array(imud)= (xx * (Xend_PipeSection(isection)- Xstart_PipeSection(isection)))+ Xstart_PipeSection(isection)
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)
exit exit
else else
Ann_RemainedVolume_in_LastSection%Array(imud)= Ann_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection)
isection= isection+ 1
Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection)
MudSystemDotisection= MudSystemDotisection+ 1
endif endif




+ 145
- 145
Equipments/MudSystem/Utube2_and_Trip_In.f90 View File

@@ -16,16 +16,16 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect
!===========================================================WELL============================================================ !===========================================================WELL============================================================
!===========================================================WELL============================================================ !===========================================================WELL============================================================
UtubeMode2Activated= .true.
MudSystemDotUtubeMode2Activated= .true.
write(*,*) 'QUtubeOutput=' , QUtubeOutput write(*,*) 'QUtubeOutput=' , QUtubeOutput
!QUTubeInput=5000. !QUTubeInput=5000.
StringFlowRate= QUtubeOutput ! (gpm)
AnnulusFlowRate= QUtubeOutput
StringFlowRateFinal= StringFlowRate
AnnulusFlowRateFinal= AnnulusFlowRate
MudSystemDotStringFlowRate= QUtubeOutput ! (gpm)
MudSystemDotAnnulusFlowRate= QUtubeOutput
MudSystemDotStringFlowRateFinal= MudSystemDotStringFlowRate
MudSystemDotAnnulusFlowRateFinal= MudSystemDotAnnulusFlowRate
!=========================================== !===========================================
if (FirstSetUtube2==0) then
if (MudSystemDotFirstSetUtube2==0) then
! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial ! 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_X%AddToFirst (Xstart_PipeSection(1))
! call St_Mud_Backhead_section%AddToFirst (1) ! call St_Mud_Backhead_section%AddToFirst (1)
@@ -46,10 +46,10 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect
!Hz_Density%Array(:)= 0.0 !Hz_Density%Array(:)= 0.0
!Hz_MudOrKick%Array(:)= 104 !Hz_MudOrKick%Array(:)= 104
Hz_Density_Utube= 0.0
Hz_MudOrKick_Utube= 104
MudSystemDotHz_Density_Utube= 0.0
MudSystemDotHz_MudOrKick_Utube= 104
FirstSetUtube2= 1
MudSystemDotFirstSetUtube2= 1
endif endif


@@ -154,90 +154,90 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect


!========================ANNULUS ENTRANCE==================== !========================ANNULUS ENTRANCE====================
if (ABS(AnnulusSuctionDensity_Old - Hz_Density_Utube) >= DensityMixTol ) then ! new mud is pumped
call Ann_Density%Add (Hz_Density_Utube)
call Ann_MudDischarged_Volume%Add (0.0d0)
call Ann_Mud_Forehead_X%Add (Xend_PipeSection(NoPipeSections))
call Ann_Mud_Forehead_section%Add (NoPipeSections)
call Ann_Mud_Backhead_X%Add (Xstart_PipeSection(NoPipeSections))
call Ann_Mud_Backhead_section%Add (NoPipeSections)
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_RemainedVolume_in_LastSection%Add (0.0d0)
call Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) call Ann_EmptyVolume_inBackheadLocation%Add (0.0d0)
call Ann_MudOrKick%Add (Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104
call Ann_MudOrKick%Add (MudSystemDotHz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104
call Ann_CuttingMud%Add (0) call Ann_CuttingMud%Add (0)
AnnulusSuctionDensity_Old= Hz_Density_Utube
AnnulusSuctionDensity_Old= MudSystemDotHz_Density_Utube
endif endif
!========================ANNULUS==================== !========================ANNULUS====================


Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())= Ann_MudDischarged_Volume%Last()+ ((AnnulusFlowRate/60.)*DeltaT_Mudline) !(gal)
MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_MudDischarged_Volume%Length())= MudSystemDotAnn_MudDischarged_Volume%Last()+ ((MudSystemDotAnnulusFlowRate/60.)*DeltaT_Mudline) !(gal)
imud= Ann_Mud_Forehead_X%Length() + 1
MudSystemDotimud= Ann_Mud_Forehead_X%Length() + 1


do while (imud > 1)
imud = imud - 1
do while (MudSystemDotimud > 1)
MudSystemDotimud = MudSystemDotimud - 1
if (imud< Ann_Mud_Forehead_X%Length()) then
Ann_Mud_Forehead_X%Array(imud)= Ann_Mud_Backhead_X%Array(imud+1)
Ann_Mud_Forehead_section%Array(imud)= Ann_Mud_Backhead_section%Array(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)
endif endif


! <<< Fracture Shoe Lost ! <<< Fracture Shoe Lost
IF ( ShoeLost .and. LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(imud) ) then
IF ( MudSystemDotShoeLost .and. MudSystemDotLostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < Ann_Mud_Backhead_X%Array(MudSystemDotimud) .and. Shoe%ShoeDepth >= Ann_Mud_Forehead_X%Array(MudSystemDotimud) ) then
!write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline)
Ann_MudDischarged_Volume%Array(imud)= Ann_MudDischarged_Volume%Array(imud)-((Qlost/60.0d0)*DeltaT_Mudline) !(gal)
if (Ann_MudDischarged_Volume%Array(imud) < 0.0) then
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
!write(*,*) 'mud is removed by shoe lost, imud=' , imud !write(*,*) 'mud is removed by shoe lost, imud=' , imud
call RemoveAnnulusMudArrays(imud)
imud= imud-1
call RemoveAnnulusMudArrays(MudSystemDotimud)
MudSystemDotimud= MudSystemDotimud-1
cycle cycle
endif endif
ENDIF ENDIF
! Fracture Shoe Lost >>> ! Fracture Shoe Lost >>>
DirectionCoef= (Xend_PipeSection(Ann_Mud_Forehead_section%Array(imud))-Xstart_PipeSection(Ann_Mud_Forehead_section%Array(imud))) &
/ ABS(Xend_PipeSection(Ann_Mud_Forehead_section%Array(imud))-Xstart_PipeSection(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)))
! +1 for string , -1 for annulus ! +1 for string , -1 for annulus
Ann_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Ann_Mud_Forehead_X%Array(imud)- Xstart_PipeSection(Ann_Mud_Forehead_section%Array(imud)))* &
Area_PipeSectionFt(Ann_Mud_Forehead_section%Array(imud)) !(ft^3)
Ann_EmptyVolume_inBackheadLocation%Array(imud)= Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal
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


if ( Ann_MudDischarged_Volume%Array(imud) <= Ann_EmptyVolume_inBackheadLocation%Array(imud)) then
Ann_Mud_Backhead_section%Array(imud)= Ann_Mud_Forehead_section%Array(imud)
Ann_Mud_Backhead_X%Array(imud)= Ann_Mud_Forehead_X%Array(imud)- DirectionCoef*(Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_PipeSectionFt(Ann_Mud_Forehead_section%Array(imud))
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))
! 7.48051948 is for gal to ft^3 ! 7.48051948 is for gal to ft^3
else else
isection= Ann_Mud_Forehead_section%Array(imud)-1
Ann_RemainedVolume_in_LastSection%Array(imud)= Ann_MudDischarged_Volume%Array(imud)- Ann_EmptyVolume_inBackheadLocation%Array(imud)
MudSystemDotisection= Ann_Mud_Forehead_section%Array(MudSystemDotimud)-1
Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)- Ann_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)
do do
if (isection < F_StringIntervalCounts+1) then ! last pipe section(well exit) F_StringIntervalCounts+1 is the first section in Annulus
Ann_MudDischarged_Volume%Array(imud)= Ann_MudDischarged_Volume%Array(imud)- Ann_RemainedVolume_in_LastSection%Array(imud)
Ann_Mud_Backhead_X%Array(imud)= Xstart_PipeSection(F_StringIntervalCounts+1)
Ann_Mud_Backhead_section%Array(imud)= F_StringIntervalCounts+1
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 (Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveAnnulusMudArrays(imud)
if (MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveAnnulusMudArrays(MudSystemDotimud)
endif endif
exit exit
endif endif
xx= Ann_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal)
MudSystemDotxx= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal)
if (xx<= 1.0) then
Ann_Mud_Backhead_section%Array(imud)= isection
Ann_Mud_Backhead_X%Array(imud)= (xx * (Xstart_PipeSection(isection)- Xend_PipeSection(isection)))+ Xend_PipeSection(isection)
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)
exit exit
else else
Ann_RemainedVolume_in_LastSection%Array(imud)= Ann_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection)
isection= isection- 1
Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= Ann_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection)
MudSystemDotisection= MudSystemDotisection- 1
endif endif
@@ -271,60 +271,60 @@ imud= Ann_Mud_Forehead_X%Length() + 1
!============================= Bottom Hole ============================== !============================= Bottom Hole ==============================
!Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux
imud=0
do while (imud < Op_Mud_Forehead_X%Length())
imud = imud + 1
MudSystemDotimud=0
do while (MudSystemDotimud < MudSystemDotOp_Mud_Forehead_X%Length())
MudSystemDotimud = MudSystemDotimud + 1
if (imud> 1) then
Op_Mud_Backhead_X%Array(imud)= Op_Mud_Forehead_X%Array(imud-1)
Op_Mud_Backhead_section%Array(imud)= Op_Mud_Forehead_section%Array(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)
endif endif
DirectionCoef= (Xend_OpSection(Op_Mud_Backhead_section%Array(imud))-Xstart_OpSection(Op_Mud_Backhead_section%Array(imud))) &
/ ABS(Xend_OpSection(Op_Mud_Backhead_section%Array(imud))-Xstart_OpSection(Op_Mud_Backhead_section%Array(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)))
! +1 for string , -1 for annulus ! +1 for string , -1 for annulus
Op_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_OpSection(Op_Mud_Backhead_section%Array(imud))- Op_Mud_Backhead_X%Array(imud))* &
Area_OpSectionFt(Op_Mud_Backhead_section%Array(imud)) !(ft^3)
Op_EmptyVolume_inBackheadLocation%Array(imud)= Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal
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
if ( Op_MudDischarged_Volume%Array(imud) <= Op_EmptyVolume_inBackheadLocation%Array(imud)) then
Op_Mud_Forehead_section%Array(imud)= Op_Mud_Backhead_section%Array(imud)
Op_Mud_Forehead_X%Array(imud)= Op_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_OpSectionFt(Op_Mud_Backhead_section%Array(imud))
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))
! 7.48051948 is for gal to ft^3 ! 7.48051948 is for gal to ft^3
else else
isection= Op_Mud_Backhead_section%Array(imud)+1
Op_RemainedVolume_in_LastSection%Array(imud)= Op_MudDischarged_Volume%Array(imud)- Op_EmptyVolume_inBackheadLocation%Array(imud)
MudSystemDotisection= Op_Mud_Backhead_section%Array(MudSystemDotimud)+1
MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotOp_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)
do do
if (isection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit)
if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space
Op_MudDischarged_Volume%Array(imud)= Op_MudDischarged_Volume%Array(imud)- Op_RemainedVolume_in_LastSection%Array(imud)
Op_Mud_Forehead_X%Array(imud)= Xend_OpSection(F_BottomHoleIntervalCounts)
Op_Mud_Forehead_section%Array(imud)= F_BottomHoleIntervalCounts
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 (Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveOpMudArrays(imud)
if (MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the well
call RemoveOpMudArrays(MudSystemDotimud)
endif endif
exit exit
endif endif
xx= Op_RemainedVolume_in_LastSection%Array(imud)/ OpSection_VolumeCapacity(isection) !(gal)
MudSystemDotxx= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection) !(gal)
if (xx<= 1.0) then
Op_Mud_Forehead_section%Array(imud)= isection
Op_Mud_Forehead_X%Array(imud)= (xx * (Xend_OpSection(isection)- Xstart_OpSection(isection)))+ Xstart_OpSection(isection)
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)
exit exit
else else
Op_RemainedVolume_in_LastSection%Array(imud)= Op_RemainedVolume_in_LastSection%Array(imud)- OpSection_VolumeCapacity(isection)
isection= isection+ 1
MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotOp_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotOpSection_VolumeCapacity(MudSystemDotisection)
MudSystemDotisection= MudSystemDotisection+ 1
endif endif


@@ -332,13 +332,13 @@ imud=0
endif endif
if (Op_Mud_Forehead_X%Array(imud)== Xend_OpSection(F_BottomHoleIntervalCounts)) then
totalLength = Op_MudDischarged_Volume%Length()
do while(imud < totalLength)
if (MudSystemDotOp_Mud_Forehead_X%Array(MudSystemDotimud)== MudSystemDotXend_OpSection(F_BottomHoleIntervalCounts)) then
MudSystemDottotalLength = MudSystemDotOp_MudDischarged_Volume%Length()
do while(MudSystemDotimud < MudSystemDottotalLength)
!imud = imud + 1 !imud = imud + 1
call RemoveOpMudArrays(totalLength)
totalLength = totalLength - 1
call RemoveOpMudArrays(MudSystemDottotalLength)
MudSystemDottotalLength = MudSystemDottotalLength - 1


enddo enddo
@@ -375,70 +375,70 @@ imud=0
!========================STRING ENTRANCE================= !========================STRING ENTRANCE=================
if ((ABS(St_Density%Last() - 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
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(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 !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 St_Density%Add (Ann_Density%First())
call St_MudDischarged_Volume%Add (0.0d0)
call St_Mud_Forehead_X%Add (Xend_PipeSection(F_StringIntervalCounts))
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 St_Mud_Forehead_section%Add (F_StringIntervalCounts)
call St_Mud_Backhead_X%Add (Xstart_PipeSection(F_StringIntervalCounts))
call MudSystemDotSt_Mud_Backhead_X%Add (MudSystemDotXstart_PipeSection(F_StringIntervalCounts))
call St_Mud_Backhead_section%Add (F_StringIntervalCounts) call St_Mud_Backhead_section%Add (F_StringIntervalCounts)
call St_RemainedVolume_in_LastSection%Add (0.0d0)
call St_EmptyVolume_inBackheadLocation%Add (0.0d0)
call MudSystemDotSt_RemainedVolume_in_LastSection%Add (0.0d0)
call MudSystemDotSt_EmptyVolume_inBackheadLocation%Add (0.0d0)
call St_MudOrKick%Add (0) call St_MudOrKick%Add (0)
!StringDensity_Old= Ann_Density%First() !StringDensity_Old= Ann_Density%First()
MudIsChanged= .true.
MudSystemDotMudIsChanged= .true.
endif endif


St_MudDischarged_Volume%Array(St_MudDischarged_Volume%Length())= St_MudDischarged_Volume%Last()+ ((StringFlowRate/60.0d0)*DeltaT_Mudline) !(gal)
MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotSt_MudDischarged_Volume%Length())= MudSystemDotSt_MudDischarged_Volume%Last()+ ((MudSystemDotStringFlowRate/60.0d0)*DeltaT_Mudline) !(gal)


!========================Tripping In==================== !========================Tripping In====================
!write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
if (DeltaVolumeOp > 0.0 .and. MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen)
write(*,*) 'DeltaVolumeOp=' , MudSystemDotDeltaVolumeOp
if (MudSystemDotDeltaVolumeOp > 0.0 .and. MudSystemDotMudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen)
!write(*,*) 'Tripping In' !write(*,*) 'Tripping In'
NewDensity= (Ann_Density%First()*((StringFlowRate/60.0d0)*DeltaT_Mudline)+Op_Density%Last()*DeltaVolumeOp)/(((StringFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp)
NewVolume= ((StringFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp
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


!write(*,*) 'St_MudDischarged_Volume%Last()=', St_MudDischarged_Volume%Last(), 'NewVolume=', NewVolume !write(*,*) 'St_MudDischarged_Volume%Last()=', St_MudDischarged_Volume%Last(), 'NewVolume=', NewVolume


if (abs(St_Density%Last()-NewDensity)< DensityMixTol) then ! .OR. (St_MudDischarged_Volume%Last()< 42.) ) then !+ NewVolume)< 42.) then ! 1-Pockets are Merged
St_Density%Array(St_Density%Length())= (St_Density%Last()*St_MudDischarged_Volume%Last()+NewDensity*NewVolume)/(St_MudDischarged_Volume%Last()+NewVolume)
St_MudDischarged_Volume%Array(St_Density%Length())= St_MudDischarged_Volume%Last()+DeltaVolumeOp
St_Mud_Forehead_X%Array(St_Density%Length())= (Xend_PipeSection(F_StringIntervalCounts))
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) St_Mud_Forehead_section%Array(St_Density%Length())= (F_StringIntervalCounts)
St_Mud_Backhead_X%Array(St_Density%Length())= (Xstart_PipeSection(F_StringIntervalCounts))
MudSystemDotSt_Mud_Backhead_X%Array(St_Density%Length())= (MudSystemDotXstart_PipeSection(F_StringIntervalCounts))
St_Mud_Backhead_section%Array(St_Density%Length())= (F_StringIntervalCounts) St_Mud_Backhead_section%Array(St_Density%Length())= (F_StringIntervalCounts)
St_RemainedVolume_in_LastSection%Array(St_Density%Length())= (0.0d0)
St_EmptyVolume_inBackheadLocation%Array(St_Density%Length())= (0.0d0)
MudSystemDotSt_RemainedVolume_in_LastSection%Array(St_Density%Length())= (0.0d0)
MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(St_Density%Length())= (0.0d0)
else ! 2-Merging conditions are not meeted, so new pocket else ! 2-Merging conditions are not meeted, so new pocket
call St_Density%Add (NewDensity) call St_Density%Add (NewDensity)
call St_MudDischarged_Volume%Add (NewVolume)
call St_Mud_Forehead_X%Add (Xend_PipeSection(F_StringIntervalCounts))
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 St_Mud_Forehead_section%Add (F_StringIntervalCounts)
call St_Mud_Backhead_X%Add (Xstart_PipeSection(F_StringIntervalCounts))
call MudSystemDotSt_Mud_Backhead_X%Add (MudSystemDotXstart_PipeSection(F_StringIntervalCounts))
call St_Mud_Backhead_section%Add (F_StringIntervalCounts) call St_Mud_Backhead_section%Add (F_StringIntervalCounts)
call St_RemainedVolume_in_LastSection%Add (0.0d0)
call St_EmptyVolume_inBackheadLocation%Add (0.0d0)
call MudSystemDotSt_RemainedVolume_in_LastSection%Add (0.0d0)
call MudSystemDotSt_EmptyVolume_inBackheadLocation%Add (0.0d0)
call St_MudOrKick%Add (0) call St_MudOrKick%Add (0)
endif endif


elseif (DeltaVolumeOp > 0.0 .and. MudIsChanged== .true.) then
elseif (MudSystemDotDeltaVolumeOp > 0.0 .and. MudSystemDotMudIsChanged== .true.) then
St_Density%Array(St_Density%Length())= NewDensity St_Density%Array(St_Density%Length())= NewDensity
St_MudDischarged_Volume%Array(St_Density%Length())= NewVolume
St_Mud_Forehead_X%Array(St_Density%Length())= (Xend_PipeSection(F_StringIntervalCounts))
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) St_Mud_Forehead_section%Array(St_Density%Length())= (F_StringIntervalCounts)
St_Mud_Backhead_X%Array(St_Density%Length())= (Xstart_PipeSection(F_StringIntervalCounts))
MudSystemDotSt_Mud_Backhead_X%Array(St_Density%Length())= (MudSystemDotXstart_PipeSection(F_StringIntervalCounts))
St_Mud_Backhead_section%Array(St_Density%Length())= (F_StringIntervalCounts) St_Mud_Backhead_section%Array(St_Density%Length())= (F_StringIntervalCounts)
St_RemainedVolume_in_LastSection%Array(St_Density%Length())= (0.0d0)
St_EmptyVolume_inBackheadLocation%Array(St_Density%Length())= (0.0d0)
MudSystemDotSt_RemainedVolume_in_LastSection%Array(St_Density%Length())= (0.0d0)
MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(St_Density%Length())= (0.0d0)
endif endif
@@ -447,60 +447,60 @@ write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
!======================== STRING ==================== !======================== STRING ====================
MudIsChanged= .false.
MudSystemDotMudIsChanged= .false.
imud= St_Mud_Forehead_X%Length() + 1
MudSystemDotimud= MudSystemDotSt_Mud_Forehead_X%Length() + 1


do while (imud > 1)
imud = imud - 1
do while (MudSystemDotimud > 1)
MudSystemDotimud = MudSystemDotimud - 1
if (imud< St_Mud_Forehead_X%Length()) then
St_Mud_Forehead_X%Array(imud)= St_Mud_Backhead_X%Array(imud+1)
St_Mud_Forehead_section%Array(imud)= St_Mud_Backhead_section%Array(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)
endif endif
DirectionCoef= (Xend_PipeSection(St_Mud_Forehead_section%Array(imud))-Xstart_PipeSection(St_Mud_Forehead_section%Array(imud))) &
/ ABS(Xend_PipeSection(St_Mud_Forehead_section%Array(imud))-Xstart_PipeSection(St_Mud_Forehead_section%Array(imud)))
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)))
! +1 for string , -1 for annulus ! +1 for string , -1 for annulus
St_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (St_Mud_Forehead_X%Array(imud)- Xstart_PipeSection(St_Mud_Forehead_section%Array(imud)))* &
Area_PipeSectionFt(St_Mud_Backhead_section%Array(imud)) !(ft^3)
St_EmptyVolume_inBackheadLocation%Array(imud)= St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal
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


if ( St_MudDischarged_Volume%Array(imud) <= St_EmptyVolume_inBackheadLocation%Array(imud)) then
St_Mud_Backhead_section%Array(imud)= St_Mud_Forehead_section%Array(imud)
St_Mud_Backhead_X%Array(imud)= St_Mud_Forehead_X%Array(imud)- DirectionCoef*(St_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_PipeSectionFt(St_Mud_Forehead_section%Array(imud))
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))
! 7.48051948 is for gal to ft^3 ! 7.48051948 is for gal to ft^3
else else
isection= St_Mud_Backhead_section%Array(imud)-1
St_RemainedVolume_in_LastSection%Array(imud)= St_MudDischarged_Volume%Array(imud)- St_EmptyVolume_inBackheadLocation%Array(imud)
MudSystemDotisection= St_Mud_Backhead_section%Array(MudSystemDotimud)-1
MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- MudSystemDotSt_EmptyVolume_inBackheadLocation%Array(MudSystemDotimud)
do do
if (isection < 1) then ! last pipe section(string exit)
St_MudDischarged_Volume%Array(imud)= St_MudDischarged_Volume%Array(imud)- St_RemainedVolume_in_LastSection%Array(imud)
St_Mud_Backhead_X%Array(imud)= Xstart_PipeSection(2)
St_Mud_Backhead_section%Array(imud)= 2
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 (St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string
call RemoveStringMudArrays(imud)
if (MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)<= 0.0d0) then ! imud is completely exited form the string
call RemoveStringMudArrays(MudSystemDotimud)
endif endif
exit exit
endif endif
xx= St_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal)
MudSystemDotxx= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)/ MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection) !(gal)
if (xx<= 1.0) then
St_Mud_Backhead_section%Array(imud)= isection
St_Mud_Backhead_X%Array(imud)= (xx * (Xstart_PipeSection(isection)- Xend_PipeSection(isection)))+ Xend_PipeSection(isection)
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)
exit exit
else else
St_RemainedVolume_in_LastSection%Array(imud)= St_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection)
isection= isection- 1
MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)= MudSystemDotSt_RemainedVolume_in_LastSection%Array(MudSystemDotimud)- MudSystemDotPipeSection_VolumeCapacity(MudSystemDotisection)
MudSystemDotisection= MudSystemDotisection- 1
endif endif




+ 6
- 6
FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 View File

@@ -45,21 +45,21 @@ IF (WellHeadOpen .OR. NoGasPocket == 0) THEN !! (mud circulation is normal we
!WRITE (*,*) 'StringFlowRate', StringFlowRate !WRITE (*,*) 'StringFlowRate', 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 = (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(MudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump
FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate + REAL(MudSystemDotMudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump
!WRITE (*,*) 'Drillstring speed (ft/s)' , FlowEl(j)%FlowRate !WRITE (*,*) 'Drillstring speed (ft/s)' , FlowEl(j)%FlowRate
!IF (NoWellToChokeEl > 0) THEN ! flowrate in choke line !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 = AnnulusFlowRate + (DeltaVolumePipe * ConvMinToSec / dt)
!END IF !END IF
IF (ShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation
IF (MudSystemDotShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation
!WRITE (*,*) ' SHoe fractured', PressureGauges(5), FlowEl(ShoeFlowElNo)%FlowRate !WRITE (*,*) ' SHoe fractured', PressureGauges(5), FlowEl(ShoeFlowElNo)%FlowRate
IF (ShoeFlowElNo > AnnulusLastEl) THEN ! shoe is in openhole IF (ShoeFlowElNo > AnnulusLastEl) THEN ! shoe is in openhole
FlowEl(ShoeFlowElNo : NumbEl)%FlowRate = - QLost
FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate - QLost
FlowEl(ShoeFlowElNo : NumbEl)%FlowRate = - MudSystemDotQlost
FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate - MudSystemDotQlost
ELSE ! shoe is in annulus ELSE ! shoe is in annulus
FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate - QLost
FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate - MudSystemDotQlost
END IF END IF
END IF END IF
@@ -141,7 +141,7 @@ IF (WellHeadOpen .OR. NoGasPocket == 0) THEN !! (mud circulation is normal we


IF (FlowEl(OpenholeFirstEl - 1)%FlowRate < 0.0) THEN IF (FlowEl(OpenholeFirstEl - 1)%FlowRate < 0.0) THEN
WRITE (*,*) ' Negative choke flowrate' WRITE (*,*) ' Negative choke flowrate'
FlowEl(OpenholeFirstEl - 1)%FlowRate = MAX((REAL(MudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0)
FlowEl(OpenholeFirstEl - 1)%FlowRate = MAX((REAL(MudSystemDotMudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0)
END IF END IF
!Kchoke = ChokeDensity / ((2. * 89158.0) * (0.26 * 0.61 * TotalOpenChokeArea)**2) !Kchoke = ChokeDensity / ((2. * 89158.0) * (0.26 * 0.61 * TotalOpenChokeArea)**2)
deltaPchoke = (Kchoke * FlowEl(OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(OpenholeFirstEl - 1)%FlowRate)) * 1.d0 deltaPchoke = (Kchoke * FlowEl(OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(OpenholeFirstEl - 1)%FlowRate)) * 1.d0


+ 1
- 1
FluidFlow/Fluid_Flow_Solver.f90 View File

@@ -21,7 +21,7 @@ subroutine Fluid_Flow_Solver
!WRITE (*,*) ' fluid flow pointer 2' !WRITE (*,*) ' fluid flow pointer 2'
FluidFlowCounter = FluidFlowCounter + 1
MudSystemDotFluidFlowCounter = MudSystemDotFluidFlowCounter + 1
call CirculationCodeSelect call CirculationCodeSelect


+ 31
- 31
FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 View File

@@ -52,10 +52,10 @@ SUBROUTINE PressureHorizAndStringDistribution
KickWasExitingThroughChoke = .FALSE. KickWasExitingThroughChoke = .FALSE.
IF (UtubeMode1Activated .OR. FloatValveWasOpen == .FALSE.) THEN ! Horizontal line flow rate
IF (MudSystemDotUtubeMode1Activated .OR. FloatValveWasOpen == .FALSE.) THEN ! Horizontal line flow rate
FlowEl(1 : NoHorizontalEl)%FlowRate = 0.0 FlowEl(1 : NoHorizontalEl)%FlowRate = 0.0
ELSE ! connection and line is open ELSE ! connection and line is open
FlowEl(1 : NoHorizontalEl)%FlowRate = StringFlowRate ! pump flow rate [gpm]
FlowEl(1 : NoHorizontalEl)%FlowRate = MudSystemDotStringFlowRate ! pump flow rate [gpm]
END IF END IF
!WRITE (*,*) 'a)A/B P Bit', StaticHeadOnBit , FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) !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 ELSE ! No gas pocket, wellhead is closed and mud is compressed based on volume pumped into annulus
AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * AnnMudVol) AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * AnnMudVol)
AnnCompressedMudVol = AnnCompressedMudVol + REAL(Ann_Saved_MudDischarged_Volume_Final) !!!!!!!!!
AnnCompressedMudVol = MAX((AnnCompressedMudVol - REAL(Qlost / ConvMinToSec / dt)) , 0.0)
AnnCompressedMudVol = AnnCompressedMudVol + REAL(MudSystemDotAnn_Saved_MudDischarged_Volume_Final) !!!!!!!!!
AnnCompressedMudVol = MAX((AnnCompressedMudVol - REAL(MudSystemDotQlost / ConvMinToSec / dt)) , 0.0)
AnnDeltaPDueToCompressibility = AnnCompressedMudVol / (MudCompressibility * AnnMudVol) AnnDeltaPDueToCompressibility = AnnCompressedMudVol / (MudCompressibility * AnnMudVol)
END IF END IF
IF (FloatValveIn == .FALSE. .OR. NoGasPocket == 0 .OR. (FloatValveWasOpen .AND. REAL(St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol)) THEN ! float valve remains open
IF (FloatValveIn == .FALSE. .OR. NoGasPocket == 0 .OR. (FloatValveWasOpen .AND. REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol)) THEN ! float valve remains open
FloatValveOpen = .TRUE. FloatValveOpen = .TRUE.
FlowEl(StringFirstEl : StringLastEl)%FlowRate = REAL(St_Saved_MudDischarged_Volume_Final) / dt * ConvMinToSec !StringFlowRate ! String flow rate pump flow rate [gpm]
FlowEl(StringFirstEl : StringLastEl)%FlowRate = REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) / dt * ConvMinToSec !StringFlowRate ! String flow rate pump flow rate [gpm]
!!!!!!!!!!!!!!! Calculating frictional pressure loss !!!!!!!!!!!!!!! Calculating frictional pressure loss
IF (WellHeadOpen) THEN 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 (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 IF (BitTotallyPluged) THEN
MudVolume_InjectedToBH = 0.d0
StCompressedMudVol = StCompressedMudVol + REAL(St_Saved_MudDischarged_Volume_Final)
MudSystemDotMudVolume_InjectedToBH = 0.d0
StCompressedMudVol = StCompressedMudVol + REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final)
StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility
ELSE IF (WellHeadOpen .OR. NoGasPocket > 0) THEN ELSE IF (WellHeadOpen .OR. NoGasPocket > 0) THEN
IF (REAL(St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN
IF (REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN
MudVolume_InjectedToBH = St_Saved_MudDischarged_Volume_Final
MudSystemDotMudVolume_InjectedToBH = MudSystemDotSt_Saved_MudDischarged_Volume_Final
!WRITE (*,*) 'MudVolume_InjectedToBH,BitTrue', MudVolume_InjectedToBH !WRITE (*,*) 'MudVolume_InjectedToBH,BitTrue', MudVolume_InjectedToBH
!IF (BitTrue .AND. UtubeMode1Activated == .FALSE.) THEN !IF (BitTrue .AND. UtubeMode1Activated == .FALSE.) THEN
IF (BitTrue) THEN IF (BitTrue) THEN
BitPressLoss = KBit * (MudVolume_InjectedToBH * ConvMinToSec / dt)**2
BitPressLoss = KBit * (MudSystemDotMudVolume_InjectedToBH * ConvMinToSec / dt)**2
!WRITE (*,*) 'BitPressLoss', BitPressLoss !WRITE (*,*) 'BitPressLoss', BitPressLoss
END IF END IF
StCompressedMudVol = BitPressLoss / StDeltaPtoDeltaVCompressibility StCompressedMudVol = BitPressLoss / StDeltaPtoDeltaVCompressibility
ELSE ELSE
MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility + SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) &
MudSystemDotMudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility + SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) &
/ StDeltaPtoDeltaVCompressibility ) * 1.d0)) / StDeltaPtoDeltaVCompressibility ) * 1.d0))
MudVolume_InjectedToBH = MIN(MudVolume_InjectedToBH , StCompressedMudVol)
StCompressedMudVol = StCompressedMudVol - MudVolume_InjectedToBH
MudSystemDotMudVolume_InjectedToBH = MIN(MudSystemDotMudVolume_InjectedToBH , StCompressedMudVol)
StCompressedMudVol = StCompressedMudVol - MudSystemDotMudVolume_InjectedToBH
END IF END IF
StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol)
ELSE ! IF (NoGasPocket == 0 .AND. WellHeadOpen == .FALSE.) THEN ELSE ! IF (NoGasPocket == 0 .AND. WellHeadOpen == .FALSE.) THEN
StCompressedMudVol = StCompressedMudVol + REAL(St_Saved_MudDischarged_Volume_Final)
StCompressedMudVol = StCompressedMudVol + REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final)
StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility
MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) &
MudSystemDotMudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) &
/ (StDeltaPtoDeltaVCompressibility + AnnDeltaPtoDeltaVCompressibility)) * 1.d0) / (StDeltaPtoDeltaVCompressibility + AnnDeltaPtoDeltaVCompressibility)) * 1.d0)
MudVolume_InjectedToBH = MIN(MudVolume_InjectedToBH , StCompressedMudVol)
StCompressedMudVol = StCompressedMudVol - REAL(MudVolume_InjectedToBH)
MudSystemDotMudVolume_InjectedToBH = MIN(MudSystemDotMudVolume_InjectedToBH , StCompressedMudVol)
StCompressedMudVol = StCompressedMudVol - REAL(MudSystemDotMudVolume_InjectedToBH)
StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol)
FlowEl(AnnulusFirstEl : NumbEl)%StartPress = FlowEl(AnnulusFirstEl : NumbEl)%StartPress + StDeltaPDueToCompressibility FlowEl(AnnulusFirstEl : NumbEl)%StartPress = FlowEl(AnnulusFirstEl : NumbEl)%StartPress + StDeltaPDueToCompressibility
FlowEl(AnnulusFirstEl : NumbEl)%EndPress = FlowEl(AnnulusFirstEl : NumbEl)%EndPress + StDeltaPDueToCompressibility FlowEl(AnnulusFirstEl : NumbEl)%EndPress = FlowEl(AnnulusFirstEl : NumbEl)%EndPress + StDeltaPDueToCompressibility
@@ -182,14 +182,14 @@ SUBROUTINE PressureHorizAndStringDistribution
!!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open and remains open !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open and remains open
ELSE IF (REAL(St_Saved_MudDischarged_Volume_Final) < PumpMinDischargedVol) THEN ! NoGasPocket > 0
ELSE IF (REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) < PumpMinDischargedVol) THEN ! NoGasPocket > 0
FloatValveOpen = FloatValveWasOpen ! remains in its former status FloatValveOpen = FloatValveWasOpen ! remains in its former status
IF (FloatValveOpen) THEN IF (FloatValveOpen) THEN
PressAboveFloatValve = MAX(FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(StringFirstEl)%Density * FlowEl(StringFirstEl)%StartTVD) PressAboveFloatValve = MAX(FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(StringFirstEl)%Density * FlowEl(StringFirstEl)%StartTVD)
ELSE ELSE
PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility
MudVolume_InjectedToBH = 0.d0
MudSystemDotMudVolume_InjectedToBH = 0.d0
END IF END IF
@@ -204,12 +204,12 @@ SUBROUTINE PressureHorizAndStringDistribution
END IF END IF
IF (FloatValveOpen) THEN IF (FloatValveOpen) THEN
MudVolume_InjectedToBH = MAX( 0.d0 , 0.1 * REAL((PressAboveFloatValve - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) &
MudSystemDotMudVolume_InjectedToBH = MAX( 0.d0 , 0.1 * REAL((PressAboveFloatValve - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) &
/ StDeltaPtoDeltaVCompressibility ) * 1.d0) / StDeltaPtoDeltaVCompressibility ) * 1.d0)
MudVolume_InjectedToBH = MIN(MudVolume_InjectedToBH , StCompressedMudVol)
MudSystemDotMudVolume_InjectedToBH = MIN(MudSystemDotMudVolume_InjectedToBH , StCompressedMudVol)
!WRITE (*,*) 'MudVolume_InjectedToBH (No Pump)', MudVolume_InjectedToBH !WRITE (*,*) 'MudVolume_InjectedToBH (No Pump)', MudVolume_InjectedToBH
StCompressedMudVol = StCompressedMudVol - MudVolume_InjectedToBH
StCompressedMudVol = StCompressedMudVol - MudSystemDotMudVolume_InjectedToBH
StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol)
!WRITE (*,*) 'StDeltaPDueToCompressibility(No Pump)', StDeltaPDueToCompressibility !WRITE (*,*) 'StDeltaPDueToCompressibility(No Pump)', StDeltaPDueToCompressibility
@@ -251,11 +251,11 @@ SUBROUTINE PressureHorizAndStringDistribution
!WRITE (*,*) ' AnnCompressedMudVol, AnnDeltaPDueToCompressibility',AnnCompressedMudVol, AnnDeltaPDueToCompressibility !WRITE (*,*) ' AnnCompressedMudVol, AnnDeltaPDueToCompressibility',AnnCompressedMudVol, AnnDeltaPDueToCompressibility
!!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open (close) and maybe remains open (close) or maybe closed !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open (close) and maybe remains open (close) or maybe closed
ELSE IF(FloatValveWasOpen == .FALSE. .AND. REAL(St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN
ELSE IF(FloatValveWasOpen == .FALSE. .AND. REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN
FloatValveOpen = .FALSE. FloatValveOpen = .FALSE.
MudVolume_InjectedToBH = 0.d0
MudSystemDotMudVolume_InjectedToBH = 0.d0
StCompressedMudVol = StCompressedMudVol + REAL(St_Saved_MudDischarged_Volume_Final)
StCompressedMudVol = StCompressedMudVol + REAL(MudSystemDotSt_Saved_MudDischarged_Volume_Final)
StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility
PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility


@@ -284,7 +284,7 @@ SUBROUTINE PressureHorizAndStringDistribution
END IF END IF
IF ((UtubePossibility == .TRUE. .AND. Get_KellyConnection() /= KELLY_CONNECTION_STRING) .OR. NewPipeFilling == 0) THEN
IF ((MudSystemDotUtubePossibility == .TRUE. .AND. Get_KellyConnection() /= KELLY_CONNECTION_STRING) .OR. MudSystemDotNewPipeFilling == 0) THEN
FlowEl(NoHorizontalEl)%EndPress = 0.0 FlowEl(NoHorizontalEl)%EndPress = 0.0
ELSE IF (WellHeadOpen == .FALSE.) THEN ELSE IF (WellHeadOpen == .FALSE.) THEN
FlowEl(NoHorizontalEl)%EndPress = FlowEl(StringFirstEl)%StartPress - 0.052 * FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD FlowEl(NoHorizontalEl)%EndPress = FlowEl(StringFirstEl)%StartPress - 0.052 * FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD
@@ -335,8 +335,8 @@ SUBROUTINE PressureHorizAndStringDistribution
!END IF !END IF


IF (UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadOpen) THEN
MudVolume_InjectedToBH = 0.d0
IF (MudSystemDotUtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadOpen) THEN
MudSystemDotMudVolume_InjectedToBH = 0.d0
MudVolume_InjectedFromAnn = 0.d0 MudVolume_InjectedFromAnn = 0.d0
!ELSE !ELSE
@@ -538,8 +538,8 @@ SUBROUTINE PressureHorizAndStringDistribution
!IF (PressureGauges(5) >= FormationLostPressure) WRITE (*,*) 'Near Shoe Flowrate', FlowEl(ShoeFlowElNo)%FlowRate !IF (PressureGauges(5) >= FormationLostPressure) WRITE (*,*) 'Near Shoe Flowrate', FlowEl(ShoeFlowElNo)%FlowRate
ShoeMudViscosity = FlowEl(ShoeFlowElNo)%MuEff
ShoeMudDensity = FlowEl(ShoeFlowElNo)%Density
MudSystemDotShoeMudViscosity = FlowEl(ShoeFlowElNo)%MuEff
MudSystemDotShoeMudDensity = FlowEl(ShoeFlowElNo)%Density
!WRITE (*,*) 'Drillstring speed (ft/s)' , DrillStringSpeed !WRITE (*,*) 'Drillstring speed (ft/s)' , DrillStringSpeed
!WRITE (*,*) 'shoe mud speed ', FlowEl(ShoeFlowElNo - 1)%vel !WRITE (*,*) 'shoe mud speed ', FlowEl(ShoeFlowElNo - 1)%vel


+ 12
- 12
FluidFlow/Well_Pressure_Data_Transfer.f90 View File

@@ -88,12 +88,12 @@ SUBROUTINE WellPressureDataTransfer
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NoHorizontalEl = NoHorizontalMudElements
NoStringEl = NoStringMudElements
NoAnnulusEl = NoCasingMudElements
NoHorizontalEl = MudSystemDotNoHorizontalMudElements
NoStringEl = MudSystemDotNoStringMudElements
NoAnnulusEl = MudSystemDotNoCasingMudElements
NoWellToChokeEl = 0 NoWellToChokeEl = 0
IF (ChokeKroneckerDelta == 1) NoWellToChokeEl = ChokeLine_Density%Length()
NoOpenHoleEl = NoBottomHoleMudElements
IF (ChokeKroneckerDelta == 1) NoWellToChokeEl = MudSystemDotChokeLine_Density%Length()
NoOpenHoleEl = MudSystemDotNoBottomHoleMudElements
NumbEl = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl + NoOpenHoleEl NumbEl = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl + NoOpenHoleEl
!WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl !WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl
IF(ALLOCATED(FlowEl)) DEALLOCATE(FlowEl) IF(ALLOCATED(FlowEl)) DEALLOCATE(FlowEl)
@@ -230,13 +230,13 @@ SUBROUTINE WellPressureDataTransfer
!ChokeLastEl = OpenholeFirstEl - 1 !ChokeLastEl = OpenholeFirstEl - 1
j = 1 j = 1
DO i = NoHorizontalEl + NoStringEl + NoAnnulusEl + 1 , NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWelltoChokeEl DO i = NoHorizontalEl + NoStringEl + NoAnnulusEl + 1 , NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWelltoChokeEl
FlowEl(i)%StartX = ChokeLine_Mud_Backhead_X%Array(j)
FlowEl(i)%EndX = ChokeLine_Mud_Forehead_X%Array(j)
FlowEl(i)%StartX = MudSystemDotChokeLine_Mud_Backhead_X%Array(j)
FlowEl(i)%EndX = MudSystemDotChokeLine_Mud_Forehead_X%Array(j)
FlowEl(i)%StartTVD = 0.d0 FlowEl(i)%StartTVD = 0.d0
FlowEl(i)%EndTVD = 0.d0 FlowEl(i)%EndTVD = 0.d0
FlowEl(i)%Id = 0.0 FlowEl(i)%Id = 0.0
FlowEl(i)%Od = BopStackSpecification%ChokeLineId FlowEl(i)%Od = BopStackSpecification%ChokeLineId
FlowEl(i)%density = ChokeLine_Density%Array(j)
FlowEl(i)%density = MudSystemDotChokeLine_Density%Array(j)
FlowEl(i)%Dhyd = FlowEl(i)%Od FlowEl(i)%Dhyd = FlowEl(i)%Od
FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX)
@@ -403,14 +403,14 @@ SUBROUTINE WellPressureDataTransfer


IF (NoGasPocket > 0) THEN IF (NoGasPocket > 0) THEN
!IF (NoWelltoChokeEl > 0 .AND. (FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .OR. KickWasExitingThroughChoke) .AND. WellHeadOpen) THEN !IF (NoWelltoChokeEl > 0 .AND. (FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .OR. KickWasExitingThroughChoke) .AND. WellHeadOpen) THEN
IF (Choke_Kick_Saved_Volume_Final > 0.d0) THEN
IF (MudSystemDotChoke_Kick_Saved_Volume_Final > 0.d0) THEN
!WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', Choke_Kick_Saved_Volume_Final, (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal) !WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', Choke_Kick_Saved_Volume_Final, (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal)
ExitMass = REAL(Choke_Kick_Saved_Volume_Final / (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal)) * GasPocketWeight%Array(NoGasPocket)
ExitMass = REAL(MudSystemDotChoke_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) !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, StringFlowRate * dt / ConvMinToSec
IF (FlowEl(OpenholeFirstEl - 1)%MaterialType /= 1) THEN IF (FlowEl(OpenholeFirstEl - 1)%MaterialType /= 1) THEN
CALL RemoveGasPocket(NoGasPocket) CALL RemoveGasPocket(NoGasPocket)
WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', Choke_Kick_Saved_Volume_Final
WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', MudSystemDotChoke_Kick_Saved_Volume_Final
END IF END IF
END IF END IF
@@ -604,7 +604,7 @@ SUBROUTINE GasPocketFlowElementTransformer
i = OpenholeFirstEl - 1 i = OpenholeFirstEl - 1
!WRITE (*,*) 'MaterialType, NoWelltoChokeEl', FlowEl(i)%MaterialType , NoWelltoChokeEl !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 (NoWelltoChokeEl > 0 .AND. FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .AND. WellHeadOpen) THEN ! kick is last element in choke line and does not exit.
IF (Choke_Kick_Saved_Volume_Final > 0.d0 .AND. WellHeadOpen) THEN
IF (MudSystemDotChoke_Kick_Saved_Volume_Final > 0.d0 .AND. WellHeadOpen) THEN
WRITE (*,*) 'Kick is exiting through the choke' 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) + StringFlowRate) / ConvMinToSec * dt
GasPocketWeight%Array(NoGasPocket) = GasPocketweight%Array(NoGasPocket) - ExitMass GasPocketWeight%Array(NoGasPocket) = GasPocketweight%Array(NoGasPocket) - ExitMass


+ 1
- 1
FluidFlow/kick/Formation_Information.f90 View File

@@ -76,7 +76,7 @@ SUBROUTINE FormationInformationCalculator
end if end if
!PermeabilityExposedHeight = KickFormLength * FormationPermeability !PermeabilityExposedHeight = KickFormLength * FormationPermeability
DownHole%PermeabilityExposedHeight = FluidFlowCounter - MudSys_timeCounter
DownHole%PermeabilityExposedHeight = MudSystemDotFluidFlowCounter - MudSystemDotMudSys_timeCounter
!==================================================== !====================================================
! Reservoir Data ! Reservoir Data
!==================================================== !====================================================


+ 4
- 4
FluidFlow/kick/Gas_Kick_Calculator.f90 View File

@@ -399,9 +399,9 @@ SUBROUTINE NewGasKick
WRITE (*,*) ' New Influx 1' WRITE (*,*) ' New Influx 1'
NoGasPocket = 1 NoGasPocket = 1
NewInfluxNumber = NewInfluxNumber + 1
MudSystemDotNewInfluxNumber = MudSystemDotNewInfluxNumber + 1
NewInfluxElementCreated = 0
MudSystemDotNewInfluxElementCreated = 0
KickOffBottom = .FALSE. KickOffBottom = .FALSE.


@@ -477,9 +477,9 @@ SUBROUTINE NewGasKick
NoGasPocket = NoGasPocket + 1 NoGasPocket = NoGasPocket + 1
NewInfluxNumber = NewInfluxNumber + 1
MudSystemDotNewInfluxNumber = MudSystemDotNewInfluxNumber + 1
NewInfluxElementCreated = 0
MudSystemDotNewInfluxElementCreated = 0
KickOffBottom = .FALSE. KickOffBottom = .FALSE.


CALL GasPocketOldPress%AddToFirst((BottomHolePress + StandardPress) * 1.d0) CALL GasPocketOldPress%AddToFirst((BottomHolePress + StandardPress) * 1.d0)


+ 1
- 1
Rop/JetImpactForce.f90 View File

@@ -15,7 +15,7 @@ subroutine JetImpactForce
Bit_Flowrate = StringFlowRateFinal ![gpm]
Bit_Flowrate = MudSystemDotStringFlowRateFinal ![gpm]
!print*, 'Bit_Flowrate=' , Bit_Flowrate !print*, 'Bit_Flowrate=' , Bit_Flowrate
!check :: Mud_Density [ppg] ?????????? !check :: Mud_Density [ppg] ??????????


+ 2
- 2
Rop/ROP_MainCalculation.f90 View File

@@ -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) 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 !IF (ALLOCATED(FlowEl)) THEN
! Mud_Viscosity = FlowEl(NoHorizontalEl + NoStringEl)%mueff !13.5 [cP] ! Mud_Viscosity = FlowEl(NoHorizontalEl + NoStringEl)%mueff !13.5 [cP]
Mud_Density = BitMudDensity ! [ppg]
Mud_Density = MudSystemDotBitMudDensity ! [ppg]
!ELSE !ELSE
Mud_Viscosity = 13.5 ! [cP] Mud_Viscosity = 13.5 ! [cP]
!Mud_Density = 9.2 ! [ppg] !Mud_Density = 9.2 ! [ppg]
!END IF !END IF
Mud_Flowrate = StringFlowRateFinal ! [gpm]
Mud_Flowrate = MudSystemDotStringFlowRateFinal ! [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) 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 $$$$$**$$$$$**$$$$$**$$$$$**$$$$$ ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$ End of Variable Initialization $$$$$**$$$$$**$$$$$**$$$$$**$$$$$


Loading…
Cancel
Save