diff --git a/.vscode/launch.json b/.vscode/launch.json index 039245b..913dcd8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -30,7 +30,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceRoot}/SimulationCore2", - "args": ["aberama.iran.liara.ir","32815","4YKFnubfFFjfh4yTK7b0Rg9X","test","5"], + "args": ["aberama.iran.liara.ir","32815","4YKFnubfFFjfh4yTK7b0Rg9X","4567bdd6-2af8-4d03-ab5e-08db9deec266","5"], "stopAtEntry": false, "cwd": "${workspaceRoot}", "externalConsole": false, diff --git a/CSharp/BasicInputs/RigSpecifications/CPower.i90 b/CSharp/BasicInputs/RigSpecifications/CPower.i90 new file mode 100644 index 0000000..0800c15 --- /dev/null +++ b/CSharp/BasicInputs/RigSpecifications/CPower.i90 @@ -0,0 +1,61 @@ +# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/RigSpecifications/CPower.f90" +module CPower + use SimulationVariables + use json_module + implicit none + public + contains + + subroutine PowerToJson(parent) + + type(json_value),pointer :: parent + type(json_core) :: json + type(json_value),pointer :: p + +! 1. create new node + call json%create_object(p,'Power') + +! 2. add member of data type to new node +! call StringConfigurationToJson(p) +! call FormationToJson(p) + call json%add(p,"CementPump",data%Configuration%Power%CementPump) + call json%add(p,"Drawworks",data%Configuration%Power%Drawworks) + call json%add(p,"GeneratorPowerRating",data%Configuration%Power%GeneratorPowerRating) + call json%add(p,"MudPump1",data%Configuration%Power%MudPump1) + call json%add(p,"MudPump2",data%Configuration%Power%MudPump2) + call json%add(p,"NumberOfgenerators",data%Configuration%Power%NumberOfgenerators) + call json%add(p,"RotaryTable",data%Configuration%Power%RotaryTable) + call json%add(p,"TopDrive",data%Configuration%Power%TopDrive) +! 3. add new node to parent + call json%add(parent,p) + end subroutine + + subroutine PowerFromJson(parent) + use json_module,IK =>json_ik + type(json_value),pointer :: parent + type(json_core) :: json + type(json_value),pointer :: p,pitems,pitem,pval,pbit + + call json%get(parent,'Power',p) + + call json%get(p,"CementPump",pitem) + call json%get(pitem,data%Configuration%Power%CementPump) + call json%get(p,"Drawworks",pitem) + call json%get(pitem,data%Configuration%Power%Drawworks) + call json%get(p,"GeneratorPowerRating",pitem) + call json%get(pitem,data%Configuration%Power%GeneratorPowerRating) + call json%get(p,"MudPump1",pitem) + call json%get(pitem,data%Configuration%Power%MudPump1) + call json%get(p,"MudPump2",pitem) + call json%get(pitem,data%Configuration%Power%MudPump2) + call json%get(p,"NumberOfgenerators",pitem) + call json%get(pitem,data%Configuration%Power%NumberOfgenerators) + call json%get(p,"RotaryTable",pitem) + call json%get(pitem,data%Configuration%Power%RotaryTable) + call json%get(p,"TopDrive",pitem) + call json%get(pitem,data%Configuration%Power%TopDrive) + + end subroutine + + +end module CPower diff --git a/CSharp/BasicInputs/RigSpecifications/CPowerVariables.i90 b/CSharp/BasicInputs/RigSpecifications/CPowerVariables.i90 new file mode 100644 index 0000000..ee45575 --- /dev/null +++ b/CSharp/BasicInputs/RigSpecifications/CPowerVariables.i90 @@ -0,0 +1,17 @@ +# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/RigSpecifications/CPowerVariables.f90" +module CPowerVariables + implicit none + public +! variables + Type::PowerType + integer :: NumberOfgenerators + real(8) :: GeneratorPowerRating + real(8) :: MudPump1 + real(8) :: MudPump2 + real(8) :: CementPump + real(8) :: RotaryTable + real(8) :: Drawworks + real(8) :: TopDrive + End type PowerType +! Type(PowerType)::Power +end module CPowerVariables diff --git a/Equipments/Pumps/PumpsMain.f90 b/Equipments/Pumps/PumpsMain.f90 index 9d215cf..39f8347 100644 --- a/Equipments/Pumps/PumpsMain.f90 +++ b/Equipments/Pumps/PumpsMain.f90 @@ -95,7 +95,7 @@ module PumpsMain ! Call DATE_AND_TIME(values=MP_END_TIME) ! MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8)) ! if(MP_SolDuration > 0.0) then -! Call sleepqq(MP_SolDuration) + ! Call sleepqq(MP_SolDuration) ! end if ! ! if (IsStopped == .true.) then diff --git a/Equipments/Pumps/PumpsMain.i90 b/Equipments/Pumps/PumpsMain.i90 new file mode 100644 index 0000000..3c316cb --- /dev/null +++ b/Equipments/Pumps/PumpsMain.i90 @@ -0,0 +1,223 @@ +# 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/Pumps/PumpsMain.f90" +module PumpsMain + use SimulationVariables + 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 Pump1_Init + Call Pumps_StartUp + end subroutine Pump1_Init + + subroutine Pump1_Step + Call Pump1_MainSolver + end subroutine Pump1_Step + +! subroutine Pump1_Output +! implicit none +! end subroutine Pump1_Output + +! subroutine Pump1MainBody +! use ifport +! use ifmt +! implicit none + + +! Call Pumps_StartUp + + +! loop1 : do + +! Call Pumps_MainSolver + +! end do loop1 + + +! end subroutine Pump1MainBody + + + + + +! **************************************** +! ***** subroutine Pump2MainBody ***** +! **************************** +! subroutine Pump2_Setup() +! use CSimulationVariables +! implicit none +! call OnSimulationInitialization%Add(Pump2_Init) +! call OnSimulationStop%Add(Pump2_Init) +! call OnPump2Step%Add(Pump2_Step) +! call OnPump2Output%Add(Pump2_Output) +! call OnPump2Main%Add(Pump2MainBody) +! end subroutine +! +! subroutine Pump2_Init +! implicit none +! end subroutine Pump2_Init +! +! subroutine Pump2_Step +! call Pump2_MainSolver +! end subroutine Pump2_Step +! +! subroutine Pump2_Output +! implicit none +! end subroutine Pump2_Output +! +! subroutine Pump2MainBody +! use ifport +! use ifmt +! use CWarnings +! implicit none +! +! integer,dimension(8) :: MP_START_TIME, MP_END_TIME +! INTEGER :: MP_SolDuration +! +! Call Pump_StartUp +! +! loop1 : do +! +! Call DATE_AND_TIME(values=MP_START_TIME) +! +! Call Pump2_MainSolver +! +! Call DATE_AND_TIME(values=MP_END_TIME) +! MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8)) +! if(MP_SolDuration > 0.0) then +! Call sleepqq(MP_SolDuration) +! end if +! +! if (IsStopped == .true.) then +! exit loop1 +! end if +! +! end do loop1 +! +! +! end subroutine Pump2MainBody +! +! +! +! +!! **************************************** +!! ***** subroutine Pump3MainBody ***** +!! **************************** +! subroutine Pump3_Setup() +! use CSimulationVariables +! implicit none +! call OnSimulationInitialization%Add(Pump3_Init) +! call OnSimulationStop%Add(Pump3_Init) +! call OnPump3Step%Add(Pump3_Step) +! call OnPump3Output%Add(Pump3_Output) +! call OnPump3Main%Add(Pump3MainBody) +! end subroutine +! +! subroutine Pump3_Init +! implicit none +! end subroutine Pump3_Init +! +! subroutine Pump3_Step +! implicit none +! end subroutine Pump3_Step +! +! subroutine Pump3_Output +! implicit none +! end subroutine Pump3_Output +! +! subroutine Pump3MainBody +! use ifport +! use ifmt +! implicit none +! +! +! integer,dimension(8) :: MP_START_TIME, MP_END_TIME +! INTEGER :: MP_SolDuration +! +! !Call Pump_StartUp +! !loop1 : do +! ! +! ! Call sleepqq(10) +! ! +! ! !!! Pump3 Malfunction ----> Power Failure +! ! !!if (data%State%Pump(1)%PowerFailMalf==1) then +! ! !! !MP1BLWR=0 +! ! !! Call Pump3_OffMode_Solver +! ! !! Call ClosePump1() +! ! !!end if +! ! +! ! !if( (MP1CPSwitch==1) .and. (MP1Throttle==0.) .and. (data%State%Pump(3)%PowerFailMalf==0) ) then +! !! +! !! loop2: do +! !! +! !! Call DATE_AND_TIME(values=MP_START_TIME) +! !! +! !!!! ! Pump3 Malfunction ----> Power Failure +! !!!! if (data%State%Pump(1)%PowerFailMalf==1) then +! !!!! !MP1BLWR=0 +! !!!! Pump3_OffMode_Solver +! !!!! Call ClosePump1() +! !!!! exit loop2 +! !!!! end if +! !! +! !! data%State%Pump(3)%N_new = MP1Throttle +! !! if (((data%State%Pump(3)%N_new-data%State%Pump(3)%N_old)/data%State%Pump(3)%time_step)>193.) then +! !! data%State%Pump(3)%N_ref =(193.*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old +! !! else if (((data%State%Pump(3)%N_old-data%State%Pump(3)%N_new)/data%State%Pump(3)%time_step)>193.) then +! !! data%State%Pump(3)%N_ref = (-193.*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old +! !! else +! !! data%State%Pump(3)%N_ref = data%State%Pump(3)%N_new +! !! end if +! !! +! !! Call Pump3_OnMode_Solver +! !! +! !! IF (data%State%Pump(3)%Flow_Rate>0.) Then +! !! Call OpenCementPump() +! !! Else +! !! Call CloseCementPump() +! !! End if +! !! +! !! data%State%Pump(3)%N_old = data%State%Pump(3)%N_ref +! !! +! !! Call DATE_AND_TIME(values=MP_END_TIME) +! !! MP_SolDuration = 100-(MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8)) +! !! !print*, 'MPtime=', MP_SolDuration +! !! if(MP_SolDuration > 0.0) then +! !! Call sleepqq(MP_SolDuration) +! !! end if +! !! +! !! if ((MP1CPSwitch==0) .or. (IsStopped == .true.)) then +! !! Call Pump3_OffMode_Solver +! !! Call CloseCementPump() +! !! exit loop2 +! !! end if +! !! end do loop2 +! ! +! ! else +! ! +! ! !Call Pump3_OffMode_Solver +! ! !Call CloseCementPump() +! ! +! ! end if +! ! +! ! if (IsStopped == .true.) then +! ! exit loop1 +! ! end if +! ! +! !end do loop1 +! +! +! end subroutine Pump3MainBody + +end module PumpsMain diff --git a/Equipments/Pumps/Pumps_StartUp.i90 b/Equipments/Pumps/Pumps_StartUp.i90 new file mode 100644 index 0000000..7f89c9c --- /dev/null +++ b/Equipments/Pumps/Pumps_StartUp.i90 @@ -0,0 +1,50 @@ +# 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/Pumps/Pumps_StartUp.f90" +subroutine Pumps_StartUp + use CPumpsVariables + use CPumps + use SimulationVariables + IMPLICIT NONE +!>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<< + data%State%Pump(1)%FlowRatePerSTK = .04d0 ![bbl] !??????? motaghayere voroudi +!data%State%Pump(1)%FlowRatePerSTK = data%State%Pump(1)%FlowRatePerSTK*0.0292d0 ![gpm] + data%State%Pump(1)%RateChange = 4.d0 ![stk/min2 ??] !??????? motaghayere voroudi + data%State%Pump(1)%Mech_Efficiency = data%Configuration%Pumps%MudPump1MechanicalEfficiency ![dimensionless] +!data%State%Pump(1)%Vol_Efficiency = MudPump1VolumetricEfficiency !bayad hazf beshe ? + data%State%Pump(1)%Max_Pressure = 6000.d0 ![psi] !??????? motaghayere voroudi + data%State%Pump(1)%MaxSPM = data%Configuration%Pumps%MudPump1Maximum ![spm] + data%State%Pump(1)%Trans_Ratio = 965.d0/data%State%Pump(1)%MaxSPM + data%State%Pump(1)%time_step = 0.1d0 !?????? niaz hast ya na?? + + data%State%Pump(1)%RateChange = 193.d0!data%State%Pump(1)%RateChange*data%State%Pump(1)%Trans_Ratio ! [rpm/min ??] ??????????????? rpm/s + data%State%Pump(1)%K_throttle = 0 + data%State%Pump(1)%N_old = 0.d0 + Call Pump_OffMode_Solver(1) +!>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<< + data%State%Pump(2)%FlowRatePerSTK = .04d0 ![bbl] !??????? motaghayere voroudi +!data%State%Pump(2)%FlowRatePerSTK = data%State%Pump(2)%FlowRatePerSTK*0.0292d0 ![gpm] + data%State%Pump(2)%RateChange = 4.d0 ![stk/min2 ??] !??????? motaghayere voroudi + data%State%Pump(2)%Mech_Efficiency = data%Configuration%Pumps%MudPump2MechanicalEfficiency ![dimensionless] +!data%State%Pump(2)%Vol_Efficiency = MudPump2VolumetricEfficiency !bayad hazf beshe ? + data%State%Pump(2)%Max_Pressure = 6000.d0 ![psi] !??????? motaghayere voroudi + data%State%Pump(2)%MaxSPM = data%Configuration%Pumps%MudPump2Maximum ![spm] + data%State%Pump(2)%Trans_Ratio = 965.d0/data%State%Pump(2)%MaxSPM + data%State%Pump(2)%time_step = 0.1d0 !?????? niaz hast ya na?? + data%State%Pump(2)%RateChange = 193.d0!data%State%Pump(2)%RateChange*data%State%Pump(2)%Trans_Ratio ! [rpm/min ??] ??????????????? rpm/s + data%State%Pump(2)%K_throttle = 0 + data%State%Pump(2)%N_old = 0.d0 + Call Pump_OffMode_Solver(2) +!!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<< + data%State%Pump(3)%FlowRatePerSTK = .04d0 ![bbl] !??????? motaghayere voroudi +!data%State%Pump(3)%FlowRatePerSTK = data%State%Pump(3)%FlowRatePerSTK*0.0292d0 ![gpm] + data%State%Pump(3)%RateChange = 4.d0 ![stk/min2 ??] !??????? motaghayere voroudi + data%State%Pump(3)%Mech_Efficiency = data%Configuration%Pumps%CementPumpMechanicalEfficiency ![dimensionless] +!data%State%Pump(3)%Vol_Efficiency = CementPumpVolumetricEfficiency !bayad hazf beshe ? + data%State%Pump(3)%Max_Pressure = 6000.d0 ![psi] !??????? motaghayere voroudi + data%State%Pump(3)%MaxSPM = data%Configuration%Pumps%CementPumpMaximum ![spm] + data%State%Pump(3)%Trans_Ratio = 965.d0/data%State%Pump(3)%MaxSPM + data%State%Pump(3)%time_step = 0.1d0 !?????? niaz hast ya na?? + data%State%Pump(3)%RateChange = 193.d0!data%State%Pump(3)%RateChange*data%State%Pump(3)%Trans_Ratio ! [rpm/min ??] ??????????????? rpm/s + data%State%Pump(3)%K_throttle = 0 + data%State%Pump(3)%N_old = 0.d0 + Call Pump_OffMode_Solver(3) +end subroutine Pumps_StartUp diff --git a/Equipments/Pumps/Pumps_VARIABLES.i90 b/Equipments/Pumps/Pumps_VARIABLES.i90 new file mode 100644 index 0000000..08973a1 --- /dev/null +++ b/Equipments/Pumps/Pumps_VARIABLES.i90 @@ -0,0 +1,49 @@ +# 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/Pumps/Pumps_VARIABLES.f90" +MODULE Pumps_VARIABLES + + IMPLICIT NONE + PUBLIC + + + + +! REAL , PARAMETER :: pi=3.14159265d0 + + + Type, public:: Pumps_Var + REAL :: Total_Pump_GPM, Total_Pump_SPM, Total_Stroke_Counter_For_Plot + end Type Pumps_Var + Type(Pumps_Var) :: MPumps + + + +!**************************************************************************************************** +!**************** Define PUMP Array ************************************************************ + TYPE, PUBLIC :: Pump_Var + +!***** Pump_VARIABLES *************************** + INTEGER :: AssignmentSwitchh, Switch, K_throttle + INTEGER :: PowerFailMalf , BlowPopOffMalf , SPMGaugeMalf , Failure + + REAL :: Throttle, RateChange + REAL :: Mech_Efficiency, Vol_Efficiency, Trans_Ratio + REAL :: StandPipe_Pressure , Max_Pressure + REAL :: Speed, N_new, N_old, MaxSPM + REAL :: Flow_Rate, Hydraulic_HorsePower, Max_Horsepower, FlowRatePerSTK, Max_FlowRate, HorsePower + REAL :: time_step + + + + INTEGER :: BLWR ! 1=On , 0=Off + INTEGER :: Open_Close ! 1=Open , 0=Close + +!************* Sound_VARIABLES ********************** + INTEGER :: SoundSPM + Logical :: SoundBlower + + END TYPE Pump_Var + +!*********************************************************************************************** +!*********************************************************************************************** + +END MODULE Pumps_VARIABLES diff --git a/FluidFlow/Frictional_Press_Drop_Calc.i90 b/FluidFlow/Frictional_Press_Drop_Calc.i90 new file mode 100644 index 0000000..a9d70cf --- /dev/null +++ b/FluidFlow/Frictional_Press_Drop_Calc.i90 @@ -0,0 +1,231 @@ +# 1 "/mnt/c/Projects/VSIM/SimulationCore2/FluidFlow/Frictional_Press_Drop_Calc.f90" +SUBROUTINE FricPressDrop(iloc) + + + +!! Record of revisions +!! Date Programmer Discription of change +!! ------ ------------ ----------------------- +!! 1396/07/23 Sheikh Original code +!! + + + + USE FricPressDropVarsModule + USE SimulationVariables + USE Fluid_Flow_Startup_Vars + USE CError + + IMPLICIT NONE + + INTEGER :: iloc + REAL :: TauZero + TauZero = 12.0 +!ActiveRheologyModel = Herschel_Bulkley_RheologyModel + +! 0 = Power Law , 1 = Bingham Plastic , 2 = Newtonian +!TotFricPressLoss = 0.0 + + FlowEl(iloc)%alpha = 1 ! assume that all elements have annulus geometry + FlowEl(iloc)%dPdLfric = 0.0 + FlowEl(iloc)%f = 0.0 + FlowEl(iloc)%FlowRate = ABS(FlowEl(iloc)%FlowRate) + + + + IF ((FlowEl(iloc)%FlowRate >= PressFlowrateTolerance) & + .AND. (FlowEl(iloc)%MaterialType /= 1) & ! not gas kick + .AND. (ABS(FlowEl(iloc)%Length) >= PressLengthTolerance) & + .AND. (FlowEl(iloc)%MaterialType /= 4)) THEN ! not air + + IF (FlowEl(iloc)%Id==0) THEN + FlowEl(iloc)%alpha = 0 + END IF + + FlowEl(iloc)%muPlastic = FlowEl(iloc)%Theta600 - FlowEl(iloc)%Theta300 ! cp + FlowEl(iloc)%YieldP = 2.0 * FlowEl(iloc)%Theta300 - FlowEl(iloc)%Theta600 ! lbf/100ft**2 + FlowEl(iloc)%nIndex = 3.32 * log10(FlowEl(iloc)%Theta600 / FlowEl(iloc)%Theta300) + FlowEl(iloc)%kIndex = 510.0 * FlowEl(iloc)%Theta300 / (511.0**FlowEl(iloc)%nIndex) ! rabete fv2 + IF (data%Configuration%Mud%ActiveRheologyModel == Herschel_Bulkley_RheologyModel .AND. FlowEl(iloc)%alpha == 0) THEN + FlowEl(iloc)%kIndex = 1.066 * FlowEl(iloc)%Theta300 / (511.0**FlowEl(iloc)%nIndex) + ELSE IF (data%Configuration%Mud%ActiveRheologyModel == Herschel_Bulkley_RheologyModel .AND. FlowEl(iloc)%alpha == 1) THEN + FlowEl(iloc)%nIndex = 3.32 * log10((FlowEl(iloc)%Theta600 - TauZero) / (FlowEl(iloc)%Theta300 - TauZero)) + FlowEl(iloc)%kIndex = 1.066 * (FlowEl(iloc)%Theta300 - TauZero) / (511.0**FlowEl(iloc)%nIndex) + END IF + + + + +! Calculating velocity + FlowEl(iloc)%vel = 0.408 * FlowEl(iloc)%FlowRate / (FlowEl(iloc)%Od**2 - FlowEl(iloc)%Id**2) ! velocity in ft/s +!FlowEl(iloc)%vel = 24.51 * FlowEl(iloc)%FlowRate / (FlowEl(iloc)%Od**2 - FlowEl(iloc)%Id**2) ! velocity in ft/min + +!IF (FlowModel == Bingham_RheologyModel) THEN ! Bingham Plastic +! FlowEl(iloc)%Gf = (2. + FlowEl(iloc)%alpha) / 2. +!ELSE IF (FlowModel == PowerLow_RheologyModel) THEN +! FlowEl(iloc)%Gf = ((3. - FlowEl(iloc)%alpha) * FlowEl(iloc)%nIndex + 1.) / FlowEl(iloc)%nIndex / (4. - FlowEl(iloc)%alpha) * (2. + FlowEl(iloc)%alpha) / 2. +!END IF + +!FlowEl(iloc)%gammaW = 1.6 * FlowEl(iloc)%Gf * FlowEl(iloc)%vel / FlowEl(iloc)%Dhyd + +!IF (FlowModel == Bingham_RheologyModel) THEN ! Bingham Plastic +! FlowEl(iloc)%tauW = 1.067 * ((4. - FlowEl(iloc)%alpha) / (3. - FlowEl(iloc)%alpha) * FlowEl(iloc)%YieldP + FlowEl(iloc)%muPlastic * FlowEl(iloc)%gammaW) +! !FlowEl(iloc)%tauW = 1.067*(FlowEl(iloc)%YieldP+FlowEl(iloc)%muPlastic*FlowEl(iloc)%gammaW) +!ELSE IF (FlowModel == PowerLow_RheologyModel) THEN ! Power law +! FlowEl(iloc)%tauW = 1.067 * FlowEl(iloc)%kIndex * FlowEl(iloc)%gammaW**FlowEl(iloc)%nIndex +!END IF + +! Calculating effective or apparent viscosity + IF (data%Configuration%Mud%ActiveRheologyModel == Bingham_RheologyModel) THEN ! Bingham Plastic + FlowEl(iloc)%mueff = FlowEl(iloc)%muPlastic + 5. * FlowEl(iloc)%YieldP * FlowEl(iloc)%Dhyd / FlowEl(iloc)%vel +!write(*,*) 'pointer1' , FlowEl(iloc)%muPlastic , FlowEl(iloc)%YieldP , FlowEl(iloc)%Dhyd , FlowEl(iloc)%vel + ELSE IF (data%Configuration%Mud%ActiveRheologyModel == PowerLaw_RheologyModel .OR. data%Configuration%Mud%ActiveRheologyModel == Herschel_Bulkley_RheologyModel) THEN ! Power Law + FlowEl(iloc)%Gf = ((3. - FlowEl(iloc)%alpha) * FlowEl(iloc)%nIndex + 1.0) / FlowEl(iloc)%nIndex / (4.0 - FlowEl(iloc)%alpha) * (2.0 + FlowEl(iloc)%alpha) / 2.0 + FlowEl(iloc)%mueff = (FlowEl(iloc)%kIndex) / (1. + FlowEl(iloc)%alpha / 2.) * ((96. * FlowEl(iloc)%vel / FlowEl(iloc)%Dhyd)**(FlowEl(iloc)%nIndex - 1)) * FlowEl(iloc)%Gf**FlowEl(iloc)%nIndex +!write(*,*) 'pointer2' , FlowEl(iloc)%kIndex ,FlowEl(iloc)%alpha , FlowEl(iloc)%vel ,FlowEl(iloc)%Dhyd,FlowEl(iloc)%nIndex ,FlowEl(iloc)%Gf ,FlowEl(iloc)%nIndex + END IF + + FlowEl(iloc)%gammaW = 96.0 * FlowEl(iloc)%Gf * FlowEl(iloc)%vel / FlowEl(iloc)%Dhyd + + FlowEl(iloc)%tauW = ((4.0 - FlowEl(iloc)%alpha) / (3.0 - FlowEl(iloc)%alpha))**FlowEl(iloc)%nIndex * TauZero + FlowEl(iloc)%kIndex * FlowEl(iloc)%gammaW**FlowEl(iloc)%nIndex + + +! Calculating Reynolds number + IF (FlowEl(iloc)%Od == FlowEl(iloc)%Dhyd) THEN + FlowEl(iloc)%GenRe = 928. * FlowEl(iloc)%density * FlowEl(iloc)%vel * FlowEl(iloc)%Dhyd / FlowEl(iloc)%mueff + ELSE + FlowEl(iloc)%GenRe = 757. * FlowEl(iloc)%density * FlowEl(iloc)%vel * FlowEl(iloc)%Dhyd / FlowEl(iloc)%mueff + END IF + +!FlowEl(iloc)%GenRe = 2997 * FlowEl(iloc)%density * FlowEl(iloc)%vel**2 / 19.36 / FlowEl(iloc)%tauW + +! Calculating friction factor + IF (data%Configuration%Mud%ActiveRheologyModel == Bingham_RheologyModel) THEN ! Bingham Plastic + IF (FlowEl(iloc)%GenRe <= 2000.0) THEN ! laminar regime + FlowEl(iloc)%f = 16.0 / FlowEl(iloc)%GenRe + ELSE IF (FlowEl(iloc)%GenRe >= 4000.0) THEN ! turbulent regime + FlowEl(iloc)%a = 0.0791 + FlowEl(iloc)%b = 0.25 + FlowEl(iloc)%f = FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b + ELSE !! transition from laminar to turbulent regime + FlowEl(iloc)%a = 0.0791 + FlowEl(iloc)%b = 0.25 + FlowEl(iloc)%f = (4000.0 - FlowEl(iloc)%GenRe) / 2000.0 * 16. / FlowEl(iloc)%GenRe & + + (FlowEl(iloc)%GenRe - 2000.0) / 2000.0 * FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b + END IF + + ELSE IF (data%Configuration%Mud%ActiveRheologyModel == PowerLaw_RheologyModel) THEN ! Power law + FlowEl(iloc)%ReCritLam = 3470. - 1370. * FlowEl(iloc)%nIndex + FlowEl(iloc)%ReCritTurb = 4270. - 1370. * FlowEl(iloc)%nIndex + + IF (FlowEl(iloc)%GenRe <= FlowEl(iloc)%ReCritLam) THEN ! laminar regime + FlowEl(iloc)%f = 16.0 / FlowEl(iloc)%GenRe / (1 - 0.184 * FlowEl(iloc)%alpha) + ELSE IF (FlowEl(iloc)%GenRe >= FlowEl(iloc)%ReCritTurb) THEN ! turbulent regime + FlowEl(iloc)%a = (log10(FlowEl(iloc)%nIndex) + 3.93) / 50. + FlowEl(iloc)%b = (1.75 - log10(FlowEl(iloc)%nIndex)) / 7. + FlowEl(iloc)%f = FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b + ELSE + FlowEl(iloc)%a = (log10(FlowEl(iloc)%nIndex) + 3.93) / 50. + FlowEl(iloc)%b = (1.75 - log10(FlowEl(iloc)%nIndex)) / 7. + FlowEl(iloc)%f = (FlowEl(iloc)%ReCritTurb - FlowEl(iloc)%GenRe) / 800.0 * 16. / FlowEl(iloc)%GenRe & + + (FlowEl(iloc)%GenRe - FlowEl(iloc)%ReCritLam) / 800.0 * FlowEl(iloc)%a / FlowEl(iloc)%GenRe**FlowEl(iloc)%b + END IF + + END IF + +!WRITE (*,*) 'fric press drop', iloc +!WRITE (*,*) 'Length', ABS(REAL(FlowEl(iloc)%Length)) +!WRITE (*,*) 'FlowRate', FlowEl(iloc)%FlowRate +!WRITE (*,*) 'Theta600 , Theta300', FlowEl(iloc)%Theta600 , FlowEl(iloc)%Theta300 +!WRITE (*,*) 'Dhyd', FlowEl(iloc)%Dhyd +!WRITE (*,*) 'GenRe', FlowEl(iloc)%GenRe +!WRITE (*,*) 'f', FlowEl(iloc)%f + + + + + END IF + +! Frictional pressure loss gradient calculation +! FlowEl(iloc)%dPdLfric = 1.076 * FlowEl(iloc)%f * FlowEl(iloc)%vel**2 * FlowEl(iloc)%density / 10**5 / FlowEl(iloc)%Dhyd + FlowEl(iloc)%dPdLfric = FlowEl(iloc)%f * (FlowEl(iloc)%vel)**2 * FlowEl(iloc)%density / 25.81 / FlowEl(iloc)%Dhyd + FlowEl(iloc)%FricPressLoss = FlowEl(iloc)%dPdLfric * ABS(REAL(FlowEl(iloc)%Length)) + + IF (FlowEl(iloc)%FrictionDirection == -1) THEN + FlowEl(iloc)%FlowRate = - FlowEl(iloc)%FlowRate + FlowEl(iloc)%dPdLfric = - FlowEl(iloc)%dPdLfric + FlowEl(iloc)%FricPressLoss = - FlowEl(iloc)%FricPressLoss + END IF + + + +!END DO + + +END SUBROUTINE FricPressDrop + + +SUBROUTINE PartialDerivativeFricToFlowRate(iloc) + + USE FricPressDropVarsModule + USE SimulationVariables + USE Fluid_Flow_Startup_Vars + use KickVARIABLESModule + USE CError + + + IMPLICIT NONE + + INTEGER :: iloc + + FlowEl(iloc)%FricToQPartialDiff = 0.0 +!FlowEl(iloc)%FlowRate = ABS(FlowEl(iloc)%FlowRate) + + + IF ((ABS(FlowEl(iloc)%FlowRate) >= PressFlowrateTolerance) & + .AND. (FlowEl(iloc)%MaterialType /= 1) & ! not gas kick + .AND. (ABS(FlowEl(iloc)%Length) >= PressLengthTolerance) & + .AND. (FlowEl(iloc)%MaterialType /= 4)) THEN ! not air + + IF (data%Configuration%Mud%ActiveRheologyModel == PowerLaw_RheologyModel) THEN ! Power law +!IF (FlowEl(iloc)%Flowrate == 0.0) THEN +! FlowEl(iloc)%Flowrate = 10.0 +! CALL FricPressDrop(iloc) +!END IF + IF (FlowEl(iloc)%GenRe <= FlowEl(iloc)%ReCritLam) THEN ! laminar flow + FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate * FlowEl(iloc)%nIndex + + ELSE IF (FlowEl(iloc)%GenRe >= FlowEl(iloc)%ReCritTurb) THEN ! turbulent flow + FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate & + * (2. - FlowEl(iloc)%b * (2. - FlowEl(iloc)%nIndex)) + + ELSE ! transition from laminar to turbulent + FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate & + * (2. + (2. - FlowEl(iloc)%nIndex) & + * ((FlowEl(iloc)%a * FlowEl(iloc)%GenRe**(1. - FlowEl(iloc)%b) - 16.) / 800. / FlowEl(iloc)%f - 1.)) + END IF + + ELSE IF (data%Configuration%Mud%ActiveRheologyModel == Bingham_RheologyModel) THEN ! Bingham Plastic + IF (FlowEl(iloc)%GenRe <= 2000.0 .OR. FlowEl(iloc)%f == 0.0) THEN ! laminar flow if f = 0.0, we have no flow in first time flowing + FlowEl(iloc)%FricToQPartialDiff = (16. * FlowEl(iloc)%muPlastic * REAL(FlowEl(iloc)%Length) * 2.224 * (10.)**(-3)) & + / (25.81 * 928. * (1 - 0.184 * FlowEl(iloc)%alpha) * FlowEl(iloc)%Dhyd**2 * FlowEl(iloc)%Area) + + ELSE IF (FlowEl(iloc)%GenRe >= 4000.0) THEN ! turbulent flow + FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate & + * (2. - FlowEl(iloc)%b * (2. - FlowEl(iloc)%muPlastic / FlowEl(iloc)%mueff)) + + ELSE ! transition from laminar to turbulent + FlowEl(iloc)%FricToQPartialDiff = FlowEl(iloc)%FricPressLoss / FlowEl(iloc)%FlowRate & + * (2. + (2. - FlowEl(iloc)%muPlastic / FlowEl(iloc)%mueff) & + * ((FlowEl(iloc)%a * FlowEl(iloc)%GenRe**(1. - FlowEl(iloc)%b) - 16.) / 2000. / FlowEl(iloc)%f - 1.)) + END IF + END IF + END IF + + + IF (FlowEl(iloc)%FricToQPartialDiff < 0.0) THEN +!WRITE (*,*) ' iloc, Re, FricPressLoss, FricToQPartialDiff' , iloc, FlowEl(iloc)%GenRe, FlowEl(iloc)%FricPressLoss, FlowEl(iloc)%FricToQPartialDiff +!CALL ERRORSTOP('Error in Calculating FricToQPartialDiff') + END IF + +END SUBROUTINE PartialDerivativeFricToFlowRate diff --git a/Makefile b/Makefile index cf1a3a6..20b8a81 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ OBJ_DIR = $(TOP_DIR)/obj # FCFLAGS = -g -J$(MOD_DIR) -fimplicit-none -Wall -cpp -ffree-line-length-256 # FCFLAGS = /module:$(MOD_DIR) /fpp -FCFLAGS = -module $(MOD_DIR) -fpp -debug all -g -traceback +FCFLAGS = -module $(MOD_DIR) -fpp -debug all -g -traceback -D IFORT TARGET = SimulationCore2 diff --git a/SimulationCore2 b/SimulationCore2 index 1c3db09..344be23 100644 Binary files a/SimulationCore2 and b/SimulationCore2 differ diff --git a/SimulationCore2.f90 b/SimulationCore2.f90 index be9557c..65bd2ab 100644 --- a/SimulationCore2.f90 +++ b/SimulationCore2.f90 @@ -1,41 +1,41 @@ -! SimulationCore2.f90 -! -! FUNCTIONS: -! SimulationCore2 - Entry point of console application. -! -!**************************************************************************** -! -! PROGRAM: SimulationCore2 -! -! PURPOSE: Entry point for the console application. -! -!**************************************************************************** - -program SimulationCore2 - - use Simulator - use RedisInterface - !use testRedisModule - implicit none - character(len=100) :: redis_host,redis_password, sim_id, temp - integer :: redis_port, log_level, stat - ! Variables - - ! Body of SimulationCore2 - ! print *, 'Hello World' - ! call read_variables() - if(command_argument_count()/=5) then - print *, "Simulator Program must have 5 parameter: redis_host,redisPort,redis_password, sim_id,log_level" - stop - endif - call get_command_argument(1, redis_host) - call get_command_argument(2, temp) - read(temp,*,iostat=stat) redis_port - call get_command_argument(3, redis_password) - call get_command_argument(4, sim_id) - call get_command_argument(5, temp) - read(temp,*,iostat=stat) log_level - - call simulate(trim(redis_host),redis_port,trim(redis_password), trim(sim_id),log_level) -end program SimulationCore2 - +! SimulationCore2.f90 +! +! FUNCTIONS: +! SimulationCore2 - Entry point of console application. +! +!**************************************************************************** +! +! PROGRAM: SimulationCore2 +! +! PURPOSE: Entry point for the console application. +! +!**************************************************************************** + +program SimulationCore2 + + use Simulator + use RedisInterface + !use testRedisModule + implicit none + character(len=100) :: redis_host,redis_password, sim_id, temp + integer :: redis_port, log_level, status + ! Variables + + ! Body of SimulationCore2 + ! print *, 'Hello World' + ! call read_variables() + if(command_argument_count()/=5) then + print *, "Simulator Program must have 5 parameter: redis_host,redisPort,redis_password, sim_id,log_level" + stop + endif + call get_command_argument(1, redis_host) + call get_command_argument(2, temp) + read(temp,*,iostat=status) redis_port + call get_command_argument(3, redis_password) + call get_command_argument(4, sim_id) + call get_command_argument(5, temp) + read(temp,*,iostat=status) log_level + + call simulate(trim(redis_host),redis_port,trim(redis_password), trim(sim_id),log_level) +end program SimulationCore2 + diff --git a/SimulationCore2.i90 b/SimulationCore2.i90 index b03ebb8..67efb73 100644 --- a/SimulationCore2.i90 +++ b/SimulationCore2.i90 @@ -19,7 +19,7 @@ program SimulationCore2 !use testRedisModule implicit none character(len=100) :: redis_host,redis_password, sim_id, temp - integer :: redis_port, log_level, stat + integer :: redis_port, log_level, status ! Variables ! Body of SimulationCore2 @@ -31,11 +31,11 @@ program SimulationCore2 endif call get_command_argument(1, redis_host) call get_command_argument(2, temp) - read(temp,*,iostat=stat) redis_port + read(temp,*,iostat=status) redis_port call get_command_argument(3, redis_password) call get_command_argument(4, sim_id) call get_command_argument(5, temp) - read(temp,*,iostat=stat) log_level + read(temp,*,iostat=status) log_level call simulate(trim(redis_host),redis_port,trim(redis_password), trim(sim_id),log_level) end program SimulationCore2 diff --git a/Simulator.f90 b/Simulator.f90 index 1829d28..242da80 100644 --- a/Simulator.f90 +++ b/Simulator.f90 @@ -1,4 +1,5 @@ module Simulator + use IFPORT use RedisInterface use Bop use PumpsMain @@ -67,7 +68,6 @@ module Simulator type(json_file) :: jsonfile type(json_core):: json integer :: simulationStatus,simulationSpeed,msPerStep,simulationEnd,simulationStep - integer,dimension(8)::timearray real :: stepTime !time for each step character(len=:),allocatable::redisInput,redisOutput enum, bind(c) @@ -79,10 +79,18 @@ module Simulator contains + FUNCTION time_ms() + INTEGER(8) :: time_ms + integer,dimension(8)::timearray + call date_and_time(values=timearray) + time_ms = timearray(8)+timearray(7)*1000 + timearray(6)*60000 + timearray(5)*60000*600000 +timearray(4)*24*60000*60000 + RETURN + END FUNCTION + subroutine Simulate(redis_host,redis_port,redis_password, sim_id,log_level) character(len=*) :: redis_host,redis_password, sim_id integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status,redis_port,log_level - integer,dimension(12)::t,t_modules + integer(8),dimension(12)::t,t_modules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! do i=1,size(t_modules) @@ -104,45 +112,41 @@ module Simulator simulationStep = 1 do while (.true.) ! print *,"simulationStep=",simulationStep - call date_and_time(values=timearray) - t0 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t0 = time_ms() ! print *,"start reading." call read_variables() if(simulationStatus==PLAY_TO_DETERMINED_TIME .and. simulationStep>simulationEnd) exit if(simulationStatus==STOP) exit - if(simulationStatus==PAUSE) cycle + if(simulationStatus==PAUSE) then + print *, "paused" + go to 211 + endif if(logging>4) print *,"end reading" - call date_and_time(values=timearray) - t1 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t1 = time_ms() t_read = t_read+t1-t0 if(logging>4) print *,"read completed" !! Rafiee, nothing changed call BopStack_Step() - call date_and_time(values=timearray) - t(1) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(1) = time_ms() t_modules(1) = t_modules(1)+t(1)-t1 !! Tarmigh, now is rewritten call Pump1_Step() - call date_and_time(values=timearray) - t(2) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(2) = time_ms() t_modules(2) = t_modules(2)+t(2)-t(1) !call Pump2_Step() !! Rafiee call ChokeControl_Step() - call date_and_time(values=timearray) - t(3) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(3) = time_ms() t_modules(3) = t_modules(3)+t(3)-t(2) !! Tarmigh, now is rewritten call RotaryTable_Step() - call date_and_time(values=timearray) - t(4) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(4) = time_ms() t_modules(4) = t_modules(4)+t(4)-t(3) !! Tarmigh, now is rewritten call Drawworks_Step() - call date_and_time(values=timearray) - t(5) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(5) = time_ms() t_modules(5) = t_modules(5)+t(5)-t(4) !! Rafiee @@ -154,37 +158,31 @@ module Simulator !! Rafiee call KillLine_Step() - call date_and_time(values=timearray) - t(6) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(6) = time_ms() t_modules(6) = t_modules(6)+t(6)-t(5) !! Rafiee call ChokeLine_Step() - call date_and_time(values=timearray) - t(7) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(7) = time_ms() t_modules(7) = t_modules(7)+t(7)-t(6) call BlindRams_Step() - call date_and_time(values=timearray) - t(8) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(8) = time_ms() t_modules(8) = t_modules(8)+t(8)-t(7) call Annular_Step() - call date_and_time(values=timearray) - t(9) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(9) = time_ms() t_modules(9) = t_modules(9)+t(9)-t(8) !!Tarmigh. Step must rewrittem call TopDrive_Step() - call date_and_time(values=timearray) - t(10) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(10) = time_ms() t_modules(10) = t_modules(10)+t(10)-t(9) ! call Geo_Step() !!Ahmadi call PathFinding_Step() - call date_and_time(values=timearray) - t(11) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(11) = time_ms() t_modules(11) = t_modules(11)+t(11)-t(10) !! Sheikh @@ -192,22 +190,25 @@ module Simulator !! Ahmadi call OperationScenarios_Step() !! Write variables to shared files - call date_and_time(values=timearray) - t2 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t2 = time_ms() ! stepTime = t2-t1 t_modules(12) = t_modules(12)+t2-t(11) t_exec = t_exec+t2-t1 ! call date_and_time(values=timearray) - ! t0 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + ! t0 = time_ms() call write_variables() - call date_and_time(values=timearray) - t3 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t3 = time_ms() + if(t3-t0 < 100) then + call sleepqq(t3-t0) + else + print *,"Simulation step can not be complete in 100 ms. step time=",t3-t0 + endif t_write = t_write+t3-t2 ! print *,"write completed" ! print *,"t=",t simulationStep = simulationStep + 1 - end do +211 end do ! call write_variables() ! call json%print(jsonroot,'test.json') ! call json%destroy(jsonroot) diff --git a/Simulator.i90 b/Simulator.i90 index 757f68c..e7d7a58 100644 --- a/Simulator.i90 +++ b/Simulator.i90 @@ -1,5 +1,6 @@ # 1 "/mnt/c/Projects/VSIM/SimulationCore2/Simulator.f90" module Simulator + use IFPORT use RedisInterface use Bop use PumpsMain @@ -68,7 +69,6 @@ module Simulator type(json_file) :: jsonfile type(json_core):: json integer :: simulationStatus,simulationSpeed,msPerStep,simulationEnd,simulationStep - integer,dimension(8)::timearray real :: stepTime !time for each step character(len=:),allocatable::redisInput,redisOutput enum, bind(c) @@ -80,10 +80,18 @@ module Simulator contains + FUNCTION time_ms() + INTEGER(8) :: time_ms + integer,dimension(8)::timearray + call date_and_time(values=timearray) + time_ms = timearray(8)+timearray(7)*1000 + timearray(6)*60000 + timearray(5)*60000*600000 +timearray(4)*24*60000*60000 + RETURN + END FUNCTION + subroutine Simulate(redis_host,redis_port,redis_password, sim_id,log_level) character(len=*) :: redis_host,redis_password, sim_id integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status,redis_port,log_level - integer,dimension(12)::t,t_modules + integer(8),dimension(12)::t,t_modules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! do i=1,size(t_modules) @@ -105,45 +113,41 @@ module Simulator simulationStep = 1 do while (.true.) ! print *,"simulationStep=",simulationStep - call date_and_time(values=timearray) - t0 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t0 = time_ms() ! print *,"start reading." call read_variables() if(simulationStatus==PLAY_TO_DETERMINED_TIME .and. simulationStep>simulationEnd) exit if(simulationStatus==STOP) exit - if(simulationStatus==PAUSE) cycle + if(simulationStatus==PAUSE) then + print *, "paused" + go to 211 + endif if(logging>4) print *,"end reading" - call date_and_time(values=timearray) - t1 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t1 = time_ms() t_read = t_read+t1-t0 if(logging>4) print *,"read completed" !! Rafiee, nothing changed call BopStack_Step() - call date_and_time(values=timearray) - t(1) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(1) = time_ms() t_modules(1) = t_modules(1)+t(1)-t1 !! Tarmigh, now is rewritten call Pump1_Step() - call date_and_time(values=timearray) - t(2) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(2) = time_ms() t_modules(2) = t_modules(2)+t(2)-t(1) !call Pump2_Step() !! Rafiee call ChokeControl_Step() - call date_and_time(values=timearray) - t(3) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(3) = time_ms() t_modules(3) = t_modules(3)+t(3)-t(2) !! Tarmigh, now is rewritten call RotaryTable_Step() - call date_and_time(values=timearray) - t(4) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(4) = time_ms() t_modules(4) = t_modules(4)+t(4)-t(3) !! Tarmigh, now is rewritten call Drawworks_Step() - call date_and_time(values=timearray) - t(5) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(5) = time_ms() t_modules(5) = t_modules(5)+t(5)-t(4) !! Rafiee @@ -155,37 +159,31 @@ module Simulator !! Rafiee call KillLine_Step() - call date_and_time(values=timearray) - t(6) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(6) = time_ms() t_modules(6) = t_modules(6)+t(6)-t(5) !! Rafiee call ChokeLine_Step() - call date_and_time(values=timearray) - t(7) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(7) = time_ms() t_modules(7) = t_modules(7)+t(7)-t(6) call BlindRams_Step() - call date_and_time(values=timearray) - t(8) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(8) = time_ms() t_modules(8) = t_modules(8)+t(8)-t(7) call Annular_Step() - call date_and_time(values=timearray) - t(9) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(9) = time_ms() t_modules(9) = t_modules(9)+t(9)-t(8) !!Tarmigh. Step must rewrittem call TopDrive_Step() - call date_and_time(values=timearray) - t(10) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(10) = time_ms() t_modules(10) = t_modules(10)+t(10)-t(9) ! call Geo_Step() !!Ahmadi call PathFinding_Step() - call date_and_time(values=timearray) - t(11) = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t(11) = time_ms() t_modules(11) = t_modules(11)+t(11)-t(10) !! Sheikh @@ -193,22 +191,25 @@ module Simulator !! Ahmadi call OperationScenarios_Step() !! Write variables to shared files - call date_and_time(values=timearray) - t2 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t2 = time_ms() ! stepTime = t2-t1 t_modules(12) = t_modules(12)+t2-t(11) t_exec = t_exec+t2-t1 ! call date_and_time(values=timearray) -! t0 = timearray(8)+timearray(7)*1000+timearray(6)*60000 +! t0 = time_ms() call write_variables() - call date_and_time(values=timearray) - t3 = timearray(8)+timearray(7)*1000+timearray(6)*60000 + t3 = time_ms() + if(t3-t0 < 100) then + call sleepqq(t3-t0) + else + print *,"Simulation step can not be complete in 100 ms. step time=",t3-t0 + endif t_write = t_write+t3-t2 ! print *,"write completed" ! print *,"t=",t simulationStep = simulationStep + 1 - end do +211 end do ! call write_variables() ! call json%print(jsonroot,'test.json') ! call json%destroy(jsonroot) diff --git a/redisContent.json b/redisContent.json index 8b42430..8f7bca7 100644 --- a/redisContent.json +++ b/redisContent.json @@ -1 +1 @@ -{"status":0,"speed":0,"endstep":0,"Configuration":{"StringConfiguration":{"StringConfigurationItems":[],"BitDefenition":{"BitCodeHundreds":0,"BitCodeOnes":0,"BitCodeTens":0,"BitLength":0.0,"BitNozzleNo":0,"BitNozzleSize":0.0,"BitSize":0.0,"BitType":0,"BitWeightPerLength":0.0,"FloatValve":false}},"Formations":[],"Reservoir":{"AutoMigrationRate":0.0,"FluidGradient":0.0,"FluidType":0,"FluidViscosity":0.0,"FormationNo":0,"FormationPermeability":0.0,"FormationTop":0.0,"GeothermalGradient":0.0,"InactiveInflux":false,"IsAutoMigrationRateSelected":false,"MakeKickSinglePacket":false,"PressureGradient":0.0},"Shoe":{"Breakdown":0.0,"FormationNo":0,"FracturePropagation":0.0,"InactiveFracture":false,"LeakOff":0.0,"ShoeDepth":0.0},"Accumulator":{"AccumulatorMinimumOperatingPressure":0.0,"AccumulatorSystemSize":0.0,"AirPlungerPumpOutput":0.0,"ElectricPumpOutput":0.0,"NumberOfBottels":0,"OilTankVolume":0.0,"PrechargePressure":0.0,"StartPressure":0.0,"StartPressure2":0.0,"StopPressure":0.0,"StopPressure2":0.0},"BopStack":{"AboveAnnularHeight":0.0,"AnnularPreventerClose":0.0,"AnnularPreventerHeight":0.0,"AnnularPreventerOpen":0.0,"AnnularStringDrag":0.0,"BlindRamClose":0.0,"BlindRamHeight":0.0,"BlindRamOpen":0.0,"ChokeClose":0.0,"ChokeLineId":0.0,"ChokeLineLength":0.0,"ChokeOpen":0.0,"GroundLevel":0.0,"KillClose":0.0,"KillHeight":0.0,"KillOpen":0.0,"LowerRamClose":0.0,"LowerRamHeight":0.0,"LowerRamOpen":0.0,"RamStringDrag":0.0,"UpperRamClose":0.0,"UpperRamHeight":0.0,"UpperRamOpen":0.0},"Hoisting":{"DrillingLineBreakingLoad":0.0,"DriveType":0,"KellyWeight":0.0,"NumberOfLine":0,"TopDriveWeight":0.0,"TravelingBlockWeight":0.0},"Power":{"CementPump":0.0,"Drawworks":0.0,"GeneratorPowerRating":0.0,"MudPump1":0.0,"MudPump2":0.0,"NumberOfgenerators":0,"RotaryTable":0.0,"TopDrive":0.0},"Pumps":{"MudPump1LinerDiameter":0.0,"MudPump1Stroke":0.0,"MudPump1MechanicalEfficiency":0.0,"MudPump1VolumetricEfficiency":0.0,"MudPump1Output":0.0,"MudPump1OutputBblStroke":0.0,"MudPump1Maximum":0.0,"MudPump1ReliefValvePressure":0.0,"MudPump2LinerDiameter":0.0,"MudPump2Stroke":0.0,"MudPump2MechanicalEfficiency":0.0,"MudPump2VolumetricEfficiency":0.0,"MudPump2Output":0.0,"MudPump2OutputBblStroke":0.0,"MudPump2Maximum":0.0,"MudPump2ReliefValvePressure":0.0,"CementPumpLinerDiameter":0.0,"CementPumpStroke":0.0,"CementPumpMechanicalEfficiency":0.0,"CementPumpVolumetricEfficiency":0.0,"CementPumpOutput":0.0,"CementPumpOutputBblStroke":0.0,"CementPumpMaximum":0.0,"CementPumpReliefValvePressure":0.0,"MudPump1ReliefValveIsSet":false,"MudPump2ReliefValveIsSet":false,"CementPumpReliefValveIsSet":false,"ManualPumpPower":false,"Valve1":false,"Valve2":false,"Valve3":false,"Valve4":false,"Valve5":false},"RigSize":{"RigType":0,"CrownHeight":0.0,"MonkeyBoandHeight":0.0,"RigFloorHeight":0.0},"CasingLinerChoke":{"CasingDepth":0.0,"CasingId":0.0,"CasingOd":0.0,"CasingWeight":0.0,"CasingCollapsePressure":0.0,"CasingTensileStrength":0.0,"LinerTopDepth":0.0,"LinerLength":0.0,"LinerId":0.0,"LinerOd":0.0,"LinerWeight":0.0,"LinerCollapsePressure":0.0,"LinerTensileStrength":0.0,"OpenHoleId":0.0,"OpenHoleLength":0.0},"Path":{"Items":[]},"Mud":{"ActiveMudType":0,"ActiveRheologyModel":0,"ActiveMudVolume":0.0,"ActiveMudVolumeGal":0.0,"ActiveDensity":0.0,"ActivePlasticViscosity":0.0,"ActiveYieldPoint":0.0,"ActiveThetaThreeHundred":0.0,"ActiveThetaSixHundred":0.0,"ReserveMudType":0,"ReserveMudVolume":0.0,"ReserveMudVolumeGal":0.0,"ReserveDensity":0.0,"ReservePlasticViscosity":0.0,"ReserveYieldPoint":0.0,"ReserveThetaThreeHundred":0.0,"ReserveThetaSixHundred":0.0,"ActiveTotalTankCapacity":0.0,"ActiveTotalTankCapacityGal":0.0,"ActiveSettledContents":0.0,"ActiveSettledContentsGal":0.0,"ActiveTotalContents":0.0,"ActiveTotalContentsGal":0.0,"ActiveAutoDensity":false,"InitialTripTankMudVolume":0.0,"InitialTripTankMudVolumeGal":0.0,"PedalFlowMeter":0.0}},"Problems":{"BitProblems":{"JetWashout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"PlugJets":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"JetWashoutCount":0,"PlugJetsCount":0},"BopProblems":{"AnnularWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AnnularFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AnnularLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"UpperRamWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"UpperRamFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"UpperRamLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MiddleRamWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MiddleRamFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MiddleRamLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"LowerRamWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"LowerRamFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"LowerRamLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorPumpFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorPumpLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorSystemFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorSystemLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"ChokeProblems":{"HydraulicChoke1Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke1Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke1Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke2Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke2Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke2Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke2Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke2Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke2Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ChokePanelAirFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1PluggedPercent":0,"HydraulicChoke2PluggedPercent":0,"HydraulicChoke1PluggedPercent":0,"ManualChoke2PluggedPercent":0},"DrillStemsProblems":{"StringDragIncrease":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StringTorqueIncrease":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StringTorqueFluctuation":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StringDragIncreaseTime":0.0,"StringTorqueIncreaseTime":0.0},"GaugesProblems":{"WeightIndicator":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RotaryRpm":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RotaryTorque":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StandPipePressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CasingPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump1Strokes":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump2Strokes":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ReturnLineTemperature":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"TripTank":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"PitGainLoss":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MudTankVolume":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ReturnMudFlow":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"TorqueLimit":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"PowerLimit":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManifoldPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AnnularPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RigAirPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StandPipe1":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StandPipe2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"DrillPipePressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ChokePosition":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CasingPressure2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"HoistingProblems":{"MotorFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ClutchEngage":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ClutchDisengage":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"KickProblems":{"Kick":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"FluidType":0,"FlowRate":0,"OverBalancePressure":0,"IsAutoMigrationRateSelected":false,"AutoMigrationRate":0.0},"LostProblems":{"LostCirculation":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"FlowRate":0.0},"MudTreatmentProblems":{"Degasser":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ShaleShaker":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Desander":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Desilter":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"OtherProblems":{"RigAlarm":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RigWaterSupply":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RigAir":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen1":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen3":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen4":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr1":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr3":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr4":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"PumpProblems":{"Pump1PowerFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump1BlowPopOffValve":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump2PowerFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump2BlowPopOffValve":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CementPumpPowerFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CementPumpBlowPopOffValve":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"RotaryProblems":{"MotorFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"OverideTorqueLimit":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}}},"Equipments":{"BopControl":{"ManifoldPressureGauge":0.0,"AirSupplyPressureGauge":0.0,"AccumulatorPressureGauge":0.0,"AnnularPressureGauge":0.0,"AnnularOpenLED":0,"AnnularCloseLED":0,"UpperRamsOpenLED":0,"UpperRamsCloseLED":0,"MiddleRamsOpenLED":0,"MiddleRamsCloseLED":0,"KillLineOpenLED":0,"KillLineCloseLED":0,"ChokeLineOpenLED":0,"ChokeLineCloseLED":0,"LowerRamsOpenLED":0,"LowerRamsCloseLED":0,"AnnularStatus":0.0,"UpperRamsStatus":0.0,"MiddleRamsStatus":0.0,"LowerRamsStatus":0.0},"ChokeControl":{"StandPipePressure":0.0,"CasingPressure":0.0,"ChokePosition":0.0,"ChokePanelSPMCounter":0.0,"ChokePanelTotalStrokeCounter":0.0,"Choke1LED":0,"Choke2LED":0,"ChokePanelRigAirSwitch":false,"ChokePanelStrokeResetSwitch":false,"ChokeControlLever":0.0},"ChokeManifold":{"HydraulicChock1":0,"HydraulicChock2":0,"HyChock1OnProblem":false,"HyChock2OnProblem":false,"LeftManChokeOnProblem":false,"RightManChokeOnProblem":false,"ChokeManifoldValve1":false,"ChokeManifoldValve2":false,"ChokeManifoldValve3":false,"ChokeManifoldValve4":false,"ChokeManifoldValve5":false,"ChokeManifoldValve6":false,"ChokeManifoldValve7":false,"ChokeManifoldValve8":false,"ChokeManifoldValve9":false,"ChokeManifoldValve10":false,"ChokeManifoldValve11":false,"ChokeManifoldValve12":false,"ChokeManifoldValve13":false,"LeftManualChoke":0.0,"RightManualChoke":0.0},"DataDisplay":{"WOBPointer":0.0,"HookLoadPointer":0.0,"TripTankGauge":0.0,"TripTankAlarmLED":0,"TripTankPumpLED":0,"StandPipePressureGauge":0.0,"CasingPressureGauge":0.0,"MP1SPMGauge":0.0,"MP2SPMGauge":0.0,"ReturnLineTempGauge":0.0,"RotaryTorqueGauge":0.0,"RotaryRPMGauge":0.0,"AcidGasDetectionLED":0,"TotalStrokeCounter":0.0,"PitGainLossGauge":0.0,"MudTanksVolumeGauge":0.0,"MVTAlarmLED":0,"ReturnMudFlowGauge":0.0,"FillStrokeCounter":0.0,"MFFITotalStrokeCounter":0.0,"MFFIAlarmLED":0,"MFFIPumpLED":0,"TotalWellDepth":0.0,"BitDepth":0.0,"HookLoad":0.0,"StandPipePressure":0.0,"CasingPressure":0.0,"MP1SPM":0.0,"MP2SPM":0.0,"RTTorque":0.0,"RTRPM":0.0,"WOP":0.0,"ROP":0.0,"MudWeightIn":0.0,"MudWeightOut":0.0,"Buzzer1":false,"Buzzer2":false,"Buzzer3":false,"Buzzer4":false},"Drilling":{"ParkingBrakeLed":false,"GEN1LED":0,"GEN2LED":0,"GEN3LED":0,"GEN4LED":0,"SCR1LED":0,"SCR2LED":0,"SCR3LED":0,"SCR4LED":0,"MP1BLWR":0,"MP2BLWR":0,"DWBLWR":0,"RTBLWR":0,"PWRLIM":0,"PWRLIMMTR":0.0,"RTTorqueLimitGauge":0.0,"AutoDWLED":0,"GEN1BTNLED":0,"GEN2BTNLED":0,"GEN3BTNLED":0,"GEN4BTNLED":0,"OpenKellyCockLed":0,"CloseKellyCockLed":0,"OpenSafetyValveLed":0,"CloseSafetyValveLed":0,"IRSafetyValveLed":0,"IRIBopLed":0,"LatchPipeLED":0,"UnlatchPipeLED":0,"SwingLed":0,"FillMouseHoleLed":0},"Hook":{"HookHeight_S":0.0,"HookHeight":0.0},"StandPipeManifold":{"StandPipeGauge1":0.0,"StandPipeGauge2":0.0,"StandPipeManifoldValve1":false,"StandPipeManifoldValve2":false,"StandPipeManifoldValve3":false,"StandPipeManifoldValve4":false,"StandPipeManifoldValve5":false,"StandPipeManifoldValve6":false,"StandPipeManifoldValve7":false,"StandPipeManifoldValve8":false,"StandPipeManifoldValve9":false,"StandPipeManifoldValve10":false,"StandPipeManifoldValve11":false,"StandPipeManifoldValve12":false,"StandPipeManifoldValve13":false,"StandPipeManifoldValve14":false,"StandPipeManifoldValve15":false},"DrillingWatch":{"Depth":0.0,"BitPosition":0.0,"HookLoad":0.0,"WeightOnBit":0.0,"RPM":0.0,"ROP":0.0,"Torque":0.0,"PumpPressure":0.0,"SPM1":0.0,"SPM2":0.0,"CasingPressure":0.0,"PercentFlow":0.0,"PitGainLose":0.0,"PitVolume":0.0,"KillMudVolume":0.0,"TripTankVolume":0.0,"MudWeightIn":0.0,"FillVolume":0.0,"MudWeightOut":0.0}}} +{"status":2,"speed":0,"endstep":0,"Configuration":{"StringConfiguration":{"StringConfigurationItems":[{"ComponentLength":3.0,"ComponentType":0,"Grade":null,"LengthPerJoint":4.0,"NominalId":50.0,"NominalOd":0.0,"NominalToolJointOd":0.0,"NumberOfJoint":5.0,"WeightPerLength":8.93},{"ComponentLength":3.0,"ComponentType":0,"Grade":null,"LengthPerJoint":4.0,"NominalId":50.0,"NominalOd":0.0,"NominalToolJointOd":0.0,"NumberOfJoint":5.0,"WeightPerLength":8.93}],"BitDefenition":{"BitCodeHundreds":0,"BitCodeOnes":2,"BitCodeTens":0,"BitLength":3.0,"BitNozzleNo":67,"BitNozzleSize":152.4,"BitSize":152.4,"BitType":0,"BitWeightPerLength":7.44,"FloatValve":true}},"Formations":[{"Abrasiveness":2.0,"Drillablity":5.0,"PorePressureGradient":158.34,"Thickness":3.0,"ThresholdWeight":6.0,"Top":4.0},{"Abrasiveness":4.0,"Drillablity":7.0,"PorePressureGradient":203.58,"Thickness":5.0,"ThresholdWeight":8.0,"Top":6.0}],"Reservoir":{"AutoMigrationRate":2.0,"FluidGradient":0.0,"FluidType":0,"FluidViscosity":0.0,"FormationNo":1,"FormationPermeability":3.0,"FormationTop":4.0,"GeothermalGradient":0.0,"InactiveInflux":false,"IsAutoMigrationRateSelected":false,"MakeKickSinglePacket":false,"PressureGradient":158.34},"Shoe":{"Breakdown":0.9,"FormationNo":2,"FracturePropagation":0.85,"InactiveFracture":false,"LeakOff":0.88,"ShoeDepth":5200.0},"Accumulator":{"AccumulatorMinimumOperatingPressure":1200.0,"AccumulatorSystemSize":10.0,"AirPlungerPumpOutput":10.0,"ElectricPumpOutput":12.0,"NumberOfBottels":20,"OilTankVolume":9.0,"PrechargePressure":1000.0,"StartPressure":2800.0,"StartPressure2":2600.0,"StopPressure":3000.0,"StopPressure2":2600.0},"BopStack":{"AboveAnnularHeight":10.0,"AnnularPreventerClose":0.64,"AnnularPreventerHeight":10.0,"AnnularPreventerOpen":0.48,"AnnularStringDrag":2.0,"BlindRamClose":1.27,"BlindRamHeight":16.24,"BlindRamOpen":1.11,"ChokeClose":1.59,"ChokeLineId":2800.0,"ChokeLineLength":12.0,"ChokeOpen":1.43,"GroundLevel":30.0,"KillClose":1.59,"KillHeight":18.8,"KillOpen":1.43,"LowerRamClose":1.91,"LowerRamHeight":21.35,"LowerRamOpen":1.75,"RamStringDrag":13.78948974609375,"UpperRamClose":0.95,"UpperRamHeight":14.632,"UpperRamOpen":0.79},"Hoisting":{"DrillingLineBreakingLoad":6.89,"DriveType":0,"KellyWeight":0.91,"NumberOfLine":1,"TopDriveWeight":1.36,"TravelingBlockWeight":0.0},"Power":{"CementPump":1600.0,"Drawworks":2000.0,"GeneratorPowerRating":1200.0,"MudPump1":1599.0,"MudPump2":1600.0,"NumberOfgenerators":4,"RotaryTable":6.0,"TopDrive":1000.0},"Pumps":{"MudPump1LinerDiameter":10.0,"MudPump1Stroke":12.0,"MudPump1MechanicalEfficiency":1.0,"MudPump1VolumetricEfficiency":80.0,"MudPump1Output":6.5008,"MudPump1OutputBblStroke":10.0,"MudPump1Maximum":12.0,"MudPump1ReliefValvePressure":0.9,"MudPump2LinerDiameter":10.0,"MudPump2Stroke":12.0,"MudPump2MechanicalEfficiency":1.0,"MudPump2VolumetricEfficiency":80.0,"MudPump2Output":6.5008,"MudPump2OutputBblStroke":10.0,"MudPump2Maximum":12.0,"MudPump2ReliefValvePressure":0.9,"CementPumpLinerDiameter":10.0,"CementPumpStroke":12.0,"CementPumpMechanicalEfficiency":1.0,"CementPumpVolumetricEfficiency":80.0,"CementPumpOutput":6.5008,"CementPumpOutputBblStroke":10.0,"CementPumpMaximum":12.0,"CementPumpReliefValvePressure":0.9,"MudPump1ReliefValveIsSet":false,"MudPump2ReliefValveIsSet":false,"CementPumpReliefValveIsSet":false,"ManualPumpPower":false,"Valve1":false,"Valve2":false,"Valve3":false,"Valve4":false,"Valve5":false},"RigSize":{"RigType":0,"CrownHeight":0.0,"MonkeyBoandHeight":0.0,"RigFloorHeight":0.0},"CasingLinerChoke":{"CasingDepth":1.0,"CasingId":50.8,"CasingOd":76.2,"CasingWeight":5.95,"CasingCollapsePressure":34.47,"CasingTensileStrength":2.72,"LinerTopDepth":7.0,"LinerLength":8.0,"LinerId":228.6,"LinerOd":254.0,"LinerWeight":8.0,"LinerCollapsePressure":82.74,"LinerTensileStrength":5.9,"OpenHoleId":381.0,"OpenHoleLength":14.0},"Path":{"Items":[{"HoleType":0,"Angle":0.0,"Length":10.0,"FinalAngle":0.0,"TotalLength":10.0,"MeasuredDepth":10.0,"TotalVerticalDepth":0.0},{"HoleType":1,"Angle":0.05,"Length":1.0,"FinalAngle":0.09,"TotalLength":1.0,"MeasuredDepth":19.52530436337984,"TotalVerticalDepth":10.0}]},"Mud":{"ActiveMudType":0,"ActiveRheologyModel":2,"ActiveMudVolume":0.32,"ActiveMudVolumeGal":13.44,"ActiveDensity":119.76048278808594,"ActivePlasticViscosity":0.0,"ActiveYieldPoint":0.0,"ActiveThetaThreeHundred":0.0,"ActiveThetaSixHundred":0.0,"ReserveMudType":0,"ReserveMudVolume":0.0,"ReserveMudVolumeGal":0.0,"ReserveDensity":0.0,"ReservePlasticViscosity":0.0,"ReserveYieldPoint":0.0,"ReserveThetaThreeHundred":0.0,"ReserveThetaSixHundred":0.0,"ActiveTotalTankCapacity":0.0,"ActiveTotalTankCapacityGal":0.0,"ActiveSettledContents":0.0,"ActiveSettledContentsGal":0.0,"ActiveTotalContents":0.0,"ActiveTotalContentsGal":0.0,"ActiveAutoDensity":false,"InitialTripTankMudVolume":0.0,"InitialTripTankMudVolumeGal":0.0,"PedalFlowMeter":1600.0}},"Problems":{"BitProblems":{"JetWashout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"PlugJets":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"JetWashoutCount":0,"PlugJetsCount":0},"BopProblems":{"AnnularWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AnnularFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AnnularLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"UpperRamWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"UpperRamFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"UpperRamLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MiddleRamWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MiddleRamFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MiddleRamLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"LowerRamWash":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"LowerRamFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"LowerRamLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorPumpFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorPumpLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorSystemFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorSystemLeak":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"ChokeProblems":{"HydraulicChoke1Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke1Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke1Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke2Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke2Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"HydraulicChoke2Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke2Plugged":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke2Fail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke2Washout":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ChokePanelAirFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManualChoke1PluggedPercent":0,"HydraulicChoke2PluggedPercent":0,"HydraulicChoke1PluggedPercent":0,"ManualChoke2PluggedPercent":0},"DrillStemsProblems":{"StringDragIncrease":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StringTorqueIncrease":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StringTorqueFluctuation":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StringDragIncreaseTime":0.0,"StringTorqueIncreaseTime":0.0},"GaugesProblems":{"WeightIndicator":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RotaryRpm":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RotaryTorque":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StandPipePressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CasingPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump1Strokes":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump2Strokes":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ReturnLineTemperature":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"TripTank":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"PitGainLoss":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"MudTankVolume":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ReturnMudFlow":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"TorqueLimit":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"PowerLimit":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AccumulatorPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ManifoldPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"AnnularPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RigAirPressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StandPipe1":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"StandPipe2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"DrillPipePressure":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ChokePosition":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CasingPressure2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"HoistingProblems":{"MotorFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ClutchEngage":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ClutchDisengage":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"KickProblems":{"Kick":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"FluidType":0,"FlowRate":0,"OverBalancePressure":0,"IsAutoMigrationRateSelected":false,"AutoMigrationRate":0.0},"LostProblems":{"LostCirculation":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"FlowRate":0.0},"MudTreatmentProblems":{"Degasser":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"ShaleShaker":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Desander":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Desilter":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"OtherProblems":{"RigAlarm":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RigWaterSupply":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"RigAir":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen1":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen3":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Gen4":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr1":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr2":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr3":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Scr4":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"PumpProblems":{"Pump1PowerFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump1BlowPopOffValve":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump2PowerFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"Pump2BlowPopOffValve":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CementPumpPowerFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"CementPumpBlowPopOffValve":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}},"RotaryProblems":{"MotorFail":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0},"OverideTorqueLimit":{"ProblemType":0,"StatusType":0,"Value":0.0,"DueValue":0.0}}},"Equipments":{"BopControl":{"ManifoldPressureGauge":0.0,"AirSupplyPressureGauge":0.0,"AccumulatorPressureGauge":0.0,"AnnularPressureGauge":0.0,"AnnularOpenLED":0,"AnnularCloseLED":0,"UpperRamsOpenLED":0,"UpperRamsCloseLED":0,"MiddleRamsOpenLED":0,"MiddleRamsCloseLED":0,"KillLineOpenLED":0,"KillLineCloseLED":0,"ChokeLineOpenLED":0,"ChokeLineCloseLED":0,"LowerRamsOpenLED":0,"LowerRamsCloseLED":0,"AnnularStatus":1.0,"UpperRamsStatus":0.0,"MiddleRamsStatus":0.0,"LowerRamsStatus":1.0},"ChokeControl":{"StandPipePressure":0.0,"CasingPressure":0.0,"ChokePosition":0.0,"ChokePanelSPMCounter":0.0,"ChokePanelTotalStrokeCounter":0.0,"Choke1LED":0,"Choke2LED":0,"ChokePanelRigAirSwitch":false,"ChokePanelStrokeResetSwitch":false,"ChokeControlLever":0.0},"ChokeManifold":{"HydraulicChock1":0,"HydraulicChock2":0,"HyChock1OnProblem":false,"HyChock2OnProblem":false,"LeftManChokeOnProblem":false,"RightManChokeOnProblem":false,"ChokeManifoldValve1":false,"ChokeManifoldValve2":false,"ChokeManifoldValve3":false,"ChokeManifoldValve4":false,"ChokeManifoldValve5":false,"ChokeManifoldValve6":false,"ChokeManifoldValve7":false,"ChokeManifoldValve8":false,"ChokeManifoldValve9":false,"ChokeManifoldValve10":false,"ChokeManifoldValve11":false,"ChokeManifoldValve12":false,"ChokeManifoldValve13":false,"LeftManualChoke":0.0,"RightManualChoke":0.0},"DataDisplay":{"WOBPointer":0.0,"HookLoadPointer":0.0,"TripTankGauge":0.0,"TripTankAlarmLED":0,"TripTankPumpLED":0,"StandPipePressureGauge":0.0,"CasingPressureGauge":0.0,"MP1SPMGauge":0.0,"MP2SPMGauge":0.0,"ReturnLineTempGauge":0.0,"RotaryTorqueGauge":0.0,"RotaryRPMGauge":0.0,"AcidGasDetectionLED":0,"TotalStrokeCounter":0.0,"PitGainLossGauge":0.0,"MudTanksVolumeGauge":0.0,"MVTAlarmLED":0,"ReturnMudFlowGauge":0.0,"FillStrokeCounter":0.0,"MFFITotalStrokeCounter":0.0,"MFFIAlarmLED":0,"MFFIPumpLED":0,"TotalWellDepth":0.0,"BitDepth":0.0,"HookLoad":0.0,"StandPipePressure":0.0,"CasingPressure":0.0,"MP1SPM":0.0,"MP2SPM":0.0,"RTTorque":0.0,"RTRPM":0.0,"WOP":0.0,"ROP":0.0,"MudWeightIn":0.0,"MudWeightOut":0.0,"Buzzer1":false,"Buzzer2":false,"Buzzer3":false,"Buzzer4":false},"Drilling":{"ParkingBrakeLed":false,"GEN1LED":0,"GEN2LED":0,"GEN3LED":0,"GEN4LED":0,"SCR1LED":0,"SCR2LED":0,"SCR3LED":0,"SCR4LED":0,"MP1BLWR":0,"MP2BLWR":0,"DWBLWR":0,"RTBLWR":0,"PWRLIM":0,"PWRLIMMTR":0.0,"RTTorqueLimitGauge":0.0,"AutoDWLED":0,"GEN1BTNLED":0,"GEN2BTNLED":0,"GEN3BTNLED":0,"GEN4BTNLED":0,"OpenKellyCockLed":0,"CloseKellyCockLed":0,"OpenSafetyValveLed":0,"CloseSafetyValveLed":0,"IRSafetyValveLed":0,"IRIBopLed":0,"LatchPipeLED":0,"UnlatchPipeLED":0,"SwingLed":0,"FillMouseHoleLed":0},"Hook":{"HookHeight_S":0.0,"HookHeight":0.0},"StandPipeManifold":{"StandPipeGauge1":0.0,"StandPipeGauge2":0.0,"StandPipeManifoldValve1":false,"StandPipeManifoldValve2":false,"StandPipeManifoldValve3":false,"StandPipeManifoldValve4":false,"StandPipeManifoldValve5":false,"StandPipeManifoldValve6":false,"StandPipeManifoldValve7":false,"StandPipeManifoldValve8":false,"StandPipeManifoldValve9":false,"StandPipeManifoldValve10":false,"StandPipeManifoldValve11":false,"StandPipeManifoldValve12":false,"StandPipeManifoldValve13":false,"StandPipeManifoldValve14":false,"StandPipeManifoldValve15":false},"DrillingWatch":{"Depth":0.0,"BitPosition":0.0,"HookLoad":0.0,"WeightOnBit":0.0,"RPM":0.0,"ROP":0.0,"Torque":0.0,"PumpPressure":0.0,"SPM1":0.0,"SPM2":0.0,"CasingPressure":0.0,"PercentFlow":0.0,"PitGainLose":0.0,"PitVolume":0.0,"KillMudVolume":0.0,"TripTankVolume":0.0,"MudWeightIn":0.0,"FillVolume":0.0,"MudWeightOut":0.0}}} diff --git a/simulatorManager.py b/simulatorManager.py index ea8dedb..ca0118d 100644 --- a/simulatorManager.py +++ b/simulatorManager.py @@ -35,12 +35,8 @@ if __name__=='__main__': break if not process_exists: subprocess.Popen(['./SimulationCore2', redis_address,str(redis_port),redis_password,simulation_id,str(log_level)], cwd=work_dir) - time.sleep(5) - - - # Connect to Redis server redis_host = 'localhost' # Replace with your Redis server's host redis_port = 6379 # Replace with your Redis server's port