diff --git a/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 b/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 index b9d4400..38a6042 100644 --- a/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 @@ -106,12 +106,12 @@ module CDataDisplayConsoleVariables subroutine Set_TotalDepth(v) use CDrillWatchVariables!!, only: DrillingWatch%Depth - use CSimulationVariables, only: SetDistanceDrilled + ! use CSimulationVariables, only: SetDistanceDrilled implicit none real(8), intent(in) :: v DataDisplayConsole%TotalWellDepth = v DrillingWatch%Depth = v - call SetDistanceDrilled(v) + ! call SetDistanceDrilled(v) end subroutine subroutine Set_BitPosition(v) diff --git a/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 b/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 index 104f1ec..fa6bc72 100644 --- a/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 +++ b/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 @@ -1,6 +1,6 @@ module CDrillingConsole use CDrillingConsoleVariables - use CSimulationVariables + ! use CSimulationVariables use CLog4 use CLog3 implicit none diff --git a/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 b/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 index 7ac2c82..37ac9be 100644 --- a/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 +++ b/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 @@ -18,7 +18,7 @@ module COperationScenariosMain ! subroutine OperationScenarios_Init ! use COperationScenariosSettings, OperationScenariosInitialization => Initialization ! implicit none - ! call OperationScenariosInitialization() + ! call OperationScenariosInitialization() ! end subroutine OperationScenarios_Init subroutine OperationScenarios_Step diff --git a/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 index 8bae7b7..db2e823 100644 --- a/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 @@ -41,62 +41,25 @@ module CTongEnum subroutine ButtonPress_Breakout_TongNotification() implicit none - - - - - - - if (Hoisting%DriveType == TopDrive_DriveType) then -#ifdef OST - print*, 'ButtonPress_Breakout_TongNotification=TopDrive' -#endif - + #ifdef OST + print*, 'ButtonPress_Breakout_TongNotification=TopDrive' + #endif !TOPDRIVE-CODE=70 if (Get_TongNotification()) then - call Set_Tong(TONG_BREAKOUT_BEGIN) return end if - - endif - - - - - - - - if (Hoisting%DriveType == Kelly_DriveType) then -#ifdef OST - print*, 'ButtonPress_Breakout_TongNotification=Kelly' -#endif - - + #ifdef OST + print*, 'ButtonPress_Breakout_TongNotification=Kelly' + #endif !OPERATION-CODE=74 if (Get_TongNotification()) then call Set_Tong(TONG_BREAKOUT_BEGIN) endif - - - - - endif - - - - - - - - - - - end subroutine diff --git a/ConfigurationVariables.f90 b/ConfigurationVariables.f90 new file mode 100644 index 0000000..e69de29 diff --git a/Data Structures.txt b/Data Structures.txt index f7f4a30..0554bd8 100644 --- a/Data Structures.txt +++ b/Data Structures.txt @@ -126,7 +126,6 @@ Equipments: TD_ROPHole TD_WellGeneral TD_WellGeo(:) - FluidFlow: diff --git a/Equipments/BopStack/BOP.f90 b/Equipments/BopStack/BOP.f90 index 830bb5a..c80b36c 100644 --- a/Equipments/BopStack/BOP.f90 +++ b/Equipments/BopStack/BOP.f90 @@ -1,6 +1,9 @@ module BOP contains + subroutine BopStack_Init + call BOP_StartUp + end subroutine BopStack_Init subroutine BopStack_Step USE VARIABLES USE CBopControlPanelVariables diff --git a/Equipments/BopStack/KILL_LINE.f90 b/Equipments/BopStack/KILL_LINE.f90 index eb4d4f0..0a81abf 100644 --- a/Equipments/BopStack/KILL_LINE.f90 +++ b/Equipments/BopStack/KILL_LINE.f90 @@ -6,7 +6,7 @@ SUBROUTINE KILL_LINE USE CBopStackVariables USE CBopControlPanelVariables USE CEquipmentsConstants - use CSimulationVariables + ! use CSimulationVariables implicit none @@ -152,7 +152,7 @@ SUBROUTINE KILL_LINE_SUB USE CBopStackVariables USE CBopControlPanelVariables USE CEquipmentsConstants - use CSimulationVariables + ! use CSimulationVariables implicit none diff --git a/Equipments/BopStack/PipeRams1Main.f90 b/Equipments/BopStack/PipeRams1Main.f90 index 1e01e54..f37d7cb 100644 --- a/Equipments/BopStack/PipeRams1Main.f90 +++ b/Equipments/BopStack/PipeRams1Main.f90 @@ -13,9 +13,9 @@ module PipeRams1Main ! call OnPipeRams1Main%Add(PipeRams1MainBody) ! end subroutine - ! subroutine PipeRams1_Init - ! implicit none - ! end subroutine PipeRams1_Init + subroutine PipeRams1_Init + call BOP_StartUp() + end subroutine PipeRams1_Init subroutine PipeRams1_Step use VARIABLES diff --git a/Equipments/ChokeControl/AirPump_Choke_Subs.f90 b/Equipments/ChokeControl/AirPump_Choke_Subs.f90 index c491ebc..1a5a713 100644 --- a/Equipments/ChokeControl/AirPump_Choke_Subs.f90 +++ b/Equipments/ChokeControl/AirPump_Choke_Subs.f90 @@ -99,28 +99,28 @@ ENDDO -SUBROUTINE PIPE_RAMS_CHOKE(CHNUMBER) - USE CHOKEVARIABLES - Use CSimulationVariables - implicit none - INTEGER CHNUMBER - Integer I - - loop3: do while (ABS(ChokeControlPanel%ChokeControlLever)==1.0 .AND. ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. CHOOKE(CHNUMBER)%FailMalf==0 .AND. AirDrivenPump%ChokeAirFail==0) - if (ChokeControlPanel%ChokeControlLever == 1.0) then - CHOOKE(CHNUMBER)%ChokeIsClosing = .true. - CHOOKE(CHNUMBER)%ChokeIsOpening = .false. - endif - if (ChokeControlPanel%ChokeControlLever == -1.0) then - CHOOKE(CHNUMBER)%ChokeIsOpening = .true. - CHOOKE(CHNUMBER)%ChokeIsClosing = .false. - endif - AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s) - call airpump_code_CHOKE(CHNUMBER) - call sleepqq(100) - if (IsStopped == .true.) return - end do loop3 !while finished_Choke==0 - end +! SUBROUTINE PIPE_RAMS_CHOKE(CHNUMBER) +! USE CHOKEVARIABLES +! Use CSimulationVariables +! implicit none +! INTEGER CHNUMBER +! Integer I + +! loop3: do while (ABS(ChokeControlPanel%ChokeControlLever)==1.0 .AND. ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. CHOOKE(CHNUMBER)%FailMalf==0 .AND. AirDrivenPump%ChokeAirFail==0) +! if (ChokeControlPanel%ChokeControlLever == 1.0) then +! CHOOKE(CHNUMBER)%ChokeIsClosing = .true. +! CHOOKE(CHNUMBER)%ChokeIsOpening = .false. +! endif +! if (ChokeControlPanel%ChokeControlLever == -1.0) then +! CHOOKE(CHNUMBER)%ChokeIsOpening = .true. +! CHOOKE(CHNUMBER)%ChokeIsClosing = .false. +! endif +! AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s) +! call airpump_code_CHOKE(CHNUMBER) +! call sleepqq(100) +! if (IsStopped == .true.) return +! end do loop3 !while finished_Choke==0 +! end @@ -244,40 +244,26 @@ SUBROUTINE PIPE_RAMS_CHOKE(CHNUMBER) ELSE ! Choke2LED==1 ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(2)%PercentClose*10 ENDIF - - !CALL SetHydraulicChock1(nint(MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)*100)) - ! CALL SetHydraulicChock2(nint(MIN(CHOOKE(2)%PercentClose / 0.91 , 1.0)*100)) - - ! .91 >> 9 percent clearance - -! =================== calculating Area - - ! AreaChoke=0.5 - ! .91 >> 9 percent clearance - - CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2) - CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2 - - !write(*,*) 'CHOOKE(1)%AreaChoke= ' , CHOOKE(1)%AreaChoke - - - - - Choke%HydraulicChoke1WashoutCoef= Choke%HydraulicChoke1WashoutCoef * CHOOKE(1)%WashoutMalf - Choke%HydraulicChoke1WashoutCoef= MIN( 0.5 , Choke%HydraulicChoke1WashoutCoef+ CHOOKE(1)%WashoutMalf*(0.5/(60.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time - - Choke%HydraulicChoke2WashoutCoef= Choke%HydraulicChoke2WashoutCoef * CHOOKE(2)%WashoutMalf - Choke%HydraulicChoke2WashoutCoef= MIN( 0.5 , Choke%HydraulicChoke2WashoutCoef+ CHOOKE(2)%WashoutMalf*(0.5/(60.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time - - - !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef - - IF (CHOOKE(1)%PlugMalf == 1) THEN + !CALL SetHydraulicChock1(nint(MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)*100)) + ! CALL SetHydraulicChock2(nint(MIN(CHOOKE(2)%PercentClose / 0.91 , 1.0)*100)) + ! .91 >> 9 percent clearance + + ! =================== calculating Area + ! AreaChoke=0.5 + ! .91 >> 9 percent clearance + + CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2) + CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2 + Choke%HydraulicChoke1WashoutCoef= Choke%HydraulicChoke1WashoutCoef * CHOOKE(1)%WashoutMalf + Choke%HydraulicChoke1WashoutCoef= MIN( 0.5 , Choke%HydraulicChoke1WashoutCoef+ CHOOKE(1)%WashoutMalf*(0.5/(60.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time + Choke%HydraulicChoke2WashoutCoef= Choke%HydraulicChoke2WashoutCoef * CHOOKE(2)%WashoutMalf + Choke%HydraulicChoke2WashoutCoef= MIN( 0.5 , Choke%HydraulicChoke2WashoutCoef+ CHOOKE(2)%WashoutMalf*(0.5/(60.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time + !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef + IF (CHOOKE(1)%PlugMalf == 1) THEN Choke%Present_HydraulicChoke1Plug= Choke%Present_HydraulicChoke1Plug * CHOOKE(1)%PlugMalf ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent - !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent if ( (ChokeProblems%HydraulicChoke1PluggedPercent - Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then @@ -285,106 +271,61 @@ SUBROUTINE PIPE_RAMS_CHOKE(CHNUMBER) Choke%Plug1TimeCounter = 0 !write(*,*) 'DeltaPlug1Percent, Present_HydraulicChoke1Plug = ' ,DeltaPlug1Percent , Present_HydraulicChoke1Plug endif - - Choke%Plug1TimeCounter= Choke%Plug1TimeCounter + 1 - Choke%HydraulicChoke1PluggedPercent_Old= ChokeProblems%HydraulicChoke1PluggedPercent if (Choke%Plug1TimeCounter <= Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=600 - Choke%Present_HydraulicChoke1Plug = Choke%Present_HydraulicChoke1Plug + CHOOKE(1)%PlugMalf* ((Choke%DeltaPlug1Percent / real(Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0 - endif - - !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug - - ENDIF - - - - - + !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug + ENDIF - IF (CHOOKE(2)%PlugMalf == 1) THEN - + IF (CHOOKE(2)%PlugMalf == 1) THEN Choke%Present_HydraulicChoke2Plug= Choke%Present_HydraulicChoke2Plug * CHOOKE(2)%PlugMalf ! integer: HydraulicChoke2PluggedPercent,HydraulicChoke2PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay ! real: Present_HydraulicChoke2Plug,DeltaPlug2Percent - - if ( (ChokeProblems%HydraulicChoke2PluggedPercent - Choke%HydraulicChoke2PluggedPercent_Old) /= 0 ) then Choke%DeltaPlug2Percent = (REAL(ChokeProblems%HydraulicChoke2PluggedPercent)/100.) - Choke%Present_HydraulicChoke2Plug Choke%Plug2TimeCounter = 0 endif - Choke%Plug2TimeCounter= Choke%Plug2TimeCounter + 1 - Choke%HydraulicChoke2PluggedPercent_Old= ChokeProblems%HydraulicChoke2PluggedPercent - if (Choke%Plug2TimeCounter <= Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=600 - Choke%Present_HydraulicChoke2Plug = Choke%Present_HydraulicChoke2Plug + CHOOKE(2)%PlugMalf *((Choke%DeltaPlug2Percent / real(Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0 + endif + ENDIF + ! fully open area is 123/64 in^2 = 0.01334635 ft^2 + CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke+(CHOOKE(1)%WashoutMalf*Choke%HydraulicChoke1WashoutCoef*Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup - endif - - ENDIF - - - - - - - - ! fully open area is 123/64 in^2 = 0.01334635 ft^2 - CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke+(CHOOKE(1)%WashoutMalf*Choke%HydraulicChoke1WashoutCoef*Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup - - !write(*,*) 'CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke=' ,CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke - - CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke-(CHOOKE(1)%PlugMalf* Choke%Present_HydraulicChoke1Plug *CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup - - CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke+(CHOOKE(2)%WashoutMalf*Choke%HydraulicChoke2WashoutCoef*Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup - CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke-(CHOOKE(2)%PlugMalf* Choke%Present_HydraulicChoke2Plug *CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup - !write(*,*) 'CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke=' ,CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke - - - CHOOKE(1)%AreaChokeFinal= CHOOKE(1)%AreaChoke - CHOOKE(2)%AreaChokeFinal= CHOOKE(2)%AreaChoke - - ! 144: ft^2 to in^2 - CALL SetHydraulicChock1(100 - nint((CHOOKE(1)%AreaChokeFinal/(Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve - CALL SetHydraulicChock2(100 - nint((CHOOKE(2)%AreaChokeFinal/(Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve - - - !write(*,*) 'CHOOKE(1)%PercentClose=' , CHOOKE(1)%PercentClose ! close percent 0 to 100 - !write(*,*) 'ChokePosition=' , ChokePosition ! close position 0 to 10 for display - !write(*,*) 'CHOOKE(1)%AreaChokeFinal=' , CHOOKE(1)%AreaChokeFinal ! Open Area (in^2) with clearance - !write(*,*) '(ChokeAreaFullyOpen/144.)=' , (ChokeAreaFullyOpen/144.) - !write(*,*) 'valve value=' , 100 - nint((CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100) ! percent close 0 to 100 with clearance - !write(*,*) 'Valve(33)%Status=' , Valve(33)%Status ! T : open , F: close - - - - - -! =================== calculating Area - - - - !write(*,*) 'CHOOKE(1)%AreaChoke= ' , CHOOKE(1)%AreaChoke - - - -! WRITE(150,50) alpha_timeair,alpha_Qair,alpha_pairp, & -! alpha_Pdownstrem,alpha_diffpair,alpha_lossesair,CHOOKE(CHNUMBER)%PassedCourse -!50 FORMAT(7(f15.5)) - - -!======================================================================================== -!======================================================================================== - + !write(*,*) 'CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke=' ,CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke + + CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke-(CHOOKE(1)%PlugMalf* Choke%Present_HydraulicChoke1Plug *CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup + + CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke+(CHOOKE(2)%WashoutMalf*Choke%HydraulicChoke2WashoutCoef*Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup + CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke-(CHOOKE(2)%PlugMalf* Choke%Present_HydraulicChoke2Plug *CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup + !write(*,*) 'CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke=' ,CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke + + + CHOOKE(1)%AreaChokeFinal= CHOOKE(1)%AreaChoke + CHOOKE(2)%AreaChokeFinal= CHOOKE(2)%AreaChoke + + ! 144: ft^2 to in^2 + CALL SetHydraulicChock1(100 - nint((CHOOKE(1)%AreaChokeFinal/(Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve + CALL SetHydraulicChock2(100 - nint((CHOOKE(2)%AreaChokeFinal/(Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve + + + !write(*,*) 'CHOOKE(1)%PercentClose=' , CHOOKE(1)%PercentClose ! close percent 0 to 100 + !write(*,*) 'ChokePosition=' , ChokePosition ! close position 0 to 10 for display + !write(*,*) 'CHOOKE(1)%AreaChokeFinal=' , CHOOKE(1)%AreaChokeFinal ! Open Area (in^2) with clearance + !write(*,*) '(ChokeAreaFullyOpen/144.)=' , (ChokeAreaFullyOpen/144.) + !write(*,*) 'valve value=' , 100 - nint((CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100) ! percent close 0 to 100 with clearance + !write(*,*) 'Valve(33)%Status=' , Valve(33)%Status ! T : open , F: close + ! =================== calculating Area + !write(*,*) 'CHOOKE(1)%AreaChoke= ' , CHOOKE(1)%AreaChoke + !WRITE(150,50) alpha_timeair,alpha_Qair,alpha_pairp, & + !alpha_Pdownstrem,alpha_diffpair,alpha_lossesair,CHOOKE(CHNUMBER)%PassedCourse + !50 FORMAT(7(f15.5)) + !======================================================================================== + !======================================================================================== ! write(*,*) PassedCourse - - - end diff --git a/Equipments/ChokeControl/CHOKE.f90 b/Equipments/ChokeControl/CHOKE.f90 index c3cb222..920969a 100644 --- a/Equipments/ChokeControl/CHOKE.f90 +++ b/Equipments/ChokeControl/CHOKE.f90 @@ -10,31 +10,40 @@ module ChokeModule contains - subroutine CHOKE_MainBody - implicit none - Integer I - INTEGER CHNUMBER - !=========================================================================== - - !StandPipePressureChoke= STGauge_Pressure ! from module mud system - !CasingPressure = CasingPressureDataDisplay - !=========================================================================== - ! - ! HYDRAULIC CHOKE CONTROL - ! - !=========================================================================== - IF(ChokeControlPanel%ChokeSelectorSwitch== 1) THEN - ChokeControlPanel%Choke1LED=1 - ChokeControlPanel%Choke2LED=0 - CHNUMBER=1 - ELSE - ChokeControlPanel%Choke2LED=1 - ChokeControlPanel%Choke1LED=0 - CHNUMBER=2 - ENDIF - if (ABS(ChokeControlPanel%ChokeControlLever)==1.0 .AND. ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. (CHOOKE(1)%FailMalf==0 .OR. CHOOKE(2)%FailMalf==0)) then - CALL PIPE_RAMS_CHOKE(CHNUMBER) - end if + ! function CHOKE_MainBody1 result(CHNUMBER) + ! implicit none + ! INTEGER CHNUMBER + ! IF(ChokeControlPanel%ChokeSelectorSwitch== 1) THEN + ! ChokeControlPanel%Choke1LED=1 + ! ChokeControlPanel%Choke2LED=0 + ! CHNUMBER=1 + ! ELSE + ! ChokeControlPanel%Choke2LED=1 + ! ChokeControlPanel%Choke1LED=0 + ! CHNUMBER=2 + ! ENDIF + ! end function CHOKE_MainBody1 + ! CALL PIPE_RAMS_CHOKE(CHNUMBER) + + ! subroutine Choke_innerLoop + ! ! do while (ABS(ChokeControlPanel%ChokeControlLever)==1.0 .AND. ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. CHOOKE(CHNUMBER)%FailMalf==0 .AND. AirDrivenPump%ChokeAirFail==0) + ! if (ChokeControlPanel%ChokeControlLever == 1.0) then + ! CHOOKE(CHNUMBER)%ChokeIsClosing = .true. + ! CHOOKE(CHNUMBER)%ChokeIsOpening = .false. + ! endif + ! if (ChokeControlPanel%ChokeControlLever == -1.0) then + ! CHOOKE(CHNUMBER)%ChokeIsOpening = .true. + ! CHOOKE(CHNUMBER)%ChokeIsClosing = .false. + ! endif + ! AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s) + ! call airpump_code_CHOKE(CHNUMBER) + ! ! call sleepqq(100) + ! ! if (IsStopped == .true.) return + ! ! enddo + ! end if + ! end subroutine Choke_innerLoop + + subroutine CHOKE_MainBody2 IF (ChokeControlPanel%Choke1LED==1) THEN ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(1)%PercentClose*10 ! display monitor ELSE ! Choke2LED==1 @@ -121,6 +130,6 @@ module ChokeModule !=========================================================================== !************************* IN MUD SYSTEM MODULE************************* - end subroutine CHOKE_MainBody + end subroutine CHOKE_MainBody2 end module ChokeModule \ No newline at end of file diff --git a/Equipments/ChokeControl/ChokeControlMain.f90 b/Equipments/ChokeControl/ChokeControlMain.f90 index c254221..d513d77 100644 --- a/Equipments/ChokeControl/ChokeControlMain.f90 +++ b/Equipments/ChokeControl/ChokeControlMain.f90 @@ -1,4 +1,5 @@ module ChokeControlMain + use CHOKEVARIABLES implicit none public contains @@ -13,14 +14,38 @@ module ChokeControlMain ! call OnChokeControlMain%Add(ChokeControlMainBody) ! end subroutine - ! subroutine ChokeControl_Init - ! implicit none - ! end subroutine ChokeControl_Init + subroutine ChokeControl_Init + call Choke_StartUp + end subroutine ChokeControl_Init subroutine ChokeControl_Step use ChokeModule implicit none - CALL CHOKE_MainBody + INTEGER CHNUMBER + + IF(ChokeControlPanel%ChokeSelectorSwitch== 1) THEN + ChokeControlPanel%Choke1LED=1 + ChokeControlPanel%Choke2LED=0 + CHNUMBER=1 + ELSE + ChokeControlPanel%Choke2LED=1 + ChokeControlPanel%Choke1LED=0 + CHNUMBER=2 + ENDIF + if(ABS(ChokeControlPanel%ChokeControlLever)==1.0 .AND. ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. CHOOKE(CHNUMBER)%FailMalf==0 .AND. AirDrivenPump%ChokeAirFail==0) then + if (ChokeControlPanel%ChokeControlLever == 1.0) then + CHOOKE(CHNUMBER)%ChokeIsClosing = .true. + CHOOKE(CHNUMBER)%ChokeIsOpening = .false. + endif + if (ChokeControlPanel%ChokeControlLever == -1.0) then + CHOOKE(CHNUMBER)%ChokeIsOpening = .true. + CHOOKE(CHNUMBER)%ChokeIsClosing = .false. + endif + AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s) + call airpump_code_CHOKE(CHNUMBER) + else + call CHOKE_MainBody2() + endif end subroutine ChokeControl_Step ! subroutine ChokeControl_Output diff --git a/Equipments/Drawworks/DrawworksMain.f90 b/Equipments/Drawworks/DrawworksMain.f90 index 7d88593..635a139 100644 --- a/Equipments/Drawworks/DrawworksMain.f90 +++ b/Equipments/Drawworks/DrawworksMain.f90 @@ -3,45 +3,30 @@ module DrawworksMain public contains - subroutine Drawworks_Setup() - use CSimulationVariables - implicit none - call OnSimulationInitialization%Add(Drawworks_Init) - call OnSimulationStop%Add(Drawworks_Init) - call OnDrawworksStep%Add(Drawworks_Step) - call OnDrawworksOutput%Add(Drawworks_Output) - call OnDrawworksMain%Add(DrawworksMainBody) - end subroutine + ! subroutine Drawworks_Setup() + ! use CSimulationVariables + ! implicit none + ! call OnSimulationInitialization%Add(Drawworks_Init) + ! call OnSimulationStop%Add(Drawworks_Init) + ! call OnDrawworksStep%Add(Drawworks_Step) + ! call OnDrawworksOutput%Add(Drawworks_Output) + ! call OnDrawworksMain%Add(DrawworksMainBody) + ! end subroutine subroutine Drawworks_Init - implicit none + call Drawworks_StartUp end subroutine Drawworks_Init subroutine Drawworks_Step - implicit none + call Drawworks_MainSolver end subroutine Drawworks_Step - - subroutine Drawworks_Output - implicit none - end subroutine Drawworks_Output - - subroutine DrawworksMainBody - + + subroutine DrawworksMainBody Use Drawworks_VARIABLES - implicit none - - Call Drawworks_StartUp - - loopdrawsim : do - Call Drawworks_MainSolver - - end do loopdrawsim - - + end do loopdrawsim end subroutine DrawworksMainBody - end module DrawworksMain \ No newline at end of file diff --git a/Equipments/Drawworks/Drawworks_INPUTS.f90 b/Equipments/Drawworks/Drawworks_INPUTS.f90 index 51a110a..ff83d1d 100644 --- a/Equipments/Drawworks/Drawworks_INPUTS.f90 +++ b/Equipments/Drawworks/Drawworks_INPUTS.f90 @@ -1,7 +1,7 @@ subroutine Drawworks_Inputs Use CDrillingConsoleVariables - Use CSimulationVariables + ! Use CSimulationVariables Use COperationScenariosVariables Use CWarningsVariables Use VARIABLES diff --git a/Equipments/MudSystem/MudSystem.f90 b/Equipments/MudSystem/MudSystem.f90 index 156ecc6..5191f5a 100644 --- a/Equipments/MudSystem/MudSystem.f90 +++ b/Equipments/MudSystem/MudSystem.f90 @@ -633,7 +633,7 @@ module MudSystemModule use CTanksVariables Use KickVariables Use CHoistingVariables - use CSimulationVariables + ! use CSimulationVariables implicit none Integer I @@ -647,87 +647,64 @@ module MudSystemModule if (PumpsSpecification%MudPump1ReliefValveIsSet==.false.) PumpsSpecification%MudPump1ReliefValvePressure=6000. if (PumpsSpecification%MudPump2ReliefValveIsSet==.false.) PumpsSpecification%MudPump2ReliefValvePressure=6000. if (PumpsSpecification%CementPumpReliefValveIsSet==.false.) PumpsSpecification%CementPumpReliefValvePressure=6000. -!=========================================================================================================================== -!=========================================================================================================================== -! >>> Should Be on Top of Other Codes <<< + !=========================================================================================================================== + !=========================================================================================================================== + ! >>> Should Be on Top of Other Codes <<< - !ActiveTankVolume= ActiveMudVolumeGal ! update from student input - !ActiveTankDensity= ActiveDensity ! update from student input - !ReserveTankVolume= ReserveMudVolumeGal ! update from student input - !ReserveTankDensity= ReserveDensity ! update from student input + !ActiveTankVolume= ActiveMudVolumeGal ! update from student input + !ActiveTankDensity= ActiveDensity ! update from student input + !ReserveTankVolume= ReserveMudVolumeGal ! update from student input + !ReserveTankDensity= ReserveDensity ! update from student input if (j7 > 0) then !ActiveTankToDump MudSystem%ActiveTankDensity= 0. MudSystem%ActiveTankVolume= 0. - endif - + endif if (j8 > 0) then !TripTankToDump MudSystem%TripTankDensityCalc= 0. MudSystem%TripTankVolumeCalc= 0. endif -!=========================================================================================================================== -!=========================================================================================================================== + !=========================================================================================================================== + !=========================================================================================================================== if (j15 > 0) then !MudPumps1&2ToActiveTank_Through65&66 !write(*,*) 'j15 is open' - ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> - - + ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> if (j2>0) Mp1Coef= 1.0 if (j12>0) Mp2Coef= 1.0 - - if (j2 /= 0 .or. j12/= 0) then - - - MudSystem%ActiveTankDensity = (MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume+ Mp1Coef*MudSystem%Mp1Density*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*MudSystem%Mp2Density*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))/ & - (MudSystem%ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60. - !write(*,*) 'active by j15' + MudSystem%ActiveTankDensity = (MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume+ Mp1Coef*MudSystem%Mp1Density*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*MudSystem%Mp2Density*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))/ & + (MudSystem%ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60. + !write(*,*) 'active by j15' endif - - - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) - !if ActiveTankVolume is higher, excess amount is dumped - + MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + !if ActiveTankVolume is higher, excess amount is dumped endif - - - if (H84 > 0.0) then !CementPumpToCementTank_Through67 - + if (H84 > 0.0) then !CementPumpToCementTank_Through67 if (j13>0) CpCoef= 1.0 - - - MudSystem%CementTankDensityCalc= (MudSystem%CementTankDensityCalc*MudSystem%CementTankVolumeCalc+ CpCoef*MudSystem%Mp3Density*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) ) / & - (MudSystem%CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)) - - MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) - - + MudSystem%CementTankDensityCalc= (MudSystem%CementTankDensityCalc*MudSystem%CementTankVolumeCalc+ CpCoef*MudSystem%Mp3Density*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) ) / & + (MudSystem%CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)) + MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) endif - -!=========================================================================================================================== -!=========================================================================================================================== - ! DUMP Path + !=========================================================================================================================== + !=========================================================================================================================== + ! DUMP Path MudSystem%PumpsDumpVolume= MudSystem%PumpsDumpVolume+ (jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate) *MudSystem%DeltaT_Mudline/60. MudSystem%PumpsDumpFlowRate= jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate - !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate + !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate if (Hoisting%DriveType==1 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then !write(*,*) 'Set_FlowFromKelly(.TRUE.)' call Activate_PumpWithKellyDisconnected() - !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate + !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate CALL Set_FlowFromKelly(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before elseif (Hoisting%DriveType==1) then call Deactivate_PumpWithKellyDisconnected() CALL Set_FlowFromKelly(0.0) ! .FALSE. before !write(*,*) 'Set_FlowFromKelly(.FALSE.)' - endif !write(*,*) 'DumpFromFillupHead_Pump1=' , DumpFromFillupHead_Pump1 - - if (Hoisting%DriveType==0 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromTopDrive_Pump1 .or. DumpFromTopDrive_Pump2 .or. DumpFromTopDrive_Pump3)) then !write(*,*) 'Set_FlowFromKelly(.TRUE.)' call Activate_PumpWithTopdriveDisconnected() @@ -736,106 +713,85 @@ module MudSystemModule call Deactivate_PumpWithTopdriveDisconnected() CALL Set_FlowFromKelly(0.0) ! .FALSE. before !write(*,*) 'Set_FlowFromKelly(.FALSE.)' - - endif - - - - if (MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then - + endif + if (MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then !call Activate_PumpWithKellyDisconnected() CALL Set_FlowFromFillupHead(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before else !call Deactivate_PumpWithKellyDisconnected() CALL Set_FlowFromFillupHead(0.0) ! .FALSE. before - endif -!####C_Program -----> DriveType = - ! = 0 TopDrive_DriveType - ! = 1 Kelly_DriveType -!=========================================================================================================================== -!=========================================================================================================================== - ! ****** Calculating Maximum Working Pressure + !####C_Program -----> DriveType = + ! = 0 TopDrive_DriveType + ! = 1 Kelly_DriveType + !=========================================================================================================================== + !=========================================================================================================================== + ! ****** Calculating Maximum Working Pressure if (PumpsSpecification%MudPump1ReliefValveIsSet) then MaxWorkingPressure1= PumpsSpecification%MudPump1ReliefValvePressure else MaxWorkingPressure1= 6000. !psi - endif - - + endif if (PumpsSpecification%MudPump2ReliefValveIsSet) then MaxWorkingPressure2= PumpsSpecification%MudPump2ReliefValvePressure else MaxWorkingPressure2= 6000. !psi endif - if (PumpsSpecification%CementPumpReliefValveIsSet) then MaxWorkingPressure3= PumpsSpecification%CementPumpReliefValveIsSet else MaxWorkingPressure3= 6000. !psi endif - - if (State1) then MaxWorkingPressure= min(MaxWorkingPressure1 , MaxWorkingPressure2 , MaxWorkingPressure3) MaxWorkingPressure1= MaxWorkingPressure MaxWorkingPressure2= MaxWorkingPressure MaxWorkingPressure3= MaxWorkingPressure endif - - if (State2) then MaxWorkingPressure= min(MaxWorkingPressure1 , MaxWorkingPressure2) MaxWorkingPressure1= MaxWorkingPressure MaxWorkingPressure2= MaxWorkingPressure endif - if (State3) then MaxWorkingPressure= min(MaxWorkingPressure1 , MaxWorkingPressure3) MaxWorkingPressure1= MaxWorkingPressure MaxWorkingPressure3= MaxWorkingPressure endif - - if (State4) then MaxWorkingPressure= min(MaxWorkingPressure2 , MaxWorkingPressure3) MaxWorkingPressure2= MaxWorkingPressure MaxWorkingPressure3= MaxWorkingPressure - endif - ! Calculating Maximum Working Pressure ****** - -!=========================================================================================================================== -!=========================================================================================================================== - - - ! ****** Blown Conditions + endif + ! Calculating Maximum Working Pressure ****** + !=========================================================================================================================== + !=========================================================================================================================== + + + ! ****** Blown Conditions - !G: PumpsToString Coefficient - !jJ2,Jj12,Jj13: TanksToMudPump Coefficient - !H: Pumps To Tank_Through65 or 67 Coefficient + !G: PumpsToString Coefficient + !jJ2,Jj12,Jj13: TanksToMudPump Coefficient + !H: Pumps To Tank_Through65 or 67 Coefficient - !write(*,*) 'j12=' , j12 - !write(*,*) 'H83=' , H83 - !write(*,*) 'DumpPump2=' , DumpPump2 - !write(*,*) 'G83=' , G83 + !write(*,*) 'j12=' , j12 + !write(*,*) 'H83=' , H83 + !write(*,*) 'DumpPump2=' , DumpPump2 + !write(*,*) 'G83=' , G83 PumpPressure1= jj2*(1-H82)*(1-DumpPump1)*G82* PressureGauges(1) PumpPressure2= jj12*(1-H83)*(1-DumpPump2)*G83* PressureGauges(1) PumpPressure3= jj13*(1-H84)*(1-DumpCementPump)*G84* PressureGauges(1) ! !write(*,*) 'jj2 , H82 , DumpPump1 , G82,PresCsureGauges(1)=' , jj2 , H82 , DumpPump1 , G82,PressureGauges(1) - !write(*,*) '1)PumpPressure1=' , PumpPressure1 - + !write(*,*) '1)PumpPressure1=' , PumpPressure1 !write(*,*) 'PumpPressure2=' , PumpPressure2 - PumpToManifoldMudVol = 3.0 * 42.0 !PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP1_Q / ConvMinToSec * dt !PumpToManifoldDeltaPDueToCompressibility = PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol) - IF(Mp1_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_82 .and. MP1_Q > 0.0) then PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP1_Q / ConvMinToSec * dt PumpPressure1= PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol) - write(*,*) '21)PumpPressure1=' , PumpPressure1 - + write(*,*) '21)PumpPressure1=' , PumpPressure1 WRITE (*,*) ' valve 1 ', Manifold%Valve(1)%Status WRITE (*,*) ' valve 4 ', Manifold%Valve(4)%Status WRITE (*,*) ' valve 6 ', Manifold%Valve(6)%Status @@ -846,16 +802,13 @@ module MudSystemModule WRITE (*,*) ' valve 68 ', Manifold%Valve(68)%Status WRITE (*,*) ' valve 69 ', Manifold%Valve(69)%Status WRITE (*,*) ' valve 48 ', Manifold%Valve(48)%Status - !call DisplayOpenPathsWrite() - ENDIF IF(Mp2_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_83 .and. MP2_Q > 0.0 ) then PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP2_Q / ConvMinToSec * dt PumpPressure2= PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol) - write(*,*) '22)PumpPressure1=' , PumpPressure2 - + write(*,*) '22)PumpPressure1=' , PumpPressure2 WRITE (*,*) ' -valve 1 ', Manifold%Valve(1)%Status WRITE (*,*) ' -valve 4 ', Manifold%Valve(4)%Status WRITE (*,*) ' -valve 6 ', Manifold%Valve(6)%Status @@ -866,20 +819,16 @@ module MudSystemModule WRITE (*,*) ' -valve 68 ', Manifold%Valve(68)%Status WRITE (*,*) ' -valve 69 ', Manifold%Valve(69)%Status WRITE (*,*) ' -valve 48 ', Manifold%Valve(48)%Status - !call DisplayOpenPathsWrites() - ENDIF + ENDIF IF(Cp_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_84 .AND. MP3_Q > 0.0 ) then PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP3_Q / ConvMinToSec * dt PumpPressure3= PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol) ENDIF - -!***************************************************************************** - - - !if(((Mp1_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_82) .or. ( PumpPressure1 >= MaxWorkingPressure1 ) & - !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array)))) .and. MP1_Q > 0.0 ) then + !***************************************************************************** + !if(((Mp1_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_82) .or. ( PumpPressure1 >= MaxWorkingPressure1 ) & + !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array)))) .and. MP1_Q > 0.0 ) then !write(*,*) ' failurrrrre ' if (PumpPressure1 >= MaxWorkingPressure1 .and. MP1_Q > 0.0) then @@ -907,15 +856,11 @@ module MudSystemModule !write(*,*) 'Pump1BlownStarted = .FALSE.' endif - !write(*,*) ' valve 65=' , Valve(65)%Status - - - + !write(*,*) ' valve 65=' , Valve(65)%Status !if(((Mp2_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_83) .or. PumpPressure2 >= MaxWorkingPressure2 & !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array))) ) .and. MP2_Q > 0.0 ) then if(PumpPressure2 >= MaxWorkingPressure2 .and. MP2_Q > 0.0 ) then - write(*,*) 'mp2,if=' , PumpPressure2 , MaxWorkingPressure2 , MP2_Q MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1 !if (Pump2BlownStarted == .FALSE. ) then @@ -937,9 +882,8 @@ module MudSystemModule !Pump2BlownInTimeStep = 0 !Pump2BlownStarted = .FALSE. endif - - !if(((Cp_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_84) .or. PumpPressure3 >= MaxWorkingPressure3 & - !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array)))) .and. MP3_Q > 0.0 ) then + !if(((Cp_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_84) .or. PumpPressure3 >= MaxWorkingPressure3 & + !.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 MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1 @@ -955,9 +899,7 @@ module MudSystemModule !Pump3BlownInTimeStep = 0 !Pump3BlownStarted = .FALSE. endif - !write(*,*) '3)PumpPressure1=' , PumpPressure1 - if (PumpPressure1>= 6000.) then MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1 if(MudSystem%Pump1BlownCount >= BlownThreshold) then @@ -998,69 +940,45 @@ module MudSystemModule !else !Pump3BlownInTimeStep = 0 !Pump3BlownStarted = .FALSE. - endif - ! Blown Conditions ******** -!=========================================================================================================================== -!=========================================================================================================================== + endif + ! Blown Conditions ******** + !=========================================================================================================================== + !=========================================================================================================================== if (j9 > 0 ) then !.and. WellisNOTFull== .false.) then !WellToBellNipple !write(*,*) 'j9 is open' - - - !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= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud - - - if (j4 > 0) then - BellNipple_FlowCoef= 13.625/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch) - MUD(7)%Q= BellNipple_FlowCoef * MUD(7)%Q - endif - - !total_annFlow= total_annFlow+(AnnulusFlowRateFinal/600.d0) - !total_DeltaVPipe= total_DeltaVPipe + DeltaVolumePipe - !write(*,*) 'total_annFlow,total_DeltaVPipe' , total_annFlow,total_DeltaVPipe - - - - if (MUD(7)%Q < 0.0 ) MUD(7)%Q= 0.0 !.or. WellisNOTFull== .true.) MUD(7)%Q= 0.0 - !!AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in - - !write(*,*) 'MUD(7)%Q=' , MUD(7)%Q - !write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn - !write(*,*) 'Ann_Kick_Saved_Volume=' , Ann_Kick_Saved_Volume - - sys_total_injected= sys_total_injected+ MudSystem%MudVolume_InjectedFromAnn - - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - sys_total_injected= 0. - endif - - !write(*,*) 'sys_total_injected=' , sys_total_injected - - - - - - !WellOutletDensity= Ann_Density%Last() ! (ppg) <<< in CirculationCodeSelect Code - - + !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= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud + if (j4 > 0) then + BellNipple_FlowCoef= 13.625/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch) + MUD(7)%Q= BellNipple_FlowCoef * MUD(7)%Q + endif + + !total_annFlow= total_annFlow+(AnnulusFlowRateFinal/600.d0) + !total_DeltaVPipe= total_DeltaVPipe + DeltaVolumePipe + !write(*,*) 'total_annFlow,total_DeltaVPipe' , total_annFlow,total_DeltaVPipe + if (MUD(7)%Q < 0.0 ) MUD(7)%Q= 0.0 !.or. WellisNOTFull== .true.) MUD(7)%Q= 0.0 + !!AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in + + !write(*,*) 'MUD(7)%Q=' , MUD(7)%Q + !write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn + !write(*,*) 'Ann_Kick_Saved_Volume=' , Ann_Kick_Saved_Volume + sys_total_injected= sys_total_injected+ MudSystem%MudVolume_InjectedFromAnn + if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + sys_total_injected= 0. + endif + !write(*,*) 'sys_total_injected=' , sys_total_injected + !WellOutletDensity= Ann_Density%Last() ! (ppg) <<< in CirculationCodeSelect Code if ((MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)) /= 0.0) then - MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%WellOutletDensity*(MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)) else MudSystem%BellNippleDensity= 0.0 endif - - !IF (WellisNOTFull== .false.) THEN ! well must be full to do this order - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline) + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline) !ENDIF - - - VolumeToBellNipple= VolumeToBellNipple + MudSystem%BellNippleVolume - !write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple - - !write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q + VolumeToBellNipple= VolumeToBellNipple + MudSystem%BellNippleVolume + !write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple + !write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q endif if (j9 == 0 ) then !.or. WellisNOTFull== .true.) then @@ -1073,12 +991,8 @@ module MudSystemModule else MudSystem%WellToPitsOpen= .false. endif - - -!=========================================================================================================================== -!=========================================================================================================================== - - + !=========================================================================================================================== + !=========================================================================================================================== if (j10 > 0) then !MudBucketToBellNipple !write(*,*) 'j10 is open' !MudBucketVolume= 0. @@ -1088,182 +1002,109 @@ module MudSystemModule MudSystem%BellNippleDensity= MudSystem%ActiveTankDensity MudSystem%MudBucketVolume= 0. endif - -!=========================================================================================================================== -!=========================================================================================================================== - + !=========================================================================================================================== + !=========================================================================================================================== if (j6 > 0) then !TripTankToActiveTank And BellNipple !write(*,*) 'j6 is open' !write(*,*) 'active by j6' MUD(6)%Q= 300. ! constant flow rate(gpm) - - - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc - ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) - - - !write(*,*) 'ActiveTankVolume before=', ActiveTankVolume - - - if (j6 == 1 .and. D71==1) then - !write(*,*) 'add to active' - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) - !write(*,*) 'ActiveTankVolume after=', ActiveTankVolume - - endif - - if (j6 == 1 .and. D80==1) then - MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) - endif - - if (j6 == 2) then - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc - ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) + !write(*,*) 'ActiveTankVolume before=', ActiveTankVolume + if (j6 == 1 .and. D71==1) then + !write(*,*) 'add to active' + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) + !write(*,*) 'ActiveTankVolume after=', ActiveTankVolume + + endif + + if (j6 == 1 .and. D80==1) then + MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) + endif - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) - endif - - - - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) - !if ActiveTankVolume is higher, excess amount is dumped + if (j6 == 2) then + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) + MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline) + endif + MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + !if ActiveTankVolume is higher, excess amount is dumped endif if (j6 == 0) then MUD(6)%Q=0.0 endif - -!=========================================================================================================================== -!=========================================================================================================================== - + !=========================================================================================================================== + !=========================================================================================================================== CALL Set_FlowFromReturnLine(.false.) - - if (j3 > 0) then !BellNippleToPits-FullWell - must be after **WellToBellNipple(j9)** !write(*,*) 'j3 is open' - !write(*,*) 'active by j3' !BellNipple flow rate= sum flow rate (well+ mudbucket+ triptank) - !Well to BellNipple: BellNippleVolume !MudBucket to BellNipple: BellNippleVolume !TripTnak to BellNipple: BellNippleVolume MUD(3)%Q = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60.d0 ! (gpm) - - !write(*,*) 'BellNippleVolume in j3 =' , BellNippleVolume - !write(*,*) 'MUD(3)%Q =' , MUD(3)%Q - call Set_FlowRate(real(100.*min(MUD(3)%Q,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8)) ! for unity display unityreturn = real(100.*min(MUD(3)%Q,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8) - !write(*,*) 'unity return=' , real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8) - - - - if (MUD(3)%Q > MudSystem%PedalMeter .and. B78==0) then MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume + ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline - (MudSystem%PedalMeter/60.)*MudSystem%DeltaT_Mudline) - !BellNippleDumpRate= MUD(3)%Q - PedalMeter - CALL Set_FlowFromReturnLine(.TRUE.) ! for unity display - endif - - !VolumeToActive = VolumeToActive + BellNippleVolume - !write(*,*) 'VolumeToActive*******=' , VolumeToActive - - + !VolumeToActive = VolumeToActive + BellNippleVolume + !write(*,*) 'VolumeToActive*******=' , VolumeToActive active_before= MudSystem%ActiveTankVolume - - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) ! to be 0. - if ( MudSystem%BellNippleDensity > 1.0) then if (j3 == 1 .and. B71==1) then !(volumes in galon) - - MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) !write(*,*) 'MUD(3)%Q=' , MUD(3)%Q - - IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) - - !write(*,*) 'active increase bell 1=' , ((MUD(3)%Q/60.)*DeltaT_Mudline) - - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN - - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg - !write(*,*) 'active increase bell 2=' , ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - !write(*,*) 'active increase bell 3=' , ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN - !write(*,*) ' Auto true 3' - - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase bell 4=' , ((MUD(3)%Q/60.d0)*DeltaT_Mudline) - - ENDIF + IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN + MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) + !write(*,*) 'active increase bell 1=' , ((MUD(3)%Q/60.)*DeltaT_Mudline) + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg + !write(*,*) 'active increase bell 2=' , ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + !write(*,*) 'active increase bell 3=' , ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN + !write(*,*) ' Auto true 3' + MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) + !write(*,*) 'active increase bell 4=' , ((MUD(3)%Q/60.d0)*DeltaT_Mudline) + ENDIF endif - - if (j3 == 1 .and. B77==1) then - - MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) - - IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - + if (j3 == 1 .and. B77==1) then + MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) + IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN - + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - + MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN - + ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN - + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN AddedVolumeToTank= ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - ENDIF - - endif - - - if (j3 == 1 .and. B78==1) then - - MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline - - !BellNippleDumpRate= MUD(3)%Q - - endif - - - + ENDIF + endif + if (j3 == 1 .and. B78==1) then + MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline + !BellNippleDumpRate= MUD(3)%Q + endif if (j3 == 2) then !78 is not allowded in this position MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) @@ -2191,7 +2032,7 @@ module MudSystemModule MPumps%Total_Stroke_Counter_For_Plot = MPumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * MudSystem%DeltaT_Mudline - CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot)) + ! CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot)) DataDisplayConsole%TotalStrokeCounter= real(nint(MudSystem%TotalStrokesPump1+MudSystem%TotalStrokesPump2)) !for drilling data display diff --git a/Equipments/MudSystem/MudSystemMain.f90 b/Equipments/MudSystem/MudSystemMain.f90 index 26ea1d8..f5a437e 100644 --- a/Equipments/MudSystem/MudSystemMain.f90 +++ b/Equipments/MudSystem/MudSystemMain.f90 @@ -20,11 +20,11 @@ module MudSystemMain CALL DEALLOCATE_ARRAYS_MudSystem() end subroutine MudSystem_Stop - subroutine MudSystem_Start + subroutine MudSystem_Init implicit none !print* , 'MudSystem_Start' CALL MudSystem_StartUp() - end subroutine MudSystem_Start + end subroutine MudSystem_Init subroutine MudSystem_Step use MudSystemModule diff --git a/Equipments/Pumps/PumpsMain.f90 b/Equipments/Pumps/PumpsMain.f90 index a548b1e..9e89782 100644 --- a/Equipments/Pumps/PumpsMain.f90 +++ b/Equipments/Pumps/PumpsMain.f90 @@ -1,27 +1,20 @@ module PumpsMain - Use Pumps_VARIABLES - - implicit none + implicit none public - contains - - - ! **************************************** -! ***** subroutine Pump1MainBody ***** -! **************************** - - subroutine Pump1_Setup() - use CSimulationVariables - implicit none - call OnSimulationInitialization%Add(Pump1_Init) - call OnSimulationStop%Add(Pump1_Init) - call OnPump1Step%Add(Pump1_Step) - call OnPump1Output%Add(Pump1_Output) - call OnPump1Main%Add(Pump1MainBody) - end subroutine +! ***** subroutine Pump1MainBody ***** +! **************************** + ! subroutine Pump1_Setup() + ! use CSimulationVariables + ! implicit none + ! call OnSimulationInitialization%Add(Pump1_Init) + ! call OnSimulationStop%Add(Pump1_Init) + ! call OnPump1Step%Add(Pump1_Step) + ! call OnPump1Output%Add(Pump1_Output) + ! call OnPump1Main%Add(Pump1MainBody) + ! end subroutine subroutine Pump1_Init Call Pumps_StartUp @@ -31,27 +24,27 @@ module PumpsMain Call Pump1_MainSolver end subroutine Pump1_Step - subroutine Pump1_Output - implicit none - end subroutine Pump1_Output + ! subroutine Pump1_Output + ! implicit none + ! end subroutine Pump1_Output - subroutine Pump1MainBody - use ifport - use ifmt - implicit none + ! subroutine Pump1MainBody + ! use ifport + ! use ifmt + ! implicit none - Call Pumps_StartUp + ! Call Pumps_StartUp - loop1 : do + ! loop1 : do - Call Pumps_MainSolver + ! Call Pumps_MainSolver - end do loop1 + ! end do loop1 - end subroutine Pump1MainBody + ! end subroutine Pump1MainBody diff --git a/Equipments/Pumps/Pumps_Outputs.f90 b/Equipments/Pumps/Pumps_Outputs.f90 index 68488a3..b321173 100644 --- a/Equipments/Pumps/Pumps_Outputs.f90 +++ b/Equipments/Pumps/Pumps_Outputs.f90 @@ -1,7 +1,7 @@ subroutine Pumps_Outputs Use CDataDisplayConsoleVariables - Use CSimulationVariables + ! Use CSimulationVariables Use Pumps_VARIABLES Use MudSystemModule Use CDrillWatchVariables diff --git a/Equipments/Pumps/Pumps_StartUp.f90 b/Equipments/Pumps/Pumps_StartUp.f90 index 172a580..f5aca06 100644 --- a/Equipments/Pumps/Pumps_StartUp.f90 +++ b/Equipments/Pumps/Pumps_StartUp.f90 @@ -1,14 +1,8 @@ subroutine Pumps_StartUp - Use CPumpsVariables Use Pumps_VARIABLES - IMPLICIT NONE - - - - -!>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<< + !>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<< PUMP(1)%FlowRatePerSTK = .04d0 ![bbl] !??????? motaghayere voroudi !PUMP(1)%FlowRatePerSTK = PUMP(1)%FlowRatePerSTK*0.0292d0 ![gpm] PUMP(1)%RateChange = 4.d0 ![stk/min2 ??] !??????? motaghayere voroudi @@ -23,11 +17,7 @@ subroutine Pumps_StartUp PUMP(1)%K_throttle = 0 PUMP(1)%N_old = 0.d0 Call Pump_OffMode_Solver(1) - - - - -!>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<< + !>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<< PUMP(2)%FlowRatePerSTK = .04d0 ![bbl] !??????? motaghayere voroudi !PUMP(2)%FlowRatePerSTK = PUMP(2)%FlowRatePerSTK*0.0292d0 ![gpm] PUMP(2)%RateChange = 4.d0 ![stk/min2 ??] !??????? motaghayere voroudi @@ -37,17 +27,11 @@ subroutine Pumps_StartUp PUMP(2)%MaxSPM = PumpsSpecification%MudPump2Maximum ![spm] PUMP(2)%Trans_Ratio = 965.d0/PUMP(2)%MaxSPM PUMP(2)%time_step = 0.1d0 !?????? niaz hast ya na?? - PUMP(2)%RateChange = 193.d0!PUMP(2)%RateChange*PUMP(2)%Trans_Ratio ! [rpm/min ??] ??????????????? rpm/s PUMP(2)%K_throttle = 0 PUMP(2)%N_old = 0.d0 - Call Pump_OffMode_Solver(2) - - - - - -!!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<< + Call Pump_OffMode_Solver(2) + !!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<< PUMP(3)%FlowRatePerSTK = .04d0 ![bbl] !??????? motaghayere voroudi !PUMP(3)%FlowRatePerSTK = PUMP(3)%FlowRatePerSTK*0.0292d0 ![gpm] PUMP(3)%RateChange = 4.d0 ![stk/min2 ??] !??????? motaghayere voroudi @@ -57,14 +41,8 @@ subroutine Pumps_StartUp PUMP(3)%MaxSPM = PumpsSpecification%CementPumpMaximum ![spm] PUMP(3)%Trans_Ratio = 965.d0/PUMP(3)%MaxSPM PUMP(3)%time_step = 0.1d0 !?????? niaz hast ya na?? - PUMP(3)%RateChange = 193.d0!PUMP(3)%RateChange*PUMP(3)%Trans_Ratio ! [rpm/min ??] ??????????????? rpm/s PUMP(3)%K_throttle = 0 PUMP(3)%N_old = 0.d0 Call Pump_OffMode_Solver(3) - - - - - end subroutine Pumps_StartUp \ No newline at end of file diff --git a/Equipments/RotaryTable/RTable_INPUTS.f90 b/Equipments/RotaryTable/RTable_INPUTS.f90 index 43ae218..f0482ac 100644 --- a/Equipments/RotaryTable/RTable_INPUTS.f90 +++ b/Equipments/RotaryTable/RTable_INPUTS.f90 @@ -1,7 +1,7 @@ subroutine RTable_INPUTS use CDrillingConsoleVariables - use CSimulationVariables + ! use CSimulationVariables use CTdsConnectionModesEnumVariables use CTdsElevatorModesEnumVariables use CHoistingVariables diff --git a/Equipments/RotaryTable/RotaryTableMain.f90 b/Equipments/RotaryTable/RotaryTableMain.f90 index 04276ba..0b64c9e 100644 --- a/Equipments/RotaryTable/RotaryTableMain.f90 +++ b/Equipments/RotaryTable/RotaryTableMain.f90 @@ -16,8 +16,7 @@ module RotaryTableMain Call RTable_StartUp end subroutine RotaryTable_Init - subroutine RotaryTable_Step - implicit none + subroutine RotaryTable_Step Call Rtable_MainSolver end subroutine RotaryTable_Step diff --git a/Equipments/TopDrive/TopDriveMain.f90 b/Equipments/TopDrive/TopDriveMain.f90 index e57bb2c..ea8bb91 100644 --- a/Equipments/TopDrive/TopDriveMain.f90 +++ b/Equipments/TopDrive/TopDriveMain.f90 @@ -23,18 +23,18 @@ module TopDriveMain subroutine TopDrive_Start implicit none - call Log_4('TopDrive_Start') + ! call Log_4('TopDrive_Start') end subroutine TopDrive_Start subroutine TopDrive_Step implicit none - call Log_4('TopDrive_Step') + ! call Log_4('TopDrive_Step') Call Rtable_MainSolver end subroutine TopDrive_Step subroutine TopDriveMainBody - use CSimulationVariables + ! use CSimulationVariables use TopDrive_VARIABLES use CDrillWatchVariables use CWarningsVariables diff --git a/Equipments/TopDrive/TopDrive_INPUTS.f90 b/Equipments/TopDrive/TopDrive_INPUTS.f90 index 705cff2..6df12bc 100644 --- a/Equipments/TopDrive/TopDrive_INPUTS.f90 +++ b/Equipments/TopDrive/TopDrive_INPUTS.f90 @@ -1,6 +1,6 @@ subroutine TopDrive_Inputs - Use CSimulationVariables + ! Use CSimulationVariables Use CTopDrivePanelVariables Use CTdsConnectionModesEnumVariables Use TopDrive_VARIABLES diff --git a/FluidFlow/FluidFlowMain.f90 b/FluidFlow/FluidFlowMain.f90 index 9c4df8b..a91cc79 100644 --- a/FluidFlow/FluidFlowMain.f90 +++ b/FluidFlow/FluidFlowMain.f90 @@ -14,14 +14,14 @@ module FluidFlowMain ! call OnFluidFlowMain%Add(FluidFlowMainBody) ! end subroutine - subroutine FluidFlow_Stop - implicit none - !WRITE (*,*) ' fluid flow done_Stop' - call DEALLOCATE_ARRAYS_NormalCirculation() - CALL DeallocateFlowTypes - end subroutine FluidFlow_Stop + ! subroutine FluidFlow_Stop + ! implicit none + ! !WRITE (*,*) ' fluid flow done_Stop' + ! call DEALLOCATE_ARRAYS_NormalCirculation() + ! CALL DeallocateFlowTypes + ! end subroutine FluidFlow_Stop - subroutine FluidFlow_Start + subroutine FluidFlow_Init USE Fluid_Flow_Startup_Vars implicit none !WRITE (*,*) ' fluid flow done_Start' @@ -33,7 +33,7 @@ module FluidFlowMain Call TD_WellElementsReadData Call TD_DrillStemReadData Call TD_PipePropertiesReadData - end subroutine FluidFlow_Start + end subroutine FluidFlow_Init subroutine FluidFlow_Step implicit none diff --git a/Rop/JetImpactForce.f90 b/Rop/JetImpactForce.f90 index 950e08d..c0fa01f 100644 --- a/Rop/JetImpactForce.f90 +++ b/Rop/JetImpactForce.f90 @@ -4,7 +4,7 @@ subroutine JetImpactForce use sROP_Variables use CStringConfigurationVariables use CformationVariables - use CSimulationVariables + ! use CSimulationVariables use CmudPropertiesVariables use MudSystemVARIABLES diff --git a/Rop/RopMain.f90 b/Rop/RopMain.f90 index 1c1ac7e..ebe1a72 100644 --- a/Rop/RopMain.f90 +++ b/Rop/RopMain.f90 @@ -3,36 +3,18 @@ module RopMain public contains - subroutine Rop_Setup() - use CSimulationVariables - implicit none - call OnSimulationInitialization%Add(Rop_Init) - call OnSimulationStop%Add(Rop_Init) - call OnRopStep%Add(Rop_Step) - call OnRopOutput%Add(Rop_Output) - call OnRopMain%Add(RopMainBody) - end subroutine - - subroutine Rop_Init - implicit none - end subroutine Rop_Init - + ! subroutine Rop_Setup() + ! use CSimulationVariables + ! implicit none + ! call OnSimulationInitialization%Add(Rop_Init) + ! call OnSimulationStop%Add(Rop_Init) + ! call OnRopStep%Add(Rop_Step) + ! call OnRopOutput%Add(Rop_Output) + ! call OnRopMain%Add(RopMainBody) + ! end subroutine + subroutine Rop_Step implicit none - end subroutine Rop_Step - - subroutine Rop_Output - implicit none - end subroutine Rop_Output - - - subroutine RopMainBody - implicit none - !loop1: do - !call sleep(1) - !call Calculate_ROP - !write(*,*) 'ROP main reached' - !end do loop1 - end subroutine RopMainBody - + end subroutine Rop_Step + end module RopMain \ No newline at end of file diff --git a/Rop/sROP_Variables.f90 b/Rop/sROP_Variables.f90 index 2a3e0b3..e0e7b18 100644 --- a/Rop/sROP_Variables.f90 +++ b/Rop/sROP_Variables.f90 @@ -13,6 +13,4 @@ implicit none END TYPE ROPInfo TYPE(ROPInfo) :: ROP_Bit - - end module sROP_Variables \ No newline at end of file diff --git a/Rop/srop_variables.mod b/Rop/srop_variables.mod deleted file mode 100644 index 1564023..0000000 Binary files a/Rop/srop_variables.mod and /dev/null differ diff --git a/CSharp/Simulation/CSimulation.f90 b/Simulation/CSimulation.f90 similarity index 100% rename from CSharp/Simulation/CSimulation.f90 rename to Simulation/CSimulation.f90 diff --git a/CSharp/Simulation/CSimulationThreads.f90 b/Simulation/CSimulationThreads.f90 similarity index 100% rename from CSharp/Simulation/CSimulationThreads.f90 rename to Simulation/CSimulationThreads.f90 diff --git a/CSharp/Simulation/CSimulationVariables.f90 b/Simulation/CSimulationVariables.f90 similarity index 100% rename from CSharp/Simulation/CSimulationVariables.f90 rename to Simulation/CSimulationVariables.f90 diff --git a/CSharp/Simulation/CSounds.f90 b/Simulation/CSounds.f90 similarity index 100% rename from CSharp/Simulation/CSounds.f90 rename to Simulation/CSounds.f90 diff --git a/SimulationCore2.vfproj b/SimulationCore2.vfproj index 5370a87..bf12fe6 100644 --- a/SimulationCore2.vfproj +++ b/SimulationCore2.vfproj @@ -226,9 +226,6 @@ - - - @@ -342,6 +339,8 @@ + + diff --git a/Simulator.f90 b/Simulator.f90 index d006bda..273e850 100644 --- a/Simulator.f90 +++ b/Simulator.f90 @@ -31,25 +31,17 @@ contains integer :: t !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! t=0 + call init_modules() do while (t<10) !!read variable from shared file call read_variables() - !!Location: ./bop - !! Variables: - !! Nothing exist in rop_step or even ropMainBody! - !! Tarmigh, Now merged with FluidFlow - call Rop_Step() + !! Tarmigh, Now merged with TorqueDrag (FluidFlow) + ! call Rop_Step() - !!Location: ./Equipment/BopStack !! Rafiee, nothing changed call BopStack_Step() - !! Location: /Equipment/Pumps - !! Variables: - !! Does not have step function - !! Call Pump_StartUp in the start - !! Why we have a infinite loop (loop2) in step? Must be rewritten !! Tarmigh, now is rewritten call Pump1_Step() !call Pump2_Step() @@ -154,5 +146,36 @@ contains ! Clean up. call json%destroy() end subroutine - + subroutine init_modules + !Tarmigh + call Pump1_Init() + !call Pump2_Step() + call RotaryTable_Init() + call Drawworks_Init() + call TopDrive_Init() + !Nothing in init (and step) + ! call Rop_Init() + ! call TorqueDrag_Init() + ! call Geo_Step() + + !! Rafiee + call BopStack_Init() + call ChokeControl_Init() + call MudSystem_Init() + !Again calls Bop_Startup + ! call PipeRams1_Init() + ! call PipeRams2_Step() + ! call KillLine_Step() + ! call ChokeLine_Step() + ! call BlindRams_Step() + ! call Annular_Step() + + !! Sheikh + call FluidFlow_Init() + + !! Ahmadi + call PathFinding_Init() + ! Calls OSInitialization and that sub only subscribes some notif + ! call OperationScenarios_Init() + end subroutine init_modules end module Simulator diff --git a/TorqueDrag/TD_MainCalculations.f90 b/TorqueDrag/TD_MainCalculations.f90 index 5f4228b..4782906 100644 --- a/TorqueDrag/TD_MainCalculations.f90 +++ b/TorqueDrag/TD_MainCalculations.f90 @@ -2,7 +2,7 @@ subroutine TD_MainCalculations Use CCasingLinerChokeVariables Use CStringConfigurationVariables - Use CSimulationVariables + ! Use CSimulationVariables Use TD_DrillStemComponents Use TD_WellElements Use TD_WellGeometry diff --git a/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 b/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 index acf9fc1..a4aa178 100644 --- a/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 +++ b/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 @@ -2,7 +2,7 @@ subroutine TD_DrillStemStartUp Use CCasingLinerChokeVariables Use CStringConfigurationVariables - Use CSimulationVariables + ! Use CSimulationVariables Use TD_DrillStemComponents Use TD_WellElements Use TD_WellGeometry diff --git a/TorqueDrag/TorqueDragMain.f90 b/TorqueDrag/TorqueDragMain.f90 index e19161a..71daa0c 100644 --- a/TorqueDrag/TorqueDragMain.f90 +++ b/TorqueDrag/TorqueDragMain.f90 @@ -2,21 +2,21 @@ MODULE TorqueDragMain USE CPumpsVariables USE CDrillingConsoleVariables USE CDataDisplayConsoleVariables - USE CSimulationVariables + ! USE CSimulationVariables USE Pumps_VARIABLES IMPLICIT NONE PUBLIC CONTAINS - subroutine TorqueDrag_Setup() - use CSimulationVariables - implicit none - call OnSimulationInitialization%Add(TorqueDrag_Init) - call OnSimulationStop%Add(TorqueDrag_Init) - call OnTorqueDragStep%Add(TorqueDrag_Step) - call OnTorqueDragOutput%Add(TorqueDrag_Output) - call OnTorqueDragMain%Add(TorqueDragMainBody) - end subroutine + ! subroutine TorqueDrag_Setup() + ! use CSimulationVariables + ! implicit none + ! call OnSimulationInitialization%Add(TorqueDrag_Init) + ! call OnSimulationStop%Add(TorqueDrag_Init) + ! call OnTorqueDragStep%Add(TorqueDrag_Step) + ! call OnTorqueDragOutput%Add(TorqueDrag_Output) + ! call OnTorqueDragMain%Add(TorqueDragMainBody) + ! end subroutine subroutine TorqueDrag_Init implicit none @@ -31,16 +31,13 @@ MODULE TorqueDragMain end subroutine TorqueDrag_Output - SUBROUTINE TorqueDragMainBody - USE ifport - USE ifmt - USE CSimulationVariables - !USE TDSUP - IMPLICIT NONE - - !CALL TD_MainCalculations - - - END SUBROUTINE TorqueDragMainBody + ! SUBROUTINE TorqueDragMainBody + ! ! USE ifport + ! ! USE ifmt + ! ! USE CSimulationVariables + ! !USE TDSUP + ! IMPLICIT NONE + ! !CALL TD_MainCalculations + ! END SUBROUTINE TorqueDragMainBody END MODULE TorqueDragMain \ No newline at end of file