diff --git a/CSharp/BasicInputs/Bha/CStringConfiguration.f90 b/CSharp/BasicInputs/Bha/CStringConfiguration.f90 index 53a6386..e32b18f 100644 --- a/CSharp/BasicInputs/Bha/CStringConfiguration.f90 +++ b/CSharp/BasicInputs/Bha/CStringConfiguration.f90 @@ -16,41 +16,41 @@ module CStringConfiguration type(CStringItem), intent(inout), target :: array(count) type(CBitInfo), intent(inout) :: bit type(CStringItem), pointer :: item - Configuration%StringConfiguration%BitDefinition%BitType = bit%BitType - Configuration%StringConfiguration%BitDefinition%BitSize = bit%BitSize - Configuration%StringConfiguration%BitDefinition%BitCodeHundreds = bit%BitCodeHundreds - Configuration%StringConfiguration%BitDefinition%BitCodeTens = bit%BitCodeTens - Configuration%StringConfiguration%BitDefinition%BitCodeOnes = bit%BitCodeOnes - Configuration%StringConfiguration%BitDefinition%BitNozzleSize = bit%BitNozzleSize - Configuration%StringConfiguration%BitDefinition%BitLength = bit%BitLength - Configuration%StringConfiguration%BitDefinition%BitWeightPerLength = bit%BitWeightPerLength - Configuration%StringConfiguration%BitDefinition%BitNozzleNo = bit%BitNozzleNo - Configuration%StringConfiguration%BitDefinition%FloatValve = bit%FloatValve - Configuration%StringConfiguration%StringConfigurationCount = count + data%Configuration%StringConfiguration%BitDefinition%BitType = bit%BitType + data%Configuration%StringConfiguration%BitDefinition%BitSize = bit%BitSize + data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds = bit%BitCodeHundreds + data%Configuration%StringConfiguration%BitDefinition%BitCodeTens = bit%BitCodeTens + data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes = bit%BitCodeOnes + data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize = bit%BitNozzleSize + data%Configuration%StringConfiguration%BitDefinition%BitLength = bit%BitLength + data%Configuration%StringConfiguration%BitDefinition%BitWeightPerLength = bit%BitWeightPerLength + data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo = bit%BitNozzleNo + data%Configuration%StringConfiguration%BitDefinition%FloatValve = bit%FloatValve + data%Configuration%StringConfiguration%StringConfigurationCount = count - if(Configuration%StringConfiguration%BitDefinition%FloatValve) then + if(data%Configuration%StringConfiguration%BitDefinition%FloatValve) then call InstallFloatValve() else call RemoveFloatValve() endif - if(size(Configuration%StringConfiguration%StringConfigurations) > 0) then - deallocate(Configuration%StringConfiguration%StringConfigurations) + if(size(data%Configuration%StringConfiguration%StringConfigurations) > 0) then + deallocate(data%Configuration%StringConfiguration%StringConfigurations) end if if(count > 0) then - allocate(Configuration%StringConfiguration%StringConfigurations(count)) + allocate(data%Configuration%StringConfiguration%StringConfigurations(count)) !j = count do i = 1, count item => array(i) - Configuration%StringConfiguration%StringConfigurations(i)%ComponentType = item%ComponentType - Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint = item%NumberOfJoint - Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint = item%LengthPerJoint - Configuration%StringConfiguration%StringConfigurations(i)%NominalOd = item%NominalOd - Configuration%StringConfiguration%StringConfigurations(i)%NominalId = item%NominalId - Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength = item%WeightPerLength - Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength = item%ComponentLength - Configuration%StringConfiguration%StringConfigurations(i)%NominalToolJointOd = item%NominalToolJointOd - Configuration%StringConfiguration%StringConfigurations(i)%Grade = item%Grade + data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType = item%ComponentType + data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint = item%NumberOfJoint + data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint = item%LengthPerJoint + data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd = item%NominalOd + data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId = item%NominalId + data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength = item%WeightPerLength + data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength = item%ComponentLength + data%Configuration%StringConfiguration%StringConfigurations(i)%NominalToolJointOd = item%NominalToolJointOd + data%Configuration%StringConfiguration%StringConfigurations(i)%Grade = item%Grade !print*, 'type=', StringConfigurations(i)%ComponentType !print*, 'NumberOfJoint=', StringConfigurations(i)%NumberOfJoint !print*, '-----------------------------------------------------------' diff --git a/CSharp/BasicInputs/Bha/CStringConfigurationVariables.f90 b/CSharp/BasicInputs/Bha/CStringConfigurationVariables.f90 index a991cba..e38c074 100644 --- a/CSharp/BasicInputs/Bha/CStringConfigurationVariables.f90 +++ b/CSharp/BasicInputs/Bha/CStringConfigurationVariables.f90 @@ -1,5 +1,5 @@ module CStringConfigurationVariables - ! use ConfigurationVariables, only: Configuration + ! !@use ConfigurationVariables, only: Configuration implicit none public !constants diff --git a/CSharp/BasicInputs/Geology/CFormation.f90 b/CSharp/BasicInputs/Geology/CFormation.f90 index 23c78ef..d1d0164 100644 --- a/CSharp/BasicInputs/Geology/CFormation.f90 +++ b/CSharp/BasicInputs/Geology/CFormation.f90 @@ -12,20 +12,20 @@ module CFormation integer :: i type(CFormationItem), intent(inout), target :: array(count) type(CFormationItem), pointer :: item - Configuration%Formation%Count = count - if(size(Configuration%Formation%Formations) > 0) then - deallocate(Configuration%Formation%Formations) + data%Configuration%Formation%Count = count + if(size(data%Configuration%Formation%Formations) > 0) then + deallocate(data%Configuration%Formation%Formations) end if if(count > 0) then - allocate(Configuration%Formation%Formations(count)) + allocate(data%Configuration%Formation%Formations(count)) do i = 1, count item => array(i) - Configuration%Formation%Formations(i)%Top = item%Top - Configuration%Formation%Formations(i)%Thickness = item%Thickness - Configuration%Formation%Formations(i)%Drillablity = item%Drillablity - Configuration%Formation%Formations(i)%Abrasiveness = item%Abrasiveness - Configuration%Formation%Formations(i)%ThresholdWeight = item%ThresholdWeight - Configuration%Formation%Formations(i)%PorePressureGradient = item%PorePressureGradient + data%Configuration%Formation%Formations(i)%Top = item%Top + data%Configuration%Formation%Formations(i)%Thickness = item%Thickness + data%Configuration%Formation%Formations(i)%Drillablity = item%Drillablity + data%Configuration%Formation%Formations(i)%Abrasiveness = item%Abrasiveness + data%Configuration%Formation%Formations(i)%ThresholdWeight = item%ThresholdWeight + data%Configuration%Formation%Formations(i)%PorePressureGradient = item%PorePressureGradient !print*, "===========================" !print*, "Formations(", i, ")%Top=", Formations(i)%Top !print*, "Formations(",i,")%Thickness", Formations(i)%Thickness diff --git a/CSharp/BasicInputs/Geology/CFormationVariables.f90 b/CSharp/BasicInputs/Geology/CFormationVariables.f90 index d6d11b2..abfb91f 100644 --- a/CSharp/BasicInputs/Geology/CFormationVariables.f90 +++ b/CSharp/BasicInputs/Geology/CFormationVariables.f90 @@ -1,5 +1,5 @@ module CFormationVariables - ! use ConfigurationVariables, only: Configuration + ! !@use ConfigurationVariables, only: Configuration implicit none public diff --git a/CSharp/BasicInputs/RigSpecifications/CHoisting.f90 b/CSharp/BasicInputs/RigSpecifications/CHoisting.f90 index 71f5eff..84f8ba8 100644 --- a/CSharp/BasicInputs/RigSpecifications/CHoisting.f90 +++ b/CSharp/BasicInputs/RigSpecifications/CHoisting.f90 @@ -1,76 +1,8 @@ module CHoisting use CHoistingVariables - implicit none + use ConfigurationVariables + use ConfigurationVariables + implicit none public - contains - subroutine SetDriveType(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetDriveType - !DEC$ ATTRIBUTES ALIAS: 'SetDriveType' :: SetDriveType - use CManifolds - use NotificationVariables, only: Set_IrSafetyValveLed - implicit none - integer, intent(in) :: v - Hoisting%DriveType = v -#ifdef deb - print*, 'DriveType=', Hoisting%DriveType -#endif - if(v == TopDrive_DriveType) then ! top drive mode - call RemoveKellyCock() - call InstallTopDriveIBop() - - call RemoveSafetyValve_TripMode() - call RemoveSafetyValve_KellyMode() - call Set_IrSafetyValveLed(.false.) - - endif - - if(v == Kelly_DriveType) then ! kelly mode - call RemoveTopDriveIBop() - call InstallKellyCock() - endif - - end subroutine - - subroutine SetTravelingBlockWeight(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTravelingBlockWeight - !DEC$ ATTRIBUTES ALIAS: 'SetTravelingBlockWeight' :: SetTravelingBlockWeight - implicit none - real*8, intent(in) :: v - Hoisting%TravelingBlockWeight = v - end subroutine - - subroutine SetTopDriveWeight(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTopDriveWeight - !DEC$ ATTRIBUTES ALIAS: 'SetTopDriveWeight' :: SetTopDriveWeight - implicit none - real*8, intent(in) :: v - Hoisting%TopDriveWeight = v - end subroutine - - subroutine SetKellyWeight(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetKellyWeight - !DEC$ ATTRIBUTES ALIAS: 'SetKellyWeight' :: SetKellyWeight - implicit none - real*8, intent(in) :: v - Hoisting%KellyWeight = v - end subroutine - - subroutine SetNumberOfLine(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetNumberOfLine - !DEC$ ATTRIBUTES ALIAS: 'SetNumberOfLine' :: SetNumberOfLine - implicit none - integer, intent(in) :: v - Hoisting%NumberOfLine = v -#ifdef deb - print*, 'NumberOfLine=', Hoisting%NumberOfLine -#endif - end subroutine - - subroutine SetDrillingLineBreakingLoad(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetDrillingLineBreakingLoad - !DEC$ ATTRIBUTES ALIAS: 'SetDrillingLineBreakingLoad' :: SetDrillingLineBreakingLoad - implicit none - real*8, intent(in) :: v - Hoisting%DrillingLineBreakingLoad = v - end subroutine + contains end module CHoisting \ No newline at end of file diff --git a/CSharp/BasicInputs/RigSpecifications/CHoistingVariables.f90 b/CSharp/BasicInputs/RigSpecifications/CHoistingVariables.f90 index 3f9fa20..c7e22a8 100644 --- a/CSharp/BasicInputs/RigSpecifications/CHoistingVariables.f90 +++ b/CSharp/BasicInputs/RigSpecifications/CHoistingVariables.f90 @@ -1,5 +1,5 @@ module CHoistingVariables - implicit none + implicit none public !constants integer :: TopDrive_DriveType = 0 @@ -15,5 +15,4 @@ module CHoistingVariables integer :: NumberOfLine real(8) :: DrillingLineBreakingLoad End type HoistingType - Type(HoistingType)::Hoisting end module CHoistingVariables \ No newline at end of file diff --git a/CSharp/BasicInputs/RigSpecifications/CPumps.f90 b/CSharp/BasicInputs/RigSpecifications/CPumps.f90 index 75408c4..e1edead 100644 --- a/CSharp/BasicInputs/RigSpecifications/CPumps.f90 +++ b/CSharp/BasicInputs/RigSpecifications/CPumps.f90 @@ -1,381 +1,150 @@ module CPumps use CPumpsVariables + ! use CPumps use CManifolds use CLog4 implicit none public - contains - subroutine SetMudPump1LinerDiameter(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1LinerDiameter - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1LinerDiameter' :: SetMudPump1LinerDiameter - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1LinerDiameter = v - call CalcPump1OutputBblStroke() -#ifdef deb - call Log_4( 'MudPump1LinerDiameter=', PumpsSpecification%MudPump1LinerDiameter) -#endif - end subroutine - - subroutine SetMudPump1Stroke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1Stroke - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1Stroke' :: SetMudPump1Stroke - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1Stroke = v - !call CalcMudPump1LinerDiameter() - call CalcPump1OutputBblStroke() -#ifdef deb - call Log_4( 'MudPump1Stroke=', v) -#endif - end subroutine - - subroutine SetMudPump1MechanicalEfficiency(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1MechanicalEfficiency - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1MechanicalEfficiency' :: SetMudPump1MechanicalEfficiency - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1MechanicalEfficiency = v - end subroutine - - subroutine SetMudPump1VolumetricEfficiency(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1VolumetricEfficiency - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1VolumetricEfficiency' :: SetMudPump1VolumetricEfficiency - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1VolumetricEfficiency = v - !call CalcMudPump1LinerDiameter() - call CalcPump1OutputBblStroke() -#ifdef deb - call Log_4( 'MudPump1VolumetricEfficiency=', PumpsSpecification%MudPump1VolumetricEfficiency) -#endif - end subroutine - - subroutine SetMudPump1Output(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1Output - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1Output' :: SetMudPump1Output - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1Output = v -#ifdef deb - print*, 'MudPump1Output=', PumpsSpecification%MudPump1Output -#endif - end subroutine - - subroutine SetMudPump1OutputBblStroke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1OutputBblStroke - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1OutputBblStroke' :: SetMudPump1OutputBblStroke - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1OutputBblStroke = v - call CalcMudPump1LinerDiameter() -#ifdef deb - print*, 'MudPump1OutputBblStroke=', PumpsSpecification%MudPump1OutputBblStroke -#endif - end subroutine - - subroutine SetMudPump1Maximum(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1Maximum - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1Maximum' :: SetMudPump1Maximum - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1Maximum = v - end subroutine - - subroutine SetMudPump1ReliefValvePressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1ReliefValvePressure - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1ReliefValvePressure' :: SetMudPump1ReliefValvePressure - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump1ReliefValvePressure = v - end subroutine - - - - subroutine SetMudPump2LinerDiameter(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2LinerDiameter - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2LinerDiameter' :: SetMudPump2LinerDiameter - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2LinerDiameter = v - call CalcPump2OutputBblStroke() -#ifdef deb - call Log_4( 'MudPump2LinerDiameter=', PumpsSpecification%MudPump2LinerDiameter) -#endif - end subroutine - - subroutine SetMudPump2Stroke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2Stroke - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2Stroke' :: SetMudPump2Stroke - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2Stroke = v - !call CalcMudPump2LinerDiameter() - call CalcPump2OutputBblStroke() -#ifdef deb - call Log_4( 'MudPump2Stroke=', PumpsSpecification%MudPump2Stroke) -#endif - end subroutine - - subroutine SetMudPump2MechanicalEfficiency(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2MechanicalEfficiency - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2MechanicalEfficiency' :: SetMudPump2MechanicalEfficiency - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2MechanicalEfficiency = v - end subroutine - - subroutine SetMudPump2VolumetricEfficiency(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2VolumetricEfficiency - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2VolumetricEfficiency' :: SetMudPump2VolumetricEfficiency - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2VolumetricEfficiency = v - !call CalcMudPump2LinerDiameter() - call CalcPump2OutputBblStroke() -#ifdef deb - call Log_4( 'MudPump2VolumetricEfficiency=', PumpsSpecification%MudPump2VolumetricEfficiency) -#endif - end subroutine - - subroutine SetMudPump2Output(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2Output - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2Output' :: SetMudPump2Output - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2Output = v -#ifdef deb - print*, 'MudPump2Output=', PumpsSpecification%MudPump2Output -#endif - end subroutine - - subroutine SetMudPump2OutputBblStroke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2OutputBblStroke - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2OutputBblStroke' :: SetMudPump2OutputBblStroke - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2OutputBblStroke = v - call CalcMudPump2LinerDiameter() -#ifdef deb - print*, 'MudPump2OutputBblStroke=', PumpsSpecification%MudPump2OutputBblStroke -#endif - end subroutine - - subroutine SetMudPump2Maximum(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2Maximum - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2Maximum' :: SetMudPump2Maximum - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2Maximum = v - end subroutine - - subroutine SetMudPump2ReliefValvePressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2ReliefValvePressure - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2ReliefValvePressure' :: SetMudPump2ReliefValvePressure - implicit none - real*8, intent(in) :: v - PumpsSpecification%MudPump2ReliefValvePressure = v - end subroutine - - - - subroutine SetCementPumpLinerDiameter(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpLinerDiameter - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpLinerDiameter' :: SetCementPumpLinerDiameter - implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpLinerDiameter = v - call CalcPump3OutputBblStroke() -#ifdef deb - call Log_4( 'CementPumpLinerDiameter=', PumpsSpecification%CementPumpLinerDiameter) -#endif - end subroutine + contains - subroutine SetCementPumpStroke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpStroke - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpStroke' :: SetCementPumpStroke + subroutine OpenPump1() + use CManifolds implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpStroke = v - !call CalcMudPump3LinerDiameter() - call CalcPump3OutputBblStroke() -#ifdef deb - call Log_4( 'CementPumpStroke=', PumpsSpecification%CementPumpStroke) -#endif + call ChangeValve(16, .true.) end subroutine - - subroutine SetCementPumpMechanicalEfficiency(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpMechanicalEfficiency - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpMechanicalEfficiency' :: SetCementPumpMechanicalEfficiency + + subroutine ClosePump1() + use CManifolds implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpMechanicalEfficiency = v + call ChangeValve(16, .false.) end subroutine - - subroutine SetCementPumpVolumetricEfficiency(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpVolumetricEfficiency - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpVolumetricEfficiency' :: SetCementPumpVolumetricEfficiency + + subroutine OpenPump2() + use CManifolds implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpVolumetricEfficiency = v - !call CalcMudPump3LinerDiameter() - call CalcPump3OutputBblStroke() -#ifdef deb - call Log_4( 'CementPumpVolumetricEfficiency=', PumpsSpecification%CementPumpVolumetricEfficiency) -#endif + call ChangeValve(17, .true.) end subroutine - - subroutine SetCementPumpOutput(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpOutput - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpOutput' :: SetCementPumpOutput + + subroutine ClosePump2() + use CManifolds implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpOutput = v -#ifdef deb - print*, 'CementPumpOutput=', PumpsSpecification%CementPumpOutput -#endif + call ChangeValve(17, .false.) end subroutine - - subroutine SetCementPumpOutputBblStroke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpOutputBblStroke - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpOutputBblStroke' :: SetCementPumpOutputBblStroke - implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpOutputBblStroke = v - call CalcMudPump3LinerDiameter() -#ifdef deb - print*, 'CementPumpOutputBblStroke=', PumpsSpecification%CementPumpOutputBblStroke -#endif - end subroutine - - subroutine SetCementPumpMaximum(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpMaximum - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpMaximum' :: SetCementPumpMaximum + + + subroutine OpenCementPump() + use CManifolds implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpMaximum = v + call ChangeValve(18, .true.) end subroutine - - subroutine SetCementPumpReliefValvePressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpReliefValvePressure - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpReliefValvePressure' :: SetCementPumpReliefValvePressure + + subroutine CloseCementPump() + use CManifolds implicit none - real*8, intent(in) :: v - PumpsSpecification%CementPumpReliefValvePressure = v - end subroutine - - subroutine SetMudPump1ReliefValveIsSet(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump1ReliefValveIsSet - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump1ReliefValveIsSet' :: SetMudPump1ReliefValveIsSet - implicit none - logical, intent(in) :: v - if (PumpsSpecification%MudPump1ReliefValveIsSet == v) return - PumpsSpecification%MudPump1ReliefValveIsSet = v -#ifdef deb - print*, 'MudPump1ReliefValveIsSet=', PumpsSpecification%MudPump1ReliefValveIsSet -#endif - end subroutine - - subroutine SetMudPump2ReliefValveIsSet(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudPump2ReliefValveIsSet - !DEC$ ATTRIBUTES ALIAS: 'SetMudPump2ReliefValveIsSet' :: SetMudPump2ReliefValveIsSet - implicit none - logical, intent(in) :: v - if (PumpsSpecification%MudPump2ReliefValveIsSet == v) return - PumpsSpecification%MudPump2ReliefValveIsSet = v -#ifdef deb - print*, 'MudPump2ReliefValveIsSet=', PumpsSpecification%MudPump2ReliefValveIsSet -#endif - end subroutine - - subroutine SetCementPumpReliefValveIsSet(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpReliefValveIsSet - !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpReliefValveIsSet' :: SetCementPumpReliefValveIsSet - implicit none - logical, intent(in) :: v - if (PumpsSpecification%CementPumpReliefValveIsSet == v) return - PumpsSpecification%CementPumpReliefValveIsSet = v -#ifdef deb - print*, 'CementPumpReliefValveIsSet=', PumpsSpecification%CementPumpReliefValveIsSet -#endif - end subroutine - - - - - - - subroutine SetManualPumpPower(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualPumpPower - !DEC$ ATTRIBUTES ALIAS: 'SetManualPumpPower' :: SetManualPumpPower - implicit none - logical, intent(in) :: v - PumpsSpecification%ManualPumpPower = v - call ChangeValve(23, v) -#ifdef deb - print*, 'ManualPumpPower=', PumpsSpecification%ManualPumpPower -#endif + call ChangeValve(18, .false.) end subroutine - subroutine SetValve1(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve1 - !DEC$ ATTRIBUTES ALIAS: 'SetValve1' :: SetValve1 - implicit none - logical, intent(in) :: v - PumpsSpecification%Valve1 = v - call ChangeValve(22, v) -#ifdef deb - print*, 'Valve1=', PumpsSpecification%Valve1 -#endif + subroutine SetMudPump1LinerDiameterN(a) + implicit none + real(8) :: a + if(associated(MudPump1LinerDiameterPtr)) call MudPump1LinerDiameterPtr(a) + end subroutine + + subroutine SetMudPump2LinerDiameterN(a) + implicit none + real(8) :: a + if(associated(MudPump2LinerDiameterPtr)) call MudPump2LinerDiameterPtr(a) + end subroutine + + subroutine SetMudPump3LinerDiameterN(a) + implicit none + real(8) :: a + if(associated(MudPump3LinerDiameterPtr)) call MudPump3LinerDiameterPtr(a) + end subroutine + + + + subroutine SetMudPump1OutputBblStrokeN(a) + implicit none + real(8) :: a + if(associated(MudPump1OutputBblStrokePtr)) call MudPump1OutputBblStrokePtr(a) + end subroutine + + subroutine SetMudPump2OutputBblStrokeN(a) + implicit none + real(8) :: a + if(associated(MudPump2OutputBblStrokePtr)) call MudPump2OutputBblStrokePtr(a) + end subroutine + + subroutine SetMudPump3OutputBblStrokeN(a) + implicit none + real(8) :: a + if(associated(MudPump3OutputBblStrokePtr)) call MudPump3OutputBblStrokePtr(a) + end subroutine + + + + + subroutine CalcMudPump1LinerDiameter() + use, intrinsic :: IEEE_ARITHMETIC + implicit none + real(8) :: a + a = (MathPI / 4.d0) * PumpsSpecification%MudPump1Stroke * 3.0d0 * PumpsSpecification%MudPump1VolumetricEfficiency / 9702.03d0 + a = dsqrt(PumpsSpecification%MudPump1OutputBblStroke / a) + if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then + PumpsSpecification%MudPump1LinerDiameter = 0.0 + else + PumpsSpecification%MudPump1LinerDiameter = a + endif + call SetMudPump1LinerDiameterN(PumpsSpecification%MudPump1LinerDiameter) + end subroutine + + subroutine CalcMudPump2LinerDiameter() + use, intrinsic :: IEEE_ARITHMETIC + implicit none + real(8) :: a + a = (MathPI / 4.d0) * PumpsSpecification%MudPump2Stroke * 3.0d0 * PumpsSpecification%MudPump2VolumetricEfficiency / 9702.03d0 + a = dsqrt(PumpsSpecification%MudPump2OutputBblStroke / a) + if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then + PumpsSpecification%MudPump2LinerDiameter = 0.0 + else + PumpsSpecification%MudPump2LinerDiameter = a + endif + call SetMudPump2LinerDiameterN(PumpsSpecification%MudPump2LinerDiameter) + end subroutine + + subroutine CalcMudPump3LinerDiameter() + use, intrinsic :: IEEE_ARITHMETIC + implicit none + real(8) :: a + a = (MathPI / 4.d0) * PumpsSpecification%CementPumpStroke * 3.0d0 * PumpsSpecification%CementPumpVolumetricEfficiency / 9702.03d0 + a = dsqrt(PumpsSpecification%CementPumpOutputBblStroke / a) + if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then + PumpsSpecification%CementPumpLinerDiameter = 0.0 + else + PumpsSpecification%CementPumpLinerDiameter = a + endif + call SetMudPump3LinerDiameterN(PumpsSpecification%CementPumpLinerDiameter) + end subroutine + + + + subroutine CalcPump1OutputBblStroke() + implicit none + PumpsSpecification%MudPump1OutputBblStroke = (MathPI / 4.d0) * (PumpsSpecification%MudPump1LinerDiameter**2) * PumpsSpecification%MudPump1Stroke * 3.0d0 * PumpsSpecification%MudPump1VolumetricEfficiency / 9702.03d0 + call SetMudPump1OutputBblStrokeN(PumpsSpecification%MudPump1OutputBblStroke) + end subroutine + + subroutine CalcPump2OutputBblStroke() + implicit none + PumpsSpecification%MudPump2OutputBblStroke = (MathPI / 4.d0) * (PumpsSpecification%MudPump2LinerDiameter**2) * PumpsSpecification%MudPump2Stroke * 3.0d0 * PumpsSpecification%MudPump2VolumetricEfficiency / 9702.03d0 + call SetMudPump2OutputBblStrokeN(PumpsSpecification%MudPump2OutputBblStroke) + end subroutine + + subroutine CalcPump3OutputBblStroke() + implicit none + PumpsSpecification%CementPumpOutputBblStroke = (MathPI / 4.d0) * (PumpsSpecification%CementPumpLinerDiameter**2) * PumpsSpecification%CementPumpStroke * 3.0d0 * PumpsSpecification%CementPumpVolumetricEfficiency / 9702.03d0 + call SetMudPump3OutputBblStrokeN(PumpsSpecification%CementPumpOutputBblStroke) end subroutine - - subroutine SetValve2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve2 - !DEC$ ATTRIBUTES ALIAS: 'SetValve2' :: SetValve2 - implicit none - logical, intent(in) :: v - PumpsSpecification%Valve2 = v - call ChangeValve(19, v) -#ifdef deb - print*, 'Valve2=', PumpsSpecification%Valve2 -#endif - end subroutine - - subroutine SetValve3(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve3 - !DEC$ ATTRIBUTES ALIAS: 'SetValve3' :: SetValve3 - implicit none - logical, intent(in) :: v - PumpsSpecification%Valve3 = v - call ChangeValve(21, v) -#ifdef deb - print*, 'Valve3=', PumpsSpecification%Valve3 -#endif - end subroutine - - subroutine SetValve4(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve4 - !DEC$ ATTRIBUTES ALIAS: 'SetValve4' :: SetValve4 - implicit none - logical, intent(in) :: v - PumpsSpecification%Valve4 = v - call ChangeValve(20, v) -#ifdef deb - print*, 'Valve4=', PumpsSpecification%Valve4 -#endif - end subroutine - - subroutine SetValve5(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve5 - !DEC$ ATTRIBUTES ALIAS: 'SetValve5' :: SetValve5 - implicit none - logical, intent(in) :: v - PumpsSpecification%Valve5 = v - call ChangeValve(24, v) -#ifdef deb - print*, 'Valve5=', PumpsSpecification%Valve5 -#endif - end subroutine - end module CPumps \ No newline at end of file diff --git a/CSharp/BasicInputs/RigSpecifications/CPumpsVariables.f90 b/CSharp/BasicInputs/RigSpecifications/CPumpsVariables.f90 index 1511cdc..5933596 100644 --- a/CSharp/BasicInputs/RigSpecifications/CPumpsVariables.f90 +++ b/CSharp/BasicInputs/RigSpecifications/CPumpsVariables.f90 @@ -56,208 +56,5 @@ module CPumpsVariables real(8) :: MathPI = 3.14159265358979d0 - contains - - - subroutine OpenPump1() - use CManifolds - implicit none - call ChangeValve(16, .true.) - end subroutine - - subroutine ClosePump1() - use CManifolds - implicit none - call ChangeValve(16, .false.) - end subroutine - - subroutine OpenPump2() - use CManifolds - implicit none - call ChangeValve(17, .true.) - end subroutine - - subroutine ClosePump2() - use CManifolds - implicit none - call ChangeValve(17, .false.) - end subroutine - - - subroutine OpenCementPump() - use CManifolds - implicit none - call ChangeValve(18, .true.) - end subroutine - - subroutine CloseCementPump() - use CManifolds - implicit none - call ChangeValve(18, .false.) - end subroutine - - - - - - - - - - subroutine SubscribeMudPump1LinerDiameter(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMudPump1LinerDiameter - !DEC$ ATTRIBUTES ALIAS: 'SubscribeMudPump1LinerDiameter' :: SubscribeMudPump1LinerDiameter - implicit none - procedure (ActionDouble) :: a - MudPump1LinerDiameterPtr => a - end subroutine - - subroutine SubscribeMudPump2LinerDiameter(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMudPump2LinerDiameter - !DEC$ ATTRIBUTES ALIAS: 'SubscribeMudPump2LinerDiameter' :: SubscribeMudPump2LinerDiameter - implicit none - procedure (ActionDouble) :: a - MudPump2LinerDiameterPtr => a - end subroutine - - subroutine SubscribeMudPump3LinerDiameter(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMudPump3LinerDiameter - !DEC$ ATTRIBUTES ALIAS: 'SubscribeMudPump3LinerDiameter' :: SubscribeMudPump3LinerDiameter - implicit none - procedure (ActionDouble) :: a - MudPump3LinerDiameterPtr => a - end subroutine - - - - subroutine SubscribeMudPump1OutputBblStroke(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMudPump1OutputBblStroke - !DEC$ ATTRIBUTES ALIAS: 'SubscribeMudPump1OutputBblStroke' :: SubscribeMudPump1OutputBblStroke - implicit none - procedure (ActionDouble) :: a - MudPump1OutputBblStrokePtr => a - end subroutine - - subroutine SubscribeMudPump2OutputBblStroke(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMudPump2OutputBblStroke - !DEC$ ATTRIBUTES ALIAS: 'SubscribeMudPump2OutputBblStroke' :: SubscribeMudPump2OutputBblStroke - implicit none - procedure (ActionDouble) :: a - MudPump2OutputBblStrokePtr => a - end subroutine - - subroutine SubscribeMudPump3OutputBblStroke(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMudPump3OutputBblStroke - !DEC$ ATTRIBUTES ALIAS: 'SubscribeMudPump3OutputBblStroke' :: SubscribeMudPump3OutputBblStroke - implicit none - procedure (ActionDouble) :: a - MudPump3OutputBblStrokePtr => a - end subroutine - - - - - subroutine SetMudPump1LinerDiameterN(a) - implicit none - real(8) :: a - if(associated(MudPump1LinerDiameterPtr)) call MudPump1LinerDiameterPtr(a) - end subroutine - - subroutine SetMudPump2LinerDiameterN(a) - implicit none - real(8) :: a - if(associated(MudPump2LinerDiameterPtr)) call MudPump2LinerDiameterPtr(a) - end subroutine - - subroutine SetMudPump3LinerDiameterN(a) - implicit none - real(8) :: a - if(associated(MudPump3LinerDiameterPtr)) call MudPump3LinerDiameterPtr(a) - end subroutine - - - - subroutine SetMudPump1OutputBblStrokeN(a) - implicit none - real(8) :: a - if(associated(MudPump1OutputBblStrokePtr)) call MudPump1OutputBblStrokePtr(a) - end subroutine - - subroutine SetMudPump2OutputBblStrokeN(a) - implicit none - real(8) :: a - if(associated(MudPump2OutputBblStrokePtr)) call MudPump2OutputBblStrokePtr(a) - end subroutine - - subroutine SetMudPump3OutputBblStrokeN(a) - implicit none - real(8) :: a - if(associated(MudPump3OutputBblStrokePtr)) call MudPump3OutputBblStrokePtr(a) - end subroutine - - - - - subroutine CalcMudPump1LinerDiameter() - use, intrinsic :: IEEE_ARITHMETIC - implicit none - real(8) :: a - a = (MathPI / 4.d0) * PumpsSpecification%MudPump1Stroke * 3.0d0 * PumpsSpecification%MudPump1VolumetricEfficiency / 9702.03d0 - a = dsqrt(PumpsSpecification%MudPump1OutputBblStroke / a) - if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then - PumpsSpecification%MudPump1LinerDiameter = 0.0 - else - PumpsSpecification%MudPump1LinerDiameter = a - endif - call SetMudPump1LinerDiameterN(PumpsSpecification%MudPump1LinerDiameter) - end subroutine - - subroutine CalcMudPump2LinerDiameter() - use, intrinsic :: IEEE_ARITHMETIC - implicit none - real(8) :: a - a = (MathPI / 4.d0) * PumpsSpecification%MudPump2Stroke * 3.0d0 * PumpsSpecification%MudPump2VolumetricEfficiency / 9702.03d0 - a = dsqrt(PumpsSpecification%MudPump2OutputBblStroke / a) - if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then - PumpsSpecification%MudPump2LinerDiameter = 0.0 - else - PumpsSpecification%MudPump2LinerDiameter = a - endif - call SetMudPump2LinerDiameterN(PumpsSpecification%MudPump2LinerDiameter) - end subroutine - - subroutine CalcMudPump3LinerDiameter() - use, intrinsic :: IEEE_ARITHMETIC - implicit none - real(8) :: a - a = (MathPI / 4.d0) * PumpsSpecification%CementPumpStroke * 3.0d0 * PumpsSpecification%CementPumpVolumetricEfficiency / 9702.03d0 - a = dsqrt(PumpsSpecification%CementPumpOutputBblStroke / a) - if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then - PumpsSpecification%CementPumpLinerDiameter = 0.0 - else - PumpsSpecification%CementPumpLinerDiameter = a - endif - call SetMudPump3LinerDiameterN(PumpsSpecification%CementPumpLinerDiameter) - end subroutine - - - - subroutine CalcPump1OutputBblStroke() - implicit none - PumpsSpecification%MudPump1OutputBblStroke = (MathPI / 4.d0) * (PumpsSpecification%MudPump1LinerDiameter**2) * PumpsSpecification%MudPump1Stroke * 3.0d0 * PumpsSpecification%MudPump1VolumetricEfficiency / 9702.03d0 - call SetMudPump1OutputBblStrokeN(PumpsSpecification%MudPump1OutputBblStroke) - end subroutine - - subroutine CalcPump2OutputBblStroke() - implicit none - PumpsSpecification%MudPump2OutputBblStroke = (MathPI / 4.d0) * (PumpsSpecification%MudPump2LinerDiameter**2) * PumpsSpecification%MudPump2Stroke * 3.0d0 * PumpsSpecification%MudPump2VolumetricEfficiency / 9702.03d0 - call SetMudPump2OutputBblStrokeN(PumpsSpecification%MudPump2OutputBblStroke) - end subroutine - - subroutine CalcPump3OutputBblStroke() - implicit none - PumpsSpecification%CementPumpOutputBblStroke = (MathPI / 4.d0) * (PumpsSpecification%CementPumpLinerDiameter**2) * PumpsSpecification%CementPumpStroke * 3.0d0 * PumpsSpecification%CementPumpVolumetricEfficiency / 9702.03d0 - call SetMudPump3OutputBblStrokeN(PumpsSpecification%CementPumpOutputBblStroke) - end subroutine - + contains end module CPumpsVariables \ No newline at end of file diff --git a/CSharp/BasicInputs/WellProfile/CPathGeneration.f90 b/CSharp/BasicInputs/WellProfile/CPathGeneration.f90 index f9e0a9c..cbd1a7d 100644 --- a/CSharp/BasicInputs/WellProfile/CPathGeneration.f90 +++ b/CSharp/BasicInputs/WellProfile/CPathGeneration.f90 @@ -1,5 +1,5 @@ module CPathGeneration - use CPathGenerationVariables + use ConfigurationVariables !@ implicit none public contains diff --git a/CSharp/DownHole/CDownHoleVariables.f90 b/CSharp/DownHole/CDownHoleVariables.f90 index 3c17817..0ed6636 100644 --- a/CSharp/DownHole/CDownHoleVariables.f90 +++ b/CSharp/DownHole/CDownHoleVariables.f90 @@ -1,6 +1,6 @@ module CDownHoleVariables use CDownHoleTypes - use CStringConfigurationVariables + ! use CStringConfigurationVariables ! use CDownHoleActions use CLog4 implicit none @@ -39,258 +39,5 @@ module CDownHoleVariables real(8) :: Volume end type DownHoleType type(DownHoleType):: DownHole - contains - - subroutine SetAnnalusFluids(count, array) - implicit none - integer, intent(in) :: count - integer :: i, offset - type(CFluid), intent(inout), target :: array(count) - type(CFluid), pointer :: item - DownHole%AnnalusFluidsCount = count - print*, 'AnnalusFluidsCount = ', count - if(size(DownHole%AnnalusFluids) > 0) then - deallocate(DownHole%AnnalusFluids) - end if - if(count > 0) then - offset = 0; - item => array(1) - if(item%StartMd > 0) then - DownHole%AnnalusFluidsCount = DownHole%AnnalusFluidsCount + 1 - offset = 1; - allocate(DownHole%AnnalusFluids(DownHole%AnnalusFluidsCount)) - DownHole%AnnalusFluids(1)%StartMd = 0 - DownHole%AnnalusFluids(1)%EndMd = item%StartMd - DownHole%AnnalusFluids(1)%Density = 0 - DownHole%AnnalusFluids(1)%MudType = FLUID_NO_MUD - endif - - !if(associated(AnnalusMudCountPtr)) then - ! call AnnalusMudCountPtr(AnnalusFluidsCount) - !end if - if(.not.allocated(DownHole%AnnalusFluids))allocate(DownHole%AnnalusFluids(DownHole%AnnalusFluidsCount)) - !print*, '============START-AN============' - if(item%StartMd < 0) DownHole%AnnalusFluids(1)%StartMd = 0 - do i = 1, count - item => array(i) - DownHole%AnnalusFluids(i + offset)%StartMd = item%StartMd - if(i==1) DownHole%AnnalusFluids(i)%StartMd = 0 - !print*, 'AnnalusFluids(',i,')%StartMd=', AnnalusFluids(i)%StartMd - DownHole%AnnalusFluids(i + offset)%EndMd = item%EndMd - !print*, 'AnnalusFluids(',i,')%EndMd=', AnnalusFluids(i)%EndMd - DownHole%AnnalusFluids(i + offset)%Density = item%Density - !print*, 'AnnalusFluids(',i,')%Density=', AnnalusFluids(i)%Density - DownHole%AnnalusFluids(i + offset)%MudType = item%MudType - !print*, 'AnnalusFluids(',i,')%MudType=', AnnalusFluids(i)%MudType - !print*, '----------------------------' - end do - !print*, '============END-AN============' - !if(associated(AnnalusMudArrayPtr)) then - ! !AnnalusFluidsPtr => AnnalusFluids - ! call AnnalusMudArrayPtr(AnnalusFluids) - !end if - end if - end subroutine SetAnnalusFluids - - subroutine SetStringFluids(count, array) - implicit none - integer, intent(in) :: count - integer :: i, offset !, startArr - type(CFluid), intent(inout), target :: array(count) - type(CFluid), pointer :: item - DownHole%StringFluidsCount = count - print*, 'StringFluidsCount = ', count - if(size(DownHole%StringFluids) > 0) then - deallocate(DownHole%StringFluids) - end if - - !startArr = 1 - - if(count > 0) then - offset = 0; - item => array(1) - ! - !if(item%StartMd <= 0 .and. item%EndMd <= 0) then - ! StringFluidsCount = StringFluidsCount - 1 - ! count = count - 1 - ! offset = offset + 1 - ! startArr = startArr + 1 - !endif - ! - !if(count <= 0) return - - if(item%StartMd > 0) then - DownHole%StringFluidsCount = DownHole%StringFluidsCount + 1 - offset = offset + 1 - allocate(DownHole%StringFluids(DownHole%StringFluidsCount)) - DownHole%StringFluids(1)%StartMd = 0 - DownHole%StringFluids(1)%EndMd = item%StartMd - DownHole%StringFluids(1)%Density = 0 - DownHole%StringFluids(1)%MudType = FLUID_NO_MUD - endif - - !if(associated(StringMudCountPtr)) then - ! call StringMudCountPtr(count) - !end if - if(.not.allocated(DownHole%StringFluids))allocate(DownHole%StringFluids(DownHole%StringFluidsCount)) - !print*, '============START-ST============' - !print*, 'count=', count - do i = 1, count - item => array(i) - DownHole%StringFluids(i + offset)%StartMd = item%StartMd - if(i==1) DownHole%StringFluids(i)%StartMd = 0 - !print*, 'StringFluids(i)%StartMd=', StringFluids(i)%StartMd - DownHole%StringFluids(i + offset)%EndMd = item%EndMd - !print*, 'StringFluids(i)%EndMd=', StringFluids(i)%EndMd - DownHole%StringFluids(i + offset)%Density = item%Density - DownHole%StringFluids(i + offset)%MudType = item%MudType - !print*, '----------------------------' - end do - !!if(item%StartMd < 0) StringFluids(1)%StartMd = 0 - !!print*, '============END-ST============' - !if(associated(StringMudArrayPtr)) then - ! call StringMudArrayPtr(StringFluids) - !end if - end if - end subroutine SetStringFluids - - subroutine SetString(count, array) - use CLog3 - implicit none - integer, intent(in) :: count - integer :: i !, j - type(CStringComponents), intent(inout), target :: array(count) - type(CStringComponents), pointer :: item - DownHole%StringCount = count - if(size(DownHole%String) > 0) then - deallocate(DownHole%String) - end if - if(count > 0) then - !if(associated(StringComponentCountPtr)) then - ! call StringComponentCountPtr(count) - !end if - allocate(DownHole%String(count)) - !j = 0 - !print*, '============CMP-ST============' - !call Log_3( '============CMP-ST============') - !do i = count, 1, -1 - do i = 1, count - item => array(i) - !String(i)%Length = item%Length - !String(i)%TopDepth = item%TopDepth - !String(i)%DownDepth = item%DownDepth - !String(i)%Od = item%Od - !String(i)%Id = item%Id - DownHole%String(i)%ComponentType= item%ComponentType - !j = j + 1 - DownHole%String(i)%StartMd = item%TopDepth - DownHole%String(i)%EndMd = item%DownDepth - - DownHole%String(i)%ComponentType=0 - !if(item%ComponentType > 4 ) then - ! String(i)%ComponentType=0 - ! String(i)%StartMd = 0 - !endif - if(item%ComponentType == 3) DownHole%String(i)%ComponentType=0 - if(item%ComponentType == 4) DownHole%String(i)%ComponentType=1 - if(item%ComponentType == 2) DownHole%String(i)%ComponentType=2 - if(item%ComponentType == 1) DownHole%String(i)%ComponentType=3 - !print*, 'item%ComponentType=', item%ComponentType - !print*, 'String(i)%ComponentType=', String(i)%ComponentType - !print*, 'String(i)%StartMd=', String(i)%StartMd - !print*, 'String(i)%EndMd=', String(i)%EndMd - !print*, '----------------------------' - - !call Log_3( 'item%ComponentType=', item%ComponentType) - !call Log_3( 'String(i)%ComponentType=', String(i)%ComponentType) - !call Log_3( 'String(i)%StartMd=', String(i)%StartMd) - !call Log_3( 'String(i)%EndMd=', String(i)%EndMd) - !call Log_3( '----------------------------') - - end do - !!print*, '============CMP-ST============' - !!call Log_3( '============CMP-ST============') - !if(associated(StringComponentArrayPtr)) then - ! call StringComponentArrayPtr(String) - !end if - end if - end subroutine SetString - - subroutine SetBopElements(array) - use CLog4 - implicit none - integer, parameter :: count = 4 - integer :: i = 1 !, j - type(CBopElement), intent(inout), target :: array(count) - type(CBopElement), pointer :: item - if(size(DownHole%BopElements) > 0) deallocate(DownHole%BopElements) - allocate(DownHole%BopElements(count)) - - do i = 1, count - item => array(i) - !call Log_4('item%ElementStart', item%ElementStart) - !call Log_4('item%ElementEnd', item%ElementEnd) - !call Log_4('item%ElementType', item%ElementType) - !call Log_4('=====================================================') - - DownHole%BopElements(i)%ElementStart = item%ElementStart - DownHole%BopElements(i)%ElementEnd = item%ElementEnd - DownHole%BopElements(i)%ElementType = item%ElementType - end do - - !if(associated(BopElementsPtr)) call BopElementsPtr(BopElements) - end subroutine SetBopElements - - subroutine GetAnnalusFluidInfo(md) - !DEC$ ATTRIBUTES DLLEXPORT::GetAnnalusFluidInfo - !DEC$ ATTRIBUTES ALIAS: 'GetAnnalusFluidInfo' :: GetAnnalusFluidInfo - !use ElementFinderVars - implicit none - integer, intent(in) :: md - - call AnnulusPropertyCalculator(md, DownHole%Density, DownHole%Pressure, DownHole%Temperature) - - !ObservationPoint(2)%MeasureDepth = md - - !Density = md + Density - 10 - !Pressure = md + Pressure - 20 - !Temperature = md + Temperature - 30 - !Height = Height * 100.0 - !Volume = Volume * 200.0 - ! - !call Log_4('GetAnnalusFluidInfo=', md) - !call Log_4('A_Height=', Height) - !call Log_4('A_Volume=', Volume) - -#ifdef deb - print*, 'GetAnnalusFluidInfo=', md -#endif - - end subroutine GetAnnalusFluidInfo - - subroutine GetStringFluidInfo(md) - !DEC$ ATTRIBUTES DLLEXPORT::GetStringFluidInfo - !DEC$ ATTRIBUTES ALIAS: 'GetStringFluidInfo' :: GetStringFluidInfo - implicit none - integer, intent(in) :: md - - call StringPropertyCalculator(md, DownHole%Density, DownHole%Pressure, DownHole%Temperature) - - !ObservationPoint(1)%MeasureDepth = md - - !Density = md + Density + 100 - !Pressure = md + Pressure + 200 - !Temperature = md + Temperature + 300 - !Height = Height * 100.0 - !Volume = Volume * 200.0 - ! - !call Log_4('GetStringFluidInfo=', md) - !call Log_4('S_Height=', Height) - !call Log_4('S_Volume=', Volume) - -#ifdef deb - print*, 'GetStringFluidInfo=', md -#endif - end subroutine GetStringFluidInfo - + contains end module CDownHoleVariables \ No newline at end of file diff --git a/CSharp/DownHole/DownHole.f90 b/CSharp/DownHole/DownHole.f90 new file mode 100644 index 0000000..7cb0913 --- /dev/null +++ b/CSharp/DownHole/DownHole.f90 @@ -0,0 +1,204 @@ +module DownHoleModule + use ConfigurationVariables + contains + subroutine SetAnnalusFluids(count, array) + implicit none + integer, intent(in) :: count + integer :: i, offset + type(CFluid), intent(inout), target :: array(count) + type(CFluid), pointer :: item + DownHole%AnnalusFluidsCount = count + print*, 'AnnalusFluidsCount = ', count + if(size(DownHole%AnnalusFluids) > 0) then + deallocate(DownHole%AnnalusFluids) + end if + if(count > 0) then + offset = 0; + item => array(1) + if(item%StartMd > 0) then + DownHole%AnnalusFluidsCount = DownHole%AnnalusFluidsCount + 1 + offset = 1; + allocate(DownHole%AnnalusFluids(DownHole%AnnalusFluidsCount)) + DownHole%AnnalusFluids(1)%StartMd = 0 + DownHole%AnnalusFluids(1)%EndMd = item%StartMd + DownHole%AnnalusFluids(1)%Density = 0 + DownHole%AnnalusFluids(1)%MudType = FLUID_NO_MUD + endif + + !if(associated(AnnalusMudCountPtr)) then + ! call AnnalusMudCountPtr(AnnalusFluidsCount) + !end if + if(.not.allocated(DownHole%AnnalusFluids))allocate(DownHole%AnnalusFluids(DownHole%AnnalusFluidsCount)) + !print*, '============START-AN============' + if(item%StartMd < 0) DownHole%AnnalusFluids(1)%StartMd = 0 + do i = 1, count + item => array(i) + DownHole%AnnalusFluids(i + offset)%StartMd = item%StartMd + if(i==1) DownHole%AnnalusFluids(i)%StartMd = 0 + !print*, 'AnnalusFluids(',i,')%StartMd=', AnnalusFluids(i)%StartMd + DownHole%AnnalusFluids(i + offset)%EndMd = item%EndMd + !print*, 'AnnalusFluids(',i,')%EndMd=', AnnalusFluids(i)%EndMd + DownHole%AnnalusFluids(i + offset)%Density = item%Density + !print*, 'AnnalusFluids(',i,')%Density=', AnnalusFluids(i)%Density + DownHole%AnnalusFluids(i + offset)%MudType = item%MudType + !print*, 'AnnalusFluids(',i,')%MudType=', AnnalusFluids(i)%MudType + !print*, '----------------------------' + end do + !print*, '============END-AN============' + !if(associated(AnnalusMudArrayPtr)) then + ! !AnnalusFluidsPtr => AnnalusFluids + ! call AnnalusMudArrayPtr(AnnalusFluids) + !end if + end if + end subroutine SetAnnalusFluids + + subroutine SetStringFluids(count, array) + implicit none + integer, intent(in) :: count + integer :: i, offset !, startArr + type(CFluid), intent(inout), target :: array(count) + type(CFluid), pointer :: item + DownHole%StringFluidsCount = count + print*, 'StringFluidsCount = ', count + if(size(DownHole%StringFluids) > 0) then + deallocate(DownHole%StringFluids) + end if + + !startArr = 1 + + if(count > 0) then + offset = 0; + item => array(1) + ! + !if(item%StartMd <= 0 .and. item%EndMd <= 0) then + ! StringFluidsCount = StringFluidsCount - 1 + ! count = count - 1 + ! offset = offset + 1 + ! startArr = startArr + 1 + !endif + ! + !if(count <= 0) return + + if(item%StartMd > 0) then + DownHole%StringFluidsCount = DownHole%StringFluidsCount + 1 + offset = offset + 1 + allocate(DownHole%StringFluids(DownHole%StringFluidsCount)) + DownHole%StringFluids(1)%StartMd = 0 + DownHole%StringFluids(1)%EndMd = item%StartMd + DownHole%StringFluids(1)%Density = 0 + DownHole%StringFluids(1)%MudType = FLUID_NO_MUD + endif + + !if(associated(StringMudCountPtr)) then + ! call StringMudCountPtr(count) + !end if + if(.not.allocated(DownHole%StringFluids))allocate(DownHole%StringFluids(DownHole%StringFluidsCount)) + !print*, '============START-ST============' + !print*, 'count=', count + do i = 1, count + item => array(i) + DownHole%StringFluids(i + offset)%StartMd = item%StartMd + if(i==1) DownHole%StringFluids(i)%StartMd = 0 + !print*, 'StringFluids(i)%StartMd=', StringFluids(i)%StartMd + DownHole%StringFluids(i + offset)%EndMd = item%EndMd + !print*, 'StringFluids(i)%EndMd=', StringFluids(i)%EndMd + DownHole%StringFluids(i + offset)%Density = item%Density + DownHole%StringFluids(i + offset)%MudType = item%MudType + !print*, '----------------------------' + end do + !!if(item%StartMd < 0) StringFluids(1)%StartMd = 0 + !!print*, '============END-ST============' + !if(associated(StringMudArrayPtr)) then + ! call StringMudArrayPtr(StringFluids) + !end if + end if + end subroutine SetStringFluids + + subroutine SetString(count, array) + use CLog3 + implicit none + integer, intent(in) :: count + integer :: i !, j + type(CStringComponents), intent(inout), target :: array(count) + type(CStringComponents), pointer :: item + DownHole%StringCount = count + if(size(DownHole%String) > 0) then + deallocate(DownHole%String) + end if + if(count > 0) then + !if(associated(StringComponentCountPtr)) then + ! call StringComponentCountPtr(count) + !end if + allocate(DownHole%String(count)) + !j = 0 + !print*, '============CMP-ST============' + !call Log_3( '============CMP-ST============') + !do i = count, 1, -1 + do i = 1, count + item => array(i) + !String(i)%Length = item%Length + !String(i)%TopDepth = item%TopDepth + !String(i)%DownDepth = item%DownDepth + !String(i)%Od = item%Od + !String(i)%Id = item%Id + DownHole%String(i)%ComponentType= item%ComponentType + !j = j + 1 + DownHole%String(i)%StartMd = item%TopDepth + DownHole%String(i)%EndMd = item%DownDepth + + DownHole%String(i)%ComponentType=0 + !if(item%ComponentType > 4 ) then + ! String(i)%ComponentType=0 + ! String(i)%StartMd = 0 + !endif + if(item%ComponentType == 3) DownHole%String(i)%ComponentType=0 + if(item%ComponentType == 4) DownHole%String(i)%ComponentType=1 + if(item%ComponentType == 2) DownHole%String(i)%ComponentType=2 + if(item%ComponentType == 1) DownHole%String(i)%ComponentType=3 + !print*, 'item%ComponentType=', item%ComponentType + !print*, 'String(i)%ComponentType=', String(i)%ComponentType + !print*, 'String(i)%StartMd=', String(i)%StartMd + !print*, 'String(i)%EndMd=', String(i)%EndMd + !print*, '----------------------------' + + !call Log_3( 'item%ComponentType=', item%ComponentType) + !call Log_3( 'String(i)%ComponentType=', String(i)%ComponentType) + !call Log_3( 'String(i)%StartMd=', String(i)%StartMd) + !call Log_3( 'String(i)%EndMd=', String(i)%EndMd) + !call Log_3( '----------------------------') + + end do + !!print*, '============CMP-ST============' + !!call Log_3( '============CMP-ST============') + !if(associated(StringComponentArrayPtr)) then + ! call StringComponentArrayPtr(String) + !end if + end if + end subroutine SetString + + subroutine SetBopElements(array) + use CLog4 + implicit none + integer, parameter :: count = 4 + integer :: i = 1 !, j + type(CBopElement), intent(inout), target :: array(count) + type(CBopElement), pointer :: item + if(size(DownHole%BopElements) > 0) deallocate(DownHole%BopElements) + allocate(DownHole%BopElements(count)) + + do i = 1, count + item => array(i) + !call Log_4('item%ElementStart', item%ElementStart) + !call Log_4('item%ElementEnd', item%ElementEnd) + !call Log_4('item%ElementType', item%ElementType) + !call Log_4('=====================================================') + + DownHole%BopElements(i)%ElementStart = item%ElementStart + DownHole%BopElements(i)%ElementEnd = item%ElementEnd + DownHole%BopElements(i)%ElementType = item%ElementType + end do + + !if(associated(BopElementsPtr)) call BopElementsPtr(BopElements) + end subroutine SetBopElements + +end module DownHoleModule \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CBopControlPanel.f90 b/CSharp/Equipments/ControlPanels/CBopControlPanel.f90 index ba8ce92..e167256 100644 --- a/CSharp/Equipments/ControlPanels/CBopControlPanel.f90 +++ b/CSharp/Equipments/ControlPanels/CBopControlPanel.f90 @@ -1,250 +1,83 @@ module CBopControlPanel - use CBopControlPanelVariables + ! use CBopControlPanel + use ConfigurationVariables implicit none public contains + subroutine OpenAnnular() + use CManifolds + implicit none + call ChangeValve(52, .true.) + end subroutine - ! Input routines - subroutine SetAnnularRegulatorSetControl(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAnnularRegulatorSetControl - !DEC$ ATTRIBUTES ALIAS: 'SetAnnularRegulatorSetControl' :: SetAnnularRegulatorSetControl - implicit none - real*8, intent(in) :: v - BopControlPanel%AnnularRegulatorSetControl = v -#ifdef deb - print*, 'AnnularRegulatorSetControl=', BopControlPanel%AnnularRegulatorSetControl -#endif + subroutine CloseAnnular() + use CManifolds + implicit none + call ChangeValve(52, .false.) end subroutine - - subroutine SetAirMasterValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAirMasterValve - !DEC$ ATTRIBUTES ALIAS: 'SetAirMasterValve' :: SetAirMasterValve - implicit none - real*8, intent(in) :: v - BopControlPanel%AirMasterValve = v -#ifdef deb - print*, 'AirMasterValve=', BopControlPanel%AirMasterValve -#endif + + subroutine OpenUpperRams() + use CManifolds + implicit none + call ChangeValve(51, .true.) end subroutine - - subroutine SetByePassValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetByePassValve - !DEC$ ATTRIBUTES ALIAS: 'SetByePassValve' :: SetByePassValve - implicit none - real*8, intent(in) :: v - BopControlPanel%ByePassValve = v -#ifdef deb - print*, 'ByePassValve=', BopControlPanel%ByePassValve -#endif + + subroutine CloseUpperRams() + use CManifolds + implicit none + call ChangeValve(51, .false.) end subroutine - - subroutine SetAnnularValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAnnularValve - !DEC$ ATTRIBUTES ALIAS: 'SetAnnularValve' :: SetAnnularValve - implicit none - real*8, intent(in) :: v - BopControlPanel%AnnularValve = v -#ifdef deb - print*, 'AnnularValve=', BopControlPanel%AnnularValve -#endif + + subroutine OpenMiddleRams() + use CManifolds + implicit none + call ToggleMiddleRams(.true.) end subroutine - - subroutine SetUpperRamsValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetUpperRamsValve - !DEC$ ATTRIBUTES ALIAS: 'SetUpperRamsValve' :: SetUpperRamsValve - implicit none - real*8, intent(in) :: v - BopControlPanel%UpperRamsValve = v -#ifdef deb - print*, 'UpperRamsValve=', BopControlPanel%UpperRamsValve -#endif + + subroutine CloseMiddleRams() + use CManifolds + implicit none + call ToggleMiddleRams(.false.) end subroutine - - subroutine SetMiddleRamsValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMiddleRamsValve - !DEC$ ATTRIBUTES ALIAS: 'SetMiddleRamsValve' :: SetMiddleRamsValve - implicit none - real*8, intent(in) :: v - BopControlPanel%MiddleRamsValve = v -#ifdef deb - print*, 'MiddleRamsValve=', BopControlPanel%MiddleRamsValve -#endif + + subroutine OpenKillLine() + use CManifolds + implicit none + call ChangeValve(46, .true.) end subroutine - - subroutine SetKillLineValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetKillLineValve - !DEC$ ATTRIBUTES ALIAS: 'SetKillLineValve' :: SetKillLineValve - implicit none - real*8, intent(in) :: v - BopControlPanel%KillLineValve = v -#ifdef deb - print*, 'KillLineValve=', BopControlPanel%KillLineValve -#endif + + subroutine CloseKillLine() + use CManifolds + implicit none + call ChangeValve(46, .false.) end subroutine - - subroutine SetChokeLineValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeLineValve - !DEC$ ATTRIBUTES ALIAS: 'SetChokeLineValve' :: SetChokeLineValve - implicit none - real*8, intent(in) :: v - BopControlPanel%ChokeLineValve = v -#ifdef deb - print*, 'ChokeLineValve=', BopControlPanel%ChokeLineValve -#endif + + subroutine OpenChokeLine() + use CManifolds + implicit none + call ChangeValve(47, .true.) + !WRITE (*,*) ' valve 47 true ' end subroutine - - subroutine SetLowerRamsValve(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetLowerRamsValve - !DEC$ ATTRIBUTES ALIAS: 'SetLowerRamsValve' :: SetLowerRamsValve - implicit none - real*8, intent(in) :: v - BopControlPanel%LowerRamsValve = v -#ifdef deb - print*, 'LowerRamsValve=', BopControlPanel%LowerRamsValve -#endif + + subroutine CloseChokeLine() + use CManifolds + implicit none + call ChangeValve(47, .false.) + !WRITE (*,*) ' valve 47 false ' + end subroutine + + subroutine OpenLowerRams() + use CManifolds + implicit none + call ChangeValve(49, .true.) + !WRITE (*,*) ' valve 49 true ' + end subroutine + + subroutine CloseLowerRams() + use CManifolds + implicit none + call ChangeValve(49, .false.) + !WRITE (*,*) ' valve 49 false ' end subroutine - - - ! Output routines - real(8) function GetManifoldPressureGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetManifoldPressureGauge - !DEC$ ATTRIBUTES ALIAS: 'GetManifoldPressureGauge' :: GetManifoldPressureGauge - implicit none - GetManifoldPressureGauge = BopControlPanel%ManifoldPressureGauge - end function - - real(8) function GetAirSupplyPressureGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetAirSupplyPressureGauge - !DEC$ ATTRIBUTES ALIAS: 'GetAirSupplyPressureGauge' :: GetAirSupplyPressureGauge - implicit none - GetAirSupplyPressureGauge = BopControlPanel%AirSupplyPressureGauge - end function - - real(8) function GetAccumulatorPressureGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetAccumulatorPressureGauge - !DEC$ ATTRIBUTES ALIAS: 'GetAccumulatorPressureGauge' :: GetAccumulatorPressureGauge - implicit none - GetAccumulatorPressureGauge = BopControlPanel%AccumulatorPressureGauge - !GetAccumulatorPressureGauge = 2000.0d0 - end function - - real(8) function GetAnnularPressureGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetAnnularPressureGauge - !DEC$ ATTRIBUTES ALIAS: 'GetAnnularPressureGauge' :: GetAnnularPressureGauge - implicit none - GetAnnularPressureGauge = BopControlPanel%AnnularPressureGauge - end function - - integer function GetAnnularOpenLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetAnnularOpenLED - !DEC$ ATTRIBUTES ALIAS: 'GetAnnularOpenLED' :: GetAnnularOpenLED - implicit none - GetAnnularOpenLED = BopControlPanel%AnnularOpenLED - end function - - integer function GetAnnularCloseLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetAnnularCloseLED - !DEC$ ATTRIBUTES ALIAS: 'GetAnnularCloseLED' :: GetAnnularCloseLED - implicit none - GetAnnularCloseLED = BopControlPanel%AnnularCloseLED - end function - - integer function GetUpperRamsOpenLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetUpperRamsOpenLED - !DEC$ ATTRIBUTES ALIAS: 'GetUpperRamsOpenLED' :: GetUpperRamsOpenLED - implicit none - GetUpperRamsOpenLED = BopControlPanel%UpperRamsOpenLED - end function - - integer function GetUpperRamsCloseLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetUpperRamsCloseLED - !DEC$ ATTRIBUTES ALIAS: 'GetUpperRamsCloseLED' :: GetUpperRamsCloseLED - implicit none - GetUpperRamsCloseLED = BopControlPanel%UpperRamsCloseLED - end function - - integer function GetMiddleRamsOpenLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMiddleRamsOpenLED - !DEC$ ATTRIBUTES ALIAS: 'GetMiddleRamsOpenLED' :: GetMiddleRamsOpenLED - implicit none - GetMiddleRamsOpenLED = BopControlPanel%MiddleRamsOpenLED - end function - - integer function GetMiddleRamsCloseLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMiddleRamsCloseLED - !DEC$ ATTRIBUTES ALIAS: 'GetMiddleRamsCloseLED' :: GetMiddleRamsCloseLED - implicit none - GetMiddleRamsCloseLED = BopControlPanel%MiddleRamsCloseLED - end function - - integer function GetKillLineOpenLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetKillLineOpenLED - !DEC$ ATTRIBUTES ALIAS: 'GetKillLineOpenLED' :: GetKillLineOpenLED - implicit none - GetKillLineOpenLED = BopControlPanel%KillLineOpenLED - end function - - integer function GetKillLineCloseLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetKillLineCloseLED - !DEC$ ATTRIBUTES ALIAS: 'GetKillLineCloseLED' :: GetKillLineCloseLED - implicit none - GetKillLineCloseLED = BopControlPanel%KillLineCloseLED - end function - - integer function GetChokeLineOpenLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetChokeLineOpenLED - !DEC$ ATTRIBUTES ALIAS: 'GetChokeLineOpenLED' :: GetChokeLineOpenLED - implicit none - GetChokeLineOpenLED = BopControlPanel%ChokeLineOpenLED - end function - - integer function GetChokeLineCloseLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetChokeLineCloseLED - !DEC$ ATTRIBUTES ALIAS: 'GetChokeLineCloseLED' :: GetChokeLineCloseLED - implicit none - GetChokeLineCloseLED = BopControlPanel%ChokeLineCloseLED - end function - - integer function GetLowerRamsOpenLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetLowerRamsOpenLED - !DEC$ ATTRIBUTES ALIAS: 'GetLowerRamsOpenLED' :: GetLowerRamsOpenLED - implicit none - GetLowerRamsOpenLED = BopControlPanel%LowerRamsOpenLED - end function - - integer function GetLowerRamsCloseLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetLowerRamsCloseLED - !DEC$ ATTRIBUTES ALIAS: 'GetLowerRamsCloseLED' :: GetLowerRamsCloseLED - implicit none - GetLowerRamsCloseLED = BopControlPanel%LowerRamsCloseLED - end function - - real(8) function GetAnnularStatus() - !DEC$ ATTRIBUTES DLLEXPORT :: GetAnnularStatus - !DEC$ ATTRIBUTES ALIAS: 'GetAnnularStatus' :: GetAnnularStatus - implicit none - GetAnnularStatus = BopControlPanel%AnnularStatus - end function - - real(8) function GetUpperRamsStatus() - !DEC$ ATTRIBUTES DLLEXPORT :: GetUpperRamsStatus - !DEC$ ATTRIBUTES ALIAS: 'GetUpperRamsStatus' :: GetUpperRamsStatus - implicit none - GetUpperRamsStatus = BopControlPanel%UpperRamsStatus - end function - - real(8) function GetMiddleRamsStatus() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMiddleRamsStatus - !DEC$ ATTRIBUTES ALIAS: 'GetMiddleRamsStatus' :: GetMiddleRamsStatus - implicit none - GetMiddleRamsStatus = BopControlPanel%MiddleRamsStatus - end function - - real(8) function GetLowerRamsStatus() - !DEC$ ATTRIBUTES DLLEXPORT :: GetLowerRamsStatus - !DEC$ ATTRIBUTES ALIAS: 'GetLowerRamsStatus' :: GetLowerRamsStatus - implicit none - GetLowerRamsStatus = BopControlPanel%LowerRamsStatus - end function end module CBopControlPanel diff --git a/CSharp/Equipments/ControlPanels/CBopControlPanelVariables.f90 b/CSharp/Equipments/ControlPanels/CBopControlPanelVariables.f90 index 56a6de7..4992d1f 100644 --- a/CSharp/Equipments/ControlPanels/CBopControlPanelVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CBopControlPanelVariables.f90 @@ -35,82 +35,6 @@ module CBopControlPanelVariables real(8) :: MiddleRamsStatus real(8) :: LowerRamsStatus end type - type(BopControlPanelType) :: BopControlPanel contains - subroutine OpenAnnular() - use CManifolds - implicit none - call ChangeValve(52, .true.) - end subroutine - - subroutine CloseAnnular() - use CManifolds - implicit none - call ChangeValve(52, .false.) - end subroutine - - subroutine OpenUpperRams() - use CManifolds - implicit none - call ChangeValve(51, .true.) - end subroutine - - subroutine CloseUpperRams() - use CManifolds - implicit none - call ChangeValve(51, .false.) - end subroutine - - subroutine OpenMiddleRams() - use CManifolds - implicit none - call ToggleMiddleRams(.true.) - end subroutine - - subroutine CloseMiddleRams() - use CManifolds - implicit none - call ToggleMiddleRams(.false.) - end subroutine - - subroutine OpenKillLine() - use CManifolds - implicit none - call ChangeValve(46, .true.) - end subroutine - - subroutine CloseKillLine() - use CManifolds - implicit none - call ChangeValve(46, .false.) - end subroutine - - subroutine OpenChokeLine() - use CManifolds - implicit none - call ChangeValve(47, .true.) - !WRITE (*,*) ' valve 47 true ' - end subroutine - - subroutine CloseChokeLine() - use CManifolds - implicit none - call ChangeValve(47, .false.) - !WRITE (*,*) ' valve 47 false ' - end subroutine - - subroutine OpenLowerRams() - use CManifolds - implicit none - call ChangeValve(49, .true.) - !WRITE (*,*) ' valve 49 true ' - end subroutine - - subroutine CloseLowerRams() - use CManifolds - implicit none - call ChangeValve(49, .false.) - !WRITE (*,*) ' valve 49 false ' - end subroutine end module CBopControlPanelVariables diff --git a/CSharp/Equipments/ControlPanels/CChokeControlPanel.f90 b/CSharp/Equipments/ControlPanels/CChokeControlPanel.f90 index 49b6b4b..f5bcc4b 100644 --- a/CSharp/Equipments/ControlPanels/CChokeControlPanel.f90 +++ b/CSharp/Equipments/ControlPanels/CChokeControlPanel.f90 @@ -1,5 +1,6 @@ module CChokeControlPanel use CChokeControlPanelVariables + use ConfigurationVariables implicit none public contains @@ -10,9 +11,9 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'SetChokePanelPumpSelectorSwitch' :: SetChokePanelPumpSelectorSwitch implicit none integer, intent(in) :: v - ChokeControlPanel%ChokePanelPumpSelectorSwitch = v + data%EquipmentControl%ChokeControlPanel%ChokePanelPumpSelectorSwitch = v #ifdef deb - print*, 'ChokePanelPumpSelectorSwitch=', ChokeControlPanel%ChokePanelPumpSelectorSwitch + print*, 'ChokePanelPumpSelectorSwitch=', data%EquipmentControl%ChokeControlPanel%ChokePanelPumpSelectorSwitch #endif end subroutine @@ -21,9 +22,9 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'SetChokePanelStrokeResetSwitch' :: SetChokePanelStrokeResetSwitch implicit none logical, intent(in) :: v - ChokeControlPanel%ChokePanelStrokeResetSwitch = v + data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch = v #ifdef deb - print*, 'ChokePanelStrokeResetSwitch=', ChokeControlPanel%ChokePanelStrokeResetSwitch + print*, 'ChokePanelStrokeResetSwitch=', data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch #endif end subroutine @@ -32,9 +33,9 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'SetChokeSelectorSwitch' :: SetChokeSelectorSwitch implicit none logical, intent(in) :: v - ChokeControlPanel%ChokeSelectorSwitch = v + data%EquipmentControl%ChokeControlPanel%ChokeSelectorSwitch = v #ifdef deb - print*, 'ChokeSelectorSwitch=', ChokeControlPanel%ChokeSelectorSwitch + print*, 'ChokeSelectorSwitch=', data%EquipmentControl%ChokeControlPanel%ChokeSelectorSwitch #endif end subroutine @@ -49,12 +50,12 @@ module CChokeControlPanel !character(5) :: zone !integer,dimension(8) :: values - ChokeControlPanel%ChokeRateControlKnob = v + data%EquipmentControl%ChokeControlPanel%ChokeRateControlKnob = v #ifdef deb !call date_and_time(date,time,zone,values) !!print '(a,2x,a,2x,a)', date, time, zone !print '(8i5)', values - print*, 'ChokeRateControlKnob=', ChokeControlPanel%ChokeRateControlKnob + print*, 'ChokeRateControlKnob=', data%EquipmentControl%ChokeControlPanel%ChokeRateControlKnob #endif end subroutine @@ -63,9 +64,9 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'SetChokeControlLever' :: SetChokeControlLever implicit none real*8, intent(in) :: v - ChokeControlPanel%ChokeControlLever = v + data%EquipmentControl%ChokeControlPanel%ChokeControlLever = v #ifdef deb - print*, 'ChokeControlLever=', ChokeControlPanel%ChokeControlLever + print*, 'ChokeControlLever=', data%EquipmentControl%ChokeControlPanel%ChokeControlLever #endif end subroutine @@ -74,9 +75,9 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'SetChokePanelRigAirSwitch' :: SetChokePanelRigAirSwitch implicit none logical, intent(in) :: v - ChokeControlPanel%ChokePanelRigAirSwitch = v + data%EquipmentControl%ChokeControlPanel%ChokePanelRigAirSwitch = v #ifdef deb - print*, 'ChokePanelRigAirSwitch=', ChokeControlPanel%ChokePanelRigAirSwitch + print*, 'ChokePanelRigAirSwitch=', data%EquipmentControl%ChokeControlPanel%ChokePanelRigAirSwitch #endif end subroutine @@ -86,9 +87,9 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'SetEnableAutoChoke' :: SetEnableAutoChoke implicit none logical, intent(in) :: v - ChokeControlPanel%EnableAutoChoke = v + data%EquipmentControl%ChokeControlPanel%EnableAutoChoke = v #ifdef deb - print*, 'EnableAutoChoke=', ChokeControlPanel%EnableAutoChoke + print*, 'EnableAutoChoke=', data%EquipmentControl%ChokeControlPanel%EnableAutoChoke #endif end subroutine @@ -108,21 +109,21 @@ module CChokeControlPanel !DEC$ ATTRIBUTES DLLEXPORT :: GetStandPipePressure !DEC$ ATTRIBUTES ALIAS: 'GetStandPipePressure' :: GetStandPipePressure implicit none - GetStandPipePressure = ChokeControlPanel%StandPipePressure + GetStandPipePressure = data%EquipmentControl%ChokeControlPanel%StandPipePressure end function real(8) function GetCasingPressure() !DEC$ ATTRIBUTES DLLEXPORT :: GetCasingPressure !DEC$ ATTRIBUTES ALIAS: 'GetCasingPressure' :: GetCasingPressure implicit none - GetCasingPressure = ChokeControlPanel%CasingPressure + GetCasingPressure = data%EquipmentControl%ChokeControlPanel%CasingPressure end function real(8) function GetChokePosition() !DEC$ ATTRIBUTES DLLEXPORT :: GetChokePosition !DEC$ ATTRIBUTES ALIAS: 'GetChokePosition' :: GetChokePosition implicit none - GetChokePosition = ChokeControlPanel%ChokePosition + GetChokePosition = data%EquipmentControl%ChokeControlPanel%ChokePosition end function real(8) function GetChokePanelSPMCounter() @@ -130,7 +131,7 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'GetChokePanelSPMCounter' :: GetChokePanelSPMCounter implicit none !GetChokePanelSPMCounter = 0 - GetChokePanelSPMCounter = ChokeControlPanel%ChokePanelSPMCounter + GetChokePanelSPMCounter = data%EquipmentControl%ChokeControlPanel%ChokePanelSPMCounter end function real(8) function GetChokePanelTotalStrokeCounter() @@ -138,21 +139,21 @@ module CChokeControlPanel !DEC$ ATTRIBUTES ALIAS: 'GetChokePanelTotalStrokeCounter' :: GetChokePanelTotalStrokeCounter implicit none !GetChokePanelTotalStrokeCounter = 0 - GetChokePanelTotalStrokeCounter = ChokeControlPanel%ChokePanelTotalStrokeCounter + GetChokePanelTotalStrokeCounter = data%EquipmentControl%ChokeControlPanel%ChokePanelTotalStrokeCounter end function integer function GetChoke1LED() !DEC$ ATTRIBUTES DLLEXPORT :: GetChoke1LED !DEC$ ATTRIBUTES ALIAS: 'GetChoke1LED' :: GetChoke1LED implicit none - GetChoke1LED = ChokeControlPanel%Choke1LED + GetChoke1LED = data%EquipmentControl%ChokeControlPanel%Choke1LED end function integer function GetChoke2LED() !DEC$ ATTRIBUTES DLLEXPORT :: GetChoke2LED !DEC$ ATTRIBUTES ALIAS: 'GetChoke2LED' :: GetChoke2LED implicit none - GetChoke2LED = ChokeControlPanel%Choke2LED + GetChoke2LED = data%EquipmentControl%ChokeControlPanel%Choke2LED end function diff --git a/CSharp/Equipments/ControlPanels/CChokeControlPanelVariables.f90 b/CSharp/Equipments/ControlPanels/CChokeControlPanelVariables.f90 index b5750fd..ec6912a 100644 --- a/CSharp/Equipments/ControlPanels/CChokeControlPanelVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CChokeControlPanelVariables.f90 @@ -20,5 +20,4 @@ module CChokeControlPanelVariables integer :: Choke1LED integer :: Choke2LED End Type ChokeControlPanelType - Type(ChokeControlPanelType)::ChokeControlPanel end module CChokeControlPanelVariables \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CChokeManifold.f90 b/CSharp/Equipments/ControlPanels/CChokeManifold.f90 index 5f7b88d..0fe00e1 100644 --- a/CSharp/Equipments/ControlPanels/CChokeManifold.f90 +++ b/CSharp/Equipments/ControlPanels/CChokeManifold.f90 @@ -1,212 +1,41 @@ module CChokeManifold - use CChokeManifoldVariables +! use CChokeManifoldVariables + use ConfigurationVariables + use CManifolds use CLog2 implicit none - public - contains - - ! Input routines - subroutine SetChokeManifoldValve1(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve1 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve1' :: SetChokeManifoldValve1 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve1 = v - call ChangeValve(61, v) -#ifdef deb - !print*, 'ChokeManifoldValve1=', ChokeManifoldValve1 -#endif - end subroutine - - subroutine SetChokeManifoldValve2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve2 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve2' :: SetChokeManifoldValve2 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve2 = v - call ChangeValve(64, v) -#ifdef deb - !print*, 'ChokeManifoldValve2=', ChokeManifoldValve2 -#endif - end subroutine - - subroutine SetLeftManualChoke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetLeftManualChoke - !DEC$ ATTRIBUTES ALIAS: 'SetLeftManualChoke' :: SetLeftManualChoke - implicit none - real*8, intent(in) :: v - !LeftManualChoke = abs(v-100) - ChokeManifold%LeftManualChoke = v - if(ChokeManifold%LeftManChokeOnProblem) then - call ChangeValve(32, .true.) + public + contains + subroutine SetHydraulicChock1(v) + implicit none + integer, intent(in) :: v + data%EquipmentControl%ChokeManifold%HydraulicChock1 = v + if(data%EquipmentControl%ChokeManifold%HyChock1OnProblem) then + call ChangeValve(33, .true.) + else + if(v == 100) then + if(Manifold%Valve(33)%Status) call ChangeValve(33, .false.) else - if(ChokeManifold%LeftManualChoke > 99.9) then - !call Log_2( 'valve 32 is closed=', LeftManualChoke) - call ChangeValve(32, .false.) - else - !call Log_2( 'valve 32 is open=', LeftManualChoke) - call ChangeValve(32, .true.) - endif + if(.not.Manifold%Valve(33)%Status) call ChangeValve(33, .true.) endif -#ifdef deb - !print*, 'LeftManualChoke=', LeftManualChoke -#endif - end subroutine - - subroutine SetChokeManifoldValve4(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve4 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve4' :: SetChokeManifoldValve4 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve4 = v - call ChangeValve(62, v) - !WRITE (*,*) ' valve 62 ', v -#ifdef deb - !print*, 'ChokeManifoldValve4=', ChokeManifoldValve4 -#endif - end subroutine - - subroutine SetChokeManifoldValve5(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve5 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve5' :: SetChokeManifoldValve5 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve5 = v - call ChangeValve(63, v) - !WRITE (*,*) ' valve 63 ', v -#ifdef deb - !print*, 'ChokeManifoldValve5=', ChokeManifoldValve5 -#endif - end subroutine - - subroutine SetRightManualChoke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRightManualChoke - !DEC$ ATTRIBUTES ALIAS: 'SetRightManualChoke' :: SetRightManualChoke - implicit none - real*8, intent(in) :: v - !RightManualChoke = abs(v -100) - ChokeManifold%RightManualChoke = v - if(ChokeManifold%RightManChokeOnProblem) then - call ChangeValve(35, .true.) - else - if(ChokeManifold%RightManualChoke > 99.9) then - !call Log_2( 'valve 35 is closed=', RightManualChoke) - call ChangeValve(35, .false.) - else - !call Log_2( 'valve 35 is open=', RightManualChoke) - call ChangeValve(35, .true.) - endif + endif + !WRITE (*,*) ' valve 33 ', Valve(33)%Status, ' arg ', v +end subroutine + +subroutine SetHydraulicChock2(v) + implicit none + integer, intent(in) :: v + data%EquipmentControl%ChokeManifold%HydraulicChock2 = v + if(data%EquipmentControl%ChokeManifold%HyChock2OnProblem) then + call ChangeValve(34, .true.) + else + if(v==100) then + if(Manifold%Valve(34)%Status) call ChangeValve(34, .false.) + else + if(.not.Manifold%Valve(34)%Status) call ChangeValve(34, .true.) endif -#ifdef deb - !print*, 'RightManualChoke=', RightManualChoke -#endif - end subroutine - - subroutine SetChokeManifoldValve7(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve7 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve7' :: SetChokeManifoldValve7 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve7 = v - call ChangeValve(27, v) -#ifdef deb - !print*, 'ChokeManifoldValve7=', ChokeManifoldValve7 -#endif - end subroutine - - subroutine SetChokeManifoldValve8(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve8 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve8' :: SetChokeManifoldValve8 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve8 = v - call ChangeValve(28, v) - !WRITE (*,*) ' valve 28 ', v -#ifdef deb - !print*, 'ChokeManifoldValve8=', ChokeManifoldValve8 -#endif - end subroutine - - subroutine SetChokeManifoldValve9(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve9 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve9' :: SetChokeManifoldValve9 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve9 = v - call ChangeValve(29, v) -#ifdef deb - !print*, 'ChokeManifoldValve9=', ChokeManifoldValve9 -#endif - end subroutine - - subroutine SetChokeManifoldValve10(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve10 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve10' :: SetChokeManifoldValve10 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve10 = v - call ChangeValve(30, v) - !WRITE (*,*) ' valve 30 ', v -#ifdef deb - !print*, 'ChokeManifoldValve10=', ChokeManifoldValve10 -#endif - end subroutine - - subroutine SetChokeManifoldValve11(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve11 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve11' :: SetChokeManifoldValve11 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve11 = v - call ChangeValve(31, v) -#ifdef deb - !print*, 'ChokeManifoldValve11=', ChokeManifoldValve11 -#endif - end subroutine - - subroutine SetChokeManifoldValve12(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve12 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve12' :: SetChokeManifoldValve12 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve12 = v - call ChangeValve(25, v) -#ifdef deb - !print*, 'ChokeManifoldValve12=', ChokeManifoldValve12 -#endif - end subroutine - - subroutine SetChokeManifoldValve13(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokeManifoldValve13 - !DEC$ ATTRIBUTES ALIAS: 'SetChokeManifoldValve13' :: SetChokeManifoldValve13 - implicit none - logical, intent(in) :: v - ChokeManifold%ChokeManifoldValve13 = v - call ChangeValve(26, v) - !WRITE (*,*) ' valve 26 ', v -#ifdef deb - !print*, 'ChokeManifoldValve13=', ChokeManifoldValve13 -#endif - end subroutine - - - ! Output routines - - integer function GetHydraulicChock1() - !DEC$ ATTRIBUTES DLLEXPORT :: GetHydraulicChock1 - !DEC$ ATTRIBUTES ALIAS: 'GetHydraulicChock1' :: GetHydraulicChock1 - implicit none - GetHydraulicChock1 = ChokeManifold%HydraulicChock1 - !GetHydraulicChock1 = 23 - end function - - integer function GetHydraulicChock2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetHydraulicChock2 - !DEC$ ATTRIBUTES ALIAS: 'GetHydraulicChock2' :: GetHydraulicChock2 - implicit none - GetHydraulicChock2 = ChokeManifold%HydraulicChock2 - !GetHydraulicChock2 = 54 - end function - + endif + !WRITE (*,*) ' valve 34 ', Valve(34)%Status, ' arg ', v +end subroutine end module CChokeManifold \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CChokeManifoldVariables.f90 b/CSharp/Equipments/ControlPanels/CChokeManifoldVariables.f90 index 9e528e8..9afc539 100644 --- a/CSharp/Equipments/ControlPanels/CChokeManifoldVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CChokeManifoldVariables.f90 @@ -1,5 +1,4 @@ module CChokeManifoldVariables - use CManifolds implicit none public Type :: ChokeManifoldType @@ -29,40 +28,9 @@ module CChokeManifoldVariables logical :: RightManChokeOnProblem = .false. End Type ChokeManifoldType - Type(ChokeManifoldType)::ChokeManifold - contains - subroutine SetHydraulicChock1(v) - implicit none - integer, intent(in) :: v - ChokeManifold%HydraulicChock1 = v - if(ChokeManifold%HyChock1OnProblem) then - call ChangeValve(33, .true.) - else - if(v == 100) then - if(Manifold%Valve(33)%Status) call ChangeValve(33, .false.) - else - if(.not.Manifold%Valve(33)%Status) call ChangeValve(33, .true.) - endif - endif - !WRITE (*,*) ' valve 33 ', Valve(33)%Status, ' arg ', v - end subroutine + contains - subroutine SetHydraulicChock2(v) - implicit none - integer, intent(in) :: v - ChokeManifold%HydraulicChock2 = v - if(ChokeManifold%HyChock2OnProblem) then - call ChangeValve(34, .true.) - else - if(v==100) then - if(Manifold%Valve(34)%Status) call ChangeValve(34, .false.) - else - if(.not.Manifold%Valve(34)%Status) call ChangeValve(34, .true.) - endif - endif - !WRITE (*,*) ' valve 34 ', Valve(34)%Status, ' arg ', v - end subroutine endmodule CChokeManifoldVariables \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CDataDisplayConsole.f90 b/CSharp/Equipments/ControlPanels/CDataDisplayConsole.f90 index 6f86e47..de25b80 100644 --- a/CSharp/Equipments/ControlPanels/CDataDisplayConsole.f90 +++ b/CSharp/Equipments/ControlPanels/CDataDisplayConsole.f90 @@ -1,796 +1,153 @@ module CDataDisplayConsole - use CDataDisplayConsoleVariables + ! use CDataDisplayConsole + use ConfigurationVariables implicit none public contains - - !Portable - subroutine SetTripAlarmLow(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripAlarmLow - !DEC$ ATTRIBUTES ALIAS: 'SetTripAlarmLow' :: SetTripAlarmLow - !use MudSystemVARIABLES, only: TripTank_MinVol_Allowded + subroutine Set_TotalDepth(v) + use ConfigurationVariables !@!!, only: data%EquipmentControl%DrillingWatch%Depth + ! use CSimulationVariables, only: SetDistanceDrilled implicit none - real*8, intent(in) :: v - DataDisplayConsole%TripAlarmLow = v - !TripTank_MinVol_Allowded = v -#ifdef deb - print*, 'TripAlarmLow=', DataDisplayConsole%TripAlarmLow -#endif + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%TotalWellDepth = v + data%EquipmentControl%DrillingWatch%Depth = v + ! call SetDistanceDrilled(v) end subroutine - - subroutine SetTripAlarmHigh(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripAlarmHigh - !DEC$ ATTRIBUTES ALIAS: 'SetTripAlarmHigh' :: SetTripAlarmHigh - !use MudSystemVARIABLES, only: TripTank_MaxVol_Allowded + + subroutine Set_BitPosition(v) + use ConfigurationVariables !@!!, only: data%EquipmentControl%DrillingWatch%BitPosition implicit none - real*8, intent(in) :: v - DataDisplayConsole%TripAlarmHigh = v - !TripTank_MaxVol_Allowded = v -#ifdef deb - print*, 'TripAlarmHigh=', DataDisplayConsole%TripAlarmHigh -#endif + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%BitDepth = v + data%EquipmentControl%DrillingWatch%BitPosition = v end subroutine - - subroutine SetRetFlowAlarmLow(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRetFlowAlarmLow - !DEC$ ATTRIBUTES ALIAS: 'SetRetFlowAlarmLow' :: SetRetFlowAlarmLow - !use MudSystemVARIABLES, only: MFFI_MinPercent_Allowded + subroutine Set_RotaryTorque(v) + use ConfigurationVariables !@!!, only: data%EquipmentControl%DrillingWatch%Torque implicit none - real*8, intent(in) :: v - DataDisplayConsole%RetFlowAlarmLow = v - !MFFI_MinPercent_Allowded = v -#ifdef deb - print*, 'RetFlowAlarmLow=', DataDisplayConsole%RetFlowAlarmLow -#endif + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%RotaryTorqueGauge = v + data%EquipmentControl%DrillingWatch%Torque = v + data%EquipmentControl%DataDisplayConsole%RTTorque = v end subroutine - - subroutine SetRetFlowAlarmHigh(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRetFlowAlarmHigh - !DEC$ ATTRIBUTES ALIAS: 'SetRetFlowAlarmHigh' :: SetRetFlowAlarmHigh - !use MudSystemVARIABLES, only: MFFI_MaxPercent_Allowded + + + subroutine Set_MudWeightIn(v) + use ConfigurationVariables !@!, only: MudWeightInDw => data%EquipmentControl%DataDisplayConsole%MudWeightIn implicit none - real*8, intent(in) :: v - DataDisplayConsole%RetFlowAlarmHigh = v - !MFFI_MaxPercent_Allowded = v -#ifdef deb - print*, 'RetFlowAlarmHigh=', DataDisplayConsole%RetFlowAlarmHigh -#endif + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%MudWeightIn = v + data%EquipmentControl%DrillingWatch%MudWeightIn = v end subroutine - - subroutine SetPitAlarmLow(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPitAlarmLow - !DEC$ ATTRIBUTES ALIAS: 'SetPitAlarmLow' :: SetPitAlarmLow + subroutine Set_MudWeightOut(v) + use ConfigurationVariables !@!, only: MudWeightOutDw => data%EquipmentControl%DataDisplayConsole%MudWeightOut implicit none - real*8, intent(in) :: v - DataDisplayConsole%PitAlarmLow = v - !call Log_4('PitAlarmLow=', PitAlarmLow) -#ifdef deb - print*, 'PitAlarmLow=', DataDisplayConsole%PitAlarmLow -#endif + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%MudWeightOut = v + data%EquipmentControl%DrillingWatch%MudWeightOut = v end subroutine - - subroutine SetPitAlarmHigh(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPitAlarmHigh - !DEC$ ATTRIBUTES ALIAS: 'SetPitAlarmHigh' :: SetPitAlarmHigh + + subroutine Set_TripTankVolume(v) + use ConfigurationVariables !@!, only: data%EquipmentControl%DrillingWatch%TripTankVolume implicit none - real*8, intent(in) :: v - DataDisplayConsole%PitAlarmHigh = v - !call Log_4('PitAlarmHigh=', PitAlarmHigh) -#ifdef deb - print*, 'PitAlarmHigh=', DataDisplayConsole%PitAlarmHigh -#endif + real(8), intent(in) :: v + data%EquipmentControl%DrillingWatch%TripTankVolume = v end subroutine - - - - - - - - - - - - - - - - ! Input routines - subroutine SetTripTankSetAlarmLow(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankSetAlarmLow - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankSetAlarmLow' :: SetTripTankSetAlarmLow - implicit none - real*8, intent(in) :: v - DataDisplayConsole%TripTankSetAlarmLow = v -#ifdef deb - print*, 'TripTankSetAlarmLow=', DataDisplayConsole%TripTankSetAlarmLow -#endif - end subroutine - - subroutine SetTripTankSetAlarmHigh(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankSetAlarmHigh - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankSetAlarmHigh' :: SetTripTankSetAlarmHigh - implicit none - real*8, intent(in) :: v - DataDisplayConsole%TripTankSetAlarmHigh = v -#ifdef deb - print*, 'TripTankSetAlarmHigh=', DataDisplayConsole%TripTankSetAlarmHigh -#endif - end subroutine - - subroutine SetTripTankSetAlarmSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankSetAlarmSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankSetAlarmSwitch' :: SetTripTankSetAlarmSwitch - implicit none - integer, intent(in) :: v - DataDisplayConsole%TripTankSetAlarmSwitch = v -#ifdef deb - print*, 'TripTankSetAlarmSwitch=', DataDisplayConsole%TripTankSetAlarmSwitch -#endif - end subroutine - - subroutine SetTripTankPowerSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankPowerSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankPowerSwitch' :: SetTripTankPowerSwitch - use CTanksVariables, only: Set_ManualPumpPower - implicit none - logical, intent(in) :: v - DataDisplayConsole%TripTankPowerSwitch = v - if(DataDisplayConsole%TripTankPowerSwitch) call Set_ManualPumpPower(DataDisplayConsole%TripTankPumpSwitch) -#ifdef deb - print*, 'TripTankPowerSwitch=', DataDisplayConsole%TripTankPowerSwitch -#endif - end subroutine - - subroutine SetTripTankPumpSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankPumpSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankPumpSwitch' :: SetTripTankPumpSwitch - use CTanksVariables, only: Set_ManualPumpPower - implicit none - logical, intent(in) :: v - DataDisplayConsole%TripTankPumpSwitch = v - if(DataDisplayConsole%TripTankPowerSwitch) call Set_ManualPumpPower(DataDisplayConsole%TripTankPumpSwitch) -#ifdef deb - print*, 'TripTankPumpSwitch=', DataDisplayConsole%TripTankPumpSwitch -#endif - end subroutine - - subroutine SetTripTankHornSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankHornSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankHornSwitch' :: SetTripTankHornSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%TripTankHornSwitch = v -#ifdef deb - print*, 'TripTankHornSwitch=', DataDisplayConsole%TripTankHornSwitch -#endif - end subroutine - - subroutine SetAcidGasDetectionHornSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAcidGasDetectionHornSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetAcidGasDetectionHornSwitch' :: SetAcidGasDetectionHornSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%AcidGasDetectionHornSwitch = v -#ifdef deb - print*, 'AcidGasDetectionHornSwitch=', DataDisplayConsole%AcidGasDetectionHornSwitch -#endif - end subroutine - - subroutine SetTotalStrokeCounterResetSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTotalStrokeCounterResetSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetTotalStrokeCounterResetSwitch' :: SetTotalStrokeCounterResetSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%TotalStrokeCounterResetSwitch = v -#ifdef deb - print*, 'TotalStrokeCounterResetSwitch=', DataDisplayConsole%TotalStrokeCounterResetSwitch -#endif - end subroutine - - subroutine SetDrillingTrippingSelectorSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetDrillingTrippingSelectorSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetDrillingTrippingSelectorSwitch' :: SetDrillingTrippingSelectorSwitch - use CCommonVariables - implicit none - logical, intent(in) :: v - DataDisplayConsole%DrillingTrippingSelectorSwitch = v - Common%DrillWatchOperationMode = v -#ifdef deb - print*, 'DrillingTrippingSelectorSwitch=', DataDisplayConsole%DrillingTrippingSelectorSwitch -#endif - end subroutine - - subroutine SetMVTSetAlarmLowKnob(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTSetAlarmLowKnob - !DEC$ ATTRIBUTES ALIAS: 'SetMVTSetAlarmLowKnob' :: SetMVTSetAlarmLowKnob - implicit none - real*8, intent(in) :: v - DataDisplayConsole%MVTSetAlarmLowKnob = v -#ifdef deb - print*, 'MVTSetAlarmLowKnob=', DataDisplayConsole%MVTSetAlarmLowKnob -#endif - end subroutine - - subroutine SetMVTSetAlarmHighKnob(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTSetAlarmHighKnob - !DEC$ ATTRIBUTES ALIAS: 'SetMVTSetAlarmHighKnob' :: SetMVTSetAlarmHighKnob - implicit none - real*8, intent(in) :: v - DataDisplayConsole%MVTSetAlarmHighKnob = v -#ifdef deb - print*, 'MVTSetAlarmHighKnob=', DataDisplayConsole%MVTSetAlarmHighKnob -#endif - end subroutine - - subroutine SetMVTSetAlarmSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTSetAlarmSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMVTSetAlarmSwitch' :: SetMVTSetAlarmSwitch - implicit none - integer, intent(in) :: v - DataDisplayConsole%MVTSetAlarmSwitch = v -#ifdef deb - print*, 'MVTSetAlarmSwitch=', DataDisplayConsole%MVTSetAlarmSwitch -#endif - end subroutine - - subroutine SetMudTank1Switch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudTank1Switch - !DEC$ ATTRIBUTES ALIAS: 'SetMudTank1Switch' :: SetMudTank1Switch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MudTank1Switch = v -#ifdef deb - print*, 'MudTank1Switch=', DataDisplayConsole%MudTank1Switch -#endif - end subroutine - - subroutine SetMudTank2Switch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudTank2Switch - !DEC$ ATTRIBUTES ALIAS: 'SetMudTank2Switch' :: SetMudTank2Switch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MudTank2Switch = v -#ifdef deb - print*, 'MudTank2Switch=', DataDisplayConsole%MudTank2Switch -#endif - end subroutine - - subroutine SetMudTank3Switch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudTank3Switch - !DEC$ ATTRIBUTES ALIAS: 'SetMudTank3Switch' :: SetMudTank3Switch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MudTank3Switch = v -#ifdef deb - print*, 'MudTank3Switch=', DataDisplayConsole%MudTank3Switch -#endif - end subroutine - - subroutine SetMudTank4Switch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudTank4Switch - !DEC$ ATTRIBUTES ALIAS: 'SetMudTank4Switch' :: SetMudTank4Switch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MudTank4Switch = v -#ifdef deb - print*, 'MudTank4Switch=', DataDisplayConsole%MudTank4Switch -#endif - end subroutine - - subroutine SetMVTFineKnob(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTFineKnob - !DEC$ ATTRIBUTES ALIAS: 'SetMVTFineKnob' :: SetMVTFineKnob - implicit none - real*8, intent(in) :: v - DataDisplayConsole%MVTFineKnob = v -#ifdef deb - print*, 'MVTFineKnob=', DataDisplayConsole%MVTFineKnob -#endif - end subroutine - - subroutine SetMVTCoarseKnob(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTCoarseKnob - !DEC$ ATTRIBUTES ALIAS: 'SetMVTCoarseKnob' :: SetMVTCoarseKnob - implicit none - real*8, intent(in) :: v - DataDisplayConsole%MVTCoarseKnob = v -#ifdef deb - print*, 'MVTCoarseKnob=', DataDisplayConsole%MVTCoarseKnob -#endif - end subroutine - - subroutine SetMVTHornSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTHornSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMVTHornSwitch' :: SetMVTHornSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MVTHornSwitch = v -#ifdef deb - print*, 'MVTHornSwitch=', DataDisplayConsole%MVTHornSwitch -#endif - end subroutine - - subroutine SetMVTDeviationTripSelectionSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTDeviationTripSelectionSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMVTDeviationTripSelectionSwitch' :: SetMVTDeviationTripSelectionSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MVTDeviationTripSelectionSwitch = v -#ifdef deb - print*, 'MVTDeviationTripSelectionSwitch=', DataDisplayConsole%MVTDeviationTripSelectionSwitch -#endif - end subroutine - - subroutine SetMVTPowerSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMVTPowerSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMVTPowerSwitch' :: SetMVTPowerSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MVTPowerSwitch = v -#ifdef deb - print*, 'MVTPowerSwitch=', DataDisplayConsole%MVTPowerSwitch -#endif - end subroutine - - subroutine SetMFFIResetTotalStrokes(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFIResetTotalStrokes - !DEC$ ATTRIBUTES ALIAS: 'SetMFFIResetTotalStrokes' :: SetMFFIResetTotalStrokes - implicit none - logical, intent(in) :: v - DataDisplayConsole%MFFIResetTotalStrokes = v -#ifdef deb - print*, 'MFFIResetTotalStrokes=', DataDisplayConsole%MFFIResetTotalStrokes -#endif - end subroutine - - subroutine SetMFFIResetFillCounter(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFIResetFillCounter - !DEC$ ATTRIBUTES ALIAS: 'SetMFFIResetFillCounter' :: SetMFFIResetFillCounter - implicit none - logical, intent(in) :: v - DataDisplayConsole%MFFIResetFillCounter = v -#ifdef deb - print*, 'MFFIResetFillCounter=', DataDisplayConsole%MFFIResetFillCounter -#endif - end subroutine - - subroutine SetMFFIPumpSelectorSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFIPumpSelectorSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMFFIPumpSelectorSwitch' :: SetMFFIPumpSelectorSwitch - implicit none - integer, intent(in) :: v - DataDisplayConsole%MFFIPumpSelectorSwitch = v -#ifdef deb - print*, 'MFFIPumpSelectorSwitch=', DataDisplayConsole%MFFIPumpSelectorSwitch -#endif - end subroutine - - subroutine SetMFFIFillSPMSelectorSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFIFillSPMSelectorSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMFFIFillSPMSelectorSwitch' :: SetMFFIFillSPMSelectorSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MFFIFillSPMSelectorSwitch = v -#ifdef deb - print*, 'MFFIFillSPMSelectorSwitch=', DataDisplayConsole%MFFIFillSPMSelectorSwitch -#endif - end subroutine - - subroutine SetMFFISetAlarmLowKnob(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFISetAlarmLowKnob - !DEC$ ATTRIBUTES ALIAS: 'SetMFFISetAlarmLowKnob' :: SetMFFISetAlarmLowKnob - implicit none - real*8, intent(in) :: v - DataDisplayConsole%MFFISetAlarmLowKnob = v -#ifdef deb - print*, 'MFFISetAlarmLowKnob=', DataDisplayConsole%MFFISetAlarmLowKnob -#endif - end subroutine - - subroutine SetMFFISetAlarmHighKnob(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFISetAlarmHighKnob - !DEC$ ATTRIBUTES ALIAS: 'SetMFFISetAlarmHighKnob' :: SetMFFISetAlarmHighKnob - implicit none - real*8, intent(in) :: v - DataDisplayConsole%MFFISetAlarmHighKnob = v -#ifdef deb - print*, 'MFFISetAlarmHighKnob=', DataDisplayConsole%MFFISetAlarmHighKnob -#endif - end subroutine - - subroutine SetMFFISetAlarmSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFISetAlarmSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMFFISetAlarmSwitch' :: SetMFFISetAlarmSwitch - implicit none - integer, intent(in) :: v - DataDisplayConsole%MFFISetAlarmSwitch = v -#ifdef deb - print*, 'MFFISetAlarmSwitch=', DataDisplayConsole%MFFISetAlarmSwitch -#endif - end subroutine - - subroutine SetMFFIPowerSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFIPowerSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMFFIPowerSwitch' :: SetMFFIPowerSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MFFIPowerSwitch = v -#ifdef deb - print*, 'MFFIPowerSwitch=', DataDisplayConsole%MFFIPowerSwitch -#endif - end subroutine - - subroutine SetMFFIHornSwitch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMFFIHornSwitch - !DEC$ ATTRIBUTES ALIAS: 'SetMFFIHornSwitch' :: SetMFFIHornSwitch - implicit none - logical, intent(in) :: v - DataDisplayConsole%MFFIHornSwitch = v -#ifdef deb - print*, 'MFFIHornSwitch=', DataDisplayConsole%MFFIHornSwitch -#endif + subroutine Set_FillVolume(v) + use ConfigurationVariables !@!, only: data%EquipmentControl%DrillingWatch%FillVolume + implicit none + real(8), intent(in) :: v + data%EquipmentControl%DrillingWatch%FillVolume = v end subroutine - subroutine SetTotalWellDepth(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTotalWellDepth - !DEC$ ATTRIBUTES ALIAS: 'SetTotalWellDepth' :: SetTotalWellDepth - implicit none - real(8), intent(in) :: v - call Set_TotalDepth(v) -#ifdef deb - print*, 'TotalWellDepth=', v -#endif + subroutine Set_HookLoad(v) + use ConfigurationVariables !@!, only: HookLoadDw => data%EquipmentControl%DataDisplayConsole%HookLoad + implicit none + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%HookLoadPointer = v + data%EquipmentControl%DrillingWatch%HookLoad = v * 1000 + data%EquipmentControl%DataDisplayConsole%HookLoad = v end subroutine - subroutine SetResetWob(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetResetWob - !DEC$ ATTRIBUTES ALIAS: 'SetResetWob' :: SetResetWob - implicit none - logical, intent(in) :: v - DataDisplayConsole%ResetWob = v -#ifdef deb - print*, 'ResetWob=', DataDisplayConsole%ResetWob -#endif + subroutine Set_WeightOnBit(v) + use ConfigurationVariables !@!, only: data%EquipmentControl%DrillingWatch%WeightOnBit + implicit none + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%WOBPointer = v + data%EquipmentControl%DrillingWatch%WeightOnBit = v + data%EquipmentControl%DataDisplayConsole%WOP = v end subroutine - subroutine SetClutch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetClutch - !DEC$ ATTRIBUTES ALIAS: 'SetClutch' :: SetClutch - implicit none - logical, intent(in) :: v - DataDisplayConsole%Clutch = v -#ifdef deb - print*, 'Clutch=', DataDisplayConsole%Clutch -#endif + subroutine Set_ROP(v) + use ConfigurationVariables !@!, only: ROPDw => data%EquipmentControl%DataDisplayConsole%ROP + implicit none + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%ROP = v + data%EquipmentControl%DrillingWatch%ROP = v end subroutine - - - ! Output routines - real(8) function GetWOBPointer() - !DEC$ ATTRIBUTES DLLEXPORT :: GetWOBPointer - !DEC$ ATTRIBUTES ALIAS: 'GetWOBPointer' :: GetWOBPointer - implicit none - GetWOBPointer = DataDisplayConsole%WOBPointer - end function - - real(8) function GetHookLoadPointer() - !DEC$ ATTRIBUTES DLLEXPORT :: GetHookLoadPointer - !DEC$ ATTRIBUTES ALIAS: 'GetHookLoadPointer' :: GetHookLoadPointer - implicit none - GetHookLoadPointer = DataDisplayConsole%HookLoadPointer - end function - - real(8) function GetTripTankGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTripTankGauge - !DEC$ ATTRIBUTES ALIAS: 'GetTripTankGauge' :: GetTripTankGauge - implicit none - GetTripTankGauge = DataDisplayConsole%TripTankGauge / 42.0 - !GetTripTankGauge = 23 - end function - - integer function GetTripTankAlarmLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTripTankAlarmLED - !DEC$ ATTRIBUTES ALIAS: 'GetTripTankAlarmLED' :: GetTripTankAlarmLED - implicit none - GetTripTankAlarmLED = DataDisplayConsole%TripTankAlarmLED - !GetTripTankAlarmLED = 1 - end function - - integer function GetTripTankPumpLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTripTankPumpLED - !DEC$ ATTRIBUTES ALIAS: 'GetTripTankPumpLED' :: GetTripTankPumpLED - implicit none - GetTripTankPumpLED = DataDisplayConsole%TripTankPumpLED - end function - - real(8) function GetStandPipePressureGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetStandPipePressureGauge - !DEC$ ATTRIBUTES ALIAS: 'GetStandPipePressureGauge' :: GetStandPipePressureGauge - implicit none - GetStandPipePressureGauge = DataDisplayConsole%StandPipePressureGauge - end function - - real(8) function GetCasingPressureGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetCasingPressureGauge - !DEC$ ATTRIBUTES ALIAS: 'GetCasingPressureGauge' :: GetCasingPressureGauge - implicit none - GetCasingPressureGauge = DataDisplayConsole%CasingPressureGauge - end function - - real(8) function GetMP1SPMGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMP1SPMGauge - !DEC$ ATTRIBUTES ALIAS: 'GetMP1SPMGauge' :: GetMP1SPMGauge - implicit none - GetMP1SPMGauge = DataDisplayConsole%MP1SPMGauge - end function - - real(8) function GetMP2SPMGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMP2SPMGauge - !DEC$ ATTRIBUTES ALIAS: 'GetMP2SPMGauge' :: GetMP2SPMGauge - implicit none - GetMP2SPMGauge = DataDisplayConsole%MP2SPMGauge - end function - - real(8) function GetReturnLineTempGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetReturnLineTempGauge - !DEC$ ATTRIBUTES ALIAS: 'GetReturnLineTempGauge' :: GetReturnLineTempGauge - implicit none - GetReturnLineTempGauge = DataDisplayConsole%ReturnLineTempGauge - end function - - real(8) function GetRotaryTorqueGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetRotaryTorqueGauge - !DEC$ ATTRIBUTES ALIAS: 'GetRotaryTorqueGauge' :: GetRotaryTorqueGauge - implicit none - GetRotaryTorqueGauge = DataDisplayConsole%RotaryTorqueGauge - end function - - real(8) function GetRotaryRPMGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetRotaryRPMGauge - !DEC$ ATTRIBUTES ALIAS: 'GetRotaryRPMGauge' :: GetRotaryRPMGauge - implicit none - GetRotaryRPMGauge = DataDisplayConsole%RotaryRPMGauge - end function - - integer function GetAcidGasDetectionLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetAcidGasDetectionLED - !DEC$ ATTRIBUTES ALIAS: 'GetAcidGasDetectionLED' :: GetAcidGasDetectionLED - implicit none - GetAcidGasDetectionLED = DataDisplayConsole%AcidGasDetectionLED - end function - - real(8) function GetTotalStrokeCounter() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTotalStrokeCounter - !DEC$ ATTRIBUTES ALIAS: 'GetTotalStrokeCounter' :: GetTotalStrokeCounter - implicit none - GetTotalStrokeCounter = DataDisplayConsole%TotalStrokeCounter - !GetTotalStrokeCounter = 456.9 - end function - - real(8) function GetPitGainLossGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPitGainLossGauge - !DEC$ ATTRIBUTES ALIAS: 'GetPitGainLossGauge' :: GetPitGainLossGauge - implicit none - GetPitGainLossGauge = DataDisplayConsole%PitGainLossGauge - !GetPitGainLossGauge = 44 - end function - - real(8) function GetMudTanksVolumeGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMudTanksVolumeGauge - !DEC$ ATTRIBUTES ALIAS: 'GetMudTanksVolumeGauge' :: GetMudTanksVolumeGauge - implicit none - GetMudTanksVolumeGauge = DataDisplayConsole%MudTanksVolumeGauge / 42.0 - end function - - integer function GetMVTAlarmLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMVTAlarmLED - !DEC$ ATTRIBUTES ALIAS: 'GetMVTAlarmLED' :: GetMVTAlarmLED - implicit none - GetMVTAlarmLED = DataDisplayConsole%MVTAlarmLED - !GetMVTAlarmLED = 1 - end function - - real(8) function GetReturnMudFlowGauge() - !DEC$ ATTRIBUTES DLLEXPORT :: GetReturnMudFlowGauge - !DEC$ ATTRIBUTES ALIAS: 'GetReturnMudFlowGauge' :: GetReturnMudFlowGauge - implicit none - GetReturnMudFlowGauge = DataDisplayConsole%ReturnMudFlowGauge - !GetReturnMudFlowGauge = 12 - end function - - real(8) function GetFillStrokeCounter() - !DEC$ ATTRIBUTES DLLEXPORT :: GetFillStrokeCounter - !DEC$ ATTRIBUTES ALIAS: 'GetFillStrokeCounter' :: GetFillStrokeCounter - implicit none - GetFillStrokeCounter = DataDisplayConsole%FillStrokeCounter - end function - - real(8) function GetMFFITotalStrokeCounter() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMFFITotalStrokeCounter - !DEC$ ATTRIBUTES ALIAS: 'GetMFFITotalStrokeCounter' :: GetMFFITotalStrokeCounter - implicit none - GetMFFITotalStrokeCounter = DataDisplayConsole%MFFITotalStrokeCounter - end function - - integer function GetMFFIAlarmLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMFFIAlarmLED - !DEC$ ATTRIBUTES ALIAS: 'GetMFFIAlarmLED' :: GetMFFIAlarmLED - implicit none - GetMFFIAlarmLED = DataDisplayConsole%MFFIAlarmLED - !GetMFFIAlarmLED = 1 - end function - - integer function GetMFFIPumpLED() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMFFIPumpLED - !DEC$ ATTRIBUTES ALIAS: 'GetMFFIPumpLED' :: GetMFFIPumpLED - implicit none - GetMFFIPumpLED = DataDisplayConsole%MFFIPumpLED - end function - - real(8) function GetTotalWellDepth() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTotalWellDepth - !DEC$ ATTRIBUTES ALIAS: 'GetTotalWellDepth' :: GetTotalWellDepth - implicit none - GetTotalWellDepth = DataDisplayConsole%TotalWellDepth - end function - - real(8) function GetBitDepth() - !DEC$ ATTRIBUTES DLLEXPORT :: GetBitDepth - !DEC$ ATTRIBUTES ALIAS: 'GetBitDepth' :: GetBitDepth - implicit none - GetBitDepth = DataDisplayConsole%BitDepth - end function - - real(8) function GetHookLoad() - !DEC$ ATTRIBUTES DLLEXPORT :: GetHookLoad - !DEC$ ATTRIBUTES ALIAS: 'GetHookLoad' :: GetHookLoad - implicit none - GetHookLoad = DataDisplayConsole%HookLoad - end function - - real(8) function GetStandPipePressure2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetStandPipePressure2 - !DEC$ ATTRIBUTES ALIAS: 'GetStandPipePressure2' :: GetStandPipePressure2 - implicit none - GetStandPipePressure2 = DataDisplayConsole%StandPipePressure - end function - - real(8) function GetCasingPressure2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetCasingPressure2 - !DEC$ ATTRIBUTES ALIAS: 'GetCasingPressure2' :: GetCasingPressure2 - implicit none - GetCasingPressure2 = DataDisplayConsole%CasingPressure - end function - - real(8) function GetMP1SPM() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMP1SPM - !DEC$ ATTRIBUTES ALIAS: 'GetMP1SPM' :: GetMP1SPM - implicit none - GetMP1SPM = DataDisplayConsole%MP1SPM - end function - - real(8) function GetMP2SPM() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMP2SPM - !DEC$ ATTRIBUTES ALIAS: 'GetMP2SPM' :: GetMP2SPM - implicit none - GetMP2SPM = DataDisplayConsole%MP2SPM - end function - - real(8) function GetRTTorque() - !DEC$ ATTRIBUTES DLLEXPORT :: GetRTTorque - !DEC$ ATTRIBUTES ALIAS: 'GetRTTorque' :: GetRTTorque - implicit none - GetRTTorque = DataDisplayConsole%RTTorque - end function - - real(8) function GetRTRPM() - !DEC$ ATTRIBUTES DLLEXPORT :: GetRTRPM - !DEC$ ATTRIBUTES ALIAS: 'GetRTRPM' :: GetRTRPM - implicit none - GetRTRPM = DataDisplayConsole%RTRPM - end function - - real(8) function GetWOP() - !DEC$ ATTRIBUTES DLLEXPORT :: GetWOP - !DEC$ ATTRIBUTES ALIAS: 'GetWOP' :: GetWOP - implicit none - GetWOP = DataDisplayConsole%WOP - end function - - real(8) function GetROP() - !DEC$ ATTRIBUTES DLLEXPORT :: GetROP - !DEC$ ATTRIBUTES ALIAS: 'GetROP' :: GetROP - implicit none - GetROP = DataDisplayConsole%ROP - end function - - real(8) function GetMudWeightIn() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMudWeightIn - !DEC$ ATTRIBUTES ALIAS: 'GetMudWeightIn' :: GetMudWeightIn - implicit none - GetMudWeightIn = DataDisplayConsole%MudWeightIn - end function - - real(8) function GetMudWeightOut() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMudWeightOut - !DEC$ ATTRIBUTES ALIAS: 'GetMudWeightOut' :: GetMudWeightOut - implicit none - GetMudWeightOut = DataDisplayConsole%MudWeightOut - end function - logical function GetBuzzer1() - !DEC$ ATTRIBUTES DLLEXPORT :: GetBuzzer1 - !DEC$ ATTRIBUTES ALIAS: 'GetBuzzer1' :: GetBuzzer1 - implicit none - GetBuzzer1 = DataDisplayConsole%Buzzer1 - !GetBuzzer1 = .true. - end function - - logical function GetBuzzer2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetBuzzer2 - !DEC$ ATTRIBUTES ALIAS: 'GetBuzzer2' :: GetBuzzer2 - implicit none - GetBuzzer2 = DataDisplayConsole%Buzzer2 - !GetBuzzer2 = .true. - end function - - logical function GetBuzzer3() - !DEC$ ATTRIBUTES DLLEXPORT :: GetBuzzer3 - !DEC$ ATTRIBUTES ALIAS: 'GetBuzzer3' :: GetBuzzer3 + subroutine Set_CasingPressure(v) + use ConfigurationVariables !@!, only: CasingPressureDw => CasingPressure + use CChokeControlPanelVariables + use ConfigurationVariables!, only: CasingPressureChoke => CasingPressure implicit none - GetBuzzer3 = DataDisplayConsole%Buzzer3 - !GetBuzzer3 = .true. - end function - - logical function GetBuzzer4() - !DEC$ ATTRIBUTES DLLEXPORT :: GetBuzzer4 - !DEC$ ATTRIBUTES ALIAS: 'GetBuzzer4' :: GetBuzzer4 - implicit none - GetBuzzer4 = DataDisplayConsole%Buzzer4 - !GetBuzzer4 = .true. - end function - - - + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%CasingPressureGauge = v + data%EquipmentControl%DrillingWatch%CasingPressure = v + data%EquipmentControl%ChokeControlPanel%CasingPressure = v + data%EquipmentControl%DataDisplayConsole%CasingPressure = v + end subroutine + subroutine Set_StandPipePressure(v) + use ConfigurationVariables !@!, only: data%EquipmentControl%DrillingWatch%PumpPressure + use CChokeControlPanelVariables + use ConfigurationVariables!, only: StandPipePressureChoke => data%EquipmentControl%DataDisplayConsole%StandPipePressure + implicit none + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%StandPipePressureGauge = v + data%EquipmentControl%DrillingWatch%PumpPressure = v + data%EquipmentControl%ChokeControlPanel%StandPipePressure = v + data%EquipmentControl%DataDisplayConsole%StandPipePressure = v + + + + end subroutine + subroutine Set_RotaryRPMGauge(v) + use ConfigurationVariables !@!, only: data%EquipmentControl%DrillingWatch%RPM + implicit none + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%RotaryRPMGauge = v + data%EquipmentControl%DrillingWatch%RPM = v + data%EquipmentControl%DataDisplayConsole%RTRPM = v + ! call data%EquipmentControl%DataDisplayConsole%OnRotaryRpmChange%RunAll(v) + end subroutine - !portable - real(8) function GetPortWeightOnBit() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPortWeightOnBit - !DEC$ ATTRIBUTES ALIAS: 'GetPortWeightOnBit' :: GetPortWeightOnBit - implicit none - GetPortWeightOnBit = DataDisplayConsole%PortWeightOnBit - end function - - real(8) function GetPortHookLoad() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPortHookLoad - !DEC$ ATTRIBUTES ALIAS: 'GetPortHookLoad' :: GetPortHookLoad - implicit none - GetPortHookLoad = DataDisplayConsole%PortHookLoad - end function - - real(8) function GetPortCasingPressure() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPortCasingPressure - !DEC$ ATTRIBUTES ALIAS: 'GetPortCasingPressure' :: GetPortCasingPressure + subroutine Set_MP1SPMGauge(v) implicit none - GetPortCasingPressure = DataDisplayConsole%PortCasingPressure - end function - - real(8) function GetPortPumpPressure() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPortPumpPressure - !DEC$ ATTRIBUTES ALIAS: 'GetPortPumpPressure' :: GetPortPumpPressure + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%MP1SPMGauge = v + data%EquipmentControl%DataDisplayConsole%MP1SPM = v + !@data%State%unitySignals%(PumpsSpmChanges)) call PumpsSpmChanges(data%EquipmentControl%DataDisplayConsole%MP1SPMGauge, data%EquipmentControl%DataDisplayConsole%MP2SPMGauge) +#ifdef deb + print*, 'MP1SPMGauge=', data%EquipmentControl%DataDisplayConsole%MP1SPMGauge +#endif + end subroutine + + subroutine Set_MP2SPMGauge(v) implicit none - GetPortPumpPressure = DataDisplayConsole%PortPumpPressure - end function - - + real(8), intent(in) :: v + data%EquipmentControl%DataDisplayConsole%MP2SPMGauge = v + data%EquipmentControl%DataDisplayConsole%MP2SPM = v + !@data%State%unitySignals%(PumpsSpmChanges)) call PumpsSpmChanges(data%EquipmentControl%DataDisplayConsole%MP1SPMGauge, data%EquipmentControl%DataDisplayConsole%MP2SPMGauge) +#ifdef deb + print*, 'MP2SPMGauge=', data%EquipmentControl%DataDisplayConsole%MP2SPMGauge +#endif + end subroutine end module CDataDisplayConsole \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 b/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 index 65c04db..8f76c26 100644 --- a/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CDataDisplayConsoleVariables.f90 @@ -96,157 +96,11 @@ module CDataDisplayConsoleVariables logical :: Buzzer3 logical :: Buzzer4 End Type DataDisplayConsoleType - Type(DataDisplayConsoleType) :: DataDisplayConsole + ! events - procedure (ActionDualDouble), pointer :: PumpsSpmChanges => null() - - contains - - - subroutine Set_TotalDepth(v) - use CDrillWatchVariables!!, only: DrillingWatch%Depth - ! use CSimulationVariables, only: SetDistanceDrilled - implicit none - real(8), intent(in) :: v - DataDisplayConsole%TotalWellDepth = v - DrillingWatch%Depth = v - ! call SetDistanceDrilled(v) - end subroutine - - subroutine Set_BitPosition(v) - use CDrillWatchVariables!!, only: DrillingWatch%BitPosition - implicit none - real(8), intent(in) :: v - DataDisplayConsole%BitDepth = v - DrillingWatch%BitPosition = v - end subroutine - - subroutine Set_RotaryTorque(v) - use CDrillWatchVariables!!, only: DrillingWatch%Torque - implicit none - real(8), intent(in) :: v - DataDisplayConsole%RotaryTorqueGauge = v - DrillingWatch%Torque = v - DataDisplayConsole%RTTorque = v - end subroutine - - - subroutine Set_MudWeightIn(v) - use CDrillWatchVariables!, only: MudWeightInDw => DataDisplayConsole%MudWeightIn - implicit none - real(8), intent(in) :: v - DataDisplayConsole%MudWeightIn = v - DrillingWatch%MudWeightIn = v - end subroutine - - subroutine Set_MudWeightOut(v) - use CDrillWatchVariables!, only: MudWeightOutDw => DataDisplayConsole%MudWeightOut - implicit none - real(8), intent(in) :: v - DataDisplayConsole%MudWeightOut = v - DrillingWatch%MudWeightOut = v - end subroutine - - subroutine Set_TripTankVolume(v) - use CDrillWatchVariables!, only: DrillingWatch%TripTankVolume - implicit none - real(8), intent(in) :: v - DrillingWatch%TripTankVolume = v - end subroutine - - subroutine Set_FillVolume(v) - use CDrillWatchVariables!, only: DrillingWatch%FillVolume - implicit none - real(8), intent(in) :: v - DrillingWatch%FillVolume = v - end subroutine - - subroutine Set_HookLoad(v) - use CDrillWatchVariables!, only: HookLoadDw => DataDisplayConsole%HookLoad - implicit none - real(8), intent(in) :: v - DataDisplayConsole%HookLoadPointer = v - DrillingWatch%HookLoad = v * 1000 - DataDisplayConsole%HookLoad = v - end subroutine - - subroutine Set_WeightOnBit(v) - use CDrillWatchVariables!, only: DrillingWatch%WeightOnBit - implicit none - real(8), intent(in) :: v - DataDisplayConsole%WOBPointer = v - DrillingWatch%WeightOnBit = v - DataDisplayConsole%WOP = v - end subroutine - - subroutine Set_ROP(v) - use CDrillWatchVariables!, only: ROPDw => DataDisplayConsole%ROP - implicit none - real(8), intent(in) :: v - DataDisplayConsole%ROP = v - DrillingWatch%ROP = v - end subroutine - - subroutine Set_CasingPressure(v) - use CDrillWatchVariables!, only: CasingPressureDw => CasingPressure - use CChokeControlPanelVariables!, only: CasingPressureChoke => CasingPressure - implicit none - real(8), intent(in) :: v - DataDisplayConsole%CasingPressureGauge = v - DrillingWatch%CasingPressure = v - ChokeControlPanel%CasingPressure = v - DataDisplayConsole%CasingPressure = v - end subroutine - - subroutine Set_StandPipePressure(v) - use CDrillWatchVariables!, only: DrillingWatch%PumpPressure - use CChokeControlPanelVariables!, only: StandPipePressureChoke => DataDisplayConsole%StandPipePressure - implicit none - real(8), intent(in) :: v - DataDisplayConsole%StandPipePressureGauge = v - DrillingWatch%PumpPressure = v - ChokeControlPanel%StandPipePressure = v - DataDisplayConsole%StandPipePressure = v - - - - end subroutine - - - subroutine Set_RotaryRPMGauge(v) - use CDrillWatchVariables!, only: DrillingWatch%RPM - implicit none - real(8), intent(in) :: v - DataDisplayConsole%RotaryRPMGauge = v - DrillingWatch%RPM = v - DataDisplayConsole%RTRPM = v - ! call DataDisplayConsole%OnRotaryRpmChange%RunAll(v) - end subroutine - - - - - subroutine Set_MP1SPMGauge(v) - implicit none - real(8), intent(in) :: v - DataDisplayConsole%MP1SPMGauge = v - DataDisplayConsole%MP1SPM = v - if(associated(PumpsSpmChanges)) call PumpsSpmChanges(DataDisplayConsole%MP1SPMGauge, DataDisplayConsole%MP2SPMGauge) -#ifdef deb - print*, 'MP1SPMGauge=', DataDisplayConsole%MP1SPMGauge -#endif - end subroutine + ! procedure (ActionDualDouble), pointer :: PumpsSpmChanges => null() - subroutine Set_MP2SPMGauge(v) - implicit none - real(8), intent(in) :: v - DataDisplayConsole%MP2SPMGauge = v - DataDisplayConsole%MP2SPM = v - if(associated(PumpsSpmChanges)) call PumpsSpmChanges(DataDisplayConsole%MP1SPMGauge, DataDisplayConsole%MP2SPMGauge) -#ifdef deb - print*, 'MP2SPMGauge=', DataDisplayConsole%MP2SPMGauge -#endif - end subroutine + contains end module CDataDisplayConsoleVariables \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 b/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 index fa6bc72..52fb1b4 100644 --- a/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 +++ b/CSharp/Equipments/ControlPanels/CDrillingConsole.f90 @@ -1,5 +1,7 @@ module CDrillingConsole - use CDrillingConsoleVariables + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables ! use CSimulationVariables use CLog4 use CLog3 @@ -13,9 +15,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetAssignmentSwitch' :: SetAssignmentSwitch implicit none integer, intent(in) :: v - DrillingConsole%AssignmentSwitch = v + data%EquipmentControl%DrillingConsole%AssignmentSwitch = v #ifdef deb - call Log_4( 'AssignmentSwitch=', DrillingConsole%AssignmentSwitch) + call Log_4( 'AssignmentSwitch=', data%EquipmentControl%DrillingConsole%AssignmentSwitch) #endif end subroutine @@ -24,9 +26,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetEmergencySwitch' :: SetEmergencySwitch implicit none logical, intent(in) :: v - DrillingConsole%EmergencySwitch = v + data%EquipmentControl%DrillingConsole%EmergencySwitch = v #ifdef deb - print*, 'EmergencySwitch=', DrillingConsole%EmergencySwitch + print*, 'EmergencySwitch=', data%EquipmentControl%DrillingConsole%EmergencySwitch #endif end subroutine @@ -35,9 +37,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetRTTorqueLimitKnob' :: SetRTTorqueLimitKnob implicit none real*8, intent(in) :: v - DrillingConsole%RTTorqueLimitKnob = v + data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob = v #ifdef deb - print*, 'RTTorqueLimitKnob=', DrillingConsole%RTTorqueLimitKnob + print*, 'RTTorqueLimitKnob=', data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob #endif end subroutine @@ -47,12 +49,12 @@ module CDrillingConsole implicit none integer, intent(in) :: v - if(DrillingConsole%MP1CPSwitch == v) return + if(data%EquipmentControl%DrillingConsole%MP1CPSwitch == v) return if(SimulationState == SimulationState_Started) then - DrillingConsole%MP1CPSwitchI = DrillingConsole%MP1CPSwitchI + 1 - if(DrillingConsole%MP1CPSwitchI >= 1) DrillingConsole%MP1CPSwitch = v - if(DrillingConsole%MP1CPSwitchI >= 100) DrillingConsole%MP1CPSwitchI = 1 + data%EquipmentControl%DrillingConsole%MP1CPSwitchI = data%EquipmentControl%DrillingConsole%MP1CPSwitchI + 1 + if(data%EquipmentControl%DrillingConsole%MP1CPSwitchI >= 1) data%EquipmentControl%DrillingConsole%MP1CPSwitch = v + if(data%EquipmentControl%DrillingConsole%MP1CPSwitchI >= 100) data%EquipmentControl%DrillingConsole%MP1CPSwitchI = 1 !call Log_3( "MP1CPSwitchI=", MP1CPSwitchI) !call Log_3( "MP1CPSwitch=", MP1CPSwitch) @@ -78,10 +80,10 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetMP1Throttle' :: SetMP1Throttle implicit none real*8, intent(in) :: v - if(DrillingConsole%MP1Throttle == v) return + if(data%EquipmentControl%DrillingConsole%MP1Throttle == v) return if(SimulationState == SimulationState_Started) then - if( abs(v - DrillingConsole%MP1Throttle) > 0.1) DrillingConsole%MP1ThrottleUpdate = .true. - if(DrillingConsole%MP1ThrottleUpdate) DrillingConsole%MP1Throttle = v + if( abs(v - data%EquipmentControl%DrillingConsole%MP1Throttle) > 0.1) data%EquipmentControl%DrillingConsole%MP1ThrottleUpdate = .true. + if(data%EquipmentControl%DrillingConsole%MP1ThrottleUpdate) data%EquipmentControl%DrillingConsole%MP1Throttle = v !call Log_3( 'v-mp1=', v) !call Log_3( 'MP1Throttle=', MP1Throttle) @@ -90,7 +92,7 @@ module CDrillingConsole !MP1Throttle = v endif #ifdef deb - print*, 'MP1Throttle=', DrillingConsole%MP1Throttle + print*, 'MP1Throttle=', data%EquipmentControl%DrillingConsole%MP1Throttle #endif end subroutine @@ -101,12 +103,12 @@ module CDrillingConsole logical, intent(in) :: v !call Log_3( 'v=', MP2SwitchT) - if(DrillingConsole%MP2Switch == v) return + if(data%EquipmentControl%DrillingConsole%MP2Switch == v) return if(SimulationState == SimulationState_Started) then - DrillingConsole%MP2SwitchI = DrillingConsole%MP2SwitchI + 1 - if(DrillingConsole%MP2SwitchI >= 1) DrillingConsole%MP2Switch = v - if(DrillingConsole%MP2SwitchI >= 100) DrillingConsole%MP2SwitchI = 1 + data%EquipmentControl%DrillingConsole%MP2SwitchI = data%EquipmentControl%DrillingConsole%MP2SwitchI + 1 + if(data%EquipmentControl%DrillingConsole%MP2SwitchI >= 1) data%EquipmentControl%DrillingConsole%MP2Switch = v + if(data%EquipmentControl%DrillingConsole%MP2SwitchI >= 100) data%EquipmentControl%DrillingConsole%MP2SwitchI = 1 !call Log_3( "MP1CPSwitchI=", MP1CPSwitchI) !call Log_3( "MP2Switch=", MP2Switch) @@ -134,10 +136,10 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetMP2Throttle' :: SetMP2Throttle implicit none real*8, intent(in) :: v - if(DrillingConsole%MP2Throttle == v) return + if(data%EquipmentControl%DrillingConsole%MP2Throttle == v) return if(SimulationState == SimulationState_Started) then - if( abs(v - DrillingConsole%MP2Throttle) > 0.1) DrillingConsole%MP2ThrottleUpdate = .true. - if(DrillingConsole%MP2ThrottleUpdate) DrillingConsole%MP2Throttle = v + if( abs(v - data%EquipmentControl%DrillingConsole%MP2Throttle) > 0.1) data%EquipmentControl%DrillingConsole%MP2ThrottleUpdate = .true. + if(data%EquipmentControl%DrillingConsole%MP2ThrottleUpdate) data%EquipmentControl%DrillingConsole%MP2Throttle = v !call Log_3( 'v-mp2=', v) !call Log_3( 'MP2Throttle=', MP2Throttle) @@ -146,7 +148,7 @@ module CDrillingConsole !MP2Throttle = v endif #ifdef deb - print*, 'MP2Throttle=', DrillingConsole%MP2Throttle + print*, 'MP2Throttle=', data%EquipmentControl%DrillingConsole%MP2Throttle #endif end subroutine @@ -155,9 +157,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetDWSwitch' :: SetDWSwitch implicit none integer, intent(in) :: v - DrillingConsole%DWSwitch = v + data%EquipmentControl%DrillingConsole%DWSwitch = v #ifdef deb - print*, 'DWSwitch=', DrillingConsole%DWSwitch + print*, 'DWSwitch=', data%EquipmentControl%DrillingConsole%DWSwitch #endif end subroutine @@ -166,9 +168,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetDWThrottle' :: SetDWThrottle implicit none real*8, intent(in) :: v - DrillingConsole%DWThrottle = v + data%EquipmentControl%DrillingConsole%DWThrottle = v #ifdef deb - print*, 'DWThrottle=', DrillingConsole%DWThrottle + print*, 'DWThrottle=', data%EquipmentControl%DrillingConsole%DWThrottle #endif end subroutine @@ -177,9 +179,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetRTSwitch' :: SetRTSwitch implicit none integer, intent(in) :: v - DrillingConsole%RTSwitch = v + data%EquipmentControl%DrillingConsole%RTSwitch = v #ifdef deb - print*, 'RTSwitch=', DrillingConsole%RTSwitch + print*, 'RTSwitch=', data%EquipmentControl%DrillingConsole%RTSwitch #endif end subroutine @@ -188,9 +190,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetRTThrottle' :: SetRTThrottle implicit none real*8, intent(in) :: v - DrillingConsole%RTThrottle = v + data%EquipmentControl%DrillingConsole%RTThrottle = v #ifdef deb - print*, 'RTThrottle=', DrillingConsole%RTThrottle + print*, 'RTThrottle=', data%EquipmentControl%DrillingConsole%RTThrottle #endif end subroutine @@ -200,10 +202,10 @@ module CDrillingConsole implicit none real*8, intent(in) :: v !if(ForceBreak) return - DrillingConsole%PreviousDWBreak = DrillingConsole%DWBreak - DrillingConsole%DWBreak = v + data%EquipmentControl%DrillingConsole%PreviousDWBreak = data%EquipmentControl%DrillingConsole%DWBreak + data%EquipmentControl%DrillingConsole%DWBreak = v #ifdef deb - print*, 'DWBreak=', DrillingConsole%DWBreak + print*, 'DWBreak=', data%EquipmentControl%DrillingConsole%DWBreak #endif end subroutine @@ -212,9 +214,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetDWAcceleretor' :: SetDWAcceleretor implicit none real*8, intent(in) :: v - DrillingConsole%DWAcceleretor = v + data%EquipmentControl%DrillingConsole%DWAcceleretor = v #ifdef deb - print*, 'DWAcceleretor=', DrillingConsole%DWAcceleretor + print*, 'DWAcceleretor=', data%EquipmentControl%DrillingConsole%DWAcceleretor #endif end subroutine @@ -223,9 +225,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetDWTransmisionLever' :: SetDWTransmisionLever implicit none real*8, intent(in) :: v - DrillingConsole%DWTransmisionLever = v + data%EquipmentControl%DrillingConsole%DWTransmisionLever = v #ifdef deb - print*, 'DWTransmisionLever=', DrillingConsole%DWTransmisionLever + print*, 'DWTransmisionLever=', data%EquipmentControl%DrillingConsole%DWTransmisionLever #endif end subroutine @@ -234,9 +236,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetDWPowerLever' :: SetDWPowerLever implicit none real*8, intent(in) :: v - DrillingConsole%DWPowerLever = v + data%EquipmentControl%DrillingConsole%DWPowerLever = v #ifdef deb - print*, 'DWPowerLever=', DrillingConsole%DWPowerLever + print*, 'DWPowerLever=', data%EquipmentControl%DrillingConsole%DWPowerLever #endif end subroutine @@ -245,8 +247,8 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetTongLever' :: SetTongLever implicit none real*8, intent(in) :: v - if (DrillingConsole%TongLever == v) return - DrillingConsole%TongLever = v + if (data%EquipmentControl%DrillingConsole%TongLever == v) return + data%EquipmentControl%DrillingConsole%TongLever = v ! if(dint(TongLever) == 1.0) then ! call OnBreakoutLeverPress%RunAll() @@ -269,7 +271,7 @@ module CDrillingConsole ! endif #ifdef deb - print*, 'TongLever=', DrillingConsole%TongLever + print*, 'TongLever=', data%EquipmentControl%DrillingConsole%TongLever #endif end subroutine @@ -278,9 +280,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetRTTransmissionLever' :: SetRTTransmissionLever implicit none real*8, intent(in) :: v - DrillingConsole%RTTransmissionLever = v + data%EquipmentControl%DrillingConsole%RTTransmissionLever = v #ifdef deb - print*, 'RTTransmissionLever=', DrillingConsole%RTTransmissionLever + print*, 'RTTransmissionLever=', data%EquipmentControl%DrillingConsole%RTTransmissionLever #endif end subroutine @@ -289,9 +291,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetDWClutchLever' :: SetDWClutchLever implicit none real*8, intent(in) :: v - DrillingConsole%DWClutchLever = v + data%EquipmentControl%DrillingConsole%DWClutchLever = v #ifdef deb - print*, 'DWClutchLever=', DrillingConsole%DWClutchLever + print*, 'DWClutchLever=', data%EquipmentControl%DrillingConsole%DWClutchLever #endif end subroutine @@ -300,9 +302,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetEddyBreakLever' :: SetEddyBreakLever implicit none real*8, intent(in) :: v - DrillingConsole%EddyBreakLever = v + data%EquipmentControl%DrillingConsole%EddyBreakLever = v #ifdef deb - print*, 'EddyBreakLever=', DrillingConsole%EddyBreakLever + print*, 'EddyBreakLever=', data%EquipmentControl%DrillingConsole%EddyBreakLever #endif end subroutine @@ -311,9 +313,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetAutoDW' :: SetAutoDW implicit none logical, intent(in) :: v - DrillingConsole%AutoDW = v + data%EquipmentControl%DrillingConsole%AutoDW = v #ifdef deb - print*, 'AutoDW=', DrillingConsole%AutoDW + print*, 'AutoDW=', data%EquipmentControl%DrillingConsole%AutoDW #endif end subroutine @@ -322,9 +324,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetGEN1' :: SetGEN1 implicit none logical, intent(in) :: v - DrillingConsole%GEN1 = v + data%EquipmentControl%DrillingConsole%GEN1 = v #ifdef deb - print*, 'GEN1=', DrillingConsole%GEN1 + print*, 'GEN1=', data%EquipmentControl%DrillingConsole%GEN1 #endif end subroutine @@ -333,9 +335,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetGEN2' :: SetGEN2 implicit none logical, intent(in) :: v - DrillingConsole%GEN2 = v + data%EquipmentControl%DrillingConsole%GEN2 = v #ifdef deb - print*, 'GEN2=', DrillingConsole%GEN2 + print*, 'GEN2=', data%EquipmentControl%DrillingConsole%GEN2 #endif end subroutine @@ -344,9 +346,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetGEN3' :: SetGEN3 implicit none logical, intent(in) :: v - DrillingConsole%GEN3 = v + data%EquipmentControl%DrillingConsole%GEN3 = v #ifdef deb - print*, 'GEN3=', DrillingConsole%GEN3 + print*, 'GEN3=', data%EquipmentControl%DrillingConsole%GEN3 #endif end subroutine @@ -355,9 +357,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetGEN4' :: SetGEN4 implicit none logical, intent(in) :: v - DrillingConsole%GEN4 = v + data%EquipmentControl%DrillingConsole%GEN4 = v #ifdef deb - print*, 'GEN4=', DrillingConsole%GEN4 + print*, 'GEN4=', data%EquipmentControl%DrillingConsole%GEN4 #endif end subroutine @@ -433,12 +435,12 @@ module CDrillingConsole use CManifolds, OpenKellyCockSub => OpenKellyCock implicit none logical, intent(in) :: v - if (DrillingConsole%OpenKellyCock == v) return - DrillingConsole%OpenKellyCock = v + if (data%EquipmentControl%DrillingConsole%OpenKellyCock == v) return + data%EquipmentControl%DrillingConsole%OpenKellyCock = v ! if (v) call OnOpenKellyCockPress%RunAll() - if(v .and. DrillingConsole%Permission_OpenKellyCock) call OpenKellyCockSub() + if(v .and. data%EquipmentControl%DrillingConsole%Permission_OpenKellyCock) call OpenKellyCockSub() #ifdef deb - print*, 'OpenKellyCock=', DrillingConsole%OpenKellyCock + print*, 'OpenKellyCock=', data%EquipmentControl%DrillingConsole%OpenKellyCock #endif end subroutine @@ -448,12 +450,12 @@ module CDrillingConsole use CManifolds, CloseKellyCockSub => CloseKellyCock implicit none logical, intent(in) :: v - if (DrillingConsole%CloseKellyCock == v) return - DrillingConsole%CloseKellyCock = v + if (data%EquipmentControl%DrillingConsole%CloseKellyCock == v) return + data%EquipmentControl%DrillingConsole%CloseKellyCock = v ! if (v) call OnCloseKellyCockPress%RunAll() - if(v .and. DrillingConsole%Permission_CloseKellyCock) call CloseKellyCockSub() + if(v .and. data%EquipmentControl%DrillingConsole%Permission_CloseKellyCock) call CloseKellyCockSub() #ifdef deb - print*, 'CloseKellyCock=', DrillingConsole%CloseKellyCock + print*, 'CloseKellyCock=', data%EquipmentControl%DrillingConsole%CloseKellyCock #endif end subroutine @@ -463,12 +465,12 @@ module CDrillingConsole !use CManifolds, OpenSafetyValveSub => OpenSafetyValve implicit none logical, intent(in) :: v - if (DrillingConsole%OpenSafetyValve == v) return - DrillingConsole%OpenSafetyValve = v + if (data%EquipmentControl%DrillingConsole%OpenSafetyValve == v) return + data%EquipmentControl%DrillingConsole%OpenSafetyValve = v ! if (v) call OnOpenSafetyValvePress%RunAll() !if(v .and. Permission_OpenSafetyValve) call OpenSafetyValveSub() #ifdef deb - print*, 'OpenSafetyValve=', DrillingConsole%OpenSafetyValve + print*, 'OpenSafetyValve=', data%EquipmentControl%DrillingConsole%OpenSafetyValve #endif end subroutine @@ -478,12 +480,12 @@ module CDrillingConsole !use CManifolds, CloseSafetyValveSub => CloseSafetyValve implicit none logical, intent(in) :: v - if (DrillingConsole%CloseSafetyValve == v) return - DrillingConsole%CloseSafetyValve = v + if (data%EquipmentControl%DrillingConsole%CloseSafetyValve == v) return + data%EquipmentControl%DrillingConsole%CloseSafetyValve = v ! if (v) call OnCloseSafetyValvePress%RunAll() !if(v .and. Permission_CloseSafetyValve) call CloseSafetyValveSub() #ifdef deb - print*, 'CloseSafetyValve=', DrillingConsole%CloseSafetyValve + print*, 'CloseSafetyValve=', data%EquipmentControl%DrillingConsole%CloseSafetyValve #endif end subroutine @@ -494,14 +496,14 @@ module CDrillingConsole implicit none logical, intent(in) :: v logical :: prev - if (DrillingConsole%IRSafetyValve == v) return - prev = DrillingConsole%IRSafetyValve - DrillingConsole%IRSafetyValve = v + if (data%EquipmentControl%DrillingConsole%IRSafetyValve == v) return + prev = data%EquipmentControl%DrillingConsole%IRSafetyValve + data%EquipmentControl%DrillingConsole%IRSafetyValve = v ! if (v) call OnIRSafetyValvePress%RunAll() !if(prev /= IRSafetyValve .and. v .and. Permission_IRSafetyValve) call ToggleSafetyValve() !if(prev /= IRSafetyValve .and. v) call ToggleSafetyValve() #ifdef deb - print*, 'IRSafetyValve=', DrillingConsole%IRSafetyValve + print*, 'IRSafetyValve=', data%EquipmentControl%DrillingConsole%IRSafetyValve #endif end subroutine @@ -512,14 +514,14 @@ module CDrillingConsole implicit none logical, intent(in) :: v logical :: prev - if (DrillingConsole%IRIBop == v) return - prev = DrillingConsole%IRIBop - DrillingConsole%IRIBop = v + if (data%EquipmentControl%DrillingConsole%IRIBop == v) return + prev = data%EquipmentControl%DrillingConsole%IRIBop + data%EquipmentControl%DrillingConsole%IRIBop = v ! if (v) call OnIRIBopPress%RunAll() !if(prev /= IRIBop .and. v .and. Permission_IRIBop) call ToggleIBop() !if(prev /= IRIBop .and. v) call ToggleIBop() #ifdef deb - print*, 'IRIBop=', DrillingConsole%IRIBop + print*, 'IRIBop=', data%EquipmentControl%DrillingConsole%IRIBop #endif end subroutine @@ -530,11 +532,11 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetLatchPipe' :: SetLatchPipe implicit none logical, intent(in) :: v - if (DrillingConsole%LatchPipe .eqv. v) return - DrillingConsole%LatchPipe = v + if (data%EquipmentControl%DrillingConsole%LatchPipe .eqv. v) return + data%EquipmentControl%DrillingConsole%LatchPipe = v ! if (v) call OnLatchPipePress%RunAll() #ifdef deb - print*, 'LatchPipe=', DrillingConsole%LatchPipe + print*, 'LatchPipe=', data%EquipmentControl%DrillingConsole%LatchPipe #endif end subroutine @@ -543,11 +545,11 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetUnlatchPipe' :: SetUnlatchPipe implicit none logical, intent(in) :: v - if (DrillingConsole%UnlatchPipe .eqv. v) return - DrillingConsole%UnlatchPipe = v + if (data%EquipmentControl%DrillingConsole%UnlatchPipe .eqv. v) return + data%EquipmentControl%DrillingConsole%UnlatchPipe = v ! if (v) call OnUnlatchPipePress%RunAll() #ifdef deb - print*, 'UnlatchPipe=', DrillingConsole%UnlatchPipe + print*, 'UnlatchPipe=', data%EquipmentControl%DrillingConsole%UnlatchPipe #endif end subroutine @@ -556,11 +558,11 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetSwing' :: SetSwing implicit none logical, intent(in) :: v - if (DrillingConsole%Swing .eqv. v) return - DrillingConsole%Swing = v + if (data%EquipmentControl%DrillingConsole%Swing .eqv. v) return + data%EquipmentControl%DrillingConsole%Swing = v ! if (v) call OnSwingPress%RunAll() #ifdef deb - print*, 'Swing=', DrillingConsole%Swing + print*, 'Swing=', data%EquipmentControl%DrillingConsole%Swing #endif end subroutine @@ -569,11 +571,11 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetFillMouseHole' :: SetFillMouseHole implicit none logical, intent(in) :: v - if (DrillingConsole%FillMouseHole .eqv. v) return - DrillingConsole%FillMouseHole = v + if (data%EquipmentControl%DrillingConsole%FillMouseHole .eqv. v) return + data%EquipmentControl%DrillingConsole%FillMouseHole = v ! if (v) call OnFillMouseHolePress%RunAll() #ifdef deb - print*, 'FillMouseHole=', DrillingConsole%FillMouseHole + print*, 'FillMouseHole=', data%EquipmentControl%DrillingConsole%FillMouseHole #endif end subroutine @@ -582,10 +584,10 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetSlips' :: SetSlips implicit none logical, intent(in) :: v - if (DrillingConsole%Slips .eqv. v) return - DrillingConsole%Slips = v + if (data%EquipmentControl%DrillingConsole%Slips .eqv. v) return + data%EquipmentControl%DrillingConsole%Slips = v #ifdef deb - print*, 'Slips=', DrillingConsole%Slips + print*, 'Slips=', data%EquipmentControl%DrillingConsole%Slips #endif ! if (v) call OnSlipsPress%RunAll() end subroutine @@ -596,9 +598,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetBrakeLeverCoefficient' :: SetBrakeLeverCoefficient implicit none real, intent(in) :: v - DrillingConsole%BrakeLeverCoefficient = v + data%EquipmentControl%DrillingConsole%BrakeLeverCoefficient = v #ifdef deb - print*, 'BrakeLeverCoefficient=', DrillingConsole%BrakeLeverCoefficient + print*, 'BrakeLeverCoefficient=', data%EquipmentControl%DrillingConsole%BrakeLeverCoefficient #endif end subroutine @@ -607,9 +609,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetHideDrillingBrake' :: SetHideDrillingBrake implicit none logical, intent(in) :: v - DrillingConsole%HideDrillingBrake = v + data%EquipmentControl%DrillingConsole%HideDrillingBrake = v #ifdef deb - print*, 'HideDrillingBrake=', DrillingConsole%HideDrillingBrake + print*, 'HideDrillingBrake=', data%EquipmentControl%DrillingConsole%HideDrillingBrake #endif end subroutine @@ -625,9 +627,9 @@ module CDrillingConsole !DEC$ ATTRIBUTES ALIAS: 'SetParkingBrake' :: SetParkingBrake implicit none logical, intent(in) :: v - DrillingConsole%ParkingBrakeBtn = v + data%EquipmentControl%DrillingConsole%ParkingBrakeBtn = v #ifdef deb - print*, 'ParkingBrakeBtn=', DrillingConsole%ParkingBrakeBtn + print*, 'ParkingBrakeBtn=', data%EquipmentControl%DrillingConsole%ParkingBrakeBtn #endif end subroutine @@ -648,7 +650,7 @@ module CDrillingConsole !DEC$ ATTRIBUTES DLLEXPORT :: GetParkingBrakeLed !DEC$ ATTRIBUTES ALIAS: 'GetParkingBrakeLed' :: GetParkingBrakeLed implicit none - GetParkingBrakeLed = DrillingConsole%ParkingBrakeLed + GetParkingBrakeLed = data%EquipmentControl%DrillingConsole%ParkingBrakeLed !GetParkingBrakeLed = .true. end function @@ -689,154 +691,154 @@ module CDrillingConsole !DEC$ ATTRIBUTES DLLEXPORT :: GetSCR1LED !DEC$ ATTRIBUTES ALIAS: 'GetSCR1LED' :: GetSCR1LED implicit none - GetSCR1LED = DrillingConsole%SCR1LED + GetSCR1LED = data%EquipmentControl%DrillingConsole%SCR1LED end function integer function GetSCR2LED() !DEC$ ATTRIBUTES DLLEXPORT :: GetSCR2LED !DEC$ ATTRIBUTES ALIAS: 'GetSCR2LED' :: GetSCR2LED implicit none - GetSCR2LED = DrillingConsole%SCR2LED + GetSCR2LED = data%EquipmentControl%DrillingConsole%SCR2LED end function integer function GetSCR3LED() !DEC$ ATTRIBUTES DLLEXPORT :: GetSCR3LED !DEC$ ATTRIBUTES ALIAS: 'GetSCR3LED' :: GetSCR3LED implicit none - GetSCR3LED = DrillingConsole%SCR3LED + GetSCR3LED = data%EquipmentControl%DrillingConsole%SCR3LED end function integer function GetSCR4LED() !DEC$ ATTRIBUTES DLLEXPORT :: GetSCR4LED !DEC$ ATTRIBUTES ALIAS: 'GetSCR4LED' :: GetSCR4LED implicit none - GetSCR4LED = DrillingConsole%SCR4LED + GetSCR4LED = data%EquipmentControl%DrillingConsole%SCR4LED end function integer function GetMP1BLWR() !DEC$ ATTRIBUTES DLLEXPORT :: GetMP1BLWR !DEC$ ATTRIBUTES ALIAS: 'GetMP1BLWR' :: GetMP1BLWR implicit none - GetMP1BLWR = DrillingConsole%MP1BLWR + GetMP1BLWR = data%EquipmentControl%DrillingConsole%MP1BLWR end function integer function GetMP2BLWR() !DEC$ ATTRIBUTES DLLEXPORT :: GetMP2BLWR !DEC$ ATTRIBUTES ALIAS: 'GetMP2BLWR' :: GetMP2BLWR implicit none - GetMP2BLWR = DrillingConsole%MP2BLWR + GetMP2BLWR = data%EquipmentControl%DrillingConsole%MP2BLWR end function integer function GetDWBLWR() !DEC$ ATTRIBUTES DLLEXPORT :: GetDWBLWR !DEC$ ATTRIBUTES ALIAS: 'GetDWBLWR' :: GetDWBLWR implicit none - GetDWBLWR = DrillingConsole%DWBLWR + GetDWBLWR = data%EquipmentControl%DrillingConsole%DWBLWR end function integer function GetRTBLWR() !DEC$ ATTRIBUTES DLLEXPORT :: GetRTBLWR !DEC$ ATTRIBUTES ALIAS: 'GetRTBLWR' :: GetRTBLWR implicit none - GetRTBLWR = DrillingConsole%RTBLWR + GetRTBLWR = data%EquipmentControl%DrillingConsole%RTBLWR end function integer function GetPWRLIM() !DEC$ ATTRIBUTES DLLEXPORT :: GetPWRLIM !DEC$ ATTRIBUTES ALIAS: 'GetPWRLIM' :: GetPWRLIM implicit none - GetPWRLIM = DrillingConsole%PWRLIM + GetPWRLIM = data%EquipmentControl%DrillingConsole%PWRLIM end function real(8) function GetPWRLIMMTR() !DEC$ ATTRIBUTES DLLEXPORT :: GetPWRLIMMTR !DEC$ ATTRIBUTES ALIAS: 'GetPWRLIMMTR' :: GetPWRLIMMTR implicit none - GetPWRLIMMTR = DrillingConsole%PWRLIMMTR + GetPWRLIMMTR = data%EquipmentControl%DrillingConsole%PWRLIMMTR end function real(8) function GetRTTorqueLimitGauge() !DEC$ ATTRIBUTES DLLEXPORT :: GetRTTorqueLimitGauge !DEC$ ATTRIBUTES ALIAS: 'GetRTTorqueLimitGauge' :: GetRTTorqueLimitGauge implicit none - GetRTTorqueLimitGauge = DrillingConsole%RTTorqueLimitGauge + GetRTTorqueLimitGauge = data%EquipmentControl%DrillingConsole%RTTorqueLimitGauge end function integer function GetAutoDWLED() !DEC$ ATTRIBUTES DLLEXPORT :: GetAutoDWLED !DEC$ ATTRIBUTES ALIAS: 'GetAutoDWLED' :: GetAutoDWLED implicit none - GetAutoDWLED = DrillingConsole%AutoDWLED + GetAutoDWLED = data%EquipmentControl%DrillingConsole%AutoDWLED end function integer function GetGEN1BTNLED() !DEC$ ATTRIBUTES DLLEXPORT :: GetGEN1BTNLED !DEC$ ATTRIBUTES ALIAS: 'GetGEN1BTNLED' :: GetGEN1BTNLED implicit none - GetGEN1BTNLED = DrillingConsole%GEN1BTNLED + GetGEN1BTNLED = data%EquipmentControl%DrillingConsole%GEN1BTNLED end function integer function GetGEN2BTNLED() !DEC$ ATTRIBUTES DLLEXPORT :: GetGEN2BTNLED !DEC$ ATTRIBUTES ALIAS: 'GetGEN2BTNLED' :: GetGEN2BTNLED implicit none - GetGEN2BTNLED = DrillingConsole%GEN2BTNLED + GetGEN2BTNLED = data%EquipmentControl%DrillingConsole%GEN2BTNLED end function integer function GetGEN3BTNLED() !DEC$ ATTRIBUTES DLLEXPORT :: GetGEN3BTNLED !DEC$ ATTRIBUTES ALIAS: 'GetGEN3BTNLED' :: GetGEN3BTNLED implicit none - GetGEN3BTNLED = DrillingConsole%GEN3BTNLED + GetGEN3BTNLED = data%EquipmentControl%DrillingConsole%GEN3BTNLED end function integer function GetGEN4BTNLED() !DEC$ ATTRIBUTES DLLEXPORT :: GetGEN4BTNLED !DEC$ ATTRIBUTES ALIAS: 'GetGEN4BTNLED' :: GetGEN4BTNLED implicit none - GetGEN4BTNLED = DrillingConsole%GEN4BTNLED + GetGEN4BTNLED = data%EquipmentControl%DrillingConsole%GEN4BTNLED end function integer function GetOpenKellyCockLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetOpenKellyCockLed !DEC$ ATTRIBUTES ALIAS: 'GetOpenKellyCockLed' :: GetOpenKellyCockLed implicit none - GetOpenKellyCockLed = DrillingConsole%OpenKellyCockLed + GetOpenKellyCockLed = data%EquipmentControl%DrillingConsole%OpenKellyCockLed end function integer function GetCloseKellyCockLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetCloseKellyCockLed !DEC$ ATTRIBUTES ALIAS: 'GetCloseKellyCockLed' :: GetCloseKellyCockLed implicit none - GetCloseKellyCockLed = DrillingConsole%CloseKellyCockLed + GetCloseKellyCockLed = data%EquipmentControl%DrillingConsole%CloseKellyCockLed end function integer function GetOpenSafetyValveLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetOpenSafetyValveLed !DEC$ ATTRIBUTES ALIAS: 'GetOpenSafetyValveLed' :: GetOpenSafetyValveLed implicit none - GetOpenSafetyValveLed = DrillingConsole%OpenSafetyValveLed + GetOpenSafetyValveLed = data%EquipmentControl%DrillingConsole%OpenSafetyValveLed end function integer function GetCloseSafetyValveLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetCloseSafetyValveLed !DEC$ ATTRIBUTES ALIAS: 'GetCloseSafetyValveLed' :: GetCloseSafetyValveLed implicit none - GetCloseSafetyValveLed = DrillingConsole%CloseSafetyValveLed + GetCloseSafetyValveLed = data%EquipmentControl%DrillingConsole%CloseSafetyValveLed end function integer function GetIRSafetyValveLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetIRSafetyValveLed !DEC$ ATTRIBUTES ALIAS: 'GetIRSafetyValveLed' :: GetIRSafetyValveLed implicit none - GetIRSafetyValveLed = DrillingConsole%IRSafetyValveLed + GetIRSafetyValveLed = data%EquipmentControl%DrillingConsole%IRSafetyValveLed end function integer function GetIRIBopLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetIRIBopLed !DEC$ ATTRIBUTES ALIAS: 'GetIRIBopLed' :: GetIRIBopLed implicit none - GetIRIBopLed = DrillingConsole%IRIBopLed + GetIRIBopLed = data%EquipmentControl%DrillingConsole%IRIBopLed end function @@ -844,28 +846,28 @@ module CDrillingConsole !DEC$ ATTRIBUTES DLLEXPORT :: GetLatchPipeLED !DEC$ ATTRIBUTES ALIAS: 'GetLatchPipeLED' :: GetLatchPipeLED implicit none - GetLatchPipeLED = DrillingConsole%LatchPipeLED + GetLatchPipeLED = data%EquipmentControl%DrillingConsole%LatchPipeLED end function integer function GetUnlatchPipeLED() !DEC$ ATTRIBUTES DLLEXPORT :: GetUnlatchPipeLED !DEC$ ATTRIBUTES ALIAS: 'GetUnlatchPipeLED' :: GetUnlatchPipeLED implicit none - GetUnlatchPipeLED = DrillingConsole%UnlatchPipeLED + GetUnlatchPipeLED = data%EquipmentControl%DrillingConsole%UnlatchPipeLED end function integer function GetSwingLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetSwingLed !DEC$ ATTRIBUTES ALIAS: 'GetSwingLed' :: GetSwingLed implicit none - GetSwingLed = DrillingConsole%SwingLed + GetSwingLed = data%EquipmentControl%DrillingConsole%SwingLed end function integer function GetFillMouseHoleLed() !DEC$ ATTRIBUTES DLLEXPORT :: GetFillMouseHoleLed !DEC$ ATTRIBUTES ALIAS: 'GetFillMouseHoleLed' :: GetFillMouseHoleLed implicit none - GetFillMouseHoleLed = DrillingConsole%FillMouseHoleLed + GetFillMouseHoleLed = data%EquipmentControl%DrillingConsole%FillMouseHoleLed end function end module CDrillingConsole \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CDrillingConsoleVariables.f90 b/CSharp/Equipments/ControlPanels/CDrillingConsoleVariables.f90 index bd5ff8d..f611d0f 100644 --- a/CSharp/Equipments/ControlPanels/CDrillingConsoleVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CDrillingConsoleVariables.f90 @@ -129,5 +129,5 @@ module CDrillingConsoleVariables integer :: SwingLed integer :: FillMouseHoleLed END TYPE DrillingConsoleType - TYPE(DrillingConsoleType) :: DrillingConsole + end module CDrillingConsoleVariables \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CHook.f90 b/CSharp/Equipments/ControlPanels/CHook.f90 index 1804d5a..9a23b75 100644 --- a/CSharp/Equipments/ControlPanels/CHook.f90 +++ b/CSharp/Equipments/ControlPanels/CHook.f90 @@ -1,6 +1,64 @@ module CHook use CHookVariables + use ConfigurationVariables implicit none public - contains + contains + + subroutine Set_HookHeight(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + implicit none + real , intent(in) :: v + +#ifdef ExcludeExtraChanges + if(data%EquipmentControl%Hook%HookHeight == v) return +#endif + data%EquipmentControl%Hook%HookHeight = v + + ! if(associated(HookHeightPtr)) then + ! call HookHeightPtr(data%EquipmentControl%Hook%HookHeight) + ! end if + +#ifdef deb + print*, 'HookHeight=', data%EquipmentControl%Hook%HookHeight +#endif + + !**call data%EquipmentControl%Hook%OnHookHeightChange%RunAll(data%EquipmentControl%Hook%HookHeight) + end subroutine + + + subroutine Set_HookHeight_S(v) + implicit none + real , intent(in) :: v + + if(v == data%EquipmentControl%Hook%HookHeight) then + return + elseif (v > data%EquipmentControl%Hook%HookHeight) then + loop1: do + call Set_HookHeight(data%EquipmentControl%Hook%HookHeight + 0.2) + if(abs(v - data%EquipmentControl%Hook%HookHeight) <= 0.1) then + call Set_HookHeight(v) + exit loop1 + endif + call sleepqq(100) + enddo loop1 + else ! v < HookHeight + loop2: do + call Set_HookHeight(data%EquipmentControl%Hook%HookHeight - 0.2) + if(abs(data%EquipmentControl%Hook%HookHeight - v) <= 0.1) then + call Set_HookHeight(v) + exit loop2 + endif + call sleepqq(100) + enddo loop2 + endif + + end subroutine + + subroutine Update_HookHeight_From_Snapshot() + implicit none + call Set_HookHeight_S(data%EquipmentControl%Hook%HookHeight_S) + end subroutine end module CHook diff --git a/CSharp/Equipments/ControlPanels/CHookVariables.f90 b/CSharp/Equipments/ControlPanels/CHookVariables.f90 index df3d7fb..617e7c6 100644 --- a/CSharp/Equipments/ControlPanels/CHookVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CHookVariables.f90 @@ -7,74 +7,10 @@ module CHookVariables real :: HookHeight !**type(RealEventHandlerCollection) :: OnHookHeightChange end type HookType - Type(HookType)::Hook + contains - subroutine Set_HookHeight(v) - use CDrillingConsoleVariables - implicit none - real , intent(in) :: v - -#ifdef ExcludeExtraChanges - if(Hook%HookHeight == v) return -#endif - Hook%HookHeight = v - - ! if(associated(HookHeightPtr)) then - ! call HookHeightPtr(Hook%HookHeight) - ! end if - -#ifdef deb - print*, 'HookHeight=', Hook%HookHeight -#endif - - !**call Hook%OnHookHeightChange%RunAll(Hook%HookHeight) - end subroutine - - - subroutine Set_HookHeight_S(v) - implicit none - real , intent(in) :: v - - if(v == Hook%HookHeight) then - return - elseif (v > Hook%HookHeight) then - loop1: do - call Set_HookHeight(Hook%HookHeight + 0.2) - if(abs(v - Hook%HookHeight) <= 0.1) then - call Set_HookHeight(v) - exit loop1 - endif - call sleepqq(100) - enddo loop1 - else ! v < HookHeight - loop2: do - call Set_HookHeight(Hook%HookHeight - 0.2) - if(abs(Hook%HookHeight - v) <= 0.1) then - call Set_HookHeight(v) - exit loop2 - endif - call sleepqq(100) - enddo loop2 - endif - - end subroutine - - - subroutine Set_HookHeight_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_HookHeight_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_HookHeight_WN' :: Set_HookHeight_WN - implicit none - real , intent(in) :: v - !call Set_HookHeight(v) - Hook%HookHeight_S = v - end subroutine - - - subroutine Update_HookHeight_From_Snapshot() - implicit none - call Set_HookHeight_S(Hook%HookHeight_S) - end subroutine + end module CHookVariables \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CStandPipeManifold.f90 b/CSharp/Equipments/ControlPanels/CStandPipeManifold.f90 index 2dc7a34..d347839 100644 --- a/CSharp/Equipments/ControlPanels/CStandPipeManifold.f90 +++ b/CSharp/Equipments/ControlPanels/CStandPipeManifold.f90 @@ -1,5 +1,6 @@ module CStandPipeManifold use CStandPipeManifoldVariables + use ConfigurationVariables use CManifolds implicit none public @@ -11,10 +12,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve1' :: SetStandPipeManifoldValve1 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve1 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve1 = v call ChangeValve(13, v) #ifdef deb - print*, 'StandPipeManifoldValve1=', StandPipeManifold%StandPipeManifoldValve1 + print*, 'StandPipeManifoldValve1=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve1 #endif end subroutine @@ -23,10 +24,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve2' :: SetStandPipeManifoldValve2 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve2 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve2 = v call ChangeValve(14, v) #ifdef deb - print*, 'StandPipeManifoldValve2=', StandPipeManifold%StandPipeManifoldValve2 + print*, 'StandPipeManifoldValve2=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve2 #endif end subroutine @@ -35,10 +36,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve3' :: SetStandPipeManifoldValve3 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve3 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve3 = v call ChangeValve(15, v) #ifdef deb - print*, 'StandPipeManifoldValve3=', StandPipeManifold%StandPipeManifoldValve3 + print*, 'StandPipeManifoldValve3=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve3 #endif end subroutine @@ -47,10 +48,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve4' :: SetStandPipeManifoldValve4 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve4 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve4 = v call ChangeValve(11, v) #ifdef deb - print*, 'StandPipeManifoldValve4=', StandPipeManifold%StandPipeManifoldValve4 + print*, 'StandPipeManifoldValve4=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve4 #endif end subroutine @@ -59,10 +60,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve5' :: SetStandPipeManifoldValve5 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve5 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve5 = v call ChangeValve(12, v) #ifdef deb - print*, 'StandPipeManifoldValve5=', StandPipeManifold%StandPipeManifoldValve5 + print*, 'StandPipeManifoldValve5=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve5 #endif end subroutine @@ -71,10 +72,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve6' :: SetStandPipeManifoldValve6 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve6 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve6 = v call ChangeValve(9, v) #ifdef deb - print*, 'StandPipeManifoldValve6=', StandPipeManifold%StandPipeManifoldValve6 + print*, 'StandPipeManifoldValve6=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve6 #endif end subroutine @@ -83,10 +84,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve7' :: SetStandPipeManifoldValve7 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve7 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve7 = v call ChangeValve(10, v) #ifdef deb - print*, 'StandPipeManifoldValve7=', StandPipeManifold%StandPipeManifoldValve7 + print*, 'StandPipeManifoldValve7=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve7 #endif end subroutine @@ -95,10 +96,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve8' :: SetStandPipeManifoldValve8 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve8 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve8 = v call ChangeValve(6, v) #ifdef deb - print*, 'StandPipeManifoldValve8=', StandPipeManifold%StandPipeManifoldValve8 + print*, 'StandPipeManifoldValve8=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve8 #endif end subroutine @@ -107,10 +108,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve9' :: SetStandPipeManifoldValve9 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve9 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve9 = v call ChangeValve(7, v) #ifdef deb - print*, 'StandPipeManifoldValve9=', StandPipeManifold%StandPipeManifoldValve9 + print*, 'StandPipeManifoldValve9=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve9 #endif end subroutine @@ -119,10 +120,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve10' :: SetStandPipeManifoldValve10 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve10 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve10 = v call ChangeValve(8, v) #ifdef deb - print*, 'StandPipeManifoldValve10=', StandPipeManifold%StandPipeManifoldValve10 + print*, 'StandPipeManifoldValve10=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve10 #endif end subroutine @@ -131,10 +132,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve11' :: SetStandPipeManifoldValve11 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve11 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve11 = v call ChangeValve(1, v) #ifdef deb - print*, 'StandPipeManifoldValve11=', StandPipeManifold%StandPipeManifoldValve11 + print*, 'StandPipeManifoldValve11=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve11 #endif end subroutine @@ -143,10 +144,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve12' :: SetStandPipeManifoldValve12 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve12 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve12 = v call ChangeValve(2, v) #ifdef deb - print*, 'StandPipeManifoldValve12=', StandPipeManifold%StandPipeManifoldValve12 + print*, 'StandPipeManifoldValve12=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve12 #endif end subroutine @@ -155,10 +156,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve13' :: SetStandPipeManifoldValve13 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve13 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve13 = v call ChangeValve(3, v) #ifdef deb - print*, 'StandPipeManifoldValve13=', StandPipeManifold%StandPipeManifoldValve13 + print*, 'StandPipeManifoldValve13=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve13 #endif end subroutine @@ -167,10 +168,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve14' :: SetStandPipeManifoldValve14 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve14 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve14 = v call ChangeValve(4, v) #ifdef deb - print*, 'StandPipeManifoldValve14=', StandPipeManifold%StandPipeManifoldValve14 + print*, 'StandPipeManifoldValve14=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve14 #endif end subroutine @@ -179,10 +180,10 @@ module CStandPipeManifold !DEC$ ATTRIBUTES ALIAS: 'SetStandPipeManifoldValve15' :: SetStandPipeManifoldValve15 implicit none logical, intent(in) :: v - StandPipeManifold%StandPipeManifoldValve15 = v + data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve15 = v call ChangeValve(5, v) #ifdef deb - print*, 'StandPipeManifoldValve15=', StandPipeManifold%StandPipeManifoldValve15 + print*, 'StandPipeManifoldValve15=', data%EquipmentControl%StandPipeManifold%StandPipeManifoldValve15 #endif end subroutine @@ -191,7 +192,7 @@ module CStandPipeManifold !DEC$ ATTRIBUTES DLLEXPORT :: GetStandPipeGauge1 !DEC$ ATTRIBUTES ALIAS: 'GetStandPipeGauge1' :: GetStandPipeGauge1 implicit none - GetStandPipeGauge1 = StandPipeManifold%StandPipeGauge1 + GetStandPipeGauge1 = data%EquipmentControl%StandPipeManifold%StandPipeGauge1 !GetStandPipeGauge1 = 567.4 end function @@ -199,7 +200,7 @@ module CStandPipeManifold !DEC$ ATTRIBUTES DLLEXPORT :: GetStandPipeGauge2 !DEC$ ATTRIBUTES ALIAS: 'GetStandPipeGauge2' :: GetStandPipeGauge2 implicit none - GetStandPipeGauge2 = StandPipeManifold%StandPipeGauge2 + GetStandPipeGauge2 = data%EquipmentControl%StandPipeManifold%StandPipeGauge2 !GetStandPipeGauge2 = 1564.0 end function diff --git a/CSharp/Equipments/ControlPanels/CStandPipeManifoldVariables.f90 b/CSharp/Equipments/ControlPanels/CStandPipeManifoldVariables.f90 index fceca73..7ffb90c 100644 --- a/CSharp/Equipments/ControlPanels/CStandPipeManifoldVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CStandPipeManifoldVariables.f90 @@ -24,5 +24,5 @@ module CStandPipeManifoldVariables real(8) :: StandPipeGauge1 real(8) :: StandPipeGauge2 End type StandPipeManifoldType - type(StandPipeManifoldType)::StandPipeManifold + end module CStandPipeManifoldVariables \ No newline at end of file diff --git a/CSharp/Equipments/ControlPanels/CTopDrivePanel.f90 b/CSharp/Equipments/ControlPanels/CTopDrivePanel.f90 index 9d19344..9a25b41 100644 --- a/CSharp/Equipments/ControlPanels/CTopDrivePanel.f90 +++ b/CSharp/Equipments/ControlPanels/CTopDrivePanel.f90 @@ -1,5 +1,6 @@ module CTopDrivePanel use CTopDrivePanelVariables + use ConfigurationVariables use CLog3 implicit none public @@ -11,9 +12,9 @@ module CTopDrivePanel !DEC$ ATTRIBUTES ALIAS: 'SetTopDriveTdsPowerState' :: SetTopDriveTdsPowerState implicit none integer, intent(in) :: v - TopDrivePanel%TopDriveTdsPowerState = v + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState = v #ifdef deb - call Log_3( 'TopDriveTdsPowerState=', TopDrivePanel%TopDriveTdsPowerState) + call Log_3( 'TopDriveTdsPowerState=', data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState) #endif end subroutine @@ -22,9 +23,9 @@ module CTopDrivePanel !DEC$ ATTRIBUTES ALIAS: 'SetTopDriveTorqueWrench' :: SetTopDriveTorqueWrench implicit none logical, intent(in) :: v - TopDrivePanel%TopDriveTorqueWrench = v + data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrench = v #ifdef deb - call Log_3( 'TopDriveTorqueWrench=', TopDrivePanel%TopDriveTorqueWrench) + call Log_3( 'TopDriveTorqueWrench=', data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrench) #endif end subroutine @@ -33,9 +34,9 @@ module CTopDrivePanel !DEC$ ATTRIBUTES ALIAS: 'SetTopDriveDrillTorqueState' :: SetTopDriveDrillTorqueState implicit none integer, intent(in) :: v - TopDrivePanel%TopDriveDrillTorqueState = v + data%EquipmentControl%TopDrivePanel%TopDriveDrillTorqueState = v #ifdef deb - call Log_3( 'TopDriveDrillTorqueState=', TopDrivePanel%TopDriveDrillTorqueState) + call Log_3( 'TopDriveDrillTorqueState=', data%EquipmentControl%TopDrivePanel%TopDriveDrillTorqueState) #endif end subroutine @@ -44,9 +45,9 @@ module CTopDrivePanel !DEC$ ATTRIBUTES ALIAS: 'SetTopDriveLinkTiltState' :: SetTopDriveLinkTiltState implicit none integer, intent(in) :: v - TopDrivePanel%TopDriveLinkTiltState = v + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState = v #ifdef deb - call Log_3( 'TopDriveLinkTiltState=', TopDrivePanel%TopDriveLinkTiltState) + call Log_3( 'TopDriveLinkTiltState=', data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState) #endif end subroutine @@ -55,9 +56,9 @@ module CTopDrivePanel !DEC$ ATTRIBUTES ALIAS: 'SetTopDriveIbop' :: SetTopDriveIbop implicit none logical, intent(in) :: v - TopDrivePanel%TopDriveIbop = v + data%EquipmentControl%TopDrivePanel%TopDriveIbop = v #ifdef deb - call Log_3( 'TopDriveIbop=', TopDrivePanel%TopDriveIbop) + call Log_3( 'TopDriveIbop=', data%EquipmentControl%TopDrivePanel%TopDriveIbop) #endif end subroutine @@ -65,33 +66,35 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: SetTopDriveTorqueLimitKnob !DEC$ ATTRIBUTES ALIAS: 'SetTopDriveTorqueLimitKnob' :: SetTopDriveTorqueLimitKnob ! use CSimulationVariables, only: IsPortable - use CDrillingConsoleVariables!, only: DrillingConsole%RTSwitch, DrillingConsole%RTTorqueLimitKnob - use CWarningsVariables, only: Activate_TopdriveRotaryTableConfilict + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: data%EquipmentControl%DrillingConsole%RTSwitch, data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob + use CWarnings, only: Activate_TopdriveRotaryTableConfilict use CScaleRange implicit none real, intent(in) :: v if (IsPortable) then - if(TopDrivePanel%TopDriveTdsPowerState /= 0 .and. DrillingConsole%RTSwitch /= 0) call Activate_TopdriveRotaryTableConfilict() - if(TopDrivePanel%TopDriveTdsPowerState /= 0 .and. DrillingConsole%RTSwitch == 0) then - DrillingConsole%RTTorqueLimitKnob = 0 - TopDrivePanel%TopDriveTorqueLimitKnob = v + if(data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= 0 .and. data%EquipmentControl%DrillingConsole%RTSwitch /= 0) call Activate_TopdriveRotaryTableConfilict() + if(data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= 0 .and. data%EquipmentControl%DrillingConsole%RTSwitch == 0) then + data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob = 0 + data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitKnob = v #ifdef deb - call Log_3( 'RTTorqueLimitKnob=', DrillingConsole%RTTorqueLimitKnob ) - call Log_3( 'TopDriveTorqueLimitKnob=', TopDrivePanel%TopDriveTorqueLimitKnob ) + call Log_3( 'RTTorqueLimitKnob=', data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob ) + call Log_3( 'TopDriveTorqueLimitKnob=', data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitKnob ) #endif endif - if(TopDrivePanel%TopDriveTdsPowerState == 0 .and. DrillingConsole%RTSwitch /= 0) then - TopDrivePanel%TopDriveTorqueLimitKnob = 0 - DrillingConsole%RTTorqueLimitKnob = real(ScaleRange(v, 0.0, 10.0, 0.0, 6000.0), 8) + if(data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == 0 .and. data%EquipmentControl%DrillingConsole%RTSwitch /= 0) then + data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitKnob = 0 + data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob = real(ScaleRange(v, 0.0, 10.0, 0.0, 6000.0), 8) #ifdef deb - call Log_3( 'RTTorqueLimitKnob=', DrillingConsole%RTTorqueLimitKnob ) - call Log_3( 'TopDriveTorqueLimitKnob=', TopDrivePanel%TopDriveTorqueLimitKnob ) + call Log_3( 'RTTorqueLimitKnob=', data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob ) + call Log_3( 'TopDriveTorqueLimitKnob=', data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitKnob ) #endif endif else - TopDrivePanel%TopDriveTorqueLimitKnob = v + data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitKnob = v #ifdef deb - call Log_3( 'TopDriveTorqueLimitKnob=', TopDrivePanel%TopDriveTorqueLimitKnob) + call Log_3( 'TopDriveTorqueLimitKnob=', data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitKnob) #endif endif @@ -101,31 +104,33 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: SetRpmKnob !DEC$ ATTRIBUTES ALIAS: 'SetRpmKnob' :: SetRpmKnob ! use CSimulationVariables, only: IsPortable - use CDrillingConsoleVariables!, only: DrillingConsole%RTSwitch, DrillingConsole%RTThrottle - use CWarningsVariables, only: Activate_TopdriveRotaryTableConfilict + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: data%EquipmentControl%DrillingConsole%RTSwitch, data%EquipmentControl%DrillingConsole%RTThrottle + use CWarnings, only: Activate_TopdriveRotaryTableConfilict use CScaleRange implicit none real, intent(in) :: v if (IsPortable) then - if(TopDrivePanel%TopDriveTdsPowerState /= 0 .and. DrillingConsole%RTSwitch /= 0) call Activate_TopdriveRotaryTableConfilict() - if(TopDrivePanel%TopDriveTdsPowerState /= 0 .and. DrillingConsole%RTSwitch == 0) then - DrillingConsole%RTThrottle = 0 - TopDrivePanel%RpmKnob = v + if(data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= 0 .and. data%EquipmentControl%DrillingConsole%RTSwitch /= 0) call Activate_TopdriveRotaryTableConfilict() + if(data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= 0 .and. data%EquipmentControl%DrillingConsole%RTSwitch == 0) then + data%EquipmentControl%DrillingConsole%RTThrottle = 0 + data%EquipmentControl%TopDrivePanel%RpmKnob = v #ifdef deb - call Log_3( 'RTThrottle=', DrillingConsole%RTThrottle ) - call Log_3( 'RpmKnob=', TopDrivePanel%RpmKnob ) + call Log_3( 'RTThrottle=', data%EquipmentControl%DrillingConsole%RTThrottle ) + call Log_3( 'RpmKnob=', data%EquipmentControl%TopDrivePanel%RpmKnob ) #endif endif - if(TopDrivePanel%TopDriveTdsPowerState == 0 .and. DrillingConsole%RTSwitch /= 0) then - TopDrivePanel%RpmKnob = 0 - DrillingConsole%RTThrottle = real(ScaleRange(v, 0.0, 965.0, 0.0, 250.0), 8) + if(data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == 0 .and. data%EquipmentControl%DrillingConsole%RTSwitch /= 0) then + data%EquipmentControl%TopDrivePanel%RpmKnob = 0 + data%EquipmentControl%DrillingConsole%RTThrottle = real(ScaleRange(v, 0.0, 965.0, 0.0, 250.0), 8) #ifdef deb - call Log_3( 'RpmKnob=', TopDrivePanel%RpmKnob ) - call Log_3( 'RTThrottle=', DrillingConsole%RTThrottle ) + call Log_3( 'RpmKnob=', data%EquipmentControl%TopDrivePanel%RpmKnob ) + call Log_3( 'RTThrottle=', data%EquipmentControl%DrillingConsole%RTThrottle ) #endif endif else - TopDrivePanel%RpmKnob = v + data%EquipmentControl%TopDrivePanel%RpmKnob = v endif @@ -133,9 +138,9 @@ module CTopDrivePanel if (IsPortable) then ! else - TopDrivePanel%RpmKnob = v + data%EquipmentControl%TopDrivePanel%RpmKnob = v #ifdef deb - call Log_3( 'RpmKnob=', TopDrivePanel%RpmKnob ) + call Log_3( 'RpmKnob=', data%EquipmentControl%TopDrivePanel%RpmKnob ) #endif endif @@ -147,7 +152,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveOperationFaultLed !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveOperationFaultLed' :: GetTopDriveOperationFaultLed implicit none - GetTopDriveOperationFaultLed = TopDrivePanel%TopDriveOperationFaultLed + GetTopDriveOperationFaultLed = data%EquipmentControl%TopDrivePanel%TopDriveOperationFaultLed !GetTopDriveOperationFaultLed = 1 end function @@ -155,7 +160,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveTdsPowerLed !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveTdsPowerLed' :: GetTopDriveTdsPowerLed implicit none - GetTopDriveTdsPowerLed = TopDrivePanel%TopDriveTdsPowerLed + GetTopDriveTdsPowerLed = data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerLed !GetTopDriveTdsPowerLed = 1 end function @@ -163,7 +168,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveTorqueWrenchLed !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveTorqueWrenchLed' :: GetTopDriveTorqueWrenchLed implicit none - GetTopDriveTorqueWrenchLed = TopDrivePanel%TopDriveTorqueWrenchLed + GetTopDriveTorqueWrenchLed = data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrenchLed !GetTopDriveTorqueWrenchLed = 1 end function @@ -171,7 +176,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveLinkTiltLed !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveLinkTiltLed' :: GetTopDriveLinkTiltLed implicit none - GetTopDriveLinkTiltLed = TopDrivePanel%TopDriveLinkTiltLed + GetTopDriveLinkTiltLed = data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed !GetTopDriveLinkTiltLed = 1 end function @@ -179,7 +184,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveIbopLed !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveIbopLed' :: GetTopDriveIbopLed implicit none - GetTopDriveIbopLed = TopDrivePanel%TopDriveIbopLed + GetTopDriveIbopLed = data%EquipmentControl%TopDrivePanel%TopDriveIbopLed !GetTopDriveIbopLed = 1 end function @@ -187,7 +192,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveTorqueGauge !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveTorqueGauge' :: GetTopDriveTorqueGauge implicit none - GetTopDriveTorqueGauge = TopDrivePanel%TopDriveTorqueGauge + GetTopDriveTorqueGauge = data%EquipmentControl%TopDrivePanel%TopDriveTorqueGauge !GetTopDriveTorqueGauge = 340 end function @@ -195,7 +200,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveTorqueLimitGauge !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveTorqueLimitGauge' :: GetTopDriveTorqueLimitGauge implicit none - GetTopDriveTorqueLimitGauge = TopDrivePanel%TopDriveTorqueLimitGauge + GetTopDriveTorqueLimitGauge = data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitGauge !GetTopDriveTorqueLimitGauge = 442 end function @@ -203,7 +208,7 @@ module CTopDrivePanel !DEC$ ATTRIBUTES DLLEXPORT :: GetTopDriveRpmGauge !DEC$ ATTRIBUTES ALIAS: 'GetTopDriveRpmGauge' :: GetTopDriveRpmGauge implicit none - GetTopDriveRpmGauge = TopDrivePanel%TopDriveRpmGauge + GetTopDriveRpmGauge = data%EquipmentControl%TopDrivePanel%TopDriveRpmGauge !GetTopDriveRpmGauge = 67 end function diff --git a/CSharp/Equipments/ControlPanels/CTopDrivePanelVariables.f90 b/CSharp/Equipments/ControlPanels/CTopDrivePanelVariables.f90 index bc1c032..d133e2d 100644 --- a/CSharp/Equipments/ControlPanels/CTopDrivePanelVariables.f90 +++ b/CSharp/Equipments/ControlPanels/CTopDrivePanelVariables.f90 @@ -40,6 +40,5 @@ module CTopDrivePanelVariables real :: TopDriveTorqueGauge real :: TopDriveRpmGauge end type TopDrivePanelType - Type(TopDrivePanelType)::TopDrivePanel contains end module CTopDrivePanelVariables \ No newline at end of file diff --git a/CSharp/Equipments/DrillWatch/CDrillWatch.f90 b/CSharp/Equipments/DrillWatch/CDrillWatch.f90 deleted file mode 100644 index 75c1994..0000000 --- a/CSharp/Equipments/DrillWatch/CDrillWatch.f90 +++ /dev/null @@ -1,171 +0,0 @@ -module CDrillWatch - use CDrillWatchVariables - !! use CSimulationVariables - implicit none - public - contains - - ! Input routines - - ! Output routines - - real(8) function GetDepth() - !DEC$ ATTRIBUTES DLLEXPORT :: GetDepth - !DEC$ ATTRIBUTES ALIAS: 'GetDepth' :: GetDepth - implicit none - GetDepth = DrillingWatch%Depth - !GetDepth = Depth + 10 + SimulationTime - end function - - real(8) function GetBitPosition() - !DEC$ ATTRIBUTES DLLEXPORT :: GetBitPosition - !DEC$ ATTRIBUTES ALIAS: 'GetBitPosition' :: GetBitPosition - implicit none - GetBitPosition = DrillingWatch%BitPosition - !GetBitPosition = BitPosition + 20 + SimulationTime - end function - - real(8) function GetHookLoadD() - !DEC$ ATTRIBUTES DLLEXPORT :: GetHookLoadD - !DEC$ ATTRIBUTES ALIAS: 'GetHookLoadD' :: GetHookLoadD - implicit none - GetHookLoadD = DrillingWatch%HookLoad - !GetHookLoadD = HookLoad + 30 + SimulationTime - end function - - real(8) function GetWeightOnBit() - !DEC$ ATTRIBUTES DLLEXPORT :: GetWeightOnBit - !DEC$ ATTRIBUTES ALIAS: 'GetWeightOnBit' :: GetWeightOnBit - implicit none - GetWeightOnBit = DrillingWatch%WeightOnBit - !GetWeightOnBit = WeightOnBit + 40 + SimulationTime - end function - - real(8) function GetRPM() - !DEC$ ATTRIBUTES DLLEXPORT :: GetRPM - !DEC$ ATTRIBUTES ALIAS: 'GetRPM' :: GetRPM - implicit none - GetRPM = DrillingWatch%RPM - !GetRPM = RPM + 50 + SimulationTime - end function - - real(8) function GetROP2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetROP2 - !DEC$ ATTRIBUTES ALIAS: 'GetROP2' :: GetROP2 - implicit none - GetROP2 = DrillingWatch%ROP - !GetROP2 = ROP + 60 + SimulationTime - end function - - real(8) function GetTorque() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTorque - !DEC$ ATTRIBUTES ALIAS: 'GetTorque' :: GetTorque - implicit none - GetTorque = DrillingWatch%Torque - !GetTorque = Torque + 70 + SimulationTime - end function - - real(8) function GetPumpPressureD() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPumpPressureD - !DEC$ ATTRIBUTES ALIAS: 'GetPumpPressureD' :: GetPumpPressureD - implicit none - GetPumpPressureD = DrillingWatch%PumpPressure - !GetPumpPressureD = PumpPressure + 80 + SimulationTime - end function - - real(8) function GetSPM1() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSPM1 - !DEC$ ATTRIBUTES ALIAS: 'GetSPM1' :: GetSPM1 - implicit none - GetSPM1 = DrillingWatch%SPM1 - !GetSPM1 = SPM1 + 90 + SimulationTime - end function - - real(8) function GetSPM2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSPM2 - !DEC$ ATTRIBUTES ALIAS: 'GetSPM2' :: GetSPM2 - implicit none - GetSPM2 = DrillingWatch%SPM2 - !GetSPM2 = SPM2 + 100 + SimulationTime - end function - - ! real(8) function GetSPM3() - !!DEC$ ATTRIBUTES DLLEXPORT :: GetSPM3 - !!DEC$ ATTRIBUTES ALIAS: 'GetSPM3' :: GetSPM3 - ! implicit none - ! GetSPM3 = SPM3 - !end function - - real(8) function GetCasingPressureD() - !DEC$ ATTRIBUTES DLLEXPORT :: GetCasingPressureD - !DEC$ ATTRIBUTES ALIAS: 'GetCasingPressureD' :: GetCasingPressureD - implicit none - GetCasingPressureD = DrillingWatch%CasingPressure - !GetCasingPressureD = CasingPressure + 110 + SimulationTime - end function - - real(8) function GetPercentFlow() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPercentFlow - !DEC$ ATTRIBUTES ALIAS: 'GetPercentFlow' :: GetPercentFlow - implicit none - GetPercentFlow = DrillingWatch%PercentFlow - !GetPercentFlow = PercentFlow + 120 + SimulationTime - end function - - real(8) function GetPitGainLose() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPitGainLose - !DEC$ ATTRIBUTES ALIAS: 'GetPitGainLose' :: GetPitGainLose - implicit none - GetPitGainLose = DrillingWatch%PitGainLose - !GetPitGainLose = PitGainLose + 130 + SimulationTime - end function - - real(8) function GetPitVolume() - !DEC$ ATTRIBUTES DLLEXPORT :: GetPitVolume - !DEC$ ATTRIBUTES ALIAS: 'GetPitVolume' :: GetPitVolume - implicit none - GetPitVolume = DrillingWatch%PitVolume - !GetPitVolume = PitVolume + 140 + SimulationTime - end function - - real(8) function GetKillMudVolume() - !DEC$ ATTRIBUTES DLLEXPORT :: GetKillMudVolume - !DEC$ ATTRIBUTES ALIAS: 'GetKillMudVolume' :: GetKillMudVolume - implicit none - GetKillMudVolume = DrillingWatch%KillMudVolume - !GetKillMudVolume = KillMudVolume + 150 + SimulationTime - end function - - real(8) function GetTripTankVolume() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTripTankVolume - !DEC$ ATTRIBUTES ALIAS: 'GetTripTankVolume' :: GetTripTankVolume - implicit none - GetTripTankVolume = DrillingWatch%TripTankVolume - !GetTripTankVolume = TripTankVolume + 160 + SimulationTime - end function - - real(8) function GetMudWeightInD() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMudWeightInD - !DEC$ ATTRIBUTES ALIAS: 'GetMudWeightInD' :: GetMudWeightInD - implicit none - GetMudWeightInD = DrillingWatch%MudWeightIn - !GetMudWeightInD = MudWeightIn + 170 + SimulationTime - end function - - real(8) function GetFillVolume() - !DEC$ ATTRIBUTES DLLEXPORT :: GetFillVolume - !DEC$ ATTRIBUTES ALIAS: 'GetFillVolume' :: GetFillVolume - implicit none - GetFillVolume = DrillingWatch%FillVolume - !GetFillVolume = FillVolume + 180 + SimulationTime - end function - - real(8) function GetMudWeightOutD() - !DEC$ ATTRIBUTES DLLEXPORT :: GetMudWeightOutD - !DEC$ ATTRIBUTES ALIAS: 'GetMudWeightOutD' :: GetMudWeightOutD - implicit none - GetMudWeightOutD = DrillingWatch%MudWeightOut - !GetMudWeightOutD = MudWeightOut + 190 + SimulationTime - end function - -end module CDrillWatch \ No newline at end of file diff --git a/CSharp/Equipments/DrillWatch/CDrillWatchVariables.f90 b/CSharp/Equipments/DrillWatch/CDrillWatchVariables.f90 index 1f6db9b..8a84e12 100644 --- a/CSharp/Equipments/DrillWatch/CDrillWatchVariables.f90 +++ b/CSharp/Equipments/DrillWatch/CDrillWatchVariables.f90 @@ -29,6 +29,6 @@ module CDrillWatchVariables real(8) :: MudWeightOut End Type DrillingWatchType - Type(DrillingWatchType)::DrillingWatch + end module CDrillWatchVariables \ No newline at end of file diff --git a/CSharp/Equipments/MudPathFinding/CManifolds.f90 b/CSharp/Equipments/MudPathFinding/CManifolds.f90 index 8060975..f02b0d7 100644 --- a/CSharp/Equipments/MudPathFinding/CManifolds.f90 +++ b/CSharp/Equipments/MudPathFinding/CManifolds.f90 @@ -2,7 +2,10 @@ module CManifolds use CStack use CArrangement ! use CPathChangeEvents - use CDrillingConsoleVariables!, only: DrillingConsole%IRSafetyValveLed, DrillingConsole%IRIBopLed, DrillingConsole%OpenKellyCockLed, DrillingConsole%CloseKellyCockLed, DrillingConsole%OpenSafetyValveLed, DrillingConsole%CloseSafetyValveLed + ! use CDrillingConsoleVariables + use ConfigurationVariables + ! use ConfigurationVariables, only: EquipmentControl + implicit none public @@ -767,7 +770,7 @@ end subroutine PathFinding_Step print*, 'InstallSafetyValve_KellyMode()' #endif - DrillingConsole%IRSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 1 call OpenSafetyValve_KellyMode() end subroutine @@ -784,10 +787,10 @@ end subroutine PathFinding_Step call Manifold%Valve(127)%AdjacentTo(128) call Manifold%Valve(128)%AdjacentTo(127) - DrillingConsole%IRSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 0 call CloseSafetyValve_KellyMode() - DrillingConsole%OpenSafetyValveLed = 0 - DrillingConsole%CloseSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 0 #ifdef deb print*, 'RemoveSafetyValve_KellyMode()' @@ -798,8 +801,8 @@ end subroutine PathFinding_Step subroutine OpenSafetyValve_KellyMode() implicit none if(.not.Manifold%IsSafetyValveInstalled_KellyMode) return - DrillingConsole%OpenSafetyValveLed = 1 - DrillingConsole%CloseSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 0 Manifold%SafetyValve = .true. call ChangeValve(56, Manifold%SafetyValve) @@ -812,8 +815,8 @@ end subroutine PathFinding_Step subroutine CloseSafetyValve_KellyMode() implicit none if(.not.Manifold%IsSafetyValveInstalled_KellyMode) return - DrillingConsole%CloseSafetyValveLed = 1 - DrillingConsole%OpenSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 0 Manifold%SafetyValve = .false. call ChangeValve(56, Manifold%SafetyValve) @@ -855,7 +858,7 @@ end subroutine PathFinding_Step call Manifold%Valve(54)%AdjacentTo(69) call Manifold%Valve(69)%AdjacentTo(54) - DrillingConsole%IRSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 1 call OpenSafetyValve_TripMode() #ifdef deb @@ -877,10 +880,10 @@ end subroutine PathFinding_Step call Manifold%Valve(124)%AdjacentTo(69) call Manifold%Valve(69)%AdjacentTo(124) - DrillingConsole%IRSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 0 call CloseSafetyValve_TripMode() - DrillingConsole%OpenSafetyValveLed = 0 - DrillingConsole%CloseSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 0 #ifdef deb print*, 'RemoveSafetyValve_TripMode()' @@ -891,8 +894,8 @@ end subroutine PathFinding_Step subroutine OpenSafetyValve_TripMode() implicit none if(.not.Manifold%IsSafetyValveInstalled_TripMode) return - DrillingConsole%OpenSafetyValveLed = 1 - DrillingConsole%CloseSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 0 Manifold%SafetyValve = .true. call ChangeValve(54, Manifold%SafetyValve) @@ -905,8 +908,8 @@ end subroutine PathFinding_Step subroutine CloseSafetyValve_TripMode() implicit none if(.not.Manifold%IsSafetyValveInstalled_TripMode) return - DrillingConsole%CloseSafetyValveLed = 1 - DrillingConsole%OpenSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 0 Manifold%SafetyValve = .false. call ChangeValve(54, Manifold%SafetyValve) @@ -942,7 +945,7 @@ end subroutine PathFinding_Step call Manifold%Valve(54)%AdjacentTo(69) call Manifold%Valve(69)%AdjacentTo(54) - DrillingConsole%IRSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 1 call OpenSafetyValve_TopDrive() #ifdef deb @@ -964,10 +967,10 @@ end subroutine PathFinding_Step call Manifold%Valve(124)%AdjacentTo(69) call Manifold%Valve(69)%AdjacentTo(124) - DrillingConsole%IRSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 0 call CloseSafetyValve_TopDrive() - DrillingConsole%OpenSafetyValveLed = 0 - DrillingConsole%CloseSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 0 #ifdef deb print*, 'RemoveSafetyValve_TopDrive()' @@ -978,8 +981,8 @@ end subroutine PathFinding_Step subroutine OpenSafetyValve_TopDrive() implicit none if(.not.Manifold%IsSafetyValveInstalled_TopDrive) return - DrillingConsole%OpenSafetyValveLed = 1 - DrillingConsole%CloseSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 0 Manifold%SafetyValve = .true. #ifdef deb @@ -992,8 +995,8 @@ end subroutine PathFinding_Step subroutine CloseSafetyValve_TopDrive() implicit none if(.not.Manifold%IsSafetyValveInstalled_TopDrive) return - DrillingConsole%CloseSafetyValveLed = 1 - DrillingConsole%OpenSafetyValveLed = 0 + data%EquipmentControl%DrillingConsole%CloseSafetyValveLed = 1 + data%EquipmentControl%DrillingConsole%OpenSafetyValveLed = 0 Manifold%SafetyValve = .false. #ifdef deb @@ -1028,7 +1031,7 @@ end subroutine PathFinding_Step print*, 'InstallIBop()' #endif - DrillingConsole%IRIBopLed = 1 + data%EquipmentControl%DrillingConsole%IRIBopLed = 1 call OpenIBop() end subroutine @@ -1049,7 +1052,7 @@ end subroutine PathFinding_Step print*, 'RemoveIBop()' #endif - DrillingConsole%IRIBopLed = 0 + data%EquipmentControl%DrillingConsole%IRIBopLed = 0 Manifold%IBop = .false. call ChangeValve(55, Manifold%IBop) end subroutine @@ -1119,8 +1122,8 @@ end subroutine PathFinding_Step Manifold%KellyCock = .false. call ChangeValve(68, Manifold%KellyCock) - DrillingConsole%CloseKellyCockLed = 0 - DrillingConsole%OpenKellyCockLed = 0 + data%EquipmentControl%DrillingConsole%CloseKellyCockLed = 0 + data%EquipmentControl%DrillingConsole%OpenKellyCockLed = 0 #ifdef deb print*, 'RemoveKellyCock()' @@ -1131,8 +1134,8 @@ end subroutine PathFinding_Step subroutine OpenKellyCock() implicit none if(.not.Manifold%IsKellyCockInstalled) return - DrillingConsole%OpenKellyCockLed = 1 - DrillingConsole%CloseKellyCockLed = 0 + data%EquipmentControl%DrillingConsole%OpenKellyCockLed = 1 + data%EquipmentControl%DrillingConsole%CloseKellyCockLed = 0 Manifold%KellyCock = .true. #ifdef deb @@ -1145,8 +1148,8 @@ end subroutine PathFinding_Step subroutine CloseKellyCock() implicit none if(.not.Manifold%IsKellyCockInstalled) return - DrillingConsole%CloseKellyCockLed = 1 - DrillingConsole%OpenKellyCockLed = 0 + data%EquipmentControl%DrillingConsole%CloseKellyCockLed = 1 + data%EquipmentControl%DrillingConsole%OpenKellyCockLed = 0 Manifold%KellyCock = .false. #ifdef deb diff --git a/CSharp/Equipments/MudPathFinding/CPathChangeEvents.f90 b/CSharp/Equipments/MudPathFinding/CPathChangeEvents.f90 index 819209f..12bdcdc 100644 --- a/CSharp/Equipments/MudPathFinding/CPathChangeEvents.f90 +++ b/CSharp/Equipments/MudPathFinding/CPathChangeEvents.f90 @@ -1,12 +1,12 @@ module CPathChangeEvents - use CIntegerArrayEventHandlerCollection - use CVoidEventHandlerCollection + ! use CIntegerArrayEventHandlerCollection + ! use CVoidEventHandlerCollection implicit none public - type(VoidEventHandlerCollection) :: BeforeTraverse - type(VoidEventHandlerCollection) :: AfterTraverse - type(IntegerArrayEventHandlerCollection) :: OnPathOpen + ! type(VoidEventHandlerCollection) :: BeforeTraverse + ! type(VoidEventHandlerCollection) :: AfterTraverse + ! type(IntegerArrayEventHandlerCollection) :: OnPathOpen contains end module CPathChangeEvents \ No newline at end of file diff --git a/CSharp/Equipments/MudPathFinding/CStack.f90 b/CSharp/Equipments/MudPathFinding/CStack.f90 index 7974679..b75aeaf 100644 --- a/CSharp/Equipments/MudPathFinding/CStack.f90 +++ b/CSharp/Equipments/MudPathFinding/CStack.f90 @@ -1,5 +1,5 @@ module CStack - use CPath + use CPath,Only:Path implicit none public diff --git a/CSharp/Equipments/Tanks/CTanks.f90 b/CSharp/Equipments/Tanks/CTanks.f90 index a238882..eb01631 100644 --- a/CSharp/Equipments/Tanks/CTanks.f90 +++ b/CSharp/Equipments/Tanks/CTanks.f90 @@ -1,252 +1,20 @@ module CTanks - use CTanksVariables - ! use CSimulationVariables + use ConfigurationVariables use CManifolds implicit none public contains - - ! Input routines - subroutine SetWaterRate(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetWaterRate - !DEC$ ATTRIBUTES ALIAS: 'SetWaterRate' :: SetWaterRate - implicit none - real*8, intent(in) :: v - Tank%WaterRate = v -#ifdef deb - print*, 'WaterRate=', Tank%WaterRate -#endif - end subroutine - - subroutine SetCementTankVolume(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementTankVolume - !DEC$ ATTRIBUTES ALIAS: 'SetCementTankVolume' :: SetCementTankVolume - implicit none - real*8, intent(in) :: v - Tank%CementTankVolume = v -#ifdef deb - print*, 'CementTankVolume=', Tank%CementTankVolume -#endif - end subroutine - - subroutine SetCementTankDensity(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCementTankDensity - !DEC$ ATTRIBUTES ALIAS: 'SetCementTankDensity' :: SetCementTankDensity - implicit none - real*8, intent(in) :: v - Tank%CementTankDensity = v -#ifdef deb - print*, 'CementTankDensity=', Tank%CementTankDensity -#endif - end subroutine - - subroutine SetTripTankVolume(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankVolume - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankVolume' :: SetTripTankVolume - implicit none - real*8, intent(in) :: v - Tank%TripTankVolume = v -#ifdef deb - print*, 'TripTankVolume=', Tank%TripTankVolume -#endif - end subroutine - - subroutine SetTripTankDensity(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTankDensity - !DEC$ ATTRIBUTES ALIAS: 'SetTripTankDensity' :: SetTripTankDensity - implicit none - real*8, intent(in) :: v - Tank%TripTankDensity = v -#ifdef deb - print*, 'TripTankDensity=', Tank%TripTankDensity -#endif - end subroutine - -! subroutine SetManualPumpPowerT(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetManualPumpPowerT -! !DEC$ ATTRIBUTES ALIAS: 'SetManualPumpPowerT' :: SetManualPumpPowerT -! implicit none -! logical, intent(in) :: v -! ManualPumpPower = v -! call ChangeValve(43, v) -!#ifdef deb -! print*, 'ManualPumpPowerT=', ManualPumpPower -!#endif -! end subroutine - - subroutine SetValve1T(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve1T - !DEC$ ATTRIBUTES ALIAS: 'SetValve1T' :: SetValve1T - implicit none - logical, intent(in) :: v - Tank%Valve1 = v - call ChangeValve(40, v) -#ifdef deb - print*, 'Valve1T=', Tank%Valve1 -#endif - end subroutine - - subroutine SetValve2T(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve2T - !DEC$ ATTRIBUTES ALIAS: 'SetValve2T' :: SetValve2T - implicit none - logical, intent(in) :: v - Tank%Valve2 = v - call ChangeValve(41, v) -#ifdef deb - print*, 'Valve2T=', Tank%Valve2 -#endif - end subroutine - - subroutine SetValve3T(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve3T - !DEC$ ATTRIBUTES ALIAS: 'SetValve3T' :: SetValve3T - implicit none - logical, intent(in) :: v - Tank%Valve3 = v - call ChangeValve(45, v) -#ifdef deb - print*, 'Valve3T=', Tank%Valve3 -#endif - end subroutine - - subroutine SetValve4T(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve4T - !DEC$ ATTRIBUTES ALIAS: 'SetValve4T' :: SetValve4T - implicit none - logical, intent(in) :: v - Tank%Valve4 = v - call ChangeValve(58, v) -#ifdef deb - print*, 'Valve4T=', Tank%Valve4 -#endif - end subroutine - - subroutine SetValve5T(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve5T - !DEC$ ATTRIBUTES ALIAS: 'SetValve5T' :: SetValve5T - implicit none - logical, intent(in) :: v - Tank%Valve5 = v - call ChangeValve(42, v) -#ifdef deb - print*, 'Valve5T=', Tank%Valve5 -#endif - end subroutine - - - - - - - - - - - - - - - subroutine SetValve6(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve6 - !DEC$ ATTRIBUTES ALIAS: 'SetValve6' :: SetValve6 - implicit none - logical, intent(in) :: v - Tank%Valve6 = v - call ChangeValve(38, v) - !WRITE (*,*) ' valve 38 ', v -#ifdef deb - print*, 'Valve6=', Tank%Valve6 -#endif + subroutine Set_ManualPumpPower(v) + use CManifolds, only:ChangeValve + implicit none + logical, intent(in) :: v + data%EquipmentControl%Tank%ManualPumpPower = v + call ChangeValve(43, v) + #ifdef deb + print*, 'ManualPumpPower=', data%EquipmentControl%Tank%ManualPumpPower + #endif end subroutine - subroutine SetValve7(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve7 - !DEC$ ATTRIBUTES ALIAS: 'SetValve7' :: SetValve7 - implicit none - logical, intent(in) :: v - Tank%Valve7 = v - call ChangeValve(59, v) -#ifdef deb - print*, 'Valve7=', Tank%Valve7 -#endif - end subroutine - - subroutine SetValve8(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve8 - !DEC$ ATTRIBUTES ALIAS: 'SetValve8' :: SetValve8 - implicit none - logical, intent(in) :: v - Tank%Valve8 = v - call ChangeValve(39, v) -#ifdef deb - print*, 'Valve8=', Tank%Valve8 -#endif - end subroutine - - subroutine SetValve9(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve9 - !DEC$ ATTRIBUTES ALIAS: 'SetValve9' :: SetValve9 - implicit none - logical, intent(in) :: v - Tank%Valve9 = v - call ChangeValve(36, v) - !WRITE (*,*) ' valve 36 ', v -#ifdef deb - print*, 'Valve9=', Tank%Valve9 -#endif - end subroutine - - subroutine SetValve10(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve10 - !DEC$ ATTRIBUTES ALIAS: 'SetValve10' :: SetValve10 - implicit none - logical, intent(in) :: v - Tank%Valve10 = v - call ChangeValve(37, v) -#ifdef deb - print*, 'Valve10=', Tank%Valve10 -#endif - end subroutine - - subroutine SetValve11(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetValve11 - !DEC$ ATTRIBUTES ALIAS: 'SetValve11' :: SetValve11 - implicit none - logical, intent(in) :: v - Tank%Valve11 = v - call ChangeValve(44, v) -#ifdef deb - print*, 'Valve11=', Tank%Valve11 -#endif - end subroutine - - - ! Output routines - - real(8) function GetTripTankVolumeT() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTripTankVolumeT - !DEC$ ATTRIBUTES ALIAS: 'GetTripTankVolumeT' :: GetTripTankVolumeT - implicit none - GetTripTankVolumeT = Tank%TripTankVolume - !GetTripTankVolumeT = 50.0 + SimulationTime - end function - - real(8) function GetTripTankDensity() - !DEC$ ATTRIBUTES DLLEXPORT :: GetTripTankDensity - !DEC$ ATTRIBUTES ALIAS: 'GetTripTankDensity' :: GetTripTankDensity - implicit none - GetTripTankDensity = Tank%TripTankDensity - !GetTripTankDensity = 13.0 + SimulationTime - end function - - logical function GetManualPumpPowerT() - !DEC$ ATTRIBUTES DLLEXPORT :: GetManualPumpPowerT - !DEC$ ATTRIBUTES ALIAS: 'GetManualPumpPowerT' :: GetManualPumpPowerT - implicit none - GetManualPumpPowerT = Tank%ManualPumpPower - !GetManualPumpPowerT = .true. - end function end module CTanks \ No newline at end of file diff --git a/CSharp/Equipments/Tanks/CTanksVariables.f90 b/CSharp/Equipments/Tanks/CTanksVariables.f90 index f7cac12..b268851 100644 --- a/CSharp/Equipments/Tanks/CTanksVariables.f90 +++ b/CSharp/Equipments/Tanks/CTanksVariables.f90 @@ -22,19 +22,8 @@ module CTanksVariables logical :: Valve10 logical :: Valve11 End Type TankType - Type(TankType)::Tank contains - subroutine Set_ManualPumpPower(v) - use CManifolds, only:ChangeValve - implicit none - logical, intent(in) :: v - Tank%ManualPumpPower = v - call ChangeValve(43, v) -#ifdef deb - print*, 'ManualPumpPower=', Tank%ManualPumpPower -#endif - end subroutine end module CTanksVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 b/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 index 37ac9be..098aa9b 100644 --- a/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 +++ b/CSharp/OperationScenarios/Common/COperationScenariosMain.f90 @@ -2,28 +2,12 @@ module COperationScenariosMain use CIActionReference implicit none public - procedure (ActionVoid), pointer :: UpdateUnityPtr + ! procedure (ActionVoid), pointer :: UpdateUnityPtr contains - - ! subroutine OperationScenarios_Setup() - ! ! use CSimulationVariables - ! implicit none - ! call OnSimulationInitialization%Add(OperationScenarios_Init) - ! call OnSimulationStop%Add(OperationScenarios_Init) - ! !call OnOperationScenariosStep%Add(OperationScenarios_Step) - ! !call OnOperationScenariosOutput%Add(OperationScenarios_Output) - ! call OnOperationScenariosMain%Add(OperationScenariosMainBody) - ! end subroutine - - ! subroutine OperationScenarios_Init - ! use COperationScenariosSettings, OperationScenariosInitialization => Initialization - ! implicit none - ! call OperationScenariosInitialization() - ! end subroutine OperationScenarios_Init - + subroutine OperationScenarios_Step ! use CSimulationVariables - use CKellyConnectionEnum + use OperationScenariosModule use CElevatorConnectionEnum use CCloseKellyCockLedNotification use CCloseSafetyValveLedNotification @@ -58,13 +42,14 @@ module COperationScenariosMain Get_ElevatorPickup, & Get_NearFloorPosition, & Get_SingleSetInMouseHole - use CBucketEnum + ! use CBucketEnum + ! use UnitySignalsModule use CElevatorEnum - use CHeadEnum + ! use CHeadEnum use CIbopEnum use CKellyEnum use CMouseHoleEnum - use COperationConditionEnum + use UnitySignalsModule use CSafetyValveEnum use CSlipsEnum use CSwingEnum @@ -77,7 +62,7 @@ module COperationScenariosMain use CSwingOffPermission use CSwingTiltPermission ! use CTdsStemJointHeight - use CTdsConnectionModesEnum + ! use UnitySignalsModule !for CTdsConnectionModesEnum use CTdsElevatorModesEnum use CTdsSpineEnum use CTdsSwingEnum @@ -167,259 +152,19 @@ module COperationScenariosMain call Evaluate_TorqueWrenchLed() end subroutine OperationScenarios_Step - - subroutine OperationScenarios_Output - implicit none - end subroutine OperationScenarios_Output - - ! subroutine OperationScenariosMainBody - ! ! use CSimulationVariables - - ! use CKellyConnectionEnum - ! use CElevatorConnectionEnum - - ! use CCloseKellyCockLedNotification - ! use CCloseSafetyValveLedNotification - ! use CFillMouseHoleLedNotification - ! use CIrIBopLedNotification - ! use CIrSafetyValveLedNotification - ! use CLatchLedNotification - ! use COpenKellyCockLedNotification - ! use COpenSafetyValveLedNotification - ! use CSlipsNotification - ! use CSwingLedNotification - ! use CTongNotification - ! use CUnlatchLedNotification - - ! use CInstallFillupHeadPermission - ! use CInstallMudBucketPermission - ! use CIrIbopPermission - ! use CIrSafetyValvePermission - ! use CRemoveFillupHeadPermission - ! use CRemoveMudBucketPermission - - ! ! use CHookHeight - ! ! use CIbopHeight - ! ! use CNearFloorConnection - ! ! use CSafetyValveHeight - ! ! use CSlackOff - ! ! use CStandRack - ! ! use CStringPressure - ! ! use CZeroStringSpeed - - ! use CUnityInputs, only: & - ! Get_ElevatorConnectionPossible, & - ! Get_JointConnectionPossible, & - ! Get_ElevatorPickup, & - ! Get_NearFloorPosition, & - ! Get_SingleSetInMouseHole - - ! use CBucketEnum - ! use CElevatorEnum - ! use CHeadEnum - ! use CIbopEnum - ! use CKellyEnum - ! use CMouseHoleEnum - ! use COperationConditionEnum - ! use CSafetyValveEnum - ! use CSlipsEnum - ! use CSwingEnum - ! use CTongEnum - - ! ! use CStringUpdate - - ! use CFlowPipeDisconnectEnum - ! use CFlowKellyDisconnectEnum - - - ! use CFillupHeadPermission - ! use CSwingDrillPermission - ! use CSwingOffPermission - ! use CSwingTiltPermission - ! ! use CTdsStemJointHeight - ! use CTdsConnectionModesEnum - ! use CTdsElevatorModesEnum - ! use CTdsSpineEnum - ! use CTdsSwingEnum - ! use CTdsTongEnum - ! use CTdsBackupClamp - - ! use CTdsIbopLedNotification - ! use CTdsPowerLedNotification - - ! use CTdsTorqueWrenchLedNotification + ! subroutine UpdateUnity() ! implicit none - ! loop1: do - ! call Evaluate_KellyConnection() - ! call Evaluate_ElevatorConnection() - - ! call Evaluate_CloseKellyCockLed() - ! call Evaluate_CloseSafetyValveLed() - ! call Evaluate_FillMouseHoleLed() - ! call Evaluate_IrIBopLed() - ! call Evaluate_IrSafetyValveLed() - ! call Evaluate_LatchLed() - ! call Evaluate_OpenKellyCockLed() - ! call Evaluate_OpenSafetyValveLed() - ! call Evaluate_SlipsNotification() - ! call Evaluate_SwingLed() - ! call Evaluate_TongNotification() - ! call Evaluate_UnlatchLed() - - ! call Evaluate_InstallFillupHeadPermission() - ! call Evaluate_InstallMudBucketPermission() - ! call Evaluate_IrIbopPermission() - ! call Evaluate_IrSafetyValvePermission() - ! call Evaluate_RemoveFillupHeadPermission() - ! call Evaluate_RemoveMudBucketPermission() - - ! call Evaluate_MudBucket() - ! call Evaluate_Elevator() - ! call Evaluate_FillupHead() - ! call Evaluate_Ibop() - ! call Evaluate_Kelly() - ! call Evaluate_MouseHole() - ! call Evaluate_MouseHole() - ! call Evaluate_OperationCondition() - ! call Evaluate_SafetyValve() - ! call Evaluate_Slips() - ! call Evaluate_Swing() - ! call Evaluate_Tong() - - ! ! call Evaluate_StringUpdate() - - ! call Evaluate_FlowKellyDisconnect() - ! call Evaluate_FlowPipeDisconnect() - - ! !if(Get_FillMouseHoleLed()) then - ! ! call Set_MouseHole(MOUSE_HOLE_FILL) - ! !else - ! ! if((Get_KellyConnection() == KELLY_CONNECTION_SINGLE .or.& - ! ! Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) .and.& - ! ! Get_HookHeight() >= 95.0 ) then - ! ! call Set_MouseHole(MOUSE_HOLE_NEUTRAL) - ! ! else - ! ! call Set_MouseHole(MOUSE_HOLE_EMPTY) - ! ! endif - ! !endif - - - - - - - - - ! !topdrive - ! call Evaluate_TdsElevatorModes() - ! call Evaluate_TdsConnectionModes() - ! call Evaluate_SwingTiltPermission() - ! call Evaluate_SwingOffPermission() - ! call Evaluate_SwingDrillPermission() - ! call Evaluate_FillupHeadPermission() - ! call Evaluate_TdsTong() - ! call Evaluate_TdsBackupClamp() - ! call Evaluate_TdsSwing() - ! call Evaluate_TdsSpine() - - ! call Evaluate_PowerLed() - ! call Evaluate_IbopLed() - - ! call Evaluate_TorqueWrenchLed() - - ! !if (IsStopped==.true.) exit loop1 - ! if(IsStopped) call Quit() - ! call sleepqq(100) - ! enddo loop1 - ! end subroutine OperationScenariosMainBody - - - - - ! subroutine SubscribeUpdateUnity(a) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeUpdateUnity - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeUpdateUnity' :: SubscribeUpdateUnity - ! implicit none - ! procedure (ActionVoid) :: a - ! UpdateUnityPtr => a - ! end subroutine - - subroutine UpdateUnity() - implicit none - if(associated(UpdateUnityPtr)) call UpdateUnityPtr() - end subroutine - - ! subroutine PreProcessingSnapshot - ! !DEC$ ATTRIBUTES DLLEXPORT :: PreProcessingSnapshot - ! !DEC$ ATTRIBUTES ALIAS: 'PreProcessingSnapshot' :: PreProcessingSnapshot - ! use CSwingEnumVariables - ! use CSlipsEnumVariables - ! use CHookVariables - ! use CTongEnumVariables - ! use CHoistingVariables - ! use CKellyConnectionEnumVariables - ! use COperationScenariosVariables - ! ! use CElevatorConnectionEnumVariables - ! use COperationConditionEnumVariables - ! use CMouseHoleEnumVariables - ! implicit none - - ! if(Hoisting%DriveType == Kelly_DriveType) then ! kelly mode - - - ! if(Get_OperationCondition() == OPERATION_DRILL) then - - ! if(Get_KellyConnection() == KELLY_CONNECTION_NOTHING) then - ! call Kelly_ConnectionNothing() - - ! elseif (Get_KellyConnection() == KELLY_CONNECTION_STRING) then - ! call Kelly_ConnectionString() - - ! elseif (Get_KellyConnection() == KELLY_CONNECTION_SINGLE) then - ! call Kelly_ConnectionSingle() - - ! endif - - ! elseif (Get_OperationCondition() == OPERATION_TRIP) then - - ! if(Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING) then - ! call Elevator_ConnectionNothing() - - ! elseif (Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING) then - ! call Elevator_ConnectionString() - - ! elseif (Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND) then - ! call Elevator_ConnectionStand() - - ! elseif (Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) then - ! call Elevator_ConnectionSingle() - - ! endif - - - ! endif - - - - - ! else ! Topdrive mode - ! ! - ! endif - - ! ! final adjustments - ! call Update_MouseHole_From_Snapshot() - - ! end subroutine PreProcessingSnapshot - - - + ! if(associated(UpdateUnityPtr)) call UpdateUnityPtr() + ! end subroutine subroutine Kelly_ConnectionNothing ! use CSwingEnumVariables ! use CSlipsEnumVariables use UnitySignalVariables - use CHookVariables + use UnitySignalsModule + use CHook + use ConfigurationVariables implicit none call Set_HookHeight(75.0) @@ -435,23 +180,23 @@ module COperationScenariosMain !TODO: possibly goto a position to activate swing ! goto preferred swing position - if(UnitySignals%Swing_S == SWING_MOUSE_HOLE_END) then + if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then call Set_Swing(SWING_MOUSE_HOLE_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop2: do if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2 call sleepqq(100) enddo loop2 - elseif (UnitySignals%Swing_S == SWING_RAT_HOLE_END) then + elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then call Set_Swing(SWING_RAT_HOLE_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop3: do if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3 call sleepqq(100) enddo loop3 !elseif (Swing_S == SWING_WELL_END) then ! call Set_Swing(SWING_WELL_BEGIN) - ! call UpdateUnity() + ! !@call UpdateUnity() ! loop4: do ! if(Get_Swing() == SWING_WELL_END) exit loop4 ! call sleepqq(100) @@ -473,7 +218,9 @@ module COperationScenariosMain ! use CSwingEnumVariables ! use CSlipsEnumVariables use UnitySignalVariables - use CHookVariables + use UnitySignalsModule + use CHook + use ConfigurationVariables ! use CTongEnumVariables implicit none @@ -493,7 +240,7 @@ module COperationScenariosMain ! start tong makeup call Set_Tong(TONG_MAKEUP_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop2: do if(Get_Tong() == TONG_MAKEUP_END) exit loop2 call sleepqq(100) @@ -502,7 +249,7 @@ module COperationScenariosMain ! release slips call Set_Slips(SLIPS_UNSET_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop3: do if(Get_Slips() == SLIPS_UNSET_END) exit loop3 call sleepqq(100) @@ -515,10 +262,10 @@ module COperationScenariosMain ! put slips to saved position - if(UnitySignals%Slips_S == SLIPS_SET_END) then + if(data%State%unitySignals%Slips_S == SLIPS_SET_END) then call Set_Slips(SLIPS_SET_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop4: do if(Get_Slips() == SLIPS_SET_END) exit loop4 call sleepqq(100) @@ -537,7 +284,9 @@ module COperationScenariosMain ! use CSlipsEnumVariables ! use CTongEnumVariables use UnitySignalVariables - use CHookVariables + use UnitySignalsModule + use CHook + use ConfigurationVariables implicit none call Set_HookHeight(75.0) @@ -557,7 +306,7 @@ module COperationScenariosMain ! swing mouse hole call Set_Swing(SWING_MOUSE_HOLE_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop2: do if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2 call sleepqq(100) @@ -572,7 +321,7 @@ module COperationScenariosMain ! start tong makeup call Set_Tong(TONG_MAKEUP_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop3: do if(Get_Tong() == TONG_MAKEUP_END) exit loop3 call sleepqq(100) @@ -581,7 +330,7 @@ module COperationScenariosMain - if (UnitySignals%Swing_S == SWING_WELL_END) then ! already in mouse hole + if (data%State%unitySignals%Swing_S == SWING_WELL_END) then ! already in mouse hole ! goto swing location call Set_HookHeight_S(98.0) @@ -589,7 +338,7 @@ module COperationScenariosMain ! goto preferred swing position call Set_Swing(SWING_WELL_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop4: do if(Get_Swing() == SWING_WELL_END) exit loop4 call sleepqq(100) @@ -604,17 +353,14 @@ module COperationScenariosMain call sleep(3) end subroutine Kelly_ConnectionSingle - - - - - - + subroutine Elevator_ConnectionNothing ! use CSwingEnumVariables ! use CSlipsEnumVariables use UnitySignalVariables - use CHookVariables + use UnitySignalsModule + use CHook + use ConfigurationVariables ! use CKellyEnumVariables implicit none @@ -633,7 +379,7 @@ module COperationScenariosMain !! first goto mouse hole !call Set_Swing(SWING_MOUSE_HOLE_BEGIN) - !call UpdateUnity() + !!@call UpdateUnity() !loop2: do ! if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2 ! call sleepqq(100) @@ -642,7 +388,7 @@ module COperationScenariosMain ! !! then goto rat hole !call Set_Swing(SWING_RAT_HOLE_BEGIN) - !call UpdateUnity() + !!@call UpdateUnity() !loop3: do ! if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3 ! call sleepqq(100) @@ -653,26 +399,24 @@ module COperationScenariosMain call Set_Kelly(KELLY_REMOVE) call sleepqq(100) - - ! goto preferred swing position - if(UnitySignals%Swing_S == SWING_MOUSE_HOLE_END) then + if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then call Set_Swing(SWING_MOUSE_HOLE_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop4: do if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop4 call sleepqq(100) enddo loop4 - elseif (UnitySignals%Swing_S == SWING_RAT_HOLE_END) then + elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then call Set_Swing(SWING_RAT_HOLE_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop5: do if(Get_Swing() == SWING_RAT_HOLE_END) exit loop5 call sleepqq(100) enddo loop5 - elseif (UnitySignals%Swing_S == SWING_WELL_END) then + elseif (data%State%unitySignals%Swing_S == SWING_WELL_END) then call Set_Swing(SWING_WELL_BEGIN) - call UpdateUnity() + !@call UpdateUnity() loop6: do if(Get_Swing() == SWING_WELL_END) exit loop6 call sleepqq(100) @@ -714,9 +458,5 @@ module COperationScenariosMain subroutine Elevator_ConnectionSingle implicit none end subroutine Elevator_ConnectionSingle - - - - - + end module COperationScenariosMain \ No newline at end of file diff --git a/CSharp/OperationScenarios/Common/COperationScenariosSettings.f90 b/CSharp/OperationScenarios/Common/COperationScenariosSettings.f90 index 3eda2f4..6d203f4 100644 --- a/CSharp/OperationScenarios/Common/COperationScenariosSettings.f90 +++ b/CSharp/OperationScenarios/Common/COperationScenariosSettings.f90 @@ -12,10 +12,10 @@ module COperationScenariosSettings ! use CSwingEnum ! use CSlipsEnum ! use CSafetyValveEnum - ! use COperationConditionEnum + ! use UnitySignalsModule ! use CMouseHoleEnum ! use CKellyEnum - ! use CKellyConnectionEnum + ! use OperationScenariosModule ! use CIbopEnum ! use CHeadEnum ! use CElevatorEnum @@ -60,7 +60,7 @@ module COperationScenariosSettings ! use CSwingOffPermission ! use CSwingTiltPermission ! use CTdsStemJointHeight - ! use CTdsConnectionModesEnum + ! use UnitySignalsModule !for CTdsConnectionModesEnum ! use CTdsElevatorModesEnum ! use CTdsSpineEnum ! use CTdsSwingEnum @@ -153,8 +153,9 @@ module COperationScenariosSettings !end subroutine subroutine SetDefaultValues() - use COperationScenariosVariables - use CHoistingVariables!, only: Hoisting%DriveType, TopDrive_DriveType + use OperationScenariosModule + use CHoistingVariables + use ConfigurationVariables!, only: data%State%Hoisting%DriveType, TopDrive_DriveType use CManifolds, only: RemoveSafetyValve_TripMode, RemoveSafetyValve_KellyMode implicit none @@ -185,7 +186,7 @@ module COperationScenariosSettings call Set_FillMouseHoleLed(.true.) !Get_FillMouseHoleLed() call Set_IrIBopLed(.false.) !Get_IrIBopLed() !call Set_IrSafetyValveLed(.true.) !Get_IrSafetyValveLed() - if(Hoisting%DriveType == TopDrive_DriveType) then + if(data%State%Hoisting%DriveType == TopDrive_DriveType) then call RemoveSafetyValve_TripMode() call RemoveSafetyValve_KellyMode() call Set_IrSafetyValveLed(.false.) @@ -302,7 +303,7 @@ module COperationScenariosSettings !Get_SafetyValve() !SAFETY_VALVE_INSTALL !SAFETY_VALVE_REMOVE - if(Hoisting%DriveType == TopDrive_DriveType) call Set_SafetyValve(SAFETY_VALVE_REMOVE) + if(data%State%Hoisting%DriveType == TopDrive_DriveType) call Set_SafetyValve(SAFETY_VALVE_REMOVE) call Set_Slips(SLIPS_SET_BEGIN) !Get_Slips() diff --git a/CSharp/OperationScenarios/Common/COperationScenariosVariables.f90 b/CSharp/OperationScenarios/Common/COperationScenariosVariables.f90 index df277ed..076b6b4 100644 --- a/CSharp/OperationScenarios/Common/COperationScenariosVariables.f90 +++ b/CSharp/OperationScenarios/Common/COperationScenariosVariables.f90 @@ -1,92 +1,4 @@ -module COperationScenariosVariables - - use CKellyConnectionEnumVariables - use CElevatorConnectionEnumVariables - - use NotificationVariables - ! use CCloseKellyCockLedNotificationVariables - ! use CCloseSafetyValveLedNotificationVariables - ! use CFillMouseHoleLedNotificationVariables - ! use CIrIBopLedNotificationVariables - ! use CIrSafetyValveLedNotificationVariables - ! use CLatchLedNotificationVariables - ! use COpenKellyCockLedNotificationVariables - ! use COpenSafetyValveLedNotificationVariables - ! use CSlipsNotificationVariables - ! use CSwingLedNotificationVariables - ! use CTongNotificationVariables - ! use CUnlatchLedNotificationVariables - - use PermissionsVariables - ! use CInstallFillupHeadPermissionVariables - ! use CInstallMudBucketPermissionVariables - ! use CIrIbopPermissionVariables - ! use CIrSafetyValvePermissionVariables - ! use CRemoveFillupHeadPermissionVariables - ! use CRemoveMudBucketPermissionVariables - - use SoftwareInputsVariables - !use CHookHeight - !use CIbopHeight - !use CNearFloorConnection - !use CSafetyValveHeight - !use CSlackOff - !use CStandRack - !use CStringPressure - !use CZeroStringSpeed - - ! use CStringUpdateVariables - - use CUnityInputs - !, only: Get_OutOfMouseHole,& - ! Get_Unlatch,& - ! Get_Latch,& - ! Get_SlipsUnSet,& - ! Get_SlipsSet,& - ! Get_BreakupTong,& - ! Get_MakeupTong,& - ! Get_NewHookHeight,& - ! Get_ElevatorConnectionPossible,& - ! Get_JointConnectionPossible,& - ! Get_NearMonkeyBoardPosition,& - ! Get_SingleSetInMouseHole,& - ! Get_SwingCenter - use CUnityOutputs, only: GetRotaryRpm - use UnitySignalVariables - ! use CBucketEnumVariables - ! use CElevatorEnumVariables - ! use CHeadEnumVariables - ! use CIbopEnumVariables - ! use CKellyEnumVariables - ! use CMouseHoleEnumVariables - ! use COperationConditionEnumVariables - ! use CSafetyValveEnumVariables - ! use CSlipsEnumVariables - ! use CSwingEnumVariables - ! use CTongEnumVariables - - use PermissionsVariables - ! use CFillupHeadPermissionVariables - ! use CSwingDrillPermissionVariables - ! use CSwingOffPermissionVariables - ! use CSwingTiltPermissionVariables - ! use CTdsStemJointHeight - use CTdsConnectionModesEnumVariables - use CTdsElevatorModesEnumVariables - ! use CTdsSpineEnumVariables - ! use CTdsSwingEnumVariables - ! use CTdsTongEnumVariables - ! use CTdsBackupClampVariables - - use CHoistingVariables - use CTopDrivePanelVariables - - ! use CTdsPowerLedNotificationVariables - ! use CTdsIbopLedNotificationVariables - use NotificationVariables - - ! use CTdsTorqueWrenchLedNotificationVariables - +module COperationScenariosVariables implicit none public type::OperationScenarioType @@ -102,76 +14,35 @@ module COperationScenariosVariables !moved from enum/CElevatorConnectionEnum integer :: ElevatorConnection = 0 - ! type(VoidEventHandlerCollection) :: OnElevatorConnectionChange !moved from SoftwareOutputs/CStringUpdateVariables integer :: StringUpdate = 0 - !**type(IntegerEventHandlerCollection) :: OnStringUpdateChange + + integer :: KellyConnection = 0 end type OperationScenarioType - type(OperationScenarioType)::OperationScenario - enum, bind(c) enumerator STRING_UPDATE_NEUTRAL enumerator STRING_UPDATE_ADD_SINGLE enumerator STRING_UPDATE_ADD_STAND enumerator STRING_UPDATE_REMOVE_SINGLE enumerator STRING_UPDATE_REMOVE_STAND - end enum - + enumerator KELLY_CONNECTION_NOTHING + enumerator KELLY_CONNECTION_STRING + enumerator KELLY_CONNECTION_SINGLE + + enumerator ELEVATOR_CONNECTION_NOTHING + enumerator ELEVATOR_CONNECTION_STRING + enumerator ELEVATOR_CONNECTION_STAND + enumerator ELEVATOR_CONNECTION_SINGLE + enumerator ELEVATOR_LATCH_STRING + enumerator ELEVATOR_LATCH_SINGLE + enumerator ELEVATOR_LATCH_STAND + end enum contains - subroutine Set_StringUpdate(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(OperationScenario%StringUpdate == v) return - #endif - OperationScenario%StringUpdate = v - !**call OperationScenario%OnStringUpdateChange%RunAll(v) - end subroutine - - integer function Get_StringUpdate() - implicit none - Get_StringUpdate = OperationScenario%StringUpdate - end function - real(8) function TJH() - use TD_DrillStemComponents - implicit none - TJH = TD_String%TopJointHeight - end function - - real function TL() - implicit none - TL = 26.97 - end function - - real function NFC() - implicit none - NFC = Get_NearFloorConnection() - end function - - - subroutine Set_ElevatorConnection(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(OperationScenario%ElevatorConnection == v) return - #endif - OperationScenario%ElevatorConnection = v - - #ifdef deb - print*, 'OperationScenario%ElevatorConnection=', OperationScenario%ElevatorConnection - #endif - !**call OperationScenario%OnElevatorConnectionChange%RunAll() - end subroutine - - integer function Get_ElevatorConnection() - implicit none - Get_ElevatorConnection = OperationScenario%ElevatorConnection - end function end module COperationScenariosVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Enums/CKellyConnectionEnum.f90 b/CSharp/OperationScenarios/Common/OperationScenarios.f90 similarity index 59% rename from CSharp/OperationScenarios/Enums/CKellyConnectionEnum.f90 rename to CSharp/OperationScenarios/Common/OperationScenarios.f90 index 605471a..6fb4e38 100644 --- a/CSharp/OperationScenarios/Enums/CKellyConnectionEnum.f90 +++ b/CSharp/OperationScenarios/Common/OperationScenarios.f90 @@ -1,46 +1,68 @@ -module CKellyConnectionEnum - use COperationScenariosVariables - use CLog4 - implicit none +module OperationScenariosModule + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! Paseted From ....Variables.f90 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! use OperationScenariosModule ! + ! use OperationScenariosModule !!CElevator... + ! use COperationScenariosVariables + use ConfigurationVariables + use PermissionsModule + use SoftwareInputsVariables + use CUnityInputs + use CUnityOutputs, only: GetRotaryRpm + use UnitySignalVariables + use UnitySignalsModule + use PermissionsModule + ! use CTdsElevatorModesEnumVariables ! + use CHoistingVariables + use ConfigurationVariables + use CTopDrivePanelVariables + use ConfigurationVariables + use NotificationModule + use UnitySignalsModule !for CTdsConnectionModesEnum!!!! + + ! use CTdsTorqueWrenchLedNotificationVariables ! contains - - subroutine Evaluate_KellyConnection() + ! moved from kellyConnectionEnum + subroutine Set_KellyConnection(v) + use CManifolds, Only: KellyConnected, KellyDisconnected implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%OperationScenario%KellyConnection == v) return + #endif + + data%State%OperationScenario%KellyConnection = v + if(data%State%OperationScenario%KellyConnection /= KELLY_CONNECTION_STRING) then + call KellyDisconnected() + else + call KellyConnected() + endif - - if (Hoisting%DriveType == TopDrive_DriveType) then + #ifdef deb + print*, 'data%State%OperationScenario%KellyConnection=', data%State%OperationScenario%KellyConnection + #endif + !**call data%State%OperationScenario%OnKellyConnectionChange%RunAll() + end subroutine + + integer function Get_KellyConnection() + implicit none + Get_KellyConnection = data%State%OperationScenario%KellyConnection + end function + + subroutine Evaluate_KellyConnection() + implicit none + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_KellyConnection=TopDrive' #endif endif - - - - - - - - - - - - - - - - - - - - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_KellyConnection=Kelly' #endif - - - !!OPERATION-CODE=4 !if (Get_OperationCondition() == OPERATION_DRILL .and.& ! Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.& @@ -71,7 +93,7 @@ module CKellyConnectionEnum !OPERATION-CODE=2 if (Get_OperationCondition() == OPERATION_DRILL .and.& Get_StringPressure() == 0 .and.& - Get_HookHeight() <= (OperationScenario%HKL + Get_NearFloorConnection()) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and.& Get_KellyConnection() == KELLY_CONNECTION_STRING .and.& Get_Swing() == SWING_WELL_END .and.& !Get_TongNotification() .and.& @@ -142,16 +164,14 @@ module CKellyConnectionEnum return end if - endif - - - - + endif end subroutine ! subroutine Subscribe_KellyConnection() ! use CDrillingConsoleVariables + ! use ConfigurationVariables + ! use ConfigurationVariables ! implicit none ! call OnBreakoutLeverPress%Add(ButtonPress_Breakout) @@ -171,5 +191,57 @@ module CKellyConnectionEnum print*, 'ButtonPress_Makeup on ======> CKellyConnectionEnum' #endif end subroutine + + + subroutine Set_StringUpdate(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%OperationScenario%StringUpdate == v) return + #endif + data%State%OperationScenario%StringUpdate = v + !**call data%State%OperationScenario%OnStringUpdateChange%RunAll(v) + end subroutine + + integer function Get_StringUpdate() + implicit none + Get_StringUpdate = data%State%OperationScenario%StringUpdate + end function + + real(8) function TJH() + use TD_DrillStemComponents + implicit none + TJH = data%State%TD_String%TopJointHeight + end function + + real function TL() + implicit none + TL = 26.97 + end function + + real function NFC() + implicit none + NFC = Get_NearFloorConnection() + end function -end module CKellyConnectionEnum \ No newline at end of file + + subroutine Set_ElevatorConnection(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%OperationScenario%ElevatorConnection == v) return + #endif + data%State%OperationScenario%ElevatorConnection = v + + #ifdef deb + print*, 'data%State%OperationScenario%ElevatorConnection=', data%State%OperationScenario%ElevatorConnection + #endif + !**call data%State%OperationScenario%OnElevatorConnectionChange%RunAll() + end subroutine + + integer function Get_ElevatorConnection() + implicit none + Get_ElevatorConnection = data%State%OperationScenario%ElevatorConnection + end function + +end module OperationScenariosModule \ No newline at end of file diff --git a/CSharp/OperationScenarios/Enums/CElevatorConnectionEnum.f90 b/CSharp/OperationScenarios/Enums/CElevatorConnectionEnum.f90 index 8549c43..db7485f 100644 --- a/CSharp/OperationScenarios/Enums/CElevatorConnectionEnum.f90 +++ b/CSharp/OperationScenarios/Enums/CElevatorConnectionEnum.f90 @@ -1,5 +1,5 @@ module CElevatorConnectionEnum - use COperationScenariosVariables + use OperationScenariosModule use CLog3 use CLog4 implicit none @@ -7,11 +7,12 @@ module CElevatorConnectionEnum subroutine Evaluate_ElevatorConnection() use CHoistingVariables + use ConfigurationVariables use CCommon, only: SetStandRack implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_ElevatorConnection=TopDrive' #endif @@ -25,7 +26,7 @@ module CElevatorConnectionEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ElevatorConnection=Kelly' #endif @@ -54,7 +55,7 @@ module CElevatorConnectionEnum !OPERATION-CODE=78 if (Get_ElevatorPickup() == .false. .and.& Get_Tong() == TONG_BREAKOUT_END .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and.& Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) then call Set_ElevatorConnection(ELEVATOR_LATCH_SINGLE) return @@ -63,7 +64,7 @@ module CElevatorConnectionEnum !OPERATION-CODE=79 if (Get_ElevatorPickup() == .false. .and.& Get_Tong() == TONG_BREAKOUT_END .and.& - Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%SL - OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%SL - data%State%OperationScenario%LG) .and.& Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) then call Set_ElevatorConnection(ELEVATOR_LATCH_STAND) return @@ -229,7 +230,7 @@ module CElevatorConnectionEnum !OPERATION-CODE=13 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and.& !Get_Swing() == SWING_WELL_END .and.& !Get_TongNotification() .and.& @@ -245,7 +246,7 @@ module CElevatorConnectionEnum !OPERATION-CODE=14 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.& !Get_Swing() == SWING_WELL_END .and.& !Get_TongNotification() .and.& @@ -261,7 +262,7 @@ module CElevatorConnectionEnum !OPERATION-CODE=15 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%SL - OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%SL - data%State%OperationScenario%LG) .and.& !Get_HookHeight() >= (HL + Get_NearFloorConnection() + SL - RE) .and. Get_HookHeight() <= (HL + Get_NearFloorConnection() + SL + LG) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and.& !Get_Swing() == SWING_WELL_END .and.& @@ -322,6 +323,8 @@ module CElevatorConnectionEnum ! subroutine Subscribe_ElevatorConnection() ! use CDrillingConsoleVariables + ! use ConfigurationVariables + ! use ConfigurationVariables ! implicit none ! call OnLatchPipePress%Add(ButtonPress_Latch_ElevatorConnection) ! call OnUnlatchPipePress%Add(ButtonPress_Unlatch_ElevatorConnection) @@ -339,7 +342,7 @@ module CElevatorConnectionEnum - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Latch_ElevatorConnection=TopDrive' #endif @@ -348,7 +351,7 @@ module CElevatorConnectionEnum !TOPDRIVE-CODE=73 - if ((Get_HookHeight() >= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC() + OperationScenario%TG)) .and.& + if ((Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() + data%State%OperationScenario%TG)) .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& Get_LatchLed()) then @@ -365,7 +368,7 @@ module CElevatorConnectionEnum !TOPDRIVE-CODE=74 - if (Get_HookHeight() <= (TL() + NFC() - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() - data%State%OperationScenario%ECG) .and.& GetRotaryRpm() == 0.0d0 .and.& Get_ElevatorConnectionPossible() .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.& @@ -411,20 +414,20 @@ module CElevatorConnectionEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Latch_ElevatorConnection=Kelly' #endif !OPERATION-CODE=86 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() - OperationScenario%ECG) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() - data%State%OperationScenario%ECG) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.& Get_LatchLed() .and.& GetRotaryRpm() == 0.0d0 .and.& Get_Swing() == SWING_WELL_END .and.& Get_ElevatorConnectionPossible() .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection())) then + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection())) then !call Log_4("OPERATION-CODE=ELEVATOR_LATCH_STRING_BEGIN") call Set_Elevator(ELEVATOR_LATCH_STRING_BEGIN) @@ -434,7 +437,7 @@ module CElevatorConnectionEnum !OPERATION-CODE=85 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection() + OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.& Get_LatchLed() .and.& Get_Swing() == SWING_WELL_END) then @@ -482,7 +485,7 @@ module CElevatorConnectionEnum - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Unlatch_ElevatorConnection=TopDrive' #endif @@ -490,7 +493,7 @@ module CElevatorConnectionEnum !TOPDRIVE-CODE=76 - if ((Get_HookHeight() >= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC() + OperationScenario%TG)) .and.& + if ((Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() + data%State%OperationScenario%TG)) .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& Get_UnlatchLed()) then @@ -508,7 +511,7 @@ module CElevatorConnectionEnum !TOPDRIVE-CODE=77 - if (Get_HookHeight() <= (TL() + NFC() - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() - data%State%OperationScenario%ECG) .and.& GetRotaryRpm() == 0.0d0 .and.& Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.& (Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING) .and.& @@ -527,7 +530,7 @@ module CElevatorConnectionEnum !TOPDRIVE-CODE=78 - if ((Get_HookHeight() > TL() .and. Get_HookHeight() < (TL() + NFC() + OperationScenario%SG)) .and.& + if ((Get_HookHeight() > TL() .and. Get_HookHeight() < (TL() + NFC() + data%State%OperationScenario%SG)) .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE .and.& Get_TdsSwing() == TDS_SWING_TILT_END .and.& Get_UnlatchLed() .and.& @@ -550,15 +553,15 @@ module CElevatorConnectionEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Unlatch_ElevatorConnection=Kelly' #endif !OPERATION-CODE=89 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() - OperationScenario%ECG) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() - data%State%OperationScenario%ECG) .and.& (Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .or. Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection()) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection()) .and.& Get_UnlatchLed() .and.& GetRotaryRpm() == 0.0d0 .and.& Get_Swing() == SWING_WELL_END .and.& @@ -572,7 +575,7 @@ module CElevatorConnectionEnum !OPERATION-CODE=88 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection() + OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.& !Get_HookHeight() >= (HL + Get_NearFloorConnection() + SL + RE) .and. Get_HookHeight() <= (HL + Get_NearFloorConnection() + SL + LG) Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND .and.& Get_UnlatchLed() .and.& @@ -587,7 +590,7 @@ module CElevatorConnectionEnum if (Get_OperationCondition() == OPERATION_TRIP .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.& Get_UnlatchLed() .and.& - Get_HookHeight() >= OperationScenario%HL .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%SG) .and.& + Get_HookHeight() >= data%State%OperationScenario%HL .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%SG) .and.& !Get_JointConnectionPossible() .and.& Get_Swing() == SWING_MOUSE_HOLE_END) then diff --git a/CSharp/OperationScenarios/Enums/CElevatorConnectionEnumVariables.f90 b/CSharp/OperationScenarios/Enums/CElevatorConnectionEnumVariables.f90 deleted file mode 100644 index 5fbc451..0000000 --- a/CSharp/OperationScenarios/Enums/CElevatorConnectionEnumVariables.f90 +++ /dev/null @@ -1,47 +0,0 @@ -module CElevatorConnectionEnumVariables - ! use CVoidEventHandlerCollection - implicit none - ! Mahmood: this variable moved to operationscenariocommon - ! integer :: OperationScenario%ElevatorConnection = 0 - ! ! type(VoidEventHandlerCollection) :: OnElevatorConnectionChange - - public - - - enum, bind(c) - enumerator ELEVATOR_CONNECTION_NOTHING - enumerator ELEVATOR_CONNECTION_STRING - enumerator ELEVATOR_CONNECTION_STAND - enumerator ELEVATOR_CONNECTION_SINGLE - enumerator ELEVATOR_LATCH_STRING - enumerator ELEVATOR_LATCH_SINGLE - enumerator ELEVATOR_LATCH_STAND - end enum - - ! private :: OperationScenario%ElevatorConnection - contains - - - - - - - - - ! subroutine Set_ElevatorConnection_WN(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: Set_ElevatorConnection_WN - ! !DEC$ ATTRIBUTES ALIAS: 'Set_ElevatorConnection_WN' :: Set_ElevatorConnection_WN - ! implicit none - ! integer , intent(in) :: v - ! call Set_ElevatorConnection(v) - ! end subroutine - - ! integer function Get_ElevatorConnection_WN() - ! !DEC$ ATTRIBUTES DLLEXPORT :: Get_ElevatorConnection_WN - ! !DEC$ ATTRIBUTES ALIAS: 'Get_ElevatorConnection_WN' :: Get_ElevatorConnection_WN - ! implicit none - ! Get_ElevatorConnection_WN = OperationScenario%ElevatorConnection - ! end function - - -end module CElevatorConnectionEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Enums/CKellyConnectionEnumVariables.f90 b/CSharp/OperationScenarios/Enums/CKellyConnectionEnumVariables.f90 deleted file mode 100644 index 0ce9cd6..0000000 --- a/CSharp/OperationScenarios/Enums/CKellyConnectionEnumVariables.f90 +++ /dev/null @@ -1,68 +0,0 @@ -module CKellyConnectionEnumVariables - ! use CVoidEventHandlerCollection - implicit none - type::KellyConnectionEnumType - integer :: KellyConnection = 0 - ! type(VoidEventHandlerCollection) :: OnKellyConnectionChange - end type KellyConnectionEnumType - type(KellyConnectionEnumType)::KellyConnectionEnum - ! public - - - enum, bind(c) - enumerator KELLY_CONNECTION_NOTHING - enumerator KELLY_CONNECTION_STRING - enumerator KELLY_CONNECTION_SINGLE - end enum - - ! private :: OperationScenario%KellyConnection - contains - - subroutine Set_KellyConnection(v) - use CManifolds, Only: KellyConnected, KellyDisconnected - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(KellyConnectionEnum%KellyConnection == v) return - #endif - - KellyConnectionEnum%KellyConnection = v - - if(KellyConnectionEnum%KellyConnection /= KELLY_CONNECTION_STRING) then - call KellyDisconnected() - else - call KellyConnected() - endif - - #ifdef deb - print*, 'KellyConnectionEnum%KellyConnection=', KellyConnectionEnum%KellyConnection - #endif - !**call KellyConnectionEnum%OnKellyConnectionChange%RunAll() - end subroutine - - integer function Get_KellyConnection() - implicit none - Get_KellyConnection = KellyConnectionEnum%KellyConnection - end function - - - - - - - ! subroutine Set_KellyConnection_WN(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: Set_KellyConnection_WN - ! !DEC$ ATTRIBUTES ALIAS: 'Set_KellyConnection_WN' :: Set_KellyConnection_WN - ! implicit none - ! integer , intent(in) :: v - ! call Set_KellyConnection(v) - ! end subroutine - - ! integer function Get_KellyConnection_WN() - ! !DEC$ ATTRIBUTES DLLEXPORT :: Get_KellyConnection_WN - ! !DEC$ ATTRIBUTES ALIAS: 'Get_KellyConnection_WN' :: Get_KellyConnection_WN - ! implicit none - ! Get_KellyConnection_WN = OperationScenario%KellyConnection - ! end function - -end module CKellyConnectionEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Enums/CTdsConnectionModesEnum.f90 b/CSharp/OperationScenarios/Enums/CTdsConnectionModesEnum.f90 deleted file mode 100644 index 59a877e..0000000 --- a/CSharp/OperationScenarios/Enums/CTdsConnectionModesEnum.f90 +++ /dev/null @@ -1,81 +0,0 @@ -module CTdsConnectionModesEnum - use COperationScenariosVariables - implicit none - contains - - subroutine Evaluate_TdsConnectionModes() - implicit none - - - - if (Hoisting%DriveType == TopDrive_DriveType) then -#ifdef OST - print*, 'Evaluate_TdsConnectionModes=TopDrive' -#endif - - !TOPDRIVE-CODE=3 - if (Get_TdsStemIn() .and.& - Get_TdsSpine() == TDS_SPINE_CONNECT_END .and.& - !TopDriveDrillTorqueState == TdsMu_SPINE - Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then - - call Set_TdsConnectionModes(TDS_CONNECTION_SPINE) - return - end if - - - !TOPDRIVE-CODE=4 - if (Get_TdsTong() == TDS_TONG_MAKEUP_END .and.& - Get_TdsConnectionModes() == TDS_CONNECTION_SPINE ) then - - call Set_TdsConnectionModes(TDS_CONNECTION_STRING) - TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF - return - end if - - - !TOPDRIVE-CODE=5 - if (Get_TdsTong() == TDS_TONG_BREAKOUT_END .and.& - Get_TdsConnectionModes() == TDS_CONNECTION_STRING ) then - - call Set_TdsConnectionModes(TDS_CONNECTION_SPINE) - TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF - return - end if - - - - !TOPDRIVE-CODE=6 - if (Get_TdsSpine() == TDS_SPINE_DISCONNECT_END .and.& - !Get_TdsStemIn() == .false. .and.& - Get_TdsConnectionModes() == TDS_CONNECTION_SPINE) then - - call Set_TdsConnectionModes(TDS_CONNECTION_NOTHING) - return - end if - - - endif - - - - - if (Hoisting%DriveType == Kelly_DriveType) then -#ifdef OST - print*, 'Evaluate_TdsConnectionModes=Kelly' -#endif - endif - - - - - - - end subroutine - - subroutine Subscribe_TdsConnectionModes() - use CDrillingConsoleVariables - implicit none - end subroutine - -end module CTdsConnectionModesEnum \ No newline at end of file diff --git a/CSharp/OperationScenarios/Enums/CTdsConnectionModesEnumVariables.f90 b/CSharp/OperationScenarios/Enums/CTdsConnectionModesEnumVariables.f90 deleted file mode 100644 index 14af54d..0000000 --- a/CSharp/OperationScenarios/Enums/CTdsConnectionModesEnumVariables.f90 +++ /dev/null @@ -1,67 +0,0 @@ -module CTdsConnectionModesEnumVariables - ! use CVoidEventHandlerCollection - implicit none - type:: TdsConnectionModesEnumType - integer :: TdsConnectionModes = 0 - ! type(VoidEventHandlerCollection) :: OnTdsConnectionModesChange - end type TdsConnectionModesEnumType - type(TdsConnectionModesEnumType)::TdsConnectionModesEnum - enum, bind(c) - enumerator TDS_CONNECTION_NOTHING - enumerator TDS_CONNECTION_STRING - enumerator TDS_CONNECTION_SPINE - end enum - - ! private :: TdsConnectionModesEnum%TdsConnectionModes - contains - - subroutine Set_TdsConnectionModes(v) - use CManifolds, Only: KellyConnected, KellyDisconnected - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(TdsConnectionModesEnum%TdsConnectionModes == v) return -#endif - TdsConnectionModesEnum%TdsConnectionModes = v - - if(TdsConnectionModesEnum%TdsConnectionModes == TDS_CONNECTION_NOTHING) then - call KellyDisconnected() - else - call KellyConnected() - endif - -#ifdef deb - print*, 'TdsConnectionModesEnum%TdsConnectionModes=', TdsConnectionModesEnum%TdsConnectionModes -#endif - !**call TdsConnectionModesEnum%OnTdsConnectionModesChange%RunAll() - end subroutine - - integer function Get_TdsConnectionModes() - implicit none - Get_TdsConnectionModes = TdsConnectionModesEnum%TdsConnectionModes - end function - - - - - subroutine Set_TdsConnectionModes_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsConnectionModes_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_TdsConnectionModes_WN' :: Set_TdsConnectionModes_WN - implicit none - integer , intent(in) :: v - call Set_TdsConnectionModes(v) - end subroutine - - - integer function Get_TdsConnectionModes_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsConnectionModes_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_TdsConnectionModes_WN' :: Get_TdsConnectionModes_WN - implicit none - Get_TdsConnectionModes_WN = TdsConnectionModesEnum%TdsConnectionModes - end function - - - - - -end module CTdsConnectionModesEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.f90 b/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.f90 index f157756..1f66cc6 100644 --- a/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.f90 +++ b/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.f90 @@ -1,5 +1,5 @@ module CTdsElevatorModesEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -7,7 +7,7 @@ module CTdsElevatorModesEnum use CCommon, only: SetStandRack implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_TdsElevatorModes=TopDrive' #endif @@ -26,7 +26,7 @@ module CTdsElevatorModesEnum !TOPDRIVE-CODE=8 - if (Get_HookHeight() <= (TL() + TJH() - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + TJH() - data%State%OperationScenario%ECG) .and.& Get_ElevatorPickup() == .false. .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING) then @@ -132,7 +132,7 @@ module CTdsElevatorModesEnum !TOPDRIVE-CODE=16 - if (Get_HookHeight() <= (TL() + NFC() + OperationScenario%PL - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.& Get_Tong() == TONG_BREAKOUT_END .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then @@ -147,7 +147,7 @@ module CTdsElevatorModesEnum !TOPDRIVE-CODE=17 - if (Get_HookHeight() <= (TL() + NFC() + OperationScenario%PL - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.& Get_Tong() == TONG_BREAKOUT_END .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then @@ -172,7 +172,7 @@ module CTdsElevatorModesEnum !TOPDRIVE-CODE=19 - if (Get_HookHeight() <= (TL() + NFC() + OperationScenario%PL - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.& Get_ElevatorPickup() == .false. .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE) then @@ -212,7 +212,7 @@ module CTdsElevatorModesEnum !TOPDRIVE-CODE=22 - if (Get_HookHeight() <= (TL() + NFC() + OperationScenario%SL - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG) .and.& Get_Tong() == TONG_BREAKOUT_END .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then @@ -226,7 +226,7 @@ module CTdsElevatorModesEnum !TOPDRIVE-CODE=23 - if (Get_HookHeight() <= (TL() + NFC() + OperationScenario%SL - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG) .and.& Get_Tong() == TONG_BREAKOUT_END .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then @@ -252,7 +252,7 @@ module CTdsElevatorModesEnum !TOPDRIVE-CODE=25 - if (Get_HookHeight() <= (TL() + NFC() + OperationScenario%SL - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG) .and.& Get_ElevatorPickup() == .false. .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND) then @@ -311,7 +311,7 @@ module CTdsElevatorModesEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_TdsElevatorModes=Kelly' #endif @@ -324,6 +324,8 @@ module CTdsElevatorModesEnum subroutine Subscribe_TdsElevatorModes() use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables implicit none end subroutine diff --git a/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnumVariables.f90 b/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnumVariables.f90 deleted file mode 100644 index 9064fea..0000000 --- a/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnumVariables.f90 +++ /dev/null @@ -1,61 +0,0 @@ -module CTdsElevatorModesEnumVariables - ! use CVoidEventHandlerCollection - implicit none - type:: TdsElevatorModesEnumType - integer :: TdsElevatorModes = 0 - ! type(VoidEventHandlerCollection) :: OnTdsElevatorModesChange - end type TdsElevatorModesEnumType - type(TdsElevatorModesEnumType)::TdsElevatorModesEnum - enum, bind(c) - enumerator TDS_ELEVATOR_CONNECTION_NOTHING - enumerator TDS_ELEVATOR_CONNECTION_STRING - enumerator TDS_ELEVATOR_CONNECTION_SINGLE - enumerator TDS_ELEVATOR_CONNECTION_STAND - enumerator TDS_ELEVATOR_LATCH_STRING - enumerator TDS_ELEVATOR_LATCH_SINGLE - enumerator TDS_ELEVATOR_LATCH_STAND - end enum - - ! private :: TdsElevatorModesEnum%TdsElevatorModes - contains - - subroutine Set_TdsElevatorModes(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(TdsElevatorModesEnum%TdsElevatorModes == v) return -#endif - TdsElevatorModesEnum%TdsElevatorModes = v - !**call TdsElevatorModesEnum%OnTdsElevatorModesChange%RunAll() - end subroutine - - integer function Get_TdsElevatorModes() - implicit none - Get_TdsElevatorModes = TdsElevatorModesEnum%TdsElevatorModes - end function - - - - - - - subroutine Set_TdsElevatorModes_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsElevatorModes_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_TdsElevatorModes_WN' :: Set_TdsElevatorModes_WN - implicit none - integer , intent(in) :: v - call Set_TdsElevatorModes(v) - end subroutine - - integer function Get_TdsElevatorModes_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsElevatorModes_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_TdsElevatorModes_WN' :: Get_TdsElevatorModes_WN - implicit none - Get_TdsElevatorModes_WN = TdsElevatorModesEnum%TdsElevatorModes - end function - - - - - -end module CTdsElevatorModesEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Notifications/CCloseKellyCockLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CCloseKellyCockLedNotification.f90 index ecc5d5e..d7f0b73 100644 --- a/CSharp/OperationScenarios/Notifications/CCloseKellyCockLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CCloseKellyCockLedNotification.f90 @@ -1,5 +1,5 @@ module CCloseKellyCockLedNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -33,6 +33,8 @@ module CCloseKellyCockLedNotification ! subroutine Subscribe_CloseKellyCockLed() ! use CDrillingConsoleVariables + ! use ConfigurationVariables + ! use ConfigurationVariables ! implicit none ! call OnCloseKellyCockPress%Add(ButtonPress_CloseKellyCock) ! end subroutine @@ -41,13 +43,13 @@ module CCloseKellyCockLedNotification implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_CloseKellyCockLed=TopDrive' #endif endif - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_CloseKellyCockLed=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/CCloseSafetyValveLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CCloseSafetyValveLedNotification.f90 index 8055d5e..d4e4db1 100644 --- a/CSharp/OperationScenarios/Notifications/CCloseSafetyValveLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CCloseSafetyValveLedNotification.f90 @@ -1,5 +1,5 @@ module CCloseSafetyValveLedNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -32,6 +32,8 @@ module CCloseSafetyValveLedNotification ! subroutine Subscribe_CloseSafetyValveLed() ! use CDrillingConsoleVariables +!@ use ConfigurationVariables +!@ use ConfigurationVariables ! implicit none ! call OnCloseSafetyValvePress%Add(ButtonPress_CloseSafetyValve) ! call OnOperationConditionChangeInt%Add(Set_Operation_CloseSafetyValveLed) @@ -41,11 +43,11 @@ module CCloseSafetyValveLedNotification implicit none integer , intent(in) :: v #ifdef ExcludeExtraChanges - if(Notifications%operation_CloseSafetyValveLed == v) return + if(data%State%notifications%operation_CloseSafetyValveLed == v) return #endif - Notifications%operation_CloseSafetyValveLed = v + data%State%notifications%operation_CloseSafetyValveLed = v #ifdef deb - print*, 'operation_CloseSafetyValveLed=', Notifications%operation_CloseSafetyValveLed + print*, 'operation_CloseSafetyValveLed=', data%State%notifications%operation_CloseSafetyValveLed #endif end subroutine @@ -55,7 +57,7 @@ module CCloseSafetyValveLedNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_CloseSafetyValveLed=TopDrive' #endif @@ -82,7 +84,7 @@ module CCloseSafetyValveLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_CloseSafetyValveLed=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/CFillMouseHoleLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CFillMouseHoleLedNotification.f90 index ce2e3c4..8ca2565 100644 --- a/CSharp/OperationScenarios/Notifications/CFillMouseHoleLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CFillMouseHoleLedNotification.f90 @@ -1,53 +1,20 @@ module CFillMouseHoleLedNotification - use COperationScenariosVariables + use OperationScenariosModule + use NotificationModule implicit none contains subroutine Evaluate_FillMouseHoleLed() - implicit none - - -! if (DriveType == TopDrive_DriveType) then -!#ifdef OST -! print*, 'Evaluate_FillMouseHoleLed=TopDrive' -!#endif -! endif -! -! -! -! -! -! -! -! -! if (DriveType == Kelly_DriveType) then -!#ifdef OST -! print*, 'Evaluate_FillMouseHoleLed=Kelly' -!#endif -! endif - - + implicit none end subroutine - - ! subroutine Subscribe_FillMouseHoleLed() - ! use CDrillingConsoleVariables - ! implicit none - ! call OnFillMouseHolePress%Add(ButtonPress_FillMouseHole) - ! end subroutine - + subroutine ButtonPress_FillMouseHole() + ! use OperationScenariosModule + use UnitySignalsModule implicit none - - - if (Hoisting%DriveType == TopDrive_DriveType) then -#ifdef OST - print*, 'Evaluate_FillMouseHoleLed=TopDrive' -#endif - - - + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then !TOPDRIVE-CODE=71 if (Get_FillMouseHoleLed()) then @@ -66,23 +33,9 @@ module CFillMouseHoleLedNotification return end if - - - - - endif - - - - - - + endif - - if (Hoisting%DriveType == Kelly_DriveType) then -#ifdef OST - print*, 'Evaluate_FillMouseHoleLed=Kelly' -#endif + if (data%State%Hoisting%DriveType == Kelly_DriveType) then !OPERATION-CODE=81 @@ -99,16 +52,10 @@ module CFillMouseHoleLedNotification call Set_FillMouseHoleLed(.true.) call Set_MouseHole(MOUSE_HOLE_FILL) return - end if - + end if endif - - - - - end subroutine end module CFillMouseHoleLedNotification \ No newline at end of file diff --git a/CSharp/OperationScenarios/Notifications/CIrIBopLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CIrIBopLedNotification.f90 index dde447b..5cbf4c9 100644 --- a/CSharp/OperationScenarios/Notifications/CIrIBopLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CIrIBopLedNotification.f90 @@ -1,6 +1,7 @@ module CIrIBopLedNotification - use COperationScenariosVariables + use OperationScenariosModule ! use CTopDrivePanelVariables + use ConfigurationVariables implicit none contains @@ -35,6 +36,8 @@ module CIrIBopLedNotification ! subroutine Subscribe_IrIBopLed() ! use CDrillingConsoleVariables +!@ use ConfigurationVariables +!@ use ConfigurationVariables ! implicit none ! call OnIRIBopPress%Add(ButtonPress_IrIBop) ! end subroutine @@ -46,7 +49,7 @@ module CIrIBopLedNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_IrIBopLed=TopDrive' #endif @@ -67,7 +70,7 @@ module CIrIBopLedNotification !TOPDRIVE-CODE=60 if (Get_IrIbopPermission() .and.& Get_IrIBopLed() == .true. .and.& - TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF) then call Set_IrIBopLed(.false.) return @@ -84,7 +87,7 @@ module CIrIBopLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_IrIBopLed=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/CIrSafetyValveLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CIrSafetyValveLedNotification.f90 index 9e713a8..207e153 100644 --- a/CSharp/OperationScenarios/Notifications/CIrSafetyValveLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CIrSafetyValveLedNotification.f90 @@ -1,6 +1,6 @@ module CIrSafetyValveLedNotification - use COperationScenariosVariables - !use COperationConditionEnumVariables + use OperationScenariosModule + !use UnitySignalsModuleVariables implicit none contains @@ -11,7 +11,7 @@ module CIrSafetyValveLedNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_IrSafetyValveLed=TopDrive' #endif @@ -31,7 +31,7 @@ module CIrSafetyValveLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_IrSafetyValveLed=Kelly' #endif @@ -64,6 +64,8 @@ module CIrSafetyValveLedNotification ! subroutine Subscribe_IrSafetyValveLed() ! use CDrillingConsoleVariables +!@ use ConfigurationVariables +!@ use ConfigurationVariables ! implicit none ! call OnIRSafetyValvePress%Add(ButtonPress_IrSafetyValve) ! call OnOperationConditionChangeInt%Add(Set_Operation_IrSafetyValveLed) @@ -73,11 +75,11 @@ module CIrSafetyValveLedNotification implicit none integer , intent(in) :: v #ifdef ExcludeExtraChanges - if(Notifications%operation_IrSafetyValveLed == v) return + if(data%State%notifications%operation_IrSafetyValveLed == v) return #endif - Notifications%operation_IrSafetyValveLed = v + data%State%notifications%operation_IrSafetyValveLed = v #ifdef deb - print*, 'operation_IrSafetyValveLed=', Notifications%operation_IrSafetyValveLed + print*, 'operation_IrSafetyValveLed=', data%State%notifications%operation_IrSafetyValveLed #endif end subroutine @@ -87,7 +89,7 @@ module CIrSafetyValveLedNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_IrSafetyValveLed=TopDrive' #endif @@ -126,7 +128,7 @@ module CIrSafetyValveLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_IrSafetyValveLed=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/CLatchLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CLatchLedNotification.f90 index fd26e0a..7413642 100644 --- a/CSharp/OperationScenarios/Notifications/CLatchLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CLatchLedNotification.f90 @@ -1,5 +1,5 @@ module CLatchLedNotification - use COperationScenariosVariables + use OperationScenariosModule use CLog4 implicit none contains @@ -11,14 +11,14 @@ module CLatchLedNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_LatchLed=TopDrive' #endif !TOPDRIVE-CODE=44 - if (Get_HookHeight() <= (TL() + NFC() - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() - data%State%OperationScenario%ECG) .and.& Get_ElevatorConnectionPossible() .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& @@ -41,7 +41,7 @@ module CLatchLedNotification !TOPDRIVE-CODE=45 - if ((Get_HookHeight() >= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC() + OperationScenario%TG)) .and.& + if ((Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() + data%State%OperationScenario%TG)) .and.& GetStandRack() > 0 .and.& Get_JointConnectionPossible() == .false. .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& @@ -64,7 +64,7 @@ module CLatchLedNotification !TOPDRIVE-CODE=46 - if ((Get_HookHeight() >= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC() + OperationScenario%TG)) .and.& + if ((Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() + data%State%OperationScenario%TG)) .and.& Get_ElevatorConnectionPossible() .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& @@ -106,14 +106,14 @@ module CLatchLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_LatchLed=Kelly' #endif !OPERATION-CODE=36 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() - OperationScenario%ECG) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() - data%State%OperationScenario%ECG) .and.& Get_ElevatorConnectionPossible() .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& @@ -137,7 +137,7 @@ module CLatchLedNotification !OPERATION-CODE=37 if (Get_OperationCondition() == OPERATION_TRIP .and.& Get_StandRack() > 0 .and.& - Get_HookHeight() >= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection() + OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& @@ -228,7 +228,7 @@ module CLatchLedNotification end subroutine ! subroutine Subscribe_LatchLed() - ! use COperationConditionEnumVariables + ! use UnitySignalsModuleVariables ! use CStandRack ! use CUnityInputs, OnElevatorConnectionChangePosibility => OnElevatorConnectionPossibleChange ! use CSwingEnumVariables diff --git a/CSharp/OperationScenarios/Notifications/COpenKellyCockLedNotification.f90 b/CSharp/OperationScenarios/Notifications/COpenKellyCockLedNotification.f90 index cd4e900..4f507fd 100644 --- a/CSharp/OperationScenarios/Notifications/COpenKellyCockLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/COpenKellyCockLedNotification.f90 @@ -1,5 +1,5 @@ module COpenKellyCockLedNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -24,6 +24,8 @@ module COpenKellyCockLedNotification ! subroutine Subscribe_OpenKellyCockLed() ! use CDrillingConsoleVariables +!@ use ConfigurationVariables +!@ use ConfigurationVariables ! implicit none ! call OnOpenKellyCockPress%Add(ButtonPress_OpenKellyCock) ! end subroutine @@ -32,7 +34,7 @@ module COpenKellyCockLedNotification implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_OpenKellyCock=TopDrive' #endif @@ -41,7 +43,7 @@ module COpenKellyCockLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_OpenKellyCock=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/COpenSafetyValveLedNotification.f90 b/CSharp/OperationScenarios/Notifications/COpenSafetyValveLedNotification.f90 index 8d53d1f..bcb25bd 100644 --- a/CSharp/OperationScenarios/Notifications/COpenSafetyValveLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/COpenSafetyValveLedNotification.f90 @@ -1,5 +1,5 @@ module COpenSafetyValveLedNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -33,6 +33,8 @@ module COpenSafetyValveLedNotification ! subroutine Subscribe_OpenSafetyValveLed() ! use CDrillingConsoleVariables + ! use ConfigurationVariables + ! use ConfigurationVariables ! implicit none ! call OnOpenSafetyValvePress%Add(ButtonPress_OpenSafetyValve) ! call OnOperationConditionChangeInt%Add(Set_Operation_OpenSafetyValveLed) @@ -43,11 +45,11 @@ module COpenSafetyValveLedNotification implicit none integer , intent(in) :: v #ifdef ExcludeExtraChanges - if(notifications%operation_OpenSafetyValveLed == v) return + if(data%State%notifications%operation_OpenSafetyValveLed == v) return #endif - notifications%operation_OpenSafetyValveLed = v + data%State%notifications%operation_OpenSafetyValveLed = v #ifdef deb - print*, 'notifications%operation_OpenSafetyValveLed=', notifications%operation_OpenSafetyValveLed + print*, 'data%State%notifications%operation_OpenSafetyValveLed=', data%State%notifications%operation_OpenSafetyValveLed #endif end subroutine @@ -56,7 +58,7 @@ module COpenSafetyValveLedNotification implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_OpenSafetyValve=TopDrive' #endif @@ -80,7 +82,7 @@ module COpenSafetyValveLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_OpenSafetyValve=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/CSlipsNotification.f90 b/CSharp/OperationScenarios/Notifications/CSlipsNotification.f90 index 35e1ba8..c38b37c 100644 --- a/CSharp/OperationScenarios/Notifications/CSlipsNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CSlipsNotification.f90 @@ -1,5 +1,5 @@ module CSlipsNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -9,7 +9,7 @@ module CSlipsNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_SlipsNotification=TopDrive' #endif @@ -52,7 +52,7 @@ module CSlipsNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_SlipsNotification=Kelly' #endif @@ -125,7 +125,7 @@ module CSlipsNotification ! call OnSlackOffChange%Add(Evaluate_SlipsNotification) ! call OnZeroStringSpeedChange%Add(Evaluate_SlipsNotification) ! call OnNearFloorConnectionChange%Add(Evaluate_SlipsNotification) - ! call OperationScenario%OnElevatorConnectionChange%Add(Evaluate_SlipsNotification) + ! call data%State%OperationScenario%OnElevatorConnectionChange%Add(Evaluate_SlipsNotification) ! call OnKellyConnectionChange%Add(Evaluate_SlipsNotification) ! call OnSlipsChange%Add(Evaluate_SlipsNotification) diff --git a/CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90 index 5ce9465..b1b8def 100644 --- a/CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90 @@ -1,5 +1,5 @@ module CSwingLedNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -10,7 +10,7 @@ module CSwingLedNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_SwingLed=TopDrive' #endif @@ -27,7 +27,7 @@ module CSwingLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_SwingLed=Kelly' #endif @@ -35,7 +35,7 @@ module CSwingLedNotification !OPERATION-CODE=22 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.& Get_JointConnectionPossible() == .false. .and.& (Get_Swing() /= SWING_WELL_BEGIN .and.& @@ -50,7 +50,7 @@ module CSwingLedNotification !OPERATION-CODE=23 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL) .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%LG + OperationScenario%PL) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%LG + data%State%OperationScenario%PL) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.& Get_JointConnectionPossible() == .false. .and.& (Get_Swing() /= SWING_WELL_BEGIN .and.& @@ -65,7 +65,7 @@ module CSwingLedNotification !OPERATION-CODE=24 if (Get_OperationCondition() == OPERATION_DRILL .and.& - Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.& Get_JointConnectionPossible() == .false. .and.& Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.& (Get_Swing() /= SWING_WELL_BEGIN .and.& @@ -79,7 +79,7 @@ module CSwingLedNotification !OPERATION-CODE=25 if (Get_OperationCondition() == OPERATION_DRILL .and.& - Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%PL) .and. Get_HookHeight() <= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%LG + OperationScenario%PL) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%LG + data%State%OperationScenario%PL) .and.& Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.& Get_JointConnectionPossible() == .false. .and.& (Get_Swing() /= SWING_WELL_BEGIN .and.& diff --git a/CSharp/OperationScenarios/Notifications/CTdsIbopLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CTdsIbopLedNotification.f90 index 2629cd3..bac93e5 100644 --- a/CSharp/OperationScenarios/Notifications/CTdsIbopLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CTdsIbopLedNotification.f90 @@ -1,5 +1,5 @@ module CTdsIbopLedNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -8,7 +8,7 @@ module CTdsIbopLedNotification implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_IbopLed=TopDrive' #endif @@ -18,11 +18,11 @@ module CTdsIbopLedNotification !TOPDRIVE-CODE=61 if (Get_IbopLed() == .false. .and.& - TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF .and.& - TopDrivePanel%TopDriveIbop == .false.) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF .and.& + data%EquipmentControl%TopDrivePanel%TopDriveIbop == .false.) then call Set_IbopLed(.true.) - TopDrivePanel%TopDriveLinkTiltLed = LED_OFF + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_OFF return end if @@ -31,11 +31,11 @@ module CTdsIbopLedNotification !TOPDRIVE-CODE=62 if (Get_IbopLed() .and.& - TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF .and.& - TopDrivePanel%TopDriveIbop) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF .and.& + data%EquipmentControl%TopDrivePanel%TopDriveIbop) then call Set_IbopLed(.false.) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if diff --git a/CSharp/OperationScenarios/Notifications/CTdsPowerLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CTdsPowerLedNotification.f90 index 3ba3377..cd3591c 100644 --- a/CSharp/OperationScenarios/Notifications/CTdsPowerLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CTdsPowerLedNotification.f90 @@ -1,5 +1,6 @@ module CTdsPowerLedNotification - use COperationScenariosVariables + use OperationScenariosModule + use ConfigurationVariables implicit none contains @@ -8,13 +9,13 @@ module CTdsPowerLedNotification implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_PowerLed=TopDrive' #endif !TOPDRIVE-CODE=63 - if (TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF) then + if (data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF) then call Set_PowerLed(.true.) return end if @@ -28,7 +29,7 @@ module CTdsPowerLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_PowerLed=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/CTdsTorqueWrenchLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CTdsTorqueWrenchLedNotification.f90 index b4da4d9..e04b9c7 100644 --- a/CSharp/OperationScenarios/Notifications/CTdsTorqueWrenchLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CTdsTorqueWrenchLedNotification.f90 @@ -1,12 +1,12 @@ module CTdsTorqueWrenchLedNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains subroutine Evaluate_TorqueWrenchLed() implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_TorqueWrenchLed=TopDrive' #endif @@ -14,14 +14,14 @@ module CTdsTorqueWrenchLedNotification !TOPDRIVE-CODE=81 if((Get_TdsBackupClamp() == BACKUP_CLAMP_OFF_BEGIN .or.& Get_TdsBackupClamp() == BACKUP_CLAMP_FW_BEGIN) .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then call Set_TorqueWrenchLed(LED_BLINK) return endif !TOPDRIVE-CODE=81 if(Get_TdsBackupClamp() == BACKUP_CLAMP_FW_END .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then call Set_TorqueWrenchLed(LED_ON) return endif @@ -39,7 +39,7 @@ module CTdsTorqueWrenchLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_SwingLed=Kelly' #endif diff --git a/CSharp/OperationScenarios/Notifications/CTongNotification.f90 b/CSharp/OperationScenarios/Notifications/CTongNotification.f90 index e32d23b..46f3445 100644 --- a/CSharp/OperationScenarios/Notifications/CTongNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CTongNotification.f90 @@ -1,5 +1,5 @@ module CTongNotification - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -10,7 +10,7 @@ module CTongNotification - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_TongNotification=TopDrive' #endif @@ -19,8 +19,8 @@ module CTongNotification !TOPDRIVE-CODE=50 - if (((Get_HookHeight() >= (TL() + OperationScenario%PL - OperationScenario%ECG + NFC() - OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + OperationScenario%PL - OperationScenario%ECG + OperationScenario%TG)) .or.& - (Get_HookHeight() >= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC() - OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + OperationScenario%SL - OperationScenario%ECG + OperationScenario%TG))).and.& + if (((Get_HookHeight() >= (TL() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + NFC() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + data%State%OperationScenario%TG)) .or.& + (Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + data%State%OperationScenario%TG))).and.& GetRotaryRpm() == 0.0d0 .and.& Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.& ((Get_Tong() /= TONG_BREAKOUT_BEGIN .and.& @@ -86,7 +86,7 @@ module CTongNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_TongNotification=Kelly' #endif @@ -95,8 +95,8 @@ module CTongNotification if (Get_OperationCondition() == OPERATION_DRILL .and.& !((Get_HookHeight() >= 65.0 .and. Get_HookHeight() <= 70.0) .or.& ! (Get_HookHeight() >= 96.0 .and. Get_HookHeight() <= 101.0)).and.& - ((Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection() - OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%TG)) .or.& - (Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%PL -OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%TG + OperationScenario%PL))).and.& + ((Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%TG)) .or.& + (Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%PL -data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%TG + data%State%OperationScenario%PL))).and.& GetRotaryRpm() == 0.0d0 .and.& Get_KellyConnection() == KELLY_CONNECTION_STRING .and.& Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.& @@ -189,8 +189,8 @@ module CTongNotification !OPERATION-CODE=50 if (Get_OperationCondition() == OPERATION_TRIP .and.& - ((Get_HookHeight() >= (OperationScenario%HL + OperationScenario%PL - OperationScenario%ECG + Get_NearFloorConnection() - OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL - OperationScenario%ECG + OperationScenario%TG)) .or.& - (Get_HookHeight() >= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection() - OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%TG - OperationScenario%ECG + OperationScenario%SL))).and.& + ((Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + Get_NearFloorConnection() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + data%State%OperationScenario%TG)) .or.& + (Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%TG - data%State%OperationScenario%ECG + data%State%OperationScenario%SL))).and.& Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.& GetRotaryRpm() == 0.0d0 .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and.& @@ -271,14 +271,14 @@ module CTongNotification ! subroutine Subscribe_TongNotification() ! implicit none - ! call UnitySignals%OnOperationConditionChange%Add(Evaluate_TongNotification) + ! call data%State%unitySignals%OnOperationConditionChange%Add(Evaluate_TongNotification) ! ! call softwareInputs%OnHookHeightChange%Add(Evaluate_TongNotification) ! call UnityInputs%OnJointConnectionPossibleChange%Add(Evaluate_TongNotification) ! call UnityInputs%OnSingleSetInMouseHoleChange%Add(Evaluate_TongNotification) - ! call OperationScenario%OnElevatorConnectionChange%Add(Evaluate_TongNotification) + ! call data%State%OperationScenario%OnElevatorConnectionChange%Add(Evaluate_TongNotification) ! call KellyConnectionEnum%OnKellyConnectionChange%Add(Evaluate_TongNotification) - ! call UnitySignals%OnSwingChange%Add(Evaluate_TongNotification) - ! call UnitySignals%OnSlipsChange%Add(Evaluate_TongNotification) + ! call data%State%unitySignals%OnSwingChange%Add(Evaluate_TongNotification) + ! call data%State%unitySignals%OnSlipsChange%Add(Evaluate_TongNotification) ! end subroutine diff --git a/CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.f90 b/CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.f90 index 7862fd1..03e12ba 100644 --- a/CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.f90 +++ b/CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.f90 @@ -1,5 +1,5 @@ module CUnlatchLedNotification - use COperationScenariosVariables + use OperationScenariosModule use CLog4 implicit none contains @@ -9,7 +9,7 @@ module CUnlatchLedNotification implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_UnlatchLed=TopDrive' #endif @@ -17,7 +17,7 @@ module CUnlatchLedNotification !TOPDRIVE-CODE=47 - if (Get_HookHeight() <= (TL() + NFC() - OperationScenario%ECG) .and.& + if (Get_HookHeight() <= (TL() + NFC() - data%State%OperationScenario%ECG) .and.& Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& @@ -38,7 +38,7 @@ module CUnlatchLedNotification !TOPDRIVE-CODE=48 - if ((Get_HookHeight() >= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC() + OperationScenario%TG)) .and.& + if ((Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() + data%State%OperationScenario%TG)) .and.& GetStandRack() > 80 .and.& Get_JointConnectionPossible() == .false. .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& @@ -61,7 +61,7 @@ module CUnlatchLedNotification !TOPDRIVE-CODE=49 - if ((Get_HookHeight() >= TL() .and. Get_HookHeight() <= (TL() + NFC() + OperationScenario%SG)) .and.& + if ((Get_HookHeight() >= TL() .and. Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SG)) .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.& @@ -92,7 +92,7 @@ module CUnlatchLedNotification - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_UnlatchLed=Kelly' #endif @@ -101,7 +101,7 @@ module CUnlatchLedNotification !OPERATION-CODE=40 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() - OperationScenario%ECG) .and.& + Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() - data%State%OperationScenario%ECG) .and.& Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& @@ -130,7 +130,7 @@ module CUnlatchLedNotification !OPERATION-CODE=41 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection() + OperationScenario%LG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.& !Get_HookHeight() >= (HL + Get_NearFloorConnection() + SL + RE) .and. Get_HookHeight() <= (HL + Get_NearFloorConnection() + SL + LG) .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& @@ -157,7 +157,7 @@ module CUnlatchLedNotification !OPERATION-CODE=42 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= OperationScenario%HL .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%SG) .and.& + Get_HookHeight() >= data%State%OperationScenario%HL .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%SG) .and.& (Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.& Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.& @@ -203,14 +203,14 @@ module CUnlatchLedNotification ! subroutine Subscribe_UnlatchLed() ! implicit none - ! !**call UnitySignals%OnOperationConditionChange%Add(Evaluate_UnlatchLed) + ! !**call data%State%unitySignals%OnOperationConditionChange%Add(Evaluate_UnlatchLed) ! ! call softwareInputs%OnHookHeightChange%Add(Evaluate_UnlatchLed) ! ! call softwareInputs%OnStandRackChanged%Add(Evaluate_UnlatchLed) - ! call OperationScenario%OnElevatorConnectionChange%Add(Evaluate_UnlatchLed) - ! !**call UnitySignals%OnSwingChange%Add(Evaluate_UnlatchLed) - ! !**call UnitySignals%OnSlipsChange%Add(Evaluate_UnlatchLed) - ! !**call Notifications%OnLatchLedChange%Add(Evaluate_UnlatchLed) - ! !**call Notifications%OnFillMouseHoleLedChange%Add(Evaluate_UnlatchLed) + ! call data%State%OperationScenario%OnElevatorConnectionChange%Add(Evaluate_UnlatchLed) + ! !**call data%State%unitySignals%OnSwingChange%Add(Evaluate_UnlatchLed) + ! !**call data%State%unitySignals%OnSlipsChange%Add(Evaluate_UnlatchLed) + ! !**call data%State%notifications%OnLatchLedChange%Add(Evaluate_UnlatchLed) + ! !**call data%State%notifications%OnFillMouseHoleLedChange%Add(Evaluate_UnlatchLed) ! end subroutine end module CUnlatchLedNotification \ No newline at end of file diff --git a/CSharp/OperationScenarios/Notifications/NotificationVariables.f90 b/CSharp/OperationScenarios/Notifications/NotificationVariables.f90 index 5825289..a7d31cf 100644 --- a/CSharp/OperationScenarios/Notifications/NotificationVariables.f90 +++ b/CSharp/OperationScenarios/Notifications/NotificationVariables.f90 @@ -3,432 +3,23 @@ module NotificationVariables implicit none type::NotificationType logical :: CloseKellyCockLed = .false. - ! type(VoidEventHandlerCollection) :: OnCloseKellyCockLedChange - logical :: CloseSafetyValveLed = .false. integer :: operation_CloseSafetyValveLed = 0 - ! type(VoidEventHandlerCollection) :: OnCloseSafetyValveLedChange - logical :: FillMouseHoleLed = .false. - ! type(VoidEventHandlerCollection) :: OnFillMouseHoleLedChange - logical :: IrIBopLed = .false. - ! type(VoidEventHandlerCollection) :: OnIrIBopLedChange - logical :: IrSafetyValveLed = .false. integer :: operation_IrSafetyValveLed = 0 - ! type(VoidEventHandlerCollection) :: OnIrSafetyValveLedChange - logical :: LatchLed = .false. - ! type(VoidEventHandlerCollection) :: OnLatchLedChange - logical :: OpenKellyCockLed = .false. - ! type(VoidEventHandlerCollection) :: OnOpenKellyCockLedChange - logical :: OpenSafetyValveLed = .false. - integer :: operation_OpenSafetyValveLed = 0 - ! type(VoidEventHandlerCollection) :: OnOpenSafetyValveLedChange - logical :: SlipsNotification = .false. - ! procedure (ActionBool), pointer :: SlipsNotificationPtr - ! type(VoidEventHandlerCollection) :: OnSlipsNotificationChange - logical :: SwingLed = .false. - ! type(VoidEventHandlerCollection) :: OnSwingLedChange - - logical :: IbopLed = .false. - ! type(VoidEventHandlerCollection) :: OnIbopLedChange - + logical :: IbopLed = .false. logical :: PowerLed = .false. - ! type(VoidEventHandlerCollection) :: OnPowerLedChange - integer :: TorqueWrenchLed = 0 - ! type(VoidEventHandlerCollection) :: OnTorqueWrenchLedChange - logical :: TongNotification = .false. - ! procedure (ActionBool), pointer :: TongNotificationPtr - ! type(VoidEventHandlerCollection) :: OnTongNotificationChange - logical :: UnlatchLed = .false. - ! type(VoidEventHandlerCollection) :: OnUnlatchLedChange end type NotificationType - type(NotificationType)::notifications - contains - - subroutine Set_UnlatchLed(v) - use CDrillingConsoleVariables!, only: DrillingConsole%UnlatchPipeLED - !use CLatchLedNotification - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%UnlatchLed == v) return - #endif - notifications%UnlatchLed = v - - if(notifications%UnlatchLed) then - DrillingConsole%UnlatchPipeLED = 1 - !call Set_LatchLed(.false.) - else - DrillingConsole%UnlatchPipeLED = 0 - endif - - !**call notifications%OnUnlatchLedChange%RunAll() - end subroutine - - logical function Get_UnlatchLed() - implicit none - Get_UnlatchLed = notifications%UnlatchLed - end function - - subroutine Set_TongNotification(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%TongNotification == v) return - #endif - notifications%TongNotification = v - ! if(associated(notifications%TongNotificationPtr)) !**call notifications%TongNotificationPtr(notifications%TongNotification) - #ifdef deb - print*, 'notifications%TongNotification=', notifications%TongNotification - #endif - !**call notifications%OnTongNotificationChange%RunAll() - end subroutine - - logical function Get_TongNotification() - implicit none - Get_TongNotification = notifications%TongNotification - end function - - subroutine Set_TorqueWrenchLed(v) - use CTopDrivePanelVariables!, only: TopDrivePanel%TopDriveTorqueWrenchLed - implicit none - integer , intent(in) :: v - - #ifdef ExcludeExtraChanges - if(notifications%TorqueWrenchLed == v) return - #endif - notifications%TorqueWrenchLed = v - TopDrivePanel%TopDriveTorqueWrenchLed = v - !**call notifications%OnTorqueWrenchLedChange%RunAll() - end subroutine - - logical function Get_TorqueWrenchLed() - implicit none - Get_TorqueWrenchLed = notifications%TorqueWrenchLed - end function - - subroutine Set_PowerLed(v) - use CTopDrivePanelVariables!, only: TopDrivePanel%TopDriveTdsPowerLed - !use CLatchLedNotification - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%PowerLed == v) return - #endif - notifications%PowerLed = v - - if(notifications%PowerLed) then - TopDrivePanel%TopDriveTdsPowerLed = 1 - !call Set_LatchLed(.false.) - else - TopDrivePanel%TopDriveTdsPowerLed = 0 - endif - - !**call notifications%OnPowerLedChange%RunAll() - end subroutine - - logical function Get_PowerLed() - implicit none - Get_PowerLed = notifications%PowerLed - end function - - subroutine Set_IbopLed(v) - use CTopDrivePanelVariables!, only: TopDrivePanel%TopDriveIbopLed - use CManifolds, Only: OpenTopDriveIBop, CloseTopDriveIBop - !use CLatchLedNotification - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%IbopLed == v) return - #endif - notifications%IbopLed = v - - if(notifications%IbopLed) then - TopDrivePanel%TopDriveIbopLed = 1 - call CloseTopDriveIBop() - else - TopDrivePanel%TopDriveIbopLed = 0 - call OpenTopDriveIBop() - endif - - !**call notifications%OnIbopLedChange%RunAll() - end subroutine - - logical function Get_IbopLed() - implicit none - Get_IbopLed = notifications%IbopLed - end function - - subroutine Set_SwingLed(v) - use CDrillingConsoleVariables!, only: SwingLedHw => SwingLed - implicit none - logical , intent(in) :: v - - #ifdef ExcludeExtraChanges - if(notifications%SwingLed == v) return - #endif - notifications%SwingLed = v - if(notifications%SwingLed) then - DrillingConsole%SwingLed = 1 - else - DrillingConsole%SwingLed = 0 - endif - !**call notifications%OnSwingLedChange%RunAll() - end subroutine - - logical function Get_SwingLed() - implicit none - Get_SwingLed = notifications%SwingLed - end function - - subroutine Set_SlipsNotification(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%SlipsNotification == v) return - #endif - notifications%SlipsNotification = v - ! if(associated(notifications%SlipsNotificationPtr)) !**call notifications%SlipsNotificationPtr(notifications%SlipsNotification) - #ifdef deb - print*, 'notifications%SlipsNotification=', notifications%SlipsNotification - #endif - !**call notifications%OnSlipsNotificationChange%RunAll() - end subroutine - - logical function Get_SlipsNotification() - implicit none - Get_SlipsNotification = notifications%SlipsNotification - end function - - subroutine Set_OpenSafetyValveLed(v) - use CDrillingConsoleVariables!, only: OpenSafetyValveLedHw => OpenSafetyValveLed - use CManifolds, only: OpenSafetyValve_TopDrive, OpenSafetyValve_KellyMode, OpenSafetyValve_TripMode - use CHoistingVariables!, only: Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%OpenSafetyValveLed == v) return - #endif - notifications%OpenSafetyValveLed = v - - if(notifications%OpenSafetyValveLed) then - !!call OpenSafetyValve() - if(Hoisting%DriveType == TopDrive_DriveType) call OpenSafetyValve_TopDrive() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_OpenSafetyValveLed == 0) call OpenSafetyValve_KellyMode() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_OpenSafetyValveLed == 1) call OpenSafetyValve_TripMode() - endif - - !**call notifications%OnOpenSafetyValveLedChange%RunAll() - end subroutine - - logical function Get_OpenSafetyValveLed() - implicit none - Get_OpenSafetyValveLed = notifications%OpenSafetyValveLed - end function - - subroutine Set_OpenKellyCockLed(v) - ! use CDrillingConsoleVariables!, only: OpenKellyCockLedHw => OpenKellyCockLed - use CManifolds, only: OpenKellyCock - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%OpenKellyCockLed == v) return - #endif - notifications%OpenKellyCockLed = v - - if(notifications%OpenKellyCockLed) then - call OpenKellyCock() - endif - - ! HAS BEEN IMPLEMENTED IN CMANIFOLD - - !if(OpenKellyCockLed) then - ! OpenKellyCockLedHw = 1 - !else - ! OpenKellyCockLedHw = 0 - !endif - - !**call notifications%OnOpenKellyCockLedChange%RunAll() - end subroutine - - logical function Get_OpenKellyCockLed() - implicit none - Get_OpenKellyCockLed = notifications%OpenKellyCockLed - end function - - subroutine Set_LatchLed(v) - use CDrillingConsoleVariables!, only: DrillingConsole%LatchPipeLED - !use CUnlatchLedNotification - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%LatchLed == v) return - #endif - notifications%LatchLed = v - if(notifications%LatchLed) then - DrillingConsole%LatchPipeLED = 1 - !call Set_UnlatchLed(.false.) - else - DrillingConsole%LatchPipeLED = 0 - endif - !**call notifications%OnLatchLedChange%RunAll() - end subroutine - - logical function Get_LatchLed() - implicit none - Get_LatchLed = notifications%LatchLed - end function - - subroutine Set_IrSafetyValveLed(v) - use CDrillingConsoleVariables!, only: DrillingConsole%CloseKellyCockLed => IRSafetyValveLed - use CManifolds, only: & - InstallSafetyValve_TopDrive, & - InstallSafetyValve_KellyMode, & - InstallSafetyValve_TripMode, & - RemoveSafetyValve_TopDrive, & - RemoveSafetyValve_KellyMode, & - RemoveSafetyValve_TripMode - use UnitySignalVariables, only: Set_SafetyValve_Install, Set_SafetyValve_Remove - use CHoistingVariables!, only: Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%IrSafetyValveLed == v) return - #endif - notifications%IrSafetyValveLed = v - - if(notifications%IrSafetyValveLed) then - DrillingConsole%IRSafetyValveLed = 1 - - if(Hoisting%DriveType == TopDrive_DriveType) call InstallSafetyValve_TopDrive() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 0) call InstallSafetyValve_KellyMode() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 1) call InstallSafetyValve_TripMode() - - call Set_SafetyValve_Install() - else - DrillingConsole%IRSafetyValveLed = 0 - - if(Hoisting%DriveType == TopDrive_DriveType) call RemoveSafetyValve_TopDrive() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 0) call RemoveSafetyValve_KellyMode() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 1) call RemoveSafetyValve_TripMode() - - call Set_SafetyValve_Remove() - endif - - !**call notifications%OnIrSafetyValveLedChange%RunAll() - end subroutine - - logical function Get_IrSafetyValveLed() - implicit none - Get_IrSafetyValveLed = notifications%IrSafetyValveLed - end function - - subroutine Set_IrIBopLed(v) - use CDrillingConsoleVariables!, only: IRIBopLedHw => IRIBopLed - use CManifolds, only: InstallIBop, RemoveIBop - use UnitySignalVariables, only: Set_Ibop_Install, Set_Ibop_Remove - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%IrIBopLed == v) return - #endif - notifications%IrIBopLed = v - if(notifications%IrIBopLed) then - DrillingConsole%IRIBopLed = 1 - call InstallIBop() - call Set_Ibop_Install() - else - DrillingConsole%IRIBopLed = 0 - call RemoveIBop() - call Set_Ibop_Remove() - endif - !**call notifications%OnIrIBopLedChange%RunAll() - end subroutine - - logical function Get_IrIBopLed() - implicit none - Get_IrIBopLed = notifications%IrIBopLed - end function - - subroutine Set_FillMouseHoleLed(v) - use CDrillingConsoleVariables!, only: FillMouseHoleLedHw => FillMouseHoleLed - ! use CMouseHoleEnumVariables - use UnitySignalVariables - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%FillMouseHoleLed == v) return - #endif - notifications%FillMouseHoleLed = v - if(notifications%FillMouseHoleLed) then - DrillingConsole%FillMouseHoleLed = 1 - !call Set_MouseHole(MOUSE_HOLE_FILL) - else - DrillingConsole%FillMouseHoleLed = 0 - !call Set_MouseHole(MOUSE_HOLE_EMPTY) - endif - !**call notifications%OnFillMouseHoleLedChange%RunAll() - end subroutine - - logical function Get_FillMouseHoleLed() - implicit none - Get_FillMouseHoleLed = notifications%FillMouseHoleLed - end function - - subroutine Set_CloseKellyCockLed(v) - use CDrillingConsoleVariables!, only: CloseKellyCockLedHw => CloseKellyCockLed - use CManifolds, only: CloseKellyCock - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%CloseKellyCockLed == v) return - #endif - notifications%CloseKellyCockLed = v - if(notifications%CloseKellyCockLed) then - call CloseKellyCock() - endif - !**call notifications%OnCloseKellyCockLedChange%RunAll() - end subroutine - - logical function Get_CloseKellyCockLed() - implicit none - Get_CloseKellyCockLed = notifications%CloseKellyCockLed - end function - - subroutine Set_CloseSafetyValveLed(v) - ! use CDrillingConsoleVariables, only: CloseSafetyValveLedHw => CloseSafetyValveLed - use CManifolds, only: CloseSafetyValve_TopDrive, CloseSafetyValve_KellyMode, CloseSafetyValve_TripMode - use CHoistingVariables!, only: Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(notifications%CloseSafetyValveLed == v) return - #endif - notifications%CloseSafetyValveLed = v - if(notifications%CloseSafetyValveLed) then - !!call CloseSafetyValve() - if(Hoisting%DriveType == TopDrive_DriveType) call CloseSafetyValve_TopDrive() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_CloseSafetyValveLed == 0) call CloseSafetyValve_KellyMode() - if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_CloseSafetyValveLed == 1) call CloseSafetyValve_TripMode() - endif - !**call notifications%OnCloseSafetyValveLedChange%RunAll() - end subroutine - - logical function Get_CloseSafetyValveLed() - implicit none - Get_CloseSafetyValveLed = notifications%CloseSafetyValveLed - end function - end module NotificationVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Notifications/Notofications.f90 b/CSharp/OperationScenarios/Notifications/Notofications.f90 new file mode 100644 index 0000000..81e34f9 --- /dev/null +++ b/CSharp/OperationScenarios/Notifications/Notofications.f90 @@ -0,0 +1,408 @@ +module NotificationModule + use ConfigurationVariables + implicit none +contains + subroutine Set_UnlatchLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + !use CLatchLedNotification + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%UnlatchLed == v) return + #endif + data%State%notifications%UnlatchLed = v + + if(data%State%notifications%UnlatchLed) then + data%EquipmentControl%DrillingConsole%UnlatchPipeLED = 1 + !call Set_LatchLed(.false.) + else + data%EquipmentControl%DrillingConsole%UnlatchPipeLED = 0 + endif + + !**call data%State%notifications%OnUnlatchLedChange%RunAll() + end subroutine + + logical function Get_UnlatchLed() + implicit none + Get_UnlatchLed = data%State%notifications%UnlatchLed + end function + + subroutine Set_TongNotification(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%TongNotification == v) return + #endif + data%State%notifications%TongNotification = v + ! if(associated(data%State%notifications%TongNotificationPtr)) !**call data%State%notifications%TongNotificationPtr(data%State%notifications%TongNotification) + #ifdef deb + print*, 'data%State%notifications%TongNotification=', data%State%notifications%TongNotification + #endif + !**call data%State%notifications%OnTongNotificationChange%RunAll() + end subroutine + + logical function Get_TongNotification() + implicit none + Get_TongNotification = data%State%notifications%TongNotification + end function + + subroutine Set_TorqueWrenchLed(v) + use CTopDrivePanelVariables + use ConfigurationVariables!, only: data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrenchLed + implicit none + integer , intent(in) :: v + + #ifdef ExcludeExtraChanges + if(data%State%notifications%TorqueWrenchLed == v) return + #endif + data%State%notifications%TorqueWrenchLed = v + data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrenchLed = v + !**call data%State%notifications%OnTorqueWrenchLedChange%RunAll() + end subroutine + + logical function Get_TorqueWrenchLed() + implicit none + Get_TorqueWrenchLed = data%State%notifications%TorqueWrenchLed + end function + + subroutine Set_PowerLed(v) + use CTopDrivePanelVariables + use ConfigurationVariables!, only: data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerLed + !use CLatchLedNotification + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%PowerLed == v) return + #endif + data%State%notifications%PowerLed = v + + if(data%State%notifications%PowerLed) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerLed = 1 + !call Set_LatchLed(.false.) + else + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerLed = 0 + endif + + !**call data%State%notifications%OnPowerLedChange%RunAll() + end subroutine + + logical function Get_PowerLed() + implicit none + Get_PowerLed = data%State%notifications%PowerLed + end function + + subroutine Set_IbopLed(v) + use CTopDrivePanelVariables + use ConfigurationVariables!, only: data%EquipmentControl%TopDrivePanel%TopDriveIbopLed + use CManifolds, Only: OpenTopDriveIBop, CloseTopDriveIBop + !use CLatchLedNotification + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%IbopLed == v) return + #endif + data%State%notifications%IbopLed = v + + if(data%State%notifications%IbopLed) then + data%EquipmentControl%TopDrivePanel%TopDriveIbopLed = 1 + call CloseTopDriveIBop() + else + data%EquipmentControl%TopDrivePanel%TopDriveIbopLed = 0 + call OpenTopDriveIBop() + endif + + !**call data%State%notifications%OnIbopLedChange%RunAll() + end subroutine + + logical function Get_IbopLed() + implicit none + Get_IbopLed = data%State%notifications%IbopLed + end function + + subroutine Set_SwingLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: SwingLedHw => SwingLed + implicit none + logical , intent(in) :: v + + #ifdef ExcludeExtraChanges + if(data%State%notifications%SwingLed == v) return + #endif + data%State%notifications%SwingLed = v + if(data%State%notifications%SwingLed) then + data%EquipmentControl%DrillingConsole%SwingLed = 1 + else + data%EquipmentControl%DrillingConsole%SwingLed = 0 + endif + !**call data%State%notifications%OnSwingLedChange%RunAll() + end subroutine + + logical function Get_SwingLed() + implicit none + Get_SwingLed = data%State%notifications%SwingLed + end function + + subroutine Set_SlipsNotification(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%SlipsNotification == v) return + #endif + data%State%notifications%SlipsNotification = v + ! if(associated(data%State%notifications%SlipsNotificationPtr)) !**call data%State%notifications%SlipsNotificationPtr(data%State%notifications%SlipsNotification) + #ifdef deb + print*, 'data%State%notifications%SlipsNotification=', data%State%notifications%SlipsNotification + #endif + !**call data%State%notifications%OnSlipsNotificationChange%RunAll() + end subroutine + + logical function Get_SlipsNotification() + implicit none + Get_SlipsNotification = data%State%notifications%SlipsNotification + end function + + subroutine Set_OpenSafetyValveLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: OpenSafetyValveLedHw => OpenSafetyValveLed + use CManifolds, only: OpenSafetyValve_TopDrive, OpenSafetyValve_KellyMode, OpenSafetyValve_TripMode + use CHoistingVariables + use ConfigurationVariables!, only: data%State%Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%OpenSafetyValveLed == v) return + #endif + data%State%notifications%OpenSafetyValveLed = v + + if(data%State%notifications%OpenSafetyValveLed) then + !!call OpenSafetyValve() + if(data%State%Hoisting%DriveType == TopDrive_DriveType) call OpenSafetyValve_TopDrive() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_OpenSafetyValveLed == 0) call OpenSafetyValve_KellyMode() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_OpenSafetyValveLed == 1) call OpenSafetyValve_TripMode() + endif + + !**call data%State%notifications%OnOpenSafetyValveLedChange%RunAll() + end subroutine + + logical function Get_OpenSafetyValveLed() + implicit none + Get_OpenSafetyValveLed = data%State%notifications%OpenSafetyValveLed + end function + + subroutine Set_OpenKellyCockLed(v) + ! use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: OpenKellyCockLedHw => OpenKellyCockLed + use CManifolds, only: OpenKellyCock + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%OpenKellyCockLed == v) return + #endif + data%State%notifications%OpenKellyCockLed = v + + if(data%State%notifications%OpenKellyCockLed) then + call OpenKellyCock() + endif + + ! HAS BEEN IMPLEMENTED IN CMANIFOLD + + !if(OpenKellyCockLed) then + ! OpenKellyCockLedHw = 1 + !else + ! OpenKellyCockLedHw = 0 + !endif + + !**call data%State%notifications%OnOpenKellyCockLedChange%RunAll() + end subroutine + + logical function Get_OpenKellyCockLed() + implicit none + Get_OpenKellyCockLed = data%State%notifications%OpenKellyCockLed + end function + + subroutine Set_LatchLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: data%EquipmentControl%DrillingConsole%LatchPipeLED + !use CUnlatchLedNotification + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%LatchLed == v) return + #endif + data%State%notifications%LatchLed = v + if(data%State%notifications%LatchLed) then + data%EquipmentControl%DrillingConsole%LatchPipeLED = 1 + !call Set_UnlatchLed(.false.) + else + data%EquipmentControl%DrillingConsole%LatchPipeLED = 0 + endif + !**call data%State%notifications%OnLatchLedChange%RunAll() + end subroutine + + logical function Get_LatchLed() + implicit none + Get_LatchLed = data%State%notifications%LatchLed + end function + + subroutine Set_IrSafetyValveLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: data%EquipmentControl%DrillingConsole%CloseKellyCockLed => IRSafetyValveLed + use CManifolds, only: & + InstallSafetyValve_TopDrive, & + InstallSafetyValve_KellyMode, & + InstallSafetyValve_TripMode, & + RemoveSafetyValve_TopDrive, & + RemoveSafetyValve_KellyMode, & + RemoveSafetyValve_TripMode + use UnitySignalVariables + use UnitySignalsModule, only: Set_SafetyValve_Install, Set_SafetyValve_Remove + use CHoistingVariables + use ConfigurationVariables!, only: data%State%Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%IrSafetyValveLed == v) return + #endif + data%State%notifications%IrSafetyValveLed = v + + if(data%State%notifications%IrSafetyValveLed) then + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 1 + + if(data%State%Hoisting%DriveType == TopDrive_DriveType) call InstallSafetyValve_TopDrive() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_IrSafetyValveLed == 0) call InstallSafetyValve_KellyMode() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_IrSafetyValveLed == 1) call InstallSafetyValve_TripMode() + + call Set_SafetyValve_Install() + else + data%EquipmentControl%DrillingConsole%IRSafetyValveLed = 0 + + if(data%State%Hoisting%DriveType == TopDrive_DriveType) call RemoveSafetyValve_TopDrive() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_IrSafetyValveLed == 0) call RemoveSafetyValve_KellyMode() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_IrSafetyValveLed == 1) call RemoveSafetyValve_TripMode() + + call Set_SafetyValve_Remove() + endif + + !**call data%State%notifications%OnIrSafetyValveLedChange%RunAll() + end subroutine + + logical function Get_IrSafetyValveLed() + implicit none + Get_IrSafetyValveLed = data%State%notifications%IrSafetyValveLed + end function + + subroutine Set_IrIBopLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: IRIBopLedHw => IRIBopLed + use CManifolds, only: InstallIBop, RemoveIBop + use UnitySignalVariables + use UnitySignalsModule, only: Set_Ibop_Install, Set_Ibop_Remove + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%IrIBopLed == v) return + #endif + data%State%notifications%IrIBopLed = v + if(data%State%notifications%IrIBopLed) then + data%EquipmentControl%DrillingConsole%IRIBopLed = 1 + call InstallIBop() + call Set_Ibop_Install() + else + data%EquipmentControl%DrillingConsole%IRIBopLed = 0 + call RemoveIBop() + call Set_Ibop_Remove() + endif + !**call data%State%notifications%OnIrIBopLedChange%RunAll() + end subroutine + + logical function Get_IrIBopLed() + implicit none + Get_IrIBopLed = data%State%notifications%IrIBopLed + end function + + subroutine Set_FillMouseHoleLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: FillMouseHoleLedHw => FillMouseHoleLed + ! use CMouseHoleEnumVariables + use UnitySignalVariables + use UnitySignalsModule + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%FillMouseHoleLed == v) return + #endif + data%State%notifications%FillMouseHoleLed = v + if(data%State%notifications%FillMouseHoleLed) then + data%EquipmentControl%DrillingConsole%FillMouseHoleLed = 1 + !call Set_MouseHole(MOUSE_HOLE_FILL) + else + data%EquipmentControl%DrillingConsole%FillMouseHoleLed = 0 + !call Set_MouseHole(MOUSE_HOLE_EMPTY) + endif + !**call data%State%notifications%OnFillMouseHoleLedChange%RunAll() + end subroutine + + logical function Get_FillMouseHoleLed() + implicit none + Get_FillMouseHoleLed = data%State%notifications%FillMouseHoleLed + end function + + subroutine Set_CloseKellyCockLed(v) + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables!, only: CloseKellyCockLedHw => CloseKellyCockLed + use CManifolds, only: CloseKellyCock + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%CloseKellyCockLed == v) return + #endif + data%State%notifications%CloseKellyCockLed = v + if(data%State%notifications%CloseKellyCockLed) then + call CloseKellyCock() + endif + !**call data%State%notifications%OnCloseKellyCockLedChange%RunAll() + end subroutine + + logical function Get_CloseKellyCockLed() + implicit none + Get_CloseKellyCockLed = data%State%notifications%CloseKellyCockLed + end function + + subroutine Set_CloseSafetyValveLed(v) + ! use CDrillingConsoleVariables + use ConfigurationVariables + !@use ConfigurationVariables, only: CloseSafetyValveLedHw => CloseSafetyValveLed + use CManifolds, only: CloseSafetyValve_TopDrive, CloseSafetyValve_KellyMode, CloseSafetyValve_TripMode + use CHoistingVariables + use ConfigurationVariables!, only: data%State%Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%notifications%CloseSafetyValveLed == v) return + #endif + data%State%notifications%CloseSafetyValveLed = v + if(data%State%notifications%CloseSafetyValveLed) then + !!call CloseSafetyValve() + if(data%State%Hoisting%DriveType == TopDrive_DriveType) call CloseSafetyValve_TopDrive() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_CloseSafetyValveLed == 0) call CloseSafetyValve_KellyMode() + if(data%State%Hoisting%DriveType == Kelly_DriveType .and. data%State%notifications%operation_CloseSafetyValveLed == 1) call CloseSafetyValve_TripMode() + endif + !**call data%State%notifications%OnCloseSafetyValveLedChange%RunAll() + end subroutine + + logical function Get_CloseSafetyValveLed() + implicit none + Get_CloseSafetyValveLed = data%State%notifications%CloseSafetyValveLed + end function + +end module NotificationModule + diff --git a/CSharp/OperationScenarios/Permissions/CFillupHeadPermission.f90 b/CSharp/OperationScenarios/Permissions/CFillupHeadPermission.f90 index 4cd7101..000f16c 100644 --- a/CSharp/OperationScenarios/Permissions/CFillupHeadPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CFillupHeadPermission.f90 @@ -1,13 +1,14 @@ module CFillupHeadPermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains subroutine Evaluate_FillupHeadPermission() + ! use UnitySignalsModule !for CTdsConnectionModesEnum implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_FillupHeadPermission=TopDrive' #endif diff --git a/CSharp/OperationScenarios/Permissions/CInstallFillupHeadPermission.f90 b/CSharp/OperationScenarios/Permissions/CInstallFillupHeadPermission.f90 index 73a49ad..ef3a71b 100644 --- a/CSharp/OperationScenarios/Permissions/CInstallFillupHeadPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CInstallFillupHeadPermission.f90 @@ -1,5 +1,5 @@ module CInstallFillupHeadPermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -10,7 +10,7 @@ module CInstallFillupHeadPermission - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_InstallFillupHeadPermission=TopDrive' #endif @@ -24,7 +24,7 @@ module CInstallFillupHeadPermission - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_InstallFillupHeadPermission=Kelly' #endif @@ -45,7 +45,7 @@ module CInstallFillupHeadPermission !OPERATION-CODE=70 if (Get_OperationCondition() == OPERATION_TRIP .and.& - TD_String%TopJointHeight >= 3.0 .and. TD_String%TopJointHeight <= 9.0 .and.& + data%State%TD_String%TopJointHeight >= 3.0 .and. data%State%TD_String%TopJointHeight <= 9.0 .and.& Get_JointConnectionPossible() == .false. .and.& !Get_ElevatorConnectionPossible() == .false. .and.& !Get_ElevatorConnection() /= ELEVATOR_CONNECTION_STRING .and.& diff --git a/CSharp/OperationScenarios/Permissions/CInstallMudBucketPermission.f90 b/CSharp/OperationScenarios/Permissions/CInstallMudBucketPermission.f90 index 56a4a4d..72988aa 100644 --- a/CSharp/OperationScenarios/Permissions/CInstallMudBucketPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CInstallMudBucketPermission.f90 @@ -1,5 +1,5 @@ module CInstallMudBucketPermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 b/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 index 3ea61e8..cf16c06 100644 --- a/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CIrIbopPermission.f90 @@ -1,15 +1,16 @@ module CIrIbopPermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains subroutine Evaluate_IrIbopPermission() use TD_DrillStemComponents - use CStudentStationVariables!, only: StudentStation%FillupHeadInstallation + use UnitySignalsModule !for CTdsConnectionModesEnum + use CStudentStationVariables!, only: data%State%StudentStation%FillupHeadInstallation implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_IrIbopPermission=TopDrive' #endif @@ -20,7 +21,7 @@ module CIrIbopPermission Get_NearFloorConnection() >= 3 .and. Get_NearFloorConnection() <= 10 .and.& Get_JointConnectionPossible() == .false. .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& - StudentStation%FillupHeadInstallation == .false.) then + data%State%StudentStation%FillupHeadInstallation == .false.) then call Set_IrIbopPermission(.true.) return @@ -39,7 +40,7 @@ module CIrIbopPermission - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_IrIbopPermission=Kelly' #endif @@ -48,7 +49,7 @@ module CIrIbopPermission if (GetRotaryRpm() == 0.0d0 .and.& Get_OperationCondition() == OPERATION_TRIP .and.& !(Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .or. Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) .and.& - TD_String%TopJointHeight >= 3.0 .and. TD_String%TopJointHeight <= 10.0 .and.& + data%State%TD_String%TopJointHeight >= 3.0 .and. data%State%TD_String%TopJointHeight <= 10.0 .and.& !Get_IbopHeight() >= 22.0 .and. Get_IbopHeight() <= 35.0 .and.& Get_JointConnectionPossible() == .false. .and.& Get_Swing() == SWING_WELL_END .and.& diff --git a/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 b/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 index a6c04ec..d281370 100644 --- a/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90 @@ -1,17 +1,17 @@ module CIrSafetyValvePermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains subroutine Evaluate_IrSafetyValvePermission() use TD_DrillStemComponents - use CStudentStationVariables!!, only: StudentStation%FillupHeadInstallation + use CStudentStationVariables!!, only: data%State%StudentStation%FillupHeadInstallation implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_IrSafetyValvePermission=TopDrive' #endif @@ -23,7 +23,7 @@ module CIrSafetyValvePermission (Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 10.0) .and.& Get_JointConnectionPossible() == .false. .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& - StudentStation%FillupHeadInstallation == .false.) then + data%State%StudentStation%FillupHeadInstallation == .false.) then call Set_IrSafetyValvePermission(.true.) return @@ -40,7 +40,7 @@ module CIrSafetyValvePermission - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_IrSafetyValvePermission=Kelly' #endif @@ -51,7 +51,7 @@ module CIrSafetyValvePermission GetRotaryRpm() == 0.0d0 .and.& !(Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .or. Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) .and.& !Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 10.0 .and.& - TD_String%TopJointHeight >= 3.0 .and. TD_String%TopJointHeight <= 10.0 .and.& + data%State%TD_String%TopJointHeight >= 3.0 .and. data%State%TD_String%TopJointHeight <= 10.0 .and.& !Get_SafetyValveHeight() >= 22.0 .and. Get_SafetyValveHeight() <= 35.0 .and.& Get_JointConnectionPossible() == .false. .and.& Get_FillupHead() == FILLUP_HEAD_REMOVE .and.& diff --git a/CSharp/OperationScenarios/Permissions/CRemoveFillupHeadPermission.f90 b/CSharp/OperationScenarios/Permissions/CRemoveFillupHeadPermission.f90 index 3317c23..4af31ed 100644 --- a/CSharp/OperationScenarios/Permissions/CRemoveFillupHeadPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CRemoveFillupHeadPermission.f90 @@ -1,5 +1,5 @@ module CRemoveFillupHeadPermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/Permissions/CRemoveMudBucketPermission.f90 b/CSharp/OperationScenarios/Permissions/CRemoveMudBucketPermission.f90 index 4f1ab9b..506cc94 100644 --- a/CSharp/OperationScenarios/Permissions/CRemoveMudBucketPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CRemoveMudBucketPermission.f90 @@ -1,5 +1,5 @@ module CRemoveMudBucketPermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/Permissions/CSwingDrillPermission.f90 b/CSharp/OperationScenarios/Permissions/CSwingDrillPermission.f90 index 174e2a3..8980cf7 100644 --- a/CSharp/OperationScenarios/Permissions/CSwingDrillPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CSwingDrillPermission.f90 @@ -1,6 +1,7 @@ module CSwingDrillPermission - use COperationScenariosVariables + use OperationScenariosModule use CTopDrivePanelVariables + use ConfigurationVariables implicit none contains @@ -9,7 +10,7 @@ module CSwingDrillPermission implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_SwingDrillPermission=TopDrive' #endif @@ -17,7 +18,7 @@ module CSwingDrillPermission !TOPDRIVE-CODE=33 if (Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then call Set_SwingDrillPermission(.true.) return diff --git a/CSharp/OperationScenarios/Permissions/CSwingOffPermission.f90 b/CSharp/OperationScenarios/Permissions/CSwingOffPermission.f90 index e9117b1..d6466cf 100644 --- a/CSharp/OperationScenarios/Permissions/CSwingOffPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CSwingOffPermission.f90 @@ -1,5 +1,5 @@ module CSwingOffPermission - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -8,7 +8,7 @@ module CSwingOffPermission implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_SwingOffPermission=TopDrive' #endif @@ -20,7 +20,7 @@ module CSwingOffPermission Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_TILT_END .and.& Get_Slips() == SLIPS_SET_END .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then call Set_SwingOffPermission(.true.) return @@ -33,7 +33,7 @@ module CSwingOffPermission if (Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_DRILL_END .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then call Set_SwingOffPermission(.true.) return diff --git a/CSharp/OperationScenarios/Permissions/CSwingTiltPermission.f90 b/CSharp/OperationScenarios/Permissions/CSwingTiltPermission.f90 index 7857f1b..3cb6498 100644 --- a/CSharp/OperationScenarios/Permissions/CSwingTiltPermission.f90 +++ b/CSharp/OperationScenarios/Permissions/CSwingTiltPermission.f90 @@ -1,5 +1,7 @@ module CSwingTiltPermission - use COperationScenariosVariables + use UnitySignalsModule + use OperationScenariosModule + use ConfigurationVariables implicit none contains @@ -7,7 +9,7 @@ module CSwingTiltPermission subroutine Evaluate_SwingTiltPermission() implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_SwingTiltPermission=TopDrive' #endif @@ -18,7 +20,7 @@ module CSwingTiltPermission Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& Get_Slips() == SLIPS_SET_END .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF) then call Set_SwingTiltPermission(.true.) return diff --git a/CSharp/OperationScenarios/Permissions/Permissions.f90 b/CSharp/OperationScenarios/Permissions/Permissions.f90 new file mode 100644 index 0000000..5bf542e --- /dev/null +++ b/CSharp/OperationScenarios/Permissions/Permissions.f90 @@ -0,0 +1,188 @@ +module PermissionsModule + use ConfigurationVariables + implicit none + +contains + subroutine Set_SwingTiltPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%SwingTiltPermission == v) return + #endif + data%State%permissions%SwingTiltPermission = v + #ifdef deb + print*, 'data%State%permissions%SwingTiltPermission=', data%State%permissions%SwingTiltPermission + #endif + !**call data%State%permissions%OnSwingTiltPermissionChange%RunAll() + end subroutine + + logical function Get_SwingTiltPermission() + implicit none + Get_SwingTiltPermission = data%State%permissions%SwingTiltPermission + end function + + subroutine Set_SwingOffPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%SwingOffPermission == v) return + #endif + data%State%permissions%SwingOffPermission = v + #ifdef deb + print*, 'data%State%permissions%SwingOffPermission=', data%State%permissions%SwingOffPermission + #endif + !**call data%State%permissions%OnSwingOffPermissionChange%RunAll() + end subroutine + + logical function Get_SwingOffPermission() + implicit none + Get_SwingOffPermission = data%State%permissions%SwingOffPermission + end function + + subroutine Set_SwingDrillPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%SwingDrillPermission == v) return + #endif + data%State%permissions%SwingDrillPermission = v + #ifdef deb + print*, 'data%State%permissions%SwingDrillPermission=', data%State%permissions%SwingDrillPermission + #endif + !**call data%State%permissions%OnSwingDrillPermissionChange%RunAll() + end subroutine + + logical function Get_SwingDrillPermission() + implicit none + Get_SwingDrillPermission = data%State%permissions%SwingDrillPermission + end function + + subroutine Set_RemoveMudBucketPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%RemoveMudBucketPermission == v) return + #endif + data%State%permissions%RemoveMudBucketPermission = v + #ifdef deb + print*, 'data%State%permissions%RemoveMudBucketPermission=', data%State%permissions%RemoveMudBucketPermission + #endif + !**call data%State%permissions%OnRemoveMudBucketPermissionChange%RunAll() + end subroutine + + logical function Get_RemoveMudBucketPermission() + implicit none + Get_RemoveMudBucketPermission = data%State%permissions%RemoveMudBucketPermission + end function + + + subroutine Set_RemoveFillupHeadPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%RemoveFillupHeadPermission == v) return + #endif + data%State%permissions%RemoveFillupHeadPermission = v + #ifdef deb + print*, 'data%State%permissions%RemoveFillupHeadPermission=', data%State%permissions%RemoveFillupHeadPermission + #endif + !**call data%State%permissions%OnRemoveFillupHeadPermissionChange%RunAll() + end subroutine + + logical function Get_RemoveFillupHeadPermission() + implicit none + Get_RemoveFillupHeadPermission = data%State%permissions%RemoveFillupHeadPermission + end function + + subroutine Set_IrSafetyValvePermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%IrSafetyValvePermission == v) return + #endif + data%State%permissions%IrSafetyValvePermission = v + #ifdef deb + print*, 'data%State%permissions%IrSafetyValvePermission=', data%State%permissions%IrSafetyValvePermission + #endif + !**call data%State%permissions%OnIrSafetyValvePermissionChange%RunAll() + end subroutine + + logical function Get_IrSafetyValvePermission() + implicit none + Get_IrSafetyValvePermission = data%State%permissions%IrSafetyValvePermission + end function + + subroutine Set_IrIbopPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%IrIbopPermission == v) return + #endif + data%State%permissions%IrIbopPermission = v + #ifdef deb + print*, 'data%State%permissions%IrIbopPermission=', data%State%permissions%IrIbopPermission + #endif + !**call data%State%permissions%OnIrIbopPermissionChange%RunAll() + end subroutine + + logical function Get_IrIbopPermission() + implicit none + Get_IrIbopPermission = data%State%permissions%IrIbopPermission + end function + + + subroutine Set_InstallMudBucketPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%InstallMudBucketPermission == v) return + #endif + data%State%permissions%InstallMudBucketPermission = v + #ifdef deb + print*, 'data%State%permissions%InstallMudBucketPermission=', data%State%permissions%InstallMudBucketPermission + #endif + !**call data%State%permissions%OnInstallMudBucketPermissionChange%RunAll() + end subroutine + + logical function Get_InstallMudBucketPermission() + implicit none + Get_InstallMudBucketPermission = data%State%permissions%InstallMudBucketPermission + end function + + subroutine Set_InstallFillupHeadPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%InstallFillupHeadPermission == v) return + #endif + data%State%permissions%InstallFillupHeadPermission = v + #ifdef deb + print*, 'InstallFillupHeadPermission=', data%State%permissions%InstallFillupHeadPermission + #endif + !**call data%State%permissions%OnInstallFillupHeadPermissionChange%RunAll() + end subroutine + + logical function Get_InstallFillupHeadPermission() + implicit none + Get_InstallFillupHeadPermission = data%State%permissions%InstallFillupHeadPermission + end function + + subroutine Set_FillupHeadPermission(v) + implicit none + logical , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%permissions%FillupHeadPermission == v) return + #endif + data%State%permissions%FillupHeadPermission = v + #ifdef deb + print*, 'FillupHeadPermission=', data%State%permissions%FillupHeadPermission + #endif + !**call data%State%permissions%OnFillupHeadPermissionChange%RunAll() + end subroutine + + logical function Get_FillupHeadPermission() + implicit none + Get_FillupHeadPermission = data%State%permissions%FillupHeadPermission + end function + +end module PermissionsModule \ No newline at end of file diff --git a/CSharp/OperationScenarios/Permissions/PermissionsVariables.f90 b/CSharp/OperationScenarios/Permissions/PermissionsVariables.f90 index a9d8b98..0949319 100644 --- a/CSharp/OperationScenarios/Permissions/PermissionsVariables.f90 +++ b/CSharp/OperationScenarios/Permissions/PermissionsVariables.f90 @@ -2,211 +2,15 @@ module PermissionsVariables ! use CVoidEventHandlerCollection type::PermissionsType logical :: FillupHeadPermission = .false. - ! type(VoidEventHandlerCollection) :: OnFillupHeadPermissionChange logical :: InstallFillupHeadPermission = .false. - ! type(VoidEventHandlerCollection) :: OnInstallFillupHeadPermissionChange logical :: InstallMudBucketPermission = .false. - ! type(VoidEventHandlerCollection) :: OnInstallMudBucketPermissionChange logical :: IrIbopPermission = .false. - ! type(VoidEventHandlerCollection) :: OnIrIbopPermissionChange logical :: IrSafetyValvePermission = .false. - ! type(VoidEventHandlerCollection) :: OnIrSafetyValvePermissionChange logical :: RemoveFillupHeadPermission = .false. - ! type(VoidEventHandlerCollection) :: OnRemoveFillupHeadPermissionChange logical :: RemoveMudBucketPermission = .false. - ! type(VoidEventHandlerCollection) :: OnRemoveMudBucketPermissionChange logical :: SwingDrillPermission = .false. - ! type(VoidEventHandlerCollection) :: OnSwingDrillPermissionChange logical :: SwingOffPermission = .false. - ! type(VoidEventHandlerCollection) :: OnSwingOffPermissionChange logical :: SwingTiltPermission = .false. - ! type(VoidEventHandlerCollection) :: OnSwingTiltPermissionChange end type PermissionsType - - type(PermissionsType):: permissions - contains - - subroutine Set_SwingTiltPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%SwingTiltPermission == v) return - #endif - permissions%SwingTiltPermission = v - #ifdef deb - print*, 'permissions%SwingTiltPermission=', permissions%SwingTiltPermission - #endif - !**call permissions%OnSwingTiltPermissionChange%RunAll() - end subroutine - - logical function Get_SwingTiltPermission() - implicit none - Get_SwingTiltPermission = permissions%SwingTiltPermission - end function - - subroutine Set_SwingOffPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%SwingOffPermission == v) return - #endif - permissions%SwingOffPermission = v - #ifdef deb - print*, 'permissions%SwingOffPermission=', permissions%SwingOffPermission - #endif - !**call permissions%OnSwingOffPermissionChange%RunAll() - end subroutine - - logical function Get_SwingOffPermission() - implicit none - Get_SwingOffPermission = permissions%SwingOffPermission - end function - - subroutine Set_SwingDrillPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%SwingDrillPermission == v) return - #endif - permissions%SwingDrillPermission = v - #ifdef deb - print*, 'permissions%SwingDrillPermission=', permissions%SwingDrillPermission - #endif - !**call permissions%OnSwingDrillPermissionChange%RunAll() - end subroutine - - logical function Get_SwingDrillPermission() - implicit none - Get_SwingDrillPermission = permissions%SwingDrillPermission - end function - - subroutine Set_RemoveMudBucketPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%RemoveMudBucketPermission == v) return - #endif - permissions%RemoveMudBucketPermission = v - #ifdef deb - print*, 'permissions%RemoveMudBucketPermission=', permissions%RemoveMudBucketPermission - #endif - !**call permissions%OnRemoveMudBucketPermissionChange%RunAll() - end subroutine - - logical function Get_RemoveMudBucketPermission() - implicit none - Get_RemoveMudBucketPermission = permissions%RemoveMudBucketPermission - end function - - - subroutine Set_RemoveFillupHeadPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%RemoveFillupHeadPermission == v) return - #endif - permissions%RemoveFillupHeadPermission = v - #ifdef deb - print*, 'permissions%RemoveFillupHeadPermission=', permissions%RemoveFillupHeadPermission - #endif - !**call permissions%OnRemoveFillupHeadPermissionChange%RunAll() - end subroutine - - logical function Get_RemoveFillupHeadPermission() - implicit none - Get_RemoveFillupHeadPermission = permissions%RemoveFillupHeadPermission - end function - - subroutine Set_IrSafetyValvePermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%IrSafetyValvePermission == v) return - #endif - permissions%IrSafetyValvePermission = v - #ifdef deb - print*, 'permissions%IrSafetyValvePermission=', permissions%IrSafetyValvePermission - #endif - !**call permissions%OnIrSafetyValvePermissionChange%RunAll() - end subroutine - - logical function Get_IrSafetyValvePermission() - implicit none - Get_IrSafetyValvePermission = permissions%IrSafetyValvePermission - end function - - subroutine Set_IrIbopPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%IrIbopPermission == v) return - #endif - permissions%IrIbopPermission = v - #ifdef deb - print*, 'permissions%IrIbopPermission=', permissions%IrIbopPermission - #endif - !**call permissions%OnIrIbopPermissionChange%RunAll() - end subroutine - - logical function Get_IrIbopPermission() - implicit none - Get_IrIbopPermission = permissions%IrIbopPermission - end function - - - subroutine Set_InstallMudBucketPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%InstallMudBucketPermission == v) return - #endif - permissions%InstallMudBucketPermission = v - #ifdef deb - print*, 'permissions%InstallMudBucketPermission=', permissions%InstallMudBucketPermission - #endif - !**call permissions%OnInstallMudBucketPermissionChange%RunAll() - end subroutine - - logical function Get_InstallMudBucketPermission() - implicit none - Get_InstallMudBucketPermission = permissions%InstallMudBucketPermission - end function - - subroutine Set_InstallFillupHeadPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%InstallFillupHeadPermission == v) return - #endif - permissions%InstallFillupHeadPermission = v - #ifdef deb - print*, 'InstallFillupHeadPermission=', permissions%InstallFillupHeadPermission - #endif - !**call permissions%OnInstallFillupHeadPermissionChange%RunAll() - end subroutine - - logical function Get_InstallFillupHeadPermission() - implicit none - Get_InstallFillupHeadPermission = permissions%InstallFillupHeadPermission - end function - - subroutine Set_FillupHeadPermission(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(permissions%FillupHeadPermission == v) return - #endif - permissions%FillupHeadPermission = v - #ifdef deb - print*, 'FillupHeadPermission=', permissions%FillupHeadPermission - #endif - !**call permissions%OnFillupHeadPermissionChange%RunAll() - end subroutine - - logical function Get_FillupHeadPermission() - implicit none - Get_FillupHeadPermission = permissions%FillupHeadPermission - end function - end module \ No newline at end of file diff --git a/CSharp/OperationScenarios/SoftwareInputsVariables.f90 b/CSharp/OperationScenarios/SoftwareInputsVariables.f90 deleted file mode 100644 index 5c2ff64..0000000 --- a/CSharp/OperationScenarios/SoftwareInputsVariables.f90 +++ /dev/null @@ -1,195 +0,0 @@ -module SoftwareInputsVariables - ! use CVoidEventHandlerCollection - type:: SoftwareInputsType - real :: HookHeight = 0 - ! type(VoidEventHandlerCollection) :: OnHookHeightChange - real :: IbopHeight = 0 - ! type(VoidEventHandlerCollection) :: OnIbopHeightChange - real :: NearFloorConnection = 0 - ! type(VoidEventHandlerCollection) :: OnNearFloorConnectionChange - real :: SafetyValveHeight = 0 - ! type(VoidEventHandlerCollection) :: OnSafetyValveHeightChange - logical :: SlackOff = .false. - ! type(VoidEventHandlerCollection) :: OnSlackOffChange - integer :: StandRack = 0 - ! type(VoidEventHandlerCollection) :: OnStandRackChanged - real :: StringPressure = 0 - ! type(VoidEventHandlerCollection) :: OnStringPressureChange - real :: TdsStemJointHeight = 0 - ! type(VoidEventHandlerCollection) :: OnTdsStemJointHeightChange - logical :: ZeroStringSpeed = .false. - ! type(VoidEventHandlerCollection) :: OnZeroStringSpeedChange - end type SoftwareInputsType - type(SoftwareInputsType):: softwareInputs - - contains - - subroutine Set_ZeroStringSpeed(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%ZeroStringSpeed == v) return - #endif - softwareInputs%ZeroStringSpeed = v - #ifdef deb - print*, 'ZeroStringSpeed=', softwareInputs%ZeroStringSpeed - #endif - ! call softwareInputs%OnZeroStringSpeedChange%RunAll() - end subroutine - - logical function Get_ZeroStringSpeed() - implicit none - Get_ZeroStringSpeed = softwareInputs%ZeroStringSpeed - !Get_ZeroStringSpeed = .true. - end function - - subroutine Set_TdsStemJointHeight(v) - implicit none - real , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%TdsStemJointHeight == v) return - #endif - softwareInputs%TdsStemJointHeight = v - #ifdef deb - print*, 'TdsStemJointHeight=', softwareInputs%TdsStemJointHeight - #endif - ! call softwareInputs%OnTdsStemJointHeightChange%RunAll() - end subroutine - - real function Get_TdsStemJointHeight() - implicit none - Get_TdsStemJointHeight = softwareInputs%TdsStemJointHeight - end function - - - subroutine Set_StringPressure(v) - implicit none - real , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%StringPressure == v) return - #endif - softwareInputs%StringPressure = v - #ifdef deb - print*, 'StringPressure=', softwareInputs%StringPressure - #endif - ! call softwareInputs%OnStringPressureChange%RunAll() - end subroutine - - real function Get_StringPressure() - implicit none - Get_StringPressure = softwareInputs%StringPressure - end function - - subroutine Set_StandRack(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%StandRack == v) return - #endif - softwareInputs%StandRack = v - #ifdef deb - print*, 'StandRack=', softwareInputs%StandRack - #endif - ! call softwareInputs%OnStandRackChanged%RunAll() - end subroutine - - integer function Get_StandRack() - implicit none - Get_StandRack = softwareInputs%StandRack - end function - - subroutine Set_SlackOff(v) - implicit none - logical , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%SlackOff == v) return - #endif - softwareInputs%SlackOff = v - #ifdef deb - print*, 'SlackOff=', softwareInputs%SlackOff - #endif - ! call softwareInputs%OnSlackOffChange%RunAll() - end subroutine - - logical function Get_SlackOff() - implicit none - Get_SlackOff = softwareInputs%SlackOff - end function - - subroutine Set_SafetyValveHeight(v) - implicit none - real , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%SafetyValveHeight == v) return - #endif - softwareInputs%SafetyValveHeight = v - #ifdef deb - print*, 'SafetyValveHeight=', softwareInputs%SafetyValveHeight - #endif - ! call softwareInputs%OnSafetyValveHeightChange%RunAll() - end subroutine - - real function Get_SafetyValveHeight() - implicit none - Get_SafetyValveHeight = softwareInputs%SafetyValveHeight - !Get_SafetyValveHeight = 23 - end function - - - subroutine Set_NearFloorConnection(v) - implicit none - real , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%NearFloorConnection == v) return - #endif - softwareInputs%NearFloorConnection = v - #ifdef deb - print*, 'NearFloorConnection=', softwareInputs%NearFloorConnection - #endif - ! call softwareInputs%OnNearFloorConnectionChange%RunAll() - end subroutine - - real function Get_NearFloorConnection() - implicit none - Get_NearFloorConnection = softwareInputs%NearFloorConnection - !Get_NearFloorConnection = 4 - end function - - subroutine Set_IbopHeight(v) - implicit none - real , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%IbopHeight == v) return - #endif - softwareInputs%IbopHeight = v - #ifdef deb - print*, 'IbopHeight=', softwareInputs%IbopHeight - #endif - ! call softwareInputs%OnIbopHeightChange%RunAll() - end subroutine - - real function Get_IbopHeight() - implicit none - Get_IbopHeight = softwareInputs%IbopHeight - !Get_IbopHeight = 23.0 - end function - - subroutine Set_HookHeight(v) - implicit none - real , intent(in) :: v - #ifdef ExcludeExtraChanges - if(softwareInputs%HookHeight == v) return - #endif - softwareInputs%HookHeight = v - #ifdef deb - print*, 'HookHeight=', softwareInputs%HookHeight - #endif - ! call softwareInputs%OnHookHeightChange%RunAll() - end subroutine - - real function Get_HookHeight() - implicit none - Get_HookHeight = softwareInputs%HookHeight - end function - -end module \ No newline at end of file diff --git a/CSharp/OperationScenarios/SoftwareOutputs/CStringUpdateVariables.f90 b/CSharp/OperationScenarios/SoftwareOutputs/CStringUpdateVariables.f90 deleted file mode 100644 index fa14bd7..0000000 --- a/CSharp/OperationScenarios/SoftwareOutputs/CStringUpdateVariables.f90 +++ /dev/null @@ -1,56 +0,0 @@ -module CStringUpdateVariables - use CIntegerEventHandlerCollection - implicit none - integer :: StringUpdate = 0 - - public - - !**type(IntegerEventHandlerCollection) :: OnStringUpdateChange - - enum, bind(c) - enumerator STRING_UPDATE_NEUTRAL - enumerator STRING_UPDATE_ADD_SINGLE - enumerator STRING_UPDATE_ADD_STAND - enumerator STRING_UPDATE_REMOVE_SINGLE - enumerator STRING_UPDATE_REMOVE_STAND - end enum - - private :: StringUpdate - - contains - - subroutine Set_StringUpdate(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(StringUpdate == v) return - #endif - StringUpdate = v - call OnStringUpdateChange%RunAll(v) - end subroutine - - integer function Get_StringUpdate() - implicit none - Get_StringUpdate = StringUpdate - end function - - - - - subroutine Set_StringUpdate_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_StringUpdate_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_StringUpdate_WN' :: Set_StringUpdate_WN - implicit none - integer , intent(in) :: v - call Set_StringUpdate(v) - end subroutine - - integer function Get_StringUpdate_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_StringUpdate_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_StringUpdate_WN' :: Get_StringUpdate_WN - implicit none - Get_StringUpdate_WN = StringUpdate - end function - - -end module CStringUpdateVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/Unity/CUnityInputs.f90 b/CSharp/OperationScenarios/Unity/CUnityInputs.f90 index 0c6b232..755d255 100644 --- a/CSharp/OperationScenarios/Unity/CUnityInputs.f90 +++ b/CSharp/OperationScenarios/Unity/CUnityInputs.f90 @@ -494,98 +494,12 @@ module CUnityInputs end function - ! logical function Get_SingleSetInMouseHole_WN() - ! !DEC$ ATTRIBUTES DLLEXPORT :: Get_SingleSetInMouseHole_WN - ! !DEC$ ATTRIBUTES ALIAS: 'Get_SingleSetInMouseHole_WN' :: Get_SingleSetInMouseHole_WN - ! implicit none - ! Get_SingleSetInMouseHole_WN = UnityInputs%SingleSetInMouseHole - ! end function - - - - - - - - -! subroutine Set_SwingCenter(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: Set_SwingCenter -! !DEC$ ATTRIBUTES ALIAS: 'Set_SwingCenter' :: Set_SwingCenter -! !USE CSwingEnum -! implicit none -! logical, intent(in) :: v -! !#ifdef ExcludeExtraChanges -! ! if(SwingCenter == v) return -! !#endif -! ! SwingCenter = v -! ! call OnSwingCenterChange%RunAll() -! ! !if(SwingCenter .and. Get_Swing() /= SWING_WELL ) call Set_Swing(SWING_WELL) -! !#ifdef deb -! ! print*, 'SwingCenter=', SwingCenter -! !#endif -! end subroutine - - !logical function Get_SwingCenter() - ! implicit none - ! Get_SwingCenter = SwingCenter - !end function - - - - - - - - - - - - - !top drive -! subroutine Set_TdsConnectionPossible(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsConnectionPossible -! !DEC$ ATTRIBUTES ALIAS: 'Set_TdsConnectionPossible' :: Set_TdsConnectionPossible -! implicit none -! logical, intent(in) :: v -! #ifdef ExcludeExtraChanges -! if(UnityInputs%TdsConnectionPossible == v) return -! #endif -! UnityInputs%TdsConnectionPossible = v -! !**call UnityInputs%OnTdsConnectionPossibleChange%RunAll() -! #ifdef deb -! print*, 'TdsConnectionPossible=', UnityInputs%TdsConnectionPossible -! #endif -! end subroutine logical function Get_TdsConnectionPossible() implicit none Get_TdsConnectionPossible = UnityInputs%TdsConnectionPossible end function -! logical function Get_TdsConnectionPossible_WN() -! !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsConnectionPossible_WN -! !DEC$ ATTRIBUTES ALIAS: 'Get_TdsConnectionPossible_WN' :: Get_TdsConnectionPossible_WN -! implicit none -! Get_TdsConnectionPossible_WN = UnityInputs%TdsConnectionPossible -! !Get_TdsConnectionPossible_WN = .true. -! end function - - - -! subroutine Set_TdsStemIn(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsStemIn -! !DEC$ ATTRIBUTES ALIAS: 'Set_TdsStemIn' :: Set_TdsStemIn -! implicit none -! logical, intent(in) :: v -! #ifdef ExcludeExtraChanges -! if(UnityInputs%TdsStemIn == v) return -! #endif -! UnityInputs%TdsStemIn = v -! !**call UnityInputs%OnTdsStemInChange%RunAll() -! #ifdef deb -! print*, 'TdsStemIn=', UnityInputs%TdsStemIn -! #endif -! end subroutine logical function Get_TdsStemIn() implicit none diff --git a/CSharp/OperationScenarios/Unity/CUnityOutputs.f90 b/CSharp/OperationScenarios/Unity/CUnityOutputs.f90 index e580124..f64f611 100644 --- a/CSharp/OperationScenarios/Unity/CUnityOutputs.f90 +++ b/CSharp/OperationScenarios/Unity/CUnityOutputs.f90 @@ -18,12 +18,13 @@ module CUnityOutputs contains - subroutine Setup() - use CDataDisplayConsoleVariables - implicit none - PumpsSpmChanges => Calc_KellyHoseVibrationRate - ! call DataDisplayConsole%OnRotaryRpmChange%Add(Set_RotaryRpm) - end subroutine + ! subroutine Setup() + ! use CDataDisplayConsole + ! use ConfigurationVariables + ! implicit none + ! ! PumpsSpmChanges => Calc_KellyHoseVibrationRate + ! ! call data%EquipmentControl%DataDisplayConsole%OnRotaryRpmChange%Add(Set_RotaryRpm) + ! end subroutine diff --git a/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 index 8e334ab..7951eb1 100644 --- a/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CBucketEnum.f90 @@ -1,93 +1,74 @@ module CBucketEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains - - subroutine Evaluate_MudBucket() - use CStudentStationVariables!, only: StudentStation%MudBoxInstallation + subroutine Set_MudBucket(v) + use CManifolds, only: ToggleMudBox implicit none - - -! if (DriveType == TopDrive_DriveType) then -!#ifdef OST -! print*, 'Evaluate_MudBucket=TopDrive' -!#endif -! endif -! -! -! -! -! if (DriveType == Kelly_DriveType) then -!#ifdef OST -! print*, 'Evaluate_MudBucket=Kelly' -!#endif -! endif - - - if (Get_MudBucket() == MUD_BUCKET_INSTALL) then - StudentStation%MudBoxInstallation = .true. - else if (Get_MudBucket() == MUD_BUCKET_REMOVE) then - StudentStation%MudBoxInstallation = .false. + integer , intent(in) :: v +#ifdef ExcludeExtraChanges + if(MudBucket == v) return +#endif + MudBucket = v + if (MudBucket == MUD_BUCKET_INSTALL) then + call ToggleMudBox(.true.) + else if (MudBucket == MUD_BUCKET_REMOVE) then + call ToggleMudBox(.false.) endif - +#ifdef deb + print*, 'MudBucket=', MudBucket +#endif + call OnMudBucketChange%RunAll() end subroutine - ! subroutine Subscribe_MudBucket() - ! use CStudentStationVariables - ! implicit none - ! call OnMudBoxInstallationPress%Add(ButtonPress_MudBoxInstallation) - ! call OnMudBoxRemovePress%Add(ButtonPress_MudBoxRemove) - ! end subroutine - - subroutine ButtonPress_MudBoxInstallation() + integer function Get_MudBucket() implicit none + Get_MudBucket = MudBucket + end function + +! subroutine ButtonPress_MudBoxInstallation() +! implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then -#ifdef OST - print*, 'ButtonPress_MudBoxInstallation=TopDrive' -#endif - endif - if (Hoisting%DriveType == Kelly_DriveType) then -#ifdef OST - print*, 'ButtonPress_MudBoxInstallation=Kelly' -#endif + +! if (data%State%Hoisting%DriveType == TopDrive_DriveType) then +! #ifdef OST +! print*, 'ButtonPress_MudBoxInstallation=TopDrive' +! #endif +! endif +! if (data%State%Hoisting%DriveType == Kelly_DriveType) then +! #ifdef OST +! print*, 'ButtonPress_MudBoxInstallation=Kelly' +! #endif - call Set_MudBucket(MUD_BUCKET_INSTALL) +! call Set_MudBucket(MUD_BUCKET_INSTALL) - endif +! endif - end subroutine +! end subroutine - subroutine ButtonPress_MudBoxRemove() - implicit none - - - if (Hoisting%DriveType == TopDrive_DriveType) then -#ifdef OST - print*, 'ButtonPress_MudBoxRemove=TopDrive' -#endif - endif - if (Hoisting%DriveType == Kelly_DriveType) then -#ifdef OST - print*, 'ButtonPress_MudBoxRemove=Kelly' -#endif - - - call Set_MudBucket(MUD_BUCKET_REMOVE) +! subroutine ButtonPress_MudBoxRemove() +! implicit none + + +! if (data%State%Hoisting%DriveType == TopDrive_DriveType) then +! #ifdef OST +! print*, 'ButtonPress_MudBoxRemove=TopDrive' +! #endif +! endif +! if (data%State%Hoisting%DriveType == Kelly_DriveType) then +! #ifdef OST +! print*, 'ButtonPress_MudBoxRemove=Kelly' +! #endif +! call Set_MudBucket(MUD_BUCKET_REMOVE) - endif - - - +! endif - - - end subroutine +! end subroutine end module CBucketEnum \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CBucketEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CBucketEnumVariables.f90 deleted file mode 100644 index 503a176..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CBucketEnumVariables.f90 +++ /dev/null @@ -1,79 +0,0 @@ -module CBucketEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: MudBucket = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnMudBucketChange - - enum, bind(c) - !enumerator MUD_BUCKET_NEUTRAL - enumerator MUD_BUCKET_REMOVE - enumerator MUD_BUCKET_INSTALL - end enum - - private :: MudBucket - - contains - - subroutine Set_MudBucket(v) - use CManifolds, only: ToggleMudBox - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(MudBucket == v) return -#endif - MudBucket = v - if (MudBucket == MUD_BUCKET_INSTALL) then - call ToggleMudBox(.true.) - else if (MudBucket == MUD_BUCKET_REMOVE) then - call ToggleMudBox(.false.) - endif -#ifdef deb - print*, 'MudBucket=', MudBucket -#endif - call OnMudBucketChange%RunAll() - end subroutine - - integer function Get_MudBucket() - implicit none - Get_MudBucket = MudBucket - end function - - - - subroutine Set_MudBucket_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_MudBucket_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_MudBucket_WN' :: Set_MudBucket_WN - implicit none - integer , intent(in) :: v - call Set_MudBucket(v) - end subroutine - - integer function Get_MudBucket_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_MudBucket_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_MudBucket_WN' :: Get_MudBucket_WN - implicit none - Get_MudBucket_WN = MudBucket - end function - - - - - - logical function Get_RemoveMudBucket() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_RemoveMudBucket - !DEC$ ATTRIBUTES ALIAS: 'Get_RemoveMudBucket' :: Get_RemoveMudBucket - implicit none - Get_RemoveMudBucket = .false. ! MudBucket == REMOVE_MUD_BUCKET - end function - - logical function Get_InstallMudBucket() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_InstallMudBucket - !DEC$ ATTRIBUTES ALIAS: 'Get_InstallMudBucket' :: Get_InstallMudBucket - implicit none - Get_InstallMudBucket = .false. ! MudBucket == INSTALL_MUD_BUCKET - end function - -end module CBucketEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CElevatorEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CElevatorEnum.f90 index 7f7a0c0..4a70ff0 100644 --- a/CSharp/OperationScenarios/UnitySignals/CElevatorEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CElevatorEnum.f90 @@ -1,5 +1,5 @@ module CElevatorEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/UnitySignals/CElevatorEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CElevatorEnumVariables.f90 deleted file mode 100644 index 0ddaedb..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CElevatorEnumVariables.f90 +++ /dev/null @@ -1,220 +0,0 @@ -module CElevatorEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: Elevator = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnElevatorChange - - enum, bind(c) - enumerator ELEVATOR_NEUTRAL - - enumerator ELEVATOR_LATCH_STRING_BEGIN - enumerator ELEVATOR_LATCH_STRING_END - - enumerator ELEVATOR_UNLATCH_STRING_BEGIN - enumerator ELEVATOR_UNLATCH_STRING_END - - enumerator ELEVATOR_LATCH_STAND_BEGIN - enumerator ELEVATOR_LATCH_STAND_END - - enumerator ELEVATOR_UNLATCH_STAND_BEGIN - enumerator ELEVATOR_UNLATCH_STAND_END - - enumerator ELEVATOR_LATCH_SINGLE_BEGIN - enumerator ELEVATOR_LATCH_SINGLE_END - - enumerator ELEVATOR_UNLATCH_SINGLE_BEGIN - enumerator ELEVATOR_UNLATCH_SINGLE_END - end enum - - private :: Elevator - contains - - subroutine Set_Elevator(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(Elevator == v) return -#endif - Elevator = v -#ifdef deb - print*, 'Elevator=', Elevator -#endif - call OnElevatorChange%RunAll() - end subroutine - - integer function Get_Elevator() - implicit none - Get_Elevator = Elevator - end function - - - subroutine Set_Elevator_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_Elevator_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_Elevator_WN' :: Set_Elevator_WN - implicit none - integer , intent(in) :: v - call Set_Elevator(v) - end subroutine - - integer function Get_Elevator_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_Elevator_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_Elevator_WN' :: Get_Elevator_WN - implicit none - Get_Elevator_WN = Elevator - end function - - - - - - - - - - subroutine ElevatorLatchStringEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: ElevatorLatchStringEnd - !DEC$ ATTRIBUTES ALIAS: 'ElevatorLatchStringEnd' :: ElevatorLatchStringEnd - implicit none -#ifdef deb - print*, 'ElevatorLatchStringEnd' -#endif - !if(Elevator /= ELEVATOR_LATCH_STRING_END) Elevator = ELEVATOR_LATCH_STRING_END - call Set_Elevator(ELEVATOR_LATCH_STRING_END) - end subroutine - - - subroutine ElevatorUnLatchStringEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: ElevatorUnLatchStringEnd - !DEC$ ATTRIBUTES ALIAS: 'ElevatorUnLatchStringEnd' :: ElevatorUnLatchStringEnd - implicit none -#ifdef deb - print*, 'ElevatorUnLatchStringEnd' -#endif - !if(Elevator /= ELEVATOR_UNLATCH_STRING_END) Elevator = ELEVATOR_UNLATCH_STRING_END - call Set_Elevator(ELEVATOR_UNLATCH_STRING_END) - end subroutine - - - subroutine ElevatorLatchStandEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: ElevatorLatchStandEnd - !DEC$ ATTRIBUTES ALIAS: 'ElevatorLatchStandEnd' :: ElevatorLatchStandEnd - !use CCommon, only: SetStandRack - !use CStandRack - implicit none -#ifdef deb - print*, 'ElevatorLatchStandEnd' -#endif - !if(Elevator /= ELEVATOR_LATCH_STAND_END) then - ! Elevator = ELEVATOR_LATCH_STAND_END - ! !call SetStandRack(Get_StandRack() - 1) - !endif - call Set_Elevator(ELEVATOR_LATCH_STAND_END) - end subroutine - - subroutine ElevatorUnLatchStandEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: ElevatorUnLatchStandEnd - !DEC$ ATTRIBUTES ALIAS: 'ElevatorUnLatchStandEnd' :: ElevatorUnLatchStandEnd - !use CCommon, only: SetStandRack - !use CStandRack - implicit none -#ifdef deb - print*, 'ElevatorUnLatchStandEnd' -#endif - !if(Elevator /= ELEVATOR_UNLATCH_STAND_END) then - ! Elevator = ELEVATOR_UNLATCH_STAND_END - ! !call SetStandRack(Get_StandRack() + 1) - !endif - call Set_Elevator(ELEVATOR_UNLATCH_STAND_END) - end subroutine - - subroutine ElevatorLatchSingleEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: ElevatorLatchSingleEnd - !DEC$ ATTRIBUTES ALIAS: 'ElevatorLatchSingleEnd' :: ElevatorLatchSingleEnd - implicit none -#ifdef deb - print*, 'ElevatorLatchSingleEnd' -#endif - !if(Elevator /= ELEVATOR_LATCH_SINGLE_END) Elevator = ELEVATOR_LATCH_SINGLE_END - call Set_Elevator(ELEVATOR_LATCH_SINGLE_END) - end subroutine - - subroutine ElevatorUnLatchSingleEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: ElevatorUnLatchSingleEnd - !DEC$ ATTRIBUTES ALIAS: 'ElevatorUnLatchSingleEnd' :: ElevatorUnLatchSingleEnd - implicit none -#ifdef deb - print*, 'ElevatorUnLatchSingleEnd' -#endif - !if(Elevator /= ELEVATOR_UNLATCH_SINGLE_END) Elevator = ELEVATOR_UNLATCH_SINGLE_END - call Set_Elevator(ELEVATOR_UNLATCH_SINGLE_END) - end subroutine - - - - - - - - - - - - - - - - - - - - - - - - - logical function Get_EvelatorLatchString() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_EvelatorLatchString - !DEC$ ATTRIBUTES ALIAS: 'Get_EvelatorLatchString' :: Get_EvelatorLatchString - implicit none - Get_EvelatorLatchString = .false. ! Elevator == ELEVATOR_LATCH_STRING - end function - - logical function Get_EvelatorLatchStand() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_EvelatorLatchStand - !DEC$ ATTRIBUTES ALIAS: 'Get_EvelatorLatchStand' :: Get_EvelatorLatchStand - implicit none - Get_EvelatorLatchStand = .false. ! Elevator == ELEVATOR_LATCH_STAND - end function - - logical function Get_EvelatorLatchSingle() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_EvelatorLatchSingle - !DEC$ ATTRIBUTES ALIAS: 'Get_EvelatorLatchSingle' :: Get_EvelatorLatchSingle - implicit none - Get_EvelatorLatchSingle = .false. ! Elevator == ELEVATOR_LATCH_SINGLE - end function - - logical function Get_EvelatorUnlatchString() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_EvelatorUnlatchString - !DEC$ ATTRIBUTES ALIAS: 'Get_EvelatorUnlatchString' :: Get_EvelatorUnlatchString - implicit none - Get_EvelatorUnlatchString = .false. ! Elevator == ELEVATOR_UNLATCH_STRING - end function - - logical function Get_EvelatorUnlatchStand() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_EvelatorUnlatchStand - !DEC$ ATTRIBUTES ALIAS: 'Get_EvelatorUnlatchStand' :: Get_EvelatorUnlatchStand - implicit none - Get_EvelatorUnlatchStand = .false. ! Elevator == ELEVATOR_UNLATCH_STAND - end function - - logical function Get_EvelatorUnlatchSingle() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_EvelatorUnlatchSingle - !DEC$ ATTRIBUTES ALIAS: 'Get_EvelatorUnlatchSingle' :: Get_EvelatorUnlatchSingle - implicit none - Get_EvelatorUnlatchSingle = .false. ! Elevator == ELEVATOR_UNLATCH_SINGLE - end function - -end module CElevatorEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CFlowKellyDisconnectEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CFlowKellyDisconnectEnum.f90 index dee6e29..824aca2 100644 --- a/CSharp/OperationScenarios/UnitySignals/CFlowKellyDisconnectEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CFlowKellyDisconnectEnum.f90 @@ -1,5 +1,5 @@ module CFlowKellyDisconnectEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/UnitySignals/CFlowKellyDisconnectEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CFlowKellyDisconnectEnumVariables.f90 deleted file mode 100644 index 4805ad9..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CFlowKellyDisconnectEnumVariables.f90 +++ /dev/null @@ -1,60 +0,0 @@ -module CFlowKellyDisconnectEnumVariables - ! use CVoidEventHandlerCollection - implicit none -! integer :: FlowKellyDisconnect = 0 -! -! public -! -! ! type(VoidEventHandlerCollection) :: OnFlowKellyDisconnectChange -! -! enum, bind(c) -! enumerator FLOW_KELLY_DISCONNECT_NEUTRAL -! enumerator FLOW_KELLY_DISCONNECT_BEGIN -! enumerator FLOW_KELLY_DISCONNECT_END -! end enum -! -! private :: FlowKellyDisconnect -! -! contains -! -! subroutine Set_FlowKellyDisconnect(v) -! implicit none -! integer , intent(in) :: v -!#ifdef ExcludeExtraChanges -! if(FlowKellyDisconnect == v) return -!#endif -! FlowKellyDisconnect = v -!#ifdef deb -! print*, 'FlowKellyDisconnect=', FlowKellyDisconnect -!#endif -! call OnFlowKellyDisconnectChange%RunAll() -! end subroutine -! -! integer function Get_FlowKellyDisconnect2() -! implicit none -! Get_FlowKellyDisconnect2 = FlowKellyDisconnect -! end function - - - -! integer function Get_FlowKellyDisconnect_deprecated() -! !DEC$ ATTRIBUTES DLLEXPORT :: Get_FlowKellyDisconnect_deprecated -! !DEC$ ATTRIBUTES ALIAS: 'Get_FlowKellyDisconnect_deprecated' :: Get_FlowKellyDisconnect_deprecated -! implicit none -! !Get_FlowKellyDisconnect_WN = FlowKellyDisconnect -! end function -! -! -! subroutine FlowKellyDisconnectEnd() -! !DEC$ ATTRIBUTES DLLEXPORT :: FlowKellyDisconnectEnd -! !DEC$ ATTRIBUTES ALIAS: 'FlowKellyDisconnectEnd' :: FlowKellyDisconnectEnd -! implicit none -! call Set_FlowKellyDisconnect(FLOW_KELLY_DISCONNECT_END) -!#ifdef deb -! print*, 'FLOW_KELLY_DISCONNECT_END' -!#endif -! end subroutine - - - -end module CFlowKellyDisconnectEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CFlowPipeDisconnectEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CFlowPipeDisconnectEnum.f90 index 95c8572..fb5adea 100644 --- a/CSharp/OperationScenarios/UnitySignals/CFlowPipeDisconnectEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CFlowPipeDisconnectEnum.f90 @@ -1,5 +1,5 @@ module CFlowPipeDisconnectEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/UnitySignals/CFlowPipeDisconnectEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CFlowPipeDisconnectEnumVariables.f90 deleted file mode 100644 index 45ed9ef..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CFlowPipeDisconnectEnumVariables.f90 +++ /dev/null @@ -1,70 +0,0 @@ -module CFlowPipeDisconnectEnumVariables - ! use CVoidEventHandlerCollection - implicit none -! integer :: FlowPipeDisconnect = 0 -! -! public -! -! ! type(VoidEventHandlerCollection) :: OnFlowPipeDisconnectChange -! -! enum, bind(c) -! enumerator FLOW_PIPE_DISCONNECT_NEUTRAL -! enumerator FLOW_PIPE_DISCONNECT_BEGIN -! enumerator FLOW_PIPE_DISCONNECT_END -! end enum -! -! private :: FlowPipeDisconnect -! -! contains -! -! subroutine Set_FlowPipeDisconnect(v) -! implicit none -! integer , intent(in) :: v -!#ifdef ExcludeExtraChanges -! if(FlowPipeDisconnect == v) return -!#endif -! FlowPipeDisconnect = v -!#ifdef deb -! print*, 'FlowPipeDisconnect=', FlowPipeDisconnect -!#endif -! call OnFlowPipeDisconnectChange%RunAll() -! end subroutine -! -! integer function Get_FlowPipeDisconnect2() -! implicit none -! Get_FlowPipeDisconnect2 = FlowPipeDisconnect -! end function - - - -! subroutine Set_FlowPipeDisconnect_deprecated(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: Set_FlowPipeDisconnect_deprecated -! !DEC$ ATTRIBUTES ALIAS: 'Set_FlowPipeDisconnect_deprecated' :: Set_FlowPipeDisconnect_deprecated -! implicit none -! integer , intent(in) :: v -! call Set_FlowPipeDisconnect(v) -! end subroutine -! -! -! integer function Get_FlowPipeDisconnect_deprecated() -! !DEC$ ATTRIBUTES DLLEXPORT :: Get_FlowPipeDisconnect_deprecated -! !DEC$ ATTRIBUTES ALIAS: 'Get_FlowPipeDisconnect_deprecated' :: Get_FlowPipeDisconnect_deprecated -! implicit none -! Get_FlowPipeDisconnect_WN = FlowPipeDisconnect -! end function -! -! -! -! subroutine FlowPipeDisconnectEnd() -! !DEC$ ATTRIBUTES DLLEXPORT :: FlowPipeDisconnectEnd -! !DEC$ ATTRIBUTES ALIAS: 'FlowPipeDisconnectEnd' :: FlowPipeDisconnectEnd -! implicit none -! call Set_FlowPipeDisconnect(FLOW_PIPE_DISCONNECT_END) -!#ifdef deb -! print*, 'FLOW_PIPE_DISCONNECT_END' -!#endif -! end subroutine - - - -end module CFlowPipeDisconnectEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 index 8360f24..0bc177f 100644 --- a/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CHeadEnum.f90 @@ -1,14 +1,44 @@ module CHeadEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none + ! enum, bind(c) + ! enumerator FILLUP_HEAD_REMOVE + ! enumerator FILLUP_HEAD_INSTALL + ! end enum contains + subroutine Set_FillupHead(v) + use CManifolds, only: ToggleFillupHead + implicit none + integer , intent(in) :: v +#ifdef ExcludeExtraChanges + if(data%State%unitySignals%FillupHead == v) return +#endif + data%State%unitySignals%FillupHead = v + + if (data%State%unitySignals%FillupHead == FILLUP_HEAD_INSTALL) then + call ToggleFillupHead(.true.) + else if (data%State%unitySignals%FillupHead == FILLUP_HEAD_REMOVE) then + call ToggleFillupHead(.false.) + endif + +#ifdef deb + print*, 'data%State%unitySignals%FillupHead=', data%State%unitySignals%FillupHead +#endif + call OnFillupHeadChange%RunAll() + end subroutine + + integer function Get_FillupHead() + implicit none + Get_FillupHead = FillupHead + end function + subroutine Evaluate_FillupHead() - use CStudentStationVariables!, only: StudentStation%FillupHeadInstallation + use CStudentStationVariables!, only: data%State%StudentStation%FillupHeadInstallation implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_FillupHead=TopDrive' #endif @@ -19,7 +49,7 @@ module CHeadEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_FillupHead=Kelly' #endif @@ -27,9 +57,9 @@ module CHeadEnum if (Get_FillupHead() == FILLUP_HEAD_INSTALL) then - StudentStation%FillupHeadInstallation = .true. + data%State%StudentStation%FillupHeadInstallation = .true. else if (Get_FillupHead() == FILLUP_HEAD_REMOVE) then - StudentStation%FillupHeadInstallation = .false. + data%State%StudentStation%FillupHeadInstallation = .false. endif end subroutine @@ -37,7 +67,7 @@ module CHeadEnum ! subroutine Subscribe_FillupHead() ! use CStudentStationVariables ! implicit none - ! call OnStudentStation%FillupHeadInstallationPress%Add(ButtonPress_StudentStation%FillupHeadInstallation) + ! call OnState%StudentStation%FillupHeadInstallationPress%Add(ButtonPress_State%StudentStation%FillupHeadInstallation) ! call OnFillupHeadRemovePress%Add(ButtonPress_FillupHeadRemove) ! end subroutine @@ -48,9 +78,9 @@ module CHeadEnum - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST - print*, 'ButtonPress_StudentStation%FillupHeadInstallation=TopDrive' + print*, 'ButtonPress_State%StudentStation%FillupHeadInstallation=TopDrive' #endif @@ -70,9 +100,9 @@ module CHeadEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST - print*, 'ButtonPress_StudentStation%FillupHeadInstallation=Kelly' + print*, 'ButtonPress_State%StudentStation%FillupHeadInstallation=Kelly' #endif @@ -102,7 +132,7 @@ module CHeadEnum - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_FillupHeadRemove=TopDrive' #endif @@ -123,7 +153,7 @@ module CHeadEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_FillupHeadRemove=Kelly' #endif diff --git a/CSharp/OperationScenarios/UnitySignals/CHeadEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CHeadEnumVariables.f90 deleted file mode 100644 index d39d9d1..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CHeadEnumVariables.f90 +++ /dev/null @@ -1,90 +0,0 @@ -module CHeadEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: FillupHead = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnFillupHeadChange - - enum, bind(c) - !enumerator FILLUP_HEAD_NEUTRAL - enumerator FILLUP_HEAD_REMOVE - enumerator FILLUP_HEAD_INSTALL - end enum - - private :: FillupHead - - contains - - subroutine Set_FillupHead(v) - use CManifolds, only: ToggleFillupHead - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(FillupHead == v) return -#endif - FillupHead = v - - if (FillupHead == FILLUP_HEAD_INSTALL) then - call ToggleFillupHead(.true.) - else if (FillupHead == FILLUP_HEAD_REMOVE) then - call ToggleFillupHead(.false.) - endif - -#ifdef deb - print*, 'FillupHead=', FillupHead -#endif - call OnFillupHeadChange%RunAll() - end subroutine - - integer function Get_FillupHead() - implicit none - Get_FillupHead = FillupHead - end function - - - - - subroutine Set_FillupHead_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_FillupHead_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_FillupHead_WN' :: Set_FillupHead_WN - implicit none - integer , intent(in) :: v - call Set_FillupHead(v) - end subroutine - - integer function Get_FillupHead_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_FillupHead_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_FillupHead_WN' :: Get_FillupHead_WN - implicit none - Get_FillupHead_WN = FillupHead - end function - - - - - - - - - - - - - - logical function Get_RemoveFillupHead() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_RemoveFillupHead - !DEC$ ATTRIBUTES ALIAS: 'Get_RemoveFillupHead' :: Get_RemoveFillupHead - implicit none - Get_RemoveFillupHead = .false. ! FillupHead == REMOVE_FILLUP_HEAD - end function - - logical function Get_InstallFillupHead() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_InstallFillupHead - !DEC$ ATTRIBUTES ALIAS: 'Get_InstallFillupHead' :: Get_InstallFillupHead - implicit none - Get_InstallFillupHead = .false. ! FillupHead == INSTALL_FILLUP_HEAD - end function - -end module CHeadEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CIbopEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CIbopEnum.f90 index 8962f07..397aebd 100644 --- a/CSharp/OperationScenarios/UnitySignals/CIbopEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CIbopEnum.f90 @@ -1,5 +1,5 @@ module CIbopEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/UnitySignals/CIbopEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CIbopEnumVariables.f90 deleted file mode 100644 index ac189fd..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CIbopEnumVariables.f90 +++ /dev/null @@ -1,85 +0,0 @@ -module CIbopEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: Ibop = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnIbopChange - - enum, bind(c) - !enumerator IBOP_NEUTRAL - enumerator IBOP_REMOVE - enumerator IBOP_INSTALL - end enum - - private :: Ibop - - contains - - subroutine Set_Ibop(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(Ibop == v) return -#endif - Ibop = v -#ifdef deb - print*, 'Ibop=', Ibop -#endif - call OnIbopChange%RunAll() - end subroutine - - integer function Get_Ibop() - implicit none - Get_Ibop = Ibop - end function - - - - - subroutine Set_Ibop_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_Ibop_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_Ibop_WN' :: Set_Ibop_WN - implicit none - integer , intent(in) :: v - call Set_Ibop(v) - end subroutine - - integer function Get_Ibop_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_Ibop_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_Ibop_WN' :: Get_Ibop_WN - implicit none - Get_Ibop_WN = Ibop - end function - - - - subroutine Set_Ibop_Install() - implicit none - call Set_Ibop(IBOP_INSTALL) - end subroutine - - subroutine Set_Ibop_Remove() - implicit none - call Set_Ibop(IBOP_REMOVE) - end subroutine - - - - - logical function Get_RemoveIbop() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_RemoveIbop - !DEC$ ATTRIBUTES ALIAS: 'Get_RemoveIbop' :: Get_RemoveIbop - implicit none - Get_RemoveIBop = .false. ! Ibop == REMOVE_IBOP - end function - - logical function Get_InstallIbop() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_InstallIbop - !DEC$ ATTRIBUTES ALIAS: 'Get_InstallIbop' :: Get_InstallIbop - implicit none - Get_InstallIbop = .false. ! Ibop == INSTALL_IBOP - end function - -end module CIbopEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CKellyEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CKellyEnum.f90 index b348d7b..1c5b612 100644 --- a/CSharp/OperationScenarios/UnitySignals/CKellyEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CKellyEnum.f90 @@ -1,10 +1,10 @@ module CKellyEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains subroutine Evaluate_Kelly() - !use COperationConditionEnum + !use UnitySignalsModule implicit none diff --git a/CSharp/OperationScenarios/UnitySignals/CKellyEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CKellyEnumVariables.f90 deleted file mode 100644 index b50b2e3..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CKellyEnumVariables.f90 +++ /dev/null @@ -1,79 +0,0 @@ -module CKellyEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: Kelly = 0 - integer :: Kelly_S = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnKellyChange - - enum, bind(c) - enumerator KELLY_NEUTRAL - enumerator KELLY_INSTALL - enumerator KELLY_REMOVE - end enum - - private :: Kelly - - contains - - subroutine Set_Kelly(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(Kelly == v) return -#endif - Kelly = v -#ifdef deb - print*, 'Kelly=', Kelly -#endif - call OnKellyChange%RunAll() - end subroutine - - integer function Get_Kelly() - implicit none - Get_Kelly = Kelly - end function - - - - - subroutine Set_Kelly_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_Kelly_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_Kelly_WN' :: Set_Kelly_WN - implicit none - integer , intent(in) :: v - !call Set_Kelly(v) - Kelly_S = v - end subroutine - - integer function Get_Kelly_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_Kelly_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_Kelly_WN' :: Get_Kelly_WN - implicit none - Get_Kelly_WN = Kelly - end function - - - - - - - - - logical function Get_KellyBack() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_KellyBack - !DEC$ ATTRIBUTES ALIAS: 'Get_KellyBack' :: Get_KellyBack - implicit none - Get_KellyBack = .false. ! Kelly == KELLY_BACK - end function - - logical function Get_InstallKelly() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_InstallKelly - !DEC$ ATTRIBUTES ALIAS: 'Get_InstallKelly' :: Get_InstallKelly - implicit none - Get_InstallKelly = .false. ! Kelly == INSTALL_KELLY - end function - -end module CKellyEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CMouseHoleEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CMouseHoleEnum.f90 index 24d85f5..27b2584 100644 --- a/CSharp/OperationScenarios/UnitySignals/CMouseHoleEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CMouseHoleEnum.f90 @@ -1,5 +1,5 @@ module CMouseHoleEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -27,6 +27,8 @@ module CMouseHoleEnum subroutine Subscribe_MouseHole() !use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables implicit none !call OnFillMouseHolePress%Add(ButtonPress_MouseHole) end subroutine diff --git a/CSharp/OperationScenarios/UnitySignals/CMouseHoleEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CMouseHoleEnumVariables.f90 deleted file mode 100644 index 0763680..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CMouseHoleEnumVariables.f90 +++ /dev/null @@ -1,83 +0,0 @@ -module CMouseHoleEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: MouseHole = 0 - integer :: MouseHole_S = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnMouseHoleChange - - enum, bind(c) - enumerator MOUSE_HOLE_NEUTRAL - enumerator MOUSE_HOLE_FILL - enumerator MOUSE_HOLE_EMPTY - end enum - - private :: MouseHole - - contains - - subroutine Set_MouseHole(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(MouseHole == v) return -#endif - !call sleep(2) - MouseHole = v -#ifdef deb - print*, 'MouseHole=', MouseHole -#endif - call OnMouseHoleChange%RunAll() - end subroutine - - integer function Get_MouseHole() - implicit none - Get_MouseHole = MouseHole - end function - - - subroutine Update_MouseHole_From_Snapshot() - implicit none - call Set_MouseHole(MouseHole_S) - end subroutine - - subroutine Set_MouseHole_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_MouseHole_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_MouseHole_WN' :: Set_MouseHole_WN - implicit none - integer , intent(in) :: v - !call Set_MouseHole(v) - MouseHole_S = v - end subroutine - - integer function Get_MouseHole_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_MouseHole_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_MouseHole_WN' :: Get_MouseHole_WN - implicit none - Get_MouseHole_WN = MouseHole - end function - - - - - - - - - logical function Get_EmptyMouseHole() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_EmptyMouseHole - !DEC$ ATTRIBUTES ALIAS: 'Get_EmptyMouseHole' :: Get_EmptyMouseHole - implicit none - Get_EmptyMouseHole = .false. ! MouseHole == EMPTY_MOUSE_HOLE - end function - - logical function Get_FillMouseHole() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_FillMouseHole - !DEC$ ATTRIBUTES ALIAS: 'Get_FillMouseHole' :: Get_FillMouseHole - implicit none - Get_FillMouseHole = .false. ! MouseHole == FILL_MOUSE_HOLE - end function - -end module CMouseHoleEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/COperationConditionEnum.f90 b/CSharp/OperationScenarios/UnitySignals/COperationConditionEnum.f90 index bcd8d94..9524c70 100644 --- a/CSharp/OperationScenarios/UnitySignals/COperationConditionEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/COperationConditionEnum.f90 @@ -1,9 +1,38 @@ module COperationConditionEnum use CLog4 - use COperationScenariosVariables + use OperationScenariosModule + use ConfigurationVariables implicit none + ! enum, bind(c) + ! enumerator OPERATION_DRILL + ! enumerator OPERATION_TRIP + ! end enum + contains + subroutine Set_OperationCondition(v) + ! use CKellyEnumVariables + implicit none + integer , intent(in) :: v +#ifdef ExcludeExtraChanges + if(data%State%unitySignals%OperationCondition == v) return +#endif + data%State%unitySignals%OperationCondition = v +#ifdef deb + print*, 'data%State%unitySignals%OperationCondition=', data%State%unitySignals%OperationCondition +#endif + ! call OnOperationConditionChange%RunAll() + ! call OnOperationConditionChangeInt%RunAll(data%State%unitySignals%OperationCondition) + end subroutine + + integer function Get_OperationCondition() + implicit none + Get_OperationCondition = data%State%unitySignals%OperationCondition + end function + + + + subroutine Evaluate_OperationCondition() implicit none @@ -30,18 +59,22 @@ module COperationConditionEnum ! subroutine Subscribe_OperationCondition() ! use CDrillingConsoleVariables +!@ use ConfigurationVariables +!@ use ConfigurationVariables ! implicit none ! call OnLatchPipePress%Add(ButtonPress_Latch_OperationCondition) ! call OnUnlatchPipePress%Add(ButtonPress_Unlatch_OperationCondition) ! end subroutine subroutine ButtonPress_Latch_OperationCondition() - use CHoistingVariables!, only: Hoisting%DriveType, Kelly_DriveType + ! use ConfigurationVariables + use CHoistingVariables + use ConfigurationVariables!, only: data%State%Hoisting%DriveType, Kelly_DriveType use CManifolds, only: InstallKellyCock implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Latch_OperationCondition=TopDrive' #endif @@ -54,7 +87,7 @@ module COperationConditionEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Latch_OperationCondition=Kelly' #endif @@ -71,7 +104,7 @@ module COperationConditionEnum call Set_LatchLed(.false.) call Set_UnlatchLed(.true.) call Set_Kelly(KELLY_INSTALL) - if(Hoisting%DriveType == Kelly_DriveType) then + if(data%State%Hoisting%DriveType == Kelly_DriveType) then call InstallKellyCock() !drill mode endif return @@ -90,11 +123,12 @@ module COperationConditionEnum end subroutine subroutine ButtonPress_Unlatch_OperationCondition() - use CHoistingVariables!, only: Hoisting%DriveType, Kelly_DriveType + use CHoistingVariables + use ConfigurationVariables!, only: data%State%Hoisting%DriveType, Kelly_DriveType use CManifolds, only: RemoveKellyCock implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Unlatch_OperationCondition=TopDrive' #endif @@ -107,7 +141,7 @@ module COperationConditionEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Unlatch_OperationConditions=Kelly' #endif @@ -127,7 +161,7 @@ module COperationConditionEnum call Set_LatchLed(.true.) call Set_UnlatchLed(.false.) call Set_IrSafetyValveLed(.false.) - if(Hoisting%DriveType == Kelly_DriveType) then ! top drive mode + if(data%State%Hoisting%DriveType == Kelly_DriveType) then ! top drive mode call RemoveKellyCock() !trip mode endif return diff --git a/CSharp/OperationScenarios/UnitySignals/COperationConditionEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/COperationConditionEnumVariables.f90 deleted file mode 100644 index 87c1d68..0000000 --- a/CSharp/OperationScenarios/UnitySignals/COperationConditionEnumVariables.f90 +++ /dev/null @@ -1,81 +0,0 @@ -module COperationConditionEnumVariables - use CIntegerEventHandlerCollection - ! use CVoidEventHandlerCollection - implicit none - integer :: OperationCondition = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnOperationConditionChange - !**type(IntegerEventHandlerCollection) :: OnOperationConditionChangeInt - - enum, bind(c) - enumerator OPERATION_DRILL - enumerator OPERATION_TRIP - end enum - - private :: OperationCondition - - contains - - subroutine Set_OperationCondition(v) - use CKellyEnumVariables - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(OperationCondition == v) return -#endif - OperationCondition = v -#ifdef deb - print*, 'OperationCondition=', OperationCondition -#endif - call OnOperationConditionChange%RunAll() - call OnOperationConditionChangeInt%RunAll(OperationCondition) - end subroutine - - integer function Get_OperationCondition() - implicit none - Get_OperationCondition = OperationCondition - end function - - - subroutine Set_OperationCondition_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_OperationCondition_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_OperationCondition_WN' :: Set_OperationCondition_WN - implicit none - integer , intent(in) :: v - call Set_OperationCondition(v) - end subroutine - - integer function Get_OperationCondition_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_OperationCondition_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_OperationCondition_WN' :: Get_OperationCondition_WN - implicit none - Get_OperationCondition_WN = OperationCondition - end function - - - - - - - - - - - - logical function Get_DrillCondition() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_DrillCondition - !DEC$ ATTRIBUTES ALIAS: 'Get_DrillCondition' :: Get_DrillCondition - implicit none - Get_DrillCondition = OperationCondition == OPERATION_DRILL - end function - - logical function Get_TripCondition() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TripCondition - !DEC$ ATTRIBUTES ALIAS: 'Get_TripCondition' :: Get_TripCondition - implicit none - Get_TripCondition = OperationCondition == OPERATION_TRIP - end function - -end module COperationConditionEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CSafetyValveEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CSafetyValveEnum.f90 index a260d0b..a267773 100644 --- a/CSharp/OperationScenarios/UnitySignals/CSafetyValveEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CSafetyValveEnum.f90 @@ -1,5 +1,5 @@ module CSafetyValveEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains diff --git a/CSharp/OperationScenarios/UnitySignals/CSafetyValveEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CSafetyValveEnumVariables.f90 deleted file mode 100644 index fd89f0c..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CSafetyValveEnumVariables.f90 +++ /dev/null @@ -1,101 +0,0 @@ -module CSafetyValveEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: SafetyValve = 0 - integer :: operation = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnSafetyValveChange - - enum, bind(c) - enumerator SAFETY_VALVE_NEUTRAL - enumerator SAFETY_VALVE_REMOVE - enumerator SAFETY_VALVE_INSTALL - end enum - - private :: SafetyValve - - contains - - subroutine Set_Operation(i) - implicit none - integer, intent (in) :: i - operation = i - end subroutine - - subroutine Set_SafetyValve(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(SafetyValve == v) return -#endif - SafetyValve = v -#ifdef deb - if(SafetyValve == SAFETY_VALVE_NEUTRAL) then - print*, 'SafetyValve=SAFETY_VALVE_NEUTRAL' - else if (SafetyValve == SAFETY_VALVE_INSTALL) then - print*, 'SafetyValve=SAFETY_VALVE_INSTALL' - else if (SafetyValve == SAFETY_VALVE_INSTALL) then - print*, 'SafetyValve=SAFETY_VALVE_REMOVE' - endif -#endif - call OnSafetyValveChange%RunAll() - end subroutine - - integer function Get_SafetyValve() - implicit none - Get_SafetyValve = SafetyValve - end function - - - - - subroutine Set_SafetyValve_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_SafetyValve_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_SafetyValve_WN' :: Set_SafetyValve_WN - implicit none - integer , intent(in) :: v - call Set_SafetyValve(v) - end subroutine - - integer function Get_SafetyValve_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_SafetyValve_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_SafetyValve_WN' :: Get_SafetyValve_WN - implicit none - Get_SafetyValve_WN = SafetyValve - end function - - - - - - subroutine Set_SafetyValve_Install() - implicit none - call Set_SafetyValve(SAFETY_VALVE_INSTALL) - end subroutine - - subroutine Set_SafetyValve_Remove() - implicit none - call Set_SafetyValve(SAFETY_VALVE_REMOVE) - end subroutine - - - - - - logical function Get_RemoveSafetyValve() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_RemoveSafetyValve - !DEC$ ATTRIBUTES ALIAS: 'Get_RemoveSafetyValve' :: Get_RemoveSafetyValve - implicit none - Get_RemoveSafetyValve = .false. ! SafetyValve == REMOVE_SAFETY_VALVE - end function - - logical function Get_InstallSafetyValve() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_InstallSafetyValve - !DEC$ ATTRIBUTES ALIAS: 'Get_InstallSafetyValve' :: Get_InstallSafetyValve - implicit none - Get_InstallSafetyValve = .false. ! SafetyValve == INSTALL_SAFETY_VALVE - end function - -end module CSafetyValveEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CSlipsEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CSlipsEnum.f90 index 7c2d8cd..d0f8a3f 100644 --- a/CSharp/OperationScenarios/UnitySignals/CSlipsEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CSlipsEnum.f90 @@ -1,5 +1,5 @@ module CSlipsEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -29,6 +29,8 @@ module CSlipsEnum ! subroutine Subscribe_Slips() ! use CDrillingConsoleVariables + ! use ConfigurationVariables + ! use ConfigurationVariables ! implicit none ! !call Set_Slips(SLIPS_SET) @@ -37,13 +39,17 @@ module CSlipsEnum ! end subroutine subroutine ButtonPress_Slips() + use UnitySignalsModule + use NotificationModule + use CUnityOutputs + use UnitySignalsModule !for CTdsConnectionModesEnum implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Slips=TopDrive' #endif @@ -96,7 +102,7 @@ module CSlipsEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Slips=Kelly' #endif diff --git a/CSharp/OperationScenarios/UnitySignals/CSlipsEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CSlipsEnumVariables.f90 index 9af122e..dd90735 100644 --- a/CSharp/OperationScenarios/UnitySignals/CSlipsEnumVariables.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CSlipsEnumVariables.f90 @@ -37,72 +37,4 @@ module CSlipsEnumVariables implicit none Get_Slips = Slips end function - - - - subroutine Set_Slips_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_Slips_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_Slips_WN' :: Set_Slips_WN - implicit none - integer , intent(in) :: v - !call Set_Slips(v) - Slips_S = v - end subroutine - - integer function Get_Slips_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_Slips_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_Slips_WN' :: Get_Slips_WN - implicit none - Get_Slips_WN = Slips - end function - - - - subroutine SlipsSetEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: SlipsSetEnd - !DEC$ ATTRIBUTES ALIAS: 'SlipsSetEnd' :: SlipsSetEnd - implicit none - !if(Slips /= SLIPS_SET_END) Slips = SLIPS_SET_END - call Set_Slips(SLIPS_SET_END) -#ifdef deb - print*, 'SlipsSetEnd' -#endif - end subroutine - - subroutine SlipsUnsetEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: SlipsUnsetEnd - !DEC$ ATTRIBUTES ALIAS: 'SlipsUnsetEnd' :: SlipsUnsetEnd - implicit none - !if(Slips /= SLIPS_UNSET_END) Slips = SLIPS_UNSET_END - call Set_Slips(SLIPS_UNSET_END) -#ifdef deb - print*, 'SlipsUnsetEnd' -#endif - end subroutine - - - - - - - - - - - - - logical function Get_SlipsUnset() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_SlipsUnset - !DEC$ ATTRIBUTES ALIAS: 'Get_SlipsUnset' :: Get_SlipsUnset - implicit none - Get_SlipsUnset = .false. ! Slips == SLIPS_UNSET - end function - - logical function Get_SlipsSet() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_SlipsSet - !DEC$ ATTRIBUTES ALIAS: 'Get_SlipsSet' :: Get_SlipsSet - implicit none - Get_SlipsSet = .false. ! Slips == SLIPS_SET - end function - end module CSlipsEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CSwingEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CSwingEnum.f90 index f5d80ac..1272f4c 100644 --- a/CSharp/OperationScenarios/UnitySignals/CSwingEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CSwingEnum.f90 @@ -1,5 +1,5 @@ module CSwingEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -30,6 +30,8 @@ module CSwingEnum ! subroutine Subscribe_Swing() ! use CDrillingConsoleVariables + ! use ConfigurationVariables + ! use ConfigurationVariables ! implicit none ! call OnSwingPress%Add(ButtonPress_Swing) ! end subroutine @@ -40,7 +42,7 @@ module CSwingEnum - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Swing=TopDrive' #endif @@ -54,7 +56,7 @@ module CSwingEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Swing=Kelly' #endif @@ -70,7 +72,7 @@ module CSwingEnum !OPERATION-CODE=26 if (Get_OperationCondition() == OPERATION_DRILL .and.& - Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%PL) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and.& Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.& Get_Swing() == SWING_WELL_END .and.& Get_SwingLed() .and.& @@ -85,7 +87,7 @@ module CSwingEnum !OPERATION-CODE=27 if (Get_OperationCondition() == OPERATION_DRILL .and.& - Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%PL) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and.& Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.& Get_Swing() == SWING_MOUSE_HOLE_END .and.& Get_SwingLed()) then @@ -99,7 +101,7 @@ module CSwingEnum !OPERATION-CODE=28 if (Get_OperationCondition() == OPERATION_DRILL .and.& - Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection()) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and.& Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.& Get_Swing() == SWING_WELL_END .and.& Get_SwingLed()) then @@ -112,7 +114,7 @@ module CSwingEnum !OPERATION-CODE=29 if (Get_OperationCondition() == OPERATION_DRILL .and.& - Get_HookHeight() >= (OperationScenario%HKL + OperationScenario%SG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HKL + data%State%OperationScenario%SG) .and.& Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.& Get_Swing() == SWING_MOUSE_HOLE_END .and.& Get_SwingLed()) then @@ -124,7 +126,7 @@ module CSwingEnum !OPERATION-CODE=30 if (Get_OperationCondition() == OPERATION_DRILL .and.& - Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection()) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and.& Get_Swing() == SWING_RAT_HOLE_END .and.& Get_SwingLed()) then @@ -136,7 +138,7 @@ module CSwingEnum !OPERATION-CODE=31 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection()) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection()) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.& Get_Swing() == SWING_WELL_END .and.& Get_SwingLed()) then @@ -163,7 +165,7 @@ module CSwingEnum !OPERATION-CODE=33 if (Get_OperationCondition() == OPERATION_TRIP .and.& - (Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection()) .and. Get_HookHeight() <= 27.41) .and.& + (Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection()) .and. Get_HookHeight() <= 27.41) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.& Get_Swing() == SWING_MOUSE_HOLE_END .and.&!Get_Swing() == SWING_MOUSE_HOLE_END .and.&!Get_Swing() /= SWING_WELL_END Get_SwingLed()) then @@ -176,7 +178,7 @@ module CSwingEnum !OPERATION-CODE=34 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL - OperationScenario%ECG) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.& Get_Swing() == SWING_WELL_END .and.& Get_SwingLed()) then @@ -191,7 +193,7 @@ module CSwingEnum !OPERATION-CODE=35 if (Get_OperationCondition() == OPERATION_TRIP .and.& - Get_HookHeight() >= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL - OperationScenario%ECG + OperationScenario%RE) .and.& + Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + data%State%OperationScenario%RE) .and.& Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.& Get_Swing() == SWING_MOUSE_HOLE_END .and.& Get_SwingLed()) then diff --git a/CSharp/OperationScenarios/UnitySignals/CSwingEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CSwingEnumVariables.f90 deleted file mode 100644 index 548fb34..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CSwingEnumVariables.f90 +++ /dev/null @@ -1,135 +0,0 @@ -module CSwingEnumVariables - ! use CVoidEventHandlerCollection - use CLog4 - implicit none - integer :: Swing = 0 - integer :: Swing_S = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnSwingChange - - enum, bind(c) - enumerator SWING_NEUTRAL - enumerator SWING_MOUSE_HOLE_BEGIN - enumerator SWING_MOUSE_HOLE_END - enumerator SWING_RAT_HOLE_BEGIN - enumerator SWING_RAT_HOLE_END - enumerator SWING_WELL_BEGIN - enumerator SWING_WELL_END - end enum - - private :: Swing - - contains - - subroutine Set_Swing(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(Swing == v) return -#endif - Swing = v -#ifdef deb - print*, 'Swing=', Swing -#endif - call OnSwingChange%RunAll() - end subroutine - - integer function Get_Swing() - implicit none - Get_Swing = Swing - end function - - - subroutine Set_Swing_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_Swing_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_Swing_WN' :: Set_Swing_WN - implicit none - integer , intent(in) :: v - !call Set_Swing(v) - Swing_S = v - end subroutine - - integer function Get_Swing_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_Swing_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_Swing_WN' :: Get_Swing_WN - implicit none - Get_Swing_WN = Swing - end function - - - - - - - - subroutine SwingMouseHoleEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: SwingMouseHoleEnd - !DEC$ ATTRIBUTES ALIAS: 'SwingMouseHoleEnd' :: SwingMouseHoleEnd - implicit none - !if(Swing /= SWING_MOUSE_HOLE_END) Swing = SWING_MOUSE_HOLE_END - call Set_Swing(SWING_MOUSE_HOLE_END) -#ifdef deb - print*, 'SWING_MOUSE_HOLE_END' -#endif - end subroutine - - - subroutine SwingRatHoleEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: SwingRatHoleEnd - !DEC$ ATTRIBUTES ALIAS: 'SwingRatHoleEnd' :: SwingRatHoleEnd - implicit none - !if(Swing /= SWING_RAT_HOLE_END) Swing = SWING_RAT_HOLE_END - call Set_Swing(SWING_RAT_HOLE_END) -#ifdef deb - print*, 'SWING_RAT_HOLE_END' -#endif - end subroutine - - - subroutine SwingWellEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: SwingWellEnd - !DEC$ ATTRIBUTES ALIAS: 'SwingWellEnd' :: SwingWellEnd - implicit none - !if(Swing /= SWING_WELL_END) Swing = SWING_WELL_END - call Set_Swing(SWING_WELL_END) -#ifdef deb - print*, 'SWING_WELL_END' -#endif - end subroutine - - - - - - - - - - - - - - logical function Get_SwingMouseHole() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_SwingMouseHole - !DEC$ ATTRIBUTES ALIAS: 'Get_SwingMouseHole' :: Get_SwingMouseHole - implicit none - Get_SwingMouseHole = .false. ! Swing == SWING_MOUSE_HOLE - end function - - logical function Get_SwingRatHole() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_SwingRatHole - !DEC$ ATTRIBUTES ALIAS: 'Get_SwingRatHole' :: Get_SwingRatHole - implicit none - Get_SwingRatHole = .false. ! Swing == SWING_RAT_HOLE - end function - - logical function Get_SwingWell() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_SwingWell - !DEC$ ATTRIBUTES ALIAS: 'Get_SwingWell' :: Get_SwingWell - implicit none - Get_SwingWell = .false. ! Swing == SWING_WELL - end function - -end module CSwingEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsBackupClamp.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsBackupClamp.f90 index 9549c88..886adcd 100644 --- a/CSharp/OperationScenarios/UnitySignals/CTdsBackupClamp.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CTdsBackupClamp.f90 @@ -1,20 +1,20 @@ module CTdsBackupClamp - use COperationScenariosVariables + use OperationScenariosModule implicit none contains subroutine Evaluate_TdsBackupClamp() implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_TdsBackupClamp=TopDrive' #endif !TOPDRIVE-CODE=79 if(Get_TdsBackupClamp() == BACKUP_CLAMP_OFF_END .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF .and.& - TopDrivePanel%TopDriveTorqueWrench) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF .and.& + data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrench) then call Set_TdsBackupClamp(BACKUP_CLAMP_FW_BEGIN) @@ -23,8 +23,8 @@ module CTdsBackupClamp !TOPDRIVE-CODE=80 if(Get_TdsBackupClamp() /= BACKUP_CLAMP_OFF_END .and.& Get_TdsBackupClamp() /= BACKUP_CLAMP_OFF_BEGIN .and.& - TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF .and.& - TopDrivePanel%TopDriveTorqueWrench == .false.) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState /= TdsPower_OFF .and.& + data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrench == .false.) then call Set_TdsBackupClamp(BACKUP_CLAMP_OFF_BEGIN) @@ -41,7 +41,7 @@ module CTdsBackupClamp - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_TdsBackupClamp=Kelly' #endif @@ -51,6 +51,8 @@ module CTdsBackupClamp subroutine Subscribe_TdsBackupClamp() use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables implicit none end subroutine diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsBackupClampVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsBackupClampVariables.f90 deleted file mode 100644 index bf30119..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CTdsBackupClampVariables.f90 +++ /dev/null @@ -1,83 +0,0 @@ -module CTdsBackupClampVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: TdsBackupClamp = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnTdsBackupClampChange - - enum, bind(c) - enumerator BACKUP_CLAMP_OFF_END - enumerator BACKUP_CLAMP_OFF_BEGIN - enumerator BACKUP_CLAMP_FW_BEGIN - enumerator BACKUP_CLAMP_FW_END - end enum - - private :: TdsBackupClamp - contains - - subroutine Set_TdsBackupClamp(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(TdsBackupClamp == v) return -#endif - TdsBackupClamp = v -#ifdef deb - print*, 'TdsBackupClamp=', TdsBackupClamp -#endif - call OnTdsBackupClampChange%RunAll() - end subroutine - - integer function Get_TdsBackupClamp() - implicit none - Get_TdsBackupClamp = TdsBackupClamp - end function - - - - subroutine Set_TdsBackupClamp_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsBackupClamp_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_TdsBackupClamp_WN' :: Set_TdsBackupClamp_WN - implicit none - integer , intent(in) :: v - call Set_TdsBackupClamp(v) - end subroutine - - integer function Get_TdsBackupClamp_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsBackupClamp_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_TdsBackupClamp_WN' :: Get_TdsBackupClamp_WN - implicit none - Get_TdsBackupClamp_WN = TdsBackupClamp - end function - - - - - - subroutine TdsBackupClampFwEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsBackupClampFwEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsBackupClampFwEnd' :: TdsBackupClampFwEnd - implicit none - call Set_TdsBackupClamp(BACKUP_CLAMP_FW_END) -#ifdef deb - print*, 'BACKUP_CLAMP_FW_END' -#endif - end subroutine - - - subroutine TdsBackupClampOffEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsBackupClampOffEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsBackupClampOffEnd' :: TdsBackupClampOffEnd - implicit none - call Set_TdsBackupClamp(BACKUP_CLAMP_OFF_END) -#ifdef deb - print*, 'BACKUP_CLAMP_OFF_END' -#endif - end subroutine - - - - -end module CTdsBackupClampVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.f90 index 719d971..2650cac 100644 --- a/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.f90 @@ -1,12 +1,13 @@ module CTdsSpineEnum - use COperationScenariosVariables + use OperationScenariosModule + use UnitySignalsModule !for CTdsConnectionModesEnum, only:Get_TdsConnectionModes implicit none contains subroutine Evaluate_TdsSpine() implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_TdsSpine=TopDrive' #endif @@ -15,8 +16,8 @@ module CTdsSpineEnum if (Get_TdsStemIn() .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& !Get_TdsConnectionPossible() .and.& - TopDrivePanel%TopDriveTdsPowerState == TdsPower_FWD .and.& - TopDrivePanel%TopDriveDrillTorqueState == TdsMu_SPINE) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_FWD .and.& + data%EquipmentControl%TopDrivePanel%TopDriveDrillTorqueState == TdsMu_SPINE) then call Set_TdsSpine(TDS_SPINE_CONNECT_BEGIN) return @@ -26,8 +27,8 @@ module CTdsSpineEnum if (Get_TdsStemIn() .and.& Get_TdsTong() == TDS_TONG_BREAKOUT_END .and.& Get_TdsConnectionModes() == TDS_CONNECTION_SPINE .and.& - TopDrivePanel%TopDriveTdsPowerState == TdsPower_REV .and.& - TopDrivePanel%TopDriveDrillTorqueState == TdsMu_SPINE) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_REV .and.& + data%EquipmentControl%TopDrivePanel%TopDriveDrillTorqueState == TdsMu_SPINE) then call Set_TdsSpine(TDS_SPINE_DISCONNECT_BEGIN) return @@ -45,7 +46,7 @@ module CTdsSpineEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_TdsSpine=Kelly' #endif @@ -55,6 +56,8 @@ module CTdsSpineEnum subroutine Subscribe_TdsSpine() use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables implicit none end subroutine diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnumVariables.f90 deleted file mode 100644 index f1e21ce..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnumVariables.f90 +++ /dev/null @@ -1,84 +0,0 @@ -module CTdsSpineEnumVariables - ! use CVoidEventHandlerCollection - use CLog4 - implicit none - integer :: TdsSpine = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnTdsSpineChange - - enum, bind(c) - enumerator TDS_SPINE_NEUTRAL - enumerator TDS_SPINE_CONNECT_BEGIN - enumerator TDS_SPINE_CONNECT_END - enumerator TDS_SPINE_DISCONNECT_BEGIN - enumerator TDS_SPINE_DISCONNECT_END - end enum - - private :: TdsSpine - contains - - subroutine Set_TdsSpine(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(TdsSpine == v) return -#endif - TdsSpine = v -#ifdef deb - print*, 'TdsSpine=', TdsSpine -#endif - call OnTdsSpineChange%RunAll() - end subroutine - - integer function Get_TdsSpine() - implicit none - Get_TdsSpine = TdsSpine - end function - - - - subroutine Set_TdsSpine_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsSpine_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_TdsSpine_WN' :: Set_TdsSpine_WN - implicit none - integer , intent(in) :: v - call Set_TdsSpine(v) - end subroutine - - integer function Get_TdsSpine_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsSpine_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_TdsSpine_WN' :: Get_TdsSpine_WN - implicit none - Get_TdsSpine_WN = TdsSpine - end function - - - - - subroutine TdsSpineConnectEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsSpineConnectEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsSpineConnectEnd' :: TdsSpineConnectEnd - implicit none - !if(TdsSpine /= TDS_SPINE_CONNECT_END) TdsSpine = TDS_SPINE_CONNECT_END - call Set_TdsSpine(TDS_SPINE_CONNECT_END) -#ifdef deb - print*, 'TDS_SPINE_CONNECT_END' -#endif - end subroutine - - - subroutine TdsSpineDisconnectEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsSpineDisconnectEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsSpineDisconnectEnd' :: TdsSpineDisconnectEnd - implicit none - !if(TdsSpine /= TDS_SPINE_DISCONNECT_END) TdsSpine = TDS_SPINE_DISCONNECT_END - call Set_TdsSpine(TDS_SPINE_DISCONNECT_END) -#ifdef deb - print*, 'TDS_SPINE_DISCONNECT_END' -#endif - end subroutine - - -end module CTdsSpineEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsSwingEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsSwingEnum.f90 index fb7207f..7970d66 100644 --- a/CSharp/OperationScenarios/UnitySignals/CTdsSwingEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CTdsSwingEnum.f90 @@ -1,12 +1,14 @@ module CTdsSwingEnum - use COperationScenariosVariables + use OperationScenariosModule + use ConfigurationVariables + use UnitySignalsModule implicit none contains subroutine Evaluate_TdsSwing() implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_TdsSwing=TopDrive' #endif @@ -16,10 +18,10 @@ module CTdsSwingEnum if (Get_SwingDrillPermission() .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& Get_FillMouseHoleLed() == .false. .and.& - TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_DRILL) then + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_DRILL) then call Set_TdsSwing(TDS_SWING_DRILL_BEGIN) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if @@ -28,10 +30,10 @@ module CTdsSwingEnum !TOPDRIVE-CODE=38 if (Get_SwingTiltPermission() .and.& Get_TdsSwing() == TDS_SWING_TILT_END .and.& - TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_TILT) then + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_TILT) then call Set_TdsSwing(TDS_SWING_TILT_BEGIN) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if @@ -41,10 +43,10 @@ module CTdsSwingEnum if (Get_SwingOffPermission() .and.& Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& - TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_OFF) then call Set_TdsSwing(TDS_SWING_OFF_BEGIN) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if @@ -56,10 +58,10 @@ module CTdsSwingEnum if (Get_SwingTiltPermission() .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& - TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_TILT) then + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_TILT) then call Set_TdsSwing(TDS_SWING_TILT_BEGIN) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if @@ -71,10 +73,10 @@ module CTdsSwingEnum if (Get_SwingOffPermission() .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.& Get_TdsSwing() == TDS_SWING_TILT_END .and.& - TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_OFF) then call Set_TdsSwing(TDS_SWING_OFF_BEGIN) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if @@ -83,14 +85,14 @@ module CTdsSwingEnum !TOPDRIVE-CODE=42 - if (Get_HookHeight() > (TL() + NFC() + OperationScenario%PL - OperationScenario%ECG) .and.& + if (Get_HookHeight() > (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.& Get_SwingTiltPermission() .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE .and.& Get_TdsSwing() == TDS_SWING_OFF_END .and.& - TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_TILT) then + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_TILT) then call Set_TdsSwing(TDS_SWING_TILT_BEGIN) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if @@ -98,14 +100,14 @@ module CTdsSwingEnum !TOPDRIVE-CODE=43 - if (Get_HookHeight() > (TL() + NFC() + OperationScenario%PL - OperationScenario%ECG) .and.& + if (Get_HookHeight() > (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.& Get_SwingOffPermission() .and.& Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE .and.& Get_TdsSwing() == TDS_SWING_TILT_END .and.& - TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_OFF) then + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltState == TdsLinkTilt_OFF) then call Set_TdsSwing(TDS_SWING_OFF_BEGIN) - TopDrivePanel%TopDriveLinkTiltLed = LED_ON + data%EquipmentControl%TopDrivePanel%TopDriveLinkTiltLed = LED_ON return end if @@ -134,6 +136,8 @@ module CTdsSwingEnum subroutine Subscribe_TdsSwing() use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables implicit none end subroutine diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsSwingEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsSwingEnumVariables.f90 deleted file mode 100644 index bcfeb62..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CTdsSwingEnumVariables.f90 +++ /dev/null @@ -1,97 +0,0 @@ -module CTdsSwingEnumVariables - ! use CVoidEventHandlerCollection - use CLog4 - implicit none - integer :: TdsSwing = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnTdsSwingChange - - enum, bind(c) - enumerator TDS_SWING_NEUTRAL - enumerator TDS_SWING_OFF_BEGIN - enumerator TDS_SWING_OFF_END - enumerator TDS_SWING_DRILL_BEGIN - enumerator TDS_SWING_DRILL_END - enumerator TDS_SWING_TILT_BEGIN - enumerator TDS_SWING_TILT_END - end enum - - private :: TdsSwing - contains - - subroutine Set_TdsSwing(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(TdsSwing == v) return -#endif - TdsSwing = v -#ifdef deb - print*, 'TdsSwing=', TdsSwing -#endif - call OnTdsSwingChange%RunAll() - end subroutine - - integer function Get_TdsSwing() - implicit none - Get_TdsSwing = TdsSwing - end function - - - - - subroutine Set_TdsSwing_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsSwing_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_TdsSwing_WN' :: Set_TdsSwing_WN - implicit none - integer , intent(in) :: v - call Set_TdsSwing(v) - end subroutine - - integer function Get_TdsSwing_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsSwing_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_TdsSwing_WN' :: Get_TdsSwing_WN - implicit none - Get_TdsSwing_WN = TdsSwing - end function - - - - subroutine TdsSwingOffEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsSwingOffEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsSwingOffEnd' :: TdsSwingOffEnd - implicit none - !if(TdsSwing /= TDS_SWING_OFF_END) TdsSwing = TDS_SWING_OFF_END - call Set_TdsSwing(TDS_SWING_OFF_END) -#ifdef deb - print*, 'TDS_SWING_OFF_END' -#endif - end subroutine - - - subroutine TdsSwingDrillEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsSwingDrillEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsSwingDrillEnd' :: TdsSwingDrillEnd - implicit none - !if(TdsSwing /= TDS_SWING_DRILL_END) TdsSwing = TDS_SWING_DRILL_END - call Set_TdsSwing(TDS_SWING_DRILL_END) -#ifdef deb - print*, 'TDS_SWING_DRILL_END' -#endif - end subroutine - - - subroutine TdsSwingTiltEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsSwingTiltEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsSwingTiltEnd' :: TdsSwingTiltEnd - implicit none - !if(TdsSwing /= TDS_SWING_TILT_END) TdsSwing = TDS_SWING_TILT_END - call Set_TdsSwing(TDS_SWING_TILT_END) -#ifdef deb - print*, 'TDS_SWING_TILT_END' -#endif - end subroutine - -end module CTdsSwingEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsTongEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsTongEnum.f90 index fca008e..b8c0017 100644 --- a/CSharp/OperationScenarios/UnitySignals/CTdsTongEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CTdsTongEnum.f90 @@ -1,12 +1,12 @@ module CTdsTongEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains subroutine Evaluate_TdsTong() implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'Evaluate_TdsTong=TopDrive' #endif @@ -16,8 +16,8 @@ module CTdsTongEnum !TOPDRIVE-CODE=1 if (Get_TdsConnectionModes() == TDS_CONNECTION_SPINE .and.& Get_TdsBackupClamp() == BACKUP_CLAMP_FW_END .and.& - TopDrivePanel%TopDriveTdsPowerState == TdsPower_FWD .and.& - TopDrivePanel%TopDriveDrillTorqueState == TdsMu_TORQ) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_FWD .and.& + data%EquipmentControl%TopDrivePanel%TopDriveDrillTorqueState == TdsMu_TORQ) then call Set_TdsTong(TDS_TONG_MAKEUP_BEGIN) !TopDriveTorqueWrenchLed = LED_ON @@ -29,8 +29,8 @@ module CTdsTongEnum !TOPDRIVE-CODE=2 if (Get_TdsConnectionModes() == TDS_CONNECTION_STRING .and.& Get_TdsBackupClamp() == BACKUP_CLAMP_FW_END .and.& - TopDrivePanel%TopDriveTdsPowerState == TdsPower_REV .and.& - TopDrivePanel%TopDriveDrillTorqueState == TdsMu_TORQ) then + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_REV .and.& + data%EquipmentControl%TopDrivePanel%TopDriveDrillTorqueState == TdsMu_TORQ) then call Set_TdsTong(TDS_TONG_BREAKOUT_BEGIN) !TopDriveTorqueWrenchLed = LED_ON @@ -48,7 +48,7 @@ module CTdsTongEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'Evaluate_TdsTong=Kelly' #endif @@ -58,6 +58,8 @@ module CTdsTongEnum subroutine Subscribe_TdsTong() use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables implicit none end subroutine diff --git a/CSharp/OperationScenarios/UnitySignals/CTdsTongEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CTdsTongEnumVariables.f90 deleted file mode 100644 index f2a0e4e..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CTdsTongEnumVariables.f90 +++ /dev/null @@ -1,86 +0,0 @@ -module CTdsTongEnumVariables - ! use CVoidEventHandlerCollection - implicit none - integer :: TdsTong = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnTdsTongChange - - enum, bind(c) - enumerator TDS_TONG_BREAKOUT_END - enumerator TDS_TONG_BREAKOUT_BEGIN - enumerator TDS_TONG_MAKEUP_BEGIN - enumerator TDS_TONG_MAKEUP_END - end enum - - private :: TdsTong - contains - - subroutine Set_TdsTong(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(TdsTong == v) return -#endif - TdsTong = v -#ifdef deb - print*, 'TdsTong=', TdsTong -#endif - call OnTdsTongChange%RunAll() - end subroutine - - integer function Get_TdsTong() - implicit none - Get_TdsTong = TdsTong - end function - - - - - subroutine Set_TdsTong_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_TdsTong_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_TdsTong_WN' :: Set_TdsTong_WN - implicit none - integer , intent(in) :: v - call Set_TdsTong(v) - end subroutine - - integer function Get_TdsTong_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsTong_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_TdsTong_WN' :: Get_TdsTong_WN - implicit none - Get_TdsTong_WN = TdsTong - end function - - - - - - subroutine TdsTongBreakoutEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsTongBreakoutEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsTongBreakoutEnd' :: TdsTongBreakoutEnd - implicit none - !if(TdsTong /= TDS_TONG_BREAKOUT_END) TdsTong = TDS_TONG_BREAKOUT_END - call Set_TdsTong(TDS_TONG_BREAKOUT_END) -#ifdef deb - print*, 'TDS_TONG_BREAKOUT_END' -#endif - end subroutine - - - subroutine TdsTongMakeupEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TdsTongMakeupEnd - !DEC$ ATTRIBUTES ALIAS: 'TdsTongMakeupEnd' :: TdsTongMakeupEnd - implicit none - !if(TdsTong /= TDS_TONG_MAKEUP_END) TdsTong = TDS_TONG_MAKEUP_END - call Set_TdsTong(TDS_TONG_MAKEUP_END) -#ifdef deb - print*, 'TDS_TONG_MAKEUP_END' -#endif - end subroutine - - - - -end module CTdsTongEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 b/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 index db2e823..613b515 100644 --- a/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 +++ b/CSharp/OperationScenarios/UnitySignals/CTongEnum.f90 @@ -1,5 +1,5 @@ module CTongEnum - use COperationScenariosVariables + use OperationScenariosModule implicit none contains @@ -29,6 +29,8 @@ module CTongEnum ! subroutine Subscribe_Tong() ! use CDrillingConsoleVariables +!@ use ConfigurationVariables +!@ use ConfigurationVariables ! implicit none ! call OnBreakoutLeverPress%Add(ButtonPress_Breakout_TongNotification) @@ -41,7 +43,7 @@ module CTongEnum subroutine ButtonPress_Breakout_TongNotification() implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Breakout_TongNotification=TopDrive' #endif @@ -51,7 +53,7 @@ module CTongEnum return end if endif - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Breakout_TongNotification=Kelly' #endif @@ -69,12 +71,12 @@ module CTongEnum subroutine ButtonPress_Makeup_TongNotification() - use NotificationVariables + use NotificationModule implicit none - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Makeup_TongNotification=TopDrive' #endif @@ -96,7 +98,7 @@ module CTongEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Makeup_TongNotification=Kelly' #endif @@ -123,7 +125,7 @@ module CTongEnum - if (Hoisting%DriveType == TopDrive_DriveType) then + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then #ifdef OST print*, 'ButtonPress_Neutral_TongNotification=TopDrive' #endif @@ -136,7 +138,7 @@ module CTongEnum - if (Hoisting%DriveType == Kelly_DriveType) then + if (data%State%Hoisting%DriveType == Kelly_DriveType) then #ifdef OST print*, 'ButtonPress_Neutral_TongNotification=Kelly' #endif diff --git a/CSharp/OperationScenarios/UnitySignals/CTongEnumVariables.f90 b/CSharp/OperationScenarios/UnitySignals/CTongEnumVariables.f90 deleted file mode 100644 index 267d4eb..0000000 --- a/CSharp/OperationScenarios/UnitySignals/CTongEnumVariables.f90 +++ /dev/null @@ -1,129 +0,0 @@ -module CTongEnumVariables - ! use CVoidEventHandlerCollection - use CLog4 - implicit none - integer :: Tong = 0 - integer :: Tong_S = 0 - - public - - ! type(VoidEventHandlerCollection) :: OnTongChange - - enum, bind(c) - enumerator TONG_NEUTRAL - enumerator TONG_BREAKOUT_BEGIN - enumerator TONG_BREAKOUT_END - enumerator TONG_MAKEUP_BEGIN - enumerator TONG_MAKEUP_END - end enum - - private :: Tong - - contains - - subroutine Set_Tong(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(Tong == v) return -#endif - Tong = v -#ifdef deb - !if(Tong==TONG_NEUTRAL) then - ! print*, 'Tong=TONG_NEUTRAL' - !else if(Tong==TONG_BREAKOUT) then - ! print*, 'Tong=TONG_BREAKOUT' - !else if(Tong==TONG_MAKEUP) then - ! print*, 'Tong=TONG_MAKEUP' - !endif - print*, 'Tong=', Tong -#endif - call OnTongChange%RunAll() - end subroutine - - integer function Get_Tong() - implicit none - Get_Tong = Tong - end function - - - - subroutine Set_Tong_WN(v) - !DEC$ ATTRIBUTES DLLEXPORT :: Set_Tong_WN - !DEC$ ATTRIBUTES ALIAS: 'Set_Tong_WN' :: Set_Tong_WN - implicit none - integer , intent(in) :: v - !call Set_Tong(v) - Tong_S = v - end subroutine - - integer function Get_Tong_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_Tong_WN - !DEC$ ATTRIBUTES ALIAS: 'Get_Tong_WN' :: Get_Tong_WN - implicit none - Get_Tong_WN = Tong - end function - - - - - - - - - - subroutine TongBreakoutEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TongBreakoutEnd - !DEC$ ATTRIBUTES ALIAS: 'TongBreakoutEnd' :: TongBreakoutEnd - implicit none - !if(Tong /= TONG_BREAKOUT_END) then - ! Tong = TONG_BREAKOUT_END - !endif - call Set_Tong(TONG_BREAKOUT_END) -#ifdef deb - print*, 'TONG_BREAKOUT_END' -#endif - end subroutine - - - subroutine TongMakeupEnd() - !DEC$ ATTRIBUTES DLLEXPORT :: TongMakeupEnd - !DEC$ ATTRIBUTES ALIAS: 'TongMakeupEnd' :: TongMakeupEnd - implicit none - !if(Tong /= TONG_MAKEUP_END) then - ! Tong = TONG_MAKEUP_END - ! - !endif - call Set_Tong(TONG_MAKEUP_END) -#ifdef deb - print*, 'TONG_MAKEUP_END' -#endif - end subroutine - - - - - - - - - - - - - - logical function Get_TongBreakout() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TongBreakout - !DEC$ ATTRIBUTES ALIAS: 'Get_TongBreakout' :: Get_TongBreakout - implicit none - Get_TongBreakout = .false. ! Tong == TONG_BREAKOUT - end function - - logical function Get_TongMakeup() - !DEC$ ATTRIBUTES DLLEXPORT :: Get_TongMakeup - !DEC$ ATTRIBUTES ALIAS: 'Get_TongMakeup' :: Get_TongMakeup - implicit none - Get_TongMakeup = .false. ! Tong == TONG_MAKEUP - end function - -end module CTongEnumVariables \ No newline at end of file diff --git a/CSharp/OperationScenarios/UnitySignals/UnitySignals.f90 b/CSharp/OperationScenarios/UnitySignals/UnitySignals.f90 new file mode 100644 index 0000000..7126714 --- /dev/null +++ b/CSharp/OperationScenarios/UnitySignals/UnitySignals.f90 @@ -0,0 +1,489 @@ +module UnitySignalsModule + use UnitySignalVariables + use ConfigurationVariables +contains + +subroutine Set_TdsElevatorModes(v) + implicit none + integer , intent(in) :: v +#ifdef ExcludeExtraChanges + if(data%State%unitySignals%TdsElevatorModes == v) return +#endif + data%State%unitySignals%TdsElevatorModes = v + !**call TdsElevatorModesEnum%OnTdsElevatorModesChange%RunAll() +end subroutine + +integer function Get_TdsElevatorModes() + implicit none + Get_TdsElevatorModes = data%State%unitySignals%TdsElevatorModes +end function + +subroutine Set_Ibop_Install() + implicit none + call Set_Ibop(IBOP_INSTALL) +end subroutine + +subroutine Set_Ibop_Remove() + implicit none + call Set_Ibop(IBOP_REMOVE) +end subroutine + +subroutine Set_Tong(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%Tong == v) return + #endif + data%State%unitySignals%Tong = v + #ifdef deb + print*, 'Tong=', data%State%unitySignals%Tong + #endif + !**call data%State%unitySignals%OnTongChange%RunAll() +end subroutine + +integer function Get_Tong() + implicit none + Get_Tong = data%State%unitySignals%Tong +end function + + +subroutine Set_TdsTong(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%TdsTong == v) return + #endif + data%State%unitySignals%TdsTong = v + #ifdef deb + print*, 'TdsTong=', data%State%unitySignals%TdsTong + #endif + !**call data%State%unitySignals%OnTdsTongChange%RunAll() +end subroutine + +integer function Get_TdsTong() + implicit none + Get_TdsTong = data%State%unitySignals%TdsTong +end function + + +subroutine Set_TdsSwing(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%TdsSwing == v) return + #endif + data%State%unitySignals%TdsSwing = v + #ifdef deb + print*, 'TdsSwing=', data%State%unitySignals%TdsSwing + #endif + !**call data%State%unitySignals%OnTdsSwingChange%RunAll() +end subroutine + +integer function Get_TdsSwing() + implicit none + Get_TdsSwing = data%State%unitySignals%TdsSwing +end function + + +subroutine Set_TdsSpine(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%TdsSpine == v) return + #endif + data%State%unitySignals%TdsSpine = v + #ifdef deb + print*, 'TdsSpine=', data%State%unitySignals%TdsSpine + #endif + !**call data%State%unitySignals%OnTdsSpineChange%RunAll() +end subroutine + +integer function Get_TdsSpine() + implicit none + Get_TdsSpine = data%State%unitySignals%TdsSpine +end function + + +subroutine Set_TdsBackupClamp(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%TdsBackupClamp == v) return + #endif + data%State%unitySignals%TdsBackupClamp = v + #ifdef deb + print*, 'TdsBackupClamp=', data%State%unitySignals%TdsBackupClamp + #endif + !**call data%State%unitySignals%OnTdsBackupClampChange%RunAll() +end subroutine + +integer function Get_TdsBackupClamp() + implicit none + Get_TdsBackupClamp = data%State%unitySignals%TdsBackupClamp +end function + + +subroutine Set_Swing(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%Swing == v) return + #endif + data%State%unitySignals%Swing = v + #ifdef deb + print*, 'Swing=', data%State%unitySignals%Swing + #endif + !**call data%State%unitySignals%OnSwingChange%RunAll() +end subroutine + +integer function Get_Swing() + implicit none + Get_Swing = data%State%unitySignals%Swing +end function + + +subroutine Set_Slips(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%Slips == v) return + #endif + data%State%unitySignals%Slips = v + #ifdef deb + print*, 'Slips=', data%State%unitySignals%Slips + #endif + !**call data%State%unitySignals%OnSlipsChange%RunAll() +end subroutine + +integer function Get_Slips() + implicit none + Get_Slips = data%State%unitySignals%Slips +end function + +subroutine Set_Operation(i) + implicit none + integer, intent (in) :: i + data%State%unitySignals%operation = i +end subroutine + +subroutine Set_SafetyValve(v) + implicit none + integer , intent(in) :: v +#ifdef ExcludeExtraChanges + if(data%State%unitySignals%SafetyValve == v) return +#endif + data%State%unitySignals%SafetyValve = v +#ifdef deb + if(data%State%unitySignals%SafetyValve == SAFETY_VALVE_NEUTRAL) then + print*, 'SafetyValve=SAFETY_VALVE_NEUTRAL' + else if (data%State%unitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then + print*, 'SafetyValve=SAFETY_VALVE_INSTALL' + else if (data%State%unitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then + print*, 'SafetyValve=SAFETY_VALVE_REMOVE' + endif +#endif + !**call data%State%unitySignals%OnSafetyValveChange%RunAll() +end subroutine + +integer function Get_SafetyValve() + implicit none + Get_SafetyValve = data%State%unitySignals%SafetyValve +end function + +subroutine Set_SafetyValve_Install() + implicit none + call Set_SafetyValve(SAFETY_VALVE_INSTALL) +end subroutine + +subroutine Set_SafetyValve_Remove() + implicit none + call Set_SafetyValve(SAFETY_VALVE_REMOVE) +end subroutine + + +subroutine Set_OperationCondition(v) + ! use CKellyEnumVariables + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%OperationCondition == v) return + #endif + data%State%unitySignals%OperationCondition = v + #ifdef deb + print*, 'OperationCondition=', data%State%unitySignals%OperationCondition + #endif + !**call data%State%unitySignals%OnOperationConditionChange%RunAll() + !**call data%State%unitySignals%OnOperationConditionChangeInt%RunAll(data%State%unitySignals%OperationCondition) +end subroutine + +integer function Get_OperationCondition() + implicit none + Get_OperationCondition = data%State%unitySignals%OperationCondition +end function + +subroutine Evaluate_OperationCondition() + implicit none +end subroutine + + +subroutine Set_MouseHole(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%MouseHole == v) return + #endif + !call sleep(2) + data%State%unitySignals%MouseHole = v + #ifdef deb + print*, 'MouseHole=', data%State%unitySignals%MouseHole + #endif + !**call data%State%unitySignals%OnMouseHoleChange%RunAll() +end subroutine + +integer function Get_MouseHole() + implicit none + Get_MouseHole = data%State%unitySignals%MouseHole +end function + + + +subroutine Set_Kelly(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%Kelly == v) return + #endif + data%State%unitySignals%Kelly = v + #ifdef deb + print*, 'Kelly=', data%State%unitySignals%Kelly + #endif + !**call data%State%unitySignals%OnKellyChange%RunAll() +end subroutine + +integer function Get_Kelly() + implicit none + Get_Kelly = data%State%unitySignals%Kelly +end function + + +subroutine Set_Ibop(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%Ibop == v) return + #endif + data%State%unitySignals%Ibop = v + #ifdef deb + print*, 'Ibop=', data%State%unitySignals%Ibop + #endif + !**call data%State%unitySignals%OnIbopChange%RunAll() +end subroutine + +integer function Get_Ibop() + implicit none + Get_Ibop = data%State%unitySignals%Ibop +end function + + +subroutine Set_FillupHead(v) + use CManifolds, only: ToggleFillupHead + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%FillupHead == v) return + #endif + data%State%unitySignals%FillupHead = v + + if (data%State%unitySignals%FillupHead == FILLUP_HEAD_INSTALL) then + call ToggleFillupHead(.true.) + else if (data%State%unitySignals%FillupHead == FILLUP_HEAD_REMOVE) then + call ToggleFillupHead(.false.) + endif + + #ifdef deb + print*, 'FillupHead=', data%State%unitySignals%FillupHead + #endif + !**call data%State%unitySignals%OnFillupHeadChange%RunAll() +end subroutine + +integer function Get_FillupHead() + implicit none + Get_FillupHead = data%State%unitySignals%FillupHead +end function + +subroutine Evaluate_FillupHead() + use CHoistingVariables + use ConfigurationVariables + use CStudentStationVariables!, only: data%State%StudentStation%FillupHeadInstallation + implicit none + + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then +#ifdef OST + print*, 'Evaluate_FillupHead=TopDrive' +#endif + endif + + + + + + + if (data%State%Hoisting%DriveType == Kelly_DriveType) then +#ifdef OST + print*, 'Evaluate_FillupHead=Kelly' +#endif + endif + + + if (Get_FillupHead() == FILLUP_HEAD_INSTALL) then + data%State%StudentStation%FillupHeadInstallation = .true. + else if (Get_FillupHead() == FILLUP_HEAD_REMOVE) then + data%State%StudentStation%FillupHeadInstallation = .false. + endif + +end subroutine + + +subroutine Set_Elevator(v) + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%Elevator == v) return + #endif + data%State%unitySignals%Elevator = v + #ifdef deb + print*, 'Elevator=', data%State%unitySignals%Elevator + #endif + !**call data%State%unitySignals%OnElevatorChange%RunAll() +end subroutine + +integer function Get_Elevator() + implicit none + Get_Elevator = data%State%unitySignals%Elevator +end function + + + +subroutine Set_MudBucket(v) + use CManifolds, only: ToggleMudBox + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%MudBucket == v) return + #endif + data%State%unitySignals%MudBucket = v + if (data%State%unitySignals%MudBucket == MUD_BUCKET_INSTALL) then + call ToggleMudBox(.true.) + else if (data%State%unitySignals%MudBucket == MUD_BUCKET_REMOVE) then + call ToggleMudBox(.false.) + endif + #ifdef deb + print*, 'MudBucket=', data%State%unitySignals%MudBucket + #endif + !**call data%State%unitySignals%OnMudBucketChange%RunAll() +end subroutine + +integer function Get_MudBucket() + implicit none + Get_MudBucket = data%State%unitySignals%MudBucket +end function + +subroutine Evaluate_MudBucket() + use CStudentStationVariables!, only: data%State%StudentStation%MudBoxInstallation + implicit none + + if (Get_MudBucket() == MUD_BUCKET_INSTALL) then + data%State%StudentStation%MudBoxInstallation = .true. + else if (Get_MudBucket() == MUD_BUCKET_REMOVE) then + data%State%StudentStation%MudBoxInstallation = .false. + endif + +end subroutine + + +!! Moved from CTdsConnectionModeEnum + +subroutine Set_TdsConnectionModes(v) + use CManifolds, Only: KellyConnected, KellyDisconnected + implicit none + integer , intent(in) :: v + #ifdef ExcludeExtraChanges + if(data%State%unitySignals%TdsConnectionModes == v) return + #endif + data%State%unitySignals%TdsConnectionModes = v + + if(data%State%unitySignals%TdsConnectionModes == TDS_CONNECTION_NOTHING) then + call KellyDisconnected() + else + call KellyConnected() + endif + + #ifdef deb + print*, 'data%State%unitySignals%TdsConnectionModes=', data%State%unitySignals%TdsConnectionModes + #endif + !**call data%State%unitySignals%OnTdsConnectionModesChange%RunAll() +end subroutine + +integer function Get_TdsConnectionModes() + use ConfigurationVariables + implicit none + Get_TdsConnectionModes = data%State%unitySignals%TdsConnectionModes +end function + +subroutine Evaluate_TdsConnectionModes() + use CUnityInputs + use ConfigurationVariables + implicit none + + if (data%State%Hoisting%DriveType == TopDrive_DriveType) then + #ifdef OST + print*, 'Evaluate_TdsConnectionModes=TopDrive' + #endif + !TOPDRIVE-CODE=3 + if (Get_TdsStemIn() .and.& + Get_TdsSpine() == TDS_SPINE_CONNECT_END .and.& + !TopDriveDrillTorqueState == TdsMu_SPINE + Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then + + call Set_TdsConnectionModes(TDS_CONNECTION_SPINE) + return + end if + + !TOPDRIVE-CODE=4 + if (Get_TdsTong() == TDS_TONG_MAKEUP_END .and.& + Get_TdsConnectionModes() == TDS_CONNECTION_SPINE ) then + + call Set_TdsConnectionModes(TDS_CONNECTION_STRING) + data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF + return + end if + + !TOPDRIVE-CODE=5 + if (Get_TdsTong() == TDS_TONG_BREAKOUT_END .and.& + Get_TdsConnectionModes() == TDS_CONNECTION_STRING ) then + + call Set_TdsConnectionModes(TDS_CONNECTION_SPINE) + data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF + return + end if + + !TOPDRIVE-CODE=6 + if (Get_TdsSpine() == TDS_SPINE_DISCONNECT_END .and.& + !Get_TdsStemIn() == .false. .and.& + Get_TdsConnectionModes() == TDS_CONNECTION_SPINE) then + + call Set_TdsConnectionModes(TDS_CONNECTION_NOTHING) + return + end if + + endif + + if (data%State%Hoisting%DriveType == Kelly_DriveType) then + #ifdef OST + print*, 'Evaluate_TdsConnectionModes=Kelly' + #endif + endif + +end subroutine + +end module UnitySignalsModule diff --git a/CSharp/OperationScenarios/UnitySignals/UnitySignalsVariables.f90 b/CSharp/OperationScenarios/UnitySignals/UnitySignalsVariables.f90 index 124d36c..d90aee1 100644 --- a/CSharp/OperationScenarios/UnitySignals/UnitySignalsVariables.f90 +++ b/CSharp/OperationScenarios/UnitySignals/UnitySignalsVariables.f90 @@ -4,42 +4,28 @@ module UnitySignalVariables type:: UnitySignalsType integer :: MudBucket = 0 - ! type(VoidEventHandlerCollection) :: OnMudBucketChange integer :: Elevator = 0 - ! type(VoidEventHandlerCollection) :: OnElevatorChange integer :: FillupHead = 0 - ! type(VoidEventHandlerCollection) :: OnFillupHeadChange integer :: Ibop = 0 - ! type(VoidEventHandlerCollection) :: OnIbopChange integer :: Kelly = 0 - ! type(VoidEventHandlerCollection) :: OnKellyChange integer :: MouseHole = 0 - ! type(VoidEventHandlerCollection) :: OnMouseHoleChange integer :: OperationCondition = 0 - ! type(VoidEventHandlerCollection) :: OnOperationConditionChange - ! !**type(IntegerEventHandlerCollection) :: OnOperationConditionChangeInt integer :: SafetyValve = 0 - ! type(VoidEventHandlerCollection) :: OnSafetyValveChange integer :: operation = 0 integer :: Slips = 0 integer :: Slips_S = 0 - ! type(VoidEventHandlerCollection) :: OnSlipsChange integer :: Swing = 0 integer :: Swing_S = 0 - ! type(VoidEventHandlerCollection) :: OnSwingChange integer :: TdsBackupClamp = 0 - ! type(VoidEventHandlerCollection) :: OnTdsBackupClampChange integer :: TdsSpine = 0 - ! type(VoidEventHandlerCollection) :: OnTdsSpineChange integer :: TdsSwing = 0 - ! type(VoidEventHandlerCollection) :: OnTdsSwingChange integer :: TdsTong = 0 - ! type(VoidEventHandlerCollection) :: OnTdsTongChange integer :: Tong = 0 integer :: Tong_S = 0 - ! type(VoidEventHandlerCollection) :: OnTongChange + integer :: TdsConnectionModes = 0 + integer :: TdsElevatorModes = 0 + end type UnitySignalsType - type(UnitySignalsType):: unitySignals enum, bind(c) enumerator TONG_NEUTRAL @@ -136,343 +122,21 @@ module UnitySignalVariables !enumerator IBOP_NEUTRAL enumerator IBOP_REMOVE enumerator IBOP_INSTALL + + enumerator TDS_CONNECTION_NOTHING + enumerator TDS_CONNECTION_STRING + enumerator TDS_CONNECTION_SPINE + + enumerator TDS_ELEVATOR_CONNECTION_NOTHING + enumerator TDS_ELEVATOR_CONNECTION_STRING + enumerator TDS_ELEVATOR_CONNECTION_SINGLE + enumerator TDS_ELEVATOR_CONNECTION_STAND + enumerator TDS_ELEVATOR_LATCH_STRING + enumerator TDS_ELEVATOR_LATCH_SINGLE + enumerator TDS_ELEVATOR_LATCH_STAND end enum contains - - subroutine Set_Ibop_Install() - implicit none - call Set_Ibop(IBOP_INSTALL) - end subroutine - - subroutine Set_Ibop_Remove() - implicit none - call Set_Ibop(IBOP_REMOVE) - end subroutine - - subroutine Set_Tong(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%Tong == v) return - #endif - UnitySignals%Tong = v - #ifdef deb - print*, 'Tong=', UnitySignals%Tong - #endif - !**call UnitySignals%OnTongChange%RunAll() - end subroutine - - integer function Get_Tong() - implicit none - Get_Tong = UnitySignals%Tong - end function - - - subroutine Set_TdsTong(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%TdsTong == v) return - #endif - UnitySignals%TdsTong = v - #ifdef deb - print*, 'TdsTong=', UnitySignals%TdsTong - #endif - !**call UnitySignals%OnTdsTongChange%RunAll() - end subroutine - - integer function Get_TdsTong() - implicit none - Get_TdsTong = UnitySignals%TdsTong - end function - - - subroutine Set_TdsSwing(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%TdsSwing == v) return - #endif - UnitySignals%TdsSwing = v - #ifdef deb - print*, 'TdsSwing=', UnitySignals%TdsSwing - #endif - !**call UnitySignals%OnTdsSwingChange%RunAll() - end subroutine - - integer function Get_TdsSwing() - implicit none - Get_TdsSwing = UnitySignals%TdsSwing - end function - - - subroutine Set_TdsSpine(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%TdsSpine == v) return - #endif - UnitySignals%TdsSpine = v - #ifdef deb - print*, 'TdsSpine=', UnitySignals%TdsSpine - #endif - !**call UnitySignals%OnTdsSpineChange%RunAll() - end subroutine - - integer function Get_TdsSpine() - implicit none - Get_TdsSpine = UnitySignals%TdsSpine - end function - - - subroutine Set_TdsBackupClamp(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%TdsBackupClamp == v) return - #endif - UnitySignals%TdsBackupClamp = v - #ifdef deb - print*, 'TdsBackupClamp=', UnitySignals%TdsBackupClamp - #endif - !**call UnitySignals%OnTdsBackupClampChange%RunAll() - end subroutine - - integer function Get_TdsBackupClamp() - implicit none - Get_TdsBackupClamp = UnitySignals%TdsBackupClamp - end function - - - subroutine Set_Swing(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%Swing == v) return - #endif - UnitySignals%Swing = v - #ifdef deb - print*, 'Swing=', UnitySignals%Swing - #endif - !**call UnitySignals%OnSwingChange%RunAll() - end subroutine - - integer function Get_Swing() - implicit none - Get_Swing = UnitySignals%Swing - end function - - - subroutine Set_Slips(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%Slips == v) return - #endif - UnitySignals%Slips = v - #ifdef deb - print*, 'Slips=', UnitySignals%Slips - #endif - !**call UnitySignals%OnSlipsChange%RunAll() - end subroutine - - integer function Get_Slips() - implicit none - Get_Slips = UnitySignals%Slips - end function - - subroutine Set_Operation(i) - implicit none - integer, intent (in) :: i - UnitySignals%operation = i - end subroutine - - subroutine Set_SafetyValve(v) - implicit none - integer , intent(in) :: v -#ifdef ExcludeExtraChanges - if(UnitySignals%SafetyValve == v) return -#endif - UnitySignals%SafetyValve = v -#ifdef deb - if(UnitySignals%SafetyValve == SAFETY_VALVE_NEUTRAL) then - print*, 'SafetyValve=SAFETY_VALVE_NEUTRAL' - else if (UnitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then - print*, 'SafetyValve=SAFETY_VALVE_INSTALL' - else if (UnitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then - print*, 'SafetyValve=SAFETY_VALVE_REMOVE' - endif -#endif - !**call UnitySignals%OnSafetyValveChange%RunAll() - end subroutine - - integer function Get_SafetyValve() - implicit none - Get_SafetyValve = UnitySignals%SafetyValve - end function - - subroutine Set_SafetyValve_Install() - implicit none - call Set_SafetyValve(SAFETY_VALVE_INSTALL) - end subroutine - - subroutine Set_SafetyValve_Remove() - implicit none - call Set_SafetyValve(SAFETY_VALVE_REMOVE) - end subroutine - - - subroutine Set_OperationCondition(v) - ! use CKellyEnumVariables - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%OperationCondition == v) return - #endif - UnitySignals%OperationCondition = v - #ifdef deb - print*, 'OperationCondition=', UnitySignals%OperationCondition - #endif - !**call UnitySignals%OnOperationConditionChange%RunAll() - !**call UnitySignals%OnOperationConditionChangeInt%RunAll(UnitySignals%OperationCondition) - end subroutine - - integer function Get_OperationCondition() - implicit none - Get_OperationCondition = UnitySignals%OperationCondition - end function - - - subroutine Set_MouseHole(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%MouseHole == v) return - #endif - !call sleep(2) - UnitySignals%MouseHole = v - #ifdef deb - print*, 'MouseHole=', UnitySignals%MouseHole - #endif - !**call UnitySignals%OnMouseHoleChange%RunAll() - end subroutine - - integer function Get_MouseHole() - implicit none - Get_MouseHole = UnitySignals%MouseHole - end function - - - - subroutine Set_Kelly(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%Kelly == v) return - #endif - UnitySignals%Kelly = v - #ifdef deb - print*, 'Kelly=', UnitySignals%Kelly - #endif - !**call UnitySignals%OnKellyChange%RunAll() - end subroutine - - integer function Get_Kelly() - implicit none - Get_Kelly = UnitySignals%Kelly - end function - - - subroutine Set_Ibop(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%Ibop == v) return - #endif - UnitySignals%Ibop = v - #ifdef deb - print*, 'Ibop=', UnitySignals%Ibop - #endif - !**call UnitySignals%OnIbopChange%RunAll() - end subroutine - - integer function Get_Ibop() - implicit none - Get_Ibop = UnitySignals%Ibop - end function - - - subroutine Set_FillupHead(v) - use CManifolds, only: ToggleFillupHead - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%FillupHead == v) return - #endif - UnitySignals%FillupHead = v - - if (UnitySignals%FillupHead == FILLUP_HEAD_INSTALL) then - call ToggleFillupHead(.true.) - else if (UnitySignals%FillupHead == FILLUP_HEAD_REMOVE) then - call ToggleFillupHead(.false.) - endif - - #ifdef deb - print*, 'FillupHead=', UnitySignals%FillupHead - #endif - !**call UnitySignals%OnFillupHeadChange%RunAll() - end subroutine - - integer function Get_FillupHead() - implicit none - Get_FillupHead = UnitySignals%FillupHead - end function - - - subroutine Set_Elevator(v) - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%Elevator == v) return - #endif - UnitySignals%Elevator = v - #ifdef deb - print*, 'Elevator=', UnitySignals%Elevator - #endif - !**call UnitySignals%OnElevatorChange%RunAll() - end subroutine - - integer function Get_Elevator() - implicit none - Get_Elevator = UnitySignals%Elevator - end function - - - - subroutine Set_MudBucket(v) - use CManifolds, only: ToggleMudBox - implicit none - integer , intent(in) :: v - #ifdef ExcludeExtraChanges - if(UnitySignals%MudBucket == v) return - #endif - UnitySignals%MudBucket = v - if (UnitySignals%MudBucket == MUD_BUCKET_INSTALL) then - call ToggleMudBox(.true.) - else if (UnitySignals%MudBucket == MUD_BUCKET_REMOVE) then - call ToggleMudBox(.false.) - endif - #ifdef deb - print*, 'MudBucket=', UnitySignals%MudBucket - #endif - !**call UnitySignals%OnMudBucketChange%RunAll() - end subroutine - - integer function Get_MudBucket() - implicit none - Get_MudBucket = UnitySignals%MudBucket - end function end module UnitySignalVariables \ No newline at end of file diff --git a/CSharp/Problems/CBitProblems.f90 b/CSharp/Problems/CBitProblems.f90 index 35e46ad..11d542e 100644 --- a/CSharp/Problems/CBitProblems.f90 +++ b/CSharp/Problems/CBitProblems.f90 @@ -1,65 +1,61 @@ module CBitProblems - use CBitProblemsVariables + use ConfigurationVariables implicit none public contains - ! Input routines - subroutine SetPlugJets(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPlugJets - !DEC$ ATTRIBUTES ALIAS: 'SetPlugJets' :: SetPlugJets - implicit none - type(CProblem), intent(in) :: v - BitProblems%PlugJets = SetDue(v, ChangePlugJets) -#ifdef deb - !print*, 'PlugJets%ProblemType=', PlugJets%ProblemType - !print*, 'PlugJets%StatusType=', PlugJets%StatusType - !print*, 'PlugJets%Value=', PlugJets%Value - !print*, 'PlugJets%DueValue=', PlugJets%DueValue + subroutine ProcessBitProblemsDueTime(time) + implicit none + integer :: time + if(data%problems%BitProblems%PlugJets%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BitProblems%PlugJets, ChangePlugJets, time) + if(data%problems%BitProblems%JetWashout%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BitProblems%JetWashout, ChangeJetWashout, time) - call Log_3("==============================") - call Log_3("PlugJets%ProblemType=", BitProblems%PlugJets%ProblemType) - call Log_3("PlugJets%StatusType=", BitProblems%PlugJets%StatusType) - call Log_3("PlugJets%Value=", BitProblems%PlugJets%Value) - call Log_3("PlugJets%DueValue=", BitProblems%PlugJets%DueValue) - call Log_3("==============================") -#endif end subroutine + + subroutine ProcessBitProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes - subroutine SetJetWashout(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetJetWashout - !DEC$ ATTRIBUTES ALIAS: 'SetJetWashout' :: SetJetWashout - implicit none - type(CProblem), intent(in) :: v - BitProblems%JetWashout = SetDue(v, ChangeJetWashout) -#ifdef deb - print*, 'JetWashout%ProblemType=', BitProblems%JetWashout%ProblemType - print*, 'JetWashout%StatusType=', BitProblems%JetWashout%StatusType - print*, 'JetWashout%Value=', BitProblems%JetWashout%Value - print*, 'JetWashout%DueValue=', BitProblems%JetWashout%DueValue -#endif + if(data%problems%BitProblems%PlugJets%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BitProblems%PlugJets, ChangePlugJets, strokes) + if(data%problems%BitProblems%JetWashout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BitProblems%JetWashout, ChangeJetWashout, strokes) + end subroutine - - subroutine SetPlugJetsCount(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPlugJetsCount - !DEC$ ATTRIBUTES ALIAS: 'SetPlugJetsCount' :: SetPlugJetsCount - implicit none - integer, intent(in) :: v - BitProblems%PlugJetsCount = v -#ifdef deb - print*, 'PlugJetsCount=', BitProblems%PlugJetsCount -#endif + + subroutine ProcessBitProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + + if(data%problems%BitProblems%PlugJets%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BitProblems%PlugJets, ChangePlugJets, volume) + if(data%problems%BitProblems%JetWashout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BitProblems%JetWashout, ChangeJetWashout, volume) + end subroutine - - subroutine SetJetWashoutCount(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetJetWashoutCount - !DEC$ ATTRIBUTES ALIAS: 'SetJetWashoutCount' :: SetJetWashoutCount - implicit none - integer, intent(in) :: v - BitProblems%JetWashoutCount = v -#ifdef deb - print*, 'JetWashoutCount=', BitProblems%JetWashoutCount -#endif + + subroutine ProcessBitProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + + if(data%problems%BitProblems%PlugJets%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BitProblems%PlugJets, ChangePlugJets, distance) + if(data%problems%BitProblems%JetWashout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BitProblems%JetWashout, ChangeJetWashout, distance) + end subroutine + subroutine ChangePlugJets(status) + USE FricPressDropVarsModule + implicit none + integer, intent (in) :: status + ! if(associated(data%problems%BitProblems%PlugJetsPtr)) call data%problems%BitProblems%PlugJetsPtr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%BitJetsPlugged = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%BitJetsPlugged = 1 + endsubroutine + + subroutine ChangeJetWashout(status) + USE FricPressDropVarsModule + implicit none + integer, intent (in) :: status + ! if(associated(data%problems%BitProblems%JetWashoutPtr)) call data%problems%BitProblems%JetWashoutPtr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%BitJetsWashedOut = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%BitJetsWashedOut = 1 + endsubroutine + + end module CBitProblems \ No newline at end of file diff --git a/CSharp/Problems/CBitProblemsVariables.f90 b/CSharp/Problems/CBitProblemsVariables.f90 index 96a3b04..2239304 100644 --- a/CSharp/Problems/CBitProblemsVariables.f90 +++ b/CSharp/Problems/CBitProblemsVariables.f90 @@ -1,6 +1,5 @@ module CBitProblemsVariables use CProblemDifinition - use CLog3 implicit none public @@ -9,91 +8,8 @@ module CBitProblemsVariables type(CProblem) :: PlugJets type(CProblem) :: JetWashout integer :: PlugJetsCount - integer :: JetWashoutCount - - ! procedure (ActionInteger), pointer :: PlugJetsPtr - ! procedure (ActionInteger), pointer :: JetWashoutPtr + integer :: JetWashoutCount end type BitProblemsType - type(BitProblemsType)::BitProblems - - contains - - subroutine ProcessBitProblemsDueTime(time) - implicit none - integer :: time - if(BitProblems%PlugJets%ProblemType == Time_ProblemType) call ProcessDueTime(BitProblems%PlugJets, ChangePlugJets, time) - if(BitProblems%JetWashout%ProblemType == Time_ProblemType) call ProcessDueTime(BitProblems%JetWashout, ChangeJetWashout, time) - - end subroutine - - subroutine ProcessBitProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - - if(BitProblems%PlugJets%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BitProblems%PlugJets, ChangePlugJets, strokes) - if(BitProblems%JetWashout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BitProblems%JetWashout, ChangeJetWashout, strokes) - - end subroutine - - subroutine ProcessBitProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - - if(BitProblems%PlugJets%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BitProblems%PlugJets, ChangePlugJets, volume) - if(BitProblems%JetWashout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BitProblems%JetWashout, ChangeJetWashout, volume) - - end subroutine - - subroutine ProcessBitProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - - if(BitProblems%PlugJets%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BitProblems%PlugJets, ChangePlugJets, distance) - if(BitProblems%JetWashout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BitProblems%JetWashout, ChangeJetWashout, distance) - - end subroutine - - subroutine ChangePlugJets(status) - USE FricPressDropVarsModule - implicit none - integer, intent (in) :: status - ! if(associated(BitProblems%PlugJetsPtr)) call BitProblems%PlugJetsPtr(status) - if(status == Clear_StatusType) FricPressDropVars%BitJetsPlugged = 0 - if(status == Executed_StatusType) FricPressDropVars%BitJetsPlugged = 1 - endsubroutine - - subroutine ChangeJetWashout(status) - USE FricPressDropVarsModule - implicit none - integer, intent (in) :: status - ! if(associated(BitProblems%JetWashoutPtr)) call BitProblems%JetWashoutPtr(status) - if(status == Clear_StatusType) FricPressDropVars%BitJetsWashedOut = 0 - if(status == Executed_StatusType) FricPressDropVars%BitJetsWashedOut = 1 - endsubroutine - - - - - - - - - - - ! subroutine SubscribePlugJets(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePlugJets - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribePlugJets' :: SubscribePlugJets - ! implicit none - ! procedure (ActionInteger) :: v - ! BitProblems%PlugJetsPtr => v - ! end subroutine - - ! subroutine SubscribeJetWashout(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeJetWashout - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeJetWashout' :: SubscribeJetWashout - ! implicit none - ! procedure (ActionInteger) :: v - ! BitProblems%JetWashoutPtr => v - ! end subroutine + contains end module CBitProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CBopProblems.f90 b/CSharp/Problems/CBopProblems.f90 index ee912ba..164a9a3 100644 --- a/CSharp/Problems/CBopProblems.f90 +++ b/CSharp/Problems/CBopProblems.f90 @@ -1,217 +1,234 @@ module CBopProblems - use CBopProblemsVariables + use ConfigurationVariables implicit none public contains - ! Input routines - - subroutine SetAnnularWash(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAnnularWash - !DEC$ ATTRIBUTES ALIAS: 'SetAnnularWash' :: SetAnnularWash - implicit none - type(CProblem), intent(in) :: v - BopProblems%AnnularWash = SetDue(v, ChangeAnnularWash) -#ifdef deb - print*, 'AnnularWash%ProblemType=', BopProblems%AnnularWash%ProblemType - print*, 'AnnularWash%StatusType=', BopProblems%AnnularWash%StatusType - print*, 'AnnularWash%Value=', BopProblems%AnnularWash%Value -#endif + subroutine ProcessBopProblemsDueTime(time) + implicit none + integer :: time + if(data%problems%BopProblems%AnnularWash%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%AnnularWash, ChangeAnnularWash, time) + if(data%problems%BopProblems%AnnularFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%AnnularFail, ChangeAnnularFail, time) + if(data%problems%BopProblems%AnnularLeak%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%AnnularLeak, ChangeAnnularLeak, time) + if(data%problems%BopProblems%UpperRamWash%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%UpperRamWash, ChangeUpperRamWash, time) + if(data%problems%BopProblems%UpperRamFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%UpperRamFail, ChangeUpperRamFail, time) + if(data%problems%BopProblems%UpperRamLeak%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%UpperRamLeak, ChangeUpperRamLeak, time) + if(data%problems%BopProblems%MiddleRamWash%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%MiddleRamWash, ChangeMiddleRamWash, time) + if(data%problems%BopProblems%MiddleRamFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%MiddleRamFail, ChangeMiddleRamFail, time) + if(data%problems%BopProblems%MiddleRamLeak%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, time) + if(data%problems%BopProblems%LowerRamWash%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%LowerRamWash, ChangeLowerRamWash, time) + if(data%problems%BopProblems%LowerRamFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%LowerRamFail, ChangeLowerRamFail, time) + if(data%problems%BopProblems%LowerRamLeak%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%LowerRamLeak, ChangeLowerRamLeak, time) + if(data%problems%BopProblems%AccumulatorPumpFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, time) + if(data%problems%BopProblems%AccumulatorPumpLeak%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, time) + if(data%problems%BopProblems%AccumulatorSystemFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail, time) + if(data%problems%BopProblems%AccumulatorSystemLeak%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, time) + end subroutine + + subroutine ProcessBopProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + if(data%problems%BopProblems%AnnularWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%AnnularWash, ChangeAnnularWash, strokes) + if(data%problems%BopProblems%AnnularFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%AnnularFail, ChangeAnnularFail, strokes) + if(data%problems%BopProblems%AnnularLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%AnnularLeak, ChangeAnnularLeak, strokes) + if(data%problems%BopProblems%UpperRamWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%UpperRamWash, ChangeUpperRamWash, strokes) + if(data%problems%BopProblems%UpperRamFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%UpperRamFail, ChangeUpperRamFail, strokes) + if(data%problems%BopProblems%UpperRamLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%UpperRamLeak, ChangeUpperRamLeak, strokes) + if(data%problems%BopProblems%MiddleRamWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%MiddleRamWash, ChangeMiddleRamWash, strokes) + if(data%problems%BopProblems%MiddleRamFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%MiddleRamFail, ChangeMiddleRamFail, strokes) + if(data%problems%BopProblems%MiddleRamLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, strokes) + if(data%problems%BopProblems%LowerRamWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%LowerRamWash, ChangeLowerRamWash, strokes) + if(data%problems%BopProblems%LowerRamFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%LowerRamFail, ChangeLowerRamFail, strokes) + if(data%problems%BopProblems%LowerRamLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%LowerRamLeak, ChangeLowerRamLeak, strokes) + if(data%problems%BopProblems%AccumulatorPumpFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, strokes) + if(data%problems%BopProblems%AccumulatorPumpLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, strokes) + if(data%problems%BopProblems%AccumulatorSystemFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail, strokes) + if(data%problems%BopProblems%AccumulatorSystemLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, strokes) + end subroutine + + subroutine ProcessBopProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + if(data%problems%BopProblems%AnnularWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%AnnularWash, ChangeAnnularWash, volume) + if(data%problems%BopProblems%AnnularFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%AnnularFail, ChangeAnnularFail, volume) + if(data%problems%BopProblems%AnnularLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%AnnularLeak, ChangeAnnularLeak, volume) + if(data%problems%BopProblems%UpperRamWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%UpperRamWash, ChangeUpperRamWash, volume) + if(data%problems%BopProblems%UpperRamFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%UpperRamFail, ChangeUpperRamFail, volume) + if(data%problems%BopProblems%UpperRamLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%UpperRamLeak, ChangeUpperRamLeak, volume) + if(data%problems%BopProblems%MiddleRamWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%MiddleRamWash, ChangeMiddleRamWash, volume) + if(data%problems%BopProblems%MiddleRamFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%MiddleRamFail, ChangeMiddleRamFail, volume) + if(data%problems%BopProblems%MiddleRamLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, volume) + if(data%problems%BopProblems%LowerRamWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%LowerRamWash, ChangeLowerRamWash, volume) + if(data%problems%BopProblems%LowerRamFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%LowerRamFail, ChangeLowerRamFail, volume) + if(data%problems%BopProblems%LowerRamLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%LowerRamLeak, ChangeLowerRamLeak, volume) + if(data%problems%BopProblems%AccumulatorPumpFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, volume) + if(data%problems%BopProblems%AccumulatorPumpLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, volume) + if(data%problems%BopProblems%AccumulatorSystemFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail,volume) + if(data%problems%BopProblems%AccumulatorSystemLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, volume) + end subroutine + + subroutine ProcessBopProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + if(data%problems%BopProblems%AnnularWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%AnnularWash, ChangeAnnularWash, distance) + if(data%problems%BopProblems%AnnularFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%AnnularFail, ChangeAnnularFail, distance) + if(data%problems%BopProblems%AnnularLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%AnnularLeak, ChangeAnnularLeak, distance) + if(data%problems%BopProblems%UpperRamWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%UpperRamWash, ChangeUpperRamWash, distance) + if(data%problems%BopProblems%UpperRamFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%UpperRamFail, ChangeUpperRamFail, distance) + if(data%problems%BopProblems%UpperRamLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%UpperRamLeak, ChangeUpperRamLeak, distance) + if(data%problems%BopProblems%MiddleRamWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%MiddleRamWash, ChangeMiddleRamWash, distance) + if(data%problems%BopProblems%MiddleRamFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%MiddleRamFail, ChangeMiddleRamFail, distance) + if(data%problems%BopProblems%MiddleRamLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, distance) + if(data%problems%BopProblems%LowerRamWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%LowerRamWash, ChangeLowerRamWash, distance) + if(data%problems%BopProblems%LowerRamFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%LowerRamFail, ChangeLowerRamFail, distance) + if(data%problems%BopProblems%LowerRamLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%LowerRamLeak, ChangeLowerRamLeak, distance) + if(data%problems%BopProblems%AccumulatorPumpFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, distance) + if(data%problems%BopProblems%AccumulatorPumpLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, distance) + if(data%problems%BopProblems%AccumulatorSystemFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail, distance) + if(data%problems%BopProblems%AccumulatorSystemLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, distance) end subroutine - subroutine SetAnnularFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAnnularFail - !DEC$ ATTRIBUTES ALIAS: 'SetAnnularFail' :: SetAnnularFail - implicit none - type(CProblem), intent(in) :: v - BopProblems%AnnularFail = SetDue(v, ChangeAnnularFail) -#ifdef deb - print*, 'AnnularFail%ProblemType=', BopProblems%AnnularFail%ProblemType - print*, 'AnnularFail%StatusType=', BopProblems%AnnularFail%StatusType - print*, 'AnnularFail%Value=', BopProblems%AnnularFail%Value -#endif - end subroutine - - subroutine SetAnnularLeak(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAnnularLeak - !DEC$ ATTRIBUTES ALIAS: 'SetAnnularLeak' :: SetAnnularLeak - implicit none - type(CProblem), intent(in) :: v - BopProblems%AnnularLeak = SetDue(v, ChangeAnnularLeak) -#ifdef deb - print*, 'AnnularLeak%ProblemType=', BopProblems%AnnularLeak%ProblemType - print*, 'AnnularLeak%StatusType=', BopProblems%AnnularLeak%StatusType - print*, 'AnnularLeak%Value=', BopProblems%AnnularLeak%Value -#endif - end subroutine - - subroutine SetUpperRamWash(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetUpperRamWash - !DEC$ ATTRIBUTES ALIAS: 'SetUpperRamWash' :: SetUpperRamWash - implicit none - type(CProblem), intent(in) :: v - BopProblems%UpperRamWash = SetDue(v, ChangeUpperRamWash) -#ifdef deb - print*, 'UpperRamWash%ProblemType=', BopProblems%UpperRamWash%ProblemType - print*, 'UpperRamWash%StatusType=', BopProblems%UpperRamWash%StatusType - print*, 'UpperRamWash%Value=', BopProblems%UpperRamWash%Value -#endif - end subroutine - subroutine SetUpperRamFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetUpperRamFail - !DEC$ ATTRIBUTES ALIAS: 'SetUpperRamFail' :: SetUpperRamFail - implicit none - type(CProblem), intent(in) :: v - BopProblems%UpperRamFail = SetDue(v, ChangeUpperRamFail) -#ifdef deb - print*, 'UpperRamFail%ProblemType=', BopProblems%UpperRamFail%ProblemType - print*, 'UpperRamFail%StatusType=', BopProblems%UpperRamFail%StatusType - print*, 'UpperRamFail%Value=', BopProblems%UpperRamFail%Value -#endif - end subroutine - - subroutine SetUpperRamLeak(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetUpperRamLeak - !DEC$ ATTRIBUTES ALIAS: 'SetUpperRamLeak' :: SetUpperRamLeak - implicit none - type(CProblem), intent(in) :: v - BopProblems%UpperRamLeak = SetDue(v, ChangeUpperRamLeak) -#ifdef deb - print*, 'UpperRamLeak%ProblemType=', BopProblems%UpperRamLeak%ProblemType - print*, 'UpperRamLeak%StatusType=', BopProblems%UpperRamLeak%StatusType - print*, 'UpperRamLeak%Value=', BopProblems%UpperRamLeak%Value -#endif - end subroutine - - subroutine SetMiddleRamWash(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMiddleRamWash - !DEC$ ATTRIBUTES ALIAS: 'SetMiddleRamWash' :: SetMiddleRamWash - implicit none - type(CProblem), intent(in) :: v - BopProblems%MiddleRamWash = SetDue(v, ChangeMiddleRamWash) -#ifdef deb - print*, 'MiddleRamWash%ProblemType=', BopProblems%MiddleRamWash%ProblemType - print*, 'MiddleRamWash%StatusType=', BopProblems%MiddleRamWash%StatusType - print*, 'MiddleRamWash%Value=', BopProblems%MiddleRamWash%Value -#endif - end subroutine + subroutine ChangeAnnularWash(status) + implicit none + integer, intent (in) :: status + ! ! if(associated(AnnularWashPtr)) call AnnularWashPtr(status) + !if(status == Clear_StatusType) print*,'On_AnnularWash_Clear' + !if(status == Executed_StatusType) print*,'On_AnnularWash_Execute' + endsubroutine - subroutine SetMiddleRamFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMiddleRamFail - !DEC$ ATTRIBUTES ALIAS: 'SetMiddleRamFail' :: SetMiddleRamFail - implicit none - type(CProblem), intent(in) :: v - BopProblems%MiddleRamFail = SetDue(v, ChangeMiddleRamFail) -#ifdef deb - print*, 'MiddleRamFail%ProblemType=', BopProblems%MiddleRamFail%ProblemType - print*, 'MiddleRamFail%StatusType=', BopProblems%MiddleRamFail%StatusType - print*, 'MiddleRamFail%Value=', BopProblems%MiddleRamFail%Value -#endif - end subroutine - - subroutine SetMiddleRamLeak(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMiddleRamLeak - !DEC$ ATTRIBUTES ALIAS: 'SetMiddleRamLeak' :: SetMiddleRamLeak - implicit none - type(CProblem), intent(in) :: v - BopProblems%MiddleRamLeak = SetDue(v, ChangeMiddleRamLeak) -#ifdef deb - print*, 'MiddleRamLeak%ProblemType=', BopProblems%MiddleRamLeak%ProblemType - print*, 'MiddleRamLeak%StatusType=', BopProblems%MiddleRamLeak%StatusType - print*, 'MiddleRamLeak%Value=', BopProblems%MiddleRamLeak%Value -#endif - end subroutine - - subroutine SetLowerRamWash(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetLowerRamWash - !DEC$ ATTRIBUTES ALIAS: 'SetLowerRamWash' :: SetLowerRamWash - implicit none - type(CProblem), intent(in) :: v - BopProblems%LowerRamWash = SetDue(v, ChangeLowerRamWash) -#ifdef deb - print*, 'LowerRamWash%ProblemType=', BopProblems%LowerRamWash%ProblemType - print*, 'LowerRamWash%StatusType=', BopProblems%LowerRamWash%StatusType - print*, 'LowerRamWash%Value=', BopProblems%LowerRamWash%Value -#endif - end subroutine + subroutine ChangeAnnularFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! ! if(associated(AnnularFailPtr)) call AnnularFailPtr(status) + if(status == Clear_StatusType) data%State%Annular%AnnularFailureMalf = 0 + if(status == Executed_StatusType) data%State%Annular%AnnularFailureMalf = 1 + endsubroutine - subroutine SetLowerRamFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetLowerRamFail - !DEC$ ATTRIBUTES ALIAS: 'SetLowerRamFail' :: SetLowerRamFail - implicit none - type(CProblem), intent(in) :: v - BopProblems%LowerRamFail = SetDue(v, ChangeLowerRamFail) -#ifdef deb - print*, 'LowerRamFail%ProblemType=', BopProblems%LowerRamFail%ProblemType - print*, 'LowerRamFail%StatusType=', BopProblems%LowerRamFail%StatusType - print*, 'LowerRamFail%Value=', BopProblems%LowerRamFail%Value -#endif - end subroutine - - subroutine SetLowerRamLeak(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetLowerRamLeak - !DEC$ ATTRIBUTES ALIAS: 'SetLowerRamLeak' :: SetLowerRamLeak - implicit none - type(CProblem), intent(in) :: v - BopProblems%LowerRamLeak = SetDue(v, ChangeLowerRamLeak) -#ifdef deb - print*, 'LowerRamLeak%ProblemType=', BopProblems%LowerRamLeak%ProblemType - print*, 'LowerRamLeak%StatusType=', BopProblems%LowerRamLeak%StatusType - print*, 'LowerRamLeak%Value=', BopProblems%LowerRamLeak%Value -#endif - end subroutine - - subroutine SetAccumulatorPumpFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAccumulatorPumpFail - !DEC$ ATTRIBUTES ALIAS: 'SetAccumulatorPumpFail' :: SetAccumulatorPumpFail - implicit none - type(CProblem), intent(in) :: v - BopProblems%AccumulatorPumpFail = SetDue(v, ChangeAccumulatorPumpFail) -#ifdef deb - print*, 'AccumulatorPumpFail%ProblemType=', BopProblems%AccumulatorPumpFail%ProblemType - print*, 'AccumulatorPumpFail%StatusType=', BopProblems%AccumulatorPumpFail%StatusType - print*, 'AccumulatorPumpFail%Value=', BopProblems%AccumulatorPumpFail%Value -#endif - end subroutine - - subroutine SetAccumulatorPumpLeak(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAccumulatorPumpLeak - !DEC$ ATTRIBUTES ALIAS: 'SetAccumulatorPumpLeak' :: SetAccumulatorPumpLeak - implicit none - type(CProblem), intent(in) :: v - BopProblems%AccumulatorPumpLeak = SetDue(v, ChangeAccumulatorPumpLeak) -#ifdef deb - print*, 'AccumulatorPumpLeak%ProblemType=', BopProblems%AccumulatorPumpLeak%ProblemType - print*, 'AccumulatorPumpLeak%StatusType=', BopProblems%AccumulatorPumpLeak%StatusType - print*, 'AccumulatorPumpLeak%Value=', BopProblems%AccumulatorPumpLeak%Value -#endif - end subroutine - - subroutine SetAccumulatorSystemFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAccumulatorSystemFail - !DEC$ ATTRIBUTES ALIAS: 'SetAccumulatorSystemFail' :: SetAccumulatorSystemFail - implicit none - type(CProblem), intent(in) :: v - BopProblems%AccumulatorSystemFail = SetDue(v, ChangeAccumulatorSystemFail) -#ifdef deb - print*, 'AccumulatorSystemFail%ProblemType=', BopProblems%AccumulatorSystemFail%ProblemType - print*, 'AccumulatorSystemFail%StatusType=', BopProblems%AccumulatorSystemFail%StatusType - print*, 'AccumulatorSystemFail%Value=', BopProblems%AccumulatorSystemFail%Value -#endif - end subroutine - - subroutine SetAccumulatorSystemLeak(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAccumulatorSystemLeak - !DEC$ ATTRIBUTES ALIAS: 'SetAccumulatorSystemLeak' :: SetAccumulatorSystemLeak - implicit none - type(CProblem), intent(in) :: v - BopProblems%AccumulatorSystemLeak = SetDue(v, ChangeAccumulatorSystemLeak) -#ifdef deb - print*, 'AccumulatorSystemLeak%ProblemType=', BopProblems%AccumulatorSystemLeak%ProblemType - print*, 'AccumulatorSystemLeak%StatusType=', BopProblems%AccumulatorSystemLeak%StatusType - print*, 'AccumulatorSystemLeak%Value=', BopProblems%AccumulatorSystemLeak%Value -#endif - end subroutine + subroutine ChangeAnnularLeak(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! ! if(associated(AnnularLeakPtr)) call AnnularLeakPtr(status) + if(status == Clear_StatusType) data%State%Annular%AnnularLeakMalf = 0 + if(status == Executed_StatusType) data%State%Annular%AnnularLeakMalf = 1 + endsubroutine + + + + subroutine ChangeUpperRamWash(status) + implicit none + integer, intent (in) :: status + ! ! if(associated(UpperRamWashPtr)) call UpperRamWashPtr(status) + !if(status == Clear_StatusType) print*,'On_UpperRamWash_Clear' + !if(status == Executed_StatusType) print*,'On_UpperRamWash_Execute' + endsubroutine + + subroutine ChangeUpperRamFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! ! if(associated(UpperRamFailPtr)) call UpperRamFailPtr(status) + if(status == Clear_StatusType) data%State%PipeRam1%UpperRamsFailureMalf = 0 + if(status == Executed_StatusType) data%State%PipeRam1%UpperRamsFailureMalf = 1 + endsubroutine + + subroutine ChangeUpperRamLeak(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! ! if(associated(UpperRamLeakPtr)) call UpperRamLeakPtr(status) + if(status == Clear_StatusType) data%State%PipeRam1%UpperRamsLeakMalf = 0 + if(status == Executed_StatusType) data%State%PipeRam1%UpperRamsLeakMalf = 1 + endsubroutine + + + subroutine ChangeMiddleRamWash(status) + implicit none + integer, intent (in) :: status + ! ! if(associated(MiddleRamWashPtr)) call MiddleRamWashPtr(status) + !if(status == Clear_StatusType) print*,'On_MiddleRamWash_Clear' + !if(status == Executed_StatusType) print*,'On_MiddleRamWash_Execute' + endsubroutine + + subroutine ChangeMiddleRamFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(MiddleRamFailPtr)) call MiddleRamFailPtr(status) + if(status == Clear_StatusType) data%State%ShearRAM%MiddleRamsFailureMalf = 0 + if(status == Executed_StatusType) data%State%ShearRAM%MiddleRamsFailureMalf = 1 + endsubroutine + + subroutine ChangeMiddleRamLeak(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! ! if(associated(MiddleRamLeakPtr)) call MiddleRamLeakPtr(status) + if(status == Clear_StatusType) data%State%ShearRAM%MiddleRamsLeakMalf = 0 + if(status == Executed_StatusType) data%State%ShearRAM%MiddleRamsLeakMalf = 1 + endsubroutine + + + + subroutine ChangeLowerRamWash(status) + implicit none + integer, intent (in) :: status + ! ! if(associated(LowerRamWashPtr)) call LowerRamWashPtr(status) + !if(status == Clear_StatusType) print*,'On_LowerRamWash_Clear' + !if(status == Executed_StatusType) print*,'On_LowerRamWash_Execute' + endsubroutine + + subroutine ChangeLowerRamFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! ! if(associated(LowerRamFailPtr)) call LowerRamFailPtr(status) + if(status == Clear_StatusType) data%State%PipeRam2%LowerRamsFailureMalf = 0 + if(status == Executed_StatusType) data%State%PipeRam2%LowerRamsFailureMalf = 1 + endsubroutine + + subroutine ChangeLowerRamLeak(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(LowerRamLeakPtr)) call LowerRamLeakPtr(status) + if(status == Clear_StatusType) data%State%PipeRam2%LowerRamsLeakMalf = 0 + if(status == Executed_StatusType) data%State%PipeRam2%LowerRamsLeakMalf = 1 + endsubroutine + + subroutine ChangeAccumulatorPumpFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(AccumulatorPumpFailPtr)) call AccumulatorPumpFailPtr(status) + if(status == Clear_StatusType) data%State%BopStackAcc%AccPupmsFailMalf = 0 + if(status == Executed_StatusType) data%State%BopStackAcc%AccPupmsFailMalf = 1 + endsubroutine + + subroutine ChangeAccumulatorPumpLeak(status) + implicit none + integer, intent (in) :: status + ! if(associated(AccumulatorPumpLeakPtr)) call AccumulatorPumpLeakPtr(status) + !if(status == Clear_StatusType) print*,'On_AccumulatorPumpLeak_Clear' + !if(status == Executed_StatusType) print*,'On_AccumulatorPumpLeak_Execute' + endsubroutine + + subroutine ChangeAccumulatorSystemFail(status) + implicit none + integer, intent (in) :: status + ! if(associated(AccumulatorSystemFailPtr)) call AccumulatorSystemFailPtr(status) + !if(status == Clear_StatusType) print*,'On_AccumulatorSystemFail_Clear' + !if(status == Executed_StatusType) print*,'On_AccumulatorSystemFail_Execute' + endsubroutine + + subroutine ChangeAccumulatorSystemLeak(status) + implicit none + integer, intent (in) :: status + ! if(associated(AccumulatorSystemLeakPtr)) call AccumulatorSystemLeakPtr(status) + !if(status == Clear_StatusType) print*,'On_AccumulatorSystemLeak_Clear' + !if(status == Executed_StatusType) print*,'On_AccumulatorSystemLeak_Execute' + endsubroutine end module CBopProblems \ No newline at end of file diff --git a/CSharp/Problems/CBopProblemsVariables.f90 b/CSharp/Problems/CBopProblemsVariables.f90 index ea055bb..63ef15e 100644 --- a/CSharp/Problems/CBopProblemsVariables.f90 +++ b/CSharp/Problems/CBopProblemsVariables.f90 @@ -22,253 +22,9 @@ module CBopProblemsVariables type(CProblem) :: AccumulatorSystemFail type(CProblem) :: AccumulatorSystemLeak end type BopProblemsType - type(BopProblemsType)::BopProblems - - ! procedure (ActionInteger), pointer :: AnnularWashPtr - ! procedure (ActionInteger), pointer :: AnnularFailPtr - ! procedure (ActionInteger), pointer :: AnnularLeakPtr - ! procedure (ActionInteger), pointer :: UpperRamWashPtr - ! procedure (ActionInteger), pointer :: UpperRamFailPtr - ! procedure (ActionInteger), pointer :: UpperRamLeakPtr - ! procedure (ActionInteger), pointer :: MiddleRamWashPtr - ! procedure (ActionInteger), pointer :: MiddleRamFailPtr - ! procedure (ActionInteger), pointer :: MiddleRamLeakPtr - ! procedure (ActionInteger), pointer :: LowerRamWashPtr - ! procedure (ActionInteger), pointer :: LowerRamFailPtr - ! procedure (ActionInteger), pointer :: LowerRamLeakPtr - ! procedure (ActionInteger), pointer :: AccumulatorPumpFailPtr - ! procedure (ActionInteger), pointer :: AccumulatorPumpLeakPtr - ! procedure (ActionInteger), pointer :: AccumulatorSystemFailPtr - ! procedure (ActionInteger), pointer :: AccumulatorSystemLeakPtr - + contains - subroutine ProcessBopProblemsDueTime(time) - implicit none - integer :: time - if(BopProblems%AnnularWash%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%AnnularWash, ChangeAnnularWash, time) - if(BopProblems%AnnularFail%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%AnnularFail, ChangeAnnularFail, time) - if(BopProblems%AnnularLeak%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%AnnularLeak, ChangeAnnularLeak, time) - if(BopProblems%UpperRamWash%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%UpperRamWash, ChangeUpperRamWash, time) - if(BopProblems%UpperRamFail%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%UpperRamFail, ChangeUpperRamFail, time) - if(BopProblems%UpperRamLeak%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%UpperRamLeak, ChangeUpperRamLeak, time) - if(BopProblems%MiddleRamWash%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%MiddleRamWash, ChangeMiddleRamWash, time) - if(BopProblems%MiddleRamFail%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%MiddleRamFail, ChangeMiddleRamFail, time) - if(BopProblems%MiddleRamLeak%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, time) - if(BopProblems%LowerRamWash%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%LowerRamWash, ChangeLowerRamWash, time) - if(BopProblems%LowerRamFail%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%LowerRamFail, ChangeLowerRamFail, time) - if(BopProblems%LowerRamLeak%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%LowerRamLeak, ChangeLowerRamLeak, time) - if(BopProblems%AccumulatorPumpFail%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, time) - if(BopProblems%AccumulatorPumpLeak%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, time) - if(BopProblems%AccumulatorSystemFail%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail, time) - if(BopProblems%AccumulatorSystemLeak%ProblemType == Time_ProblemType) call ProcessDueTime(BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, time) - end subroutine - - subroutine ProcessBopProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - if(BopProblems%AnnularWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%AnnularWash, ChangeAnnularWash, strokes) - if(BopProblems%AnnularFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%AnnularFail, ChangeAnnularFail, strokes) - if(BopProblems%AnnularLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%AnnularLeak, ChangeAnnularLeak, strokes) - if(BopProblems%UpperRamWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%UpperRamWash, ChangeUpperRamWash, strokes) - if(BopProblems%UpperRamFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%UpperRamFail, ChangeUpperRamFail, strokes) - if(BopProblems%UpperRamLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%UpperRamLeak, ChangeUpperRamLeak, strokes) - if(BopProblems%MiddleRamWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%MiddleRamWash, ChangeMiddleRamWash, strokes) - if(BopProblems%MiddleRamFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%MiddleRamFail, ChangeMiddleRamFail, strokes) - if(BopProblems%MiddleRamLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, strokes) - if(BopProblems%LowerRamWash%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%LowerRamWash, ChangeLowerRamWash, strokes) - if(BopProblems%LowerRamFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%LowerRamFail, ChangeLowerRamFail, strokes) - if(BopProblems%LowerRamLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%LowerRamLeak, ChangeLowerRamLeak, strokes) - if(BopProblems%AccumulatorPumpFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, strokes) - if(BopProblems%AccumulatorPumpLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, strokes) - if(BopProblems%AccumulatorSystemFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail, strokes) - if(BopProblems%AccumulatorSystemLeak%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, strokes) - end subroutine - - subroutine ProcessBopProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - if(BopProblems%AnnularWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%AnnularWash, ChangeAnnularWash, volume) - if(BopProblems%AnnularFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%AnnularFail, ChangeAnnularFail, volume) - if(BopProblems%AnnularLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%AnnularLeak, ChangeAnnularLeak, volume) - if(BopProblems%UpperRamWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%UpperRamWash, ChangeUpperRamWash, volume) - if(BopProblems%UpperRamFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%UpperRamFail, ChangeUpperRamFail, volume) - if(BopProblems%UpperRamLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%UpperRamLeak, ChangeUpperRamLeak, volume) - if(BopProblems%MiddleRamWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%MiddleRamWash, ChangeMiddleRamWash, volume) - if(BopProblems%MiddleRamFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%MiddleRamFail, ChangeMiddleRamFail, volume) - if(BopProblems%MiddleRamLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, volume) - if(BopProblems%LowerRamWash%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%LowerRamWash, ChangeLowerRamWash, volume) - if(BopProblems%LowerRamFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%LowerRamFail, ChangeLowerRamFail, volume) - if(BopProblems%LowerRamLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%LowerRamLeak, ChangeLowerRamLeak, volume) - if(BopProblems%AccumulatorPumpFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, volume) - if(BopProblems%AccumulatorPumpLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, volume) - if(BopProblems%AccumulatorSystemFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail,volume) - if(BopProblems%AccumulatorSystemLeak%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, volume) - end subroutine - - subroutine ProcessBopProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - if(BopProblems%AnnularWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%AnnularWash, ChangeAnnularWash, distance) - if(BopProblems%AnnularFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%AnnularFail, ChangeAnnularFail, distance) - if(BopProblems%AnnularLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%AnnularLeak, ChangeAnnularLeak, distance) - if(BopProblems%UpperRamWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%UpperRamWash, ChangeUpperRamWash, distance) - if(BopProblems%UpperRamFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%UpperRamFail, ChangeUpperRamFail, distance) - if(BopProblems%UpperRamLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%UpperRamLeak, ChangeUpperRamLeak, distance) - if(BopProblems%MiddleRamWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%MiddleRamWash, ChangeMiddleRamWash, distance) - if(BopProblems%MiddleRamFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%MiddleRamFail, ChangeMiddleRamFail, distance) - if(BopProblems%MiddleRamLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%MiddleRamLeak, ChangeMiddleRamLeak, distance) - if(BopProblems%LowerRamWash%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%LowerRamWash, ChangeLowerRamWash, distance) - if(BopProblems%LowerRamFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%LowerRamFail, ChangeLowerRamFail, distance) - if(BopProblems%LowerRamLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%LowerRamLeak, ChangeLowerRamLeak, distance) - if(BopProblems%AccumulatorPumpFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%AccumulatorPumpFail, ChangeAccumulatorPumpFail, distance) - if(BopProblems%AccumulatorPumpLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%AccumulatorPumpLeak, ChangeAccumulatorPumpLeak, distance) - if(BopProblems%AccumulatorSystemFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%AccumulatorSystemFail, ChangeAccumulatorSystemFail, distance) - if(BopProblems%AccumulatorSystemLeak%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(BopProblems%AccumulatorSystemLeak, ChangeAccumulatorSystemLeak, distance) - end subroutine - - - subroutine ChangeAnnularWash(status) - implicit none - integer, intent (in) :: status - ! ! if(associated(AnnularWashPtr)) call AnnularWashPtr(status) - !if(status == Clear_StatusType) print*,'On_AnnularWash_Clear' - !if(status == Executed_StatusType) print*,'On_AnnularWash_Execute' - endsubroutine - - subroutine ChangeAnnularFail(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! ! if(associated(AnnularFailPtr)) call AnnularFailPtr(status) - if(status == Clear_StatusType) Annular%AnnularFailureMalf = 0 - if(status == Executed_StatusType) Annular%AnnularFailureMalf = 1 - endsubroutine - - subroutine ChangeAnnularLeak(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! ! if(associated(AnnularLeakPtr)) call AnnularLeakPtr(status) - if(status == Clear_StatusType) Annular%AnnularLeakMalf = 0 - if(status == Executed_StatusType) Annular%AnnularLeakMalf = 1 - endsubroutine - - - - subroutine ChangeUpperRamWash(status) - implicit none - integer, intent (in) :: status - ! ! if(associated(UpperRamWashPtr)) call UpperRamWashPtr(status) - !if(status == Clear_StatusType) print*,'On_UpperRamWash_Clear' - !if(status == Executed_StatusType) print*,'On_UpperRamWash_Execute' - endsubroutine - - subroutine ChangeUpperRamFail(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! ! if(associated(UpperRamFailPtr)) call UpperRamFailPtr(status) - if(status == Clear_StatusType) PipeRam1%UpperRamsFailureMalf = 0 - if(status == Executed_StatusType) PipeRam1%UpperRamsFailureMalf = 1 - endsubroutine - - subroutine ChangeUpperRamLeak(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! ! if(associated(UpperRamLeakPtr)) call UpperRamLeakPtr(status) - if(status == Clear_StatusType) PipeRam1%UpperRamsLeakMalf = 0 - if(status == Executed_StatusType) PipeRam1%UpperRamsLeakMalf = 1 - endsubroutine - - - subroutine ChangeMiddleRamWash(status) - implicit none - integer, intent (in) :: status - ! ! if(associated(MiddleRamWashPtr)) call MiddleRamWashPtr(status) - !if(status == Clear_StatusType) print*,'On_MiddleRamWash_Clear' - !if(status == Executed_StatusType) print*,'On_MiddleRamWash_Execute' - endsubroutine - - subroutine ChangeMiddleRamFail(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(MiddleRamFailPtr)) call MiddleRamFailPtr(status) - if(status == Clear_StatusType) ShearRam%MiddleRamsFailureMalf = 0 - if(status == Executed_StatusType) ShearRam%MiddleRamsFailureMalf = 1 - endsubroutine - - subroutine ChangeMiddleRamLeak(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! ! if(associated(MiddleRamLeakPtr)) call MiddleRamLeakPtr(status) - if(status == Clear_StatusType) ShearRam%MiddleRamsLeakMalf = 0 - if(status == Executed_StatusType) ShearRam%MiddleRamsLeakMalf = 1 - endsubroutine - - - - subroutine ChangeLowerRamWash(status) - implicit none - integer, intent (in) :: status - ! ! if(associated(LowerRamWashPtr)) call LowerRamWashPtr(status) - !if(status == Clear_StatusType) print*,'On_LowerRamWash_Clear' - !if(status == Executed_StatusType) print*,'On_LowerRamWash_Execute' - endsubroutine - - subroutine ChangeLowerRamFail(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! ! if(associated(LowerRamFailPtr)) call LowerRamFailPtr(status) - if(status == Clear_StatusType) PipeRam2%LowerRamsFailureMalf = 0 - if(status == Executed_StatusType) PipeRam2%LowerRamsFailureMalf = 1 - endsubroutine - - subroutine ChangeLowerRamLeak(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(LowerRamLeakPtr)) call LowerRamLeakPtr(status) - if(status == Clear_StatusType) PipeRam2%LowerRamsLeakMalf = 0 - if(status == Executed_StatusType) PipeRam2%LowerRamsLeakMalf = 1 - endsubroutine - - subroutine ChangeAccumulatorPumpFail(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(AccumulatorPumpFailPtr)) call AccumulatorPumpFailPtr(status) - if(status == Clear_StatusType) BopStackAcc%AccPupmsFailMalf = 0 - if(status == Executed_StatusType) BopStackAcc%AccPupmsFailMalf = 1 - endsubroutine - - subroutine ChangeAccumulatorPumpLeak(status) - implicit none - integer, intent (in) :: status - ! if(associated(AccumulatorPumpLeakPtr)) call AccumulatorPumpLeakPtr(status) - !if(status == Clear_StatusType) print*,'On_AccumulatorPumpLeak_Clear' - !if(status == Executed_StatusType) print*,'On_AccumulatorPumpLeak_Execute' - endsubroutine - - subroutine ChangeAccumulatorSystemFail(status) - implicit none - integer, intent (in) :: status - ! if(associated(AccumulatorSystemFailPtr)) call AccumulatorSystemFailPtr(status) - !if(status == Clear_StatusType) print*,'On_AccumulatorSystemFail_Clear' - !if(status == Executed_StatusType) print*,'On_AccumulatorSystemFail_Execute' - endsubroutine - - subroutine ChangeAccumulatorSystemLeak(status) - implicit none - integer, intent (in) :: status - ! if(associated(AccumulatorSystemLeakPtr)) call AccumulatorSystemLeakPtr(status) - !if(status == Clear_StatusType) print*,'On_AccumulatorSystemLeak_Clear' - !if(status == Executed_StatusType) print*,'On_AccumulatorSystemLeak_Execute' - endsubroutine diff --git a/CSharp/Problems/CChokeProblems.f90 b/CSharp/Problems/CChokeProblems.f90 index 0acddc9..06089cd 100644 --- a/CSharp/Problems/CChokeProblems.f90 +++ b/CSharp/Problems/CChokeProblems.f90 @@ -1,221 +1,223 @@ module CChokeProblems - use CChokeProblemsVariables + use ConfigurationVariables implicit none public - contains - - ! Input routines - subroutine SetHydraulicChoke1Plugged(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke1Plugged - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke1Plugged' :: SetHydraulicChoke1Plugged - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%HydraulicChoke1Plugged = SetDue(v, ChangeHydraulicChoke1Plugged) -#ifdef deb - print*, 'HydraulicChoke1Plugged%ProblemType=', ChokeProblems%HydraulicChoke1Plugged%ProblemType - print*, 'HydraulicChoke1Plugged%StatusType=', ChokeProblems%HydraulicChoke1Plugged%StatusType - print*, 'HydraulicChoke1Plugged%Value=', ChokeProblems%HydraulicChoke1Plugged%Value -#endif - end subroutine - - subroutine SetHydraulicChoke1Fail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke1Fail - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke1Fail' :: SetHydraulicChoke1Fail - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%HydraulicChoke1Fail = SetDue(v, ChangeHydraulicChoke1Fail) -#ifdef deb - print*, 'HydraulicChoke1Fail%ProblemType=', ChokeProblems%HydraulicChoke1Fail%ProblemType - print*, 'HydraulicChoke1Fail%StatusType=', ChokeProblems%HydraulicChoke1Fail%StatusType - print*, 'HydraulicChoke1Fail%Value=', ChokeProblems%HydraulicChoke1Fail%Value -#endif - end subroutine - - subroutine SetHydraulicChoke1Washout(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke1Washout - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke1Washout' :: SetHydraulicChoke1Washout - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%HydraulicChoke1Washout = SetDue(v, ChangeHydraulicChoke1Washout) -#ifdef deb - print*, 'HydraulicChoke1Washout%ProblemType=', ChokeProblems%HydraulicChoke1Washout%ProblemType - print*, 'HydraulicChoke1Washout%StatusType=', ChokeProblems%HydraulicChoke1Washout%StatusType - print*, 'HydraulicChoke1Washout%Value=', ChokeProblems%HydraulicChoke1Washout%Value -#endif - end subroutine - - subroutine SetHydraulicChoke1PluggedPercent(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke1PluggedPercent - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke1PluggedPercent' :: SetHydraulicChoke1PluggedPercent - implicit none - integer, intent(in) :: v - ChokeProblems%HydraulicChoke1PluggedPercent = v -#ifdef deb - print*, 'HydraulicChoke1PluggedPercent=', ChokeProblems%HydraulicChoke1PluggedPercent -#endif - end subroutine - - subroutine SetHydraulicChoke2Plugged(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke2Plugged - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke2Plugged' :: SetHydraulicChoke2Plugged - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%HydraulicChoke2Plugged = SetDue(v, ChangeHydraulicChoke2Plugged) -#ifdef deb - print*, 'HydraulicChoke2Plugged%ProblemType=', ChokeProblems%HydraulicChoke2Plugged%ProblemType - print*, 'HydraulicChoke2Plugged%StatusType=', ChokeProblems%HydraulicChoke2Plugged%StatusType - print*, 'HydraulicChoke2Plugged%Value=', ChokeProblems%HydraulicChoke2Plugged%Value -#endif - end subroutine - - subroutine SetHydraulicChoke2Fail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke2Fail - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke2Fail' :: SetHydraulicChoke2Fail - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%HydraulicChoke2Fail = SetDue(v, ChangeHydraulicChoke2Fail) -#ifdef deb - print*, 'HydraulicChoke2Fail%ProblemType=', ChokeProblems%HydraulicChoke2Fail%ProblemType - print*, 'HydraulicChoke2Fail%StatusType=', ChokeProblems%HydraulicChoke2Fail%StatusType - print*, 'HydraulicChoke2Fail%Value=', ChokeProblems%HydraulicChoke2Fail%Value -#endif - end subroutine - - subroutine SetHydraulicChoke2Washout(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke2Washout - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke2Washout' :: SetHydraulicChoke2Washout - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%HydraulicChoke2Washout = SetDue(v, ChangeHydraulicChoke2Washout) -#ifdef deb - print*, 'HydraulicChoke2Washout%ProblemType=', ChokeProblems%HydraulicChoke2Washout%ProblemType - print*, 'HydraulicChoke2Washout%StatusType=', ChokeProblems%HydraulicChoke2Washout%StatusType - print*, 'HydraulicChoke2Washout%Value=', ChokeProblems%HydraulicChoke2Washout%Value -#endif - end subroutine - - subroutine SetHydraulicChoke2PluggedPercent(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetHydraulicChoke2PluggedPercent - !DEC$ ATTRIBUTES ALIAS: 'SetHydraulicChoke2PluggedPercent' :: SetHydraulicChoke2PluggedPercent - implicit none - integer, intent(in) :: v - ChokeProblems%HydraulicChoke2PluggedPercent = v -#ifdef deb - print*, 'HydraulicChoke2PluggedPercent=', ChokeProblems%HydraulicChoke2PluggedPercent -#endif - end subroutine - - subroutine SetManualChoke1Plugged(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualChoke1Plugged - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke1Plugged' :: SetManualChoke1Plugged - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%ManualChoke1Plugged = SetDue(v, ChangeManualChoke1Plugged) -#ifdef deb - print*, 'ManualChoke1Plugged%ProblemType=', ChokeProblems%ManualChoke1Plugged%ProblemType - print*, 'ManualChoke1Plugged%StatusType=', ChokeProblems%ManualChoke1Plugged%StatusType - print*, 'ManualChoke1Plugged%Value=', ChokeProblems%ManualChoke1Plugged%Value -#endif - end subroutine - - subroutine SetManualChoke1Fail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualChoke1Fail - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke1Fail' :: SetManualChoke1Fail - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%ManualChoke1Fail = SetDue(v, ChangeManualChoke1Fail) -#ifdef deb - print*, 'ManualChoke1Fail%ProblemType=', ChokeProblems%ManualChoke1Fail%ProblemType - print*, 'ManualChoke1Fail%StatusType=', ChokeProblems%ManualChoke1Fail%StatusType - print*, 'ManualChoke1Fail%Value=', ChokeProblems%ManualChoke1Fail%Value -#endif - end subroutine - - subroutine SetManualChoke1Washout(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualChoke1Washout - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke1Washout' :: SetManualChoke1Washout - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%ManualChoke1Washout = SetDue(v, ChangeManualChoke1Washout) -#ifdef deb - print*, 'ManualChoke1Washout%ProblemType=', ChokeProblems%ManualChoke1Washout%ProblemType - print*, 'ManualChoke1Washout%StatusType=', ChokeProblems%ManualChoke1Washout%StatusType - print*, 'ManualChoke1Washout%Value=', ChokeProblems%ManualChoke1Washout%Value -#endif - end subroutine - - subroutine SetManualChoke1PluggedPercent(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualChoke1PluggedPercent - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke1PluggedPercent' :: SetManualChoke1PluggedPercent - implicit none - integer, intent(in) :: v - ChokeProblems%ManualChoke1PluggedPercent = v -#ifdef deb - print*, 'ManualChoke1PluggedPercent=', ChokeProblems%ManualChoke1PluggedPercent -#endif - end subroutine - - subroutine SetManualChoke2Plugged(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualChoke2Plugged - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke2Plugged' :: SetManualChoke2Plugged - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%ManualChoke2Plugged = SetDue(v, ChangeManualChoke2Plugged) -#ifdef deb - print*, 'ManualChoke2Plugged%ProblemType=', ChokeProblems%ManualChoke2Plugged%ProblemType - print*, 'ManualChoke2Plugged%StatusType=', ChokeProblems%ManualChoke2Plugged%StatusType - print*, 'ManualChoke2Plugged%Value=', ChokeProblems%ManualChoke2Plugged%Value -#endif - end subroutine - - subroutine SetManualChoke2Fail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualChoke2Fail - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke2Fail' :: SetManualChoke2Fail - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%ManualChoke2Fail = SetDue(v, ChangeManualChoke2Fail) -#ifdef deb - print*, 'ManualChoke2Fail%ProblemType=', ChokeProblems%ManualChoke2Fail%ProblemType - print*, 'ManualChoke2Fail%StatusType=', ChokeProblems%ManualChoke2Fail%StatusType - print*, 'ManualChoke2Fail%Value=', ChokeProblems%ManualChoke2Fail%Value -#endif - end subroutine - - subroutine SetManualChoke2Washout(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManualChoke2Washout - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke2Washout' :: SetManualChoke2Washout - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%ManualChoke2Washout = SetDue(v, ChangeManualChoke2Washout) -#ifdef deb - print*, 'ManualChoke2Washout%ProblemType=', ChokeProblems%ManualChoke2Washout%ProblemType - print*, 'ManualChoke2Washout%StatusType=', ChokeProblems%ManualChoke2Washout%StatusType - print*, 'ManualChoke2Washout%Value=', ChokeProblems%ManualChoke2Washout%Value -#endif - end subroutine - - subroutine SetManualChoke2PluggedPercent(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManu alChoke2PluggedPercent - !DEC$ ATTRIBUTES ALIAS: 'SetManualChoke2PluggedPercent' :: SetManualChoke2PluggedPercent - implicit none - integer, intent(in) :: v - ChokeProblems%ManualChoke2PluggedPercent = v -#ifdef deb - print*, 'ManualChoke2PluggedPercent=', ChokeProblems%ManualChoke2PluggedPercent -#endif - end subroutine - - subroutine SetChokePanelAirFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokePanelAirFail - !DEC$ ATTRIBUTES ALIAS: 'SetChokePanelAirFail' :: SetChokePanelAirFail - implicit none - type(CProblem), intent(in) :: v - ChokeProblems%ChokePanelAirFail = SetDue(v, ChangeChokePanelAirFail) -#ifdef deb - print*, 'ChokePanelAirFail%ProblemType=', ChokeProblems%ChokePanelAirFail%ProblemType - print*, 'ChokePanelAirFail%StatusType=', ChokeProblems%ChokePanelAirFail%StatusType - print*, 'ChokePanelAirFail%Value=', ChokeProblems%ChokePanelAirFail%Value -#endif + contains + subroutine ProcessChokeProblemsDueTime(time) + implicit none + integer :: time + if(data%problems%ChokeProblems%HydraulicChoke1Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, time) + if(data%problems%ChokeProblems%HydraulicChoke1Fail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, time) + if(data%problems%ChokeProblems%HydraulicChoke1Washout%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, time) + if(data%problems%ChokeProblems%HydraulicChoke2Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, time) + if(data%problems%ChokeProblems%HydraulicChoke2Fail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, time) + if(data%problems%ChokeProblems%HydraulicChoke2Washout%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, time) + if(data%problems%ChokeProblems%ManualChoke1Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, time) + if(data%problems%ChokeProblems%ManualChoke1Fail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, time) + if(data%problems%ChokeProblems%ManualChoke1Washout%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, time) + if(data%problems%ChokeProblems%ManualChoke2Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, time) + if(data%problems%ChokeProblems%ManualChoke2Fail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, time) + if(data%problems%ChokeProblems%ManualChoke2Washout%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, time) + if(data%problems%ChokeProblems%ChokePanelAirFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, time) end subroutine - + + subroutine ProcessChokeProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + if(data%problems%ChokeProblems%HydraulicChoke1Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, strokes) + if(data%problems%ChokeProblems%HydraulicChoke1Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, strokes) + if(data%problems%ChokeProblems%HydraulicChoke1Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, strokes) + if(data%problems%ChokeProblems%HydraulicChoke2Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, strokes) + if(data%problems%ChokeProblems%HydraulicChoke2Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, strokes) + if(data%problems%ChokeProblems%HydraulicChoke2Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, strokes) + if(data%problems%ChokeProblems%ManualChoke1Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, strokes) + if(data%problems%ChokeProblems%ManualChoke1Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, strokes) + if(data%problems%ChokeProblems%ManualChoke1Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, strokes) + if(data%problems%ChokeProblems%ManualChoke2Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, strokes) + if(data%problems%ChokeProblems%ManualChoke2Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, strokes) + if(data%problems%ChokeProblems%ManualChoke2Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, strokes) + if(data%problems%ChokeProblems%ChokePanelAirFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, strokes) + end subroutine + + subroutine ProcessChokeProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + if(data%problems%ChokeProblems%HydraulicChoke1Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, volume) + if(data%problems%ChokeProblems%HydraulicChoke1Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, volume) + if(data%problems%ChokeProblems%HydraulicChoke1Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, volume) + if(data%problems%ChokeProblems%HydraulicChoke2Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, volume) + if(data%problems%ChokeProblems%HydraulicChoke2Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, volume) + if(data%problems%ChokeProblems%HydraulicChoke2Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, volume) + if(data%problems%ChokeProblems%ManualChoke1Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, volume) + if(data%problems%ChokeProblems%ManualChoke1Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, volume) + if(data%problems%ChokeProblems%ManualChoke1Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, volume) + if(data%problems%ChokeProblems%ManualChoke2Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, volume) + if(data%problems%ChokeProblems%ManualChoke2Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, volume) + if(data%problems%ChokeProblems%ManualChoke2Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, volume) + if(data%problems%ChokeProblems%ChokePanelAirFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, volume) + end subroutine + + subroutine ProcessChokeProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + if(data%problems%ChokeProblems%HydraulicChoke1Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, distance) + if(data%problems%ChokeProblems%HydraulicChoke1Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, distance) + if(data%problems%ChokeProblems%HydraulicChoke1Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, distance) + if(data%problems%ChokeProblems%HydraulicChoke2Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, distance) + if(data%problems%ChokeProblems%HydraulicChoke2Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, distance) + if(data%problems%ChokeProblems%HydraulicChoke2Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, distance) + if(data%problems%ChokeProblems%ManualChoke1Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, distance) + if(data%problems%ChokeProblems%ManualChoke1Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, distance) + if(data%problems%ChokeProblems%ManualChoke1Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, distance) + if(data%problems%ChokeProblems%ManualChoke2Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, distance) + if(data%problems%ChokeProblems%ManualChoke2Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, distance) + if(data%problems%ChokeProblems%ManualChoke2Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, distance) + if(data%problems%ChokeProblems%ChokePanelAirFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, distance) + end subroutine + + + + + subroutine ChangeHydraulicChoke1Plugged(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(HydraulicChoke1PluggedPtr)) call HydraulicChoke1PluggedPtr(status) + if(status == Clear_StatusType) data%State%CHOOKE(1)%PlugMalf = 0 + if(status == Executed_StatusType) data%State%CHOOKE(1)%PlugMalf = 1 + endsubroutine + + subroutine ChangeHydraulicChoke1Fail(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(HydraulicChoke1FailPtr)) call HydraulicChoke1FailPtr(status) + if(status == Clear_StatusType) data%State%CHOOKE(1)%FailMalf = 0 + if(status == Executed_StatusType) data%State%CHOOKE(1)%FailMalf = 1 + endsubroutine + + subroutine ChangeHydraulicChoke1Washout(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + use CChokeManifoldVariables + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(HydraulicChoke1WashoutPtr)) call HydraulicChoke1WashoutPtr(status) + if(status == Clear_StatusType) data%State%CHOOKE(1)%WashoutMalf = 0 + if(status == Executed_StatusType) data%State%CHOOKE(1)%WashoutMalf = 1 + + if(status == Clear_StatusType) data%EquipmentControl%ChokeManifold%HyChock1OnProblem = .false. + if(status == Executed_StatusType) data%EquipmentControl%ChokeManifold%HyChock1OnProblem = .true. + endsubroutine + + subroutine ChangeHydraulicChoke2Plugged(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(HydraulicChoke2PluggedPtr)) call HydraulicChoke2PluggedPtr(status) + if(status == Clear_StatusType) data%State%CHOOKE(2)%PlugMalf = 0 + if(status == Executed_StatusType) data%State%CHOOKE(2)%PlugMalf = 1 + endsubroutine + + subroutine ChangeHydraulicChoke2Fail(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(HydraulicChoke2FailPtr)) call HydraulicChoke2FailPtr(status) + if(status == Clear_StatusType) data%State%CHOOKE(2)%FailMalf = 0 + if(status == Executed_StatusType) data%State%CHOOKE(2)%FailMalf = 1 + endsubroutine + + subroutine ChangeHydraulicChoke2Washout(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + use CChokeManifoldVariables + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(HydraulicChoke2WashoutPtr)) call HydraulicChoke2WashoutPtr(status) + if(status == Clear_StatusType) data%State%CHOOKE(2)%WashoutMalf = 0 + if(status == Executed_StatusType) data%State%CHOOKE(2)%WashoutMalf = 1 + + if(status == Clear_StatusType) data%EquipmentControl%ChokeManifold%HyChock2OnProblem = .false. + if(status == Executed_StatusType) data%EquipmentControl%ChokeManifold%HyChock2OnProblem = .true. + endsubroutine + + subroutine ChangeManualChoke1Plugged(status) + USE FricPressDropVarsModule + implicit none + integer, intent (in) :: status + ! if(associated(ManualChoke1PluggedPtr)) call ManualChoke1PluggedPtr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%ManChoke1Plug = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%ManChoke1Plug = 1 + endsubroutine + + subroutine ChangeManualChoke1Fail(status) + implicit none + integer, intent (in) :: status + ! if(associated(ManualChoke1FailPtr)) call ManualChoke1FailPtr(status) + !if(status == Clear_StatusType) print*,'On_ManualChoke1Fail_Clear' + !if(status == Executed_StatusType) print*,'On_ManualChoke1Fail_Execute' + endsubroutine + + subroutine ChangeManualChoke1Washout(status) + USE FricPressDropVarsModule + use CChokeManifoldVariables + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(ManualChoke1WashoutPtr)) call ManualChoke1WashoutPtr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%ManChoke1Washout = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%ManChoke1Washout = 1 + + if(status == Clear_StatusType) data%EquipmentControl%ChokeManifold%LeftManChokeOnProblem = .false. + if(status == Executed_StatusType) data%EquipmentControl%ChokeManifold%LeftManChokeOnProblem = .true. + endsubroutine + + subroutine ChangeManualChoke2Plugged(status) + USE FricPressDropVarsModule + implicit none + integer, intent (in) :: status + ! if(associated(ManualChoke2PluggedPtr)) call ManualChoke2PluggedPtr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%ManChoke2Plug = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%ManChoke2Plug = 1 + endsubroutine + + subroutine ChangeManualChoke2Fail(status) + implicit none + integer, intent (in) :: status + ! if(associated(ManualChoke2FailPtr)) call ManualChoke2FailPtr(status) + !if(status == Clear_StatusType) print*,'On_ManualChoke2Fail_Clear' + !if(status == Executed_StatusType) print*,'On_ManualChoke2Fail_Execute' + endsubroutine + + subroutine ChangeManualChoke2Washout(status) + USE FricPressDropVarsModule + use CChokeManifoldVariables + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(ManualChoke2WashoutPtr)) call ManualChoke2WashoutPtr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%ManChoke2Washout = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%ManChoke2Washout = 1 + + if(status == Clear_StatusType) data%EquipmentControl%ChokeManifold%RightManChokeOnProblem = .false. + if(status == Executed_StatusType) data%EquipmentControl%ChokeManifold%RightManChokeOnProblem = .true. + endsubroutine + + subroutine ChangeChokePanelAirFail(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(ChokePanelAirFailPtr)) call ChokePanelAirFailPtr(status) + if(status == Clear_StatusType) data%State%AirDrivenPump%ChokeAirFail = 0 + if(status == Executed_StatusType) data%State%AirDrivenPump%ChokeAirFail = 1 + endsubroutine + end module CChokeProblems \ No newline at end of file diff --git a/CSharp/Problems/CChokeProblemsVariables.f90 b/CSharp/Problems/CChokeProblemsVariables.f90 index 1145b48..d100e11 100644 --- a/CSharp/Problems/CChokeProblemsVariables.f90 +++ b/CSharp/Problems/CChokeProblemsVariables.f90 @@ -24,346 +24,7 @@ module CChokeProblemsVariables integer :: ManualChoke2PluggedPercent type(CProblem) :: ChokePanelAirFail end type ChokeProblemsType - type(ChokeProblemsType)::ChokeProblems - ! procedure (ActionInteger), pointer :: HydraulicChoke1PluggedPtr - ! procedure (ActionInteger), pointer :: HydraulicChoke1FailPtr - ! procedure (ActionInteger), pointer :: HydraulicChoke1WashoutPtr - ! procedure (ActionInteger), pointer :: HydraulicChoke2PluggedPtr - ! procedure (ActionInteger), pointer :: HydraulicChoke2FailPtr - ! procedure (ActionInteger), pointer :: HydraulicChoke2WashoutPtr - ! procedure (ActionInteger), pointer :: ManualChoke1PluggedPtr - ! procedure (ActionInteger), pointer :: ManualChoke1FailPtr - ! procedure (ActionInteger), pointer :: ManualChoke1WashoutPtr - ! procedure (ActionInteger), pointer :: ManualChoke2PluggedPtr - ! procedure (ActionInteger), pointer :: ManualChoke2FailPtr - ! procedure (ActionInteger), pointer :: ManualChoke2WashoutPtr - ! procedure (ActionInteger), pointer :: ChokePanelAirFailPtr - contains - - subroutine ProcessChokeProblemsDueTime(time) - implicit none - integer :: time - if(ChokeProblems%HydraulicChoke1Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, time) - if(ChokeProblems%HydraulicChoke1Fail%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, time) - if(ChokeProblems%HydraulicChoke1Washout%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, time) - if(ChokeProblems%HydraulicChoke2Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, time) - if(ChokeProblems%HydraulicChoke2Fail%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, time) - if(ChokeProblems%HydraulicChoke2Washout%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, time) - if(ChokeProblems%ManualChoke1Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, time) - if(ChokeProblems%ManualChoke1Fail%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, time) - if(ChokeProblems%ManualChoke1Washout%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, time) - if(ChokeProblems%ManualChoke2Plugged%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, time) - if(ChokeProblems%ManualChoke2Fail%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, time) - if(ChokeProblems%ManualChoke2Washout%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, time) - if(ChokeProblems%ChokePanelAirFail%ProblemType == Time_ProblemType) call ProcessDueTime(ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, time) - end subroutine - - subroutine ProcessChokeProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - if(ChokeProblems%HydraulicChoke1Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, strokes) - if(ChokeProblems%HydraulicChoke1Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, strokes) - if(ChokeProblems%HydraulicChoke1Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, strokes) - if(ChokeProblems%HydraulicChoke2Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, strokes) - if(ChokeProblems%HydraulicChoke2Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, strokes) - if(ChokeProblems%HydraulicChoke2Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, strokes) - if(ChokeProblems%ManualChoke1Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, strokes) - if(ChokeProblems%ManualChoke1Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, strokes) - if(ChokeProblems%ManualChoke1Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, strokes) - if(ChokeProblems%ManualChoke2Plugged%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, strokes) - if(ChokeProblems%ManualChoke2Fail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, strokes) - if(ChokeProblems%ManualChoke2Washout%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, strokes) - if(ChokeProblems%ChokePanelAirFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, strokes) - end subroutine - - subroutine ProcessChokeProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - if(ChokeProblems%HydraulicChoke1Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, volume) - if(ChokeProblems%HydraulicChoke1Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, volume) - if(ChokeProblems%HydraulicChoke1Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, volume) - if(ChokeProblems%HydraulicChoke2Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, volume) - if(ChokeProblems%HydraulicChoke2Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, volume) - if(ChokeProblems%HydraulicChoke2Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, volume) - if(ChokeProblems%ManualChoke1Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, volume) - if(ChokeProblems%ManualChoke1Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, volume) - if(ChokeProblems%ManualChoke1Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, volume) - if(ChokeProblems%ManualChoke2Plugged%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, volume) - if(ChokeProblems%ManualChoke2Fail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, volume) - if(ChokeProblems%ManualChoke2Washout%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, volume) - if(ChokeProblems%ChokePanelAirFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, volume) - end subroutine - - subroutine ProcessChokeProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - if(ChokeProblems%HydraulicChoke1Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%HydraulicChoke1Plugged, ChangeHydraulicChoke1Plugged, distance) - if(ChokeProblems%HydraulicChoke1Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%HydraulicChoke1Fail, ChangeHydraulicChoke1Fail, distance) - if(ChokeProblems%HydraulicChoke1Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%HydraulicChoke1Washout, ChangeHydraulicChoke1Washout, distance) - if(ChokeProblems%HydraulicChoke2Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%HydraulicChoke2Plugged, ChangeHydraulicChoke2Plugged, distance) - if(ChokeProblems%HydraulicChoke2Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%HydraulicChoke2Fail, ChangeHydraulicChoke2Fail, distance) - if(ChokeProblems%HydraulicChoke2Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%HydraulicChoke2Washout, ChangeHydraulicChoke2Washout, distance) - if(ChokeProblems%ManualChoke1Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%ManualChoke1Plugged, ChangeManualChoke1Plugged, distance) - if(ChokeProblems%ManualChoke1Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%ManualChoke1Fail, ChangeManualChoke1Fail, distance) - if(ChokeProblems%ManualChoke1Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%ManualChoke1Washout, ChangeManualChoke1Washout, distance) - if(ChokeProblems%ManualChoke2Plugged%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%ManualChoke2Plugged, ChangeManualChoke2Plugged, distance) - if(ChokeProblems%ManualChoke2Fail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%ManualChoke2Fail, ChangeManualChoke2Fail, distance) - if(ChokeProblems%ManualChoke2Washout%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%ManualChoke2Washout, ChangeManualChoke2Washout, distance) - if(ChokeProblems%ChokePanelAirFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(ChokeProblems%ChokePanelAirFail, ChangeChokePanelAirFail, distance) - end subroutine - - - - - subroutine ChangeHydraulicChoke1Plugged(status) - USE CHOKEVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(HydraulicChoke1PluggedPtr)) call HydraulicChoke1PluggedPtr(status) - if(status == Clear_StatusType) CHOOKE(1)%PlugMalf = 0 - if(status == Executed_StatusType) CHOOKE(1)%PlugMalf = 1 - endsubroutine - - subroutine ChangeHydraulicChoke1Fail(status) - USE CHOKEVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(HydraulicChoke1FailPtr)) call HydraulicChoke1FailPtr(status) - if(status == Clear_StatusType) CHOOKE(1)%FailMalf = 0 - if(status == Executed_StatusType) CHOOKE(1)%FailMalf = 1 - endsubroutine - - subroutine ChangeHydraulicChoke1Washout(status) - USE CHOKEVARIABLES - use CChokeManifoldVariables - implicit none - integer, intent (in) :: status - ! if(associated(HydraulicChoke1WashoutPtr)) call HydraulicChoke1WashoutPtr(status) - if(status == Clear_StatusType) CHOOKE(1)%WashoutMalf = 0 - if(status == Executed_StatusType) CHOOKE(1)%WashoutMalf = 1 - - if(status == Clear_StatusType) ChokeManifold%HyChock1OnProblem = .false. - if(status == Executed_StatusType) ChokeManifold%HyChock1OnProblem = .true. - endsubroutine - - subroutine ChangeHydraulicChoke2Plugged(status) - USE CHOKEVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(HydraulicChoke2PluggedPtr)) call HydraulicChoke2PluggedPtr(status) - if(status == Clear_StatusType) CHOOKE(2)%PlugMalf = 0 - if(status == Executed_StatusType) CHOOKE(2)%PlugMalf = 1 - endsubroutine - - subroutine ChangeHydraulicChoke2Fail(status) - USE CHOKEVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(HydraulicChoke2FailPtr)) call HydraulicChoke2FailPtr(status) - if(status == Clear_StatusType) CHOOKE(2)%FailMalf = 0 - if(status == Executed_StatusType) CHOOKE(2)%FailMalf = 1 - endsubroutine - - subroutine ChangeHydraulicChoke2Washout(status) - USE CHOKEVARIABLES - use CChokeManifoldVariables - implicit none - integer, intent (in) :: status - ! if(associated(HydraulicChoke2WashoutPtr)) call HydraulicChoke2WashoutPtr(status) - if(status == Clear_StatusType) CHOOKE(2)%WashoutMalf = 0 - if(status == Executed_StatusType) CHOOKE(2)%WashoutMalf = 1 - - if(status == Clear_StatusType) ChokeManifold%HyChock2OnProblem = .false. - if(status == Executed_StatusType) ChokeManifold%HyChock2OnProblem = .true. - endsubroutine - - subroutine ChangeManualChoke1Plugged(status) - USE FricPressDropVarsModule - implicit none - integer, intent (in) :: status - ! if(associated(ManualChoke1PluggedPtr)) call ManualChoke1PluggedPtr(status) - if(status == Clear_StatusType) FricPressDropVars%ManChoke1Plug = 0 - if(status == Executed_StatusType) FricPressDropVars%ManChoke1Plug = 1 - endsubroutine - - subroutine ChangeManualChoke1Fail(status) - implicit none - integer, intent (in) :: status - ! if(associated(ManualChoke1FailPtr)) call ManualChoke1FailPtr(status) - !if(status == Clear_StatusType) print*,'On_ManualChoke1Fail_Clear' - !if(status == Executed_StatusType) print*,'On_ManualChoke1Fail_Execute' - endsubroutine - - subroutine ChangeManualChoke1Washout(status) - USE FricPressDropVarsModule - use CChokeManifoldVariables - implicit none - integer, intent (in) :: status - ! if(associated(ManualChoke1WashoutPtr)) call ManualChoke1WashoutPtr(status) - if(status == Clear_StatusType) FricPressDropVars%ManChoke1Washout = 0 - if(status == Executed_StatusType) FricPressDropVars%ManChoke1Washout = 1 - - if(status == Clear_StatusType) ChokeManifold%LeftManChokeOnProblem = .false. - if(status == Executed_StatusType) ChokeManifold%LeftManChokeOnProblem = .true. - endsubroutine - - subroutine ChangeManualChoke2Plugged(status) - USE FricPressDropVarsModule - implicit none - integer, intent (in) :: status - ! if(associated(ManualChoke2PluggedPtr)) call ManualChoke2PluggedPtr(status) - if(status == Clear_StatusType) FricPressDropVars%ManChoke2Plug = 0 - if(status == Executed_StatusType) FricPressDropVars%ManChoke2Plug = 1 - endsubroutine - - subroutine ChangeManualChoke2Fail(status) - implicit none - integer, intent (in) :: status - ! if(associated(ManualChoke2FailPtr)) call ManualChoke2FailPtr(status) - !if(status == Clear_StatusType) print*,'On_ManualChoke2Fail_Clear' - !if(status == Executed_StatusType) print*,'On_ManualChoke2Fail_Execute' - endsubroutine - - subroutine ChangeManualChoke2Washout(status) - USE FricPressDropVarsModule - use CChokeManifoldVariables - implicit none - integer, intent (in) :: status - ! if(associated(ManualChoke2WashoutPtr)) call ManualChoke2WashoutPtr(status) - if(status == Clear_StatusType) FricPressDropVars%ManChoke2Washout = 0 - if(status == Executed_StatusType) FricPressDropVars%ManChoke2Washout = 1 - - if(status == Clear_StatusType) ChokeManifold%RightManChokeOnProblem = .false. - if(status == Executed_StatusType) ChokeManifold%RightManChokeOnProblem = .true. - endsubroutine - - subroutine ChangeChokePanelAirFail(status) - USE CHOKEVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(ChokePanelAirFailPtr)) call ChokePanelAirFailPtr(status) - if(status == Clear_StatusType) AirDrivenPump%ChokeAirFail = 0 - if(status == Executed_StatusType) AirDrivenPump%ChokeAirFail = 1 - endsubroutine - - - - - - - - - - - - - - - - - ! subroutine SubscribeHydraulicChoke1Plugged(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeHydraulicChoke1Plugged - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeHydraulicChoke1Plugged' :: SubscribeHydraulicChoke1Plugged - ! implicit none - ! procedure (ActionInteger) :: v - ! HydraulicChoke1PluggedPtr => v - ! end subroutine - - ! subroutine SubscribeHydraulicChoke1Fail(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeHydraulicChoke1Fail - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeHydraulicChoke1Fail' :: SubscribeHydraulicChoke1Fail - ! implicit none - ! procedure (ActionInteger) :: v - ! HydraulicChoke1FailPtr => v - ! end subroutine - - ! subroutine SubscribeHydraulicChoke1Washout(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeHydraulicChoke1Washout - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeHydraulicChoke1Washout' :: SubscribeHydraulicChoke1Washout - ! implicit none - ! procedure (ActionInteger) :: v - ! HydraulicChoke1WashoutPtr => v - ! end subroutine - - ! subroutine SubscribeHydraulicChoke2Plugged(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeHydraulicChoke2Plugged - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeHydraulicChoke2Plugged' :: SubscribeHydraulicChoke2Plugged - ! implicit none - ! procedure (ActionInteger) :: v - ! HydraulicChoke2PluggedPtr => v - ! end subroutine - - ! subroutine SubscribeHydraulicChoke2Fail(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeHydraulicChoke2Fail - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeHydraulicChoke2Fail' :: SubscribeHydraulicChoke2Fail - ! implicit none - ! procedure (ActionInteger) :: v - ! HydraulicChoke2FailPtr => v - ! end subroutine - - ! subroutine SubscribeHydraulicChoke2Washout(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeHydraulicChoke2Washout - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeHydraulicChoke2Washout' :: SubscribeHydraulicChoke2Washout - ! implicit none - ! procedure (ActionInteger) :: v - ! HydraulicChoke2WashoutPtr => v - ! end subroutine - - ! subroutine SubscribeManualChoke1Plugged(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeManualChoke1Plugged - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeManualChoke1Plugged' :: SubscribeManualChoke1Plugged - ! implicit none - ! procedure (ActionInteger) :: v - ! ManualChoke1PluggedPtr => v - ! end subroutine - - ! subroutine SubscribeManualChoke1Fail(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeManualChoke1Fail - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeManualChoke1Fail' :: SubscribeManualChoke1Fail - ! implicit none - ! procedure (ActionInteger) :: v - ! ManualChoke1FailPtr => v - ! end subroutine - - ! subroutine SubscribeManualChoke1Washout(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeManualChoke1Washout - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeManualChoke1Washout' :: SubscribeManualChoke1Washout - ! implicit none - ! procedure (ActionInteger) :: v - ! ManualChoke1WashoutPtr => v - ! end subroutine - - ! subroutine SubscribeManualChoke2Plugged(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeManualChoke2Plugged - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeManualChoke2Plugged' :: SubscribeManualChoke2Plugged - ! implicit none - ! procedure (ActionInteger) :: v - ! ManualChoke2PluggedPtr => v - ! end subroutine - - ! subroutine SubscribeManualChoke2Fail(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeManualChoke2Fail - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeManualChoke2Fail' :: SubscribeManualChoke2Fail - ! implicit none - ! procedure (ActionInteger) :: v - ! ManualChoke2FailPtr => v - ! end subroutine - - ! subroutine SubscribeManualChoke2Washout(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeManualChoke2Washout - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeManualChoke2Washout' :: SubscribeManualChoke2Washout - ! implicit none - ! procedure (ActionInteger) :: v - ! ManualChoke2WashoutPtr => v - ! end subroutine - - ! subroutine SubscribeChokePanelAirFail(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeChokePanelAirFail - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeChokePanelAirFail' :: SubscribeChokePanelAirFail - ! implicit none - ! procedure (ActionInteger) :: v - ! ChokePanelAirFailPtr => v - ! end subroutine + contains end module CChokeProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CDrillStemProblems.f90 b/CSharp/Problems/CDrillStemProblems.f90 index 6e7a9f0..000bdbc 100644 --- a/CSharp/Problems/CDrillStemProblems.f90 +++ b/CSharp/Problems/CDrillStemProblems.f90 @@ -1,69 +1,64 @@ module CDrillStemProblems - use CDrillStemProblemsVariables + use ConfigurationVariables implicit none public - contains - - ! Input routines - subroutine SetStringDragIncrease(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStringDragIncrease - !DEC$ ATTRIBUTES ALIAS: 'SetStringDragIncrease' :: SetStringDragIncrease - implicit none - type(CProblem), intent(in) :: v - DrillStemProblems%StringDragIncrease = SetDue(v, ChangeStringDragIncrease) -#ifdef deb - print*, 'StringDragIncrease%ProblemType=', DrillStemProblems%StringDragIncrease%ProblemType - print*, 'StringDragIncrease%StatusType=', DrillStemProblems%StringDragIncrease%StatusType - print*, 'StringDragIncrease%Value=', DrillStemProblems%StringDragIncrease%Value -#endif + contains + subroutine ProcessDrillStemProblemsDueTime(time) + implicit none + integer :: time + if(data%problems%DrillStemProblems%StringDragIncrease%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, time) + if(data%problems%DrillStemProblems%StringTorqueIncrease%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, time) + if(data%problems%DrillStemProblems%StringTorqueFluctuation%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, time) end subroutine - - subroutine SetStringTorqueIncrease(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStringTorqueIncrease - !DEC$ ATTRIBUTES ALIAS: 'SetStringTorqueIncrease' :: SetStringTorqueIncrease - implicit none - type(CProblem), intent(in) :: v - DrillStemProblems%StringTorqueIncrease = SetDue(v, ChangeStringTorqueIncrease) -#ifdef deb - print*, 'StringTorqueIncrease%ProblemType=', DrillStemProblems%StringTorqueIncrease%ProblemType - print*, 'StringTorqueIncrease%StatusType=', DrillStemProblems%StringTorqueIncrease%StatusType - print*, 'StringTorqueIncrease%Value=', DrillStemProblems%StringTorqueIncrease%Value -#endif + + subroutine ProcessDrillStemProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + if(data%problems%DrillStemProblems%StringDragIncrease%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, strokes) + if(data%problems%DrillStemProblems%StringTorqueIncrease%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, strokes) + if(data%problems%DrillStemProblems%StringTorqueFluctuation%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, strokes) end subroutine - - subroutine SetStringTorqueFluctuation(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStringTorqueFluctuation - !DEC$ ATTRIBUTES ALIAS: 'SetStringTorqueFluctuation' :: SetStringTorqueFluctuation - implicit none - type(CProblem), intent(in) :: v - DrillStemProblems%StringTorqueFluctuation = SetDue(v, ChangeStringTorqueFluctuation) -#ifdef deb - print*, 'StringTorqueFluctuation%ProblemType=', DrillStemProblems%StringTorqueFluctuation%ProblemType - print*, 'StringTorqueFluctuation%StatusType=', DrillStemProblems%StringTorqueFluctuation%StatusType - print*, 'StringTorqueFluctuation%Value=', DrillStemProblems%StringTorqueFluctuation%Value -#endif + + subroutine ProcessDrillStemProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + if(data%problems%DrillStemProblems%StringDragIncrease%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, volume) + if(data%problems%DrillStemProblems%StringTorqueIncrease%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, volume) + if(data%problems%DrillStemProblems%StringTorqueFluctuation%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, volume) end subroutine - - subroutine SetStringDragIncreaseTime(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStringDragIncreaseTime - !DEC$ ATTRIBUTES ALIAS: 'SetStringDragIncreaseTime' :: SetStringDragIncreaseTime - implicit none - real(8), intent(in) :: v - DrillStemProblems%StringDragIncreaseTime = v -#ifdef deb - print*, 'StringDragIncreaseTime=', DrillStemProblems%StringDragIncreaseTime -#endif - end subroutine - - subroutine SetStringTorqueIncreaseTime(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStringTorqueIncreaseTime - !DEC$ ATTRIBUTES ALIAS: 'SetStringTorqueIncreaseTime' :: SetStringTorqueIncreaseTime - implicit none - real(8), intent(in) :: v - DrillStemProblems%StringTorqueIncreaseTime = v -#ifdef deb - print*, 'StringTorqueIncreaseTime=', DrillStemProblems%StringTorqueIncreaseTime -#endif + + subroutine ProcessDrillStemProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + if(data%problems%DrillStemProblems%StringDragIncrease%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, distance) + if(data%problems%DrillStemProblems%StringTorqueIncrease%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, distance) + if(data%problems%DrillStemProblems%StringTorqueFluctuation%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, distance) end subroutine + + + + subroutine ChangeStringDragIncrease(status) + implicit none + integer, intent (in) :: status + ! if(associated(StringDragIncreasePtr)) call StringDragIncreasePtr(status) + !if(status == Clear_StatusType) print*,'On_StringDragIncrease_Clear' + !if(status == Executed_StatusType) print*,'On_StringDragIncrease_Execute' + endsubroutine + subroutine ChangeStringTorqueIncrease(status) + implicit none + integer, intent (in) :: status + ! if(associated(StringTorqueIncreasePtr)) call StringTorqueIncreasePtr(status) + !if(status == Clear_StatusType) print*,'On_StringTorqueIncrease_Clear' + !if(status == Executed_StatusType) print*,'On_StringTorqueIncrease_Execute' + endsubroutine + + subroutine ChangeStringTorqueFluctuation(status) + implicit none + integer, intent (in) :: status + ! if(associated(StringTorqueFluctuationPtr)) call StringTorqueFluctuationPtr(status) + !if(status == Clear_StatusType) print*,'On_StringTorqueFluctuation_Clear' + !if(status == Executed_StatusType) print*,'On_StringTorqueFluctuation_Execute' + endsubroutine + end module CDrillStemProblems \ No newline at end of file diff --git a/CSharp/Problems/CDrillStemProblemsVariables.f90 b/CSharp/Problems/CDrillStemProblemsVariables.f90 index 0b75380..16829ef 100644 --- a/CSharp/Problems/CDrillStemProblemsVariables.f90 +++ b/CSharp/Problems/CDrillStemProblemsVariables.f90 @@ -11,105 +11,7 @@ module CDrillStemProblemsVariables real(8) :: StringDragIncreaseTime real(8) :: StringTorqueIncreaseTime end type DrillStemProblemsType - type(DrillStemProblemsType)::DrillStemProblems - - ! procedure (ActionInteger), pointer :: StringDragIncreasePtr - ! procedure (ActionInteger), pointer :: StringTorqueIncreasePtr - ! procedure (ActionInteger), pointer :: StringTorqueFluctuationPtr - - contains - - subroutine ProcessDrillStemProblemsDueTime(time) - implicit none - integer :: time - if(DrillStemProblems%StringDragIncrease%ProblemType == Time_ProblemType) call ProcessDueTime(DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, time) - if(DrillStemProblems%StringTorqueIncrease%ProblemType == Time_ProblemType) call ProcessDueTime(DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, time) - if(DrillStemProblems%StringTorqueFluctuation%ProblemType == Time_ProblemType) call ProcessDueTime(DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, time) - end subroutine - - subroutine ProcessDrillStemProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - if(DrillStemProblems%StringDragIncrease%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, strokes) - if(DrillStemProblems%StringTorqueIncrease%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, strokes) - if(DrillStemProblems%StringTorqueFluctuation%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, strokes) - end subroutine - - subroutine ProcessDrillStemProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - if(DrillStemProblems%StringDragIncrease%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, volume) - if(DrillStemProblems%StringTorqueIncrease%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, volume) - if(DrillStemProblems%StringTorqueFluctuation%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, volume) - end subroutine - - subroutine ProcessDrillStemProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - if(DrillStemProblems%StringDragIncrease%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(DrillStemProblems%StringDragIncrease, ChangeStringDragIncrease, distance) - if(DrillStemProblems%StringTorqueIncrease%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(DrillStemProblems%StringTorqueIncrease, ChangeStringTorqueIncrease, distance) - if(DrillStemProblems%StringTorqueFluctuation%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(DrillStemProblems%StringTorqueFluctuation, ChangeStringTorqueFluctuation, distance) - end subroutine - - - - subroutine ChangeStringDragIncrease(status) - implicit none - integer, intent (in) :: status - ! if(associated(StringDragIncreasePtr)) call StringDragIncreasePtr(status) - !if(status == Clear_StatusType) print*,'On_StringDragIncrease_Clear' - !if(status == Executed_StatusType) print*,'On_StringDragIncrease_Execute' - endsubroutine - - subroutine ChangeStringTorqueIncrease(status) - implicit none - integer, intent (in) :: status - ! if(associated(StringTorqueIncreasePtr)) call StringTorqueIncreasePtr(status) - !if(status == Clear_StatusType) print*,'On_StringTorqueIncrease_Clear' - !if(status == Executed_StatusType) print*,'On_StringTorqueIncrease_Execute' - endsubroutine - - subroutine ChangeStringTorqueFluctuation(status) - implicit none - integer, intent (in) :: status - ! if(associated(StringTorqueFluctuationPtr)) call StringTorqueFluctuationPtr(status) - !if(status == Clear_StatusType) print*,'On_StringTorqueFluctuation_Clear' - !if(status == Executed_StatusType) print*,'On_StringTorqueFluctuation_Execute' - endsubroutine - - - - - - - - - - ! subroutine SubscribeStringDragIncrease(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeStringDragIncrease - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeStringDragIncrease' :: SubscribeStringDragIncrease - ! implicit none - ! procedure (ActionInteger) :: v - ! StringDragIncreasePtr => v - ! end subroutine - ! subroutine SubscribeStringTorqueIncrease(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeStringTorqueIncrease - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeStringTorqueIncrease' :: SubscribeStringTorqueIncrease - ! implicit none - ! procedure (ActionInteger) :: v - ! StringTorqueIncreasePtr => v - ! end subroutine - - ! subroutine SubscribeStringTorqueFluctuation(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeStringTorqueFluctuation - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeStringTorqueFluctuation' :: SubscribeStringTorqueFluctuation - ! implicit none - ! procedure (ActionInteger) :: v - ! StringTorqueFluctuationPtr => v - ! end subroutine - - - + contains end module CDrillStemProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CGaugesProblems.f90 b/CSharp/Problems/CGaugesProblems.f90 index 7082bde..c24d310 100644 --- a/CSharp/Problems/CGaugesProblems.f90 +++ b/CSharp/Problems/CGaugesProblems.f90 @@ -1,307 +1,337 @@ module CGaugesProblems - use CGaugesProblemsVariables + use ConfigurationVariables implicit none public contains - ! Input routines - subroutine SetWeightIndicator(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetWeightIndicator - !DEC$ ATTRIBUTES ALIAS: 'SetWeightIndicator' :: SetWeightIndicator - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%WeightIndicator = SetDue(v, ChangeWeightIndicator) -#ifdef deb - print*, 'WeightIndicator%ProblemType=', GaugesProblems%WeightIndicator%ProblemType - print*, 'WeightIndicator%StatusType=', GaugesProblems%WeightIndicator%StatusType - print*, 'WeightIndicator%Value=', GaugesProblems%WeightIndicator%Value -#endif + subroutine ProcessGaugesProblemsDueTime(time) + implicit none + integer :: time + if(data%problems%GaugesProblems%WeightIndicator%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%WeightIndicator, ChangeWeightIndicator, time) + if(data%problems%GaugesProblems%RotaryRpm%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%RotaryRpm, ChangeRotaryRpm, time) + if(data%problems%GaugesProblems%RotaryTorque%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%RotaryTorque, ChangeRotaryTorque, time) + if(data%problems%GaugesProblems%StandPipePressure%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%StandPipePressure, ChangeStandPipePressure, time) + if(data%problems%GaugesProblems%CasingPressure%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%CasingPressure, ChangeCasingPressure, time) + if(data%problems%GaugesProblems%Pump1Strokes%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%Pump1Strokes, ChangePump1Strokes, time) + if(data%problems%GaugesProblems%Pump2Strokes%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%Pump2Strokes, ChangePump2Strokes, time) + if(data%problems%GaugesProblems%ReturnLineTemperature%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, time) + if(data%problems%GaugesProblems%TripTank%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%TripTank, ChangeTripTank, time) + if(data%problems%GaugesProblems%PitGainLoss%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%PitGainLoss, ChangePitGainLoss, time) + if(data%problems%GaugesProblems%MudTankVolume%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%MudTankVolume, ChangeMudTankVolume, time) + if(data%problems%GaugesProblems%ReturnMudFlow%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, time) + if(data%problems%GaugesProblems%TorqueLimit%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%TorqueLimit, ChangeTorqueLimit, time) + if(data%problems%GaugesProblems%PowerLimit%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%PowerLimit, ChangePowerLimit, time) + if(data%problems%GaugesProblems%AccumulatorPressure%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, time) + if(data%problems%GaugesProblems%ManifoldPressure%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%ManifoldPressure, ChangeManifoldPressure, time) + if(data%problems%GaugesProblems%AnnularPressure%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%AnnularPressure, ChangeAnnularPressure, time) + if(data%problems%GaugesProblems%RigAirPressure%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%RigAirPressure, ChangeRigAirPressure, time) + if(data%problems%GaugesProblems%StandPipe1%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%StandPipe1, ChangeStandPipe1, time) + if(data%problems%GaugesProblems%StandPipe2%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%StandPipe2, ChangeStandPipe2, time) + if(data%problems%GaugesProblems%DrillPipePressure%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, time) + if(data%problems%GaugesProblems%ChokePosition%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%ChokePosition, ChangeChokePosition, time) + if(data%problems%GaugesProblems%CasingPressure2%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%GaugesProblems%CasingPressure2, ChangeCasingPressure2, time) end subroutine - - subroutine SetRotaryRpm(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRotaryRpm - !DEC$ ATTRIBUTES ALIAS: 'SetRotaryRpm' :: SetRotaryRpm - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%RotaryRpm = SetDue(v, ChangeRotaryRpm) -#ifdef deb - print*, 'RotaryRpm%ProblemType=', GaugesProblems%RotaryRpm%ProblemType - print*, 'RotaryRpm%StatusType=', GaugesProblems%RotaryRpm%StatusType - print*, 'RotaryRpm%Value=', GaugesProblems%RotaryRpm%Value -#endif + + subroutine ProcessGaugesProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + if(data%problems%GaugesProblems%WeightIndicator%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%WeightIndicator, ChangeWeightIndicator, strokes) + if(data%problems%GaugesProblems%RotaryRpm%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%RotaryRpm, ChangeRotaryRpm, strokes) + if(data%problems%GaugesProblems%RotaryTorque%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%RotaryTorque, ChangeRotaryTorque, strokes) + if(data%problems%GaugesProblems%StandPipePressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%StandPipePressure, ChangeStandPipePressure, strokes) + if(data%problems%GaugesProblems%CasingPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%CasingPressure, ChangeCasingPressure, strokes) + if(data%problems%GaugesProblems%Pump1Strokes%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%Pump1Strokes, ChangePump1Strokes, strokes) + if(data%problems%GaugesProblems%Pump2Strokes%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%Pump2Strokes, ChangePump2Strokes, strokes) + if(data%problems%GaugesProblems%ReturnLineTemperature%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, strokes) + if(data%problems%GaugesProblems%TripTank%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%TripTank, ChangeTripTank, strokes) + if(data%problems%GaugesProblems%PitGainLoss%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%PitGainLoss, ChangePitGainLoss, strokes) + if(data%problems%GaugesProblems%MudTankVolume%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%MudTankVolume, ChangeMudTankVolume, strokes) + if(data%problems%GaugesProblems%ReturnMudFlow%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, strokes) + if(data%problems%GaugesProblems%TorqueLimit%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%TorqueLimit, ChangeTorqueLimit, strokes) + if(data%problems%GaugesProblems%PowerLimit%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%PowerLimit, ChangePowerLimit, strokes) + if(data%problems%GaugesProblems%AccumulatorPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, strokes) + if(data%problems%GaugesProblems%ManifoldPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%ManifoldPressure, ChangeManifoldPressure, strokes) + if(data%problems%GaugesProblems%AnnularPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%AnnularPressure, ChangeAnnularPressure, strokes) + if(data%problems%GaugesProblems%RigAirPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%RigAirPressure, ChangeRigAirPressure, strokes) + if(data%problems%GaugesProblems%StandPipe1%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%StandPipe1, ChangeStandPipe1, strokes) + if(data%problems%GaugesProblems%StandPipe2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%StandPipe2, ChangeStandPipe2, strokes) + if(data%problems%GaugesProblems%DrillPipePressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, strokes) + if(data%problems%GaugesProblems%ChokePosition%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%ChokePosition, ChangeChokePosition, strokes) + if(data%problems%GaugesProblems%CasingPressure2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%GaugesProblems%CasingPressure2, ChangeCasingPressure2, strokes) end subroutine - - subroutine SetRotaryTorque(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRotaryTorque - !DEC$ ATTRIBUTES ALIAS: 'SetRotaryTorque' :: SetRotaryTorque - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%RotaryTorque = SetDue(v, ChangeRotaryTorque) -#ifdef deb - print*, 'RotaryTorque%ProblemType=', GaugesProblems%RotaryTorque%ProblemType - print*, 'RotaryTorque%StatusType=', GaugesProblems%RotaryTorque%StatusType - print*, 'RotaryTorque%Value=', GaugesProblems%RotaryTorque%Value -#endif + + subroutine ProcessGaugesProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + if(data%problems%GaugesProblems%WeightIndicator%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%WeightIndicator, ChangeWeightIndicator, volume) + if(data%problems%GaugesProblems%RotaryRpm%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%RotaryRpm, ChangeRotaryRpm, volume) + if(data%problems%GaugesProblems%RotaryTorque%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%RotaryTorque, ChangeRotaryTorque, volume) + if(data%problems%GaugesProblems%StandPipePressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%StandPipePressure, ChangeStandPipePressure, volume) + if(data%problems%GaugesProblems%CasingPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%CasingPressure, ChangeCasingPressure, volume) + if(data%problems%GaugesProblems%Pump1Strokes%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%Pump1Strokes, ChangePump1Strokes, volume) + if(data%problems%GaugesProblems%Pump2Strokes%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%Pump2Strokes, ChangePump2Strokes, volume) + if(data%problems%GaugesProblems%ReturnLineTemperature%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, volume) + if(data%problems%GaugesProblems%TripTank%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%TripTank, ChangeTripTank, volume) + if(data%problems%GaugesProblems%PitGainLoss%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%PitGainLoss, ChangePitGainLoss, volume) + if(data%problems%GaugesProblems%MudTankVolume%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%MudTankVolume, ChangeMudTankVolume, volume) + if(data%problems%GaugesProblems%ReturnMudFlow%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, volume) + if(data%problems%GaugesProblems%TorqueLimit%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%TorqueLimit, ChangeTorqueLimit, volume) + if(data%problems%GaugesProblems%PowerLimit%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%PowerLimit, ChangePowerLimit, volume) + if(data%problems%GaugesProblems%AccumulatorPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, volume) + if(data%problems%GaugesProblems%ManifoldPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%ManifoldPressure, ChangeManifoldPressure, volume) + if(data%problems%GaugesProblems%AnnularPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%AnnularPressure, ChangeAnnularPressure, volume) + if(data%problems%GaugesProblems%RigAirPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%RigAirPressure, ChangeRigAirPressure, volume) + if(data%problems%GaugesProblems%StandPipe1%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%StandPipe1, ChangeStandPipe1, volume) + if(data%problems%GaugesProblems%StandPipe2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%StandPipe2, ChangeStandPipe2, volume) + if(data%problems%GaugesProblems%DrillPipePressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, volume) + if(data%problems%GaugesProblems%ChokePosition%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%ChokePosition, ChangeChokePosition, volume) + if(data%problems%GaugesProblems%CasingPressure2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%GaugesProblems%CasingPressure2, ChangeCasingPressure2, volume) end subroutine - - subroutine SetStandPipePressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStandPipePressure - !DEC$ ATTRIBUTES ALIAS: 'SetStandPipePressure' :: SetStandPipePressure - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%StandPipePressure = SetDue(v, ChangeStandPipePressure) -#ifdef deb - print*, 'StandPipePressure%ProblemType=', GaugesProblems%StandPipePressure%ProblemType - print*, 'StandPipePressure%StatusType=', GaugesProblems%StandPipePressure%StatusType - print*, 'StandPipePressure%Value=', GaugesProblems%StandPipePressure%Value -#endif - end subroutine - - subroutine SetCasingPressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCasingPressure - !DEC$ ATTRIBUTES ALIAS: 'SetCasingPressure' :: SetCasingPressure - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%CasingPressure = SetDue(v, ChangeCasingPressure) -#ifdef deb - print*, 'CasingPressure%ProblemType=', GaugesProblems%CasingPressure%ProblemType - print*, 'CasingPressure%StatusType=', GaugesProblems%CasingPressure%StatusType - print*, 'CasingPressure%Value=', GaugesProblems%CasingPressure%Value -#endif - end subroutine - - subroutine SetPump1Strokes(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPump1Strokes - !DEC$ ATTRIBUTES ALIAS: 'SetPump1Strokes' :: SetPump1Strokes - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%Pump1Strokes = SetDue(v, ChangePump1Strokes) -#ifdef deb - print*, 'Pump1Strokes%ProblemType=', GaugesProblems%Pump1Strokes%ProblemType - print*, 'Pump1Strokes%StatusType=', GaugesProblems%Pump1Strokes%StatusType - print*, 'Pump1Strokes%Value=', GaugesProblems%Pump1Strokes%Value -#endif - end subroutine - - subroutine SetPump2Strokes(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPump2Strokes - !DEC$ ATTRIBUTES ALIAS: 'SetPump2Strokes' :: SetPump2Strokes - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%Pump2Strokes = SetDue(v, ChangePump2Strokes) -#ifdef deb - print*, 'Pump2Strokes%ProblemType=', GaugesProblems%Pump2Strokes%ProblemType - print*, 'Pump2Strokes%StatusType=', GaugesProblems%Pump2Strokes%StatusType - print*, 'Pump2Strokes%Value=', GaugesProblems%Pump2Strokes%Value -#endif - end subroutine - - subroutine SetReturnLineTemperature(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetReturnLineTemperature - !DEC$ ATTRIBUTES ALIAS: 'SetReturnLineTemperature' :: SetReturnLineTemperature - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%ReturnLineTemperature = SetDue(v, ChangeReturnLineTemperature) -#ifdef deb - print*, 'ReturnLineTemperature%ProblemType=', GaugesProblems%ReturnLineTemperature%ProblemType - print*, 'ReturnLineTemperature%StatusType=', GaugesProblems%ReturnLineTemperature%StatusType - print*, 'ReturnLineTemperature%Value=', GaugesProblems%ReturnLineTemperature%Value -#endif - end subroutine - - subroutine SetTripTank(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTripTank - !DEC$ ATTRIBUTES ALIAS: 'SetTripTank' :: SetTripTank - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%TripTank = SetDue(v, ChangeTripTank) -#ifdef deb - print*, 'TripTank%ProblemType=', GaugesProblems%TripTank%ProblemType - print*, 'TripTank%StatusType=', GaugesProblems%TripTank%StatusType - print*, 'TripTank%Value=', GaugesProblems%TripTank%Value -#endif - end subroutine - - subroutine SetPitGainLoss(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPitGainLoss - !DEC$ ATTRIBUTES ALIAS: 'SetPitGainLoss' :: SetPitGainLoss - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%PitGainLoss = SetDue(v, ChangePitGainLoss) -#ifdef deb - print*, 'PitGainLoss%ProblemType=', GaugesProblems%PitGainLoss%ProblemType - print*, 'PitGainLoss%StatusType=', GaugesProblems%PitGainLoss%StatusType - print*, 'PitGainLoss%Value=', GaugesProblems%PitGainLoss%Value -#endif - end subroutine - - subroutine SetMudTankVolume(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMudTankVolume - !DEC$ ATTRIBUTES ALIAS: 'SetMudTankVolume' :: SetMudTankVolume - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%MudTankVolume = SetDue(v, ChangeMudTankVolume) -#ifdef deb - print*, 'MudTankVolume%ProblemType=', GaugesProblems%MudTankVolume%ProblemType - print*, 'MudTankVolume%StatusType=', GaugesProblems%MudTankVolume%StatusType - print*, 'MudTankVolume%Value=', GaugesProblems%MudTankVolume%Value -#endif - end subroutine - - subroutine SetReturnMudFlow(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetReturnMudFlow - !DEC$ ATTRIBUTES ALIAS: 'SetReturnMudFlow' :: SetReturnMudFlow - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%ReturnMudFlow = SetDue(v, ChangeReturnMudFlow) -#ifdef deb - print*, 'ReturnMudFlow%ProblemType=', GaugesProblems%ReturnMudFlow%ProblemType - print*, 'ReturnMudFlow%StatusType=', GaugesProblems%ReturnMudFlow%StatusType - print*, 'ReturnMudFlow%Value=', GaugesProblems%ReturnMudFlow%Value -#endif - end subroutine - - subroutine SetTorqueLimit(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetTorqueLimit - !DEC$ ATTRIBUTES ALIAS: 'SetTorqueLimit' :: SetTorqueLimit - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%TorqueLimit = SetDue(v, ChangeTorqueLimit) -#ifdef deb - print*, 'TorqueLimit%ProblemType=', GaugesProblems%TorqueLimit%ProblemType - print*, 'TorqueLimit%StatusType=', GaugesProblems%TorqueLimit%StatusType - print*, 'TorqueLimit%Value=', GaugesProblems%TorqueLimit%Value -#endif - end subroutine - - subroutine SetPowerLimit(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetPowerLimit - !DEC$ ATTRIBUTES ALIAS: 'SetPowerLimit' :: SetPowerLimit - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%PowerLimit = SetDue(v, ChangePowerLimit) -#ifdef deb - print*, 'PowerLimit%ProblemType=', GaugesProblems%PowerLimit%ProblemType - print*, 'PowerLimit%StatusType=', GaugesProblems%PowerLimit%StatusType - print*, 'PowerLimit%Value=', GaugesProblems%PowerLimit%Value -#endif - end subroutine - - subroutine SetAccumulatorPressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAccumulatorPressure - !DEC$ ATTRIBUTES ALIAS: 'SetAccumulatorPressure' :: SetAccumulatorPressure - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%AccumulatorPressure = SetDue(v, ChangeAccumulatorPressure) -#ifdef deb - print*, 'AccumulatorPressure%ProblemType=', GaugesProblems%AccumulatorPressure%ProblemType - print*, 'AccumulatorPressure%StatusType=', GaugesProblems%AccumulatorPressure%StatusType - print*, 'AccumulatorPressure%Value=', GaugesProblems%AccumulatorPressure%Value -#endif - end subroutine - - subroutine SetManifoldPressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetManifoldPressure - !DEC$ ATTRIBUTES ALIAS: 'SetManifoldPressure' :: SetManifoldPressure - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%ManifoldPressure = SetDue(v, ChangeManifoldPressure) -#ifdef deb - print*, 'ManifoldPressure%ProblemType=', GaugesProblems%ManifoldPressure%ProblemType - print*, 'ManifoldPressure%StatusType=', GaugesProblems%ManifoldPressure%StatusType - print*, 'ManifoldPressure%Value=', GaugesProblems%ManifoldPressure%Value -#endif - end subroutine - - subroutine SetAnnularPressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAnnularPressure - !DEC$ ATTRIBUTES ALIAS: 'SetAnnularPressure' :: SetAnnularPressure - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%AnnularPressure = SetDue(v, ChangeAnnularPressure) -#ifdef deb - print*, 'AnnularPressure%ProblemType=', GaugesProblems%AnnularPressure%ProblemType - print*, 'AnnularPressure%StatusType=', GaugesProblems%AnnularPressure%StatusType - print*, 'AnnularPressure%Value=', GaugesProblems%AnnularPressure%Value -#endif - end subroutine - - subroutine SetRigAirPressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRigAirPressure - !DEC$ ATTRIBUTES ALIAS: 'SetRigAirPressure' :: SetRigAirPressure - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%RigAirPressure = SetDue(v, ChangeRigAirPressure) -#ifdef deb - print*, 'RigAirPressure%ProblemType=', GaugesProblems%RigAirPressure%ProblemType - print*, 'RigAirPressure%StatusType=', GaugesProblems%RigAirPressure%StatusType - print*, 'RigAirPressure%Value=', GaugesProblems%RigAirPressure%Value -#endif - end subroutine - - subroutine SetStandPipe1(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStandPipe1 - !DEC$ ATTRIBUTES ALIAS: 'SetStandPipe1' :: SetStandPipe1 - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%StandPipe1 = SetDue(v, ChangeStandPipe1) -#ifdef deb - print*, 'StandPipe1%ProblemType=', GaugesProblems%StandPipe1%ProblemType - print*, 'StandPipe1%StatusType=', GaugesProblems%StandPipe1%StatusType - print*, 'StandPipe1%Value=', GaugesProblems%StandPipe1%Value -#endif - end subroutine - - subroutine SetStandPipe2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetStandPipe2 - !DEC$ ATTRIBUTES ALIAS: 'SetStandPipe2' :: SetStandPipe2 - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%StandPipe2 = SetDue(v, ChangeStandPipe2) -#ifdef deb - print*, 'StandPipe2%ProblemType=', GaugesProblems%StandPipe2%ProblemType - print*, 'StandPipe2%StatusType=', GaugesProblems%StandPipe2%StatusType - print*, 'StandPipe2%Value=', GaugesProblems%StandPipe2%Value -#endif - end subroutine - - subroutine SetDrillPipePressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetDrillPipePressure - !DEC$ ATTRIBUTES ALIAS: 'SetDrillPipePressure' :: SetDrillPipePressure - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%DrillPipePressure = SetDue(v, ChangeDrillPipePressure) -#ifdef deb - print*, 'DrillPipePressure%ProblemType=', GaugesProblems%DrillPipePressure%ProblemType - print*, 'DrillPipePressure%StatusType=', GaugesProblems%DrillPipePressure%StatusType - print*, 'DrillPipePressure%Value=', GaugesProblems%DrillPipePressure%Value -#endif - end subroutine - - subroutine SetChokePosition(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetChokePosition - !DEC$ ATTRIBUTES ALIAS: 'SetChokePosition' :: SetChokePosition - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%ChokePosition = SetDue(v, ChangeChokePosition) -#ifdef deb - print*, 'ChokePosition%ProblemType=', GaugesProblems%ChokePosition%ProblemType - print*, 'ChokePosition%StatusType=', GaugesProblems%ChokePosition%StatusType - print*, 'ChokePosition%Value=', GaugesProblems%ChokePosition%Value -#endif - end subroutine - - subroutine SetCasingPressure2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetCasingPressure2 - !DEC$ ATTRIBUTES ALIAS: 'SetCasingPressure2' :: SetCasingPressure2 - implicit none - type(CProblem), intent(in) :: v - GaugesProblems%CasingPressure2 = SetDue(v, ChangeCasingPressure2) -#ifdef deb - print*, 'CasingPressure2%ProblemType=', GaugesProblems%CasingPressure2%ProblemType - print*, 'CasingPressure2%StatusType=', GaugesProblems%CasingPressure2%StatusType - print*, 'CasingPressure2%Value=', GaugesProblems%CasingPressure2%Value -#endif + + subroutine ProcessGaugesProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + if(data%problems%GaugesProblems%WeightIndicator%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%WeightIndicator, ChangeWeightIndicator, distance) + if(data%problems%GaugesProblems%RotaryRpm%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%RotaryRpm, ChangeRotaryRpm, distance) + if(data%problems%GaugesProblems%RotaryTorque%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%RotaryTorque, ChangeRotaryTorque, distance) + if(data%problems%GaugesProblems%StandPipePressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%StandPipePressure, ChangeStandPipePressure, distance) + if(data%problems%GaugesProblems%CasingPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%CasingPressure, ChangeCasingPressure, distance) + if(data%problems%GaugesProblems%Pump1Strokes%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%Pump1Strokes, ChangePump1Strokes, distance) + if(data%problems%GaugesProblems%Pump2Strokes%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%Pump2Strokes, ChangePump2Strokes, distance) + if(data%problems%GaugesProblems%ReturnLineTemperature%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, distance) + if(data%problems%GaugesProblems%TripTank%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%TripTank, ChangeTripTank, distance) + if(data%problems%GaugesProblems%PitGainLoss%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%PitGainLoss, ChangePitGainLoss, distance) + if(data%problems%GaugesProblems%MudTankVolume%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%MudTankVolume, ChangeMudTankVolume, distance) + if(data%problems%GaugesProblems%ReturnMudFlow%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, distance) + if(data%problems%GaugesProblems%TorqueLimit%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%TorqueLimit, ChangeTorqueLimit, distance) + if(data%problems%GaugesProblems%PowerLimit%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%PowerLimit, ChangePowerLimit, distance) + if(data%problems%GaugesProblems%AccumulatorPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, distance) + if(data%problems%GaugesProblems%ManifoldPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%ManifoldPressure, ChangeManifoldPressure, distance) + if(data%problems%GaugesProblems%AnnularPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%AnnularPressure, ChangeAnnularPressure, distance) + if(data%problems%GaugesProblems%RigAirPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%RigAirPressure, ChangeRigAirPressure, distance) + if(data%problems%GaugesProblems%StandPipe1%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%StandPipe1, ChangeStandPipe1, distance) + if(data%problems%GaugesProblems%StandPipe2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%StandPipe2, ChangeStandPipe2, distance) + if(data%problems%GaugesProblems%DrillPipePressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, distance) + if(data%problems%GaugesProblems%ChokePosition%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%ChokePosition, ChangeChokePosition, distance) + if(data%problems%GaugesProblems%CasingPressure2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%GaugesProblems%CasingPressure2, ChangeCasingPressure2, distance) end subroutine + + + + + + + + + + subroutine ChangeWeightIndicator(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(WeightIndicatorPtr)) call WeightIndicatorPtr(status) + if(status == Clear_StatusType) data%State%TD_General%WeightIndicatorMalf = 0 + if(status == Executed_StatusType) data%State%TD_General%WeightIndicatorMalf = 1 + endsubroutine + + subroutine ChangeRotaryRpm(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(RotaryRpmPtr)) call RotaryRpmPtr(status) + if(status == Clear_StatusType) data%State%RTable%RpmGaugeMalf = 0 + if(status == Executed_StatusType) data%State%RTable%RpmGaugeMalf = 1 + endsubroutine + + subroutine ChangeRotaryTorque(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(RotaryTorquePtr)) call RotaryTorquePtr(status) + if(status == Clear_StatusType) data%State%RTable%TorqueGaugeMalf = 0 + if(status == Executed_StatusType) data%State%RTable%TorqueGaugeMalf = 1 + endsubroutine + + subroutine ChangeStandPipePressure(status) + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ + implicit none + integer, intent (in) :: status + ! if(associated(StandPipePressurePtr)) call StandPipePressurePtr(status) + if(status == Clear_StatusType) data%State%MudSystem%StandPipePressure_DataDisplayMalf = 0 + if(status == Executed_StatusType) data%State%MudSystem%StandPipePressure_DataDisplayMalf = 1 + endsubroutine + + subroutine ChangeCasingPressure(status) + USE FricPressDropVarsModule + implicit none + integer, intent (in) :: status + ! if(associated(CasingPressurePtr)) call CasingPressurePtr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%CasingPressure_DataDisplayMalF = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%CasingPressure_DataDisplayMalF = 1 + endsubroutine + + subroutine ChangePump1Strokes(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(Pump1StrokesPtr)) call Pump1StrokesPtr(status) + if(status == Clear_StatusType) data%State%Pump(1)%SPMGaugeMalf = 0 + if(status == Executed_StatusType) data%State%Pump(1)%SPMGaugeMalf = 1 + endsubroutine + + subroutine ChangePump2Strokes(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(Pump2StrokesPtr)) call Pump2StrokesPtr(status) + if(status == Clear_StatusType) data%State%Pump(2)%SPMGaugeMalf = 0 + if(status == Executed_StatusType) data%State%Pump(2)%SPMGaugeMalf = 1 + endsubroutine + + subroutine ChangeReturnLineTemperature(status) + implicit none + integer, intent (in) :: status + ! if(associated(ReturnLineTemperaturePtr)) call ReturnLineTemperaturePtr(status) + !if(status == Clear_StatusType) print*,'On_ReturnLineTemperature_Clear' + !if(status == Executed_StatusType) print*,'On_ReturnLineTemperature_Execute' + endsubroutine + + subroutine ChangeTripTank(status) + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ + implicit none + integer, intent (in) :: status + ! if(associated(TripTankPtr)) call TripTankPtr(status) + if(status == Clear_StatusType) data%State%MudSystem%TripTankPressure_DataDisplayMalf = 0 + if(status == Executed_StatusType) data%State%MudSystem%TripTankPressure_DataDisplayMalf = 1 + endsubroutine + + subroutine ChangePitGainLoss(status) + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ + implicit none + integer, intent (in) :: status + ! if(associated(PitGainLossPtr)) call PitGainLossPtr(status) + if(status == Clear_StatusType) data%State%MudSystem%PitGainLossGaugeMalf = 0 + if(status == Executed_StatusType) data%State%MudSystem%PitGainLossGaugeMalf = 1 + endsubroutine + + subroutine ChangeMudTankVolume(status) + implicit none + integer, intent (in) :: status + ! if(associated(MudTankVolumePtr)) call MudTankVolumePtr(status) + !if(status == Clear_StatusType) print*,'On_MudTankVolume_Clear' + !if(status == Executed_StatusType) print*,'On_MudTankVolume_Execute' + endsubroutine + + subroutine ChangeReturnMudFlow(status) + implicit none + integer, intent (in) :: status + ! if(associated(ReturnMudFlowPtr)) call ReturnMudFlowPtr(status) + !if(status == Clear_StatusType) print*,'On_ReturnMudFlow_Clear' + !if(status == Executed_StatusType) print*,'On_ReturnMudFlow_Execute' + endsubroutine + + subroutine ChangeTorqueLimit(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(TorqueLimitPtr)) call TorqueLimitPtr(status) + if(status == Clear_StatusType) data%State%RTable%TorqueLimitGaugeMalf = 0 + if(status == Executed_StatusType) data%State%RTable%TorqueLimitGaugeMalf = 1 + endsubroutine + + subroutine ChangePowerLimit(status) + implicit none + integer, intent (in) :: status + ! if(associated(PowerLimitPtr)) call PowerLimitPtr(status) + !if(status == Clear_StatusType) print*,'On_PowerLimit_Clear' + !if(status == Executed_StatusType) print*,'On_PowerLimit_Execute' + endsubroutine + + subroutine ChangeAccumulatorPressure(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(AccumulatorPressurePtr)) call AccumulatorPressurePtr(status) + if(status == Clear_StatusType) data%State%BopStackAcc%AccumulatorPressureGaugeMalf = 0 + if(status == Executed_StatusType) data%State%BopStackAcc%AccumulatorPressureGaugeMalf = 1 + endsubroutine + + subroutine ChangeManifoldPressure(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(ManifoldPressurePtr)) call ManifoldPressurePtr(status) + if(status == Clear_StatusType) data%State%BopStackAcc%ManifoldPressureGaugeMalf = 0 + if(status == Executed_StatusType) data%State%BopStackAcc%ManifoldPressureGaugeMalf = 1 + endsubroutine + + subroutine ChangeAnnularPressure(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(AnnularPressurePtr)) call AnnularPressurePtr(status) + if(status == Clear_StatusType) data%State%Annular%AnnularPressureGaugeMalf = 0 + if(status == Executed_StatusType) data%State%Annular%AnnularPressureGaugeMalf = 1 + endsubroutine + + subroutine ChangeRigAirPressure(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + ! if(associated(RigAirPressurePtr)) call RigAirPressurePtr(status) + if(status == Clear_StatusType) data%State%BopStackAcc%AirSupplyPressureGaugeMalf = 0 + if(status == Executed_StatusType) data%State%BopStackAcc%AirSupplyPressureGaugeMalf = 1 + endsubroutine + + subroutine ChangeStandPipe1(status) + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ + implicit none + integer, intent (in) :: status + ! if(associated(StandPipe1Ptr)) call StandPipe1Ptr(status) + if(status == Clear_StatusType) data%State%MudSystem%StandPipeGauge1Malf = 0 + if(status == Executed_StatusType) data%State%MudSystem%StandPipeGauge1Malf = 1 + endsubroutine + + subroutine ChangeStandPipe2(status) + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ + implicit none + integer, intent (in) :: status + ! if(associated(StandPipe2Ptr)) call StandPipe2Ptr(status) + if(status == Clear_StatusType) data%State%MudSystem%StandPipeGauge2Malf = 0 + if(status == Executed_StatusType) data%State%MudSystem%StandPipeGauge2Malf = 1 + endsubroutine + + subroutine ChangeDrillPipePressure(status) + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ + implicit none + integer, intent (in) :: status + ! if(associated(DrillPipePressurePtr)) call DrillPipePressurePtr(status) + if(status == Clear_StatusType) data%State%MudSystem%DrillPipePressureMalf = 0 + if(status == Executed_StatusType) data%State%MudSystem%DrillPipePressureMalf = 1 + endsubroutine + + subroutine ChangeChokePosition(status) + USE CHOKEVARIABLES +use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(ChokePositionPtr)) call ChokePositionPtr(status) + if(status == Clear_StatusType) data%State%Choke%GaugeChokePositionMailf = 0 + if(status == Executed_StatusType) data%State%Choke%GaugeChokePositionMailf = 1 + endsubroutine + + subroutine ChangeCasingPressure2(status) + USE FricPressDropVarsModule + implicit none + integer, intent (in) :: status + ! if(associated(CasingPressure2Ptr)) call CasingPressure2Ptr(status) + if(status == Clear_StatusType) data%State%FricPressDrop%CasingPressure_ChokeMalF = 0 + if(status == Executed_StatusType) data%State%FricPressDrop%CasingPressure_ChokeMalF = 1 + endsubroutine end module CGaugesProblems \ No newline at end of file diff --git a/CSharp/Problems/CGaugesProblemsVariables.f90 b/CSharp/Problems/CGaugesProblemsVariables.f90 index bdcb5b8..643b6c7 100644 --- a/CSharp/Problems/CGaugesProblemsVariables.f90 +++ b/CSharp/Problems/CGaugesProblemsVariables.f90 @@ -27,560 +27,7 @@ module CGaugesProblemsVariables type(CProblem) :: ChokePosition type(CProblem) :: CasingPressure2 end type GaugesProblemsType - type(GaugesProblemsType)::GaugesProblems - - - - ! procedure (ActionInteger), pointer :: WeightIndicatorPtr - ! procedure (ActionInteger), pointer :: RotaryRpmPtr - ! procedure (ActionInteger), pointer :: RotaryTorquePtr - ! procedure (ActionInteger), pointer :: StandPipePressurePtr - ! procedure (ActionInteger), pointer :: CasingPressurePtr - ! procedure (ActionInteger), pointer :: Pump1StrokesPtr - ! procedure (ActionInteger), pointer :: Pump2StrokesPtr - ! procedure (ActionInteger), pointer :: ReturnLineTemperaturePtr - ! procedure (ActionInteger), pointer :: TripTankPtr - ! procedure (ActionInteger), pointer :: PitGainLossPtr - ! procedure (ActionInteger), pointer :: MudTankVolumePtr - ! procedure (ActionInteger), pointer :: ReturnMudFlowPtr - ! procedure (ActionInteger), pointer :: TorqueLimitPtr - ! procedure (ActionInteger), pointer :: PowerLimitPtr - ! procedure (ActionInteger), pointer :: AccumulatorPressurePtr - ! procedure (ActionInteger), pointer :: ManifoldPressurePtr - ! procedure (ActionInteger), pointer :: AnnularPressurePtr - ! procedure (ActionInteger), pointer :: RigAirPressurePtr - ! procedure (ActionInteger), pointer :: StandPipe1Ptr - ! procedure (ActionInteger), pointer :: StandPipe2Ptr - ! procedure (ActionInteger), pointer :: DrillPipePressurePtr - ! procedure (ActionInteger), pointer :: ChokePositionPtr - ! procedure (ActionInteger), pointer :: CasingPressure2Ptr - contains - - subroutine ProcessGaugesProblemsDueTime(time) - implicit none - integer :: time - if(GaugesProblems%WeightIndicator%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%WeightIndicator, ChangeWeightIndicator, time) - if(GaugesProblems%RotaryRpm%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%RotaryRpm, ChangeRotaryRpm, time) - if(GaugesProblems%RotaryTorque%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%RotaryTorque, ChangeRotaryTorque, time) - if(GaugesProblems%StandPipePressure%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%StandPipePressure, ChangeStandPipePressure, time) - if(GaugesProblems%CasingPressure%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%CasingPressure, ChangeCasingPressure, time) - if(GaugesProblems%Pump1Strokes%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%Pump1Strokes, ChangePump1Strokes, time) - if(GaugesProblems%Pump2Strokes%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%Pump2Strokes, ChangePump2Strokes, time) - if(GaugesProblems%ReturnLineTemperature%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, time) - if(GaugesProblems%TripTank%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%TripTank, ChangeTripTank, time) - if(GaugesProblems%PitGainLoss%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%PitGainLoss, ChangePitGainLoss, time) - if(GaugesProblems%MudTankVolume%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%MudTankVolume, ChangeMudTankVolume, time) - if(GaugesProblems%ReturnMudFlow%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, time) - if(GaugesProblems%TorqueLimit%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%TorqueLimit, ChangeTorqueLimit, time) - if(GaugesProblems%PowerLimit%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%PowerLimit, ChangePowerLimit, time) - if(GaugesProblems%AccumulatorPressure%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, time) - if(GaugesProblems%ManifoldPressure%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%ManifoldPressure, ChangeManifoldPressure, time) - if(GaugesProblems%AnnularPressure%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%AnnularPressure, ChangeAnnularPressure, time) - if(GaugesProblems%RigAirPressure%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%RigAirPressure, ChangeRigAirPressure, time) - if(GaugesProblems%StandPipe1%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%StandPipe1, ChangeStandPipe1, time) - if(GaugesProblems%StandPipe2%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%StandPipe2, ChangeStandPipe2, time) - if(GaugesProblems%DrillPipePressure%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, time) - if(GaugesProblems%ChokePosition%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%ChokePosition, ChangeChokePosition, time) - if(GaugesProblems%CasingPressure2%ProblemType == Time_ProblemType) call ProcessDueTime(GaugesProblems%CasingPressure2, ChangeCasingPressure2, time) - end subroutine - - subroutine ProcessGaugesProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - if(GaugesProblems%WeightIndicator%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%WeightIndicator, ChangeWeightIndicator, strokes) - if(GaugesProblems%RotaryRpm%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%RotaryRpm, ChangeRotaryRpm, strokes) - if(GaugesProblems%RotaryTorque%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%RotaryTorque, ChangeRotaryTorque, strokes) - if(GaugesProblems%StandPipePressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%StandPipePressure, ChangeStandPipePressure, strokes) - if(GaugesProblems%CasingPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%CasingPressure, ChangeCasingPressure, strokes) - if(GaugesProblems%Pump1Strokes%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%Pump1Strokes, ChangePump1Strokes, strokes) - if(GaugesProblems%Pump2Strokes%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%Pump2Strokes, ChangePump2Strokes, strokes) - if(GaugesProblems%ReturnLineTemperature%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, strokes) - if(GaugesProblems%TripTank%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%TripTank, ChangeTripTank, strokes) - if(GaugesProblems%PitGainLoss%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%PitGainLoss, ChangePitGainLoss, strokes) - if(GaugesProblems%MudTankVolume%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%MudTankVolume, ChangeMudTankVolume, strokes) - if(GaugesProblems%ReturnMudFlow%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, strokes) - if(GaugesProblems%TorqueLimit%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%TorqueLimit, ChangeTorqueLimit, strokes) - if(GaugesProblems%PowerLimit%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%PowerLimit, ChangePowerLimit, strokes) - if(GaugesProblems%AccumulatorPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, strokes) - if(GaugesProblems%ManifoldPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%ManifoldPressure, ChangeManifoldPressure, strokes) - if(GaugesProblems%AnnularPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%AnnularPressure, ChangeAnnularPressure, strokes) - if(GaugesProblems%RigAirPressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%RigAirPressure, ChangeRigAirPressure, strokes) - if(GaugesProblems%StandPipe1%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%StandPipe1, ChangeStandPipe1, strokes) - if(GaugesProblems%StandPipe2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%StandPipe2, ChangeStandPipe2, strokes) - if(GaugesProblems%DrillPipePressure%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, strokes) - if(GaugesProblems%ChokePosition%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%ChokePosition, ChangeChokePosition, strokes) - if(GaugesProblems%CasingPressure2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(GaugesProblems%CasingPressure2, ChangeCasingPressure2, strokes) - end subroutine - - subroutine ProcessGaugesProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - if(GaugesProblems%WeightIndicator%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%WeightIndicator, ChangeWeightIndicator, volume) - if(GaugesProblems%RotaryRpm%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%RotaryRpm, ChangeRotaryRpm, volume) - if(GaugesProblems%RotaryTorque%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%RotaryTorque, ChangeRotaryTorque, volume) - if(GaugesProblems%StandPipePressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%StandPipePressure, ChangeStandPipePressure, volume) - if(GaugesProblems%CasingPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%CasingPressure, ChangeCasingPressure, volume) - if(GaugesProblems%Pump1Strokes%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%Pump1Strokes, ChangePump1Strokes, volume) - if(GaugesProblems%Pump2Strokes%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%Pump2Strokes, ChangePump2Strokes, volume) - if(GaugesProblems%ReturnLineTemperature%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, volume) - if(GaugesProblems%TripTank%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%TripTank, ChangeTripTank, volume) - if(GaugesProblems%PitGainLoss%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%PitGainLoss, ChangePitGainLoss, volume) - if(GaugesProblems%MudTankVolume%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%MudTankVolume, ChangeMudTankVolume, volume) - if(GaugesProblems%ReturnMudFlow%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, volume) - if(GaugesProblems%TorqueLimit%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%TorqueLimit, ChangeTorqueLimit, volume) - if(GaugesProblems%PowerLimit%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%PowerLimit, ChangePowerLimit, volume) - if(GaugesProblems%AccumulatorPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, volume) - if(GaugesProblems%ManifoldPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%ManifoldPressure, ChangeManifoldPressure, volume) - if(GaugesProblems%AnnularPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%AnnularPressure, ChangeAnnularPressure, volume) - if(GaugesProblems%RigAirPressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%RigAirPressure, ChangeRigAirPressure, volume) - if(GaugesProblems%StandPipe1%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%StandPipe1, ChangeStandPipe1, volume) - if(GaugesProblems%StandPipe2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%StandPipe2, ChangeStandPipe2, volume) - if(GaugesProblems%DrillPipePressure%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, volume) - if(GaugesProblems%ChokePosition%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%ChokePosition, ChangeChokePosition, volume) - if(GaugesProblems%CasingPressure2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(GaugesProblems%CasingPressure2, ChangeCasingPressure2, volume) - end subroutine - - subroutine ProcessGaugesProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - if(GaugesProblems%WeightIndicator%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%WeightIndicator, ChangeWeightIndicator, distance) - if(GaugesProblems%RotaryRpm%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%RotaryRpm, ChangeRotaryRpm, distance) - if(GaugesProblems%RotaryTorque%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%RotaryTorque, ChangeRotaryTorque, distance) - if(GaugesProblems%StandPipePressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%StandPipePressure, ChangeStandPipePressure, distance) - if(GaugesProblems%CasingPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%CasingPressure, ChangeCasingPressure, distance) - if(GaugesProblems%Pump1Strokes%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%Pump1Strokes, ChangePump1Strokes, distance) - if(GaugesProblems%Pump2Strokes%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%Pump2Strokes, ChangePump2Strokes, distance) - if(GaugesProblems%ReturnLineTemperature%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%ReturnLineTemperature, ChangeReturnLineTemperature, distance) - if(GaugesProblems%TripTank%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%TripTank, ChangeTripTank, distance) - if(GaugesProblems%PitGainLoss%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%PitGainLoss, ChangePitGainLoss, distance) - if(GaugesProblems%MudTankVolume%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%MudTankVolume, ChangeMudTankVolume, distance) - if(GaugesProblems%ReturnMudFlow%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%ReturnMudFlow, ChangeReturnMudFlow, distance) - if(GaugesProblems%TorqueLimit%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%TorqueLimit, ChangeTorqueLimit, distance) - if(GaugesProblems%PowerLimit%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%PowerLimit, ChangePowerLimit, distance) - if(GaugesProblems%AccumulatorPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%AccumulatorPressure, ChangeAccumulatorPressure, distance) - if(GaugesProblems%ManifoldPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%ManifoldPressure, ChangeManifoldPressure, distance) - if(GaugesProblems%AnnularPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%AnnularPressure, ChangeAnnularPressure, distance) - if(GaugesProblems%RigAirPressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%RigAirPressure, ChangeRigAirPressure, distance) - if(GaugesProblems%StandPipe1%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%StandPipe1, ChangeStandPipe1, distance) - if(GaugesProblems%StandPipe2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%StandPipe2, ChangeStandPipe2, distance) - if(GaugesProblems%DrillPipePressure%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%DrillPipePressure, ChangeDrillPipePressure, distance) - if(GaugesProblems%ChokePosition%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%ChokePosition, ChangeChokePosition, distance) - if(GaugesProblems%CasingPressure2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(GaugesProblems%CasingPressure2, ChangeCasingPressure2, distance) - end subroutine - - - - - - - - - - subroutine ChangeWeightIndicator(status) - use TD_GeneralData - implicit none - integer, intent (in) :: status - ! if(associated(WeightIndicatorPtr)) call WeightIndicatorPtr(status) - if(status == Clear_StatusType) TD_general%WeightIndicatorMalf = 0 - if(status == Executed_StatusType) TD_general%WeightIndicatorMalf = 1 - endsubroutine - - subroutine ChangeRotaryRpm(status) - use RTable_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(RotaryRpmPtr)) call RotaryRpmPtr(status) - if(status == Clear_StatusType) RTable%RpmGaugeMalf = 0 - if(status == Executed_StatusType) RTable%RpmGaugeMalf = 1 - endsubroutine - - subroutine ChangeRotaryTorque(status) - use RTable_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(RotaryTorquePtr)) call RotaryTorquePtr(status) - if(status == Clear_StatusType) RTable%TorqueGaugeMalf = 0 - if(status == Executed_StatusType) RTable%TorqueGaugeMalf = 1 - endsubroutine - - subroutine ChangeStandPipePressure(status) - use MudSystemVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(StandPipePressurePtr)) call StandPipePressurePtr(status) - if(status == Clear_StatusType) MudSystem%StandPipePressure_DataDisplayMalf = 0 - if(status == Executed_StatusType) MudSystem%StandPipePressure_DataDisplayMalf = 1 - endsubroutine - - subroutine ChangeCasingPressure(status) - USE FricPressDropVarsModule - implicit none - integer, intent (in) :: status - ! if(associated(CasingPressurePtr)) call CasingPressurePtr(status) - if(status == Clear_StatusType) FricPressDropVars%CasingPressure_DataDisplayMalF = 0 - if(status == Executed_StatusType) FricPressDropVars%CasingPressure_DataDisplayMalF = 1 - endsubroutine - - subroutine ChangePump1Strokes(status) - use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(Pump1StrokesPtr)) call Pump1StrokesPtr(status) - if(status == Clear_StatusType) PUMP(1)%SPMGaugeMalf = 0 - if(status == Executed_StatusType) PUMP(1)%SPMGaugeMalf = 1 - endsubroutine - - subroutine ChangePump2Strokes(status) - use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(Pump2StrokesPtr)) call Pump2StrokesPtr(status) - if(status == Clear_StatusType) PUMP(2)%SPMGaugeMalf = 0 - if(status == Executed_StatusType) PUMP(2)%SPMGaugeMalf = 1 - endsubroutine - - subroutine ChangeReturnLineTemperature(status) - implicit none - integer, intent (in) :: status - ! if(associated(ReturnLineTemperaturePtr)) call ReturnLineTemperaturePtr(status) - !if(status == Clear_StatusType) print*,'On_ReturnLineTemperature_Clear' - !if(status == Executed_StatusType) print*,'On_ReturnLineTemperature_Execute' - endsubroutine - - subroutine ChangeTripTank(status) - USE MudSystemVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(TripTankPtr)) call TripTankPtr(status) - if(status == Clear_StatusType) MudSystem%TripTankPressure_DataDisplayMalf = 0 - if(status == Executed_StatusType) MudSystem%TripTankPressure_DataDisplayMalf = 1 - endsubroutine - - subroutine ChangePitGainLoss(status) - USE MudSystemVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(PitGainLossPtr)) call PitGainLossPtr(status) - if(status == Clear_StatusType) MudSystem%PitGainLossGaugeMalf = 0 - if(status == Executed_StatusType) MudSystem%PitGainLossGaugeMalf = 1 - endsubroutine - - subroutine ChangeMudTankVolume(status) - implicit none - integer, intent (in) :: status - ! if(associated(MudTankVolumePtr)) call MudTankVolumePtr(status) - !if(status == Clear_StatusType) print*,'On_MudTankVolume_Clear' - !if(status == Executed_StatusType) print*,'On_MudTankVolume_Execute' - endsubroutine - - subroutine ChangeReturnMudFlow(status) - implicit none - integer, intent (in) :: status - ! if(associated(ReturnMudFlowPtr)) call ReturnMudFlowPtr(status) - !if(status == Clear_StatusType) print*,'On_ReturnMudFlow_Clear' - !if(status == Executed_StatusType) print*,'On_ReturnMudFlow_Execute' - endsubroutine - - subroutine ChangeTorqueLimit(status) - use RTable_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(TorqueLimitPtr)) call TorqueLimitPtr(status) - if(status == Clear_StatusType) RTable%TorqueLimitGaugeMalf = 0 - if(status == Executed_StatusType) RTable%TorqueLimitGaugeMalf = 1 - endsubroutine - - subroutine ChangePowerLimit(status) - implicit none - integer, intent (in) :: status - ! if(associated(PowerLimitPtr)) call PowerLimitPtr(status) - !if(status == Clear_StatusType) print*,'On_PowerLimit_Clear' - !if(status == Executed_StatusType) print*,'On_PowerLimit_Execute' - endsubroutine - - subroutine ChangeAccumulatorPressure(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(AccumulatorPressurePtr)) call AccumulatorPressurePtr(status) - if(status == Clear_StatusType) BopStackAcc%AccumulatorPressureGaugeMalf = 0 - if(status == Executed_StatusType) BopStackAcc%AccumulatorPressureGaugeMalf = 1 - endsubroutine - - subroutine ChangeManifoldPressure(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(ManifoldPressurePtr)) call ManifoldPressurePtr(status) - if(status == Clear_StatusType) BopStackAcc%ManifoldPressureGaugeMalf = 0 - if(status == Executed_StatusType) BopStackAcc%ManifoldPressureGaugeMalf = 1 - endsubroutine - - subroutine ChangeAnnularPressure(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(AnnularPressurePtr)) call AnnularPressurePtr(status) - if(status == Clear_StatusType) Annular%AnnularPressureGaugeMalf = 0 - if(status == Executed_StatusType) Annular%AnnularPressureGaugeMalf = 1 - endsubroutine - - subroutine ChangeRigAirPressure(status) - USE VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(RigAirPressurePtr)) call RigAirPressurePtr(status) - if(status == Clear_StatusType) BopStackAcc%AirSupplyPressureGaugeMalf = 0 - if(status == Executed_StatusType) BopStackAcc%AirSupplyPressureGaugeMalf = 1 - endsubroutine - - subroutine ChangeStandPipe1(status) - use MudSystemVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(StandPipe1Ptr)) call StandPipe1Ptr(status) - if(status == Clear_StatusType) MudSystem%StandPipeGauge1Malf = 0 - if(status == Executed_StatusType) MudSystem%StandPipeGauge1Malf = 1 - endsubroutine - - subroutine ChangeStandPipe2(status) - use MudSystemVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(StandPipe2Ptr)) call StandPipe2Ptr(status) - if(status == Clear_StatusType) MudSystem%StandPipeGauge2Malf = 0 - if(status == Executed_StatusType) MudSystem%StandPipeGauge2Malf = 1 - endsubroutine - - subroutine ChangeDrillPipePressure(status) - use MudSystemVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(DrillPipePressurePtr)) call DrillPipePressurePtr(status) - if(status == Clear_StatusType) MudSystem%DrillPipePressureMalf = 0 - if(status == Executed_StatusType) MudSystem%DrillPipePressureMalf = 1 - endsubroutine - - subroutine ChangeChokePosition(status) - USE CHOKEVARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(ChokePositionPtr)) call ChokePositionPtr(status) - if(status == Clear_StatusType) Choke%GaugeChokePositionMailf = 0 - if(status == Executed_StatusType) Choke%GaugeChokePositionMailf = 1 - endsubroutine - - subroutine ChangeCasingPressure2(status) - USE FricPressDropVarsModule - implicit none - integer, intent (in) :: status - ! if(associated(CasingPressure2Ptr)) call CasingPressure2Ptr(status) - if(status == Clear_StatusType) FricPressDropVars%CasingPressure_ChokeMalF = 0 - if(status == Executed_StatusType) FricPressDropVars%CasingPressure_ChokeMalF = 1 - endsubroutine - - - - - - - - - - - - - - - - - ! subroutine SubscribeWeightIndicator(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeWeightIndicator - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeWeightIndicator' :: SubscribeWeightIndicator - ! implicit none - ! procedure (ActionInteger) :: v - ! WeightIndicatorPtr => v - ! end subroutine - - ! subroutine SubscribeRotaryRpm(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeRotaryRpm - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeRotaryRpm' :: SubscribeRotaryRpm - ! implicit none - ! procedure (ActionInteger) :: v - ! RotaryRpmPtr => v - ! end subroutine - - ! subroutine SubscribeRotaryTorque(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeRotaryTorque - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeRotaryTorque' :: SubscribeRotaryTorque - ! implicit none - ! procedure (ActionInteger) :: v - ! RotaryTorquePtr => v - ! end subroutine - - ! subroutine SubscribeStandPipePressure(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeStandPipePressure - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeStandPipePressure' :: SubscribeStandPipePressure - ! implicit none - ! procedure (ActionInteger) :: v - ! StandPipePressurePtr => v - ! end subroutine - - ! subroutine SubscribeCasingPressure(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeCasingPressure - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeCasingPressure' :: SubscribeCasingPressure - ! implicit none - ! procedure (ActionInteger) :: v - ! CasingPressurePtr => v - ! end subroutine - - ! subroutine SubscribePump1Strokes(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump1Strokes - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribePump1Strokes' :: SubscribePump1Strokes - ! implicit none - ! procedure (ActionInteger) :: v - ! Pump1StrokesPtr => v - ! end subroutine - - ! subroutine SubscribePump2Strokes(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump2Strokes - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribePump2Strokes' :: SubscribePump2Strokes - ! implicit none - ! procedure (ActionInteger) :: v - ! Pump2StrokesPtr => v - ! end subroutine - - ! subroutine SubscribeReturnLineTemperature(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeReturnLineTemperature - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeReturnLineTemperature' :: SubscribeReturnLineTemperature - ! implicit none - ! procedure (ActionInteger) :: v - ! ReturnLineTemperaturePtr => v - ! end subroutine - - ! subroutine SubscribeTripTank(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeTripTank - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeTripTank' :: SubscribeTripTank - ! implicit none - ! procedure (ActionInteger) :: v - ! TripTankPtr => v - ! end subroutine - - ! subroutine SubscribePitGainLoss(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePitGainLoss - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribePitGainLoss' :: SubscribePitGainLoss - ! implicit none - ! procedure (ActionInteger) :: v - ! PitGainLossPtr => v - ! end subroutine - - ! subroutine SubscribeMudTankVolume(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMudTankVolume - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeMudTankVolume' :: SubscribeMudTankVolume - ! implicit none - ! procedure (ActionInteger) :: v - ! MudTankVolumePtr => v - ! end subroutine - - ! subroutine SubscribeReturnMudFlow(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeReturnMudFlow - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeReturnMudFlow' :: SubscribeReturnMudFlow - ! implicit none - ! procedure (ActionInteger) :: v - ! ReturnMudFlowPtr => v - ! end subroutine - - ! subroutine SubscribeTorqueLimit(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeTorqueLimit - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeTorqueLimit' :: SubscribeTorqueLimit - ! implicit none - ! procedure (ActionInteger) :: v - ! TorqueLimitPtr => v - ! end subroutine - - ! subroutine SubscribePowerLimit(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePowerLimit - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribePowerLimit' :: SubscribePowerLimit - ! implicit none - ! procedure (ActionInteger) :: v - ! PowerLimitPtr => v - ! end subroutine - - ! subroutine SubscribeAccumulatorPressure(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeAccumulatorPressure - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeAccumulatorPressure' :: SubscribeAccumulatorPressure - ! implicit none - ! procedure (ActionInteger) :: v - ! AccumulatorPressurePtr => v - ! end subroutine - - ! subroutine SubscribeManifoldPressure(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeManifoldPressure - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeManifoldPressure' :: SubscribeManifoldPressure - ! implicit none - ! procedure (ActionInteger) :: v - ! ManifoldPressurePtr => v - ! end subroutine - - ! subroutine SubscribeAnnularPressure(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeAnnularPressure - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeAnnularPressure' :: SubscribeAnnularPressure - ! implicit none - ! procedure (ActionInteger) :: v - ! AnnularPressurePtr => v - ! end subroutine - - ! subroutine SubscribeRigAirPressure(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeRigAirPressure - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeRigAirPressure' :: SubscribeRigAirPressure - ! implicit none - ! procedure (ActionInteger) :: v - ! RigAirPressurePtr => v - ! end subroutine - - ! subroutine SubscribeStandPipe1(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeStandPipe1 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeStandPipe1' :: SubscribeStandPipe1 - ! implicit none - ! procedure (ActionInteger) :: v - ! StandPipe1Ptr => v - ! end subroutine - - ! subroutine SubscribeStandPipe2(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeStandPipe2 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeStandPipe2' :: SubscribeStandPipe2 - ! implicit none - ! procedure (ActionInteger) :: v - ! StandPipe2Ptr => v - ! end subroutine - - ! subroutine SubscribeDrillPipePressure(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeDrillPipePressure - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeDrillPipePressure' :: SubscribeDrillPipePressure - ! implicit none - ! procedure (ActionInteger) :: v - ! DrillPipePressurePtr => v - ! end subroutine - - ! subroutine SubscribeChokePosition(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeChokePosition - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeChokePosition' :: SubscribeChokePosition - ! implicit none - ! procedure (ActionInteger) :: v - ! ChokePositionPtr => v - ! end subroutine - - ! subroutine SubscribeCasingPressure2(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeCasingPressure2 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeCasingPressure2' :: SubscribeCasingPressure2 - ! implicit none - ! procedure (ActionInteger) :: v - ! CasingPressure2Ptr => v - ! end subroutine - - - - + end module CGaugesProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CHoistingProblems.f90 b/CSharp/Problems/CHoistingProblems.f90 index ccba4f2..4ccb197 100644 --- a/CSharp/Problems/CHoistingProblems.f90 +++ b/CSharp/Problems/CHoistingProblems.f90 @@ -1,47 +1,71 @@ module CHoistingProblems - use CHoistingProblemsVariables + use ConfigurationVariables implicit none public contains - ! Input routines - subroutine SetMotorFail(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetMotorFail - !DEC$ ATTRIBUTES ALIAS: 'SetMotorFail' :: SetMotorFail - implicit none - type(CProblem), intent(in) :: v - HoistingProblems%MotorFail = SetDue(v, ChangeMotorFail) -#ifdef deb - print*, 'MotorFail%ProblemType=', HoistingProblems%MotorFail%ProblemType - print*, 'MotorFail%StatusType=', HoistingProblems%MotorFail%StatusType - print*, 'MotorFail%Value=', HoistingProblems%MotorFail%Value -#endif - end subroutine - - subroutine SetClutchEngage(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetClutchEngage - !DEC$ ATTRIBUTES ALIAS: 'SetClutchEngage' :: SetClutchEngage - implicit none - type(CProblem), intent(in) :: v - HoistingProblems%ClutchEngage = SetDue(v, ChangeClutchEngage) -#ifdef deb - print*, 'ClutchEngage%ProblemType=', HoistingProblems%ClutchEngage%ProblemType - print*, 'ClutchEngage%StatusType=', HoistingProblems%ClutchEngage%StatusType - print*, 'ClutchEngage%Value=', HoistingProblems%ClutchEngage%Value -#endif - end subroutine - - subroutine SetClutchDisengage(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetClutchDisengage - !DEC$ ATTRIBUTES ALIAS: 'SetClutchDisengage' :: SetClutchDisengage - implicit none - type(CProblem), intent(in) :: v - HoistingProblems%ClutchDisengage = SetDue(v, ChangeClutchDisengage) -#ifdef deb - print*, 'ClutchDisengage%ProblemType=', HoistingProblems%ClutchDisengage%ProblemType - print*, 'ClutchDisengage%StatusType=', HoistingProblems%ClutchDisengage%StatusType - print*, 'ClutchDisengage%Value=', HoistingProblems%ClutchDisengage%Value -#endif + subroutine ProcessHoistingProblemsDueTime(time) + implicit none + integer :: time + if(data%problems%HoistingProblems%MotorFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%HoistingProblems%MotorFail, ChangeMotorFail, time) + if(data%problems%HoistingProblems%ClutchEngage%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%HoistingProblems%ClutchEngage, ChangeClutchEngage, time) + if(data%problems%HoistingProblems%ClutchDisengage%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%HoistingProblems%ClutchDisengage, ChangeClutchDisengage, time) + end subroutine + + subroutine ProcessHoistingProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + if(data%problems%HoistingProblems%MotorFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%HoistingProblems%MotorFail, ChangeMotorFail, strokes) + if(data%problems%HoistingProblems%ClutchEngage%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%HoistingProblems%ClutchEngage, ChangeClutchEngage, strokes) + if(data%problems%HoistingProblems%ClutchDisengage%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%HoistingProblems%ClutchDisengage, ChangeClutchDisengage, strokes) + end subroutine + + subroutine ProcessHoistingProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + if(data%problems%HoistingProblems%MotorFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%HoistingProblems%MotorFail, ChangeMotorFail, volume) + if(data%problems%HoistingProblems%ClutchEngage%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%HoistingProblems%ClutchEngage, ChangeClutchEngage, volume) + if(data%problems%HoistingProblems%ClutchDisengage%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%HoistingProblems%ClutchDisengage, ChangeClutchDisengage, volume) end subroutine + + subroutine ProcessHoistingProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + if(data%problems%HoistingProblems%MotorFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%HoistingProblems%MotorFail, ChangeMotorFail, distance) + if(data%problems%HoistingProblems%ClutchEngage%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%HoistingProblems%ClutchEngage, ChangeClutchEngage, distance) + if(data%problems%HoistingProblems%ClutchDisengage%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%HoistingProblems%ClutchDisengage, ChangeClutchDisengage, distance) + end subroutine + + + + + + + subroutine ChangeMotorFail(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(MotorFailPtr)) call MotorFailPtr(status) + if(status == Clear_StatusType) data%State%Drawworks%MotorFaileMalf=0 + if(status == Executed_StatusType) data%State%Drawworks%MotorFaileMalf=1 + endsubroutine + + subroutine ChangeClutchEngage(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(ClutchEngagePtr)) call ClutchEngagePtr(status) + if(status == Clear_StatusType) data%State%Drawworks%ClutchEngageMalf=0 + if(status == Executed_StatusType) data%State%Drawworks%ClutchEngageMalf=1 + endsubroutine + + subroutine ChangeClutchDisengage(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + ! if(associated(ClutchDisengagePtr)) call ClutchDisengagePtr(status) + if(status == Clear_StatusType) data%State%Drawworks%ClutchDisengageMalf=0 + if(status == Executed_StatusType) data%State%Drawworks%ClutchDisengageMalf=1 + endsubroutine end module CHoistingProblems \ No newline at end of file diff --git a/CSharp/Problems/CHoistingProblemsVariables.f90 b/CSharp/Problems/CHoistingProblemsVariables.f90 index e8d40f1..1057ada 100644 --- a/CSharp/Problems/CHoistingProblemsVariables.f90 +++ b/CSharp/Problems/CHoistingProblemsVariables.f90 @@ -9,110 +9,9 @@ module CHoistingProblemsVariables type(CProblem) :: ClutchEngage type(CProblem) :: ClutchDisengage end type HoistingProblemsType - type(HoistingProblemsType):: HoistingProblems - ! procedure (ActionInteger), pointer :: MotorFailPtr - ! procedure (ActionInteger), pointer :: ClutchEngagePtr - ! procedure (ActionInteger), pointer :: ClutchDisengagePtr contains - subroutine ProcessHoistingProblemsDueTime(time) - implicit none - integer :: time - if(HoistingProblems%MotorFail%ProblemType == Time_ProblemType) call ProcessDueTime(HoistingProblems%MotorFail, ChangeMotorFail, time) - if(HoistingProblems%ClutchEngage%ProblemType == Time_ProblemType) call ProcessDueTime(HoistingProblems%ClutchEngage, ChangeClutchEngage, time) - if(HoistingProblems%ClutchDisengage%ProblemType == Time_ProblemType) call ProcessDueTime(HoistingProblems%ClutchDisengage, ChangeClutchDisengage, time) - end subroutine - - subroutine ProcessHoistingProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - if(HoistingProblems%MotorFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(HoistingProblems%MotorFail, ChangeMotorFail, strokes) - if(HoistingProblems%ClutchEngage%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(HoistingProblems%ClutchEngage, ChangeClutchEngage, strokes) - if(HoistingProblems%ClutchDisengage%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(HoistingProblems%ClutchDisengage, ChangeClutchDisengage, strokes) - end subroutine - - subroutine ProcessHoistingProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - if(HoistingProblems%MotorFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(HoistingProblems%MotorFail, ChangeMotorFail, volume) - if(HoistingProblems%ClutchEngage%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(HoistingProblems%ClutchEngage, ChangeClutchEngage, volume) - if(HoistingProblems%ClutchDisengage%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(HoistingProblems%ClutchDisengage, ChangeClutchDisengage, volume) - end subroutine - - subroutine ProcessHoistingProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - if(HoistingProblems%MotorFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(HoistingProblems%MotorFail, ChangeMotorFail, distance) - if(HoistingProblems%ClutchEngage%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(HoistingProblems%ClutchEngage, ChangeClutchEngage, distance) - if(HoistingProblems%ClutchDisengage%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(HoistingProblems%ClutchDisengage, ChangeClutchDisengage, distance) - end subroutine - - - - - - - subroutine ChangeMotorFail(status) - use Drawworks_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(MotorFailPtr)) call MotorFailPtr(status) - if(status == Clear_StatusType) Drawworks%MotorFaileMalf=0 - if(status == Executed_StatusType) Drawworks%MotorFaileMalf=1 - endsubroutine - - subroutine ChangeClutchEngage(status) - use Drawworks_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(ClutchEngagePtr)) call ClutchEngagePtr(status) - if(status == Clear_StatusType) Drawworks%ClutchEngageMalf=0 - if(status == Executed_StatusType) Drawworks%ClutchEngageMalf=1 - endsubroutine - - subroutine ChangeClutchDisengage(status) - use Drawworks_VARIABLES - implicit none - integer, intent (in) :: status - ! if(associated(ClutchDisengagePtr)) call ClutchDisengagePtr(status) - if(status == Clear_StatusType) Drawworks%ClutchDisengageMalf=0 - if(status == Executed_StatusType) Drawworks%ClutchDisengageMalf=1 - endsubroutine - - - - - - - - - - - ! subroutine SubscribeMotorFail(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMotorFail - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeMotorFail' :: SubscribeMotorFail - ! implicit none - ! procedure (ActionInteger) :: v - ! MotorFailPtr => v - ! end subroutine - - ! subroutine SubscribeClutchEngage(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeClutchEngage - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeClutchEngage' :: SubscribeClutchEngage - ! implicit none - ! procedure (ActionInteger) :: v - ! ClutchEngagePtr => v - ! end subroutine - ! subroutine SubscribeClutchDisengage(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeClutchDisengage - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeClutchDisengage' :: SubscribeClutchDisengage - ! implicit none - ! procedure (ActionInteger) :: v - ! ClutchDisengagePtr => v - ! end subroutine - - end module CHoistingProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CKickProblems.f90 b/CSharp/Problems/CKickProblems.f90 index 6728f3b..aeecafc 100644 --- a/CSharp/Problems/CKickProblems.f90 +++ b/CSharp/Problems/CKickProblems.f90 @@ -1,76 +1,54 @@ module CKickProblems - use CKickProblemsVariables + use ConfigurationVariables implicit none - public + public + !constants + integer :: Gas_FluidType = 0 + integer :: Oil_FluidType = 1 + integer :: Water_FluidType = 2 + contains - ! Input routines - subroutine SetKick(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetKick - !DEC$ ATTRIBUTES ALIAS: 'SetKick' :: SetKick - implicit none - type(CProblem), intent(in) :: v - KickProblems%Kick = SetDue(v, ChangeKick) -#ifdef deb - print*, 'Kick%ProblemType=', KickProblems%Kick%ProblemType - print*, 'Kick%StatusType=', KickProblems%Kick%StatusType - print*, 'Kick%Value=', KickProblems%Kick%Value -#endif - end subroutine - subroutine SetFluidTypeP(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetFluidTypeP - !DEC$ ATTRIBUTES ALIAS: 'SetFluidTypeP' :: SetFluidTypeP - implicit none - integer, intent(in) :: v - KickProblems%FluidType = v -#ifdef deb - print*, 'FluidType=', KickProblems%FluidType -#endif - end subroutine - - subroutine SetFlowRateP(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetFlowRateP - !DEC$ ATTRIBUTES ALIAS: 'SetFlowRateP' :: SetFlowRateP - implicit none - real*8, intent(in) :: v - KickProblems%FlowRate = v -#ifdef deb - print*, 'FlowRate=', KickProblems%FlowRate -#endif + subroutine ProcessKickProblemsDueTime(time) + implicit none + integer :: time + + if(data%problems%KickProblems%Kick%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%KickProblems%Kick, ChangeKick, time) + end subroutine - - subroutine SetOverBalancePressure(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetOverBalancePressure - !DEC$ ATTRIBUTES ALIAS: 'SetOverBalancePressure' :: SetOverBalancePressure - implicit none - real*8, intent(in) :: v - KickProblems%OverBalancePressure = v -#ifdef deb - print*, 'OverBalancePressure=', KickProblems%OverBalancePressure -#endif + + subroutine ProcessKickProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + + if(data%problems%KickProblems%Kick%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%KickProblems%Kick, ChangeKick, strokes) + end subroutine - - subroutine SetIsAutoMigrationRateSelectedP(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetIsAutoMigrationRateSelectedP - !DEC$ ATTRIBUTES ALIAS: 'SetIsAutoMigrationRateSelectedP' :: SetIsAutoMigrationRateSelectedP - implicit none - logical, intent(in) :: v - KickProblems%IsAutoMigrationRateSelected = v -#ifdef deb - print*, 'IsAutoMigrationRateSelected=', KickProblems%IsAutoMigrationRateSelected -#endif + + subroutine ProcessKickProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + + if(data%problems%KickProblems%Kick%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%KickProblems%Kick, ChangeKick, volume) + end subroutine - - subroutine SetAutoMigrationRateP(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetAutoMigrationRateP - !DEC$ ATTRIBUTES ALIAS: 'SetAutoMigrationRateP' :: SetAutoMigrationRateP - implicit none - real*8, intent(in) :: v - KickProblems%AutoMigrationRate = v -#ifdef deb - print*, 'AutoMigrationRate=', KickProblems%AutoMigrationRate -#endif + + subroutine ProcessKickProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + + if(data%problems%KickProblems%Kick%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%KickProblems%Kick, ChangeKick, distance) + end subroutine + + subroutine ChangeKick(status) + implicit none + integer, intent (in) :: status + ! if(associated(data%problems%KickProblems%KickPtr)) call data%problems%KickProblems%KickPtr(status) + !if(status == Clear_StatusType) print*,'On_Kick_Clear' + !if(status == Executed_StatusType) print*,'On_Kick_Execute' + endsubroutine + end module CKickProblems \ No newline at end of file diff --git a/CSharp/Problems/CKickProblemsVariables.f90 b/CSharp/Problems/CKickProblemsVariables.f90 index e5fd098..495c62e 100644 --- a/CSharp/Problems/CKickProblemsVariables.f90 +++ b/CSharp/Problems/CKickProblemsVariables.f90 @@ -3,10 +3,6 @@ module CKickProblemsVariables implicit none public - !constants - integer :: Gas_FluidType = 0 - integer :: Oil_FluidType = 1 - integer :: Water_FluidType = 2 ! Input vars @@ -18,71 +14,5 @@ module CKickProblemsVariables logical :: IsAutoMigrationRateSelected real(8) :: AutoMigrationRate end type KickProblemsType - type(KickProblemsType)::KickProblems - ! procedure (ActionInteger), pointer :: KickPtr - - contains - - - subroutine ProcessKickProblemsDueTime(time) - implicit none - integer :: time - - if(KickProblems%Kick%ProblemType == Time_ProblemType) call ProcessDueTime(KickProblems%Kick, ChangeKick, time) - - end subroutine - - subroutine ProcessKickProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - - if(KickProblems%Kick%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(KickProblems%Kick, ChangeKick, strokes) - - end subroutine - - subroutine ProcessKickProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - - if(KickProblems%Kick%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(KickProblems%Kick, ChangeKick, volume) - - end subroutine - - subroutine ProcessKickProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - - if(KickProblems%Kick%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(KickProblems%Kick, ChangeKick, distance) - - end subroutine - - subroutine ChangeKick(status) - implicit none - integer, intent (in) :: status - ! if(associated(KickProblems%KickPtr)) call KickProblems%KickPtr(status) - !if(status == Clear_StatusType) print*,'On_Kick_Clear' - !if(status == Executed_StatusType) print*,'On_Kick_Execute' - endsubroutine - - - - - - - - - - - - - ! subroutine SubscribeKick(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeKick - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeKick' :: SubscribeKick - ! implicit none - ! procedure (ActionInteger) :: v - ! KickProblems%KickPtr => v - ! end subroutine - - end module CKickProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CLostProblems.f90 b/CSharp/Problems/CLostProblems.f90 index 7401864..0232e82 100644 --- a/CSharp/Problems/CLostProblems.f90 +++ b/CSharp/Problems/CLostProblems.f90 @@ -1,32 +1,48 @@ module CLostProblems - use CLostProblemsVariables + use ConfigurationVariables implicit none public contains + subroutine ProcessLostProblemsDueTime(time) + implicit none + integer :: time + if(data%problems%LostProblems%LostCirculation%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, time) + end subroutine + + subroutine ProcessLostProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + + if(data%problems%LostProblems%LostCirculation%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, strokes) + + end subroutine - ! Input routines - subroutine SetLostCirculation(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetLostCirculation - !DEC$ ATTRIBUTES ALIAS: 'SetLostCirculation' :: SetLostCirculation - implicit none - type(CProblem), intent(in) :: v - LostProblems%LostCirculation = SetDue(v, ChangeLostCirculation) -#ifdef deb - print*, 'LostCirculation%ProblemType=', LostProblems%LostCirculation%ProblemType - print*, 'LostCirculation%StatusType=', LostProblems%LostCirculation%StatusType - print*, 'LostCirculation%Value=', LostProblems%LostCirculation%Value -#endif + subroutine ProcessLostProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + + if(data%problems%LostProblems%LostCirculation%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, volume) + end subroutine - - subroutine SetFlowRate(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetFlowRate - !DEC$ ATTRIBUTES ALIAS: 'SetFlowRate' :: SetFlowRate - implicit none - real*8, intent(in) :: v - LostProblems%FlowRate = v -#ifdef deb - print*, 'FlowRate=', LostProblems%FlowRate -#endif + + subroutine ProcessLostProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + + if(data%problems%LostProblems%LostCirculation%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, distance) + end subroutine + + + + subroutine ChangeLostCirculation(status) + implicit none + integer, intent (in) :: status + ! if(associated(LostCirculationPtr)) call LostCirculationPtr(status) + !if(status == Clear_StatusType) print*,'On_LostCirculation_Clear' + !if(status == Executed_StatusType) print*,'On_LostCirculation_Execute' + endsubroutine + + end module CLostProblems \ No newline at end of file diff --git a/CSharp/Problems/CLostProblemsVariables.f90 b/CSharp/Problems/CLostProblemsVariables.f90 index e3f296e..88dd41a 100644 --- a/CSharp/Problems/CLostProblemsVariables.f90 +++ b/CSharp/Problems/CLostProblemsVariables.f90 @@ -8,67 +8,10 @@ module CLostProblemsVariables type(CProblem) :: LostCirculation real(8) :: FlowRate end type LostProblemsType - type(LostProblemsType)::LostProblems ! procedure (ActionInteger), pointer :: LostCirculationPtr contains - subroutine ProcessLostProblemsDueTime(time) - implicit none - integer :: time - if(LostProblems%LostCirculation%ProblemType == Time_ProblemType) call ProcessDueTime(LostProblems%LostCirculation, ChangeLostCirculation, time) - end subroutine - - subroutine ProcessLostProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - - if(LostProblems%LostCirculation%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(LostProblems%LostCirculation, ChangeLostCirculation, strokes) - - end subroutine - - subroutine ProcessLostProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - - if(LostProblems%LostCirculation%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(LostProblems%LostCirculation, ChangeLostCirculation, volume) - - end subroutine - - subroutine ProcessLostProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - - if(LostProblems%LostCirculation%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(LostProblems%LostCirculation, ChangeLostCirculation, distance) - - end subroutine - - - - - subroutine ChangeLostCirculation(status) - implicit none - integer, intent (in) :: status - ! if(associated(LostCirculationPtr)) call LostCirculationPtr(status) - !if(status == Clear_StatusType) print*,'On_LostCirculation_Clear' - !if(status == Executed_StatusType) print*,'On_LostCirculation_Execute' - endsubroutine - - - - - - - - - - ! subroutine SubscribeLostCirculation(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeLostCirculation - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeLostCirculation' :: SubscribeLostCirculation - ! implicit none - ! procedure (ActionInteger) :: v - ! LostCirculationPtr => v - ! end subroutine - + end module CLostProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CMudTreatmentProblems.f90 b/CSharp/Problems/CMudTreatmentProblems.f90 index 4a174b9..6971ea8 100644 --- a/CSharp/Problems/CMudTreatmentProblems.f90 +++ b/CSharp/Problems/CMudTreatmentProblems.f90 @@ -1,60 +1,91 @@ module CMudTreatmentProblems - use CMudTreatmentProblemsVariables + use ConfigurationVariables implicit none public contains - ! Input routines - subroutine SetDegasser(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetDegasser - !DEC$ ATTRIBUTES ALIAS: 'SetDegasser' :: SetDegasser - implicit none - type(CProblem), intent(in) :: v - MudTreatmentProblems%Degasser = SetDue(v, ChangeDegasser) -#ifdef deb - print*, 'Degasser%ProblemType=', V%ProblemType - print*, 'Degasser%StatusType=', V%StatusType - print*, 'Degasser%Value=', V%Value -#endif - end subroutine - - subroutine SetShaleShaker(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetShaleShaker - !DEC$ ATTRIBUTES ALIAS: 'SetShaleShaker' :: SetShaleShaker - implicit none - type(CProblem), intent(in) :: v - MudTreatmentProblems%ShaleShaker = SetDue(v, ChangeShaleShaker) -#ifdef deb - print*, 'ShaleShaker%ProblemType=', V%ProblemType - print*, 'ShaleShaker%StatusType=', V%StatusType - print*, 'ShaleShaker%Value=', V%Value -#endif - end subroutine - - subroutine SetDesander(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetDesander - !DEC$ ATTRIBUTES ALIAS: 'SetDesander' :: SetDesander - implicit none - type(CProblem), intent(in) :: v - MudTreatmentProblems%Desander = SetDue(v, ChangeDesander) -#ifdef deb - print*, 'Desander%ProblemType=', V%ProblemType - print*, 'Desander%StatusType=', V%StatusType - print*, 'Desander%Value=', V%Value -#endif - end subroutine - - subroutine SetDesilter(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetDesilter - !DEC$ ATTRIBUTES ALIAS: 'SetDesilter' :: SetDesilter - implicit none - type(CProblem), intent(in) :: v - MudTreatmentProblems%Desilter = SetDue(v, ChangeDesilter) -#ifdef deb - print*, 'Desilter%ProblemType=', V%ProblemType - print*, 'Desilter%StatusType=', V%StatusType - print*, 'Desilter%Value=', V%Value -#endif + subroutine ProcessMudTreatmentProblemsDueTime(time) + implicit none + integer :: time + + if(data%problems%MudTreatmentProblems%Degasser%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%MudTreatmentProblems%Degasser, ChangeDegasser, time) + if(data%problems%MudTreatmentProblems%ShaleShaker%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, time) + if(data%problems%MudTreatmentProblems%Desander%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%MudTreatmentProblems%Desander, ChangeDesander, time) + if(data%problems%MudTreatmentProblems%Desilter%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%MudTreatmentProblems%Desilter, ChangeDesilter, time) + + end subroutine + + + subroutine ProcessMudTreatmentProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + + if(data%problems%MudTreatmentProblems%Degasser%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%MudTreatmentProblems%Degasser, ChangeDegasser, strokes) + if(data%problems%MudTreatmentProblems%ShaleShaker%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, strokes) + if(data%problems%MudTreatmentProblems%Desander%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%MudTreatmentProblems%Desander, ChangeDesander, strokes) + if(data%problems%MudTreatmentProblems%Desilter%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%MudTreatmentProblems%Desilter, ChangeDesilter, strokes) + end subroutine + + + subroutine ProcessMudTreatmentProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + + if(data%problems%MudTreatmentProblems%Degasser%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%MudTreatmentProblems%Degasser, ChangeDegasser, volume) + if(data%problems%MudTreatmentProblems%ShaleShaker%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, volume) + if(data%problems%MudTreatmentProblems%Desander%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%MudTreatmentProblems%Desander, ChangeDesander, volume) + if(data%problems%MudTreatmentProblems%Desilter%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%MudTreatmentProblems%Desilter, ChangeDesilter, volume) + + end subroutine + + subroutine ProcessMudTreatmentProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + + if(data%problems%MudTreatmentProblems%Degasser%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%MudTreatmentProblems%Degasser, ChangeDegasser, distance) + if(data%problems%MudTreatmentProblems%ShaleShaker%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, distance) + if(data%problems%MudTreatmentProblems%Desander%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%MudTreatmentProblems%Desander, ChangeDesander, distance) + if(data%problems%MudTreatmentProblems%Desilter%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%MudTreatmentProblems%Desilter, ChangeDesilter, distance) + + end subroutine + + + + + + + + subroutine ChangeDegasser(status) + implicit none + integer, intent (in) :: status + !if(associated(DegasserPtr)) call DegasserPtr(status) + !if(status == Clear_StatusType) print*,'On_Degasser_Clear' + !if(status == Executed_StatusType) print*,'On_Degasser_Execute' + endsubroutine + + subroutine ChangeShaleShaker(status) + implicit none + integer, intent (in) :: status + !if(associated(ShaleShakerPtr)) call ShaleShakerPtr(status) + !if(status == Clear_StatusType) print*,'On_ShaleShaker_Clear' + !if(status == Executed_StatusType) print*,'On_ShaleShaker_Execute' + endsubroutine + + subroutine ChangeDesander(status) + implicit none + integer, intent (in) :: status + !if(associated(DesanderPtr)) call DesanderPtr(status) + !if(status == Clear_StatusType) print*,'On_Desander_Clear' + !if(status == Executed_StatusType) print*,'On_Desander_Execute' + endsubroutine + + subroutine ChangeDesilter(status) + implicit none + integer, intent (in) :: status + !if(associated(DesilterPtr)) call DesilterPtr(status) + !if(status == Clear_StatusType) print*,'On_Desilter_Clear' + !if(status == Executed_StatusType) print*,'On_Desilter_Execute' + endsubroutine end module CMudTreatmentProblems \ No newline at end of file diff --git a/CSharp/Problems/CMudTreatmentProblemsVariables.f90 b/CSharp/Problems/CMudTreatmentProblemsVariables.f90 index 15a9761..daa4fd6 100644 --- a/CSharp/Problems/CMudTreatmentProblemsVariables.f90 +++ b/CSharp/Problems/CMudTreatmentProblemsVariables.f90 @@ -10,147 +10,8 @@ module CMudTreatmentProblemsVariables type(CProblem) :: Desander type(CProblem) :: Desilter end type MudTreatmentProblemsType - type(MudTreatmentProblemsType)::MudTreatmentProblems - - ! procedure (ActionInteger), pointer :: DegasserPtr - ! procedure (ActionInteger), pointer :: ShaleShakerPtr - ! procedure (ActionInteger), pointer :: DesanderPtr - ! procedure (ActionInteger), pointer :: DesilterPtr contains - subroutine ProcessMudTreatmentProblemsDueTime(time) - implicit none - integer :: time - - if(MudTreatmentProblems%Degasser%ProblemType == Time_ProblemType) call ProcessDueTime(MudTreatmentProblems%Degasser, ChangeDegasser, time) - if(MudTreatmentProblems%ShaleShaker%ProblemType == Time_ProblemType) call ProcessDueTime(MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, time) - if(MudTreatmentProblems%Desander%ProblemType == Time_ProblemType) call ProcessDueTime(MudTreatmentProblems%Desander, ChangeDesander, time) - if(MudTreatmentProblems%Desilter%ProblemType == Time_ProblemType) call ProcessDueTime(MudTreatmentProblems%Desilter, ChangeDesilter, time) - - end subroutine - - - subroutine ProcessMudTreatmentProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - - if(MudTreatmentProblems%Degasser%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(MudTreatmentProblems%Degasser, ChangeDegasser, strokes) - if(MudTreatmentProblems%ShaleShaker%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, strokes) - if(MudTreatmentProblems%Desander%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(MudTreatmentProblems%Desander, ChangeDesander, strokes) - if(MudTreatmentProblems%Desilter%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(MudTreatmentProblems%Desilter, ChangeDesilter, strokes) - - end subroutine - - - subroutine ProcessMudTreatmentProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - - if(MudTreatmentProblems%Degasser%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(MudTreatmentProblems%Degasser, ChangeDegasser, volume) - if(MudTreatmentProblems%ShaleShaker%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, volume) - if(MudTreatmentProblems%Desander%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(MudTreatmentProblems%Desander, ChangeDesander, volume) - if(MudTreatmentProblems%Desilter%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(MudTreatmentProblems%Desilter, ChangeDesilter, volume) - - end subroutine - - subroutine ProcessMudTreatmentProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - - if(MudTreatmentProblems%Degasser%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(MudTreatmentProblems%Degasser, ChangeDegasser, distance) - if(MudTreatmentProblems%ShaleShaker%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(MudTreatmentProblems%ShaleShaker, ChangeShaleShaker, distance) - if(MudTreatmentProblems%Desander%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(MudTreatmentProblems%Desander, ChangeDesander, distance) - if(MudTreatmentProblems%Desilter%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(MudTreatmentProblems%Desilter, ChangeDesilter, distance) - - end subroutine - - - - - - - - subroutine ChangeDegasser(status) - implicit none - integer, intent (in) :: status - !if(associated(DegasserPtr)) call DegasserPtr(status) - !if(status == Clear_StatusType) print*,'On_Degasser_Clear' - !if(status == Executed_StatusType) print*,'On_Degasser_Execute' - endsubroutine - - subroutine ChangeShaleShaker(status) - implicit none - integer, intent (in) :: status - !if(associated(ShaleShakerPtr)) call ShaleShakerPtr(status) - !if(status == Clear_StatusType) print*,'On_ShaleShaker_Clear' - !if(status == Executed_StatusType) print*,'On_ShaleShaker_Execute' - endsubroutine - - subroutine ChangeDesander(status) - implicit none - integer, intent (in) :: status - !if(associated(DesanderPtr)) call DesanderPtr(status) - !if(status == Clear_StatusType) print*,'On_Desander_Clear' - !if(status == Executed_StatusType) print*,'On_Desander_Execute' - endsubroutine - - subroutine ChangeDesilter(status) - implicit none - integer, intent (in) :: status - !if(associated(DesilterPtr)) call DesilterPtr(status) - !if(status == Clear_StatusType) print*,'On_Desilter_Clear' - !if(status == Executed_StatusType) print*,'On_Desilter_Execute' - endsubroutine - - - - - - - - - - - - - - - - - ! subroutine SubscribeDegasser(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeDegasser - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeDegasser' :: SubscribeDegasser - ! implicit none - ! procedure (ActionInteger) :: v - ! DegasserPtr => v - ! end subroutine - - ! subroutine SubscribeShaleShaker(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeShaleShaker - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeShaleShaker' :: SubscribeShaleShaker - ! implicit none - ! procedure (ActionInteger) :: v - ! ShaleShakerPtr => v - ! end subroutine - - ! subroutine SubscribeDesander(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeDesander - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeDesander' :: SubscribeDesander - ! implicit none - ! procedure (ActionInteger) :: v - ! DesanderPtr => v - ! end subroutine - ! subroutine SubscribeDesilter(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeDesilter - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeDesilter' :: SubscribeDesilter - ! implicit none - ! procedure (ActionInteger) :: v - ! DesilterPtr => v - ! end subroutine - - - - end module CMudTreatmentProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/COtherProblems.f90 b/CSharp/Problems/COtherProblems.f90 index 7e618fe..99d7f7c 100644 --- a/CSharp/Problems/COtherProblems.f90 +++ b/CSharp/Problems/COtherProblems.f90 @@ -3,149 +3,167 @@ module COtherProblems implicit none public contains + subroutine ProcessOtherProblemsDueTime(time) + implicit none + integer :: time + + if(data%problems%OtherProblems%RigAlarm%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%RigAlarm, ChangeRigAlarm, time) + if(data%problems%OtherProblems%RigWaterSupply%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%RigWaterSupply, ChangeRigWaterSupply, time) + if(data%problems%OtherProblems%RigAir%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%RigAir, ChangeRigAir, time) + if(data%problems%OtherProblems%Gen1%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Gen1, ChangeGen1, time) + if(data%problems%OtherProblems%Gen2%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Gen2, ChangeGen2, time) + if(data%problems%OtherProblems%Gen3%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Gen3, ChangeGen3, time) + if(data%problems%OtherProblems%Gen4%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Gen4, ChangeGen4, time) + if(data%problems%OtherProblems%Scr1%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Scr1, ChangeScr1, time) + if(data%problems%OtherProblems%Scr2%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Scr2, ChangeScr2, time) + if(data%problems%OtherProblems%Scr3%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Scr3, ChangeScr3, time) + if(data%problems%OtherProblems%Scr4%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%OtherProblems%Scr4, ChangeScr4, time) + + end subroutine + + subroutine ProcessOtherProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + + if(data%problems%OtherProblems%RigAlarm%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%RigAlarm, ChangeRigAlarm, strokes) + if(data%problems%OtherProblems%RigWaterSupply%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%RigWaterSupply, ChangeRigWaterSupply, strokes) + if(data%problems%OtherProblems%RigAir%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%RigAir, ChangeRigAir, strokes) + if(data%problems%OtherProblems%Gen1%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Gen1, ChangeGen1, strokes) + if(data%problems%OtherProblems%Gen2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Gen2, ChangeGen2, strokes) + if(data%problems%OtherProblems%Gen3%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Gen3, ChangeGen3, strokes) + if(data%problems%OtherProblems%Gen4%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Gen4, ChangeGen4, strokes) + if(data%problems%OtherProblems%Scr1%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Scr1, ChangeScr1, strokes) + if(data%problems%OtherProblems%Scr2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Scr2, ChangeScr2, strokes) + if(data%problems%OtherProblems%Scr3%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Scr3, ChangeScr3, strokes) + if(data%problems%OtherProblems%Scr4%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%OtherProblems%Scr4, ChangeScr4, strokes) + + end subroutine + + subroutine ProcessOtherProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + + if(data%problems%OtherProblems%RigAlarm%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%RigAlarm, ChangeRigAlarm, volume) + if(data%problems%OtherProblems%RigWaterSupply%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%RigWaterSupply, ChangeRigWaterSupply, volume) + if(data%problems%OtherProblems%RigAir%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%RigAir, ChangeRigAir, volume) + if(data%problems%OtherProblems%Gen1%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Gen1, ChangeGen1, volume) + if(data%problems%OtherProblems%Gen2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Gen2, ChangeGen2, volume) + if(data%problems%OtherProblems%Gen3%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Gen3, ChangeGen3, volume) + if(data%problems%OtherProblems%Gen4%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Gen4, ChangeGen4, volume) + if(data%problems%OtherProblems%Scr1%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Scr1, ChangeScr1, volume) + if(data%problems%OtherProblems%Scr2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Scr2, ChangeScr2, volume) + if(data%problems%OtherProblems%Scr3%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Scr3, ChangeScr3, volume) + if(data%problems%OtherProblems%Scr4%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%OtherProblems%Scr4, ChangeScr4, volume) + + end subroutine + + subroutine ProcessOtherProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + + if(data%problems%OtherProblems%RigAlarm%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%RigAlarm, ChangeRigAlarm, distance) + if(data%problems%OtherProblems%RigWaterSupply%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%RigWaterSupply, ChangeRigWaterSupply, distance) + if(data%problems%OtherProblems%RigAir%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%RigAir, ChangeRigAir, distance) + if(data%problems%OtherProblems%Gen1%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Gen1, ChangeGen1, distance) + if(data%problems%OtherProblems%Gen2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Gen2, ChangeGen2, distance) + if(data%problems%OtherProblems%Gen3%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Gen3, ChangeGen3, distance) + if(data%problems%OtherProblems%Gen4%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Gen4, ChangeGen4, distance) + if(data%problems%OtherProblems%Scr1%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Scr1, ChangeScr1, distance) + if(data%problems%OtherProblems%Scr2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Scr2, ChangeScr2, distance) + if(data%problems%OtherProblems%Scr3%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Scr3, ChangeScr3, distance) + if(data%problems%OtherProblems%Scr4%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%OtherProblems%Scr4, ChangeScr4, distance) + + end subroutine - ! Input routines - subroutine SetRigAlarm(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRigAlarm - !DEC$ ATTRIBUTES ALIAS: 'SetRigAlarm' :: SetRigAlarm - implicit none - type(CProblem), intent(in) :: v - OtherProblems%RigAlarm = SetDue(v, ChangeRigAlarm) -#ifdef deb - print*, 'RigAlarm%ProblemType=', V%ProblemType - print*, 'RigAlarm%StatusType=', V%StatusType - print*, 'RigAlarm%Value=', V%Value -#endif - end subroutine - - subroutine SetRigWaterSupply(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRigWaterSupply - !DEC$ ATTRIBUTES ALIAS: 'SetRigWaterSupply' :: SetRigWaterSupply - implicit none - type(CProblem), intent(in) :: v - OtherProblems%RigWaterSupply = SetDue(v, ChangeRigWaterSupply) -#ifdef deb - print*, 'RigWaterSupply%ProblemType=', V%ProblemType - print*, 'RigWaterSupply%StatusType=', V%StatusType - print*, 'RigWaterSupply%Value=', V%Value -#endif - end subroutine - - subroutine SetRigAir(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetRigAir - !DEC$ ATTRIBUTES ALIAS: 'SetRigAir' :: SetRigAir - implicit none - type(CProblem), intent(in) :: v - OtherProblems%RigAir = SetDue(v, ChangeRigAir) -#ifdef deb - print*, 'RigAir%ProblemType=', V%ProblemType - print*, 'RigAir%StatusType=', V%StatusType - print*, 'RigAir%Value=', V%Value -#endif - end subroutine - - subroutine SetGen1(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetGen1 - !DEC$ ATTRIBUTES ALIAS: 'SetGen1' :: SetGen1 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Gen1 = SetDue(v, ChangeGen1) -#ifdef deb - print*, 'Gen1%ProblemType=', V%ProblemType - print*, 'Gen1%StatusType=', V%StatusType - print*, 'Gen1%Value=', V%Value -#endif - end subroutine - - subroutine SetGen2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetGen2 - !DEC$ ATTRIBUTES ALIAS: 'SetGen2' :: SetGen2 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Gen2 = SetDue(v, ChangeGen2) -#ifdef deb - print*, 'Gen2%ProblemType=', V%ProblemType - print*, 'Gen2%StatusType=', V%StatusType - print*, 'Gen2%Value=', V%Value -#endif - end subroutine - - subroutine SetGen3(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetGen3 - !DEC$ ATTRIBUTES ALIAS: 'SetGen3' :: SetGen3 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Gen3 = SetDue(v, ChangeGen3) -#ifdef deb - print*, 'Gen3%ProblemType=', V%ProblemType - print*, 'Gen3%StatusType=', V%StatusType - print*, 'Gen3%Value=', V%Value -#endif - end subroutine - - subroutine SetGen4(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetGen4 - !DEC$ ATTRIBUTES ALIAS: 'SetGen4' :: SetGen4 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Gen4 = SetDue(v, ChangeGen4) -#ifdef deb - print*, 'Gen4%ProblemType=', V%ProblemType - print*, 'Gen4%StatusType=', V%StatusType - print*, 'Gen4%Value=', V%Value -#endif - end subroutine - - subroutine SetScr1(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetScr1 - !DEC$ ATTRIBUTES ALIAS: 'SetScr1' :: SetScr1 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Scr1 = SetDue(v, ChangeScr1) -#ifdef deb - print*, 'Scr1%ProblemType=', V%ProblemType - print*, 'Scr1%StatusType=', V%StatusType - print*, 'Scr1%Value=', V%Value -#endif - end subroutine - - subroutine SetScr2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetScr2 - !DEC$ ATTRIBUTES ALIAS: 'SetScr2' :: SetScr2 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Scr2 = SetDue(v, ChangeScr2) -#ifdef deb - print*, 'Scr2%ProblemType=', V%ProblemType - print*, 'Scr2%StatusType=', V%StatusType - print*, 'Scr2%Value=', V%Value -#endif - end subroutine - - subroutine SetScr3(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetScr3 - !DEC$ ATTRIBUTES ALIAS: 'SetScr3' :: SetScr3 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Scr3 = SetDue(v, ChangeScr3) -#ifdef deb - print*, 'Scr3%ProblemType=', V%ProblemType - print*, 'Scr3%StatusType=', V%StatusType - print*, 'Scr3%Value=', V%Value -#endif - end subroutine + + subroutine ChangeRigAlarm(status) + implicit none + integer, intent (in) :: status + !if(associated(RigAlarmPtr)) call RigAlarmPtr(status) + !if(status == Clear_StatusType) print*,'On_RigAlarm_Clear' + !if(status == Executed_StatusType) print*,'On_RigAlarm_Execute' + endsubroutine + + subroutine ChangeRigWaterSupply(status) + implicit none + integer, intent (in) :: status + !if(associated(RigWaterSupplyPtr)) call RigWaterSupplyPtr(status) + !if(status == Clear_StatusType) print*,'On_RigWaterSupply_Clear' + !if(status == Executed_StatusType) print*,'On_RigWaterSupply_Execute' + endsubroutine + + subroutine ChangeRigAir(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + !if(associated(RigAirPtr)) call RigAirPtr(status) + if(status == Clear_StatusType) data%State%BopStackAcc%RigAirMalf = 0 + if(status == Executed_StatusType) data%State%BopStackAcc%RigAirMalf = 1 + endsubroutine + + subroutine ChangeGen1(status) + implicit none + integer, intent (in) :: status + !if(associated(Gen1Ptr)) call Gen1Ptr(status) + !if(status == Clear_StatusType) print*,'On_Gen1_Clear' + !if(status == Executed_StatusType) print*,'On_Gen1_Execute' + endsubroutine + + subroutine ChangeGen2(status) + implicit none + integer, intent (in) :: status + !if(associated(Gen2Ptr)) call Gen2Ptr(status) + !if(status == Clear_StatusType) print*,'On_Gen2_Clear' + !if(status == Executed_StatusType) print*,'On_Gen2_Execute' + endsubroutine + + subroutine ChangeGen3(status) + implicit none + integer, intent (in) :: status + !if(associated(Gen3Ptr)) call Gen3Ptr(status) + !if(status == Clear_StatusType) print*,'On_Gen3_Clear' + !if(status == Executed_StatusType) print*,'On_Gen3_Execute' + endsubroutine + + subroutine ChangeGen4(status) + implicit none + integer, intent (in) :: status + !if(associated(Gen4Ptr)) call Gen4Ptr(status) + !if(status == Clear_StatusType) print*,'On_Gen4_Clear' + !if(status == Executed_StatusType) print*,'On_Gen4_Execute' + endsubroutine + + subroutine ChangeScr1(status) + implicit none + integer, intent (in) :: status + !if(associated(Scr1Ptr)) call Scr1Ptr(status) + !if(status == Clear_StatusType) print*,'On_Scr1_Clear' + !if(status == Executed_StatusType) print*,'On_Scr1_Execute' + endsubroutine + + subroutine ChangeScr2(status) + implicit none + integer, intent (in) :: status + !if(associated(Scr2Ptr)) call Scr2Ptr(status) + !if(status == Clear_StatusType) print*,'On_Scr2_Clear' + !if(status == Executed_StatusType) print*,'On_Scr2_Execute' + endsubroutine + + subroutine ChangeScr3(status) + implicit none + integer, intent (in) :: status + !if(associated(Scr3Ptr)) call Scr3Ptr(status) + !if(status == Clear_StatusType) print*,'On_Scr3_Clear' + !if(status == Executed_StatusType) print*,'On_Scr3_Execute' + endsubroutine + + subroutine ChangeScr4(status) + implicit none + integer, intent (in) :: status + !if(associated(Scr4Ptr)) call Scr4Ptr(status) + !if(status == Clear_StatusType) print*,'On_Scr4_Clear' + !if(status == Executed_StatusType) print*,'On_Scr4_Execute' + endsubroutine - subroutine SetScr4(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SetScr4 - !DEC$ ATTRIBUTES ALIAS: 'SetScr4' :: SetScr4 - implicit none - type(CProblem), intent(in) :: v - OtherProblems%Scr4 = SetDue(v, ChangeScr4) -#ifdef deb - print*, 'Scr4%ProblemType=', V%ProblemType - print*, 'Scr4%StatusType=', V%StatusType - print*, 'Scr4%Value=', V%Value -#endif - end subroutine end module COtherProblems \ No newline at end of file diff --git a/CSharp/Problems/COtherProblemsVariables.f90 b/CSharp/Problems/COtherProblemsVariables.f90 index 3a5972a..bbc20b6 100644 --- a/CSharp/Problems/COtherProblemsVariables.f90 +++ b/CSharp/Problems/COtherProblemsVariables.f90 @@ -17,182 +17,13 @@ module COtherProblemsVariables type(CProblem) :: Scr3 type(CProblem) :: Scr4 end type OtherProblemsType - type(OtherProblemsType)::OtherProblems - ! procedure (ActionInteger), pointer :: RigAlarmPtr - ! procedure (ActionInteger), pointer :: RigWaterSupplyPtr - ! procedure (ActionInteger), pointer :: RigAirPtr - ! procedure (ActionInteger), pointer :: Gen1Ptr - ! procedure (ActionInteger), pointer :: Gen2Ptr - ! procedure (ActionInteger), pointer :: Gen3Ptr - ! procedure (ActionInteger), pointer :: Gen4Ptr - ! procedure (ActionInteger), pointer :: Scr1Ptr - ! procedure (ActionInteger), pointer :: Scr2Ptr - ! procedure (ActionInteger), pointer :: Scr3Ptr - ! procedure (ActionInteger), pointer :: Scr4Ptr - contains - subroutine ProcessOtherProblemsDueTime(time) - implicit none - integer :: time - - if(OtherProblems%RigAlarm%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%RigAlarm, ChangeRigAlarm, time) - if(OtherProblems%RigWaterSupply%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%RigWaterSupply, ChangeRigWaterSupply, time) - if(OtherProblems%RigAir%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%RigAir, ChangeRigAir, time) - if(OtherProblems%Gen1%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Gen1, ChangeGen1, time) - if(OtherProblems%Gen2%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Gen2, ChangeGen2, time) - if(OtherProblems%Gen3%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Gen3, ChangeGen3, time) - if(OtherProblems%Gen4%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Gen4, ChangeGen4, time) - if(OtherProblems%Scr1%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Scr1, ChangeScr1, time) - if(OtherProblems%Scr2%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Scr2, ChangeScr2, time) - if(OtherProblems%Scr3%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Scr3, ChangeScr3, time) - if(OtherProblems%Scr4%ProblemType == Time_ProblemType) call ProcessDueTime(OtherProblems%Scr4, ChangeScr4, time) - - end subroutine - - subroutine ProcessOtherProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - - if(OtherProblems%RigAlarm%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%RigAlarm, ChangeRigAlarm, strokes) - if(OtherProblems%RigWaterSupply%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%RigWaterSupply, ChangeRigWaterSupply, strokes) - if(OtherProblems%RigAir%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%RigAir, ChangeRigAir, strokes) - if(OtherProblems%Gen1%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Gen1, ChangeGen1, strokes) - if(OtherProblems%Gen2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Gen2, ChangeGen2, strokes) - if(OtherProblems%Gen3%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Gen3, ChangeGen3, strokes) - if(OtherProblems%Gen4%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Gen4, ChangeGen4, strokes) - if(OtherProblems%Scr1%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Scr1, ChangeScr1, strokes) - if(OtherProblems%Scr2%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Scr2, ChangeScr2, strokes) - if(OtherProblems%Scr3%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Scr3, ChangeScr3, strokes) - if(OtherProblems%Scr4%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(OtherProblems%Scr4, ChangeScr4, strokes) - - end subroutine - - subroutine ProcessOtherProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - - if(OtherProblems%RigAlarm%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%RigAlarm, ChangeRigAlarm, volume) - if(OtherProblems%RigWaterSupply%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%RigWaterSupply, ChangeRigWaterSupply, volume) - if(OtherProblems%RigAir%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%RigAir, ChangeRigAir, volume) - if(OtherProblems%Gen1%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Gen1, ChangeGen1, volume) - if(OtherProblems%Gen2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Gen2, ChangeGen2, volume) - if(OtherProblems%Gen3%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Gen3, ChangeGen3, volume) - if(OtherProblems%Gen4%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Gen4, ChangeGen4, volume) - if(OtherProblems%Scr1%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Scr1, ChangeScr1, volume) - if(OtherProblems%Scr2%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Scr2, ChangeScr2, volume) - if(OtherProblems%Scr3%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Scr3, ChangeScr3, volume) - if(OtherProblems%Scr4%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(OtherProblems%Scr4, ChangeScr4, volume) - - end subroutine - - subroutine ProcessOtherProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - - if(OtherProblems%RigAlarm%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%RigAlarm, ChangeRigAlarm, distance) - if(OtherProblems%RigWaterSupply%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%RigWaterSupply, ChangeRigWaterSupply, distance) - if(OtherProblems%RigAir%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%RigAir, ChangeRigAir, distance) - if(OtherProblems%Gen1%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Gen1, ChangeGen1, distance) - if(OtherProblems%Gen2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Gen2, ChangeGen2, distance) - if(OtherProblems%Gen3%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Gen3, ChangeGen3, distance) - if(OtherProblems%Gen4%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Gen4, ChangeGen4, distance) - if(OtherProblems%Scr1%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Scr1, ChangeScr1, distance) - if(OtherProblems%Scr2%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Scr2, ChangeScr2, distance) - if(OtherProblems%Scr3%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Scr3, ChangeScr3, distance) - if(OtherProblems%Scr4%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(OtherProblems%Scr4, ChangeScr4, distance) - - end subroutine - - - subroutine ChangeRigAlarm(status) - implicit none - integer, intent (in) :: status - !if(associated(RigAlarmPtr)) call RigAlarmPtr(status) - !if(status == Clear_StatusType) print*,'On_RigAlarm_Clear' - !if(status == Executed_StatusType) print*,'On_RigAlarm_Execute' - endsubroutine - - subroutine ChangeRigWaterSupply(status) - implicit none - integer, intent (in) :: status - !if(associated(RigWaterSupplyPtr)) call RigWaterSupplyPtr(status) - !if(status == Clear_StatusType) print*,'On_RigWaterSupply_Clear' - !if(status == Executed_StatusType) print*,'On_RigWaterSupply_Execute' - endsubroutine - - subroutine ChangeRigAir(status) - use VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(RigAirPtr)) call RigAirPtr(status) - if(status == Clear_StatusType) BopStackAcc%RigAirMalf = 0 - if(status == Executed_StatusType) BopStackAcc%RigAirMalf = 1 - endsubroutine - - subroutine ChangeGen1(status) - implicit none - integer, intent (in) :: status - !if(associated(Gen1Ptr)) call Gen1Ptr(status) - !if(status == Clear_StatusType) print*,'On_Gen1_Clear' - !if(status == Executed_StatusType) print*,'On_Gen1_Execute' - endsubroutine - - subroutine ChangeGen2(status) - implicit none - integer, intent (in) :: status - !if(associated(Gen2Ptr)) call Gen2Ptr(status) - !if(status == Clear_StatusType) print*,'On_Gen2_Clear' - !if(status == Executed_StatusType) print*,'On_Gen2_Execute' - endsubroutine - - subroutine ChangeGen3(status) - implicit none - integer, intent (in) :: status - !if(associated(Gen3Ptr)) call Gen3Ptr(status) - !if(status == Clear_StatusType) print*,'On_Gen3_Clear' - !if(status == Executed_StatusType) print*,'On_Gen3_Execute' - endsubroutine - subroutine ChangeGen4(status) - implicit none - integer, intent (in) :: status - !if(associated(Gen4Ptr)) call Gen4Ptr(status) - !if(status == Clear_StatusType) print*,'On_Gen4_Clear' - !if(status == Executed_StatusType) print*,'On_Gen4_Execute' - endsubroutine - subroutine ChangeScr1(status) - implicit none - integer, intent (in) :: status - !if(associated(Scr1Ptr)) call Scr1Ptr(status) - !if(status == Clear_StatusType) print*,'On_Scr1_Clear' - !if(status == Executed_StatusType) print*,'On_Scr1_Execute' - endsubroutine - subroutine ChangeScr2(status) - implicit none - integer, intent (in) :: status - !if(associated(Scr2Ptr)) call Scr2Ptr(status) - !if(status == Clear_StatusType) print*,'On_Scr2_Clear' - !if(status == Executed_StatusType) print*,'On_Scr2_Execute' - endsubroutine - subroutine ChangeScr3(status) - implicit none - integer, intent (in) :: status - !if(associated(Scr3Ptr)) call Scr3Ptr(status) - !if(status == Clear_StatusType) print*,'On_Scr3_Clear' - !if(status == Executed_StatusType) print*,'On_Scr3_Execute' - endsubroutine - subroutine ChangeScr4(status) - implicit none - integer, intent (in) :: status - !if(associated(Scr4Ptr)) call Scr4Ptr(status) - !if(status == Clear_StatusType) print*,'On_Scr4_Clear' - !if(status == Executed_StatusType) print*,'On_Scr4_Execute' - endsubroutine @@ -200,103 +31,5 @@ module COtherProblemsVariables - - - - - - ! subroutine SubscribeRigAlarm(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeRigAlarm - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeRigAlarm' :: SubscribeRigAlarm - ! implicit none - ! procedure (ActionInteger) :: v - ! RigAlarmPtr => v - ! end subroutine - - ! subroutine SubscribeRigWaterSupply(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeRigWaterSupply - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeRigWaterSupply' :: SubscribeRigWaterSupply - ! implicit none - ! procedure (ActionInteger) :: v - ! RigWaterSupplyPtr => v - ! end subroutine - - ! subroutine SubscribeRigAir(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeRigAir - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeRigAir' :: SubscribeRigAir - ! implicit none - ! procedure (ActionInteger) :: v - ! RigAirPtr => v - ! end subroutine - ! subroutine SubscribeGen1(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeGen1 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeGen1' :: SubscribeGen1 - ! implicit none - ! procedure (ActionInteger) :: v - ! Gen1Ptr => v - ! end subroutine - - ! subroutine SubscribeGen2(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeGen2 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeGen2' :: SubscribeGen2 - ! implicit none - ! procedure (ActionInteger) :: v - ! Gen2Ptr => v - ! end subroutine - - ! subroutine SubscribeGen3(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeGen3 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeGen3' :: SubscribeGen3 - ! implicit none - ! procedure (ActionInteger) :: v - ! Gen3Ptr => v - ! end subroutine - - ! subroutine SubscribeGen4(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeGen4 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeGen4' :: SubscribeGen4 - ! implicit none - ! procedure (ActionInteger) :: v - ! Gen4Ptr => v - ! end subroutine - - ! subroutine SubscribeScr1(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeScr1 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeScr1' :: SubscribeScr1 - ! implicit none - ! procedure (ActionInteger) :: v - ! Scr1Ptr => v - ! end subroutine - - ! subroutine SubscribeScr2(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeScr2 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeScr2' :: SubscribeScr2 - ! implicit none - ! procedure (ActionInteger) :: v - ! Scr2Ptr => v - ! end subroutine - - ! subroutine SubscribeScr3(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeScr3 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeScr3' :: SubscribeScr3 - ! implicit none - ! procedure (ActionInteger) :: v - ! Scr3Ptr => v - ! end subroutine - - ! subroutine SubscribeScr4(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeScr4 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeScr4' :: SubscribeScr4 - ! implicit none - ! procedure (ActionInteger) :: v - ! Scr4Ptr => v - ! end subroutine - - - - - - - end module COtherProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CProblemDifinition.f90 b/CSharp/Problems/CProblemDifinition.f90 index affd98a..51f0ff3 100644 --- a/CSharp/Problems/CProblemDifinition.f90 +++ b/CSharp/Problems/CProblemDifinition.f90 @@ -3,7 +3,7 @@ module CProblemDifinition implicit none public - procedure (ActionInteger), pointer :: Nil => null() + ! procedure (ActionInteger), pointer :: Nil => null() integer, parameter :: Time_ProblemType = 0 integer, parameter :: PumpStrokes_ProblemType = 1 @@ -31,82 +31,9 @@ module CProblemDifinition if(problem%StatusType == Executed_StatusType .and. associated(action)) call action(Executed_StatusType) end subroutine - ! type(CProblem) function SetDue(problem, action) - ! ! use CSimulationVariables - - ! implicit none - ! type(CProblem), intent(in) :: problem - ! procedure (ActionInteger), pointer, intent(in) :: action - ! real(8) :: CurrentTime - ! real(8) :: CurrentPumpStrokes - ! real(8) :: CurrentVolumePumped - ! real(8) :: CurrentDistanceDrilled - ! real(8) :: Due - - ! CurrentTime = 0 - ! CurrentPumpStrokes = 0 - ! CurrentVolumePumped = 0 - ! CurrentDistanceDrilled = 0 - - ! SetDue = problem - - ! if(problem%StatusType == Clear_StatusType .and. associated(action)) then - ! call action(Clear_StatusType) - ! SetDue%DueValue = 0 - ! return - ! endif - - ! select case (problem%ProblemType) - ! case(Time_ProblemType) - ! select case (SimulationState) - ! case(SimulationState_Stopped) - ! CurrentTime = 0 - ! case(SimulationState_Started) - ! CurrentTime = dble(SimulationTime) - ! case(SimulationState_Paused) - ! CurrentTime = dble(SimulationTime) - ! end select - ! Due = problem%Value + CurrentTime - ! case(PumpStrokes_ProblemType) - ! select case (SimulationState) - ! case(SimulationState_Stopped) - ! CurrentPumpStrokes = 0 - ! case(SimulationState_Started) - ! CurrentPumpStrokes = TotalPumpStrokes - ! case(SimulationState_Paused) - ! CurrentPumpStrokes = TotalPumpStrokes - ! end select - ! Due = problem%Value + CurrentPumpStrokes - ! case(VolumePumped_ProblemType) - ! select case (SimulationState) - ! case(SimulationState_Stopped) - ! CurrentVolumePumped = 0 - ! case(SimulationState_Started) - ! CurrentVolumePumped = TotalVolumePumped - ! case(SimulationState_Paused) - ! CurrentVolumePumped = TotalVolumePumped - ! end select - ! Due = problem%Value + CurrentVolumePumped - ! case(DistanceDrilled_ProblemType) - ! select case (SimulationState) - ! case(SimulationState_Stopped) - ! CurrentDistanceDrilled = 0 - ! case(SimulationState_Started) - ! CurrentDistanceDrilled = DistanceDrilled - ! case(SimulationState_Paused) - ! CurrentDistanceDrilled = DistanceDrilled - ! end select - ! Due = problem%Value + CurrentDistanceDrilled - ! end select - - ! SetDue%DueValue = Due - - - ! end function SetDue subroutine ProcessDueTime(problem, action, time) - ! use CSimulationVariables use CLog3 implicit none type(CProblem) :: problem @@ -118,7 +45,6 @@ module CProblemDifinition end subroutine subroutine ProcessDuePumpStrokes(problem, action, strokes) - ! use CSimulationVariables implicit none type(CProblem) :: problem procedure (ActionInteger), pointer, intent(in) :: action @@ -129,7 +55,6 @@ module CProblemDifinition end subroutine subroutine ProcessDueVolumePumped(problem, action, volume) - ! use CSimulationVariables implicit none type(CProblem) :: problem procedure (ActionInteger), pointer, intent(in) :: action @@ -140,7 +65,6 @@ module CProblemDifinition end subroutine subroutine ProcessDueDistanceDrilled(problem, action, distance) - ! use CSimulationVariables implicit none type(CProblem) :: problem procedure (ActionInteger), pointer, intent(in) :: action diff --git a/CSharp/Problems/CPumpProblems.f90 b/CSharp/Problems/CPumpProblems.f90 index 3a858e0..070db4f 100644 --- a/CSharp/Problems/CPumpProblems.f90 +++ b/CSharp/Problems/CPumpProblems.f90 @@ -1,86 +1,123 @@ module CPumpProblems - use CPumpProblemsVariables + use ConfigurationVariables implicit none public contains + subroutine ProcessPumpProblemsDueTime(time) + implicit none + integer :: time + + if(data%problems%PumpProblems%Pump1PowerFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%PumpProblems%Pump1PowerFail, ChangePump1PowerFail, time) + if(data%problems%PumpProblems%Pump1BlowPopOffValve%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, time) + if(data%problems%PumpProblems%Pump2PowerFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%PumpProblems%Pump2PowerFail, ChangePump2PowerFail, time) + if(data%problems%PumpProblems%Pump2BlowPopOffValve%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, time) + if(data%problems%PumpProblems%CementPumpPowerFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, time) + if(data%problems%PumpProblems%CementPumpBlowPopOffValve%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, time) + + end subroutine + + subroutine ProcessPumpProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + + if(data%problems%PumpProblems%Pump1PowerFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%PumpProblems%Pump1PowerFail, ChangePump1PowerFail, strokes) + if(data%problems%PumpProblems%Pump1BlowPopOffValve%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, strokes) + if(data%problems%PumpProblems%Pump2PowerFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%PumpProblems%Pump2PowerFail, ChangePump2PowerFail, strokes) + if(data%problems%PumpProblems%Pump2BlowPopOffValve%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, strokes) + if(data%problems%PumpProblems%CementPumpPowerFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, strokes) + if(data%problems%PumpProblems%CementPumpBlowPopOffValve%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, strokes) + + end subroutine + + subroutine ProcessPumpProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + + if(data%problems%PumpProblems%Pump1PowerFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%PumpProblems%Pump1PowerFail, ChangePump1PowerFail, volume) + if(data%problems%PumpProblems%Pump1BlowPopOffValve%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, volume) + if(data%problems%PumpProblems%Pump2PowerFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%PumpProblems%Pump2PowerFail, ChangePump2PowerFail, volume) + if(data%problems%PumpProblems%Pump2BlowPopOffValve%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, volume) + if(data%problems%PumpProblems%CementPumpPowerFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, volume) + if(data%problems%PumpProblems%CementPumpBlowPopOffValve%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, volume) + + end subroutine + + subroutine ProcessPumpProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + + if(data%problems%PumpProblems%Pump1PowerFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%PumpProblems%Pump1PowerFail, ChangePump1PowerFail, distance) + if(data%problems%PumpProblems%Pump1BlowPopOffValve%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, distance) + if(data%problems%PumpProblems%Pump2PowerFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%PumpProblems%Pump2PowerFail, ChangePump2PowerFail, distance) + if(data%problems%PumpProblems%Pump2BlowPopOffValve%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, distance) + if(data%problems%PumpProblems%CementPumpPowerFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, distance) + if(data%problems%PumpProblems%CementPumpBlowPopOffValve%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, distance) + + end subroutine + + + + + + + + + + + + subroutine ChangePump1PowerFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + !if(associated(Pump1PowerFailPtr)) call Pump1PowerFailPtr(status) + if(status == Clear_StatusType) data%State%Pump(1)%PowerFailMalf=0 + if(status == Executed_StatusType) data%State%Pump(1)%PowerFailMalf=1 + endsubroutine + + subroutine ChangePump1BlowPopOffValve(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + !if(associated(Pump1BlowPopOffValvePtr)) call Pump1BlowPopOffValvePtr(status) + if(status == Clear_StatusType) data%State%Pump(1)%BlowPopOffMalf=0 + if(status == Executed_StatusType) data%State%Pump(1)%BlowPopOffMalf=1 + endsubroutine + + subroutine ChangePump2PowerFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + !if(associated(Pump2PowerFailPtr)) call Pump2PowerFailPtr(status) + if(status == Clear_StatusType) data%State%Pump(2)%PowerFailMalf=0 + if(status == Executed_StatusType) data%State%Pump(2)%PowerFailMalf=1 + endsubroutine + + subroutine ChangePump2BlowPopOffValve(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + !if(associated(Pump2BlowPopOffValvePtr)) call Pump2BlowPopOffValvePtr(status) + if(status == Clear_StatusType) data%State%Pump(2)%BlowPopOffMalf=0 + if(status == Executed_StatusType) data%State%Pump(2)%BlowPopOffMalf=1 + endsubroutine + + subroutine ChangeCementPumpPowerFail(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + !if(associated(CementPumpPowerFailPtr)) call CementPumpPowerFailPtr(status) + if(status == Clear_StatusType) data%State%Pump(3)%PowerFailMalf=0 + if(status == Executed_StatusType) data%State%Pump(3)%PowerFailMalf=1 + endsubroutine + + subroutine ChangeCementPumpBlowPopOffValve(status) + use ConfigurationVariables + implicit none + integer, intent (in) :: status + !if(associated(CementPumpBlowPopOffValvePtr)) call CementPumpBlowPopOffValvePtr(status) + if(status == Clear_StatusType) data%State%Pump(3)%BlowPopOffMalf=0 + if(status == Executed_StatusType) data%State%Pump(3)%BlowPopOffMalf=1 + endsubroutine -! ! Input routines -! subroutine SetPump1PowerFail(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetPump1PowerFail -! !DEC$ ATTRIBUTES ALIAS: 'SetPump1PowerFail' :: SetPump1PowerFail -! implicit none -! type(CProblem), intent(in) :: v -! Pump1PowerFail = SetDue(v, ChangePump1PowerFail) -! #ifdef deb -! print*, 'Pump1PowerFail%ProblemType=', V%ProblemType -! print*, 'Pump1PowerFail%StatusType=', V%StatusType -! print*, 'Pump1PowerFail%Value=', V%Value -! #endif -! end subroutine - -! subroutine SetPump1BlowPopOffValve(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetPump1BlowPopOffValve -! !DEC$ ATTRIBUTES ALIAS: 'SetPump1BlowPopOffValve' :: SetPump1BlowPopOffValve -! implicit none -! type(CProblem), intent(in) :: v -! PumpProblems%Pump1BlowPopOffValve = SetDue(v, ChangePump1BlowPopOffValve) -! #ifdef deb -! print*, 'Pump1BlowPopOffValve%ProblemType=', V%ProblemType -! print*, 'Pump1BlowPopOffValve%StatusType=', V%StatusType -! print*, 'Pump1BlowPopOffValve%Value=', V%Value -! #endif -! end subroutine - -! subroutine SetPump2PowerFail(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetPump2PowerFail -! !DEC$ ATTRIBUTES ALIAS: 'SetPump2PowerFail' :: SetPump2PowerFail -! implicit none -! type(CProblem), intent(in) :: v -! PumpProblems%Pump2PowerFail = SetDue(v, ChangePump2PowerFail) -! #ifdef deb -! print*, 'Pump2PowerFail%ProblemType=', V%ProblemType -! print*, 'Pump2PowerFail%StatusType=', V%StatusType -! print*, 'Pump2PowerFail%Value=', V%Value -! #endif -! end subroutine - -! subroutine SetPump2BlowPopOffValve(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetPump2BlowPopOffValve -! !DEC$ ATTRIBUTES ALIAS: 'SetPump2BlowPopOffValve' :: SetPump2BlowPopOffValve -! implicit none -! type(CProblem), intent(in) :: v -! PumpProblems%Pump2BlowPopOffValve = SetDue(v, ChangePump2BlowPopOffValve) -! #ifdef deb -! print*, 'Pump2BlowPopOffValve%ProblemType=', V%ProblemType -! print*, 'Pump2BlowPopOffValve%StatusType=', V%StatusType -! print*, 'Pump2BlowPopOffValve%Value=', V%Value -! #endif -! end subroutine - -! subroutine SetCementPumpPowerFail(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpPowerFail -! !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpPowerFail' :: SetCementPumpPowerFail -! implicit none -! type(CProblem), intent(in) :: v -! PumpProblems%CementPumpPowerFail = SetDue(v, ChangeCementPumpPowerFail) -! #ifdef deb -! print*, 'CementPumpPowerFail%ProblemType=', V%ProblemType -! print*, 'CementPumpPowerFail%StatusType=', V%StatusType -! print*, 'CementPumpPowerFail%Value=', V%Value -! #endif -! end subroutine - -! subroutine SetCementPumpBlowPopOffValve(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetCementPumpBlowPopOffValve -! !DEC$ ATTRIBUTES ALIAS: 'SetCementPumpBlowPopOffValve' :: SetCementPumpBlowPopOffValve -! implicit none -! type(CProblem), intent(in) :: v -! PumpProblems%CementPumpBlowPopOffValve = SetDue(v, ChangeCementPumpBlowPopOffValve) -! #ifdef deb -! print*, 'CementPumpBlowPopOffValve%ProblemType=', V%ProblemType -! print*, 'CementPumpBlowPopOffValve%StatusType=', V%StatusType -! print*, 'CementPumpBlowPopOffValve%Value=', V%Value -! #endif -! end subroutine end module CPumpProblems \ No newline at end of file diff --git a/CSharp/Problems/CPumpProblemsVariables.f90 b/CSharp/Problems/CPumpProblemsVariables.f90 index 3896e9a..39d76fd 100644 --- a/CSharp/Problems/CPumpProblemsVariables.f90 +++ b/CSharp/Problems/CPumpProblemsVariables.f90 @@ -12,147 +12,8 @@ module CPumpProblemsVariables type(CProblem) :: CementPumpPowerFail type(CProblem) :: CementPumpBlowPopOffValve end type PumpProblemsType - type(PumpProblemsType)::PumpProblems - ! procedure (ActionInteger), pointer :: Pump1PowerFailPtr - ! procedure (ActionInteger), pointer :: Pump1BlowPopOffValvePtr - ! procedure (ActionInteger), pointer :: Pump2PowerFailPtr - ! procedure (ActionInteger), pointer :: Pump2BlowPopOffValvePtr - ! procedure (ActionInteger), pointer :: CementPumpPowerFailPtr - ! procedure (ActionInteger), pointer :: CementPumpBlowPopOffValvePtr - - contains - subroutine ProcessPumpProblemsDueTime(time) - implicit none - integer :: time - - if(PumpProblems%Pump1PowerFail%ProblemType == Time_ProblemType) call ProcessDueTime(PumpProblems%Pump1PowerFail, ChangePump1PowerFail, time) - if(PumpProblems%Pump1BlowPopOffValve%ProblemType == Time_ProblemType) call ProcessDueTime(PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, time) - if(PumpProblems%Pump2PowerFail%ProblemType == Time_ProblemType) call ProcessDueTime(PumpProblems%Pump2PowerFail, ChangePump2PowerFail, time) - if(PumpProblems%Pump2BlowPopOffValve%ProblemType == Time_ProblemType) call ProcessDueTime(PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, time) - if(PumpProblems%CementPumpPowerFail%ProblemType == Time_ProblemType) call ProcessDueTime(PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, time) - if(PumpProblems%CementPumpBlowPopOffValve%ProblemType == Time_ProblemType) call ProcessDueTime(PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, time) - - end subroutine - - subroutine ProcessPumpProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - - if(PumpProblems%Pump1PowerFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(PumpProblems%Pump1PowerFail, ChangePump1PowerFail, strokes) - if(PumpProblems%Pump1BlowPopOffValve%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, strokes) - if(PumpProblems%Pump2PowerFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(PumpProblems%Pump2PowerFail, ChangePump2PowerFail, strokes) - if(PumpProblems%Pump2BlowPopOffValve%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, strokes) - if(PumpProblems%CementPumpPowerFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, strokes) - if(PumpProblems%CementPumpBlowPopOffValve%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, strokes) - - end subroutine - - subroutine ProcessPumpProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - - if(PumpProblems%Pump1PowerFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(PumpProblems%Pump1PowerFail, ChangePump1PowerFail, volume) - if(PumpProblems%Pump1BlowPopOffValve%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, volume) - if(PumpProblems%Pump2PowerFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(PumpProblems%Pump2PowerFail, ChangePump2PowerFail, volume) - if(PumpProblems%Pump2BlowPopOffValve%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, volume) - if(PumpProblems%CementPumpPowerFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, volume) - if(PumpProblems%CementPumpBlowPopOffValve%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, volume) - - end subroutine - - subroutine ProcessPumpProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - - if(PumpProblems%Pump1PowerFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(PumpProblems%Pump1PowerFail, ChangePump1PowerFail, distance) - if(PumpProblems%Pump1BlowPopOffValve%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(PumpProblems%Pump1BlowPopOffValve, ChangePump1BlowPopOffValve, distance) - if(PumpProblems%Pump2PowerFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(PumpProblems%Pump2PowerFail, ChangePump2PowerFail, distance) - if(PumpProblems%Pump2BlowPopOffValve%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(PumpProblems%Pump2BlowPopOffValve, ChangePump2BlowPopOffValve, distance) - if(PumpProblems%CementPumpPowerFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(PumpProblems%CementPumpPowerFail, ChangeCementPumpPowerFail, distance) - if(PumpProblems%CementPumpBlowPopOffValve%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(PumpProblems%CementPumpBlowPopOffValve, ChangeCementPumpBlowPopOffValve, distance) - - end subroutine - - - - - - - - - - - - subroutine ChangePump1PowerFail(status) - Use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(Pump1PowerFailPtr)) call Pump1PowerFailPtr(status) - if(status == Clear_StatusType) PUMP(1)%PowerFailMalf=0 - if(status == Executed_StatusType) PUMP(1)%PowerFailMalf=1 - endsubroutine - - subroutine ChangePump1BlowPopOffValve(status) - Use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(Pump1BlowPopOffValvePtr)) call Pump1BlowPopOffValvePtr(status) - if(status == Clear_StatusType) PUMP(1)%BlowPopOffMalf=0 - if(status == Executed_StatusType) PUMP(1)%BlowPopOffMalf=1 - endsubroutine - - subroutine ChangePump2PowerFail(status) - Use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(Pump2PowerFailPtr)) call Pump2PowerFailPtr(status) - if(status == Clear_StatusType) PUMP(2)%PowerFailMalf=0 - if(status == Executed_StatusType) PUMP(2)%PowerFailMalf=1 - endsubroutine - - subroutine ChangePump2BlowPopOffValve(status) - Use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(Pump2BlowPopOffValvePtr)) call Pump2BlowPopOffValvePtr(status) - if(status == Clear_StatusType) PUMP(2)%BlowPopOffMalf=0 - if(status == Executed_StatusType) PUMP(2)%BlowPopOffMalf=1 - endsubroutine - - subroutine ChangeCementPumpPowerFail(status) - Use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(CementPumpPowerFailPtr)) call CementPumpPowerFailPtr(status) - if(status == Clear_StatusType) PUMP(3)%PowerFailMalf=0 - if(status == Executed_StatusType) PUMP(3)%PowerFailMalf=1 - endsubroutine - - subroutine ChangeCementPumpBlowPopOffValve(status) - Use Pumps_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(CementPumpBlowPopOffValvePtr)) call CementPumpBlowPopOffValvePtr(status) - if(status == Clear_StatusType) PUMP(3)%BlowPopOffMalf=0 - if(status == Executed_StatusType) PUMP(3)%BlowPopOffMalf=1 - endsubroutine - - - - - - - - - - - - - - - - + end module CPumpProblemsVariables \ No newline at end of file diff --git a/CSharp/Problems/CRotaryProblems.f90 b/CSharp/Problems/CRotaryProblems.f90 index 4f95aac..5254d4d 100644 --- a/CSharp/Problems/CRotaryProblems.f90 +++ b/CSharp/Problems/CRotaryProblems.f90 @@ -1,34 +1,66 @@ module CRotaryProblems - use CRotaryProblemsVariables + use ConfigurationVariables implicit none public contains + subroutine ProcessRotaryProblemsDueTime(time) + implicit none + integer :: time + + if(data%problems%RotaryProblems%MotorFail%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%RotaryProblems%MotorFail, ChangeMotorFail, time) + if(data%problems%RotaryProblems%OverideTorqueLimit%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, time) + + end subroutine -! ! Input routines -! subroutine SetMotorFail2(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetMotorFail2 -! !DEC$ ATTRIBUTES ALIAS: 'SetMotorFail2' :: SetMotorFail2 -! implicit none -! type(CProblem), intent(in) :: v -! RotaryProblems%MotorFail = SetDue(v, ChangeMotorFail) -! #ifdef deb -! print*, 'MotorFail%ProblemType=', V%ProblemType -! print*, 'MotorFail%StatusType=', V%StatusType -! print*, 'MotorFail%Value=', V%Value -! #endif -! end subroutine - -! subroutine SetOverideTorqueLimit2(v) -! !DEC$ ATTRIBUTES DLLEXPORT :: SetOverideTorqueLimit2 -! !DEC$ ATTRIBUTES ALIAS: 'SetOverideTorqueLimit2' :: SetOverideTorqueLimit2 -! implicit none -! type(CProblem), intent(in) :: v -! RotaryProblems%OverideTorqueLimit = SetDue(v, ChangeOverideTorqueLimit) -! #ifdef deb -! print*, 'OverideTorqueLimit%ProblemType=', V%ProblemType -! print*, 'OverideTorqueLimit%StatusType=', V%StatusType -! print*, 'OverideTorqueLimit%Value=', V%Value -! #endif -! end subroutine + subroutine ProcessRotaryProblemsDuePumpStrokes(strokes) + implicit none + integer :: strokes + + if(data%problems%RotaryProblems%MotorFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%RotaryProblems%MotorFail, ChangeMotorFail, strokes) + if(data%problems%RotaryProblems%OverideTorqueLimit%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, strokes) + + end subroutine + + subroutine ProcessRotaryProblemsDueVolumePumped(volume) + implicit none + real(8) :: volume + + if(data%problems%RotaryProblems%MotorFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%RotaryProblems%MotorFail, ChangeMotorFail, volume) + if(data%problems%RotaryProblems%OverideTorqueLimit%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, volume) + + end subroutine + + subroutine ProcessRotaryProblemsDueDistanceDrilled(distance) + implicit none + real(8) :: distance + + if(data%problems%RotaryProblems%MotorFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%RotaryProblems%MotorFail, ChangeMotorFail, distance) + if(data%problems%RotaryProblems%OverideTorqueLimit%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, distance) + + end subroutine + + + + + + + + subroutine ChangeMotorFail(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + !if(associated(MotorFailPtr)) call MotorFailPtr(status) + if(status == Clear_StatusType) data%State%RTable%MotorFaileMalf=0 + if(status == Executed_StatusType) data%State%RTable%MotorFaileMalf=1 + endsubroutine + + subroutine ChangeOverideTorqueLimit(status) + use ConfigurationVariables !@ + implicit none + integer, intent (in) :: status + !if(associated(OverideTorqueLimitPtr)) call OverideTorqueLimitPtr(status) + if(status == Clear_StatusType) data%State%RTable%OverideTorqueLimitMalf=0 + if(status == Executed_StatusType) data%State%RTable%OverideTorqueLimitMalf=1 + endsubroutine end module CRotaryProblems \ No newline at end of file diff --git a/CSharp/Problems/CRotaryProblemsVariables.f90 b/CSharp/Problems/CRotaryProblemsVariables.f90 index 1772d6b..2c2230b 100644 --- a/CSharp/Problems/CRotaryProblemsVariables.f90 +++ b/CSharp/Problems/CRotaryProblemsVariables.f90 @@ -8,101 +8,7 @@ module CRotaryProblemsVariables type(CProblem) :: MotorFail type(CProblem) :: OverideTorqueLimit end type RotaryProblemsType - type(RotaryProblemsType)::RotaryProblems - ! procedure (ActionInteger), pointer :: MotorFailPtr - ! procedure (ActionInteger), pointer :: OverideTorqueLimitPtr contains - subroutine ProcessRotaryProblemsDueTime(time) - implicit none - integer :: time - - if(RotaryProblems%MotorFail%ProblemType == Time_ProblemType) call ProcessDueTime(RotaryProblems%MotorFail, ChangeMotorFail, time) - if(RotaryProblems%OverideTorqueLimit%ProblemType == Time_ProblemType) call ProcessDueTime(RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, time) - - end subroutine - - subroutine ProcessRotaryProblemsDuePumpStrokes(strokes) - implicit none - integer :: strokes - - if(RotaryProblems%MotorFail%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(RotaryProblems%MotorFail, ChangeMotorFail, strokes) - if(RotaryProblems%OverideTorqueLimit%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, strokes) - - end subroutine - - subroutine ProcessRotaryProblemsDueVolumePumped(volume) - implicit none - real(8) :: volume - - if(RotaryProblems%MotorFail%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(RotaryProblems%MotorFail, ChangeMotorFail, volume) - if(RotaryProblems%OverideTorqueLimit%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, volume) - - end subroutine - - subroutine ProcessRotaryProblemsDueDistanceDrilled(distance) - implicit none - real(8) :: distance - - if(RotaryProblems%MotorFail%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(RotaryProblems%MotorFail, ChangeMotorFail, distance) - if(RotaryProblems%OverideTorqueLimit%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(RotaryProblems%OverideTorqueLimit, ChangeOverideTorqueLimit, distance) - - end subroutine - - - - - - - - subroutine ChangeMotorFail(status) - use RTable_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(MotorFailPtr)) call MotorFailPtr(status) - if(status == Clear_StatusType) RTable%MotorFaileMalf=0 - if(status == Executed_StatusType) RTable%MotorFaileMalf=1 - endsubroutine - - subroutine ChangeOverideTorqueLimit(status) - use RTable_VARIABLES - implicit none - integer, intent (in) :: status - !if(associated(OverideTorqueLimitPtr)) call OverideTorqueLimitPtr(status) - if(status == Clear_StatusType) RTable%OverideTorqueLimitMalf=0 - if(status == Executed_StatusType) RTable%OverideTorqueLimitMalf=1 - endsubroutine - - - - - - - - - - - - - - - ! subroutine SubscribeMotorFail2(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMotorFail2 - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeMotorFail2' :: SubscribeMotorFail2 - ! implicit none - ! procedure (ActionInteger) :: v - ! MotorFailPtr => v - ! end subroutine - - ! subroutine SubscribeOverideTorqueLimit(v) - ! !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeOverideTorqueLimit - ! !DEC$ ATTRIBUTES ALIAS: 'SubscribeOverideTorqueLimit' :: SubscribeOverideTorqueLimit - ! implicit none - ! procedure (ActionInteger) :: v - ! OverideTorqueLimitPtr => v - ! end subroutine - - - end module CRotaryProblemsVariables \ No newline at end of file diff --git a/CSharp/StudentStation/CStudentStationVariables.f90 b/CSharp/StudentStation/CStudentStationVariables.f90 index 21531dc..e7b8801 100644 --- a/CSharp/StudentStation/CStudentStationVariables.f90 +++ b/CSharp/StudentStation/CStudentStationVariables.f90 @@ -10,17 +10,6 @@ module CStudentStationVariables logical :: MudBoxInstallation logical :: TapSelector end type StudentStationType - type(StudentStationType)::StudentStation - ! ! type(VoidEventHandlerCollection) :: OnStudentStation%FillupHeadInstallationPress - ! ! type(VoidEventHandlerCollection) :: OnFillupHeadRemovePress - - - ! ! type(VoidEventHandlerCollection) :: OnMudBoxInstallationPress - ! ! type(VoidEventHandlerCollection) :: - - - - ! Output vars contains end module CStudentStationVariables \ No newline at end of file diff --git a/CSharp/Warnings/CWarnings.f90 b/CSharp/Warnings/CWarnings.f90 index ab83947..ca4b42c 100644 --- a/CSharp/Warnings/CWarnings.f90 +++ b/CSharp/Warnings/CWarnings.f90 @@ -1,6 +1,568 @@ module CWarnings - use CWarningsVariables + ! use CWarnings + use ConfigurationVariables implicit none - public + public contains + subroutine Activate_PumpWithKellyDisconnected() + implicit none + if(data%Warnings%PumpWithKellyDisconnected) return + data%Warnings%PumpWithKellyDisconnected = .true. + call RunPumpWithKellyDisconnected() + end subroutine + + subroutine Activate_PumpWithTopdriveDisconnected() + implicit none + if(data%Warnings%PumpWithTopdriveDisconnected) return + data%Warnings%PumpWithTopdriveDisconnected = .true. + call RunPumpWithTopdriveDisconnected() + end subroutine + + subroutine Activate_Pump1PopOffValveBlown() + implicit none + if(data%Warnings%Pump1PopOffValveBlown) return + data%Warnings%Pump1PopOffValveBlown = .true. + call RunPump1PopOffValveBlown() + end subroutine + + subroutine Activate_Pump1Failure() + implicit none + if(data%Warnings%Pump1Failure) return + data%Warnings%Pump1Failure = .true. + call RunPump1Failure() + end subroutine + + subroutine Activate_Pump2PopOffValveBlown() + implicit none + if(data%Warnings%Pump2PopOffValveBlown) return + data%Warnings%Pump2PopOffValveBlown = .true. + call RunPump2PopOffValveBlown() + end subroutine + + subroutine Activate_Pump2Failure() + implicit none + if(data%Warnings%Pump2Failure) return + data%Warnings%Pump2Failure = .true. + call RunPump2Failure() + end subroutine + + subroutine Activate_Pump3PopOffValveBlown() + implicit none + if(data%Warnings%Pump3PopOffValveBlown) return + data%Warnings%Pump3PopOffValveBlown = .true. + call RunPump3PopOffValveBlown() + end subroutine + + subroutine Activate_Pump3Failure() + implicit none + if(data%Warnings%Pump3Failure) return + data%Warnings%Pump3Failure = .true. + call RunPump3Failure() + end subroutine + + subroutine Activate_DrawworksGearsAbuse() + implicit none + if(data%Warnings%DrawworksGearsAbuse) return + data%Warnings%DrawworksGearsAbuse = .true. + call RunDrawworksGearsAbuse() + end subroutine + + subroutine Activate_RotaryGearsAbuse() + implicit none + if(data%Warnings%RotaryGearsAbuse) return + data%Warnings%RotaryGearsAbuse = .true. + call RunRotaryGearsAbuse() + end subroutine + + subroutine Activate_HoistLineBreak() + implicit none + if(data%Warnings%HoistLineBreak) return + data%Warnings%HoistLineBreak = .true. + call RunHoistLineBreak() + end subroutine + + subroutine Activate_PartedDrillString() + implicit none + if(data%Warnings%PartedDrillString) return + data%Warnings%PartedDrillString = .true. + call RunPartedDrillString() + end subroutine + + subroutine Activate_ActiveTankOverflow() + implicit none + if(data%Warnings%ActiveTankOverflow) return + data%Warnings%ActiveTankOverflow = .true. + call RunActiveTankOverflow() + end subroutine + + subroutine Activate_ActiveTankUnderVolume() + implicit none + if(data%Warnings%ActiveTankUnderVolume) return + data%Warnings%ActiveTankUnderVolume = .true. + call RunActiveTankUnderVolume() + end subroutine + + subroutine Activate_TripTankOverflow() + implicit none + if(data%Warnings%TripTankOverflow) return + data%Warnings%TripTankOverflow = .true. + call RunTripTankOverflow() + end subroutine + + subroutine Activate_DrillPipeTwistOff() + implicit none + if(data%Warnings%DrillPipeTwistOff) return + data%Warnings%DrillPipeTwistOff = .true. + call RunDrillPipeTwistOff() + end subroutine + + subroutine Activate_DrillPipeParted() + implicit none + if(data%Warnings%DrillPipeParted) return + data%Warnings%DrillPipeParted = .true. + call RunDrillPipeParted() + end subroutine + + subroutine Activate_TripWithSlipsSet() + implicit none + if(data%Warnings%TripWithSlipsSet) return + data%Warnings%TripWithSlipsSet = .true. + call RunTripWithSlipsSet() + end subroutine + + subroutine Activate_Blowout() + implicit none + if(data%Warnings%Blowout) return + data%Warnings%Blowout = .true. + call RunBlowout() + end subroutine + + subroutine Activate_UndergroundBlowout() + implicit none + if(data%Warnings%UndergroundBlowout) return + data%Warnings%UndergroundBlowout = .true. + call RunUndergroundBlowout() + end subroutine + + subroutine Activate_MaximumWellDepthExceeded() + implicit none + if(data%Warnings%MaximumWellDepthExceeded) return + data%Warnings%MaximumWellDepthExceeded = .true. + call RunMaximumWellDepthExceeded() + end subroutine + + subroutine Activate_CrownCollision() + implicit none + if(data%Warnings%CrownCollision) return + data%Warnings%CrownCollision = .true. + call RunCrownCollision() + end subroutine + + subroutine Activate_FloorCollision() + implicit none + if(data%Warnings%FloorCollision) return + data%Warnings%FloorCollision = .true. + call RunFloorCollision() + end subroutine + + subroutine Activate_TopdriveRotaryTableConfilict() + implicit none + if(data%Warnings%TopdriveRotaryTableConfilict) return + data%Warnings%TopdriveRotaryTableConfilict = .true. + call RunTopdriveRotaryTableConfilict() + end subroutine + + + + + + + + + + + + + + + + + + + + + + + + + + + subroutine Deactivate_PumpWithKellyDisconnected() + implicit none + if(.not.data%Warnings%PumpWithKellyDisconnected) return + data%Warnings%PumpWithKellyDisconnected = .false. + call RunPumpWithKellyDisconnected() + end subroutine + + subroutine Deactivate_PumpWithTopdriveDisconnected() + implicit none + if(.not.data%Warnings%PumpWithTopdriveDisconnected) return + data%Warnings%PumpWithTopdriveDisconnected = .false. + call RunPumpWithTopdriveDisconnected() + end subroutine + + subroutine Deactivate_Pump1PopOffValveBlown() + use CManifolds + implicit none + if(.not.data%Warnings%Pump1PopOffValveBlown) return + data%Warnings%Pump1PopOffValveBlown = .false. + call ChangeValve(65, .false.) + call RunPump1PopOffValveBlown() + end subroutine + + subroutine Deactivate_Pump1Failure() + use CManifolds + implicit none + if(.not.data%Warnings%Pump1Failure) return + data%Warnings%Pump1Failure = .false. + call RunPump1Failure() + end subroutine + + subroutine Deactivate_Pump2PopOffValveBlown() + use CManifolds + implicit none + if(.not.data%Warnings%Pump2PopOffValveBlown) return + data%Warnings%Pump2PopOffValveBlown = .false. + call ChangeValve(66, .false.) + call RunPump2PopOffValveBlown() + end subroutine + + subroutine Deactivate_Pump2Failure() + use CManifolds + implicit none + if(.not.data%Warnings%Pump2Failure) return + data%Warnings%Pump2Failure = .false. + call RunPump2Failure() + end subroutine + + subroutine Deactivate_Pump3PopOffValveBlown() + use CManifolds + implicit none + if(.not.data%Warnings%Pump3PopOffValveBlown) return + data%Warnings%Pump3PopOffValveBlown = .false. + call RunPump3PopOffValveBlown() + end subroutine + + subroutine Deactivate_Pump3Failure() + use CManifolds + implicit none + if(.not.data%Warnings%Pump3Failure) return + data%Warnings%Pump3Failure = .false. + call RunPump3Failure() + end subroutine + + subroutine Deactivate_DrawworksGearsAbuse() + implicit none + if(.not.data%Warnings%DrawworksGearsAbuse) return + data%Warnings%DrawworksGearsAbuse = .false. + call RunDrawworksGearsAbuse() + end subroutine + + subroutine Deactivate_RotaryGearsAbuse() + implicit none + if(.not.data%Warnings%RotaryGearsAbuse) return + data%Warnings%RotaryGearsAbuse = .false. + call RunRotaryGearsAbuse() + end subroutine + + subroutine Deactivate_HoistLineBreak() + implicit none + if(.not.data%Warnings%HoistLineBreak) return + data%Warnings%HoistLineBreak = .false. + call RunHoistLineBreak() + end subroutine + + subroutine Deactivate_PartedDrillString() + implicit none + if(.not.data%Warnings%PartedDrillString) return + data%Warnings%PartedDrillString = .false. + call RunPartedDrillString() + end subroutine + + subroutine Deactivate_ActiveTankOverflow() + implicit none + if(.not.data%Warnings%ActiveTankOverflow) return + data%Warnings%ActiveTankOverflow = .false. + call RunActiveTankOverflow() + end subroutine + + subroutine Deactivate_ActiveTankUnderVolume() + implicit none + if(.not.data%Warnings%ActiveTankUnderVolume) return + data%Warnings%ActiveTankUnderVolume = .false. + call RunActiveTankUnderVolume() + end subroutine + + subroutine Deactivate_TripTankOverflow() + implicit none + if(.not.data%Warnings%TripTankOverflow) return + data%Warnings%TripTankOverflow = .false. + call RunTripTankOverflow() + end subroutine + + subroutine Deactivate_DrillPipeTwistOff() + implicit none + if(.not.data%Warnings%DrillPipeTwistOff) return + data%Warnings%DrillPipeTwistOff = .false. + call RunDrillPipeTwistOff() + end subroutine + + subroutine Deactivate_DrillPipeParted() + implicit none + if(.not.data%Warnings%DrillPipeParted) return + data%Warnings%DrillPipeParted = .false. + call RunDrillPipeParted() + end subroutine + + subroutine Deactivate_TripWithSlipsSet() + implicit none + if(.not.data%Warnings%TripWithSlipsSet) return + data%Warnings%TripWithSlipsSet = .false. + call RunTripWithSlipsSet() + end subroutine + + subroutine Deactivate_Blowout() + implicit none + if(.not.data%Warnings%Blowout) return + data%Warnings%Blowout = .false. + call RunBlowout() + end subroutine + + subroutine Deactivate_UndergroundBlowout() + implicit none + if(.not.data%Warnings%UndergroundBlowout) return + data%Warnings%UndergroundBlowout = .false. + call RunUndergroundBlowout() + end subroutine + + subroutine Deactivate_MaximumWellDepthExceeded() + implicit none + if(.not.data%Warnings%MaximumWellDepthExceeded) return + data%Warnings%MaximumWellDepthExceeded = .false. + call RunMaximumWellDepthExceeded() + end subroutine + + subroutine Deactivate_CrownCollision() + implicit none + if(.not.data%Warnings%CrownCollision) return + data%Warnings%CrownCollision = .false. + call RunCrownCollision() + end subroutine + + subroutine Deactivate_FloorCollision() + implicit none + if(.not.data%Warnings%FloorCollision) return + data%Warnings%FloorCollision = .false. + call RunFloorCollision() + end subroutine + + subroutine Deactivate_TopdriveRotaryTableConfilict() + implicit none + if(.not.data%Warnings%TopdriveRotaryTableConfilict) return + data%Warnings%TopdriveRotaryTableConfilict = .false. + call RunTopdriveRotaryTableConfilict() + end subroutine + + + + + + + + + + + + + + + + + + + + + + + + + + subroutine RunPumpWithKellyDisconnected() + implicit none + ! if(associated(PumpWithKellyDisconnectedPtr)) then + ! call PumpWithKellyDisconnectedPtr(data%Warnings%PumpWithKellyDisconnected) + ! end if + end subroutine + + subroutine RunPumpWithTopdriveDisconnected() + implicit none + ! if(associated(PumpWithTopdriveDisconnectedPtr)) then + ! call PumpWithTopdriveDisconnectedPtr(data%Warnings%PumpWithTopdriveDisconnected) + ! end if + end subroutine + + subroutine RunPump1PopOffValveBlown() + implicit none + ! if(associated(Pump1PopOffValveBlownPtr)) then + ! call Pump1PopOffValveBlownPtr(data%Warnings%Pump1PopOffValveBlown) + ! end if + end subroutine + + subroutine RunPump1Failure() + ! implicit none + ! if(associated(Pump1FailurePtr)) then + ! call Pump1FailurePtr(data%Warnings%Pump1Failure) + ! end if + end subroutine + + subroutine RunPump2PopOffValveBlown() + ! implicit none + ! if(associated(Pump2PopOffValveBlownPtr)) then + ! call Pump2PopOffValveBlownPtr(data%Warnings%Pump2PopOffValveBlown) + ! end if + end subroutine + + subroutine RunPump2Failure() + implicit none + ! if(associated(Pump2FailurePtr)) then + ! call Pump2FailurePtr(data%Warnings%Pump2Failure) + ! end if + end subroutine + + subroutine RunPump3PopOffValveBlown() + implicit none + ! if(associated(Pump3PopOffValveBlownPtr)) then + ! call Pump3PopOffValveBlownPtr(data%Warnings%Pump3PopOffValveBlown) + ! end if + end subroutine + + subroutine RunPump3Failure() + implicit none + ! if(associated(Pump3FailurePtr)) then + ! call Pump3FailurePtr(data%Warnings%Pump3Failure) + ! end if + end subroutine + + subroutine RunDrawworksGearsAbuse() + implicit none + ! if(associated(DrawworksGearsAbusePtr)) then + ! call DrawworksGearsAbusePtr(data%Warnings%DrawworksGearsAbuse) + ! end if + end subroutine + + subroutine RunRotaryGearsAbuse() + implicit none + ! if(associated(RotaryGearsAbusePtr)) then + ! call RotaryGearsAbusePtr(data%Warnings%RotaryGearsAbuse) + ! end if + end subroutine + + subroutine RunHoistLineBreak() + implicit none + ! if(associated(HoistLineBreakPtr)) then + ! call HoistLineBreakPtr(data%Warnings%HoistLineBreak) + ! end if + end subroutine + + subroutine RunPartedDrillString() + implicit none + ! if(associated(PartedDrillStringPtr)) then + ! call PartedDrillStringPtr(data%Warnings%PartedDrillString) + ! end if + end subroutine + + subroutine RunActiveTankOverflow() + implicit none + ! if(associated(ActiveTankOverflowPtr)) then + ! call ActiveTankOverflowPtr(data%Warnings%ActiveTankOverflow) + ! end if + end subroutine + + subroutine RunActiveTankUnderVolume() + implicit none + ! if(associated(ActiveTankUnderVolumePtr)) then + ! call ActiveTankUnderVolumePtr(data%Warnings%ActiveTankUnderVolume) + ! end if + end subroutine + + subroutine RunTripTankOverflow() + implicit none + ! if(associated(TripTankOverflowPtr)) then + ! call TripTankOverflowPtr(data%Warnings%TripTankOverflow) + ! end if + end subroutine + + subroutine RunDrillPipeTwistOff() + implicit none + ! if(associated(DrillPipeTwistOffPtr)) then + ! call DrillPipeTwistOffPtr(data%Warnings%DrillPipeTwistOff) + ! end if + end subroutine + + subroutine RunDrillPipeParted() + implicit none + ! if(associated(DrillPipePartedPtr)) then + ! call DrillPipePartedPtr(data%Warnings%DrillPipeParted) + ! end if + end subroutine + + subroutine RunTripWithSlipsSet() + implicit none + ! if(associated(TripWithSlipsSetPtr)) then + ! call TripWithSlipsSetPtr(data%Warnings%TripWithSlipsSet) + ! end if + end subroutine + + subroutine RunBlowout() + implicit none + ! if(associated(BlowoutPtr)) then + ! call BlowoutPtr(data%Warnings%Blowout) + ! end if + end subroutine + + subroutine RunUndergroundBlowout() + implicit none + ! if(associated(UndergroundBlowoutPtr)) then + ! call UndergroundBlowoutPtr(data%Warnings%UndergroundBlowout) + ! end if + end subroutine + + subroutine RunMaximumWellDepthExceeded() + implicit none + ! if(associated(MaximumWellDepthExceededPtr)) then + ! call MaximumWellDepthExceededPtr(data%Warnings%MaximumWellDepthExceeded) + ! end if + end subroutine + + subroutine RunCrownCollision() + implicit none + ! if(associated(CrownCollisionPtr)) then + ! call CrownCollisionPtr(data%Warnings%CrownCollision) + ! end if + end subroutine + + subroutine RunFloorCollision() + implicit none + ! if(associated(FloorCollisionPtr)) then + ! call FloorCollisionPtr(data%Warnings%FloorCollision) + ! end if + end subroutine + + subroutine RunTopdriveRotaryTableConfilict() + implicit none + ! if(associated(TopdriveRotaryTableConfilictPtr)) then + ! call TopdriveRotaryTableConfilictPtr(data%Warnings%TopdriveRotaryTableConfilict) + ! end if + end subroutine + end module CWarnings \ No newline at end of file diff --git a/CSharp/Warnings/CWarningsActions.f90 b/CSharp/Warnings/CWarningsActions.f90 deleted file mode 100644 index 3d1b926..0000000 --- a/CSharp/Warnings/CWarningsActions.f90 +++ /dev/null @@ -1,224 +0,0 @@ -module CWarningsActions - use CIActionReference - implicit none - public - - procedure (ActionBool), pointer :: PumpWithKellyDisconnectedPtr - procedure (ActionBool), pointer :: PumpWithTopdriveDisconnectedPtr - procedure (ActionBool), pointer :: Pump1PopOffValveBlownPtr - procedure (ActionBool), pointer :: Pump1FailurePtr - procedure (ActionBool), pointer :: Pump2PopOffValveBlownPtr - procedure (ActionBool), pointer :: Pump2FailurePtr - procedure (ActionBool), pointer :: Pump3PopOffValveBlownPtr - procedure (ActionBool), pointer :: Pump3FailurePtr - procedure (ActionBool), pointer :: DrawworksGearsAbusePtr - procedure (ActionBool), pointer :: RotaryGearsAbusePtr - procedure (ActionBool), pointer :: HoistLineBreakPtr - procedure (ActionBool), pointer :: PartedDrillStringPtr - procedure (ActionBool), pointer :: ActiveTankOverflowPtr - procedure (ActionBool), pointer :: ActiveTankUnderVolumePtr - procedure (ActionBool), pointer :: TripTankOverflowPtr - procedure (ActionBool), pointer :: DrillPipeTwistOffPtr - procedure (ActionBool), pointer :: DrillPipePartedPtr - procedure (ActionBool), pointer :: TripWithSlipsSetPtr - procedure (ActionBool), pointer :: BlowoutPtr - procedure (ActionBool), pointer :: UndergroundBlowoutPtr - procedure (ActionBool), pointer :: MaximumWellDepthExceededPtr - procedure (ActionBool), pointer :: CrownCollisionPtr - procedure (ActionBool), pointer :: FloorCollisionPtr - procedure (ActionBool), pointer :: TopdriveRotaryTableConfilictPtr - - contains - subroutine SubscribePumpWithKellyDisconnected(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePumpWithKellyDisconnected - !DEC$ ATTRIBUTES ALIAS: 'SubscribePumpWithKellyDisconnected' :: SubscribePumpWithKellyDisconnected - implicit none - procedure (ActionBool) :: a - PumpWithKellyDisconnectedPtr => a - end subroutine - - subroutine SubscribePumpWithTopdriveDisconnected(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePumpWithTopdriveDisconnected - !DEC$ ATTRIBUTES ALIAS: 'SubscribePumpWithTopdriveDisconnected' :: SubscribePumpWithTopdriveDisconnected - implicit none - procedure (ActionBool) :: a - PumpWithTopdriveDisconnectedPtr => a - end subroutine - - subroutine SubscribePump1PopOffValveBlown(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump1PopOffValveBlown - !DEC$ ATTRIBUTES ALIAS: 'SubscribePump1PopOffValveBlown' :: SubscribePump1PopOffValveBlown - implicit none - procedure (ActionBool) :: a - Pump1PopOffValveBlownPtr => a - end subroutine - - subroutine SubscribePump1Failure(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump1Failure - !DEC$ ATTRIBUTES ALIAS: 'SubscribePump1Failure' :: SubscribePump1Failure - implicit none - procedure (ActionBool) :: a - Pump1FailurePtr => a - end subroutine - - subroutine SubscribePump2PopOffValveBlown(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump2PopOffValveBlown - !DEC$ ATTRIBUTES ALIAS: 'SubscribePump2PopOffValveBlown' :: SubscribePump2PopOffValveBlown - implicit none - procedure (ActionBool) :: a - Pump2PopOffValveBlownPtr => a - end subroutine - - subroutine SubscribePump2Failure(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump2Failure - !DEC$ ATTRIBUTES ALIAS: 'SubscribePump2Failure' :: SubscribePump2Failure - implicit none - procedure (ActionBool) :: a - Pump2FailurePtr => a - end subroutine - - subroutine SubscribePump3PopOffValveBlown(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump3PopOffValveBlown - !DEC$ ATTRIBUTES ALIAS: 'SubscribePump3PopOffValveBlown' :: SubscribePump3PopOffValveBlown - implicit none - procedure (ActionBool) :: a - Pump3PopOffValveBlownPtr => a - end subroutine - - subroutine SubscribePump3Failure(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePump3Failure - !DEC$ ATTRIBUTES ALIAS: 'SubscribePump3Failure' :: SubscribePump3Failure - implicit none - procedure (ActionBool) :: a - Pump3FailurePtr => a - end subroutine - - subroutine SubscribeDrawworksGearsAbuse(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeDrawworksGearsAbuse - !DEC$ ATTRIBUTES ALIAS: 'SubscribeDrawworksGearsAbuse' :: SubscribeDrawworksGearsAbuse - implicit none - procedure (ActionBool) :: a - DrawworksGearsAbusePtr => a - end subroutine - - subroutine SubscribeRotaryGearsAbuse(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeRotaryGearsAbuse - !DEC$ ATTRIBUTES ALIAS: 'SubscribeRotaryGearsAbuse' :: SubscribeRotaryGearsAbuse - implicit none - procedure (ActionBool) :: a - RotaryGearsAbusePtr => a - end subroutine - - subroutine SubscribeHoistLineBreak(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeHoistLineBreak - !DEC$ ATTRIBUTES ALIAS: 'SubscribeHoistLineBreak' :: SubscribeHoistLineBreak - implicit none - procedure (ActionBool) :: a - HoistLineBreakPtr => a - end subroutine - - subroutine SubscribePartedDrillString(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribePartedDrillString - !DEC$ ATTRIBUTES ALIAS: 'SubscribePartedDrillString' :: SubscribePartedDrillString - implicit none - procedure (ActionBool) :: a - PartedDrillStringPtr => a - end subroutine - - subroutine SubscribeActiveTankOverflow(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeActiveTankOverflow - !DEC$ ATTRIBUTES ALIAS: 'SubscribeActiveTankOverflow' :: SubscribeActiveTankOverflow - implicit none - procedure (ActionBool) :: a - ActiveTankOverflowPtr => a - end subroutine - - subroutine SubscribeActiveTankUnderVolume(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeActiveTankUnderVolume - !DEC$ ATTRIBUTES ALIAS: 'SubscribeActiveTankUnderVolume' :: SubscribeActiveTankUnderVolume - implicit none - procedure (ActionBool) :: a - ActiveTankUnderVolumePtr => a - end subroutine - - subroutine SubscribeTripTankOverflow(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeTripTankOverflow - !DEC$ ATTRIBUTES ALIAS: 'SubscribeTripTankOverflow' :: SubscribeTripTankOverflow - implicit none - procedure (ActionBool) :: a - TripTankOverflowPtr => a - end subroutine - - subroutine SubscribeDrillPipeTwistOff(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeDrillPipeTwistOff - !DEC$ ATTRIBUTES ALIAS: 'SubscribeDrillPipeTwistOff' :: SubscribeDrillPipeTwistOff - implicit none - procedure (ActionBool) :: a - DrillPipeTwistOffPtr => a - end subroutine - - subroutine SubscribeDrillPipeParted(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeDrillPipeParted - !DEC$ ATTRIBUTES ALIAS: 'SubscribeDrillPipeParted' :: SubscribeDrillPipeParted - implicit none - procedure (ActionBool) :: a - DrillPipePartedPtr => a - end subroutine - - subroutine SubscribeTripWithSlipsSet(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeTripWithSlipsSet - !DEC$ ATTRIBUTES ALIAS: 'SubscribeTripWithSlipsSet' :: SubscribeTripWithSlipsSet - implicit none - procedure (ActionBool) :: a - TripWithSlipsSetPtr => a - end subroutine - - subroutine SubscribeBlowout(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeBlowout - !DEC$ ATTRIBUTES ALIAS: 'SubscribeBlowout' :: SubscribeBlowout - implicit none - procedure (ActionBool) :: a - BlowoutPtr => a - end subroutine - - subroutine SubscribeUndergroundBlowout(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeUndergroundBlowout - !DEC$ ATTRIBUTES ALIAS: 'SubscribeUndergroundBlowout' :: SubscribeUndergroundBlowout - implicit none - procedure (ActionBool) :: a - UndergroundBlowoutPtr => a - end subroutine - - subroutine SubscribeMaximumWellDepthExceeded(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeMaximumWellDepthExceeded - !DEC$ ATTRIBUTES ALIAS: 'SubscribeMaximumWellDepthExceeded' :: SubscribeMaximumWellDepthExceeded - implicit none - procedure (ActionBool) :: a - MaximumWellDepthExceededPtr => a - end subroutine - - subroutine SubscribeCrownCollision(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeCrownCollision - !DEC$ ATTRIBUTES ALIAS: 'SubscribeCrownCollision' :: SubscribeCrownCollision - implicit none - procedure (ActionBool) :: a - CrownCollisionPtr => a - end subroutine - - subroutine SubscribeFloorCollision(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeFloorCollision - !DEC$ ATTRIBUTES ALIAS: 'SubscribeFloorCollision' :: SubscribeFloorCollision - implicit none - procedure (ActionBool) :: a - FloorCollisionPtr => a - end subroutine - - subroutine SubscribeTopdriveRotaryTableConfilict(a) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeTopdriveRotaryTableConfilict - !DEC$ ATTRIBUTES ALIAS: 'SubscribeTopdriveRotaryTableConfilict' :: SubscribeTopdriveRotaryTableConfilict - implicit none - procedure (ActionBool) :: a - TopdriveRotaryTableConfilictPtr => a - end subroutine - -end module CWarningsActions \ No newline at end of file diff --git a/CSharp/Warnings/CWarningsVariables.f90 b/CSharp/Warnings/CWarningsVariables.f90 index 1690009..6c27656 100644 --- a/CSharp/Warnings/CWarningsVariables.f90 +++ b/CSharp/Warnings/CWarningsVariables.f90 @@ -1,5 +1,4 @@ module CWarningsVariables - use CWarningsActions implicit none public @@ -29,1005 +28,6 @@ module CWarningsVariables logical :: FloorCollision logical :: TopdriveRotaryTableConfilict end type WarmingsType - type(WarmingsType)::Warmings - contains - - subroutine Activate_PumpWithKellyDisconnected() - implicit none - if(Warmings%PumpWithKellyDisconnected) return - Warmings%PumpWithKellyDisconnected = .true. - call RunPumpWithKellyDisconnected() - end subroutine - - subroutine Activate_PumpWithTopdriveDisconnected() - implicit none - if(Warmings%PumpWithTopdriveDisconnected) return - Warmings%PumpWithTopdriveDisconnected = .true. - call RunPumpWithTopdriveDisconnected() - end subroutine - - subroutine Activate_Pump1PopOffValveBlown() - implicit none - if(Warmings%Pump1PopOffValveBlown) return - Warmings%Pump1PopOffValveBlown = .true. - call RunPump1PopOffValveBlown() - end subroutine - - subroutine Activate_Pump1Failure() - implicit none - if(Warmings%Pump1Failure) return - Warmings%Pump1Failure = .true. - call RunPump1Failure() - end subroutine - - subroutine Activate_Pump2PopOffValveBlown() - implicit none - if(Warmings%Pump2PopOffValveBlown) return - Warmings%Pump2PopOffValveBlown = .true. - call RunPump2PopOffValveBlown() - end subroutine - - subroutine Activate_Pump2Failure() - implicit none - if(Warmings%Pump2Failure) return - Warmings%Pump2Failure = .true. - call RunPump2Failure() - end subroutine - - subroutine Activate_Pump3PopOffValveBlown() - implicit none - if(Warmings%Pump3PopOffValveBlown) return - Warmings%Pump3PopOffValveBlown = .true. - call RunPump3PopOffValveBlown() - end subroutine - - subroutine Activate_Pump3Failure() - implicit none - if(Warmings%Pump3Failure) return - Warmings%Pump3Failure = .true. - call RunPump3Failure() - end subroutine - - subroutine Activate_DrawworksGearsAbuse() - implicit none - if(Warmings%DrawworksGearsAbuse) return - Warmings%DrawworksGearsAbuse = .true. - call RunDrawworksGearsAbuse() - end subroutine - - subroutine Activate_RotaryGearsAbuse() - implicit none - if(Warmings%RotaryGearsAbuse) return - Warmings%RotaryGearsAbuse = .true. - call RunRotaryGearsAbuse() - end subroutine - - subroutine Activate_HoistLineBreak() - implicit none - if(Warmings%HoistLineBreak) return - Warmings%HoistLineBreak = .true. - call RunHoistLineBreak() - end subroutine - - subroutine Activate_PartedDrillString() - implicit none - if(Warmings%PartedDrillString) return - Warmings%PartedDrillString = .true. - call RunPartedDrillString() - end subroutine - - subroutine Activate_ActiveTankOverflow() - implicit none - if(Warmings%ActiveTankOverflow) return - Warmings%ActiveTankOverflow = .true. - call RunActiveTankOverflow() - end subroutine - - subroutine Activate_ActiveTankUnderVolume() - implicit none - if(Warmings%ActiveTankUnderVolume) return - Warmings%ActiveTankUnderVolume = .true. - call RunActiveTankUnderVolume() - end subroutine - - subroutine Activate_TripTankOverflow() - implicit none - if(Warmings%TripTankOverflow) return - Warmings%TripTankOverflow = .true. - call RunTripTankOverflow() - end subroutine - - subroutine Activate_DrillPipeTwistOff() - implicit none - if(Warmings%DrillPipeTwistOff) return - Warmings%DrillPipeTwistOff = .true. - call RunDrillPipeTwistOff() - end subroutine - - subroutine Activate_DrillPipeParted() - implicit none - if(Warmings%DrillPipeParted) return - Warmings%DrillPipeParted = .true. - call RunDrillPipeParted() - end subroutine - - subroutine Activate_TripWithSlipsSet() - implicit none - if(Warmings%TripWithSlipsSet) return - Warmings%TripWithSlipsSet = .true. - call RunTripWithSlipsSet() - end subroutine - - subroutine Activate_Blowout() - implicit none - if(Warmings%Blowout) return - Warmings%Blowout = .true. - call RunBlowout() - end subroutine - - subroutine Activate_UndergroundBlowout() - implicit none - if(Warmings%UndergroundBlowout) return - Warmings%UndergroundBlowout = .true. - call RunUndergroundBlowout() - end subroutine - - subroutine Activate_MaximumWellDepthExceeded() - implicit none - if(Warmings%MaximumWellDepthExceeded) return - Warmings%MaximumWellDepthExceeded = .true. - call RunMaximumWellDepthExceeded() - end subroutine - - subroutine Activate_CrownCollision() - implicit none - if(Warmings%CrownCollision) return - Warmings%CrownCollision = .true. - call RunCrownCollision() - end subroutine - - subroutine Activate_FloorCollision() - implicit none - if(Warmings%FloorCollision) return - Warmings%FloorCollision = .true. - call RunFloorCollision() - end subroutine - - subroutine Activate_TopdriveRotaryTableConfilict() - implicit none - if(Warmings%TopdriveRotaryTableConfilict) return - Warmings%TopdriveRotaryTableConfilict = .true. - call RunTopdriveRotaryTableConfilict() - end subroutine - - - - - - - - - - - - - - - - - - - - - - - - - - - subroutine Deactivate_PumpWithKellyDisconnected() - implicit none - if(.not.Warmings%PumpWithKellyDisconnected) return - Warmings%PumpWithKellyDisconnected = .false. - call RunPumpWithKellyDisconnected() - end subroutine - - subroutine Deactivate_PumpWithTopdriveDisconnected() - implicit none - if(.not.Warmings%PumpWithTopdriveDisconnected) return - Warmings%PumpWithTopdriveDisconnected = .false. - call RunPumpWithTopdriveDisconnected() - end subroutine - - subroutine Deactivate_Pump1PopOffValveBlown() - use CManifolds - implicit none - if(.not.Warmings%Pump1PopOffValveBlown) return - Warmings%Pump1PopOffValveBlown = .false. - call ChangeValve(65, .false.) - call RunPump1PopOffValveBlown() - end subroutine - - subroutine Deactivate_Pump1Failure() - use CManifolds - implicit none - if(.not.Warmings%Pump1Failure) return - Warmings%Pump1Failure = .false. - call RunPump1Failure() - end subroutine - - subroutine Deactivate_Pump2PopOffValveBlown() - use CManifolds - implicit none - if(.not.Warmings%Pump2PopOffValveBlown) return - Warmings%Pump2PopOffValveBlown = .false. - call ChangeValve(66, .false.) - call RunPump2PopOffValveBlown() - end subroutine - - subroutine Deactivate_Pump2Failure() - use CManifolds - implicit none - if(.not.Warmings%Pump2Failure) return - Warmings%Pump2Failure = .false. - call RunPump2Failure() - end subroutine - - subroutine Deactivate_Pump3PopOffValveBlown() - use CManifolds - implicit none - if(.not.Warmings%Pump3PopOffValveBlown) return - Warmings%Pump3PopOffValveBlown = .false. - call RunPump3PopOffValveBlown() - end subroutine - - subroutine Deactivate_Pump3Failure() - use CManifolds - implicit none - if(.not.Warmings%Pump3Failure) return - Warmings%Pump3Failure = .false. - call RunPump3Failure() - end subroutine - - subroutine Deactivate_DrawworksGearsAbuse() - implicit none - if(.not.Warmings%DrawworksGearsAbuse) return - Warmings%DrawworksGearsAbuse = .false. - call RunDrawworksGearsAbuse() - end subroutine - - subroutine Deactivate_RotaryGearsAbuse() - implicit none - if(.not.Warmings%RotaryGearsAbuse) return - Warmings%RotaryGearsAbuse = .false. - call RunRotaryGearsAbuse() - end subroutine - - subroutine Deactivate_HoistLineBreak() - implicit none - if(.not.Warmings%HoistLineBreak) return - Warmings%HoistLineBreak = .false. - call RunHoistLineBreak() - end subroutine - - subroutine Deactivate_PartedDrillString() - implicit none - if(.not.Warmings%PartedDrillString) return - Warmings%PartedDrillString = .false. - call RunPartedDrillString() - end subroutine - - subroutine Deactivate_ActiveTankOverflow() - implicit none - if(.not.Warmings%ActiveTankOverflow) return - Warmings%ActiveTankOverflow = .false. - call RunActiveTankOverflow() - end subroutine - - subroutine Deactivate_ActiveTankUnderVolume() - implicit none - if(.not.Warmings%ActiveTankUnderVolume) return - Warmings%ActiveTankUnderVolume = .false. - call RunActiveTankUnderVolume() - end subroutine - - subroutine Deactivate_TripTankOverflow() - implicit none - if(.not.Warmings%TripTankOverflow) return - Warmings%TripTankOverflow = .false. - call RunTripTankOverflow() - end subroutine - - subroutine Deactivate_DrillPipeTwistOff() - implicit none - if(.not.Warmings%DrillPipeTwistOff) return - Warmings%DrillPipeTwistOff = .false. - call RunDrillPipeTwistOff() - end subroutine - - subroutine Deactivate_DrillPipeParted() - implicit none - if(.not.Warmings%DrillPipeParted) return - Warmings%DrillPipeParted = .false. - call RunDrillPipeParted() - end subroutine - - subroutine Deactivate_TripWithSlipsSet() - implicit none - if(.not.Warmings%TripWithSlipsSet) return - Warmings%TripWithSlipsSet = .false. - call RunTripWithSlipsSet() - end subroutine - - subroutine Deactivate_Blowout() - implicit none - if(.not.Warmings%Blowout) return - Warmings%Blowout = .false. - call RunBlowout() - end subroutine - - subroutine Deactivate_UndergroundBlowout() - implicit none - if(.not.Warmings%UndergroundBlowout) return - Warmings%UndergroundBlowout = .false. - call RunUndergroundBlowout() - end subroutine - - subroutine Deactivate_MaximumWellDepthExceeded() - implicit none - if(.not.Warmings%MaximumWellDepthExceeded) return - Warmings%MaximumWellDepthExceeded = .false. - call RunMaximumWellDepthExceeded() - end subroutine - - subroutine Deactivate_CrownCollision() - implicit none - if(.not.Warmings%CrownCollision) return - Warmings%CrownCollision = .false. - call RunCrownCollision() - end subroutine - - subroutine Deactivate_FloorCollision() - implicit none - if(.not.Warmings%FloorCollision) return - Warmings%FloorCollision = .false. - call RunFloorCollision() - end subroutine - - subroutine Deactivate_TopdriveRotaryTableConfilict() - implicit none - if(.not.Warmings%TopdriveRotaryTableConfilict) return - Warmings%TopdriveRotaryTableConfilict = .false. - call RunTopdriveRotaryTableConfilict() - end subroutine - - - - - - - - - - - - - - - - - - - - - - - - - - subroutine RunPumpWithKellyDisconnected() - implicit none - if(associated(PumpWithKellyDisconnectedPtr)) then - call PumpWithKellyDisconnectedPtr(Warmings%PumpWithKellyDisconnected) - end if - end subroutine - - subroutine RunPumpWithTopdriveDisconnected() - implicit none - if(associated(PumpWithTopdriveDisconnectedPtr)) then - call PumpWithTopdriveDisconnectedPtr(Warmings%PumpWithTopdriveDisconnected) - end if - end subroutine - - subroutine RunPump1PopOffValveBlown() - implicit none - if(associated(Pump1PopOffValveBlownPtr)) then - call Pump1PopOffValveBlownPtr(Warmings%Pump1PopOffValveBlown) - end if - end subroutine - - subroutine RunPump1Failure() - implicit none - if(associated(Pump1FailurePtr)) then - call Pump1FailurePtr(Warmings%Pump1Failure) - end if - end subroutine - - subroutine RunPump2PopOffValveBlown() - implicit none - if(associated(Pump2PopOffValveBlownPtr)) then - call Pump2PopOffValveBlownPtr(Warmings%Pump2PopOffValveBlown) - end if - end subroutine - - subroutine RunPump2Failure() - implicit none - if(associated(Pump2FailurePtr)) then - call Pump2FailurePtr(Warmings%Pump2Failure) - end if - end subroutine - - subroutine RunPump3PopOffValveBlown() - implicit none - if(associated(Pump3PopOffValveBlownPtr)) then - call Pump3PopOffValveBlownPtr(Warmings%Pump3PopOffValveBlown) - end if - end subroutine - - subroutine RunPump3Failure() - implicit none - if(associated(Pump3FailurePtr)) then - call Pump3FailurePtr(Warmings%Pump3Failure) - end if - end subroutine - - subroutine RunDrawworksGearsAbuse() - implicit none - if(associated(DrawworksGearsAbusePtr)) then - call DrawworksGearsAbusePtr(Warmings%DrawworksGearsAbuse) - end if - end subroutine - - subroutine RunRotaryGearsAbuse() - implicit none - if(associated(RotaryGearsAbusePtr)) then - call RotaryGearsAbusePtr(Warmings%RotaryGearsAbuse) - end if - end subroutine - - subroutine RunHoistLineBreak() - implicit none - if(associated(HoistLineBreakPtr)) then - call HoistLineBreakPtr(Warmings%HoistLineBreak) - end if - end subroutine - - subroutine RunPartedDrillString() - implicit none - if(associated(PartedDrillStringPtr)) then - call PartedDrillStringPtr(Warmings%PartedDrillString) - end if - end subroutine - - subroutine RunActiveTankOverflow() - implicit none - if(associated(ActiveTankOverflowPtr)) then - call ActiveTankOverflowPtr(Warmings%ActiveTankOverflow) - end if - end subroutine - - subroutine RunActiveTankUnderVolume() - implicit none - if(associated(ActiveTankUnderVolumePtr)) then - call ActiveTankUnderVolumePtr(Warmings%ActiveTankUnderVolume) - end if - end subroutine - - subroutine RunTripTankOverflow() - implicit none - if(associated(TripTankOverflowPtr)) then - call TripTankOverflowPtr(Warmings%TripTankOverflow) - end if - end subroutine - - subroutine RunDrillPipeTwistOff() - implicit none - if(associated(DrillPipeTwistOffPtr)) then - call DrillPipeTwistOffPtr(Warmings%DrillPipeTwistOff) - end if - end subroutine - - subroutine RunDrillPipeParted() - implicit none - if(associated(DrillPipePartedPtr)) then - call DrillPipePartedPtr(Warmings%DrillPipeParted) - end if - end subroutine - - subroutine RunTripWithSlipsSet() - implicit none - if(associated(TripWithSlipsSetPtr)) then - call TripWithSlipsSetPtr(Warmings%TripWithSlipsSet) - end if - end subroutine - - subroutine RunBlowout() - implicit none - if(associated(BlowoutPtr)) then - call BlowoutPtr(Warmings%Blowout) - end if - end subroutine - - subroutine RunUndergroundBlowout() - implicit none - if(associated(UndergroundBlowoutPtr)) then - call UndergroundBlowoutPtr(Warmings%UndergroundBlowout) - end if - end subroutine - - subroutine RunMaximumWellDepthExceeded() - implicit none - if(associated(MaximumWellDepthExceededPtr)) then - call MaximumWellDepthExceededPtr(Warmings%MaximumWellDepthExceeded) - end if - end subroutine - - subroutine RunCrownCollision() - implicit none - if(associated(CrownCollisionPtr)) then - call CrownCollisionPtr(Warmings%CrownCollision) - end if - end subroutine - - subroutine RunFloorCollision() - implicit none - if(associated(FloorCollisionPtr)) then - call FloorCollisionPtr(Warmings%FloorCollision) - end if - end subroutine - - subroutine RunTopdriveRotaryTableConfilict() - implicit none - if(associated(TopdriveRotaryTableConfilictPtr)) then - call TopdriveRotaryTableConfilictPtr(Warmings%TopdriveRotaryTableConfilict) - end if - end subroutine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - subroutine Activate_PumpWithKellyDisconnected_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_PumpWithKellyDisconnected_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_PumpWithKellyDisconnected_WN' :: Activate_PumpWithKellyDisconnected_WN - implicit none - call Activate_PumpWithKellyDisconnected() - end subroutine - - subroutine Activate_PumpWithTopdriveDisconnected_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_PumpWithTopdriveDisconnected_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_PumpWithTopdriveDisconnected_WN' :: Activate_PumpWithTopdriveDisconnected_WN - implicit none - call Activate_PumpWithTopdriveDisconnected() - end subroutine - - subroutine Activate_Pump1PopOffValveBlown_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_Pump1PopOffValveBlown_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_Pump1PopOffValveBlown_WN' :: Activate_Pump1PopOffValveBlown_WN - implicit none - call Activate_Pump1PopOffValveBlown() - end subroutine - - subroutine Activate_Pump1Failure_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_Pump1Failure_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_Pump1Failure_WN' :: Activate_Pump1Failure_WN - implicit none - call Activate_Pump1Failure() - end subroutine - - subroutine Activate_Pump2PopOffValveBlown_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_Pump2PopOffValveBlown_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_Pump2PopOffValveBlown_WN' :: Activate_Pump2PopOffValveBlown_WN - implicit none - call Activate_Pump2PopOffValveBlown() - end subroutine - - subroutine Activate_Pump2Failure_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_Pump2Failure_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_Pump2Failure_WN' :: Activate_Pump2Failure_WN - implicit none - call Activate_Pump2Failure() - end subroutine - - subroutine Activate_Pump3PopOffValveBlown_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_Pump3PopOffValveBlown_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_Pump3PopOffValveBlown_WN' :: Activate_Pump3PopOffValveBlown_WN - implicit none - call Activate_Pump3PopOffValveBlown() - end subroutine - - subroutine Activate_Pump3Failure_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_Pump3Failure_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_Pump3Failure_WN' :: Activate_Pump3Failure_WN - implicit none - call Activate_Pump3Failure() - end subroutine - - subroutine Activate_DrawworksGearsAbuse_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_DrawworksGearsAbuse_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_DrawworksGearsAbuse_WN' :: Activate_DrawworksGearsAbuse_WN - implicit none - call Activate_DrawworksGearsAbuse() - end subroutine - - subroutine Activate_RotaryGearsAbuse_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_RotaryGearsAbuse_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_RotaryGearsAbuse_WN' :: Activate_RotaryGearsAbuse_WN - implicit none - call Activate_RotaryGearsAbuse() - end subroutine - - subroutine Activate_HoistLineBreak_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_HoistLineBreak_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_HoistLineBreak_WN' :: Activate_HoistLineBreak_WN - implicit none - call Activate_HoistLineBreak() - end subroutine - - subroutine Activate_PartedDrillString_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_PartedDrillString_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_PartedDrillString_WN' :: Activate_PartedDrillString_WN - implicit none - call Activate_PartedDrillString() - end subroutine - - subroutine Activate_ActiveTankOverflow_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_ActiveTankOverflow_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_ActiveTankOverflow_WN' :: Activate_ActiveTankOverflow_WN - implicit none - call Activate_ActiveTankOverflow() - end subroutine - - subroutine Activate_ActiveTankUnderVolume_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_ActiveTankUnderVolume_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_ActiveTankUnderVolume_WN' :: Activate_ActiveTankUnderVolume_WN - implicit none - call Activate_ActiveTankUnderVolume() - end subroutine - - subroutine Activate_TripTankOverflow_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_TripTankOverflow_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_TripTankOverflow_WN' :: Activate_TripTankOverflow_WN - implicit none - call Activate_TripTankOverflow() - end subroutine - - subroutine Activate_DrillPipeTwistOff_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_DrillPipeTwistOff_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_DrillPipeTwistOff_WN' :: Activate_DrillPipeTwistOff_WN - implicit none - call Activate_DrillPipeTwistOff() - end subroutine - - subroutine Activate_DrillPipeParted_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_DrillPipeParted_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_DrillPipeParted_WN' :: Activate_DrillPipeParted_WN - implicit none - call Activate_DrillPipeParted() - end subroutine - - subroutine Activate_TripWithSlipsSet_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_TripWithSlipsSet_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_TripWithSlipsSet_WN' :: Activate_TripWithSlipsSet_WN - implicit none - call Activate_TripWithSlipsSet() - end subroutine - - subroutine Activate_Blowout_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_Blowout_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_Blowout_WN' :: Activate_Blowout_WN - implicit none - call Activate_Blowout() - end subroutine - - subroutine Activate_UndergroundBlowout_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_UndergroundBlowout_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_UndergroundBlowout_WN' :: Activate_UndergroundBlowout_WN - implicit none - call Activate_UndergroundBlowout() - end subroutine - - subroutine Activate_MaximumWellDepthExceeded_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_MaximumWellDepthExceeded_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_MaximumWellDepthExceeded_WN' :: Activate_MaximumWellDepthExceeded_WN - implicit none - call Activate_MaximumWellDepthExceeded() - end subroutine - - subroutine Activate_CrownCollision_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_CrownCollision_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_CrownCollision_WN' :: Activate_CrownCollision_WN - implicit none - call Activate_CrownCollision() - end subroutine - - subroutine Activate_FloorCollision_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_FloorCollision_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_FloorCollision_WN' :: Activate_FloorCollision_WN - implicit none - call Activate_FloorCollision() - end subroutine - - subroutine Activate_TopdriveRotaryTableConfilict_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Activate_TopdriveRotaryTableConfilict_WN - !DEC$ ATTRIBUTES ALIAS: 'Activate_TopdriveRotaryTableConfilict_WN' :: Activate_TopdriveRotaryTableConfilict_WN - implicit none - call Activate_TopdriveRotaryTableConfilict() - end subroutine - - - - - - - - - - - - - - - - - - - - - - - - - - - subroutine Deactivate_PumpWithKellyDisconnected_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_PumpWithKellyDisconnected_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_PumpWithKellyDisconnected_WN' :: Deactivate_PumpWithKellyDisconnected_WN - implicit none - call Deactivate_PumpWithKellyDisconnected() - end subroutine - - subroutine Deactivate_PumpWithTopdriveDisconnected_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_PumpWithTopdriveDisconnected_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_PumpWithTopdriveDisconnected_WN' :: Deactivate_PumpWithTopdriveDisconnected_WN - implicit none - call Deactivate_PumpWithTopdriveDisconnected() - end subroutine - - subroutine Deactivate_Pump1PopOffValveBlown_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_Pump1PopOffValveBlown_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_Pump1PopOffValveBlown_WN' :: Deactivate_Pump1PopOffValveBlown_WN - implicit none - call Deactivate_Pump1PopOffValveBlown() - end subroutine - - subroutine Deactivate_Pump1Failure_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_Pump1Failure_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_Pump1Failure_WN' :: Deactivate_Pump1Failure_WN - implicit none - call Deactivate_Pump1Failure() - end subroutine - - subroutine Deactivate_Pump2PopOffValveBlown_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_Pump2PopOffValveBlown_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_Pump2PopOffValveBlown_WN' :: Deactivate_Pump2PopOffValveBlown_WN - implicit none - call Deactivate_Pump2PopOffValveBlown() - end subroutine - - subroutine Deactivate_Pump2Failure_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_Pump2Failure_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_Pump2Failure_WN' :: Deactivate_Pump2Failure_WN - implicit none - call Deactivate_Pump2Failure() - end subroutine - - subroutine Deactivate_Pump3PopOffValveBlown_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_Pump3PopOffValveBlown_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_Pump3PopOffValveBlown_WN' :: Deactivate_Pump3PopOffValveBlown_WN - implicit none - call Deactivate_Pump3PopOffValveBlown() - end subroutine - - subroutine Deactivate_Pump3Failure_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_Pump3Failure_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_Pump3Failure_WN' :: Deactivate_Pump3Failure_WN - implicit none - call Deactivate_Pump3Failure() - end subroutine - - subroutine Deactivate_DrawworksGearsAbuse_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_DrawworksGearsAbuse_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_DrawworksGearsAbuse_WN' :: Deactivate_DrawworksGearsAbuse_WN - implicit none - call Deactivate_DrawworksGearsAbuse() - end subroutine - - subroutine Deactivate_RotaryGearsAbuse_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_RotaryGearsAbuse_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_RotaryGearsAbuse_WN' :: Deactivate_RotaryGearsAbuse_WN - implicit none - call Deactivate_RotaryGearsAbuse() - end subroutine - - subroutine Deactivate_HoistLineBreak_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_HoistLineBreak_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_HoistLineBreak_WN' :: Deactivate_HoistLineBreak_WN - implicit none - call Deactivate_HoistLineBreak() - end subroutine - - subroutine Deactivate_PartedDrillString_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_PartedDrillString_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_PartedDrillString_WN' :: Deactivate_PartedDrillString_WN - implicit none - call Deactivate_PartedDrillString() - end subroutine - - subroutine Deactivate_ActiveTankOverflow_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_ActiveTankOverflow_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_ActiveTankOverflow_WN' :: Deactivate_ActiveTankOverflow_WN - implicit none - call Deactivate_ActiveTankOverflow() - end subroutine - - subroutine Deactivate_ActiveTankUnderVolume_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_ActiveTankUnderVolume_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_ActiveTankUnderVolume_WN' :: Deactivate_ActiveTankUnderVolume_WN - implicit none - call Deactivate_ActiveTankUnderVolume() - end subroutine - - subroutine Deactivate_TripTankOverflow_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_TripTankOverflow_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_TripTankOverflow_WN' :: Deactivate_TripTankOverflow_WN - implicit none - call Deactivate_TripTankOverflow() - end subroutine - - subroutine Deactivate_DrillPipeTwistOff_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_DrillPipeTwistOff_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_DrillPipeTwistOff_WN' :: Deactivate_DrillPipeTwistOff_WN - implicit none - call Deactivate_DrillPipeTwistOff() - end subroutine - - subroutine Deactivate_DrillPipeParted_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_DrillPipeParted_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_DrillPipeParted_WN' :: Deactivate_DrillPipeParted_WN - implicit none - call Deactivate_DrillPipeParted() - end subroutine - - subroutine Deactivate_TripWithSlipsSet_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_TripWithSlipsSet_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_TripWithSlipsSet_WN' :: Deactivate_TripWithSlipsSet_WN - implicit none - call Deactivate_TripWithSlipsSet() - end subroutine - - subroutine Deactivate_Blowout_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_Blowout_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_Blowout_WN' :: Deactivate_Blowout_WN - implicit none - call Deactivate_Blowout() - end subroutine - - subroutine Deactivate_UndergroundBlowout_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_UndergroundBlowout_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_UndergroundBlowout_WN' :: Deactivate_UndergroundBlowout_WN - implicit none - call Deactivate_UndergroundBlowout() - end subroutine - - subroutine Deactivate_MaximumWellDepthExceeded_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_MaximumWellDepthExceeded_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_MaximumWellDepthExceeded_WN' :: Deactivate_MaximumWellDepthExceeded_WN - implicit none - call Deactivate_MaximumWellDepthExceeded() - end subroutine - - subroutine Deactivate_CrownCollision_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_CrownCollision_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_CrownCollision_WN' :: Deactivate_CrownCollision_WN - implicit none - call Deactivate_CrownCollision() - end subroutine - - subroutine Deactivate_FloorCollision_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_FloorCollision_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_FloorCollision_WN' :: Deactivate_FloorCollision_WN - implicit none - call Deactivate_FloorCollision() - end subroutine - - subroutine Deactivate_TopdriveRotaryTableConfilict_WN() - !DEC$ ATTRIBUTES DLLEXPORT :: Deactivate_TopdriveRotaryTableConfilict_WN - !DEC$ ATTRIBUTES ALIAS: 'Deactivate_TopdriveRotaryTableConfilict_WN' :: Deactivate_TopdriveRotaryTableConfilict_WN - implicit none - call Deactivate_TopdriveRotaryTableConfilict() - end subroutine - - - - - + contains end module CWarningsVariables \ No newline at end of file diff --git a/CSounds.f90 b/CSounds.f90 deleted file mode 100644 index f0ed6be..0000000 --- a/CSounds.f90 +++ /dev/null @@ -1,683 +0,0 @@ -module CSounds - use CIActionReference - implicit none - public - - ! Input vars - - ! Output vars - integer :: Sounds%MP1s - integer :: Sounds%MP2s - integer :: Sounds%MP3s - integer :: Sounds%RTs - integer :: Sounds%DwFws - integer :: Sounds%DwRevs - integer :: Sounds%DwBrakes - integer :: Sounds%ChokePumps - integer :: Sounds%GasThroughChokes - integer :: Sounds%KoomeyAirPumps - integer :: Sounds%KoomeyElectricPumps - logical :: Sounds%RtGearCrashs - logical :: Sounds%DwGearCrashs - logical :: Sounds%FloorCollisions - logical :: Sounds%CrownCollisions - logical :: Sounds%DwClutchs - logical :: Sounds%Blowers - logical :: Sounds%BlowerMp1s - logical :: Sounds%BlowerMp2s - logical :: Sounds%BlowerMp3s - logical :: Sounds%BlowerRts - logical :: Sounds%BlowerDws - logical :: Sounds%BlowerStarts - logical :: Sounds%BlowerShutdowns - logical :: Sounds%ElectricPumps - - - procedure (ActionInteger), pointer :: SoundMP1Ptr - procedure (ActionInteger), pointer :: SoundMP2Ptr - procedure (ActionInteger), pointer :: SoundMP3Ptr - procedure (ActionInteger), pointer :: SoundRTPtr - procedure (ActionInteger), pointer :: SoundDwFwPtr - procedure (ActionInteger), pointer :: SoundDwRevPtr - procedure (ActionInteger), pointer :: SoundDwBrakePtr - procedure (ActionInteger), pointer :: SoundChokePumpPtr - procedure (ActionInteger), pointer :: SoundGasThroughChokePtr - procedure (ActionInteger), pointer :: SoundKoomeyAirPumpPtr - procedure (ActionInteger), pointer :: SoundKoomeyElectricPumpPtr - procedure (ActionBool), pointer :: SoundRtGearCrashPtr - procedure (ActionBool), pointer :: SoundDwGearCrashPtr - procedure (ActionBool), pointer :: SoundFloorCollisionPtr - procedure (ActionBool), pointer :: SoundCrownCollisionPtr - procedure (ActionBool), pointer :: SoundDwClutchPtr - procedure (ActionBool), pointer :: SoundBlowerPtr - procedure (ActionBool), pointer :: SoundBlowerMp1Ptr - procedure (ActionBool), pointer :: SoundBlowerMp2Ptr - procedure (ActionBool), pointer :: SoundBlowerMp3Ptr - procedure (ActionBool), pointer :: SoundBlowerRtPtr - procedure (ActionBool), pointer :: SoundBlowerDwPtr - procedure (ActionBool), pointer :: SoundBlowerStartPtr - procedure (ActionBool), pointer :: SoundBlowerShutdownPtr - procedure (ActionBool), pointer :: SoundElectricPumpPtr - - private :: SoundMP1Ptr, SoundMP2Ptr, SoundMP3Ptr, SoundRTPtr, SoundDwFwPtr, SoundDwRevPtr,SoundDwBrakePtr,SoundChokePumpPtr,SoundGasThroughChokePtr,SoundKoomeyAirPumpPtr, & - SoundKoomeyElectricPumpPtr, SoundRtGearCrashPtr,SoundDwGearCrashPtr,SoundFloorCollisionPtr,SoundCrownCollisionPtr,SoundDwClutchPtr,SoundBlowerPtr, & - SoundBlowerMp1Ptr, SoundBlowerMp2Ptr,SoundBlowerMp3Ptr,SoundBlowerRtPtr,SoundBlowerDwPtr,SoundBlowerStartPtr,SoundBlowerShutdownPtr,SoundElectricPumpPtr - - contains - - - - - - subroutine SetSoundMP1(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundMP1Ptr)) call SoundMP1Ptr(v) - Sounds%MP1s = v - end subroutine - - subroutine SetSoundMP2(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundMP2Ptr)) call SoundMP2Ptr(v) - Sounds%MP2s = v - end subroutine - - subroutine SetSoundMP3(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundMP3Ptr)) call SoundMP3Ptr(v) - Sounds%MP3s = v - end subroutine - - subroutine SetSoundRT(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundRTPtr)) call SoundRTPtr(v) - Sounds%RTs = v - end subroutine - - subroutine SetSoundDwFw(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundDwFwPtr)) call SoundDwFwPtr(v) - Sounds%DwFws = v - end subroutine - - subroutine SetSoundDwRev(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundDwRevPtr)) call SoundDwRevPtr(v) - Sounds%DwRevs = v - end subroutine - - subroutine SetSoundDwBrake(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundDwBrakePtr)) call SoundDwBrakePtr(v) - Sounds%DwBrakes = v - end subroutine - - subroutine SetSoundChokePump(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundChokePumpPtr)) call SoundChokePumpPtr(v) - Sounds%ChokePumps = v - end subroutine - - subroutine SetSoundGasThroughChoke(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundGasThroughChokePtr)) call SoundGasThroughChokePtr(v) - Sounds%GasThroughChokes = v - end subroutine - - subroutine SetSoundKoomeyAirPump(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundKoomeyAirPumpPtr)) call SoundKoomeyAirPumpPtr(v) - Sounds%KoomeyAirPumps = v - end subroutine - - subroutine SetSoundKoomeyElectricPump(v) - implicit none - integer, intent(inout) :: v - !if(associated(SoundKoomeyElectricPumpPtr)) call SoundKoomeyElectricPumpPtr(v) - Sounds%KoomeyElectricPumps = v - end subroutine - - subroutine SetSoundRtGearCrash(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundRtGearCrashPtr)) call SoundRtGearCrashPtr(v) - Sounds%RtGearCrashs = v - end subroutine - - subroutine SetSoundDwGearCrash(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundDwGearCrashPtr)) call SoundDwGearCrashPtr(v) - Sounds%DwGearCrashs = v - end subroutine - - subroutine SetSoundFloorCollision(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundFloorCollisionPtr)) call SoundFloorCollisionPtr(v) - Sounds%FloorCollisions = v - end subroutine - - subroutine SetSoundCrownCollision(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundCrownCollisionPtr)) call SoundCrownCollisionPtr(v) - Sounds%CrownCollisions = v - end subroutine - - subroutine SetSoundDwClutch(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundDwClutchPtr)) call SoundDwClutchPtr(v) - Sounds%DwClutchs = v - end subroutine - - subroutine SetSoundBlower(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerPtr)) call SoundBlowerPtr(v) - Sounds%Blowers = v - end subroutine - - subroutine SetSoundBlowerMP1(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerMp1Ptr)) call SoundBlowerMp1Ptr(v) - Sounds%BlowerMp1s = v - end subroutine - - subroutine SetSoundBlowerMP2(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerMp2Ptr)) call SoundBlowerMp2Ptr(v) - Sounds%BlowerMp2s = v - end subroutine - - subroutine SetSoundBlowerMP3(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerMp3Ptr)) call SoundBlowerMp3Ptr(v) - Sounds%BlowerMp3s = v - end subroutine - - subroutine SetSoundBlowerRT(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerRtPtr)) call SoundBlowerRtPtr(v) - Sounds%BlowerRts = v - end subroutine - - subroutine SetSoundBlowerDW(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerDwPtr)) call SoundBlowerDwPtr(v) - Sounds%BlowerDws = v - end subroutine - - - subroutine SetSoundBlowerStart(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerStartPtr)) call SoundBlowerStartPtr(v) - Sounds%BlowerStarts = v - end subroutine - - subroutine SetSoundBlowerShutdown(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundBlowerShutdownPtr)) call SoundBlowerShutdownPtr(v) - Sounds%BlowerShutdowns = v - end subroutine - - - subroutine SetSoundElectricPump(v) - implicit none - logical, intent(inout) :: v - !if(associated(SoundElectricPumpPtr)) call SoundElectricPumpPtr(v) - Sounds%ElectricPumps = v - end subroutine - - - - - - - - - - - - - - - - - - - subroutine SubscribeSoundMP1(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundMP1 - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundMP1' :: SubscribeSoundMP1 - implicit none - procedure (ActionInteger) :: v - SoundMP1Ptr => v - end subroutine - - subroutine SubscribeSoundMP2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundMP2 - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundMP2' :: SubscribeSoundMP2 - implicit none - procedure (ActionInteger) :: v - SoundMP2Ptr => v - end subroutine - - subroutine SubscribeSoundMP3(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundMP3 - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundMP3' :: SubscribeSoundMP3 - implicit none - procedure (ActionInteger) :: v - SoundMP3Ptr => v - end subroutine - - subroutine SubscribeSoundRT(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundRT - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundRT' :: SubscribeSoundRT - implicit none - procedure (ActionInteger) :: v - SoundRTPtr => v - end subroutine - - subroutine SubscribeSoundDwFw(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundDwFw - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundDwFw' :: SubscribeSoundDwFw - implicit none - procedure (ActionInteger) :: v - SoundDwFwPtr => v - end subroutine - - subroutine SubscribeSoundDwRev(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundDwRev - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundDwRev' :: SubscribeSoundDwRev - implicit none - procedure (ActionInteger) :: v - SoundDwRevPtr => v - end subroutine - - subroutine SubscribeSoundDwBrake(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundDwBrake - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundDwBrake' :: SubscribeSoundDwBrake - implicit none - procedure (ActionInteger) :: v - SoundDwBrakePtr => v - end subroutine - - subroutine SubscribeSoundChokePump(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundChokePump - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundChokePump' :: SubscribeSoundChokePump - implicit none - procedure (ActionInteger) :: v - SoundChokePumpPtr => v - end subroutine - - subroutine SubscribeSoundGasThroughChoke(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundGasThroughChoke - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundGasThroughChoke' :: SubscribeSoundGasThroughChoke - implicit none - procedure (ActionInteger) :: v - SoundGasThroughChokePtr => v - end subroutine - - subroutine SubscribeSoundKoomeyAirPump(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundKoomeyAirPump - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundKoomeyAirPump' :: SubscribeSoundKoomeyAirPump - implicit none - procedure (ActionInteger) :: v - SoundKoomeyAirPumpPtr => v - end subroutine - - subroutine SubscribeSoundKoomeyElectricPump(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundKoomeyElectricPump - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundKoomeyElectricPump' :: SubscribeSoundKoomeyElectricPump - implicit none - procedure (ActionInteger) :: v - SoundKoomeyElectricPumpPtr => v - end subroutine - - subroutine SubscribeSoundRtGearCrash(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundRtGearCrash - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundRtGearCrash' :: SubscribeSoundRtGearCrash - implicit none - procedure (ActionBool) :: v - SoundRtGearCrashPtr => v - end subroutine - - subroutine SubscribeSoundDwGearCrash(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundDwGearCrash - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundDwGearCrash' :: SubscribeSoundDwGearCrash - implicit none - procedure (ActionBool) :: v - SoundDwGearCrashPtr => v - end subroutine - - subroutine SubscribeSoundFloorCollision(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundFloorCollision - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundFloorCollision' :: SubscribeSoundFloorCollision - implicit none - procedure (ActionBool) :: v - SoundFloorCollisionPtr => v - end subroutine - - subroutine SubscribeSoundCrownCollision(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundCrownCollision - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundCrownCollision' :: SubscribeSoundCrownCollision - implicit none - procedure (ActionBool) :: v - SoundCrownCollisionPtr => v - end subroutine - - subroutine SubscribeSoundDwClutch(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundDwClutch - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundDwClutch' :: SubscribeSoundDwClutch - implicit none - procedure (ActionBool) :: v - SoundDwClutchPtr => v - end subroutine - - subroutine SubscribeSoundBlower(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlower - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlower' :: SubscribeSoundBlower - implicit none - procedure (ActionBool) :: v - SoundBlowerPtr => v - end subroutine - - subroutine SubscribeSoundBlowerMp1(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlowerMp1 - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlowerMp1' :: SubscribeSoundBlowerMp1 - implicit none - procedure (ActionBool) :: v - SoundBlowerMp1Ptr => v - end subroutine - - subroutine SubscribeSoundBlowerMp2(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlowerMp2 - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlowerMp2' :: SubscribeSoundBlowerMp2 - implicit none - procedure (ActionBool) :: v - SoundBlowerMp2Ptr => v - end subroutine - - subroutine SubscribeSoundBlowerMp3(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlowerMp3 - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlowerMp3' :: SubscribeSoundBlowerMp3 - implicit none - procedure (ActionBool) :: v - SoundBlowerMp3Ptr => v - end subroutine - - subroutine SubscribeSoundBlowerRt(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlowerRt - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlowerRt' :: SubscribeSoundBlowerRt - implicit none - procedure (ActionBool) :: v - SoundBlowerRtPtr => v - end subroutine - - subroutine SubscribeSoundBlowerDw(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlowerDw - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlowerDw' :: SubscribeSoundBlowerDw - implicit none - procedure (ActionBool) :: v - SoundBlowerDwPtr => v - end subroutine - - subroutine SubscribeSoundBlowerStart(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlowerStart - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlowerStart' :: SubscribeSoundBlowerStart - implicit none - procedure (ActionBool) :: v - SoundBlowerStartPtr => v - end subroutine - - subroutine SubscribeSoundBlowerShutdown(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundBlowerShutdown - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundBlowerShutdown' :: SubscribeSoundBlowerShutdown - implicit none - procedure (ActionBool) :: v - SoundBlowerShutdownPtr => v - end subroutine - - subroutine SubscribeSoundElectricPump(v) - !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeSoundElectricPump - !DEC$ ATTRIBUTES ALIAS: 'SubscribeSoundElectricPump' :: SubscribeSoundElectricPump - implicit none - procedure (ActionBool) :: v - SoundElectricPumpPtr => v - end subroutine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Input routines - - ! Output routines - integer function GetSoundMP1() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundMP1 - !DEC$ ATTRIBUTES ALIAS: 'GetSoundMP1' :: GetSoundMP1 - implicit none - GetSoundMP1 = Sounds%MP1s - end function - - integer function GetSoundMP2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundMP2 - !DEC$ ATTRIBUTES ALIAS: 'GetSoundMP2' :: GetSoundMP2 - implicit none - GetSoundMP2 = Sounds%MP2s - end function - - integer function GetSoundMP3() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundMP3 - !DEC$ ATTRIBUTES ALIAS: 'GetSoundMP3' :: GetSoundMP3 - implicit none - GetSoundMP3 = Sounds%MP3s - end function - - integer function GetSoundRT() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundRT - !DEC$ ATTRIBUTES ALIAS: 'GetSoundRT' :: GetSoundRT - implicit none - GetSoundRT = Sounds%RTs - end function - - integer function GetSoundDwFw() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundDwFw - !DEC$ ATTRIBUTES ALIAS: 'GetSoundDwFw' :: GetSoundDwFw - implicit none - GetSoundDwFw = Sounds%DwFws - end function - - integer function GetSoundDwRev() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundDwRev - !DEC$ ATTRIBUTES ALIAS: 'GetSoundDwRev' :: GetSoundDwRev - implicit none - GetSoundDwRev = Sounds%DwRevs - end function - - integer function GetSoundDwBrake() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundDwBrake - !DEC$ ATTRIBUTES ALIAS: 'GetSoundDwBrake' :: GetSoundDwBrake - implicit none - GetSoundDwBrake = Sounds%DwBrakes - end function - - integer function GetSoundChokePump() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundChokePump - !DEC$ ATTRIBUTES ALIAS: 'GetSoundChokePump' :: GetSoundChokePump - implicit none - GetSoundChokePump = Sounds%ChokePumps - end function - - integer function GetSoundGasThroughChoke() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundGasThroughChoke - !DEC$ ATTRIBUTES ALIAS: 'GetSoundGasThroughChoke' :: GetSoundGasThroughChoke - implicit none - GetSoundGasThroughChoke = Sounds%GasThroughChokes - end function - - integer function GetSoundKoomeyAirPump() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundKoomeyAirPump - !DEC$ ATTRIBUTES ALIAS: 'GetSoundKoomeyAirPump' :: GetSoundKoomeyAirPump - implicit none - GetSoundKoomeyAirPump = Sounds%KoomeyAirPumps - end function - - integer function GetSoundKoomeyElectricPump() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundKoomeyElectricPump - !DEC$ ATTRIBUTES ALIAS: 'GetSoundKoomeyElectricPump' :: GetSoundKoomeyElectricPump - implicit none - GetSoundKoomeyElectricPump = Sounds%KoomeyElectricPumps - end function - - logical function GetSoundRtGearCrash() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundRtGearCrash - !DEC$ ATTRIBUTES ALIAS: 'GetSoundRtGearCrash' :: GetSoundRtGearCrash - implicit none - GetSoundRtGearCrash = Sounds%RtGearCrashs - end function - - logical function GetSoundDwGearCrash() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundDwGearCrash - !DEC$ ATTRIBUTES ALIAS: 'GetSoundDwGearCrash' :: GetSoundDwGearCrash - implicit none - GetSoundDwGearCrash = Sounds%DwGearCrashs - end function - - logical function GetSoundFloorCollision() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundFloorCollision - !DEC$ ATTRIBUTES ALIAS: 'GetSoundFloorCollision' :: GetSoundFloorCollision - implicit none - GetSoundFloorCollision = Sounds%FloorCollisions - end function - - logical function GetSoundCrownCollision() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundCrownCollision - !DEC$ ATTRIBUTES ALIAS: 'GetSoundCrownCollision' :: GetSoundCrownCollision - implicit none - GetSoundCrownCollision = Sounds%CrownCollisions - end function - - logical function GetSoundDwClutch() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundDwClutch - !DEC$ ATTRIBUTES ALIAS: 'GetSoundDwClutch' :: GetSoundDwClutch - implicit none - GetSoundDwClutch = Sounds%DwClutchs - end function - - logical function GetSoundBlower() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlower - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlower' :: GetSoundBlower - implicit none - GetSoundBlower = Sounds%Blowers - end function - - logical function GetSoundBlowerMp1() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlowerMp1 - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlowerMp1' :: GetSoundBlowerMp1 - implicit none - GetSoundBlowerMp1 = Sounds%BlowerMp1s - end function - - logical function GetSoundBlowerMp2() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlowerMp2 - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlowerMp2' :: GetSoundBlowerMp2 - implicit none - GetSoundBlowerMp2 = Sounds%BlowerMp2s - end function - - logical function GetSoundBlowerMp3() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlowerMp3 - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlowerMp3' :: GetSoundBlowerMp3 - implicit none - GetSoundBlowerMp3 = Sounds%BlowerMp3s - end function - - logical function GetSoundBlowerRt() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlowerRt - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlowerRt' :: GetSoundBlowerRt - implicit none - GetSoundBlowerRt = Sounds%BlowerRts - end function - - logical function GetSoundBlowerDw() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlowerDw - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlowerDw' :: GetSoundBlowerDw - implicit none - GetSoundBlowerDw = Sounds%BlowerDws - end function - - logical function GetSoundBlowerStart() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlowerStart - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlowerStart' :: GetSoundBlowerStart - implicit none - GetSoundBlowerStart = Sounds%BlowerStarts - end function - - logical function GetSoundBlowerShutdown() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundBlowerShutdown - !DEC$ ATTRIBUTES ALIAS: 'GetSoundBlowerShutdown' :: GetSoundBlowerShutdown - implicit none - GetSoundBlowerShutdown = Sounds%BlowerShutdowns - end function - - logical function GetSoundElectricPump() - !DEC$ ATTRIBUTES DLLEXPORT :: GetSoundElectricPump - !DEC$ ATTRIBUTES ALIAS: 'GetSoundElectricPump' :: GetSoundElectricPump - implicit none - GetSoundElectricPump = Sounds%ElectricPumps - end function - - - - - - - - - - - -end module CSounds \ No newline at end of file diff --git a/Common/DynamicDoubleArray.f90 b/Common/DynamicDoubleArray.f90 index c7b1091..88143e4 100644 --- a/Common/DynamicDoubleArray.f90 +++ b/Common/DynamicDoubleArray.f90 @@ -15,9 +15,9 @@ module DynamicDoubleArray procedure :: Empty => Empty end type DynamicDoubleArrayType + private::First,Last,Length contains - real(8) function First(this) implicit none class(DynamicDoubleArrayType), intent(in) :: this diff --git a/Common/DynamicIntegerArray.f90 b/Common/DynamicIntegerArray.f90 index c9d7be1..56f1363 100644 --- a/Common/DynamicIntegerArray.f90 +++ b/Common/DynamicIntegerArray.f90 @@ -14,7 +14,8 @@ module DynamicIntegerArray procedure :: Remove => Remove procedure :: Empty => Empty end type DynamicIntegerArrayType - + private::First,Last,Length + contains diff --git a/Common/DynamicLogicalArray.f90 b/Common/DynamicLogicalArray.f90 index c22fd1a..473671b 100644 --- a/Common/DynamicLogicalArray.f90 +++ b/Common/DynamicLogicalArray.f90 @@ -14,7 +14,8 @@ module DynamicLogicalArray procedure :: Remove => Remove procedure :: Empty => Empty end type DynamicLogicalArrayType - + private::First,Last,Length + contains diff --git a/Common/DynamicRealArray.f90 b/Common/DynamicRealArray.f90 index fbb89f8..5d217bf 100644 --- a/Common/DynamicRealArray.f90 +++ b/Common/DynamicRealArray.f90 @@ -14,6 +14,7 @@ module DynamicRealArray procedure :: Remove => Remove procedure :: Empty => Empty end type DynamicRealArrayType + private::First,Last,Length contains diff --git a/ConfigurationVariables.f90 b/ConfigurationVariables.f90 deleted file mode 100644 index e69de29..0000000 diff --git a/Data Structures.txt b/Data Structures.txt index 0554bd8..36db7b1 100644 --- a/Data Structures.txt +++ b/Data Structures.txt @@ -104,28 +104,28 @@ Equipments: TDS TorqueDrag: TDGeo - F_String(:) + data%State%F_String(:) F_Counts - F_Interval(:) - OD_Annulus(4) - TD_String - TD_DrillStem(:) - TD_DrillStems(:) - TD_Count - G_StringElement - TD_Vol - TD_General - TD_BOP - TD_BOPElement(4) - TD_StConn - TD_Load - TD_WellEl - TD_Casing - TD_Liner - TD_OpenHole - TD_ROPHole - TD_WellGeneral - TD_WellGeo(:) + data%State%F_Interval(:) + data%State%OD_Annulus(4) + data%State%TD_String + data%State%TD_DrillStem(:) + data%State%TD_DrillStems(:) + data%State%TD_Count + data%State%G_StringElement + data%State%TD_Vol + data%State%TD_General + data%State%TD_BOP + data%State%TD_BOPElement(4) + data%State%TD_StConn + data%State%TD_Load + data%State%TD_WellEl + data%State%TD_Casing + data%State%TD_Liner + data%State%TD_OpenHole + data%State%TD_ROPHole + data%State%TD_WellGeneral + data%State%TD_WellGeo(:) FluidFlow: diff --git a/Equipments/BopStack/ANNULAR.f90 b/Equipments/BopStack/ANNULAR.f90 index f8d63e7..3b8e8be 100644 --- a/Equipments/BopStack/ANNULAR.f90 +++ b/Equipments/BopStack/ANNULAR.f90 @@ -1,6 +1,7 @@ SUBROUTINE ANNULAR_SUB1 - USE VARIABLES - USE CBopControlPanelVariables + use ConfigurationVariables + use CBopControlPanel + use ConfigurationVariables use PressureDisplayVARIABLESModule USE CEquipmentsConstants USE CBopStackVariables @@ -13,80 +14,80 @@ SUBROUTINE ANNULAR_SUB1 ! START CONDITIONS FOR ANNULAR PREVENTER !===================================================================== - RAM(1)%SuccessionCounter = RAM(1)%SuccessionCounter + 1 + data%State%RAM(1)%SuccessionCounter = data%State%RAM(1)%SuccessionCounter + 1 - if (BopControlPanel%AnnularValve == 1.0 .and. Annular%AnnularFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%AnnularValve == 1.0 .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then - if (BopStackInput%AnnularCloseLedMine == LedOn) then + if (data%State%BopStackInput%AnnularCloseLedMine == LedOn) then RETURN end if - if ( RAM(1)%SuccessionCounter /= RAM(1)%SuccessionCounterOld+1 ) then - RAM(1)%SuccessionCounter = 0 ! also in starup - RAM(1)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then + data%State%RAM(1)%SuccessionCounter = 0 ! also in starup + data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(1)%SuccessionCounterOld= RAM(1)%SuccessionCounter + data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter endif - if ( RAM(1)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - RAM(1)%First_CloseTimecheck= 1 + data%State%RAM(1)%First_CloseTimecheck= 1 - BopControlPanel%AnnularOpenLED = LedOff - BopStackInput%AnnularOpenLedMine = LedOff - BopControlPanel%AnnularCloseLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%AnnularOpenLED = LedOff + data%State%BopStackInput%AnnularOpenLedMine = LedOff + data%EquipmentControl%BopControlPanel%AnnularCloseLED = LedOn !LedBlinking - RAM(1)%FourwayValve = 1 + data%State%RAM(1)%FourwayValve = 1 endif endif - if (RAM(1)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure .and. Annular%Pannular_reg>AnnularComputational%AnnularMovingPressure) then ! 1: Open , 0: Close + if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure) then ! 1: Open , 0: Close - RAM(1)%FourwayValve = 0 + data%State%RAM(1)%FourwayValve = 0 - Annular%Annular_closed=0 + data%State%Annular%Annular_closed=0 !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1) - RAM(1)%vdis_tot=0 - RAM(1)%vdis_bottles=0. - RAM(1)%fvr_air=0. - RAM(1)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(1)%Qzero=70 - RAM(1)%Q=RAM(1)%Qzero - RAM(1)%flow=70 - Annular%tolAnnular=0.0018 - if (Annular%finished_Annular==1) then - Annular%AnnularLeverOld=-1.0 + data%State%RAM(1)%vdis_tot=0 + data%State%RAM(1)%vdis_bottles=0. + data%State%RAM(1)%fvr_air=0. + data%State%RAM(1)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(1)%Qzero=70 + data%State%RAM(1)%Q=data%State%RAM(1)%Qzero + data%State%RAM(1)%flow=70 + data%State%Annular%tolAnnular=0.0018 + if (data%State%Annular%finished_Annular==1) then + data%State%Annular%AnnularLeverOld=-1.0 else - Annular%AnnularLeverOld=BopControlPanel%AnnularValve + data%State%Annular%AnnularLeverOld=data%EquipmentControl%BopControlPanel%AnnularValve endif - Annular%finished_Annular=0 - Annular%AnnularIsClosing = .true. - Annular%AnnularIsOpening = .false. + data%State%Annular%finished_Annular=0 + data%State%Annular%AnnularIsClosing = .true. + data%State%Annular%AnnularIsOpening = .false. - RAM(2)%bop_type = 3 + data%State%RAM(2)%bop_type = 3 !AbopAnnular=963.1 !(in^2) - Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerClose*231.)/((Annular%IDAnnularBase-Annular%ODDrillpipe_inAnnularBase)/2.) ! 231 in^3 = 1 gal - Annular%NeededVolumeAnnular=Annular%AbopAnnular*(Annular%IDAnnularBase-max(Annular%ODDrillpipe_inAnnular,Annular%ODDrillpipe_inAnnularBase))/(2.*231) !=17.98 galon for IDAnnularBase=13 5/8 , ODDrillpipe_inAnnularBase=5 + data%State%Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerClose*231.)/((data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnularBase)/2.) ! 231 in^3 = 1 gal + data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnularBase-max(data%State%Annular%ODDrillpipe_inAnnular,data%State%Annular%ODDrillpipe_inAnnularBase))/(2.*231) !=17.98 galon for IDAnnularBase=13 5/8 , ODDrillpipe_inAnnularBase=5 !WRITE(*,*) 'a)NeededVolumeAnnular=' , NeededVolumeAnnular !write(*,*) 'close 1' endif - if (BopControlPanel%AnnularValve == -1.0 .and. Annular%AnnularFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 ) then + if (data%EquipmentControl%BopControlPanel%AnnularValve == -1.0 .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 ) then - if (BopStackInput%AnnularOpenLedMine == LedOn) then + if (data%State%BopStackInput%AnnularOpenLedMine == LedOn) then RETURN end if @@ -95,26 +96,26 @@ SUBROUTINE ANNULAR_SUB1 !note: (AnnularSealingPressure) is only for opening while well is pressurised - if ( RAM(1)%SuccessionCounter /= RAM(1)%SuccessionCounterOld+1 ) then - RAM(1)%SuccessionCounter = 0 ! also in starup - RAM(1)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then + data%State%RAM(1)%SuccessionCounter = 0 ! also in starup + data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(1)%SuccessionCounterOld= RAM(1)%SuccessionCounter + data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter endif - if ( RAM(1)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - RAM(1)%First_OpenTimecheck= 1 + data%State%RAM(1)%First_OpenTimecheck= 1 - BopControlPanel%AnnularCloseLED = LedOff !new - BopStackInput%AnnularCloseLedMine = LedOff !new - BopControlPanel%AnnularOpenLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%AnnularCloseLED = LedOff !new + data%State%BopStackInput%AnnularCloseLedMine = LedOff !new + data%EquipmentControl%BopControlPanel%AnnularOpenLED = LedOn !LedBlinking - RAM(1)%FourwayValve = 1 + data%State%RAM(1)%FourwayValve = 1 endif @@ -124,36 +125,36 @@ SUBROUTINE ANNULAR_SUB1 - if (RAM(1)%FourwayValve == 1 .and. Annular%Pannular_reg>AnnularComputational%AnnularMovingPressure .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure & - .and. (Annular%Annular_closed==0 .or. (Annular%Annular_closed==1 .and. PressureDisplayVARIABLES%PressureGauges(2) <=100.0) .or. (Annular%Annular_closed==1 .and. PressureDisplayVARIABLES%PressureGauges(2)>100.0 .and. Annular%Pannular_reg>=AnnularComputational%AnnularSealingPressure))) then ! 1: Open , 0: Close + if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure & + .and. (data%State%Annular%Annular_closed==0 .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2) <=100.0) .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2)>100.0 .and. data%State%Annular%Pannular_reg>=data%State%AnnularComputational%AnnularSealingPressure))) then ! 1: Open , 0: Close !write(*,*) 'open 2' - RAM(1)%FourwayValve = 0 + data%State%RAM(1)%FourwayValve = 0 - Annular%Annular_closed=0 + data%State%Annular%Annular_closed=0 !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1) - RAM(1)%vdis_tot=0 - RAM(1)%vdis_bottles=0. - RAM(1)%fvr_air=0. - RAM(1)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(1)%Qzero=70 - RAM(1)%Q=RAM(1)%Qzero - RAM(1)%flow=70 - Annular%tolAnnular=0.0018 + data%State%RAM(1)%vdis_tot=0 + data%State%RAM(1)%vdis_bottles=0. + data%State%RAM(1)%fvr_air=0. + data%State%RAM(1)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(1)%Qzero=70 + data%State%RAM(1)%Q=data%State%RAM(1)%Qzero + data%State%RAM(1)%flow=70 + data%State%Annular%tolAnnular=0.0018 - if (Annular%finished_Annular==1) then - Annular%AnnularLeverOld=1.0 + if (data%State%Annular%finished_Annular==1) then + data%State%Annular%AnnularLeverOld=1.0 else - Annular%AnnularLeverOld=BopControlPanel%AnnularValve + data%State%Annular%AnnularLeverOld=data%EquipmentControl%BopControlPanel%AnnularValve endif - Annular%finished_Annular=0 - Annular%AnnularIsOpening = .true. - Annular%AnnularIsClosing = .false. + data%State%Annular%finished_Annular=0 + data%State%Annular%AnnularIsOpening = .true. + data%State%Annular%AnnularIsClosing = .false. !if (AnnularOpenLed == LedOn) then @@ -162,17 +163,17 @@ SUBROUTINE ANNULAR_SUB1 - RAM(1)%bop_type = 3 + data%State%RAM(1)%bop_type = 3 !AbopAnnular=758.48 !(in^2) - Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerOpen*231)/((Annular%IDAnnularBase-max(Annular%ODDrillpipe_inAnnular,Annular%ODDrillpipe_inAnnularBase))/2.) - Annular%NeededVolumeAnnular=Annular%AbopAnnular*(Annular%IDAnnularBase-Annular%ODDrillpipe_inAnnular)/(2.*231) !=14.16 galon for IDAnnularBase=13 5/8 , ODDrillpipe_inAnnular=5 + data%State%Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerOpen*231)/((data%State%Annular%IDAnnularBase-max(data%State%Annular%ODDrillpipe_inAnnular,data%State%Annular%ODDrillpipe_inAnnularBase))/2.) + data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnular)/(2.*231) !=14.16 galon for IDAnnularBase=13 5/8 , ODDrillpipe_inAnnular=5 !write(*,*) 'open 1' endif !===================================================================== -if (Annular%AnnularIsOpening .or. Annular%AnnularIsClosing .or. RAM(1)%Bottles_Charged_MalfActive) then +if (data%State%Annular%AnnularIsOpening .or. data%State%Annular%AnnularIsClosing .or. data%State%RAM(1)%Bottles_Charged_MalfActive) then CALL ANNULAR_SUB2 end if @@ -195,9 +196,10 @@ end if SUBROUTINE ANNULAR_SUB2 - USE VARIABLES + use ConfigurationVariables use PressureDisplayVARIABLESModule - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants USE CBopStackVariables ! use CSimulationVariables @@ -205,8 +207,8 @@ SUBROUTINE ANNULAR_SUB2 implicit none - Annular%FirstSet= 0 - AnnularComputational%RamsFirstSet= 0 + data%State%Annular%FirstSet= 0 + data%State%AnnularComputational%RamsFirstSet= 0 ! loop5: do while (finished_Annular==0) @@ -214,33 +216,33 @@ SUBROUTINE ANNULAR_SUB2 !write(*,*) 'checkpoint 2' - RAM(1)%SuccessionCounter = RAM(1)%SuccessionCounter + 1 + data%State%RAM(1)%SuccessionCounter = data%State%RAM(1)%SuccessionCounter + 1 ! CALL CPU_TIME(Annular_StartTime) - if (BopControlPanel%AnnularValve == 1.0 .and. Annular%AnnularLeverOld == -1.0 .and. Annular%AnnularFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then - if ( RAM(1)%First_CloseTimecheck == 0 ) then + if (data%EquipmentControl%BopControlPanel%AnnularValve == 1.0 .and. data%State%Annular%AnnularLeverOld == -1.0 .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then + if ( data%State%RAM(1)%First_CloseTimecheck == 0 ) then - if ( RAM(1)%SuccessionCounter /= RAM(1)%SuccessionCounterOld+1 ) then - RAM(1)%SuccessionCounter = 0 ! also in starup - RAM(1)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then + data%State%RAM(1)%SuccessionCounter = 0 ! also in starup + data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(1)%SuccessionCounterOld= RAM(1)%SuccessionCounter + data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter endif - if ( RAM(1)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - BopControlPanel%AnnularOpenLED = LedOff - BopStackInput%AnnularOpenLedMine = LedOff - BopControlPanel%AnnularCloseLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%AnnularOpenLED = LedOff + data%State%BopStackInput%AnnularOpenLedMine = LedOff + data%EquipmentControl%BopControlPanel%AnnularCloseLED = LedOn !LedBlinking - RAM(1)%FourwayValve = 1 + data%State%RAM(1)%FourwayValve = 1 endif @@ -250,59 +252,59 @@ SUBROUTINE ANNULAR_SUB2 endif - if (RAM(1)%FourwayValve == 1 .and. Annular%Pannular_reg>AnnularComputational%AnnularMovingPressure .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then !write(*,*) 'close 4' - RAM(1)%FourwayValve = 0 + data%State%RAM(1)%FourwayValve = 0 - Annular%Annular_closed=0 + data%State%Annular%Annular_closed=0 !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1) - AnnularComputational%p_annular=AnnularComputational%pa_annular - Annular%AnnularLeverOld = BopControlPanel%AnnularValve + data%State%AnnularComputational%p_annular=data%State%AnnularComputational%pa_annular + data%State%Annular%AnnularLeverOld = data%EquipmentControl%BopControlPanel%AnnularValve CALL OpenAnnular - Annular%Annular_Situation_forTD= 0 ! open - for TD code - RAM(1)%bop_type = 3 + data%State%Annular%Annular_Situation_forTD= 0 ! open - for TD code + data%State%RAM(1)%bop_type = 3 !AbopAnnular=963.1 !(in^2) - Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerClose*231)/((Annular%IDAnnularBase-Annular%ODDrillpipe_inAnnularBase)/2.) + data%State%Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerClose*231)/((data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnularBase)/2.) !write(*,*) 'NeededVolumeShearRams1=',NeededVolumeShearRams - Annular%NeededVolumeAnnular=Annular%AbopAnnular*(Annular%IDAnnular-max(Annular%ODDrillpipe_inAnnular,Annular%ODDrillpipe_inAnnularBase))/(2*231.) + data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnular-max(data%State%Annular%ODDrillpipe_inAnnular,data%State%Annular%ODDrillpipe_inAnnularBase))/(2*231.) ! write(*,*) 'NeededVolumeAnnular=',NeededVolumeAnnular - RAM(1)%vdis_bottles=0. - RAM(1)%fvr_air=0. - RAM(1)%vdis_elecp=0. - Annular%AnnularIsClosing = .true. - Annular%AnnularIsOpening = .false. + data%State%RAM(1)%vdis_bottles=0. + data%State%RAM(1)%fvr_air=0. + data%State%RAM(1)%vdis_elecp=0. + data%State%Annular%AnnularIsClosing = .true. + data%State%Annular%AnnularIsOpening = .false. !write(*,*) 'close 2' endif - if (BopControlPanel%AnnularValve == -1.0 .and. Annular%AnnularLeverOld == 1.0 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure .and. Annular%AnnularFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 ) then + if (data%EquipmentControl%BopControlPanel%AnnularValve == -1.0 .and. data%State%Annular%AnnularLeverOld == 1.0 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 ) then !CasingPressure : PressureGauges(2) *****temp conditionssssss !note: (AnnularSealingPressure) is only for opening while well is pressurised - if ( RAM(1)%First_OpenTimecheck == 0 ) then + if ( data%State%RAM(1)%First_OpenTimecheck == 0 ) then - if ( RAM(1)%SuccessionCounter /= RAM(1)%SuccessionCounterOld+1 ) then - RAM(1)%SuccessionCounter = 0 ! also in starup - RAM(1)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then + data%State%RAM(1)%SuccessionCounter = 0 ! also in starup + data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(1)%SuccessionCounterOld= RAM(1)%SuccessionCounter + data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter endif - if ( RAM(1)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - BopControlPanel%AnnularCloseLED = LedOff - BopStackInput%AnnularCloseLedMine= LedOff - BopControlPanel%AnnularOpenLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%AnnularCloseLED = LedOff + data%State%BopStackInput%AnnularCloseLedMine= LedOff + data%EquipmentControl%BopControlPanel%AnnularOpenLED = LedOn !LedBlinking - RAM(1)%FourwayValve = 1 + data%State%RAM(1)%FourwayValve = 1 endif @@ -313,30 +315,30 @@ SUBROUTINE ANNULAR_SUB2 - if (RAM(1)%FourwayValve == 1 .and. Annular%Pannular_reg>AnnularComputational%AnnularMovingPressure & - .and. (Annular%Annular_closed==0 .or. (Annular%Annular_closed==1 .and. PressureDisplayVARIABLES%PressureGauges(2) <=100.0) .or. (Annular%Annular_closed==1 .and. PressureDisplayVARIABLES%PressureGauges(2)>100.0 .and. Annular%Pannular_reg>=AnnularComputational%AnnularSealingPressure))) then + if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure & + .and. (data%State%Annular%Annular_closed==0 .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2) <=100.0) .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2)>100.0 .and. data%State%Annular%Pannular_reg>=data%State%AnnularComputational%AnnularSealingPressure))) then !write(*,*) 'open 4' - RAM(1)%FourwayValve = 0 + data%State%RAM(1)%FourwayValve = 0 - Annular%Annular_closed=0 + data%State%Annular%Annular_closed=0 !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1) - AnnularComputational%p_annular=AnnularComputational%pa_annular - Annular%AnnularLeverOld = BopControlPanel%AnnularValve + data%State%AnnularComputational%p_annular=data%State%AnnularComputational%pa_annular + data%State%Annular%AnnularLeverOld = data%EquipmentControl%BopControlPanel%AnnularValve CALL OpenAnnular - Annular%Annular_Situation_forTD= 0 ! open - for TD code - RAM(1)%bop_type = 3 + data%State%Annular%Annular_Situation_forTD= 0 ! open - for TD code + data%State%RAM(1)%bop_type = 3 !AbopAnnular=758.48 !(in^2) - Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerOpen*231)/((Annular%IDAnnularBase-Annular%ODDrillpipe_inAnnularBase)/2.) - Annular%NeededVolumeAnnular=Annular%AbopAnnular*(Annular%IDAnnularBase-Annular%IDAnnular)/(2*231.) - RAM(1)%vdis_bottles=0. - RAM(1)%fvr_air=0. - RAM(1)%vdis_elecp=0. + data%State%Annular%AbopAnnular=(BopStackSpecification%AnnularPreventerOpen*231)/((data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnularBase)/2.) + data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnularBase-data%State%Annular%IDAnnular)/(2*231.) + data%State%RAM(1)%vdis_bottles=0. + data%State%RAM(1)%fvr_air=0. + data%State%RAM(1)%vdis_elecp=0. - Annular%AnnularIsOpening = .true. - Annular%AnnularIsClosing = .false. + data%State%Annular%AnnularIsOpening = .true. + data%State%Annular%AnnularIsClosing = .false. !write(*,*) 'open 2' @@ -344,10 +346,10 @@ SUBROUTINE ANNULAR_SUB2 - RAM(1)%First_CloseTimecheck = 0 - RAM(1)%First_OpenTimecheck = 0 + data%State%RAM(1)%First_CloseTimecheck = 0 + data%State%RAM(1)%First_OpenTimecheck = 0 - RAM(1)%time=RAM(1)%time+RamLine%DeltaT_BOP !overal time (s) + data%State%RAM(1)%time=data%State%RAM(1)%time+data%State%RamLine%DeltaT_BOP !overal time (s) @@ -356,18 +358,18 @@ SUBROUTINE ANNULAR_SUB2 !=================================================== ! BOP !=================================================== -if (Annular%Annular_closed==0) then !bop closing +if (data%State%Annular%Annular_closed==0) then !bop closing !write(*,*) 'AnnularIsClosing,AnnularIsOpening' , AnnularIsClosing,AnnularIsOpening call bop_codeAnnular(1) !ramtype=4 1=RNUMBER endif !bop is closing !================================================================ -if (Annular%Annular_closed==1) then - RAM(1)%Q=0 +if (data%State%Annular%Annular_closed==1) then + data%State%RAM(1)%Q=0 !p_bop=pram_reg - AnnularComputational%p_annular=AnnularComputational%pa_annular + data%State%AnnularComputational%p_annular=data%State%AnnularComputational%pa_annular endif -RAM(1)%timecounter_ram=RAM(1)%timecounter_ram+1 +data%State%RAM(1)%timecounter_ram=data%State%RAM(1)%timecounter_ram+1 @@ -383,8 +385,8 @@ RAM(1)%timecounter_ram=RAM(1)%timecounter_ram+1 ! ! ! -! WRITE(60,60) RAM(1)%time,RAM(1)%Q,RAM(1)%vdis_tot,p_acc, & -! pram_reg,Pannular_reg,RAM(1)%p_bop,IDshearBop, & +! WRITE(60,60) data%State%RAM(1)%time,data%State%RAM(1)%Q,data%State%RAM(1)%vdis_tot,p_acc, & +! pram_reg,Pannular_reg,data%State%RAM(1)%p_bop,IDshearBop, & ! IDPipeRam1,IDPipeRam2,IDAnnular !60 FORMAT(11(f18.5)) @@ -395,18 +397,18 @@ RAM(1)%timecounter_ram=RAM(1)%timecounter_ram+1 !CALL CPU_TIME(Annular_EndTime) ! ! - !PUMP(1)%INT_CPU_TIME=IDINT((Annular_EndTime-Annular_StartTime)*1000.) - !PUMP(1)%Dt_ref=IDINT(DeltaT_BOP*1000.) + !data%State%Pump(1)%INT_CPU_TIME=IDINT((Annular_EndTime-Annular_StartTime)*1000.) + !data%State%Pump(1)%Dt_ref=IDINT(DeltaT_BOP*1000.) ! - !call sleepqq(PUMP(1)%Dt_ref-PUMP(1)%INT_CPU_TIME) + !call sleepqq(data%State%Pump(1)%Dt_ref-data%State%Pump(1)%INT_CPU_TIME) -if (Annular%Annular_closed==1) then +if (data%State%Annular%Annular_closed==1) then ! if ((MiddleRamsValve==1. .and. MiddleRamsFailureMalf==0) .or. (MiddleRamsValve==-1.0 .and. MiddleRamsFailureMalf==0) .or. (LowerRamsValve==1. .and. LowerRamsFailureMalf==0) .or. (LowerRamsValve==-1.0 .and. LowerRamsFailureMalf==0) .or. (UpperRamsValve==1. .and. UpperRamsFailureMalf==0) .or. (UpperRamsValve==-1.0 .and. UpperRamsFailureMalf==0) .or. ChokeLineValve==1. .or. ChokeLineValve==-1.0 .or. KillLineValve==1. .or. KillLineValve==-1.0) then - Annular%finished_Annular=1 + data%State%Annular%finished_Annular=1 ! endif endif @@ -419,7 +421,7 @@ endif - if ( Annular%finished_Annular==1 .and. RAM(1)%Bottles_Charged_MalfActive==.true.) then + if ( data%State%Annular%finished_Annular==1 .and. data%State%RAM(1)%Bottles_Charged_MalfActive==.true.) then call bop_codeAnnular(1) !ramtype=4 1=RNUMBER ! call sleepqq(100) endif diff --git a/Equipments/BopStack/AnnularMain.f90 b/Equipments/BopStack/AnnularMain.f90 index f786704..e59303c 100644 --- a/Equipments/BopStack/AnnularMain.f90 +++ b/Equipments/BopStack/AnnularMain.f90 @@ -18,12 +18,12 @@ module AnnularMain ! end subroutine Annular_Init subroutine Annular_Step - use VARIABLES + use ConfigurationVariables implicit none - if (Annular%finished_Annular/=0) then + if (data%State%Annular%finished_Annular/=0) then call ANNULAR_SUB1 - if (Annular%AnnularIsOpening .or. Annular%AnnularIsClosing .or. RAM(1)%Bottles_Charged_MalfActive) then - if(Annular%finished_Annular==0) then + if (data%State%Annular%AnnularIsOpening .or. data%State%Annular%AnnularIsClosing .or. data%State%RAM(1)%Bottles_Charged_MalfActive) then + if(data%State%Annular%finished_Annular==0) then call ANNULAR_SUB2 !only body of loop2 endif endif @@ -32,45 +32,5 @@ module AnnularMain endif end subroutine Annular_Step - ! subroutine Annular_Output - ! implicit none - ! end subroutine Annular_Output - - ! subroutine AnnularMainBody - ! USE ifport - ! USE ifmt - ! ! use CSimulationVariables - ! ! USE BOP - ! implicit none - - ! INTEGER :: AnnularDuration - ! integer,dimension(8) :: AnnularStartTime , AnnularEndTime - - ! ! CALL BOP_StartUp() - ! loop1: DO - ! CALL DATE_AND_TIME(values=AnnularStartTime) - - ! CALL ANNULAR - - ! CALL DATE_AND_TIME(values=AnnularEndTime) - - ! AnnularDuration = 3600000 * (AnnularEndTime(5) - AnnularStartTime(5)) + 60000 * (AnnularEndTime(6) - AnnularStartTime(6)) + 1000 * (AnnularEndTime(7) - AnnularStartTime(7)) + (AnnularEndTime(8) - AnnularStartTime(8)) - - ! if (AnnularDuration < 100) then - ! call sleepqq(100 - AnnularDuration) - ! ELSE - ! WRITE (*,*) 'Annular BOP run duration exceeded 100 ms and =', AnnularDuration - ! end if - - ! IF (IsStopped==.true.) THEN - ! EXIT loop1 - ! ENDIF - - ! ENDDO loop1 - - - ! ! CALL DEALLOCATE_ARRAYS() - ! end subroutine AnnularMainBody - end module AnnularMain \ No newline at end of file diff --git a/Equipments/BopStack/BOP.f90 b/Equipments/BopStack/BOP.f90 index c80b36c..5196544 100644 --- a/Equipments/BopStack/BOP.f90 +++ b/Equipments/BopStack/BOP.f90 @@ -4,26 +4,28 @@ module BOP subroutine BopStack_Init call BOP_StartUp end subroutine BopStack_Init + subroutine BopStack_Step - USE VARIABLES - USE CBopControlPanelVariables - USE TD_GeneralData + use ConfigurationVariables + use CBopControlPanel + use BopVariables + use ConfigurationVariables !@ ! USE CEquipmentsConstants use CSounds implicit none - BopStackInput%BOP_timeCounter= BopStackInput%BOP_timeCounter + 1 + data%State%BopStackInput%BOP_timeCounter= data%State%BopStackInput%BOP_timeCounter + 1 - write(*,*) 'BOP_timeCounter=' , BopStackInput%BOP_timeCounter + write(*,*) 'BOP_timeCounter=' , data%State%BopStackInput%BOP_timeCounter - BopControlPanel%AirSupplyPressureGauge= (1 - BopStackAcc%AirSupplyPressureGaugeMalf)* (1 - BopStackAcc%RigAirMalf) *120. !psi + data%EquipmentControl%BopControlPanel%AirSupplyPressureGauge= (1 - data%State%BopStackAcc%AirSupplyPressureGaugeMalf)* (1 - data%State%BopStackAcc%RigAirMalf) *120. !psi - if (BopStackAcc%pram_reg < 2300.) then - ShearRam%ShearIsNotAllowed= 1 + if (data%State%BopStackAcc%pram_reg < 2300.) then + data%State%ShearRAM%ShearIsNotAllowed= 1 else - ShearRam%ShearIsNotAllowed= 0 + data%State%ShearRAM%ShearIsNotAllowed= 0 endif !write(*,*) 'ShearIsNotAllowed=' , ShearIsNotAllowed @@ -39,10 +41,10 @@ module BOP !=== Instantaneous Pipe Diameters in Each Ram (Input from TD Module):== - Annular%ODDrillpipe_inAnnular= TD_BOP%AnnularPreventerDiam * 12.0 ! ft to inch - PipeRam1%ODDrillpipe_in= TD_BOP%UpperRamDiam * 12.0 - ShearRam%ODDrillpipe_inShearRam= TD_BOP%BlindRamDiam * 12.0 - PipeRam2%ODDrillpipe_in= TD_BOP%LowerRamDiam * 12.0 + data%State%Annular%ODDrillpipe_inAnnular= data%State%TD_BOP%AnnularPreventerDiam * 12.0 ! ft to inch + data%State%PipeRam1%ODDrillpipe_in= data%State%TD_BOP%UpperRamDiam * 12.0 + data%State%ShearRAM%ODDrillpipe_inShearRam= data%State%TD_BOP%BlindRamDiam * 12.0 + data%State%PipeRam2%ODDrillpipe_in= data%State%TD_BOP%LowerRamDiam * 12.0 @@ -51,12 +53,12 @@ module BOP !IDPipeRam2Final !IDAnnularFinal - ShearRam%OpenArea_shearBop= PI*(ShearRam%IDshearBopFinal**2-ShearRam%ODDrillpipe_inShearRam**2)/4.0d0 !D(in), AREA(in^2) - ShearRam%OpenArea_PipeRam1= PI*(ShearRam%IDPipeRam1Final**2-PipeRam1%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2) - ShearRam%OpenArea_PipeRam2= PI*(ShearRam%IDPipeRam2Final**2-PipeRam2%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2) - ShearRam%OpenArea_Annular= PI*(ShearRam%IDAnnularFinal**2-Annular%ODDrillpipe_inAnnular**2)/4.0d0 !D(in), AREA(in^2) + data%State%ShearRAM%OpenArea_shearBop= PI*(data%State%ShearRAM%IDshearBopFinal**2-data%State%ShearRAM%ODDrillpipe_inShearRam**2)/4.0d0 !D(in), AREA(in^2) + data%State%ShearRAM%OpenArea_PipeRam1= PI*(data%State%ShearRAM%IDPipeRam1Final**2-data%State%PipeRam1%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2) + data%State%ShearRAM%OpenArea_PipeRam2= PI*(data%State%ShearRAM%IDPipeRam2Final**2-data%State%PipeRam2%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2) + data%State%ShearRAM%OpenArea_Annular= PI*(data%State%ShearRAM%IDAnnularFinal**2-data%State%Annular%ODDrillpipe_inAnnular**2)/4.0d0 !D(in), AREA(in^2) - ShearRam%MinimumOpenArea_InBOP= min(ShearRam%OpenArea_shearBop,ShearRam%OpenArea_PipeRam1,ShearRam%OpenArea_PipeRam2,ShearRam%OpenArea_Annular) + data%State%ShearRAM%MinimumOpenArea_InBOP= min(data%State%ShearRAM%OpenArea_shearBop,data%State%ShearRAM%OpenArea_PipeRam1,data%State%ShearRAM%OpenArea_PipeRam2,data%State%ShearRAM%OpenArea_Annular) !TD_BOPConnectionPossibility(j) = 0 or 1 @@ -67,89 +69,89 @@ module BOP !===================================================================== !============SEALING PRESSURES TO BE SET IN ANNULAR REGULATOR========== - AnnularComputational%WellBorePressure=5000. - if (Annular%ODDrillpipe_inAnnular>0.) then - if (Annular%ODDrillpipe_inAnnular>0. .and. Annular%ODDrillpipe_inAnnular<=1.99) then - AnnularComputational%acoef=-0.2673 - AnnularComputational%Bcoef=994.3 - AnnularComputational%const=77 - elseif (Annular%ODDrillpipe_inAnnular>1.99 .and. Annular%ODDrillpipe_inAnnular<=2.375) then - AnnularComputational%acoef=-0.2539 - AnnularComputational%Bcoef=994.3 - AnnularComputational%const=73.15 - elseif (Annular%ODDrillpipe_inAnnular>2.375 .and. Annular%ODDrillpipe_inAnnular<=2.875) then - AnnularComputational%acoef=-0.2005 - AnnularComputational%Bcoef=745.9 - AnnularComputational%const=57.75 - elseif (Annular%ODDrillpipe_inAnnular>2.875 .and. Annular%ODDrillpipe_inAnnular<=3.5) then - AnnularComputational%acoef=-0.1871 - AnnularComputational%Bcoef=696.1 - AnnularComputational%const=53.9 - elseif (Annular%ODDrillpipe_inAnnular>3.5 .and. Annular%ODDrillpipe_inAnnular<=5) then - AnnularComputational%acoef=-0.1733 - AnnularComputational%Bcoef=647 - AnnularComputational%const=50 - elseif (Annular%ODDrillpipe_inAnnular>5 .and. Annular%ODDrillpipe_inAnnular<=10) then - AnnularComputational%acoef=-0.1604 - AnnularComputational%Bcoef=596.7 - AnnularComputational%const=46.2 + data%State%AnnularComputational%WellBorePressure=5000. + if (data%State%Annular%ODDrillpipe_inAnnular>0.) then + if (data%State%Annular%ODDrillpipe_inAnnular>0. .and. data%State%Annular%ODDrillpipe_inAnnular<=1.99) then + data%State%AnnularComputational%acoef=-0.2673 + data%State%AnnularComputational%Bcoef=994.3 + data%State%AnnularComputational%const=77 + elseif (data%State%Annular%ODDrillpipe_inAnnular>1.99 .and. data%State%Annular%ODDrillpipe_inAnnular<=2.375) then + data%State%AnnularComputational%acoef=-0.2539 + data%State%AnnularComputational%Bcoef=994.3 + data%State%AnnularComputational%const=73.15 + elseif (data%State%Annular%ODDrillpipe_inAnnular>2.375 .and. data%State%Annular%ODDrillpipe_inAnnular<=2.875) then + data%State%AnnularComputational%acoef=-0.2005 + data%State%AnnularComputational%Bcoef=745.9 + data%State%AnnularComputational%const=57.75 + elseif (data%State%Annular%ODDrillpipe_inAnnular>2.875 .and. data%State%Annular%ODDrillpipe_inAnnular<=3.5) then + data%State%AnnularComputational%acoef=-0.1871 + data%State%AnnularComputational%Bcoef=696.1 + data%State%AnnularComputational%const=53.9 + elseif (data%State%Annular%ODDrillpipe_inAnnular>3.5 .and. data%State%Annular%ODDrillpipe_inAnnular<=5) then + data%State%AnnularComputational%acoef=-0.1733 + data%State%AnnularComputational%Bcoef=647 + data%State%AnnularComputational%const=50 + elseif (data%State%Annular%ODDrillpipe_inAnnular>5 .and. data%State%Annular%ODDrillpipe_inAnnular<=10) then + data%State%AnnularComputational%acoef=-0.1604 + data%State%AnnularComputational%Bcoef=596.7 + data%State%AnnularComputational%const=46.2 endif - AnnularComputational%AnnularSealingPressure= max((AnnularComputational%acoef*AnnularComputational%WellBorePressure+AnnularComputational%Bcoef), AnnularComputational%const) !(psi) + data%State%AnnularComputational%AnnularSealingPressure= max((data%State%AnnularComputational%acoef*data%State%AnnularComputational%WellBorePressure+data%State%AnnularComputational%Bcoef), data%State%AnnularComputational%const) !(psi) else !CSO(COMPLETE SHUT OFF) ODDrillpipe_inAnnular=0 - AnnularComputational%AnnularSealingPressure= 1150. !(psi) + data%State%AnnularComputational%AnnularSealingPressure= 1150. !(psi) endif !===================================================================== ! BYPASS POSITION !===================================================================== - if(BopControlPanel%ByePassValve == -1.0 .and. BopControlPanel%AirMasterValve==1) then - BopStackAcc%ByPassOld= -1.0 + if(data%EquipmentControl%BopControlPanel%ByePassValve == -1.0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then + data%State%BopStackAcc%ByPassOld= -1.0 !write(*,*) 'ByePassValve to -1' ,ByePassValve - elseif(BopControlPanel%ByePassValve == 1.0 .and. BopControlPanel%AirMasterValve==1) then - BopStackAcc%ByPassOld= 1.0 + elseif(data%EquipmentControl%BopControlPanel%ByePassValve == 1.0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then + data%State%BopStackAcc%ByPassOld= 1.0 !write(*,*) 'ByePassValve to 1=' ,ByePassValve endif !write(*,*) 'ByePassValve,ByPassOld=' ,ByePassValve,ByPassOld !===================================================================== !WRITE(*,*) 'AnnularRegulatorSetControl====' , AnnularRegulatorSetControl - Annular%Pannular_regset=min(BopControlPanel%AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously - if (Annular%Annular_closed==1) then - if (Annular%FirstSet==1) then ! code start - Annular%Pannular_reg= Annular%Pannular_regset + data%State%Annular%Pannular_regset=min(data%EquipmentControl%BopControlPanel%AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously + if (data%State%Annular%Annular_closed==1) then + if (data%State%Annular%FirstSet==1) then ! code start + data%State%Annular%Pannular_reg= data%State%Annular%Pannular_regset endif - if (Annular%FirstSet==0) then ! durig run, but annular is not closing or opening - Annular%Pannular_reg= min(RamLine%P_ACC,Annular%Pannular_regset) + if (data%State%Annular%FirstSet==0) then ! durig run, but annular is not closing or opening + data%State%Annular%Pannular_reg= min(data%State%RamLine%P_ACC,data%State%Annular%Pannular_regset) endif endif !=================================================================== ! Annular Preventer Pressure Rise On Tooljoint !=================================================================== - if ( Annular%Annular_Situation_forTD == 1 .and. TD_BOP%AnnularFillingFinal==0.0 ) then ! Annular_Situation_forTD= 1 ! closed - for TD code - AnnularComputational%AnnPressureRise= .true. - elseif ( Annular%Annular_Situation_forTD == 0 ) then - AnnularComputational%AnnPressureRise= .false. + if ( data%State%Annular%Annular_Situation_forTD == 1 .and. data%State%TD_BOP%AnnularFillingFinal==0.0 ) then ! Annular_Situation_forTD= 1 ! closed - for TD code + data%State%AnnularComputational%AnnPressureRise= .true. + elseif ( data%State%Annular%Annular_Situation_forTD == 0 ) then + data%State%AnnularComputational%AnnPressureRise= .false. endif - if (AnnularComputational%AnnPressureRise == .true.) then - Annular%Pannular_reg= Annular%Pannular_reg + 200. * TD_BOP%AnnularFillingFinal ! 200 psi pressure rise when 100% of AnnPreventer is filled by tool joint + if (data%State%AnnularComputational%AnnPressureRise == .true.) then + data%State%Annular%Pannular_reg= data%State%Annular%Pannular_reg + 200. * data%State%TD_BOP%AnnularFillingFinal ! 200 psi pressure rise when 100% of AnnPreventer is filled by tool joint !TD_AnnularFillingFinal ! (0.0 to 1.0) percentage filled by tool joint endif !=================================================================== - if (Annular%FirstSet== 1) then + if (data%State%Annular%FirstSet== 1) then !new= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.) - CALL AnnularComputational%Pannular_regDelay%AddToFirst( (1 - Annular%AnnularPressureGaugeMalf) * min(BopControlPanel%AnnularRegulatorSetControl,1700.) ) - CALL AnnularComputational%Pannular_regDelay%Remove(AnnularComputational%Pannular_regDelay%Length()) - BopControlPanel%AnnularPressureGauge= AnnularComputational%Pannular_regDelay%Last() + CALL data%State%AnnularComputational%Pannular_regDelay%AddToFirst( (1 - data%State%Annular%AnnularPressureGaugeMalf) * min(data%EquipmentControl%BopControlPanel%AnnularRegulatorSetControl,1700.) ) + CALL data%State%AnnularComputational%Pannular_regDelay%Remove(data%State%AnnularComputational%Pannular_regDelay%Length()) + data%EquipmentControl%BopControlPanel%AnnularPressureGauge= data%State%AnnularComputational%Pannular_regDelay%Last() !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.) !write(*,*) 'set 1' , AnnularPressureGauge else !FirstSet== 0 !new= (1 - AnnularPressureGaugeMalf) * Pannular_reg - CALL AnnularComputational%Pannular_regDelay%AddToFirst( (1 - Annular%AnnularPressureGaugeMalf) * Annular%Pannular_reg) - CALL AnnularComputational%Pannular_regDelay%Remove(AnnularComputational%Pannular_regDelay%Length()) - BopControlPanel%AnnularPressureGauge= AnnularComputational%Pannular_regDelay%Last() + CALL data%State%AnnularComputational%Pannular_regDelay%AddToFirst( (1 - data%State%Annular%AnnularPressureGaugeMalf) * data%State%Annular%Pannular_reg) + CALL data%State%AnnularComputational%Pannular_regDelay%Remove(data%State%AnnularComputational%Pannular_regDelay%Length()) + data%EquipmentControl%BopControlPanel%AnnularPressureGauge= data%State%AnnularComputational%Pannular_regDelay%Last() !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * Pannular_reg !write(*,*) 'set 0' , AnnularPressureGauge endif @@ -157,122 +159,122 @@ module BOP !=================================================== ! AIR OPERATED PUMP CODE- START !=================================================== - if (RamLine%P_ACCPumps%AIR_OFF .and. RamLine%AIRP_SWITCH==1) then - RamLine%AIRP_SWITCH=0 - call SetSoundKoomeyAirPump(RamLine%AIRP_SWITCH) + if (data%State%RamLine%P_ACC>data%State%Pumps%AIR_OFF .and. data%State%RamLine%AIRP_SWITCH==1) then + data%State%RamLine%AIRP_SWITCH=0 + call SetSoundKoomeyAirPump(data%State%RamLine%AIRP_SWITCH) endif - if (RamLine%P_ACCPumps%ELECTRIC_OFF .and. RamLine%ELECP_SWITCH==1) then - RamLine%ELECP_SWITCH=0 + if (data%State%RamLine%P_ACC>data%State%Pumps%ELECTRIC_OFF .and. data%State%RamLine%ELECP_SWITCH==1) then + data%State%RamLine%ELECP_SWITCH=0 endif !write(*,*) 'airp_switch,elecp_switch=' , airp_switch,elecp_switch !================CHARGING BOTTLES======================= - if (RamLine%AIRP_SWITCH==1 .or. RamLine%ELECP_SWITCH==1) then - if (Annular%Annular_closed==1 .and. RamLine%ShearBop_closed==1 .and. PipeRam1%closed==1 .and. PipeRam2%closed==1 .and. ChokeLine%closed==1 .and. KillLine%closed==1) then + if (data%State%RamLine%AIRP_SWITCH==1 .or. data%State%RamLine%ELECP_SWITCH==1) then + if (data%State%Annular%Annular_closed==1 .and. data%State%RamLine%ShearBop_closed==1 .and. data%State%PipeRam1%closed==1 .and. data%State%PipeRam2%closed==1 .and. data%State%ChokeLine%closed==1 .and. data%State%KillLine%closed==1) then call pumps_charge_bottle() ! increases volume and pressure in the bottles - if (RamLine%P_ACC>BopStackAcc%acc_ChargedPressure) then - RamLine%P_ACC=BopStackAcc%acc_ChargedPressure - if (Annular%AnnularLeakMalf== 0) then + if (data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_ChargedPressure) then + data%State%RamLine%P_ACC=data%State%BopStackAcc%acc_ChargedPressure + if (data%State%Annular%AnnularLeakMalf== 0) then !finished_Annular=1 - RAM(1)%Bottles_Charged_MalfActive= .false. + data%State%RAM(1)%Bottles_Charged_MalfActive= .false. else - Annular%finished_Annular=0 - RAM(1)%Bottles_Charged_MalfActive= .true. + data%State%Annular%finished_Annular=0 + data%State%RAM(1)%Bottles_Charged_MalfActive= .true. !fvr=fvr-2.5 endif - if (PipeRam1%UpperRamsLeakMalf== 0) then + if (data%State%PipeRam1%UpperRamsLeakMalf== 0) then !finished_pipe1=1 - RAM(2)%Bottles_Charged_MalfActive= .false. + data%State%RAM(2)%Bottles_Charged_MalfActive= .false. else - PipeRam1%finished=0 - RAM(2)%Bottles_Charged_MalfActive= .true. + data%State%PipeRam1%finished=0 + data%State%RAM(2)%Bottles_Charged_MalfActive= .true. !fvr=fvr-2.5 endif - if (PipeRam2%LowerRamsLeakMalf== 0) then + if (data%State%PipeRam2%LowerRamsLeakMalf== 0) then !finished_pipe2=1 - RAM(3)%Bottles_Charged_MalfActive= .false. + data%State%RAM(3)%Bottles_Charged_MalfActive= .false. else - PipeRam2%finished=0 - RAM(3)%Bottles_Charged_MalfActive= .true. + data%State%PipeRam2%finished=0 + data%State%RAM(3)%Bottles_Charged_MalfActive= .true. !fvr=fvr-2.5 endif - if (ShearRam%MiddleRamsLeakMalf== 0) then + if (data%State%ShearRAM%MiddleRamsLeakMalf== 0) then !finished_shear=1 - RAM(4)%Bottles_Charged_MalfActive= .false. + data%State%RAM(4)%Bottles_Charged_MalfActive= .false. else - RamLine%FINISHED_shear=0 - RAM(4)%Bottles_Charged_MalfActive= .true. + data%State%RamLine%FINISHED_shear=0 + data%State%RAM(4)%Bottles_Charged_MalfActive= .true. !fvr=fvr-2.5 endif - KillLine%finished=1 - ChokeLine%finished=1 + data%State%KillLine%finished=1 + data%State%ChokeLine%finished=1 - if (Annular%AnnularLeakMalf== 0 .and. PipeRam1%UpperRamsLeakMalf== 0 .and. PipeRam2%LowerRamsLeakMalf== 0 .and. ShearRam%MiddleRamsLeakMalf== 0) then - RamLine%ELECP_SWITCH=0 - RamLine%AIRP_SWITCH=0 + if (data%State%Annular%AnnularLeakMalf== 0 .and. data%State%PipeRam1%UpperRamsLeakMalf== 0 .and. data%State%PipeRam2%LowerRamsLeakMalf== 0 .and. data%State%ShearRAM%MiddleRamsLeakMalf== 0) then + data%State%RamLine%ELECP_SWITCH=0 + data%State%RamLine%AIRP_SWITCH=0 endif endif endif endif !======================================================= - if (RamLine%ELECP_SWITCH==1 .and. BopStackAcc%AccPupmsFailMalf==0) then !on position - Pumps%DELTAV_ELECP=Pumps%QELECTRIC*RamLine%DeltaT_BOP/60. !QELECTRIC_PUMP(gpm), deltav_elecp(gal), DeltaT_BOP(0.1 sec) - Pumps%SoundKoomeyElectric= .True. + if (data%State%RamLine%ELECP_SWITCH==1 .and. data%State%BopStackAcc%AccPupmsFailMalf==0) then !on position + data%State%Pumps%DELTAV_ELECP=data%State%Pumps%QELECTRIC*data%State%RamLine%DeltaT_BOP/60. !QELECTRIC_PUMP(gpm), deltav_elecp(gal), DeltaT_BOP(0.1 sec) + data%State%Pumps%SoundKoomeyElectric= .True. else - Pumps%DELTAV_ELECP=0 - Pumps%SoundKoomeyElectric= .false. + data%State%Pumps%DELTAV_ELECP=0 + data%State%Pumps%SoundKoomeyElectric= .false. endif !call SetSoundKoomeyElectricPump(SoundKoomeyElectricPump) - if (RamLine%AIRP_SWITCH==1 .and. BopStackAcc%AccPupmsFailMalf==0) then !on position + if (data%State%RamLine%AIRP_SWITCH==1 .and. data%State%BopStackAcc%AccPupmsFailMalf==0) then !on position call airpump_code() !ramtype=2 end if ! if (airp_switch==1) then !on position !===============AIR OPERATED PUMP CODE- END================ - if (RamLine%ShearBop_closed==1 .and. PipeRam1%closed==1 .and. PipeRam2%closed==1 .and. ChokeLine%closed==1 .and. KillLine%closed==1) then + if (data%State%RamLine%ShearBop_closed==1 .and. data%State%PipeRam1%closed==1 .and. data%State%PipeRam2%closed==1 .and. data%State%ChokeLine%closed==1 .and. data%State%KillLine%closed==1) then !write(*,*) ' All Rams are closed' - if(BopStackAcc%ByPassOld== -1.0) then ! (OPEN POSITION) + if(data%State%BopStackAcc%ByPassOld== -1.0) then ! (OPEN POSITION) !old=pram_reg - !new=p_acc- MAXVAL(RAM%loss_before) + !new=p_acc- MAXVAL(data%State%RAM%loss_before) !difference= new-old - BopStackAcc%PressureDifference= RamLine%P_ACC- MAXVAL(RAM%loss_before) - BopStackAcc%pram_reg - if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 300. psi - BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. + data%State%BopStackAcc%PressureDifference= data%State%RamLine%P_ACC- MAXVAL(data%State%RAM%loss_before) - data%State%BopStackAcc%pram_reg + if (ABS(data%State%BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 300. psi + data%State%BopStackAcc%pram_reg= data%State%BopStackAcc%pram_reg + (data%State%BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. else - BopStackAcc%pram_reg= RamLine%P_ACC- MAXVAL(RAM%loss_before) ! mishe khate paeen ye shart gozasht ke pacc=3000 shod, in adad dige kam nashe + data%State%BopStackAcc%pram_reg= data%State%RamLine%P_ACC- MAXVAL(data%State%RAM%loss_before) ! mishe khate paeen ye shart gozasht ke pacc=3000 shod, in adad dige kam nashe endif - elseif (BopStackAcc%ByPassOld== 1.0) then ! (CLOSE POSITION) + elseif (data%State%BopStackAcc%ByPassOld== 1.0) then ! (CLOSE POSITION) !pram_reg= prams_regset !if (RamsFirstSet==1) then !write(*,*) 'bypass CLOSE POSITION' !old=pram_reg !new=prams_regset !difference= new-old - BopStackAcc%PressureDifference= BopStackAcc%PRAMS_REGSET - BopStackAcc%pram_reg + data%State%BopStackAcc%PressureDifference= data%State%BopStackAcc%PRAMS_REGSET - data%State%BopStackAcc%pram_reg !write(*,*) 'PressureDifference, prams_regset , pram_reg=' , PressureDifference, prams_regset , pram_reg - if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 200. ! psi in starup - BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. in startup + if (ABS(data%State%BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 200. ! psi in starup + data%State%BopStackAcc%pram_reg= data%State%BopStackAcc%pram_reg + (data%State%BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. in startup else - BopStackAcc%pram_reg= BopStackAcc%PRAMS_REGSET + data%State%BopStackAcc%pram_reg= data%State%BopStackAcc%PRAMS_REGSET endif !write(*,*) 'pram_reg=' , pram_reg @@ -282,16 +284,16 @@ module BOP endif - BopControlPanel%MiddleRamsStatus = ShearRam%IDshearBop - BopControlPanel%UpperRamsStatus = PipeRam1%ID - BopControlPanel%LowerRamsStatus = PipeRam2%ID - BopControlPanel%AnnularStatus = Annular%IDAnnular - BopControlPanel%AccumulatorPressureGauge = (1 - BopStackAcc%AccumulatorPressureGaugeMalf) * RamLine%P_ACC - BopControlPanel%ManifoldPressureGauge= (1 - BopStackAcc%ManifoldPressureGaugeMalf) * BopStackAcc%pram_reg + data%EquipmentControl%BopControlPanel%MiddleRamsStatus = data%State%ShearRAM%IDshearBop + data%EquipmentControl%BopControlPanel%UpperRamsStatus = data%State%PipeRam1%ID + data%EquipmentControl%BopControlPanel%LowerRamsStatus = data%State%PipeRam2%ID + data%EquipmentControl%BopControlPanel%AnnularStatus = data%State%Annular%IDAnnular + data%EquipmentControl%BopControlPanel%AccumulatorPressureGauge = (1 - data%State%BopStackAcc%AccumulatorPressureGaugeMalf) * data%State%RamLine%P_ACC + data%EquipmentControl%BopControlPanel%ManifoldPressureGauge= (1 - data%State%BopStackAcc%ManifoldPressureGaugeMalf) * data%State%BopStackAcc%pram_reg !AnnularPressureGauge=Pannular_reg ! - ! WRITE(60,60) RAM(2)%time,RAM(2)%Q,RAM(2)%vdis_tot,p_acc, & - ! pram_reg,Pannular_reg,RAM(2)%p_bop,IDshearBop, & + ! WRITE(60,60) data%State%RAM(2)%time,data%State%RAM(2)%Q,data%State%RAM(2)%vdis_tot,p_acc, & + ! pram_reg,Pannular_reg,data%State%RAM(2)%p_bop,IDshearBop, & ! IDPipeRam1,IDPipeRam2,IDAnnular !60 FORMAT(11(f18.5)) !WRITE(*,*) 'IDAnnular=' , IDAnnular diff --git a/Equipments/BopStack/BOPstartup.f90 b/Equipments/BopStack/BOPstartup.f90 index c4a44c9..c9770f3 100644 --- a/Equipments/BopStack/BOPstartup.f90 +++ b/Equipments/BopStack/BOPstartup.f90 @@ -1,9 +1,10 @@ SUBROUTINE BOP_StartUp() -USE VARIABLES +use ConfigurationVariables USE CAccumulatorVariables USE CBopStackVariables -USE CBopControlPanelVariables +use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants implicit none @@ -22,7 +23,7 @@ integer i !AirSupplyPressureGauge=0 !======================= SETTING VARIABLES -BopStackInput%BOP_timeCounter= 0 +data%State%BopStackInput%BOP_timeCounter= 0 !============== FOR MANIFOLD VALVES CODE===================== CALL OpenAnnular @@ -32,10 +33,10 @@ CALL CloseKillLine CALL CloseChokeLine CALL OpenLowerRams -Annular%Annular_Situation_forTD= 0 ! open - for TD code -RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code -PipeRam1%Situation_forTD= 0 ! open - for TD code -PipeRam2%Situation_forTD= 0 ! open - for TD code +data%State%Annular%Annular_Situation_forTD= 0 ! open - for TD code +data%State%RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code +data%State%PipeRam1%Situation_forTD= 0 ! open - for TD code +data%State%PipeRam2%Situation_forTD= 0 ! open - for TD code !====================================================================== CALL LOSS_INPUTS() @@ -46,19 +47,19 @@ CALL LOSS_INPUTS() ! GET INPUTS !====================================================================== -RAM%SuccessionCounter = 0 -RAM%SuccessionCounterOld = 0 +data%State%RAM%SuccessionCounter = 0 +data%State%RAM%SuccessionCounterOld = 0 -RAM%First_CloseTimecheck= 0 -RAM%First_OpenTimecheck= 0 +data%State%RAM%First_CloseTimecheck= 0 +data%State%RAM%First_OpenTimecheck= 0 -BopStackAcc%Cumulative_AirVolume= 0.0 +data%State%BopStackAcc%Cumulative_AirVolume= 0.0 -BopStackAcc%BOTTLE_CAPACITY=10 !(GALON) -BopStackAcc%NOBOTTLES=Accumulator%NumberOfBottels +data%State%BopStackAcc%BOTTLE_CAPACITY=10 !(GALON) +data%State%BopStackAcc%NOBOTTLES=Accumulator%NumberOfBottels @@ -67,82 +68,82 @@ BopStackAcc%NOBOTTLES=Accumulator%NumberOfBottels !fvr_tot=40 !(GALON) IN CHARGED POSITION -BopStackAcc%PRAMS_REGSET=1500 !RamsReglatorSet !=1500 DEFAULT regulator set pressure (PSI) -BopStackAcc%acc_ChargedPressure=3000 !charged(PSI) -BopStackAcc%acc_MinPressure=Accumulator%AccumulatorMinimumOperatingPressure !1200 !discharged(PSI) +data%State%BopStackAcc%PRAMS_REGSET=1500 !RamsReglatorSet !=1500 DEFAULT regulator set pressure (PSI) +data%State%BopStackAcc%acc_ChargedPressure=3000 !charged(PSI) +data%State%BopStackAcc%acc_MinPressure=Accumulator%AccumulatorMinimumOperatingPressure !1200 !discharged(PSI) !acc_precharge=1000 -BopStackAcc%FVR_TOT=(-2451*(BopStackAcc%acc_ChargedPressure**(-0.8202))+8.435)*BopStackAcc%NOBOTTLES ! IT IS WRRITEN FOR PRECHARGE 1000 PSI FROM ITS CURVE +data%State%BopStackAcc%FVR_TOT=(-2451*(data%State%BopStackAcc%acc_ChargedPressure**(-0.8202))+8.435)*data%State%BopStackAcc%NOBOTTLES ! IT IS WRRITEN FOR PRECHARGE 1000 PSI FROM ITS CURVE !write(*,*) 'fvr_tot=',fvr_tot !ELECTRIC_PUMPON=2800 -Pumps%ELECTRIC_ON=Accumulator%StartPressure +data%State%Pumps%ELECTRIC_ON=Accumulator%StartPressure !ELECTRIC_PUMPOFF=acc_ChargedPressure !=3000 psi -Pumps%ELECTRIC_OFF=Accumulator%StopPressure +data%State%Pumps%ELECTRIC_OFF=Accumulator%StopPressure !QELECTRIC_PUMP=12 !(gpm) -Pumps%QELECTRIC=Accumulator%ElectricPumpOutput +data%State%Pumps%QELECTRIC=Accumulator%ElectricPumpOutput !AIR_PUMPON=2600 -Pumps%AIR_ON=Accumulator%StartPressure2 +data%State%Pumps%AIR_ON=Accumulator%StartPressure2 !AIR_PUMPOFF=2900 -Pumps%AIR_OFF=Accumulator%StopPressure2 +data%State%Pumps%AIR_OFF=Accumulator%StopPressure2 -RAM%tol=0.0037 !%=(2700-2600)/2700 -RAM%tolzero=RAM%tol +data%State%RAM%tol=0.0037 !%=(2700-2600)/2700 +data%State%RAM%tolzero=data%State%RAM%tol -Annular%tolAnnular=0.0018 !=(2900-2895)/2900 -Annular%tolzeroAnnular=Annular%tolAnnular +data%State%Annular%tolAnnular=0.0018 !=(2900-2895)/2900 +data%State%Annular%tolzeroAnnular=data%State%Annular%tolAnnular !======================OTHER INPUTS(CONSTANTS)=========================== -ShearRam%PA=300 !(PSI) -ShearRam%P_SHEAR=1200 !(PSI) +data%State%ShearRAM%PA=300 !(PSI) +data%State%ShearRAM%P_SHEAR=1200 !(PSI) !p_shear=2423.1 !(PSI) -ShearRam%PB=ShearRam%P_SHEAR-ShearRam%PA -AnnularComputational%pa_annular=100 !(psi) +data%State%ShearRAM%PB=data%State%ShearRAM%P_SHEAR-data%State%ShearRAM%PA +data%State%AnnularComputational%pa_annular=100 !(psi) -Annular%IDAnnularBase=13.625 !(inch) -Annular%IDAnnular=Annular%IDAnnularBase -Annular%ODDrillpipe_inAnnularBase=5. ! so 18 gal is for complete closing of annular -Annular%ODDrillpipe_inAnnular=5. ! initial -AnnularComputational%AnnularMovingPressure=360. !(psi) -ShearRam%IDAnnularFinal= Annular%IDAnnular +data%State%Annular%IDAnnularBase=13.625 !(inch) +data%State%Annular%IDAnnular=data%State%Annular%IDAnnularBase +data%State%Annular%ODDrillpipe_inAnnularBase=5. ! so 18 gal is for complete closing of annular +data%State%Annular%ODDrillpipe_inAnnular=5. ! initial +data%State%AnnularComputational%AnnularMovingPressure=360. !(psi) +data%State%ShearRAM%IDAnnularFinal= data%State%Annular%IDAnnular -ShearRam%IDshearBopBase=13.625 !(inch) -ShearRam%IDshearBop=ShearRam%IDshearBopBase -ShearRam%ODDrillpipe_inShearRamBase=5 !initial -ShearRam%ODDrillpipe_inShearRam=5 !initial -ShearRam%IDshearBopFinal= ShearRam%IDshearBop +data%State%ShearRAM%IDshearBopBase=13.625 !(inch) +data%State%ShearRAM%IDshearBop=data%State%ShearRAM%IDshearBopBase +data%State%ShearRAM%ODDrillpipe_inShearRamBase=5 !initial +data%State%ShearRAM%ODDrillpipe_inShearRam=5 !initial +data%State%ShearRAM%IDshearBopFinal= data%State%ShearRAM%IDshearBop -PipeRam1%IDBase=13.625 !(inch) -PipeRam1%ID=PipeRam1%IDBase -PipeRam1%ODDrillpipe_inBase=5 !initial -PipeRam1%ODDrillpipe_in=5 !initial -ShearRam%IDPipeRam1Final= PipeRam1%ID +data%State%PipeRam1%IDBase=13.625 !(inch) +data%State%PipeRam1%ID=data%State%PipeRam1%IDBase +data%State%PipeRam1%ODDrillpipe_inBase=5 !initial +data%State%PipeRam1%ODDrillpipe_in=5 !initial +data%State%ShearRAM%IDPipeRam1Final= data%State%PipeRam1%ID -PipeRam2%ID=PipeRam1%IDBase !(inch) -PipeRam2%ODDrillpipe_inBase=5 !initial -PipeRam2%ODDrillpipe_in=5 !initial -ShearRam%IDPipeRam2Final= PipeRam2%ID +data%State%PipeRam2%ID=data%State%PipeRam1%IDBase !(inch) +data%State%PipeRam2%ODDrillpipe_inBase=5 !initial +data%State%PipeRam2%ODDrillpipe_in=5 !initial +data%State%ShearRAM%IDPipeRam2Final= data%State%PipeRam2%ID -ChokeLine%IDBase=8.6 !(inch) -ChokeLine%ID=ChokeLine%IDBase -ChokeLine%ODDrillpipe_inBase=5 -ChokeLine%ODDrillpipe_in=5 +data%State%ChokeLine%IDBase=8.6 !(inch) +data%State%ChokeLine%ID=data%State%ChokeLine%IDBase +data%State%ChokeLine%ODDrillpipe_inBase=5 +data%State%ChokeLine%ODDrillpipe_in=5 -KillLine%IDBase=8.6 !(inch) -KillLine%ID=KillLine%IDBase -KillLine%ODDrillpipe_inBase=5 -KillLine%ODDrillpipe_in=5 +data%State%KillLine%IDBase=8.6 !(inch) +data%State%KillLine%ID=data%State%KillLine%IDBase +data%State%KillLine%ODDrillpipe_inBase=5 +data%State%KillLine%ODDrillpipe_in=5 !va=4 !(liter) @@ -150,102 +151,102 @@ KillLine%ODDrillpipe_in=5 !cv=2; !flow coefficinet of regulator -ShearRam%RAM_COURSE=320.2 !milimeter -ShearRam%H_REGRAM=0 !(m)<<<<<<<<<<<<<<<<<<<<<<<< -ShearRam%H_ShearRamBop=(BopStackSpecification%GroundLevel-BopStackSpecification%BlindRamHeight)*0.3048 ! foot to meter -PipeRam1%H=(BopStackSpecification%GroundLevel-BopStackSpecification%UpperRamHeight)*0.3048 ! foot to meter -PipeRam2%H_Bop=(BopStackSpecification%GroundLevel-BopStackSpecification%LowerRamHeight)*0.3048 ! foot to meter -Annular%H_AnnularBop=(BopStackSpecification%GroundLevel-BopStackSpecification%AnnularPreventerHeight)*0.3048 ! foot to meter -ChokeLine%H_Bop=(BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight)*0.3048 ! foot to meter -KillLine%H_Bop=(BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight)*0.3048 ! foot to meter +data%State%ShearRAM%RAM_COURSE=320.2 !milimeter +data%State%ShearRAM%H_REGRAM=0 !(m)<<<<<<<<<<<<<<<<<<<<<<<< +data%State%ShearRAM%H_ShearRamBop=(BopStackSpecification%GroundLevel-BopStackSpecification%BlindRamHeight)*0.3048 ! foot to meter +data%State%PipeRam1%H=(BopStackSpecification%GroundLevel-BopStackSpecification%UpperRamHeight)*0.3048 ! foot to meter +data%State%PipeRam2%H_Bop=(BopStackSpecification%GroundLevel-BopStackSpecification%LowerRamHeight)*0.3048 ! foot to meter +data%State%Annular%H_AnnularBop=(BopStackSpecification%GroundLevel-BopStackSpecification%AnnularPreventerHeight)*0.3048 ! foot to meter +data%State%ChokeLine%H_Bop=(BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight)*0.3048 ! foot to meter +data%State%KillLine%H_Bop=(BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight)*0.3048 ! foot to meter -RamLine%P_ACC=BopStackAcc%acc_ChargedPressure -RAM%vdis_bottles=0 !initial discharged volume -RamLine%FVR=BopStackAcc%FVR_TOT -RAMS%minloss=0. +data%State%RamLine%P_ACC=data%State%BopStackAcc%acc_ChargedPressure +data%State%RAM%vdis_bottles=0 !initial discharged volume +data%State%RamLine%FVR=data%State%BopStackAcc%FVR_TOT +data%State%RAMS%minloss=0. !======================AIRPUMP INPUTS(CONSTANTS)=========================== -RAM%FVR_AIR=0 -Pumps%P_AIRP=0 +data%State%RAM%FVR_AIR=0 +data%State%Pumps%P_AIRP=0 -RamLine%BA1=1003; RamLine%BA2=.03375; RamLine%BA3=4.014; RamLine%BA4=.2458 -RamLine%BBA1 =31.8; RamLine%BBA2 =-725.7 ; RamLine%BBA3 =4154 +data%State%RamLine%BA1=1003; data%State%RamLine%BA2=.03375; data%State%RamLine%BA3=4.014; data%State%RamLine%BA4=.2458 +data%State%RamLine%BBA1 =31.8; data%State%RamLine%BBA2 =-725.7 ; data%State%RamLine%BBA3 =4154 -Pumps%Qiter=7 !(gpm) +data%State%Pumps%Qiter=7 !(gpm) ! Q=0.0003585; true -RamLine%DeltaT_BOP=0.1 !second -Pumps%TOL_AIR=.08 +data%State%RamLine%DeltaT_BOP=0.1 !second +data%State%Pumps%TOL_AIR=.08 -Pumps%alpha_Qair=0 -Pumps%alpha_timeair=0 -Pumps%alpha_paccair=RamLine%P_ACC -Pumps%alpha_pairp=RamLine%P_ACC -Pumps%alpha_diffpair=0 -Pumps%alpha_lossesair=0 -Pumps%alpha_fvrair=0 +data%State%Pumps%alpha_Qair=0 +data%State%Pumps%alpha_timeair=0 +data%State%Pumps%alpha_paccair=data%State%RamLine%P_ACC +data%State%Pumps%alpha_pairp=data%State%RamLine%P_ACC +data%State%Pumps%alpha_diffpair=0 +data%State%Pumps%alpha_lossesair=0 +data%State%Pumps%alpha_fvrair=0 -RamLine%counter_airp=1 +data%State%RamLine%counter_airp=1 !======================BOP INPUTS(CONSTANTS)=========================== if (Accumulator%PrechargePressure == 1400.) then - RamLine%B1=1396; RamLine%B2=0.17; RamLine%B3=3.873; RamLine%B4=1.101 + data%State%RamLine%B1=1396; data%State%RamLine%B2=0.17; data%State%RamLine%B3=3.873; data%State%RamLine%B4=1.101 elseif (Accumulator%PrechargePressure == 2000.) then - RamLine%B1=1980; RamLine%B2=0.1237; RamLine%B3=15.69; RamLine%B4=1.029 + data%State%RamLine%B1=1980; data%State%RamLine%B2=0.1237; data%State%RamLine%B3=15.69; data%State%RamLine%B4=1.029 elseif (Accumulator%PrechargePressure == 600.) then - RamLine%B1=591.9; RamLine%B2=0.1968; RamLine%B3=2.887; RamLine%B4=0.9757 + data%State%RamLine%B1=591.9; data%State%RamLine%B2=0.1968; data%State%RamLine%B3=2.887; data%State%RamLine%B4=0.9757 else !(PrechargePressure == 1000.) then ! this is for precharge=1000 psi - RamLine%B1=993.7; RamLine%B2=0.164; RamLine%B3=5.492; RamLine%B4=0.9796 + data%State%RamLine%B1=993.7; data%State%RamLine%B2=0.164; data%State%RamLine%B3=5.492; data%State%RamLine%B4=0.9796 endif -BopStackAcc%ByPassOld= 1.0 +data%State%BopStackAcc%ByPassOld= 1.0 -RAM%p_bop=ShearRam%PA -AnnularComputational%p_annular=AnnularComputational%pa_annular +data%State%RAM%p_bop=data%State%ShearRAM%PA +data%State%AnnularComputational%p_annular=data%State%AnnularComputational%pa_annular !Q=0.0055; !initial flow rate (m^3/s) -RAM%flow=60 !(gpm) initial value -RAM%Qzero=70 !for DP code, increasing Q after shear -RAM%vdis_tot=0 -RamLine%AIRP_SWITCH=0 !off position -RamLine%ELECP_SWITCH=0 !off position -RamLine%ShearBop_closed=1 -PipeRam1%closed=1 -PipeRam2%closed=1 -ChokeLine%closed=1 -KillLine%closed=1 -Annular%Annular_closed=1 -RamLine%FINISHED_shear=0 -PipeRam1%finished=0 -PipeRam2%finished=0 -ChokeLine%finished=0 -KillLine%finished=0 -Annular%finished_Annular=0 -Pumps%DELTAV_ELECP=0 -RAM%vdis_elecp=0 +data%State%RAM%flow=60 !(gpm) initial value +data%State%RAM%Qzero=70 !for DP code, increasing Q after shear +data%State%RAM%vdis_tot=0 +data%State%RamLine%AIRP_SWITCH=0 !off position +data%State%RamLine%ELECP_SWITCH=0 !off position +data%State%RamLine%ShearBop_closed=1 +data%State%PipeRam1%closed=1 +data%State%PipeRam2%closed=1 +data%State%ChokeLine%closed=1 +data%State%KillLine%closed=1 +data%State%Annular%Annular_closed=1 +data%State%RamLine%FINISHED_shear=0 +data%State%PipeRam1%finished=0 +data%State%PipeRam2%finished=0 +data%State%ChokeLine%finished=0 +data%State%KillLine%finished=0 +data%State%Annular%finished_Annular=0 +data%State%Pumps%DELTAV_ELECP=0 +data%State%RAM%vdis_elecp=0 !================================================================== -RAM%timecounter_ram=0 -RAM%Q=0 -BopStackAcc%pram_reg=BopStackAcc%PRAMS_REGSET !psi !RamsReglatorSet -Annular%Pannular_reg=min(BopControlPanel%AnnularRegulatorSetControl,1700.) +data%State%RAM%timecounter_ram=0 +data%State%RAM%Q=0 +data%State%BopStackAcc%pram_reg=data%State%BopStackAcc%PRAMS_REGSET !psi !RamsReglatorSet +data%State%Annular%Pannular_reg=min(data%EquipmentControl%BopControlPanel%AnnularRegulatorSetControl,1700.) -BopControlPanel%MiddleRamsStatus= ShearRam%IDshearBop -BopControlPanel%UpperRamsStatus= PipeRam1%ID -BopControlPanel%LowerRamsStatus= PipeRam2%ID -BopControlPanel%AnnularStatus = Annular%IDAnnular +data%EquipmentControl%BopControlPanel%MiddleRamsStatus= data%State%ShearRAM%IDshearBop +data%EquipmentControl%BopControlPanel%UpperRamsStatus= data%State%PipeRam1%ID +data%EquipmentControl%BopControlPanel%LowerRamsStatus= data%State%PipeRam2%ID +data%EquipmentControl%BopControlPanel%AnnularStatus = data%State%Annular%IDAnnular -BopControlPanel%AccumulatorPressureGauge = RamLine%P_ACC +data%EquipmentControl%BopControlPanel%AccumulatorPressureGauge = data%State%RamLine%P_ACC -RAM%time=0 +data%State%RAM%time=0 ! WRITE(60,10) ' Overal Time','Q Ram Line','Vdis Ram Line','P Accumulator','Preg Ram Line','Preg Annular',' P BOP','ID Shear Ram', & ! 'ID Pipe Ram1','ID Pipe Ram2','ID Annular' @@ -253,69 +254,69 @@ RAM%time=0 ! ! ! -! WRITE(60,60) RAM(2)%time,RAM(2)%Q,RAM(2)%vdis_tot,p_acc, & -! pram_reg,Pannular_reg,RAM(2)%p_bop,IDshearBop, & +! WRITE(60,60) data%State%RAM(2)%time,data%State%RAM(2)%Q,data%State%RAM(2)%vdis_tot,p_acc, & +! pram_reg,Pannular_reg,data%State%RAM(2)%p_bop,IDshearBop, & ! IDPipeRam1,IDPipeRam2,IDAnnular !60 FORMAT(11(f18.5)) - BopControlPanel%MiddleRamsOpenLED = LedOn - BopStackInput%MiddleRamsOpenLEDMine = LedOn - BopControlPanel%MiddleRamsCloseLED = LedOff - BopStackInput%MiddleRamsCloseLEDMine = LedOff - RamLine%ShearRamIsOpening = .false. - RamLine%ShearRamIsClosing = .false. + data%EquipmentControl%BopControlPanel%MiddleRamsOpenLED = LedOn + data%State%BopStackInput%MiddleRamsOpenLEDMine = LedOn + data%EquipmentControl%BopControlPanel%MiddleRamsCloseLED = LedOff + data%State%BopStackInput%MiddleRamsCloseLEDMine = LedOff + data%State%RamLine%ShearRamIsOpening = .false. + data%State%RamLine%ShearRamIsClosing = .false. - BopControlPanel%UpperRamsOpenLED = LedOn - BopStackInput%UpperRamsOpenLEDMine = LedOn - BopControlPanel%UpperRamsCloseLED = LedOff - BopStackInput%UpperRamsCloseLEDMine = LedOff - PipeRam1%IsOpening = .false. - PipeRam1%IsClosing = .false. + data%EquipmentControl%BopControlPanel%UpperRamsOpenLED = LedOn + data%State%BopStackInput%UpperRamsOpenLEDMine = LedOn + data%EquipmentControl%BopControlPanel%UpperRamsCloseLED = LedOff + data%State%BopStackInput%UpperRamsCloseLEDMine = LedOff + data%State%PipeRam1%IsOpening = .false. + data%State%PipeRam1%IsClosing = .false. - BopControlPanel%LowerRamsOpenLED = LedOn - BopStackInput%LowerRamsOpenLEDMine = LedOn - BopControlPanel%LowerRamsCloseLED = LedOff - BopStackInput%LowerRamsCloseLEDMine = LedOff - PipeRam2%IsOpening = .false. - PipeRam2%IsClosing = .false. + data%EquipmentControl%BopControlPanel%LowerRamsOpenLED = LedOn + data%State%BopStackInput%LowerRamsOpenLEDMine = LedOn + data%EquipmentControl%BopControlPanel%LowerRamsCloseLED = LedOff + data%State%BopStackInput%LowerRamsCloseLEDMine = LedOff + data%State%PipeRam2%IsOpening = .false. + data%State%PipeRam2%IsClosing = .false. - BopControlPanel%ChokeLineOpenLED = LedOff - BopStackInput%ChokeLineOpenLEDMine = LedOff - BopControlPanel%ChokeLineCloseLED = LedOn - BopStackInput%ChokeLineCloseLEDMine = LedOn - ChokeLine%IsOpening = .false. - ChokeLine%IsClosing = .false. + data%EquipmentControl%BopControlPanel%ChokeLineOpenLED = LedOff + data%State%BopStackInput%ChokeLineOpenLEDMine = LedOff + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOn + data%State%BopStackInput%ChokeLineCloseLEDMine = LedOn + data%State%ChokeLine%IsOpening = .false. + data%State%ChokeLine%IsClosing = .false. - BopControlPanel%KillLineOpenLED = LedOff - BopStackInput%KillLineOpenLedMine = LedOff - BopControlPanel%KillLineCloseLED = LedOn - BopStackInput%KillLineCloseLedMine = LedOn - KillLine%IsOpening = .false. - KillLine%IsClosing = .false. + data%EquipmentControl%BopControlPanel%KillLineOpenLED = LedOff + data%State%BopStackInput%KillLineOpenLedMine = LedOff + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOn + data%State%BopStackInput%KillLineCloseLedMine = LedOn + data%State%KillLine%IsOpening = .false. + data%State%KillLine%IsClosing = .false. - BopControlPanel%AnnularOpenLED = LedOn - BopStackInput%AnnularOpenLedMine = LedOn + data%EquipmentControl%BopControlPanel%AnnularOpenLED = LedOn + data%State%BopStackInput%AnnularOpenLedMine = LedOn - BopControlPanel%AnnularCloseLED = LedOff - BopStackInput%AnnularCloseLedMine = LedOff + data%EquipmentControl%BopControlPanel%AnnularCloseLED = LedOff + data%State%BopStackInput%AnnularCloseLedMine = LedOff - Annular%AnnularIsOpening = .false. - Annular%AnnularIsClosing = .false. + data%State%Annular%AnnularIsOpening = .false. + data%State%Annular%AnnularIsClosing = .false. - Annular%FirstSet=1 - AnnularComputational%RamsFirstSet=1 - BopControlPanel%ManifoldPressureGauge=BopStackAcc%PRAMS_REGSET !RamsReglatorSet - BopControlPanel%AnnularPressureGauge= (1 - Annular%AnnularPressureGaugeMalf) * min(BopControlPanel%AnnularRegulatorSetControl,1700.) + data%State%Annular%FirstSet=1 + data%State%AnnularComputational%RamsFirstSet=1 + data%EquipmentControl%BopControlPanel%ManifoldPressureGauge=data%State%BopStackAcc%PRAMS_REGSET !RamsReglatorSet + data%EquipmentControl%BopControlPanel%AnnularPressureGauge= (1 - data%State%Annular%AnnularPressureGaugeMalf) * min(data%EquipmentControl%BopControlPanel%AnnularRegulatorSetControl,1700.) -AnnularComputational%PannularTimeStepDelay = int(1./RamLine%DeltaT_BOP) ! 1/0.1 : for 1 sec delay in AnnRegulator shot time +data%State%AnnularComputational%PannularTimeStepDelay = int(1./data%State%RamLine%DeltaT_BOP) ! 1/0.1 : for 1 sec delay in AnnRegulator shot time - DO i = 1 , AnnularComputational%PannularTimeStepDelay - CALL AnnularComputational%Pannular_regDelay%AddToFirst(BopControlPanel%AnnularPressureGauge) + DO i = 1 , data%State%AnnularComputational%PannularTimeStepDelay + CALL data%State%AnnularComputational%Pannular_regDelay%AddToFirst(data%EquipmentControl%BopControlPanel%AnnularPressureGauge) END DO diff --git a/Equipments/BopStack/BlindRamsMain.f90 b/Equipments/BopStack/BlindRamsMain.f90 index 7319b6e..7649283 100644 --- a/Equipments/BopStack/BlindRamsMain.f90 +++ b/Equipments/BopStack/BlindRamsMain.f90 @@ -18,24 +18,24 @@ module BlindRamsMain ! end subroutine BlindRams_Init subroutine BlindRams_Step - use VARIABLES + use ConfigurationVariables implicit none - if (RamLine%FINISHED_shear/=0) then + if (data%State%RamLine%FINISHED_shear/=0) then call SHEAR_RAMS - if (RamLine%ShearRamIsOpening .or. RamLine%ShearRamIsClosing .or. RAM(4)%Bottles_Charged_MalfActive) then - Annular%FirstSet= 0 - AnnularComputational%RamsFirstSet= 0 - if(RamLine%FINISHED_shear==0) then + if (data%State%RamLine%ShearRamIsOpening .or. data%State%RamLine%ShearRamIsClosing .or. data%State%RAM(4)%Bottles_Charged_MalfActive) then + data%State%Annular%FirstSet= 0 + data%State%AnnularComputational%RamsFirstSet= 0 + if(data%State%RamLine%FINISHED_shear==0) then call SHEAR_RAMS_SUB !only body of loop2 - if (RamLine%FINISHED_shear/=0 .and. RamLine%FINISHED_shear==1 .and. RAM(4)%Bottles_Charged_MalfActive==.true.) then - call bop_code(1,ShearRam%H_ShearRamBop,4) + if (data%State%RamLine%FINISHED_shear/=0 .and. data%State%RamLine%FINISHED_shear==1 .and. data%State%RAM(4)%Bottles_Charged_MalfActive==.true.) then + call bop_code(1,data%State%ShearRAM%H_ShearRamBop,4) endif endif endif else call SHEAR_RAMS_SUB - if (RamLine%FINISHED_shear/=0 .and. RamLine%FINISHED_shear==1 .and. RAM(4)%Bottles_Charged_MalfActive==.true.) then - call bop_code(1,ShearRam%H_ShearRamBop,4) + if (data%State%RamLine%FINISHED_shear/=0 .and. data%State%RamLine%FINISHED_shear==1 .and. data%State%RAM(4)%Bottles_Charged_MalfActive==.true.) then + call bop_code(1,data%State%ShearRAM%H_ShearRamBop,4) endif endif diff --git a/Equipments/BopStack/CHOKE_LINE.f90 b/Equipments/BopStack/CHOKE_LINE.f90 index 6c5eadd..ad69851 100644 --- a/Equipments/BopStack/CHOKE_LINE.f90 +++ b/Equipments/BopStack/CHOKE_LINE.f90 @@ -1,10 +1,11 @@ SUBROUTINE CHOKE_LINE - USE VARIABLES + use ConfigurationVariables USE CAccumulatorVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants implicit none @@ -15,116 +16,116 @@ SUBROUTINE CHOKE_LINE ! START CONDITIONS FOR CHOKE LINE 1 !===================================================================== - RAM(5)%SuccessionCounter = RAM(5)%SuccessionCounter + 1 + data%State%RAM(5)%SuccessionCounter = data%State%RAM(5)%SuccessionCounter + 1 - if (BopControlPanel%ChokeLineValve == -1.0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%EquipmentControl%BopControlPanel%ChokeLineValve == -1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then - if ( RAM(5)%SuccessionCounter /= RAM(5)%SuccessionCounterOld+1 ) then - RAM(5)%SuccessionCounter = 0 ! also in starup - RAM(5)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then + data%State%RAM(5)%SuccessionCounter = 0 ! also in starup + data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup return else - RAM(5)%SuccessionCounterOld= RAM(5)%SuccessionCounter + data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter endif - if ( RAM(5)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif - RAM(5)%First_CloseTimecheck= 1 + data%State%RAM(5)%First_CloseTimecheck= 1 - if (BopStackInput%ChokeLineOpenLEDMine == LedOn) then + if (data%State%BopStackInput%ChokeLineOpenLEDMine == LedOn) then RETURN end if - ChokeLine%closed=0 - RAM(5)%vdis_tot=0 - RAM(5)%vdis_bottles=0. - RAM(5)%fvr_air=0. - RAM(5)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(5)%Qzero=70 - RAM(5)%Q=RAM(5)%Qzero - RAM(5)%flow=70 - RAM(5)%tol=0.0037 - if (ChokeLine%finished==1) then - ChokeLine%LeverOld= 1.0 + data%State%ChokeLine%closed=0 + data%State%RAM(5)%vdis_tot=0 + data%State%RAM(5)%vdis_bottles=0. + data%State%RAM(5)%fvr_air=0. + data%State%RAM(5)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(5)%Qzero=70 + data%State%RAM(5)%Q=data%State%RAM(5)%Qzero + data%State%RAM(5)%flow=70 + data%State%RAM(5)%tol=0.0037 + if (data%State%ChokeLine%finished==1) then + data%State%ChokeLine%LeverOld= 1.0 else - ChokeLine%LeverOld=BopControlPanel%ChokeLineValve + data%State%ChokeLine%LeverOld=data%EquipmentControl%BopControlPanel%ChokeLineValve endif - ChokeLine%finished=0 - ChokeLine%IsOpening = .true. - BopControlPanel%ChokeLineCloseLED = LedOff - BopStackInput%ChokeLineCloseLEDMine = LedOff - BopControlPanel%ChokeLineOpenLED = LedOn !LedBlinking - RAM(5)%bop_type = 3 + data%State%ChokeLine%finished=0 + data%State%ChokeLine%IsOpening = .true. + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOff + data%State%BopStackInput%ChokeLineCloseLEDMine = LedOff + data%EquipmentControl%BopControlPanel%ChokeLineOpenLED = LedOn !LedBlinking + data%State%RAM(5)%bop_type = 3 !AbopChokeLine=196.67 - ChokeLine%Abop=(BopStackSpecification%ChokeClose*231)/((ChokeLine%IDBase-ChokeLine%ODDrillpipe_inBase)/2.) - ChokeLine%NeededVolume=ChokeLine%Abop*(ChokeLine%IDBase-max(ChokeLine%ODDrillpipe_in,ChokeLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP + data%State%ChokeLine%Abop=(BopStackSpecification%ChokeClose*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.) + data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%IDBase-max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP endif - if (BopControlPanel%ChokeLineValve == 1.0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%EquipmentControl%BopControlPanel%ChokeLineValve == 1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then - if ( RAM(5)%SuccessionCounter /= RAM(5)%SuccessionCounterOld+1 ) then - RAM(5)%SuccessionCounter = 0 ! also in starup - RAM(5)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then + data%State%RAM(5)%SuccessionCounter = 0 ! also in starup + data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup return else - RAM(5)%SuccessionCounterOld= RAM(5)%SuccessionCounter + data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter endif - if ( RAM(5)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif - RAM(5)%First_OpenTimecheck= 1 + data%State%RAM(5)%First_OpenTimecheck= 1 - if (BopStackInput%ChokeLineCloseLEDMine == LedOn) then + if (data%State%BopStackInput%ChokeLineCloseLEDMine == LedOn) then RETURN end if - ChokeLine%closed=0 - RAM(5)%vdis_tot=0 - RAM(5)%vdis_bottles=0. - RAM(5)%fvr_air=0. - RAM(5)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(5)%Qzero=70 - RAM(5)%Q=RAM(5)%Qzero - RAM(5)%flow=70 - RAM(5)%tol=0.0037 + data%State%ChokeLine%closed=0 + data%State%RAM(5)%vdis_tot=0 + data%State%RAM(5)%vdis_bottles=0. + data%State%RAM(5)%fvr_air=0. + data%State%RAM(5)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(5)%Qzero=70 + data%State%RAM(5)%Q=data%State%RAM(5)%Qzero + data%State%RAM(5)%flow=70 + data%State%RAM(5)%tol=0.0037 - if (ChokeLine%finished==1) then - ChokeLine%LeverOld= -1.0 + if (data%State%ChokeLine%finished==1) then + data%State%ChokeLine%LeverOld= -1.0 else - ChokeLine%LeverOld=BopControlPanel%ChokeLineValve + data%State%ChokeLine%LeverOld=data%EquipmentControl%BopControlPanel%ChokeLineValve endif - ChokeLine%finished=0 - ChokeLine%IsClosing = .true. + data%State%ChokeLine%finished=0 + data%State%ChokeLine%IsClosing = .true. !if (ChokeLineCloseLED == LedOn) then ! RETURN !end if - BopControlPanel%ChokeLineCloseLED = LedOff !new - BopStackInput%ChokeLineCloseLEDMine = LedOff !new + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOff !new + data%State%BopStackInput%ChokeLineCloseLEDMine = LedOff !new - BopControlPanel%ChokeLineCloseLED = LedOn !LedBlinking - RAM(5)%bop_type = 3 + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOn !LedBlinking + data%State%RAM(5)%bop_type = 3 !AbopChokeLine=196.67 - ChokeLine%Abop=(BopStackSpecification%ChokeOpen*231)/((ChokeLine%IDBase-ChokeLine%ODDrillpipe_inBase)/2.) - ChokeLine%NeededVolume=ChokeLine%Abop*(ChokeLine%IDBase-max(ChokeLine%ODDrillpipe_in,ChokeLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP + data%State%ChokeLine%Abop=(BopStackSpecification%ChokeOpen*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.) + data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%IDBase-max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP endif @@ -150,10 +151,11 @@ SUBROUTINE CHOKE_LINE SUBROUTINE CHOKE_LINE_SUB - USE VARIABLES + use ConfigurationVariables USE CAccumulatorVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables implicit none @@ -165,25 +167,25 @@ SUBROUTINE CHOKE_LINE_SUB ! loop5: do while (finished_ChokeLine==0) - RAM(5)%SuccessionCounter = RAM(5)%SuccessionCounter + 1 + data%State%RAM(5)%SuccessionCounter = data%State%RAM(5)%SuccessionCounter + 1 - if (BopControlPanel%ChokeLineValve == 1.0 .and. ChokeLine%LeverOld == -1.0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%EquipmentControl%BopControlPanel%ChokeLineValve == 1.0 .and. data%State%ChokeLine%LeverOld == -1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then - if ( RAM(5)%First_CloseTimecheck == 0 ) then + if ( data%State%RAM(5)%First_CloseTimecheck == 0 ) then - if ( RAM(5)%SuccessionCounter /= RAM(5)%SuccessionCounterOld+1 ) then - RAM(5)%SuccessionCounter = 0 ! also in starup - RAM(5)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then + data%State%RAM(5)%SuccessionCounter = 0 ! also in starup + data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup return else - RAM(5)%SuccessionCounterOld= RAM(5)%SuccessionCounter + data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter endif - if ( RAM(5)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif @@ -191,38 +193,38 @@ SUBROUTINE CHOKE_LINE_SUB - ChokeLine%closed=0 - RAM(5)%p_bop=ShearRam%PA - ChokeLine%LeverOld = BopControlPanel%ChokeLineValve - BopControlPanel%ChokeLineOpenLED = LedOff - BopStackInput%ChokeLineOpenLEDMine = LedOff - BopControlPanel%ChokeLineCloseLED = LedOn !LedBlinking + data%State%ChokeLine%closed=0 + data%State%RAM(5)%p_bop=data%State%ShearRAM%PA + data%State%ChokeLine%LeverOld = data%EquipmentControl%BopControlPanel%ChokeLineValve + data%EquipmentControl%BopControlPanel%ChokeLineOpenLED = LedOff + data%State%BopStackInput%ChokeLineOpenLEDMine = LedOff + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOn !LedBlinking CALL OpenChokeLine - RAM(5)%bop_type = 3 + data%State%RAM(5)%bop_type = 3 !AbopChokeLine=196.67 - ChokeLine%Abop=(BopStackSpecification%ChokeClose*231)/((ChokeLine%IDBase-ChokeLine%ODDrillpipe_inBase)/2.) - ChokeLine%NeededVolume=ChokeLine%Abop*(ChokeLine%ID-max(ChokeLine%ODDrillpipe_in,ChokeLine%ODDrillpipe_inBase))/(2.*231) + data%State%ChokeLine%Abop=(BopStackSpecification%ChokeClose*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.) + data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%ID-max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase))/(2.*231) - RAM(5)%vdis_bottles=0. - RAM(5)%fvr_air=0. - RAM(5)%vdis_elecp=0. - ChokeLine%IsClosing = .true. - ChokeLine%IsOpening = .false. + data%State%RAM(5)%vdis_bottles=0. + data%State%RAM(5)%fvr_air=0. + data%State%RAM(5)%vdis_elecp=0. + data%State%ChokeLine%IsClosing = .true. + data%State%ChokeLine%IsOpening = .false. endif - if (BopControlPanel%ChokeLineValve == -1.0 .and. ChokeLine%LeverOld == 1.0 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%ChokeLineValve == -1.0 .and. data%State%ChokeLine%LeverOld == 1.0 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then - if ( RAM(5)%First_OpenTimecheck == 0 ) then + if ( data%State%RAM(5)%First_OpenTimecheck == 0 ) then - if ( RAM(5)%SuccessionCounter /= RAM(5)%SuccessionCounterOld+1 ) then - RAM(5)%SuccessionCounter = 0 ! also in starup - RAM(5)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then + data%State%RAM(5)%SuccessionCounter = 0 ! also in starup + data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup return else - RAM(5)%SuccessionCounterOld= RAM(5)%SuccessionCounter + data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter endif - if ( RAM(5)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif @@ -230,49 +232,49 @@ SUBROUTINE CHOKE_LINE_SUB - ChokeLine%closed=0 - RAM(5)%p_bop=ShearRam%PA - ChokeLine%LeverOld = BopControlPanel%ChokeLineValve - BopControlPanel%ChokeLineCloseLED = LedOff - BopStackInput%ChokeLineCloseLEDMine = LedOff - BopControlPanel%ChokeLineOpenLED = LedOn !LedBlinking + data%State%ChokeLine%closed=0 + data%State%RAM(5)%p_bop=data%State%ShearRAM%PA + data%State%ChokeLine%LeverOld = data%EquipmentControl%BopControlPanel%ChokeLineValve + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOff + data%State%BopStackInput%ChokeLineCloseLEDMine = LedOff + data%EquipmentControl%BopControlPanel%ChokeLineOpenLED = LedOn !LedBlinking CALL OpenChokeLine - RAM(5)%bop_type = 3 + data%State%RAM(5)%bop_type = 3 !AbopChokeLine=196.67 - ChokeLine%Abop=(BopStackSpecification%ChokeOpen*231)/((ChokeLine%IDBase-ChokeLine%ODDrillpipe_inBase)/2.) - ChokeLine%NeededVolume=ChokeLine%Abop*(ChokeLine%IDBase-ChokeLine%ID)/(2.*231) - RAM(5)%vdis_bottles=0. - RAM(5)%fvr_air=0. - RAM(5)%vdis_elecp=0. + data%State%ChokeLine%Abop=(BopStackSpecification%ChokeOpen*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.) + data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%IDBase-data%State%ChokeLine%ID)/(2.*231) + data%State%RAM(5)%vdis_bottles=0. + data%State%RAM(5)%fvr_air=0. + data%State%RAM(5)%vdis_elecp=0. - ChokeLine%IsOpening = .true. - ChokeLine%IsClosing = .false. + data%State%ChokeLine%IsOpening = .true. + data%State%ChokeLine%IsClosing = .false. endif - RAM(5)%First_CloseTimecheck = 0 - RAM(5)%First_OpenTimecheck = 0 + data%State%RAM(5)%First_CloseTimecheck = 0 + data%State%RAM(5)%First_OpenTimecheck = 0 - RAM(5)%time=RAM(5)%time+RamLine%DeltaT_BOP !overal time (s) + data%State%RAM(5)%time=data%State%RAM(5)%time+data%State%RamLine%DeltaT_BOP !overal time (s) !=================================================== ! BOP !=================================================== -if (ChokeLine%closed==0) then !bop closing - call bop_code(4,ChokeLine%H_Bop,5) !ramtype=4 5=RNUMBER +if (data%State%ChokeLine%closed==0) then !bop closing + call bop_code(4,data%State%ChokeLine%H_Bop,5) !ramtype=4 5=RNUMBER endif !bop is closing !================================================================ -if (ChokeLine%closed==1) then - RAM(5)%Q=0 +if (data%State%ChokeLine%closed==1) then + data%State%RAM(5)%Q=0 !p_bop=pram_reg - RAM(5)%p_bop=ShearRam%PA - RAMS%minloss(5,17)=0. !RNUMBER=5 + data%State%RAM(5)%p_bop=data%State%ShearRAM%PA + data%State%RAMS%minloss(5,17)=0. !RNUMBER=5 endif -RAM(5)%timecounter_ram=RAM(5)%timecounter_ram+1 +data%State%RAM(5)%timecounter_ram=data%State%RAM(5)%timecounter_ram+1 @@ -288,16 +290,16 @@ RAM(5)%timecounter_ram=RAM(5)%timecounter_ram+1 ! ! ! -! WRITE(60,60) RAM(5)%time,RAM(5)%Q,RAM(5)%vdis_tot,p_acc, & -! pram_reg,Pannular_reg,RAM(5)%p_bop,IDshearBop, & +! WRITE(60,60) data%State%RAM(5)%time,data%State%RAM(5)%Q,data%State%RAM(5)%vdis_tot,p_acc, & +! pram_reg,Pannular_reg,data%State%RAM(5)%p_bop,IDshearBop, & ! IDPipeRam1,IDPipeRam2,IDAnnular !60 FORMAT(11(f18.5)) ! call sleepqq(100) - if (ChokeLine%closed==1) then + if (data%State%ChokeLine%closed==1) then ! if ((UpperRamsValve==1. .and. UpperRamsFailureMalf==0) .or. (UpperRamsValve==-1.0 .and. UpperRamsFailureMalf==0) .or. (MiddleRamsValve==1. .and. MiddleRamsFailureMalf==0) .or. (MiddleRamsValve==-1.0 .and. MiddleRamsFailureMalf==0) .or. (LowerRamsValve==1. .and. LowerRamsFailureMalf==0) .or. (LowerRamsValve==-1.0 .and. LowerRamsFailureMalf==0) .or. (AnnularValve==1. .and. AnnularFailureMalf==0) .or. (AnnularValve==-1.0 .and. AnnularFailureMalf==0) .or. KillLineValve==1. .or. KillLineValve==-1.0) then - ChokeLine%finished=1 + data%State%ChokeLine%finished=1 ! endif endif diff --git a/Equipments/BopStack/ChokeLineMain.f90 b/Equipments/BopStack/ChokeLineMain.f90 index a4b910a..6e62242 100644 --- a/Equipments/BopStack/ChokeLineMain.f90 +++ b/Equipments/BopStack/ChokeLineMain.f90 @@ -18,14 +18,14 @@ module ChokeLineMain ! end subroutine ChokeLine_Init subroutine ChokeLine_Step - use VARIABLES + use ConfigurationVariables implicit none - if (ChokeLine%finished/=0) then + if (data%State%ChokeLine%finished/=0) then call CHOKE_LINE - if (ChokeLine%IsOpening .or. ChokeLine%IsClosing) then - Annular%FirstSet= 0 - AnnularComputational%RamsFirstSet= 0 - if(ChokeLine%finished==0) then + if (data%State%ChokeLine%IsOpening .or. data%State%ChokeLine%IsClosing) then + data%State%Annular%FirstSet= 0 + data%State%AnnularComputational%RamsFirstSet= 0 + if(data%State%ChokeLine%finished==0) then call CHOKE_LINE_SUB !only body of loop2 endif endif diff --git a/Equipments/BopStack/KILL_LINE.f90 b/Equipments/BopStack/KILL_LINE.f90 index 0a81abf..48ae649 100644 --- a/Equipments/BopStack/KILL_LINE.f90 +++ b/Equipments/BopStack/KILL_LINE.f90 @@ -1,10 +1,11 @@ SUBROUTINE KILL_LINE - USE VARIABLES + use ConfigurationVariables USE CAccumulatorVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables @@ -16,119 +17,119 @@ SUBROUTINE KILL_LINE ! START CONDITIONS FOR KILL LINE 1 !===================================================================== - RAM(6)%SuccessionCounter = RAM(6)%SuccessionCounter + 1 + data%State%RAM(6)%SuccessionCounter = data%State%RAM(6)%SuccessionCounter + 1 - if (BopControlPanel%KillLineValve == -1.0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%EquipmentControl%BopControlPanel%KillLineValve == -1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then - if ( RAM(6)%SuccessionCounter /= RAM(6)%SuccessionCounterOld+1 ) then - RAM(6)%SuccessionCounter = 0 ! also in starup - RAM(6)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(6)%SuccessionCounter /= data%State%RAM(6)%SuccessionCounterOld+1 ) then + data%State%RAM(6)%SuccessionCounter = 0 ! also in starup + data%State%RAM(6)%SuccessionCounterOld = 0 ! also in starup return else - RAM(6)%SuccessionCounterOld= RAM(6)%SuccessionCounter + data%State%RAM(6)%SuccessionCounterOld= data%State%RAM(6)%SuccessionCounter endif - if ( RAM(6)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(6)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif - RAM(6)%First_CloseTimecheck= 1 + data%State%RAM(6)%First_CloseTimecheck= 1 - if (BopStackInput%KillLineOpenLedMine == LedOn) then + if (data%State%BopStackInput%KillLineOpenLedMine == LedOn) then RETURN end if - KillLine%closed=0 - RAM(6)%vdis_tot=0 - RAM(6)%vdis_bottles=0. - RAM(6)%fvr_air=0. - RAM(6)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(6)%Qzero=70 - RAM(6)%Q=RAM(6)%Qzero - RAM(6)%flow=70 - RAM(6)%tol=0.0037 - if (KillLine%finished==1) then - KillLine%LeverOld= 1.0 + data%State%KillLine%closed=0 + data%State%RAM(6)%vdis_tot=0 + data%State%RAM(6)%vdis_bottles=0. + data%State%RAM(6)%fvr_air=0. + data%State%RAM(6)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(6)%Qzero=70 + data%State%RAM(6)%Q=data%State%RAM(6)%Qzero + data%State%RAM(6)%flow=70 + data%State%RAM(6)%tol=0.0037 + if (data%State%KillLine%finished==1) then + data%State%KillLine%LeverOld= 1.0 else - KillLine%LeverOld=BopControlPanel%KillLineValve + data%State%KillLine%LeverOld=data%EquipmentControl%BopControlPanel%KillLineValve endif - KillLine%finished=0 - KillLine%IsOpening = .true. - BopControlPanel%KillLineCloseLED = LedOff - BopStackInput%KillLineCloseLedMine = LedOff - BopControlPanel%KillLineOpenLED = LedOn !LedBlinking - RAM(6)%bop_type = 3 + data%State%KillLine%finished=0 + data%State%KillLine%IsOpening = .true. + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOff + data%State%BopStackInput%KillLineCloseLedMine = LedOff + data%EquipmentControl%BopControlPanel%KillLineOpenLED = LedOn !LedBlinking + data%State%RAM(6)%bop_type = 3 !AbopKillLine=196.67 - KillLine%Abop=(BopStackSpecification%KillClose*231)/((KillLine%IDBase-KillLine%ODDrillpipe_inBase)/2.) - KillLine%NeededVolume=KillLine%Abop*(KillLine%IDBase-max(KillLine%ODDrillpipe_in,KillLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP + data%State%KillLine%Abop=(BopStackSpecification%KillClose*231)/((data%State%KillLine%IDBase-data%State%KillLine%ODDrillpipe_inBase)/2.) + data%State%KillLine%NeededVolume=data%State%KillLine%Abop*(data%State%KillLine%IDBase-max(data%State%KillLine%ODDrillpipe_in,data%State%KillLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP endif - if (BopControlPanel%KillLineValve == 1.0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%EquipmentControl%BopControlPanel%KillLineValve == 1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then - if ( RAM(6)%SuccessionCounter /= RAM(6)%SuccessionCounterOld+1 ) then - RAM(6)%SuccessionCounter = 0 ! also in starup - RAM(6)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(6)%SuccessionCounter /= data%State%RAM(6)%SuccessionCounterOld+1 ) then + data%State%RAM(6)%SuccessionCounter = 0 ! also in starup + data%State%RAM(6)%SuccessionCounterOld = 0 ! also in starup return else - RAM(6)%SuccessionCounterOld= RAM(6)%SuccessionCounter + data%State%RAM(6)%SuccessionCounterOld= data%State%RAM(6)%SuccessionCounter endif - if ( RAM(6)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(6)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif - RAM(6)%First_OpenTimecheck= 1 + data%State%RAM(6)%First_OpenTimecheck= 1 - if (BopStackInput%KillLineCloseLedMine == LedOn) then + if (data%State%BopStackInput%KillLineCloseLedMine == LedOn) then RETURN end if - KillLine%closed=0 - RAM(6)%vdis_tot=0 - RAM(6)%vdis_bottles=0. - RAM(6)%fvr_air=0. - RAM(6)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(6)%Qzero=70 - RAM(6)%Q=RAM(6)%Qzero - RAM(6)%flow=70 - RAM(6)%tol=0.0037 + data%State%KillLine%closed=0 + data%State%RAM(6)%vdis_tot=0 + data%State%RAM(6)%vdis_bottles=0. + data%State%RAM(6)%fvr_air=0. + data%State%RAM(6)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(6)%Qzero=70 + data%State%RAM(6)%Q=data%State%RAM(6)%Qzero + data%State%RAM(6)%flow=70 + data%State%RAM(6)%tol=0.0037 - if (KillLine%finished==1) then - KillLine%LeverOld= -1.0 + if (data%State%KillLine%finished==1) then + data%State%KillLine%LeverOld= -1.0 else - KillLine%LeverOld=BopControlPanel%KillLineValve + data%State%KillLine%LeverOld=data%EquipmentControl%BopControlPanel%KillLineValve endif - KillLine%finished=0 - KillLine%IsClosing = .true. + data%State%KillLine%finished=0 + data%State%KillLine%IsClosing = .true. !if (KillLineCloseLed == LedOn) then ! RETURN !end if - BopControlPanel%KillLineCloseLED = LedOff !new - BopStackInput%KillLineCloseLedMine = LedOff !new + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOff !new + data%State%BopStackInput%KillLineCloseLedMine = LedOff !new - BopControlPanel%KillLineCloseLED = LedOn !LedBlinking - RAM(6)%bop_type = 3 + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOn !LedBlinking + data%State%RAM(6)%bop_type = 3 !AbopKillLine=196.67 - KillLine%Abop=(BopStackSpecification%KillOpen*231)/((KillLine%IDBase-KillLine%ODDrillpipe_inBase)/2.) - KillLine%NeededVolume=KillLine%Abop*(KillLine%IDBase-max(KillLine%ODDrillpipe_in,KillLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP + data%State%KillLine%Abop=(BopStackSpecification%KillOpen*231)/((data%State%KillLine%IDBase-data%State%KillLine%ODDrillpipe_inBase)/2.) + data%State%KillLine%NeededVolume=data%State%KillLine%Abop*(data%State%KillLine%IDBase-max(data%State%KillLine%ODDrillpipe_in,data%State%KillLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP endif !========================================================================== -if (KillLine%IsOpening .or. KillLine%IsClosing) then +if (data%State%KillLine%IsOpening .or. data%State%KillLine%IsClosing) then CALL KILL_LINE_SUB end if @@ -147,42 +148,43 @@ end if SUBROUTINE KILL_LINE_SUB - USE VARIABLES + use ConfigurationVariables USE CAccumulatorVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables implicit none - Annular%FirstSet= 0 - AnnularComputational%RamsFirstSet= 0 + data%State%Annular%FirstSet= 0 + data%State%AnnularComputational%RamsFirstSet= 0 ! loop6: do while (finished_KillLine==0) - RAM(6)%SuccessionCounter = RAM(6)%SuccessionCounter + 1 + data%State%RAM(6)%SuccessionCounter = data%State%RAM(6)%SuccessionCounter + 1 - if (BopControlPanel%KillLineValve == 1.0 .and. KillLine%LeverOld == -1.0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%EquipmentControl%BopControlPanel%KillLineValve == 1.0 .and. data%State%KillLine%LeverOld == -1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then - if ( RAM(6)%First_CloseTimecheck == 0 ) then + if ( data%State%RAM(6)%First_CloseTimecheck == 0 ) then - if ( RAM(6)%SuccessionCounter /= RAM(6)%SuccessionCounterOld+1 ) then - RAM(6)%SuccessionCounter = 0 ! also in starup - RAM(6)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(6)%SuccessionCounter /= data%State%RAM(6)%SuccessionCounterOld+1 ) then + data%State%RAM(6)%SuccessionCounter = 0 ! also in starup + data%State%RAM(6)%SuccessionCounterOld = 0 ! also in starup return else - RAM(6)%SuccessionCounterOld= RAM(6)%SuccessionCounter + data%State%RAM(6)%SuccessionCounterOld= data%State%RAM(6)%SuccessionCounter endif - if ( RAM(6)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(6)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif @@ -190,88 +192,88 @@ SUBROUTINE KILL_LINE_SUB - KillLine%closed=0 - RAM(6)%p_bop=ShearRam%PA - KillLine%LeverOld = BopControlPanel%KillLineValve - BopControlPanel%KillLineOpenLED = LedOff - BopStackInput%KillLineOpenLedMine = LedOff - BopControlPanel%KillLineCloseLED = LedOn !LedBlinking + data%State%KillLine%closed=0 + data%State%RAM(6)%p_bop=data%State%ShearRAM%PA + data%State%KillLine%LeverOld = data%EquipmentControl%BopControlPanel%KillLineValve + data%EquipmentControl%BopControlPanel%KillLineOpenLED = LedOff + data%State%BopStackInput%KillLineOpenLedMine = LedOff + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOn !LedBlinking CALL OpenKillLine - RAM(6)%bop_type = 3 + data%State%RAM(6)%bop_type = 3 !AbopKillLine=196.67 - KillLine%Abop=(BopStackSpecification%KillClose*231)/((KillLine%IDBase-KillLine%ODDrillpipe_inBase)/2.) - KillLine%NeededVolume=KillLine%Abop*(KillLine%ID-max(KillLine%ODDrillpipe_in,KillLine%ODDrillpipe_inBase))/(2.*231) + data%State%KillLine%Abop=(BopStackSpecification%KillClose*231)/((data%State%KillLine%IDBase-data%State%KillLine%ODDrillpipe_inBase)/2.) + data%State%KillLine%NeededVolume=data%State%KillLine%Abop*(data%State%KillLine%ID-max(data%State%KillLine%ODDrillpipe_in,data%State%KillLine%ODDrillpipe_inBase))/(2.*231) - RAM(6)%vdis_bottles=0. - RAM(6)%fvr_air=0. - RAM(6)%vdis_elecp=0. - KillLine%IsClosing = .true. - KillLine%IsOpening = .false. + data%State%RAM(6)%vdis_bottles=0. + data%State%RAM(6)%fvr_air=0. + data%State%RAM(6)%vdis_elecp=0. + data%State%KillLine%IsClosing = .true. + data%State%KillLine%IsOpening = .false. endif - if (BopControlPanel%KillLineValve == -1.0 .and. KillLine%LeverOld == 1.0 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%KillLineValve == -1.0 .and. data%State%KillLine%LeverOld == 1.0 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then - if ( RAM(6)%First_OpenTimecheck == 0 ) then + if ( data%State%RAM(6)%First_OpenTimecheck == 0 ) then - if ( RAM(6)%SuccessionCounter /= RAM(6)%SuccessionCounterOld+1 ) then - RAM(6)%SuccessionCounter = 0 ! also in starup - RAM(6)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(6)%SuccessionCounter /= data%State%RAM(6)%SuccessionCounterOld+1 ) then + data%State%RAM(6)%SuccessionCounter = 0 ! also in starup + data%State%RAM(6)%SuccessionCounterOld = 0 ! also in starup return else - RAM(6)%SuccessionCounterOld= RAM(6)%SuccessionCounter + data%State%RAM(6)%SuccessionCounterOld= data%State%RAM(6)%SuccessionCounter endif - if ( RAM(6)%SuccessionCounter < int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(6)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then return endif endif - KillLine%closed=0 - RAM(6)%p_bop=ShearRam%PA - KillLine%LeverOld = BopControlPanel%KillLineValve - BopControlPanel%KillLineCloseLED = LedOff - BopStackInput%KillLineCloseLedMine = LedOff - BopControlPanel%KillLineOpenLED = LedOn !LedBlinking + data%State%KillLine%closed=0 + data%State%RAM(6)%p_bop=data%State%ShearRAM%PA + data%State%KillLine%LeverOld = data%EquipmentControl%BopControlPanel%KillLineValve + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOff + data%State%BopStackInput%KillLineCloseLedMine = LedOff + data%EquipmentControl%BopControlPanel%KillLineOpenLED = LedOn !LedBlinking CALL OpenKillLine - RAM(6)%bop_type = 3 + data%State%RAM(6)%bop_type = 3 !AbopKillLine=196.67 - KillLine%Abop=(BopStackSpecification%KillOpen*231)/((KillLine%IDBase-KillLine%ODDrillpipe_inBase)/2.) - KillLine%NeededVolume=KillLine%Abop*(KillLine%IDBase-KillLine%ID)/(2.*231) - RAM(6)%vdis_bottles=0. - RAM(6)%fvr_air=0. - RAM(6)%vdis_elecp=0. + data%State%KillLine%Abop=(BopStackSpecification%KillOpen*231)/((data%State%KillLine%IDBase-data%State%KillLine%ODDrillpipe_inBase)/2.) + data%State%KillLine%NeededVolume=data%State%KillLine%Abop*(data%State%KillLine%IDBase-data%State%KillLine%ID)/(2.*231) + data%State%RAM(6)%vdis_bottles=0. + data%State%RAM(6)%fvr_air=0. + data%State%RAM(6)%vdis_elecp=0. - KillLine%IsOpening = .true. - KillLine%IsClosing = .false. + data%State%KillLine%IsOpening = .true. + data%State%KillLine%IsClosing = .false. endif - RAM(6)%First_CloseTimecheck = 0 - RAM(6)%First_OpenTimecheck = 0 + data%State%RAM(6)%First_CloseTimecheck = 0 + data%State%RAM(6)%First_OpenTimecheck = 0 - RAM(6)%time=RAM(6)%time+RamLine%DeltaT_BOP !overal time (s) + data%State%RAM(6)%time=data%State%RAM(6)%time+data%State%RamLine%DeltaT_BOP !overal time (s) !=================================================== ! BOP !=================================================== -if (KillLine%closed==0) then !bop closing - call bop_code(5,KillLine%H_Bop,6) !ramtype=5 6=RNUMBER +if (data%State%KillLine%closed==0) then !bop closing + call bop_code(5,data%State%KillLine%H_Bop,6) !ramtype=5 6=RNUMBER endif !bop is closing !================================================================ -if (KillLine%closed==1) then - RAM(6)%Q=0 +if (data%State%KillLine%closed==1) then + data%State%RAM(6)%Q=0 !p_bop=pram_reg - RAM(6)%p_bop=ShearRam%PA - RAMS%minloss(6,17)=0. !RNUMBER=6 + data%State%RAM(6)%p_bop=data%State%ShearRAM%PA + data%State%RAMS%minloss(6,17)=0. !RNUMBER=6 endif -RAM(6)%timecounter_ram=RAM(6)%timecounter_ram+1 +data%State%RAM(6)%timecounter_ram=data%State%RAM(6)%timecounter_ram+1 @@ -287,17 +289,17 @@ RAM(6)%timecounter_ram=RAM(6)%timecounter_ram+1 ! ! ! -! WRITE(60,60) RAM(6)%time,RAM(6)%Q,RAM(6)%vdis_tot,p_acc, & -! pram_reg,Pannular_reg,RAM(6)%p_bop,IDshearBop, & +! WRITE(60,60) data%State%RAM(6)%time,data%State%RAM(6)%Q,data%State%RAM(6)%vdis_tot,p_acc, & +! pram_reg,Pannular_reg,data%State%RAM(6)%p_bop,IDshearBop, & ! IDPipeRam1,IDPipeRam2,IDAnnular !60 FORMAT(11(f18.5)) ! call sleepqq(100) -if (KillLine%closed==1) then +if (data%State%KillLine%closed==1) then ! if ((UpperRamsValve==1. .and. UpperRamsFailureMalf==0) .or. (UpperRamsValve==-1.0 .and. UpperRamsFailureMalf==0) .or. (MiddleRamsValve==1. .and. MiddleRamsFailureMalf==0) .or. (MiddleRamsValve==-1.0 .and. MiddleRamsFailureMalf==0) .or. (LowerRamsValve==1. .and. LowerRamsFailureMalf==0) .or. (LowerRamsValve==-1.0 .and. LowerRamsFailureMalf==0) .or. (AnnularValve==1. .and. AnnularFailureMalf==0) .or. (AnnularValve==-1.0 .and. AnnularFailureMalf==0) .or. ChokeLineValve==1. .or. ChokeLineValve==-1.0) then - KillLine%finished=1 + data%State%KillLine%finished=1 ! endif endif diff --git a/Equipments/BopStack/KillLineMain.f90 b/Equipments/BopStack/KillLineMain.f90 index 2cf31cb..34de14d 100644 --- a/Equipments/BopStack/KillLineMain.f90 +++ b/Equipments/BopStack/KillLineMain.f90 @@ -18,12 +18,12 @@ module KillLineMain ! end subroutine KillLine_Init subroutine KillLine_Step - use VARIABLES + use ConfigurationVariables implicit none - if (KillLine%finished/=0) then + if (data%State%KillLine%finished/=0) then call KILL_LINE - if (KillLine%IsOpening .or. KillLine%IsClosing) then - if(KillLine%finished==0) then + if (data%State%KillLine%IsOpening .or. data%State%KillLine%IsClosing) then + if(data%State%KillLine%finished==0) then call KILL_LINE_SUB !only body of loop2 endif endif @@ -32,48 +32,5 @@ module KillLineMain endif end subroutine KillLine_Step - ! subroutine KillLine_Output - ! implicit none - ! end subroutine KillLine_Output - - ! subroutine KillLineMainBody - ! USE ifport - ! USE ifmt - ! ! use CSimulationVariables - ! ! USE BOP - ! implicit none - - ! INTEGER :: KillLineDuration - ! integer,dimension(8) :: KillLineStartTime , KillLineEndTime - - ! ! CALL BOP_StartUp() - ! loop1: DO - - ! CALL DATE_AND_TIME(values=KillLineStartTime) - - ! CALL KILL_LINE - - ! CALL DATE_AND_TIME(values=KillLineEndTime) - - ! KillLineDuration = 3600000 * (KillLineEndTime(5) - KillLineStartTime(5)) + 60000 * (KillLineEndTime(6) - KillLineStartTime(6)) + 1000 * (KillLineEndTime(7) - KillLineStartTime(7)) + (KillLineEndTime(8) - KillLineStartTime(8)) - - ! if (KillLineDuration < 100) then - ! call sleepqq(100 - KillLineDuration) - ! ELSE - ! WRITE (*,*) 'KillLine BOP run duration exceeded 100 ms and =', KillLineDuration - ! end if - - - ! IF (IsStopped==.true.) THEN - ! EXIT loop1 - ! ENDIF - - - ! ENDDO loop1 - - - ! ! CALL DEALLOCATE_ARRAYS() - - ! end subroutine KillLineMainBody end module KillLineMain \ No newline at end of file diff --git a/Equipments/BopStack/LOSS_INPUTS.f90 b/Equipments/BopStack/LOSS_INPUTS.f90 index bf7626b..22196cf 100644 --- a/Equipments/BopStack/LOSS_INPUTS.f90 +++ b/Equipments/BopStack/LOSS_INPUTS.f90 @@ -1,43 +1,43 @@ SUBROUTINE DEALLOCATE_ARRAYS() -USE VARIABLES +use ConfigurationVariables implicit none !=========================================================================== ! RAMLINE MINOR LOSSES INPUT !=========================================================================== - DEALLOCATE (BopStackInput%MINORS1,RamLine%MINORDIAMETER_RAMLINE,RamLine%AREAMINOR_RAMLINE & - ,RamLine%LF_RAMLINE,RamLine%CV_RAMLINE,RamLine%NOTE_RAMLINE,RAMS%minlosspa,RAMS%minloss) + DEALLOCATE (data%State%BopStackInput%MINORS1,data%State%RamLine%MINORDIAMETER_RAMLINE,data%State%RamLine%AREAMINOR_RAMLINE & + ,data%State%RamLine%LF_RAMLINE,data%State%RamLine%CV_RAMLINE,data%State%RamLine%NOTE_RAMLINE,data%State%RAMS%minlosspa,data%State%RAMS%minloss) !=========================================================================== ! RAMLINE PIPNING LOSSES INPUT !=========================================================================== - DEALLOCATE (BopStackInput%PIPINGS_RAMLINE,RamLine%DIAM_RAMLINE_INCH, & - RamLine%AREA_RAMLINE,RamLine%LENGT_RAMLINE,RamLine%ROUGHNESS_RAMLINE,RamLine%RELROUGH_RAMLINE & - ,RAMS%Re_ramline,RAMS%fric,RAMS%fricloss) + DEALLOCATE (data%State%BopStackInput%PIPINGS_RAMLINE,data%State%RamLine%DIAM_RAMLINE_INCH, & + data%State%RamLine%AREA_RAMLINE,data%State%RamLine%LENGT_RAMLINE,data%State%RamLine%ROUGHNESS_RAMLINE,data%State%RamLine%RELROUGH_RAMLINE & + ,data%State%RAMS%Re_ramline,data%State%RAMS%fric,data%State%RAMS%fricloss) !=========================================================================== ! ANNULAR MINOR LOSSES INPUT !=========================================================================== - DEALLOCATE (BopStackInput%MINORS_ANNULAR,AnnularComputational%MINORDIAMETER_ANNULARLINE,AnnularComputational%AREAMINOR_ANNULARLINE & - ,AnnularComputational%LF_ANNULARLINE,AnnularComputational%CV_ANNULARLINE,AnnularComputational%NOTE_ANNULARLINE,AnnularComputational%minlosspa_ANNULAR,AnnularComputational%minloss_ANNULAR) + DEALLOCATE (data%State%BopStackInput%MINORS_ANNULAR,data%State%AnnularComputational%MINORDIAMETER_ANNULARLINE,data%State%AnnularComputational%AREAMINOR_ANNULARLINE & + ,data%State%AnnularComputational%LF_ANNULARLINE,data%State%AnnularComputational%CV_ANNULARLINE,data%State%AnnularComputational%NOTE_ANNULARLINE,data%State%AnnularComputational%minlosspa_ANNULAR,data%State%AnnularComputational%minloss_ANNULAR) !=========================================================================== ! ANNULAR PIPNING LOSSES INPUT !=========================================================================== - DEALLOCATE (BopStackInput%PIPINGS_ANNULAR,AnnularComputational%DIAM_ANNULARLINE_INCH,AnnularComputational%AREA_ANNULARLINE, & - AnnularComputational%LENGT_ANNULARLINE,AnnularComputational%ROUGHNESS_ANNULARLINE,AnnularComputational%RELROUGH_ANNULARLINE & - ,AnnularComputational%Re_ANNULARline,AnnularComputational%fricANNULAR,AnnularComputational%friclossANNULAR) + DEALLOCATE (data%State%BopStackInput%PIPINGS_ANNULAR,data%State%AnnularComputational%DIAM_ANNULARLINE_INCH,data%State%AnnularComputational%AREA_ANNULARLINE, & + data%State%AnnularComputational%LENGT_ANNULARLINE,data%State%AnnularComputational%ROUGHNESS_ANNULARLINE,data%State%AnnularComputational%RELROUGH_ANNULARLINE & + ,data%State%AnnularComputational%Re_ANNULARline,data%State%AnnularComputational%fricANNULAR,data%State%AnnularComputational%friclossANNULAR) !=========================================================================== ! AIR PUMP LOSSES INPUT !=========================================================================== -DEALLOCATE (BopStackInput%PIPINGS_AIRPUMP,RamLine%DIAM_AIR_INCH, & - RamLine%Re_air,RamLine%AREA_AIR,RamLine%LENGT_AIR,RamLine%ROUGHNESS_AIRPLINE,RamLine%REL_ROUGHAIR, & - RamLine%fric_air,RamLine%fricloss_air) +DEALLOCATE (data%State%BopStackInput%PIPINGS_AIRPUMP,data%State%RamLine%DIAM_AIR_INCH, & + data%State%RamLine%Re_air,data%State%RamLine%AREA_AIR,data%State%RamLine%LENGT_AIR,data%State%RamLine%ROUGHNESS_AIRPLINE,data%State%RamLine%REL_ROUGHAIR, & + data%State%RamLine%fric_air,data%State%RamLine%fricloss_air) !================================================================ -DEALLOCATE (BopStackInput%MINORS_AIRPUMP,RamLine%MINORDIAM_AIR_INCH, & - RamLine%MINORAREA_AIR,RamLine%LF_AIR,RamLine%CV_AIR,RamLine%NOTE_AIR & - ,RamLine%minlosspa_air,RamLine%minloss_air) +DEALLOCATE (data%State%BopStackInput%MINORS_AIRPUMP,data%State%RamLine%MINORDIAM_AIR_INCH, & + data%State%RamLine%MINORAREA_AIR,data%State%RamLine%LF_AIR,data%State%RamLine%CV_AIR,data%State%RamLine%NOTE_AIR & + ,data%State%RamLine%minlosspa_air,data%State%RamLine%minloss_air) !=========================================================================== ! DELAY ARRAYS !=========================================================================== -call AnnularComputational%Pannular_regDelay%Empty() +call data%State%AnnularComputational%Pannular_regDelay%Empty() @@ -54,111 +54,111 @@ call AnnularComputational%Pannular_regDelay%Empty() SUBROUTINE LOSS_INPUTS() -USE VARIABLES +use ConfigurationVariables implicit none INTEGER I !=========================================================================== ! RAMLINE MINOR LOSSES INPUT !=========================================================================== -RamLine%NO_MINORSRAMLINE=34 +data%State%RamLine%NO_MINORSRAMLINE=34 -ALLOCATE (BopStackInput%MINORS1(RamLine%NO_MINORSRAMLINE,4)) +ALLOCATE (data%State%BopStackInput%MINORS1(data%State%RamLine%NO_MINORSRAMLINE,4)) ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION -BopStackInput%MINORS1(1,1:4)= (/2., 2., 0., 0./) !Acc.tee -BopStackInput%MINORS1(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee -BopStackInput%MINORS1(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee -BopStackInput%MINORS1(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee -BopStackInput%MINORS1(5,1:4)= (/2., 0.9, 0., 0./) !tee -BopStackInput%MINORS1(6,1:4)= (/2., 2., 0., 0./) !tee -BopStackInput%MINORS1(7,1:4)= (/2., 0., 105., 0./) !valve -BopStackInput%MINORS1(8,1:4)= (/2., 0.9, 0., 0./) !tee -BopStackInput%MINORS1(9,1:4)= (/2., 0., 105., 0./) !valve -BopStackInput%MINORS1(10,1:4)= (/2., 0.42, 0., 0./) !elbow -BopStackInput%MINORS1(11,1:4)= (/2., 0.42, 0., 0./) !elbow -BopStackInput%MINORS1(12,1:4)= (/2., 0.8, 0., 0./) !unionA -BopStackInput%MINORS1(13,1:4)= (/2., 0.8, 0., 0./) !unionA -BopStackInput%MINORS1(14,1:4)= (/2., 1.5, 0., 0./) !elbow -BopStackInput%MINORS1(15,1:4)= (/2., 0., 425., 0./) !valve -BopStackInput%MINORS1(16,1:4)= (/2., 2., 0., 0./) !tee -BopStackInput%MINORS1(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR -BopStackInput%MINORS1(18,1:4)= (/1., 2., 0., 0./) !tee -BopStackInput%MINORS1(19,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS1(20,1:4)= (/1., 0.42, 0., 0./) !elbow -BopStackInput%MINORS1(21,1:4)= (/1., 0.42, 0., 0./) !elbow -BopStackInput%MINORS1(22,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS1(23,1:4)= (/1., 0., 105., 0./) !valve -BopStackInput%MINORS1(24,1:4)= (/1., 0.9, 0., 0./) !tee -BopStackInput%MINORS1(25,1:4)= (/1., 0., 0., 0.5/) !FT -BopStackInput%MINORS1(26,1:4)= (/1., 0., 0., 3.4/) !filter -BopStackInput%MINORS1(27,1:4)= (/1., 0., 105., 0./) !valve -BopStackInput%MINORS1(28,1:4)= (/1., 0.9, 0., 0./) !tee -BopStackInput%MINORS1(29,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS1(30,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS1(31,1:4)= (/1., 0., 9.2, 0./) !valve -BopStackInput%MINORS1(32,1:4)= (/1., 0.8, 0., 0./) !unionA -BopStackInput%MINORS1(33,1:4)= (/1., 0.8, 0., 0./) !unionA -BopStackInput%MINORS1(34,1:4)= (/0.75, 0.35, 0., 0./) !contraction - - -ALLOCATE (RamLine%MINORDIAMETER_RAMLINE(RamLine%NO_MINORSRAMLINE),RamLine%AREAMINOR_RAMLINE(RamLine%NO_MINORSRAMLINE),RamLine%LF_RAMLINE(RamLine%NO_MINORSRAMLINE),RamLine%CV_RAMLINE(RamLine%NO_MINORSRAMLINE) & - ,RamLine%NOTE_RAMLINE(RamLine%NO_MINORSRAMLINE),RAMS%minlosspa(6,RamLine%NO_MINORSRAMLINE),RAMS%minloss(6,RamLine%NO_MINORSRAMLINE)) - - - -DO I=1,RamLine%NO_MINORSRAMLINE - RamLine%MINORDIAMETER_RAMLINE(I)=BopStackInput%MINORS1(I,1) - RamLine%LF_RAMLINE(I)=BopStackInput%MINORS1(I,2) - RamLine%CV_RAMLINE(I)=BopStackInput%MINORS1(I,3) - RamLine%NOTE_RAMLINE(I)=BopStackInput%MINORS1(I,4) +data%State%BopStackInput%MINORS1(1,1:4)= (/2., 2., 0., 0./) !Acc.tee +data%State%BopStackInput%MINORS1(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee +data%State%BopStackInput%MINORS1(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee +data%State%BopStackInput%MINORS1(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee +data%State%BopStackInput%MINORS1(5,1:4)= (/2., 0.9, 0., 0./) !tee +data%State%BopStackInput%MINORS1(6,1:4)= (/2., 2., 0., 0./) !tee +data%State%BopStackInput%MINORS1(7,1:4)= (/2., 0., 105., 0./) !valve +data%State%BopStackInput%MINORS1(8,1:4)= (/2., 0.9, 0., 0./) !tee +data%State%BopStackInput%MINORS1(9,1:4)= (/2., 0., 105., 0./) !valve +data%State%BopStackInput%MINORS1(10,1:4)= (/2., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(11,1:4)= (/2., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(12,1:4)= (/2., 0.8, 0., 0./) !unionA +data%State%BopStackInput%MINORS1(13,1:4)= (/2., 0.8, 0., 0./) !unionA +data%State%BopStackInput%MINORS1(14,1:4)= (/2., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(15,1:4)= (/2., 0., 425., 0./) !valve +data%State%BopStackInput%MINORS1(16,1:4)= (/2., 2., 0., 0./) !tee +data%State%BopStackInput%MINORS1(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR +data%State%BopStackInput%MINORS1(18,1:4)= (/1., 2., 0., 0./) !tee +data%State%BopStackInput%MINORS1(19,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(20,1:4)= (/1., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(21,1:4)= (/1., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(22,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(23,1:4)= (/1., 0., 105., 0./) !valve +data%State%BopStackInput%MINORS1(24,1:4)= (/1., 0.9, 0., 0./) !tee +data%State%BopStackInput%MINORS1(25,1:4)= (/1., 0., 0., 0.5/) !FT +data%State%BopStackInput%MINORS1(26,1:4)= (/1., 0., 0., 3.4/) !filter +data%State%BopStackInput%MINORS1(27,1:4)= (/1., 0., 105., 0./) !valve +data%State%BopStackInput%MINORS1(28,1:4)= (/1., 0.9, 0., 0./) !tee +data%State%BopStackInput%MINORS1(29,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(30,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS1(31,1:4)= (/1., 0., 9.2, 0./) !valve +data%State%BopStackInput%MINORS1(32,1:4)= (/1., 0.8, 0., 0./) !unionA +data%State%BopStackInput%MINORS1(33,1:4)= (/1., 0.8, 0., 0./) !unionA +data%State%BopStackInput%MINORS1(34,1:4)= (/0.75, 0.35, 0., 0./) !contraction + + +ALLOCATE (data%State%RamLine%MINORDIAMETER_RAMLINE(data%State%RamLine%NO_MINORSRAMLINE),data%State%RamLine%AREAMINOR_RAMLINE(data%State%RamLine%NO_MINORSRAMLINE),data%State%RamLine%LF_RAMLINE(data%State%RamLine%NO_MINORSRAMLINE),data%State%RamLine%CV_RAMLINE(data%State%RamLine%NO_MINORSRAMLINE) & + ,data%State%RamLine%NOTE_RAMLINE(data%State%RamLine%NO_MINORSRAMLINE),data%State%RAMS%minlosspa(6,data%State%RamLine%NO_MINORSRAMLINE),data%State%RAMS%minloss(6,data%State%RamLine%NO_MINORSRAMLINE)) + + + +DO I=1,data%State%RamLine%NO_MINORSRAMLINE + data%State%RamLine%MINORDIAMETER_RAMLINE(I)=data%State%BopStackInput%MINORS1(I,1) + data%State%RamLine%LF_RAMLINE(I)=data%State%BopStackInput%MINORS1(I,2) + data%State%RamLine%CV_RAMLINE(I)=data%State%BopStackInput%MINORS1(I,3) + data%State%RamLine%NOTE_RAMLINE(I)=data%State%BopStackInput%MINORS1(I,4) - RamLine%AREAMINOR_RAMLINE(I)=PI*(RamLine%MINORDIAMETER_RAMLINE(I)*0.0254)**2/4. !D(in), AREA(m) + data%State%RamLine%AREAMINOR_RAMLINE(I)=PI*(data%State%RamLine%MINORDIAMETER_RAMLINE(I)*0.0254)**2/4. !D(in), AREA(m) ENDDO !=========================================================================== ! RAMLINE PIPNING LOSSES INPUT !=========================================================================== -RamLine%NO_PIPINGSRAMLINE=15 +data%State%RamLine%NO_PIPINGSRAMLINE=15 -ALLOCATE (BopStackInput%PIPINGS_RAMLINE(RamLine%NO_PIPINGSRAMLINE,3)) +ALLOCATE (data%State%BopStackInput%PIPINGS_RAMLINE(data%State%RamLine%NO_PIPINGSRAMLINE,3)) ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION -BopStackInput%PIPINGS_RAMLINE(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance -BopStackInput%PIPINGS_RAMLINE(2,1:3)= (/2., 730., 0.03/) !Acc.end.horizontal -BopStackInput%PIPINGS_RAMLINE(3,1:3)= (/2., 2000., 0.03/) !Acc.end.vertical -BopStackInput%PIPINGS_RAMLINE(4,1:3)= (/2., 6000., 0.05/) !Hyd.hose -BopStackInput%PIPINGS_RAMLINE(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1 -BopStackInput%PIPINGS_RAMLINE(6,1:3)= (/2., 210., 0.03/) !Add.from.bend -BopStackInput%PIPINGS_RAMLINE(7,1:3)= (/1., 780., 0.03/) !Corner.horizontal1 -BopStackInput%PIPINGS_RAMLINE(8,1:3)= (/1., 780., 0.03/) !Corner.horizontal2 -BopStackInput%PIPINGS_RAMLINE(9,1:3)= (/1., 750., 0.03/) !Extra.length.back -BopStackInput%PIPINGS_RAMLINE(10,1:3)= (/1., 800., 0.03/) !Corner.horizontal3 -BopStackInput%PIPINGS_RAMLINE(11,1:3)= (/1., 1650., 0.03/) !Corner.vertical2 -BopStackInput%PIPINGS_RAMLINE(12,1:3)= (/1., 340., 0.03/) !12.Valves.horizontal -BopStackInput%PIPINGS_RAMLINE(13,1:3)= (/1., 1650., 0.03/) !Valves.vertical -BopStackInput%PIPINGS_RAMLINE(14,1:3)= (/1., 31000., 10./) !Hyd.hose -BopStackInput%PIPINGS_RAMLINE(15,1:3)= (/1., 526., 0.03/) !Add.from.bend - - - - ALLOCATE (RamLine%DIAM_RAMLINE_INCH(RamLine%NO_PIPINGSRAMLINE), & - RamLine%AREA_RAMLINE(RamLine%NO_PIPINGSRAMLINE),RamLine%LENGT_RAMLINE(RamLine%NO_PIPINGSRAMLINE),RamLine%ROUGHNESS_RAMLINE(RamLine%NO_PIPINGSRAMLINE),RamLine%RELROUGH_RAMLINE(RamLine%NO_PIPINGSRAMLINE) & - ,RAMS%Re_ramline(6,RamLine%NO_PIPINGSRAMLINE),RAMS%fric(6,RamLine%NO_PIPINGSRAMLINE),RAMS%fricloss(6,RamLine%NO_PIPINGSRAMLINE)) - -DO I=1,RamLine%NO_PIPINGSRAMLINE - RamLine%DIAM_RAMLINE_INCH(I)=BopStackInput%PIPINGS_RAMLINE(I,1) - RamLine%LENGT_RAMLINE(I)=BopStackInput%PIPINGS_RAMLINE(I,2) - RamLine%ROUGHNESS_RAMLINE(I)=BopStackInput%PIPINGS_RAMLINE(I,3) +data%State%BopStackInput%PIPINGS_RAMLINE(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance +data%State%BopStackInput%PIPINGS_RAMLINE(2,1:3)= (/2., 730., 0.03/) !Acc.end.horizontal +data%State%BopStackInput%PIPINGS_RAMLINE(3,1:3)= (/2., 2000., 0.03/) !Acc.end.vertical +data%State%BopStackInput%PIPINGS_RAMLINE(4,1:3)= (/2., 6000., 0.05/) !Hyd.hose +data%State%BopStackInput%PIPINGS_RAMLINE(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1 +data%State%BopStackInput%PIPINGS_RAMLINE(6,1:3)= (/2., 210., 0.03/) !Add.from.bend +data%State%BopStackInput%PIPINGS_RAMLINE(7,1:3)= (/1., 780., 0.03/) !Corner.horizontal1 +data%State%BopStackInput%PIPINGS_RAMLINE(8,1:3)= (/1., 780., 0.03/) !Corner.horizontal2 +data%State%BopStackInput%PIPINGS_RAMLINE(9,1:3)= (/1., 750., 0.03/) !Extra.length.back +data%State%BopStackInput%PIPINGS_RAMLINE(10,1:3)= (/1., 800., 0.03/) !Corner.horizontal3 +data%State%BopStackInput%PIPINGS_RAMLINE(11,1:3)= (/1., 1650., 0.03/) !Corner.vertical2 +data%State%BopStackInput%PIPINGS_RAMLINE(12,1:3)= (/1., 340., 0.03/) !12.Valves.horizontal +data%State%BopStackInput%PIPINGS_RAMLINE(13,1:3)= (/1., 1650., 0.03/) !Valves.vertical +data%State%BopStackInput%PIPINGS_RAMLINE(14,1:3)= (/1., 31000., 10./) !Hyd.hose +data%State%BopStackInput%PIPINGS_RAMLINE(15,1:3)= (/1., 526., 0.03/) !Add.from.bend + + + + ALLOCATE (data%State%RamLine%DIAM_RAMLINE_INCH(data%State%RamLine%NO_PIPINGSRAMLINE), & + data%State%RamLine%AREA_RAMLINE(data%State%RamLine%NO_PIPINGSRAMLINE),data%State%RamLine%LENGT_RAMLINE(data%State%RamLine%NO_PIPINGSRAMLINE),data%State%RamLine%ROUGHNESS_RAMLINE(data%State%RamLine%NO_PIPINGSRAMLINE),data%State%RamLine%RELROUGH_RAMLINE(data%State%RamLine%NO_PIPINGSRAMLINE) & + ,data%State%RAMS%Re_ramline(6,data%State%RamLine%NO_PIPINGSRAMLINE),data%State%RAMS%fric(6,data%State%RamLine%NO_PIPINGSRAMLINE),data%State%RAMS%fricloss(6,data%State%RamLine%NO_PIPINGSRAMLINE)) + +DO I=1,data%State%RamLine%NO_PIPINGSRAMLINE + data%State%RamLine%DIAM_RAMLINE_INCH(I)=data%State%BopStackInput%PIPINGS_RAMLINE(I,1) + data%State%RamLine%LENGT_RAMLINE(I)=data%State%BopStackInput%PIPINGS_RAMLINE(I,2) + data%State%RamLine%ROUGHNESS_RAMLINE(I)=data%State%BopStackInput%PIPINGS_RAMLINE(I,3) - RamLine%AREA_RAMLINE(I)=PI*(RamLine%DIAM_RAMLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m) - RamLine%RELROUGH_RAMLINE(I)=RamLine%ROUGHNESS_RAMLINE(I)/(RamLine%DIAM_RAMLINE_INCH(I)*25.4) !e/D + data%State%RamLine%AREA_RAMLINE(I)=PI*(data%State%RamLine%DIAM_RAMLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m) + data%State%RamLine%RELROUGH_RAMLINE(I)=data%State%RamLine%ROUGHNESS_RAMLINE(I)/(data%State%RamLine%DIAM_RAMLINE_INCH(I)*25.4) !e/D !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m) - RamLine%LENGT_RAMLINE(I)=RamLine%LENGT_RAMLINE(I)*.001 ! (m) + data%State%RamLine%LENGT_RAMLINE(I)=data%State%RamLine%LENGT_RAMLINE(I)*.001 ! (m) ENDDO @@ -166,160 +166,160 @@ ENDDO !=========================================================================== ! ANNULAR PREVENTER MINOR LOSSES INPUT !=========================================================================== -AnnularComputational%NO_MinorsAnnularLine=29 +data%State%AnnularComputational%NO_MinorsAnnularLine=29 -ALLOCATE (BopStackInput%MINORS_ANNULAR(AnnularComputational%NO_MinorsAnnularLine,4)) +ALLOCATE (data%State%BopStackInput%MINORS_ANNULAR(data%State%AnnularComputational%NO_MinorsAnnularLine,4)) ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION -BopStackInput%MINORS_ANNULAR(1,1:4)= (/2., 2., 0., 0./) !Acc.tee -BopStackInput%MINORS_ANNULAR(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee -BopStackInput%MINORS_ANNULAR(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee -BopStackInput%MINORS_ANNULAR(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee -BopStackInput%MINORS_ANNULAR(5,1:4)= (/2., 0.9, 0., 0./) !tee -BopStackInput%MINORS_ANNULAR(6,1:4)= (/2., 2., 0., 0./) !tee -BopStackInput%MINORS_ANNULAR(7,1:4)= (/2., 0., 105., 0./) !valve -BopStackInput%MINORS_ANNULAR(8,1:4)= (/2., 0.9, 0., 0./) !tee -BopStackInput%MINORS_ANNULAR(9,1:4)= (/2., 0., 105., 0./) !valve -BopStackInput%MINORS_ANNULAR(10,1:4)= (/2., 0.42, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(11,1:4)= (/2., 0.42, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(12,1:4)= (/2., 0.8, 0., 0./) !unionA -BopStackInput%MINORS_ANNULAR(13,1:4)= (/2., 0.8, 0., 0./) !unionA -BopStackInput%MINORS_ANNULAR(14,1:4)= (/2., 1.5, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(15,1:4)= (/2., 0., 425., 0./) !valve -BopStackInput%MINORS_ANNULAR(16,1:4)= (/2., 2., 0., 0./) !tee -BopStackInput%MINORS_ANNULAR(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR -BopStackInput%MINORS_ANNULAR(18,1:4)= (/1., 2., 0., 0./) !tee -BopStackInput%MINORS_ANNULAR(19,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(20,1:4)= (/1., 0.42, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(21,1:4)= (/1., 0.42, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(22,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(23,1:4)= (/1., 0., 3.2, 0./) !valve -BopStackInput%MINORS_ANNULAR(24,1:4)= (/1., 2., 0., 0./) !tee -BopStackInput%MINORS_ANNULAR(25,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(26,1:4)= (/1., 0.42, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(27,1:4)= (/1., 0.42, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(28,1:4)= (/1., 1.5, 0., 0./) !elbow -BopStackInput%MINORS_ANNULAR(29,1:4)= (/1., 0., 3.2, 0./) !valve - - - - ALLOCATE (AnnularComputational%MINORDIAMETER_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%AREAMINOR_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%LF_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine) & - ,AnnularComputational%CV_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%NOTE_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%minlosspa_ANNULAR(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%minloss_ANNULAR(AnnularComputational%NO_MinorsAnnularLine)) - - - -DO I=1,AnnularComputational%NO_MinorsAnnularLine - AnnularComputational%MINORDIAMETER_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,1) - AnnularComputational%LF_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,2) - AnnularComputational%CV_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,3) - AnnularComputational%NOTE_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,4) +data%State%BopStackInput%MINORS_ANNULAR(1,1:4)= (/2., 2., 0., 0./) !Acc.tee +data%State%BopStackInput%MINORS_ANNULAR(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee +data%State%BopStackInput%MINORS_ANNULAR(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee +data%State%BopStackInput%MINORS_ANNULAR(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee +data%State%BopStackInput%MINORS_ANNULAR(5,1:4)= (/2., 0.9, 0., 0./) !tee +data%State%BopStackInput%MINORS_ANNULAR(6,1:4)= (/2., 2., 0., 0./) !tee +data%State%BopStackInput%MINORS_ANNULAR(7,1:4)= (/2., 0., 105., 0./) !valve +data%State%BopStackInput%MINORS_ANNULAR(8,1:4)= (/2., 0.9, 0., 0./) !tee +data%State%BopStackInput%MINORS_ANNULAR(9,1:4)= (/2., 0., 105., 0./) !valve +data%State%BopStackInput%MINORS_ANNULAR(10,1:4)= (/2., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(11,1:4)= (/2., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(12,1:4)= (/2., 0.8, 0., 0./) !unionA +data%State%BopStackInput%MINORS_ANNULAR(13,1:4)= (/2., 0.8, 0., 0./) !unionA +data%State%BopStackInput%MINORS_ANNULAR(14,1:4)= (/2., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(15,1:4)= (/2., 0., 425., 0./) !valve +data%State%BopStackInput%MINORS_ANNULAR(16,1:4)= (/2., 2., 0., 0./) !tee +data%State%BopStackInput%MINORS_ANNULAR(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR +data%State%BopStackInput%MINORS_ANNULAR(18,1:4)= (/1., 2., 0., 0./) !tee +data%State%BopStackInput%MINORS_ANNULAR(19,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(20,1:4)= (/1., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(21,1:4)= (/1., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(22,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(23,1:4)= (/1., 0., 3.2, 0./) !valve +data%State%BopStackInput%MINORS_ANNULAR(24,1:4)= (/1., 2., 0., 0./) !tee +data%State%BopStackInput%MINORS_ANNULAR(25,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(26,1:4)= (/1., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(27,1:4)= (/1., 0.42, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(28,1:4)= (/1., 1.5, 0., 0./) !elbow +data%State%BopStackInput%MINORS_ANNULAR(29,1:4)= (/1., 0., 3.2, 0./) !valve + + + + ALLOCATE (data%State%AnnularComputational%MINORDIAMETER_ANNULARLINE(data%State%AnnularComputational%NO_MinorsAnnularLine),data%State%AnnularComputational%AREAMINOR_ANNULARLINE(data%State%AnnularComputational%NO_MinorsAnnularLine),data%State%AnnularComputational%LF_ANNULARLINE(data%State%AnnularComputational%NO_MinorsAnnularLine) & + ,data%State%AnnularComputational%CV_ANNULARLINE(data%State%AnnularComputational%NO_MinorsAnnularLine),data%State%AnnularComputational%NOTE_ANNULARLINE(data%State%AnnularComputational%NO_MinorsAnnularLine),data%State%AnnularComputational%minlosspa_ANNULAR(data%State%AnnularComputational%NO_MinorsAnnularLine),data%State%AnnularComputational%minloss_ANNULAR(data%State%AnnularComputational%NO_MinorsAnnularLine)) + + + +DO I=1,data%State%AnnularComputational%NO_MinorsAnnularLine + data%State%AnnularComputational%MINORDIAMETER_ANNULARLINE(I)=data%State%BopStackInput%MINORS_ANNULAR(I,1) + data%State%AnnularComputational%LF_ANNULARLINE(I)=data%State%BopStackInput%MINORS_ANNULAR(I,2) + data%State%AnnularComputational%CV_ANNULARLINE(I)=data%State%BopStackInput%MINORS_ANNULAR(I,3) + data%State%AnnularComputational%NOTE_ANNULARLINE(I)=data%State%BopStackInput%MINORS_ANNULAR(I,4) - AnnularComputational%AREAMINOR_ANNULARLINE(I)=PI*(AnnularComputational%MINORDIAMETER_ANNULARLINE(I)*0.0254)**2/4. !D(in), AREA(m) + data%State%AnnularComputational%AREAMINOR_ANNULARLINE(I)=PI*(data%State%AnnularComputational%MINORDIAMETER_ANNULARLINE(I)*0.0254)**2/4. !D(in), AREA(m) ENDDO !=========================================================================== ! ANNULAR PREVENTER PIPNING LOSSES INPUT !=========================================================================== -AnnularComputational%NO_PipingsAnnularLine=10 +data%State%AnnularComputational%NO_PipingsAnnularLine=10 -ALLOCATE (BopStackInput%PIPINGS_ANNULAR(AnnularComputational%NO_PipingsAnnularLine,3)) +ALLOCATE (data%State%BopStackInput%PIPINGS_ANNULAR(data%State%AnnularComputational%NO_PipingsAnnularLine,3)) ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION -BopStackInput%PIPINGS_ANNULAR(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance -BopStackInput%PIPINGS_ANNULAR(2,1:3)= (/2., 730., 0.03/) !Acc.endhorizontal -BopStackInput%PIPINGS_ANNULAR(3,1:3)= (/2., 2000., 0.03/) !Acc.endvertical -BopStackInput%PIPINGS_ANNULAR(4,1:3)= (/2., 6000., 0.03/) !Hyd.hose -BopStackInput%PIPINGS_ANNULAR(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1 -BopStackInput%PIPINGS_ANNULAR(6,1:3)= (/2., 210., 0.03/) !Add.frombend -BopStackInput%PIPINGS_ANNULAR(7,1:3)= (/2., 1000., 0.03/) !manifold -BopStackInput%PIPINGS_ANNULAR(8,1:3)= (/1., 46000., 0.03/) !pipe -BopStackInput%PIPINGS_ANNULAR(9,1:3)= (/2., 1000., 0.03/) !manifold -BopStackInput%PIPINGS_ANNULAR(10,1:3)= (/1., 46000., 0.03/) !pipe +data%State%BopStackInput%PIPINGS_ANNULAR(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance +data%State%BopStackInput%PIPINGS_ANNULAR(2,1:3)= (/2., 730., 0.03/) !Acc.endhorizontal +data%State%BopStackInput%PIPINGS_ANNULAR(3,1:3)= (/2., 2000., 0.03/) !Acc.endvertical +data%State%BopStackInput%PIPINGS_ANNULAR(4,1:3)= (/2., 6000., 0.03/) !Hyd.hose +data%State%BopStackInput%PIPINGS_ANNULAR(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1 +data%State%BopStackInput%PIPINGS_ANNULAR(6,1:3)= (/2., 210., 0.03/) !Add.frombend +data%State%BopStackInput%PIPINGS_ANNULAR(7,1:3)= (/2., 1000., 0.03/) !manifold +data%State%BopStackInput%PIPINGS_ANNULAR(8,1:3)= (/1., 46000., 0.03/) !pipe +data%State%BopStackInput%PIPINGS_ANNULAR(9,1:3)= (/2., 1000., 0.03/) !manifold +data%State%BopStackInput%PIPINGS_ANNULAR(10,1:3)= (/1., 46000., 0.03/) !pipe - ALLOCATE (AnnularComputational%DIAM_ANNULARLINE_INCH(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%AREA_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%LENGT_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine) & - ,AnnularComputational%ROUGHNESS_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%RELROUGH_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine) & - ,AnnularComputational%Re_ANNULARline(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%fricANNULAR(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%friclossANNULAR(AnnularComputational%NO_PipingsAnnularLine)) + ALLOCATE (data%State%AnnularComputational%DIAM_ANNULARLINE_INCH(data%State%AnnularComputational%NO_PipingsAnnularLine),data%State%AnnularComputational%AREA_ANNULARLINE(data%State%AnnularComputational%NO_PipingsAnnularLine),data%State%AnnularComputational%LENGT_ANNULARLINE(data%State%AnnularComputational%NO_PipingsAnnularLine) & + ,data%State%AnnularComputational%ROUGHNESS_ANNULARLINE(data%State%AnnularComputational%NO_PipingsAnnularLine),data%State%AnnularComputational%RELROUGH_ANNULARLINE(data%State%AnnularComputational%NO_PipingsAnnularLine) & + ,data%State%AnnularComputational%Re_ANNULARline(data%State%AnnularComputational%NO_PipingsAnnularLine),data%State%AnnularComputational%fricANNULAR(data%State%AnnularComputational%NO_PipingsAnnularLine),data%State%AnnularComputational%friclossANNULAR(data%State%AnnularComputational%NO_PipingsAnnularLine)) -DO I=1,AnnularComputational%NO_PipingsAnnularLine - AnnularComputational%DIAM_ANNULARLINE_INCH(I)=BopStackInput%PIPINGS_ANNULAR(I,1) - AnnularComputational%LENGT_ANNULARLINE(I)=BopStackInput%PIPINGS_ANNULAR(I,2) - AnnularComputational%ROUGHNESS_ANNULARLINE(I)=BopStackInput%PIPINGS_ANNULAR(I,3) +DO I=1,data%State%AnnularComputational%NO_PipingsAnnularLine + data%State%AnnularComputational%DIAM_ANNULARLINE_INCH(I)=data%State%BopStackInput%PIPINGS_ANNULAR(I,1) + data%State%AnnularComputational%LENGT_ANNULARLINE(I)=data%State%BopStackInput%PIPINGS_ANNULAR(I,2) + data%State%AnnularComputational%ROUGHNESS_ANNULARLINE(I)=data%State%BopStackInput%PIPINGS_ANNULAR(I,3) - AnnularComputational%AREA_ANNULARLINE(I)=PI*(AnnularComputational%DIAM_ANNULARLINE_INCH(I)*0.0254)**2/4. !D(in), AREA(m) - AnnularComputational%RELROUGH_ANNULARLINE(I)=AnnularComputational%ROUGHNESS_ANNULARLINE(I)/(AnnularComputational%DIAM_ANNULARLINE_INCH(I)*25.4) + data%State%AnnularComputational%AREA_ANNULARLINE(I)=PI*(data%State%AnnularComputational%DIAM_ANNULARLINE_INCH(I)*0.0254)**2/4. !D(in), AREA(m) + data%State%AnnularComputational%RELROUGH_ANNULARLINE(I)=data%State%AnnularComputational%ROUGHNESS_ANNULARLINE(I)/(data%State%AnnularComputational%DIAM_ANNULARLINE_INCH(I)*25.4) !DIAM_ANNULARLINE_MM(I)=DIAM_ANNULARLINE_MM(I)*.001 ! (m) - AnnularComputational%LENGT_ANNULARLINE(I)=AnnularComputational%LENGT_ANNULARLINE(I)*.001 ! (m) + data%State%AnnularComputational%LENGT_ANNULARLINE(I)=data%State%AnnularComputational%LENGT_ANNULARLINE(I)*.001 ! (m) ENDDO !=========================================================================== ! AIR PUMP LOSSES INPUT !=========================================================================== -RamLine%NO_PIPINGS_AIRPLINE=1 +data%State%RamLine%NO_PIPINGS_AIRPLINE=1 -ALLOCATE (BopStackInput%PIPINGS_AIRPUMP(RamLine%NO_PIPINGS_AIRPLINE,3)) +ALLOCATE (data%State%BopStackInput%PIPINGS_AIRPUMP(data%State%RamLine%NO_PIPINGS_AIRPLINE,3)) ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION -BopStackInput%PIPINGS_AIRPUMP(1,1:3)= (/2., 10000., 0.03/) !Avg.acc.distance +data%State%BopStackInput%PIPINGS_AIRPUMP(1,1:3)= (/2., 10000., 0.03/) !Avg.acc.distance - ALLOCATE (RamLine%DIAM_AIR_INCH(RamLine%NO_PIPINGS_AIRPLINE),RamLine%Re_air(RamLine%NO_PIPINGS_AIRPLINE),RamLine%AREA_AIR(RamLine%NO_PIPINGS_AIRPLINE), & - RamLine%LENGT_AIR(RamLine%NO_PIPINGS_AIRPLINE),RamLine%ROUGHNESS_AIRPLINE(RamLine%NO_PIPINGS_AIRPLINE),RamLine%REL_ROUGHAIR(RamLine%NO_PIPINGS_AIRPLINE), & - RamLine%fric_air(RamLine%NO_PIPINGS_AIRPLINE),RamLine%fricloss_air(RamLine%NO_PIPINGS_AIRPLINE)) + ALLOCATE (data%State%RamLine%DIAM_AIR_INCH(data%State%RamLine%NO_PIPINGS_AIRPLINE),data%State%RamLine%Re_air(data%State%RamLine%NO_PIPINGS_AIRPLINE),data%State%RamLine%AREA_AIR(data%State%RamLine%NO_PIPINGS_AIRPLINE), & + data%State%RamLine%LENGT_AIR(data%State%RamLine%NO_PIPINGS_AIRPLINE),data%State%RamLine%ROUGHNESS_AIRPLINE(data%State%RamLine%NO_PIPINGS_AIRPLINE),data%State%RamLine%REL_ROUGHAIR(data%State%RamLine%NO_PIPINGS_AIRPLINE), & + data%State%RamLine%fric_air(data%State%RamLine%NO_PIPINGS_AIRPLINE),data%State%RamLine%fricloss_air(data%State%RamLine%NO_PIPINGS_AIRPLINE)) -DO I=1,RamLine%NO_PIPINGS_AIRPLINE - RamLine%DIAM_AIR_INCH(I)=BopStackInput%PIPINGS_AIRPUMP(I,1) - RamLine%LENGT_AIR(I)=BopStackInput%PIPINGS_AIRPUMP(I,2) - RamLine%ROUGHNESS_AIRPLINE(I)=BopStackInput%PIPINGS_AIRPUMP(I,3) +DO I=1,data%State%RamLine%NO_PIPINGS_AIRPLINE + data%State%RamLine%DIAM_AIR_INCH(I)=data%State%BopStackInput%PIPINGS_AIRPUMP(I,1) + data%State%RamLine%LENGT_AIR(I)=data%State%BopStackInput%PIPINGS_AIRPUMP(I,2) + data%State%RamLine%ROUGHNESS_AIRPLINE(I)=data%State%BopStackInput%PIPINGS_AIRPUMP(I,3) - RamLine%AREA_AIR(I)=PI*(RamLine%DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m) - RamLine%REL_ROUGHAIR(I)=RamLine%ROUGHNESS_AIRPLINE(I)/(RamLine%DIAM_AIR_INCH(I)*25.4) + data%State%RamLine%AREA_AIR(I)=PI*(data%State%RamLine%DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m) + data%State%RamLine%REL_ROUGHAIR(I)=data%State%RamLine%ROUGHNESS_AIRPLINE(I)/(data%State%RamLine%DIAM_AIR_INCH(I)*25.4) !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m) - RamLine%LENGT_AIR(I)=RamLine%LENGT_AIR(I)*.001 ! (m) + data%State%RamLine%LENGT_AIR(I)=data%State%RamLine%LENGT_AIR(I)*.001 ! (m) ENDDO !================================================================ -RamLine%NO_MINORS_AIRPLINE=6 +data%State%RamLine%NO_MINORS_AIRPLINE=6 -ALLOCATE (BopStackInput%MINORS_AIRPUMP(RamLine%NO_MINORS_AIRPLINE,4)) +ALLOCATE (data%State%BopStackInput%MINORS_AIRPUMP(data%State%RamLine%NO_MINORS_AIRPLINE,4)) ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION -BopStackInput%MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee -BopStackInput%MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow -BopStackInput%MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter -BopStackInput%MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve -BopStackInput%MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve -BopStackInput%MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA +data%State%BopStackInput%MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee +data%State%BopStackInput%MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow +data%State%BopStackInput%MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter +data%State%BopStackInput%MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve +data%State%BopStackInput%MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve +data%State%BopStackInput%MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA - ALLOCATE (RamLine%MINORDIAM_AIR_INCH(RamLine%NO_MINORS_AIRPLINE),RamLine%MINORAREA_AIR(RamLine%NO_MINORS_AIRPLINE), & - RamLine%LF_AIR(RamLine%NO_MINORS_AIRPLINE),RamLine%CV_AIR(RamLine%NO_MINORS_AIRPLINE),RamLine%NOTE_AIR(RamLine%NO_MINORS_AIRPLINE) & - ,RamLine%minlosspa_air(RamLine%NO_MINORS_AIRPLINE),RamLine%minloss_air(RamLine%NO_MINORS_AIRPLINE)) + ALLOCATE (data%State%RamLine%MINORDIAM_AIR_INCH(data%State%RamLine%NO_MINORS_AIRPLINE),data%State%RamLine%MINORAREA_AIR(data%State%RamLine%NO_MINORS_AIRPLINE), & + data%State%RamLine%LF_AIR(data%State%RamLine%NO_MINORS_AIRPLINE),data%State%RamLine%CV_AIR(data%State%RamLine%NO_MINORS_AIRPLINE),data%State%RamLine%NOTE_AIR(data%State%RamLine%NO_MINORS_AIRPLINE) & + ,data%State%RamLine%minlosspa_air(data%State%RamLine%NO_MINORS_AIRPLINE),data%State%RamLine%minloss_air(data%State%RamLine%NO_MINORS_AIRPLINE)) -DO I=1,RamLine%NO_MINORS_AIRPLINE - RamLine%MINORDIAM_AIR_INCH(I)=BopStackInput%MINORS_AIRPUMP(I,1) - RamLine%LF_AIR(I)=BopStackInput%MINORS_AIRPUMP(I,2) - RamLine%CV_AIR(I)=BopStackInput%MINORS_AIRPUMP(I,3) - RamLine%NOTE_AIR(I)=BopStackInput%MINORS_AIRPUMP(I,4) +DO I=1,data%State%RamLine%NO_MINORS_AIRPLINE + data%State%RamLine%MINORDIAM_AIR_INCH(I)=data%State%BopStackInput%MINORS_AIRPUMP(I,1) + data%State%RamLine%LF_AIR(I)=data%State%BopStackInput%MINORS_AIRPUMP(I,2) + data%State%RamLine%CV_AIR(I)=data%State%BopStackInput%MINORS_AIRPUMP(I,3) + data%State%RamLine%NOTE_AIR(I)=data%State%BopStackInput%MINORS_AIRPUMP(I,4) - RamLine%MINORAREA_AIR(I)=PI*(RamLine%MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m) + data%State%RamLine%MINORAREA_AIR(I)=PI*(data%State%RamLine%MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m) ENDDO @@ -327,10 +327,11 @@ ENDDO END SUBROUTINE pumps_charge_bottle() -USE VARIABLES +use ConfigurationVariables USE CAccumulatorVariables USE CBopStackVariables -USE CBopControlPanelVariables +use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables implicit none @@ -338,10 +339,10 @@ implicit none !Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously !write(*,*) 'pumps_charge_bottle' - if(BopControlPanel%ByePassValve == -1.0) then - BopStackAcc%ByPassOld= -1.0 - elseif(BopControlPanel%ByePassValve == 1.0) then - BopStackAcc%ByPassOld= 1.0 + if(data%EquipmentControl%BopControlPanel%ByePassValve == -1.0) then + data%State%BopStackAcc%ByPassOld= -1.0 + elseif(data%EquipmentControl%BopControlPanel%ByePassValve == 1.0) then + data%State%BopStackAcc%ByPassOld= 1.0 endif @@ -351,36 +352,36 @@ implicit none !for charging bottles by the pump !((((((((IN OUTER LOOP)))))) ! ba1=1003; ba2=.03375; ba3=4.014; ba4=.2458; -if (RamLine%AIRP_SWITCH==0) Pumps%DELTAV_AIR=0 -RamLine%FVR=RamLine%FVR+Pumps%DELTAV_AIR+Pumps%DELTAV_ELECP +if (data%State%RamLine%AIRP_SWITCH==0) data%State%Pumps%DELTAV_AIR=0 +data%State%RamLine%FVR=data%State%RamLine%FVR+data%State%Pumps%DELTAV_AIR+data%State%Pumps%DELTAV_ELECP -RamLine%pacc_before=RamLine%P_ACC -RamLine%P_ACC=RamLine%B1*exp(RamLine%B2*RamLine%FVR/BopStackAcc%NOBOTTLES)+RamLine%B3*exp(RamLine%B4*RamLine%FVR/BopStackAcc%NOBOTTLES) ! adiabatic(psig)<<<< 8=no. of bottles +data%State%RamLine%pacc_before=data%State%RamLine%P_ACC +data%State%RamLine%P_ACC=data%State%RamLine%B1*exp(data%State%RamLine%B2*data%State%RamLine%FVR/data%State%BopStackAcc%NOBOTTLES)+data%State%RamLine%B3*exp(data%State%RamLine%B4*data%State%RamLine%FVR/data%State%BopStackAcc%NOBOTTLES) ! adiabatic(psig)<<<< 8=no. of bottles !===================================================================== - if(BopStackAcc%ByPassOld == 1.0) then + if(data%State%BopStackAcc%ByPassOld == 1.0) then - if (BopStackAcc%pram_reg BaseDifferenceP) then - BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. + if (ABS(data%State%BopStackAcc%PressureDifference) > BaseDifferenceP) then + data%State%BopStackAcc%pram_reg= data%State%BopStackAcc%pram_reg + (data%State%BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. else - if (BopStackAcc%pram_reg BaseDifferenceP) then - BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. + data%State%BopStackAcc%PressureDifference= data%State%RamLine%P_ACC- MAXVAL(data%State%RAM%loss_before) - data%State%BopStackAcc%pram_reg + if (ABS(data%State%BopStackAcc%PressureDifference) > BaseDifferenceP) then + data%State%BopStackAcc%pram_reg= data%State%BopStackAcc%pram_reg + (data%State%BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. else - BopStackAcc%pram_reg= RamLine%P_ACC- MAXVAL(RAM%loss_before) + data%State%BopStackAcc%pram_reg= data%State%RamLine%P_ACC- MAXVAL(data%State%RAM%loss_before) endif endif @@ -412,39 +413,39 @@ RamLine%P_ACC=RamLine%B1*exp(RamLine%B2*RamLine%FVR/BopStackAcc%NOBOTTLES)+RamLi SUBROUTINE airpump_code() -USE VARIABLES +use ConfigurationVariables use CSounds implicit none INTEGER I -Pumps%QAIR=Pumps%Qiter+.1 !(gpm) maximum flow for the start -RamLine%diffp_air=-10 -RamLine%losses_air=10 +data%State%Pumps%QAIR=data%State%Pumps%Qiter+.1 !(gpm) maximum flow for the start +data%State%RamLine%diffp_air=-10 +data%State%RamLine%losses_air=10 !=================================================================== ! AIR OPERATED PUMP !=================for air consumption at 8 bar====================== -do while (RamLine%diffp_air<0) - Pumps%QAIR=Pumps%QAIR-.1 +do while (data%State%RamLine%diffp_air<0) + data%State%Pumps%QAIR=data%State%Pumps%QAIR-.1 ! Qup=QAIR_PUMP; ! bba1 =31.8; bba2 =-725.7 ; bba3 =4154; - Pumps%P_AIRP=RamLine%BBA1*Pumps%QAIR**2+RamLine%BBA2*Pumps%QAIR+RamLine%BBA3 !(psig) - RamLine%kinetic_air=sg*wdens*(Pumps%QAIR*6.30902e-5/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi) + data%State%Pumps%P_AIRP=data%State%RamLine%BBA1*data%State%Pumps%QAIR**2+data%State%RamLine%BBA2*data%State%Pumps%QAIR+data%State%RamLine%BBA3 !(psig) + data%State%RamLine%kinetic_air=sg*wdens*(data%State%Pumps%QAIR*6.30902e-5/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi) - RamLine%diffp_air=Pumps%P_AIRP+RamLine%kinetic_air-RamLine%P_ACC + data%State%RamLine%diffp_air=data%State%Pumps%P_AIRP+data%State%RamLine%kinetic_air-data%State%RamLine%P_ACC end do !returns Qup - do while (abs((RamLine%diffp_air-RamLine%losses_air)/RamLine%diffp_air)>Pumps%TOL_AIR) !finding correct QAIR_pump for 1 timecounter_ram + do while (abs((data%State%RamLine%diffp_air-data%State%RamLine%losses_air)/data%State%RamLine%diffp_air)>data%State%Pumps%TOL_AIR) !finding correct QAIR_pump for 1 timecounter_ram -if (RamLine%diffp_air-RamLine%losses_air>0) then - Pumps%QAIR=Pumps%QAIR+.01 +if (data%State%RamLine%diffp_air-data%State%RamLine%losses_air>0) then + data%State%Pumps%QAIR=data%State%Pumps%QAIR+.01 else - Pumps%QAIR=Pumps%QAIR-.01 + data%State%Pumps%QAIR=data%State%Pumps%QAIR-.01 endif !=================================================================== @@ -452,79 +453,79 @@ endif ! Maximator - Model: GX (35) !=================for air consumption at 8 bar====================== - Pumps%P_AIRP=RamLine%BBA1*Pumps%QAIR**2+RamLine%BBA2*Pumps%QAIR+RamLine%BBA3 !(psig) - RamLine%kinetic_air=sg*wdens*(Pumps%QAIR*6.30902e-005/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi) + data%State%Pumps%P_AIRP=data%State%RamLine%BBA1*data%State%Pumps%QAIR**2+data%State%RamLine%BBA2*data%State%Pumps%QAIR+data%State%RamLine%BBA3 !(psig) + data%State%RamLine%kinetic_air=sg*wdens*(data%State%Pumps%QAIR*6.30902e-005/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi) - RamLine%diffp_air=Pumps%P_AIRP+RamLine%kinetic_air-RamLine%P_ACC + data%State%RamLine%diffp_air=data%State%Pumps%P_AIRP+data%State%RamLine%kinetic_air-data%State%RamLine%P_ACC !===========================LOSSES==================================== - do i=1,RamLine%NO_PIPINGS_AIRPLINE -RamLine%Re_air(i)=Pumps%QAIR*6.30902e-005*RamLine%DIAM_AIR_INCH(I)*0.0254/(RamLine%AREA_AIR(i)*nu) + do i=1,data%State%RamLine%NO_PIPINGS_AIRPLINE +data%State%RamLine%Re_air(i)=data%State%Pumps%QAIR*6.30902e-005*data%State%RamLine%DIAM_AIR_INCH(I)*0.0254/(data%State%RamLine%AREA_AIR(i)*nu) enddo -do i=1,RamLine%NO_PIPINGS_AIRPLINE - if (RamLine%Re_air(i)ShearRam%NeededVolumeShearRams) then + if ( data%State%RAM(RNUMBER)%vdis_tot>data%State%ShearRAM%NeededVolumeShearRams) then - RamLine%ShearBop_closed=1 + data%State%RamLine%ShearBop_closed=1 !ShearBop_closed_withPossibility= ShearBop_closed * TD_BOPConnectionPossibility(3) - BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17) - RamLine%P_ACC= RAM(RNUMBER)%p_acccheck - - if (RamLine%ShearRamIsClosing) then - ShearRam%IDshearBop=0. + ShearRam%ShearIsNotAllowed*ShearRam%ODDrillpipe_inShearRam - BopControlPanel%MiddleRamsCloseLED = LedOn - BopStackInput%MiddleRamsCloseLEDMine = LedOn - BopControlPanel%MiddleRamsOpenLED = LedOff - BopStackInput%MiddleRamsOpenLEDMine = LedOff - if (TD_BOP%BOPConnectionPossibility(3) == 1 .and. ShearRam%ShearIsNotAllowed==0) then + data%State%BopStackAcc%pram_reg=data%State%BopStackAcc%pram_reg+data%State%RAMS%minloss(RNUMBER,17) + data%State%RamLine%P_ACC= data%State%RAM(RNUMBER)%p_acccheck + + if (data%State%RamLine%ShearRamIsClosing) then + data%State%ShearRAM%IDshearBop=0. + data%State%ShearRAM%ShearIsNotAllowed*data%State%ShearRAM%ODDrillpipe_inShearRam + data%EquipmentControl%BopControlPanel%MiddleRamsCloseLED = LedOn + data%State%BopStackInput%MiddleRamsCloseLEDMine = LedOn + data%EquipmentControl%BopControlPanel%MiddleRamsOpenLED = LedOff + data%State%BopStackInput%MiddleRamsOpenLEDMine = LedOff + if (data%State%TD_BOP%BOPConnectionPossibility(3) == 1 .and. data%State%ShearRAM%ShearIsNotAllowed==0) then CALL CloseMiddleRams - RamLine%ShearBop_Situation_forTD= 1 ! closed - for TD code + data%State%RamLine%ShearBop_Situation_forTD= 1 ! closed - for TD code endif endif - if (RamLine%ShearRamIsOpening) then - ShearRam%IDshearBop=ShearRam%IDshearBopBase - BopControlPanel%MiddleRamsOpenLED = LedOn - BopStackInput%MiddleRamsOpenLEDMine = LedOn - BopControlPanel%MiddleRamsCloseLED = LedOff - BopStackInput%MiddleRamsCloseLEDMine = LedOff + if (data%State%RamLine%ShearRamIsOpening) then + data%State%ShearRAM%IDshearBop=data%State%ShearRAM%IDshearBopBase + data%EquipmentControl%BopControlPanel%MiddleRamsOpenLED = LedOn + data%State%BopStackInput%MiddleRamsOpenLEDMine = LedOn + data%EquipmentControl%BopControlPanel%MiddleRamsCloseLED = LedOff + data%State%BopStackInput%MiddleRamsCloseLEDMine = LedOff CALL OpenMiddleRams - RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code + data%State%RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code endif endif - ShearRam%IDshearBopFinal= ShearRam%IDshearBop ! for output data + data%State%ShearRAM%IDshearBopFinal= data%State%ShearRAM%IDshearBop ! for output data endif if (ramtype==2) then !for pipe ram1 - if (PipeRam1%IsClosing) then - PipeRam1%ID=(2.*(PipeRam1%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A)+max(PipeRam1%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase) + if (data%State%PipeRam1%IsClosing) then + data%State%PipeRam1%ID=(2.*(data%State%PipeRam1%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%PipeRam1%A)+max(data%State%PipeRam1%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase) endif - if (PipeRam1%IsOpening) then - PipeRam1%ID=PipeRam1%IDBase-2.*(PipeRam1%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A + if (data%State%PipeRam1%IsOpening) then + data%State%PipeRam1%ID=data%State%PipeRam1%IDBase-2.*(data%State%PipeRam1%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%PipeRam1%A endif - if ( RAM(RNUMBER)%vdis_tot>PipeRam1%NeededVolume) then + if ( data%State%RAM(RNUMBER)%vdis_tot>data%State%PipeRam1%NeededVolume) then - PipeRam1%closed=1 + data%State%PipeRam1%closed=1 !PipeRam1_Situation_forTD= PipeRam1_closed * TD_BOPConnectionPossibility(2) - BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17) - RamLine%P_ACC= RAM(RNUMBER)%p_acccheck - - if (PipeRam1%IsClosing) then - PipeRam1%ID=max(PipeRam1%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase) - BopControlPanel%UpperRamsCloseLED = LedOn - BopStackInput%UpperRamsCloseLEDMine = LedOn - BopControlPanel%UpperRamsOpenLED = LedOff - BopStackInput%UpperRamsOpenLEDMine = LedOff - if (TD_BOP%BOPConnectionPossibility(2) == 1) then + data%State%BopStackAcc%pram_reg=data%State%BopStackAcc%pram_reg+data%State%RAMS%minloss(RNUMBER,17) + data%State%RamLine%P_ACC= data%State%RAM(RNUMBER)%p_acccheck + + if (data%State%PipeRam1%IsClosing) then + data%State%PipeRam1%ID=max(data%State%PipeRam1%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase) + data%EquipmentControl%BopControlPanel%UpperRamsCloseLED = LedOn + data%State%BopStackInput%UpperRamsCloseLEDMine = LedOn + data%EquipmentControl%BopControlPanel%UpperRamsOpenLED = LedOff + data%State%BopStackInput%UpperRamsOpenLEDMine = LedOff + if (data%State%TD_BOP%BOPConnectionPossibility(2) == 1) then CALL CloseUpperRams ! for C code call Set_BlowoutFromAnnular(.true.) - PipeRam1%Situation_forTD= 1 ! closed - for TD code + data%State%PipeRam1%Situation_forTD= 1 ! closed - for TD code endif endif - if (PipeRam1%IsOpening) then - PipeRam1%ID=PipeRam1%IDBase - BopControlPanel%UpperRamsOpenLED = LedOn - BopStackInput%UpperRamsOpenLEDMine = LedOn - BopControlPanel%UpperRamsCloseLED = LedOff - BopStackInput%UpperRamsCloseLEDMine = LedOff + if (data%State%PipeRam1%IsOpening) then + data%State%PipeRam1%ID=data%State%PipeRam1%IDBase + data%EquipmentControl%BopControlPanel%UpperRamsOpenLED = LedOn + data%State%BopStackInput%UpperRamsOpenLEDMine = LedOn + data%EquipmentControl%BopControlPanel%UpperRamsCloseLED = LedOff + data%State%BopStackInput%UpperRamsCloseLEDMine = LedOff Call OpenUpperRams ! for C code - PipeRam1%Situation_forTD= 0 ! open - for TD code + data%State%PipeRam1%Situation_forTD= 0 ! open - for TD code endif endif - ShearRam%IDPipeRam1Final= PipeRam1%ID ! for output data + data%State%ShearRAM%IDPipeRam1Final= data%State%PipeRam1%ID ! for output data endif if (ramtype==3) then !for pipe ram2 - if (PipeRam2%IsClosing) then - PipeRam2%ID=(2.*(PipeRam2%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A)+max(PipeRam2%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase) + if (data%State%PipeRam2%IsClosing) then + data%State%PipeRam2%ID=(2.*(data%State%PipeRam2%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%PipeRam1%A)+max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase) endif - if (PipeRam2%IsOpening) then - PipeRam2%ID=PipeRam1%IDBase-2.*(PipeRam2%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A + if (data%State%PipeRam2%IsOpening) then + data%State%PipeRam2%ID=data%State%PipeRam1%IDBase-2.*(data%State%PipeRam2%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%PipeRam1%A endif - if ( RAM(RNUMBER)%vdis_tot>PipeRam2%NeededVolume) then + if ( data%State%RAM(RNUMBER)%vdis_tot>data%State%PipeRam2%NeededVolume) then - PipeRam2%closed=1 + data%State%PipeRam2%closed=1 !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4) - BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17) - RamLine%P_ACC= RAM(RNUMBER)%p_acccheck - - if (PipeRam2%IsClosing) then - PipeRam2%ID=max(PipeRam2%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase) - BopControlPanel%LowerRamsCloseLED = LedOn - BopStackInput%LowerRamsCloseLEDMine = LedOn - BopControlPanel%LowerRamsOpenLED = LedOff - BopStackInput%LowerRamsOpenLEDMine = LedOff - if (TD_BOP%BOPConnectionPossibility(4) == 1) then + data%State%BopStackAcc%pram_reg=data%State%BopStackAcc%pram_reg+data%State%RAMS%minloss(RNUMBER,17) + data%State%RamLine%P_ACC= data%State%RAM(RNUMBER)%p_acccheck + + if (data%State%PipeRam2%IsClosing) then + data%State%PipeRam2%ID=max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase) + data%EquipmentControl%BopControlPanel%LowerRamsCloseLED = LedOn + data%State%BopStackInput%LowerRamsCloseLEDMine = LedOn + data%EquipmentControl%BopControlPanel%LowerRamsOpenLED = LedOff + data%State%BopStackInput%LowerRamsOpenLEDMine = LedOff + if (data%State%TD_BOP%BOPConnectionPossibility(4) == 1) then CALL CloseLowerRams - PipeRam2%Situation_forTD= 1 ! closed - for TD code + data%State%PipeRam2%Situation_forTD= 1 ! closed - for TD code endif endif - if (PipeRam2%IsOpening) then - PipeRam2%ID=PipeRam1%IDBase - BopControlPanel%LowerRamsOpenLED = LedOn - BopStackInput%LowerRamsOpenLEDMine = LedOn - BopControlPanel%LowerRamsCloseLED = LedOff - BopStackInput%LowerRamsCloseLEDMine = LedOff + if (data%State%PipeRam2%IsOpening) then + data%State%PipeRam2%ID=data%State%PipeRam1%IDBase + data%EquipmentControl%BopControlPanel%LowerRamsOpenLED = LedOn + data%State%BopStackInput%LowerRamsOpenLEDMine = LedOn + data%EquipmentControl%BopControlPanel%LowerRamsCloseLED = LedOff + data%State%BopStackInput%LowerRamsCloseLEDMine = LedOff CALL OpenLowerRams - PipeRam2%Situation_forTD= 0 ! open - for TD code + data%State%PipeRam2%Situation_forTD= 0 ! open - for TD code endif endif - ShearRam%IDPipeRam2Final= PipeRam2%ID ! for output data + data%State%ShearRAM%IDPipeRam2Final= data%State%PipeRam2%ID ! for output data endif if (ramtype==4) then !for Choke Line - if (ChokeLine%IsClosing) then - ChokeLine%ID=(2.*(ChokeLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./ChokeLine%Abop)+max(ChokeLine%ODDrillpipe_in,ChokeLine%ODDrillpipe_inBase) + if (data%State%ChokeLine%IsClosing) then + data%State%ChokeLine%ID=(2.*(data%State%ChokeLine%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%ChokeLine%Abop)+max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase) endif - if (ChokeLine%IsOpening) then - ChokeLine%ID=ChokeLine%IDBase-2.*(ChokeLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./ChokeLine%Abop + if (data%State%ChokeLine%IsOpening) then + data%State%ChokeLine%ID=data%State%ChokeLine%IDBase-2.*(data%State%ChokeLine%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%ChokeLine%Abop endif - if ( RAM(RNUMBER)%vdis_tot>ChokeLine%NeededVolume) then + if ( data%State%RAM(RNUMBER)%vdis_tot>data%State%ChokeLine%NeededVolume) then - ChokeLine%closed=1 - BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17) - RamLine%P_ACC= RAM(RNUMBER)%p_acccheck + data%State%ChokeLine%closed=1 + data%State%BopStackAcc%pram_reg=data%State%BopStackAcc%pram_reg+data%State%RAMS%minloss(RNUMBER,17) + data%State%RamLine%P_ACC= data%State%RAM(RNUMBER)%p_acccheck - if (ChokeLine%IsClosing) then - ChokeLine%ID=max(ChokeLine%ODDrillpipe_in,ChokeLine%ODDrillpipe_inBase) - BopControlPanel%ChokeLineCloseLED = LedOn - BopStackInput%ChokeLineCloseLEDMine = LedOn - BopControlPanel%ChokeLineOpenLED = LedOff - BopStackInput%ChokeLineOpenLEDMine = LedOff + if (data%State%ChokeLine%IsClosing) then + data%State%ChokeLine%ID=max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase) + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOn + data%State%BopStackInput%ChokeLineCloseLEDMine = LedOn + data%EquipmentControl%BopControlPanel%ChokeLineOpenLED = LedOff + data%State%BopStackInput%ChokeLineOpenLEDMine = LedOff CALL CloseChokeLine endif - if (ChokeLine%IsOpening) then - ChokeLine%ID=ChokeLine%IDBase - BopControlPanel%ChokeLineOpenLED = LedOn - BopStackInput%ChokeLineOpenLEDMine = LedOn - BopControlPanel%ChokeLineCloseLED = LedOff - BopStackInput%ChokeLineCloseLEDMine = LedOff + if (data%State%ChokeLine%IsOpening) then + data%State%ChokeLine%ID=data%State%ChokeLine%IDBase + data%EquipmentControl%BopControlPanel%ChokeLineOpenLED = LedOn + data%State%BopStackInput%ChokeLineOpenLEDMine = LedOn + data%EquipmentControl%BopControlPanel%ChokeLineCloseLED = LedOff + data%State%BopStackInput%ChokeLineCloseLEDMine = LedOff CALL OpenChokeLine endif @@ -943,35 +945,35 @@ endif if (ramtype==5) then !for Kill Line - if (KillLine%IsClosing) then - KillLine%ID=(2.*(KillLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./KillLine%Abop)+max(KillLine%ODDrillpipe_in,KillLine%ODDrillpipe_inBase) + if (data%State%KillLine%IsClosing) then + data%State%KillLine%ID=(2.*(data%State%KillLine%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%KillLine%Abop)+max(data%State%KillLine%ODDrillpipe_in,data%State%KillLine%ODDrillpipe_inBase) endif - if (KillLine%IsOpening) then - KillLine%ID=KillLine%IDBase-2.*(KillLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./KillLine%Abop + if (data%State%KillLine%IsOpening) then + data%State%KillLine%ID=data%State%KillLine%IDBase-2.*(data%State%KillLine%NeededVolume- data%State%RAM(RNUMBER)%vdis_tot)*231./data%State%KillLine%Abop endif - if ( RAM(RNUMBER)%vdis_tot>KillLine%NeededVolume) then + if ( data%State%RAM(RNUMBER)%vdis_tot>data%State%KillLine%NeededVolume) then - KillLine%closed=1 - BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17) - RamLine%P_ACC= RAM(RNUMBER)%p_acccheck + data%State%KillLine%closed=1 + data%State%BopStackAcc%pram_reg=data%State%BopStackAcc%pram_reg+data%State%RAMS%minloss(RNUMBER,17) + data%State%RamLine%P_ACC= data%State%RAM(RNUMBER)%p_acccheck - if (KillLine%IsClosing) then - KillLine%ID=max(KillLine%ODDrillpipe_in,KillLine%ODDrillpipe_inBase) - BopControlPanel%KillLineCloseLED = LedOn - BopStackInput%KillLineCloseLedMine = LedOn - BopControlPanel%KillLineOpenLED = LedOff - BopStackInput%KillLineOpenLedMine = LedOff + if (data%State%KillLine%IsClosing) then + data%State%KillLine%ID=max(data%State%KillLine%ODDrillpipe_in,data%State%KillLine%ODDrillpipe_inBase) + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOn + data%State%BopStackInput%KillLineCloseLedMine = LedOn + data%EquipmentControl%BopControlPanel%KillLineOpenLED = LedOff + data%State%BopStackInput%KillLineOpenLedMine = LedOff CALL CloseKillLine endif - if (KillLine%IsOpening) then - KillLine%ID=KillLine%IDBase - BopControlPanel%KillLineOpenLED = LedOn - BopStackInput%KillLineOpenLedMine = LedOn - BopControlPanel%KillLineCloseLED = LedOff - BopStackInput%KillLineCloseLedMine = LedOff + if (data%State%KillLine%IsOpening) then + data%State%KillLine%ID=data%State%KillLine%IDBase + data%EquipmentControl%BopControlPanel%KillLineOpenLED = LedOn + data%State%BopStackInput%KillLineOpenLedMine = LedOn + data%EquipmentControl%BopControlPanel%KillLineCloseLED = LedOff + data%State%BopStackInput%KillLineCloseLedMine = LedOff CALL OpenKillLine endif @@ -994,7 +996,7 @@ endif ! if (vdis_tot>NeededVolumeAnnular) then ! ! Annular_closed=1 -! p_acc= RAM(RNUMBER)%p_acccheck +! p_acc= data%State%RAM(RNUMBER)%p_acccheck ! ! if (AnnularIsClosing) then ! IDAnnular=ODDrillpipe_inAnnular @@ -1019,10 +1021,11 @@ endif SUBROUTINE bop_codeAnnular(RNUMBER) - USE VARIABLES - USE CBopControlPanelVariables + use ConfigurationVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants - USE TD_GeneralData + use ConfigurationVariables !@ implicit none INTEGER RNUMBER, I @@ -1034,108 +1037,108 @@ INTEGER RNUMBER, I !==================================================== !if (bop_type==3) then !p_annular=510.725-(30.145*IDAnnular) - AnnularComputational%p_annular=448-(19.7*Annular%IDAnnular) + data%State%AnnularComputational%p_annular=448-(19.7*data%State%Annular%IDAnnular) ! Q=flow ! endif - RAM(RNUMBER)%clock=0 + data%State%RAM(RNUMBER)%clock=0 !======================Losses============================ - RAM(RNUMBER)%loss_after=0 !initial value - RAM(RNUMBER)%diffp_ram=1000 !initial value - RAM(RNUMBER)%loss_before=0 + data%State%RAM(RNUMBER)%loss_after=0 !initial value + data%State%RAM(RNUMBER)%diffp_ram=1000 !initial value + data%State%RAM(RNUMBER)%loss_before=0 !Q=0.0055; %initial flow rate (m^3/s) - RAM(RNUMBER)%Q=RAM(RNUMBER)%flow + data%State%RAM(RNUMBER)%Q=data%State%RAM(RNUMBER)%flow !write(*,*) 'Q1=' , Q !write(*,*) 'tol=' , tol -do while (abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)/ RAM(RNUMBER)%diffp_ram>Annular%tolAnnular) - if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) exit -! while abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)>10 - RAM(RNUMBER)%clock= RAM(RNUMBER)%clock+1 +do while (abs( data%State%RAM(RNUMBER)%diffp_ram- data%State%RAM(RNUMBER)%loss_after)/ data%State%RAM(RNUMBER)%diffp_ram>data%State%Annular%tolAnnular) + if (data%State%RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) exit +! while abs( data%State%RAM(RNUMBER)%diffp_ram- data%State%RAM(RNUMBER)%loss_after)>10 + data%State%RAM(RNUMBER)%clock= data%State%RAM(RNUMBER)%clock+1 -if ( RAM(RNUMBER)%clock>20) then +if ( data%State%RAM(RNUMBER)%clock>20) then ! tclock=clock - Annular%tolAnnular=Annular%tolzeroAnnular+(floor( RAM(RNUMBER)%clock/10)-1)*.001 + data%State%Annular%tolAnnular=data%State%Annular%tolzeroAnnular+(floor( data%State%RAM(RNUMBER)%clock/10)-1)*.001 endif ! if (clock==1) continue - if ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after> RAM(RNUMBER)%diffp_ram) then - RAM(RNUMBER)%Q=RAM(RNUMBER)%Q-.1 - elseif ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after<= RAM(RNUMBER)%diffp_ram) then - RAM(RNUMBER)%Q=RAM(RNUMBER)%Q+.01 + if ( data%State%RAM(RNUMBER)%clock/=1 .and. data%State%RAM(RNUMBER)%loss_after> data%State%RAM(RNUMBER)%diffp_ram) then + data%State%RAM(RNUMBER)%Q=data%State%RAM(RNUMBER)%Q-.1 + elseif ( data%State%RAM(RNUMBER)%clock/=1 .and. data%State%RAM(RNUMBER)%loss_after<= data%State%RAM(RNUMBER)%diffp_ram) then + data%State%RAM(RNUMBER)%Q=data%State%RAM(RNUMBER)%Q+.01 endif !====================Before Regulator========================= -do i=1,AnnularComputational%NO_PipingsAnnularLine -AnnularComputational%Re_ANNULARline(i)=RAM(RNUMBER)%Q*6.30902e-5*AnnularComputational%DIAM_ANNULARLINE_INCH(i)*0.0254/(AnnularComputational%AREA_ANNULARLINE(i)*nu) +do i=1,data%State%AnnularComputational%NO_PipingsAnnularLine +data%State%AnnularComputational%Re_ANNULARline(i)=data%State%RAM(RNUMBER)%Q*6.30902e-5*data%State%AnnularComputational%DIAM_ANNULARLINE_INCH(i)*0.0254/(data%State%AnnularComputational%AREA_ANNULARLINE(i)*nu) enddo -do i=1,AnnularComputational%NO_PipingsAnnularLine - if (AnnularComputational%Re_ANNULARline(i)= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(2)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - RAM(2)%First_OpenTimecheck= 1 + data%State%RAM(2)%First_OpenTimecheck= 1 - BopControlPanel%UpperRamsCloseLED = LedOff !new - BopStackInput%UpperRamsCloseLEDMine = LedOff !new - BopControlPanel%UpperRamsOpenLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%UpperRamsCloseLED = LedOff !new + data%State%BopStackInput%UpperRamsCloseLEDMine = LedOff !new + data%EquipmentControl%BopControlPanel%UpperRamsOpenLED = LedOn !LedBlinking - RAM(2)%FourwayValve = 1 + data%State%RAM(2)%FourwayValve = 1 endif endif - if (RAM(2)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close + if (data%State%RAM(2)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close !write(*,*) 'open 2' - RAM(2)%FourwayValve = 0 + data%State%RAM(2)%FourwayValve = 0 - PipeRam1%closed=0 + data%State%PipeRam1%closed=0 !PipeRam1_closed_withPossibility= PipeRam1_closed * TD_BOPConnectionPossibility(2) - RAM(2)%vdis_tot=0 - RAM(2)%vdis_bottles=0. - RAM(2)%fvr_air=0. - RAM(2)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(2)%Qzero=70 - RAM(2)%Q=RAM(2)%Qzero - RAM(2)%flow=70 - RAM(2)%tol=0.0037 + data%State%RAM(2)%vdis_tot=0 + data%State%RAM(2)%vdis_bottles=0. + data%State%RAM(2)%fvr_air=0. + data%State%RAM(2)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(2)%Qzero=70 + data%State%RAM(2)%Q=data%State%RAM(2)%Qzero + data%State%RAM(2)%flow=70 + data%State%RAM(2)%tol=0.0037 - if (PipeRam1%finished==1) then - PipeRam1%PipeRams1DotLeverOld=1.0 + if (data%State%PipeRam1%finished==1) then + data%State%PipeRam1%PipeRams1DotLeverOld=1.0 else - PipeRam1%PipeRams1DotLeverOld=BopControlPanel%UpperRamsValve + data%State%PipeRam1%PipeRams1DotLeverOld=data%EquipmentControl%BopControlPanel%UpperRamsValve endif - PipeRam1%finished=0 - PipeRam1%IsOpening = .true. - PipeRam1%IsClosing = .false. + data%State%PipeRam1%finished=0 + data%State%PipeRam1%IsOpening = .true. + data%State%PipeRam1%IsClosing = .false. !if (UpperRamsOpenLED == LedOn) then @@ -142,19 +143,19 @@ SUBROUTINE PIPE_RAMS1 - RAM(2)%bop_type = 3 + data%State%RAM(2)%bop_type = 3 !AbopPipeRam=186.5 - PipeRam1%A=(BopStackSpecification%UpperRamOpen*231)/((PipeRam1%IDBase-PipeRam1%ODDrillpipe_inBase)/2.) - PipeRam1%NeededVolume=PipeRam1%A*(PipeRam1%IDBase-max(PipeRam1%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase))/(2.*231) !3.48 galon for each BOP + data%State%PipeRam1%A=(BopStackSpecification%UpperRamOpen*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.) + data%State%PipeRam1%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-max(data%State%PipeRam1%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231) !3.48 galon for each BOP endif !===================================================================== - Annular%FirstSet= 0 - AnnularComputational%RamsFirstSet= 0 -if (PipeRam1%IsOpening .or. PipeRam1%IsClosing .or. RAM(2)%Bottles_Charged_MalfActive) then - Annular%FirstSet= 0 - AnnularComputational%RamsFirstSet= 0 + data%State%Annular%FirstSet= 0 + data%State%AnnularComputational%RamsFirstSet= 0 +if (data%State%PipeRam1%IsOpening .or. data%State%PipeRam1%IsClosing .or. data%State%RAM(2)%Bottles_Charged_MalfActive) then + data%State%Annular%FirstSet= 0 + data%State%AnnularComputational%RamsFirstSet= 0 CALL PIPE_RAMS1_SUB end if @@ -173,9 +174,10 @@ end if SUBROUTINE PIPE_RAMS1_SUB - USE VARIABLES + use ConfigurationVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables implicit none @@ -187,34 +189,34 @@ SUBROUTINE PIPE_RAMS1_SUB ! loop3: do while (finished_pipe1==0) - RAM(2)%SuccessionCounter = RAM(2)%SuccessionCounter + 1 + data%State%RAM(2)%SuccessionCounter = data%State%RAM(2)%SuccessionCounter + 1 - if (BopControlPanel%UpperRamsValve == 1.0 .and. PipeRam1%PipeRams1DotLeverOld == -1.0 .and. PipeRam1%UpperRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%UpperRamsValve == 1.0 .and. data%State%PipeRam1%PipeRams1DotLeverOld == -1.0 .and. data%State%PipeRam1%UpperRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then - if ( RAM(2)%First_CloseTimecheck == 0 ) then + if ( data%State%RAM(2)%First_CloseTimecheck == 0 ) then - if ( RAM(2)%SuccessionCounter /= RAM(2)%SuccessionCounterOld+1 ) then - RAM(2)%SuccessionCounter = 0 ! also in starup - RAM(2)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(2)%SuccessionCounter /= data%State%RAM(2)%SuccessionCounterOld+1 ) then + data%State%RAM(2)%SuccessionCounter = 0 ! also in starup + data%State%RAM(2)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(2)%SuccessionCounterOld= RAM(2)%SuccessionCounter + data%State%RAM(2)%SuccessionCounterOld= data%State%RAM(2)%SuccessionCounter endif - if ( RAM(2)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(2)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - BopControlPanel%UpperRamsOpenLED = LedOff - BopStackInput%UpperRamsOpenLEDMine = LedOff - BopControlPanel%UpperRamsCloseLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%UpperRamsOpenLED = LedOff + data%State%BopStackInput%UpperRamsOpenLEDMine = LedOff + data%EquipmentControl%BopControlPanel%UpperRamsCloseLED = LedOn !LedBlinking - RAM(2)%FourwayValve = 1 + data%State%RAM(2)%FourwayValve = 1 endif @@ -222,55 +224,55 @@ SUBROUTINE PIPE_RAMS1_SUB endif - if (RAM(2)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%State%RAM(2)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then !write(*,*) 'close 4' - RAM(2)%FourwayValve = 0 + data%State%RAM(2)%FourwayValve = 0 - PipeRam1%closed=0 + data%State%PipeRam1%closed=0 !PipeRam1_closed_withPossibility= PipeRam1_closed * TD_BOPConnectionPossibility(2) ! for TD code CALL OpenUpperRams ! for C code - PipeRam1%Situation_forTD= 0 ! open - for TD code - RAM(2)%p_bop=ShearRam%PA - PipeRam1%PipeRams1DotLeverOld = BopControlPanel%UpperRamsValve + data%State%PipeRam1%Situation_forTD= 0 ! open - for TD code + data%State%RAM(2)%p_bop=data%State%ShearRAM%PA + data%State%PipeRam1%PipeRams1DotLeverOld = data%EquipmentControl%BopControlPanel%UpperRamsValve - RAM(2)%bop_type = 3 + data%State%RAM(2)%bop_type = 3 !AbopPipeRam=196.67 - PipeRam1%A=(BopStackSpecification%UpperRamClose*231)/((PipeRam1%IDBase-PipeRam1%ODDrillpipe_inBase)/2.) + data%State%PipeRam1%A=(BopStackSpecification%UpperRamClose*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.) !write(*,*) 'NeededVolumeShearRams1=',NeededVolumeShearRams - PipeRam1%NeededVolume=PipeRam1%A*(PipeRam1%ID-max(PipeRam1%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase))/(2.*231) + data%State%PipeRam1%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%ID-max(data%State%PipeRam1%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231) ! write(*,*) 'NeededVolumeShearRams2=',NeededVolumeShearRams - RAM(2)%vdis_bottles=0. - RAM(2)%fvr_air=0. - RAM(2)%vdis_elecp=0. - PipeRam1%IsClosing = .true. - PipeRam1%IsOpening = .false. + data%State%RAM(2)%vdis_bottles=0. + data%State%RAM(2)%fvr_air=0. + data%State%RAM(2)%vdis_elecp=0. + data%State%PipeRam1%IsClosing = .true. + data%State%PipeRam1%IsOpening = .false. endif - if (BopControlPanel%UpperRamsValve == -1.0 .and. PipeRam1%PipeRams1DotLeverOld == 1.0 .and. PipeRam1%UpperRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%UpperRamsValve == -1.0 .and. data%State%PipeRam1%PipeRams1DotLeverOld == 1.0 .and. data%State%PipeRam1%UpperRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then - if ( RAM(2)%First_OpenTimecheck == 0 ) then + if ( data%State%RAM(2)%First_OpenTimecheck == 0 ) then - if ( RAM(2)%SuccessionCounter /= RAM(2)%SuccessionCounterOld+1 ) then - RAM(2)%SuccessionCounter = 0 ! also in starup - RAM(2)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(2)%SuccessionCounter /= data%State%RAM(2)%SuccessionCounterOld+1 ) then + data%State%RAM(2)%SuccessionCounter = 0 ! also in starup + data%State%RAM(2)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(2)%SuccessionCounterOld= RAM(2)%SuccessionCounter + data%State%RAM(2)%SuccessionCounterOld= data%State%RAM(2)%SuccessionCounter endif - if ( RAM(2)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(2)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - BopControlPanel%UpperRamsCloseLED = LedOff - BopStackInput%UpperRamsCloseLEDMine = LedOff - BopControlPanel%UpperRamsOpenLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%UpperRamsCloseLED = LedOff + data%State%BopStackInput%UpperRamsCloseLEDMine = LedOff + data%EquipmentControl%BopControlPanel%UpperRamsOpenLED = LedOn !LedBlinking - RAM(2)%FourwayValve = 1 + data%State%RAM(2)%FourwayValve = 1 endif @@ -279,56 +281,56 @@ SUBROUTINE PIPE_RAMS1_SUB endif - if (RAM(2)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%State%RAM(2)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then !write(*,*) 'open 4' - RAM(2)%FourwayValve = 0 + data%State%RAM(2)%FourwayValve = 0 - PipeRam1%closed=0 + data%State%PipeRam1%closed=0 !PipeRam1_closed_withPossibility= PipeRam1_closed * TD_BOPConnectionPossibility(2) CALL OpenUpperRams - PipeRam1%Situation_forTD= 0 ! open - for TD code - RAM(2)%p_bop=ShearRam%PA - PipeRam1%PipeRams1DotLeverOld = BopControlPanel%UpperRamsValve + data%State%PipeRam1%Situation_forTD= 0 ! open - for TD code + data%State%RAM(2)%p_bop=data%State%ShearRAM%PA + data%State%PipeRam1%PipeRams1DotLeverOld = data%EquipmentControl%BopControlPanel%UpperRamsValve - RAM(2)%bop_type = 3 + data%State%RAM(2)%bop_type = 3 !AbopPipeRam=186.5 - PipeRam1%A=(BopStackSpecification%UpperRamOpen*231)/((PipeRam1%IDBase-PipeRam1%ODDrillpipe_inBase)/2.) - PipeRam1%NeededVolume=PipeRam1%A*(PipeRam1%IDBase-PipeRam1%ID)/(2.*231) - RAM(2)%vdis_bottles=0. - RAM(2)%fvr_air=0. - RAM(2)%vdis_elecp=0. + data%State%PipeRam1%A=(BopStackSpecification%UpperRamOpen*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.) + data%State%PipeRam1%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-data%State%PipeRam1%ID)/(2.*231) + data%State%RAM(2)%vdis_bottles=0. + data%State%RAM(2)%fvr_air=0. + data%State%RAM(2)%vdis_elecp=0. - PipeRam1%IsOpening = .true. - PipeRam1%IsClosing = .false. + data%State%PipeRam1%IsOpening = .true. + data%State%PipeRam1%IsClosing = .false. endif - RAM(2)%First_CloseTimecheck = 0 - RAM(2)%First_OpenTimecheck = 0 + data%State%RAM(2)%First_CloseTimecheck = 0 + data%State%RAM(2)%First_OpenTimecheck = 0 - RAM(2)%time=RAM(2)%time+RamLine%DeltaT_BOP !overal time (s) + data%State%RAM(2)%time=data%State%RAM(2)%time+data%State%RamLine%DeltaT_BOP !overal time (s) !=================================================== ! BOP !=================================================== -if (PipeRam1%closed==0) then !bop closing - call bop_code(2,PipeRam1%H,2) !ramtype=2 2=RNUMBER +if (data%State%PipeRam1%closed==0) then !bop closing + call bop_code(2,data%State%PipeRam1%H,2) !ramtype=2 2=RNUMBER endif !bop is closing !================================================================ -if (PipeRam1%closed==1) then - RAM(2)%Q=0 +if (data%State%PipeRam1%closed==1) then + data%State%RAM(2)%Q=0 !p_bop=pram_reg - RAM(2)%p_bop=ShearRam%PA - RAMS%minloss(2,17)=0. !RNUMBER=2 + data%State%RAM(2)%p_bop=data%State%ShearRAM%PA + data%State%RAMS%minloss(2,17)=0. !RNUMBER=2 endif -RAM(2)%timecounter_ram=RAM(2)%timecounter_ram+1 +data%State%RAM(2)%timecounter_ram=data%State%RAM(2)%timecounter_ram+1 @@ -344,17 +346,17 @@ RAM(2)%timecounter_ram=RAM(2)%timecounter_ram+1 ! ! ! -! WRITE(60,60) RAM(2)%time,RAM(2)%Q,RAM(2)%vdis_tot,p_acc, & -! pram_reg,Pannular_reg,RAM(2)%p_bop,IDshearBop, & +! WRITE(60,60) data%State%RAM(2)%time,data%State%RAM(2)%Q,data%State%RAM(2)%vdis_tot,p_acc, & +! pram_reg,Pannular_reg,data%State%RAM(2)%p_bop,IDshearBop, & ! IDPipeRam1,IDPipeRam2,IDAnnular !60 FORMAT(11(f18.5)) ! call sleepqq(100) -if (PipeRam1%closed==1) then +if (data%State%PipeRam1%closed==1) then ! if ((MiddleRamsValve==1. .and. MiddleRamsFailureMalf==0) .or. (MiddleRamsValve==-1.0 .and. MiddleRamsFailureMalf==0) .or. (LowerRamsValve==1. .and. LowerRamsFailureMalf==0) .or. (LowerRamsValve==-1.0 .and. LowerRamsFailureMalf==0) .or. (AnnularValve==1. .and. AnnularFailureMalf==0) .or. (AnnularValve==-1.0 .and. AnnularFailureMalf==0) .or. ChokeLineValve==1. .or. ChokeLineValve==-1.0 .or. KillLineValve==1. .or. KillLineValve==-1.0) then - PipeRam1%finished=1 + data%State%PipeRam1%finished=1 ! endif endif @@ -367,8 +369,8 @@ endif - if ( PipeRam1%finished==1 .and. RAM(2)%Bottles_Charged_MalfActive==.true.) then - call bop_code(2,PipeRam1%H,2) !ramtype=2 2=RNUMBER + if ( data%State%PipeRam1%finished==1 .and. data%State%RAM(2)%Bottles_Charged_MalfActive==.true.) then + call bop_code(2,data%State%PipeRam1%H,2) !ramtype=2 2=RNUMBER ! call sleepqq(100) endif diff --git a/Equipments/BopStack/PIPE_RAM2.f90 b/Equipments/BopStack/PIPE_RAM2.f90 index 9f7c4db..f8b9253 100644 --- a/Equipments/BopStack/PIPE_RAM2.f90 +++ b/Equipments/BopStack/PIPE_RAM2.f90 @@ -1,9 +1,10 @@ SUBROUTINE PIPE_RAMS2 - USE VARIABLES + use ConfigurationVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! ! use CSimulationVariables implicit none @@ -15,37 +16,37 @@ SUBROUTINE PIPE_RAMS2 ! PIPE RAMS 2- BOP CAMERON Type U 5000 ! START CONDITIONS FOR PIPE RAMS 2 !===================================================================== - RAM(3)%SuccessionCounter = RAM(3)%SuccessionCounter + 1 + data%State%RAM(3)%SuccessionCounter = data%State%RAM(3)%SuccessionCounter + 1 - if (BopControlPanel%LowerRamsValve == 1.0 .and. PipeRam2%LowerRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%LowerRamsValve == 1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then !write(*,*) 'close 1' - if (BopStackInput%LowerRamsCloseLEDMine == LedOn) then + if (data%State%BopStackInput%LowerRamsCloseLEDMine == LedOn) then RETURN end if - if ( RAM(3)%SuccessionCounter /= RAM(3)%SuccessionCounterOld+1 ) then - RAM(3)%SuccessionCounter = 0 ! also in starup - RAM(3)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then + data%State%RAM(3)%SuccessionCounter = 0 ! also in starup + data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(3)%SuccessionCounterOld= RAM(3)%SuccessionCounter + data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter endif - if ( RAM(3)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - RAM(3)%First_CloseTimecheck= 1 + data%State%RAM(3)%First_CloseTimecheck= 1 - BopControlPanel%LowerRamsOpenLED = LedOff - BopStackInput%LowerRamsOpenLEDMine = LedOff - BopControlPanel%LowerRamsCloseLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%LowerRamsOpenLED = LedOff + data%State%BopStackInput%LowerRamsOpenLEDMine = LedOff + data%EquipmentControl%BopControlPanel%LowerRamsCloseLED = LedOn !LedBlinking - RAM(3)%FourwayValve = 1 + data%State%RAM(3)%FourwayValve = 1 endif @@ -54,68 +55,68 @@ SUBROUTINE PIPE_RAMS2 - if (RAM(3)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close + if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close !write(*,*) 'close 2' - RAM(3)%FourwayValve = 0 + data%State%RAM(3)%FourwayValve = 0 - PipeRam2%closed=0 + data%State%PipeRam2%closed=0 !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4) - RAM(3)%vdis_tot=0 - RAM(3)%vdis_bottles=0. - RAM(3)%fvr_air=0. - RAM(3)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(3)%Qzero=70 - RAM(3)%Q=RAM(3)%Qzero - RAM(3)%flow=70 - RAM(3)%tol=0.0037 - if (PipeRam2%finished==1) then - PipeRam2%LeverOld=-1.0 + data%State%RAM(3)%vdis_tot=0 + data%State%RAM(3)%vdis_bottles=0. + data%State%RAM(3)%fvr_air=0. + data%State%RAM(3)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(3)%Qzero=70 + data%State%RAM(3)%Q=data%State%RAM(3)%Qzero + data%State%RAM(3)%flow=70 + data%State%RAM(3)%tol=0.0037 + if (data%State%PipeRam2%finished==1) then + data%State%PipeRam2%LeverOld=-1.0 else - PipeRam2%LeverOld=BopControlPanel%LowerRamsValve + data%State%PipeRam2%LeverOld=data%EquipmentControl%BopControlPanel%LowerRamsValve endif - PipeRam2%finished=0 - PipeRam2%IsClosing = .true. - PipeRam2%IsOpening = .false. + data%State%PipeRam2%finished=0 + data%State%PipeRam2%IsClosing = .true. + data%State%PipeRam2%IsOpening = .false. - RAM(3)%bop_type = 3 + data%State%RAM(3)%bop_type = 3 !AbopPipeRam=196.67 - PipeRam1%A=(BopStackSpecification%LowerRamClose*231)/((PipeRam1%IDBase-PipeRam1%ODDrillpipe_inBase)/2.) - PipeRam2%NeededVolume=PipeRam1%A*(PipeRam1%IDBase-max(PipeRam2%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase))/(2.*231) !galon for each BOP + data%State%PipeRam1%A=(BopStackSpecification%LowerRamClose*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.) + data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231) !galon for each BOP !write(*,*) 'close 1' endif - if (BopControlPanel%LowerRamsValve == -1.0 .and. PipeRam2%LowerRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%LowerRamsValve == -1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then !write(*,*) 'open 1' - if (BopStackInput%LowerRamsOpenLEDMine == LedOn) then + if (data%State%BopStackInput%LowerRamsOpenLEDMine == LedOn) then RETURN end if - if ( RAM(3)%SuccessionCounter /= RAM(3)%SuccessionCounterOld+1 ) then - RAM(3)%SuccessionCounter = 0 ! also in starup - RAM(3)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then + data%State%RAM(3)%SuccessionCounter = 0 ! also in starup + data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(3)%SuccessionCounterOld= RAM(3)%SuccessionCounter + data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter endif - if ( RAM(3)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - RAM(3)%First_OpenTimecheck= 1 + data%State%RAM(3)%First_OpenTimecheck= 1 - BopControlPanel%LowerRamsCloseLED = LedOff !new - BopStackInput%LowerRamsCloseLEDMine = LedOff !new - BopControlPanel%LowerRamsOpenLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%LowerRamsCloseLED = LedOff !new + data%State%BopStackInput%LowerRamsCloseLEDMine = LedOff !new + data%EquipmentControl%BopControlPanel%LowerRamsOpenLED = LedOn !LedBlinking - RAM(3)%FourwayValve = 1 + data%State%RAM(3)%FourwayValve = 1 endif @@ -123,31 +124,31 @@ SUBROUTINE PIPE_RAMS2 endif - if (RAM(3)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close + if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close !write(*,*) 'open 2' - RAM(3)%FourwayValve = 0 + data%State%RAM(3)%FourwayValve = 0 - PipeRam2%closed=0 + data%State%PipeRam2%closed=0 !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4) - RAM(3)%vdis_tot=0 - RAM(3)%vdis_bottles=0. - RAM(3)%fvr_air=0. - RAM(3)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(3)%Qzero=70 - RAM(3)%Q=RAM(3)%Qzero - RAM(3)%flow=70 - RAM(3)%tol=0.0037 + data%State%RAM(3)%vdis_tot=0 + data%State%RAM(3)%vdis_bottles=0. + data%State%RAM(3)%fvr_air=0. + data%State%RAM(3)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(3)%Qzero=70 + data%State%RAM(3)%Q=data%State%RAM(3)%Qzero + data%State%RAM(3)%flow=70 + data%State%RAM(3)%tol=0.0037 - if (PipeRam2%finished==1) then - PipeRam2%LeverOld=1.0 + if (data%State%PipeRam2%finished==1) then + data%State%PipeRam2%LeverOld=1.0 else - PipeRam2%LeverOld=BopControlPanel%LowerRamsValve + data%State%PipeRam2%LeverOld=data%EquipmentControl%BopControlPanel%LowerRamsValve endif - PipeRam2%finished=0 - PipeRam2%IsOpening = .true. - PipeRam2%IsClosing = .false. + data%State%PipeRam2%finished=0 + data%State%PipeRam2%IsOpening = .true. + data%State%PipeRam2%IsClosing = .false. !if (LowerRamsOpenLED == LedOn) then @@ -155,10 +156,10 @@ SUBROUTINE PIPE_RAMS2 !end if - RAM(3)%bop_type = 3 + data%State%RAM(3)%bop_type = 3 !AbopPipeRam=186.5 - PipeRam1%A=(BopStackSpecification%LowerRamOpen*231)/((PipeRam1%IDBase-PipeRam1%ODDrillpipe_inBase)/2.) - PipeRam2%NeededVolume=PipeRam1%A*(PipeRam1%IDBase-max(PipeRam2%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase))/(2.*231) !galon for each BOP + data%State%PipeRam1%A=(BopStackSpecification%LowerRamOpen*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.) + data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231) !galon for each BOP !write(*,*) 'open 1' endif @@ -166,9 +167,9 @@ SUBROUTINE PIPE_RAMS2 !===================================================================== - if (PipeRam2%IsOpening .or. PipeRam2%IsClosing .or. RAM(3)%Bottles_Charged_MalfActive) then - Annular%FirstSet= 0 - AnnularComputational%RamsFirstSet= 0 + if (data%State%PipeRam2%IsOpening .or. data%State%PipeRam2%IsClosing .or. data%State%RAM(3)%Bottles_Charged_MalfActive) then + data%State%Annular%FirstSet= 0 + data%State%AnnularComputational%RamsFirstSet= 0 CALL PIPE_RAMS2_SUB end if @@ -187,9 +188,10 @@ END SUBROUTINE PIPE_RAMS2 SUBROUTINE PIPE_RAMS2_SUB - USE VARIABLES + use ConfigurationVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables implicit none @@ -203,34 +205,34 @@ SUBROUTINE PIPE_RAMS2_SUB !write(*,*) 'checkpoint 2' - RAM(3)%SuccessionCounter = RAM(3)%SuccessionCounter + 1 + data%State%RAM(3)%SuccessionCounter = data%State%RAM(3)%SuccessionCounter + 1 - if (BopControlPanel%LowerRamsValve == 1.0 .and. PipeRam2%LeverOld == -1.0 .and. PipeRam2%LowerRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%LowerRamsValve == 1.0 .and. data%State%PipeRam2%LeverOld == -1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then !write(*,*) 'close 3' - if ( RAM(3)%First_CloseTimecheck == 0 ) then + if ( data%State%RAM(3)%First_CloseTimecheck == 0 ) then - if ( RAM(3)%SuccessionCounter /= RAM(3)%SuccessionCounterOld+1 ) then - RAM(3)%SuccessionCounter = 0 ! also in starup - RAM(3)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then + data%State%RAM(3)%SuccessionCounter = 0 ! also in starup + data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(3)%SuccessionCounterOld= RAM(3)%SuccessionCounter + data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter endif - if ( RAM(3)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - BopControlPanel%LowerRamsOpenLED = LedOff - BopStackInput%LowerRamsOpenLEDMine = LedOff - BopControlPanel%LowerRamsCloseLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%LowerRamsOpenLED = LedOff + data%State%BopStackInput%LowerRamsOpenLEDMine = LedOff + data%EquipmentControl%BopControlPanel%LowerRamsCloseLED = LedOn !LedBlinking - RAM(3)%FourwayValve = 1 + data%State%RAM(3)%FourwayValve = 1 endif @@ -241,55 +243,55 @@ SUBROUTINE PIPE_RAMS2_SUB endif - if (RAM(3)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then !write(*,*) 'close 4' - RAM(3)%FourwayValve = 0 + data%State%RAM(3)%FourwayValve = 0 - PipeRam2%closed=0 + data%State%PipeRam2%closed=0 !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4) - RAM(3)%p_bop=ShearRam%PA - PipeRam2%LeverOld = BopControlPanel%LowerRamsValve + data%State%RAM(3)%p_bop=data%State%ShearRAM%PA + data%State%PipeRam2%LeverOld = data%EquipmentControl%BopControlPanel%LowerRamsValve CALL OpenLowerRams - PipeRam2%Situation_forTD= 0 ! open - for TD code - RAM(3)%bop_type = 3 + data%State%PipeRam2%Situation_forTD= 0 ! open - for TD code + data%State%RAM(3)%bop_type = 3 !AbopPipeRam=196.67 - PipeRam1%A=(BopStackSpecification%LowerRamClose*231)/((PipeRam1%IDBase-PipeRam1%ODDrillpipe_inBase)/2.) - PipeRam2%NeededVolume=PipeRam1%A*(PipeRam2%ID-max(PipeRam2%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase))/(2.*231) + data%State%PipeRam1%A=(BopStackSpecification%LowerRamClose*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.) + data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam2%ID-max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231) - RAM(3)%vdis_bottles=0. - RAM(3)%fvr_air=0. - RAM(3)%vdis_elecp=0. - PipeRam2%IsClosing = .true. - PipeRam2%IsOpening = .false. + data%State%RAM(3)%vdis_bottles=0. + data%State%RAM(3)%fvr_air=0. + data%State%RAM(3)%vdis_elecp=0. + data%State%PipeRam2%IsClosing = .true. + data%State%PipeRam2%IsOpening = .false. !write(*,*) 'close 2' endif - if (BopControlPanel%LowerRamsValve == -1.0 .and. PipeRam2%LeverOld == 1.0 .and. PipeRam2%LowerRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%LowerRamsValve == -1.0 .and. data%State%PipeRam2%LeverOld == 1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then !write(*,*) 'open 3' - if ( RAM(3)%First_OpenTimecheck == 0 ) then + if ( data%State%RAM(3)%First_OpenTimecheck == 0 ) then - if ( RAM(3)%SuccessionCounter /= RAM(3)%SuccessionCounterOld+1 ) then - RAM(3)%SuccessionCounter = 0 ! also in starup - RAM(3)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then + data%State%RAM(3)%SuccessionCounter = 0 ! also in starup + data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(3)%SuccessionCounterOld= RAM(3)%SuccessionCounter + data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter endif - if ( RAM(3)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - BopControlPanel%LowerRamsCloseLED = LedOff - BopStackInput%LowerRamsCloseLEDMine = LedOff - BopControlPanel%LowerRamsOpenLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%LowerRamsCloseLED = LedOff + data%State%BopStackInput%LowerRamsCloseLEDMine = LedOff + data%EquipmentControl%BopControlPanel%LowerRamsOpenLED = LedOn !LedBlinking - RAM(3)%FourwayValve = 1 + data%State%RAM(3)%FourwayValve = 1 endif @@ -299,57 +301,57 @@ SUBROUTINE PIPE_RAMS2_SUB endif - if (RAM(3)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then + if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then !write(*,*) 'open 4' - RAM(3)%FourwayValve = 0 + data%State%RAM(3)%FourwayValve = 0 - PipeRam2%closed=0 + data%State%PipeRam2%closed=0 !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4) - RAM(3)%p_bop=ShearRam%PA - PipeRam2%LeverOld = BopControlPanel%LowerRamsValve + data%State%RAM(3)%p_bop=data%State%ShearRAM%PA + data%State%PipeRam2%LeverOld = data%EquipmentControl%BopControlPanel%LowerRamsValve CALL OpenLowerRams - PipeRam2%Situation_forTD= 0 ! open - for TD code - RAM(3)%bop_type = 3 + data%State%PipeRam2%Situation_forTD= 0 ! open - for TD code + data%State%RAM(3)%bop_type = 3 !AbopPipeRam=186.5 - PipeRam1%A=(BopStackSpecification%LowerRamOpen*231)/((PipeRam1%IDBase-PipeRam1%ODDrillpipe_inBase)/2.) - PipeRam2%NeededVolume=PipeRam1%A*(PipeRam1%IDBase-PipeRam2%ID)/(2.*231) - RAM(3)%vdis_bottles=0. - RAM(3)%fvr_air=0. - RAM(3)%vdis_elecp=0. + data%State%PipeRam1%A=(BopStackSpecification%LowerRamOpen*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.) + data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-data%State%PipeRam2%ID)/(2.*231) + data%State%RAM(3)%vdis_bottles=0. + data%State%RAM(3)%fvr_air=0. + data%State%RAM(3)%vdis_elecp=0. - PipeRam2%IsOpening = .true. - PipeRam2%IsClosing = .false. + data%State%PipeRam2%IsOpening = .true. + data%State%PipeRam2%IsClosing = .false. !write(*,*) 'open 2' endif - RAM(3)%First_CloseTimecheck = 0 - RAM(3)%First_OpenTimecheck = 0 + data%State%RAM(3)%First_CloseTimecheck = 0 + data%State%RAM(3)%First_OpenTimecheck = 0 - RAM(3)%time=RAM(3)%time+RamLine%DeltaT_BOP !overal time (s) + data%State%RAM(3)%time=data%State%RAM(3)%time+data%State%RamLine%DeltaT_BOP !overal time (s) !=================================================== ! BOP !=================================================== -if (PipeRam2%closed==0) then !bop closing +if (data%State%PipeRam2%closed==0) then !bop closing !write(*,*) 'BOP code is called' - call bop_code(3,PipeRam2%H_Bop,3) !ramtype=3 3=RNUMBER + call bop_code(3,data%State%PipeRam2%H_Bop,3) !ramtype=3 3=RNUMBER endif !bop is closing !================================================================ -if (PipeRam2%closed==1) then - RAM(3)%Q=0 +if (data%State%PipeRam2%closed==1) then + data%State%RAM(3)%Q=0 !p_bop=pram_reg - RAM(3)%p_bop=ShearRam%PA - RAMS%minloss(3,17)=0. !RNUMBER=3 + data%State%RAM(3)%p_bop=data%State%ShearRAM%PA + data%State%RAMS%minloss(3,17)=0. !RNUMBER=3 endif -RAM(3)%timecounter_ram=RAM(3)%timecounter_ram+1 +data%State%RAM(3)%timecounter_ram=data%State%RAM(3)%timecounter_ram+1 @@ -365,18 +367,18 @@ RAM(3)%timecounter_ram=RAM(3)%timecounter_ram+1 ! ! ! -! WRITE(60,60) RAM(3)%time,RAM(3)%Q,RAM(3)%vdis_tot,p_acc, & -! pram_reg,Pannular_reg,RAM(3)%p_bop,IDshearBop, & +! WRITE(60,60) data%State%RAM(3)%time,data%State%RAM(3)%Q,data%State%RAM(3)%vdis_tot,p_acc, & +! pram_reg,Pannular_reg,data%State%RAM(3)%p_bop,IDshearBop, & ! IDPipeRam1,IDPipeRam2,IDAnnular !60 FORMAT(11(f18.5)) ! call sleepqq(100) -if (PipeRam2%closed==1) then +if (data%State%PipeRam2%closed==1) then ! if ((MiddleRamsValve==1. .and. MiddleRamsFailureMalf==0) .or. (MiddleRamsValve==-1.0 .and. MiddleRamsFailureMalf==0) .or. (UpperRamsValve==1. .and. UpperRamsFailureMalf==0) .or. (UpperRamsValve==-1.0 .and. UpperRamsFailureMalf==0) .or. (AnnularValve==1. .and. AnnularFailureMalf==0) .or. (AnnularValve==-1.0 .and. AnnularFailureMalf==0) .or. ChokeLineValve==1. .or. ChokeLineValve==-1.0 .or. KillLineValve==1. .or. KillLineValve==-1.0) then - PipeRam2%finished=1 + data%State%PipeRam2%finished=1 ! endif endif @@ -385,8 +387,8 @@ endif ! end do loop4 !while finished_pipe2==0 - if ( PipeRam2%finished==1 .and. RAM(3)%Bottles_Charged_MalfActive==.true.) then - call bop_code(3,PipeRam2%H_Bop,3) !ramtype=3 3=RNUMBER + if ( data%State%PipeRam2%finished==1 .and. data%State%RAM(3)%Bottles_Charged_MalfActive==.true.) then + call bop_code(3,data%State%PipeRam2%H_Bop,3) !ramtype=3 3=RNUMBER ! call sleepqq(100) endif diff --git a/Equipments/BopStack/PipeRams1Main.f90 b/Equipments/BopStack/PipeRams1Main.f90 index f37d7cb..8df78d9 100644 --- a/Equipments/BopStack/PipeRams1Main.f90 +++ b/Equipments/BopStack/PipeRams1Main.f90 @@ -18,12 +18,12 @@ module PipeRams1Main end subroutine PipeRams1_Init subroutine PipeRams1_Step - use VARIABLES + use ConfigurationVariables implicit none - if (PipeRam1%finished/=0) then + if (data%State%PipeRam1%finished/=0) then call PIPE_RAMS1 - if (PipeRam1%IsOpening .or. PipeRam1%IsClosing .or. RAM(2)%Bottles_Charged_MalfActive) then - if(PipeRam1%finished==0) then + if (data%State%PipeRam1%IsOpening .or. data%State%PipeRam1%IsClosing .or. data%State%RAM(2)%Bottles_Charged_MalfActive) then + if(data%State%PipeRam1%finished==0) then call PIPE_RAMS1_SUB !only body of loop2 endif endif diff --git a/Equipments/BopStack/PipeRams2Main.f90 b/Equipments/BopStack/PipeRams2Main.f90 index 0fd8b31..28d97ce 100644 --- a/Equipments/BopStack/PipeRams2Main.f90 +++ b/Equipments/BopStack/PipeRams2Main.f90 @@ -19,12 +19,12 @@ ! end subroutine PipeRams2_Init subroutine PipeRams2_Step - use VARIABLES + use ConfigurationVariables implicit none - if (PipeRam2%finished/=0) then + if (data%State%PipeRam2%finished/=0) then call PIPE_RAMS2 - if (PipeRam2%IsOpening .or. PipeRam2%IsClosing .or. RAM(3)%Bottles_Charged_MalfActive) then - if(PipeRam2%finished==0) then + if (data%State%PipeRam2%IsOpening .or. data%State%PipeRam2%IsClosing .or. data%State%RAM(3)%Bottles_Charged_MalfActive) then + if(data%State%PipeRam2%finished==0) then call PIPE_RAMS2_SUB !only body of loop2 endif endif diff --git a/Equipments/BopStack/SHEAR_RAM.f90 b/Equipments/BopStack/SHEAR_RAM.f90 index bf69fdd..ecb7dfc 100644 --- a/Equipments/BopStack/SHEAR_RAM.f90 +++ b/Equipments/BopStack/SHEAR_RAM.f90 @@ -1,8 +1,9 @@ SUBROUTINE SHEAR_RAMS - USE VARIABLES + use ConfigurationVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables implicit none @@ -14,145 +15,145 @@ SUBROUTINE SHEAR_RAMS ! START CONDITIONS FOR SHEAR RAMS !===================================================================== - RAM(4)%SuccessionCounter = RAM(4)%SuccessionCounter + 1 + data%State%RAM(4)%SuccessionCounter = data%State%RAM(4)%SuccessionCounter + 1 - if (BopControlPanel%MiddleRamsValve == 1.0 .and. ShearRam%MiddleRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%MiddleRamsValve == 1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then - if (BopStackInput%MiddleRamsCloseLEDMine == LedOn) then + if (data%State%BopStackInput%MiddleRamsCloseLEDMine == LedOn) then RETURN end if - if ( RAM(4)%SuccessionCounter /= RAM(4)%SuccessionCounterOld+1 ) then - RAM(4)%SuccessionCounter = 0 ! also in starup - RAM(4)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then + data%State%RAM(4)%SuccessionCounter = 0 ! also in starup + data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(4)%SuccessionCounterOld= RAM(4)%SuccessionCounter + data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter endif - if ( RAM(4)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - RAM(4)%First_CloseTimecheck= 1 + data%State%RAM(4)%First_CloseTimecheck= 1 - BopControlPanel%MiddleRamsOpenLED = LedOff - BopStackInput%MiddleRamsOpenLEDMine = LedOff - BopControlPanel%MiddleRamsCloseLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%MiddleRamsOpenLED = LedOff + data%State%BopStackInput%MiddleRamsOpenLEDMine = LedOff + data%EquipmentControl%BopControlPanel%MiddleRamsCloseLED = LedOn !LedBlinking - RAM(4)%FourwayValve = 1 + data%State%RAM(4)%FourwayValve = 1 endif endif - if (RAM(4)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close + if (data%State%RAM(4)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close !write(*,*) 'close 2' - RAM(4)%FourwayValve = 0 + data%State%RAM(4)%FourwayValve = 0 - RamLine%ShearBop_closed=0 + data%State%RamLine%ShearBop_closed=0 !ShearBop_closed_withPossibility= ShearBop_closed * TD_BOPConnectionPossibility(3) - RAM(4)%vdis_tot=0 - RAM(4)%vdis_bottles=0. - RAM(4)%fvr_air=0. - RAM(4)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(4)%Qzero=70 - RAM(4)%Q=RAM(4)%Qzero - RAM(4)%flow=70 - RAM(4)%tol=0.0037 + data%State%RAM(4)%vdis_tot=0 + data%State%RAM(4)%vdis_bottles=0. + data%State%RAM(4)%fvr_air=0. + data%State%RAM(4)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(4)%Qzero=70 + data%State%RAM(4)%Q=data%State%RAM(4)%Qzero + data%State%RAM(4)%flow=70 + data%State%RAM(4)%tol=0.0037 - if (RamLine%FINISHED_shear==1) then - RamLine%ShearRamsLeverOld=-1.0 + if (data%State%RamLine%FINISHED_shear==1) then + data%State%RamLine%ShearRamsLeverOld=-1.0 else - RamLine%ShearRamsLeverOld=BopControlPanel%MiddleRamsValve + data%State%RamLine%ShearRamsLeverOld=data%EquipmentControl%BopControlPanel%MiddleRamsValve endif - RamLine%FINISHED_shear=0 - RamLine%ShearRamIsClosing = .true. - RamLine%ShearRamIsOpening = .false. + data%State%RamLine%FINISHED_shear=0 + data%State%RamLine%ShearRamIsClosing = .true. + data%State%RamLine%ShearRamIsOpening = .false. - RAM(4)%bop_type = 2 + data%State%RAM(4)%bop_type = 2 !NeededVolumeShearRams=5.8 !galon for each BOP !AbopShearRam=196.67 !(in^2) - ShearRam%AbopShearRam=(BopStackSpecification%BlindRamClose*231)/(ShearRam%IDshearBopBase/2.) + data%State%ShearRAM%AbopShearRam=(BopStackSpecification%BlindRamClose*231)/(data%State%ShearRAM%IDshearBopBase/2.) !NeededVolumeShearRams=BlindRamClose !galon for each BOP **changed - ShearRam%NeededVolumeShearRams=ShearRam%AbopShearRam*(ShearRam%IDshearBopBase-ShearRam%ShearIsNotAllowed*ShearRam%ODDrillpipe_inShearRam)/(2.*231) !3.67 galon for each BOP ! **changed - ShearRam%VA=ShearRam%AbopShearRam*(ShearRam%IDshearBopBase-ShearRam%ODDrillpipe_inShearRam)/(2.*231) - ShearRam%VB=ShearRam%NeededVolumeShearRams + data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%ShearIsNotAllowed*data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231) !3.67 galon for each BOP ! **changed + data%State%ShearRAM%VA=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231) + data%State%ShearRAM%VB=data%State%ShearRAM%NeededVolumeShearRams endif - if (BopControlPanel%MiddleRamsValve == -1.0 .and. ShearRam%MiddleRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1) then + if (data%EquipmentControl%BopControlPanel%MiddleRamsValve == -1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1) then - if (BopStackInput%MiddleRamsOpenLEDMine == LedOn) then + if (data%State%BopStackInput%MiddleRamsOpenLEDMine == LedOn) then RETURN end if - if ( RAM(4)%SuccessionCounter /= RAM(4)%SuccessionCounterOld+1 ) then - RAM(4)%SuccessionCounter = 0 ! also in starup - RAM(4)%SuccessionCounterOld = 0 ! also in starup + if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then + data%State%RAM(4)%SuccessionCounter = 0 ! also in starup + data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(4)%SuccessionCounterOld= RAM(4)%SuccessionCounter + data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter endif - if ( RAM(4)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then + if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then !return - RAM(4)%First_OpenTimecheck= 1 + data%State%RAM(4)%First_OpenTimecheck= 1 - BopControlPanel%MiddleRamsCloseLED = LedOff !new - BopStackInput%MiddleRamsCloseLEDMine = LedOff !new - BopControlPanel%MiddleRamsOpenLED = LedOn !LedBlinking + data%EquipmentControl%BopControlPanel%MiddleRamsCloseLED = LedOff !new + data%State%BopStackInput%MiddleRamsCloseLEDMine = LedOff !new + data%EquipmentControl%BopControlPanel%MiddleRamsOpenLED = LedOn !LedBlinking endif endif - if (RAM(4)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close + if (data%State%RAM(4)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close !write(*,*) 'open 2' - RAM(4)%FourwayValve = 0 + data%State%RAM(4)%FourwayValve = 0 - RamLine%ShearBop_closed=0 + data%State%RamLine%ShearBop_closed=0 !ShearBop_closed_withPossibility= ShearBop_closed * TD_BOPConnectionPossibility(3) - RAM(4)%vdis_tot=0 - RAM(4)%vdis_bottles=0. - RAM(4)%fvr_air=0. - RAM(4)%vdis_elecp=0. - Pumps%Qiter=7 - RAM(4)%Qzero=70 - RAM(4)%Q=RAM(4)%Qzero - RAM(4)%flow=70 - RAM(4)%tol=0.0037 + data%State%RAM(4)%vdis_tot=0 + data%State%RAM(4)%vdis_bottles=0. + data%State%RAM(4)%fvr_air=0. + data%State%RAM(4)%vdis_elecp=0. + data%State%Pumps%Qiter=7 + data%State%RAM(4)%Qzero=70 + data%State%RAM(4)%Q=data%State%RAM(4)%Qzero + data%State%RAM(4)%flow=70 + data%State%RAM(4)%tol=0.0037 - if (RamLine%FINISHED_shear==1) then - RamLine%ShearRamsLeverOld=1.0 + if (data%State%RamLine%FINISHED_shear==1) then + data%State%RamLine%ShearRamsLeverOld=1.0 else - RamLine%ShearRamsLeverOld=BopControlPanel%MiddleRamsValve + data%State%RamLine%ShearRamsLeverOld=data%EquipmentControl%BopControlPanel%MiddleRamsValve endif - RamLine%FINISHED_shear=0 - RamLine%ShearRamIsOpening = .true. - RamLine%ShearRamIsClosing = .false. + data%State%RamLine%FINISHED_shear=0 + data%State%RamLine%ShearRamIsOpening = .true. + data%State%RamLine%ShearRamIsClosing = .false. - RAM(4)%bop_type = 3 + data%State%RAM(4)%bop_type = 3 !AbopShearRam=186.5 !(in^2) - ShearRam%AbopShearRam=(BopStackSpecification%BlindRamOpen*231)/(ShearRam%IDshearBopBase/2.) + data%State%ShearRAM%AbopShearRam=(BopStackSpecification%BlindRamOpen*231)/(data%State%ShearRAM%IDshearBopBase/2.) !NeededVolumeShearRams=5.5 !galon for each BOP !NeededVolumeShearRams=BlindRamOpen ! **changed - ShearRam%NeededVolumeShearRams=ShearRam%AbopShearRam*(ShearRam%IDshearBopBase-ShearRam%ShearIsNotAllowed*ShearRam%ODDrillpipe_inShearRam)/(2.*231) !3.67 galon for each BOP ! **changed + data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%ShearIsNotAllowed*data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231) !3.67 galon for each BOP ! **changed !va=AbopShearRam*(IDshearBopBase-ODDrillpipe_inShearRam)/(2.*231) !vb=NeededVolumeShearRams endif !===================================================================== - ! if (ShearRamIsOpening .or. ShearRamIsClosing .or. RAM(4)%Bottles_Charged_MalfActive) then + ! if (ShearRamIsOpening .or. ShearRamIsClosing .or. data%State%RAM(4)%Bottles_Charged_MalfActive) then ! CALL SHEAR_RAMS_SUB ! end if @@ -163,9 +164,10 @@ END SUBROUTINE SHEAR_RAMS SUBROUTINE SHEAR_RAMS_SUB - USE VARIABLES + use ConfigurationVariables USE CBopStackVariables - USE CBopControlPanelVariables + use CBopControlPanel + use ConfigurationVariables USE CEquipmentsConstants ! use CSimulationVariables implicit none @@ -174,99 +176,99 @@ SUBROUTINE SHEAR_RAMS_SUB ! RamsFirstSet= 0 ! loop2: do while (finished_shear==0) - RAM(4)%SuccessionCounter = RAM(4)%SuccessionCounter + 1 - if (BopControlPanel%MiddleRamsValve == 1.0 .and. RamLine%ShearRamsLeverOld == -1.0 .and. ShearRam%MiddleRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RAM(4)%First_CloseTimecheck == 0) then - if ( RAM(4)%SuccessionCounter /= RAM(4)%SuccessionCounterOld+1 ) then - RAM(4)%SuccessionCounter = 0 ! also in starup - RAM(4)%SuccessionCounterOld = 0 ! also in starup + data%State%RAM(4)%SuccessionCounter = data%State%RAM(4)%SuccessionCounter + 1 + if (data%EquipmentControl%BopControlPanel%MiddleRamsValve == 1.0 .and. data%State%RamLine%ShearRamsLeverOld == -1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RAM(4)%First_CloseTimecheck == 0) then + if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then + data%State%RAM(4)%SuccessionCounter = 0 ! also in starup + data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup else - RAM(4)%SuccessionCounterOld= RAM(4)%SuccessionCounter + data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter endif - if ( RAM(4)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then - BopControlPanel%MiddleRamsOpenLED = LedOff - BopStackInput%MiddleRamsOpenLEDMine = LedOff - BopControlPanel%MiddleRamsCloseLED = LedOn !LedBlinking - RAM(4)%FourwayValve = 1 + if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then + data%EquipmentControl%BopControlPanel%MiddleRamsOpenLED = LedOff + data%State%BopStackInput%MiddleRamsOpenLEDMine = LedOff + data%EquipmentControl%BopControlPanel%MiddleRamsCloseLED = LedOn !LedBlinking + data%State%RAM(4)%FourwayValve = 1 endif endif - if (RAM(4)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then - RAM(4)%FourwayValve = 0 - RamLine%ShearBop_closed=0 - RAM(4)%p_bop=ShearRam%PA - RamLine%ShearRamsLeverOld = BopControlPanel%MiddleRamsValve + if (data%State%RAM(4)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then + data%State%RAM(4)%FourwayValve = 0 + data%State%RamLine%ShearBop_closed=0 + data%State%RAM(4)%p_bop=data%State%ShearRAM%PA + data%State%RamLine%ShearRamsLeverOld = data%EquipmentControl%BopControlPanel%MiddleRamsValve CALL OpenMiddleRams ! for C code - RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code - RAM(4)%bop_type = 2 - ShearRam%AbopShearRam=(BopStackSpecification%BlindRamClose*231)/(ShearRam%IDshearBopBase/2.) - ShearRam%NeededVolumeShearRams=ShearRam%AbopShearRam*(ShearRam%IDshearBop-ShearRam%ShearIsNotAllowed*ShearRam%ODDrillpipe_inShearRam)/(2.*231) ! **changed - RAM(4)%vdis_bottles=0. - RAM(4)%fvr_air=0. - RAM(4)%vdis_elecp=0. - RamLine%ShearRamIsClosing = .true. - RamLine%ShearRamIsOpening = .false. + data%State%RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code + data%State%RAM(4)%bop_type = 2 + data%State%ShearRAM%AbopShearRam=(BopStackSpecification%BlindRamClose*231)/(data%State%ShearRAM%IDshearBopBase/2.) + data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBop-data%State%ShearRAM%ShearIsNotAllowed*data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231) ! **changed + data%State%RAM(4)%vdis_bottles=0. + data%State%RAM(4)%fvr_air=0. + data%State%RAM(4)%vdis_elecp=0. + data%State%RamLine%ShearRamIsClosing = .true. + data%State%RamLine%ShearRamIsOpening = .false. endif - if (BopControlPanel%MiddleRamsValve == -1.0 .and. RamLine%ShearRamsLeverOld == 1.0 .and. ShearRam%MiddleRamsFailureMalf==0 .and. BopStackAcc%RigAirMalf==0 .and. BopControlPanel%AirMasterValve==1 .and. RAM(4)%First_OpenTimecheck == 0) then - if ( RAM(4)%SuccessionCounter /= RAM(4)%SuccessionCounterOld+1 ) then - RAM(4)%SuccessionCounter = 0 ! also in starup - RAM(4)%SuccessionCounterOld = 0 ! also in starup + if (data%EquipmentControl%BopControlPanel%MiddleRamsValve == -1.0 .and. data%State%RamLine%ShearRamsLeverOld == 1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%EquipmentControl%BopControlPanel%AirMasterValve==1 .and. data%State%RAM(4)%First_OpenTimecheck == 0) then + if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then + data%State%RAM(4)%SuccessionCounter = 0 ! also in starup + data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup !return else - RAM(4)%SuccessionCounterOld= RAM(4)%SuccessionCounter + data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter endif - if ( RAM(4)%SuccessionCounter >= int(2.5/RamLine%DeltaT_BOP) ) then - BopControlPanel%MiddleRamsCloseLED = LedOff - BopStackInput%MiddleRamsCloseLEDMine = LedOff - BopControlPanel%MiddleRamsOpenLED = LedOn !LedBlinking - RAM(4)%FourwayValve = 1 + if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then + data%EquipmentControl%BopControlPanel%MiddleRamsCloseLED = LedOff + data%State%BopStackInput%MiddleRamsCloseLEDMine = LedOff + data%EquipmentControl%BopControlPanel%MiddleRamsOpenLED = LedOn !LedBlinking + data%State%RAM(4)%FourwayValve = 1 endif endif - if (RAM(4)%FourwayValve == 1 .and. RamLine%P_ACC>BopStackAcc%acc_MinPressure) then - RAM(4)%FourwayValve = 0 - RamLine%ShearBop_closed=0 - RAM(4)%p_bop=ShearRam%PA - RamLine%ShearRamsLeverOld = BopControlPanel%MiddleRamsValve + if (data%State%RAM(4)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then + data%State%RAM(4)%FourwayValve = 0 + data%State%RamLine%ShearBop_closed=0 + data%State%RAM(4)%p_bop=data%State%ShearRAM%PA + data%State%RamLine%ShearRamsLeverOld = data%EquipmentControl%BopControlPanel%MiddleRamsValve CALL OpenMiddleRams - RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code - RAM(4)%bop_type = 3 - ShearRam%NeededVolumeShearRams=ShearRam%AbopShearRam*(ShearRam%IDshearBopBase-ShearRam%IDshearBop)/(2.*231) - RAM(4)%vdis_bottles=0. - RAM(4)%fvr_air=0. - RAM(4)%vdis_elecp=0. - RamLine%ShearRamIsOpening = .true. - RamLine%ShearRamIsClosing = .false. + data%State%RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code + data%State%RAM(4)%bop_type = 3 + data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%IDshearBop)/(2.*231) + data%State%RAM(4)%vdis_bottles=0. + data%State%RAM(4)%fvr_air=0. + data%State%RAM(4)%vdis_elecp=0. + data%State%RamLine%ShearRamIsOpening = .true. + data%State%RamLine%ShearRamIsClosing = .false. endif - RAM(4)%First_CloseTimecheck = 0 - RAM(4)%First_OpenTimecheck = 0 - RAM(4)%time=RAM(4)%time+RamLine%DeltaT_BOP !overal time (s) + data%State%RAM(4)%First_CloseTimecheck = 0 + data%State%RAM(4)%First_OpenTimecheck = 0 + data%State%RAM(4)%time=data%State%RAM(4)%time+data%State%RamLine%DeltaT_BOP !overal time (s) !=================================================== ! BOP !=================================================== - if (RamLine%ShearBop_closed==0) then !bop closing - call bop_code(1,ShearRam%H_ShearRamBop,4) !ramtype=1 4=RNUMBER + if (data%State%RamLine%ShearBop_closed==0) then !bop closing + call bop_code(1,data%State%ShearRAM%H_ShearRamBop,4) !ramtype=1 4=RNUMBER endif !bop is closing !================================================================ - if (RamLine%ShearBop_closed==1) then - RAM(4)%Q=0 - RAM(4)%p_bop=ShearRam%PA - RAMS%minloss(4,17)=0. !RNUMBER=4 + if (data%State%RamLine%ShearBop_closed==1) then + data%State%RAM(4)%Q=0 + data%State%RAM(4)%p_bop=data%State%ShearRAM%PA + data%State%RAMS%minloss(4,17)=0. !RNUMBER=4 endif - RAM(4)%timecounter_ram=RAM(4)%timecounter_ram+1 + data%State%RAM(4)%timecounter_ram=data%State%RAM(4)%timecounter_ram+1 call sleepqq(100) - if (RamLine%ShearBop_closed==1) then - RamLine%FINISHED_shear=1 + if (data%State%RamLine%ShearBop_closed==1) then + data%State%RamLine%FINISHED_shear=1 endif ! if (IsStopped == .true.) return ! end do loop2 !while finished_shear==0 - ! if ( finished_shear==1 .and. RAM(4)%Bottles_Charged_MalfActive==.true.) then + ! if ( finished_shear==1 .and. data%State%RAM(4)%Bottles_Charged_MalfActive==.true.) then ! call bop_code(1,H_ShearRamBop,4) !ramtype=1 4=RNUMBER ! call sleepqq(100) ! endif diff --git a/Equipments/BopStack/VARIABLES.f90 b/Equipments/BopStack/VARIABLES.f90 index c6a256c..8acf589 100644 --- a/Equipments/BopStack/VARIABLES.f90 +++ b/Equipments/BopStack/VARIABLES.f90 @@ -1,5 +1,5 @@ -MODULE VARIABLES - use DynamicDoubleArray +MODULE BopVariables + use DynamicDoubleArray, only:DynamicDoubleArrayType IMPLICIT NONE @@ -14,11 +14,10 @@ type :: BopStackInputType integer MiddleRamsOpenLEDMine,MiddleRamsCloseLEDMine,KillLineOpenLedMine,KillLineCloseLedMine,ChokeLineOpenLEDMine,ChokeLineCloseLEDMine integer BOP_timeCounter end type BopStackInputType -type(BopStackInputType)::BopStackInput !=========================================================================== ! ACC. VARIABLES !=========================================================================== -REAL,PARAMETER :: PI=3.141593 ,PressureDifferenceSteps = 20. ,BaseDifferenceP= 200. ! psi +REAL,PARAMETER :: PressureDifferenceSteps = 20. ,BaseDifferenceP= 200. ! psi type::BopStackAccType REAL FVR_TOT,BOTTLE_CAPACITY,PRAMS_REGSET,acc_ChargedPressure,acc_MinPressure,ACC_PRECHARGE,ByPassOld REAL pram_reg,test1,test2,test3,test4,test5,test6,test7,test8,test9,ax,bx @@ -26,7 +25,6 @@ type::BopStackAccType real Cumulative_AirVolume, PressureDifference integer SoundKoomeyAirPump end type BopStackAccType -type(BopStackAccType)::BopStackAcc !=========================================================================== ! RAM LINE COMPUTATIONAL VARIABLES @@ -53,7 +51,7 @@ type:: RamLineType real:: counter_airp,pacc_before integer Annular_active,ShearBop_active,PipeRam1_active,PipeRam2_active,ChokeLine_active,KillLine_active end type RamLineType -type(RamLineType)::RamLine + !=========================================================================== ! ANNULAR PREVENTER COMPUTATIONAL VARIABLES !=========================================================================== @@ -73,7 +71,6 @@ type::AnnularComputationalType CHARACTER,ALLOCATABLE:: DECRIPTIONANNULAR(:),DECRIPTION2ANNULAR(:),DECRIPTION_ANNULAR(:) REAL WellBorePressure,acoef,Bcoef,const,AnnularSealingPressure,AnnularMovingPressure end type AnnularComputationalType -type(AnnularComputationalType)::AnnularComputational !=========================================================================== ! ANNULAR PREVENTER VARIABLES !=========================================================================== @@ -86,7 +83,6 @@ type :: AnnularType REAL AnnularLeverOld,H_AnnularBop,IDAnnular,AbopAnnular,ODDrillpipe_inAnnular,IDAnnularBase,ODDrillpipe_inAnnularBase REAL NeededVolumeAnnular end type AnnularType -type(AnnularType)::Annular !=========================================================================== ! PIPE RAMS 1 VARIABLES !=========================================================================== @@ -95,9 +91,8 @@ type::PipeRams1Type REAL PipeRams1DotLeverOld,H REAL NeededVolume,A,IDBase,ID,ODDrillpipe_in,ODDrillpipe_inBase integer closed,finished,UpperRamsFailureMalf,UpperRamsLeakMalf,Situation_forTD - REAL real_ID + ! REAL real_ID end type PipeRams1Type -type(PipeRams1Type)::PipeRam1 !============================================================================ ! SHEAR RAM BOP VARIABLES !============================================================================ @@ -111,7 +106,6 @@ type:: ShearRamType Real MinimumOpenArea_InBOP integer MiddleRamsFailureMalf,MiddleRamsLeakMalf,ShearIsNotAllowed end type ShearRamType -type(ShearRamType)::ShearRam !=========================================================================== ! PIPE RAMS 2 VARIABLES !=========================================================================== @@ -123,7 +117,6 @@ type::PipeRam2Type !REAL,ALLOCATABLE:: real_IDPipeRam2(:) REAL real_ID end type PipeRam2Type -type(PipeRam2Type)::PipeRam2 !=========================================================================== ! CHOKE LINE VARIABLES !=========================================================================== @@ -135,7 +128,6 @@ type::ChokeLineType !REAL,ALLOCATABLE:: real_IDPipeRam1(:) REAL real_ID end type ChokeLineType -type(ChokeLineType)::ChokeLine !=========================================================================== ! KILL LINE VARIABLES !=========================================================================== @@ -147,11 +139,10 @@ type::KillLineType !REAL,ALLOCATABLE:: real_IDPipeRam1(:) REAL real_ID end type KillLineType -type(KillLineType)::KillLine !============================================================================ ! OIL & ENVIRONMENT VARIABLES !============================================================================ -REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000,NU=9e-6 +! REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000 !specific gravity of liquid !water density(kg/m^3) !============================================================================ @@ -164,7 +155,6 @@ type::PumpsType REAL alpha_Qair,alpha_timeair,alpha_paccair,alpha_pairp,alpha_diffpair,alpha_lossesair,alpha_fvrair logical SoundKoomeyElectric end type PumpsType -type(PumpsType)::Pumps !================================================================================= @@ -176,7 +166,6 @@ type(PumpsType)::Pumps Logical Bottles_Charged_MalfActive END TYPE BOP_TypeVars - TYPE(BOP_TypeVars), DIMENSION(1:6) :: RAM ! 1 : Annular (RNUMBER) ! 2 : PipeRam1 (RNUMBER) ! 3 : PipeRam2 (RNUMBER) @@ -188,12 +177,4 @@ type(PumpsType)::Pumps REAL, ALLOCATABLE:: minlosspa(:,:),minloss(:,:) REAL,ALLOCATABLE:: Re_ramline(:,:),fric(:,:),fricloss(:,:) END TYPE BOP_TypeVars2D - - TYPE(BOP_TypeVars2D) :: RAMS - -END MODULE - - - - - +END MODULE \ No newline at end of file diff --git a/Equipments/ChokeControl/AirPump_Choke_Subs.f90 b/Equipments/ChokeControl/AirPump_Choke_Subs.f90 index 1a5a713..2b42e9e 100644 --- a/Equipments/ChokeControl/AirPump_Choke_Subs.f90 +++ b/Equipments/ChokeControl/AirPump_Choke_Subs.f90 @@ -2,6 +2,8 @@ SUBROUTINE DEALLOCATE_ARRAYS_CHOKE() USE CHOKEVARIABLES +use ConfigurationVariables !@ + implicit none write(*,*) 'deallocateeeeeeeeeeeee' !=========================================================================== @@ -9,13 +11,13 @@ write(*,*) 'deallocateeeeeeeeeeeee' !=========================================================================== !if(allocated(PIPINGS_AIRPUMP)) deallocate(PIPINGS_AIRPUMP) -DEALLOCATE (AirPumpLine%PIPINGS_AIRPUMP,AirPumpLine%DIAM_AIR_INCH, & - AirPumpLine%Re_air,AirPumpLine%AREA_AIR,AirPumpLine%LENGT_AIR,AirPumpLine%ROUGHNESS_AIRPLINE,AirPumpLine%REL_ROUGHAIR, & - AirPumpLine%fric_air,AirPumpLine%fricloss_air) +DEALLOCATE (data%State%AirPumpLine%PIPINGS_AIRPUMP,data%State%AirPumpLine%DIAM_AIR_INCH, & + data%State%AirPumpLine%Re_air,data%State%AirPumpLine%AREA_AIR,data%State%AirPumpLine%LENGT_AIR,data%State%AirPumpLine%ROUGHNESS_AIRPLINE,data%State%AirPumpLine%REL_ROUGHAIR, & + data%State%AirPumpLine%fric_air,data%State%AirPumpLine%fricloss_air) !================================================================ -DEALLOCATE (AirPumpLine%MINORS_AIRPUMP,AirPumpLine%MINORDIAM_AIR_INCH, & - AirPumpLine%MINORAREA_AIR,AirPumpLine%LF_AIR,AirPumpLine%CV_AIR,AirPumpLine%NOTE_AIR & - ,AirPumpLine%minlosspa_air,AirPumpLine%minloss_air) +DEALLOCATE (data%State%AirPumpLine%MINORS_AIRPUMP,data%State%AirPumpLine%MINORDIAM_AIR_INCH, & + data%State%AirPumpLine%MINORAREA_AIR,data%State%AirPumpLine%LF_AIR,data%State%AirPumpLine%CV_AIR,data%State%AirPumpLine%NOTE_AIR & + ,data%State%AirPumpLine%minlosspa_air,data%State%AirPumpLine%minloss_air) END @@ -26,6 +28,7 @@ DEALLOCATE (AirPumpLine%MINORS_AIRPUMP,AirPumpLine%MINORDIAM_AIR_INCH, & SUBROUTINE LOSS_INPUTS_CHOKE() USE CHOKEVARIABLES +use ConfigurationVariables !@ implicit none Integer I @@ -33,63 +36,63 @@ implicit none !=========================================================================== ! AIR PUMP LOSSES INPUT !=========================================================================== -AirPumpLine%NO_PIPINGS_AIRPLINE=1 +data%State%AirPumpLine%NO_PIPINGS_AIRPLINE=1 -ALLOCATE (AirPumpLine%PIPINGS_AIRPUMP(AirPumpLine%NO_PIPINGS_AIRPLINE,3)) +ALLOCATE (data%State%AirPumpLine%PIPINGS_AIRPUMP(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE,3)) ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION -AirPumpLine%PIPINGS_AIRPUMP(1,1:3)= (/0.5, 60960., 0.03/) !Avg.acc.distance +data%State%AirPumpLine%PIPINGS_AIRPUMP(1,1:3)= (/0.5, 60960., 0.03/) !Avg.acc.distance !60960= 200 ft - ALLOCATE (AirPumpLine%DIAM_AIR_INCH(AirPumpLine%NO_PIPINGS_AIRPLINE),AirPumpLine%Re_air(AirPumpLine%NO_PIPINGS_AIRPLINE),AirPumpLine%AREA_AIR(AirPumpLine%NO_PIPINGS_AIRPLINE), & - AirPumpLine%LENGT_AIR(AirPumpLine%NO_PIPINGS_AIRPLINE),AirPumpLine%ROUGHNESS_AIRPLINE(AirPumpLine%NO_PIPINGS_AIRPLINE),AirPumpLine%REL_ROUGHAIR(AirPumpLine%NO_PIPINGS_AIRPLINE), & - AirPumpLine%fric_air(AirPumpLine%NO_PIPINGS_AIRPLINE),AirPumpLine%fricloss_air(AirPumpLine%NO_PIPINGS_AIRPLINE)) + ALLOCATE (data%State%AirPumpLine%DIAM_AIR_INCH(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE),data%State%AirPumpLine%Re_air(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE),data%State%AirPumpLine%AREA_AIR(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE), & + data%State%AirPumpLine%LENGT_AIR(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE),data%State%AirPumpLine%ROUGHNESS_AIRPLINE(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE),data%State%AirPumpLine%REL_ROUGHAIR(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE), & + data%State%AirPumpLine%fric_air(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE),data%State%AirPumpLine%fricloss_air(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE)) -DO I=1,AirPumpLine%NO_PIPINGS_AIRPLINE - AirPumpLine%DIAM_AIR_INCH(I)=AirPumpLine%PIPINGS_AIRPUMP(I,1) - AirPumpLine%LENGT_AIR(I)=AirPumpLine%PIPINGS_AIRPUMP(I,2) - AirPumpLine%ROUGHNESS_AIRPLINE(I)=AirPumpLine%PIPINGS_AIRPUMP(I,3) +DO I=1,data%State%AirPumpLine%NO_PIPINGS_AIRPLINE + data%State%AirPumpLine%DIAM_AIR_INCH(I)=data%State%AirPumpLine%PIPINGS_AIRPUMP(I,1) + data%State%AirPumpLine%LENGT_AIR(I)=data%State%AirPumpLine%PIPINGS_AIRPUMP(I,2) + data%State%AirPumpLine%ROUGHNESS_AIRPLINE(I)=data%State%AirPumpLine%PIPINGS_AIRPUMP(I,3) - AirPumpLine%AREA_AIR(I)=PI*(AirPumpLine%DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m) - AirPumpLine%REL_ROUGHAIR(I)=AirPumpLine%ROUGHNESS_AIRPLINE(I)/(AirPumpLine%DIAM_AIR_INCH(I)*25.4) + data%State%AirPumpLine%AREA_AIR(I)=PI*(data%State%AirPumpLine%DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m) + data%State%AirPumpLine%REL_ROUGHAIR(I)=data%State%AirPumpLine%ROUGHNESS_AIRPLINE(I)/(data%State%AirPumpLine%DIAM_AIR_INCH(I)*25.4) !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m) - AirPumpLine%LENGT_AIR(I)=AirPumpLine%LENGT_AIR(I)*.001 ! (m) + data%State%AirPumpLine%LENGT_AIR(I)=data%State%AirPumpLine%LENGT_AIR(I)*.001 ! (m) ENDDO !================================================================ -AirPumpLine%NO_MINORS_AIRPLINE=6 +data%State%AirPumpLine%NO_MINORS_AIRPLINE=6 -ALLOCATE (AirPumpLine%MINORS_AIRPUMP(AirPumpLine%NO_MINORS_AIRPLINE,4)) +ALLOCATE (data%State%AirPumpLine%MINORS_AIRPUMP(data%State%AirPumpLine%NO_MINORS_AIRPLINE,4)) ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION -AirPumpLine%MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee -AirPumpLine%MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow -AirPumpLine%MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter -AirPumpLine%MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve -AirPumpLine%MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve -AirPumpLine%MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA +data%State%AirPumpLine%MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee +data%State%AirPumpLine%MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow +data%State%AirPumpLine%MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter +data%State%AirPumpLine%MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve +data%State%AirPumpLine%MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve +data%State%AirPumpLine%MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA - ALLOCATE (AirPumpLine%MINORDIAM_AIR_INCH(AirPumpLine%NO_MINORS_AIRPLINE),AirPumpLine%MINORAREA_AIR(AirPumpLine%NO_MINORS_AIRPLINE), & - AirPumpLine%LF_AIR(AirPumpLine%NO_MINORS_AIRPLINE),AirPumpLine%CV_AIR(AirPumpLine%NO_MINORS_AIRPLINE),AirPumpLine%NOTE_AIR(AirPumpLine%NO_MINORS_AIRPLINE) & - ,AirPumpLine%minlosspa_air(AirPumpLine%NO_MINORS_AIRPLINE),AirPumpLine%minloss_air(AirPumpLine%NO_MINORS_AIRPLINE)) + ALLOCATE (data%State%AirPumpLine%MINORDIAM_AIR_INCH(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%MINORAREA_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE), & + data%State%AirPumpLine%LF_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%CV_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%NOTE_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE) & + ,data%State%AirPumpLine%minlosspa_air(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%minloss_air(data%State%AirPumpLine%NO_MINORS_AIRPLINE)) -DO I=1,AirPumpLine%NO_MINORS_AIRPLINE - AirPumpLine%MINORDIAM_AIR_INCH(I)=AirPumpLine%MINORS_AIRPUMP(I,1) - AirPumpLine%LF_AIR(I)=AirPumpLine%MINORS_AIRPUMP(I,2) - AirPumpLine%CV_AIR(I)=AirPumpLine%MINORS_AIRPUMP(I,3) - AirPumpLine%NOTE_AIR(I)=AirPumpLine%MINORS_AIRPUMP(I,4) +DO I=1,data%State%AirPumpLine%NO_MINORS_AIRPLINE + data%State%AirPumpLine%MINORDIAM_AIR_INCH(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,1) + data%State%AirPumpLine%LF_AIR(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,2) + data%State%AirPumpLine%CV_AIR(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,3) + data%State%AirPumpLine%NOTE_AIR(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,4) - AirPumpLine%MINORAREA_AIR(I)=PI*(AirPumpLine%MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m) + data%State%AirPumpLine%MINORAREA_AIR(I)=PI*(data%State%AirPumpLine%MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m) ENDDO @@ -101,21 +104,22 @@ ENDDO ! SUBROUTINE PIPE_RAMS_CHOKE(CHNUMBER) ! USE CHOKEVARIABLES +! use ConfigurationVariables !@ ! 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. +! loop3: do while (ABS(data%EquipmentControl%ChokeControlPanel%ChokeControlLever)==1.0 .AND. data%EquipmentControl%ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. data%State%CHOOKE(CHNUMBER)%FailMalf==0 .AND. data%State%AirDrivenPump%ChokeAirFail==0) +! if (data%EquipmentControl%ChokeControlPanel%ChokeControlLever == 1.0) then +! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .true. +! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .false. ! endif -! if (ChokeControlPanel%ChokeControlLever == -1.0) then -! CHOOKE(CHNUMBER)%ChokeIsOpening = .true. -! CHOOKE(CHNUMBER)%ChokeIsClosing = .false. +! if (data%EquipmentControl%ChokeControlPanel%ChokeControlLever == -1.0) then +! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .true. +! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .false. ! endif -! AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s) +! data%State%AirPumpLine%TIME=data%State%AirPumpLine%TIME+data%State%AirPumpLine%DeltaT_Choke !overal time (s) ! call airpump_code_CHOKE(CHNUMBER) ! call sleepqq(100) ! if (IsStopped == .true.) return @@ -129,7 +133,9 @@ ENDDO SUBROUTINE airpump_code_CHOKE(CHNUMBER) USE CHOKEVARIABLES - USE CChokeManifoldVariables +use ConfigurationVariables !@ + use CChokeManifold + use ConfigurationVariables use CSounds USE CChokeProblemsVariables implicit none @@ -137,193 +143,193 @@ ENDDO INTEGER CHNUMBER - AirDrivenPump%QAIR_PUMP=AirPumpLine%QITER+.1 !(gpm) maximum flow for the start - AirPumpLine%diffp_air=-10 - AirPumpLine%losses_air=10 + data%State%AirDrivenPump%QAIR_PUMP=data%State%AirPumpLine%QITER+.1 !(gpm) maximum flow for the start + data%State%AirPumpLine%diffp_air=-10 + data%State%AirPumpLine%losses_air=10 !=================================================================== ! AIR OPERATED PUMP ! MODEL 10-6000W030 RATIO 55:1 !=================for air consumption at 100 psig=================== - do while (AirPumpLine%diffp_air<0) - AirDrivenPump%QAIR_PUMP=AirDrivenPump%QAIR_PUMP-.1 - ! Qup=AirDrivenPump%QAIR_PUMP; + do while (data%State%AirPumpLine%diffp_air<0) + data%State%AirDrivenPump%QAIR_PUMP=data%State%AirDrivenPump%QAIR_PUMP-.1 + ! Qup=data%State%AirDrivenPump%QAIR_PUMP; !cc1 = 1354; cc2 = -2066; cc3 = -2109; cc4 = -513.6; cc5 = 5935 FOR OUTPUT IN GPM - AirPumpLine%P_AIRP=AirDrivenPump%cc1*(AirDrivenPump%QAIR_PUMP**4) + AirDrivenPump%cc2*(AirDrivenPump%QAIR_PUMP**3) + AirDrivenPump%cc3*(AirDrivenPump%QAIR_PUMP**2) + AirDrivenPump%cc4*AirDrivenPump%QAIR_PUMP + AirDrivenPump%cc5 !(psig) + data%State%AirPumpLine%P_AIRP=data%State%AirDrivenPump%cc1*(data%State%AirDrivenPump%QAIR_PUMP**4) + data%State%AirDrivenPump%cc2*(data%State%AirDrivenPump%QAIR_PUMP**3) + data%State%AirDrivenPump%cc3*(data%State%AirDrivenPump%QAIR_PUMP**2) + data%State%AirDrivenPump%cc4*data%State%AirDrivenPump%QAIR_PUMP + data%State%AirDrivenPump%cc5 !(psig) ! kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-5/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi) - AirPumpLine%diffp_air= AirPumpLine%P_AIRP - AirPumpLine%Pdownstrem + data%State%AirPumpLine%diffp_air= data%State%AirPumpLine%P_AIRP - data%State%AirPumpLine%Pdownstrem end do !returns Qup - do while (abs((AirPumpLine%diffp_air-AirPumpLine%losses_air)/AirPumpLine%diffp_air)>AirPumpLine%TOL_AIR) !finding correct QAIR_pump for 1 timecounter_ram - if (AirPumpLine%diffp_air-AirPumpLine%losses_air>0) then - AirDrivenPump%QAIR_PUMP=AirDrivenPump%QAIR_PUMP+.005 + do while (abs((data%State%AirPumpLine%diffp_air-data%State%AirPumpLine%losses_air)/data%State%AirPumpLine%diffp_air)>data%State%AirPumpLine%TOL_AIR) !finding correct QAIR_pump for 1 timecounter_ram + if (data%State%AirPumpLine%diffp_air-data%State%AirPumpLine%losses_air>0) then + data%State%AirDrivenPump%QAIR_PUMP=data%State%AirDrivenPump%QAIR_PUMP+.005 else - AirDrivenPump%QAIR_PUMP=AirDrivenPump%QAIR_PUMP-.005 + data%State%AirDrivenPump%QAIR_PUMP=data%State%AirDrivenPump%QAIR_PUMP-.005 endif !=================================================================== ! AIR OPERATED PUMP ! MODEL 10-6000W030 RATIO 55:1 !=================for air consumption at 100 psig=================== - AirPumpLine%P_AIRP=AirDrivenPump%cc1*(AirDrivenPump%QAIR_PUMP**4) + AirDrivenPump%cc2*(AirDrivenPump%QAIR_PUMP**3) + AirDrivenPump%cc3*(AirDrivenPump%QAIR_PUMP**2) + AirDrivenPump%cc4*AirDrivenPump%QAIR_PUMP + AirDrivenPump%cc5 !(psig) + data%State%AirPumpLine%P_AIRP=data%State%AirDrivenPump%cc1*(data%State%AirDrivenPump%QAIR_PUMP**4) + data%State%AirDrivenPump%cc2*(data%State%AirDrivenPump%QAIR_PUMP**3) + data%State%AirDrivenPump%cc3*(data%State%AirDrivenPump%QAIR_PUMP**2) + data%State%AirDrivenPump%cc4*data%State%AirDrivenPump%QAIR_PUMP + data%State%AirDrivenPump%cc5 !(psig) !kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-005/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi) - AirPumpLine%diffp_air= AirPumpLine%P_AIRP - AirPumpLine%Pdownstrem + data%State%AirPumpLine%diffp_air= data%State%AirPumpLine%P_AIRP - data%State%AirPumpLine%Pdownstrem !===========================LOSSES==================================== - do i=1,AirPumpLine%NO_PIPINGS_AIRPLINE - AirPumpLine%Re_air(i)=AirDrivenPump%QAIR_PUMP*6.30902e-005*AirPumpLine%DIAM_AIR_INCH(I)*0.0254/(AirPumpLine%AREA_AIR(i)*nu) + do i=1,data%State%AirPumpLine%NO_PIPINGS_AIRPLINE + data%State%AirPumpLine%Re_air(i)=data%State%AirDrivenPump%QAIR_PUMP*6.30902e-005*data%State%AirPumpLine%DIAM_AIR_INCH(I)*0.0254/(data%State%AirPumpLine%AREA_AIR(i)*nu) enddo - do i=1,AirPumpLine%NO_PIPINGS_AIRPLINE - if (AirPumpLine%Re_air(i) 1.0 ) then - Choke%SoundChokePump= 60 - Choke%Cumulative_AirVolume_Choke= Choke%Cumulative_AirVolume_Choke - 1.0 + if ( data%State%Choke%Cumulative_AirVolume_Choke > 1.0 ) then + data%State%Choke%SoundChokePump= 60 + data%State%Choke%Cumulative_AirVolume_Choke= data%State%Choke%Cumulative_AirVolume_Choke - 1.0 else - Choke%SoundChokePump= 0.0 + data%State%Choke%SoundChokePump= 0.0 endif - AirPumpLine%DELTAV_AIR=AirDrivenPump%QAIR_PUMP*AirPumpLine%DeltaT_Choke/60 !(galon) delta_t=1sec , Q(gpm) - if (CHOOKE(CHNUMBER)%ChokeIsClosing) CHOOKE(CHNUMBER)%PassedCourse=CHOOKE(CHNUMBER)%PassedCourse + (AirPumpLine%DELTAV_AIR*3785.412/AirPumpLine%Acylinder)!*(ChokeRateControlKnob/10.) ! 3785.412 : GALON TO CM^3 - if (CHOOKE(CHNUMBER)%ChokeIsOpening) CHOOKE(CHNUMBER)%PassedCourse=CHOOKE(CHNUMBER)%PassedCourse - (AirPumpLine%DELTAV_AIR*3785.412/AirPumpLine%Acylinder)!*(ChokeRateControlKnob/10.) + data%State%AirPumpLine%DELTAV_AIR=data%State%AirDrivenPump%QAIR_PUMP*data%State%AirPumpLine%DeltaT_Choke/60 !(galon) delta_t=1sec , Q(gpm) + if (data%State%CHOOKE(CHNUMBER)%ChokeIsClosing) data%State%CHOOKE(CHNUMBER)%PassedCourse=data%State%CHOOKE(CHNUMBER)%PassedCourse + (data%State%AirPumpLine%DELTAV_AIR*3785.412/data%State%AirPumpLine%Acylinder)!*(ChokeRateControlKnob/10.) ! 3785.412 : GALON TO CM^3 + if (data%State%CHOOKE(CHNUMBER)%ChokeIsOpening) data%State%CHOOKE(CHNUMBER)%PassedCourse=data%State%CHOOKE(CHNUMBER)%PassedCourse - (data%State%AirPumpLine%DELTAV_AIR*3785.412/data%State%AirPumpLine%Acylinder)!*(ChokeRateControlKnob/10.) !DeltaT_Choke= 1sec or 2sec !((((((((IN OUTER LOOP)))))) !===============AIR PUMP OUTPUTS========================= - AirPumpLine%alpha_timeair=AirPumpLine%TIME ! overal time (s) - AirPumpLine%alpha_Pdownstrem=AirPumpLine%Pdownstrem - AirPumpLine%alpha_pairp=AirPumpLine%P_AIRP - AirPumpLine%alpha_Qair=AirDrivenPump%QAIR_PUMP + data%State%AirPumpLine%alpha_timeair=data%State%AirPumpLine%TIME ! overal time (s) + data%State%AirPumpLine%alpha_Pdownstrem=data%State%AirPumpLine%Pdownstrem + data%State%AirPumpLine%alpha_pairp=data%State%AirPumpLine%P_AIRP + data%State%AirPumpLine%alpha_Qair=data%State%AirDrivenPump%QAIR_PUMP !write(*,*) 'diffp_air=',diffp_air !pause - AirPumpLine%alpha_diffpair=AirPumpLine%diffp_air - AirPumpLine%alpha_lossesair=AirPumpLine%losses_air + data%State%AirPumpLine%alpha_diffpair=data%State%AirPumpLine%diffp_air + data%State%AirPumpLine%alpha_lossesair=data%State%AirPumpLine%losses_air !======================================================== !OPEN(150,FILE='CHOKE_AIRPUMP_OUTPUTS.DAT') - if (CHOOKE(CHNUMBER)%ChokeIsClosing .AND. CHOOKE(CHNUMBER)%PassedCourse>AirPumpLine%CourseBase) then - CHOOKE(CHNUMBER)%PassedCourse=AirPumpLine%CourseBase - Choke%SoundChokePump= 0.0 + if (data%State%CHOOKE(CHNUMBER)%ChokeIsClosing .AND. data%State%CHOOKE(CHNUMBER)%PassedCourse>data%State%AirPumpLine%CourseBase) then + data%State%CHOOKE(CHNUMBER)%PassedCourse=data%State%AirPumpLine%CourseBase + data%State%Choke%SoundChokePump= 0.0 endif - if (CHOOKE(CHNUMBER)%ChokeIsOpening .AND. CHOOKE(CHNUMBER)%PassedCourse<0.) then - CHOOKE(CHNUMBER)%PassedCourse=0. - Choke%SoundChokePump= 0.0 + if (data%State%CHOOKE(CHNUMBER)%ChokeIsOpening .AND. data%State%CHOOKE(CHNUMBER)%PassedCourse<0.) then + data%State%CHOOKE(CHNUMBER)%PassedCourse=0. + data%State%Choke%SoundChokePump= 0.0 endif - call SetSoundChokePump(Choke%SoundChokePump) - CHOOKE(CHNUMBER)%PercentClose= CHOOKE(CHNUMBER)%PassedCourse/AirPumpLine%CourseBase - IF (ChokeControlPanel%Choke1LED==1) THEN - ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(1)%PercentClose*10 + call SetSoundChokePump(data%State%Choke%SoundChokePump) + data%State%CHOOKE(CHNUMBER)%PercentClose= data%State%CHOOKE(CHNUMBER)%PassedCourse/data%State%AirPumpLine%CourseBase + IF (data%EquipmentControl%ChokeControlPanel%Choke1LED==1) THEN + data%EquipmentControl%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%CHOOKE(1)%PercentClose*10 ELSE ! Choke2LED==1 - ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(2)%PercentClose*10 + data%EquipmentControl%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%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)) + !CALL SetHydraulicChock1(nint(MIN(data%State%CHOOKE(1)%PercentClose / 0.91 , 1.0)*100)) + ! CALL SetHydraulicChock2(nint(MIN(data%State%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 + data%State%CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(data%State%CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2) + data%State%CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(data%State%CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2 + data%State%Choke%HydraulicChoke1WashoutCoef= data%State%Choke%HydraulicChoke1WashoutCoef * data%State%CHOOKE(1)%WashoutMalf + data%State%Choke%HydraulicChoke1WashoutCoef= MIN( 0.5 , data%State%Choke%HydraulicChoke1WashoutCoef+ data%State%CHOOKE(1)%WashoutMalf*(0.5/(60.0/data%State%AirPumpLine%DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time + data%State%Choke%HydraulicChoke2WashoutCoef= data%State%Choke%HydraulicChoke2WashoutCoef * data%State%CHOOKE(2)%WashoutMalf + data%State%Choke%HydraulicChoke2WashoutCoef= MIN( 0.5 , data%State%Choke%HydraulicChoke2WashoutCoef+ data%State%CHOOKE(2)%WashoutMalf*(0.5/(60.0/data%State%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 + IF (data%State%CHOOKE(1)%PlugMalf == 1) THEN + data%State%Choke%Present_HydraulicChoke1Plug= data%State%Choke%Present_HydraulicChoke1Plug * data%State%CHOOKE(1)%PlugMalf ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent - if ( (ChokeProblems%HydraulicChoke1PluggedPercent - Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then - Choke%DeltaPlug1Percent = (REAL(ChokeProblems%HydraulicChoke1PluggedPercent)/100.) - Choke%Present_HydraulicChoke1Plug - Choke%Plug1TimeCounter = 0 + if ( (data%problems%ChokeProblems%HydraulicChoke1PluggedPercent - data%State%Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then + data%State%Choke%DeltaPlug1Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke1PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke1Plug + data%State%Choke%Plug1TimeCounter = 0 !write(*,*) 'DeltaPlug1Percent, Present_HydraulicChoke1Plug = ' ,DeltaPlug1Percent , Present_HydraulicChoke1Plug endif - Choke%Plug1TimeCounter= Choke%Plug1TimeCounter + 1 - Choke%HydraulicChoke1PluggedPercent_Old= ChokeProblems%HydraulicChoke1PluggedPercent + data%State%Choke%Plug1TimeCounter= data%State%Choke%Plug1TimeCounter + 1 + data%State%Choke%HydraulicChoke1PluggedPercent_Old= data%problems%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 + if (data%State%Choke%Plug1TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=600 + data%State%Choke%Present_HydraulicChoke1Plug = data%State%Choke%Present_HydraulicChoke1Plug + data%State%CHOOKE(1)%PlugMalf* ((data%State%Choke%DeltaPlug1Percent / real(data%State%Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0 endif !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug ENDIF - IF (CHOOKE(2)%PlugMalf == 1) THEN - Choke%Present_HydraulicChoke2Plug= Choke%Present_HydraulicChoke2Plug * CHOOKE(2)%PlugMalf + IF (data%State%CHOOKE(2)%PlugMalf == 1) THEN + data%State%Choke%Present_HydraulicChoke2Plug= data%State%Choke%Present_HydraulicChoke2Plug * data%State%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 + if ( (data%problems%ChokeProblems%HydraulicChoke2PluggedPercent - data%State%Choke%HydraulicChoke2PluggedPercent_Old) /= 0 ) then + data%State%Choke%DeltaPlug2Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke2PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke2Plug + data%State%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 + data%State%Choke%Plug2TimeCounter= data%State%Choke%Plug2TimeCounter + 1 + data%State%Choke%HydraulicChoke2PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke2PluggedPercent + if (data%State%Choke%Plug2TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=600 + data%State%Choke%Present_HydraulicChoke2Plug = data%State%Choke%Present_HydraulicChoke2Plug + data%State%CHOOKE(2)%PlugMalf *((data%State%Choke%DeltaPlug2Percent / real(data%State%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 + data%State%CHOOKE(1)%AreaChoke=data%State%CHOOKE(1)%AreaChoke+(data%State%CHOOKE(1)%WashoutMalf*data%State%Choke%HydraulicChoke1WashoutCoef*data%State%Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup - !write(*,*) 'CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke=' ,CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke + !write(*,*) 'data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke=' ,data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke - CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke-(CHOOKE(1)%PlugMalf* Choke%Present_HydraulicChoke1Plug *CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup + data%State%CHOOKE(1)%AreaChoke=data%State%CHOOKE(1)%AreaChoke-(data%State%CHOOKE(1)%PlugMalf* data%State%Choke%Present_HydraulicChoke1Plug *data%State%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 + data%State%CHOOKE(2)%AreaChoke=data%State%CHOOKE(2)%AreaChoke+(data%State%CHOOKE(2)%WashoutMalf*data%State%Choke%HydraulicChoke2WashoutCoef*data%State%Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup + data%State%CHOOKE(2)%AreaChoke=data%State%CHOOKE(2)%AreaChoke-(data%State%CHOOKE(2)%PlugMalf* data%State%Choke%Present_HydraulicChoke2Plug *data%State%CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup + !write(*,*) 'data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke=' ,data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke - CHOOKE(1)%AreaChokeFinal= CHOOKE(1)%AreaChoke - CHOOKE(2)%AreaChokeFinal= CHOOKE(2)%AreaChoke + data%State%CHOOKE(1)%AreaChokeFinal= data%State%CHOOKE(1)%AreaChoke + data%State%CHOOKE(2)%AreaChokeFinal= data%State%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 + CALL SetHydraulicChock1(100 - nint((data%State%CHOOKE(1)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve + CALL SetHydraulicChock2(100 - nint((data%State%CHOOKE(2)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve - !write(*,*) 'CHOOKE(1)%PercentClose=' , CHOOKE(1)%PercentClose ! close percent 0 to 100 + !write(*,*) 'data%State%CHOOKE(1)%PercentClose=' , data%State%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(*,*) 'data%State%CHOOKE(1)%AreaChokeFinal=' , data%State%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 value=' , 100 - nint((data%State%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(*,*) 'data%State%CHOOKE(1)%AreaChoke= ' , data%State%CHOOKE(1)%AreaChoke !WRITE(150,50) alpha_timeair,alpha_Qair,alpha_pairp, & - !alpha_Pdownstrem,alpha_diffpair,alpha_lossesair,CHOOKE(CHNUMBER)%PassedCourse + !alpha_Pdownstrem,alpha_diffpair,alpha_lossesair,data%State%CHOOKE(CHNUMBER)%PassedCourse !50 FORMAT(7(f15.5)) !======================================================================================== !======================================================================================== diff --git a/Equipments/ChokeControl/CHOKE.f90 b/Equipments/ChokeControl/CHOKE.f90 index 920969a..f20d14f 100644 --- a/Equipments/ChokeControl/CHOKE.f90 +++ b/Equipments/ChokeControl/CHOKE.f90 @@ -1,41 +1,46 @@ module ChokeModule - USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables, CasingPressureDataDisplay=>CasingPressure!, StandPipePressureDataDisplay=>StandPipePressure + USE CHOKEVARIABLES +use ConfigurationVariables !@ + !use CDataDisplayConsole + ! !@use ConfigurationVariables, CasingPressureDataDisplay=>CasingPressure!, StandPipePressureDataDisplay=>StandPipePressure USE CChokeProblemsVariables - !use CChokeControlPanelVariables, StandPipePressureChoke=>StandPipePressure - use MudSystemVARIABLES - USE CChokeManifoldVariables + !use CChokeControlPanelVariables + ! !@use ConfigurationVariables, StandPipePressureChoke=>StandPipePressure + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ + use CChokeManifold + use ConfigurationVariables contains ! function CHOKE_MainBody1 result(CHNUMBER) ! implicit none ! INTEGER CHNUMBER - ! IF(ChokeControlPanel%ChokeSelectorSwitch== 1) THEN - ! ChokeControlPanel%Choke1LED=1 - ! ChokeControlPanel%Choke2LED=0 + ! IF(data%EquipmentControl%ChokeControlPanel%ChokeSelectorSwitch== 1) THEN + ! data%EquipmentControl%ChokeControlPanel%Choke1LED=1 + ! data%EquipmentControl%ChokeControlPanel%Choke2LED=0 ! CHNUMBER=1 ! ELSE - ! ChokeControlPanel%Choke2LED=1 - ! ChokeControlPanel%Choke1LED=0 + ! data%EquipmentControl%ChokeControlPanel%Choke2LED=1 + ! data%EquipmentControl%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. + ! ! do while (ABS(data%EquipmentControl%ChokeControlPanel%ChokeControlLever)==1.0 .AND. data%EquipmentControl%ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. data%State%CHOOKE(CHNUMBER)%FailMalf==0 .AND. data%State%AirDrivenPump%ChokeAirFail==0) + ! if (data%EquipmentControl%ChokeControlPanel%ChokeControlLever == 1.0) then + ! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .true. + ! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .false. ! endif - ! if (ChokeControlPanel%ChokeControlLever == -1.0) then - ! CHOOKE(CHNUMBER)%ChokeIsOpening = .true. - ! CHOOKE(CHNUMBER)%ChokeIsClosing = .false. + ! if (data%EquipmentControl%ChokeControlPanel%ChokeControlLever == -1.0) then + ! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .true. + ! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .false. ! endif - ! AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s) + ! data%State%AirPumpLine%TIME=data%State%AirPumpLine%TIME+data%State%AirPumpLine%DeltaT_Choke !overal time (s) ! call airpump_code_CHOKE(CHNUMBER) ! ! call sleepqq(100) ! ! if (IsStopped == .true.) return @@ -44,83 +49,83 @@ module ChokeModule ! end subroutine Choke_innerLoop subroutine CHOKE_MainBody2 - IF (ChokeControlPanel%Choke1LED==1) THEN - ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(1)%PercentClose*10 ! display monitor + IF (data%EquipmentControl%ChokeControlPanel%Choke1LED==1) THEN + data%EquipmentControl%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%CHOOKE(1)%PercentClose*10 ! display monitor ELSE ! Choke2LED==1 - ChokeControlPanel%ChokePosition= (1 - Choke%GaugeChokePositionMailf) * CHOOKE(2)%PercentClose*10 ! display monitor + data%EquipmentControl%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%CHOOKE(2)%PercentClose*10 ! display monitor ENDIF ! =================== 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/(180.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time - Choke%HydraulicChoke2WashoutCoef= Choke%HydraulicChoke2WashoutCoef * CHOOKE(2)%WashoutMalf - Choke%HydraulicChoke2WashoutCoef= MIN( 0.5 , Choke%HydraulicChoke2WashoutCoef+ CHOOKE(2)%WashoutMalf*(0.5/(180.0/AirPumpLine%DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time + data%State%CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(data%State%CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2) + data%State%CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(data%State%CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2 + !write(*,*) 'data%State%CHOOKE(1)%AreaChoke= ' , data%State%CHOOKE(1)%AreaChoke + data%State%Choke%HydraulicChoke1WashoutCoef= data%State%Choke%HydraulicChoke1WashoutCoef * data%State%CHOOKE(1)%WashoutMalf + data%State%Choke%HydraulicChoke1WashoutCoef= MIN( 0.5 , data%State%Choke%HydraulicChoke1WashoutCoef+ data%State%CHOOKE(1)%WashoutMalf*(0.5/(180.0/data%State%AirPumpLine%DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time + data%State%Choke%HydraulicChoke2WashoutCoef= data%State%Choke%HydraulicChoke2WashoutCoef * data%State%CHOOKE(2)%WashoutMalf + data%State%Choke%HydraulicChoke2WashoutCoef= MIN( 0.5 , data%State%Choke%HydraulicChoke2WashoutCoef+ data%State%CHOOKE(2)%WashoutMalf*(0.5/(180.0/data%State%AirPumpLine%DeltaT_Choke)) ) ! 0.5 = maximum washout coef , 180.0 sec = 3 min duration time !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef - IF (CHOOKE(1)%PlugMalf == 1) THEN - Choke%Present_HydraulicChoke1Plug= Choke%Present_HydraulicChoke1Plug * CHOOKE(1)%PlugMalf + IF (data%State%CHOOKE(1)%PlugMalf == 1) THEN + data%State%Choke%Present_HydraulicChoke1Plug= data%State%Choke%Present_HydraulicChoke1Plug * data%State%CHOOKE(1)%PlugMalf ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent - if ( (ChokeProblems%HydraulicChoke1PluggedPercent - Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then - Choke%DeltaPlug1Percent = (REAL(ChokeProblems%HydraulicChoke1PluggedPercent)/100.) - Choke%Present_HydraulicChoke1Plug - Choke%Plug1TimeCounter = 0 + if ( (data%problems%ChokeProblems%HydraulicChoke1PluggedPercent - data%State%Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then + data%State%Choke%DeltaPlug1Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke1PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke1Plug + data%State%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=1800 - Choke%Present_HydraulicChoke1Plug = Choke%Present_HydraulicChoke1Plug + CHOOKE(1)%PlugMalf* ((Choke%DeltaPlug1Percent / real(Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0 + data%State%Choke%Plug1TimeCounter= data%State%Choke%Plug1TimeCounter + 1 + data%State%Choke%HydraulicChoke1PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke1PluggedPercent + if (data%State%Choke%Plug1TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800 + data%State%Choke%Present_HydraulicChoke1Plug = data%State%Choke%Present_HydraulicChoke1Plug + data%State%CHOOKE(1)%PlugMalf* ((data%State%Choke%DeltaPlug1Percent / real(data%State%Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0 endif !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug ENDIF - IF (CHOOKE(2)%PlugMalf == 1) THEN - Choke%Present_HydraulicChoke2Plug= Choke%Present_HydraulicChoke2Plug * CHOOKE(2)%PlugMalf + IF (data%State%CHOOKE(2)%PlugMalf == 1) THEN + data%State%Choke%Present_HydraulicChoke2Plug= data%State%Choke%Present_HydraulicChoke2Plug * data%State%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 + if ( (data%problems%ChokeProblems%HydraulicChoke2PluggedPercent - data%State%Choke%HydraulicChoke2PluggedPercent_Old) /= 0 ) then + data%State%Choke%DeltaPlug2Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke2PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke2Plug + data%State%Choke%Plug2TimeCounter = 0 endif - Choke%Plug2TimeCounter= Choke%Plug2TimeCounter + 1 - Choke%HydraulicChoke2PluggedPercent_Old= ChokeProblems%HydraulicChoke2PluggedPercent - if (Choke%Plug2TimeCounter <= Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800 - Choke%Present_HydraulicChoke2Plug = Choke%Present_HydraulicChoke2Plug + CHOOKE(2)%PlugMalf *((Choke%DeltaPlug2Percent / real(Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 1800.0 + data%State%Choke%Plug2TimeCounter= data%State%Choke%Plug2TimeCounter + 1 + data%State%Choke%HydraulicChoke2PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke2PluggedPercent + if (data%State%Choke%Plug2TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=1800 + data%State%Choke%Present_HydraulicChoke2Plug = data%State%Choke%Present_HydraulicChoke2Plug + data%State%CHOOKE(2)%PlugMalf *((data%State%Choke%DeltaPlug2Percent / real(data%State%Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 1800.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 + data%State%CHOOKE(1)%AreaChoke=data%State%CHOOKE(1)%AreaChoke+(data%State%CHOOKE(1)%WashoutMalf*data%State%Choke%HydraulicChoke1WashoutCoef*data%State%Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup - !write(*,*) 'CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke=' ,CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke + !write(*,*) 'data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke=' ,data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke - CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke-(CHOOKE(1)%PlugMalf* Choke%Present_HydraulicChoke1Plug *CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup + data%State%CHOOKE(1)%AreaChoke=data%State%CHOOKE(1)%AreaChoke-(data%State%CHOOKE(1)%PlugMalf* data%State%Choke%Present_HydraulicChoke1Plug *data%State%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 + data%State%CHOOKE(2)%AreaChoke=data%State%CHOOKE(2)%AreaChoke+(data%State%CHOOKE(2)%WashoutMalf*data%State%Choke%HydraulicChoke2WashoutCoef*data%State%Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup + data%State%CHOOKE(2)%AreaChoke=data%State%CHOOKE(2)%AreaChoke-(data%State%CHOOKE(2)%PlugMalf* data%State%Choke%Present_HydraulicChoke2Plug *data%State%CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup + !write(*,*) 'data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke=' ,data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke - CHOOKE(1)%AreaChokeFinal= CHOOKE(1)%AreaChoke - CHOOKE(2)%AreaChokeFinal= CHOOKE(2)%AreaChoke + data%State%CHOOKE(1)%AreaChokeFinal= data%State%CHOOKE(1)%AreaChoke + data%State%CHOOKE(2)%AreaChokeFinal= data%State%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 + CALL SetHydraulicChock1(100 - nint((data%State%CHOOKE(1)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve + CALL SetHydraulicChock2(100 - nint((data%State%CHOOKE(2)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve - !write(*,*) 'CHOOKE(1)%PercentClose=' , CHOOKE(1)%PercentClose ! close percent 0 to 100 + !write(*,*) 'data%State%CHOOKE(1)%PercentClose=' , data%State%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(*,*) 'data%State%CHOOKE(1)%AreaChokeFinal=' , data%State%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 value=' , 100 - nint((data%State%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 - !AreaChoke= CHOOKE(1)%AreaChoke !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< badan moteghayer 1 ya 2 shavad + !AreaChoke= data%State%CHOOKE(1)%AreaChoke !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< badan moteghayer 1 ya 2 shavad ! write(*,*) 'AreaChoke:',AreaChoke diff --git a/Equipments/ChokeControl/CHOKE_VARIABLES.f90 b/Equipments/ChokeControl/CHOKE_VARIABLES.f90 index 9fdd7a2..82ff61a 100644 --- a/Equipments/ChokeControl/CHOKE_VARIABLES.f90 +++ b/Equipments/ChokeControl/CHOKE_VARIABLES.f90 @@ -1,11 +1,13 @@ MODULE CHOKEVARIABLES !IMPLICIT DOUBLEPRECISION(A-H,O-Z) -use CBopControlPanelVariables -use CEquipmentsConstants +! use CBopControlPanel +! use ConfigurationVariables +! use CEquipmentsConstants ! use CSimulationVariables -use CAccumulatorVariables -use CBopStackVariables -use CChokeControlPanelVariables +! use CAccumulatorVariables +! use CBopStackVariables +! use CChokeControlPanelVariables + ! use ConfigurationVariables IMPLICIT NONE @@ -30,7 +32,6 @@ type::ChokeType Integer HydraulicChoke1PluggedPercent_Old,HydraulicChoke2PluggedPercent_Old,Plug1TimeCounter,Plug2TimeCounter,ChokePlugTimeDelay Real ChokeAreaFullyOpen end type ChokeType -type(ChokeType)::Choke !=========================================================================== ! AIR DRIVEN PUMP VARIABLES !=========================================================================== @@ -38,13 +39,12 @@ type::AirDrivenPumpType REAL QAIR_PUMP,cc1,cc2,cc3,cc4,cc5 INTEGER ChokeAirFail end type AirDrivenPumpType -type(AirDrivenPumpType)::AirDrivenPump -PARAMETER PI=3.141593 +! PARAMETER PI=3.141593 !============================================================================ ! OIL & ENVIRONMENT VARIABLES !============================================================================ -REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000,NU=9e-6 +! REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000 !specific gravity of liquid !water density(kg/m^3) @@ -65,7 +65,6 @@ type::AirPumpLineType REAL Acylinder,CourseBase!,PassedCourse REAL alpha_Qair,alpha_timeair,alpha_pairp,alpha_diffpair,alpha_lossesair,alpha_Pdownstrem,Pdownstrem end type AirPumpLineType -type(AirPumpLineType)::AirPumpLine !================================================================================= @@ -75,11 +74,5 @@ type(AirPumpLineType)::AirPumpLine logical ChokeIsClosing,ChokeIsOpening END TYPE CHOKE_TypeVars - TYPE(CHOKE_TypeVars), DIMENSION(1:2) :: CHOOKE -END MODULE - - - - - +END MODULE \ No newline at end of file diff --git a/Equipments/ChokeControl/ChokeControlMain.f90 b/Equipments/ChokeControl/ChokeControlMain.f90 index d513d77..d4c4ad2 100644 --- a/Equipments/ChokeControl/ChokeControlMain.f90 +++ b/Equipments/ChokeControl/ChokeControlMain.f90 @@ -1,5 +1,6 @@ module ChokeControlMain - use CHOKEVARIABLES + USE CHOKEVARIABLES +use ConfigurationVariables !@ implicit none public contains @@ -23,25 +24,25 @@ module ChokeControlMain implicit none INTEGER CHNUMBER - IF(ChokeControlPanel%ChokeSelectorSwitch== 1) THEN - ChokeControlPanel%Choke1LED=1 - ChokeControlPanel%Choke2LED=0 + IF(data%EquipmentControl%ChokeControlPanel%ChokeSelectorSwitch== 1) THEN + data%EquipmentControl%ChokeControlPanel%Choke1LED=1 + data%EquipmentControl%ChokeControlPanel%Choke2LED=0 CHNUMBER=1 ELSE - ChokeControlPanel%Choke2LED=1 - ChokeControlPanel%Choke1LED=0 + data%EquipmentControl%ChokeControlPanel%Choke2LED=1 + data%EquipmentControl%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. + if(ABS(data%EquipmentControl%ChokeControlPanel%ChokeControlLever)==1.0 .AND. data%EquipmentControl%ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. data%State%CHOOKE(CHNUMBER)%FailMalf==0 .AND. data%State%AirDrivenPump%ChokeAirFail==0) then + if (data%EquipmentControl%ChokeControlPanel%ChokeControlLever == 1.0) then + data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .true. + data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .false. endif - if (ChokeControlPanel%ChokeControlLever == -1.0) then - CHOOKE(CHNUMBER)%ChokeIsOpening = .true. - CHOOKE(CHNUMBER)%ChokeIsClosing = .false. + if (data%EquipmentControl%ChokeControlPanel%ChokeControlLever == -1.0) then + data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .true. + data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .false. endif - AirPumpLine%TIME=AirPumpLine%TIME+AirPumpLine%DeltaT_Choke !overal time (s) + data%State%AirPumpLine%TIME=data%State%AirPumpLine%TIME+data%State%AirPumpLine%DeltaT_Choke !overal time (s) call airpump_code_CHOKE(CHNUMBER) else call CHOKE_MainBody2() diff --git a/Equipments/ChokeControl/ChokeStartup.f90 b/Equipments/ChokeControl/ChokeStartup.f90 index adfbd39..69f50e1 100644 --- a/Equipments/ChokeControl/ChokeStartup.f90 +++ b/Equipments/ChokeControl/ChokeStartup.f90 @@ -1,6 +1,7 @@ SUBROUTINE Choke_StartUp() USE CHOKEVARIABLES +use ConfigurationVariables !@ USE CChokeProblemsVariables implicit none @@ -9,13 +10,13 @@ !OPEN(150,FILE='CHOKE_AIRPUMP_OUTPUTS.DAT') - !CHOOKE(1)%WashoutMalf=1 - !CHOOKE(1)%PlugMalf=0 - !CHOOKE(1)%FailMalf=0 + !data%State%CHOOKE(1)%WashoutMalf=1 + !data%State%CHOOKE(1)%PlugMalf=0 + !data%State%CHOOKE(1)%FailMalf=0 ! - !CHOOKE(2)%WashoutMalf=1 - !CHOOKE(2)%PlugMalf=0 - !CHOOKE(2)%FailMalf=0 + !data%State%CHOOKE(2)%WashoutMalf=1 + !data%State%CHOOKE(2)%PlugMalf=0 + !data%State%CHOOKE(2)%FailMalf=0 ! ! !ChokeAirFail=0 @@ -28,64 +29,64 @@ - Choke%kRatio=1.4 -Choke%Cp=0.24 -Choke%CL=0.8 + data%State%Choke%kRatio=1.4 +data%State%Choke%Cp=0.24 +data%State%Choke%CL=0.8 -Choke%x1=0.5 +data%State%Choke%x1=0.5 -Choke%LiquidPPG=9. -Choke%LiquidDensity=Choke%LiquidPPG*7.48 !lbm/ft**3 +data%State%Choke%LiquidPPG=9. +data%State%Choke%LiquidDensity=data%State%Choke%LiquidPPG*7.48 !lbm/ft**3 -Choke%VL=1.0/Choke%LiquidDensity !SpecificVolume of Liquid +data%State%Choke%VL=1.0/data%State%Choke%LiquidDensity !SpecificVolume of Liquid -Choke%Cv=Choke%Cp/Choke%kRatio +data%State%Choke%Cv=data%State%Choke%Cp/data%State%Choke%kRatio -Choke%nPolytripic=1+(Choke%x1*(Choke%Cp-Choke%Cv)/(Choke%x1*Choke%Cv+(1-Choke%x1)*Choke%CL)) +data%State%Choke%nPolytripic=1+(data%State%Choke%x1*(data%State%Choke%Cp-data%State%Choke%Cv)/(data%State%Choke%x1*data%State%Choke%Cv+(1-data%State%Choke%x1)*data%State%Choke%CL)) -Choke%VG1=1./0.748 !lbm/ft**3 Specific Volume of Air, Upstream +data%State%Choke%VG1=1./0.748 !lbm/ft**3 Specific Volume of Air, Upstream -Choke%Cdrag=0.8 -Choke%Pwh=1400. !psi +data%State%Choke%Cdrag=0.8 +data%State%Choke%Pwh=1400. !psi -Choke%Patm=14.7 -Choke%MixDens2=Choke%x1*Choke%VG1 !lbm/ft**3 +data%State%Choke%Patm=14.7 +data%State%Choke%MixDens2=data%State%Choke%x1*data%State%Choke%VG1 !lbm/ft**3 -Choke%epsilon_abs= 1e-5 -Choke%epsilon_step= 1e-5 +data%State%Choke%epsilon_abs= 1e-5 +data%State%Choke%epsilon_step= 1e-5 !ChokeDiameter= 32/64. !in -CHOOKE%PercentClose= 0.0 +data%State%CHOOKE%PercentClose= 0.0 !AreaChoke=0.01334635 - ! CHOOKE(1)%AreaChoke=0.01334635 + ! data%State%CHOOKE(1)%AreaChoke=0.01334635 !ChokeAreaFullyOpen = 123.d0 / 64.d0 ! fully open area is 123/64 in^2 = 0.01334635 ft^2 -AirPumpLine%DeltaT_Choke=0.1 +data%State%AirPumpLine%DeltaT_Choke=0.1 !TotalStrokes1=0. !TotalStrokes2=0. -Choke%HydraulicChoke1WashoutCoef= 0.0 -Choke%HydraulicChoke2WashoutCoef= 0.0 +data%State%Choke%HydraulicChoke1WashoutCoef= 0.0 +data%State%Choke%HydraulicChoke2WashoutCoef= 0.0 -Choke%ChokePlugTimeDelay = int(180./AirPumpLine%DeltaT_Choke) ! =1800 = 180/0.1 : for 3 min delay +data%State%Choke%ChokePlugTimeDelay = int(180./data%State%AirPumpLine%DeltaT_Choke) ! =1800 = 180/0.1 : for 3 min delay -Choke%Present_HydraulicChoke1Plug = REAL(ChokeProblems%HydraulicChoke1PluggedPercent)/100. -Choke%HydraulicChoke1PluggedPercent_Old= ChokeProblems%HydraulicChoke1PluggedPercent -Choke%Plug1TimeCounter= 0 -Choke%DeltaPlug1Percent = 0.0 +data%State%Choke%Present_HydraulicChoke1Plug = REAL(data%problems%ChokeProblems%HydraulicChoke1PluggedPercent)/100. +data%State%Choke%HydraulicChoke1PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke1PluggedPercent +data%State%Choke%Plug1TimeCounter= 0 +data%State%Choke%DeltaPlug1Percent = 0.0 -Choke%Present_HydraulicChoke2Plug = REAL(ChokeProblems%HydraulicChoke2PluggedPercent)/100. -Choke%HydraulicChoke2PluggedPercent_Old= ChokeProblems%HydraulicChoke2PluggedPercent -Choke%Plug2TimeCounter= 0 -Choke%DeltaPlug2Percent = 0.0 +data%State%Choke%Present_HydraulicChoke2Plug = REAL(data%problems%ChokeProblems%HydraulicChoke2PluggedPercent)/100. +data%State%Choke%HydraulicChoke2PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke2PluggedPercent +data%State%Choke%Plug2TimeCounter= 0 +data%State%Choke%DeltaPlug2Percent = 0.0 @@ -93,34 +94,34 @@ Choke%DeltaPlug2Percent = 0.0 !======================AIRPUMP INPUTS(CONSTANTS)=========================== - AirPumpLine%CourseBase= 24. !cm - CHOOKE%PassedCourse= 0. - ChokeControlPanel%ChokePosition=0. + data%State%AirPumpLine%CourseBase= 24. !cm + data%State%CHOOKE%PassedCourse= 0. + data%EquipmentControl%ChokeControlPanel%ChokePosition=0. - AirPumpLine%Acylinder= PI*(8.**2)/4. ! (CM^2), 8=DIAMETER, 24=course , 3785.412: cm^3 to galon + data%State%AirPumpLine%Acylinder= PI*(8.**2)/4. ! (CM^2), 8=DIAMETER, 24=course , 3785.412: cm^3 to galon - CHOOKE%ChokeIsOpening = .false. - CHOOKE%ChokeIsClosing = .false. + data%State%CHOOKE%ChokeIsOpening = .false. + data%State%CHOOKE%ChokeIsClosing = .false. - AirPumpLine%P_AIRP=0 + data%State%AirPumpLine%P_AIRP=0 - AirDrivenPump%cc1 = 0.1354; AirDrivenPump%cc2 = -2.066; AirDrivenPump%cc3 = -21.09; AirDrivenPump%cc4 = -51.36; AirDrivenPump%cc5 = 5935 ! FOR OUTPUT IN GPM + data%State%AirDrivenPump%cc1 = 0.1354; data%State%AirDrivenPump%cc2 = -2.066; data%State%AirDrivenPump%cc3 = -21.09; data%State%AirDrivenPump%cc4 = -51.36; data%State%AirDrivenPump%cc5 = 5935 ! FOR OUTPUT IN GPM ! cc1 = 4.754e-07; cc2 = -0.0001676; cc3 = -0.03953; cc4 = -2.223; cc5 = 5935 FOR OUTPUT IN IN^3/MIN -AirPumpLine%Pdownstrem= 4950 !+0.01*Pchoke (psi) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -AirPumpLine%QITER=5. !(gpm) +data%State%AirPumpLine%Pdownstrem= 4950 !+0.01*Pchoke (psi) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +data%State%AirPumpLine%QITER=5. !(gpm) ! Q=0.0003585; true -AirPumpLine%TIME=0 -AirPumpLine%TOL_AIR=0.05 - -AirPumpLine%alpha_Qair=0 -AirPumpLine%alpha_timeair=0 -AirPumpLine%alpha_Pdownstrem=AirPumpLine%Pdownstrem -AirPumpLine%alpha_diffpair=0 -AirPumpLine%alpha_lossesair=0 +data%State%AirPumpLine%TIME=0 +data%State%AirPumpLine%TOL_AIR=0.05 + +data%State%AirPumpLine%alpha_Qair=0 +data%State%AirPumpLine%alpha_timeair=0 +data%State%AirPumpLine%alpha_Pdownstrem=data%State%AirPumpLine%Pdownstrem +data%State%AirPumpLine%alpha_diffpair=0 +data%State%AirPumpLine%alpha_lossesair=0 end \ No newline at end of file diff --git a/Equipments/Drawworks/DWFixModeMotion.f90 b/Equipments/Drawworks/DWFixModeMotion.f90 index 329da52..dd9713b 100644 --- a/Equipments/Drawworks/DWFixModeMotion.f90 +++ b/Equipments/Drawworks/DWFixModeMotion.f90 @@ -1,16 +1,16 @@ subroutine DWFixModeMotion - Use Drawworks_VARIABLES + use ConfigurationVariables !@ IMPLICIT NONE - Drawworks%Hook_Height_final = Drawworks%Hook_Height_final ![ft] - Drawworks%Hook_Height = Drawworks%Hook_Height_final/3.280839895d0 ![m] - Drawworks%w_drum = 0.d0 - Drawworks%w_old_drum = 0.d0 - Drawworks%motion = 0 + data%State%Drawworks%Hook_Height_final = data%State%Drawworks%Hook_Height_final ![ft] + data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height_final/3.280839895d0 ![m] + data%State%Drawworks%w_drum = 0.d0 + data%State%Drawworks%w_old_drum = 0.d0 + data%State%Drawworks%motion = 0 diff --git a/Equipments/Drawworks/DWMalfunction_MotorFailure.f90 b/Equipments/Drawworks/DWMalfunction_MotorFailure.f90 index 013856f..709f8bd 100644 --- a/Equipments/Drawworks/DWMalfunction_MotorFailure.f90 +++ b/Equipments/Drawworks/DWMalfunction_MotorFailure.f90 @@ -1,17 +1,21 @@ subroutine DWMalfunction_MotorFailure use CDrillingConsoleVariables - use CDataDisplayConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + use CDataDisplayConsole + use ConfigurationVariables use CHoistingVariables - use Drawworks_VARIABLES + use ConfigurationVariables + use ConfigurationVariables !@ IMPLICIT NONE - if (Drawworks%MotorFaileMalf==1) then - Drawworks%Conv_Ratio = 1.0D0 + if (data%State%Drawworks%MotorFaileMalf==1) then + data%State%Drawworks%Conv_Ratio = 1.0D0 end if diff --git a/Equipments/Drawworks/DrawworksMain.f90 b/Equipments/Drawworks/DrawworksMain.f90 index 635a139..92ad1dd 100644 --- a/Equipments/Drawworks/DrawworksMain.f90 +++ b/Equipments/Drawworks/DrawworksMain.f90 @@ -22,7 +22,7 @@ module DrawworksMain end subroutine Drawworks_Step subroutine DrawworksMainBody - Use Drawworks_VARIABLES + use ConfigurationVariables !@ implicit none Call Drawworks_StartUp loopdrawsim : do diff --git a/Equipments/Drawworks/Drawworks_Direction.f90 b/Equipments/Drawworks/Drawworks_Direction.f90 index 5d050b0..571d3c2 100644 --- a/Equipments/Drawworks/Drawworks_Direction.f90 +++ b/Equipments/Drawworks/Drawworks_Direction.f90 @@ -1,8 +1,11 @@ subroutine Drawworks_Direction - Use CDrillingConsoleVariables - Use CDataDisplayConsoleVariables - Use Drawworks_VARIABLES + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + use CDataDisplayConsole + use ConfigurationVariables + use ConfigurationVariables !@ IMPLICIT NONE @@ -11,21 +14,21 @@ subroutine Drawworks_Direction - if (Drawworks%Switch==1) then !Up - Drawworks%motion = +1 - Drawworks%w_old_drum = Drawworks%w_drum !(pi*(Drawworks%N_old/Drawworks%Conv_Ratio)/30.d0) ? - Drawworks%w_drum = (pi*(Drawworks%Speed/Drawworks%Conv_Ratio)/30.d0) ![rad/s] - Drawworks%Hook_Height = Drawworks%Hook_Height+(((Drawworks%Diameter/2.0)*(Drawworks%time_step*0.5d0*(Drawworks%w_drum+Drawworks%w_old_drum)))/Drawworks%NumberOfLine) ![m] - else if (Drawworks%Switch==-1) then !Down - Drawworks%motion = -1 - Drawworks%w_old_drum = Drawworks%w_drum !(pi*(Drawworks%N_old/Drawworks%Conv_Ratio)/30.d0) ? - Drawworks%w_drum = (pi*(Drawworks%Speed/Drawworks%Conv_Ratio)/30.d0) ![rad/s] - Drawworks%Hook_Height = Drawworks%Hook_Height-(((Drawworks%Diameter/2.0)*(Drawworks%time_step*0.5d0*(Drawworks%w_drum+Drawworks%w_old_drum)))/Drawworks%NumberOfLine) ![m] - !else if (Drawworks%Switch==0) then !Off - ! Drawworks%motion = 0 - ! Drawworks%w_old_drum = 0.d0 - ! Drawworks%w_drum = 0.d0 - ! Drawworks%Hook_Height = Drawworks%Hook_Height + if (data%State%Drawworks%Switch==1) then !Up + data%State%Drawworks%motion = +1 + data%State%Drawworks%w_old_drum = data%State%Drawworks%w_drum !(pi*(data%State%Drawworks%N_old/data%State%Drawworks%Conv_Ratio)/30.d0) ? + data%State%Drawworks%w_drum = (pi*(data%State%Drawworks%Speed/data%State%Drawworks%Conv_Ratio)/30.d0) ![rad/s] + data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height+(((data%State%Drawworks%Diameter/2.0)*(data%State%Drawworks%time_step*0.5d0*(data%State%Drawworks%w_drum+data%State%Drawworks%w_old_drum)))/data%State%Drawworks%NumberOfLine) ![m] + else if (data%State%Drawworks%Switch==-1) then !Down + data%State%Drawworks%motion = -1 + data%State%Drawworks%w_old_drum = data%State%Drawworks%w_drum !(pi*(data%State%Drawworks%N_old/data%State%Drawworks%Conv_Ratio)/30.d0) ? + data%State%Drawworks%w_drum = (pi*(data%State%Drawworks%Speed/data%State%Drawworks%Conv_Ratio)/30.d0) ![rad/s] + data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height-(((data%State%Drawworks%Diameter/2.0)*(data%State%Drawworks%time_step*0.5d0*(data%State%Drawworks%w_drum+data%State%Drawworks%w_old_drum)))/data%State%Drawworks%NumberOfLine) ![m] + !else if (data%State%Drawworks%Switch==0) then !Off + ! data%State%Drawworks%motion = 0 + ! data%State%Drawworks%w_old_drum = 0.d0 + ! data%State%Drawworks%w_drum = 0.d0 + ! data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height end if @@ -43,39 +46,39 @@ subroutine Drawworks_Direction - !if (Drawworks%Conv_Ratio==1.d0) then + !if (data%State%Drawworks%Conv_Ratio==1.d0) then ! ! - ! IF (Drawworks%motion==+1) THEN + ! IF (data%State%Drawworks%motion==+1) THEN ! Call Drawworks_Free_Traction_motor_Dir - ! if (Drawworks%w_drum_Dir<=0.) then - ! Drawworks%motion = 0 + ! if (data%State%Drawworks%w_drum_Dir<=0.) then + ! data%State%Drawworks%motion = 0 ! else - ! Drawworks%motion = +1 + ! data%State%Drawworks%motion = +1 ! Call Drawworks_Free_Traction_motor - ! Drawworks%w = Drawworks%w_drum*Drawworks%Conv_Ratio - ! Drawworks%w_old = Drawworks%w_old_drum*Drawworks%Conv_Ratio + ! data%State%Drawworks%w = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%w_old = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio ! end if ! ELSE - ! if (((Drawworks%F_fastline*(Drawworks%Diameter/2.0d0))-(((Drawworks%Diameter/2.0d0)*Drawworks%BreakLoad)*(Drawworks%ManualBreak/100.0d0)))<=0.) then - ! Drawworks%motion = 0 - ! Drawworks%w_drum = 0.0d0 - ! Drawworks%w_old_drum = 0.0d0 - ! Drawworks%w = Drawworks%w_drum*Drawworks%Conv_Ratio - ! Drawworks%w_old = Drawworks%w_old_drum*Drawworks%Conv_Ratio - ! Drawworks%Hook_Height = Drawworks%Hook_Height + ! if (((data%State%Drawworks%F_fastline*(data%State%Drawworks%Diameter/2.0d0))-(((data%State%Drawworks%Diameter/2.0d0)*data%State%Drawworks%BreakLoad)*(data%State%Drawworks%ManualBreak/100.0d0)))<=0.) then + ! data%State%Drawworks%motion = 0 + ! data%State%Drawworks%w_drum = 0.0d0 + ! data%State%Drawworks%w_old_drum = 0.0d0 + ! data%State%Drawworks%w = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%w_old = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height ! - ! Drawworks%ia = 0. - ! Drawworks%ia_old = 0. - ! Drawworks%x = 0. - ! Drawworks%x_old = 0. - ! Drawworks%y = 0. - ! Drawworks%y_old = 0. + ! data%State%Drawworks%ia = 0. + ! data%State%Drawworks%ia_old = 0. + ! data%State%Drawworks%x = 0. + ! data%State%Drawworks%x_old = 0. + ! data%State%Drawworks%y = 0. + ! data%State%Drawworks%y_old = 0. ! else - ! Drawworks%motion = -1 + ! data%State%Drawworks%motion = -1 ! Call Drawworks_Free_Traction_motor_dawn_motion - ! Drawworks%w = Drawworks%w_drum*Drawworks%Conv_Ratio - ! Drawworks%w_old = Drawworks%w_old_drum*Drawworks%Conv_Ratio + ! data%State%Drawworks%w = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%w_old = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio ! end if ! ! END IF @@ -83,57 +86,57 @@ subroutine Drawworks_Direction ! !else ! - ! IF (Drawworks%motion==-1) THEN - ! Drawworks%w = -Drawworks%w - ! Drawworks%w_old = -Drawworks%w_old - ! Drawworks%w_drum = -Drawworks%w_drum - ! Drawworks%w_old_drum = -Drawworks%w_old_drum + ! IF (data%State%Drawworks%motion==-1) THEN + ! data%State%Drawworks%w = -data%State%Drawworks%w + ! data%State%Drawworks%w_old = -data%State%Drawworks%w_old + ! data%State%Drawworks%w_drum = -data%State%Drawworks%w_drum + ! data%State%Drawworks%w_old_drum = -data%State%Drawworks%w_old_drum ! END IF ! Call Drawworks_Traction_motor_ClutchMode_Dir - ! IF (Drawworks%w_Dir>0.d0) then + ! IF (data%State%Drawworks%w_Dir>0.d0) then ! - ! Drawworks%motion = +1 + ! data%State%Drawworks%motion = +1 ! Call Drawworks_Traction_motor_ClutchMode - ! Drawworks%w_drum = Drawworks%w/Drawworks%Conv_Ratio - ! Drawworks%w_old_drum = Drawworks%w_old/Drawworks%Conv_Ratio + ! data%State%Drawworks%w_drum = data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%w_old_drum = data%State%Drawworks%w_old/data%State%Drawworks%Conv_Ratio ! ELSE - ! Drawworks%EddyTorque = (1.039d5*exp(4.343d-4*(30.0d0*(Drawworks%w/Drawworks%Conv_Ratio)/pi)))+(-1.036d5*exp(-.047920d0*(30.0d0*(Drawworks%w/Drawworks%Conv_Ratio)/pi))) !Lbf.ft - ! if (Drawworks%EddyTorque>115000.) then - ! Drawworks%EddyTorque = 115000.0d0 + ! data%State%Drawworks%EddyTorque = (1.039d5*exp(4.343d-4*(30.0d0*(data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio)/pi)))+(-1.036d5*exp(-.047920d0*(30.0d0*(data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio)/pi))) !Lbf.ft + ! if (data%State%Drawworks%EddyTorque>115000.) then + ! data%State%Drawworks%EddyTorque = 115000.0d0 ! end if - ! Drawworks%EddyTorque = 1.355817948*Drawworks%EddyTorque ![N.m] - ! if ((Drawworks%F_fastline*(Drawworks%Diameter/2.0d0))>((((Drawworks%Diameter/2.0d0)*Drawworks%BreakLoad)*(Drawworks%ManualBreak/100.0d0))+(Drawworks%EddyTorque*(Drawworks%EddyBreak/100.0d0)))) then - ! Drawworks%motion = -1 + ! data%State%Drawworks%EddyTorque = 1.355817948*data%State%Drawworks%EddyTorque ![N.m] + ! if ((data%State%Drawworks%F_fastline*(data%State%Drawworks%Diameter/2.0d0))>((((data%State%Drawworks%Diameter/2.0d0)*data%State%Drawworks%BreakLoad)*(data%State%Drawworks%ManualBreak/100.0d0))+(data%State%Drawworks%EddyTorque*(data%State%Drawworks%EddyBreak/100.0d0)))) then + ! data%State%Drawworks%motion = -1 ! - ! IF (Drawworks%w_drum<0.) THEN - ! Drawworks%w = -Drawworks%w - ! Drawworks%w_old = -Drawworks%w_old - ! !Drawworks%w = 0. !??????????????? - ! !Drawworks%w_old = 0. !??????????????? - ! Drawworks%w_drum = -Drawworks%w_drum - ! Drawworks%w_old_drum = -Drawworks%w_old_drum + ! IF (data%State%Drawworks%w_drum<0.) THEN + ! data%State%Drawworks%w = -data%State%Drawworks%w + ! data%State%Drawworks%w_old = -data%State%Drawworks%w_old + ! !data%State%Drawworks%w = 0. !??????????????? + ! !data%State%Drawworks%w_old = 0. !??????????????? + ! data%State%Drawworks%w_drum = -data%State%Drawworks%w_drum + ! data%State%Drawworks%w_old_drum = -data%State%Drawworks%w_old_drum ! END IF ! - ! Drawworks%Conv_Ratio = 1. + ! data%State%Drawworks%Conv_Ratio = 1. ! Call Drawworks_Free_Traction_motor_dawn_motion - ! Drawworks%w = Drawworks%w_drum*Drawworks%Conv_Ratio - ! Drawworks%w_old = Drawworks%w_old_drum*Drawworks%Conv_Ratio - ! !Drawworks%w_drum = Drawworks%w/Drawworks%Conv_Ratio - ! !Drawworks%w_old_drum = Drawworks%w_old/Drawworks%Conv_Ratio + ! data%State%Drawworks%w = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%w_old = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio + ! !data%State%Drawworks%w_drum = data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio + ! !data%State%Drawworks%w_old_drum = data%State%Drawworks%w_old/data%State%Drawworks%Conv_Ratio ! else - ! Drawworks%motion = 0 - ! Drawworks%w_drum = 0.0d0 - ! Drawworks%w_old_drum = 0.0d0 - ! Drawworks%w = Drawworks%w_drum*Drawworks%Conv_Ratio - ! Drawworks%w_old = Drawworks%w_old_drum*Drawworks%Conv_Ratio - ! Drawworks%Hook_Height = Drawworks%Hook_Height + ! data%State%Drawworks%motion = 0 + ! data%State%Drawworks%w_drum = 0.0d0 + ! data%State%Drawworks%w_old_drum = 0.0d0 + ! data%State%Drawworks%w = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%w_old = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio + ! data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height ! - ! Drawworks%ia = 0. - ! Drawworks%ia_old = 0. - ! Drawworks%x = 0. - ! Drawworks%x_old = 0. - ! Drawworks%y = 0. - ! Drawworks%y_old = 0. + ! data%State%Drawworks%ia = 0. + ! data%State%Drawworks%ia_old = 0. + ! data%State%Drawworks%x = 0. + ! data%State%Drawworks%x_old = 0. + ! data%State%Drawworks%y = 0. + ! data%State%Drawworks%y_old = 0. ! end if ! ! END IF diff --git a/Equipments/Drawworks/Drawworks_INPUTS.f90 b/Equipments/Drawworks/Drawworks_INPUTS.f90 index ff83d1d..b7345b9 100644 --- a/Equipments/Drawworks/Drawworks_INPUTS.f90 +++ b/Equipments/Drawworks/Drawworks_INPUTS.f90 @@ -1,184 +1,186 @@ subroutine Drawworks_Inputs - Use CDrillingConsoleVariables + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables ! Use CSimulationVariables - Use COperationScenariosVariables - Use CWarningsVariables - Use VARIABLES - Use Drawworks_VARIABLES + use OperationScenariosModule + use CWarnings + use ConfigurationVariables + use ConfigurationVariables !@ Use TD_StringConnectionData Use TD_DrillStemComponents - Use TD_GeneralData - Use TD_WellGeometry + use ConfigurationVariables !@ + use ConfigurationVariables !@ IMPLICIT NONE - Drawworks%AssignmentSwitch = DrillingConsole%AssignmentSwitch - Drawworks%Switch = DrillingConsole%DWSwitch - Drawworks%Throttle = DrillingConsole%DWThrottle ![RPM] - Drawworks%DriveType = Hoisting%DriveType - Drawworks%ShearBopSituation = RamLine%ShearBop_Situation_forTD - !Drawworks%MotorFaileMalf = ?????? motaghayere voroudi !dar CHoistingProblemsVariables meghdardehi mishavad + data%State%Drawworks%AssignmentSwitch = data%EquipmentControl%DrillingConsole%AssignmentSwitch + data%State%Drawworks%Switch = data%EquipmentControl%DrillingConsole%DWSwitch + data%State%Drawworks%Throttle = data%EquipmentControl%DrillingConsole%DWThrottle ![RPM] + data%State%Drawworks%DriveType = data%State%Hoisting%DriveType + data%State%Drawworks%ShearBopSituation = data%State%RamLine%ShearBop_Situation_forTD + !data%State%Drawworks%MotorFaileMalf = ?????? motaghayere voroudi !dar CHoistingProblemsVariables meghdardehi mishavad !>>> RAM & ToolJoint Collision - Drawworks%TDBOPElementNo = TD_BOP%BOPElementNo - Drawworks%TDBOPHeight = TD_BOP%BOPHeight - Drawworks%TDBOPRamDiam = TD_BOP%BOPRamDiam - Drawworks%TDBOPThickness = TD_BOP%BOPThickness - Drawworks%TDDrillStemBottom = TD_String%DrillStemBottom - Drawworks%TDWellTotalLength = TD_WellGeneral%WellTotalLength - Drawworks%TDDlMax = TD_String%DlMax - Drawworks%TDDrillStemComponentsNumbs = TD_String%DrillStemComponentsNumbs - if (Allocated(Drawworks%TDDrillStemsDownDepth)) deAllocate (Drawworks%TDDrillStemsDownDepth) ! inja gozashtameshun cho momkene tuye startup tedade elemanha dir berese va error bede - Allocate (Drawworks%TDDrillStemsDownDepth(Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components - Drawworks%TDDrillStemsDownDepth = TD_DrillStems%DownDepth - if (Allocated(Drawworks%TDDrillStemsToolJointRange)) deAllocate (Drawworks%TDDrillStemsToolJointRange) - Allocate (Drawworks%TDDrillStemsToolJointRange(Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components - Drawworks%TDDrillStemsToolJointRange = TD_DrillStems%ToolJointRange - if (Allocated(Drawworks%TDDrillStemsTopDepth)) deAllocate (Drawworks%TDDrillStemsTopDepth) - Allocate (Drawworks%TDDrillStemsTopDepth(Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components - Drawworks%TDDrillStemsTopDepth = TD_DrillStems%TopDepth - if (Allocated(Drawworks%TDDrillStemsRtoolJoint)) deAllocate (Drawworks%TDDrillStemsRtoolJoint) - Allocate (Drawworks%TDDrillStemsRtoolJoint(Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components - Drawworks%TDDrillStemsRtoolJoint = TD_DrillStems%RtoolJoint + data%State%Drawworks%TDBOPElementNo = data%State%TD_BOP%BOPElementNo + data%State%Drawworks%TDBOPHeight = data%State%TD_BOP%BOPHeight + data%State%Drawworks%TDBOPRamDiam = data%State%TD_BOP%BOPRamDiam + data%State%Drawworks%TDBOPThickness = data%State%TD_BOP%BOPThickness + data%State%Drawworks%TDDrillStemBottom = data%State%TD_String%DrillStemBottom + data%State%Drawworks%TDWellTotalLength = data%State%TD_WellGeneral%WellTotalLength + data%State%Drawworks%TDDlMax = data%State%TD_String%DlMax + data%State%Drawworks%TDDrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs + if (Allocated(data%State%Drawworks%TDDrillStemsDownDepth)) deAllocate (data%State%Drawworks%TDDrillStemsDownDepth) ! inja gozashtameshun cho momkene tuye startup tedade elemanha dir berese va error bede + Allocate (data%State%Drawworks%TDDrillStemsDownDepth(data%State%Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components + data%State%Drawworks%TDDrillStemsDownDepth = data%State%TD_DrillStems%DownDepth + if (Allocated(data%State%Drawworks%TDDrillStemsToolJointRange)) deAllocate (data%State%Drawworks%TDDrillStemsToolJointRange) + Allocate (data%State%Drawworks%TDDrillStemsToolJointRange(data%State%Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components + data%State%Drawworks%TDDrillStemsToolJointRange = data%State%TD_DrillStems%ToolJointRange + if (Allocated(data%State%Drawworks%TDDrillStemsTopDepth)) deAllocate (data%State%Drawworks%TDDrillStemsTopDepth) + Allocate (data%State%Drawworks%TDDrillStemsTopDepth(data%State%Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components + data%State%Drawworks%TDDrillStemsTopDepth = data%State%TD_DrillStems%TopDepth + if (Allocated(data%State%Drawworks%TDDrillStemsRtoolJoint)) deAllocate (data%State%Drawworks%TDDrillStemsRtoolJoint) + Allocate (data%State%Drawworks%TDDrillStemsRtoolJoint(data%State%Drawworks%TDDrillStemComponentsNumbs+400)) ! +400: because of: Add or Remove DrillStem Components + data%State%Drawworks%TDDrillStemsRtoolJoint = data%State%TD_DrillStems%RtoolJoint !>>> Warnings - Drawworks%CrownCollision = Warmings%CrownCollision - Drawworks%FloorCollision = Warmings%FloorCollision + data%State%Drawworks%CrownCollision = data%Warnings%CrownCollision + data%State%Drawworks%FloorCollision = data%Warnings%FloorCollision - Drawworks%Conv_Ratio = 1.0d0/.380d0 !che meghdari bashad?????????????????? !Drawworks%FWD_Conv_Ratio(Drawworks%ClutchMode,Drawworks%TransMode) + data%State%Drawworks%Conv_Ratio = 1.0d0/.380d0 !che meghdari bashad?????????????????? !data%State%Drawworks%FWD_Conv_Ratio(data%State%Drawworks%ClutchMode,data%State%Drawworks%TransMode) - DrillingConsole%ParkingBrakeLed = 0 + data%EquipmentControl%DrillingConsole%ParkingBrakeLed = 0 !===> min&max Hook Height - if ( Drawworks%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL ) then + if ( data%State%Drawworks%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL ) then if ( Get_Swing()==SWING_WELL_END .and. Get_KellyConnection()==KELLY_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 1 - Drawworks%min_Hook_Height = TD_String%TopJointHeight+OperationScenario%HKL-OperationScenario%RE ![ft] HKL=63.76=Kelly Ass. Height , RE=Release - Drawworks%max_Hook_Height = 120.d0 ![ft] + data%State%Drawworks%DrillModeCond = 1 + data%State%Drawworks%min_Hook_Height = data%State%TD_String%TopJointHeight+data%State%OperationScenario%HKL-data%State%OperationScenario%RE ![ft] HKL=63.76=Kelly Ass. Height , RE=Release + data%State%Drawworks%max_Hook_Height = 120.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_KellyConnection()==KELLY_CONNECTION_SINGLE ) then - Drawworks%DrillModeCond = 2 - Drawworks%min_Hook_Height = TD_String%TopJointHeight+OperationScenario%HKL+OperationScenario%PL-OperationScenario%RE ![ft] PL=30=Pipe Lenght - Drawworks%max_Hook_Height = 120.d0 ![ft] + data%State%Drawworks%DrillModeCond = 2 + data%State%Drawworks%min_Hook_Height = data%State%TD_String%TopJointHeight+data%State%OperationScenario%HKL+data%State%OperationScenario%PL-data%State%OperationScenario%RE ![ft] PL=30=Pipe Lenght + data%State%Drawworks%max_Hook_Height = 120.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then - Drawworks%DrillModeCond = 3 - Drawworks%min_Hook_Height = 21.44d0-OperationScenario%RE ![ft] ?????????? check 21.44=(TD_StConn%KellyConst-TD_StConn%KellyElementConst) - Drawworks%max_Hook_Height = 120.d0 ![ft] + data%State%Drawworks%DrillModeCond = 3 + data%State%Drawworks%min_Hook_Height = 21.44d0-data%State%OperationScenario%RE ![ft] ?????????? check 21.44=(data%State%TD_StConn%KellyConst-data%State%TD_StConn%KellyElementConst) + data%State%Drawworks%max_Hook_Height = 120.d0 ![ft] else if ( Get_Swing()==SWING_MOUSE_HOLE_END .and. Get_KellyConnection()==KELLY_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 4 - Drawworks%min_Hook_Height = 66.d0-OperationScenario%RE ![ft] - Drawworks%max_Hook_Height = 120.d0 ![ft] + data%State%Drawworks%DrillModeCond = 4 + data%State%Drawworks%min_Hook_Height = 66.d0-data%State%OperationScenario%RE ![ft] + data%State%Drawworks%max_Hook_Height = 120.d0 ![ft] else if ( Get_Swing()==SWING_MOUSE_HOLE_END .and. Get_KellyConnection()==KELLY_CONNECTION_SINGLE ) then - Drawworks%DrillModeCond = 5 - Drawworks%min_Hook_Height = 65.1d0-OperationScenario%RE ![ft] - Drawworks%max_Hook_Height = 120.d0 ![ft] + data%State%Drawworks%DrillModeCond = 5 + data%State%Drawworks%min_Hook_Height = 65.1d0-data%State%OperationScenario%RE ![ft] + data%State%Drawworks%max_Hook_Height = 120.d0 ![ft] else if ( Get_Swing()==SWING_RAT_HOLE_END ) then - Drawworks%DrillModeCond = 6 - Drawworks%min_Hook_Height = 66.d0-OperationScenario%RE ![ft] - Drawworks%max_Hook_Height = 120.d0 ![ft] + data%State%Drawworks%DrillModeCond = 6 + data%State%Drawworks%min_Hook_Height = 66.d0-data%State%OperationScenario%RE ![ft] + data%State%Drawworks%max_Hook_Height = 120.d0 ![ft] end if - else if ( Drawworks%DriveType==1 .and. Get_OperationCondition()==OPERATION_TRIP ) then + else if ( data%State%Drawworks%DriveType==1 .and. Get_OperationCondition()==OPERATION_TRIP ) then if ( Get_Swing()==SWING_WELL_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 7 - Drawworks%min_Hook_Height = 18.38d0 ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 7 + data%State%Drawworks%min_Hook_Height = 18.38d0 ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND ) then - Drawworks%DrillModeCond = 8 - Drawworks%min_Hook_Height = TD_String%TopJointHeight+OperationScenario%HL+OperationScenario%SL-(3.d0*OperationScenario%RE) ![ft] HL=17.81=Hook Assy , SL=90=Stand Length , 3: chon meghdari az toole loole(tool joint) dakhele elevator gharar migirad - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 8 + data%State%Drawworks%min_Hook_Height = data%State%TD_String%TopJointHeight+data%State%OperationScenario%HL+data%State%OperationScenario%SL-(3.d0*data%State%OperationScenario%RE) ![ft] HL=17.81=Hook Assy , SL=90=Stand Length , 3: chon meghdari az toole loole(tool joint) dakhele elevator gharar migirad + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE ) then - Drawworks%DrillModeCond = 9 - Drawworks%min_Hook_Height = TD_String%TopJointHeight+OperationScenario%HL+OperationScenario%PL-(3.d0*OperationScenario%RE) ![ft] 3: chon meghdari az toole loole(tool joint) balaye elevator mimanad - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 9 + data%State%Drawworks%min_Hook_Height = data%State%TD_String%TopJointHeight+data%State%OperationScenario%HL+data%State%OperationScenario%PL-(3.d0*data%State%OperationScenario%RE) ![ft] 3: chon meghdari az toole loole(tool joint) balaye elevator mimanad + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING ) then - Drawworks%DrillModeCond = 10 - Drawworks%min_Hook_Height = 18.5d0-OperationScenario%RE ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 10 + data%State%Drawworks%min_Hook_Height = 18.5d0-data%State%OperationScenario%RE ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_MOUSE_HOLE_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 11 - Drawworks%min_Hook_Height = 19.38d0-OperationScenario%RE ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 11 + data%State%Drawworks%min_Hook_Height = 19.38d0-data%State%OperationScenario%RE ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_MOUSE_HOLE_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE ) then - Drawworks%DrillModeCond = 12 - Drawworks%min_Hook_Height = 17.73d0-OperationScenario%RE ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 12 + data%State%Drawworks%min_Hook_Height = 17.73d0-data%State%OperationScenario%RE ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_RAT_HOLE_END ) then - Drawworks%DrillModeCond = 13 - Drawworks%min_Hook_Height = 27.41d0-OperationScenario%RE ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 13 + data%State%Drawworks%min_Hook_Height = 27.41d0-data%State%OperationScenario%RE ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_ElevatorConnection() == ELEVATOR_LATCH_STRING ) then - Drawworks%DrillModeCond = 14 - Drawworks%min_Hook_Height = 18.38d0 ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 14 + data%State%Drawworks%min_Hook_Height = 18.38d0 ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_ElevatorConnection() == ELEVATOR_LATCH_SINGLE ) then - Drawworks%DrillModeCond = 25 !warning & collision - Drawworks%min_Hook_Height = 18.38d0 !????????????????? ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 25 !warning & collision + data%State%Drawworks%min_Hook_Height = 18.38d0 !????????????????? ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_MOUSE_HOLE_END .and. Get_ElevatorConnection() == ELEVATOR_LATCH_SINGLE ) then - Drawworks%DrillModeCond = 26 - Drawworks%min_Hook_Height = 10.38d0 !????????????????? ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 26 + data%State%Drawworks%min_Hook_Height = 10.38d0 !????????????????? ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_Swing()==SWING_WELL_END .and. Get_ElevatorConnection() == ELEVATOR_LATCH_STAND ) then - Drawworks%DrillModeCond = 27 - Drawworks%min_Hook_Height = 18.38d0 !????????????????? ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 27 + data%State%Drawworks%min_Hook_Height = 18.38d0 !????????????????? ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] end if - else if ( Drawworks%DriveType==0 ) then + else if ( data%State%Drawworks%DriveType==0 ) then if ( Get_TdsSwing()==TDS_SWING_TILT_END ) then if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_SINGLE ) then - Drawworks%DrillModeCond = 15 - Drawworks%min_Hook_Height = 15.0d0 ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 15 + data%State%Drawworks%min_Hook_Height = 15.0d0 ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_SINGLE ) then - Drawworks%DrillModeCond = 16 - Drawworks%min_Hook_Height = 15.0d0 ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 16 + data%State%Drawworks%min_Hook_Height = 15.0d0 ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 17 - Drawworks%min_Hook_Height = 15.0d0 ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 17 + data%State%Drawworks%min_Hook_Height = 15.0d0 ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] end if else if ( Get_TdsSwing()==TDS_SWING_OFF_END ) then if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STRING ) then - Drawworks%DrillModeCond = 18 - Drawworks%min_Hook_Height = max(16.0d0,TD_String%TopJointHeight) ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 18 + data%State%Drawworks%min_Hook_Height = max(16.0d0,data%State%TD_String%TopJointHeight) ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING ) then - Drawworks%DrillModeCond = 19 - Drawworks%min_Hook_Height = TD_String%TopJointHeight ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 19 + data%State%Drawworks%min_Hook_Height = data%State%TD_String%TopJointHeight ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 20 - Drawworks%min_Hook_Height = TD_String%TopJointHeight ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 20 + data%State%Drawworks%min_Hook_Height = data%State%TD_String%TopJointHeight ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 21 - Drawworks%min_Hook_Height = max(16.0d0,TD_String%TopJointHeight) ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 21 + data%State%Drawworks%min_Hook_Height = max(16.0d0,data%State%TD_String%TopJointHeight) ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STAND ) then - Drawworks%DrillModeCond = 22 - Drawworks%min_Hook_Height = max(16.0d0,TD_String%TopJointHeight) ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 22 + data%State%Drawworks%min_Hook_Height = max(16.0d0,data%State%TD_String%TopJointHeight) ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STAND ) then - Drawworks%DrillModeCond = 23 - Drawworks%min_Hook_Height = max(16.0d0,TD_String%TopJointHeight) ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 23 + data%State%Drawworks%min_Hook_Height = max(16.0d0,data%State%TD_String%TopJointHeight) ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then - Drawworks%DrillModeCond = 24 - Drawworks%min_Hook_Height = TD_String%TopJointHeight ![ft] - Drawworks%max_Hook_Height = 140.d0 ![ft] + data%State%Drawworks%DrillModeCond = 24 + data%State%Drawworks%min_Hook_Height = data%State%TD_String%TopJointHeight ![ft] + data%State%Drawworks%max_Hook_Height = 140.d0 ![ft] end if end if end if @@ -186,19 +188,19 @@ subroutine Drawworks_Inputs !===> SLIPS SET , No Motion - if ( Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then - Drawworks%Speed = 0.d0 + if ( data%State%Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then + data%State%Drawworks%Speed = 0.d0 end if - if ( Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_SPINE .or. Get_TdsConnectionModes()==TDS_CONNECTION_STRING) ) then - Drawworks%Speed = 0.d0 + if ( data%State%Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_SPINE .or. Get_TdsConnectionModes()==TDS_CONNECTION_STRING) ) then + data%State%Drawworks%Speed = 0.d0 end if !===> Closed BOP Rams , No Motion - if ( Drawworks%ShearBopSituation==1 .and. (any(Drawworks%DrillModeCond==(/3,10,19,20,24/))) ) then - Drawworks%Speed = 0.d0 + if ( data%State%Drawworks%ShearBopSituation==1 .and. (any(data%State%Drawworks%DrillModeCond==(/3,10,19,20,24/))) ) then + data%State%Drawworks%Speed = 0.d0 end if diff --git a/Equipments/Drawworks/Drawworks_MainSolver.f90 b/Equipments/Drawworks/Drawworks_MainSolver.f90 index 60d375c..45cc5ae 100644 --- a/Equipments/Drawworks/Drawworks_MainSolver.f90 +++ b/Equipments/Drawworks/Drawworks_MainSolver.f90 @@ -1,6 +1,6 @@ subroutine Drawworks_MainSolver - Use Drawworks_VARIABLES + use ConfigurationVariables !@ IMPLICIT NONE @@ -8,54 +8,54 @@ subroutine Drawworks_MainSolver Call Drawworks_Inputs - if (Drawworks%Throttle<=0.d0) then - Drawworks%K_Throttle = 1 + if (data%State%Drawworks%Throttle<=0.d0) then + data%State%Drawworks%K_Throttle = 1 end if - if((any(Drawworks%AssignmentSwitch==(/1,2,3,4,5,7,8,9,10,11/))) .and. (Drawworks%Switch==-1 .or. Drawworks%Switch==1) .and. (Drawworks%CrownCollision==.false. .and. Drawworks%FloorCollision==.false.) .and. (Drawworks%K_Throttle==1)) then + if((any(data%State%Drawworks%AssignmentSwitch==(/1,2,3,4,5,7,8,9,10,11/))) .and. (data%State%Drawworks%Switch==-1 .or. data%State%Drawworks%Switch==1) .and. (data%State%Drawworks%CrownCollision==.false. .and. data%State%Drawworks%FloorCollision==.false.) .and. (data%State%Drawworks%K_Throttle==1)) then - Drawworks%SoundBlower = .true. - Drawworks%BLWR = 1 + data%State%Drawworks%SoundBlower = .true. + data%State%Drawworks%BLWR = 1 Call Drawworks_Solver - if ( Drawworks%motion==+1 ) then - Drawworks%SoundRev = 0 ![rpm or rad/s????????????????] , Integer - Drawworks%SoundFw = INT(Drawworks%w_drum) ![rpm] , Integer + if ( data%State%Drawworks%motion==+1 ) then + data%State%Drawworks%SoundRev = 0 ![rpm or rad/s????????????????] , Integer + data%State%Drawworks%SoundFw = INT(data%State%Drawworks%w_drum) ![rpm] , Integer else - Drawworks%SoundFw = 0 ![rpm] , Integer - Drawworks%SoundRev = INT(Drawworks%w_drum) ![rpm] , Integer + data%State%Drawworks%SoundFw = 0 ![rpm] , Integer + data%State%Drawworks%SoundRev = INT(data%State%Drawworks%w_drum) ![rpm] , Integer end if else - if((any(Drawworks%AssignmentSwitch==(/1,2,3,4,5,7,8,9,10,11/))) .and. (Drawworks%Switch==-1 .or. Drawworks%Switch==1)) then - Drawworks%SoundBlower = .true. - Drawworks%BLWR = 1 + if((any(data%State%Drawworks%AssignmentSwitch==(/1,2,3,4,5,7,8,9,10,11/))) .and. (data%State%Drawworks%Switch==-1 .or. data%State%Drawworks%Switch==1)) then + data%State%Drawworks%SoundBlower = .true. + data%State%Drawworks%BLWR = 1 else - Drawworks%SoundBlower = .false. - Drawworks%BLWR = 0 + data%State%Drawworks%SoundBlower = .false. + data%State%Drawworks%BLWR = 0 end if Call Drawworks_Solver_OffMode - if ( Drawworks%motion==+1 ) then - Drawworks%SoundRev = 0 ![rpm] , Integer - Drawworks%SoundFw = INT(Drawworks%w_drum) ![rpm] , Integer + if ( data%State%Drawworks%motion==+1 ) then + data%State%Drawworks%SoundRev = 0 ![rpm] , Integer + data%State%Drawworks%SoundFw = INT(data%State%Drawworks%w_drum) ![rpm] , Integer else - Drawworks%SoundFw = 0 ![rpm] , Integer - Drawworks%SoundRev = INT(Drawworks%w_drum) ![rpm] , Integer + data%State%Drawworks%SoundFw = 0 ![rpm] , Integer + data%State%Drawworks%SoundRev = INT(data%State%Drawworks%w_drum) ![rpm] , Integer end if - Drawworks%K_Throttle = 0 + data%State%Drawworks%K_Throttle = 0 end if Call Drawworks_Outputs - Drawworks%N_old = Drawworks%Speed + data%State%Drawworks%N_old = data%State%Drawworks%Speed diff --git a/Equipments/Drawworks/Drawworks_Outputs.f90 b/Equipments/Drawworks/Drawworks_Outputs.f90 index c1c6efc..a8402e4 100644 --- a/Equipments/Drawworks/Drawworks_Outputs.f90 +++ b/Equipments/Drawworks/Drawworks_Outputs.f90 @@ -1,35 +1,38 @@ subroutine Drawworks_Outputs Use CSounds - Use CHookVariables - Use CWarningsVariables - Use Drawworks_VARIABLES - Use CDrillingConsoleVariables + use CHook + use ConfigurationVariables + use CWarnings + use ConfigurationVariables !@ + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables IMPLICIT NONE - DrillingConsole%DWBLWR = Drawworks%BLWR + data%EquipmentControl%DrillingConsole%DWBLWR = data%State%Drawworks%BLWR - Call SetSoundBlowerDW( Drawworks%SoundBlower ) !.true. or .false. - Call SetSoundDwRev( Drawworks%SoundRev ) ![rpm] ??? or rad/s, Integer - Call SetSoundDwFw( Drawworks%SoundFw ) ![rpm] , Integer - Call SetSoundCrownCollision( Drawworks%SoundCrownCollision ) !.true. or .false. - Call SetSoundFloorCollision( Drawworks%SoundFloorCollision ) !.true. or .false. + Call SetSoundBlowerDW( data%State%Drawworks%SoundBlower ) !.true. or .false. + Call SetSoundDwRev( data%State%Drawworks%SoundRev ) ![rpm] ??? or rad/s, Integer + Call SetSoundDwFw( data%State%Drawworks%SoundFw ) ![rpm] , Integer + Call SetSoundCrownCollision( data%State%Drawworks%SoundCrownCollision ) !.true. or .false. + Call SetSoundFloorCollision( data%State%Drawworks%SoundFloorCollision ) !.true. or .false. - if (Drawworks%CrownCollision==1) then + if (data%State%Drawworks%CrownCollision==1) then Call Activate_CrownCollision() end if - if (Drawworks%FloorCollision==1) then + if (data%State%Drawworks%FloorCollision==1) then Call Activate_FloorCollision() end if - Call Set_HookHeight( real(Drawworks%Hook_Height_final) ) ![ft] - Drawworks%TDHookHeight = Drawworks%Hook_Height_final ![ft] - !!Drawworks%HookHeight_graph_output + Call Set_HookHeight( real(data%State%Drawworks%Hook_Height_final) ) ![ft] + data%State%Drawworks%TDHookHeight = data%State%Drawworks%Hook_Height_final ![ft] + !!data%State%Drawworks%HookHeight_graph_output - !DrillingConsole%ParkingBrakeLed = 0 ! in Drawworks_Inputs + !data%EquipmentControl%DrillingConsole%ParkingBrakeLed = 0 ! in Drawworks_Inputs diff --git a/Equipments/Drawworks/Drawworks_Solver.f90 b/Equipments/Drawworks/Drawworks_Solver.f90 index a46c9e6..5a21f41 100644 --- a/Equipments/Drawworks/Drawworks_Solver.f90 +++ b/Equipments/Drawworks/Drawworks_Solver.f90 @@ -1,13 +1,14 @@ subroutine Drawworks_Solver Use CUnityInputs - Use UnitySignalVariables - Use Drawworks_VARIABLES - Use CKellyConnectionEnumVariables - Use CElevatorConnectionEnumVariables - Use CTdsConnectionModesEnumVariables - Use CTdsElevatorModesEnumVariables - Use COperationScenariosVariables + use UnitySignalVariables + use UnitySignalsModule + use ConfigurationVariables !@ + use OperationScenariosModule + use OperationScenariosModule !!CElevator... + use UnitySignalsModule + ! Use CTdsElevatorModesEnumVariables + use OperationScenariosModule IMPLICIT NONE @@ -21,38 +22,38 @@ subroutine Drawworks_Solver !>>>>>>>>>>>>>>>>>>>> Speed <<<<<<<<<<<<<<<<<<<<<<<< - Drawworks%N_Throtle = Drawworks%Throttle ![rpm] - !Drawworks%N_Accelarator = (Drawworks%Acceleretor/100.d0)*965.d0 ![rpm] + data%State%Drawworks%N_Throtle = data%State%Drawworks%Throttle ![rpm] + !data%State%Drawworks%N_Accelarator = (data%State%Drawworks%Acceleretor/100.d0)*965.d0 ![rpm] - !IF (Drawworks%N_Throtle>Drawworks%N_Accelarator) THEN - Drawworks%N_new = Drawworks%N_Throtle + !IF (data%State%Drawworks%N_Throtle>data%State%Drawworks%N_Accelarator) THEN + data%State%Drawworks%N_new = data%State%Drawworks%N_Throtle !ELSE - ! Drawworks%N_new = Drawworks%N_Accelarator + ! data%State%Drawworks%N_new = data%State%Drawworks%N_Accelarator !END IF !========================== Drawworks Rate limit ========================== - if (((Drawworks%N_new-Drawworks%N_old)/Drawworks%time_step)>Drawworks%RateChange) then - Drawworks%Speed =(Drawworks%RateChange*Drawworks%time_step)+Drawworks%N_old ![rpm] - else if (((Drawworks%N_old-Drawworks%N_new)/Drawworks%time_step)>Drawworks%RateChange) then - Drawworks%Speed = (-Drawworks%RateChange*Drawworks%time_step)+Drawworks%N_old + if (((data%State%Drawworks%N_new-data%State%Drawworks%N_old)/data%State%Drawworks%time_step)>data%State%Drawworks%RateChange) then + data%State%Drawworks%Speed =(data%State%Drawworks%RateChange*data%State%Drawworks%time_step)+data%State%Drawworks%N_old ![rpm] + else if (((data%State%Drawworks%N_old-data%State%Drawworks%N_new)/data%State%Drawworks%time_step)>data%State%Drawworks%RateChange) then + data%State%Drawworks%Speed = (-data%State%Drawworks%RateChange*data%State%Drawworks%time_step)+data%State%Drawworks%N_old else - Drawworks%Speed = Drawworks%N_new + data%State%Drawworks%Speed = data%State%Drawworks%N_new end if !======================================================================= !========================== Speed Correction ========================== !===> SLIPS SET , No Motion - if ( Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then - Drawworks%Speed = 0.d0 + if ( data%State%Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then + data%State%Drawworks%Speed = 0.d0 end if - if ( Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_SPINE .or. Get_TdsConnectionModes()==TDS_CONNECTION_STRING) ) then - Drawworks%Speed = 0.d0 + if ( data%State%Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_SPINE .or. Get_TdsConnectionModes()==TDS_CONNECTION_STRING) ) then + data%State%Drawworks%Speed = 0.d0 end if !===> Closed BOP Rams , No Motion - if ( Drawworks%ShearBopSituation==1 .and. (any(Drawworks%DrillModeCond==(/3,10,19,20,24/))) ) then - Drawworks%Speed = 0.d0 + if ( data%State%Drawworks%ShearBopSituation==1 .and. (any(data%State%Drawworks%DrillModeCond==(/3,10,19,20,24/))) ) then + data%State%Drawworks%Speed = 0.d0 end if !======================================================================= @@ -64,10 +65,10 @@ subroutine Drawworks_Solver !==================================================== ! Collision & Warning !==================================================== - if ( Drawworks%CrownCollision == .false. ) then + if ( data%State%Drawworks%CrownCollision == .false. ) then CrownCollision_Status = 0 end if - if ( Drawworks%FloorCollision == .false. ) then + if ( data%State%Drawworks%FloorCollision == .false. ) then FloorCollision_Status = 0 end if @@ -79,16 +80,16 @@ subroutine Drawworks_Solver !==================================================== ! Crown Collision (Max_Hook_Height) !==================================================== - if ( ((3.280839895d0*Drawworks%Hook_Height)>=Drawworks%max_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then - if ( CrownCollision_Status==0 .and. Drawworks%motion==1 ) then + if ( ((3.280839895d0*data%State%Drawworks%Hook_Height)>=data%State%Drawworks%max_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then + if ( CrownCollision_Status==0 .and. data%State%Drawworks%motion==1 ) then CrownCollision_Status = 1 - Drawworks%CrownCollision = .true. - Drawworks%SoundCrownCollision = .true. + data%State%Drawworks%CrownCollision = .true. + data%State%Drawworks%SoundCrownCollision = .true. else - Drawworks%SoundCrownCollision = .false. + data%State%Drawworks%SoundCrownCollision = .false. end if - if ( Drawworks%motion==-1 .and. Drawworks%CrownCollision==.false. ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( data%State%Drawworks%motion==-1 .and. data%State%Drawworks%CrownCollision==.false. ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -104,16 +105,16 @@ subroutine Drawworks_Solver !==================================================== ! Floor Collision (Min_Hook_Height) !==================================================== - if ( ((3.280839895*Drawworks%Hook_Height)<=Drawworks%min_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then - if ( FloorCollision_Status==0 .and. Drawworks%motion==-1 ) then + if ( ((3.280839895*data%State%Drawworks%Hook_Height)<=data%State%Drawworks%min_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then + if ( FloorCollision_Status==0 .and. data%State%Drawworks%motion==-1 ) then FloorCollision_Status = 1 - Drawworks%FloorCollision = .true. - Drawworks%SoundFloorCollision = .true. + data%State%Drawworks%FloorCollision = .true. + data%State%Drawworks%SoundFloorCollision = .true. else - Drawworks%SoundFloorCollision = .false. + data%State%Drawworks%SoundFloorCollision = .false. end if - if ( Drawworks%motion==1 .and. Drawworks%FloorCollision==.false. ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( data%State%Drawworks%motion==1 .and. data%State%Drawworks%FloorCollision==.false. ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -130,9 +131,9 @@ subroutine Drawworks_Solver !==================================================== ! Crown Warning !==================================================== - if ( ((3.280839895*Drawworks%Hook_Height)>=Drawworks%max_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then - if ( Drawworks%motion==-1 ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( ((3.280839895*data%State%Drawworks%Hook_Height)>=data%State%Drawworks%max_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then + if ( data%State%Drawworks%motion==-1 ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -148,9 +149,9 @@ subroutine Drawworks_Solver !==================================================== ! Floor Warning !==================================================== - if ( ((3.280839895*Drawworks%Hook_Height)<=Drawworks%min_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then - if ( Drawworks%motion==1 ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( ((3.280839895*data%State%Drawworks%Hook_Height)<=data%State%Drawworks%min_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then + if ( data%State%Drawworks%motion==1 ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -169,12 +170,12 @@ subroutine Drawworks_Solver !==================================================== ! ELEVATOR CONNECTION STRING (SLIPS SET , No Motion) !==================================================== - if ( Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and. Drawworks%motion/=-1 ) then + if ( data%State%Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and. data%State%Drawworks%motion/=-1 ) then Call DWFixModeMotion return end if - if ( Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING) .and. Drawworks%motion/=-1 ) then + if ( data%State%Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING) .and. data%State%Drawworks%motion/=-1 ) then Call DWFixModeMotion return end if @@ -193,10 +194,10 @@ subroutine Drawworks_Solver ! RAM & ToolJoint Collision (Top of RAM) !==================================================== Do j = 2,4 !startup problem ??????? - if ( Drawworks%TDBOPElementNo(j)/=0 ) then - if ( ((Drawworks%TDBOPHeight(j)-Drawworks%TDBOPThickness)<=(Drawworks%TDDrillStemsTopDepth(Drawworks%TDBOPElementNo(j))+Drawworks%TDDrillStemsToolJointRange(Drawworks%TDBOPElementNo(j)))) .and. ((Drawworks%TDBOPHeight(j)-Drawworks%TDBOPThickness)>Drawworks%TDDrillStemsTopDepth(Drawworks%TDBOPElementNo(j))) .and. (Drawworks%TDBOPRamDiam(j)<(2.d0*12.d0*Drawworks%TDDrillStemsRtoolJoint(Drawworks%TDBOPElementNo(j)))) ) then - if ( Drawworks%motion==1 ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( data%State%Drawworks%TDBOPElementNo(j)/=0 ) then + if ( ((data%State%Drawworks%TDBOPHeight(j)-data%State%Drawworks%TDBOPThickness)<=(data%State%Drawworks%TDDrillStemsTopDepth(data%State%Drawworks%TDBOPElementNo(j))+data%State%Drawworks%TDDrillStemsToolJointRange(data%State%Drawworks%TDBOPElementNo(j)))) .and. ((data%State%Drawworks%TDBOPHeight(j)-data%State%Drawworks%TDBOPThickness)>data%State%Drawworks%TDDrillStemsTopDepth(data%State%Drawworks%TDBOPElementNo(j))) .and. (data%State%Drawworks%TDBOPRamDiam(j)<(2.d0*12.d0*data%State%Drawworks%TDDrillStemsRtoolJoint(data%State%Drawworks%TDBOPElementNo(j)))) ) then + if ( data%State%Drawworks%motion==1 ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -217,10 +218,10 @@ subroutine Drawworks_Solver ! RAM & ToolJoint Collision (Bottom of RAM) !==================================================== Do j = 2,4 - if ( Drawworks%TDBOPElementNo(j)/=0 ) then - if ( ((Drawworks%TDBOPHeight(j)+Drawworks%TDBOPThickness)>=(Drawworks%TDDrillStemsDownDepth(Drawworks%TDBOPElementNo(j))-Drawworks%TDDrillStemsToolJointRange(Drawworks%TDBOPElementNo(j)))) .and. ((Drawworks%TDBOPHeight(j)+Drawworks%TDBOPThickness)=(data%State%Drawworks%TDDrillStemsDownDepth(data%State%Drawworks%TDBOPElementNo(j))-data%State%Drawworks%TDDrillStemsToolJointRange(data%State%Drawworks%TDBOPElementNo(j)))) .and. ((data%State%Drawworks%TDBOPHeight(j)+data%State%Drawworks%TDBOPThickness) BottomHole ROP Condition - if ( (int(Drawworks%TDDrillStemBottom*10000.d0)>=(int((Drawworks%TDWellTotalLength+Drawworks%TDDlMax)*10000.d0))) .and. (Drawworks%motion==-1 .or. Drawworks%motion==0) ) then - if ( Drawworks%StringIsBottomOfWell==0 ) then - Drawworks%Hook_Height_final = Drawworks%Hook_Height_final+(Drawworks%TDDrillStemBottom-(Drawworks%TDWellTotalLength+Drawworks%TDDlMax)) - Drawworks%StringIsBottomOfWell = 1 + if ( (int(data%State%Drawworks%TDDrillStemBottom*10000.d0)>=(int((data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax)*10000.d0))) .and. (data%State%Drawworks%motion==-1 .or. data%State%Drawworks%motion==0) ) then + if ( data%State%Drawworks%StringIsBottomOfWell==0 ) then + data%State%Drawworks%Hook_Height_final = data%State%Drawworks%Hook_Height_final+(data%State%Drawworks%TDDrillStemBottom-(data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax)) + data%State%Drawworks%StringIsBottomOfWell = 1 end if Call DWFixModeMotion return else - Drawworks%StringIsBottomOfWell = 0 + data%State%Drawworks%StringIsBottomOfWell = 0 end if @@ -274,8 +275,8 @@ subroutine Drawworks_Solver - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] - Drawworks%HookHeight_graph_output = 0.1189d0*((3.280839895d0*Drawworks%Hook_Height)-28.d0)-2.6d0 ![ft] + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] + data%State%Drawworks%HookHeight_graph_output = 0.1189d0*((3.280839895d0*data%State%Drawworks%Hook_Height)-28.d0)-2.6d0 ![ft] diff --git a/Equipments/Drawworks/Drawworks_Solver_OffMode.f90 b/Equipments/Drawworks/Drawworks_Solver_OffMode.f90 index 265b547..0a86ee4 100644 --- a/Equipments/Drawworks/Drawworks_Solver_OffMode.f90 +++ b/Equipments/Drawworks/Drawworks_Solver_OffMode.f90 @@ -1,13 +1,14 @@ subroutine Drawworks_Solver_OffMode Use CUnityInputs - Use UnitySignalVariables - Use Drawworks_VARIABLES - Use CKellyConnectionEnumVariables - Use CElevatorConnectionEnumVariables - Use CTdsConnectionModesEnumVariables - Use CTdsElevatorModesEnumVariables - Use COperationScenariosVariables + use UnitySignalVariables + use UnitySignalsModule + use ConfigurationVariables !@ + use OperationScenariosModule + use OperationScenariosModule !!CElevator... + use UnitySignalsModule + ! Use CTdsElevatorModesEnumVariables + use OperationScenariosModule IMPLICIT NONE @@ -19,10 +20,10 @@ subroutine Drawworks_Solver_OffMode - Drawworks%motion = 0 - Drawworks%w_old_drum = 0.d0 - Drawworks%w_drum = 0.d0 - Drawworks%Hook_Height = Drawworks%Hook_Height + data%State%Drawworks%motion = 0 + data%State%Drawworks%w_old_drum = 0.d0 + data%State%Drawworks%w_drum = 0.d0 + data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height @@ -32,10 +33,10 @@ subroutine Drawworks_Solver_OffMode !==================================================== ! Collision & Warning !==================================================== - if ( Drawworks%CrownCollision == .false. ) then + if ( data%State%Drawworks%CrownCollision == .false. ) then CrownCollision_Status = 0 end if - if ( Drawworks%FloorCollision == .false. ) then + if ( data%State%Drawworks%FloorCollision == .false. ) then FloorCollision_Status = 0 end if @@ -48,16 +49,16 @@ subroutine Drawworks_Solver_OffMode !==================================================== ! Crown Collision (Max_Hook_Height) !==================================================== - if ( ((3.280839895*Drawworks%Hook_Height)>=Drawworks%max_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then - if ( CrownCollision_Status==0 .and. Drawworks%motion==1 ) then + if ( ((3.280839895*data%State%Drawworks%Hook_Height)>=data%State%Drawworks%max_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then + if ( CrownCollision_Status==0 .and. data%State%Drawworks%motion==1 ) then CrownCollision_Status = 1 - Drawworks%CrownCollision = .true. - Drawworks%SoundCrownCollision = .true. + data%State%Drawworks%CrownCollision = .true. + data%State%Drawworks%SoundCrownCollision = .true. else - Drawworks%SoundCrownCollision = .false. + data%State%Drawworks%SoundCrownCollision = .false. end if - if ( Drawworks%motion==-1 .and. Drawworks%CrownCollision==.false. ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( data%State%Drawworks%motion==-1 .and. data%State%Drawworks%CrownCollision==.false. ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -73,16 +74,16 @@ subroutine Drawworks_Solver_OffMode !==================================================== ! Floor Collision (Min_Hook_Height) !==================================================== - if ( ((3.280839895*Drawworks%Hook_Height)<=Drawworks%min_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then - if ( FloorCollision_Status==0 .and. Drawworks%motion==-1 ) then + if ( ((3.280839895*data%State%Drawworks%Hook_Height)<=data%State%Drawworks%min_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/3,4,7,10,11,12,14/))) ) then + if ( FloorCollision_Status==0 .and. data%State%Drawworks%motion==-1 ) then FloorCollision_Status = 1 - Drawworks%FloorCollision = .true. - Drawworks%SoundFloorCollision = .true. + data%State%Drawworks%FloorCollision = .true. + data%State%Drawworks%SoundFloorCollision = .true. else - Drawworks%SoundFloorCollision = .false. + data%State%Drawworks%SoundFloorCollision = .false. end if - if ( Drawworks%motion==1 .and. Drawworks%FloorCollision==.false. ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( data%State%Drawworks%motion==1 .and. data%State%Drawworks%FloorCollision==.false. ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -99,9 +100,9 @@ subroutine Drawworks_Solver_OffMode !==================================================== ! Warning (Max_Hook_Height) !==================================================== - if ( ((3.280839895*Drawworks%Hook_Height)>=Drawworks%max_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then - if ( Drawworks%motion==-1 ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( ((3.280839895*data%State%Drawworks%Hook_Height)>=data%State%Drawworks%max_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then + if ( data%State%Drawworks%motion==-1 ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -117,9 +118,9 @@ subroutine Drawworks_Solver_OffMode !==================================================== ! Warning (Min_Hook_Height) !==================================================== - if ( ((3.280839895*Drawworks%Hook_Height)<=Drawworks%min_Hook_Height) .and. (any(Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then - if ( Drawworks%motion==1 ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( ((3.280839895*data%State%Drawworks%Hook_Height)<=data%State%Drawworks%min_Hook_Height) .and. (any(data%State%Drawworks%DrillModeCond==(/1,2,5,6,8,9,13/))) ) then + if ( data%State%Drawworks%motion==1 ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -137,12 +138,12 @@ subroutine Drawworks_Solver_OffMode !==================================================== ! ELEVATOR CONNECTION STRING (SLIPS SET , No Motion) !==================================================== - if ( Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and. Drawworks%motion/=-1 ) then + if ( data%State%Drawworks%DriveType==1 .and. Get_Slips() == SLIPS_SET_END .and. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and. data%State%Drawworks%motion/=-1 ) then Call DWFixModeMotion return end if - if ( Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING) .and. Drawworks%motion/=-1 ) then + if ( data%State%Drawworks%DriveType==0 .and. Get_Slips() == SLIPS_SET_END .and. (Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING) .and. data%State%Drawworks%motion/=-1 ) then Call DWFixModeMotion return end if @@ -159,10 +160,10 @@ subroutine Drawworks_Solver_OffMode ! RAM & ToolJoint Collision (Top of RAM) !==================================================== Do j = 2,4 !startup problem ??????? - if ( Drawworks%TDBOPElementNo(j)/=0 ) then - if ( ((Drawworks%TDBOPHeight(j)-Drawworks%TDBOPThickness)<=(Drawworks%TDDrillStemsTopDepth(Drawworks%TDBOPElementNo(j))+Drawworks%TDDrillStemsToolJointRange(Drawworks%TDBOPElementNo(j)))) .and. ((Drawworks%TDBOPHeight(j)-Drawworks%TDBOPThickness)>Drawworks%TDDrillStemsTopDepth(Drawworks%TDBOPElementNo(j))) .and. (Drawworks%TDBOPRamDiam(j)<(2.d0*12.d0*Drawworks%TDDrillStemsRtoolJoint(Drawworks%TDBOPElementNo(j)))) ) then - if ( Drawworks%motion==1 ) then - Drawworks%Hook_Height_final = 3.280839895d0*Drawworks%Hook_Height ![ft] + if ( data%State%Drawworks%TDBOPElementNo(j)/=0 ) then + if ( ((data%State%Drawworks%TDBOPHeight(j)-data%State%Drawworks%TDBOPThickness)<=(data%State%Drawworks%TDDrillStemsTopDepth(data%State%Drawworks%TDBOPElementNo(j))+data%State%Drawworks%TDDrillStemsToolJointRange(data%State%Drawworks%TDBOPElementNo(j)))) .and. ((data%State%Drawworks%TDBOPHeight(j)-data%State%Drawworks%TDBOPThickness)>data%State%Drawworks%TDDrillStemsTopDepth(data%State%Drawworks%TDBOPElementNo(j))) .and. (data%State%Drawworks%TDBOPRamDiam(j)<(2.d0*12.d0*data%State%Drawworks%TDDrillStemsRtoolJoint(data%State%Drawworks%TDBOPElementNo(j)))) ) then + if ( data%State%Drawworks%motion==1 ) then + data%State%Drawworks%Hook_Height_final = 3.280839895d0*data%State%Drawworks%Hook_Height ![ft] else Call DWFixModeMotion end if @@ -183,10 +184,10 @@ subroutine Drawworks_Solver_OffMode ! RAM & ToolJoint Collision (Bottom of RAM) !==================================================== Do j = 2,4 - if ( Drawworks%TDBOPElementNo(j)/=0 ) then - if ( ((Drawworks%TDBOPHeight(j)+Drawworks%TDBOPThickness)>=(Drawworks%TDDrillStemsDownDepth(Drawworks%TDBOPElementNo(j))-Drawworks%TDDrillStemsToolJointRange(Drawworks%TDBOPElementNo(j)))) .and. ((Drawworks%TDBOPHeight(j)+Drawworks%TDBOPThickness)=(data%State%Drawworks%TDDrillStemsDownDepth(data%State%Drawworks%TDBOPElementNo(j))-data%State%Drawworks%TDDrillStemsToolJointRange(data%State%Drawworks%TDBOPElementNo(j)))) .and. ((data%State%Drawworks%TDBOPHeight(j)+data%State%Drawworks%TDBOPThickness) BottomHole ROP Condition - if ( (int(Drawworks%TDDrillStemBottom*10000.d0)>=(int((Drawworks%TDWellTotalLength+Drawworks%TDDlMax)*10000.d0))) .and. (Drawworks%motion==-1 .or. Drawworks%motion==0) ) then - if ( Drawworks%StringIsBottomOfWell==0 ) then - Drawworks%Hook_Height_final = Drawworks%Hook_Height_final+(Drawworks%TDDrillStemBottom-(Drawworks%TDWellTotalLength+Drawworks%TDDlMax)) - Drawworks%StringIsBottomOfWell = 1 + if ( (int(data%State%Drawworks%TDDrillStemBottom*10000.d0)>=(int((data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax)*10000.d0))) .and. (data%State%Drawworks%motion==-1 .or. data%State%Drawworks%motion==0) ) then + if ( data%State%Drawworks%StringIsBottomOfWell==0 ) then + data%State%Drawworks%Hook_Height_final = data%State%Drawworks%Hook_Height_final+(data%State%Drawworks%TDDrillStemBottom-(data%State%Drawworks%TDWellTotalLength+data%State%Drawworks%TDDlMax)) + data%State%Drawworks%StringIsBottomOfWell = 1 end if Call DWFixModeMotion return else - Drawworks%StringIsBottomOfWell = 0 + data%State%Drawworks%StringIsBottomOfWell = 0 end if @@ -237,8 +238,8 @@ subroutine Drawworks_Solver_OffMode - Drawworks%Hook_Height_final=3.280839895d0*Drawworks%Hook_Height ![ft] - Drawworks%HookHeight_graph_output=0.1189d0*((3.280839895d0*Drawworks%Hook_Height)-28.0d0)-2.6d0 ![ft] + data%State%Drawworks%Hook_Height_final=3.280839895d0*data%State%Drawworks%Hook_Height ![ft] + data%State%Drawworks%HookHeight_graph_output=0.1189d0*((3.280839895d0*data%State%Drawworks%Hook_Height)-28.0d0)-2.6d0 ![ft] diff --git a/Equipments/Drawworks/Drawworks_StartUp.f90 b/Equipments/Drawworks/Drawworks_StartUp.f90 index d8ed956..01b6633 100644 --- a/Equipments/Drawworks/Drawworks_StartUp.f90 +++ b/Equipments/Drawworks/Drawworks_StartUp.f90 @@ -1,52 +1,55 @@ subroutine Drawworks_StartUp - Use CDrillingConsoleVariables - Use CHoistingVariables - Use Drawworks_VARIABLES - !Use CWarningsVariables + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + use CHoistingVariables + use ConfigurationVariables + use ConfigurationVariables !@ + !use CWarnings IMPLICIT NONE - Drawworks%RateChange = 193.d0 ! [rpm/s?] !??????? motaghayere voroudi + data%State%Drawworks%RateChange = 193.d0 ! [rpm/s?] !??????? motaghayere voroudi !===> Hook Height - Drawworks%Hook_Height_ini = 75.0d0 ![ft] - Drawworks%Hook_Height_ini_graph_output = -1.54090d0 ![ft] - Drawworks%Hook_Height_inim = 0.3048d0*Drawworks%Hook_Height_ini ![m] - Drawworks%Hook_Height = Drawworks%Hook_Height_inim ![m] - Drawworks%Hook_Height_final = 75.d0 ![ft] - Drawworks%TDHookHeight = 75.d0 ![ft] + data%State%Drawworks%Hook_Height_ini = 75.0d0 ![ft] + data%State%Drawworks%Hook_Height_ini_graph_output = -1.54090d0 ![ft] + data%State%Drawworks%Hook_Height_inim = 0.3048d0*data%State%Drawworks%Hook_Height_ini ![m] + data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height_inim ![m] + data%State%Drawworks%Hook_Height_final = 75.d0 ![ft] + data%State%Drawworks%TDHookHeight = 75.d0 ![ft] !===> Drum (Drawworks) Diameter - Drawworks%Diameter = 2.50d0 ![ft] - Drawworks%Diameter = 0.3048d0*Drawworks%Diameter ![m] + data%State%Drawworks%Diameter = 2.50d0 ![ft] + data%State%Drawworks%Diameter = 0.3048d0*data%State%Drawworks%Diameter ![m] !===> Number of Line - Drawworks%NumberOfLine = Hoisting%NumberOfLine + data%State%Drawworks%NumberOfLine = data%State%Hoisting%NumberOfLine !===> Simulation time step - Drawworks%time_step = 0.10d0 ![s] + data%State%Drawworks%time_step = 0.10d0 ![s] !===> Initial Values - Drawworks%w_drum = 0.d0 - Drawworks%w_old_drum = 0.d0 - Drawworks%motion = 0 - Drawworks%K_Throttle = 0 - Drawworks%StringIsBottomOfWell = 0 ! 1= string is at the bottom of the well - !Drawworks%CrownCollision = 0 - !Drawworks%FloorCollision = 0 + data%State%Drawworks%w_drum = 0.d0 + data%State%Drawworks%w_old_drum = 0.d0 + data%State%Drawworks%motion = 0 + data%State%Drawworks%K_Throttle = 0 + data%State%Drawworks%StringIsBottomOfWell = 0 ! 1= string is at the bottom of the well + !data%State%Drawworks%CrownCollision = 0 + !data%State%Drawworks%FloorCollision = 0 diff --git a/Equipments/Drawworks/Drawworks_VARIABLES.f90 b/Equipments/Drawworks/Drawworks_VARIABLES.f90 index 31d0acc..0eedbc6 100644 --- a/Equipments/Drawworks/Drawworks_VARIABLES.f90 +++ b/Equipments/Drawworks/Drawworks_VARIABLES.f90 @@ -5,16 +5,13 @@ MODULE Drawworks_VARIABLES - REAL, PARAMETER :: pi=3.14159265 + ! REAL, PARAMETER :: pi=3.14159265 !************************************************************************************************** !**************** Define Drawworks Array **************************************************** TYPE, PUBLIC :: Drawworks_Var - - - !***** Drawworks_VARIABLES ********************** logical :: CrownCollision, FloorCollision @@ -40,10 +37,6 @@ MODULE Drawworks_VARIABLES REAL :: time_step - - - - INTEGER :: BLWR ! 1=On , 0=Off !************* Sound_VARIABLES ********************** @@ -51,11 +44,7 @@ MODULE Drawworks_VARIABLES Logical :: SoundBlower Logical :: SoundFloorCollision , SoundCrownCollision - - - END TYPE Drawworks_Var - TYPE(Drawworks_Var) :: Drawworks !*********************************************************************************************** !**************************************************************************************************** diff --git a/Equipments/DrillingConsole_ScrLEDs.f90 b/Equipments/DrillingConsole_ScrLEDs.f90 index c26465b..9d778e8 100644 --- a/Equipments/DrillingConsole_ScrLEDs.f90 +++ b/Equipments/DrillingConsole_ScrLEDs.f90 @@ -1,45 +1,47 @@ subroutine DrillingConsole_ScrLEDs - USE CDrillingConsoleVariables - USE RTable_VARIABLES + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + use ConfigurationVariables !@ IMPLICIT NONE !===> Torque Limit - DrillingConsole%RTTorqueLimitGauge = sngl(1-RTable%TorqueLimitGaugeMalf)*(DrillingConsole%RTTorqueLimitKnob/10.d0)*7000.d0 !tabdile bazeye 0-10 be 0-7000 taghribi anjam shode, baadan eslah shavad ?????? + data%EquipmentControl%DrillingConsole%RTTorqueLimitGauge = sngl(1-data%State%RTable%TorqueLimitGaugeMalf)*(data%EquipmentControl%DrillingConsole%RTTorqueLimitKnob/10.d0)*7000.d0 !tabdile bazeye 0-10 be 0-7000 taghribi anjam shode, baadan eslah shavad ?????? - if((any(DrillingConsole%AssignmentSwitch==(/1,2,3,4,8,9,10,11/)))) then + if((any(data%EquipmentControl%DrillingConsole%AssignmentSwitch==(/1,2,3,4,8,9,10,11/)))) then - DrillingConsole%SCR1LED=1 - DrillingConsole%SCR2LED=1 - DrillingConsole%SCR3LED=1 - DrillingConsole%SCR4LED=1 + data%EquipmentControl%DrillingConsole%SCR1LED=1 + data%EquipmentControl%DrillingConsole%SCR2LED=1 + data%EquipmentControl%DrillingConsole%SCR3LED=1 + data%EquipmentControl%DrillingConsole%SCR4LED=1 - else if (DrillingConsole%AssignmentSwitch == 5) then + else if (data%EquipmentControl%DrillingConsole%AssignmentSwitch == 5) then - DrillingConsole%SCR1LED=1 - DrillingConsole%SCR2LED=1 - DrillingConsole%SCR3LED=0 - DrillingConsole%SCR4LED=1 + data%EquipmentControl%DrillingConsole%SCR1LED=1 + data%EquipmentControl%DrillingConsole%SCR2LED=1 + data%EquipmentControl%DrillingConsole%SCR3LED=0 + data%EquipmentControl%DrillingConsole%SCR4LED=1 - else if (DrillingConsole%AssignmentSwitch == 7) then + else if (data%EquipmentControl%DrillingConsole%AssignmentSwitch == 7) then - DrillingConsole%SCR1LED=1 - DrillingConsole%SCR2LED=1 - DrillingConsole%SCR3LED=1 - DrillingConsole%SCR4LED=0 + data%EquipmentControl%DrillingConsole%SCR1LED=1 + data%EquipmentControl%DrillingConsole%SCR2LED=1 + data%EquipmentControl%DrillingConsole%SCR3LED=1 + data%EquipmentControl%DrillingConsole%SCR4LED=0 else - DrillingConsole%SCR1LED=0 - DrillingConsole%SCR2LED=0 - DrillingConsole%SCR3LED=0 - DrillingConsole%SCR4LED=0 + data%EquipmentControl%DrillingConsole%SCR1LED=0 + data%EquipmentControl%DrillingConsole%SCR2LED=0 + data%EquipmentControl%DrillingConsole%SCR3LED=0 + data%EquipmentControl%DrillingConsole%SCR4LED=0 end if diff --git a/Equipments/MudSystem-old/Circulation_Code_Select.f90 b/Equipments/MudSystem-old/Circulation_Code_Select.f90 deleted file mode 100644 index b99a9bd..0000000 --- a/Equipments/MudSystem-old/Circulation_Code_Select.f90 +++ /dev/null @@ -1,148 +0,0 @@ -subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver - - use KickVARIABLESModule - Use MudSystemVARIABLES - USE TD_DrillStemComponents - Use CUnityInputs - Use CUnityOutputs - USE CKellyConnectionEnumVariables - use UTUBEVARSModule - use sROP_Variables - use PressureDisplayVARIABLESModule - - - - implicit none - - - Integer i,KickNumber - - !NewInfluxNumber = NoGasPocket - - MudSystem%Flow_timeCounter= MudSystem%Flow_timeCounter+1 - - !if (ChokePanelStrokeResetSwitch == 1) then - ! Flow_timeCounter= 0 - !endif - - - !write(*,*) 'Flow_timeCounter' , Flow_timeCounter - -!===========================Shoe Lost=============================== - - call ShoeLostSub - -!=================================================================== - - - MudSystem%iLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data) - !KickMigration_2SideBit= .false. - Call Set_FlowPipeDisconnect(.false.) - Call Set_FlowKellyDisconnect(.false.) - - call ElementsCreation - - - - - if (MUD(8)%Q > 0.0) call FillingWell_By_BellNipple ! Filling Well Through BellNipple ( Path j11 ) - !if (MUD(10)%Q > 0.0) call FillingWell_By_Pumps ! Filling Well Through Pumps ( Path j19 ) - - !write(*,*) 'TD_RemoveVolume,Get_JointConnectionPossible=' , TD_RemoveVolume,Get_JointConnectionPossible() - - if (TD_Vol%RemoveVolume > 0.) call DisconnectingPipe !! .and. Get_JointConnectionPossible() == .false.) call DisconnectingPipe - - - IF (KickFlux .AND. NOT(KickOffBottom)) THEN - call Kick_Influx - endif - - - - - IF ( MudSystem%NewInfluxNumber > 0 ) THEN - !write(*,*) 'KickOffBottom , ROP=' , KickOffBottom , ROP_Bit%RateOfPenetration - call Kick_Migration - endif - -! ============================ must be after migration ============================== - - DO KickNumber= MudSystem%NewInfluxNumber-NoGasPocket+1 , MudSystem%NewInfluxNumber - ! FINDING NEW KICK LOCATIONS: - MudSystem%Ann_KickLoc= 0 - MudSystem%Op_KickLoc= 0 - MudSystem%ChokeLine_KickLoc= 0 - - do i = 1, MudSystem%Ann_MudOrKick%Length () - if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then - MudSystem%Ann_KickLoc = i - exit - endif - end do - - do i = 1, MudSystem%Op_MudOrKick%Length () - if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then - MudSystem%Op_KickLoc = i - exit - endif - end do - - do i = 1, MudSystem%ChokeLine_MudOrKick%Length () - if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then - MudSystem%ChokeLine_KickLoc = i - exit - endif - end do - - ! ============================ must be after migration-end =========================== - - IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == MudSystem%NewInfluxNumber .AND. NOT(KickOffBottom) .AND. MudSystem%WellHeadIsOpen) THEN - - cycle - - ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN - - if (((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) > 0.0 .AND. MudSystem%WellHeadIsOpen) .or. MudSystem%Kickexpansion_DueToMudLost) ) call Kick_Expansion - - if ((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. MudSystem%WellHeadIsOpen == .FALSE.) CALL Kick_Contraction - - ENDIF - ENDDO - MudSystem%KickNumber = KickNumber - MudSystem%LostInTripOutIsDone= .false. - - if( MudSystem%DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then - !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - call Pump_and_TripIn - elseif (MudSystem%DeltaVolumeOp < 0.0) then - ! when we have Utube and tripping out simultaneously, it uses "TripOut_and_Pump" subroutine, and then Utube code is done - ! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in - call TripOut_and_Pump - endif - - MudSystem%WellOutletDensity= MudSystem%Ann_Density%Last() ! (ppg) used in MudSystem - - - - if (MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18 - call ChokeLineMud - endif - - - call Choke_GasSound - - !WRITE(*,*) 'CIRCU-Ann_Saved_MudDischarged_Volume' , Ann_Saved_MudDischarged_Volume - - !****Utube is called in Plot Subroutine**** - - Call Instructor_CirculationMud_Edit - - - - call PlotFinalMudElements - - MudSystem%MudChecked= .true. - MudSystem%UtubePossibility= .true. - !WRITE(*,*) '***********************************************************************' - -end subroutine CirculationCodeSelect \ No newline at end of file diff --git a/Equipments/MudSystem-old/Deallocate_Normal_Circulation.f90 b/Equipments/MudSystem-old/Deallocate_Normal_Circulation.f90 deleted file mode 100644 index d865d2b..0000000 --- a/Equipments/MudSystem-old/Deallocate_Normal_Circulation.f90 +++ /dev/null @@ -1,186 +0,0 @@ -subroutine DEALLOCATE_ARRAYS_NormalCirculation() ! is called in module FluidFlowMain - USE MudSystemVARIABLES - implicit none - - -if(allocated(MudSystem%Xstart_PipeSection)) deallocate(MudSystem%Xstart_PipeSection) -if(allocated(MudSystem%Xend_PipeSection)) deallocate(MudSystem%Xend_PipeSection) -if(allocated(MudSystem%PipeSection_VolumeCapacity)) deallocate(MudSystem%PipeSection_VolumeCapacity) -if(allocated(MudSystem%Area_PipeSectionFt)) deallocate(MudSystem%Area_PipeSectionFt) -if(allocated(MudSystem%OD_PipeSectionInch)) deallocate(MudSystem%OD_PipeSectionInch) -if(allocated(MudSystem%ID_PipeSectionInch)) deallocate(MudSystem%ID_PipeSectionInch) -if(allocated(MudSystem%Xstart_OpSection)) deallocate(MudSystem%Xstart_OpSection) -if(allocated(MudSystem%Xend_OpSection)) deallocate(MudSystem%Xend_OpSection) -if(allocated(MudSystem%Area_OpSectionFt)) deallocate(MudSystem%Area_OpSectionFt) -if(allocated(MudSystem%OD_OpSectionInch)) deallocate(MudSystem%OD_OpSectionInch) -if(allocated(MudSystem%ID_OpSectionInch)) deallocate(MudSystem%ID_OpSectionInch) -if(allocated(MudSystem%OpSection_VolumeCapacity)) deallocate(MudSystem%OpSection_VolumeCapacity) -if(allocated(MudSystem%GeoTypeOp)) deallocate(MudSystem%GeoTypeOp) -if(allocated(MudSystem%GeoType)) deallocate(MudSystem%GeoType) - - - call MudSystem%Hz_MudDischarged_Volume%Empty() - call MudSystem%Hz_Mud_Backhead_X%Empty() - call MudSystem%Hz_Mud_Backhead_section%Empty() - call MudSystem%Hz_Mud_Forehead_X%Empty() - call MudSystem%Hz_Mud_Forehead_section%Empty() - call MudSystem%Hz_Density%Empty() - call MudSystem%Hz_RemainedVolume_in_LastSection%Empty() - call MudSystem%Hz_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%Hz_MudOrKick%Empty() - - - call MudSystem%St_MudDischarged_Volume%Empty() - call MudSystem%St_Mud_Backhead_X%Empty() - call MudSystem%St_Mud_Backhead_section%Empty() - call MudSystem%St_Mud_Forehead_X%Empty() - call MudSystem%St_Mud_Forehead_section%Empty() - call MudSystem%St_Density%Empty() - call MudSystem%St_RemainedVolume_in_LastSection%Empty() - call MudSystem%St_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%St_MudOrKick%Empty() - - - call MudSystem%Ann_MudDischarged_Volume%Empty() - call MudSystem%Ann_Mud_Backhead_X%Empty() - call MudSystem%Ann_Mud_Backhead_section%Empty() - call MudSystem%Ann_Mud_Forehead_X%Empty() - call MudSystem%Ann_Mud_Forehead_section%Empty() - call MudSystem%Ann_Density%Empty() - call MudSystem%Ann_RemainedVolume_in_LastSection%Empty() - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%Ann_MudOrKick%Empty() - call MudSystem%Ann_CuttingMud%Empty() - - - call MudSystem%Op_MudDischarged_Volume%Empty() - call MudSystem%Op_Mud_Backhead_X%Empty() - call MudSystem%Op_Mud_Backhead_section%Empty() - call MudSystem%Op_Mud_Forehead_X%Empty() - call MudSystem%Op_Mud_Forehead_section%Empty() - call MudSystem%Op_Density%Empty() - call MudSystem%Op_RemainedVolume_in_LastSection%Empty() - call MudSystem%Op_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%Op_MudOrKick%Empty() - - - call MudSystem%ChokeLine_MudDischarged_Volume%Empty() - call MudSystem%ChokeLine_Mud_Backhead_X%Empty() - call MudSystem%ChokeLine_Mud_Backhead_section%Empty() - call MudSystem%ChokeLine_Mud_Forehead_X%Empty() - call MudSystem%ChokeLine_Mud_Forehead_section%Empty() - call MudSystem%ChokeLine_Density%Empty() - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%Empty() - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%ChokeLine_MudOrKick%Empty() - - - call MudSystem%Xend_MudElement%Empty() - call MudSystem%Xstart_MudElement%Empty() - call MudSystem%TVDend_MudElement%Empty() - call MudSystem%TVDstart_MudElement%Empty() - call MudSystem%Density_MudElement%Empty() - call MudSystem%MudGeoType%Empty() - call MudSystem%PipeID_MudElement%Empty() - call MudSystem%PipeOD_MudElement%Empty() - call MudSystem%MudType_MudElement%Empty() - - call MudSystem%Xend_OpMudElement%Empty() - call MudSystem%Xstart_OpMudElement%Empty() - call MudSystem%TVDend_OpMudElement%Empty() - call MudSystem%TVDstart_OpMudElement%Empty() - call MudSystem%Density_OpMudElement%Empty() - call MudSystem%PipeID_OpMudElement%Empty() - call MudSystem%PipeOD_OpMudElement%Empty() - call MudSystem%MudTypeOp_MudElement%Empty() - end subroutine - - - -subroutine RemoveAnnulusMudArrays(ilocal) - USE MudSystemVARIABLES - implicit none - - INTEGER :: ilocal - - - call MudSystem%Ann_MudDischarged_Volume%Remove (ilocal) - call MudSystem%Ann_Mud_Backhead_X%Remove (ilocal) - call MudSystem%Ann_Mud_Backhead_section%Remove (ilocal) - call MudSystem%Ann_Mud_Forehead_X%Remove (ilocal) - call MudSystem%Ann_Mud_Forehead_section%Remove (ilocal) - call MudSystem%Ann_Density%Remove (ilocal) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%Ann_MudOrKick%Remove (ilocal) - call MudSystem%Ann_CuttingMud%Remove (ilocal) - - - - end subroutine - - -subroutine RemoveStringMudArrays(ilocal) - USE MudSystemVARIABLES - implicit none - - INTEGER :: ilocal - - - call MudSystem%St_MudDischarged_Volume%Remove (ilocal) - call MudSystem%St_Mud_Backhead_X%Remove (ilocal) - call MudSystem%St_Mud_Backhead_section%Remove (ilocal) - call MudSystem%St_Mud_Forehead_X%Remove (ilocal) - call MudSystem%St_Mud_Forehead_section%Remove (ilocal) - call MudSystem%St_Density%Remove (ilocal) - call MudSystem%St_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%St_MudOrKick%Remove (ilocal) - - - - end subroutine - - -subroutine RemoveOpMudArrays(ilocal) - USE MudSystemVARIABLES - implicit none - - INTEGER :: ilocal - - - call MudSystem%Op_MudDischarged_Volume%Remove (ilocal) - call MudSystem%Op_Mud_Backhead_X%Remove (ilocal) - call MudSystem%Op_Mud_Backhead_section%Remove (ilocal) - call MudSystem%Op_Mud_Forehead_X%Remove (ilocal) - call MudSystem%Op_Mud_Forehead_section%Remove (ilocal) - call MudSystem%Op_Density%Remove (ilocal) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%Op_MudOrKick%Remove (ilocal) - - - - end subroutine - -subroutine RemoveHzMudArrays(ilocal) - USE MudSystemVARIABLES - implicit none - - INTEGER :: ilocal - - - call MudSystem%Hz_MudDischarged_Volume%Remove (ilocal) - call MudSystem%Hz_Mud_Backhead_X%Remove (ilocal) - call MudSystem%Hz_Mud_Backhead_section%Remove (ilocal) - call MudSystem%Hz_Mud_Forehead_X%Remove (ilocal) - call MudSystem%Hz_Mud_Forehead_section%Remove (ilocal) - call MudSystem%Hz_Density%Remove (ilocal) - call MudSystem%Hz_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%Hz_MudOrKick%Remove (ilocal) - - - - end subroutine - \ No newline at end of file diff --git a/Equipments/MudSystem-old/Disconnecting_Pipe.f90 b/Equipments/MudSystem-old/Disconnecting_Pipe.f90 deleted file mode 100644 index 5dc26fa..0000000 --- a/Equipments/MudSystem-old/Disconnecting_Pipe.f90 +++ /dev/null @@ -1,108 +0,0 @@ -subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - ! !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - USE TD_DrillStemComponents - Use CKellyConnectionEnumVariables - Use CUnityOutputs - USE CManifolds - - implicit none - - Real(8) ExcessMudVolume, ExcessMudVolume_Remained - write(*,*) 'DisconnectingPipe' - - !TD_RemoveVolume= TD_RemoveVolume* 7.48051948 ! ft^3 to gal - - ExcessMudVolume= sum(MudSystem%St_MudDischarged_Volume%Array(:)) - sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) - - - ! ======if(ExcessMudVolume <= 0.) No Modification Needed Because Removed Pipe was Empty===== - - if (Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and. Manifold%Valve(56)%Status == .False.) ExcessMudVolume= 0.d0 !Valve(56)%Status == .False. :: safety valve installed - - if (ExcessMudVolume > 0.) then - - if ( Manifold%Valve(53)%Status == .true. ) then - MudSystem%MudBucketVolume= ExcessMudVolume - else - MudSystem%MudBucketVolume= 0.0 - endif - - - - - -!========================Flow Disconnect Unity Input Signals================= - - !if ( Get_JointConnectionPossible() == .false. ) then - if (Get_KellyConnection() == KELLY_CONNECTION_NOTHING) then - Call Set_FlowKellyDisconnect(.true.) - else - Call Set_FlowPipeDisconnect(.true.) - endif - !endif - - - -!====================Flow Disconnect Unity Input Signals-End================= - - - - -!========================Disconnecting Pipe from the String================= - - ExcessMudVolume_Remained= ExcessMudVolume ! ft^3 to gal - - - imud=1 - - Do - - if(MudSystem%St_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then - ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystem%St_MudDischarged_Volume%Array(imud) - call MudSystem%St_MudDischarged_Volume%Remove (imud) - call MudSystem%St_Mud_Backhead_X%Remove (imud) - call MudSystem%St_Mud_Backhead_section%Remove (imud) - call MudSystem%St_Mud_Forehead_X%Remove (imud) - call MudSystem%St_Mud_Forehead_section%Remove (imud) - call MudSystem%St_Density%Remove (imud) - call MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%St_MudOrKick%Remove (imud) - - elseif(MudSystem%St_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained - exit - - else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) - call MudSystem%St_MudDischarged_Volume%Remove (imud) - call MudSystem%St_Mud_Backhead_X%Remove (imud) - call MudSystem%St_Mud_Backhead_section%Remove (imud) - call MudSystem%St_Mud_Forehead_X%Remove (imud) - call MudSystem%St_Mud_Forehead_section%Remove (imud) - call MudSystem%St_Density%Remove (imud) - call MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%St_MudOrKick%Remove (imud) - exit - - endif - - enddo - - - - -!=================Disconnecting Pipe from the String - End=================== - endif - - - end subroutine DisconnectingPipe \ No newline at end of file diff --git a/Equipments/MudSystem-old/Elements_Creation.f90 b/Equipments/MudSystem-old/Elements_Creation.f90 deleted file mode 100644 index 5243cf3..0000000 --- a/Equipments/MudSystem-old/Elements_Creation.f90 +++ /dev/null @@ -1,274 +0,0 @@ -subroutine ElementsCreation ! is called in subroutine Fluid_Flow_Solver - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure - !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES - !use CChokeManifoldVariables - ! !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - use CError - - implicit none - - integer jelement, jmud, jsection,ielement,i - integer jopelement,jopmud,jopsection,iisection,isection,OpSection - -!===========================================================WELL============================================================ -!===========================================================WELL============================================================ - - if(allocated(MudSystem%Xstart_PipeSection)) deallocate(MudSystem%Xstart_PipeSection) - if(allocated(MudSystem%Xend_PipeSection)) deallocate(MudSystem%Xend_PipeSection) - if(allocated(MudSystem%PipeSection_VolumeCapacity)) deallocate(MudSystem%PipeSection_VolumeCapacity) - if(allocated(MudSystem%Area_PipeSectionFt)) deallocate(MudSystem%Area_PipeSectionFt) - if(allocated(MudSystem%GeoType)) deallocate(MudSystem%GeoType) - if(allocated(MudSystem%OD_PipeSectionInch)) deallocate(MudSystem%OD_PipeSectionInch) - if(allocated(MudSystem%ID_PipeSectionInch)) deallocate(MudSystem%ID_PipeSectionInch) - if(allocated(MudSystem%Angle_PipeSection)) deallocate(MudSystem%Angle_PipeSection) - - if(allocated(MudSystem%Xstart_OpSection)) deallocate(MudSystem%Xstart_OpSection) - if(allocated(MudSystem%Xend_OpSection)) deallocate(MudSystem%Xend_OpSection) - if(allocated(MudSystem%OpSection_VolumeCapacity)) deallocate(MudSystem%OpSection_VolumeCapacity) - if(allocated(MudSystem%Area_OpSectionFt)) deallocate(MudSystem%Area_OpSectionFt) - if(allocated(MudSystem%GeoTypeOp)) deallocate(MudSystem%GeoTypeOp) - if(allocated(MudSystem%OD_OpSectionInch)) deallocate(MudSystem%OD_OpSectionInch) - if(allocated(MudSystem%ID_OpSectionInch)) deallocate(MudSystem%ID_OpSectionInch) - if(allocated(MudSystem%Angle_OpSection)) deallocate(MudSystem%Angle_OpSection) - - - -ALLOCATE (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts) & - ,MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%Area_PipeSectionFt(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts), & - MudSystem%GeoType(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%OD_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%ID_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts)) - - -ALLOCATE (MudSystem%Xstart_OpSection(F_Counts%BottomHoleIntervalCounts),MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) & - ,MudSystem%OpSection_VolumeCapacity(F_Counts%BottomHoleIntervalCounts),MudSystem%Area_OpSectionFt(F_Counts%BottomHoleIntervalCounts), & - MudSystem%GeoTypeOp(F_Counts%BottomHoleIntervalCounts),MudSystem%OD_OpSectionInch(F_Counts%BottomHoleIntervalCounts),MudSystem%ID_OpSectionInch(F_Counts%BottomHoleIntervalCounts)) - - MudSystem%OpSection=0 - MudSystem%isection=0 - - - DO iisection=1, F_Counts%IntervalsTotalCounts - IF (F_Interval(iisection)%GeoType == 1) THEN - MudSystem%OpSection= MudSystem%OpSection+1 - MudSystem%Xstart_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%StartDepth) - MudSystem%Xend_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%EndDepth) - MudSystem%Area_OpSectionFt(MudSystem%OpSection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) - MudSystem%OD_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%OD) - MudSystem%ID_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%ID) !REAL(F_Interval(iisection)%Volume) - MudSystem%GeoTypeOp(MudSystem%OpSection)= F_Interval(iisection)%GeoType ! niaz nist ehtemalan - !Angle_OpSection(OpSection)= F_Interval(iisection)%Angle - !write(*,*) 'iisection=' , iisection - !write(*,*) 'StartDepth=' , F_Interval(iisection)%StartDepth - !write(*,*) 'EndDepth=' , F_Interval(iisection)%EndDepth - !write(*,*) 'OD=' , F_Interval(iisection)%OD - !write(*,*) 'ID=' , F_Interval(iisection)%ID - ELSE - MudSystem%isection= MudSystem%isection+1 - MudSystem%Xstart_PipeSection(MudSystem%isection)= (F_Interval(iisection)%StartDepth) - !write(*,*) 'F_Interval(iisection)%StartDepth=' , F_Interval(iisection)%StartDepth - MudSystem%Xend_PipeSection(MudSystem%isection)= (F_Interval(iisection)%EndDepth) - !write(*,*) 'F_Interval(iisection)%EndDepth=' , F_Interval(iisection)%EndDepth - - MudSystem%OD_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%OD) - MudSystem%Area_PipeSectionFt(MudSystem%isection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) - MudSystem%ID_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%ID) - !PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948 !REAL(F_Interval(iisection)%Volume) ! (gal) - MudSystem%GeoType(MudSystem%isection)= F_Interval(iisection)%GeoType - !Angle_PipeSection(isection)= F_Interval(iisection)%Angle - ENDIF - - ENDDO - - - - call MudSystem%Xstart_MudElement%Empty() - call MudSystem%Xstart_MudElement%Add(MudSystem%Xstart_PipeSection(1)) - - - call MudSystem%Xstart_OpMudElement%Empty() - call MudSystem%Xstart_OpMudElement%Add(MudSystem%Xstart_OpSection(1)) - - - call MudSystem%TVDstart_MudElement%Empty() - call TVD_Calculator(MudSystem%Xstart_PipeSection(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) - - - call MudSystem%TVDstart_OpMudElement%Empty() - call TVD_Calculator(MudSystem%Xstart_OpSection(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_OpMudElement%Add(MudSystem%MudCircVerticalDepth) - - - - MudSystem%NoPipeSections= MudSystem%isection ! sections in string and annulus(GeoType 0 & 2) - - - DO OpSection= 1,F_Counts%BottomHoleIntervalCounts - MudSystem%OpSection_VolumeCapacity(OpSection)= MudSystem%Area_OpSectionFt(OpSection)* ABS(MudSystem%Xend_OpSection(OpSection)-MudSystem%Xstart_OpSection(OpSection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) - ENDDO - MudSystem%OpSection=OpSection - DO isection= 1,MudSystem%NoPipeSections - MudSystem%PipeSection_VolumeCapacity(isection)= MudSystem%Area_PipeSectionFt(isection)* ABS(MudSystem%Xend_PipeSection(isection)-MudSystem%Xstart_PipeSection(isection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) ! (gal) - ENDDO - MudSystem%isection = isection - - - - !types: Mud= 0 Kick=1 - -!=========================================== - if (MudSystem%FirstMudSet==0) then - call MudSystem%Hz_MudDischarged_Volume%AddToFirst(MudSystem%PipeSection_VolumeCapacity(1)) !startup initial - call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(1)) - call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Hz_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Hz_MudOrKick%AddToFirst (0) - - - call MudSystem%St_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts))) !startup initial - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts) - call MudSystem%St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (0) - - - call MudSystem%Ann_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections))) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%NoPipeSections) - call MudSystem%Ann_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (0) - call MudSystem%Ann_CuttingMud%AddToFirst (0) - - MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - - MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - - - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst(MudSystem%ChokeLine_VolumeCapacity) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - - - call MudSystem%Op_MudDischarged_Volume%AddToFirst (sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts))) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (F_Counts%BottomHoleIntervalCounts) - call MudSystem%Op_Density%AddToFirst (MudProperties%ActiveDensity) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - !F_StringIntervalCountsOld= F_StringIntervalCounts ! is used for adding new pipe to string - MudSystem%F_StringIntervalCounts_Old= F_Counts%StringIntervalCounts ! is used for adding new pipe to string - - - MudSystem%FirstMudSet= 1 - endif - - -!===================== Trip Detection ================ - - !DeltaVolumeOp > 0 : Trip in - !DeltaVolumeOp < 0 : Trip out - - - MudSystem%DeltaVolumeOp= ((MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%OD_PipeSectionInch(F_Counts%StringIntervalCounts+1)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal ! D(in) - MudSystem%DeltaVolumeOp = INT(MudSystem%DeltaVolumeOp * 100000.d0) / 100000.d0 - - MudSystem%DeltaVolumePipe= ((MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%ID_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal - MudSystem%DeltaVolumePipe = INT(MudSystem%DeltaVolumePipe * 100000.d0) / 100000.d0 - - !DeltaVolumeAnnulusCapacity= ((Xend_PipeSection(F_Counts%StringIntervalCounts)-OldPosition))*Area_PipeSectionFt(NoPipeSections)* 7.48051948d0! ft^3 to gal - DrillStringSpeed = (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition) / 0.1 - - MudSystem%DeltaVolumeAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%OldAnnulusCapacity - - - !write(*,*) 'DeltaVolumeAnnulusCapacity= ' , DeltaVolumeAnnulusCapacity - - !write(*,*) 'DeltaVolumePipe=' , DeltaVolumePipe - !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - ! - ! - !write(*,*) 'Bit here=' , Xend_PipeSection(F_Counts%StringIntervalCounts) - - - - - MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - - MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - - ! Needed for trip in or out: - if (MudSystem%Hz_Mud_Backhead_X%Length() == 0) then - - CALL ErrorStop('Hz_Mud_Backhead_X Length is 0') - endif - - - MudSystem%Hz_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(1) - MudSystem%Hz_Mud_Backhead_section%Array(1)= 1 - - MudSystem%AddedElementsToString = F_Counts%StringIntervalCounts - MudSystem%F_StringIntervalCounts_Old - MudSystem%St_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(1)= 2 - MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - MudSystem%Ann_Mud_Backhead_section%Array(1)= F_Counts%StringIntervalCounts+1 - MudSystem%Op_Mud_Backhead_X%Array(1)= MudSystem%Xstart_OpSection(1) - MudSystem%Op_Mud_Backhead_section%Array(1)= 1 - MudSystem%ChokeLine_Mud_Backhead_X%Array(1)= 0. - MudSystem%ChokeLine_Mud_Backhead_section%Array(1)= 1 - - - MudSystem%F_StringIntervalCounts_Old= F_Counts%StringIntervalCounts -!write(*,*) 'Xstart_PipeSection(2)' , Xstart_PipeSection(2) -!write(*,*) 'Xend_PipeSection(1)' , Xend_PipeSection(1) - - -!=================================================== - - ! - !DeltaWellCap= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) + sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - WellCapOld - !WellCapOld= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) + sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - !write(*,*) 'DeltaWellCap=' , DeltaWellCap - ! - ! - ! - !DeltaAnnCap= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - AnnCapOld - !AnnCapOld= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - !write(*,*) 'DeltaAnnCap=' , DeltaAnnCap - - end subroutine ElementsCreation - - - - diff --git a/Equipments/MudSystem-old/FillingWell_By_BellNipple.f90 b/Equipments/MudSystem-old/FillingWell_By_BellNipple.f90 deleted file mode 100644 index ed83f05..0000000 --- a/Equipments/MudSystem-old/FillingWell_By_BellNipple.f90 +++ /dev/null @@ -1,215 +0,0 @@ -subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCodeSelect - - ! this subroutine is for lines: 1) BellNippleToWell-NonFullWell : MUD(8)%Q - ! 2) PumpsToWell_KillLine : MUD(10)%Q - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - - implicit none - - real(8) deltaV,Xposition,FillingDensity - - integer kloc,SectionPosition - - - - - ! Well Is Not Full - - - - if (MudSystem%Ann_MudOrKick%Last() == 104) then ! Last Element is air we must observe: Ann_Mud_Forehead_X%Last()=0.0 - - write(*,*) 'FillingWell_By_BellNipple-Last Element is air' - - !write(*,*) '*Ann_Mud_Forehead_X%Last()=' , Ann_Mud_Forehead_X%Last() - !write(*,*) '*Ann_MudOrKick%Last()=' , Ann_MudOrKick%Last() - - - - FillingDensity= MudSystem%BellNippleDensity - -!**************************** - if ( MudSystem%Ann_MudDischarged_Volume%Last() > (((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline)) then ! air baghi mimune - - kloc= MudSystem%Ann_MudDischarged_Volume%Length()-1 - - - - deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length()) - deltaV - - -!========================ANNULUS ENTRANCE==================== - - if (ABS(MudSystem%Ann_Density%Array(kloc) - FillingDensity) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%Ann_Density%AddTo (kloc, FillingDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (kloc, 0.0d0) - call MudSystem%Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0) - call MudSystem%Ann_Mud_Forehead_section%AddTo (kloc, 1) - call MudSystem%Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0) - call MudSystem%Ann_Mud_Backhead_section%AddTo (kloc, MudSystem%NoPipeSections) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (kloc, 0) - call MudSystem%Ann_CuttingMud%AddTo (kloc,0) - - !AnnulusSuctionDensity_Old= Hz_Density_Utube - endif - -!========================ANNULUS==================== - - MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+ deltaV !(gal) - - - - else ! ( Ann_MudDischarged_Volume%Last() <= (((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi namune - - - - - kloc= MudSystem%Ann_MudDischarged_Volume%Length()-1 - - deltaV= MudSystem%Ann_MudDischarged_Volume%Last() - - - - if (ABS(MudSystem%Ann_Density%Array(kloc)-FillingDensity)< MudSystem%DensityMixTol .and. MudSystem%Ann_CuttingMud%Array(kloc)==0) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)< 42.) ) then ! 1-Pockets are Merged - MudSystem%Ann_Density%Array(kloc)= (MudSystem%Ann_Density%Array(kloc)*MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) - MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV - MudSystem%Ann_Mud_Forehead_X%Array(kloc)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(kloc)= MudSystem%NoPipeSections - !Ann_Mud_Backhead_X%Array(kloc)= no change - !Ann_Mud_Backhead_section%Array(kloc)= no change - MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) - - call MudSystem%Ann_MudDischarged_Volume%Remove (kloc+1) - call MudSystem%Ann_Mud_Backhead_X%Remove (kloc+1) - call MudSystem%Ann_Mud_Backhead_section%Remove (kloc+1) - call MudSystem%Ann_Mud_Forehead_X%Remove (kloc+1) - call MudSystem%Ann_Mud_Forehead_section%Remove (kloc+1) - call MudSystem%Ann_Density%Remove (kloc+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (kloc+1) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (kloc+1) - call MudSystem%Ann_MudOrKick%Remove (kloc+1) - call MudSystem%Ann_CuttingMud%Remove (kloc+1) - - - else ! 2-Merging conditions are not meeted, so new pocket== air is replaced with filling mud - MudSystem%Ann_Density%Array(kloc+1) =FillingDensity - MudSystem%Ann_MudOrKick%Array(kloc+1)= 0 - - endif - - - endif - - ! end condition (Ann_MudOrKick%Last() == 104) ! Last Element is air - -!********************************************************************************************************************************************************** - - - - - else ! (Ann_MudOrKick%Last() == 0) then ! Last Element is NOT air- so we must observe: Ann_Mud_Forehead_X%Last()/=0.0 - - !write(*,*) 'FillingWell_By_BellNipple-Last Element is NOT air' - ! - !write(*,*) '*Ann_Mud_Forehead_X%Last()=' , Ann_Mud_Forehead_X%Last() - !write(*,*) '*Ann_MudOrKick%Last()=' , Ann_MudOrKick%Last() - - - deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline - - kloc= MudSystem%Ann_MudDischarged_Volume%Length() - - - - - -!========================ANNULUS ENTRANCE==================== - - if (ABS(MudSystem%Ann_Density%Last() - FillingDensity) >= MudSystem%DensityMixTol .or. MudSystem%Ann_CuttingMud%Last()==1) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)>42.) ) then ! new mud is pumped - Xposition= MudSystem%Ann_Mud_Forehead_X%Last() - SectionPosition= MudSystem%Ann_Mud_Forehead_section%Last() - call MudSystem%Ann_Density%Add (FillingDensity) - call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) - call MudSystem%Ann_Mud_Forehead_X%Add (Xposition) - call MudSystem%Ann_Mud_Forehead_section%Add (SectionPosition) - call MudSystem%Ann_Mud_Backhead_X%Add (Xposition) - call MudSystem%Ann_Mud_Backhead_section%Add (SectionPosition) - call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Ann_MudOrKick%Add (0) - call MudSystem%Ann_CuttingMud%Add (0) - - !AnnulusSuctionDensity_Old= Hz_Density_Utube - !endif - -!========================ANNULUS==================== - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())+ deltaV !(gal) - - - else ! Merged with last Mud - MudSystem%Ann_Density%Array(kloc)= (MudSystem%Ann_Density%Array(kloc)*MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) - MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV - !Ann_Mud_Forehead_X%Array(kloc)= Xend_PipeSection(NoPipeSections) - !Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections - !Ann_Mud_Backhead_X%Array(kloc)= no change - !Ann_Mud_Backhead_section%Array(kloc)= no change - MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) - endif - - - - - - - endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end subroutine FillingWell_By_BellNipple \ No newline at end of file diff --git a/Equipments/MudSystem-old/Kick_Expansion_and_Contraction.f90 b/Equipments/MudSystem-old/Kick_Expansion_and_Contraction.f90 deleted file mode 100644 index 8852476..0000000 --- a/Equipments/MudSystem-old/Kick_Expansion_and_Contraction.f90 +++ /dev/null @@ -1,234 +0,0 @@ -subroutine Kick_Expansion ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - USE CReservoirVariables - use KickVARIABLESModule - - - implicit none - real(8) ExpansionVolume - - !write(*,*) 'Kick Expansion' - - ExpansionVolume= GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - MudSystem%KickNumber + 1) * 7.48 - -IF ( MudSystem%Kickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) - - -!============================== kick zire mate bashad ============================== - - if (MudSystem%Op_KickLoc > 0 .and. MudSystem%Ann_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then - - !write(*,*) 'expansion (1)' - - - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)+ ExpansionVolume - - - !if (MUD(4)%Q > 0.) then - ! - ! if (abs(ChokeLine_Density%Array(1)-Ann_Density%Last())< DensityMixTol) then - ! ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1) + ExpansionVolume - ! else - ! call ChokeLine_Density%AddToFirst (Ann_Density%Last()) - ! call ChokeLine_MudDischarged_Volume%AddToFirst (ExpansionVolume) ! farz kardam ke hameye hajm ro ba yek density ezafe konim - ! call ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - ! call ChokeLine_Mud_Forehead_section%AddToFirst (1) - ! call ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - ! call ChokeLine_Mud_Backhead_section%AddToFirst (1) - ! call ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call ChokeLine_MudOrKick%AddToFirst (Ann_MudOrKick%Last()) - ! endif - ! - !endif - - endif -!======================================================================================== - - - -!============================= foreheade dar fazaye annulus bashad =========================== - ! agar kick be entehaye annulus reside bashe, expansion ra emaal nemikonim - if (MudSystem%Ann_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then - !write(*,*) 'expansion (2)' - - !if ( sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc)) + ExpansionVolume > sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ) then ! agar khast az mate rad kone - ! ExpansionVolume= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc)) - !endif - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)+ ExpansionVolume - - !if (MUD(4)%Q > 0.) then - ! - ! - ! if (abs(ChokeLine_Density%Array(1)-Ann_Density%Last())< DensityMixTol) then - ! ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1) + ExpansionVolume - ! else - ! call ChokeLine_Density%AddToFirst (Ann_Density%Last()) - ! call ChokeLine_MudDischarged_Volume%AddToFirst (ExpansionVolume) ! farz kardam ke hameye hajm ro ba yek density ezafe konim - ! call ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - ! call ChokeLine_Mud_Forehead_section%AddToFirst (1) - ! call ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - ! call ChokeLine_Mud_Backhead_section%AddToFirst (1) - ! call ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call ChokeLine_MudOrKick%AddToFirst (Ann_MudOrKick%Last()) - ! endif - ! - !endif - - endif -!======================================================================================== - - - - - -!=============================== foreheade dar choke line bashad ============================= - - if (MudSystem%ChokeLine_KickLoc > 0 .and. MudSystem%Ann_KickLoc==0) then - - MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)= MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)+ ExpansionVolume - - endif - - -!======================================================================================== - - !write(*,*) 'Expansion======0' - ! !do imud=1, Ann_MudDischarged_Volume%Length() - ! ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! !enddo - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - !write(*,*) '0======expansion' - - - - end subroutine Kick_Expansion - - - - - -subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - USE CReservoirVariables - use KickVARIABLESModule - USE CError - - - implicit none - - integer jelement, jmud, jsection,ielement,i - integer jopelement,jopmud,jopsection - real(8) ContractionVolume - - -!********************************************************* - -! contraction is always with pump flow - -!********************************************************* - !write(*,*) 'Kick Contraction' - - !MUD(2)%Q= MPumps%Total_Pump_GPM - MudSystem%StringFlowRate= MUD(2)%Q - MudSystem%AnnulusFlowRate= MUD(2)%Q - - if (MudSystem%NewPipeFilling == 0) then - MudSystem%StringFlowRate= 0. - MudSystem%AnnulusFlowRate= 0. - endif - - - - - - !if (WellHeadIsOpen) then - ContractionVolume= - GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - MudSystem%KickNumber + 1) * 7.48 - !else - !ContractionVolume = (MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe - if (MudSystem%KickNumber == 1 .and. MudSystem%WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline + MudSystem%DeltaVolumePipe - !endif - - -!************************************************************************************************************************************************************************** - - ! pump mud is added in "pump&TripIn" code - - IF (MudSystem%Op_KickLoc > 0 .and. MudSystem%Ann_KickLoc == 0) then ! All of kick is under bit (iloc == 1) - - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc) - ( ContractionVolume ) - - ELSE IF (MudSystem%Op_KickLoc == 0 .AND. MudSystem%Ann_KickLoc > 0 .AND. MudSystem%ChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1) - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc) - ( ContractionVolume ) - - ELSE IF (MudSystem%Ann_KickLoc == 0 .AND. MudSystem%ChokeLine_KickLoc > 0) THEN ! kick is in chokeline only - - MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)= MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc) - ( ContractionVolume ) - - ELSE IF (MudSystem%Op_KickLoc > 0 .AND. MudSystem%Ann_KickLoc > 0) THEN ! Kick is around bit (iloc==2) - - if (MudSystem%Ann_MudDischarged_Volume%Array(1) > ContractionVolume ) then - - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - ( ContractionVolume ) - - - elseif (MudSystem%Op_MudDischarged_Volume%Last() > ContractionVolume ) then - - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_MudDischarged_Volume%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_MudDischarged_Volume%Length()) - ( ContractionVolume ) - - else - Call ErrorStop ('kick contraction error 1') - endif - - ELSE IF (MudSystem%Ann_KickLoc > 0 .AND. MudSystem%ChokeLine_KickLoc > 0) THEN - - if (MudSystem%ChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then - - MudSystem%ChokeLine_MudDischarged_Volume%Array(1) = MudSystem%ChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume ) - - - elseif (MudSystem%Ann_MudDischarged_Volume%Last() > ContractionVolume ) then - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length()) - ( ContractionVolume ) - - else - Call ErrorStop ('kick contraction error 2') - endif - - - - endif - - ! write(*,*) 'contract======0' - !! !do imud=1, Ann_MudDischarged_Volume%Length() - !! ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - !! !enddo - !! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - !write(*,*) '0======contract' - -end subroutine Kick_Contraction diff --git a/Equipments/MudSystem-old/Kick_Influx.f90 b/Equipments/MudSystem-old/Kick_Influx.f90 deleted file mode 100644 index 9880077..0000000 --- a/Equipments/MudSystem-old/Kick_Influx.f90 +++ /dev/null @@ -1,215 +0,0 @@ -subroutine Kick_Influx ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - - - implicit none - - -!===========================================================WELL============================================================ -!===========================================================WELL============================================================ - - !write(*,*) 'Kick Influx' - - -!=================== Bottom Hole Kick Influx ENTRANCE(due to Kick) =================== - - MudSystem%Kick_Density= 2 - MudSystem%NewInflux_Density= MudSystem%Kick_Density - - - if ( MudSystem%NewInfluxElementCreated==0 ) then ! new kick is pumped- (it is set to zero in sheykh subroutine after a new kick influx) - call MudSystem%Op_Density%AddToFirst (MudSystem%NewInflux_Density) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (MudSystem%NewInfluxNumber) ! KickNumber= NewInfluxNumber - - - MudSystem%NewInfluxElementCreated= 1 - endif - - - MudSystem%Op_MudDischarged_Volume%Array(1)= MudSystem%Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) due to KickFlux - !write(*,*) 'kick volume ok=' , Op_MudDischarged_Volume%Array(1) - - - - end subroutine Kick_Influx - - - - - - - - - - - -subroutine Instructor_CirculationMud_Edit ! is called in subroutine CirculationCodeSelect - - use KickVARIABLESModule - Use MudSystemVARIABLES - USE TD_DrillStemComponents - Use CUnityInputs - Use CUnityOutputs - USE CKellyConnectionEnumVariables - use UTUBEVARSModule - use sROP_Variables - use sROP_Other_Variables - use CDownHoleVariables - - - implicit none - - - - - - if ( DownHole%AnnDrillMud == .true. .and. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%DeltaVolumeOp>0.0) ) then - - do imud= 1, MudSystem%Ann_Density%Length() - - if ( MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then - MudSystem%Ann_Density%Array(imud)= (MudSystem%St_Density%Last() * MudSystem%AnnulusFlowRate + 141.4296E-4*ROP_Bit%RateOfPenetration*ROP_Spec%DiameterOfBit**2)/(MudSystem%AnnulusFlowRate+6.7995E-4*ROP_Bit%RateOfPenetration*ROP_Spec%DiameterOfBit**2) - MudSystem%Ann_CuttingMud%Array(imud)= 1 - endif - - enddo - - endif - - - if ( DownHole%AnnCirculateMud == .true. ) then - - do imud= 1, MudSystem%Ann_Density%Length() - - if ( MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then - MudSystem%Ann_Density%Array(imud)= MudSystem%ActiveTankDensity - MudSystem%Ann_CuttingMud%Array(imud)= 0 - endif - - enddo - - do imud= 1, MudSystem%St_Density%Length() - - MudSystem%St_Density%Array(imud)= MudSystem%ActiveTankDensity - - enddo - - endif - - - - - end subroutine Instructor_CirculationMud_Edit - - - -subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect - - use KickVARIABLESModule - Use MudSystemVARIABLES - USE TD_DrillStemComponents - Use CUnityInputs - Use CUnityOutputs - USE CKellyConnectionEnumVariables - use UTUBEVARSModule - use sROP_Variables - use sROP_Other_Variables - use CDownHoleVariables - use CShoeVariables - use PressureDisplayVARIABLESModule - Use CWarningsVariables - - - implicit none - - MudSystem%ShoeLost= .false. - MudSystem%Kickexpansion_DueToMudLost= .false. - - MudSystem%ShoeMudPressure= PressureGauges(5) - - - MudSystem%UGBOSuccessionCounter = MudSystem%UGBOSuccessionCounter + 1 - !write(*,*) 'check point 1' - - if (Shoe%InactiveFracture == .FALSE. .AND. ((MudSystem%ShoeMudPressure >= MudSystem%FormationLostPressure) .or. MudSystem%ShoeFractured )) then - !write(*,*) 'check point 2 ,UGBOSuccessionCounter' , UGBOSuccessionCounter - - ! if ShoeFractured changed to true , then time counter is not needed more - if ( MudSystem%UGBOSuccessionCounter /= MudSystem%UGBOSuccessionCounterOld+1 .and. MudSystem%ShoeFractured==.false. ) then - MudSystem%UGBOSuccessionCounter = 0 ! also in starup - MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup - return - else - MudSystem%UGBOSuccessionCounterOld= MudSystem%UGBOSuccessionCounter - endif - - if ( MudSystem%UGBOSuccessionCounter < 10 .and. MudSystem%ShoeFractured==.false.) then - return - endif - - !write(*,*) 'check point 3 ,UGBOSuccessionCounter' , UGBOSuccessionCounter - - - - MudSystem%ShoeFractured= .true. - - MudSystem%ShoeMudViscosity= MAX(MudSystem%ShoeMudViscosity, 12.d0) - !write(*,*) 'ShoeMudDensity , ShoeMudViscosity' , ShoeMudDensity , ShoeMudViscosity - MudSystem%ShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * MudSystem%ShoeMudDensity / & - (MudSystem%ShoeMudViscosity * LOG(10000.d0)) - !write(*,*) 'lost parameters 1' , ShoeMudPressure , FormationLostPressure - MudSystem%Qlost = MAX( (MudSystem%ShoeLostCoef * (MudSystem%ShoeMudPressure - (MudSystem%FormationLostPressure/2.0))) , 0.d0 ) - if (MudSystem%Qlost > 0.0) then - MudSystem%ShoeLost= .true. - else - MudSystem%ShoeLost= .false. - endif - - !write(*,*) 'Qlost=' , Qlost, ShoeMudPressure, FormationLostPressure - call Activate_UndergroundBlowout() - - - do imud= 1, MudSystem%Ann_Mud_Forehead_X%Length() - - IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) & - .and. MudSystem%Ann_MudOrKick%Array(imud) == 0 .and. MudSystem%WellHeadIsOpen == .FALSE. ) then - - MudSystem%Kickexpansion_DueToMudLost= .true. - write(*,*) 'Kickexpansion_DueToMudLost' - - EXIT - - ENDIF - - - enddo - - - - endif - - if (Warmings%UndergroundBlowout == .false.) MudSystem%ShoeLost= .false. - - - - end subroutine ShoeLostSub - - - - \ No newline at end of file diff --git a/Equipments/MudSystem-old/Kick_Migration.f90 b/Equipments/MudSystem-old/Kick_Migration.f90 deleted file mode 100644 index 1d2e833..0000000 --- a/Equipments/MudSystem-old/Kick_Migration.f90 +++ /dev/null @@ -1,1176 +0,0 @@ -subroutine Kick_Migration ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - USE CReservoirVariables - use KickVARIABLESModule - - - implicit none - - integer jelement, jmud, jsection,ielement,i,kickNumber - integer jopelement,jopmud,jopsection,CuttingValue - - - !MUD(2)%Q= MPumps%Total_Pump_GPM - !MudSystem%StringFlowRate= MUD(2)%Q - !MudSystem%AnnulusFlowRate= MUD(2)%Q - ! - !if (NewPipeFilling == 0) then - ! MudSystem%StringFlowRate= 0. - ! MudSystem%AnnulusFlowRate= 0. - !endif - - !StringFlowRateFinal= MudSystem%StringFlowRate - !AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate - - - - !write(*,*) 'MUD(2)%Q=====' , MUD(2)%Q - !write(*,*) 'Kick Migration,NewInfluxNumber:' , NewInfluxNumber - - - - !FirstSetKickMigration - !write(*,*) 'NewInfluxNumber=' , NewInfluxNumber -DO KickNumber= MudSystem%NewInfluxNumber-NoGasPocket+1 , MudSystem%NewInfluxNumber - !write(*,*) 'KickNumber=' , KickNumber - if (KickFlux .AND. NOT(KickOffBottom) .and. KickNumber == MudSystem%NewInfluxNumber) cycle - if ( KickNumber == MudSystem%Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called - !write(*,*) 'Migration will be done for,KickNumber=' ,KickNumber - - !=================== Bottom Hole ENTRANCE(due to Kick) =================== - !KickDx= (AutoMigrationRate/60.)*DeltaT_Mudline !3600 (ft/min)= 6 ft set in start up - - - MudSystem%Op_KickLoc= 0 - MudSystem%Ann_KickLoc= 0 - MudSystem%ChokeLine_KickLoc= 0 - - do i = 1, MudSystem%Op_MudOrKick%Length () - if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then - MudSystem%Op_KickLoc = i - exit - endif - end do - - do i = 1, MudSystem%Ann_MudOrKick%Length () - if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then - MudSystem%Ann_KickLoc = i - exit - endif - end do - - do i = 1, MudSystem%ChokeLine_MudOrKick%Length () - if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then - MudSystem%ChokeLine_KickLoc = i - exit - endif - end do - - !write(*,*) 'Op_KickLoc=' , Op_KickLoc - !write(*,*) 'Ann_KickLoc=' , Ann_KickLoc - !!write(*,*) 'ChokeLine_KickLoc=' , ChokeLine_KickLoc - ! - ! - !write(*,*) 'Op_MudOrKick%Length ()=' , Op_MudOrKick%Length () - ! - ! - - - - -!============================== foreheade kick be mate reside bashad *3 ============================== - -if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann_KickLoc==0 ) then - !write(*,*) '****3' - - MudSystem%iLoc= 2 - - MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - - - MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (1), MudSystem%Op_MudDischarged_Volume%Last () ) - - MudSystem%NewDensity= MudSystem%Ann_Density%Array (1) - MudSystem%NewVolume= MudSystem%MinKickDv - - if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund - - MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv - - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) - call MudSystem%Ann_CuttingMud%AddToFirst (0) - - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv - - ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - - - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume - - endif - else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1=============================== - !write(*,*) '****3-1' - - - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - endif - - - - elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund - - MudSystem%Ann_Density%Array(1)= MudSystem%Op_Density%Last() - MudSystem%Ann_MudOrKick%Array(1)= KickNumber - - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv - - ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - - - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume - - endif - - else !if Op_KickLoc == 1 (*****Migration Start*****) *3-2=============================== - !write(*,*) '****3-2' - - - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - endif - - - ! - elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod - - MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv - - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) - call MudSystem%Ann_CuttingMud%AddToFirst (0) - - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc) - - - ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - - - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - - - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume - - endif - - else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3=============================== - !write(*,*) '****3-3' - - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - endif - - - - - endif - - - endif - -!======================================================================================== - - -!============================== foreheade kick be mate reside bashad *3 with pump ============================== - -! if (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 .and. MudSystem%AnnulusFlowRate /= 0.0 ) then -! write(*,*) '****3 with pump' -! -! KickMigration_2SideBit= .true. -! !iloc= 2 -! -! !KickDv= Area_OpSectionFt(Op_Mud_Forehead_section%Array(Op_KickLoc)) * KickDx * 7.48051948 ! ft^3 to gal -! -!!farz mikonam baraye in yek iteration kick az OP hazf nemishavad va hajme aan bishtar az pump flow ast -! -! KickDv= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) -! -! call Ann_Density%AddToFirst (Kick_Density) -! call Ann_MudDischarged_Volume%AddToFirst (KickDv) -! call Ann_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) -! call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) -! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) -! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) -! call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) -! call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) -! call Ann_MudOrKick%AddToFirst (KickNumber) -! call Ann_CuttingMud%AddToFirst (0) -! -! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv -! -! ! -! !if ( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad -! ! -! ! KickDv= ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) -! -! -! -! ! BackHead: -! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then -! -! -! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) -! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) -! -! call Op_Density%AddTo (Op_KickLocMudSystem%St_Density%Last()) -! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,KickDv) -! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) -! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) -! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) -! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) -! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) -! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) -! call Op_MudOrKick%AddTo (Op_KickLoc,0) -! -! -! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity -! -! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + KickDv -! -! endif -! -! -! -! -! endif - -!======================================================================================== - - -!============================= tamame kick zire mate bashad *1 ================================ - if ( MudSystem%Op_KickLoc>0 .and. MudSystem%Op_KickLoc < MudSystem%Op_MudOrKick%Length () ) then - !write(*,*) '****1' - !iloc= 1 - - MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - if ( MudSystem%KickDv < MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) ) then !eleman bala sari baghi mimund - - !write(*,*) 'cond 11111111111111' - - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) - MudSystem%KickDv - - MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1) - MudSystem%NewVolume= MudSystem%KickDv - - else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund - - ! write(*,*) 'cond 22222222222222222' - - - MudSystem%KickDv= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) - - MudSystem%NewVolume= MudSystem%KickDv - MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1) - - - - - call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc+1) - - endif - - ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - - - - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - - else !Op_Density%Array (Op_KickLoc-1) == MudSystem%NewDensity - - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume - - endif - else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1=============================== - !write(*,*) '****5-1' - - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - endif - - - endif - -!======================================================================================== - - !write(*,*) 'a) density and cutting:' , Ann_Density%Length() , Ann_CuttingMud%Length() - - -!=========================== tamame kick balaye mate bashad *2 ================================== - - if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc==0 ) then - !write(*,*) '****2' - - !iloc= 1 - - MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - - MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1) - MudSystem%NewVolume= MudSystem%KickDv - CuttingValue= MudSystem%Ann_CuttingMud%Array (MudSystem%Ann_KickLoc+1) - - if ( MudSystem%KickDv < MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then !eleman bala sari baghi mimund - - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%KickDv - - else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund - - MudSystem%KickDv= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%NewVolume= MudSystem%KickDv - - call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1) - - endif - - ! backheade kick balaye mate bashad - - if (MudSystem%Ann_KickLoc > 1) then - !if ( Ann_Density%Array (Ann_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc) - - - call MudSystem%Ann_Density%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%Ann_KickLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Ann_KickLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%Ann_KickLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%Ann_KickLoc,0) - - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - - MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)= (MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1) + MudSystem%NewVolume - - - endif - - else !if Ann_KickLoc == 1 *6 =============================== - !write(*,*) '****6' - - MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc) - - - call MudSystem%Ann_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (0) - call MudSystem%Ann_CuttingMud%AddToFirst (CuttingValue) - - endif - - endif - - !======================================================================================== - - - - - - - -!============================== kick 2 tarafe mate bashad *4 ============================== - - if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc > 0 ) then - !write(*,*) '****4' - - MudSystem%iLoc= 2 - - MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - - - MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1), MudSystem%Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick - - MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1) - MudSystem%NewVolume= MudSystem%MinKickDv - - if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund - !write(*,*) '****4----1' - - - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv - - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 - - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last - - - ! backheade kick zire mate bashad - if ( MudSystem%Op_KickLoc>1) then - - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - - - else ! merge - - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume - - endif - - else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - !write(*,*) '****5-2' - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - endif - - - - elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund - !write(*,*) '****4----2' - - call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1) - - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 - - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last - - ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - - - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume - - endif - - else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - endif - - - elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod - !write(*,*) '****4----3' - - - - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv - - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 - - - - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) - - - call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc) ! Op_KickLoc= last - call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc) - - ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then - - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then - - - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) - - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume - - endif - - else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) - - endif - - MudSystem%iLoc= 1 ! ok - - endif - - - endif - -!======================================================================================== - - - -!============================== kick 2 tarafe mate bashad *4 with pump ============================== - - ! - !if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 .and. MudSystem%AnnulusFlowRate /= 0.0 ) then - ! write(*,*) '****4 with pump' - ! - ! KickMigration_2SideBit= .true. - ! - ! !iloc= 2 - ! - ! KickDv= Area_PipeSectionFt(Ann_Mud_Forehead_section%Array(Ann_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal - ! !MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick - ! - ! - ! !MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick - ! ! - ! !MudSystem%NewDensity= Ann_Density%Array (Ann_KickLoc+1) - ! !NewVolume= MinKickDv - ! - ! - ! if ( ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad---tu in halat aslan kari be elemane balaiye kick tuye Ann nadarim - ! !WRITE(*,*) '*****sorate pump bishtar az kick*******' - ! MinKickDv= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! dar asl maxKickDv ast - ! - ! - ! - ! - ! - ! - ! - ! - ! if ( Op_MudDischarged_Volume%Last () > MinKickDv ) then !eleman paeeni(kick) dar OP baghi mimund - ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last - ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! ! backheade kick zire mate bashad - ! if ( Op_KickLoc>1) then - ! - ! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then - ! - ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! call Op_Density%AddTo (Op_KickLocMudSystem%St_Density%Last()) - ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,MinKickDv) - ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) - ! call Op_MudOrKick%AddTo (Op_KickLoc,0) - ! - ! - ! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! - ! endif - ! - ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - ! write(*,*) '****5-2 with pump' - ! - ! - ! !Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! !Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! - ! call Op_Density%AddToFirst MudSystem%St_Density%Last()) - ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) - ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call Op_MudOrKick%AddToFirst (0) - ! - ! endif - ! - ! elseif ( Op_MudDischarged_Volume%Last () <= MinKickDv ) then !eleman paeeni(kick) dar OP baghi nemimund yani kick az OP kamel kharej mishod - ! - ! MinKickDv= Op_MudDischarged_Volume%Last () - ! - ! - ! write(*,*) '****4----3 with pump a' - ! - ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) + ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)-MinKickDv - ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 - ! - ! call Op_MudDischarged_Volume%Remove (Op_KickLoc) ! Op_KickLoc= last - ! call Op_Mud_Backhead_X%Remove (Op_KickLoc) - ! call Op_Mud_Backhead_section%Remove (Op_KickLoc) - ! call Op_Mud_Forehead_X%Remove (Op_KickLoc) - ! call Op_Mud_Forehead_section%Remove (Op_KickLoc) - ! call Op_Density%Remove (Op_KickLoc) - ! call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc) - ! call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc) - ! call Op_MudOrKick%Remove (Op_KickLoc) - ! - ! - ! ! backheade kick zire mate bashad - ! if (Op_KickLoc > 1) then - ! - ! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then - ! - ! - ! !Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! !Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! call Op_Density%AddTo (Op_KickLocMudSystem%St_Density%Last()) - ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,MinKickDv) - ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) - ! call Op_MudOrKick%AddTo (Op_KickLoc,0) - ! - ! - ! - ! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - ! - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + MinKickDv - ! - ! endif - ! - ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - ! - ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! - ! call Op_Density%AddToFirst MudSystem%St_Density%Last()) - ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) - ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call Op_MudOrKick%AddToFirst (0) - ! - ! endif - ! - ! - ! endif ! ende 2 halat ke kick tuye Op baghi bemune ya namune- dar halati ke ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) ! sorate pump bishtar az kick bashad - ! - ! - ! - ! - ! else !if( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) then ! sorate pump kamtar az kick bashad - ! !WRITE(*,*) '*****sorate pump kamtar az kick*******' - ! - ! - ! - ! - ! MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick - ! - ! - ! - ! !write(*,*) 'MinKickDv=' , MinKickDv - ! - ! - ! if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund - ! !write(*,*) '****4----1 with pump' - ! !write(*,*) MudSystem%St_Density%Last()=' ,MudSystem%St_Density%Last() - ! !write(*,*) '((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)=' , ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) - ! !write(*,*) 'Ann_Density%Array(Ann_KickLoc+1)=' , Ann_Density%Array(Ann_KickLoc+1) - ! !write(*,*) '(MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline))=' , (MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)) - ! - ! - ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & - ! / (((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + (MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) - ! NewVolume= MinKickDv - ! - ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - (MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)) - ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last - ! - ! - ! ! backheade kick zire mate bashad - ! if ( Op_KickLoc>1) then - ! - ! - ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then - ! - ! - ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) - ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) - ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) - ! call Op_MudOrKick%AddTo (Op_KickLoc,0) - ! - ! - ! else !Merge Condition - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & - ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) - ! - ! - ! endif - ! - ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - ! write(*,*) '****5-2 with pump' - ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! - ! call Op_Density%AddToFirst (MudSystem%NewDensity) - ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) - ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call Op_MudOrKick%AddToFirst (0) - ! - ! endif - ! - ! - ! - ! elseif ( MinKickDv == Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund - ! write(*,*) '****4----2 with pump' - ! - ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & - ! / (((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)) - ! NewVolume= MinKickDv - ! - ! call RemoveAnnulusMudArrays(Ann_KickLoc+1) - ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last - ! - ! ! backheade kick zire mate bashad - ! if (Op_KickLoc > 1) then - ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then - ! - ! ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) - ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) - ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) - ! call Op_MudOrKick%AddTo (Op_KickLoc,0) - ! - ! - ! else !Merge Condition - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & - ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) - ! - ! - ! - ! endif - ! - ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! - ! call Op_Density%AddToFirst (MudSystem%NewDensity) - ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) - ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call Op_MudOrKick%AddToFirst (0) - ! - ! endif - ! - ! - ! elseif ( MinKickDv == Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod - ! write(*,*) '****4----3 with pump b' - ! - ! MudSystem%NewDensity=MudSystem%St_Density%Last() - ! NewVolume= MinKickDv - ! - ! - ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) - ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) - ! - ! - ! !Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - MinKickDv farz kardam dast be elemane balaee nazanam - ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 - ! !write(*,*) 'pointer 1' - ! call Op_MudDischarged_Volume%Remove (Op_KickLoc) ! Op_KickLoc= last - ! call Op_Mud_Backhead_X%Remove (Op_KickLoc) - ! call Op_Mud_Backhead_section%Remove (Op_KickLoc) - ! call Op_Mud_Forehead_X%Remove (Op_KickLoc) - ! call Op_Mud_Forehead_section%Remove (Op_KickLoc) - ! call Op_Density%Remove (Op_KickLoc) - ! call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc) - ! call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc) - ! call Op_MudOrKick%Remove (Op_KickLoc) - ! - ! !write(*,*) 'pointer 2' - ! - ! ! backheade kick zire mate bashad - ! if (Op_KickLoc > 1) then - ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then - ! !write(*,*) 'pointer 3' - ! - ! - ! - ! - ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) - ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) - ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) - ! call Op_MudOrKick%AddTo (Op_KickLoc,0) - ! - ! !write(*,*) 'pointer 4' - ! - ! else !Merge Condition - ! - ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & - ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) - ! - ! endif - ! - ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - ! !write(*,*) 'pointer 5' - ! - ! - ! !write(*,*) 'pointer 6' - ! - ! - ! call Op_Density%AddToFirst (MudSystem%NewDensity) - ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) - ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) - ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) - ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call Op_MudOrKick%AddToFirst (0) - ! !write(*,*) 'pointer 7' - ! - ! endif - ! - ! - ! endif - ! - ! - ! - ! endif !( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) ! sorate pump kamtar az kick bashad - ! - ! - ! - ! - ! endif - -!======================================================================================== - -ENDDO ! KickNumber= 1, NewInfluxNumber -MudSystem%KickNumber = kickNumber - - !write(*,*) 'c)Ann_MudDischarged_Volume%Array(:)=' , sum(Ann_MudDischarged_Volume%Array(:)) - - - - end subroutine Kick_Migration \ No newline at end of file diff --git a/Equipments/MudSystem-old/MudSystem.f90 b/Equipments/MudSystem-old/MudSystem.f90 deleted file mode 100644 index 0798c79..0000000 --- a/Equipments/MudSystem-old/MudSystem.f90 +++ /dev/null @@ -1,3295 +0,0 @@ -module MudSystemModule - - USE MudSystemVARIABLES - use PressureDisplayVARIABLESModule - USE FricPressDropVarsModule - USE Fluid_Flow_Startup_Vars - USE CMudPropertiesVariables - USE CManifolds - USE CPumpsVariables - USE CUnityOutputs - use CWarningsVariables - use DynamicIntegerArray - use CError - use CLog1 - USE CDataDisplayConsoleVariables - use CStudentStationVariables !, PitGainLossReset=>PitGainLossZero - - - implicit none - - real j2,j12,j13,jj2,jj12,jj13 - real A71,A72,A73 - integer j3,B71,B77,B78 - integer j4 - real C71,C77,C78 - integer j5 - integer j6,D71,D80 - integer j7,j8,j9,j10,j11 - real E71,E72,E73 - real F71,F72,F73 - integer j14 - real G82,G83,G84 - integer j15 - real H82,H83,H84 - integer j16,K82,K83,K84,K79,K78 - integer j17,L82,L83,L84,L79,L78 - integer j18 - real M71,M77,M78, Pump1toCh,Pump2toCh,Pump3toCh,Denominator_a - integer j19 - real N82,N83,N84 - integer j20 - integer j21 - real unityreturn - - - - real(8) DumpPump1,DumpPump2,DumpCementPump,Denominator - real(8) Mp1Coef,Mp2Coef,CpCoef - real(8) PumpPressure1,PumpPressure2,PumpPressure3 - integer Mp1_NoPath,Mp2_NoPath,Cp_NoPath - real P1toSt,P2toSt,CptoSt - real(8) MaxWorkingPressure1,MaxWorkingPressure2,MaxWorkingPressure3,MaxWorkingPressure - - REAL(8) DumpFromKelly, DumpFromFillupHead - real(8) AddedVolumeToTank,PUMP1_Flow_Rate_Old,PUMP2_Flow_Rate_Old,PUMP3_Flow_Rate_Old - real(8) VolumeToActive,VolumeToBellNipple,BellNipple_FlowCoef,ChokeLine_FlowCoef - - - REAL RealJ2,RealJ12,RealJ13,RealJ4,RealJ18 - INTEGER active32,active33,active34,active35,active29 - - logical condition1, condition2, condition3, condition4, condition5, condition6, condition7, condition8, condition9, condition10, condition11, condition12, condition13, condition14, condition15 - logical condition16,condition17,condition18,condition19,condition20,condition21,condition22,condition23,condition24,condition25,condition26,condition27,condition28,condition29,condition30,condition31 - logical condition32,condition33,condition34,condition35,condition36,condition37,condition38,condition39,condition40,condition41,condition42,condition43,condition44,condition45 - logical condition46,condition47,condition48,condition49,condition50,condition51,condition52,condition53,condition54,condition55,condition56,condition57,condition58 - logical condition59,condition60,condition61 - logical ac32, ac33, ac34, ac35, ac29 - logical ThereIsPathFrom_71_72_73_To_82, ThereIsPathFrom_71_72_73_To_83, ThereIsPathFrom_71_72_73_To_84 - logical DumpFromKelly_Pump1, DumpFromKelly_Pump2, DumpFromKelly_Pump3 - logical DumpFromTopDrive_Pump1,DumpFromTopDrive_Pump2,DumpFromTopDrive_Pump3 - logical DumpFromFillupHead_Pump1, DumpFromFillupHead_Pump2, DumpFromFillupHead_Pump3 - logical State1,State2, State3, State4 - type(DynamicIntegerArrayType) Pump1_Lasts,Pump2_Lasts, Pump3_Lasts - REAL MP1_Q, MP2_Q, MP3_Q - real TimePassed - - real(8) active_after, active_before, active_increase, total_active_increase,total_decrease,sys_total_injected - real(8) total_annFlow,total_DeltaVPipe - contains - - subroutine LineupAndPath() - implicit none - -!=========================================================================== -! MUDLINE CODE -!=========================================================================== - ! Initialize - j2=0 - jj2=0 - A71=0 - A72=0 - A73=0 - RealJ2=0.0 - - j3=0 - B71=0 - B77=0 - B78=0 - - j4=0 - C71=0. - C77=0. - C78=0. - active32=0 - active33=0 - active34=0 - active35=0 - active29=0 - - - j5=0 - - j6=0 - D71=0 - D80=0 - - j7=0 - - j8=0 - - j9=0 - j10=0 - j11=0 - - j12=0 - jj12=0 - E71=0 - E72=0 - E73=0 - RealJ12=0.0 - - j13=0 - jj13=0 - F71=0 - F72=0 - F73=0 - RealJ13=0.0 - - j14=0 - G82=0 - G83=0 - G84=0 - - DumpPump1=0. - DumpPump2=0. - DumpCementPump=0. - - j15=0 - H82=0.0 - H83=0.0 - H84=0.0 - - Mp1Coef= 0.0 - Mp1Coef= 0.0 - CpCoef= 0.0 - - Mp1_NoPath= 0 - Mp2_NoPath= 0 - Cp_NoPath= 0 - - j16=0 - K82=0 - K83=0 - K84=0 - K78=0 - K79=0 - - - j17=0 - L82=0 - L83=0 - L84=0 - L78=0 - L79=0 - - j18=0 - M71=0. - M77=0. - M78=0. - Pump1toCh=0. - Pump2toCh=0. - Pump3toCh=0. - - - j19=0 - N82=0 - N83=0 - N84=0 - - j20=0 - - j21=0 - - - -!=========================================================================== - - !===============TanksToMudPump1================= - if(condition1) then - j2=j2+1 - A71=1 - jj2=1 - endif - - if(condition2) then - j2=j2+1 - A72=1 - jj2=1 - endif - - if(condition3) then - j2=j2+1 - A73=1 - jj2=1 - endif - - !================================================ - - !============BellNippleToPits-FullWell============== - if(MudSystem%FirstMudSet== 1 ) then !.and. WellisNOTFull== .false.) then ! Well Must Be Full !Ann_Mud_Forehead_X%Last()==AboveAnnularHeight .and. Ann_Density%Last()/=0.0) - if(condition4) then - j3=j3+1 - B71=1 - endif - - if(condition5) then - j3=j3+1 - B77=1 - endif - - if(condition6) then - j3=j3+1 - B78=1 - endif - - endif - - !================================================ - - !============WellToChokeManifold(Through 26)============== - if(condition7) then - j4=j4+1 - C71=1. - endif - - if(condition8) then - j4=j4+1 - C77=1. - endif - - if(condition45) then - j4=j4+1 - C78=1. - endif - if (ac32) active32=1 - if (ac33) active33=1 - if (ac34) active34=1 - if (ac35) active35=1 - if (ac29) active29=1 !BYPASS VALVE - - - - !================================================ - - - !============ActiveTankToTripTank============== - if(condition9) then - j5=j5+1 - endif - !================================================ - - !write(*,*) 'j5====' , j5 - !============TripTankToActiveTank And BellNipple============== - if(condition10) then - j6=j6+1 - D71=1 - endif - - if(condition11) then - j6=j6+1 - D80=1 - endif - !================================================ - - !============ActiveTankToDump============== - if(condition12) then - j7=j7+1 - endif - !================================================ - - !============TripTankToDump============== - if(condition13) then - j8=j8+1 - endif - !================================================ - - !============WellToBellNipple============== - if(condition14) then - j9=j9+1 - endif - !================================================ - - !============MudBucketToBellNipple============== - if(condition15) then - j10=j10+1 - endif - !================================================ - - !============BellNippleToWell-NonFullWell============== - - - if(condition16 .and. MudSystem%FirstMudSet== 1 .and. MudSystem%BellNippleVolume > 0.0001 .and. MudSystem%WellisNOTFull) then - - write(*,*) 'MUD(7)%Q=' , MUD(7)%Q - write(*,*) 'BellNippleVolume=' , MudSystem%BellNippleVolume - - - write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn - - write(*,*) 'int:::=' , (MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) - write(*,*) 'Ann_Mud_Forehead_X%Last()=' , MudSystem%Ann_Mud_Forehead_X%Last() - write(*,*) 'AboveAnnularHeight=' , BopStackSpecification%AboveAnnularHeight - write(*,*) 'Ann_Density%Last()=' , MudSystem%Ann_Density%Last() - CALL ErrorStop('error stop1') - - j11=j11+1 - endif - !================================================ - - !===============TanksToMudPump2=================== - - if(condition17) then - j12=j12+1 - E71=1 - jj12=1 - endif - - if(condition18) then - j12=j12+1 - E72=1 - jj12=1 - endif - - if(condition19) then - j12=j12+1 - E73=1 - jj12=1 - endif - - !================================================ - - !===============TanksToCementPump=================== - if(condition20) then - j13=j13+1 - F71=1 - jj13=1 - endif - - if(condition21) then - j13=j13+1 - F72=1 - jj13=1 - endif - - if(condition22) then - j13=j13+1 - F73=1 - jj13=1 - endif - - !================================================ - - !===============PumpsToString=================== - if(condition23) then - j14=j14+1 - G82=1 - endif - - if(condition24) then - j14=j14+1 - G83=1 - endif - - if(condition25) then - j14=j14+1 - G84=1 - endif - !================================================ - - - !===============PumpsToDump=================== - if(condition26) then - DumpPump1=1.0 - endif - - if(condition27) then - DumpPump2=1.0 - endif - - if(condition28) then - DumpCementPump=1.0 - endif - !================================================ - - - !=======MudPumps1&2ToActiveTank_Through65&66========== - if(condition29) then - !write(*,*) 'condition 29' - j15=j15+1 - H82=1.0 - endif - - if(condition30) then - j15=j15+1 - H83=1.0 - endif - - !================================================ - - - !=======CementPumpToActiveTank_Through65========== - - if(condition31) then - - H84=1.0 - - endif - !================================================ - - !write(*,*) 'condition32===' , condition32 - - !============MudPump1HasNoPath=================== - if(MudSystem%condition32Final) then - !write(*,*) 'MudPump1HasNoPath' - Mp1_NoPath = 1 - endif - !================================================ - - !============MudPump2HasNoPath=================== - if(MudSystem%condition33Final) then - !write(*,*) 'MudPump2HasNoPath' - Mp2_NoPath = 1 - endif - !================================================ - - - !============CementPumpHasNoPath=================== - if(MudSystem%condition34Final) then - Cp_NoPath = 1 - endif - !================================================ - - !===============PathsToGauge75=================== - if(condition35) then !Pump1 to Gauge75 - j16=j16+1 - K82=1 - endif - - if(condition36) then !Pump2 to Gauge75 - j16=j16+1 - K83=1 - endif - - if(condition37) then !Pump3 to Gauge75 - j16=j16+1 - K84=1 - endif - - if(condition38) then !String to Gauge75 - j16=j16+1 - K79=1 - endif - - if(condition39) then !Dump to Gauge75 - j16=j16+1 - K78=1 - endif - - !================================================ - !write(*,*) '****j16=' , j16 - !===============PathsToGauge76=================== - if(condition40) then !Pump1 to Gauge76 - j17=j17+1 - L82=1 - endif - - if(condition41) then !Pump2 to Gauge76 - j17=j17+1 - L83=1 - endif - - if(condition42) then !Pump3 to Gauge76 - j17=j17+1 - L84=1 - endif - - if(condition43) then !String to Gauge76 - j17=j17+1 - L79=1 - endif - - if(condition44) then !Dump to Gauge76 - j17=j17+1 - L78=1 - endif - - !================================================ - - !====Pump1-StandPipeManifoldToChokeManifold-Through ChokeLine==== - if(condition46) then - j18=j18+1 - M71=1. - Pump1toCh= 1. - endif - - if(condition47) then - j18=j18+1 - M77=1. - Pump1toCh= 1. - endif - - if(condition48) then - j18=j18+1 - M78=1. - Pump1toCh= 1. - endif - !================================================================= - - - !====Pump2-StandPipeManifoldToChokeManifold-Through ChokeLine==== - if(condition49) then - j18=j18+1 - M71=1. - Pump2toCh= 1. - endif - - if(condition50) then - j18=j18+1 - M77=1. - Pump2toCh= 1. - endif - - if(condition51) then - j18=j18+1 - M78=1. - Pump2toCh= 1. - endif - !================================================================= - - - !====Pump3-StandPipeManifoldToChokeManifold-Through ChokeLine==== - if(condition52) then - j18=j18+1 - M71=1. - Pump3toCh= 1. - endif - - if(condition53) then - j18=j18+1 - M77=1. - Pump3toCh= 1. - endif - - if(condition54) then - j18=j18+1 - M78=1. - Pump3toCh= 1. - endif - !================================================================= - - - !===============PumpsToWell_KillLine============ - if(condition55) then - j19=j19+1 - N82=1 - endif - - if(condition56) then - j19=j19+1 - N83=1 - endif - - if(condition57) then - j19=j19+1 - N84=1 - endif - !================================================ - - !===============WellToChokeLineGauge============ - if(condition58) then - j20=j20+1 - endif - - if (j20>0) then - MudSystem%WellToChokeLineGauge= .true. - else - MudSystem%WellToChokeLineGauge= .false. - endif - !================================================ - - - !============ChokeLineGaugeToTanks=============== - if(condition59) then - j21=j21+1 - endif - - if(condition60) then - j21=j21+1 - endif - - if(condition61) then - j21=j21+1 - endif - - if (j21>0) then - MudSystem%ChokeLineGaugeToTanks= .true. - else - MudSystem%ChokeLineGaugeToTanks= .false. - endif - !================================================ - - - end subroutine - - subroutine main - Use GeoElements_FluidModule - USE Pumps_VARIABLES - USE CHOKEVARIABLES - USE CDataDisplayConsoleVariables - use CDrillWatchVariables - use CHOKEVARIABLES - use CChokeManifoldVariables - use CTanksVariables - use KickVARIABLESModule - Use CHoistingVariables - ! use CSimulationVariables - - implicit none - Integer I - - MudSystem%MudSys_timeCounter = MudSystem%MudSys_timeCounter + 1 - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%MudSys_timeCounter= 0 - endif - - !WRITE (*,*) 'MudSys_timeCounter', MudSys_timeCounter - 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 <<< - - - !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 - - 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 (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' - endif - 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 (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.) - endif - !=========================================================================================================================== - !=========================================================================================================================== - ! 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 - - if (Hoisting%DriveType==1 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then - !write(*,*) 'Set_FlowFromKelly(.TRUE.)' - call Activate_PumpWithKellyDisconnected() - !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate - CALL Set_FlowFromKelly(min(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() - CALL Set_FlowFromKelly(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before - elseif (Hoisting%DriveType==0) then - call Deactivate_PumpWithTopdriveDisconnected() - CALL Set_FlowFromKelly(0.0) ! .FALSE. before - !write(*,*) 'Set_FlowFromKelly(.FALSE.)' - 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 - if (PumpsSpecification%MudPump1ReliefValveIsSet) then - MaxWorkingPressure1= PumpsSpecification%MudPump1ReliefValvePressure - else - MaxWorkingPressure1= 6000. !psi - 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 - - !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 - 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(*,*) '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 (*,*) ' valve 1 ', Manifold%Valve(1)%Status - WRITE (*,*) ' valve 4 ', Manifold%Valve(4)%Status - WRITE (*,*) ' valve 6 ', Manifold%Valve(6)%Status - WRITE (*,*) ' valve 7 ', Manifold%Valve(7)%Status - WRITE (*,*) ' valve 8 ', Manifold%Valve(8)%Status - WRITE (*,*) ' valve 9 ', Manifold%Valve(9)%Status - WRITE (*,*) ' valve 13 ', Manifold%Valve(13)%Status - 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 (*,*) ' -valve 1 ', Manifold%Valve(1)%Status - WRITE (*,*) ' -valve 4 ', Manifold%Valve(4)%Status - WRITE (*,*) ' -valve 6 ', Manifold%Valve(6)%Status - WRITE (*,*) ' -valve 7 ', Manifold%Valve(7)%Status - WRITE (*,*) ' -valve 8 ', Manifold%Valve(8)%Status - WRITE (*,*) ' -valve 9 ', Manifold%Valve(9)%Status - WRITE (*,*) ' -valve 13 ', Manifold%Valve(13)%Status - WRITE (*,*) ' -valve 68 ', Manifold%Valve(68)%Status - WRITE (*,*) ' -valve 69 ', Manifold%Valve(69)%Status - WRITE (*,*) ' -valve 48 ', Manifold%Valve(48)%Status - !call DisplayOpenPathsWrites() - 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 - !write(*,*) ' failurrrrre ' - - if (PumpPressure1 >= MaxWorkingPressure1 .and. MP1_Q > 0.0) then - write(*,*) 'mp1,if=' , PumpPressure1 , MaxWorkingPressure1 , MP1_Q - MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1 - !if (Pump1BlownStarted == .FALSE.) then - ! write(*,*) 'if (Pump1BlownStarted == .FALSE. ) then' - ! Pump1BlownInTimeStep = SimulationTime + BlownThresholdInSecond - ! Pump1BlownStarted = .TRUE. - !endif - !write(*,*) 'SimulationTime===', SimulationTime, Pump1BlownInTimeStep - if(PumpsSpecification%MudPump1ReliefValveIsSet .and. MudSystem%Pump1BlownCount >= BlownThreshold) then - write(*,*) 'valve 65 open, BLOWN' - call ChangeValve(65, .TRUE.) - PumpToManifoldCompressedMudVol= 0.0 - MudSystem%Pump1BlownCount = 0 - !Pump1BlownStarted = .FALSE. - !else - ! write(*,*) 'PumpPressure1= 6000 psi' - ! PumpPressure1= 6000. !psi - endif - !else - !Pump1BlownInTimeStep = 0 - !Pump1BlownStarted = .FALSE. - !write(*,*) 'Pump1BlownStarted = .FALSE.' - endif - - !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 - ! Pump2BlownInTimeStep = SimulationTime + BlownThresholdInSecond - ! Pump2BlownStarted = .TRUE. - !endif - !if (MudPump2ReliefValveIsSet .and. SimulationTime >= Pump2BlownInTimeStep .and. Pump2BlownStarted) then - if (PumpsSpecification%MudPump2ReliefValveIsSet .and. MudSystem%Pump2BlownCount >= BlownThreshold) then - write(*,*) 'valve 66 open, BLOWN' - call ChangeValve(66, .TRUE.) - PumpToManifoldCompressedMudVol= 0.0 - MudSystem%Pump2BlownCount = 0 - !Pump2BlownInTimeStep = 0 - !Pump2BlownStarted = .FALSE. - !else - ! PumpPressure2= 6000. !psi - endif - !else - !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(PumpPressure3 >= MaxWorkingPressure3 .and. MP3_Q > 0.0 ) then - MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1 - if (PumpsSpecification%CementPumpReliefValveIsSet .and. MudSystem%Pump3BlownCount >= BlownThreshold) then - !write(*,*) 'valve 67 open, BLOWN' - call ChangeValve(67, .TRUE.) - PumpToManifoldCompressedMudVol= 0.0 - MudSystem%Pump3BlownCount = 0 - !else - ! PumpPressure3= 6000. !psi - endif - !else - !Pump3BlownInTimeStep = 0 - !Pump3BlownStarted = .FALSE. - endif - !write(*,*) '3)PumpPressure1=' , PumpPressure1 - if (PumpPressure1>= 6000.) then - MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1 - if(MudSystem%Pump1BlownCount >= BlownThreshold) then - call ChangeValve(65, .TRUE.) - PumpToManifoldCompressedMudVol= 0.0 - call Activate_Pump1Failure() - MudSystem%Pump1OffFailure= .true. - MudSystem%Pump1BlownCount = 0 - endif - !else - !Pump1BlownInTimeStep = 0 - !Pump1BlownStarted = .FALSE. - endif - - if (PumpPressure2>= 6000.) then - MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1 - if(MudSystem%Pump2BlownCount >= BlownThreshold) then - call ChangeValve(66, .TRUE.) - PumpToManifoldCompressedMudVol= 0.0 - call Activate_Pump2Failure() - MudSystem%Pump2OffFailure= .true. - MudSystem%Pump2BlownCount = 0 - endif - !else - !Pump2BlownInTimeStep = 0 - !Pump2BlownStarted = .FALSE. - endif - - if (PumpPressure3>= 6000.) then - MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1 - if(MudSystem%Pump3BlownCount >= BlownThreshold) then - call ChangeValve(67, .TRUE.) - PumpToManifoldCompressedMudVol= 0.0 - call Activate_Pump3Failure() - MudSystem%Pump3OffFailure= .true. - MudSystem%Pump3BlownCount = 0 - endif - !else - !Pump3BlownInTimeStep = 0 - !Pump3BlownStarted = .FALSE. - 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 - 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) - !ENDIF - VolumeToBellNipple= VolumeToBellNipple + MudSystem%BellNippleVolume - !write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple - !write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q - endif - - if (j9 == 0 ) then !.or. WellisNOTFull== .true.) then - !write(*,*) 'WellisNOTFull=' , WellisNOTFull - MUD(7)%Q=0.0 ! for normal circulation input - endif - - if (j9 > 0) then - MudSystem%WellToPitsOpen= .true. - else - MudSystem%WellToPitsOpen= .false. - endif - !=========================================================================================================================== - !=========================================================================================================================== - if (j10 > 0) then !MudBucketToBellNipple - !write(*,*) 'j10 is open' - !MudBucketVolume= 0. - !MudBucketDensity= 0. - ! MudBucketVolume gets value in DisconnectingPipe subroutine - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ MudSystem%MudBucketVolume - 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%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 - 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 - endif - 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 - 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%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - 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 - 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 - if (j3 == 2) then !78 is not allowded in this position - - MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) - - IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN - - - AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN - - AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - 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%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - - ENDIF - - - endif - - endif !( BellNippleDensity > 1.0) then - - active_after= MudSystem%ActiveTankVolume - - active_increase = active_after - active_before - - total_active_increase= total_active_increase + active_increase - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - total_active_increase= 0. - endif - - !write(*,*) 'total_active_increase=' , total_active_increase - - - - !write(*,*) 'ReturnFlowRate=MUD(3)%Q= after' , MUD(3)%Q - - MudSystem%ReturnFlowRate = MUD(3)%Q - - MudSystem%TripTankVolumeCalc = min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal - !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - - MudSystem%ActiveTankVolume = min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal - MudProperties%ActiveSettledContentsGal) - !if ActiveTankVolume is higher, excess amount is dumped - !write(*,*) 'BellNippleDensity=' , BellNippleDensity - - !MudWeightOut2 = BellNippleDensity !for drillwatch display - !write(*,*) 'MudWeightOut2=' , MudWeightOut2 - - !write(*,*) - - - endif - - if (j3 == 0) then - MUD(3)%Q=0.0 ! for normal circulation input - call Set_FlowRate(0d0) - endif - - - -!=========================================================================================================================== -!=========================================================================================================================== - - - - if (j11 > 0 .and. MudSystem%MudChecked== .true.) then !BellNippleToWell-NonFullWell ( FillingWell_By_BellNipple subroutine is called for this state ) - !write(*,*) 'j11 is open' - MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds - !WellToPitsOpen = .TRUE. - - !BellNipple flow rate= sum flow rate (well+ mudbucket+ triptank) - - !Well to BellNipple: BellNippleVolume - !MudBucket to BellNipple: BellNippleVolume - !TripTnak to BellNipple: BellNippleVolume - - MUD(8)%Q = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60. - !write(*,*) 'MUD(8)%Q=' , MUD(8)%Q - - - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(8)%Q/60.)*MudSystem%DeltaT_Mudline) ! to be 0. - !write(*,*) 'BellNippleVolume-2nd Mode=' , BellNippleVolume - - !BellNippleDensity - ! - ! - !BellNippleDensity , MUD(8)%Q be code gel dade beshe - !shart: j11 > 0 , MUD(8)%Q > 0.0 - - - endif - - if (j11 == 0) then - MUD(8)%Q=0.0 ! for normal circulation input - !WellToPitsOpen= .false. - endif - - - -!=========================================================================================================================== -!=========================================================================================================================== - - - - !WRITE (*,*) 'choke condition', j4, ChokeLineNOTFull - if (j4 > 0 .and. MudSystem%ChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26) - !write(*,*) 'j4 is open' - !write(*,*) 'active by j4' - - - - !MUD(4)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline - MUD(4)%Q= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud - - - !if ( WellisNOTFull== .true. ) MUD(4)%Q= 0.0 - - - if (j9 > 0) then - ChokeLine_FlowCoef= BopStackSpecification%ChokeLineId/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch) - MUD(4)%Q= ChokeLine_FlowCoef * MUD(4)%Q - endif - - - !call Log_1('MUD(4)%Q=', MUD(4)%Q) - - MudSystem%ChokeOutletDensity= MudSystem%ChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code - - - !MudWeightOut2= ChokeOutletDensity !for drillwatch display -! - !AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in - - - - - - RealJ4= real(j4) - - !C71: Active Tank C77: Trip Tank C78: ChokeManifoldDump - - if ( MudSystem%BellNippleDensity > 1.0) then - ! IN ALL CONDITIONS EFFECT OF 78 IS COMPUTED BY RealJ4 - if (C71==1 .and. C77==0) then !(volumes in galon) RealJ4: 1 OR 2(IF 78 IS OPEN) - - IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase choke1=' , (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN - - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase choke2=' , ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity < 5.0) THEN - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase choke3=' ,((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN - !write(*,*) ' Auto true 3' - - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - - !write(*,*) 'active increase choke4=' , (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) - - ENDIF - - - - endif - - if (C77==1 .and. C71==0) then !RealJ4: 1 OR 2(IF 78 IS OPEN) - - IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN - - AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity < 5.0) THEN - - AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN - - AddedVolumeToTank= (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - - ENDIF - - - - endif - - if (C71==1 .and. C77==1) then !RealJ4: 2 OR 3(IF 78 IS OPEN) - - IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN - - - AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN - - AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN - - AddedVolumeToTank= ((1.d0/RealJ4)*MUD(4)%Q/60.d0) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - - - ENDIF - - - endif - - - if (C71==0 .and. C77==0 .and. C78==1) then !RealJ4: 1 - ! autodensity niaz nadarad - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - - endif - - - - endif ! if ( BellNippleDensity > 1.0) then - - - MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal - !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) - !if ActiveTankVolume is higher, excess amount is dumped - - endif - - - - - - if (j4 == 0 .or. MudSystem%ChokeLineNOTFull== .true.) then - !Pressure_BeforeChokes=0.0 ! for normal circulation input - MUD(4)%Q=0.0 ! for CirculationCodeSelect input. - endif - - - if (j4 > 0) then - MudSystem%WellToChokeManifoldOpen= .true. - else - MudSystem%WellToChokeManifoldOpen= .false. - endif - -!=========================================================================================================================== -!=========================================================================================================================== - - if (j18 > 0) then !StandPipeManifoldToChokeManifold-Through ChokeLine - !write(*,*) 'j18 is open' - !write(*,*) 'active by j18' - -! STEP 1: REDUCTION FROM PUMPS STEP 1: REDUCTION FROM PUMPS STEP 1: REDUCTION FROM PUMPS (SAME TO PumpsToString LINE) - ! (NOT NEEDED) - - - -! STEP 2: ADD TO TANKS STEP 2: ADD TO TANKS STEP 2: ADD TO TANKS STEP 2: ADD TO TANKS (SAME TO WellToChokeManifold LINE) - - !Pump1toCh: PumpsToChokeManifold Coefficient - !Jj2,Jj12,Jj13: TanksToMudPump Coefficient - !H: Pumps To Tank_Through65 or 67 Coefficient - - MUD(9)%Q= jj2*(1-H82)*(1-DumpPump1)*Pump1toCh*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*Pump2toCh*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*Pump3toCh*PUMP(3)%Flow_Rate - - - - Denominator_a= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*PUMP(3)%Flow_Rate) - - if (Denominator_a /= 0.) then - MudSystem%Density_Ch= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & - Denominator_a - !write(*,*) 'Density_Ch=' , Density_Ch - ! - ! else - !Density_Ch= 0.0 - endif - - - RealJ18= M71+M77+M78 - - !C71: Active Tank C77: Trip Tank C78: ChokeManifoldDump - - - ! IN ALL CONDITIONS EFFECT OF 78 IS COMPUTED BY RealJ18 - if (M71==1 .and. M77==0) then !(volumes in galon) RealJ18: 1 OR 2(IF 78 IS OPEN) - - ! autodensity niaz nadarad - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - - endif - - if (M77==1 .and. M71==0) then !RealJ18: 1 OR 2(IF 78 IS OPEN) - - ! autodensity niaz nadarad - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - - endif - - if (M71==1 .and. M77==1) then !RealJ18: 2 OR 3(IF 78 IS OPEN) - - ! autodensity niaz nadarad - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - - endif - - - if (M71==0 .and. M77==0 .and. M78==1) then !RealJ18: 1 - ! autodensity niaz nadarad - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - - endif - - - - - - - - - MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal - !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) - !if ActiveTankVolume is higher, excess amount is dumped - - endif - - - if (j18 == 0) then - MUD(9)%Q=0.0 - endif - - -!=========================================================================================================================== -!=========================================================================================================================== - - if (j5 > 0 .and. (MudSystem%ActiveTankVolume/MudSystem%ActiveTankFloorArea) > (MudSystem%TripTankVolumeCalc/MudSystem%TripTankFloorArea)) then !ActiveTankToTripTank - ! second condition is for Utube flow - !write(*,*) 'j5 is open' - - ! ActiveTankVolume/ActiveTankFloorArea... means tank height - MUD(5)%Q= 300. ! constant flow rate(gpm) - - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume - ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc + ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline) - - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*(MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline)) - - - - MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal - !if TripTankVolumeCalc>50, excess value(TripTankVolumeCalc-50) is dumped - - endif - - if (j5 == 0) then - MUD(5)%Q=0.0 - endif - -!=========================================================================================================================== -!=========================================================================================================================== - - if (j16 > 0) then !PathsToGauge75 - - if (K79 == 1) then - - MudSystem%PressureGauge75= PressureGauges(1) !String to Gauge75 - - elseif (K82 == 1 .and. k83 == 0 .and. k84 == 0 .and. k78 == 0) then - MudSystem%PressureGauge75= PumpPressure1 - elseif (K82 == 0 .and. k83 == 1 .and. k84 == 0 .and. k78 == 0) then - MudSystem%PressureGauge75= PumpPressure2 - elseif (K82 == 0 .and. k83 == 0 .and. k84 == 1 .and. k78 == 0) then - MudSystem%PressureGauge75= PumpPressure3 - elseif (K82 == 0 .and. k83 == 0 .and. k84 == 0 .and. k78 == 1) then - MudSystem%PressureGauge75= 0. - endif - - !if (K82 == 1) PressureGauge75= PumpPressure1 !Pump1 to Gauge75' - !if (K83 == 1) PressureGauge75= PumpPressure2 !Pump2 to Gauge75 - !if (K84 == 1) PressureGauge75= PumpPressure3 !Pump3 to Gauge75 - !if (K78 == 1) PressureGauge75= 0. !Dump to Gauge75 - - endif - - - StandPipeManifold%StandPipeGauge1= (1 - MudSystem%StandPipeGauge1Malf) * MudSystem%PressureGauge75 ! for STManifold Display - !write(*,*) 'PressureGauge75=' , PressureGauge75 - !P1toSt= jj2*(1-H82)*(1-DumpPump1)*G82 - !P2toSt= jj12*(1-H83)*(1-DumpPump2)*G83 - !CptoSt= jj13*(1-H84)*(1-DumpCementPump)*G84 -!=========================================================================================================================== -!=========================================================================================================================== - - if (j17 > 0) then !PumpsToGauge76 - - if (L79 == 1) then - - MudSystem%PressureGauge76= PressureGauges(1) !String to Gauge76 - - elseif (L82 == 1 .and. L83 == 0 .and. L84 == 0 .and. L78 == 0) then - MudSystem%PressureGauge76= PumpPressure1 - elseif (L82 == 0 .and. L83 == 1 .and. L84 == 0 .and. L78 == 0) then - MudSystem%PressureGauge76= PumpPressure2 - elseif (L82 == 0 .and. L83 == 0 .and. L84 == 1 .and. L78 == 0) then - MudSystem%PressureGauge76= PumpPressure3 - elseif (L82 == 0 .and. L83 == 0 .and. L84 == 0 .and. L78 == 1) then - MudSystem%PressureGauge76= 0. - endif - - - !if (L79 == 1) PressureGauge76= PressureGauges(1) !String to Gauge76 - !if (L82 == 1) PressureGauge76= PumpPressure1 !Pump1 to Gauge76 - !if (L83 == 1) PressureGauge76= PumpPressure2 !Pump2 to Gauge76 - !if (L84 == 1) PressureGauge76= PumpPressure3 !Pump3 to Gauge76 - !if (L78 == 1) PressureGauge76= 0. !Dump to Gauge76 - - endif - StandPipeManifold%StandPipeGauge2= (1 - MudSystem%StandPipeGauge2Malf) * MudSystem%PressureGauge76 ! for STManifold Display -!=========================================================================================================================== -!=========================================================================================================================== - ! - !if (PressureGauge75 == PressureGauges(1)) then ! means: 75 goes to string - ! PumpPressureDW= PressureGauges(1) !for DrillWatch Display - ! CALL Set_StandPipePressure(real(PressureGauges(1) , 8)) !for Data Display Console - !endif - ! - ! - !if (PressureGauge76 == PressureGauges(1)) then ! means: 76 goes to string - ! PumpPressureDW= PressureGauges(1) !for DrillWatch Display - ! CALL Set_StandPipePressure(real(PressureGauges(1) , 8)) !for Data Display Console - !endif - ! - !if (PressureGauge75 /= PressureGauges(1) .and. PressureGauge76 /= PressureGauges(1)) then ! means: non of gauges go to string - ! PumpPressureDW= max(PressureGauge75,PressureGauge76) !for DrillWatch Display - ! !StandPipePressureGauge= max(PressureGauge75,PressureGauge76) !for Data Display Console - ! CALL Set_StandPipePressure(real(max(PressureGauge75,PressureGauge76) , 8)) !for Data Display Console - !endif - !write(*,*) 'TapSelector=' , TapSelector - - - if (StudentStation%TapSelector == .false.) then - - DrillingWatch%PumpPressure= MudSystem%PressureGauge75 !for DrillWatch Display - CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%PressureGauge75 , 8)) !for Data Display Console - else - DrillingWatch%PumpPressure= MudSystem%PressureGauge76 !for DrillWatch Display - CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%PressureGauge76 , 8)) !for Data Display Console - endif - -!=========================================================================================================================== -!=========================================================================================================================== - ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem - - if (j2 > 0) then !TanksToMudPump1 - - - !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate - - - RealJ2= real(j2) - - if (A71==1 .and. (MudSystem%ActiveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - A71= 0 - RealJ2= RealJ2-1 - write(*,*) 'ActiveTank Level Warning' - call Activate_ActiveTankUnderVolume() - endif - - if (A72==1 .and. (MudSystem%ReserveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - A72= 0 - RealJ2= RealJ2-1 - write(*,*) 'ReserveTank Level Warning' - endif - - if (A71==3 .and. (MudSystem%CementTankVolumeCalc-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - A73= 0 - RealJ2= RealJ2-1 - write(*,*) 'CementTank Level Warning' - endif - - - if(RealJ2> 0.0) then - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- A72*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- A73*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - !write(*,*) 'Active-decline=' , A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline) - total_decrease= total_decrease+ A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - total_decrease= 0. - endif - !write(*,*) 'total_decrease=' , total_decrease - - - MudSystem%Mp1Density= (A71*MudSystem%ActiveTankDensity+A72*MudSystem%ReserveTankDensity+A73*MudSystem%CementTankDensityCalc)/RealJ2 - else - write(*,*) 'stop' - endif - - - - endif - - -!=========================================================================================================================== -!=========================================================================================================================== - ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem - - if (j12 > 0) then !TanksToMudPump2 - - - !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate - - RealJ12= real(J12) - - if (E71==1 .and. (MudSystem%ActiveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - E71= 0 - RealJ12= RealJ12-1 - write(*,*) 'ActiveTank Level Warning' - endif - - if (E72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - E72= 0 - RealJ12= RealJ12-1 - write(*,*) 'ReserveTank Level Warning' - endif - - if (E71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - E73= 0 - RealJ12= RealJ12-1 - write(*,*) 'CementTank Level Warning' - endif - - - if(RealJ12> 0.0) then - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- E71*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- E72*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- E73*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - - - - MudSystem%Mp2Density= (E71*MudSystem%ActiveTankDensity+E72*MudSystem%ReserveTankDensity+E73*MudSystem%CementTankDensityCalc)/RealJ12 - else - write(*,*) 'stop' - endif - - - endif - - -!=========================================================================================================================== -!=========================================================================================================================== - ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem - - if (j13 > 0) then !TanksToCementPump - - - !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate - - - RealJ13= real(J13) - - if (F71==1 .and. (MudSystem%ActiveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - F71= 0 - RealJ13= RealJ13-1 - write(*,*) 'ActiveTank Level Warning' - endif - - if (F72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - F72= 0 - RealJ13= RealJ13-1 - write(*,*) 'ReserveTank Level Warning' - endif - - if (F71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then - F73= 0 - RealJ13= RealJ13-1 - write(*,*) 'CementTank Level Warning' - endif - - - if(RealJ13> 0.0) then - - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- F71*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- F72*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- F73*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - - - MudSystem%Mp3Density= (F71*MudSystem%ActiveTankDensity+F72*MudSystem%ReserveTankDensity+F73*MudSystem%CementTankDensityCalc)/RealJ13 - else - write(*,*) 'stop' - endif - - - endif - - - -!=========================================================================================================================== -!=========================================================================================================================== - ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem - - if (j14 > 0) then !PumpsToString Suction_Density_MudSystem is used for Mud Circulation Code - !write(*,*) 'j14 is open' - !call Log_1('j14 is open') - - ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> - - ! pump flow rate1 be sharti be samte string miravad ke masire j2 bar gharar bashad - ! pump flow rate2 be sharti be samte string miravad ke masire j12 bar gharar bashad - ! pump flow rate3 be sharti be samte string miravad ke masire j13 bar gharar bashad - - !G: PumpsToString Coefficient - !Jj2,Jj12,Jj13: TanksToMudPump Coefficient - !H: Pumps To Tank_Through65 or 67 Coefficient - ! - !write(*,*) 'jj2=' , jj2 - !write(*,*) 'jj12=' , jj12 - !write(*,*) 'jj13=' , jj13 - !write(*,*) 'H82=' , H82 - !write(*,*) 'H83=' , H83 - !write(*,*) 'H84=' , H84 - !write(*,*) 'DumpPump1=' , DumpPump1 - !write(*,*) 'DumpPump2=' , DumpPump2 - !write(*,*) 'DumpCementPump=' , DumpCementPump - !write(*,*) 'G82=' , G82 - !write(*,*) 'G83=' , G83 - !write(*,*) 'G84=' , G84 - !write(*,*) 'Mp1Density=' , Mp1Density - !write(*,*) 'Mp2Density=' , Mp2Density - !write(*,*) 'Mp3Density=' , Mp3Density - ! - ! - - - - !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate - - Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*PUMP(3)%Flow_Rate) - - if (Denominator /= 0.) then - MudSystem%Suction_Density_MudSystem= (jj2*(1.-H82)*(1.-DumpPump1)*G82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & - Denominator - endif - - MudSystem%CompressedMudDensity= MudSystem%Suction_Density_MudSystem - - DrillingWatch%MudWeightIn= MudSystem%Suction_Density_MudSystem !for drillwatch display - - - MUD(2)%Q= jj2*(1-H82)*(1-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*G84*PUMP(3)%Flow_Rate - - !write(*,*) 'MUD(2)%Q=' , MUD(2)%Q - - - - !jj2*(1-H82)*(1-DumpPump1)*G82 :if ==1, Pump1 to String is open - !jj12*(1-H83)*(1-DumpPump2)*G83 :if ==1, Pump2 to String is open - !jj13*(1-H84)*(1-DumpCementPump)*G84 :if ==1, Cement to String is open - - - - endif - - if (j14 == 0) then ! for normal circulation input - MUD(2)%Q=0.0 - !PumpPressure1= 0.0 - !PumpPressure2= 0.0 - !PumpPressure3= 0.0 - endif - - - -!=========================================================================================================================== -!=========================================================================================================================== - - if (j19 > 0 .and. MudSystem%MudChecked== .true.) then !PumpsToWell_KillLine Suction_Density_PumpsToWell is used for Mud Circulation Code - !write(*,*) 'j19 is open' - MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds - - ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> - - ! pump flow rate1 be sharti be samte well miravad ke masire j2 bar gharar bashad - ! pump flow rate2 be sharti be samte well miravad ke masire j12 bar gharar bashad - ! pump flow rate3 be sharti be samte well miravad ke masire j13 bar gharar bashad - - !G: PumpsToString Coefficient - !Jj2,Jj12,Jj13: TanksToMudPump Coefficient - !H: Pumps To Tank_Through65 or 67 Coefficient - ! - !write(*,*) 'jj2=' , jj2 - !write(*,*) 'jj12=' , jj12 - !write(*,*) 'jj13=' , jj13 - !write(*,*) 'H82=' , H82 - !write(*,*) 'H83=' , H83 - !write(*,*) 'H84=' , H84 - !write(*,*) 'DumpPump1=' , DumpPump1 - !write(*,*) 'DumpPump2=' , DumpPump2 - !write(*,*) 'DumpCementPump=' , DumpCementPump - !write(*,*) 'G82=' , G82 - !write(*,*) 'G83=' , G83 - !write(*,*) 'G84=' , G84 - !write(*,*) 'Mp1Density=' , Mp1Density - !write(*,*) 'Mp2Density=' , Mp2Density - !write(*,*) 'Mp3Density=' , Mp3Density - ! - ! - - - - !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate - - Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*N82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*PUMP(3)%Flow_Rate) - - if (Denominator /= 0.) then - MudSystem%Suction_Density_PumpsToWell= (jj2*(1.-H82)*(1.-DumpPump1)*N82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & - Denominator - endif - - - - - - MUD(10)%Q= jj2*(1-H82)*(1-DumpPump1)*N82*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*N83*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*N84*PUMP(3)%Flow_Rate - - - - - - - endif - - if (j19 == 0) then ! for normal circulation input - MUD(10)%Q=0.0 - !PumpPressure1= 0.0 - !PumpPressure2= 0.0 - !PumpPressure3= 0.0 - endif -!=========================================================================================================================== -!=========================================================================================================================== - - - -!AnnulusFlowRateFinal = 0.d0 ! this is a reset for calculated flow rate in UTUBES,TRIPIN,TRIPOUT codes - - - - - - - - - - - - - -!!====================================================================== -!! Well Head Condition Determination -!!====================================================================== - - - if ( MudSystem%WellToChokeManifoldOpen .or. MudSystem%WellToPitsOpen) then - MudSystem%WellHeadIsOpen= .true. - else - MudSystem%WellHeadIsOpen= .false. - endif - - - - - - - -!!====================================================================== -!! WARNINGS -!!====================================================================== - - - IF (Manifold%Valve(65)%Status == .TRUE.) call Activate_Pump1PopOffValveBlown() !Pump1PopOffValveBlown= .TRUE. - IF (Manifold%Valve(66)%Status == .TRUE.) call Activate_Pump2PopOffValveBlown() ! Pump2PopOffValveBlown= .TRUE. - IF (Manifold%Valve(67)%Status == .TRUE.) call Activate_Pump3PopOffValveBlown() !Pump2PopOffValveBlown= .TRUE. - - - IF (MudSystem%ActiveTankVolume >= (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)) THEN - MudSystem%ActiveTankVolume = (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) - call Activate_ActiveTankOverflow() - ELSE - call Deactivate_ActiveTankOverflow() - ENDIF - - - -!!====================================================================== -!! UPDATING TANKS DENSITIES & Volumes FOR MUD CIRCULATION -!!====================================================================== - - !write(*,*) 'ReserveTankVolume=' , real(ReserveTankVolume) - - call Set_ActiveMudVolume_StudentStation(real(MudSystem%ActiveTankVolume/42.,8)) ! 42: gal to bbl - call Set_ActiveDensity_StudentStation(real(MudSystem%ActiveTankDensity,8)) - call Set_ReserveMudVolume_StudentStation(real(MudSystem%ReserveTankVolume/42.,8)) ! 42: gal to bbl - call Set_ReserveDensity_StudentStation(real(MudSystem%ReserveTankDensity,8)) - DrillingWatch%KillMudVolume= MudSystem%ReserveTankVolume/42. ! for DrillWatch - !PitGainLose= - - -!!====================================================================== -!! DRILLING DATA DISPLAY -!!====================================================================== - - - IF (DataDisplayConsole%TotalStrokeCounterResetSwitch == 1) then !for drilling data display - MudSystem%TotalStrokesPump1=0. - MudSystem%TotalStrokesPump2=0. - ENDIF - - MudSystem%TotalStrokesPump1=MudSystem%TotalStrokesPump1+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display - MudSystem%TotalStrokesPump2=MudSystem%TotalStrokesPump2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display - MudSystem%GraphTotalStrokes=MudSystem%GraphTotalStrokes+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline - - - MPumps%Total_Stroke_Counter_For_Plot = MPumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * MudSystem%DeltaT_Mudline - - ! CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot)) - - DataDisplayConsole%TotalStrokeCounter= real(nint(MudSystem%TotalStrokesPump1+MudSystem%TotalStrokesPump2)) !for drilling data display - -!=========================================================================== -! MUD PUMP STROKES -! & TOTAL STROKE- CHOKE CONTROL PANEL -!=========================================================================== - !write(*,*) 'a)))' , ChokePanelStrokeResetSwitch - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - IF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN - !write(*,*) '1 reset' - Choke%TotalStrokes1 =0. - elseif (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN - !write(*,*) '2 reset' - Choke%TotalStrokes2 =0. - else - !write(*,*) 'both reset' - - Choke%TotalStrokes1 =0. - Choke%TotalStrokes2 =0. - endif - endif - - !write(*,*) 'b)))' , ChokePanelStrokeResetSwitch - - - Choke%TotalStrokes1= Choke%TotalStrokes1+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline - Choke%TotalStrokes2= Choke%TotalStrokes2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline - - - - IF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN - ChokeControlPanel%ChokePanelSPMCounter = real(nint(DataDisplayConsole%MP1SPMGauge)) - ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes1)) - ELSEIF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN - ChokeControlPanel%ChokePanelSPMCounter = real(nint(DataDisplayConsole%MP2SPMGauge)) - ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes2)) - ELSE - ChokeControlPanel%ChokePanelSPMCounter= real(nint(DataDisplayConsole%MP1SPMGauge+DataDisplayConsole%MP2SPMGauge)) - ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes1+Choke%TotalStrokes2)) - ENDIF - - ! ChokePanelStrokeResetSwitch = 0 -!====================================================================== - -!!====================================================================== -!! MUD VOLUME TOTALIZER DISPLAY VALUES -!!====================================================================== - - - DrillingWatch%PitVolume= MudSystem%ActiveTankVolume/42.d0 !(bbl) For DrillWatch Display - - !write(*,*) 'PitVolume,ActiveTankVolume=' ,PitVolume,ActiveTankVolume - - - MudSystem%MudTank1_vol= MudSystem%ActiveTankVolume/3. ! (gal) - MudSystem%MudTank2_vol= MudSystem%ActiveTankVolume/3. ! (gal) - MudSystem%MudTank3_vol= MudSystem%ActiveTankVolume/3. ! (gal) - MudSystem%MudTank4_vol= MudSystem%TripTankVolumeCalc - - - - - - IF (DataDisplayConsole%MVTPowerSwitch==1) THEN - DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%MudTanksVolumeGaugeMalf) *((MudSystem%MudTank1_vol*DataDisplayConsole%MudTank1Switch)+(MudSystem%MudTank2_vol*DataDisplayConsole%MudTank2Switch)+ & - (MudSystem%MudTank3_vol*DataDisplayConsole%MudTank3Switch)+(MudSystem%MudTank4_vol*DataDisplayConsole%MudTank4Switch)+MudSystem%ActiveTankSettled) !(gal) - ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN - DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%MudTanksVolumeGaugeMalf) *0. - ENDIF - -!!====================================================================== -!! MUD VOLUME TOTALIZER -!!====================================================================== - - - - - ! IF (DataDisplayConsole%MVTPowerSwitch==1 .and. IsPortable==.false.) THEN - - - - ! IF (DataDisplayConsole%MVTSetAlarmSwitch==0) THEN - - ! DataDisplayConsole%PitGainLossGauge= ( ((ActiveTankVolume/42.) - RefrencePitVolume)) - PitGainLossGaugeMalf*(( ((ActiveTankVolume/42.) - RefrencePitVolume))+50) !(bbl) - - ! ELSEIF (DataDisplayConsole%MVTSetAlarmSwitch==-1) THEN - - - ! MVT_MinVol_Allowded= PitGainLossZero+ MIN(0.,(DataDisplayConsole%MVTSetAlarmLowKnob-50))-0.1 - ! DataDisplayConsole%PitGainLossGauge= MVT_MinVol_Allowded - PitGainLossGaugeMalf*(MVT_MinVol_Allowded+50) - ! ! - PitGainLossGaugeMalf*(MVT_MinVol_Allowded+50) : Malf effect - ! !PitGainLose=(MVT_MinVol_Allowded) ! DrillWatch (incorrect) - ! !RefrencePitVolume= ActiveTankVolume/42. !(bbl) - - ! ELSE !(MVTSetAlarmSwitch==1) - - ! MVT_MaxVol_Allowded= PitGainLossZero+ MAX(0., (DataDisplayConsole%MVTSetAlarmHighKnob-50.))+0.1 - ! DataDisplayConsole%PitGainLossGauge= MVT_MaxVol_Allowded - PitGainLossGaugeMalf*(MVT_MaxVol_Allowded+50) - ! ! - PitGainLossGaugeMalf*(MVT_MaxVol_Allowded+50) : Malf effect - ! !PitGainLose=(MVT_MaxVol_Allowded) ! DrillWatch (incorrect) - ! !RefrencePitVolume= ActiveTankVolume/42. !(bbl) - ! ENDIF - - ! !PitGainLossZero_Old= PitGainLossZero - ! !MVTCoarseKnob_Old= MVTCoarseKnob - ! !MVTFineKnob_Old= MVTFineKnob - ! !FirstSet_Time= .false. - - - - ! IF ( ActiveTankVolume/42. < (RefrencePitVolume-ABS(MVT_MinVol_Allowded)) .OR. ActiveTankVolume/42. > (RefrencePitVolume+ABS(MVT_MaxVol_Allowded)) ) THEN - - ! DataDisplayConsole%MVTAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%MVTHornSwitch) THEN - ! DataDisplayConsole%Buzzer2= .TRUE. - ! ELSE - ! DataDisplayConsole%Buzzer2= .FALSE. - ! ENDIF - - ! ELSE - ! DataDisplayConsole%MVTAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer2= .false. - ! ENDIF - - - - ! ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN - ! !MudTanksVolumeGauge= 0. - ! DataDisplayConsole%PitGainLossGauge= -50 - ! DataDisplayConsole%MVTAlarmLED= 0 - ! DataDisplayConsole%Buzzer2= .false. - - - ! ENDIF - -!!====================================================================== -!! RETURN CALCULATIONS -!!====================================================================== - - - - - DrillingWatch%PercentFlow= (MudSystem%ReturnFlowRate/MudSystem%PedalMeter) *100. !(percent) ! for DrillWatch display - if (abs(DrillingWatch%PercentFlow - unityreturn) > 1.0) then - - write(*,*) 'PercentFlow,ReturnFlowRate,PedalMeter=' , DrillingWatch%PercentFlow,MudSystem%ReturnFlowRate,MudSystem%PedalMeter - write(*,*) 'unityreturn=' , unityreturn - endif - - - ! ReturnFlowRate=800. set in startup as initial value - MudSystem%ReturnFlowPercent= (MudSystem%ReturnFlowRate/MudSystem%PedalMeter) *100. !(percent) - !write(*,*) 'ReturnFlowPercent,ReturnFlowRate=' , ReturnFlowPercent,ReturnFlowRate - ! if ReturnFlowRate>PedalMeter, excess value(ReturnFlowRate-PedalMeter) is dumped in the code before - - -!!====================================================================== -!! DRILL WATCH -!!====================================================================== - - DrillingWatch%PitGainLose= ((MudSystem%ActiveTankVolume/42.) - MudSystem%RefrencePitVolume_DrillWatch) ! DrillWatch - !write(*,*) 'PitGainLose galon' , PitGainLose*42. - - - ! if (IsPortable) then - - ! MVT_MinVol_Allowded= DataDisplayConsole%PitAlarmLow - ! MVT_MaxVol_Allowded= DataDisplayConsole%PitAlarmHigh - - ! IF ( ActiveTankVolume/42. < (RefrencePitVolume-ABS(MVT_MinVol_Allowded)) .OR. ActiveTankVolume/42. > (RefrencePitVolume+ABS(MVT_MaxVol_Allowded)) ) THEN - - ! DataDisplayConsole%MVTAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%MVTHornSwitch) THEN - ! DataDisplayConsole%Buzzer2= .TRUE. - ! ELSE - ! DataDisplayConsole%Buzzer2= .FALSE. - ! ENDIF - - ! ELSE - ! DataDisplayConsole%MVTAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer2= .false. - ! ENDIF - - ! endif - - - if (StudentStation%PitGainLossZero) then - DrillingWatch%PitGainLose= 0.d0 !DrillWatch - MudSystem%RefrencePitVolume_DrillWatch= MudSystem%ActiveTankVolume/42. !(bbl) !DrillWatch - !********************************************* - DataDisplayConsole%PitGainLossGauge= 0. !MFF Indicator - MudSystem%RefrencePitVolume= MudSystem%ActiveTankVolume/42. !(bbl) !MFF Indicator - endif -!!====================================================================== -!! MUD FLOW-FILL INDICATOR -!!====================================================================== - IF (DataDisplayConsole%MFFIPowerSwitch==1 ) THEN !.and. IsPortable==.false. -!====================TotalStrokes Reset and Calculate====================== - if (DataDisplayConsole%MFFIResetTotalStrokes == 1) then - IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN - MudSystem%TotalStrokes1MFFI =0. - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN - MudSystem%TotalStrokes2MFFI =0. - else - MudSystem%TotalStrokes1MFFI =0. - MudSystem%TotalStrokes2MFFI =0. - endif - endif - MudSystem%TotalStrokes1MFFI= MudSystem%TotalStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline - MudSystem%TotalStrokes2MFFI= MudSystem%TotalStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline - -!==================FillStrokes Reset and Calculate========================= - if (DataDisplayConsole%MFFIResetFillCounter == 1) then - IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN - MudSystem%TotalFillStrokes1MFFI =0. - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN - MudSystem%TotalFillStrokes2MFFI =0. - else - MudSystem%TotalFillStrokes1MFFI =0. - MudSystem%TotalFillStrokes2MFFI =0. - endif - endif - - - MudSystem%TotalFillStrokes1MFFI= MudSystem%TotalFillStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline - MudSystem%TotalFillStrokes2MFFI= MudSystem%TotalFillStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline -!=================================================================== - - - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI)) !TotalStroke LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes2MFFI)) !TotalStroke LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI+MudSystem%TotalStrokes2MFFI)) !TotalStroke LED - endif - - - IF (DataDisplayConsole%MFFIFillSPMSelectorSwitch== .false.) THEN !(spm mode) - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = real(nint(DataDisplayConsole%MP1SPMGauge)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = real(nint(DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= real(nint(DataDisplayConsole%MP1SPMGauge+DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED - endif - - ELSE ! (MFFIFillSPMSelectorSwitch== .true.) then !(fill mode) - if (MudSystem%ReturnFlowRate== 0) then - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes1MFFI)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED - endif - - - MudSystem%TotalFilledStrokesBy1MFFI = real(nint(MudSystem%TotalFillStrokes1MFFI))! for values=fix on LED after the well filled - MudSystem%TotalFilledStrokesBy2MFFI = real(nint(MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled - MudSystem%TotalFilledStrokesBy1and2MFFI= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled - - - - else !(ReturnFlowRate>0) - - ! these values=fix on LED after the well filled - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = MudSystem%TotalFilledStrokesBy1MFFI !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = MudSystem%TotalFilledStrokesBy2MFFI !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= MudSystem%TotalFilledStrokesBy1and2MFFI !Fill or SPM LED - endif - endif - - - ENDIF - - - - !=================================================================================== - - - - - if (MudSystem%ReturnFlowRate>0) then - DataDisplayConsole%MFFIPumpLED=1 !(Returns Lamp) - else - DataDisplayConsole%MFFIPumpLED=0 !(Returns Lamp) - endif - - - - IF (DataDisplayConsole%MFFISetAlarmSwitch==0) THEN - - DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%ReturnFlowPercent !(percent) - - ELSEIF (DataDisplayConsole%MFFISetAlarmSwitch==-1) THEN - MudSystem%MFFI_MinPercent_Allowded=DataDisplayConsole%MFFISetAlarmLowKnob - DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MinPercent_Allowded - - ELSE !(MFFISetAlarmSwitch==1) - - MudSystem%MFFI_MaxPercent_Allowded=DataDisplayConsole%MFFISetAlarmHighKnob - DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MaxPercent_Allowded - ENDIF - - - IF (MudSystem%ReturnFlowPercentMudSystem%MFFI_MaxPercent_Allowded) THEN - !write(*,*) 'alarm return:' , ReturnFlowRate - DataDisplayConsole%MFFIAlarmLED = 2 !(blinking) - IF (DataDisplayConsole%MFFIHornSwitch) THEN - DataDisplayConsole%Buzzer3= .true. - ELSE - DataDisplayConsole%Buzzer3= .FALSE. - ENDIF - ELSE - DataDisplayConsole%MFFIAlarmLED = 0 !(OFF) - DataDisplayConsole%Buzzer3= .false. - ENDIF - !=================================================================================== - - - ELSEIF (DataDisplayConsole%MFFIPowerSwitch==0) THEN - DataDisplayConsole%ReturnMudFlowGauge= 0. - DataDisplayConsole%FillStrokeCounter= 0 - DataDisplayConsole%MFFITotalStrokeCounter= 0 - DataDisplayConsole%MFFIAlarmLED= 0 - DataDisplayConsole%Buzzer3= .false. - ENDIF - - - ! if ( IsPortable ) then - - ! MFFI_MinPercent_Allowded=DataDisplayConsole%RetFlowAlarmLow - ! MFFI_MaxPercent_Allowded=DataDisplayConsole%RetFlowAlarmHigh - - - ! IF (ReturnFlowPercentMFFI_MaxPercent_Allowded) THEN - - ! DataDisplayConsole%MFFIAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%MFFIHornSwitch) THEN - ! DataDisplayConsole%Buzzer3= .true. - ! ELSE - ! DataDisplayConsole%Buzzer3= .FALSE. - ! ENDIF - ! ELSE - ! DataDisplayConsole%MFFIAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer3= .false. - ! ENDIF - - ! endif - - -!!====================================================================== -!! TRIP TANK PANEL DISPLAY VALUES -!!====================================================================== - - Tank%TripTankVolume = MudSystem%TripTankVolumeCalc/42. !(Drill Watch display) - Tank%TripTankDensity= MudSystem%TripTankDensityCalc !(display) - - - IF (DataDisplayConsole%TripTankPowerSwitch==1 ) THEN !.and. IsPortable==.false. - - IF (DataDisplayConsole%TripTankSetAlarmSwitch==0) THEN - - DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTankVolumeCalc ! (gal) - ELSEIF (DataDisplayConsole%TripTankSetAlarmSwitch==-1) THEN - - MudSystem%TripTank_MinVol_Allowded= DataDisplayConsole%TripTankSetAlarmLow/2. ! 2: because knob input is 0-100 but gauge is 0-50 - DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MinVol_Allowded - - ELSE !(TripTankSetAlarmSwitch==1) - MudSystem%TripTank_MaxVol_Allowded= DataDisplayConsole%TripTankSetAlarmHigh/2. ! 2: because knob input is 0-100 but gauge is 0-50 - DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MaxVol_Allowded - ENDIF - - - - IF ((MudSystem%TripTankVolumeCalc < MudSystem%TripTank_MinVol_Allowded) .OR. (MudSystem%TripTankVolumeCalc > MudSystem%TripTank_MaxVol_Allowded)) THEN - DataDisplayConsole%TripTankAlarmLED = 2 !(blinking) - IF (DataDisplayConsole%TripTankHornSwitch) THEN - DataDisplayConsole%Buzzer1= .true. - ELSE - DataDisplayConsole%Buzzer1= .false. - ENDIF - ELSE - DataDisplayConsole%TripTankAlarmLED = 0 !(OFF) - DataDisplayConsole%Buzzer1= .false. - ENDIF - - DataDisplayConsole%TripTankPumpLED= DataDisplayConsole%TripTankPumpSwitch - - - ELSEIF (DataDisplayConsole%TripTankPowerSwitch==0) THEN - DataDisplayConsole%TripTankGauge= 0. !(gal) - DataDisplayConsole%TripTankAlarmLED= 0 - DataDisplayConsole%TripTankPumpLED= 0 - DataDisplayConsole%Buzzer1= .false. - ENDIF - - - ! if ( IsPortable ) then - - ! TripTank_MinVol_Allowded= DataDisplayConsole%TripAlarmLow - ! TripTank_MaxVol_Allowded= DataDisplayConsole%TripAlarmHigh - - - ! IF ((TripTankVolumeCalc < TripTank_MinVol_Allowded) .OR. (TripTankVolumeCalc > TripTank_MaxVol_Allowded)) THEN - ! DataDisplayConsole%TripTankAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%TripTankHornSwitch) THEN - ! DataDisplayConsole%Buzzer1= .true. - ! ELSE - ! DataDisplayConsole%Buzzer1= .false. - ! ENDIF - ! ELSE - ! DataDisplayConsole%TripTankAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer1= .false. - ! ENDIF - - ! endif - - - - - !write(*,*) '=====================================================================' - - - - ! if (IsStopped) return - - end subroutine main - - - - - !=================================================================================================================== - !=================================================================================================================== - !=================================================================================================================== - - subroutine ActiveMudVolumeChanged(v) - !use CLog4 - implicit none - real(8), intent (in) :: v - !call Log_4('ActiveMudVolumeChanged=', v) - MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! update from student input - end subroutine - - subroutine ActiveDensityChanged(v) - !use CLog4 - implicit none - real(8), intent (in) :: v - !call Log_4('ActiveDensityChanged=', v) - MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! update from student input - end subroutine - - subroutine ReserveMudVolumeChanged(v) - !use CLog4 - implicit none - real(8), intent (in) :: v - !call Log_4('ReserveMudVolumeChanged=', v) - MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! update from student input - end subroutine - - subroutine ReserveDensityChanged(v) - !use CLog4 - implicit none - real(8), intent (in) :: v - !call Log_4('ReserveDensityChanged=', v) - MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! update from student input - end subroutine - - ! subroutine SetupMudSystem() - ! ! use CPathChangeEvents - ! use CMudPropertiesVariables - ! implicit none - - ! call BeforeTraverse%Add(InitialVarsBeforePathsChanges) - ! call AfterTraverse%Add(AfterPathsChanges) - ! call OnPathOpen%Add(WhenPathOpen) - - - ! call OnActiveMudVolumeChange%Add(ActiveMudVolumeChanged) - ! call OnActiveDensityChange%Add(ActiveDensityChanged) - ! call OnReserveMudVolumeChange%Add(ReserveMudVolumeChanged) - ! call OnReserveDensityChange%Add(ReserveDensityChanged) - - ! end subroutine - - subroutine AfterPathsChanges() - implicit none - integer i - - if(Pump1_Lasts%Length() <= 0) return - do i = 1, Pump1_Lasts%Length() - if(Pump2_Lasts%Length() <= 0) cycle - if(any(Pump2_Lasts%Array == Pump1_Lasts%Array(i))) then - State2 = .true. ! Pumps 1 & 2 have same destination - !print*, 'State2 = .true.' - endif - if(Pump3_Lasts%Length() <= 0) cycle - if(any(Pump3_Lasts%Array == Pump1_Lasts%Array(i))) then - State3 = .true. ! Pumps 1 & 3 have same destination - !print*, 'State3 = .true.' - endif - enddo - - if(Pump2_Lasts%Length() <= 0) return - do i = 1, Pump2_Lasts%Length() - if(Pump3_Lasts%Length() <= 0) cycle - if(any(Pump3_Lasts%Array == Pump2_Lasts%Array(i))) then - State4 = .true. ! Pumps 2 & 3 have same destination - !print*, 'State4 = .true.' - endif - enddo - - State1 = State2 .and. State3 ! Pumps 1 & 2 & 3 have same destination - !if(State1) print*, 'State1 = .true.' - - end subroutine - - subroutine InitialVarsBeforePathsChanges() - implicit none - - condition1 = .false. - condition2 = .false. - condition3 = .false. - condition4 = .false. - condition5 = .false. - condition6 = .false. - condition7 = .false. - condition8 = .false. - condition9 = .false. - condition10 = .false. - condition11 = .false. - condition12 = .false. - condition13 = .false. - condition14 = .false. - condition15 = .false. - condition16 = .false. - condition17 = .false. - condition18 = .false. - condition19 = .false. - condition20 = .false. - condition21 = .false. - condition22 = .false. - condition23 = .false. - condition24 = .false. - condition25 = .false. - condition26 = .false. - condition27 = .false. - condition28 = .false. - condition29 = .false. - condition30 = .false. - condition31 = .false. - condition32 = .true. - condition33 = .true. - condition34 = .true. - condition35 = .false. - condition36 = .false. - condition37 = .false. - condition38 = .false. - condition39 = .false. - condition40 = .false. - condition41 = .false. - condition42 = .false. - condition43 = .false. - condition44 = .false. - condition45 = .false. - condition46 = .false. - condition47 = .false. - condition48 = .false. - condition49 = .false. - condition50 = .false. - condition51 = .false. - condition52 = .false. - condition53 = .false. - condition54 = .false. - condition55 = .false. - condition56 = .false. - condition57 = .false. - condition58 = .false. - condition59= .false. - condition60= .false. - condition61= .false. - - - - - - - - !ThereIsPathFrom82 = .false. - !!print*, "ThereIsPathFrom82=",ThereIsPathFrom82 - !ThereIsPathFrom83 = .false. - !!print*, "ThereIsPathFrom82=",ThereIsPathFrom82 - !ThereIsPathFrom84 = .false. - !!print*, "ThereIsPathFrom82=",ThereIsPathFrom82 - - ThereIsPathFrom_71_72_73_To_82 = .false. - !print*, "ThereIsPathFrom_71_72_73_To_82=",ThereIsPathFrom_71_72_73_To_82 - ThereIsPathFrom_71_72_73_To_83 = .false. - !print*, "ThereIsPathFrom_71_72_73_To_83=",ThereIsPathFrom_71_72_73_To_83 - ThereIsPathFrom_71_72_73_To_84 = .false. - !print*, "ThereIsPathFrom_71_72_73_To_84=",ThereIsPathFrom_71_72_73_To_84 - - DumpFromKelly_Pump1 = .false. - DumpFromFillupHead_Pump1 = .false. - DumpFromTopDrive_Pump1 = .false. - - - DumpFromKelly_Pump2 = .false. - DumpFromFillupHead_Pump2 = .false. - DumpFromTopDrive_Pump2 = .false. - - - DumpFromKelly_Pump3 = .false. - DumpFromFillupHead_Pump3 = .false. - DumpFromTopDrive_Pump3 = .false. - - - - State1 = .false. - State2 = .false. - State3 = .false. - State4 = .false. - - call Pump1_Lasts%Empty() - call Pump2_Lasts%Empty() - call Pump3_Lasts%Empty() - - - - - - ac32 = .false. - ac33 = .false. - ac34 = .false. - ac35 = .false. - ac29 = .false. - - end subroutine - - subroutine WhenPathOpen(valves) - use Pumps_VARIABLES - implicit none - integer, allocatable, intent (in) :: valves(:) - integer :: first, last - if (.not.allocated(valves)) return - if(size(valves) <= 0) return - - if ( any(valves == 32)) ac32 = .true. - if ( any(valves == 33)) ac33 = .true. - if ( any(valves == 34)) ac34 = .true. - if ( any(valves == 35)) ac35 = .true. - if ( any(valves == 29)) ac29 = .true. - - - first = 1 - last = size(valves) - - MP1_Q = PUMP(1)%Flow_Rate - MP2_Q = PUMP(2)%Flow_Rate - MP3_Q = PUMP(3)%Flow_Rate - - - - if(valves(first) == 82) call Pump1_Lasts%Add(valves(last)) - if(valves(first) == 83) call Pump2_Lasts%Add(valves(last)) - if(valves(first) == 84) call Pump3_Lasts%Add(valves(last)) - - !print*, '==============================================' - !do i = 1, Pump1_Lasts%Length() - ! print*, 'mp1=', Pump1_Lasts%Array(i) - !enddo - ! - !print*, '-------------------------------' - ! - !do i = 1, Pump2_Lasts%Length() - ! print*, 'mp2=', Pump2_Lasts%Array(i) - !enddo - ! - !print*, '-------------------------------' - ! - ! - !do i = 1, Pump3_Lasts%Length() - ! print*, 'mp3=', Pump3_Lasts%Array(i) - !enddo - ! - !print*, '==============================================' - - - !if(valves(first)==82 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71)) then - ! ThereIsPathFrom82 = .true. - ! !print*, "ThereIsPathFrom82=",ThereIsPathFrom82 - !endif - ! - !if(valves(first)==83 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71)) then - ! ThereIsPathFrom83 = .true. - ! !print*, "ThereIsPathFrom83=",ThereIsPathFrom83 - !endif - ! - !if(valves(first)==84 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71)) then - ! ThereIsPathFrom84 = .true. - ! !print*, "ThereIsPathFrom84=",ThereIsPathFrom84 - !endif - - if(valves(last)==82 .and. (valves(first)==71 .or. valves(first)==72 .or. valves(first)==73)) then - ThereIsPathFrom_71_72_73_To_82 = .true. - !print*, "ThereIsPathFrom_71_72_73_To_82=",ThereIsPathFrom_71_72_73_To_82 - endif - - if(valves(last)==83 .and. (valves(first)==71 .or. valves(first)==72 .or. valves(first)==73)) then - ThereIsPathFrom_71_72_73_To_83 = .true. - !print*, "ThereIsPathFrom_71_72_73_To_83=",ThereIsPathFrom_71_72_73_To_83 - endif - - if(valves(last)==84 .and. (valves(first)==71 .or. valves(first)==72 .or. valves(first)==73)) then - ThereIsPathFrom_71_72_73_To_84 = .true. - !print*, "ThereIsPathFrom_71_72_73_To_84=",ThereIsPathFrom_71_72_73_To_84 - endif - - !if (.not.allocated(OpenPaths)) exit - !===============TanksToMudPump1=================== - if(valves(last)==82) then - if(valves(first)==71) then - !j2=j2+1 - !A71=1 - condition1 = .true. - endif - - if(valves(first)==72) then - !j2=j2+1 - !A72=1 - condition2 = .true. - endif - - if(valves(first)==73) then - !j2=j2+1 - !A73=1 - condition3 = .true. - endif - - endif - !================================================ - - - !============BellNippleToPits-FullWell(MLnumber=3)============== - - if ( Manifold%Valve(41)%Status == .false. .and. Manifold%Valve(42)%Status == .false. ) then - call ChangeValve(60, .TRUE.) - else - call ChangeValve(60, .FALSE.) - endif - - if(valves(first)==80 .and. valves(last)==71 .and. any(valves == 42)) condition4 = .true. - if(valves(first)==80 .and. valves(last)==77 .and. any(valves == 41)) condition5 = .true. - if(valves(first)==80 .and. valves(last)==78) condition6 = .true. - - !================================================ - - - !============WellToChokeManifold(Through 26)============== - if(valves(first)==79 .and. any(valves == 26)) then - if(valves(last)==71) then - !j4=j4+1 - !C71=1. - condition7 = .true. - endif - - if(valves(last)==77) then - !j4=j4+1 - !C77=1. - condition8 = .true. - endif - - if(valves(last)==78) then - !j4=j4+1 - !C78=1. - condition45 = .true. - endif - - endif - - !================================================ - - - !============ActiveTankToTripTank============== - if(valves(first)==71 .and. valves(last)==77) then - !j5=j5+1 - condition9 = .true. - endif - !================================================ - - - - !============TripTankToActiveTank And BellNipple============== - if(valves(first)==77) then - if(valves(last)==71) then - !j6=j6+1 - !D71=1 - condition10 = .true. - endif - - if(valves(last)==80) then - !j6=j6+1 - !D80=1 - condition11 = .true. - endif - - endif - !================================================ - - - !============ActiveTankToDump============== - if(valves(first)==71 .and. valves(last)==78) then - !j7=j7+1 - condition12 = .true. - endif - !================================================ - - - !============TripTankToDump============== - if(valves(first)==77 .and. valves(last)==78) then - !j8=j8+1 - condition13 = .true. - endif - !================================================ - - - !============WellToBellNipple============== - if(valves(first)==79 .and. valves(last)==80) then - !j9=j9+1 - condition14 = .true. - endif - !================================================ - - !============MudBucketToBellNipple============== - if(valves(first)==81 .and. valves(last)==80) then - !j10=j10+1 - condition15 = .true. - endif - !================================================ - - - !============BellNippleToWell-NonFullWell============== - if(valves(first)==80 .and. valves(last)==79) then ! Well is NOT Full - !j11=j11+1 - condition16 = .true. - endif - !================================================ - - !===============TanksToMudPump2=================== - if(valves(last)==83) then - if(valves(first)==71) then - !j12=j12+1 - !E71=1 - condition17 = .true. - endif - - if(valves(first)==72) then - !j12=j12+1 - !E72=1 - condition18 = .true. - endif - - if(valves(first)==73) then - !j12=j12+1 - !E73=1 - condition19 = .true. - endif - - endif - !================================================ - - - !===============TanksToCementPump=================== - if(valves(last)==84) then - if(valves(first)==71) then - !j13=j13+1 - !F71=1 - condition20 = .true. - endif - - if(valves(first)==72) then - !j13=j13+1 - !F72=1 - condition21 = .true. - endif - - if(valves(first)==73) then - !j13=j13+1 - !F73=1 - condition22 = .true. - endif - - endif - !================================================ - - !===============PumpsToString=================== - if(valves(last)==79) then - if(valves(first)==82) then - !j14=j14+1 - !G82=1 - condition23 = .true. - endif - - if(valves(first)==83) then - !j14=j14+1 - !G83=1 - condition24 = .true. - endif - - if(valves(first)==84) then - !j14=j14+1 - !G84=1 - condition25 = .true. - endif - - endif - !================================================ - - - - - - !============MudPump1HasPath=================== - if(ThereIsPathFrom_71_72_73_To_82 .and. (valves(first)==82 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71))) then - !Mp1_NoPath= 0 - condition32 = .false. - endif - MudSystem%condition32Final = condition32 - !================================================ - - - !============MudPump2HasPath=================== - if(ThereIsPathFrom_71_72_73_To_83 .and. (valves(first)==83 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71))) then - !write(*,*) 'condition33 ******' - !Mp2_NoPath= 0 - condition33 = .false. - endif - MudSystem%condition33Final= condition33 - !================================================ - - - !============CementPumpHasNoPath=================== - if(ThereIsPathFrom_71_72_73_To_84 .and. (valves(first)==84 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71))) then - !Cp_NoPath= 1 - condition34 = .false. - endif - MudSystem%condition34Final = condition34 - !================================================ - - - - - !===============PumpsToDump=================== - !DumpFromKelly = 0.0 - !DumpFromFillupHead= 0.0 - - if(valves(last)==78) then - if(valves(first)==82) then - !DumpPump1=1 - condition26 = .true. - IF(any(valves == 56)) DumpFromKelly_Pump1 = .true. - IF(any(valves == 14)) DumpFromFillupHead_Pump1 = .true. - IF(any(valves == 70)) DumpFromTopDrive_Pump1 = .true. - - - endif - - - if(valves(first)==83) then - !DumpPump2=1 - print*, "THERE IS DUMP" - condition27 = .true. - IF(any(valves == 56)) DumpFromKelly_Pump2 = .true. - IF(any(valves == 14)) DumpFromFillupHead_Pump2 = .true. - IF(any(valves == 70)) DumpFromTopDrive_Pump2 = .true. - - endif - - - if(valves(first)==84) then - !DumpCementPump=1 - condition28 = .true. - IF(any(valves == 56)) DumpFromKelly_Pump3 = .true. - IF(any(valves == 14)) DumpFromFillupHead_Pump3 = .true. - IF(any(valves == 70)) DumpFromTopDrive_Pump3 = .true. - - endif - - ! DumpFromKelly - !if (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3) then - ! DumpFromKelly = 1.0 - !else - ! DumpFromKelly = 0.0 - !endif - - - ! DumpFromFillupHead - if (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3) then - DumpFromFillupHead = 1.0 - else - DumpFromFillupHead = 0.0 - endif - - endif - - - - !================================================ - - - !=======MudPumps1&2ToActiveTank_Through65&66========== - - ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> - - - if(valves(last)==71) then - if(valves(first)==82 .and. any(valves == 65)) then - !j15=j15+1 - !H82=1.0 - condition29 = .true. - endif - - if(valves(first)==83 .and. any(valves == 66)) then - !j15=j15+1 - !H83=1.0 - condition30 = .true. - endif - - endif - !================================================ - - !=======CementPumpToCementTank_Through67========== - - ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> - - - if(valves(last)==73 .and. valves(first)==84 .and. any(valves == 67)) then - - !H84=1.0 - condition31 = .true. - - endif - !================================================ - - - - !===============PathsToGauge75=================== - if(valves(last)==75) then - if(valves(first)==82) then !Pump1 to Gauge75 - !j16=j16+1 - !K82=1 - condition35 = .true. - endif - - if(valves(first)==83) then !Pump2 to Gauge75 - !j16=j16+1 - !K83=1 - condition36 = .true. - endif - - if(valves(first)==84) then !Pump3 to Gauge75 - !j16=j16+1 - !K84=1 - condition37 = .true. - endif - - if(valves(first)==79) then !String to Gauge75 - !j16=j16+1 - !K79=1 - condition38 = .true. - endif - - if(valves(first)==78) then !Dump to Gauge75 - !j16=j16+1 - !K78=1 - condition39 = .true. - endif - - endif - !================================================ - - !===============PathsToGauge76=================== - if(valves(last)==76) then - if(valves(first)==82) then !Pump1 to Gauge76 - !j17=j17+1 - !L82=1 - condition40 = .true. - endif - - if(valves(first)==83) then !Pump2 to Gauge76 - !j17=j17+1 - !L83=1 - condition41 = .true. - endif - - if(valves(first)==84) then !Pump3 to Gauge76 - !j17=j17+1 - !L84=1 - condition42 = .true. - endif - - if(valves(first)==79) then !String to Gauge76 - !j17=j17+1 - !L79=1 - condition43 = .true. - endif - - if(valves(first)==78) then !Dump to Gauge76 - !j17=j17+1 - !L78=1 - condition44 = .true. - endif - - endif - !================================================ - - - !====Pump1-StandPipeManifoldToChokeManifold-Through ChokeLine==== - if(valves(first)==82 .and. any(valves == 2)) then - if(valves(last)==71) then - !j18=j18+1 - !M71=1. - !Pump1toCh= 1. - condition46 = .true. - endif - - if(valves(last)==77) then - !j18=j18+1 - !M77=1. - !Pump1toCh= 1. - condition47 = .true. - endif - - if(valves(last)==78) then - !j18=j18+1 - !M78=1. - !Pump1toCh= 1. - condition48 = .true. - endif - - endif - !================================================================= - - - !====Pump2-StandPipeManifoldToChokeManifold-Through ChokeLine==== - if(valves(first)==83 .and. any(valves == 2)) then - if(valves(last)==71) then - !j18=j18+1 - !M71=1. - !Pump2toCh= 1. - condition49 = .true. - endif - - if(valves(last)==77) then - !j18=j18+1 - !M77=1. - !Pump2toCh= 1. - condition50 = .true. - endif - - if(valves(last)==78) then - !j18=j18+1 - !M78=1. - !Pump2toCh= 1. - condition51 = .true. - endif - - endif - !================================================================= - - - !====Pump3-StandPipeManifoldToChokeManifold-Through ChokeLine==== - if(valves(first)==84 .and. any(valves == 2)) then - if(valves(last)==71) then - !j18=j18+1 - !M71=1. - !Pump3toCh= 1. - condition52 = .true. - endif - - if(valves(last)==77) then - !j18=j18+1 - !M77=1. - !Pump3toCh= 1. - condition53 = .true. - endif - - if(valves(last)==78) then - !j18=j18+1 - !M78=1. - !Pump3toCh= 1. - condition54 = .true. - endif - - endif - !================================================================= - - - - - !===============PumpsToWell_KillLine============ - if(valves(last)==79) then - if(valves(first)==82) then - !j19=j19+1 - !N82=1 - condition55 = .true. - endif - - if(valves(first)==83) then - !j19=j19+1 - !N83=1 - condition56 = .true. - endif - - if(valves(first)==84) then - !j19=j19+1 - !N84=1 - condition57 = .true. - endif - - endif - !================================================ - - !===============WellToChokeLineGauge============ - if(valves(first)==79 .and. valves(last)==85) then - !j20=j20+1 - condition58 = .true. - endif - !================================================ - - - !============ChokeLineGaugeToTanks=============== - if(valves(first)==85) then - if(valves(last)==71) then - !j21=j21+1 - condition59 = .true. - endif - - if(valves(last)==77) then - !j21=j21+1 - condition60 = .true. - endif - - if(valves(last)==78) then - !j21=j21+1 - condition61 = .true. - endif - - endif - !================================================ - - end subroutine - -end module MudSystemModule \ No newline at end of file diff --git a/Equipments/MudSystem-old/MudSystemMain.f90 b/Equipments/MudSystem-old/MudSystemMain.f90 deleted file mode 100644 index f5a437e..0000000 --- a/Equipments/MudSystem-old/MudSystemMain.f90 +++ /dev/null @@ -1,85 +0,0 @@ -module MudSystemMain - implicit none - public - contains - - ! subroutine MudSystem_Setup() - ! ! use CSimulationVariables - ! use MudSystemModule - ! implicit none - ! call SetupMudSystem() - ! call OnSimulationStop%Add(MudSystem_Stop) - ! call OnMudSystemStart%Add(MudSystem_Start) - ! call OnMudSystemStep%Add(MudSystem_Step) - ! call OnMudSystemMain%Add(MudSystemMainBody) - ! end subroutine - - subroutine MudSystem_Stop - implicit none - !print* , 'MudSystem_Stop' - CALL DEALLOCATE_ARRAYS_MudSystem() - end subroutine MudSystem_Stop - - subroutine MudSystem_Init - implicit none - !print* , 'MudSystem_Start' - CALL MudSystem_StartUp() - end subroutine MudSystem_Init - - subroutine MudSystem_Step - use MudSystemModule - use CManifolds - implicit none - !print* , 'MudSystem_Step' - !CALL main - if(Manifold%IsTraverse) then - call LineupAndPath() - Manifold%IsTraverse = .false. - endif - call main() - end subroutine MudSystem_Step - - ! subroutine MudSystemMainBody - ! ! use CSimulationVariables - ! use MudSystemModule - ! implicit none - -! INTEGER :: MudDuration -! integer,dimension(8) :: MudStartTime , MudEndTime -! -!CALL MudSystem_StartUp() -! loop1: DO -! -! CALL DATE_AND_TIME(values=MudStartTime) -! !WRITE (*,*) '***MudSys_timeCounter', MudSys_timeCounter -! -! -! CALL main -! -! CALL DATE_AND_TIME(values=MudEndTime) -! -! MudDuration = 3600000 * (MudEndTime(5) - MudStartTime(5)) + 60000 * (MudEndTime(6) - MudStartTime(6)) + 1000 * (MudEndTime(7) - MudStartTime(7)) + (MudEndTime(8) - MudStartTime(8)) -! -! if (MudDuration < 100) then -! ELSE -! WRITE (*,*) 'Mud System run duration exceeded 100 ms and =', MudDuration -! end if -! -! IF (IsStopped==.true.) THEN -! EXIT loop1 -! ENDIF -! -! !CALL DATE_AND_TIME(values=FlowEndTime) -! !WRITE (*,*) 'FlowEndTime=' , FlowEndTime -! -! !FlowDuration = FlowEndTime(8) - FlowStartTime(8) -! -! !WRITE (*,*) 'FlowDuration Mud system=' , FlowDuration -! -! ENDDO loop1 -! -! CALL DEALLOCATE_ARRAYS_MudSystem() - - ! end subroutine MudSystemMainBody - -end module MudSystemMain \ No newline at end of file diff --git a/Equipments/MudSystem-old/MudSystemStartup.f90 b/Equipments/MudSystem-old/MudSystemStartup.f90 deleted file mode 100644 index f16b31d..0000000 --- a/Equipments/MudSystem-old/MudSystemStartup.f90 +++ /dev/null @@ -1,501 +0,0 @@ - SUBROUTINE NormalCirculation_StartUp() ! is called in module FluidFlowMain - - USE MudSystemVARIABLES - use CTanksVariables - USE CMudPropertiesVariables - Use GeoElements_FluidModule - use KickVARIABLESModule - Use CUnityOutputs - Use CShoeVariables - USE Pumps_VARIABLES - - implicit none - - ! temporary varibales for solving pressure jerks -- 1399-11-09 - !Pump1BlownInTimeStep = 0 - !Pump2BlownInTimeStep = 0 - !Pump3BlownInTimeStep = 0 - - !Pump1BlownStarted = .FALSE. - !Pump2BlownStarted = .FALSE. - !Pump3BlownStarted = .FALSE. - - MudSystem%Pump1BlownCount = 0 - MudSystem%Pump2BlownCount = 0 - MudSystem%Pump3BlownCount = 0 - - -MudSystem%DeltaWellCap=0. -MudSystem%WellCapOld = 0. -MudSystem%AnnCapOld=0. -MudSystem%DeltaAnnCap=0. - - -MPumps%Total_Stroke_Counter_For_Plot = 0.0 - - MudSystem%DeltaT_Mudline=0.1 !second - - Call Set_FlowKellyDisconnect(.false.) - Call Set_FlowPipeDisconnect(.false.) - -!HZ_ADD= 0.d0 -MudSystem%Flow_timeCounter= 0 -MudSystem%MudSys_timeCounter= 0 -MudSystem%FluidFlowCounter = 0 -!======================================================================== -! MUD CIRCULATION STARTUP -!======================================================================== - - MudSystem%FormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth - MudSystem%ShoeFractured= .false. - - MudSystem%UGBOSuccessionCounter = 0 ! also in starup - MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup - - - - MudSystem%ChokeLineFlowRate= 0.0 - MudSystem%StringFlowRate= 0.0 - MudSystem%AnnulusFlowRate= 0.0 - - MudSystem%MudVolume_InjectedFromAnn= 0.D0 - MudSystem%MudVolume_InjectedToBH= 0.D0 - - MudSystem%DensityMixTol= 0.1 !(ppg) - MudSystem%CuttingDensityMixTol= 0.5 - MudSystem%NewPipeFilling= 1 - MudSystem%UtubeFilling= 1 - MudSystem%UtubeEmptyVolume= 0.0 - - MudSystem%UtubeMode1Activated= .false. - MudSystem%UtubeMode2Activated= .false. - MudSystem%UtubePossibility= .false. - - - !KickMigration_2SideBit = .FALSE. - - MudSystem%KickDx= (Reservoir%AutoMigrationRate/3600.)*MudSystem%DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline - - - MudSystem%NewInfluxElementCreated= 0 - MudSystem%NewInfluxNumber= 0 - - !KickVolumeinAnnulus= 0.0 - MudSystem%KickDeltaVinAnnulus= 0.0 - GasKickPumpFlowRate= 0.0 - - MudSystem%FirstMudSet= 0 - MudSystem%FirstSetUtube1=0 - MudSystem%FirstSetUtube2=0 - MudSystem%SuctionMud=1 - MudSystem%ImudCount= 1 - imud=1 - MudSystem%iLoc= 1 ! for Kick - - MudSystem%Suction_Density_MudSystem= MudProperties%ActiveDensity - MudSystem%SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystem%StringDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystem%AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystem%ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - - MudSystem%TotalAddedVolume= 0. - - - MudSystem%xx=0. - - - - END SUBROUTINE NormalCirculation_StartUp - - - - - - - - SUBROUTINE MudSystem_StartUp() - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE CDataDisplayConsoleVariables - USE CHOKEVARIABLES - USE Pumps_VARIABLES - USE CBopStackVariables - USE CPumpsVariables - use CTanksVariables - use KickVARIABLESModule - implicit none - - - - - - CALL MUDLINE_LOSS_INPUTS() - -!MPumps%Total_Pump_GPM=10. ! Initial Value - MUD%Q=0. ! Initial Value - - MudSystem%Q_flow32=0. - MudSystem%Q_flow33=0. - MudSystem%Q_flow34=0. - MudSystem%Q_flow35=0. - - MudSystem%DeltaT_Mudline=0.1 !second - - GasKickPumpFlowRate= 0. - MudSystem%BellNippleVolume= 0. - MudSystem%BellNippleDensity= 0. - MudSystem%MudBucketVolume= 0. - MudSystem%MudBucketDensity= 0. - MudSystem%BellNippleDumpVolume= 0. - !BellNippleDumpRate= 0. - !BellNippleToPitsRate= 0.0 - MudSystem%MudChecked= .true. - - MudSystem%condition32Final= .TRUE. - MudSystem%condition33Final= .TRUE. - MudSystem%condition34Final= .TRUE. - - -MudSystem%PressureGauge75= 0.0 -MudSystem%PressureGauge76 = 0.0 - - -!!====================================================================== -!! TRIP TANK -!!====================================================================== - - MudSystem%TripTank_MinVol_Allowded= 50.*42. !(bbl to gal, initial value) - MudSystem%TripTank_MaxVol_Allowded= 50. *42. !(bbl to gal, initial value) - - -MudSystem%ActiveTankFloorArea= (MudProperties%ActiveTotalTankCapacityGal) / (7.48051948*100./12.) ! (ft^2) - Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 -MudSystem%TripTankFloorArea= (50.*42.) / (7.48051948*100./12.) ! (ft^2) - 50.*42.=Trip Tank Capacity in BBl*42= Gal , Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 - - - -MudSystem%TripTank_Vol= MudProperties%InitialTripTankMudVolumeGal !(gal) -MudSystem%TripTank_Dens= 1. -DataDisplayConsole%TripTankGauge=0. - - - -MudSystem%ReturnToTrip_Q= 1. -MudSystem%ActiveToTrip_Q= 1. - - -MudSystem%TripTankPump_Q= .8 - - -MudSystem%ReturnToTrip_Dens=1.0 ! ppg(lbm/gal) -MudSystem%ActiveToTrip_Dens=1.0 - -!!====================================================================== -!! MUD VOLUME TOTALIZER -!!====================================================================== - -MudSystem%Mp1Density= 0.0 !(VALVE82) -MudSystem%Mp2Density= 0.0 !(VALVE83) -MudSystem%Mp3Density= 0.0 !(VALVE84) - - -MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! initial volume (gal) -MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! initial - - - -MudSystem%CementTankVolumeCalc= Tank%CementTankVolume !movaghat--- initial volume (gal) -MudSystem%CementTankDensityCalc= Tank%CementTankDensity !movaghat--- initial - -MudSystem%PumpsDumpVolume=0.0 -MudSystem%PumpsDumpFlowRate= 0.0 - - - -MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! initial volume (gal) -MudSystem%RefrencePitVolume= MudSystem%ActiveTankVolume/42. !(bbl) -MudSystem%RefrencePitVolume_DrillWatch= MudSystem%ActiveTankVolume/42. !(bbl) - -MudSystem%MVT_MinVol_Allowded= 0. -MudSystem%MVT_MaxVol_Allowded= 0. - -MudSystem%MudTank1_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudSystem%MudTank2_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudSystem%MudTank3_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudSystem%ActiveTankSettled= MudProperties%ActiveSettledContentsGal ! (gal) -MudSystem%MudTank4_vol= MudProperties%InitialTripTankMudVolumeGal ! (gal) - -MudSystem%TripTankVolumeCalc= MudProperties%InitialTripTankMudVolumeGal ! initial volume (gal) -MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! initial(ppg) -MudSystem%TripTankDensityCalc= Tank%TripTankDensity ! initial(ppg) - -MudSystem%ChokeManifoldDumpVolume= 0.0 - -MudSystem%PitGainLossZero= 0. -MudSystem%PitGainLossZero_Old= MudSystem%PitGainLossZero -MudSystem%MVTCoarseKnob_Old= DataDisplayConsole%MVTCoarseKnob -MudSystem%MVTFineKnob_Old= DataDisplayConsole%MVTFineKnob -MudSystem%FirstSet_Time= .true. - - - -MudSystem%PedalMeter= MudProperties%PedalFlowMeter !1600. !(gpm) -MudSystem%ReturnFlowRate=0. - - - - MudSystem%TotalStrokes1MFFI =0. - MudSystem%TotalStrokes2MFFI =0. - - MudSystem%TotalStrokesPump1=0. - MudSystem%TotalStrokesPump2=0. - MudSystem%GraphTotalStrokes=0. - - - Choke%TotalStrokes1 =0. - Choke%TotalStrokes2 =0. - - - - - - - end - - - - - - - - - - - -SUBROUTINE MUDLINE_LOSS_INPUTS() -USE MudSystemVARIABLES -USE CBopStackVariables -USE CPumpsVariables -implicit none -INTEGER I - - - -!=========================================================================== -! MUDLINE MINOR LOSSES INPUT -!=========================================================================== - -MudSystem%NO_MudMinors=4 - -ALLOCATE (MudSystem%MudMinors(MudSystem%NO_MudMinors,4)) - -! ID(INCH) LF CV NOTE(BAR) DESCRIPTION -MudSystem%MudMinors(1,1)= PumpsSpecification%MudPump1Output -MudSystem%MudMinors(1,2:4)= (/1.5*8., 0., 0./) !elbow (MLnumber=1,,PumpsToString) -MudSystem%MudMinors(2,1)= PumpsSpecification%MudPump1Output -MudSystem%MudMinors(2,2:4)= (/1.5*6., 0., 0./) !elbow (MLnumber=2,,STGaugeToString) -MudSystem%MudMinors(3,1:4)= (/0., 0., 0., 0./) !elbow (MLnumber=3,,WellToPits) -MudSystem%MudMinors(4,1)= BopStackSpecification%ChokeLineId -MudSystem%MudMinors(4,2:4)= (/1.5*7., 0., 0./) !elbow (MLnumber=4,,WellToChokeManifold) - - - -ALLOCATE (MudSystem%MINORDIAMETER_MUDLINE(MudSystem%NO_MudMinors),MudSystem%AREAMINOR_MUDLINE(MudSystem%NO_MudMinors),MudSystem%LF_MUDLINE(MudSystem%NO_MudMinors),MudSystem%CV_MUDLINE(MudSystem%NO_MudMinors) & - ,MudSystem%NOTE_MUDLINE(MudSystem%NO_MudMinors)) - - - -DO I=1,MudSystem%NO_MudMinors - MudSystem%MINORDIAMETER_MUDLINE(I)=MudSystem%MudMinors(I,1) - MudSystem%LF_MUDLINE(I)=MudSystem%MudMinors(I,2) - MudSystem%CV_MUDLINE(I)=MudSystem%MudMinors(I,3) - MudSystem%NOTE_MUDLINE(I)=MudSystem%MudMinors(I,4) - - - MudSystem%AREAMINOR_MUDLINE(I)=PII*(MudSystem%MINORDIAMETER_MUDLINE(I)*0.0254)**2/4. !D(in), AREA(m^2) -ENDDO - -!=========================================================================== -! MUDLINE PIPNING LOSSES INPUT -!=========================================================================== -MudSystem%NO_PIPINGSMUDLINE=4 - -ALLOCATE (MudSystem%PIPINGS_MUDLINE(MudSystem%NO_PIPINGSMUDLINE,3)) - - ! ID(INCH) L(FEET) ROUGHNESS(MM)=e DESCRIPTION -MudSystem%PIPINGS_MUDLINE(1,1)= PumpsSpecification%MudPump1Output -MudSystem%PIPINGS_MUDLINE(1,2:3)= (/265., 0.03/) !(MLnumber=1,,PumpsToString) -MudSystem%PIPINGS_MUDLINE(2,1)= PumpsSpecification%MudPump1Output -MudSystem%PIPINGS_MUDLINE(2,2:3)= (/100., 0.03/) !(MLnumber=2,,STGaugeToString) -MudSystem%PIPINGS_MUDLINE(3,1:3)= (/0., 0., 0./) !(MLnumber=3,,WellToPits) -MudSystem%PIPINGS_MUDLINE(4,1)= BopStackSpecification%ChokeLineId -MudSystem%PIPINGS_MUDLINE(4,2)= BopStackSpecification%ChokeLineLength -MudSystem%PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold) - -MudSystem%Area_ChokeLineFt= PII*((BopStackSpecification%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2) -MudSystem%ChokeLine_VolumeCapacity= MudSystem%Area_ChokeLineFt* BopStackSpecification%ChokeLineLength* 7.48051948 ! (gal) - - ALLOCATE (MudSystem%DIAM_MUDLINE_INCH(MudSystem%NO_PIPINGSMUDLINE), & - MudSystem%AREA_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%LENGT_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%ROUGHNESS_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%RELROUGH_MUDLINE(MudSystem%NO_PIPINGSMUDLINE)) - - -DO I=1,MudSystem%NO_PIPINGSMUDLINE - MudSystem%DIAM_MUDLINE_INCH(I)=MudSystem%PIPINGS_MUDLINE(I,1) - MudSystem%LENGT_MUDLINE(I)=MudSystem%PIPINGS_MUDLINE(I,2) - MudSystem%ROUGHNESS_MUDLINE(I)=MudSystem%PIPINGS_MUDLINE(I,3) - - - - MudSystem%AREA_MUDLINE(I)=PII*(MudSystem%DIAM_MUDLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m^2) - MudSystem%RELROUGH_MUDLINE(I)=MudSystem%ROUGHNESS_MUDLINE(I)/(MudSystem%DIAM_MUDLINE_INCH(I)*25.4) !e/D - !DIAM_MUDLINE_MM(I)=DIAM_MUDLINE_MM(I)*.001 ! (m) - MudSystem%LENGT_MUDLINE(I)=MudSystem%LENGT_MUDLINE(I)*.3048 ! (m) -ENDDO - - -!=========================================================================== -! MUDLINE STATIC LOSSES INPUT -!=========================================================================== - -! Height are in (meter) -MudSystem%Pumps_Height= 0. -MudSystem%STpipeGauge_Height= 2. !(m) -MudSystem%Pits_Height= 1. !(m) -MudSystem%ChokeManifold_Height= 1.*0.3048 !(ft to meter) -MudSystem%WellChokeExit_Height= BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight - - - - - - - - - - - - - - END - - - - - SUBROUTINE MUDLINE_LOSSES(MLnumber) - - USE MudSystemVARIABLES - implicit none - integer I - INTEGER MLnumber - - -!===============================PIPE LOSS=================================== - MUD(MLnumber)%Re_MUDline=MUD(MLnumber)%Q*6.30902e-5*MudSystem%DIAM_MUDLINE_INCH(MLnumber)*0.0254/(MudSystem%AREA_MUDLINE(MLnumber)*MUD(MLnumber)%nu) !<<<<<< nu: DOROST SHAVAD.ALAN DAR STARTUP SET SHODE -!write(*,*) 'MUD(MLnumber)%Re_MUDline=' , MUD(MLnumber)%Re_MUDline -! Q*6.30902e-5 for (gpm) to (m^3/sec) - if ( MUD(MLnumber)%Re_MUDlineStandPipePressure - !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES - !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - USE CKellyConnectionEnumVariables - use UTUBEVARSModule - use CLog1 - Use CError - Use , intrinsic :: IEEE_Arithmetic - - implicit none - - integer jelement, jmud, jsection,ielement,i - integer jopelement,jopmud,jopsection - character(len=120) :: temp1, temp2 - - - - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - write(*,*) 'well cap=' , sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - MudSystem%DeltaWellCap= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - MudSystem%WellCapOld - MudSystem%WellCapOld= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - write(*,*) 'cap_reset,DeltaWellCap=' , MudSystem%DeltaWellCap - endif - - - - -!========================ANNULUS END================= -if ((MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) > 0.8 .or. MudSystem%Ann_Density%Last()==0.0) then ! for Line (BellNippleToWell-NonFullWell) - MudSystem%WellisNOTFull= .true. -else - MudSystem%WellisNOTFull= .false. -endif - -!WRITE(*,*) 'Ann_Mud_Forehead_X%Last() , KillHeight', Ann_Mud_Forehead_X%Last() , KillHeight -if ((MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%KillHeight)>0.8 .or. MudSystem%Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26) - MudSystem%ChokeLineNOTFull= .true. -else - MudSystem%ChokeLineNOTFull= .false. -endif - -!========================================================= - - jmud= 1 - jsection= 1 - jelement= 0 ! number of final mud elements - - - - call MudSystem%Xend_MudElement%Empty() - call MudSystem%TVDend_MudElement%Empty() - call MudSystem%Density_MudElement%Empty() - call MudSystem%MudGeoType%Empty() - call MudSystem%PipeID_MudElement%Empty() - call MudSystem%PipeOD_MudElement%Empty() - !call Angle_MudElement%Empty() - call MudSystem%MudType_MudElement%Empty() - - - - DO WHILE(jmud <= MudSystem%Hz_Mud_Forehead_X%Length() .and. jsection<=1) - - jelement= jelement+1 - MudSystem%TrueMinValue= min(MudSystem%Hz_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) - - call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_MudElement%Add(MudSystem%Hz_Density%Array(jmud)) - call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) - call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) - !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudSystem%MudType_MudElement%Add(MudSystem%Hz_MudOrKick%Array(jmud)) - - - if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%Hz_Mud_Forehead_X%Array(jmud)) then - jmud= jmud+1 - else - jsection= jsection+1 - endif - - ENDDO - - MudSystem%NoHorizontalMudElements= jelement - - - - - jmud= 1 - jsection= 2 - - DO WHILE(jmud <= MudSystem%St_Mud_Forehead_X%Length() .and. jsection<=F_Counts%StringIntervalCounts) - - jelement= jelement+1 - MudSystem%TrueMinValue= min(MudSystem%St_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) - - call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_MudElement%Add(MudSystem%St_Density%Array(jmud)) - call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) - call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) - !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudSystem%MudType_MudElement%Add(MudSystem%St_MudOrKick%Array(jmud)) - - - if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%St_Mud_Forehead_X%Array(jmud)) then - jmud= jmud+1 - else - jsection= jsection+1 - endif - - ENDDO - - MudSystem%NoStringMudElements= jelement- MudSystem%NoHorizontalMudElements - - - - - - jmud= 1 - jsection= F_Counts%StringIntervalCounts+1 - DO WHILE(jmud<= MudSystem%Ann_Mud_Forehead_X%Length() .and. jsection<=MudSystem%NoPipeSections) - - jelement= jelement+1 - MudSystem%TrueMinValue= max(MudSystem%Ann_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) - - call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_MudElement%Add(MudSystem%Ann_Density%Array(jmud)) - call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) - call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) - !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudSystem%MudType_MudElement%Add(MudSystem%Ann_MudOrKick%Array(jmud)) - - - if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%Ann_Mud_Forehead_X%Array(jmud)) then - jmud= jmud+1 - else - jsection= jsection+1 - endif - - ENDDO - - do i= 2, MudSystem%Xend_MudElement%Length() - if ( i== MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+1) then - call MudSystem%Xstart_MudElement%Add (MudSystem%Ann_Mud_Backhead_X%Array(1)) ! start of annulus - call TVD_Calculator(MudSystem%Ann_Mud_Backhead_X%Array(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) - elseif ( i== MudSystem%NoHorizontalMudElements+1 ) then - call MudSystem%Xstart_MudElement%Add (MudSystem%St_Mud_Backhead_X%Array(1)) ! start of stirng - call TVD_Calculator(MudSystem%St_Mud_Backhead_X%Array(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) - else - call MudSystem%Xstart_MudElement%Add(MudSystem%Xend_MudElement%Array(i-1)) ! normal calculation - call MudSystem%TVDstart_MudElement%Add(MudSystem%TVDend_MudElement%Array(i-1)) ! normal calculation - endif - - enddo - - MudSystem%NoCasingMudElements = jelement- MudSystem%NoStringMudElements- MudSystem%NoHorizontalMudElements - - -!=========================For Torque and Drag======================== - if (allocated(MudSystem%TDXstart_MudElementArray)) deallocate(MudSystem%TDXstart_MudElementArray) - allocate(MudSystem%TDXstart_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) - if (allocated(MudSystem%TDXend_MudElementArray)) deallocate(MudSystem%TDXend_MudElementArray) - allocate(MudSystem%TDXend_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) - if (allocated(MudSystem%TDDensity_MudElementArray)) deallocate(MudSystem%TDDensity_MudElementArray) - allocate(MudSystem%TDDensity_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) - - MudSystem%TDNoHorizontalMudElements= MudSystem%NoHorizontalMudElements - MudSystem%TDNoStringMudElements= MudSystem%NoStringMudElements - MudSystem%TDNoCasingMudElements= MudSystem%NoCasingMudElements - - - MudSystem%TDXstart_MudElementArray(:) = MudSystem%Xstart_MudElement%Array(:) - MudSystem%TDXend_MudElementArray(:) = MudSystem%Xend_MudElement%Array(:) - MudSystem%TDDensity_MudElementArray(:) = MudSystem%Density_MudElement%Array(:) -!===================================================================== - - - !do i=NoHorizontalMudElements+1, NoHorizontalMudElements+NoStringMudElements ! 2-string elements - ! write(*,333) 'STRING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i) - !enddo - - - - !================================================================ - - ! Open Hole Mud Elements - jopmud= 1 - jopsection= 1 - jopelement= 0 ! number of final mud elements - - - call MudSystem%Xend_OpMudElement%Empty() - call MudSystem%TVDend_OpMudElement%Empty() - call MudSystem%Density_OpMudElement%Empty() - call MudSystem%PipeID_OpMudElement%Empty() - call MudSystem%PipeOD_OpMudElement%Empty() - !call Angle_OpMudElement%Empty() - call MudSystem%MudTypeOp_MudElement%Empty() - - - - DO WHILE(jopmud<= MudSystem%Op_Mud_Forehead_X%Length() .and. jopsection<=F_Counts%BottomHoleIntervalCounts) - - jopelement= jopelement+1 - MudSystem%TrueMinValue= max(MudSystem%Op_Mud_Forehead_X%Array(jopmud), MudSystem%Xend_OpSection(jopsection)) - call MudSystem%Xend_OpMudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_OpMudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_OpMudElement%Add(MudSystem%Op_Density%Array(jopmud)) - call MudSystem%PipeID_OpMudElement%Add(MudSystem%ID_OpSectionInch(jopsection)) - call MudSystem%PipeOD_OpMudElement%Add(MudSystem%OD_OpSectionInch(jopsection)) - !call Angle_MudElement%Add(Angle_PipeSection(jopsection)) - call MudSystem%MudTypeOp_MudElement%Add(MudSystem%Op_MudOrKick%Array(jopmud)) - - - if (MudSystem%Xend_OpMudElement%Array(jopelement)== MudSystem%Op_Mud_Forehead_X%Array(jopmud)) then - jopmud= jopmud+1 - else - jopsection= jopsection+1 - endif - - ENDDO - - do i= 2, MudSystem%Xend_OpMudElement%Length() - call MudSystem%Xstart_OpMudElement%Add(MudSystem%Xend_OpMudElement%Array(i-1)) - call MudSystem%TVDstart_OpMudElement%Add(MudSystem%TVDend_OpMudElement%Array(i-1)) - enddo - - MudSystem%NoBottomHoleMudElements = jopelement - - - !================================================================ - - - - if(allocated(MudSystem%StringMudElement)) deallocate(MudSystem%StringMudElement) - allocate(MudSystem%StringMudElement(MudSystem%NoStringMudElements)) - - if(allocated(MudSystem%CasingMudElement)) deallocate(MudSystem%CasingMudElement) - allocate(MudSystem%CasingMudElement(MudSystem%NoCasingMudElements+MudSystem%NoBottomHoleMudElements)) - - MudSystem%istring=0 - MudSystem%icasing=0 - - MudSystem%BitMudDensity= MudSystem%Density_MudElement%Array(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements) ! (for ROP module) - !================================================================ - - !============================ UTUBE ============================= - - !IF (UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadIsOpen) THEN - IF (MudSystem%UtubePossibility== .true. .and. TD_StConn%FluidStringConnectionMode==0 .and. MudSystem%WellHeadIsOpen .AND. NoGasPocket == 0) THEN - CALL WellPressureDataTransfer - !WRITE (*,*) ' U-Tube Done 1' - CALL Utube - !WRITE (*,*) ' U-Tube Done 2' - if (QUtubeInput> 0.0) call Utube1_and_TripIn - if (QUtubeOutput> 0.0) call Utube2_and_TripIn - END IF - - !========================== UTUBE- end ========================= - - ! do imud=1, st_MudDischarged_Volume%Length() - ! write(*,*) 'st-plot:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud) - !enddo -!==================== Display ======================== - !do i=1, St_MudOrKick%Length() - ! write(*,555) i,'St_Volume(i), type=' ,St_MudDischarged_Volume%Array(i),St_MudOrKick%Array(i) - ! - ! IF (IEEE_Is_NaN(St_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in St Volume-Plot') - ! IF (St_MudDischarged_Volume%Array(i)<0.) call ErrorStop('St Volume <0' , St_MudDischarged_Volume%Array(i)) - !enddo - - - IF (ANY(IEEE_Is_NaN(MudSystem%Op_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystem%Op_MudDischarged_Volume%Array(:) <= 0.0)) THEN - do i = 1 , MudSystem%Op_MudOrKick%Length() - write(*,555) i,'Op_Volume(i), type=' ,MudSystem%Op_MudDischarged_Volume%Array(i) , MudSystem%Op_MudOrKick%Array(i) , MudSystem%Op_Density%Array(i) - end do - call ErrorStop('NaN in Op Volume-Plot or Op Volume <=0') - END IF - - - IF (ANY(IEEE_Is_NaN(MudSystem%Ann_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystem%Ann_MudDischarged_Volume%Array(:) <= 0.0)) THEN - do i = 1 , MudSystem%Ann_MudOrKick%Length() - write(*,555) i,'Ann_Volume(i), type=' ,MudSystem%Ann_MudDischarged_Volume%Array(i) , MudSystem%Ann_MudOrKick%Array(i) , MudSystem%Ann_Density%Array(i) - end do - call ErrorStop('NaN in Ann Volume-Plot or Ann Volume <=0') - END IF - - !do i=1, Ann_MudOrKick%Length() - ! !write(*,555) i,'Ann_Volume(i), type=' ,Ann_MudDischarged_Volume%Array(i),Ann_MudOrKick%Array(i),Ann_Density%Array(i) - ! - ! IF (IEEE_Is_NaN(Ann_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in Ann Volume-Plot') - ! IF (Ann_MudDischarged_Volume%Array(i)<=0.) call ErrorStop('Ann Volume <=0' , Ann_MudDischarged_Volume%Array(i)) - !enddo - -555 FORMAT(I3,5X,A42,(f12.5),5X,I3,5X,(f12.5)) - - MudSystem%NoStringMudElementsForPlot= MudSystem%NoStringMudElements - - ! 1-Horizontal Mud Elements are not shown - !write(*,333) 'Horiz:', 1,'Xstart\=', Xstart_MudElement%Array(1), 'Xend=' , Xend_MudElement%Array(1), 'Density=' , Density_MudElement%Array(1), 'MudType=' , MudType_MudElement%Array(1) - - do i=MudSystem%NoHorizontalMudElements+1, MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements ! 2-string elements - if (MudSystem%Xend_MudElement%Array(i) <= 0.0) then - MudSystem%NoStringMudElementsForPlot= MudSystem%NoStringMudElementsForPlot-1 - cycle - endif - MudSystem%istring= MudSystem%istring+1 - MudSystem%StringMudElement(MudSystem%istring)%StartMd = MudSystem%Xstart_MudElement%Array(i) - MudSystem%StringMudElement(MudSystem%istring)%EndMd = MudSystem%Xend_MudElement%Array(i) - !StringMudElement(istring)%Id = PipeID_MudElement%Array(i) - !StringMudElement(istring)%Od = PipeOD_MudElement%Array(i) - MudSystem%StringMudElement(MudSystem%istring)%Density = MudSystem%Density_MudElement%Array(i) - - if (MudSystem%MudType_MudElement%Array(i) == 104) then - MudSystem%MudType_MudElement%Array(i)= 4 ! air - elseif (MudSystem%MudType_MudElement%Array(i) > 0 .and. MudSystem%MudType_MudElement%Array(i) < 100) then ! all kicks - MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick - endif - - MudSystem%StringMudElement(MudSystem%istring)%MudType = MudSystem%MudType_MudElement%Array(i) - !write(*,333) 'STRING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i) - enddo - - - - do i=MudSystem%Xend_MudElement%Length(), MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+1 , -1 ! 3-casing elements - MudSystem%icasing= MudSystem%icasing+1 - MudSystem%CasingMudElement(MudSystem%icasing)%StartMd = MudSystem%Xend_MudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%EndMd = MudSystem%Xstart_MudElement%Array(i) - !CasingMudElement(icasing)%Id = PipeID_MudElement%Array(i) - !CasingMudElement(icasing)%Od = PipeOD_MudElement%Array(i) - !write(*,333) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i) - !call Log_1(temp1) - !write(*,444) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%Density = MudSystem%Density_MudElement%Array(i) - - if (MudSystem%MudType_MudElement%Array(i) == 104) then - MudSystem%MudType_MudElement%Array(i)= 4 ! air - elseif (MudSystem%MudType_MudElement%Array(i) > 0 .and. MudSystem%MudType_MudElement%Array(i) < 100) then - MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick - endif - - MudSystem%CasingMudElement(MudSystem%icasing)%MudType = MudSystem%MudType_MudElement%Array(i) - - enddo - - do i= MudSystem%NoBottomHoleMudElements, 1 , -1 ! 4-open hole elements - MudSystem%icasing= MudSystem%icasing+1 - MudSystem%CasingMudElement(MudSystem%icasing)%StartMd = MudSystem%Xend_OpMudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%EndMd = MudSystem%Xstart_OpMudElement%Array(i) - !CasingMudElement(icasing)%Id = PipeID_OpMudElement%Array(i) - !CasingMudElement(icasing)%Od = PipeOD_OpMudElement%Array(i) - !write(*,333) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'Density=' , Density_OpMudElement%Array(i), 'MudType=' , MudTypeOp_MudElement%Array(i) - !call Log_1(temp2) - !write(*,444) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%Density = MudSystem%Density_OpMudElement%Array(i) - - if (MudSystem%MudTypeOp_MudElement%Array(i) == 104) then - MudSystem%MudTypeOp_MudElement%Array(i)= 4 ! air - elseif (MudSystem%MudTypeOp_MudElement%Array(i) > 0 .and. MudSystem%MudTypeOp_MudElement%Array(i) < 100) then - MudSystem%MudTypeOp_MudElement%Array(i)= 1 ! gas kick - endif - - MudSystem%CasingMudElement(MudSystem%icasing)%MudType = MudSystem%MudTypeOp_MudElement%Array(i) - enddo - - - -333 FORMAT(A10,I3,5X,A8,(f12.5),5X,A8,(f12.5),5X,A8,(f12.5),5X,A8,I3) -444 FORMAT(A10,I2,5X,A8,(f12.3),5X,A8,(f12.3),5X,A8,(f12.3),5X,A8,(f12.3)) - - - - ! shomare gozari be tartib HZ mud, ST mud, Casing - ! shomare gzari OpenHole jodagane ast az 1 - - call SetStringFluids(MudSystem%NoStringMudElementsForPlot, MudSystem%StringMudElement) !for data display in string - call SetAnnalusFluids(MudSystem%NoCasingMudElements+MudSystem%NoBottomHoleMudElements, MudSystem%CasingMudElement) !for data display in casing - - -!=========================================================================================================================== -!=========================================================================================================================== - - - end subroutine PlotFinalMudElements - - - diff --git a/Equipments/MudSystem-old/Pump_and_Trip_In.f90 b/Equipments/MudSystem-old/Pump_and_Trip_In.f90 deleted file mode 100644 index d9cf373..0000000 --- a/Equipments/MudSystem-old/Pump_and_Trip_In.f90 +++ /dev/null @@ -1,1627 +0,0 @@ -subroutine Pump_and_TripIn ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure - !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES - !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - Use CShoeVariables - use CError - - - implicit none - -integer i,ii,AddLocation -!===========================================================WELL============================================================ -!===========================================================WELL============================================================ - - MudSystem%StringFlowRate= MUD(2)%Q - MudSystem%AnnulusFlowRate= MUD(2)%Q - - - !write(*,*) 'Trip In' - - -!========================Horizontal PIPE ENTRANCE================= - - if (ABS(MudSystem%SuctionDensity_Old - MudSystem%Suction_Density_MudSystem) >= MudSystem%DensityMixTol) then ! new mud is pumped - - call MudSystem%Hz_Density%AddToFirst (MudSystem%Suction_Density_MudSystem) - call MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Hz_MudOrKick%AddToFirst (0) - - MudSystem%SuctionDensity_Old= MudSystem%Suction_Density_MudSystem - endif - -!========================Horizontal PIPE STRING================= - - MudSystem%Hz_MudDischarged_Volume%Array(1)= MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - - MudSystem%total_add = MudSystem%total_add + ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_add= 0. - endif - - - !write(*,*) ' total decrease(add to HZ)=' , total_add - !write(*,*) ' add to HZ=' , ((MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) - -imud=0 - do while (imud < MudSystem%Hz_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Hz_Mud_Backhead_X%Array(imud)= MudSystem%Hz_Mud_Forehead_X%Array(imud-1) - MudSystem%Hz_Mud_Backhead_section%Array(imud)= MudSystem%Hz_Mud_Forehead_section%Array(imud-1) - endif - - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))- MudSystem%Hz_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Hz_MudDischarged_Volume%Array(imud) <= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%Hz_Mud_Backhead_section%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Hz_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) - - else - - - MudSystem%isection= MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > 1) then ! (horizontal pipe exit) - MudSystem%Hz_MudDischarged_Volume%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(1) - MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 - - if (MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveHzMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Hz_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif - - enddo -!========================Horizontal PIPE END================= - - -!========================Utube1 Air Element Removing================= - - !if (UtubeMode1Activated== .true.) then ! StringUpdate == .true. - ! - ! - ! !StringDensity_Old=MudSystem%St_Density%Array(2) - ! - ! write(*,*) 'StringDensity_Old=' , StringDensity_Old - ! - ! UtubeMode1Activated= .false. - !endif - -!========================Utube1 Air Element Removing End================= - -!!========================Utube2 Removing from Annulus================= not needed 97.04.26 -! -! if (UtubeMode2Activated== .true.) then ! StringUpdate == .true. -! -! if (Ann_MudOrKick%Last() == 104) then !movaghati. albate age merge anjam shode bashe moshkeli nist -! call RemoveAnnulusMudArrays(Ann_MudOrKick%Length()) -! endif -! -! UtubeMode2Activated= .false. -! endif -! -! -!!========================Utube2 Removing from Annulus End================= - -!========================New Pipe Filling================= - - !if (F_StringIntervalCounts > F_StringIntervalCountsOld) then ! StringUpdate == .true. - if (MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. - - !NoPipeAdded= F_Counts%StringIntervalCounts - F_StringIntervalCountsOld - - - MudSystem%NewPipeFilling=0 - - IF (MudSystem%St_MudOrKick%First() == 104) then - MudSystem%St_MudDischarged_Volume%Array(1) = MudSystem%St_MudDischarged_Volume%Array(1) + sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString)) ! new pipe is filled by air - else - call MudSystem%St_Density%AddToFirst (0.d0) - call MudSystem%St_MudDischarged_Volume%AddToFirst (sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString))) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) - call MudSystem%St_MudOrKick%AddToFirst (104) - endif - - endif - - !F_StringIntervalCountsOld= F_StringIntervalCounts - - - - if (MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) - - - MudSystem%LackageMudVolume= MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element - - - write(*,*) 'LackageMudVolume=' , MudSystem%LackageMudVolume - - - - if (ABS(MudSystem%St_Density%Array(2) - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddTo (2,MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddTo (2, 0.d0) - call MudSystem%St_Mud_Forehead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) - call MudSystem%St_Mud_Backhead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) - call MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) - call MudSystem%St_MudOrKick%AddTo (2,0) - - !StringDensity_Old= Hz_Density%Last() - endif - - - MudSystem%St_MudDischarged_Volume%Array(2)= MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) !(gal) - - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)- min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) ! air(gal) - - !LackageMudVolumeAfterFilling= sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) - sum(St_MudDischarged_Volume%Array(:)) - - MudSystem%LackageMudVolumeAfterFilling= MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero - - - - if (MudSystem%LackageMudVolumeAfterFilling == 0.) then - MudSystem%NewPipeFilling= 1 - call RemoveStringMudArrays(1) - MudSystem%St_Mud_Backhead_X%Array(1) = MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(1) = 2 - endif - - endif - -!========================New Pipe Filling End================= - - - - - if (MudSystem%NewPipeFilling == 0) then - MudSystem%StringFlowRate= 0. - MudSystem%AnnulusFlowRate= 0. - endif - - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate - - - - -!========================STRING ENTRANCE================= - - if (MudSystem%StringFlowRateFinal > 0.0 .and. ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (0) - - !StringDensity_Old= Hz_Density%Last() - endif - - - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - -!=============== save String Mud data=========== - - - - - MudSystem%StMudVolumeSum= 0.d0 - !St_MudSaved_Density= 0.d0 - MudSystem%St_Saved_MudDischarged_Volume= 0.d0 - !Saved_St_MudOrKick= 0 - !Ann_to_Choke_2mud= .false. - - do imud=1, MudSystem%St_MudDischarged_Volume%Length() - - MudSystem%StMudVolumeSum = MudSystem%StMudVolumeSum + MudSystem%St_MudDischarged_Volume%Array(imud) - - if ( MudSystem%StMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) ) then - - !IF (St_MudOrKick%Array(imud) == 0) THEN - MudSystem%St_MudSaved_Density =MudSystem%St_Density%Array(imud) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%StMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) - !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR - ! St_Kick_Saved_Volume = StMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! Saved_St_MudOrKick= St_MudOrKick%Array (imud) - ! St_KickSaved_Density=MudSystem%St_Density%Array(imud) - !END IF - - do ii= imud + 1, MudSystem%St_MudDischarged_Volume%Length() - !IF (St_MudOrKick%Array(ii) == 0) THEN - MudSystem%St_MudSaved_Density = ((MudSystem%St_MudSaved_Density * MudSystem%St_Saved_MudDischarged_Volume) + (MudSystem%St_Density%Array(ii) * MudSystem%St_MudDischarged_Volume%Array(ii))) / (MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii)) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii) - - !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR - ! St_Kick_Saved_Volume = St_Kick_Saved_Volume + St_MudDischarged_Volume%Array(ii) - ! Saved_St_MudOrKick= St_MudOrKick%Array (ii) - ! St_KickSaved_Density=MudSystem%St_Density%Array(ii) - !END IF - enddo - - - !WRITE (*,*) 'St_Saved_Mud_Volume, St_Kick_Saved_Volume', St_Saved_MudDischarged_Volume, St_Kick_Saved_Volume - exit ! exits do - - endif - - enddo -MudSystem%St_Saved_MudDischarged_Volume_Final = MudSystem%St_Saved_MudDischarged_Volume - -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final -!====================================================================== - -!========================STRING================= - -imud=0 - do while (imud < MudSystem%St_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) - endif - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - !write(*,*) 'St_Mud_Backhead_section%Array(1)=' , St_Mud_Backhead_section%Array(1) - !write(*,*) 'Xend_PipeSection(St_Mud_Backhead_section%Array(1))=' , Xend_PipeSection(St_Mud_Backhead_section%Array(1)) - ! - !write(*,*) 'St_EmptyVolume_inBackheadLocation%Array(1)=' , St_EmptyVolume_inBackheadLocation%Array(1) - !write(*,*) 'St_Mud_Backhead_X%Array(1)=' , St_Mud_Backhead_X%Array(1) - - - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > F_Counts%StringIntervalCounts) then ! last pipe section(string exit) F_Counts%StringIntervalCounts includes Horizontal line - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Forehead_section%Array(imud)= F_Counts%StringIntervalCounts - - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - - endif - - enddo - - endif - - enddo - - - !write(*,*) ' a before==' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - !write(*,*) '==== a before' - - - - - !write(*,*) ' iloc (a): ' , iloc - -!========================STRING END================= - - IF (MudSystem%Op_MudOrKick%Last() /= 0 .and. MudSystem%Op_MudOrKick%Last()==MudSystem%Ann_MudOrKick%First()) MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick -!write(*,*) ' iloc (b): ' , iloc - -!=============================Add PumpFlowRate to Bottom Hole ============================== - !if ( MudSystem%AnnulusFlowRate>0.0 ) then - if ( MudSystem%MudVolume_InjectedToBH > 0.0 ) then - - - if (KickOffBottom) then ! (kickOffBottom = F) means kick is next to the bottom hole and usually kick is entering the - AddLocation= MudSystem%Op_Density%Length()-MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick - else - AddLocation= MudSystem%Op_Density%Length()+1 - endif - !write(*,*) 'AddLocation====' , AddLocation - if ( AddLocation== 0) CALL ErrorStop ('AddLocation=0') - - - if ( ABS(MudSystem%St_Density%Last() - MudSystem%Op_Density%Array(AddLocation-1)) >= MudSystem%DensityMixTol ) then - !write(*,*) 'new pocket**' - !write(*,*) MudSystem%St_Density%Last()=' ,MudSystem%St_Density%Last() - !write(*,*) 'Op_Density%Array(AddLocation-1)=' , Op_Density%Array(AddLocation-1) - - - call MudSystem%Op_Density% AddTo (AddLocation,MudSystem%St_Density%Last()) - !call Op_MudDischarged_Volume%AddTo (AddLocation,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - call MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,MudSystem%MudVolume_InjectedToBH) - call MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) - call MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (AddLocation,0) - else - !write(*,*) 'merge**' - !write(*,*) 'density before=' , Op_Density%Array(AddLocation-1) - !write(*,*) MudSystem%St_Density%Last() for mix=' ,MudSystem%St_Density%Last() - - !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) - - MudSystem%Op_Density%Array(AddLocation-1)= (MudSystem%Op_Density%Array(AddLocation-1)*MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*MudSystem%MudVolume_InjectedToBH)/(MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%MudVolume_InjectedToBH) - MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + MudSystem%MudVolume_InjectedToBH - !write(*,*) 'density after=' , Op_Density%Array(AddLocation-1) - - endif - - endif -!=======================Add PumpFlowRate to Bottom Hole- End ============================== - - - - -!=============== save OP Mud data to transfer to the annulus enterance due to tripin or kick - MudSystem%OpMudVolumeSum= 0.d0 - !Op_MudSaved_Density= 0.d0 - !Op_KickSaved_Density= 0.d0 - MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Op_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Op_MudOrKick= 0 - - - - !write(*,*) 'Op_Capacity===' , sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - !write(*,*) 'Op_MudDischarged_Volume%Length()===' , Op_MudDischarged_Volume%Length() - ! - - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - !write(*,*) 'imud, Op_MudDischarged_Volume%Array(imud)=' , imud,Op_MudDischarged_Volume%Array(imud) - - MudSystem%OpMudVolumeSum= MudSystem%OpMudVolumeSum + MudSystem%Op_MudDischarged_Volume%Array(imud) - - if ( MudSystem%OpMudVolumeSum > sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then - - IF (MudSystem%Op_MudOrKick%Array(imud) == 0) THEN - MudSystem%Op_MudSaved_Density = MudSystem%Op_Density%Array(imud) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - ELSE - MudSystem%Op_Kick_Saved_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - !write(*,*) 'cond 1- Op_MudOrKick%Array (imud),Op_Density%Array(imud):' ,Op_MudOrKick%Array (imud),Op_Density%Array(imud) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (imud) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(imud) - MudSystem%iLoc= 2 - END IF - - do ii= imud + 1, MudSystem%Op_MudDischarged_Volume%Length() - IF (MudSystem%Op_MudOrKick%Array(ii) == 0) THEN - MudSystem%Op_MudSaved_Density = ((MudSystem%Op_MudSaved_Density * MudSystem%Op_Saved_MudDischarged_Volume) + (MudSystem%Op_Density%Array(ii) * MudSystem%Op_MudDischarged_Volume%Array(ii))) / (MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii)) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) - ELSE - MudSystem%Op_Kick_Saved_Volume = MudSystem%Op_Kick_Saved_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) - !write(*,*) 'cond 2- Op_MudOrKick%Array (ii),Op_Density%Array(ii):' ,Op_MudOrKick%Array (ii),Op_Density%Array(ii) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (ii) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(ii) - MudSystem%iLoc= 2 - END IF - enddo - - exit ! exits do - - endif - - enddo - !WRITE (*,*) 'Op_Saved_MudDischarged_Volume, Op_Kick_Saved_Volume',Op_Saved_MudDischarged_Volume, Op_Kick_Saved_Volume -!write(*,*) ' iloc (c): ' , iloc - -!====================================================================== - -!====================================================================== - - - - - - !if (iLoc == 1) then - MudSystem%MudSection= F_Counts%StringIntervalCounts+1 - MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - !elseif (iLoc == 2) then - ! MudSection= Kick_Forehead_section - ! BackheadX= Kick_Forehead_X - !endif - -!========================ANNULUS ENTRANCE==================== - !if (KickMigration_2SideBit == .FALSE.) then ! because its effect is applied in Migration Code - ! !write(*,*) 'iloc=====' , iLoc bejaye ROP_Bit%RateOfPenetration ==0. in bude: DeltaVolumeOp == 0.0 - ! if (ABS(AnnulusSuctionDensity_OldMudSystem%St_Density%Last()) >= DensityMixTol .OR. (DeltaVolumeOp == 0.0 .and. ABS(Ann_Density%Array(iLoc)MudSystem%St_Density%Last())>=DensityMixTol .and. MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped - ! call Ann_Density%AddTo (iLocMudSystem%St_Density%Last()) - ! call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0) - ! call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) - ! call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection) - ! call Ann_Mud_Backhead_X%AddTo (iLoc,BackheadX) - ! call Ann_Mud_Backhead_section%AddTo (iLoc,MudSection) - ! call Ann_RemainedVolume_in_LastSection%AddTo (iLoc,0.0d0) - ! call Ann_EmptyVolume_inBackheadLocation%AddTo (iLoc,0.0d0) - ! call Ann_MudOrKick%AddTo (iLoc,0) - ! call Ann_CuttingMud%AddTo (iLoc,0) - ! !write(*,*) 'c) annLength=' , Ann_Density%Length() - ! - ! AnnulusSuctionDensity_Old=MudSystem%St_Density%Last() - ! - ! MudIsChanged= .true. - ! endif - ! - ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) !(gal) - ! - !endif - - - - - - - MudSystem%Ann_Mud_Backhead_section%Array(1)= MudSystem%MudSection !it is needed to be updated for a condition that one pipe is removed from Annulus due to trip out - MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%BackheadX - - - - ! write(*,*) 'zero)Ann_Mud sum=' , sum(Ann_MudDischarged_Volume%Array(:)) - ! - ! - !write(*,*) 'pump added-before add to ann==' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - !write(*,*) '====pump added-before add to ann' - - - -!========================Tripping In==================== - -!write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - if (ROP_Bit%RateOfPenetration==0.) then ! .and. Op_MudOrKick%Last() == 0) then ! trip in mode(loole paeen) Mud - - !write(*,*) 'Tripping In' - !write(*,*) 'before' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - !if ( MudIsChanged== .true. ) then - ! call RemoveAnnulusMudArrays(iLoc) - !endif - - - if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then - write(*,*) 'Kick influx enters Annulus' - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< - call MudSystem%Ann_CuttingMud%AddToFirst (0) - elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume - endif - - - if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then - MudSystem%NewDensity= MudSystem%Op_MudSaved_Density - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume - !write(*,*) 'NewVolume=' , NewVolume - !write(*,*) 'iloc=' , iloc,'Ann_MudDischarged_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - - - if ((ROP_Bit%RateOfPenetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) - !write(*,*) 'd) annLength=' , Ann_Density%Length() - !write(*,*) 'new' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - endif - endif - - endif - -!========================Tripping In - End==================== - -!========================Drilling Mode======================== - - if (ROP_Bit%RateOfPenetration>0. .and. MudSystem%DeltaVolumeOp>0.0) then ! trip in mode(loole paeen) DrillingMode== .true. - !write(*,*) 'Drilling Mode' - - !if ( MudIsChanged== .true. ) then - ! call RemoveAnnulusMudArrays(iLoc) - !endif - !write(*,*) 'before' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - - !MudSystem%NewDensity= MudSystem%St_Density%Last() * MudSystem%AnnulusFlowRate + 141.4296E-4*ROP_Bit%RateOfPenetration*ROP_Spec%DiameterOfBit**2)/(MudSystem%AnnulusFlowRate+6.7995E-4*ROP_Bit%RateOfPenetration*Diameter_of_Bit**2) - - MudSystem%NewDensity=MudSystem%St_Density%Last() - - - !NewVolume= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp - !!! Density in ppg, flow rate in gpm, ROP in ft/s, bit diameter in inch - - - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - if ( MudSystem%Op_MudOrKick%Array(imud) == 0 ) then - MudSystem%Op_Density%Array(imud)= MudSystem%NewDensity - - endif - enddo - - - - if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then - write(*,*) 'Kick influx enters Annulus first time' - !write(*,*) 'Saved_Op_MudOrKick=',Saved_Op_MudOrKick - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< - call MudSystem%Ann_CuttingMud%AddToFirst (0) - elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume - endif - - - if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then - !write(*,*) 'Op_Saved_Mud added' - MudSystem%NewDensity= MudSystem%NewDensity !(drilling density) - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%DeltaVolumeOp ! (DeltaVolumeOp: for Cuttings Volume) - !write(*,*) 'NewVolume=' , NewVolume - !write(*,*) 'iloc=' , iloc,'Ann_MudDischarged_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - if ( (MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol ) & - .or. (MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)= 1 - !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - else ! 2-Merging conditions are not meeted, so new pocket - !write(*,*) 'before e) ', iloc, Ann_Density%Array(iLoc),MudSystem%NewDensity - !write(*,*) 'before e) Ann_MudDischarged_Volume%Array(iLoc)=' , Ann_MudDischarged_Volume%Array(iLoc) - - - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,1) ! 1= cutting 0= mud - !write(*,*) 'new' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - !write(*,*) 'e) annLength=' , Ann_Density%Length() - - - endif - - - endif - - endif -!=================================================================== - - !write(*,*) 'after add to ann==' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - !write(*,*) '==after add to ann' - - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume - - if (MudSystem%iLoc==2 .and. MudSystem%Op_MudOrKick%Last()==0 .and. MudSystem%NewVolume > 0.d0 ) then ! for avoid kick separation - !write(*,*) 'avoid kick separation' - - - MudSystem%NewDensity= MudSystem%Op_MudSaved_Density - - call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann - if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)- MudSystem%Op_Saved_MudDischarged_Volume) then! 1st in Ann = kick - !write(*,*) 'mode1' - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) -MudSystem%Op_Saved_MudDischarged_Volume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) !kick - else - call RemoveAnnulusMudArrays(1) !kick is removed - MudSystem%iLoc= 1 - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) - !write(*,*) 'mode2' - - ! including a little expand - endif - - - if ((ROP_Bit%RateOfPenetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) - !write(*,*) 'd) annLength=' , Ann_Density%Length() - - endif - - - endif -!=================================================================== - if( MudSystem%Op_MudOrKick%Last() == 1 .and. MudSystem%Ann_MudOrKick%First() == 0 ) then - - write(*,*) '***error2****==' - - write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , MudSystem%Op_Kick_Saved_Volume,MudSystem%Op_Saved_MudDischarged_Volume - - - write(*,*) 'after add to ann==' - - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - write(*,*) 'Op:', imud, MudSystem%Op_MudDischarged_Volume%Array(imud), MudSystem%Op_Density%Array(imud) ,MudSystem%Op_MudOrKick%Array(imud) - enddo - - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - write(*,*) 'Ann:', imud, MudSystem%Ann_MudDischarged_Volume%Array(imud), MudSystem%Ann_Density%Array(imud) ,MudSystem%Ann_MudOrKick%Array(imud) - enddo - - write(*,*) '==after add to ann' - - write(*,*) 'NewVolume,Op_MudOrKick%Last=' , MudSystem%NewVolume,MudSystem%Op_MudOrKick%Last() - write(*,*) '==***error2****' - - endif - - - - - -!=============== save Ann Mud data to transfer to the ChokeLine enterance - MudSystem%AnnMudVolumeSum= 0.d0 - !Ann_MudSaved_Density= 0.d0 - !Ann_KickSaved_Density= 0.d0 - MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Ann_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Ann_MudOrKick= 0 - MudSystem%Ann_to_Choke_2mud= .false. - - - - - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - - MudSystem%AnnMudVolumeSum= MudSystem%AnnMudVolumeSum + MudSystem%Ann_MudDischarged_Volume%Array(imud) - - if ( MudSystem%AnnMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) ) then - - IF (MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN - MudSystem%Ann_MudSaved_Density = MudSystem%Ann_Density%Array(imud) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - ELSEIF (MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (imud) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(imud) - END IF - - do ii= imud + 1, MudSystem%Ann_MudDischarged_Volume%Length() - IF (MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN - MudSystem%Ann_MudSaved_Density = ((MudSystem%Ann_MudSaved_Density * MudSystem%Ann_Saved_MudDischarged_Volume) + (MudSystem%Ann_Density%Array(ii) * MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii)) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Ann_to_Choke_2mud= .true. - ELSEIF (MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%Ann_Kick_Saved_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (ii) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(ii) - END IF - enddo - - - !WRITE (*,*) 'Ann_Saved_Mud_Volume, Ann_Kick_Saved_Volume', Ann_Saved_MudDischarged_Volume, Ann_Kick_Saved_Volume - exit - - endif - - enddo -MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume !+ Ann_Kick_Saved_Volume -MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final -((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) -!WRITE (*,*) 'MudSystem%MudVolume_InjectedFromAnn=', MudSystem%MudVolume_InjectedFromAnn -!====================================================================== - - !write(*,*) 'c)Ann_Mud sum=' , sum(Ann_MudDischarged_Volume%Array(:)) - !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - !write(*,*) 'Ann_Saved_Mud=' , Ann_Saved_MudDischarged_Volume - - MudSystem%total_injected = MudSystem%total_injected + MudSystem%MudVolume_InjectedFromAnn - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_injected= 0. - endif - - !write(*,*) ' total injected-tripin =' , total_injected - !write(*,*) 'injected-tripin =' , MudSystem%MudVolume_InjectedFromAnn - - - - - -!======================== Annulus ==================== - - !MudIsChanged= .false. - -imud= 0 - - do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) - endif - - - -! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then - !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then - !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(imud) - imud= imud-1 - cycle - endif - - ENDIF -! Fracture Shoe Lost >>> - - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections - - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - !write(*,*) 'remove******' - call RemoveAnnulusMudArrays(imud) - endif - exit - endif - - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif -! write(*,*) 'imud=' , imud -!write(*,*) 'Pinter4 **Ann_Length()=' , Ann_Mud_Forehead_X%Length() -! write(*,*) 'Ann_Density%Array (imud)=' , Ann_Density%Array (imud) -! -! -!write(*,*) imud,'Ann_Mud_Forehead_X%Array(imud)=' , Ann_Mud_Forehead_X%Array(imud) - - !if (Ann_Mud_Forehead_X%Array(imud) < Xend_PipeSection(NoPipeSections)) then - ! Ann_Mud_Forehead_X%Array(imud) = Xend_PipeSection(NoPipeSections) ! for error preventing - !endif - - !write(*,*) imud, 'Ann_MudDischarged_Volume%Array(imud)=' , Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) - - - enddo - - if (MudSystem%Ann_Mud_Forehead_X%Last() < MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) then - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length()) = MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) ! for error preventing - endif - -!========================ANNULUS END================= - !write(*,*) 'sum(Ann_MudDischarged_Volume%Array())=' , sum(Ann_MudDischarged_Volume%Array(:)) - -!========================================================= - - - !write(*,*) 'before======2' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - !write(*,*) '2======before' - - -!========================Bottom Hole================= -imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) - endif - !write(*,*) 'imud**=' , imud - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - !write(*,*) ' Op_EmptyVolume_inBackheadLocation%Array(1) =' , Op_EmptyVolume_inBackheadLocation%Array(1) - if ( MudSystem%Op_EmptyVolume_inBackheadLocation%Array(1) < 0.0) CALL ErrorStop1 ('Negative Empty volume') - - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - - else - - - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) - !if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts - - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveOpMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) - exit - else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif -! for OP remove: - - if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then - MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() - do while(imud < MudSystem%totalLength) - - !imud = imud + 1 - call RemoveOpMudArrays(MudSystem%totalLength) - MudSystem%totalLength = MudSystem%totalLength - 1 - - - enddo - - exit ! - - endif - - - - - !if (Op_Mud_Forehead_X%Array(imud)== Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then - ! totalLength = Op_MudDischarged_Volume%Length() - ! do while(imud <= totalLength) - ! - ! imud = imud + 1 - ! call RemoveOpMudArrays(imud) - ! totalLength = totalLength - 1 - ! - ! - ! enddo - ! - ! exit ! - ! - !endif - - enddo - - !write(*,*) 'OpSection_VolumeCapacity sum=' , sum(OpSection_VolumeCapacity(:)) - - - -!========================Bottom Hole END================= - - - !write(*,*) 'after sorting==' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - ! ! - ! !do imud=1, st_MudDischarged_Volume%Length() - ! ! write(*,*) 'st:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud) - ! !enddo - ! - !write(*,*) '==after sorting' - - - ! write(*,*) 'after sorting st==' - ! - ! do imud=1, st_MudDischarged_Volume%Length() - ! write(*,*) 'st-plot:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud)MudSystem%St_Density%Array(imud) - ! enddo - ! - !write(*,*) '==after sorting st' - - - - - !write(*,*) '**Ann_Kick_Saved_Final,Mud_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn - - end subroutine Pump_and_TripIn - - - - - - - - - - - - subroutine ChokeLineMud ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure - !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES - !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - use PressureDisplayVARIABLESModule - Use CError - Use , intrinsic :: IEEE_Arithmetic - - - implicit none - - integer i,ii,error_occured - - error_occured = 0 - - - - - !write(*,*) 'begining chokeline==' - !write(*,*) 'Ann last:', Ann_MudDischarged_Volume%Last(), Ann_Density%Last() ,Ann_MudOrKick%Last() - ! - !do imud=1, ChokeLine_MudDischarged_Volume%Length() - ! write(*,*) 'ChokeLine:', imud, ChokeLine_MudDischarged_Volume%Array(imud), ChokeLine_Density%Array(imud) ,ChokeLine_MudOrKick%Array(imud) - !enddo - - - - !write(*,*) 'Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn - - !write(*,*) 'begining chokeline==' - - - - - - - - MudSystem%ChokeLineFlowRate = MUD(4)%Q - !WRITE (*,*) 'MUD(4)%Q', MUD(4)%Q - - - if (MudSystem%NewPipeFilling == 0) then ! .or. UtubeFilling==0) then - MudSystem%ChokeLineFlowRate= 0. - endif - - - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then - write(*,*) 'error_location is 1' - error_occured = 1 - endif - enddo - - - - ! - !do imud=1, st_MudDischarged_Volume%Length() - ! write(*,*) 'st:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud) - !enddo - - - !========================CHOKE LINE ENTRANCE================= - - !if ( Ann_Kick_Saved_Volume > 0.0 .and. ( Ann_Saved_MudDischarged_Volume-((Qlost/60.0d0)*DeltaT_Mudline) ) == 0.0 ) then - if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( MudSystem%MudVolume_InjectedFromAnn ) <= 1.0e-5 ) then - - !WRITE (*,*) 'only kick enters to chokeline, Casing pressure = ', PressureGauges(2) - - if (MudSystem%ChokeLine_MudOrKick%First() == 0) then - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_KickSaved_Density) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.d0) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (MudSystem%Saved_Ann_MudOrKick) - - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_KickSaved_Density - - endif - - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ MudSystem%Ann_Kick_Saved_Volume !(gal) - - endif - - - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then - write(*,*) 'error_location is 2' - - error_occured = 1 - - endif - enddo - - - - !if ( Ann_Kick_Saved_Volume == 0.0 .and. ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 ) then - if ( MudSystem%Ann_Kick_Saved_Volume <= 1.0e-5 .and. MudSystem%MudVolume_InjectedFromAnn > 1.0e-5 ) then - - !WRITE (*,*) 'only mud enters to chokeline' - - - if ((MudSystem%Ann_to_Choke_2mud == .false. .and. ABS(MudSystem%ChokeLineDensity_Old - MudSystem%Ann_MudSaved_Density) >= MudSystem%DensityMixTol) .or. MudSystem%ChokeLine_MudOrKick%First() /= 0) then ! new mud is pumped - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_MudSaved_Density) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_MudSaved_Density - endif - - !ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1)+ (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) !(gal) - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ (MudSystem%MudVolume_InjectedFromAnn) !(gal) - - - - endif - - - - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then - write(*,*) 'error_location is 3' - error_occured = 1 - - endif - enddo - - - !if ( Ann_Kick_Saved_Volume > 0.0 .and. (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 .and. ChokeLine_MudOrKick%First() /= 0 ) then - if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. (MudSystem%MudVolume_InjectedFromAnn) > 1.0e-5 .and. MudSystem%ChokeLine_MudOrKick%First() /= 0 ) then - - WRITE (*,*) 'Kick Enters Choke line Last Time' - - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ MudSystem%Ann_Kick_Saved_Volume !(gal) - - - - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_MudSaved_Density) - !call ChokeLine_MudDischarged_Volume%AddToFirst (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (MudSystem%MudVolume_InjectedFromAnn) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_MudSaved_Density - - - - - - !ELSE if ( Ann_Kick_Saved_Volume > 0.0 .and. ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 .and. ChokeLine_MudOrKick%First() == 0 ) then - ELSE if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( MudSystem%MudVolume_InjectedFromAnn ) > 1.0e-5 .and. MudSystem%ChokeLine_MudOrKick%First() == 0 ) then - WRITE (*,*) 'Kick Enters Choke line First Time' - - - - !ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1)+ ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) !(gal) - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ ( MudSystem%MudVolume_InjectedFromAnn ) !(gal) - - - - - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_KickSaved_Density) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (MudSystem%Ann_Kick_Saved_Volume) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (MudSystem%Saved_Ann_MudOrKick) - - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_KickSaved_Density - - - endif - - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then - write(*,*) 'error_location is 4' - error_occured = 1 - - endif - enddo - - if (error_occured == 1) then - - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length() - write(*,*) 'ChokeLine:', imud, MudSystem%ChokeLine_Density%Array(imud) ,MudSystem%ChokeLine_MudOrKick%Array(imud) - enddo - - endif - - -!========================================================== - - ! - !write(*,*) 'after add chokeline==' - ! - ! do imud=1, ChokeLine_MudDischarged_Volume%Length() - ! write(*,*) 'ChokeLine:', imud, ChokeLine_MudDischarged_Volume%Array(imud), ChokeLine_Density%Array(imud) ,ChokeLine_MudOrKick%Array(imud) - ! enddo - ! - !write(*,*) 'after add chokeline==' - ! - ! - - -!=============== save Choke Mud data========================== - MudSystem%ChokeMudVolumeSum= 0.d0 - !Ann_MudSaved_Density= 0.d0 - !Ann_KickSaved_Density= 0.d0 - MudSystem%Choke_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Choke_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Choke_MudOrKick= 0 - - - - - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length() - - MudSystem%ChokeMudVolumeSum= MudSystem%ChokeMudVolumeSum + MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) - - if ( MudSystem%ChokeMudVolumeSum > MudSystem%ChokeLine_VolumeCapacity ) then - - IF (MudSystem%ChokeLine_MudOrKick%Array(imud) == 0) THEN - MudSystem%Choke_MudSaved_Density = MudSystem%ChokeLine_Density%Array(imud) - MudSystem%Choke_Saved_MudDischarged_Volume = MudSystem%ChokeMudVolumeSum - MudSystem%ChokeLine_VolumeCapacity - ELSEIF (MudSystem%ChokeLine_MudOrKick%Array(imud) > 0 .AND. MudSystem%ChokeLine_MudOrKick%Array(imud) <100) THEN ! 104= AIR - MudSystem%Choke_Kick_Saved_Volume = MudSystem%ChokeMudVolumeSum - MudSystem%ChokeLine_VolumeCapacity - MudSystem%Saved_Choke_MudOrKick= MudSystem%ChokeLine_MudOrKick%Array (imud) - MudSystem%Choke_KickSaved_Density= MudSystem%ChokeLine_Density%Array(imud) - END IF - - do ii= imud + 1, MudSystem%ChokeLine_MudDischarged_Volume%Length() - - IF (MudSystem%ChokeLine_MudOrKick%Array(ii) == 0) THEN - MudSystem%Choke_MudSaved_Density = ((MudSystem%Choke_MudSaved_Density * MudSystem%Choke_Saved_MudDischarged_Volume) + (MudSystem%ChokeLine_Density%Array(ii) * MudSystem%ChokeLine_MudDischarged_Volume%Array(ii))) / (MudSystem%Choke_Saved_MudDischarged_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii)) - MudSystem%Choke_Saved_MudDischarged_Volume = MudSystem%Choke_Saved_MudDischarged_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) - ELSEIF (MudSystem%ChokeLine_MudOrKick%Array(ii) > 0 .AND. MudSystem%ChokeLine_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystem%Choke_Kick_Saved_Volume = MudSystem%Choke_Kick_Saved_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Choke_MudOrKick= MudSystem%ChokeLine_MudOrKick%Array (ii) - MudSystem%Choke_KickSaved_Density= MudSystem%ChokeLine_Density%Array(ii) - END IF - enddo - - - !WRITE (*,*) 'Choke_Saved_Mud_Volume, Choke_Kick_Saved_Volume', Choke_Saved_MudDischarged_Volume, Choke_Kick_Saved_Volume - exit ! exits do - - endif - - enddo -MudSystem%Choke_Saved_MudDischarged_Volume_Final= MudSystem%Choke_Saved_MudDischarged_Volume !+ Choke_Kick_Saved_Volume -MudSystem%Choke_Kick_Saved_Volume_Final= MudSystem%Choke_Kick_Saved_Volume -!====================================================================== - - - ! - !do imud=1, ChokeLine_MudDischarged_Volume%Length() - ! write(*,*) 'a)ChokeLine:', imud, ChokeLine_MudDischarged_Volume%Array(imud) ,ChokeLine_MudOrKick%Array(imud) - !enddo - - - !write(*,*) 'choke_Mud sum=' , sum(ChokeLine_MudDischarged_Volume%Array(:)) - !write(*,*) 'choke_cap=' , ChokeLine_VolumeCapacity - !write(*,*) 'Choke_Saved_Mud=' , Choke_Saved_MudDischarged_Volume_Final - !write(*,*) 'Choke_Saved_Kick=' , Choke_Kick_Saved_Volume_Final - - - -!========================Choke Line================= - -imud=0 - do while (imud < MudSystem%ChokeLine_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)= MudSystem%ChokeLine_Mud_Forehead_X%Array(imud-1) - MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)= MudSystem%ChokeLine_Mud_Forehead_section%Array(imud-1) - endif - - - !DirectionCoef= (Xend_PipeSection(St_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(St_Mud_Backhead_section%Array(imud))) & - ! / ABS(Xend_PipeSection(St_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(St_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= (BopStackSpecification%ChokeLineLength- MudSystem%ChokeLine_Mud_Backhead_X%Array(imud))* MudSystem%Area_ChokeLineFt !(ft^3) - - MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - if ( MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) <= MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= MudSystem%ChokeLine_Mud_Backhead_section%Array(imud) - MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)+ (MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_ChokeLineFt - ! 7.48 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)+1 - MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > 1) then ! last pipe section(Chokeline exit) - MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)= MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud) - MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= BopStackSpecification%ChokeLineLength - MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= 1 - if (MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call MudSystem%ChokeLine_MudDischarged_Volume%Remove (imud) - call MudSystem%ChokeLine_Mud_Backhead_X%Remove (imud) - call MudSystem%ChokeLine_Mud_Backhead_section%Remove (imud) - call MudSystem%ChokeLine_Mud_Forehead_X%Remove (imud) - call MudSystem%ChokeLine_Mud_Forehead_section%Remove (imud) - call MudSystem%ChokeLine_Density%Remove (imud) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%ChokeLine_MudOrKick%Remove (imud) - - endif - exit - endif - - MudSystem%xx= MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%ChokeLine_VolumeCapacity !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= MudSystem%xx * BopStackSpecification%ChokeLineLength - exit - else - MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)- MudSystem%ChokeLine_VolumeCapacity - MudSystem%isection= MudSystem%isection+ 1 - - - endif - - enddo - - endif - - enddo -!========================Choke Line END================= - - !do imud=1, ChokeLine_MudDischarged_Volume%Length() - ! write(*,*) 'b)ChokeLine:', imud, ChokeLine_MudDischarged_Volume%Array(imud) ,ChokeLine_MudOrKick%Array(imud) - !enddo - - MudSystem%ChokeOutletDensity= MudSystem%ChokeLine_Density%Last() ! used in MudSystem - - - - - - do i=1, MudSystem%ChokeLine_MudOrKick%Length() - !write(*,555) i,'Choke_Volume(i), type=' ,ChokeLine_MudDischarged_Volume%Array(i),ChokeLine_MudOrKick%Array(i) - - IF (IEEE_Is_NaN(MudSystem%ChokeLine_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in Choke Volume-Plot') - IF (MudSystem%ChokeLine_MudDischarged_Volume%Array(i)<=0.) call ErrorStop('Choke Volume= <=0' , MudSystem%ChokeLine_MudDischarged_Volume%Array(i)) - enddo - -555 FORMAT(I3,5X,A42,(f12.5),5X,I3) - - - !write(*,*) 'after sorting chokeline==' - !IF (ANY(ChokeLine_MudOrKick%Array(:) > 0)) THEN - ! do imud=1, ChokeLine_MudDischarged_Volume%Length() - ! write(*,*) 'ChokeLine:', imud, ChokeLine_MudDischarged_Volume%Array(imud), ChokeLine_Density%Array(imud) ,ChokeLine_MudOrKick%Array(imud) - ! enddo - !END IF - - - !do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - !enddo - ! - !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - - - !write(*,*) '==after sorting chokeline' - - - end subroutine ChokeLineMud - - - - - -subroutine Choke_GasSound ! is called in subroutine CirculationCodeSelect - - -use CSounds - !Use GeoElements_FluidModule - !USE CMudPropertiesVariables - USE MudSystemVARIABLES - !USE Pumps_VARIABLES - !!USE CHOKEVARIABLES - !!USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure - !!use CManifolds - !use CDrillWatchVariables - !!use CHOKEVARIABLES - !!use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => TripTankVolume, TripTankDensity2 => TripTankDensity - !USE sROP_Other_Variables - !USE sROP_Variables - !use KickVARIABLESModule - !use PressureDisplayVARIABLESModule - !Use CError - !Use , intrinsic :: IEEE_Arithmetic - - - - - - if ( MudSystem%ChokeLine_MudOrKick%Last() > 0 .AND. MudSystem%WellToChokeManifoldOpen == .true.) then - !WellToChokeManifoldWasOpen - - MudSystem%SoundGasThroughChoke = 100 !100:chon dar adadhaye kamtar az 100 seda ghaat mishavad. eslah shavad.5.8.98 !int (min(ChokeLineFlowRate/2. , 100.)) - print* , 'SoundGasThroughChoke1=', MudSystem%SoundGasThroughChoke - !WRITE (*,*) 'WellToChokeManifoldWasOpen-Sound', WellToChokeManifoldWasOpen - WRITE (*,*) 'WellToChokeManifoldOpen', MudSystem%WellToChokeManifoldOpen - else - MudSystem%SoundGasThroughChoke = 0 - print* , 'SoundGasThroughChoke2=', MudSystem%SoundGasThroughChoke - endif - !print* , 'SoundGasThroughChoke3=', SoundGasThroughChoke - - - - call SetSoundGasThroughChoke(MudSystem%SoundGasThroughChoke) - - - end subroutine Choke_GasSound \ No newline at end of file diff --git a/Equipments/MudSystem-old/Trip_Out_andPump.f90 b/Equipments/MudSystem-old/Trip_Out_andPump.f90 deleted file mode 100644 index 8e2b422..0000000 --- a/Equipments/MudSystem-old/Trip_Out_andPump.f90 +++ /dev/null @@ -1,1364 +0,0 @@ -subroutine TripOut_and_Pump ! is called in subroutine CirculationCodeSelect - - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure - !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES - !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - USE sROP_Other_Variables - USE sROP_Variables - use KickVARIABLESModule - Use CShoeVariables - use CError - - implicit none - -integer i,ii,AddLocation, iloc_edited, iloc_changedTo2 -Real(8) ExcessMudVolume_Remained,SavedDensityForOp - -!===========================================================WELL============================================================ -!===========================================================WELL============================================================ - - MudSystem%StringFlowRate= MUD(2)%Q - MudSystem%AnnulusFlowRate= MUD(2)%Q - !write(*,*) 'MUD(2)%Q=====' , MUD(2)%Q - - - write(*,*) 'Trip Out' - - ! write(*,*) 'check point 1==' - ! - ! - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - ! write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - ! - ! - !write(*,*) '==check point 1' - -!========================Horizontal PIPE ENTRANCE================= - - if (ABS(MudSystem%SuctionDensity_Old - MudSystem%Suction_Density_MudSystem) >= MudSystem%DensityMixTol) then ! new mud is pumped - - call MudSystem%Hz_Density%AddToFirst (MudSystem%Suction_Density_MudSystem) - call MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Hz_MudOrKick%AddToFirst (0) - - MudSystem%SuctionDensity_Old= MudSystem%Suction_Density_MudSystem - endif - -!========================Horizontal PIPE STRING================= - - MudSystem%Hz_MudDischarged_Volume%Array(1)= MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - - - MudSystem%total_add = MudSystem%total_add + ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) - - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_add= 0. - endif - - !write(*,*) ' total decrease(add to HZ)=' , total_add - !write(*,*) ' add to HZ=' , ((MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) - - - -imud=0 - do while (imud < MudSystem%Hz_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Hz_Mud_Backhead_X%Array(imud)= MudSystem%Hz_Mud_Forehead_X%Array(imud-1) - MudSystem%Hz_Mud_Backhead_section%Array(imud)= MudSystem%Hz_Mud_Forehead_section%Array(imud-1) - endif - - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))- MudSystem%Hz_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Hz_MudDischarged_Volume%Array(imud) <= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%Hz_Mud_Backhead_section%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Hz_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) - - else - - - MudSystem%isection= MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > 1) then ! (horizontal pipe exit) - MudSystem%Hz_MudDischarged_Volume%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(1) - MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 - - if (MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveHzMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Hz_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif - - enddo -!========================Horizontal PIPE END================= - - - -!========================Utube1 Air Element Removing================= - - !if (UtubeMode1Activated== .true.) then ! StringUpdate == .true. - ! - ! StringDensity_Old= MudSystem%St_Density%Array(2) - ! - ! UtubeMode1Activated= .false. - !endif - -!========================Utube1 Air Element Removing================= - - -!========================Utube2 Removing from Annulus================= - - if (MudSystem%UtubeMode2Activated== .true.) then ! StringUpdate == .true. - MudSystem%TotalAddedVolume=0. - - if (MudSystem%Ann_MudOrKick%Last() == 104) then !movaghati. albate age merge anjam shode bashe moshkeli nist - call RemoveAnnulusMudArrays(MudSystem%Ann_MudOrKick%Length()) - endif - - MudSystem%UtubeMode2Activated= .false. - endif - - -!========================Utube2 Removing from Annulus End================= - -!========================New Pipe Filling================= - - if (MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. - - !NoPipeAdded= F_StringIntervalCounts - F_StringIntervalCountsOld - - - MudSystem%NewPipeFilling=0 - - IF (MudSystem%St_MudOrKick%First() == 104) then - MudSystem%St_MudDischarged_Volume%Array(1) = MudSystem%St_MudDischarged_Volume%Array(1) + sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString)) ! new pipe is filled by air - else - call MudSystem%St_Density%AddToFirst (0.d0) - call MudSystem%St_MudDischarged_Volume%AddToFirst (sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString))) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) - call MudSystem%St_MudOrKick%AddToFirst (104) - endif - - endif - - !F_StringIntervalCountsOld= F_StringIntervalCounts - - - - if (MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) - - - MudSystem%LackageMudVolume= MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element - - - !write(*,*) 'LackageMudVolume=' , LackageMudVolume - - - - if (ABS(MudSystem%St_Density%Array(2) - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddTo (2,MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddTo (2,0.d0) - call MudSystem%St_Mud_Forehead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) - call MudSystem%St_Mud_Backhead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) - call MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) - call MudSystem%St_MudOrKick%AddTo (2,0) - - !StringDensity_Old= Hz_Density%Last() - endif - - - MudSystem%St_MudDischarged_Volume%Array(2)= MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) !(gal) - - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)- min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) ! air(gal) - - !LackageMudVolumeAfterFilling= sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) - sum(St_MudDischarged_Volume%Array(:)) - - MudSystem%LackageMudVolumeAfterFilling= MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero - - - - if (MudSystem%LackageMudVolumeAfterFilling == 0.) then - MudSystem%NewPipeFilling= 1 - call RemoveStringMudArrays(1) - MudSystem%St_Mud_Backhead_X%Array(1) = MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(1) = 2 - endif - - endif - -!========================New Pipe Filling End================= - - - if (MudSystem%NewPipeFilling == 0) then - MudSystem%StringFlowRate= 0. - MudSystem%AnnulusFlowRate= 0. - endif - - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate - - -!========================STRING ENTRANCE================= - if (MudSystem%StringFlowRateFinal > 0.0 .and. ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped - !if (ABS(StringDensity_Old - Hz_Density%Last()) >= DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (0) - - !StringDensity_Old= Hz_Density%Last() - endif - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - -!=============== save String Mud data=========== - MudSystem%StMudVolumeSum= 0.d0 - !St_MudSaved_Density= 0.d0 - MudSystem%St_Saved_MudDischarged_Volume= 0.d0 - !Saved_St_MudOrKick= 0 - !Ann_to_Choke_2mud= .false. - - do imud=1, MudSystem%St_MudDischarged_Volume%Length() - MudSystem%StMudVolumeSum= MudSystem%StMudVolumeSum + MudSystem%St_MudDischarged_Volume%Array(imud) - if ( MudSystem%StMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) ) then - !IF (St_MudOrKick%Array(imud) == 0) THEN - MudSystem%St_MudSaved_Density = MudSystem%St_Density%Array(imud) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%StMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) - !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR - ! St_Kick_Saved_Volume = StMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! Saved_St_MudOrKick= St_MudOrKick%Array (imud) - ! St_KickSaved_Density= MudSystem%St_Density%Array(imud) - !END IF - - do ii= imud + 1, MudSystem%St_MudDischarged_Volume%Length() - !IF (St_MudOrKick%Array(ii) == 0) THEN - MudSystem%St_MudSaved_Density = ((MudSystem%St_MudSaved_Density * MudSystem%St_Saved_MudDischarged_Volume) + (MudSystem%St_Density%Array(ii) * MudSystem%St_MudDischarged_Volume%Array(ii))) / (MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii)) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii) - - !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR - ! St_Kick_Saved_Volume = St_Kick_Saved_Volume + St_MudDischarged_Volume%Array(ii) - ! Saved_St_MudOrKick= St_MudOrKick%Array (ii) - ! St_KickSaved_Density= MudSystem%St_Density%Array(ii) - !END IF - enddo - - - !WRITE (*,*) 'St_Saved_Mud_Volume, St_Kick_Saved_Volume', St_Saved_MudDischarged_Volume, St_Kick_Saved_Volume - exit ! exits do - - endif - - enddo -MudSystem%St_Saved_MudDischarged_Volume_Final= MudSystem%St_Saved_MudDischarged_Volume - -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final - -!====================================================================== - - -!========================STRING================= - -imud=0 - do while (imud < MudSystem%St_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) - endif - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > F_Counts%StringIntervalCounts) then ! last pipe section(string exit) - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Forehead_section%Array(imud)= F_Counts%StringIntervalCounts - - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - - endif - - enddo - - endif - - enddo -!========================STRING END================= - - !write(*,*) ' a before==' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - ! write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - ! - ! - !write(*,*) '==== a before' - - iloc_changedTo2 = 0 - - IF (MudSystem%Op_MudOrKick%Last() /= 0 .and. MudSystem%Op_MudOrKick%Last()==MudSystem%Ann_MudOrKick%First()) then - MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick - iloc_changedTo2= 1 - endif - - - - iloc_edited= 0 - !write(*,*) sum(Op_MudDischarged_Volume%Array(:)) , ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) , Ann_MudDischarged_Volume%First() , sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - if (MudSystem%iLoc==2 .and. sum(MudSystem%Op_MudDischarged_Volume%Array(:))+((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)+MudSystem%Ann_MudDischarged_Volume%First() < sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then - MudSystem%iLoc = 1 - iloc_edited = 1 - !write(*,*) 'hellooooooo' - endif - - -!write(*,*) 'ann-cap:' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1 :F_StringIntervalCounts+F_AnnulusIntervalCounts) ) - - - !write(*,*) 'iloc====' , iloc - !MudVolume_InjectedToBH - - -!=============================Add PumpFlowRate to Bottom Hole ============================== - !if ( MudSystem%AnnulusFlowRate>0.0 ) then - if ( MudSystem%MudVolume_InjectedToBH > 0.0 ) then - - - if (KickOffBottom) then ! (kickOffBottom = F) means kick is next to the bottom hole and usually kick is entering the - AddLocation= MudSystem%Op_Density%Length()-MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick - else - AddLocation= MudSystem%Op_Density%Length()+1 - endif - !write(*,*) 'AddLocation====' , AddLocation - if ( AddLocation== 0) CALL ErrorStop ('AddLocation=0') - - - if ( ABS(MudSystem%St_Density%Last() - MudSystem%Op_Density%Array(AddLocation-1)) >= MudSystem%DensityMixTol ) then - !write(*,*) 'new pocket**' - !write(*,*) 'MudSystem%St_Density%Last()=' , MudSystem%St_Density%Last() - !write(*,*) 'Op_Density%Array(AddLocation-1)=' , Op_Density%Array(AddLocation-1) - - - call MudSystem%Op_Density% AddTo (AddLocation,MudSystem%St_Density%Last()) - !call Op_MudDischarged_Volume%AddTo (AddLocation,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - call MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,MudSystem%MudVolume_InjectedToBH) - call MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) - call MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (AddLocation,0) - else - !write(*,*) 'merge**' - !write(*,*) 'density before=' , Op_Density%Array(AddLocation-1) - !write(*,*) 'MudSystem%St_Density%Last() for mix=' , MudSystem%St_Density%Last() - - !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) - - MudSystem%Op_Density%Array(AddLocation-1)= (MudSystem%Op_Density%Array(AddLocation-1)*MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*MudSystem%MudVolume_InjectedToBH)/(MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%MudVolume_InjectedToBH) - MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + MudSystem%MudVolume_InjectedToBH - !write(*,*) 'density after=' , Op_Density%Array(AddLocation-1) - - endif - - endif -!=======================Add PumpFlowRate to Bottom Hole- End ============================== - - !write(*,*) 'pump added-before add to ann==' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - ! write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - ! - ! - ! - !write(*,*) 'pump added====before add to ann' - - -!=============== save OP Mud data to transfer to the annulus enterance due to tripin or kick - MudSystem%OpMudVolumeSum= 0.d0 - !Op_MudSaved_Density= 0.d0 - !Op_KickSaved_Density= 0.d0 - MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Op_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Op_MudOrKick= 0 - MudSystem%Op_NeededVolume_ToFill= 0.d0 - - - - - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - - MudSystem%OpMudVolumeSum= MudSystem%OpMudVolumeSum + MudSystem%Op_MudDischarged_Volume%Array(imud) - - if ( MudSystem%OpMudVolumeSum > sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then !1st mode - - IF (MudSystem%Op_MudOrKick%Array(imud) == 0) THEN - MudSystem%Op_MudSaved_Density = MudSystem%Op_Density%Array(imud) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - ELSE - - MudSystem%Op_Kick_Saved_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (imud) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(imud) - MudSystem%iLoc= 2 - iloc_changedTo2= 2 - END IF - - do ii= imud + 1, MudSystem%Op_MudDischarged_Volume%Length() - IF (MudSystem%Op_MudOrKick%Array(ii) == 0) THEN - MudSystem%Op_MudSaved_Density = ((MudSystem%Op_MudSaved_Density * MudSystem%Op_Saved_MudDischarged_Volume) + (MudSystem%Op_Density%Array(ii) * MudSystem%Op_MudDischarged_Volume%Array(ii))) / (MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii)) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) - ELSE - MudSystem%Op_Kick_Saved_Volume = MudSystem%Op_Kick_Saved_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (ii) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(ii) - MudSystem%iLoc= 2 - iloc_changedTo2= 3 - END IF - enddo - - exit ! exits do - - endif - - enddo - - if ( sum(MudSystem%Op_MudDischarged_Volume%Array(:)) < sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then !2nd & 3rd mode - - MudSystem%Op_NeededVolume_ToFill= sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - sum(MudSystem%Op_MudDischarged_Volume%Array(:)) - endif - - - ! - !write(*,*) 'Op_NeededVolume_ToFill=' , Op_NeededVolume_ToFill - !write(*,*) 'Op_Saved_MudDischarged_Volume=' , Op_Saved_MudDischarged_Volume - !write(*,*) 'Op_Kick_Saved_Volume=' , Op_Kick_Saved_Volume - ! - !write(*,*) 'op cap=' , sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - !write(*,*) ' op sum mud=' , sum(Op_MudDischarged_Volume%Array(:)) - - - - - -!====================================================================== - - - - -!========================Tripping Out- 1st & 3rd Mode==================== - - - - if ( (MudSystem%Op_Kick_Saved_Volume > 0.0 .or. MudSystem%Op_Saved_MudDischarged_Volume> 0.0) .or. & ! 1st Mode-Pump flow is more than trip out so fluid Level in Annulus Increases - (MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity)) ) then !3rd Mode-fluid Level in Annulus Increases - - - !if ( Op_Kick_Saved_Volume > 0.0 .or. Op_Saved_MudDischarged_Volume> 0.0 ) write(*,*) 'trip out 1st mode' - - if ( MudSystem%Op_NeededVolume_ToFill > 0.0 .and. MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity) ) then - ! write(*,*) 'trip out 3rd mode' - - MudSystem%NewVolume= 0.d0 ! for condition iloc=1 - - SavedDensityForOp= MudSystem%Ann_Density%Array(1) - - ExcessMudVolume_Remained= MudSystem%Op_NeededVolume_ToFill - - - imud=1 - - Do - - if(MudSystem%Ann_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then - ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystem%Ann_MudDischarged_Volume%Array(imud) - call MudSystem%Ann_MudDischarged_Volume%Remove (imud) - call MudSystem%Ann_Mud_Backhead_X%Remove (imud) - call MudSystem%Ann_Mud_Backhead_section%Remove (imud) - call MudSystem%Ann_Mud_Forehead_X%Remove (imud) - call MudSystem%Ann_Mud_Forehead_section%Remove (imud) - call MudSystem%Ann_Density%Remove (imud) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%Ann_MudOrKick%Remove (imud) - - elseif(MudSystem%Ann_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained - exit - - else !(Ann_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) - call MudSystem%Ann_MudDischarged_Volume%Remove (imud) - call MudSystem%Ann_Mud_Backhead_X%Remove (imud) - call MudSystem%Ann_Mud_Backhead_section%Remove (imud) - call MudSystem%Ann_Mud_Forehead_X%Remove (imud) - call MudSystem%Ann_Mud_Forehead_section%Remove (imud) - call MudSystem%Ann_Density%Remove (imud) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%Ann_MudOrKick%Remove (imud) - exit - - endif - - enddo - - - !write(*,*) 'Op_NeededVolume_ToFill=' ,Op_NeededVolume_ToFill - !write(*,*) 'ABS(DeltaVolumeAnnulusCapacity)=' ,ABS(DeltaVolumeAnnulusCapacity) - !write(*,*) 'Op_MudOrKick%Last()=' ,Op_MudOrKick%Last() - !write(*,*) 'iloc=' ,iloc - !write(*,*) 'iloc_edited=' ,iloc_edited - - - endif - - - ! (MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) - DeltaVolumeOp will be added to annulus - - !if (iLoc == 1) then - MudSystem%MudSection= F_Counts%StringIntervalCounts+1 - MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - !elseif (iLoc == 2) then - ! MudSection= Kick_Forehead_section - ! BackheadX= Kick_Forehead_X - !endif - -!========================ANNULUS ENTRANCE==================== - !if (KickMigration_2SideBit == .FALSE.) then - ! if ( ABS(AnnulusSuctionDensity_Old - MudSystem%St_Density%Last()) >= DensityMixTol ) then ! new mud is pumped - ! call Ann_Density%AddTo (iLoc,MudSystem%St_Density%Last()) - ! call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0) - ! call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) - ! call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection) - ! call Ann_Mud_Backhead_X%AddTo (iLoc,BackheadX) - ! call Ann_Mud_Backhead_section%AddTo (iLoc,MudSection) - ! call Ann_RemainedVolume_in_LastSection%AddTo (iLoc,0.0d0) - ! call Ann_EmptyVolume_inBackheadLocation%AddTo (iLoc,0.0d0) - ! call Ann_MudOrKick%AddTo (iLoc,0) - ! call Ann_CuttingMud%AddTo (iLoc,0) - ! - ! AnnulusSuctionDensity_Old= MudSystem%St_Density%Last() - ! - ! MudIsChanged= .true. - ! endif - ! - ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) - ((2-iloc)*ABS(DeltaVolumePipe)) !(gal) - ! - !endif - - - - - MudSystem%Ann_Mud_Backhead_section%Array(1)= MudSystem%MudSection !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) - MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%BackheadX - - - - !iloc=1 : (2-iloc)=1 normal - !iloc=2 : (2-iloc)=0 kick influx or migration is in annulus - -!========================Same to Tripping In==================== - - !write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume - - - if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then !1st Mode - write(*,*) 'Kick influx enters Annulus' - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< - call MudSystem%Ann_CuttingMud%AddToFirst (0) - elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume - endif - - - - if ( MudSystem%Op_NeededVolume_ToFill > 0.0 .and. (MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity)) .and. MudSystem%Op_MudOrKick%Last() == 0 .and. (MudSystem%iLoc==2 .or. iloc_edited==1)) then !3rd Mode - !write(*,*) 'checkpoint 0' - !! for avoid kick separation -Op_MudOrKick%Last() == 0: because of pump - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ! =volume that should be added to iloc=2 in Ann - call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann in %%1 section - if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ) then! 1st in Ann = kick ,, we expect: ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)= OpMudVolLast - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ! kick - else - call RemoveAnnulusMudArrays(1) !kick is removed - MudSystem%iLoc= 1 - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - write(*,*) 'little expand' - ! including a little expand - endif - endif - - if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then !1st Mode - MudSystem%NewDensity= MudSystem%Op_MudSaved_Density - !write(*,*) 'iloc,...' , iloc,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline),Op_Saved_MudDischarged_Volume - if (MudSystem%iLoc==1) then - !write(*,*) 'checkpoint 1' - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume - elseif (real(((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)) - real(MudSystem%Op_Saved_MudDischarged_Volume) > 0.d0 ) then ! for avoid kick separation - !write(*,*) 'checkpoint 2' - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) !- Op_Saved_MudDischarged_Volume - call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann - if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) ) then! 1st in Ann = kick - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) !kick - else - call RemoveAnnulusMudArrays(1) !kick is removed - MudSystem%iLoc =1 - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) - write(*,*) 'little expand' - - ! including a little expand - endif - - - else ! iloc==2 , ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) == Op_Saved_MudDischarged_Volume - !write(*,*) 'checkpoint 3' - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume ! it is normal mode - endif - - - endif - - !write(*,*) 'NewVolume=' ,NewVolume - - - if( MudSystem%Ann_Density%Length() == 1 .and. MudSystem%iLoc ==2 ) then - - write(*,*) '***errorb****==' - - write(*,*) 'iloc_edited=' , iloc_edited - write(*,*) 'iloc_changedTo2=' , iloc_changedTo2 - - write(*,*) 'Op_Capacity===' , sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - - WRITE (*,*) 'Op_Saved_MudDischarged_Volume, Op_Kick_Saved_Volume',MudSystem%Op_Saved_MudDischarged_Volume, MudSystem%Op_Kick_Saved_Volume - - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - write(*,*) 'Op:', imud, MudSystem%Op_MudDischarged_Volume%Array(imud), MudSystem%Op_Density%Array(imud) ,MudSystem%Op_MudOrKick%Array(imud) - enddo - - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - write(*,*) 'Ann:', imud, MudSystem%Ann_MudDischarged_Volume%Array(imud), MudSystem%Ann_Density%Array(imud) ,MudSystem%Ann_MudOrKick%Array(imud) - enddo - - - - write(*,*) '==***errorb****' - endif - - - - - - if ((ROP_Bit%RateOfPenetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & !%%1 section - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - !write(*,*) '%%1 section a)' - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - else ! 2-Merging conditions are not meeted, so new pocket - !write(*,*) '%%1 section b)' - - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) - !write(*,*) 'd) annLength=' , Ann_Density%Length() - - endif - - - - -!========================Same to Tripping In - End==================== - - !write(*,*) 'b)Ann_Mud sum=' , sum(Ann_MudDischarged_Volume%Array(:)) - - !write(*,*) 'no======2' - ! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - ! - ! write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - ! - ! - !write(*,*) '2======no' - -!=============== save Ann Mud data to transfer to the ChokeLine enterance - MudSystem%AnnMudVolumeSum= 0.d0 - !Ann_MudSaved_Density= 0.d0 - !Ann_KickSaved_Density= 0.d0 - MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Ann_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Ann_MudOrKick= 0 - MudSystem%Ann_to_Choke_2mud= .false. - - - - - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - - MudSystem%AnnMudVolumeSum= MudSystem%AnnMudVolumeSum + MudSystem%Ann_MudDischarged_Volume%Array(imud) - - if ( MudSystem%AnnMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) ) then - - IF (MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN - MudSystem%Ann_MudSaved_Density = MudSystem%Ann_Density%Array(imud) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - ELSEIF (MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (imud) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(imud) - END IF - - do ii= imud + 1, MudSystem%Ann_MudDischarged_Volume%Length() - IF (MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN - MudSystem%Ann_MudSaved_Density = ((MudSystem%Ann_MudSaved_Density * MudSystem%Ann_Saved_MudDischarged_Volume) + (MudSystem%Ann_Density%Array(ii) * MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii)) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Ann_to_Choke_2mud= .true. - ELSEIF (MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%Ann_Kick_Saved_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (ii) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(ii) - END IF - enddo - - exit ! exits do - - endif - - enddo - -MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume -MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume - !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:NoPipeSections)) - !write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) - !NoGasPocket -!write(*,*) 'Ann_Saved_Mud_Vol,Ann_Kick_Saved_Vol=' , Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume - -!====================================================================== - - - !write(*,*) 'Ann_Saved_Mud=' , Ann_Saved_MudDischarged_Volume -!======================== Annulus ==================== - - !MudIsChanged= .false. - -imud= 0 - - do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) - endif - - ! write(*,*) 'imud==' , imud - !write(*,*) '***)Ann_Mud_Backhead_section(imud)= ' , Ann_Mud_Backhead_section%Array(imud), Ann_density%Array(imud) - - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections - - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif - - enddo - - if (MudSystem%Ann_Mud_Forehead_X%Last() < MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) then - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length()) = MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) ! for error preventing - endif - -!========================ANNULUS END================= - - - -!************************************************************************************************************************* - -!========================Tripping Out- 2nd Mode==================== - - - elseif ( MudSystem%Op_NeededVolume_ToFill > ABS(MudSystem%DeltaVolumeAnnulusCapacity) ) then !pump is off or Pump flow is less than trip out so fluid Level in Annulus decreases - !write(*,*) 'trip out 2nd mode' - - - SavedDensityForOp= MudSystem%Ann_Density%Array(1) -!========================ANNULUS ENTRANCE==================== - - ! <<< SIMILAR TO UTUBE 2 >>> - if ( MudSystem%Ann_Density%Last() /= 0.0 ) then ! new mud is pumped - call MudSystem%Ann_Density%Add (0.0d0) - call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) - call MudSystem%Ann_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Forehead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Backhead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Ann_MudOrKick%Add (104) - call MudSystem%Ann_CuttingMud%Add (0) - - !AnnulusSuctionDensity_Old= Hz_Density%Last() - endif - - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_Mud_Forehead_section%Length())= MudSystem%NoPipeSections !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length())= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Last()+ (MudSystem%Op_NeededVolume_ToFill - ABS(MudSystem%DeltaVolumeAnnulusCapacity)) ! Op_NeededVolume_ToFill !ABS(DeltaVolumePipe) - ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) !(gal) - -!=================================================================== - - - - if ( (MudSystem%iLoc==2 .or. iloc_edited==1) .and. MudSystem%Op_MudOrKick%Last()==0 ) then ! for avoid kick separation - !write(*,*) 'here mud should be removed from Op last' - - if (abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%Op_Density%Last())< MudSystem%DensityMixTol) then - - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_Density%Last()*MudSystem%Op_MudDischarged_Volume%Last())/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_MudDischarged_Volume%Last()) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - - else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%Op_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%Op_MudDischarged_Volume%Last()) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) - endif - - MudSystem%Op_NeededVolume_ToFill= MudSystem%Op_NeededVolume_ToFill + MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) - - call RemoveOpMudArrays(MudSystem%Op_MudOrKick%Length()) - - - endif -!=================================================================== - - -!=============== save Ann Mud data to transfer to the ChokeLine enterance - !AnnMudVolumeSum= 0.d0 - !!Ann_MudSaved_Density= 0.d0 - !!Ann_KickSaved_Density= 0.d0 - MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Ann_Kick_Saved_Volume= 0.d0 - !Saved_Ann_MudOrKick= 0 - !Ann_to_Choke_2mud= .false. - - - - - !do imud=1, Ann_MudDischarged_Volume%Length() - ! - ! AnnMudVolumeSum= AnnMudVolumeSum + Ann_MudDischarged_Volume%Array(imud) - ! - ! if ( AnnMudVolumeSum > sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ) then - ! - ! IF (Ann_MudOrKick%Array(imud) == 0) THEN - ! Ann_MudSaved_Density = Ann_Density%Array(imud) - ! Ann_Saved_MudDischarged_Volume = AnnMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! ELSEIF (Ann_MudOrKick%Array(imud) > 0 .AND. Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR - ! Ann_Kick_Saved_Volume = AnnMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! Saved_Ann_MudOrKick= Ann_MudOrKick%Array (imud) - ! Ann_KickSaved_Density= Ann_Density%Array(imud) - ! END IF - ! - ! do ii= imud + 1, Ann_MudDischarged_Volume%Length() - ! IF (Ann_MudOrKick%Array(ii) == 0) THEN - ! Ann_MudSaved_Density = ((Ann_MudSaved_Density * Ann_Saved_MudDischarged_Volume) + (Ann_Density%Array(ii) * Ann_MudDischarged_Volume%Array(ii))) / (Ann_Saved_MudDischarged_Volume + Ann_MudDischarged_Volume%Array(ii)) - ! Ann_Saved_MudDischarged_Volume = Ann_Saved_MudDischarged_Volume + Ann_MudDischarged_Volume%Array(ii) - ! Ann_to_Choke_2mud= .true. - ! ELSEIF (Ann_MudOrKick%Array(ii) > 0 .AND. Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR - ! Ann_Kick_Saved_Volume = Ann_Kick_Saved_Volume + Ann_MudDischarged_Volume%Array(ii) - ! Saved_Ann_MudOrKick= Ann_MudOrKick%Array (ii) - ! Ann_KickSaved_Density= Ann_Density%Array(ii) - ! END IF - ! enddo - ! - ! exit ! exits do - ! - ! endif - ! - !enddo - - - ! write(*,*) 'check point 2==' - ! - ! - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - ! - ! write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - ! write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - ! - ! - !write(*,*) '==check point 2' - - - - - -MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume -MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume - !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - !write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - - !write(*,*) 'Ann_Saved_MudDischarged_Volume_Final=' , Ann_Saved_MudDischarged_Volume_Final - - - -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) - !! NoGasPocket > 0 .AND. - -!write(*,*) 'Ann_Saved_Mud_Vol,Ann_Kick_Saved_Vol=' , Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume - - -!====================================================================== - -!========================ANNULUS==================== - ! <<< SIMILAR TO UTUBE 2 >>> - - !write(*,*) Ann_MudOrKick%Last(), 'DeltaVolumePipe , after volume=' ,ABS(DeltaVolumePipe), Ann_MudDischarged_Volume%Last() -imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 - - do while (imud > 1) - imud = imud - 1 - - if (imud< MudSystem%Ann_Mud_Forehead_X%Length()) then - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud+1) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud+1) - endif - - -! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then - !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then - !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(imud) - imud= imud-1 - cycle - endif - MudSystem%LostInTripOutIsDone= .true. - ENDIF -! Fracture Shoe Lost >>> - - - - - - - - - !write(*,*) 'a)imud,Ann_Mud_Forehead_section=',imud,Ann_Mud_Forehead_section%Array(imud) - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) - ! +1 for string , -1 for annulus - - !write(*,*) 'b)imud,Forehead_X,Xstart_PipeSection=',imud,Ann_Mud_Forehead_X%Array(imud),Xstart_PipeSection(Ann_Mud_Forehead_section%Array(imud)) - - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) - ! 7.48051948 is for gal to ft^3 - else - MudSystem%isection= MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection < F_Counts%StringIntervalCounts+1) then ! last pipe section(well exit) F_Counts%StringIntervalCounts+1 is the first section in Annulus - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= F_Counts%StringIntervalCounts+1 - - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) - exit - else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection- 1 - - - endif - - enddo - - endif - - enddo -!========================ANNULUS END================= - - endif ! end of 1st &3rd & 2nd Mode - - -!************************************************************************************************************************* - - - - - - -!======================== Bottom Hole Entrance ========================== - !if (iloc == 1) then - if ( MudSystem%Op_NeededVolume_ToFill > 0.0 ) then ! it is needed for 2nd & 3rd mode - !write(*,*) 'op add for 2nd & 3rd mode done' - - - - if ( ABS(MudSystem%Op_Density%Last() - SavedDensityForOp ) >= MudSystem%DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Last()>42.) ) then ! 1-Merging conditions are not meeted, so new pocket - - call MudSystem%Op_Density%Add (SavedDensityForOp) - call MudSystem%Op_MudDischarged_Volume%Add (MudSystem%Op_NeededVolume_ToFill) - call MudSystem%Op_Mud_Forehead_X%Add (0.0d0) - call MudSystem%Op_Mud_Forehead_section%Add (1) - call MudSystem%Op_Mud_Backhead_X%Add (0.0d0) - call MudSystem%Op_Mud_Backhead_section%Add (1) - call MudSystem%Op_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Op_MudOrKick%Add (MudSystem%Ann_MudOrKick%Array(1)) - else ! 2-Pockets are Merged - - MudSystem%Op_Density%Array (MudSystem%Op_Density%Length())= (SavedDensityForOp*MudSystem%Op_NeededVolume_ToFill+MudSystem%Op_Density%Last()*MudSystem%Op_MudDischarged_Volume%Last())/(MudSystem%Op_MudDischarged_Volume%Last()+MudSystem%Op_NeededVolume_ToFill) - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_Density%Length()) + MudSystem%Op_NeededVolume_ToFill - MudSystem%Op_RemainedVolume_in_LastSection%Array (MudSystem%Op_Density%Length())= 0.0 - MudSystem%Op_EmptyVolume_inBackheadLocation%Array (MudSystem%Op_Density%Length())= 0.0 - - endif - - endif - - - - -!============================= Bottom Hole ============================== - -imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) - endif - - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) - ! 7.48051948 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) - !if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts - - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call MudSystem%Op_MudDischarged_Volume%Remove (imud) - call MudSystem%Op_Mud_Backhead_X%Remove (imud) - call MudSystem%Op_Mud_Backhead_section%Remove (imud) - call MudSystem%Op_Mud_Forehead_X%Remove (imud) - call MudSystem%Op_Mud_Forehead_section%Remove (imud) - call MudSystem%Op_Density%Remove (imud) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%Op_MudOrKick%Remove (imud) - - endif - - exit - endif - - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) - exit - else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif - - enddo - - - -!========================Bottom Hole END================= - ! write(*,*) 'after sorting==' - !!! - ! do imud=1, Op_MudDischarged_Volume%Length() - ! write(*,*) 'Op:', imud, Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) ,Op_MudOrKick%Array(imud) - ! enddo - ! - ! do imud=1, Ann_MudDischarged_Volume%Length() - ! write(*,*) 'Ann:', imud, Ann_MudDischarged_Volume%Array(imud), Ann_Density%Array(imud) ,Ann_MudOrKick%Array(imud) - ! enddo - !!! - !! write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - !! write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) - !!! - !!! - !write(*,*) '==after sorting' - -!========================================================= - - - MudSystem%total_injected = MudSystem%total_injected + MudSystem%MudVolume_InjectedFromAnn - - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_injected= 0. - endif - !write(*,*) ' MudSystem%MudVolume_InjectedFromAnn =' , MudSystem%MudVolume_InjectedFromAnn - - !write(*,*) ' total injected-tripout =' , total_injected - !write(*,*) ' injected-tripout =' , MudSystem%MudVolume_InjectedFromAnn - - - - - - - - end subroutine TripOut_and_Pump - - - diff --git a/Equipments/MudSystem-old/Utube1_and_Trip_In.f90 b/Equipments/MudSystem-old/Utube1_and_Trip_In.f90 deleted file mode 100644 index 3530fa2..0000000 --- a/Equipments/MudSystem-old/Utube1_and_Trip_In.f90 +++ /dev/null @@ -1,532 +0,0 @@ -SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect string to annulus - - use UTUBEVARSModule - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - USE sROP_Variables - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - Use CShoeVariables - Use CUnityOutputs - - implicit none - - write(*,*) 'Utube1 code' -!===========================================================WELL============================================================ -!===========================================================WELL============================================================ - MudSystem%UtubeMode1Activated= .true. - !write(*,*) 'QUTubeInput=' , QUTubeInput - !Qinput=5000. - MudSystem%StringFlowRate= QUTubeInput ! (gpm) - MudSystem%AnnulusFlowRate= QUTubeInput - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate -!=========================================== - - if (MudSystem%FirstSetUtube1==0) then - ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial - ! call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) - ! call St_Mud_Backhead_section%AddToFirst (1) - ! call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts)) - ! call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) - ! call MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) - ! call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! - ! call Ann_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval((F_StringIntervalCounts+F_BottomHoleIntervalCounts+1):F_IntervalsTotalCounts)%Volume))) !startup initial - ! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) - ! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - ! call Ann_Mud_Forehead_X%AddToFirst (Xend_PipeSection(NoPipeSections)) - ! call Ann_Mud_Forehead_section%AddToFirst (NoPipeSections) - ! call Ann_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) - ! call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - !Hz_Density%Array(:)= 0.0 !commented - !Hz_MudOrKick%Array(:)= 104 !commented - - MudSystem%Hz_Density_Utube= 0.0 - MudSystem%Hz_MudOrKick_Utube= 104 - - MudSystem%FirstSetUtube1= 1 - endif - - - - -!========================Horizontal PIPE ENTRANCE================= - - !if (SuctionDensity_Old >= (ActiveDensity+0.05) .or. SuctionDensity_Old <= (ActiveDensity-0.05)) then ! new mud is pumped - ! !ImudCount= ImudCount+1 - ! !SuctionMud= ImudCount - ! call Hz_Density%AddToFirst (REAL(ActiveDensity)) !ActiveDensity : badan in moteghayer bayad avaz beshe - ! call Hz_MudDischarged_Volume%AddToFirst (0.0d0) - ! call Hz_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(1)) - ! call Hz_Mud_Forehead_section%AddToFirst (1) - ! call Hz_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) - ! call Hz_Mud_Backhead_section%AddToFirst (1) - ! call Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call Hz_MudOrKick%AddToFirst (0) - ! - ! SuctionDensity_Old= ActiveDensity - !endif - -!========================Horizontal PIPE STRING================= - - !commented - -! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) -! -!imud=0 -! do while (imud < Hz_Mud_Forehead_X%Length()) -! imud = imud + 1 -! -! if (imud> 1) then -! Hz_Mud_Backhead_X%Array(imud)= Hz_Mud_Forehead_X%Array(imud-1) -! Hz_Mud_Backhead_section%Array(imud)= Hz_Mud_Forehead_section%Array(imud-1) -! endif -! -! -! DirectionCoef= (Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Hz_Mud_Backhead_section%Array(imud))) & -! / ABS(Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Hz_Mud_Backhead_section%Array(imud))) -! ! +1 for string , -1 for annulus -! -! -! Hz_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))- Hz_Mud_Backhead_X%Array(imud))* & -! Area_PipeSectionFt(Hz_Mud_Backhead_section%Array(imud)) !(ft^3) -! Hz_EmptyVolume_inBackheadLocation%Array(imud)= Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948 ! ft^3 to gal -! -! -! if ( Hz_MudDischarged_Volume%Array(imud) <= Hz_EmptyVolume_inBackheadLocation%Array(imud)) then -! Hz_Mud_Forehead_section%Array(imud)= Hz_Mud_Backhead_section%Array(imud) -! Hz_Mud_Forehead_X%Array(imud)= Hz_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Hz_MudDischarged_Volume%Array(imud)/7.48051948)/Area_PipeSectionFt(Hz_Mud_Backhead_section%Array(imud)) -! ! 7.48 is for gal to ft^3 -! else -! -! isection= Hz_Mud_Backhead_section%Array(imud)+1 -! Hz_RemainedVolume_in_LastSection%Array(imud)= Hz_MudDischarged_Volume%Array(imud)- Hz_EmptyVolume_inBackheadLocation%Array(imud) -! -! do -! if (isection > 1) then ! (horizontal pipe exit) -! Hz_MudDischarged_Volume%Array(imud)= Hz_MudDischarged_Volume%Array(imud)- Hz_RemainedVolume_in_LastSection%Array(imud) -! Hz_Mud_Forehead_X%Array(imud)= Xend_PipeSection(1) -! Hz_Mud_Forehead_section%Array(imud)= 1 -! if (Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string -! call Hz_MudDischarged_Volume%Remove (imud) -! call Hz_Mud_Backhead_X%Remove (imud) -! call Hz_Mud_Backhead_section%Remove (imud) -! call Hz_Mud_Forehead_X%Remove (imud) -! call Hz_Mud_Forehead_section%Remove (imud) -! call Hz_Density%Remove (imud) -! call Hz_RemainedVolume_in_LastSection%Remove (imud) -! call Hz_EmptyVolume_inBackheadLocation%Remove (imud) -! call Hz_MudOrKick%Remove (imud) -! -! endif -! exit -! endif -! -! xx= Hz_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal) -! -! if (xx<= 1.0) then -! Hz_Mud_Forehead_section%Array(imud)= isection -! Hz_Mud_Forehead_X%Array(imud)= (xx * (Xend_PipeSection(isection)- Xstart_PipeSection(isection)))+ Xstart_PipeSection(isection) -! exit -! else -! Hz_RemainedVolume_in_LastSection%Array(imud)= Hz_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection) -! isection= isection+ 1 -! -! -! endif -! -! enddo -! -! endif -! -! enddo - - !commented - -!========================Horizontal PIPE END================= - -!========================STRING ENTRANCE================= - !write(*,*) 'a) MudSystem%St_Density%Length()=' , MudSystem%St_Density%Length() - - if (ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density_Utube) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density_Utube) - call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 - - !StringDensity_Old= Hz_Density_Utube - endif - !write(*,*) 'b) MudSystem%St_Density%Length()=' , MudSystem%St_Density%Length() - !write(*,*) 'b) MudSystem%St_Density%Array(1)=' , MudSystem%St_Density%Array(1) - !write(*,*) 'b) St_MudOrKick%Array(1)=' , St_MudOrKick%Array(1) - - -!========================STRING================= - !WRITE (*,*) 'Utube1 MudSystem%StringFlowRate', MudSystem%StringFlowRate - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.d0)*MudSystem%DeltaT_Mudline) !(gal) - -imud=0 - do while (imud < MudSystem%St_Mud_Forehead_X%Length()) - imud = imud + 1 - - - if (imud> 1) then - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) - endif - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - else - - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > F_Counts%StringIntervalCounts) then ! last pipe section(string exit) F_Counts%StringIntervalCounts includes Horizontal line - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Forehead_section%Array(imud)= F_Counts%StringIntervalCounts - - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - - endif - - enddo - - endif - - enddo -!========================STRING END================= - -!========================== tripping in for OP remove =============================== - - !if (DeltaVolumeOp>0. .and. DeltaVolumeOp< Op_MudDischarged_Volume%Last()) then - ! Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length())= Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()) - DeltaVolumeOp - !else - ! Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()-1)= Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()-1) - (DeltaVolumeOp-Op_MudDischarged_Volume%Last()) - ! - ! call Op_MudDischarged_Volume%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Backhead_X%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Backhead_section%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Forehead_X%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Forehead_section%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Density%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_RemainedVolume_in_LastSection%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_EmptyVolume_inBackheadLocation%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_MudOrKick%Remove (Op_MudDischarged_Volume%Length()) - !endif - ! - -!============================= Bottom Hole ============================== - - !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux -imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) - endif - - - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) - if( imud==1) MudSystem%KickDeltaVinAnnulus= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts - - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveOpMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) - exit - else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif - - - if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then - MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() - do while(imud < MudSystem%totalLength) - - !imud = imud + 1 - call RemoveOpMudArrays(MudSystem%totalLength) - MudSystem%totalLength = MudSystem%totalLength - 1 - - - enddo - - exit ! - - endif - - !WRITE(*,*) imud,'Op_MudDischarged_Volume%Array(imud)' , Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) - - - - enddo - - - !write(*,*) 'Op_Mud_Forehead_X%Length()' , Op_Mud_Forehead_X%Length() - ! - ! WRITE(*,*) 'Xend_PipeSection(F_StringIntervalCounts)' , Xend_PipeSection(F_StringIntervalCounts) - ! WRITE(*,*) 'Op_Mud_Backhead_X%Array(1)' , Op_Mud_Backhead_X%Array(1) - ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(1)' , Op_Mud_Forehead_X%Array(1) - ! WRITE(*,*) 'Op_Mud_Backhead_X%Array(2)' , Op_Mud_Backhead_X%Array(2) - ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(2)' , Op_Mud_Forehead_X%Array(2) -!========================Bottom Hole END================= - - if (MudSystem%iLoc == 1) then - MudSystem%MudSection= F_Counts%StringIntervalCounts+1 - MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - elseif (MudSystem%iLoc == 2) then - MudSystem%MudSection= MudSystem%Kick_Forehead_section - MudSystem%BackheadX= MudSystem%Kick_Forehead_X - endif - -!========================ANNULUS ENTRANCE==================== - - !write(*,*) 'iloc=====' , iLoc - if ((ABS(MudSystem%AnnulusSuctionDensity_Old - MudSystem%St_Density%Last()) >= MudSystem%DensityMixTol) .OR. (MudSystem%DeltaVolumeOp == 0.0 .and. ABS(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%St_Density%Last())>=MudSystem%DensityMixTol .and. MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%St_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) - - MudSystem%AnnulusSuctionDensity_Old= MudSystem%St_Density%Last() - - MudSystem%MudIsChanged= .true. - endif - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+ ((MudSystem%AnnulusFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - -!========================Tripping In==================== - -!write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - if (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) - - !write(*,*) 'Tripping In' - - MudSystem%NewDensity= (MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline)+MudSystem%Op_Density%Last()*MudSystem%DeltaVolumeOp)/(((MudSystem%AnnulusFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp) - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp - - !write(*,*) 'Ann_MudDischarged_Volume%Array(1)=', Ann_MudDischarged_Volume%Array(1), 'NewVolume=', NewVolume - - if (abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) then ! 1-Pockets are Merged - (ROP is 0) - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%DeltaVolumeOp - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) - - endif - - - elseif (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .true. .and. ROP_Bit%RateOfPenetration==0.) then - MudSystem%Ann_Density%Array(MudSystem%iLoc)= MudSystem%NewDensity - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - endif - - -!========================Tripping In - End==================== - - -!======================== ANNULUS ==================== - - MudSystem%MudIsChanged= .false. - -imud= 0 - - do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) - endif - - -! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then - !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then - !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(imud) - imud= imud-1 - cycle - endif - ENDIF -! Fracture Shoe Lost >>> - - - - - - - - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) - ! 7.48 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections - - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) - exit - else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif - - enddo -!========================ANNULUS END================= - - !if ( WellisNOTFull == .false. ) then - ! write(*,*) 'MudSystem%AnnulusFlowRate==' , MudSystem%AnnulusFlowRate - ! call Set_FlowRate(real(100.*min(MudSystem%AnnulusFlowRate,PedalMeter)/(PedalMeter/10.), 8)) - ! - ! - !endif - - - -end subroutine Utube1_and_TripIn \ No newline at end of file diff --git a/Equipments/MudSystem-old/Utube2_and_Trip_In.f90 b/Equipments/MudSystem-old/Utube2_and_Trip_In.f90 deleted file mode 100644 index 8abe51e..0000000 --- a/Equipments/MudSystem-old/Utube2_and_Trip_In.f90 +++ /dev/null @@ -1,517 +0,0 @@ -SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect annulus to string - - use UTUBEVARSModule - Use GeoElements_FluidModule - USE CMudPropertiesVariables - USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity - Use CShoeVariables - - implicit none - - write(*,*) 'Utube2 code' - -!===========================================================WELL============================================================ -!===========================================================WELL============================================================ - - MudSystem%UtubeMode2Activated= .true. - write(*,*) 'QUtubeOutput=' , QUtubeOutput - !QUTubeInput=5000. - MudSystem%StringFlowRate= QUtubeOutput ! (gpm) - MudSystem%AnnulusFlowRate= QUtubeOutput - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate -!=========================================== - - if (MudSystem%FirstSetUtube2==0) then - ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial - ! call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) - ! call St_Mud_Backhead_section%AddToFirst (1) - ! call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts)) - ! call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) - ! call MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) - ! call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! - ! call Ann_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval((F_StringIntervalCounts+F_BottomHoleIntervalCounts+1):F_IntervalsTotalCounts)%Volume))) !startup initial - ! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) - ! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) - ! call Ann_Mud_Forehead_X%AddToFirst (Xend_PipeSection(NoPipeSections)) - ! call Ann_Mud_Forehead_section%AddToFirst (NoPipeSections) - ! call Ann_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) - ! call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - !Hz_Density%Array(:)= 0.0 - !Hz_MudOrKick%Array(:)= 104 - - MudSystem%Hz_Density_Utube= 0.0 - MudSystem%Hz_MudOrKick_Utube= 104 - - MudSystem%FirstSetUtube2= 1 - endif - - - - -!========================Horizontal PIPE ENTRANCE================= - - !if (SuctionDensity_Old >= (ActiveDensity+0.05) .or. SuctionDensity_Old <= (ActiveDensity-0.05)) then ! new mud is pumped - ! !ImudCount= ImudCount+1 - ! !SuctionMud= ImudCount - ! call Hz_Density%AddToFirst (REAL(ActiveDensity)) !ActiveDensity : badan in moteghayer bayad avaz beshe - ! call Hz_MudDischarged_Volume%AddToFirst (0.0d0) - ! call Hz_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(1)) - ! call Hz_Mud_Forehead_section%AddToFirst (1) - ! call Hz_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) - ! call Hz_Mud_Backhead_section%AddToFirst (1) - ! call Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - ! call Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - ! call Hz_MudOrKick%AddToFirst (0) - - ! deltaV= 0. - ! - ! SuctionDensity_Old= ActiveDensity - !endif - -!========================Horizontal PIPE STRING================= - - !commented - -! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) -! -!imud=0 -! do while (imud < Hz_Mud_Forehead_X%Length()) -! imud = imud + 1 -! -! if (imud> 1) then -! Hz_Mud_Backhead_X%Array(imud)= Hz_Mud_Forehead_X%Array(imud-1) -! Hz_Mud_Backhead_section%Array(imud)= Hz_Mud_Forehead_section%Array(imud-1) -! endif -! -! -! DirectionCoef= (Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Hz_Mud_Backhead_section%Array(imud))) & -! / ABS(Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Hz_Mud_Backhead_section%Array(imud))) -! ! +1 for string , -1 for annulus -! -! -! Hz_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))- Hz_Mud_Backhead_X%Array(imud))* & -! Area_PipeSectionFt(Hz_Mud_Backhead_section%Array(imud)) !(ft^3) -! Hz_EmptyVolume_inBackheadLocation%Array(imud)= Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948 ! ft^3 to gal -! -! -! if ( Hz_MudDischarged_Volume%Array(imud) <= Hz_EmptyVolume_inBackheadLocation%Array(imud)) then -! Hz_Mud_Forehead_section%Array(imud)= Hz_Mud_Backhead_section%Array(imud) -! Hz_Mud_Forehead_X%Array(imud)= Hz_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Hz_MudDischarged_Volume%Array(imud)/7.48051948)/Area_PipeSectionFt(Hz_Mud_Backhead_section%Array(imud)) -! ! 7.48051948 is for gal to ft^3 -! else -! -! isection= Hz_Mud_Backhead_section%Array(imud)+1 -! Hz_RemainedVolume_in_LastSection%Array(imud)= Hz_MudDischarged_Volume%Array(imud)- Hz_EmptyVolume_inBackheadLocation%Array(imud) -! -! do -! if (isection > 1) then ! (horizontal pipe exit) -! Hz_MudDischarged_Volume%Array(imud)= Hz_MudDischarged_Volume%Array(imud)- Hz_RemainedVolume_in_LastSection%Array(imud) -! Hz_Mud_Forehead_X%Array(imud)= Xend_PipeSection(1) -! Hz_Mud_Forehead_section%Array(imud)= 1 -! if (Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string -! call Hz_MudDischarged_Volume%Remove (imud) -! call Hz_Mud_Backhead_X%Remove (imud) -! call Hz_Mud_Backhead_section%Remove (imud) -! call Hz_Mud_Forehead_X%Remove (imud) -! call Hz_Mud_Forehead_section%Remove (imud) -! call Hz_Density%Remove (imud) -! call Hz_RemainedVolume_in_LastSection%Remove (imud) -! call Hz_EmptyVolume_inBackheadLocation%Remove (imud) -! call Hz_MudOrKick%Remove (imud) -! endif -! exit -! endif -! -! xx= Hz_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal) -! -! if (xx<= 1.0) then -! Hz_Mud_Forehead_section%Array(imud)= isection -! Hz_Mud_Forehead_X%Array(imud)= (xx * (Xend_PipeSection(isection)- Xstart_PipeSection(isection)))+ Xstart_PipeSection(isection) -! exit -! else -! Hz_RemainedVolume_in_LastSection%Array(imud)= Hz_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection) -! isection= isection+ 1 -! -! -! endif -! -! enddo -! -! endif -! -! enddo - - !commented - -!========================Horizontal PIPE END================= - -!========================ANNULUS ENTRANCE==================== - - if (ABS(MudSystem%AnnulusSuctionDensity_Old - MudSystem%Hz_Density_Utube) >= MudSystem%DensityMixTol ) then ! new mud is pumped - call MudSystem%Ann_Density%Add (MudSystem%Hz_Density_Utube) - call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) - call MudSystem%Ann_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Forehead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Backhead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Ann_MudOrKick%Add (MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 - call MudSystem%Ann_CuttingMud%Add (0) - - MudSystem%AnnulusSuctionDensity_Old= MudSystem%Hz_Density_Utube - endif - -!========================ANNULUS==================== - - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Last()+ ((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline) !(gal) - -imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 - - do while (imud > 1) - imud = imud - 1 - - if (imud< MudSystem%Ann_Mud_Forehead_X%Length()) then - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud+1) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud+1) - endif - -! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then - !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then - !write(*,*) 'mud is removed by shoe lost, imud=' , imud - call RemoveAnnulusMudArrays(imud) - imud= imud-1 - cycle - endif - ENDIF -! Fracture Shoe Lost >>> - - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) - ! 7.48051948 is for gal to ft^3 - else - - MudSystem%isection= MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection < F_Counts%StringIntervalCounts+1) then ! last pipe section(well exit) F_Counts%StringIntervalCounts+1 is the first section in Annulus - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= F_Counts%StringIntervalCounts+1 - - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveAnnulusMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) - exit - else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection- 1 - - - endif - - enddo - - endif - - enddo -!========================ANNULUS END================= - -!========================== tripping in for OP remove =============================== - - !if (DeltaVolumeOp>0. .and. DeltaVolumeOp< Op_MudDischarged_Volume%Last()) then - ! Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length())= Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()) - DeltaVolumeOp - !else - ! Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()-1)= Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()-1) - (DeltaVolumeOp-Op_MudDischarged_Volume%Last()) - ! - ! call Op_MudDischarged_Volume%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Backhead_X%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Backhead_section%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Forehead_X%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Mud_Forehead_section%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_Density%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_RemainedVolume_in_LastSection%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_EmptyVolume_inBackheadLocation%Remove (Op_MudDischarged_Volume%Length()) - ! call Op_MudOrKick%Remove (Op_MudDischarged_Volume%Length()) - !endif - ! - -!============================= Bottom Hole ============================== - - !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux -imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) - imud = imud + 1 - - if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) - endif - - - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) - ! 7.48051948 is for gal to ft^3 - - else - - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) - if( imud==1) MudSystem%KickDeltaVinAnnulus= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts - - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call RemoveOpMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) - exit - else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 - - endif - - enddo - - endif - - if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then - MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() - do while(imud < MudSystem%totalLength) - - !imud = imud + 1 - call RemoveOpMudArrays(MudSystem%totalLength) - MudSystem%totalLength = MudSystem%totalLength - 1 - - - enddo - - exit ! - - endif - - !WRITE(*,*) imud,'Op_MudDischarged_Volume%Array(imud)' , Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) - - - - - - - enddo - - - !write(*,*) 'Op_Mud_Forehead_X%Length()' , Op_Mud_Forehead_X%Length() - ! - ! WRITE(*,*) 'Xend_PipeSection(F_StringIntervalCounts)' , Xend_PipeSection(F_StringIntervalCounts) - ! WRITE(*,*) 'Op_Mud_Backhead_X%Array(1)' , Op_Mud_Backhead_X%Array(1) - ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(1)' , Op_Mud_Forehead_X%Array(1) - ! WRITE(*,*) 'Op_Mud_Backhead_X%Array(2)' , Op_Mud_Backhead_X%Array(2) - ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(2)' , Op_Mud_Forehead_X%Array(2) -!========================Bottom Hole END================= - - - - - ! NO KICK - - - -!========================STRING ENTRANCE================= - - if ((ABS(MudSystem%St_Density%Last() - MudSystem%Ann_Density%First()) >= MudSystem%DensityMixTol) .OR. (MudSystem%DeltaVolumeOp == 0.0 .and. MudSystem%St_Density%Last() /= MudSystem%Ann_Density%Array(1) .and. MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped - - !if ((ABS(StringDensity_Old - Ann_Density%First()) >= DensityMixTol) .OR. (DeltaVolumeOp == 0.0 .and. MudSystem%St_Density%Last() /= Ann_Density%Array(1) .and. MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped - call MudSystem%St_Density%Add (MudSystem%Ann_Density%First()) - call MudSystem%St_MudDischarged_Volume%Add (0.0d0) - call MudSystem%St_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Forehead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Backhead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%St_MudOrKick%Add (0) - - !StringDensity_Old= Ann_Density%First() - - MudSystem%MudIsChanged= .true. - endif - - MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_MudDischarged_Volume%Length())= MudSystem%St_MudDischarged_Volume%Last()+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - -!========================Tripping In==================== - -!write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp -write(*,*) 'DeltaVolumeOp=' , MudSystem%DeltaVolumeOp - if (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) - - !write(*,*) 'Tripping In' - - MudSystem%NewDensity= (MudSystem%Ann_Density%First()*((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%Op_Density%Last()*MudSystem%DeltaVolumeOp)/(((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp) - MudSystem%NewVolume= ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp - - !write(*,*) 'St_MudDischarged_Volume%Last()=', St_MudDischarged_Volume%Last(), 'NewVolume=', NewVolume - - if (abs(MudSystem%St_Density%Last()-MudSystem%NewDensity)< MudSystem%DensityMixTol) then ! .OR. (St_MudDischarged_Volume%Last()< 42.) ) then !+ NewVolume)< 42.) then ! 1-Pockets are Merged - MudSystem%St_Density%Array(MudSystem%St_Density%Length())= (MudSystem%St_Density%Last()*MudSystem%St_MudDischarged_Volume%Last()+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%St_MudDischarged_Volume%Last()+MudSystem%NewVolume) - MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_Density%Length())= MudSystem%St_MudDischarged_Volume%Last()+MudSystem%DeltaVolumeOp - MudSystem%St_Mud_Forehead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Forehead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Backhead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Backhead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_RemainedVolume_in_LastSection%Array(MudSystem%St_Density%Length())= (0.0d0) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(MudSystem%St_Density%Length())= (0.0d0) - else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%St_Density%Add (MudSystem%NewDensity) - call MudSystem%St_MudDischarged_Volume%Add (MudSystem%NewVolume) - call MudSystem%St_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Forehead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Backhead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%St_MudOrKick%Add (0) - endif - - - elseif (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .true.) then - MudSystem%St_Density%Array(MudSystem%St_Density%Length())= MudSystem%NewDensity - MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_Density%Length())= MudSystem%NewVolume - MudSystem%St_Mud_Forehead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Forehead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Backhead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Backhead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_RemainedVolume_in_LastSection%Array(MudSystem%St_Density%Length())= (0.0d0) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(MudSystem%St_Density%Length())= (0.0d0) - endif - - -!========================Tripping In - End==================== - - -!======================== STRING ==================== - - MudSystem%MudIsChanged= .false. - - imud= MudSystem%St_Mud_Forehead_X%Length() + 1 - - do while (imud > 1) - imud = imud - 1 - - if (imud< MudSystem%St_Mud_Forehead_X%Length()) then - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud+1) - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud+1) - endif - - - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))) - ! +1 for string , -1 for annulus - - - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%St_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud)))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - - - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud) - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Forehead_section%Array(imud)) - ! 7.48051948 is for gal to ft^3 - else - - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)-1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) - - do - if (MudSystem%isection < 1) then ! last pipe section(string exit) - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(imud)= 2 - - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call RemoveStringMudArrays(imud) - endif - - exit - endif - - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) - - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) - exit - else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection- 1 - - endif - - enddo - - endif - - enddo -!========================STRING END================= - - - - -end subroutine Utube2_and_TripIn \ No newline at end of file diff --git a/Equipments/MudSystem/Circulation_Code_Select.f90 b/Equipments/MudSystem/Circulation_Code_Select.f90 index a9a9e16..07d050c 100644 --- a/Equipments/MudSystem/Circulation_Code_Select.f90 +++ b/Equipments/MudSystem/Circulation_Code_Select.f90 @@ -1,11 +1,12 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver use KickVARIABLESModule - Use MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE TD_DrillStemComponents Use CUnityInputs Use CUnityOutputs - USE CKellyConnectionEnumVariables + use OperationScenariosModule use UTUBEVARSModule use sROP_Variables use PressureDisplayVARIABLESModule @@ -19,7 +20,7 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver !NewInfluxNumber = NoGasPocket - MudSystem%Flow_timeCounter= MudSystem%Flow_timeCounter+1 + data%State%MudSystem%Flow_timeCounter= data%State%MudSystem%Flow_timeCounter+1 !if (ChokePanelStrokeResetSwitch == 1) then ! Flow_timeCounter= 0 @@ -35,7 +36,7 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver !=================================================================== - MudSystem%iLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data) + data%State%MudSystem%iLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data) !KickMigration_2SideBit= .false. Call Set_FlowPipeDisconnect(.false.) Call Set_FlowKellyDisconnect(.false.) @@ -45,12 +46,12 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver - if (MUD(8)%Q > 0.0) call FillingWell_By_BellNipple ! Filling Well Through BellNipple ( Path j11 ) - !if (MUD(10)%Q > 0.0) call FillingWell_By_Pumps ! Filling Well Through Pumps ( Path j19 ) + if (data%State%MUD(8)%Q > 0.0) call FillingWell_By_BellNipple ! Filling Well Through BellNipple ( Path j11 ) + !if (data%State%MUD(10)%Q > 0.0) call FillingWell_By_Pumps ! Filling Well Through Pumps ( Path j19 ) !write(*,*) 'TD_RemoveVolume,Get_JointConnectionPossible=' , TD_RemoveVolume,Get_JointConnectionPossible() - if (TD_Vol%RemoveVolume > 0.) call DisconnectingPipe !! .and. Get_JointConnectionPossible() == .false.) call DisconnectingPipe + if (data%State%TD_Vol%RemoveVolume > 0.) call DisconnectingPipe !! .and. Get_JointConnectionPossible() == .false.) call DisconnectingPipe IF (KickVARIABLES%KickFlux .AND. NOT(KickVARIABLES%KickOffBottom)) THEN @@ -60,70 +61,70 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver - IF ( MudSystem%NewInfluxNumber > 0 ) THEN + IF ( data%State%MudSystem%NewInfluxNumber > 0 ) THEN call Kick_Migration endif ! ============================ must be after migration ============================== - DO KickNumber= MudSystem%NewInfluxNumber-KickVARIABLES%NoGasPocket+1 , MudSystem%NewInfluxNumber + DO KickNumber= data%State%MudSystem%NewInfluxNumber-KickVARIABLES%NoGasPocket+1 , data%State%MudSystem%NewInfluxNumber ! FINDING NEW KICK LOCATIONS: - MudSystem%Ann_KickLoc= 0 - MudSystem%Op_KickLoc= 0 - MudSystem%ChokeLine_KickLoc= 0 + data%State%MudSystem%Ann_KickLoc= 0 + data%State%MudSystem%Op_KickLoc= 0 + data%State%MudSystem%ChokeLine_KickLoc= 0 - do i = 1, MudSystem%Ann_MudOrKick%Length () - if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then - MudSystem%Ann_KickLoc = i + do i = 1, data%State%MudSystem%Ann_MudOrKick%Length () + if (data%State%MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then + data%State%MudSystem%Ann_KickLoc = i exit endif end do - do i = 1, MudSystem%Op_MudOrKick%Length () - if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then - MudSystem%Op_KickLoc = i + do i = 1, data%State%MudSystem%Op_MudOrKick%Length () + if (data%State%MudSystem%Op_MudOrKick%Array(i) == KickNumber) then + data%State%MudSystem%Op_KickLoc = i exit endif end do - do i = 1, MudSystem%ChokeLine_MudOrKick%Length () - if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then - MudSystem%ChokeLine_KickLoc = i + do i = 1, data%State%MudSystem%ChokeLine_MudOrKick%Length () + if (data%State%MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then + data%State%MudSystem%ChokeLine_KickLoc = i exit endif end do ! ============================ must be after migration-end =========================== - IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == MudSystem%NewInfluxNumber .AND. NOT(KickVARIABLES%KickOffBottom) .AND. MudSystem%WellHeadIsOpen) THEN + IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == data%State%MudSystem%NewInfluxNumber .AND. NOT(KickVARIABLES%KickOffBottom) .AND. data%State%MudSystem%WellHeadIsOpen) THEN cycle ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN - if (((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) > 0.0 .AND. MudSystem%WellHeadIsOpen) .or. MudSystem%Kickexpansion_DueToMudLost) ) call Kick_Expansion + if (((GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - KickNumber + 1) > 0.0 .AND. data%State%MudSystem%WellHeadIsOpen) .or. data%State%MudSystem%Kickexpansion_DueToMudLost) ) call Kick_Expansion - if ((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. MudSystem%WellHeadIsOpen == .FALSE.) CALL Kick_Contraction + if ((GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. data%State%MudSystem%WellHeadIsOpen == .FALSE.) CALL Kick_Contraction ENDIF ENDDO - MudSystem%KickNumber = KickNumber - MudSystem%LostInTripOutIsDone= .false. + data%State%MudSystem%KickNumber = KickNumber + data%State%MudSystem%LostInTripOutIsDone= .false. - if( MudSystem%DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then + if( data%State%MudSystem%DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp call Pump_and_TripIn - elseif (MudSystem%DeltaVolumeOp < 0.0) then + elseif (data%State%MudSystem%DeltaVolumeOp < 0.0) then ! when we have Utube and tripping out simultaneously, it uses "TripOut_and_Pump" subroutine, and then Utube code is done ! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in call TripOut_and_Pump endif - MudSystem%WellOutletDensity= MudSystem%Ann_Density%Last() ! (ppg) used in MudSystem + data%State%MudSystem%WellOutletDensity= data%State%MudSystem%Ann_Density%Last() ! (ppg) used in MudSystem - if (MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18 + if (data%State%MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18 call ChokeLineMud endif @@ -140,8 +141,8 @@ subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver call PlotFinalMudElements - MudSystem%MudChecked= .true. - MudSystem%UtubePossibility= .true. + data%State%MudSystem%MudChecked= .true. + data%State%MudSystem%UtubePossibility= .true. !WRITE(*,*) '***********************************************************************' end subroutine CirculationCodeSelect \ No newline at end of file diff --git a/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 b/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 index d865d2b..5679072 100644 --- a/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 +++ b/Equipments/MudSystem/Deallocate_Normal_Circulation.f90 @@ -1,119 +1,121 @@ subroutine DEALLOCATE_ARRAYS_NormalCirculation() ! is called in module FluidFlowMain USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none -if(allocated(MudSystem%Xstart_PipeSection)) deallocate(MudSystem%Xstart_PipeSection) -if(allocated(MudSystem%Xend_PipeSection)) deallocate(MudSystem%Xend_PipeSection) -if(allocated(MudSystem%PipeSection_VolumeCapacity)) deallocate(MudSystem%PipeSection_VolumeCapacity) -if(allocated(MudSystem%Area_PipeSectionFt)) deallocate(MudSystem%Area_PipeSectionFt) -if(allocated(MudSystem%OD_PipeSectionInch)) deallocate(MudSystem%OD_PipeSectionInch) -if(allocated(MudSystem%ID_PipeSectionInch)) deallocate(MudSystem%ID_PipeSectionInch) -if(allocated(MudSystem%Xstart_OpSection)) deallocate(MudSystem%Xstart_OpSection) -if(allocated(MudSystem%Xend_OpSection)) deallocate(MudSystem%Xend_OpSection) -if(allocated(MudSystem%Area_OpSectionFt)) deallocate(MudSystem%Area_OpSectionFt) -if(allocated(MudSystem%OD_OpSectionInch)) deallocate(MudSystem%OD_OpSectionInch) -if(allocated(MudSystem%ID_OpSectionInch)) deallocate(MudSystem%ID_OpSectionInch) -if(allocated(MudSystem%OpSection_VolumeCapacity)) deallocate(MudSystem%OpSection_VolumeCapacity) -if(allocated(MudSystem%GeoTypeOp)) deallocate(MudSystem%GeoTypeOp) -if(allocated(MudSystem%GeoType)) deallocate(MudSystem%GeoType) +if(allocated(data%State%MudSystem%Xstart_PipeSection)) deallocate(data%State%MudSystem%Xstart_PipeSection) +if(allocated(data%State%MudSystem%Xend_PipeSection)) deallocate(data%State%MudSystem%Xend_PipeSection) +if(allocated(data%State%MudSystem%PipeSection_VolumeCapacity)) deallocate(data%State%MudSystem%PipeSection_VolumeCapacity) +if(allocated(data%State%MudSystem%Area_PipeSectionFt)) deallocate(data%State%MudSystem%Area_PipeSectionFt) +if(allocated(data%State%MudSystem%OD_PipeSectionInch)) deallocate(data%State%MudSystem%OD_PipeSectionInch) +if(allocated(data%State%MudSystem%ID_PipeSectionInch)) deallocate(data%State%MudSystem%ID_PipeSectionInch) +if(allocated(data%State%MudSystem%Xstart_OpSection)) deallocate(data%State%MudSystem%Xstart_OpSection) +if(allocated(data%State%MudSystem%Xend_OpSection)) deallocate(data%State%MudSystem%Xend_OpSection) +if(allocated(data%State%MudSystem%Area_OpSectionFt)) deallocate(data%State%MudSystem%Area_OpSectionFt) +if(allocated(data%State%MudSystem%OD_OpSectionInch)) deallocate(data%State%MudSystem%OD_OpSectionInch) +if(allocated(data%State%MudSystem%ID_OpSectionInch)) deallocate(data%State%MudSystem%ID_OpSectionInch) +if(allocated(data%State%MudSystem%OpSection_VolumeCapacity)) deallocate(data%State%MudSystem%OpSection_VolumeCapacity) +if(allocated(data%State%MudSystem%GeoTypeOp)) deallocate(data%State%MudSystem%GeoTypeOp) +if(allocated(data%State%MudSystem%GeoType)) deallocate(data%State%MudSystem%GeoType) - call MudSystem%Hz_MudDischarged_Volume%Empty() - call MudSystem%Hz_Mud_Backhead_X%Empty() - call MudSystem%Hz_Mud_Backhead_section%Empty() - call MudSystem%Hz_Mud_Forehead_X%Empty() - call MudSystem%Hz_Mud_Forehead_section%Empty() - call MudSystem%Hz_Density%Empty() - call MudSystem%Hz_RemainedVolume_in_LastSection%Empty() - call MudSystem%Hz_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%Hz_MudOrKick%Empty() + call data%State%MudSystem%Hz_MudDischarged_Volume%Empty() + call data%State%MudSystem%Hz_Mud_Backhead_X%Empty() + call data%State%MudSystem%Hz_Mud_Backhead_section%Empty() + call data%State%MudSystem%Hz_Mud_Forehead_X%Empty() + call data%State%MudSystem%Hz_Mud_Forehead_section%Empty() + call data%State%MudSystem%Hz_Density%Empty() + call data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Empty() + call data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Empty() + call data%State%MudSystem%Hz_MudOrKick%Empty() - call MudSystem%St_MudDischarged_Volume%Empty() - call MudSystem%St_Mud_Backhead_X%Empty() - call MudSystem%St_Mud_Backhead_section%Empty() - call MudSystem%St_Mud_Forehead_X%Empty() - call MudSystem%St_Mud_Forehead_section%Empty() - call MudSystem%St_Density%Empty() - call MudSystem%St_RemainedVolume_in_LastSection%Empty() - call MudSystem%St_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%St_MudOrKick%Empty() + call data%State%MudSystem%St_MudDischarged_Volume%Empty() + call data%State%MudSystem%St_Mud_Backhead_X%Empty() + call data%State%MudSystem%St_Mud_Backhead_section%Empty() + call data%State%MudSystem%St_Mud_Forehead_X%Empty() + call data%State%MudSystem%St_Mud_Forehead_section%Empty() + call data%State%MudSystem%St_Density%Empty() + call data%State%MudSystem%St_RemainedVolume_in_LastSection%Empty() + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Empty() + call data%State%MudSystem%St_MudOrKick%Empty() - call MudSystem%Ann_MudDischarged_Volume%Empty() - call MudSystem%Ann_Mud_Backhead_X%Empty() - call MudSystem%Ann_Mud_Backhead_section%Empty() - call MudSystem%Ann_Mud_Forehead_X%Empty() - call MudSystem%Ann_Mud_Forehead_section%Empty() - call MudSystem%Ann_Density%Empty() - call MudSystem%Ann_RemainedVolume_in_LastSection%Empty() - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%Ann_MudOrKick%Empty() - call MudSystem%Ann_CuttingMud%Empty() + call data%State%MudSystem%Ann_MudDischarged_Volume%Empty() + call data%State%MudSystem%Ann_Mud_Backhead_X%Empty() + call data%State%MudSystem%Ann_Mud_Backhead_section%Empty() + call data%State%MudSystem%Ann_Mud_Forehead_X%Empty() + call data%State%MudSystem%Ann_Mud_Forehead_section%Empty() + call data%State%MudSystem%Ann_Density%Empty() + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Empty() + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Empty() + call data%State%MudSystem%Ann_MudOrKick%Empty() + call data%State%MudSystem%Ann_CuttingMud%Empty() - call MudSystem%Op_MudDischarged_Volume%Empty() - call MudSystem%Op_Mud_Backhead_X%Empty() - call MudSystem%Op_Mud_Backhead_section%Empty() - call MudSystem%Op_Mud_Forehead_X%Empty() - call MudSystem%Op_Mud_Forehead_section%Empty() - call MudSystem%Op_Density%Empty() - call MudSystem%Op_RemainedVolume_in_LastSection%Empty() - call MudSystem%Op_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%Op_MudOrKick%Empty() + call data%State%MudSystem%Op_MudDischarged_Volume%Empty() + call data%State%MudSystem%Op_Mud_Backhead_X%Empty() + call data%State%MudSystem%Op_Mud_Backhead_section%Empty() + call data%State%MudSystem%Op_Mud_Forehead_X%Empty() + call data%State%MudSystem%Op_Mud_Forehead_section%Empty() + call data%State%MudSystem%Op_Density%Empty() + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Empty() + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Empty() + call data%State%MudSystem%Op_MudOrKick%Empty() - call MudSystem%ChokeLine_MudDischarged_Volume%Empty() - call MudSystem%ChokeLine_Mud_Backhead_X%Empty() - call MudSystem%ChokeLine_Mud_Backhead_section%Empty() - call MudSystem%ChokeLine_Mud_Forehead_X%Empty() - call MudSystem%ChokeLine_Mud_Forehead_section%Empty() - call MudSystem%ChokeLine_Density%Empty() - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%Empty() - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Empty() - call MudSystem%ChokeLine_MudOrKick%Empty() + call data%State%MudSystem%ChokeLine_MudDischarged_Volume%Empty() + call data%State%MudSystem%ChokeLine_Mud_Backhead_X%Empty() + call data%State%MudSystem%ChokeLine_Mud_Backhead_section%Empty() + call data%State%MudSystem%ChokeLine_Mud_Forehead_X%Empty() + call data%State%MudSystem%ChokeLine_Mud_Forehead_section%Empty() + call data%State%MudSystem%ChokeLine_Density%Empty() + call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Empty() + call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Empty() + call data%State%MudSystem%ChokeLine_MudOrKick%Empty() - call MudSystem%Xend_MudElement%Empty() - call MudSystem%Xstart_MudElement%Empty() - call MudSystem%TVDend_MudElement%Empty() - call MudSystem%TVDstart_MudElement%Empty() - call MudSystem%Density_MudElement%Empty() - call MudSystem%MudGeoType%Empty() - call MudSystem%PipeID_MudElement%Empty() - call MudSystem%PipeOD_MudElement%Empty() - call MudSystem%MudType_MudElement%Empty() + call data%State%MudSystem%Xend_MudElement%Empty() + call data%State%MudSystem%Xstart_MudElement%Empty() + call data%State%MudSystem%TVDend_MudElement%Empty() + call data%State%MudSystem%TVDstart_MudElement%Empty() + call data%State%MudSystem%Density_MudElement%Empty() + call data%State%MudSystem%MudGeoType%Empty() + call data%State%MudSystem%PipeID_MudElement%Empty() + call data%State%MudSystem%PipeOD_MudElement%Empty() + call data%State%MudSystem%MudType_MudElement%Empty() - call MudSystem%Xend_OpMudElement%Empty() - call MudSystem%Xstart_OpMudElement%Empty() - call MudSystem%TVDend_OpMudElement%Empty() - call MudSystem%TVDstart_OpMudElement%Empty() - call MudSystem%Density_OpMudElement%Empty() - call MudSystem%PipeID_OpMudElement%Empty() - call MudSystem%PipeOD_OpMudElement%Empty() - call MudSystem%MudTypeOp_MudElement%Empty() + call data%State%MudSystem%Xend_OpMudElement%Empty() + call data%State%MudSystem%Xstart_OpMudElement%Empty() + call data%State%MudSystem%TVDend_OpMudElement%Empty() + call data%State%MudSystem%TVDstart_OpMudElement%Empty() + call data%State%MudSystem%Density_OpMudElement%Empty() + call data%State%MudSystem%PipeID_OpMudElement%Empty() + call data%State%MudSystem%PipeOD_OpMudElement%Empty() + call data%State%MudSystem%MudTypeOp_MudElement%Empty() end subroutine subroutine RemoveAnnulusMudArrays(ilocal) USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none INTEGER :: ilocal - call MudSystem%Ann_MudDischarged_Volume%Remove (ilocal) - call MudSystem%Ann_Mud_Backhead_X%Remove (ilocal) - call MudSystem%Ann_Mud_Backhead_section%Remove (ilocal) - call MudSystem%Ann_Mud_Forehead_X%Remove (ilocal) - call MudSystem%Ann_Mud_Forehead_section%Remove (ilocal) - call MudSystem%Ann_Density%Remove (ilocal) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%Ann_MudOrKick%Remove (ilocal) - call MudSystem%Ann_CuttingMud%Remove (ilocal) + call data%State%MudSystem%Ann_MudDischarged_Volume%Remove (ilocal) + call data%State%MudSystem%Ann_Mud_Backhead_X%Remove (ilocal) + call data%State%MudSystem%Ann_Mud_Backhead_section%Remove (ilocal) + call data%State%MudSystem%Ann_Mud_Forehead_X%Remove (ilocal) + call data%State%MudSystem%Ann_Mud_Forehead_section%Remove (ilocal) + call data%State%MudSystem%Ann_Density%Remove (ilocal) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Remove (ilocal) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (ilocal) + call data%State%MudSystem%Ann_MudOrKick%Remove (ilocal) + call data%State%MudSystem%Ann_CuttingMud%Remove (ilocal) @@ -122,20 +124,21 @@ subroutine RemoveAnnulusMudArrays(ilocal) subroutine RemoveStringMudArrays(ilocal) USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none INTEGER :: ilocal - call MudSystem%St_MudDischarged_Volume%Remove (ilocal) - call MudSystem%St_Mud_Backhead_X%Remove (ilocal) - call MudSystem%St_Mud_Backhead_section%Remove (ilocal) - call MudSystem%St_Mud_Forehead_X%Remove (ilocal) - call MudSystem%St_Mud_Forehead_section%Remove (ilocal) - call MudSystem%St_Density%Remove (ilocal) - call MudSystem%St_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%St_MudOrKick%Remove (ilocal) + call data%State%MudSystem%St_MudDischarged_Volume%Remove (ilocal) + call data%State%MudSystem%St_Mud_Backhead_X%Remove (ilocal) + call data%State%MudSystem%St_Mud_Backhead_section%Remove (ilocal) + call data%State%MudSystem%St_Mud_Forehead_X%Remove (ilocal) + call data%State%MudSystem%St_Mud_Forehead_section%Remove (ilocal) + call data%State%MudSystem%St_Density%Remove (ilocal) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%Remove (ilocal) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Remove (ilocal) + call data%State%MudSystem%St_MudOrKick%Remove (ilocal) @@ -144,20 +147,21 @@ subroutine RemoveStringMudArrays(ilocal) subroutine RemoveOpMudArrays(ilocal) USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none INTEGER :: ilocal - call MudSystem%Op_MudDischarged_Volume%Remove (ilocal) - call MudSystem%Op_Mud_Backhead_X%Remove (ilocal) - call MudSystem%Op_Mud_Backhead_section%Remove (ilocal) - call MudSystem%Op_Mud_Forehead_X%Remove (ilocal) - call MudSystem%Op_Mud_Forehead_section%Remove (ilocal) - call MudSystem%Op_Density%Remove (ilocal) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%Op_MudOrKick%Remove (ilocal) + call data%State%MudSystem%Op_MudDischarged_Volume%Remove (ilocal) + call data%State%MudSystem%Op_Mud_Backhead_X%Remove (ilocal) + call data%State%MudSystem%Op_Mud_Backhead_section%Remove (ilocal) + call data%State%MudSystem%Op_Mud_Forehead_X%Remove (ilocal) + call data%State%MudSystem%Op_Mud_Forehead_section%Remove (ilocal) + call data%State%MudSystem%Op_Density%Remove (ilocal) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Remove (ilocal) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (ilocal) + call data%State%MudSystem%Op_MudOrKick%Remove (ilocal) @@ -165,20 +169,21 @@ subroutine RemoveOpMudArrays(ilocal) subroutine RemoveHzMudArrays(ilocal) USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none INTEGER :: ilocal - call MudSystem%Hz_MudDischarged_Volume%Remove (ilocal) - call MudSystem%Hz_Mud_Backhead_X%Remove (ilocal) - call MudSystem%Hz_Mud_Backhead_section%Remove (ilocal) - call MudSystem%Hz_Mud_Forehead_X%Remove (ilocal) - call MudSystem%Hz_Mud_Forehead_section%Remove (ilocal) - call MudSystem%Hz_Density%Remove (ilocal) - call MudSystem%Hz_RemainedVolume_in_LastSection%Remove (ilocal) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%Remove (ilocal) - call MudSystem%Hz_MudOrKick%Remove (ilocal) + call data%State%MudSystem%Hz_MudDischarged_Volume%Remove (ilocal) + call data%State%MudSystem%Hz_Mud_Backhead_X%Remove (ilocal) + call data%State%MudSystem%Hz_Mud_Backhead_section%Remove (ilocal) + call data%State%MudSystem%Hz_Mud_Forehead_X%Remove (ilocal) + call data%State%MudSystem%Hz_Mud_Forehead_section%Remove (ilocal) + call data%State%MudSystem%Hz_Density%Remove (ilocal) + call data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Remove (ilocal) + call data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Remove (ilocal) + call data%State%MudSystem%Hz_MudOrKick%Remove (ilocal) diff --git a/Equipments/MudSystem/Disconnecting_Pipe.f90 b/Equipments/MudSystem/Disconnecting_Pipe.f90 index 5dc26fa..bed5ed0 100644 --- a/Equipments/MudSystem/Disconnecting_Pipe.f90 +++ b/Equipments/MudSystem/Disconnecting_Pipe.f90 @@ -3,14 +3,16 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - ! !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity +use ConfigurationVariables !@@@ + use ConfigurationVariables + use ConfigurationVariables !@ + ! !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule USE TD_DrillStemComponents - Use CKellyConnectionEnumVariables + use OperationScenariosModule Use CUnityOutputs USE CManifolds @@ -21,7 +23,7 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect !TD_RemoveVolume= TD_RemoveVolume* 7.48051948 ! ft^3 to gal - ExcessMudVolume= sum(MudSystem%St_MudDischarged_Volume%Array(:)) - sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) + ExcessMudVolume= sum(data%State%MudSystem%St_MudDischarged_Volume%Array(:)) - sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:data%State%F_Counts%StringIntervalCounts)) ! ======if(ExcessMudVolume <= 0.) No Modification Needed Because Removed Pipe was Empty===== @@ -31,9 +33,9 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect if (ExcessMudVolume > 0.) then if ( Manifold%Valve(53)%Status == .true. ) then - MudSystem%MudBucketVolume= ExcessMudVolume + data%State%MudSystem%MudBucketVolume= ExcessMudVolume else - MudSystem%MudBucketVolume= 0.0 + data%State%MudSystem%MudBucketVolume= 0.0 endif @@ -66,32 +68,32 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect Do - if(MudSystem%St_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then - ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystem%St_MudDischarged_Volume%Array(imud) - call MudSystem%St_MudDischarged_Volume%Remove (imud) - call MudSystem%St_Mud_Backhead_X%Remove (imud) - call MudSystem%St_Mud_Backhead_section%Remove (imud) - call MudSystem%St_Mud_Forehead_X%Remove (imud) - call MudSystem%St_Mud_Forehead_section%Remove (imud) - call MudSystem%St_Density%Remove (imud) - call MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%St_MudOrKick%Remove (imud) + if(data%State%MudSystem%St_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then + ExcessMudVolume_Remained= ExcessMudVolume_Remained- data%State%MudSystem%St_MudDischarged_Volume%Array(imud) + call data%State%MudSystem%St_MudDischarged_Volume%Remove (imud) + call data%State%MudSystem%St_Mud_Backhead_X%Remove (imud) + call data%State%MudSystem%St_Mud_Backhead_section%Remove (imud) + call data%State%MudSystem%St_Mud_Forehead_X%Remove (imud) + call data%State%MudSystem%St_Mud_Forehead_section%Remove (imud) + call data%State%MudSystem%St_Density%Remove (imud) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) + call data%State%MudSystem%St_MudOrKick%Remove (imud) - elseif(MudSystem%St_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained + elseif(data%State%MudSystem%St_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then + data%State%MudSystem%St_MudDischarged_Volume%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained exit else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) - call MudSystem%St_MudDischarged_Volume%Remove (imud) - call MudSystem%St_Mud_Backhead_X%Remove (imud) - call MudSystem%St_Mud_Backhead_section%Remove (imud) - call MudSystem%St_Mud_Forehead_X%Remove (imud) - call MudSystem%St_Mud_Forehead_section%Remove (imud) - call MudSystem%St_Density%Remove (imud) - call MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%St_MudOrKick%Remove (imud) + call data%State%MudSystem%St_MudDischarged_Volume%Remove (imud) + call data%State%MudSystem%St_Mud_Backhead_X%Remove (imud) + call data%State%MudSystem%St_Mud_Backhead_section%Remove (imud) + call data%State%MudSystem%St_Mud_Forehead_X%Remove (imud) + call data%State%MudSystem%St_Mud_Forehead_section%Remove (imud) + call data%State%MudSystem%St_Density%Remove (imud) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%Remove (imud) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud) + call data%State%MudSystem%St_MudOrKick%Remove (imud) exit endif diff --git a/Equipments/MudSystem/Elements_Creation.f90 b/Equipments/MudSystem/Elements_Creation.f90 index d4f2273..ff25057 100644 --- a/Equipments/MudSystem/Elements_Creation.f90 +++ b/Equipments/MudSystem/Elements_Creation.f90 @@ -3,14 +3,20 @@ subroutine ElementsCreation ! is called in subroutine Fluid_Flow_Solver Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure +use ConfigurationVariables !@@@ + use ConfigurationVariables + USE CHOKEVARIABLES +!use ConfigurationVariables !@ + !use CDataDisplayConsole + !@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES + use ConfigurationVariables !@ + USE CHOKEVARIABLES +!use ConfigurationVariables !@ !use CChokeManifoldVariables - ! !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity + use ConfigurationVariables + ! !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule @@ -24,174 +30,174 @@ subroutine ElementsCreation ! is called in subroutine Fluid_Flow_Solver !===========================================================WELL============================================================ !===========================================================WELL============================================================ - if(allocated(MudSystem%Xstart_PipeSection)) deallocate(MudSystem%Xstart_PipeSection) - if(allocated(MudSystem%Xend_PipeSection)) deallocate(MudSystem%Xend_PipeSection) - if(allocated(MudSystem%PipeSection_VolumeCapacity)) deallocate(MudSystem%PipeSection_VolumeCapacity) - if(allocated(MudSystem%Area_PipeSectionFt)) deallocate(MudSystem%Area_PipeSectionFt) - if(allocated(MudSystem%GeoType)) deallocate(MudSystem%GeoType) - if(allocated(MudSystem%OD_PipeSectionInch)) deallocate(MudSystem%OD_PipeSectionInch) - if(allocated(MudSystem%ID_PipeSectionInch)) deallocate(MudSystem%ID_PipeSectionInch) - if(allocated(MudSystem%Angle_PipeSection)) deallocate(MudSystem%Angle_PipeSection) - - if(allocated(MudSystem%Xstart_OpSection)) deallocate(MudSystem%Xstart_OpSection) - if(allocated(MudSystem%Xend_OpSection)) deallocate(MudSystem%Xend_OpSection) - if(allocated(MudSystem%OpSection_VolumeCapacity)) deallocate(MudSystem%OpSection_VolumeCapacity) - if(allocated(MudSystem%Area_OpSectionFt)) deallocate(MudSystem%Area_OpSectionFt) - if(allocated(MudSystem%GeoTypeOp)) deallocate(MudSystem%GeoTypeOp) - if(allocated(MudSystem%OD_OpSectionInch)) deallocate(MudSystem%OD_OpSectionInch) - if(allocated(MudSystem%ID_OpSectionInch)) deallocate(MudSystem%ID_OpSectionInch) - if(allocated(MudSystem%Angle_OpSection)) deallocate(MudSystem%Angle_OpSection) + if(allocated(data%State%MudSystem%Xstart_PipeSection)) deallocate(data%State%MudSystem%Xstart_PipeSection) + if(allocated(data%State%MudSystem%Xend_PipeSection)) deallocate(data%State%MudSystem%Xend_PipeSection) + if(allocated(data%State%MudSystem%PipeSection_VolumeCapacity)) deallocate(data%State%MudSystem%PipeSection_VolumeCapacity) + if(allocated(data%State%MudSystem%Area_PipeSectionFt)) deallocate(data%State%MudSystem%Area_PipeSectionFt) + if(allocated(data%State%MudSystem%GeoType)) deallocate(data%State%MudSystem%GeoType) + if(allocated(data%State%MudSystem%OD_PipeSectionInch)) deallocate(data%State%MudSystem%OD_PipeSectionInch) + if(allocated(data%State%MudSystem%ID_PipeSectionInch)) deallocate(data%State%MudSystem%ID_PipeSectionInch) + if(allocated(data%State%MudSystem%Angle_PipeSection)) deallocate(data%State%MudSystem%Angle_PipeSection) + + if(allocated(data%State%MudSystem%Xstart_OpSection)) deallocate(data%State%MudSystem%Xstart_OpSection) + if(allocated(data%State%MudSystem%Xend_OpSection)) deallocate(data%State%MudSystem%Xend_OpSection) + if(allocated(data%State%MudSystem%OpSection_VolumeCapacity)) deallocate(data%State%MudSystem%OpSection_VolumeCapacity) + if(allocated(data%State%MudSystem%Area_OpSectionFt)) deallocate(data%State%MudSystem%Area_OpSectionFt) + if(allocated(data%State%MudSystem%GeoTypeOp)) deallocate(data%State%MudSystem%GeoTypeOp) + if(allocated(data%State%MudSystem%OD_OpSectionInch)) deallocate(data%State%MudSystem%OD_OpSectionInch) + if(allocated(data%State%MudSystem%ID_OpSectionInch)) deallocate(data%State%MudSystem%ID_OpSectionInch) + if(allocated(data%State%MudSystem%Angle_OpSection)) deallocate(data%State%MudSystem%Angle_OpSection) -ALLOCATE (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts) & - ,MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%Area_PipeSectionFt(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts), & - MudSystem%GeoType(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%OD_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts),MudSystem%ID_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts)) +ALLOCATE (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts),data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts) & + ,data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts),data%State%MudSystem%Area_PipeSectionFt(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts), & + data%State%MudSystem%GeoType(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts),data%State%MudSystem%OD_PipeSectionInch(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts),data%State%MudSystem%ID_PipeSectionInch(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts)) -ALLOCATE (MudSystem%Xstart_OpSection(F_Counts%BottomHoleIntervalCounts),MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) & - ,MudSystem%OpSection_VolumeCapacity(F_Counts%BottomHoleIntervalCounts),MudSystem%Area_OpSectionFt(F_Counts%BottomHoleIntervalCounts), & - MudSystem%GeoTypeOp(F_Counts%BottomHoleIntervalCounts),MudSystem%OD_OpSectionInch(F_Counts%BottomHoleIntervalCounts),MudSystem%ID_OpSectionInch(F_Counts%BottomHoleIntervalCounts)) +ALLOCATE (data%State%MudSystem%Xstart_OpSection(data%State%F_Counts%BottomHoleIntervalCounts),data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts) & + ,data%State%MudSystem%OpSection_VolumeCapacity(data%State%F_Counts%BottomHoleIntervalCounts),data%State%MudSystem%Area_OpSectionFt(data%State%F_Counts%BottomHoleIntervalCounts), & + data%State%MudSystem%GeoTypeOp(data%State%F_Counts%BottomHoleIntervalCounts),data%State%MudSystem%OD_OpSectionInch(data%State%F_Counts%BottomHoleIntervalCounts),data%State%MudSystem%ID_OpSectionInch(data%State%F_Counts%BottomHoleIntervalCounts)) - MudSystem%OpSection=0 - MudSystem%isection=0 + data%State%MudSystem%OpSection=0 + data%State%MudSystem%isection=0 - DO iisection=1, F_Counts%IntervalsTotalCounts - IF (F_Interval(iisection)%GeoType == 1) THEN - MudSystem%OpSection= MudSystem%OpSection+1 - MudSystem%Xstart_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%StartDepth) - MudSystem%Xend_OpSection(MudSystem%OpSection)= (F_Interval(iisection)%EndDepth) - MudSystem%Area_OpSectionFt(MudSystem%OpSection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) - MudSystem%OD_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%OD) - MudSystem%ID_OpSectionInch(MudSystem%OpSection)= (F_Interval(iisection)%ID) !REAL(F_Interval(iisection)%Volume) - MudSystem%GeoTypeOp(MudSystem%OpSection)= F_Interval(iisection)%GeoType ! niaz nist ehtemalan - !Angle_OpSection(OpSection)= F_Interval(iisection)%Angle + DO iisection=1, data%State%F_Counts%IntervalsTotalCounts + IF (data%State%F_Interval(iisection)%GeoType == 1) THEN + data%State%MudSystem%OpSection= data%State%MudSystem%OpSection+1 + data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%OpSection)= (data%State%F_Interval(iisection)%StartDepth) + data%State%MudSystem%Xend_OpSection(data%State%MudSystem%OpSection)= (data%State%F_Interval(iisection)%EndDepth) + data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%OpSection)= PII*((data%State%F_Interval(iisection)%OD/12.0d0)**2-(data%State%F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) + data%State%MudSystem%OD_OpSectionInch(data%State%MudSystem%OpSection)= (data%State%F_Interval(iisection)%OD) + data%State%MudSystem%ID_OpSectionInch(data%State%MudSystem%OpSection)= (data%State%F_Interval(iisection)%ID) !REAL(data%State%F_Interval(iisection)%Volume) + data%State%MudSystem%GeoTypeOp(data%State%MudSystem%OpSection)= data%State%F_Interval(iisection)%GeoType ! niaz nist ehtemalan + !Angle_OpSection(OpSection)= data%State%F_Interval(iisection)%Angle !write(*,*) 'iisection=' , iisection - !write(*,*) 'StartDepth=' , F_Interval(iisection)%StartDepth - !write(*,*) 'EndDepth=' , F_Interval(iisection)%EndDepth - !write(*,*) 'OD=' , F_Interval(iisection)%OD - !write(*,*) 'ID=' , F_Interval(iisection)%ID + !write(*,*) 'StartDepth=' , data%State%F_Interval(iisection)%StartDepth + !write(*,*) 'EndDepth=' , data%State%F_Interval(iisection)%EndDepth + !write(*,*) 'OD=' , data%State%F_Interval(iisection)%OD + !write(*,*) 'ID=' , data%State%F_Interval(iisection)%ID ELSE - MudSystem%isection= MudSystem%isection+1 - MudSystem%Xstart_PipeSection(MudSystem%isection)= (F_Interval(iisection)%StartDepth) - !write(*,*) 'F_Interval(iisection)%StartDepth=' , F_Interval(iisection)%StartDepth - MudSystem%Xend_PipeSection(MudSystem%isection)= (F_Interval(iisection)%EndDepth) - !write(*,*) 'F_Interval(iisection)%EndDepth=' , F_Interval(iisection)%EndDepth + data%State%MudSystem%isection= data%State%MudSystem%isection+1 + data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)= (data%State%F_Interval(iisection)%StartDepth) + !write(*,*) 'data%State%F_Interval(iisection)%StartDepth=' , data%State%F_Interval(iisection)%StartDepth + data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)= (data%State%F_Interval(iisection)%EndDepth) + !write(*,*) 'data%State%F_Interval(iisection)%EndDepth=' , data%State%F_Interval(iisection)%EndDepth - MudSystem%OD_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%OD) - MudSystem%Area_PipeSectionFt(MudSystem%isection)= PII*((F_Interval(iisection)%OD/12.0d0)**2-(F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) - MudSystem%ID_PipeSectionInch(MudSystem%isection)= (F_Interval(iisection)%ID) - !PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948 !REAL(F_Interval(iisection)%Volume) ! (gal) - MudSystem%GeoType(MudSystem%isection)= F_Interval(iisection)%GeoType - !Angle_PipeSection(isection)= F_Interval(iisection)%Angle + data%State%MudSystem%OD_PipeSectionInch(data%State%MudSystem%isection)= (data%State%F_Interval(iisection)%OD) + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%isection)= PII*((data%State%F_Interval(iisection)%OD/12.0d0)**2-(data%State%F_Interval(iisection)%ID/12.0d0)**2)/4.0d0 !D(in), AREA(ft^2) + data%State%MudSystem%ID_PipeSectionInch(data%State%MudSystem%isection)= (data%State%F_Interval(iisection)%ID) + !PipeSection_VolumeCapacity(isection)= Area_PipeSectionFt(isection)* ABS(Xend_PipeSection(isection)-Xstart_PipeSection(isection))* 7.48051948 !REAL(data%State%F_Interval(iisection)%Volume) ! (gal) + data%State%MudSystem%GeoType(data%State%MudSystem%isection)= data%State%F_Interval(iisection)%GeoType + !Angle_PipeSection(isection)= data%State%F_Interval(iisection)%Angle ENDIF ENDDO - call MudSystem%Xstart_MudElement%Empty() - call MudSystem%Xstart_MudElement%Add(MudSystem%Xstart_PipeSection(1)) + call data%State%MudSystem%Xstart_MudElement%Empty() + call data%State%MudSystem%Xstart_MudElement%Add(data%State%MudSystem%Xstart_PipeSection(1)) - call MudSystem%Xstart_OpMudElement%Empty() - call MudSystem%Xstart_OpMudElement%Add(MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Xstart_OpMudElement%Empty() + call data%State%MudSystem%Xstart_OpMudElement%Add(data%State%MudSystem%Xstart_OpSection(1)) - call MudSystem%TVDstart_MudElement%Empty() - call TVD_Calculator(MudSystem%Xstart_PipeSection(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDstart_MudElement%Empty() + call TVD_Calculator(data%State%MudSystem%Xstart_PipeSection(1),data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDstart_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_OpMudElement%Empty() - call TVD_Calculator(MudSystem%Xstart_OpSection(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_OpMudElement%Add(MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDstart_OpMudElement%Empty() + call TVD_Calculator(data%State%MudSystem%Xstart_OpSection(1),data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDstart_OpMudElement%Add(data%State%MudSystem%MudCircVerticalDepth) - MudSystem%NoPipeSections= MudSystem%isection ! sections in string and annulus(GeoType 0 & 2) + data%State%MudSystem%NoPipeSections= data%State%MudSystem%isection ! sections in string and annulus(GeoType 0 & 2) - DO OpSection= 1,F_Counts%BottomHoleIntervalCounts - MudSystem%OpSection_VolumeCapacity(OpSection)= MudSystem%Area_OpSectionFt(OpSection)* ABS(MudSystem%Xend_OpSection(OpSection)-MudSystem%Xstart_OpSection(OpSection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) + DO OpSection= 1,data%State%F_Counts%BottomHoleIntervalCounts + data%State%MudSystem%OpSection_VolumeCapacity(OpSection)= data%State%MudSystem%Area_OpSectionFt(OpSection)* ABS(data%State%MudSystem%Xend_OpSection(OpSection)-data%State%MudSystem%Xstart_OpSection(OpSection))* 7.48051948d0 !REAL(data%State%F_Interval(iisection)%Volume) ENDDO - MudSystem%OpSection=OpSection - DO isection= 1,MudSystem%NoPipeSections - MudSystem%PipeSection_VolumeCapacity(isection)= MudSystem%Area_PipeSectionFt(isection)* ABS(MudSystem%Xend_PipeSection(isection)-MudSystem%Xstart_PipeSection(isection))* 7.48051948d0 !REAL(F_Interval(iisection)%Volume) ! (gal) + data%State%MudSystem%OpSection=OpSection + DO isection= 1,data%State%MudSystem%NoPipeSections + data%State%MudSystem%PipeSection_VolumeCapacity(isection)= data%State%MudSystem%Area_PipeSectionFt(isection)* ABS(data%State%MudSystem%Xend_PipeSection(isection)-data%State%MudSystem%Xstart_PipeSection(isection))* 7.48051948d0 !REAL(data%State%F_Interval(iisection)%Volume) ! (gal) ENDDO - MudSystem%isection = isection + data%State%MudSystem%isection = isection !types: Mud= 0 Kick=1 !=========================================== - if (MudSystem%FirstMudSet==0) then - call MudSystem%Hz_MudDischarged_Volume%AddToFirst(MudSystem%PipeSection_VolumeCapacity(1)) !startup initial - call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(1)) - call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Hz_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Hz_MudOrKick%AddToFirst (0) + if (data%State%MudSystem%FirstMudSet==0) then + call data%State%MudSystem%Hz_MudDischarged_Volume%AddToFirst(data%State%MudSystem%PipeSection_VolumeCapacity(1)) !startup initial + call data%State%MudSystem%Hz_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(1)) + call data%State%MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%Hz_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xend_PipeSection(1)) + call data%State%MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%Hz_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call data%State%MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_MudOrKick%AddToFirst (0) - call MudSystem%St_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts))) !startup initial - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts) - call MudSystem%St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (0) + call data%State%MudSystem%St_MudDischarged_Volume%AddToFirst(sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:data%State%F_Counts%StringIntervalCounts))) !startup initial + call data%State%MudSystem%St_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call data%State%MudSystem%St_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)) + call data%State%MudSystem%St_Mud_Forehead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts) + call data%State%MudSystem%St_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%St_MudOrKick%AddToFirst (0) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst(sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections))) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%NoPipeSections) - call MudSystem%Ann_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (0) - call MudSystem%Ann_CuttingMud%AddToFirst (0) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddToFirst(sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections))) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections)) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddToFirst (data%State%MudSystem%NoPipeSections) + call data%State%MudSystem%Ann_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Ann_CuttingMud%AddToFirst (0) - MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) + data%State%MudSystem%OldPosition= data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts) - MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + data%State%MudSystem%OldAnnulusCapacity= sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst(MudSystem%ChokeLine_VolumeCapacity) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) + call data%State%MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst(data%State%MudSystem%ChokeLine_VolumeCapacity) + call data%State%MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (BopStackSpecification%ChokeLineLength) + call data%State%MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_Density%AddToFirst (MudProperties%ActiveDensity) ! initial(ppg) + call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts))) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (F_Counts%BottomHoleIntervalCounts) - call MudSystem%Op_Density%AddToFirst (MudProperties%ActiveDensity) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts))) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts)) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%F_Counts%BottomHoleIntervalCounts) + call data%State%MudSystem%Op_Density%AddToFirst (MudProperties%ActiveDensity) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) !F_StringIntervalCountsOld= F_StringIntervalCounts ! is used for adding new pipe to string - MudSystem%F_StringIntervalCounts_Old= F_Counts%StringIntervalCounts ! is used for adding new pipe to string + data%State%MudSystem%F_StringIntervalCounts_Old= data%State%F_Counts%StringIntervalCounts ! is used for adding new pipe to string - MudSystem%FirstMudSet= 1 + data%State%MudSystem%FirstMudSet= 1 endif @@ -201,16 +207,16 @@ ALLOCATE (MudSystem%Xstart_OpSection(F_Counts%BottomHoleIntervalCounts),MudSyste !DeltaVolumeOp < 0 : Trip out - MudSystem%DeltaVolumeOp= ((MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%OD_PipeSectionInch(F_Counts%StringIntervalCounts+1)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal ! D(in) - MudSystem%DeltaVolumeOp = INT(MudSystem%DeltaVolumeOp * 100000.d0) / 100000.d0 + data%State%MudSystem%DeltaVolumeOp= ((data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)-data%State%MudSystem%OldPosition)*PII*((data%State%MudSystem%OD_PipeSectionInch(data%State%F_Counts%StringIntervalCounts+1)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal ! D(in) + data%State%MudSystem%DeltaVolumeOp = INT(data%State%MudSystem%DeltaVolumeOp * 100000.d0) / 100000.d0 - MudSystem%DeltaVolumePipe= ((MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition)*PII*((MudSystem%ID_PipeSectionInch(F_Counts%StringIntervalCounts+F_Counts%AnnulusIntervalCounts)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal - MudSystem%DeltaVolumePipe = INT(MudSystem%DeltaVolumePipe * 100000.d0) / 100000.d0 + data%State%MudSystem%DeltaVolumePipe= ((data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)-data%State%MudSystem%OldPosition)*PII*((data%State%MudSystem%ID_PipeSectionInch(data%State%F_Counts%StringIntervalCounts+data%State%F_Counts%AnnulusIntervalCounts)/12.0d0)**2)/4.0d0)* 7.48051948d0! ft^3 to gal + data%State%MudSystem%DeltaVolumePipe = INT(data%State%MudSystem%DeltaVolumePipe * 100000.d0) / 100000.d0 - !DeltaVolumeAnnulusCapacity= ((Xend_PipeSection(F_Counts%StringIntervalCounts)-OldPosition))*Area_PipeSectionFt(NoPipeSections)* 7.48051948d0! ft^3 to gal - KickVARIABLES%DrillStringSpeed = (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)-MudSystem%OldPosition) / 0.1 + !DeltaVolumeAnnulusCapacity= ((Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)-OldPosition))*Area_PipeSectionFt(NoPipeSections)* 7.48051948d0! ft^3 to gal + KickVARIABLES%DrillStringSpeed = (data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)-data%State%MudSystem%OldPosition) / 0.1 - MudSystem%DeltaVolumeAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%OldAnnulusCapacity + data%State%MudSystem%DeltaVolumeAnnulusCapacity= sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) - data%State%MudSystem%OldAnnulusCapacity !write(*,*) 'DeltaVolumeAnnulusCapacity= ' , DeltaVolumeAnnulusCapacity @@ -219,37 +225,37 @@ ALLOCATE (MudSystem%Xstart_OpSection(F_Counts%BottomHoleIntervalCounts),MudSyste !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp ! ! - !write(*,*) 'Bit here=' , Xend_PipeSection(F_Counts%StringIntervalCounts) + !write(*,*) 'Bit here=' , Xend_PipeSection(data%State%F_Counts%StringIntervalCounts) - MudSystem%OldAnnulusCapacity= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + data%State%MudSystem%OldAnnulusCapacity= sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) - MudSystem%OldPosition= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) + data%State%MudSystem%OldPosition= data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts) ! Needed for trip in or out: - if (MudSystem%Hz_Mud_Backhead_X%Length() == 0) then + if (data%State%MudSystem%Hz_Mud_Backhead_X%Length() == 0) then CALL ErrorStop('Hz_Mud_Backhead_X Length is 0') endif - MudSystem%Hz_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(1) - MudSystem%Hz_Mud_Backhead_section%Array(1)= 1 + data%State%MudSystem%Hz_Mud_Backhead_X%Array(1)= data%State%MudSystem%Xstart_PipeSection(1) + data%State%MudSystem%Hz_Mud_Backhead_section%Array(1)= 1 - MudSystem%AddedElementsToString = F_Counts%StringIntervalCounts - MudSystem%F_StringIntervalCounts_Old - MudSystem%St_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(1)= 2 - MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - MudSystem%Ann_Mud_Backhead_section%Array(1)= F_Counts%StringIntervalCounts+1 - MudSystem%Op_Mud_Backhead_X%Array(1)= MudSystem%Xstart_OpSection(1) - MudSystem%Op_Mud_Backhead_section%Array(1)= 1 - MudSystem%ChokeLine_Mud_Backhead_X%Array(1)= 0. - MudSystem%ChokeLine_Mud_Backhead_section%Array(1)= 1 + data%State%MudSystem%AddedElementsToString = data%State%F_Counts%StringIntervalCounts - data%State%MudSystem%F_StringIntervalCounts_Old + data%State%MudSystem%St_Mud_Backhead_X%Array(1)= data%State%MudSystem%Xstart_PipeSection(2) + data%State%MudSystem%St_Mud_Backhead_section%Array(1)= 2 + data%State%MudSystem%Ann_Mud_Backhead_X%Array(1)= data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1) + data%State%MudSystem%Ann_Mud_Backhead_section%Array(1)= data%State%F_Counts%StringIntervalCounts+1 + data%State%MudSystem%Op_Mud_Backhead_X%Array(1)= data%State%MudSystem%Xstart_OpSection(1) + data%State%MudSystem%Op_Mud_Backhead_section%Array(1)= 1 + data%State%MudSystem%ChokeLine_Mud_Backhead_X%Array(1)= 0. + data%State%MudSystem%ChokeLine_Mud_Backhead_section%Array(1)= 1 - MudSystem%F_StringIntervalCounts_Old= F_Counts%StringIntervalCounts + data%State%MudSystem%F_StringIntervalCounts_Old= data%State%F_Counts%StringIntervalCounts !write(*,*) 'Xstart_PipeSection(2)' , Xstart_PipeSection(2) !write(*,*) 'Xend_PipeSection(1)' , Xend_PipeSection(1) diff --git a/Equipments/MudSystem/FillingWell_By_BellNipple.f90 b/Equipments/MudSystem/FillingWell_By_BellNipple.f90 index ed83f05..7eee41c 100644 --- a/Equipments/MudSystem/FillingWell_By_BellNipple.f90 +++ b/Equipments/MudSystem/FillingWell_By_BellNipple.f90 @@ -1,14 +1,16 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCodeSelect - ! this subroutine is for lines: 1) BellNippleToWell-NonFullWell : MUD(8)%Q - ! 2) PumpsToWell_KillLine : MUD(10)%Q + ! this subroutine is for lines: 1) BellNippleToWell-NonFullWell : data%State%MUD(8)%Q + ! 2) PumpsToWell_KillLine : data%State%MUD(10)%Q Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity +use ConfigurationVariables !@@@ + use ConfigurationVariables + use ConfigurationVariables !@ + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule @@ -26,7 +28,7 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo - if (MudSystem%Ann_MudOrKick%Last() == 104) then ! Last Element is air we must observe: Ann_Mud_Forehead_X%Last()=0.0 + if (data%State%MudSystem%Ann_MudOrKick%Last() == 104) then ! Last Element is air we must observe: Ann_Mud_Forehead_X%Last()=0.0 write(*,*) 'FillingWell_By_BellNipple-Last Element is air' @@ -35,79 +37,79 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo - FillingDensity= MudSystem%BellNippleDensity + FillingDensity= data%State%MudSystem%BellNippleDensity !**************************** - if ( MudSystem%Ann_MudDischarged_Volume%Last() > (((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline)) then ! air baghi mimune + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Last() > (((data%State%MUD(8)%Q+data%State%MUD(10)%Q)/60.)*data%State%MudSystem%DeltaT_Mudline)) then ! air baghi mimune - kloc= MudSystem%Ann_MudDischarged_Volume%Length()-1 + kloc= data%State%MudSystem%Ann_MudDischarged_Volume%Length()-1 - deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline + deltaV= ((data%State%MUD(8)%Q+data%State%MUD(10)%Q)/60.)*data%State%MudSystem%DeltaT_Mudline - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length()) - deltaV + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length())= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length()) - deltaV !========================ANNULUS ENTRANCE==================== - if (ABS(MudSystem%Ann_Density%Array(kloc) - FillingDensity) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%Ann_Density%AddTo (kloc, FillingDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (kloc, 0.0d0) - call MudSystem%Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0) - call MudSystem%Ann_Mud_Forehead_section%AddTo (kloc, 1) - call MudSystem%Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0) - call MudSystem%Ann_Mud_Backhead_section%AddTo (kloc, MudSystem%NoPipeSections) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (kloc, 0) - call MudSystem%Ann_CuttingMud%AddTo (kloc,0) + if (ABS(data%State%MudSystem%Ann_Density%Array(kloc) - FillingDensity) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped + call data%State%MudSystem%Ann_Density%AddTo (kloc, FillingDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (kloc, 0.0d0) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (kloc, 1) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (kloc, data%State%MudSystem%NoPipeSections) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (kloc, 0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (kloc,0) !AnnulusSuctionDensity_Old= Hz_Density_Utube endif !========================ANNULUS==================== - MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+ deltaV !(gal) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)+ deltaV !(gal) - else ! ( Ann_MudDischarged_Volume%Last() <= (((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi namune + else ! ( Ann_MudDischarged_Volume%Last() <= (((data%State%MUD(8)%Q+data%State%MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi namune - kloc= MudSystem%Ann_MudDischarged_Volume%Length()-1 + kloc= data%State%MudSystem%Ann_MudDischarged_Volume%Length()-1 - deltaV= MudSystem%Ann_MudDischarged_Volume%Last() + deltaV= data%State%MudSystem%Ann_MudDischarged_Volume%Last() - if (ABS(MudSystem%Ann_Density%Array(kloc)-FillingDensity)< MudSystem%DensityMixTol .and. MudSystem%Ann_CuttingMud%Array(kloc)==0) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)< 42.) ) then ! 1-Pockets are Merged - MudSystem%Ann_Density%Array(kloc)= (MudSystem%Ann_Density%Array(kloc)*MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) - MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV - MudSystem%Ann_Mud_Forehead_X%Array(kloc)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(kloc)= MudSystem%NoPipeSections + if (ABS(data%State%MudSystem%Ann_Density%Array(kloc)-FillingDensity)< data%State%MudSystem%DensityMixTol .and. data%State%MudSystem%Ann_CuttingMud%Array(kloc)==0) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)< 42.) ) then ! 1-Pockets are Merged + data%State%MudSystem%Ann_Density%Array(kloc)= (data%State%MudSystem%Ann_Density%Array(kloc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV + data%State%MudSystem%Ann_Mud_Forehead_X%Array(kloc)= data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections) + data%State%MudSystem%Ann_Mud_Forehead_section%Array(kloc)= data%State%MudSystem%NoPipeSections !Ann_Mud_Backhead_X%Array(kloc)= no change !Ann_Mud_Backhead_section%Array(kloc)= no change - MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) - call MudSystem%Ann_MudDischarged_Volume%Remove (kloc+1) - call MudSystem%Ann_Mud_Backhead_X%Remove (kloc+1) - call MudSystem%Ann_Mud_Backhead_section%Remove (kloc+1) - call MudSystem%Ann_Mud_Forehead_X%Remove (kloc+1) - call MudSystem%Ann_Mud_Forehead_section%Remove (kloc+1) - call MudSystem%Ann_Density%Remove (kloc+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (kloc+1) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (kloc+1) - call MudSystem%Ann_MudOrKick%Remove (kloc+1) - call MudSystem%Ann_CuttingMud%Remove (kloc+1) + call data%State%MudSystem%Ann_MudDischarged_Volume%Remove (kloc+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%Remove (kloc+1) + call data%State%MudSystem%Ann_Mud_Backhead_section%Remove (kloc+1) + call data%State%MudSystem%Ann_Mud_Forehead_X%Remove (kloc+1) + call data%State%MudSystem%Ann_Mud_Forehead_section%Remove (kloc+1) + call data%State%MudSystem%Ann_Density%Remove (kloc+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Remove (kloc+1) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (kloc+1) + call data%State%MudSystem%Ann_MudOrKick%Remove (kloc+1) + call data%State%MudSystem%Ann_CuttingMud%Remove (kloc+1) else ! 2-Merging conditions are not meeted, so new pocket== air is replaced with filling mud - MudSystem%Ann_Density%Array(kloc+1) =FillingDensity - MudSystem%Ann_MudOrKick%Array(kloc+1)= 0 + data%State%MudSystem%Ann_Density%Array(kloc+1) =FillingDensity + data%State%MudSystem%Ann_MudOrKick%Array(kloc+1)= 0 endif @@ -129,9 +131,9 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo !write(*,*) '*Ann_MudOrKick%Last()=' , Ann_MudOrKick%Last() - deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*MudSystem%DeltaT_Mudline + deltaV= ((data%State%MUD(8)%Q+data%State%MUD(10)%Q)/60.)*data%State%MudSystem%DeltaT_Mudline - kloc= MudSystem%Ann_MudDischarged_Volume%Length() + kloc= data%State%MudSystem%Ann_MudDischarged_Volume%Length() @@ -139,37 +141,37 @@ subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCo !========================ANNULUS ENTRANCE==================== - if (ABS(MudSystem%Ann_Density%Last() - FillingDensity) >= MudSystem%DensityMixTol .or. MudSystem%Ann_CuttingMud%Last()==1) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)>42.) ) then ! new mud is pumped - Xposition= MudSystem%Ann_Mud_Forehead_X%Last() - SectionPosition= MudSystem%Ann_Mud_Forehead_section%Last() - call MudSystem%Ann_Density%Add (FillingDensity) - call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) - call MudSystem%Ann_Mud_Forehead_X%Add (Xposition) - call MudSystem%Ann_Mud_Forehead_section%Add (SectionPosition) - call MudSystem%Ann_Mud_Backhead_X%Add (Xposition) - call MudSystem%Ann_Mud_Backhead_section%Add (SectionPosition) - call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Ann_MudOrKick%Add (0) - call MudSystem%Ann_CuttingMud%Add (0) + if (ABS(data%State%MudSystem%Ann_Density%Last() - FillingDensity) >= data%State%MudSystem%DensityMixTol .or. data%State%MudSystem%Ann_CuttingMud%Last()==1) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)>42.) ) then ! new mud is pumped + Xposition= data%State%MudSystem%Ann_Mud_Forehead_X%Last() + SectionPosition= data%State%MudSystem%Ann_Mud_Forehead_section%Last() + call data%State%MudSystem%Ann_Density%Add (FillingDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) + call data%State%MudSystem%Ann_Mud_Forehead_X%Add (Xposition) + call data%State%MudSystem%Ann_Mud_Forehead_section%Add (SectionPosition) + call data%State%MudSystem%Ann_Mud_Backhead_X%Add (Xposition) + call data%State%MudSystem%Ann_Mud_Backhead_section%Add (SectionPosition) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%Add (0) + call data%State%MudSystem%Ann_CuttingMud%Add (0) !AnnulusSuctionDensity_Old= Hz_Density_Utube !endif !========================ANNULUS==================== - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())+ deltaV !(gal) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length())= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length())+ deltaV !(gal) else ! Merged with last Mud - MudSystem%Ann_Density%Array(kloc)= (MudSystem%Ann_Density%Array(kloc)*MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) - MudSystem%Ann_MudDischarged_Volume%Array(kloc)= MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV + data%State%MudSystem%Ann_Density%Array(kloc)= (data%State%MudSystem%Ann_Density%Array(kloc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(kloc)+deltaV !Ann_Mud_Forehead_X%Array(kloc)= Xend_PipeSection(NoPipeSections) !Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections !Ann_Mud_Backhead_X%Array(kloc)= no change !Ann_Mud_Backhead_section%Array(kloc)= no change - MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0) endif diff --git a/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 b/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 index 8852476..0161ba6 100644 --- a/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 +++ b/Equipments/MudSystem/Kick_Expansion_and_Contraction.f90 @@ -3,9 +3,10 @@ subroutine Kick_Expansion ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity +use ConfigurationVariables !@@@ + use ConfigurationVariables + use ConfigurationVariables !@ + !use CTanks !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables USE CReservoirVariables @@ -17,22 +18,22 @@ subroutine Kick_Expansion ! is called in subroutine CirculationCodeSelect !write(*,*) 'Kick Expansion' - ExpansionVolume= GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - MudSystem%KickNumber + 1) * 7.48 + ExpansionVolume= GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - data%State%MudSystem%KickNumber + 1) * 7.48 -IF ( MudSystem%Kickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) +IF ( data%State%MudSystem%Kickexpansion_DueToMudLost ) ExpansionVolume = ((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !============================== kick zire mate bashad ============================== - if (MudSystem%Op_KickLoc > 0 .and. MudSystem%Ann_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then + if (data%State%MudSystem%Op_KickLoc > 0 .and. data%State%MudSystem%Ann_KickLoc==0) then ! .and. Op_KickLoc /= Op_MudOrKick%Length ()) then !write(*,*) 'expansion (1)' - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)+ ExpansionVolume + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc)+ ExpansionVolume - !if (MUD(4)%Q > 0.) then + !if (data%State%MUD(4)%Q > 0.) then ! ! if (abs(ChokeLine_Density%Array(1)-Ann_Density%Last())< DensityMixTol) then ! ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1) + ExpansionVolume @@ -57,16 +58,16 @@ IF ( MudSystem%Kickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystem%Qlos !============================= foreheade dar fazaye annulus bashad =========================== ! agar kick be entehaye annulus reside bashe, expansion ra emaal nemikonim - if (MudSystem%Ann_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then + if (data%State%MudSystem%Ann_KickLoc > 0) then ! .and. Ann_KickLoc /= Ann_MudOrKick%Length ()) then !write(*,*) 'expansion (2)' !if ( sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc)) + ExpansionVolume > sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ) then ! agar khast az mate rad kone ! ExpansionVolume= sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) - sum(Ann_MudDischarged_Volume%Array(1:Ann_KickLoc)) !endif - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)+ ExpansionVolume + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc)+ ExpansionVolume - !if (MUD(4)%Q > 0.) then + !if (data%State%MUD(4)%Q > 0.) then ! ! ! if (abs(ChokeLine_Density%Array(1)-Ann_Density%Last())< DensityMixTol) then @@ -94,9 +95,9 @@ IF ( MudSystem%Kickexpansion_DueToMudLost ) ExpansionVolume = ((MudSystem%Qlos !=============================== foreheade dar choke line bashad ============================= - if (MudSystem%ChokeLine_KickLoc > 0 .and. MudSystem%Ann_KickLoc==0) then + if (data%State%MudSystem%ChokeLine_KickLoc > 0 .and. data%State%MudSystem%Ann_KickLoc==0) then - MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)= MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)+ ExpansionVolume + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc)+ ExpansionVolume endif @@ -126,9 +127,10 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity +use ConfigurationVariables !@@@ + use ConfigurationVariables + use ConfigurationVariables !@ + !use CTanks !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables USE CReservoirVariables @@ -150,13 +152,13 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect !********************************************************* !write(*,*) 'Kick Contraction' - !MUD(2)%Q= MPumps%Total_Pump_GPM - MudSystem%StringFlowRate= MUD(2)%Q - MudSystem%AnnulusFlowRate= MUD(2)%Q + !data%State%MUD(2)%Q= data%State%MPumps%Total_Pump_GPM + data%State%MudSystem%StringFlowRate= data%State%MUD(2)%Q + data%State%MudSystem%AnnulusFlowRate= data%State%MUD(2)%Q - if (MudSystem%NewPipeFilling == 0) then - MudSystem%StringFlowRate= 0. - MudSystem%AnnulusFlowRate= 0. + if (data%State%MudSystem%NewPipeFilling == 0) then + data%State%MudSystem%StringFlowRate= 0. + data%State%MudSystem%AnnulusFlowRate= 0. endif @@ -164,10 +166,10 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect !if (WellHeadIsOpen) then - ContractionVolume= - GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - MudSystem%KickNumber + 1) * 7.48 + ContractionVolume= - GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - data%State%MudSystem%KickNumber + 1) * 7.48 !else - !ContractionVolume = (MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe - if (MudSystem%KickNumber == 1 .and. MudSystem%WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline + MudSystem%DeltaVolumePipe + !ContractionVolume = (data%State%MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline + DeltaVolumePipe + if (data%State%MudSystem%KickNumber == 1 .and. data%State%MudSystem%WellHeadIsOpen==.false.) ContractionVolume = ContractionVolume + (data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline + data%State%MudSystem%DeltaVolumePipe !endif @@ -175,43 +177,43 @@ subroutine Kick_Contraction ! is called in subroutine CirculationCodeSelect ! pump mud is added in "pump&TripIn" code - IF (MudSystem%Op_KickLoc > 0 .and. MudSystem%Ann_KickLoc == 0) then ! All of kick is under bit (iloc == 1) + IF (data%State%MudSystem%Op_KickLoc > 0 .and. data%State%MudSystem%Ann_KickLoc == 0) then ! All of kick is under bit (iloc == 1) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc) - ( ContractionVolume ) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc) - ( ContractionVolume ) - ELSE IF (MudSystem%Op_KickLoc == 0 .AND. MudSystem%Ann_KickLoc > 0 .AND. MudSystem%ChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1) + ELSE IF (data%State%MudSystem%Op_KickLoc == 0 .AND. data%State%MudSystem%Ann_KickLoc > 0 .AND. data%State%MudSystem%ChokeLine_KickLoc == 0) THEN ! All of kick is an Annulus (iloc == 1) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc) - ( ContractionVolume ) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc) - ( ContractionVolume ) - ELSE IF (MudSystem%Ann_KickLoc == 0 .AND. MudSystem%ChokeLine_KickLoc > 0) THEN ! kick is in chokeline only + ELSE IF (data%State%MudSystem%Ann_KickLoc == 0 .AND. data%State%MudSystem%ChokeLine_KickLoc > 0) THEN ! kick is in chokeline only - MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc)= MudSystem%ChokeLine_MudDischarged_Volume%Array(MudSystem%ChokeLine_KickLoc) - ( ContractionVolume ) + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(data%State%MudSystem%ChokeLine_KickLoc) - ( ContractionVolume ) - ELSE IF (MudSystem%Op_KickLoc > 0 .AND. MudSystem%Ann_KickLoc > 0) THEN ! Kick is around bit (iloc==2) + ELSE IF (data%State%MudSystem%Op_KickLoc > 0 .AND. data%State%MudSystem%Ann_KickLoc > 0) THEN ! Kick is around bit (iloc==2) - if (MudSystem%Ann_MudDischarged_Volume%Array(1) > ContractionVolume ) then + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) > ContractionVolume ) then - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - ( ContractionVolume ) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) - ( ContractionVolume ) - elseif (MudSystem%Op_MudDischarged_Volume%Last() > ContractionVolume ) then + elseif (data%State%MudSystem%Op_MudDischarged_Volume%Last() > ContractionVolume ) then - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_MudDischarged_Volume%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_MudDischarged_Volume%Length()) - ( ContractionVolume ) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_MudDischarged_Volume%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_MudDischarged_Volume%Length()) - ( ContractionVolume ) else Call ErrorStop ('kick contraction error 1') endif - ELSE IF (MudSystem%Ann_KickLoc > 0 .AND. MudSystem%ChokeLine_KickLoc > 0) THEN + ELSE IF (data%State%MudSystem%Ann_KickLoc > 0 .AND. data%State%MudSystem%ChokeLine_KickLoc > 0) THEN - if (MudSystem%ChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then + if (data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1) > ContractionVolume ) then - MudSystem%ChokeLine_MudDischarged_Volume%Array(1) = MudSystem%ChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume ) + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1) = data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1) - ( ContractionVolume ) - elseif (MudSystem%Ann_MudDischarged_Volume%Last() > ContractionVolume ) then + elseif (data%State%MudSystem%Ann_MudDischarged_Volume%Last() > ContractionVolume ) then - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length()) - ( ContractionVolume ) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length())= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length()) - ( ContractionVolume ) else Call ErrorStop ('kick contraction error 2') diff --git a/Equipments/MudSystem/Kick_Influx.f90 b/Equipments/MudSystem/Kick_Influx.f90 index 910d904..452e60d 100644 --- a/Equipments/MudSystem/Kick_Influx.f90 +++ b/Equipments/MudSystem/Kick_Influx.f90 @@ -3,9 +3,11 @@ subroutine Kick_Influx ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity +use ConfigurationVariables !@@@ + use ConfigurationVariables + use ConfigurationVariables !@ + !use CTanks + ! !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule @@ -22,27 +24,27 @@ subroutine Kick_Influx ! is called in subroutine CirculationCodeSelect !=================== Bottom Hole Kick Influx ENTRANCE(due to Kick) =================== - MudSystem%Kick_Density= 2 - MudSystem%NewInflux_Density= MudSystem%Kick_Density + data%State%MudSystem%Kick_Density= 2 + data%State%MudSystem%NewInflux_Density= data%State%MudSystem%Kick_Density - if ( MudSystem%NewInfluxElementCreated==0 ) then ! new kick is pumped- (it is set to zero in sheykh subroutine after a new kick influx) - call MudSystem%Op_Density%AddToFirst (MudSystem%NewInflux_Density) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (MudSystem%NewInfluxNumber) ! KickNumber= NewInfluxNumber + if ( data%State%MudSystem%NewInfluxElementCreated==0 ) then ! new kick is pumped- (it is set to zero in sheykh subroutine after a new kick influx) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewInflux_Density) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (0.0d0) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (data%State%MudSystem%NewInfluxNumber) ! KickNumber= NewInfluxNumber - MudSystem%NewInfluxElementCreated= 1 + data%State%MudSystem%NewInfluxElementCreated= 1 endif - MudSystem%Op_MudDischarged_Volume%Array(1)= MudSystem%Op_MudDischarged_Volume%Array(1)+ ((KickVARIABLES%GasKickPumpFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) due to KickFlux + data%State%MudSystem%Op_MudDischarged_Volume%Array(1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(1)+ ((KickVARIABLES%GasKickPumpFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) due to KickFlux !write(*,*) 'kick volume ok=' , Op_MudDischarged_Volume%Array(1) @@ -62,11 +64,12 @@ subroutine Kick_Influx ! is called in subroutine CirculationCodeSelect subroutine Instructor_CirculationMud_Edit ! is called in subroutine CirculationCodeSelect use KickVARIABLESModule - Use MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE TD_DrillStemComponents Use CUnityInputs Use CUnityOutputs - USE CKellyConnectionEnumVariables + use OperationScenariosModule use UTUBEVARSModule use sROP_Variables use sROP_Other_Variables @@ -79,13 +82,13 @@ subroutine Instructor_CirculationMud_Edit ! is called in subroutine Circulat - if ( DownHole%AnnDrillMud == .true. .and. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%DeltaVolumeOp>0.0) ) then + if ( DownHole%AnnDrillMud == .true. .and. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%DeltaVolumeOp>0.0) ) then - do imud= 1, MudSystem%Ann_Density%Length() + do imud= 1, data%State%MudSystem%Ann_Density%Length() - if ( MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then - MudSystem%Ann_Density%Array(imud)= (MudSystem%St_Density%Last() * MudSystem%AnnulusFlowRate + 141.4296E-4*ROP_Bit%RateOfPenetration*ROP_Spec%DiameterOfBit**2)/(MudSystem%AnnulusFlowRate+6.7995E-4*ROP_Bit%RateOfPenetration*ROP_Spec%DiameterOfBit**2) - MudSystem%Ann_CuttingMud%Array(imud)= 1 + if ( data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then + data%State%MudSystem%Ann_Density%Array(imud)= (data%State%MudSystem%St_Density%Last() * data%State%MudSystem%AnnulusFlowRate + 141.4296E-4*data%State%ROP_Bit%RateOfPenetration*data%State%ROP_Spec%DiameterOfBit**2)/(data%State%MudSystem%AnnulusFlowRate+6.7995E-4*data%State%ROP_Bit%RateOfPenetration*data%State%ROP_Spec%DiameterOfBit**2) + data%State%MudSystem%Ann_CuttingMud%Array(imud)= 1 endif enddo @@ -95,18 +98,18 @@ subroutine Instructor_CirculationMud_Edit ! is called in subroutine Circulat if ( DownHole%AnnCirculateMud == .true. ) then - do imud= 1, MudSystem%Ann_Density%Length() + do imud= 1, data%State%MudSystem%Ann_Density%Length() - if ( MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then - MudSystem%Ann_Density%Array(imud)= MudSystem%ActiveTankDensity - MudSystem%Ann_CuttingMud%Array(imud)= 0 + if ( data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then + data%State%MudSystem%Ann_Density%Array(imud)= data%State%MudSystem%ActiveTankDensity + data%State%MudSystem%Ann_CuttingMud%Array(imud)= 0 endif enddo - do imud= 1, MudSystem%St_Density%Length() + do imud= 1, data%State%MudSystem%St_Density%Length() - MudSystem%St_Density%Array(imud)= MudSystem%ActiveTankDensity + data%State%MudSystem%St_Density%Array(imud)= data%State%MudSystem%ActiveTankDensity enddo @@ -122,44 +125,45 @@ subroutine Instructor_CirculationMud_Edit ! is called in subroutine Circulat subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect use KickVARIABLESModule - Use MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE TD_DrillStemComponents Use CUnityInputs Use CUnityOutputs - USE CKellyConnectionEnumVariables + use OperationScenariosModule use UTUBEVARSModule use sROP_Variables use sROP_Other_Variables use CDownHoleVariables use CShoeVariables use PressureDisplayVARIABLESModule - Use CWarningsVariables + use CWarnings implicit none - MudSystem%ShoeLost= .false. - MudSystem%Kickexpansion_DueToMudLost= .false. + data%State%MudSystem%ShoeLost= .false. + data%State%MudSystem%Kickexpansion_DueToMudLost= .false. - MudSystem%ShoeMudPressure= PressureDisplayVARIABLES%PressureGauges(5) + data%State%MudSystem%ShoeMudPressure= data%State%PressureDisplay%PressureGauges(5) - MudSystem%UGBOSuccessionCounter = MudSystem%UGBOSuccessionCounter + 1 + data%State%MudSystem%UGBOSuccessionCounter = data%State%MudSystem%UGBOSuccessionCounter + 1 !write(*,*) 'check point 1' - if (Shoe%InactiveFracture == .FALSE. .AND. ((MudSystem%ShoeMudPressure >= MudSystem%FormationLostPressure) .or. MudSystem%ShoeFractured )) then + if (Shoe%InactiveFracture == .FALSE. .AND. ((data%State%MudSystem%ShoeMudPressure >= data%State%MudSystem%FormationLostPressure) .or. data%State%MudSystem%ShoeFractured )) then !write(*,*) 'check point 2 ,UGBOSuccessionCounter' , UGBOSuccessionCounter ! if ShoeFractured changed to true , then time counter is not needed more - if ( MudSystem%UGBOSuccessionCounter /= MudSystem%UGBOSuccessionCounterOld+1 .and. MudSystem%ShoeFractured==.false. ) then - MudSystem%UGBOSuccessionCounter = 0 ! also in starup - MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup + if ( data%State%MudSystem%UGBOSuccessionCounter /= data%State%MudSystem%UGBOSuccessionCounterOld+1 .and. data%State%MudSystem%ShoeFractured==.false. ) then + data%State%MudSystem%UGBOSuccessionCounter = 0 ! also in starup + data%State%MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup return else - MudSystem%UGBOSuccessionCounterOld= MudSystem%UGBOSuccessionCounter + data%State%MudSystem%UGBOSuccessionCounterOld= data%State%MudSystem%UGBOSuccessionCounter endif - if ( MudSystem%UGBOSuccessionCounter < 10 .and. MudSystem%ShoeFractured==.false.) then + if ( data%State%MudSystem%UGBOSuccessionCounter < 10 .and. data%State%MudSystem%ShoeFractured==.false.) then return endif @@ -167,30 +171,30 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect - MudSystem%ShoeFractured= .true. + data%State%MudSystem%ShoeFractured= .true. - MudSystem%ShoeMudViscosity= MAX(MudSystem%ShoeMudViscosity, 12.d0) + data%State%MudSystem%ShoeMudViscosity= MAX(data%State%MudSystem%ShoeMudViscosity, 12.d0) !write(*,*) 'ShoeMudDensity , ShoeMudViscosity' , ShoeMudDensity , ShoeMudViscosity - MudSystem%ShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * MudSystem%ShoeMudDensity / & - (MudSystem%ShoeMudViscosity * LOG(10000.d0)) + data%State%MudSystem%ShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * data%State%MudSystem%ShoeMudDensity / & + (data%State%MudSystem%ShoeMudViscosity * LOG(10000.d0)) !write(*,*) 'lost parameters 1' , ShoeMudPressure , FormationLostPressure - MudSystem%Qlost = MAX( (MudSystem%ShoeLostCoef * (MudSystem%ShoeMudPressure - (MudSystem%FormationLostPressure/2.0))) , 0.d0 ) - if (MudSystem%Qlost > 0.0) then - MudSystem%ShoeLost= .true. + data%State%MudSystem%Qlost = MAX( (data%State%MudSystem%ShoeLostCoef * (data%State%MudSystem%ShoeMudPressure - (data%State%MudSystem%FormationLostPressure/2.0))) , 0.d0 ) + if (data%State%MudSystem%Qlost > 0.0) then + data%State%MudSystem%ShoeLost= .true. else - MudSystem%ShoeLost= .false. + data%State%MudSystem%ShoeLost= .false. endif !write(*,*) 'Qlost=' , Qlost, ShoeMudPressure, FormationLostPressure call Activate_UndergroundBlowout() - do imud= 1, MudSystem%Ann_Mud_Forehead_X%Length() + do imud= 1, data%State%MudSystem%Ann_Mud_Forehead_X%Length() - IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) & - .and. MudSystem%Ann_MudOrKick%Array(imud) == 0 .and. MudSystem%WellHeadIsOpen == .FALSE. ) then + IF ( data%State%MudSystem%ShoeLost .and. Shoe%ShoeDepth < data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud) & + .and. data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0 .and. data%State%MudSystem%WellHeadIsOpen == .FALSE. ) then - MudSystem%Kickexpansion_DueToMudLost= .true. + data%State%MudSystem%Kickexpansion_DueToMudLost= .true. write(*,*) 'Kickexpansion_DueToMudLost' EXIT @@ -204,7 +208,7 @@ subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect endif - if (Warmings%UndergroundBlowout == .false.) MudSystem%ShoeLost= .false. + if (data%Warnings%UndergroundBlowout == .false.) data%State%MudSystem%ShoeLost= .false. diff --git a/Equipments/MudSystem/Kick_Migration.f90 b/Equipments/MudSystem/Kick_Migration.f90 index 30d963b..c90487a 100644 --- a/Equipments/MudSystem/Kick_Migration.f90 +++ b/Equipments/MudSystem/Kick_Migration.f90 @@ -3,9 +3,11 @@ subroutine Kick_Migration ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity +use ConfigurationVariables !@@@ + use ConfigurationVariables + use ConfigurationVariables !@ + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables USE CReservoirVariables @@ -18,58 +20,58 @@ subroutine Kick_Migration ! is called in subroutine CirculationCodeSelect integer jopelement,jopmud,jopsection,CuttingValue - !MUD(2)%Q= MPumps%Total_Pump_GPM - !MudSystem%StringFlowRate= MUD(2)%Q - !MudSystem%AnnulusFlowRate= MUD(2)%Q + !data%State%MUD(2)%Q= data%State%MPumps%Total_Pump_GPM + !data%State%MudSystem%StringFlowRate= data%State%MUD(2)%Q + !data%State%MudSystem%AnnulusFlowRate= data%State%MUD(2)%Q ! !if (NewPipeFilling == 0) then - ! MudSystem%StringFlowRate= 0. - ! MudSystem%AnnulusFlowRate= 0. + ! data%State%MudSystem%StringFlowRate= 0. + ! data%State%MudSystem%AnnulusFlowRate= 0. !endif - !StringFlowRateFinal= MudSystem%StringFlowRate - !AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate + !StringFlowRateFinal= data%State%MudSystem%StringFlowRate + !AnnulusFlowRateFinal= data%State%MudSystem%AnnulusFlowRate - !write(*,*) 'MUD(2)%Q=====' , MUD(2)%Q + !write(*,*) 'data%State%MUD(2)%Q=====' , data%State%MUD(2)%Q !write(*,*) 'Kick Migration,NewInfluxNumber:' , NewInfluxNumber !FirstSetKickMigration !write(*,*) 'NewInfluxNumber=' , NewInfluxNumber -DO KickNumber= MudSystem%NewInfluxNumber-KickVARIABLES%NoGasPocket+1 , MudSystem%NewInfluxNumber +DO KickNumber= data%State%MudSystem%NewInfluxNumber-KickVARIABLES%NoGasPocket+1 , data%State%MudSystem%NewInfluxNumber !write(*,*) 'KickNumber=' , KickNumber - if (KickVARIABLES%KickFlux .AND. NOT(KickVARIABLES%KickOffBottom) .and. KickNumber == MudSystem%NewInfluxNumber) cycle - if ( KickNumber == MudSystem%Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called + if (KickVARIABLES%KickFlux .AND. NOT(KickVARIABLES%KickOffBottom) .and. KickNumber == data%State%MudSystem%NewInfluxNumber) cycle + if ( KickNumber == data%State%MudSystem%Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called !write(*,*) 'Migration will be done for,KickNumber=' ,KickNumber !=================== Bottom Hole ENTRANCE(due to Kick) =================== !KickDx= (AutoMigrationRate/60.)*DeltaT_Mudline !3600 (ft/min)= 6 ft set in start up - MudSystem%Op_KickLoc= 0 - MudSystem%Ann_KickLoc= 0 - MudSystem%ChokeLine_KickLoc= 0 + data%State%MudSystem%Op_KickLoc= 0 + data%State%MudSystem%Ann_KickLoc= 0 + data%State%MudSystem%ChokeLine_KickLoc= 0 - do i = 1, MudSystem%Op_MudOrKick%Length () - if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then - MudSystem%Op_KickLoc = i + do i = 1, data%State%MudSystem%Op_MudOrKick%Length () + if (data%State%MudSystem%Op_MudOrKick%Array(i) == KickNumber) then + data%State%MudSystem%Op_KickLoc = i exit endif end do - do i = 1, MudSystem%Ann_MudOrKick%Length () - if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then - MudSystem%Ann_KickLoc = i + do i = 1, data%State%MudSystem%Ann_MudOrKick%Length () + if (data%State%MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then + data%State%MudSystem%Ann_KickLoc = i exit endif end do - do i = 1, MudSystem%ChokeLine_MudOrKick%Length () - if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then - MudSystem%ChokeLine_KickLoc = i + do i = 1, data%State%MudSystem%ChokeLine_MudOrKick%Length () + if (data%State%MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then + data%State%MudSystem%ChokeLine_KickLoc = i exit endif end do @@ -88,114 +90,114 @@ DO KickNumber= MudSystem%NewInfluxNumber-KickVARIABLES%NoGasPocket+1 , MudSystem !============================== foreheade kick be mate reside bashad *3 ============================== -if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann_KickLoc==0 ) then +if (data%State%MudSystem%Op_KickLoc == data%State%MudSystem%Op_MudOrKick%Length () .and. data%State%MudSystem%Ann_KickLoc==0 ) then !write(*,*) '****3' - MudSystem%iLoc= 2 + data%State%MudSystem%iLoc= 2 - MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%KickDv= data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Forehead_section%Array(data%State%MudSystem%Op_KickLoc)) * data%State%MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (1), MudSystem%Op_MudDischarged_Volume%Last () ) + data%State%MudSystem%MinKickDv= min( data%State%MudSystem%KickDv,data%State%MudSystem%Ann_MudDischarged_Volume%Array (1), data%State%MudSystem%Op_MudDischarged_Volume%Last () ) - MudSystem%NewDensity= MudSystem%Ann_Density%Array (1) - MudSystem%NewVolume= MudSystem%MinKickDv + data%State%MudSystem%NewDensity= data%State%MudSystem%Ann_Density%Array (1) + data%State%MudSystem%NewVolume= data%State%MudSystem%MinKickDv - if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund + if ( data%State%MudSystem%MinKickDv == data%State%MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund - MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv + data%State%MudSystem%Ann_MudDischarged_Volume%Array (1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (1) - data%State%MudSystem%MinKickDv - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) - call MudSystem%Ann_CuttingMud%AddToFirst (0) + call data%State%MudSystem%Ann_Density%AddToFirst (data%State%MudSystem%Op_Density%Last()) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddToFirst (data%State%MudSystem%MinKickDv) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) + call data%State%MudSystem%Ann_CuttingMud%AddToFirst (0) - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv + data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc) - data%State%MudSystem%MinKickDv ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then + if (data%State%MudSystem%Op_KickLoc > 1) then + !if ( Op_Density%Array (Op_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) + call data%State%MudSystem%Op_Density%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (data%State%MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume + data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)= (data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1) + data%State%MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1=============================== !write(*,*) '****3-1' - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) endif - elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund + elseif ( data%State%MudSystem%MinKickDv == data%State%MudSystem%Ann_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund - MudSystem%Ann_Density%Array(1)= MudSystem%Op_Density%Last() - MudSystem%Ann_MudOrKick%Array(1)= KickNumber + data%State%MudSystem%Ann_Density%Array(1)= data%State%MudSystem%Op_Density%Last() + data%State%MudSystem%Ann_MudOrKick%Array(1)= KickNumber - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv + data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc) - data%State%MudSystem%MinKickDv ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then + if (data%State%MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) + call data%State%MudSystem%Op_Density%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (data%State%MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume + data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)= (data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1) + data%State%MudSystem%NewVolume endif @@ -203,88 +205,88 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann !write(*,*) '****3-2' - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) endif ! - elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod + elseif ( data%State%MudSystem%MinKickDv == data%State%MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod - MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv + data%State%MudSystem%Ann_MudDischarged_Volume%Array (1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (1) - data%State%MudSystem%MinKickDv - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) - call MudSystem%Ann_CuttingMud%AddToFirst (0) + call data%State%MudSystem%Ann_Density%AddToFirst (data%State%MudSystem%Op_Density%Last()) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddToFirst (data%State%MudSystem%MinKickDv) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddToFirst (KickNumber) + call data%State%MudSystem%Ann_CuttingMud%AddToFirst (0) - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_MudDischarged_Volume%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Mud_Backhead_X%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Mud_Backhead_section%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Mud_Forehead_X%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Mud_Forehead_section%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Density%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_MudOrKick%Remove (data%State%MudSystem%Op_KickLoc) ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then + if (data%State%MudSystem%Op_KickLoc > 1) then + !if ( Op_Density%Array (Op_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) + call data%State%MudSystem%Op_Density%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (data%State%MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume + data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)= (data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1) + data%State%MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3=============================== !write(*,*) '****3-3' - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) endif @@ -301,7 +303,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann !============================== foreheade kick be mate reside bashad *3 with pump ============================== -! if (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 .and. MudSystem%AnnulusFlowRate /= 0.0 ) then +! if (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 .and. data%State%MudSystem%AnnulusFlowRate /= 0.0 ) then ! write(*,*) '****3 with pump' ! ! KickMigration_2SideBit= .true. @@ -311,11 +313,11 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! !!farz mikonam baraye in yek iteration kick az OP hazf nemishavad va hajme aan bishtar az pump flow ast ! -! KickDv= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) +! KickDv= ((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! ! call Ann_Density%AddToFirst (Kick_Density) ! call Ann_MudDischarged_Volume%AddToFirst (KickDv) -! call Ann_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) +! call Ann_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) ! call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) ! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) ! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) @@ -327,14 +329,14 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! ! ! -! !if ( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad +! !if ( ((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad ! ! -! ! KickDv= ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) +! ! KickDv= ((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) ! ! ! ! ! BackHead: -! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then +! if ( Op_Density%Array (Op_KickLoc-1) /=data%State%MudSystem%St_Density%Last() ) then ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) @@ -351,7 +353,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! -! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity +! else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + KickDv ! @@ -366,87 +368,87 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann !============================= tamame kick zire mate bashad *1 ================================ - if ( MudSystem%Op_KickLoc>0 .and. MudSystem%Op_KickLoc < MudSystem%Op_MudOrKick%Length () ) then + if ( data%State%MudSystem%Op_KickLoc>0 .and. data%State%MudSystem%Op_KickLoc < data%State%MudSystem%Op_MudOrKick%Length () ) then !write(*,*) '****1' !iloc= 1 - MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%KickDv= data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Forehead_section%Array(data%State%MudSystem%Op_KickLoc)) * data%State%MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - if ( MudSystem%KickDv < MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) ) then !eleman bala sari baghi mimund + if ( data%State%MudSystem%KickDv < data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc+1) ) then !eleman bala sari baghi mimund !write(*,*) 'cond 11111111111111' - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) - MudSystem%KickDv + data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc+1)= data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc+1) - data%State%MudSystem%KickDv - MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1) - MudSystem%NewVolume= MudSystem%KickDv + data%State%MudSystem%NewDensity= data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc+1) + data%State%MudSystem%NewVolume= data%State%MudSystem%KickDv else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund ! write(*,*) 'cond 22222222222222222' - MudSystem%KickDv= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) + data%State%MudSystem%KickDv= data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc+1) - MudSystem%NewVolume= MudSystem%KickDv - MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1) + data%State%MudSystem%NewVolume= data%State%MudSystem%KickDv + data%State%MudSystem%NewDensity= data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc+1) - call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc+1) - call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_MudDischarged_Volume%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_Mud_Backhead_X%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_Mud_Backhead_section%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_Mud_Forehead_X%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_Mud_Forehead_section%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_Density%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (data%State%MudSystem%Op_KickLoc+1) + call data%State%MudSystem%Op_MudOrKick%Remove (data%State%MudSystem%Op_KickLoc+1) endif ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then + if (data%State%MudSystem%Op_KickLoc > 1) then + !if ( Op_Density%Array (Op_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) + call data%State%MudSystem%Op_Density%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (data%State%MudSystem%Op_KickLoc,0) - else !Op_Density%Array (Op_KickLoc-1) == MudSystem%NewDensity + else !Op_Density%Array (Op_KickLoc-1) == data%State%MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume + data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)= (data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1) + data%State%MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1=============================== !write(*,*) '****5-1' - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) endif @@ -460,65 +462,65 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann !=========================== tamame kick balaye mate bashad *2 ================================== - if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc==0 ) then + if ( data%State%MudSystem%Ann_KickLoc > 0 .and. data%State%MudSystem%Op_KickLoc==0 ) then !write(*,*) '****2' !iloc= 1 - MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%KickDv= data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%Ann_KickLoc)) * data%State%MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1) - MudSystem%NewVolume= MudSystem%KickDv - CuttingValue= MudSystem%Ann_CuttingMud%Array (MudSystem%Ann_KickLoc+1) + data%State%MudSystem%NewDensity= data%State%MudSystem%Ann_Density%Array (data%State%MudSystem%Ann_KickLoc+1) + data%State%MudSystem%NewVolume= data%State%MudSystem%KickDv + CuttingValue= data%State%MudSystem%Ann_CuttingMud%Array (data%State%MudSystem%Ann_KickLoc+1) - if ( MudSystem%KickDv < MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then !eleman bala sari baghi mimund + if ( data%State%MudSystem%KickDv < data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1) ) then !eleman bala sari baghi mimund - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%KickDv + data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1) - data%State%MudSystem%KickDv else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund - MudSystem%KickDv= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%NewVolume= MudSystem%KickDv + data%State%MudSystem%KickDv= data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1) + data%State%MudSystem%NewVolume= data%State%MudSystem%KickDv - call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_MudDischarged_Volume%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Backhead_section%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Forehead_X%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Forehead_section%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Density%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_MudOrKick%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_CuttingMud%Remove (data%State%MudSystem%Ann_KickLoc+1) endif ! backheade kick balaye mate bashad - if (MudSystem%Ann_KickLoc > 1) then - !if ( Ann_Density%Array (Ann_KickLoc-1) /= MudSystem%NewDensity ) then + if (data%State%MudSystem%Ann_KickLoc > 1) then + !if ( Ann_Density%Array (Ann_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Ann_Density%Array (data%State%MudSystem%Ann_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Ann_Mud_Backhead_X%Array (data%State%MudSystem%Ann_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Ann_Mud_Backhead_section%Array (data%State%MudSystem%Ann_KickLoc) - call MudSystem%Ann_Density%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%Ann_KickLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Ann_KickLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%Ann_KickLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%Ann_KickLoc,0) + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%Ann_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%Ann_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%Ann_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%Ann_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%Ann_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%Ann_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Ann_KickLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Ann_KickLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%Ann_KickLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%Ann_KickLoc,0) - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity - MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)= (MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1) + MudSystem%NewVolume + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%Ann_KickLoc-1)= (data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%Ann_KickLoc-1)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc-1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_KickLoc-1) + data%State%MudSystem%NewVolume endif @@ -526,20 +528,20 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann else !if Ann_KickLoc == 1 *6 =============================== !write(*,*) '****6' - MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Ann_Mud_Backhead_X%Array (data%State%MudSystem%Ann_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Ann_Mud_Backhead_section%Array (data%State%MudSystem%Ann_KickLoc) - call MudSystem%Ann_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (0) - call MudSystem%Ann_CuttingMud%AddToFirst (CuttingValue) + call data%State%MudSystem%Ann_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Ann_CuttingMud%AddToFirst (CuttingValue) endif @@ -555,208 +557,208 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann !============================== kick 2 tarafe mate bashad *4 ============================== - if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc > 0 ) then + if ( data%State%MudSystem%Ann_KickLoc > 0 .and. data%State%MudSystem%Op_KickLoc > 0 ) then !write(*,*) '****4' - MudSystem%iLoc= 2 + data%State%MudSystem%iLoc= 2 - MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%KickDv= data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%Ann_KickLoc)) * data%State%MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal - MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1), MudSystem%Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick + data%State%MudSystem%MinKickDv= min( data%State%MudSystem%KickDv,data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1), data%State%MudSystem%Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick - MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1) - MudSystem%NewVolume= MudSystem%MinKickDv + data%State%MudSystem%NewDensity= data%State%MudSystem%Ann_Density%Array (data%State%MudSystem%Ann_KickLoc+1) + data%State%MudSystem%NewVolume= data%State%MudSystem%MinKickDv - if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund + if ( data%State%MudSystem%MinKickDv == data%State%MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund !write(*,*) '****4----1' - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv + data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1) - data%State%MudSystem%MinKickDv - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 + data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc) + data%State%MudSystem%MinKickDv ! Ann_KickLoc= 1 - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last + data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc) - data%State%MudSystem%MinKickDv ! Op_KickLoc= last ! backheade kick zire mate bashad - if ( MudSystem%Op_KickLoc>1) then + if ( data%State%MudSystem%Op_KickLoc>1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) + call data%State%MudSystem%Op_Density%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (data%State%MudSystem%Op_KickLoc,0) else ! merge - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume + data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)= (data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1) + data%State%MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== !write(*,*) '****5-2' - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) endif - elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund + elseif ( data%State%MudSystem%MinKickDv == data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund !write(*,*) '****4----2' - call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1) - call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_MudDischarged_Volume%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Backhead_section%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Forehead_X%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Mud_Forehead_section%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_Density%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_MudOrKick%Remove (data%State%MudSystem%Ann_KickLoc+1) + call data%State%MudSystem%Ann_CuttingMud%Remove (data%State%MudSystem%Ann_KickLoc+1) - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 + data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc) + data%State%MudSystem%MinKickDv ! Ann_KickLoc= 1 - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last + data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc)= data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_KickLoc) - data%State%MudSystem%MinKickDv ! Op_KickLoc= last ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then + if (data%State%MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) + call data%State%MudSystem%Op_Density%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (data%State%MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume + else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity + data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)= (data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1) + data%State%MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) endif - elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod + elseif ( data%State%MudSystem%MinKickDv == data%State%MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod !write(*,*) '****4----3' - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv + data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc+1) - data%State%MudSystem%MinKickDv - MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1 + data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array (data%State%MudSystem%Ann_KickLoc) + data%State%MudSystem%MinKickDv ! Ann_KickLoc= 1 - MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc) - MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_X= data%State%MudSystem%Op_Mud_Backhead_X%Array (data%State%MudSystem%Op_KickLoc) + data%State%MudSystem%Old_KickBackHead_Section= data%State%MudSystem%Op_Mud_Backhead_section%Array (data%State%MudSystem%Op_KickLoc) - call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc) ! Op_KickLoc= last - call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc) - call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_MudDischarged_Volume%Remove (data%State%MudSystem%Op_KickLoc) ! Op_KickLoc= last + call data%State%MudSystem%Op_Mud_Backhead_X%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Mud_Backhead_section%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Mud_Forehead_X%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Mud_Forehead_section%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_Density%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (data%State%MudSystem%Op_KickLoc) + call data%State%MudSystem%Op_MudOrKick%Remove (data%State%MudSystem%Op_KickLoc) ! backheade kick zire mate bashad - if (MudSystem%Op_KickLoc > 1) then + if (data%State%MudSystem%Op_KickLoc > 1) then - !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then + !if ( Op_Density%Array (Op_KickLoc-1) /= data%State%MudSystem%NewDensity ) then - if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_KickLoc-1) - data%State%MudSystem%NewDensity) >= data%State%MudSystem%DensityMixTol ) then - call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0) + call data%State%MudSystem%Op_Density%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (data%State%MudSystem%Op_KickLoc,data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%Op_KickLoc,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (data%State%MudSystem%Op_KickLoc,0) - else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity - MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume + else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity + data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)= (data%State%MudSystem%Op_Density%Array(data%State%MudSystem%Op_KickLoc-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_KickLoc-1) + data%State%MudSystem%NewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== - call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity) - call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume) - call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X) - call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section) - call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Op_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewDensity) + call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (data%State%MudSystem%NewVolume) + call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Old_KickBackHead_X) + call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (data%State%MudSystem%Old_KickBackHead_Section) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddToFirst (0) endif - MudSystem%iLoc= 1 ! ok + data%State%MudSystem%iLoc= 1 ! ok endif @@ -770,7 +772,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann !============================== kick 2 tarafe mate bashad *4 with pump ============================== ! - !if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 .and. MudSystem%AnnulusFlowRate /= 0.0 ) then + !if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 .and. data%State%MudSystem%AnnulusFlowRate /= 0.0 ) then ! write(*,*) '****4 with pump' ! ! KickMigration_2SideBit= .true. @@ -783,13 +785,13 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! !MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick ! ! - ! !MudSystem%NewDensity= Ann_Density%Array (Ann_KickLoc+1) + ! !data%State%MudSystem%NewDensity= Ann_Density%Array (Ann_KickLoc+1) ! !NewVolume= MinKickDv ! ! - ! if ( ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad---tu in halat aslan kari be elemane balaiye kick tuye Ann nadarim + ! if ( ((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad---tu in halat aslan kari be elemane balaiye kick tuye Ann nadarim ! !WRITE(*,*) '*****sorate pump bishtar az kick*******' - ! MinKickDv= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! dar asl maxKickDv ast + ! MinKickDv= ((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! dar asl maxKickDv ast ! ! ! @@ -809,7 +811,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! backheade kick zire mate bashad ! if ( Op_KickLoc>1) then ! - ! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then + ! if ( Op_Density%Array (Op_KickLoc-1) /=data%State%MudSystem%St_Density%Last() ) then ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) @@ -826,7 +828,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! - ! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + ! else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume ! @@ -840,7 +842,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! !Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst MudSystem%St_Density%Last()) + ! call Op_Density%AddToFirst data%State%MudSystem%St_Density%Last()) ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -860,7 +862,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! write(*,*) '****4----3 with pump a' ! ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) + ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)-MinKickDv + ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) + ((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)-MinKickDv ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! @@ -878,7 +880,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! - ! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%St_Density%Last() ) then + ! if ( Op_Density%Array (Op_KickLoc-1) /=data%State%MudSystem%St_Density%Last() ) then ! ! ! !Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) @@ -896,7 +898,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! ! - ! else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity + ! else !Op_Density%Array (imudKick-1) == data%State%MudSystem%NewDensity ! ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + MinKickDv @@ -910,7 +912,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst MudSystem%St_Density%Last()) + ! call Op_Density%AddToFirst data%State%MudSystem%St_Density%Last()) ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -923,12 +925,12 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! endif ! ! - ! endif ! ende 2 halat ke kick tuye Op baghi bemune ya namune- dar halati ke ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) ! sorate pump bishtar az kick bashad + ! endif ! ende 2 halat ke kick tuye Op baghi bemune ya namune- dar halati ke ((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) ! sorate pump bishtar az kick bashad ! ! ! ! - ! else !if( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) then ! sorate pump kamtar az kick bashad + ! else !if( ((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) then ! sorate pump kamtar az kick bashad ! !WRITE(*,*) '*****sorate pump kamtar az kick*******' ! ! @@ -943,18 +945,18 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund ! !write(*,*) '****4----1 with pump' - ! !write(*,*) MudSystem%St_Density%Last()=' ,MudSystem%St_Density%Last() - ! !write(*,*) '((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)=' , ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) + ! !write(*,*) data%State%MudSystem%St_Density%Last()=' ,data%State%MudSystem%St_Density%Last() + ! !write(*,*) '((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)=' , ((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) ! !write(*,*) 'Ann_Density%Array(Ann_KickLoc+1)=' , Ann_Density%Array(Ann_KickLoc+1) - ! !write(*,*) '(MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline))=' , (MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)) + ! !write(*,*) '(MinKickDv-((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline))=' , (MinKickDv-((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)) ! ! - ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & - ! / (((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + (MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) + ! data%State%MudSystem%NewDensity= data%State%MudSystem%St_Density%Last()*((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & + ! / (((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + (MinKickDv-((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) ! NewVolume= MinKickDv ! ! - ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - (MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)) + ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - (MinKickDv-((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)) ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! @@ -966,14 +968,14 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then + ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - data%State%MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! - ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) + ! call Op_Density%AddTo (Op_KickLoc,data%State%MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -987,7 +989,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & + ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*data%State%MudSystem%NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! @@ -1000,7 +1002,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst (MudSystem%NewDensity) + ! call Op_Density%AddToFirst (data%State%MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -1017,8 +1019,8 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! elseif ( MinKickDv == Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund ! write(*,*) '****4----2 with pump' ! - ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & - ! / (((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)) + ! data%State%MudSystem%NewDensity= data%State%MudSystem%St_Density%Last()*((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & + ! / (((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)) ! NewVolume= MinKickDv ! ! call RemoveAnnulusMudArrays(Ann_KickLoc+1) @@ -1030,13 +1032,13 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then + ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - data%State%MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! - ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) + ! call Op_Density%AddTo (Op_KickLoc,data%State%MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -1050,7 +1052,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & + ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*data%State%MudSystem%NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! @@ -1063,7 +1065,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! - ! call Op_Density%AddToFirst (MudSystem%NewDensity) + ! call Op_Density%AddToFirst (data%State%MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -1079,7 +1081,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! elseif ( MinKickDv == Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod ! write(*,*) '****4----3 with pump b' ! - ! MudSystem%NewDensity=MudSystem%St_Density%Last() + ! data%State%MudSystem%NewDensity=data%State%MudSystem%St_Density%Last() ! NewVolume= MinKickDv ! ! @@ -1106,13 +1108,13 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! - ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then + ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - data%State%MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! !write(*,*) 'pointer 3' ! ! ! ! - ! call Op_Density%AddTo (Op_KickLoc,MudSystem%NewDensity) + ! call Op_Density%AddTo (Op_KickLoc,data%State%MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) @@ -1127,7 +1129,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume - ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*MudSystem%NewDensity) / & + ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*data%State%MudSystem%NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! endif @@ -1139,7 +1141,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! !write(*,*) 'pointer 6' ! ! - ! call Op_Density%AddToFirst (MudSystem%NewDensity) + ! call Op_Density%AddToFirst (data%State%MudSystem%NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) @@ -1157,7 +1159,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann ! ! ! - ! endif !( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) ! sorate pump kamtar az kick bashad + ! endif !( ((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) ! sorate pump kamtar az kick bashad ! ! ! @@ -1167,7 +1169,7 @@ if (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann !======================================================================================== ENDDO ! KickNumber= 1, NewInfluxNumber -MudSystem%KickNumber = kickNumber +data%State%MudSystem%KickNumber = kickNumber !write(*,*) 'c)Ann_MudDischarged_Volume%Array(:)=' , sum(Ann_MudDischarged_Volume%Array(:)) diff --git a/Equipments/MudSystem/MudSystem.f90 b/Equipments/MudSystem/MudSystem.f90 index 49bebb8..f330e33 100644 --- a/Equipments/MudSystem/MudSystem.f90 +++ b/Equipments/MudSystem/MudSystem.f90 @@ -1,18 +1,21 @@ module MudSystemModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ use PressureDisplayVARIABLESModule USE FricPressDropVarsModule USE Fluid_Flow_Startup_Vars USE CMudPropertiesVariables USE CManifolds - USE CPumpsVariables + use CPumpsVariables + use CPumps USE CUnityOutputs - use CWarningsVariables - use DynamicIntegerArray + use CWarnings + use DynamicIntegerArray,only: DynamicIntegerArrayType use CError use CLog1 - USE CDataDisplayConsoleVariables + use CDataDisplayConsole + use ConfigurationVariables use CStudentStationVariables !, PitGainLossReset=>PitGainLossZero @@ -217,7 +220,7 @@ module MudSystemModule !================================================ !============BellNippleToPits-FullWell============== - if(MudSystem%FirstMudSet== 1 ) then !.and. WellisNOTFull== .false.) then ! Well Must Be Full !Ann_Mud_Forehead_X%Last()==AboveAnnularHeight .and. Ann_Density%Last()/=0.0) + if(data%State%MudSystem%FirstMudSet== 1 ) then !.and. WellisNOTFull== .false.) then ! Well Must Be Full !Ann_Mud_Forehead_X%Last()==AboveAnnularHeight .and. Ann_Density%Last()/=0.0) if(condition4) then j3=j3+1 B71=1 @@ -309,18 +312,18 @@ module MudSystemModule !============BellNippleToWell-NonFullWell============== - if(condition16 .and. MudSystem%FirstMudSet== 1 .and. MudSystem%BellNippleVolume > 0.0001 .and. MudSystem%WellisNOTFull) then + if(condition16 .and. data%State%MudSystem%FirstMudSet== 1 .and. data%State%MudSystem%BellNippleVolume > 0.0001 .and. data%State%MudSystem%WellisNOTFull) then - write(*,*) 'MUD(7)%Q=' , MUD(7)%Q - write(*,*) 'BellNippleVolume=' , MudSystem%BellNippleVolume + write(*,*) 'data%State%MUD(7)%Q=' , data%State%MUD(7)%Q + write(*,*) 'BellNippleVolume=' , data%State%MudSystem%BellNippleVolume - write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn + write(*,*) 'data%State%MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , data%State%MudSystem%MudVolume_InjectedFromAnn - write(*,*) 'int:::=' , (MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) - write(*,*) 'Ann_Mud_Forehead_X%Last()=' , MudSystem%Ann_Mud_Forehead_X%Last() + write(*,*) 'int:::=' , (data%State%MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) + write(*,*) 'Ann_Mud_Forehead_X%Last()=' , data%State%MudSystem%Ann_Mud_Forehead_X%Last() write(*,*) 'AboveAnnularHeight=' , BopStackSpecification%AboveAnnularHeight - write(*,*) 'Ann_Density%Last()=' , MudSystem%Ann_Density%Last() + write(*,*) 'Ann_Density%Last()=' , data%State%MudSystem%Ann_Density%Last() CALL ErrorStop('error stop1') j11=j11+1 @@ -430,14 +433,14 @@ module MudSystemModule !write(*,*) 'condition32===' , condition32 !============MudPump1HasNoPath=================== - if(MudSystem%condition32Final) then + if(data%State%MudSystem%condition32Final) then !write(*,*) 'MudPump1HasNoPath' Mp1_NoPath = 1 endif !================================================ !============MudPump2HasNoPath=================== - if(MudSystem%condition33Final) then + if(data%State%MudSystem%condition33Final) then !write(*,*) 'MudPump2HasNoPath' Mp2_NoPath = 1 endif @@ -445,7 +448,7 @@ module MudSystemModule !============CementPumpHasNoPath=================== - if(MudSystem%condition34Final) then + if(data%State%MudSystem%condition34Final) then Cp_NoPath = 1 endif !================================================ @@ -592,9 +595,9 @@ module MudSystemModule endif if (j20>0) then - MudSystem%WellToChokeLineGauge= .true. + data%State%MudSystem%WellToChokeLineGauge= .true. else - MudSystem%WellToChokeLineGauge= .false. + data%State%MudSystem%WellToChokeLineGauge= .false. endif !================================================ @@ -613,9 +616,9 @@ module MudSystemModule endif if (j21>0) then - MudSystem%ChokeLineGaugeToTanks= .true. + data%State%MudSystem%ChokeLineGaugeToTanks= .true. else - MudSystem%ChokeLineGaugeToTanks= .false. + data%State%MudSystem%ChokeLineGaugeToTanks= .false. endif !================================================ @@ -624,23 +627,29 @@ module MudSystemModule subroutine main Use GeoElements_FluidModule - USE Pumps_VARIABLES + use ConfigurationVariables USE CHOKEVARIABLES - USE CDataDisplayConsoleVariables - use CDrillWatchVariables - use CHOKEVARIABLES +use ConfigurationVariables !@ + use CDataDisplayConsole + use ConfigurationVariables + use ConfigurationVariables !@ + USE CHOKEVARIABLES +use ConfigurationVariables !@ use CChokeManifoldVariables - use CTanksVariables + use ConfigurationVariables + use CTanks + use ConfigurationVariables use KickVARIABLESModule - Use CHoistingVariables + use CHoistingVariables + use ConfigurationVariables ! use CSimulationVariables implicit none Integer I - MudSystem%MudSys_timeCounter = MudSystem%MudSys_timeCounter + 1 - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%MudSys_timeCounter= 0 + data%State%MudSystem%MudSys_timeCounter = data%State%MudSystem%MudSys_timeCounter + 1 + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + data%State%MudSystem%MudSys_timeCounter= 0 endif !WRITE (*,*) 'MudSys_timeCounter', MudSys_timeCounter @@ -657,13 +666,13 @@ module MudSystemModule !ReserveTankVolume= ReserveMudVolumeGal ! update from student input !ReserveTankDensity= ReserveDensity ! update from student input if (j7 > 0) then !ActiveTankToDump - MudSystem%ActiveTankDensity= 0. - MudSystem%ActiveTankVolume= 0. + data%State%MudSystem%ActiveTankDensity= 0. + data%State%MudSystem%ActiveTankVolume= 0. endif if (j8 > 0) then !TripTankToDump - MudSystem%TripTankDensityCalc= 0. - MudSystem%TripTankVolumeCalc= 0. + data%State%MudSystem%TripTankDensityCalc= 0. + data%State%MudSystem%TripTankVolumeCalc= 0. endif !=========================================================================================================================== !=========================================================================================================================== @@ -673,50 +682,50 @@ module MudSystemModule 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. + data%State%MudSystem%ActiveTankDensity = (data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume+ Mp1Coef*data%State%MudSystem%Mp1Density*(data%State%Pump(1)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60.) + Mp2Coef*data%State%MudSystem%Mp2Density*(data%State%Pump(2)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60.))/ & + (data%State%MudSystem%ActiveTankVolume+ Mp1Coef*(data%State%Pump(1)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60.) + Mp2Coef*(data%State%Pump(2)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60.)) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ Mp1Coef*data%State%Pump(1)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60. + Mp2Coef*data%State%Pump(2)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60. !write(*,*) 'active by j15' endif - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + data%State%MudSystem%ActiveTankVolume=min(data%State%MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif 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.) + data%State%MudSystem%CementTankDensityCalc= (data%State%MudSystem%CementTankDensityCalc*data%State%MudSystem%CementTankVolumeCalc+ CpCoef*data%State%MudSystem%Mp3Density*(data%State%Pump(3)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60.) ) / & + (data%State%MudSystem%CementTankVolumeCalc+CpCoef*(data%State%Pump(3)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60.)) + data%State%MudSystem%CementTankVolumeCalc= data%State%MudSystem%CementTankVolumeCalc+ CpCoef*(data%State%Pump(3)%Flow_Rate*data%State%MudSystem%DeltaT_Mudline/60.) endif !=========================================================================================================================== !=========================================================================================================================== ! 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 + data%State%MudSystem%PumpsDumpVolume= data%State%MudSystem%PumpsDumpVolume+ (jj2*(1-H82)*DumpPump1*data%State%Pump(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*data%State%Pump(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*data%State%Pump(3)%Flow_Rate) *data%State%MudSystem%DeltaT_Mudline/60. + data%State%MudSystem%PumpsDumpFlowRate= jj2*(1-H82)*DumpPump1*data%State%Pump(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*data%State%Pump(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*data%State%Pump(3)%Flow_Rate !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate - if (Hoisting%DriveType==1 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then + if (data%State%Hoisting%DriveType==1 .and. data%State%MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then !write(*,*) 'Set_FlowFromKelly(.TRUE.)' call Activate_PumpWithKellyDisconnected() !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate - CALL Set_FlowFromKelly(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before - elseif (Hoisting%DriveType==1) then + CALL Set_FlowFromKelly(min(data%State%MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before + elseif (data%State%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 + if (data%State%Hoisting%DriveType==0 .and. data%State%MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromTopDrive_Pump1 .or. DumpFromTopDrive_Pump2 .or. DumpFromTopDrive_Pump3)) then !write(*,*) 'Set_FlowFromKelly(.TRUE.)' call Activate_PumpWithTopdriveDisconnected() - CALL Set_FlowFromKelly(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before - elseif (Hoisting%DriveType==0) then + CALL Set_FlowFromKelly(min(data%State%MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before + elseif (data%State%Hoisting%DriveType==0) then 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 + if (data%State%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 + CALL Set_FlowFromFillupHead(min(data%State%MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before else !call Deactivate_PumpWithKellyDisconnected() CALL Set_FlowFromFillupHead(0.0) ! .FALSE. before @@ -778,19 +787,19 @@ module MudSystemModule !write(*,*) 'H83=' , H83 !write(*,*) 'DumpPump2=' , DumpPump2 !write(*,*) 'G83=' , G83 - PumpPressure1= jj2*(1-H82)*(1-DumpPump1)*G82* PressureDisplayVARIABLES%PressureGauges(1) - PumpPressure2= jj12*(1-H83)*(1-DumpPump2)*G83* PressureDisplayVARIABLES%PressureGauges(1) - PumpPressure3= jj13*(1-H84)*(1-DumpCementPump)*G84* PressureDisplayVARIABLES%PressureGauges(1) + PumpPressure1= jj2*(1-H82)*(1-DumpPump1)*G82* data%State%PressureDisplay%PressureGauges(1) + PumpPressure2= jj12*(1-H83)*(1-DumpPump2)*G83* data%State%PressureDisplay%PressureGauges(1) + PumpPressure3= jj13*(1-H84)*(1-DumpCementPump)*G84* data%State%PressureDisplay%PressureGauges(1) ! !write(*,*) 'jj2 , H82 , DumpPump1 , G82,PresCsureGauges(1)=' , jj2 , H82 , DumpPump1 , G82,PressureGauges(1) !write(*,*) '1)PumpPressure1=' , PumpPressure1 !write(*,*) 'PumpPressure2=' , PumpPressure2 - FricPressDropVars%PumpToManifoldMudVol = 3.0 * 42.0 + data%State%FricPressDrop%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 - FricPressDropVars%PumpToManifoldCompressedMudVol = FricPressDropVars%PumpToManifoldCompressedMudVol + MP1_Q / ConvMinToSec * dt - PumpPressure1= FricPressDropVars%PumpToManifoldCompressedMudVol / (MudCompressibility * FricPressDropVars%PumpToManifoldMudVol) + data%State%FricPressDrop%PumpToManifoldCompressedMudVol = data%State%FricPressDrop%PumpToManifoldCompressedMudVol + MP1_Q / ConvMinToSec * dt + PumpPressure1= data%State%FricPressDrop%PumpToManifoldCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%PumpToManifoldMudVol) write(*,*) '21)PumpPressure1=' , PumpPressure1 WRITE (*,*) ' valve 1 ', Manifold%Valve(1)%Status WRITE (*,*) ' valve 4 ', Manifold%Valve(4)%Status @@ -806,8 +815,8 @@ module MudSystemModule ENDIF IF(Mp2_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_83 .and. MP2_Q > 0.0 ) then - FricPressDropVars%PumpToManifoldCompressedMudVol = FricPressDropVars%PumpToManifoldCompressedMudVol + MP2_Q / ConvMinToSec * dt - PumpPressure2= FricPressDropVars%PumpToManifoldCompressedMudVol / (MudCompressibility * FricPressDropVars%PumpToManifoldMudVol) + data%State%FricPressDrop%PumpToManifoldCompressedMudVol = data%State%FricPressDrop%PumpToManifoldCompressedMudVol + MP2_Q / ConvMinToSec * dt + PumpPressure2= data%State%FricPressDrop%PumpToManifoldCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%PumpToManifoldMudVol) write(*,*) '22)PumpPressure1=' , PumpPressure2 WRITE (*,*) ' -valve 1 ', Manifold%Valve(1)%Status WRITE (*,*) ' -valve 4 ', Manifold%Valve(4)%Status @@ -823,8 +832,8 @@ module MudSystemModule ENDIF IF(Cp_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_84 .AND. MP3_Q > 0.0 ) then - FricPressDropVars%PumpToManifoldCompressedMudVol = FricPressDropVars%PumpToManifoldCompressedMudVol + MP3_Q / ConvMinToSec * dt - PumpPressure3= FricPressDropVars%PumpToManifoldCompressedMudVol / (MudCompressibility * FricPressDropVars%PumpToManifoldMudVol) + data%State%FricPressDrop%PumpToManifoldCompressedMudVol = data%State%FricPressDrop%PumpToManifoldCompressedMudVol + MP3_Q / ConvMinToSec * dt + PumpPressure3= data%State%FricPressDrop%PumpToManifoldCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%PumpToManifoldMudVol) ENDIF !***************************************************************************** !if(((Mp1_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_82) .or. ( PumpPressure1 >= MaxWorkingPressure1 ) & @@ -833,18 +842,18 @@ module MudSystemModule if (PumpPressure1 >= MaxWorkingPressure1 .and. MP1_Q > 0.0) then write(*,*) 'mp1,if=' , PumpPressure1 , MaxWorkingPressure1 , MP1_Q - MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1 + data%State%MudSystem%Pump1BlownCount = data%State%MudSystem%Pump1BlownCount + 1 !if (Pump1BlownStarted == .FALSE.) then ! write(*,*) 'if (Pump1BlownStarted == .FALSE. ) then' ! Pump1BlownInTimeStep = SimulationTime + BlownThresholdInSecond ! Pump1BlownStarted = .TRUE. !endif !write(*,*) 'SimulationTime===', SimulationTime, Pump1BlownInTimeStep - if(PumpsSpecification%MudPump1ReliefValveIsSet .and. MudSystem%Pump1BlownCount >= BlownThreshold) then + if(PumpsSpecification%MudPump1ReliefValveIsSet .and. data%State%MudSystem%Pump1BlownCount >= BlownThreshold) then write(*,*) 'valve 65 open, BLOWN' call ChangeValve(65, .TRUE.) - FricPressDropVars%PumpToManifoldCompressedMudVol= 0.0 - MudSystem%Pump1BlownCount = 0 + data%State%FricPressDrop%PumpToManifoldCompressedMudVol= 0.0 + data%State%MudSystem%Pump1BlownCount = 0 !Pump1BlownStarted = .FALSE. !else ! write(*,*) 'PumpPressure1= 6000 psi' @@ -862,17 +871,17 @@ module MudSystemModule if(PumpPressure2 >= MaxWorkingPressure2 .and. MP2_Q > 0.0 ) then write(*,*) 'mp2,if=' , PumpPressure2 , MaxWorkingPressure2 , MP2_Q - MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1 + data%State%MudSystem%Pump2BlownCount = data%State%MudSystem%Pump2BlownCount + 1 !if (Pump2BlownStarted == .FALSE. ) then ! Pump2BlownInTimeStep = SimulationTime + BlownThresholdInSecond ! Pump2BlownStarted = .TRUE. !endif !if (MudPump2ReliefValveIsSet .and. SimulationTime >= Pump2BlownInTimeStep .and. Pump2BlownStarted) then - if (PumpsSpecification%MudPump2ReliefValveIsSet .and. MudSystem%Pump2BlownCount >= BlownThreshold) then + if (PumpsSpecification%MudPump2ReliefValveIsSet .and. data%State%MudSystem%Pump2BlownCount >= BlownThreshold) then write(*,*) 'valve 66 open, BLOWN' call ChangeValve(66, .TRUE.) - FricPressDropVars%PumpToManifoldCompressedMudVol= 0.0 - MudSystem%Pump2BlownCount = 0 + data%State%FricPressDrop%PumpToManifoldCompressedMudVol= 0.0 + data%State%MudSystem%Pump2BlownCount = 0 !Pump2BlownInTimeStep = 0 !Pump2BlownStarted = .FALSE. !else @@ -886,12 +895,12 @@ module MudSystemModule !.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 - if (PumpsSpecification%CementPumpReliefValveIsSet .and. MudSystem%Pump3BlownCount >= BlownThreshold) then + data%State%MudSystem%Pump3BlownCount = data%State%MudSystem%Pump3BlownCount + 1 + if (PumpsSpecification%CementPumpReliefValveIsSet .and. data%State%MudSystem%Pump3BlownCount >= BlownThreshold) then !write(*,*) 'valve 67 open, BLOWN' call ChangeValve(67, .TRUE.) - FricPressDropVars%PumpToManifoldCompressedMudVol= 0.0 - MudSystem%Pump3BlownCount = 0 + data%State%FricPressDrop%PumpToManifoldCompressedMudVol= 0.0 + data%State%MudSystem%Pump3BlownCount = 0 !else ! PumpPressure3= 6000. !psi endif @@ -901,13 +910,13 @@ module MudSystemModule endif !write(*,*) '3)PumpPressure1=' , PumpPressure1 if (PumpPressure1>= 6000.) then - MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1 - if(MudSystem%Pump1BlownCount >= BlownThreshold) then + data%State%MudSystem%Pump1BlownCount = data%State%MudSystem%Pump1BlownCount + 1 + if(data%State%MudSystem%Pump1BlownCount >= BlownThreshold) then call ChangeValve(65, .TRUE.) - FricPressDropVars%PumpToManifoldCompressedMudVol= 0.0 + data%State%FricPressDrop%PumpToManifoldCompressedMudVol= 0.0 call Activate_Pump1Failure() - MudSystem%Pump1OffFailure= .true. - MudSystem%Pump1BlownCount = 0 + data%State%MudSystem%Pump1OffFailure= .true. + data%State%MudSystem%Pump1BlownCount = 0 endif !else !Pump1BlownInTimeStep = 0 @@ -915,13 +924,13 @@ module MudSystemModule endif if (PumpPressure2>= 6000.) then - MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1 - if(MudSystem%Pump2BlownCount >= BlownThreshold) then + data%State%MudSystem%Pump2BlownCount = data%State%MudSystem%Pump2BlownCount + 1 + if(data%State%MudSystem%Pump2BlownCount >= BlownThreshold) then call ChangeValve(66, .TRUE.) - FricPressDropVars%PumpToManifoldCompressedMudVol= 0.0 + data%State%FricPressDrop%PumpToManifoldCompressedMudVol= 0.0 call Activate_Pump2Failure() - MudSystem%Pump2OffFailure= .true. - MudSystem%Pump2BlownCount = 0 + data%State%MudSystem%Pump2OffFailure= .true. + data%State%MudSystem%Pump2BlownCount = 0 endif !else !Pump2BlownInTimeStep = 0 @@ -929,13 +938,13 @@ module MudSystemModule endif if (PumpPressure3>= 6000.) then - MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1 - if(MudSystem%Pump3BlownCount >= BlownThreshold) then + data%State%MudSystem%Pump3BlownCount = data%State%MudSystem%Pump3BlownCount + 1 + if(data%State%MudSystem%Pump3BlownCount >= BlownThreshold) then call ChangeValve(67, .TRUE.) - FricPressDropVars%PumpToManifoldCompressedMudVol= 0.0 + data%State%FricPressDrop%PumpToManifoldCompressedMudVol= 0.0 call Activate_Pump3Failure() - MudSystem%Pump3OffFailure= .true. - MudSystem%Pump3BlownCount = 0 + data%State%MudSystem%Pump3OffFailure= .true. + data%State%MudSystem%Pump3BlownCount = 0 endif !else !Pump3BlownInTimeStep = 0 @@ -946,50 +955,50 @@ module MudSystemModule !=========================================================================================================================== 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 + !data%State%MUD(7)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline + data%State%MUD(7)%Q= ( data%State%MudSystem%MudVolume_InjectedFromAnn + data%State%MudSystem%Ann_Kick_Saved_Volume )*60.d0/data%State%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 + data%State%MUD(7)%Q= BellNipple_FlowCoef * data%State%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 + if (data%State%MUD(7)%Q < 0.0 ) data%State%MUD(7)%Q= 0.0 !.or. WellisNOTFull== .true.) data%State%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(*,*) 'data%State%MUD(7)%Q=' , data%State%MUD(7)%Q + !write(*,*) 'data%State%MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , data%State%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= sys_total_injected+ data%State%MudSystem%MudVolume_InjectedFromAnn + if (data%EquipmentControl%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)) + if ((data%State%MudSystem%BellNippleVolume+((data%State%MUD(7)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) /= 0.0) then + data%State%MudSystem%BellNippleDensity= ((data%State%MudSystem%BellNippleDensity*data%State%MudSystem%BellNippleVolume)+(data%State%MudSystem%WellOutletDensity*(data%State%MUD(7)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%BellNippleVolume+((data%State%MUD(7)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) else - MudSystem%BellNippleDensity= 0.0 + data%State%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) + data%State%MudSystem%BellNippleVolume= data%State%MudSystem%BellNippleVolume+ ((data%State%MUD(7)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) !ENDIF - VolumeToBellNipple= VolumeToBellNipple + MudSystem%BellNippleVolume + VolumeToBellNipple= VolumeToBellNipple + data%State%MudSystem%BellNippleVolume !write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple - !write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q + !write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , data%State%MUD(7)%Q endif if (j9 == 0 ) then !.or. WellisNOTFull== .true.) then !write(*,*) 'WellisNOTFull=' , WellisNOTFull - MUD(7)%Q=0.0 ! for normal circulation input + data%State%MUD(7)%Q=0.0 ! for normal circulation input endif if (j9 > 0) then - MudSystem%WellToPitsOpen= .true. + data%State%MudSystem%WellToPitsOpen= .true. else - MudSystem%WellToPitsOpen= .false. + data%State%MudSystem%WellToPitsOpen= .false. endif !=========================================================================================================================== !=========================================================================================================================== @@ -998,44 +1007,44 @@ module MudSystemModule !MudBucketVolume= 0. !MudBucketDensity= 0. ! MudBucketVolume gets value in DisconnectingPipe subroutine - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ MudSystem%MudBucketVolume - MudSystem%BellNippleDensity= MudSystem%ActiveTankDensity - MudSystem%MudBucketVolume= 0. + data%State%MudSystem%BellNippleVolume= data%State%MudSystem%BellNippleVolume+ data%State%MudSystem%MudBucketVolume + data%State%MudSystem%BellNippleDensity= data%State%MudSystem%ActiveTankDensity + data%State%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) + data%State%MUD(6)%Q= 300. ! constant flow rate(gpm) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc - ((data%State%MUD(6)%Q/60.)*data%State%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) + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%TripTankDensityCalc*(data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+((data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((data%State%MUD(6)%Q/60.)*data%State%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) + data%State%MudSystem%BellNippleDensity= ((data%State%MudSystem%BellNippleDensity*data%State%MudSystem%BellNippleVolume)+(data%State%MudSystem%TripTankDensityCalc*(data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%BellNippleVolume+((data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%BellNippleVolume= data%State%MudSystem%BellNippleVolume+ ((data%State%MUD(6)%Q/60.)*data%State%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)) + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%TripTankDensityCalc*(0.5*data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+((0.5*data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%BellNippleDensity= ((data%State%MudSystem%BellNippleDensity*data%State%MudSystem%BellNippleVolume)+(data%State%MudSystem%TripTankDensityCalc*(0.5*data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%BellNippleVolume+((0.5*data%State%MUD(6)%Q/60.)*data%State%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) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((0.5*data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%BellNippleVolume= data%State%MudSystem%BellNippleVolume+ ((0.5*data%State%MUD(6)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) endif - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + data%State%MudSystem%ActiveTankVolume=min(data%State%MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif if (j6 == 0) then - MUD(6)%Q=0.0 + data%State%MUD(6)%Q=0.0 endif !=========================================================================================================================== !=========================================================================================================================== @@ -1047,100 +1056,100 @@ module MudSystemModule !Well to BellNipple: BellNippleVolume !MudBucket to BellNipple: BellNippleVolume !TripTnak to BellNipple: BellNippleVolume - MUD(3)%Q = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60.d0 ! (gpm) + data%State%MUD(3)%Q = (data%State%MudSystem%BellNippleVolume/data%State%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 + !write(*,*) 'data%State%MUD(3)%Q =' , data%State%MUD(3)%Q + call Set_FlowRate(real(100.*min(data%State%MUD(3)%Q,data%State%MudSystem%PedalMeter)/data%State%MudSystem%PedalMeter, 8)) ! for unity display + unityreturn = real(100.*min(data%State%MUD(3)%Q,data%State%MudSystem%PedalMeter)/data%State%MudSystem%PedalMeter, 8) + !write(*,*) 'unity return=' , real(100.*min(data%State%MUD(3)%Q,PedalMeter)/PedalMeter, 8) + if (data%State%MUD(3)%Q > data%State%MudSystem%PedalMeter .and. B78==0) then + data%State%MudSystem%BellNippleDumpVolume= data%State%MudSystem%BellNippleDumpVolume + ((data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline - (data%State%MudSystem%PedalMeter/60.)*data%State%MudSystem%DeltaT_Mudline) + !BellNippleDumpRate= data%State%MUD(3)%Q - PedalMeter CALL Set_FlowFromReturnLine(.TRUE.) ! for unity display endif !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 + active_before= data%State%MudSystem%ActiveTankVolume + data%State%MudSystem%BellNippleVolume= data%State%MudSystem%BellNippleVolume- ((data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) ! to be 0. + if ( data%State%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 + data%State%MUD(3)%Q = min(data%State%MUD(3)%Q , data%State%MudSystem%PedalMeter) + !write(*,*) 'data%State%MUD(3)%Q=' , data%State%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 + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%BellNippleDensity*(data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+((data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) + !write(*,*) 'active increase bell 1=' , ((data%State%MUD(3)%Q/60.)*DeltaT_Mudline) + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%BellNippleDensity > data%State%MudSystem%ActiveTankDensity) THEN + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((20.8d0-data%State%MudSystem%BellNippleDensity)/(20.8d0-data%State%MudSystem%ActiveTankDensity))*((data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg + !write(*,*) 'active increase bell 2=' , ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((data%State%MUD(3)%Q/60.d0)*DeltaT_Mudline) + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%BellNippleDensity < 5.0) THEN + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((2.d0-data%State%MudSystem%BellNippleDensity)/(2.d0-data%State%MudSystem%ActiveTankDensity))*((data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + !write(*,*) 'active increase bell 3=' , ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((data%State%MUD(3)%Q/60.d0)*DeltaT_Mudline) + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%BellNippleDensity .and. data%State%MudSystem%BellNippleDensity <= data%State%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) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + !write(*,*) 'active increase bell 4=' , ((data%State%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) + data%State%MUD(3)%Q = min(data%State%MUD(3)%Q , data%State%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 - 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%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - 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 - 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 + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%BellNippleDensity*(data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%TripTankVolumeCalc+((data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ (data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%BellNippleDensity > data%State%MudSystem%ActiveTankDensity) THEN + AddedVolumeToTank= ((20.8d0-data%State%MudSystem%BellNippleDensity)/(20.8d0-data%State%MudSystem%ActiveTankDensity))*((data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%BellNippleDensity < 5.0) THEN + AddedVolumeToTank= ((2.d0-data%State%MudSystem%BellNippleDensity)/(2.d0-data%State%MudSystem%ActiveTankDensity))*((data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%BellNippleDensity .and. data%State%MudSystem%BellNippleDensity <= data%State%MudSystem%ActiveTankDensity) THEN + AddedVolumeToTank= ((data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + data%State%MudSystem%TripTankVolumeCalc= data%State%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 + data%State%MudSystem%BellNippleDumpVolume= data%State%MudSystem%BellNippleDumpVolume+ (data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline + !BellNippleDumpRate= data%State%MUD(3)%Q endif if (j3 == 2) then !78 is not allowded in this position - MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter) + data%State%MUD(3)%Q = min(data%State%MUD(3)%Q , data%State%MudSystem%PedalMeter) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)) + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%BellNippleDensity*(0.5*data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+((0.5*data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%BellNippleDensity*(0.5*data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%TripTankVolumeCalc+((0.5*data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((0.5*data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ ((0.5*data%State%MUD(3)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%BellNippleDensity > data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((20.8d0-data%State%MudSystem%BellNippleDensity)/(20.8d0-data%State%MudSystem%ActiveTankDensity))*((0.5d0*data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((2.d0-data%State%MudSystem%BellNippleDensity)/(2.d0-data%State%MudSystem%ActiveTankDensity))*((0.5d0*data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%BellNippleDensity .and. data%State%MudSystem%BellNippleDensity <= data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((data%State%MUD(3)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank ENDIF @@ -1150,13 +1159,13 @@ module MudSystemModule endif !( BellNippleDensity > 1.0) then - active_after= MudSystem%ActiveTankVolume + active_after= data%State%MudSystem%ActiveTankVolume active_increase = active_after - active_before total_active_increase= total_active_increase + active_increase - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then total_active_increase= 0. endif @@ -1164,14 +1173,14 @@ module MudSystemModule - !write(*,*) 'ReturnFlowRate=MUD(3)%Q= after' , MUD(3)%Q + !write(*,*) 'ReturnFlowRate=data%State%MUD(3)%Q= after' , data%State%MUD(3)%Q - MudSystem%ReturnFlowRate = MUD(3)%Q + data%State%MudSystem%ReturnFlowRate = data%State%MUD(3)%Q - MudSystem%TripTankVolumeCalc = min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + data%State%MudSystem%TripTankVolumeCalc = min(data%State%MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - MudSystem%ActiveTankVolume = min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal - MudProperties%ActiveSettledContentsGal) + data%State%MudSystem%ActiveTankVolume = min(data%State%MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal - MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped !write(*,*) 'BellNippleDensity=' , BellNippleDensity @@ -1184,7 +1193,7 @@ module MudSystemModule endif if (j3 == 0) then - MUD(3)%Q=0.0 ! for normal circulation input + data%State%MUD(3)%Q=0.0 ! for normal circulation input call Set_FlowRate(0d0) endif @@ -1195,9 +1204,9 @@ module MudSystemModule - if (j11 > 0 .and. MudSystem%MudChecked== .true.) then !BellNippleToWell-NonFullWell ( FillingWell_By_BellNipple subroutine is called for this state ) + if (j11 > 0 .and. data%State%MudSystem%MudChecked== .true.) then !BellNippleToWell-NonFullWell ( FillingWell_By_BellNipple subroutine is called for this state ) !write(*,*) 'j11 is open' - MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds + data%State%MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds !WellToPitsOpen = .TRUE. !BellNipple flow rate= sum flow rate (well+ mudbucket+ triptank) @@ -1206,24 +1215,24 @@ module MudSystemModule !MudBucket to BellNipple: BellNippleVolume !TripTnak to BellNipple: BellNippleVolume - MUD(8)%Q = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60. - !write(*,*) 'MUD(8)%Q=' , MUD(8)%Q + data%State%MUD(8)%Q = (data%State%MudSystem%BellNippleVolume/data%State%MudSystem%DeltaT_Mudline)*60. + !write(*,*) 'data%State%MUD(8)%Q=' , data%State%MUD(8)%Q - MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(8)%Q/60.)*MudSystem%DeltaT_Mudline) ! to be 0. + data%State%MudSystem%BellNippleVolume= data%State%MudSystem%BellNippleVolume- ((data%State%MUD(8)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) ! to be 0. !write(*,*) 'BellNippleVolume-2nd Mode=' , BellNippleVolume !BellNippleDensity ! ! - !BellNippleDensity , MUD(8)%Q be code gel dade beshe - !shart: j11 > 0 , MUD(8)%Q > 0.0 + !BellNippleDensity , data%State%MUD(8)%Q be code gel dade beshe + !shart: j11 > 0 , data%State%MUD(8)%Q > 0.0 endif if (j11 == 0) then - MUD(8)%Q=0.0 ! for normal circulation input + data%State%MUD(8)%Q=0.0 ! for normal circulation input !WellToPitsOpen= .false. endif @@ -1235,28 +1244,28 @@ module MudSystemModule !WRITE (*,*) 'choke condition', j4, ChokeLineNOTFull - if (j4 > 0 .and. MudSystem%ChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26) + if (j4 > 0 .and. data%State%MudSystem%ChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26) !write(*,*) 'j4 is open' !write(*,*) 'active by j4' - !MUD(4)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline - MUD(4)%Q= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud + !data%State%MUD(4)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline + data%State%MUD(4)%Q= ( data%State%MudSystem%MudVolume_InjectedFromAnn + data%State%MudSystem%Ann_Kick_Saved_Volume )*60.d0/data%State%MudSystem%DeltaT_Mudline !Injected is referred only to Mud - !if ( WellisNOTFull== .true. ) MUD(4)%Q= 0.0 + !if ( WellisNOTFull== .true. ) data%State%MUD(4)%Q= 0.0 if (j9 > 0) then ChokeLine_FlowCoef= BopStackSpecification%ChokeLineId/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch) - MUD(4)%Q= ChokeLine_FlowCoef * MUD(4)%Q + data%State%MUD(4)%Q= ChokeLine_FlowCoef * data%State%MUD(4)%Q endif - !call Log_1('MUD(4)%Q=', MUD(4)%Q) + !call Log_1('data%State%MUD(4)%Q=', data%State%MUD(4)%Q) - MudSystem%ChokeOutletDensity= MudSystem%ChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code + data%State%MudSystem%ChokeOutletDensity= data%State%MudSystem%ChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code !MudWeightOut2= ChokeOutletDensity !for drillwatch display @@ -1271,38 +1280,38 @@ module MudSystemModule !C71: Active Tank C77: Trip Tank C78: ChokeManifoldDump - if ( MudSystem%BellNippleDensity > 1.0) then + if ( data%State%MudSystem%BellNippleDensity > 1.0) then ! IN ALL CONDITIONS EFFECT OF 78 IS COMPUTED BY RealJ4 if (C71==1 .and. C77==0) then !(volumes in galon) RealJ4: 1 OR 2(IF 78 IS OPEN) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase choke1=' , (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%ChokeOutletDensity*((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+(((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ (((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) + !write(*,*) 'active increase choke1=' , (((1./RealJ4)*data%State%MUD(4)%Q/60.)*DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%ChokeOutletDensity > data%State%MudSystem%ActiveTankDensity) THEN - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase choke2=' , ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((20.8d0-data%State%MudSystem%ChokeOutletDensity)/(20.8d0-data%State%MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + !write(*,*) 'active increase choke2=' , ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity < 5.0) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%ChokeOutletDensity < 5.0) THEN - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase choke3=' ,((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ ((2.d0-data%State%MudSystem%ChokeOutletDensity)/(2.d0-data%State%MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + !write(*,*) 'active increase choke3=' ,((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%ChokeOutletDensity .and. data%State%MudSystem%ChokeOutletDensity <= data%State%MudSystem%ActiveTankDensity) THEN !write(*,*) ' Auto true 3' - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ (((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) - !write(*,*) 'active increase choke4=' , (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) + !write(*,*) 'active increase choke4=' , (((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*DeltaT_Mudline) ENDIF @@ -1313,38 +1322,38 @@ module MudSystemModule if (C77==1 .and. C71==0) then !RealJ4: 1 OR 2(IF 78 IS OPEN) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ChokeOutletDensity*((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%TripTankVolumeCalc+(((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%ChokeOutletDensity > data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((20.8d0-data%State%MudSystem%ChokeOutletDensity)/(20.8d0-data%State%MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity < 5.0) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%ChokeOutletDensity < 5.0) THEN - AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((2.d0-data%State%MudSystem%ChokeOutletDensity)/(2.d0-data%State%MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%ChokeOutletDensity .and. data%State%MudSystem%ChokeOutletDensity <= data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= (((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ENDIF @@ -1355,44 +1364,44 @@ module MudSystemModule if (C71==1 .and. C77==1) then !RealJ4: 2 OR 3(IF 78 IS OPEN) IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)) + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%ChokeOutletDensity*((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+(((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ChokeOutletDensity*((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%TripTankVolumeCalc+(((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ (((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. data%State%MudSystem%ChokeOutletDensity > data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((20.8d0-data%State%MudSystem%ChokeOutletDensity)/(20.8d0-data%State%MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((2.d0-data%State%MudSystem%ChokeOutletDensity)/(2.d0-data%State%MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) - ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN + ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < data%State%MudSystem%ChokeOutletDensity .and. data%State%MudSystem%ChokeOutletDensity <= data%State%MudSystem%ActiveTankDensity) THEN - AddedVolumeToTank= ((1.d0/RealJ4)*MUD(4)%Q/60.d0) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank) + AddedVolumeToTank= ((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*AddedVolumeToTank))/(data%State%MudSystem%TripTankVolumeCalc+AddedVolumeToTank) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ AddedVolumeToTank + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ AddedVolumeToTank - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*data%State%MUD(4)%Q/60.d0)*data%State%MudSystem%DeltaT_Mudline) ENDIF @@ -1403,7 +1412,7 @@ module MudSystemModule if (C71==0 .and. C77==0 .and. C78==1) then !RealJ4: 1 ! autodensity niaz nadarad - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ4)*data%State%MUD(4)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) endif @@ -1412,10 +1421,10 @@ module MudSystemModule endif ! if ( BellNippleDensity > 1.0) then - MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + data%State%MudSystem%TripTankVolumeCalc=min(data%State%MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + data%State%MudSystem%ActiveTankVolume=min(data%State%MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif @@ -1424,16 +1433,16 @@ module MudSystemModule - if (j4 == 0 .or. MudSystem%ChokeLineNOTFull== .true.) then + if (j4 == 0 .or. data%State%MudSystem%ChokeLineNOTFull== .true.) then !Pressure_BeforeChokes=0.0 ! for normal circulation input - MUD(4)%Q=0.0 ! for CirculationCodeSelect input. + data%State%MUD(4)%Q=0.0 ! for CirculationCodeSelect input. endif if (j4 > 0) then - MudSystem%WellToChokeManifoldOpen= .true. + data%State%MudSystem%WellToChokeManifoldOpen= .true. else - MudSystem%WellToChokeManifoldOpen= .false. + data%State%MudSystem%WellToChokeManifoldOpen= .false. endif !=========================================================================================================================== @@ -1454,14 +1463,14 @@ module MudSystemModule !Jj2,Jj12,Jj13: TanksToMudPump Coefficient !H: Pumps To Tank_Through65 or 67 Coefficient - MUD(9)%Q= jj2*(1-H82)*(1-DumpPump1)*Pump1toCh*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*Pump2toCh*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*Pump3toCh*PUMP(3)%Flow_Rate + data%State%MUD(9)%Q= jj2*(1-H82)*(1-DumpPump1)*Pump1toCh*data%State%Pump(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*Pump2toCh*data%State%Pump(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*Pump3toCh*data%State%Pump(3)%Flow_Rate - Denominator_a= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*PUMP(3)%Flow_Rate) + Denominator_a= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*data%State%Pump(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*data%State%Pump(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*data%State%Pump(3)%Flow_Rate) if (Denominator_a /= 0.) then - MudSystem%Density_Ch= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & + data%State%MudSystem%Density_Ch= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*data%State%MudSystem%Mp1Density*data%State%Pump(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*data%State%MudSystem%Mp2Density*data%State%Pump(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*data%State%MudSystem%Mp3Density*data%State%Pump(3)%Flow_Rate)/ & Denominator_a !write(*,*) 'Density_Ch=' , Density_Ch ! @@ -1479,40 +1488,40 @@ module MudSystemModule if (M71==1 .and. M77==0) then !(volumes in galon) RealJ18: 1 OR 2(IF 78 IS OPEN) ! autodensity niaz nadarad - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%Density_Ch*((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+(((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ (((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) endif if (M77==1 .and. M71==0) then !RealJ18: 1 OR 2(IF 78 IS OPEN) ! autodensity niaz nadarad - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%Density_Ch*((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%TripTankVolumeCalc+(((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) endif if (M71==1 .and. M77==1) then !RealJ18: 2 OR 3(IF 78 IS OPEN) ! autodensity niaz nadarad - MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)) + data%State%MudSystem%ActiveTankDensity= ((data%State%MudSystem%ActiveTankDensity*data%State%MudSystem%ActiveTankVolume)+(data%State%MudSystem%Density_Ch*((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%ActiveTankVolume+(((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%Density_Ch*((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%TripTankVolumeCalc+(((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume+ (((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) endif if (M71==0 .and. M77==0 .and. M78==1) then !RealJ18: 1 ! autodensity niaz nadarad - MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ChokeManifoldDumpVolume= data%State%MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ18)*data%State%MUD(9)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) endif @@ -1523,45 +1532,45 @@ module MudSystemModule - MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + data%State%MudSystem%TripTankVolumeCalc=min(data%State%MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped - MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + data%State%MudSystem%ActiveTankVolume=min(data%State%MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) !if ActiveTankVolume is higher, excess amount is dumped endif if (j18 == 0) then - MUD(9)%Q=0.0 + data%State%MUD(9)%Q=0.0 endif !=========================================================================================================================== !=========================================================================================================================== - if (j5 > 0 .and. (MudSystem%ActiveTankVolume/MudSystem%ActiveTankFloorArea) > (MudSystem%TripTankVolumeCalc/MudSystem%TripTankFloorArea)) then !ActiveTankToTripTank + if (j5 > 0 .and. (data%State%MudSystem%ActiveTankVolume/data%State%MudSystem%ActiveTankFloorArea) > (data%State%MudSystem%TripTankVolumeCalc/data%State%MudSystem%TripTankFloorArea)) then !ActiveTankToTripTank ! second condition is for Utube flow !write(*,*) 'j5 is open' ! ActiveTankVolume/ActiveTankFloorArea... means tank height - MUD(5)%Q= 300. ! constant flow rate(gpm) + data%State%MUD(5)%Q= 300. ! constant flow rate(gpm) - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume - ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline) - MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc + ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume - ((data%State%MUD(5)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%TripTankVolumeCalc= data%State%MudSystem%TripTankVolumeCalc + ((data%State%MUD(5)%Q/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*(MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline)) + data%State%MudSystem%TripTankDensityCalc= ((data%State%MudSystem%TripTankDensityCalc*data%State%MudSystem%TripTankVolumeCalc)+(data%State%MudSystem%ActiveTankDensity*(data%State%MUD(5)%Q/60.)*data%State%MudSystem%DeltaT_Mudline))/(data%State%MudSystem%TripTankVolumeCalc+((data%State%MUD(5)%Q/60.)*data%State%MudSystem%DeltaT_Mudline)) - MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal + data%State%MudSystem%TripTankVolumeCalc=min(data%State%MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal !if TripTankVolumeCalc>50, excess value(TripTankVolumeCalc-50) is dumped endif if (j5 == 0) then - MUD(5)%Q=0.0 + data%State%MUD(5)%Q=0.0 endif !=========================================================================================================================== @@ -1571,16 +1580,16 @@ module MudSystemModule if (K79 == 1) then - MudSystem%PressureGauge75= PressureDisplayVARIABLES%PressureGauges(1) !String to Gauge75 + data%State%MudSystem%PressureGauge75= data%State%PressureDisplay%PressureGauges(1) !String to Gauge75 elseif (K82 == 1 .and. k83 == 0 .and. k84 == 0 .and. k78 == 0) then - MudSystem%PressureGauge75= PumpPressure1 + data%State%MudSystem%PressureGauge75= PumpPressure1 elseif (K82 == 0 .and. k83 == 1 .and. k84 == 0 .and. k78 == 0) then - MudSystem%PressureGauge75= PumpPressure2 + data%State%MudSystem%PressureGauge75= PumpPressure2 elseif (K82 == 0 .and. k83 == 0 .and. k84 == 1 .and. k78 == 0) then - MudSystem%PressureGauge75= PumpPressure3 + data%State%MudSystem%PressureGauge75= PumpPressure3 elseif (K82 == 0 .and. k83 == 0 .and. k84 == 0 .and. k78 == 1) then - MudSystem%PressureGauge75= 0. + data%State%MudSystem%PressureGauge75= 0. endif !if (K82 == 1) PressureGauge75= PumpPressure1 !Pump1 to Gauge75' @@ -1591,7 +1600,7 @@ module MudSystemModule endif - StandPipeManifold%StandPipeGauge1= (1 - MudSystem%StandPipeGauge1Malf) * MudSystem%PressureGauge75 ! for STManifold Display + data%EquipmentControl%StandPipeManifold%StandPipeGauge1= (1 - data%State%MudSystem%StandPipeGauge1Malf) * data%State%MudSystem%PressureGauge75 ! for STManifold Display !write(*,*) 'PressureGauge75=' , PressureGauge75 !P1toSt= jj2*(1-H82)*(1-DumpPump1)*G82 !P2toSt= jj12*(1-H83)*(1-DumpPump2)*G83 @@ -1603,16 +1612,16 @@ module MudSystemModule if (L79 == 1) then - MudSystem%PressureGauge76= PressureDisplayVARIABLES%PressureGauges(1) !String to Gauge76 + data%State%MudSystem%PressureGauge76= data%State%PressureDisplay%PressureGauges(1) !String to Gauge76 elseif (L82 == 1 .and. L83 == 0 .and. L84 == 0 .and. L78 == 0) then - MudSystem%PressureGauge76= PumpPressure1 + data%State%MudSystem%PressureGauge76= PumpPressure1 elseif (L82 == 0 .and. L83 == 1 .and. L84 == 0 .and. L78 == 0) then - MudSystem%PressureGauge76= PumpPressure2 + data%State%MudSystem%PressureGauge76= PumpPressure2 elseif (L82 == 0 .and. L83 == 0 .and. L84 == 1 .and. L78 == 0) then - MudSystem%PressureGauge76= PumpPressure3 + data%State%MudSystem%PressureGauge76= PumpPressure3 elseif (L82 == 0 .and. L83 == 0 .and. L84 == 0 .and. L78 == 1) then - MudSystem%PressureGauge76= 0. + data%State%MudSystem%PressureGauge76= 0. endif @@ -1623,7 +1632,7 @@ module MudSystemModule !if (L78 == 1) PressureGauge76= 0. !Dump to Gauge76 endif - StandPipeManifold%StandPipeGauge2= (1 - MudSystem%StandPipeGauge2Malf) * MudSystem%PressureGauge76 ! for STManifold Display + data%EquipmentControl%StandPipeManifold%StandPipeGauge2= (1 - data%State%MudSystem%StandPipeGauge2Malf) * data%State%MudSystem%PressureGauge76 ! for STManifold Display !=========================================================================================================================== !=========================================================================================================================== ! @@ -1646,13 +1655,13 @@ module MudSystemModule !write(*,*) 'TapSelector=' , TapSelector - if (StudentStation%TapSelector == .false.) then + if (data%State%StudentStation%TapSelector == .false.) then - DrillingWatch%PumpPressure= MudSystem%PressureGauge75 !for DrillWatch Display - CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%PressureGauge75 , 8)) !for Data Display Console + data%EquipmentControl%DrillingWatch%PumpPressure= data%State%MudSystem%PressureGauge75 !for DrillWatch Display + CALL Set_StandPipePressure(real((1-data%State%MudSystem%DrillPipePressureMalf)*data%State%MudSystem%PressureGauge75 , 8)) !for Data Display Console else - DrillingWatch%PumpPressure= MudSystem%PressureGauge76 !for DrillWatch Display - CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%PressureGauge76 , 8)) !for Data Display Console + data%EquipmentControl%DrillingWatch%PumpPressure= data%State%MudSystem%PressureGauge76 !for DrillWatch Display + CALL Set_StandPipePressure(real((1-data%State%MudSystem%DrillPipePressureMalf)*data%State%MudSystem%PressureGauge76 , 8)) !for Data Display Console endif !=========================================================================================================================== @@ -1662,25 +1671,25 @@ module MudSystemModule if (j2 > 0) then !TanksToMudPump1 - !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate + !Relief= 0: deactive 1: active data%State%Pump(1)%Flow_Rate , data%State%Pump(2)%Flow_Rate RealJ2= real(j2) - if (A71==1 .and. (MudSystem%ActiveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (A71==1 .and. (data%State%MudSystem%ActiveTankVolume-(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then A71= 0 RealJ2= RealJ2-1 write(*,*) 'ActiveTank Level Warning' call Activate_ActiveTankUnderVolume() endif - if (A72==1 .and. (MudSystem%ReserveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (A72==1 .and. (data%State%MudSystem%ReserveTankVolume-(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then A72= 0 RealJ2= RealJ2-1 write(*,*) 'ReserveTank Level Warning' endif - if (A71==3 .and. (MudSystem%CementTankVolumeCalc-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (A71==3 .and. (data%State%MudSystem%CementTankVolumeCalc-(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then A73= 0 RealJ2= RealJ2-1 write(*,*) 'CementTank Level Warning' @@ -1689,19 +1698,19 @@ module MudSystemModule if(RealJ2> 0.0) then - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- A72*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- A73*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - !write(*,*) 'Active-decline=' , A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline) - total_decrease= total_decrease+ A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume- A71*(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%ReserveTankVolume= data%State%MudSystem%ReserveTankVolume- A72*(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%CementTankVolumeCalc= data%State%MudSystem%CementTankVolumeCalc- A73*(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) + !write(*,*) 'Active-decline=' , A71*(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*DeltaT_Mudline) + total_decrease= total_decrease+ A71*(((1./RealJ2)*data%State%Pump(1)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then total_decrease= 0. endif !write(*,*) 'total_decrease=' , total_decrease - MudSystem%Mp1Density= (A71*MudSystem%ActiveTankDensity+A72*MudSystem%ReserveTankDensity+A73*MudSystem%CementTankDensityCalc)/RealJ2 + data%State%MudSystem%Mp1Density= (A71*data%State%MudSystem%ActiveTankDensity+A72*data%State%MudSystem%ReserveTankDensity+A73*data%State%MudSystem%CementTankDensityCalc)/RealJ2 else write(*,*) 'stop' endif @@ -1718,23 +1727,23 @@ module MudSystemModule if (j12 > 0) then !TanksToMudPump2 - !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate + !Relief= 0: deactive 1: active data%State%Pump(1)%Flow_Rate , data%State%Pump(2)%Flow_Rate RealJ12= real(J12) - if (E71==1 .and. (MudSystem%ActiveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (E71==1 .and. (data%State%MudSystem%ActiveTankVolume-(((1/RealJ12)*data%State%Pump(2)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then E71= 0 RealJ12= RealJ12-1 write(*,*) 'ActiveTank Level Warning' endif - if (E72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (E72==1 .and. (data%State%MudSystem%ReserveTankVolume-(((1/RealJ12)*data%State%Pump(2)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then E72= 0 RealJ12= RealJ12-1 write(*,*) 'ReserveTank Level Warning' endif - if (E71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (E71==3 .and. (data%State%MudSystem%CementTankVolumeCalc-(((1/RealJ12)*data%State%Pump(2)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then E73= 0 RealJ12= RealJ12-1 write(*,*) 'CementTank Level Warning' @@ -1743,13 +1752,13 @@ module MudSystemModule if(RealJ12> 0.0) then - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- E71*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- E72*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- E73*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume- E71*(((1/RealJ12)*data%State%Pump(2)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%ReserveTankVolume= data%State%MudSystem%ReserveTankVolume- E72*(((1/RealJ12)*data%State%Pump(2)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%CementTankVolumeCalc= data%State%MudSystem%CementTankVolumeCalc- E73*(((1/RealJ12)*data%State%Pump(2)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%Mp2Density= (E71*MudSystem%ActiveTankDensity+E72*MudSystem%ReserveTankDensity+E73*MudSystem%CementTankDensityCalc)/RealJ12 + data%State%MudSystem%Mp2Density= (E71*data%State%MudSystem%ActiveTankDensity+E72*data%State%MudSystem%ReserveTankDensity+E73*data%State%MudSystem%CementTankDensityCalc)/RealJ12 else write(*,*) 'stop' endif @@ -1765,24 +1774,24 @@ module MudSystemModule if (j13 > 0) then !TanksToCementPump - !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate + !Relief= 0: deactive 1: active data%State%Pump(1)%Flow_Rate , data%State%Pump(2)%Flow_Rate RealJ13= real(J13) - if (F71==1 .and. (MudSystem%ActiveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (F71==1 .and. (data%State%MudSystem%ActiveTankVolume-(((1/RealJ13)*data%State%Pump(3)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then F71= 0 RealJ13= RealJ13-1 write(*,*) 'ActiveTank Level Warning' endif - if (F72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (F72==1 .and. (data%State%MudSystem%ReserveTankVolume-(((1/RealJ13)*data%State%Pump(3)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then F72= 0 RealJ13= RealJ13-1 write(*,*) 'ReserveTank Level Warning' endif - if (F71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then + if (F71==3 .and. (data%State%MudSystem%CementTankVolumeCalc-(((1/RealJ13)*data%State%Pump(3)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline)) < 0.0) then F73= 0 RealJ13= RealJ13-1 write(*,*) 'CementTank Level Warning' @@ -1791,12 +1800,12 @@ module MudSystemModule if(RealJ13> 0.0) then - MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- F71*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- F72*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) - MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- F73*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%ActiveTankVolume= data%State%MudSystem%ActiveTankVolume- F71*(((1/RealJ13)*data%State%Pump(3)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%ReserveTankVolume= data%State%MudSystem%ReserveTankVolume- F72*(((1/RealJ13)*data%State%Pump(3)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%CementTankVolumeCalc= data%State%MudSystem%CementTankVolumeCalc- F73*(((1/RealJ13)*data%State%Pump(3)%Flow_Rate/60.)*data%State%MudSystem%DeltaT_Mudline) - MudSystem%Mp3Density= (F71*MudSystem%ActiveTankDensity+F72*MudSystem%ReserveTankDensity+F73*MudSystem%CementTankDensityCalc)/RealJ13 + data%State%MudSystem%Mp3Density= (F71*data%State%MudSystem%ActiveTankDensity+F72*data%State%MudSystem%ReserveTankDensity+F73*data%State%MudSystem%CementTankDensityCalc)/RealJ13 else write(*,*) 'stop' endif @@ -1844,23 +1853,23 @@ module MudSystemModule - !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate + !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*data%State%Pump(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*data%State%Pump(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*data%State%Pump(3)%Flow_Rate - Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*PUMP(3)%Flow_Rate) + Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*G82*data%State%Pump(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*data%State%Pump(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*data%State%Pump(3)%Flow_Rate) if (Denominator /= 0.) then - MudSystem%Suction_Density_MudSystem= (jj2*(1.-H82)*(1.-DumpPump1)*G82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & + data%State%MudSystem%Suction_Density_MudSystem= (jj2*(1.-H82)*(1.-DumpPump1)*G82*data%State%MudSystem%Mp1Density*data%State%Pump(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*data%State%MudSystem%Mp2Density*data%State%Pump(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*data%State%MudSystem%Mp3Density*data%State%Pump(3)%Flow_Rate)/ & Denominator endif - MudSystem%CompressedMudDensity= MudSystem%Suction_Density_MudSystem + data%State%MudSystem%CompressedMudDensity= data%State%MudSystem%Suction_Density_MudSystem - DrillingWatch%MudWeightIn= MudSystem%Suction_Density_MudSystem !for drillwatch display + data%EquipmentControl%DrillingWatch%MudWeightIn= data%State%MudSystem%Suction_Density_MudSystem !for drillwatch display - MUD(2)%Q= jj2*(1-H82)*(1-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*G84*PUMP(3)%Flow_Rate + data%State%MUD(2)%Q= jj2*(1-H82)*(1-DumpPump1)*G82*data%State%Pump(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*G83*data%State%Pump(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*G84*data%State%Pump(3)%Flow_Rate - !write(*,*) 'MUD(2)%Q=' , MUD(2)%Q + !write(*,*) 'data%State%MUD(2)%Q=' , data%State%MUD(2)%Q @@ -1873,7 +1882,7 @@ module MudSystemModule endif if (j14 == 0) then ! for normal circulation input - MUD(2)%Q=0.0 + data%State%MUD(2)%Q=0.0 !PumpPressure1= 0.0 !PumpPressure2= 0.0 !PumpPressure3= 0.0 @@ -1884,9 +1893,9 @@ module MudSystemModule !=========================================================================================================================== !=========================================================================================================================== - if (j19 > 0 .and. MudSystem%MudChecked== .true.) then !PumpsToWell_KillLine Suction_Density_PumpsToWell is used for Mud Circulation Code + if (j19 > 0 .and. data%State%MudSystem%MudChecked== .true.) then !PumpsToWell_KillLine Suction_Density_PumpsToWell is used for Mud Circulation Code !write(*,*) 'j19 is open' - MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds + data%State%MudSystem%MudChecked= .false. !to be sure that well is not full after arranging muds ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >> @@ -1918,12 +1927,12 @@ module MudSystemModule - !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate + !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*data%State%Pump(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*data%State%Pump(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*data%State%Pump(3)%Flow_Rate - Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*N82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*PUMP(3)%Flow_Rate) + Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*N82*data%State%Pump(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*data%State%Pump(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*data%State%Pump(3)%Flow_Rate) if (Denominator /= 0.) then - MudSystem%Suction_Density_PumpsToWell= (jj2*(1.-H82)*(1.-DumpPump1)*N82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ & + data%State%MudSystem%Suction_Density_PumpsToWell= (jj2*(1.-H82)*(1.-DumpPump1)*N82*data%State%MudSystem%Mp1Density*data%State%Pump(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*data%State%MudSystem%Mp2Density*data%State%Pump(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*data%State%MudSystem%Mp3Density*data%State%Pump(3)%Flow_Rate)/ & Denominator endif @@ -1931,7 +1940,7 @@ module MudSystemModule - MUD(10)%Q= jj2*(1-H82)*(1-DumpPump1)*N82*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*N83*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*N84*PUMP(3)%Flow_Rate + data%State%MUD(10)%Q= jj2*(1-H82)*(1-DumpPump1)*N82*data%State%Pump(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*N83*data%State%Pump(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*N84*data%State%Pump(3)%Flow_Rate @@ -1941,7 +1950,7 @@ module MudSystemModule endif if (j19 == 0) then ! for normal circulation input - MUD(10)%Q=0.0 + data%State%MUD(10)%Q=0.0 !PumpPressure1= 0.0 !PumpPressure2= 0.0 !PumpPressure3= 0.0 @@ -1970,10 +1979,10 @@ module MudSystemModule !!====================================================================== - if ( MudSystem%WellToChokeManifoldOpen .or. MudSystem%WellToPitsOpen) then - MudSystem%WellHeadIsOpen= .true. + if ( data%State%MudSystem%WellToChokeManifoldOpen .or. data%State%MudSystem%WellToPitsOpen) then + data%State%MudSystem%WellHeadIsOpen= .true. else - MudSystem%WellHeadIsOpen= .false. + data%State%MudSystem%WellHeadIsOpen= .false. endif @@ -1992,8 +2001,8 @@ module MudSystemModule IF (Manifold%Valve(67)%Status == .TRUE.) call Activate_Pump3PopOffValveBlown() !Pump2PopOffValveBlown= .TRUE. - IF (MudSystem%ActiveTankVolume >= (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)) THEN - MudSystem%ActiveTankVolume = (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) + IF (data%State%MudSystem%ActiveTankVolume >= (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)) THEN + data%State%MudSystem%ActiveTankVolume = (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal) call Activate_ActiveTankOverflow() ELSE call Deactivate_ActiveTankOverflow() @@ -2007,11 +2016,11 @@ module MudSystemModule !write(*,*) 'ReserveTankVolume=' , real(ReserveTankVolume) - call Set_ActiveMudVolume_StudentStation(real(MudSystem%ActiveTankVolume/42.,8)) ! 42: gal to bbl - call Set_ActiveDensity_StudentStation(real(MudSystem%ActiveTankDensity,8)) - call Set_ReserveMudVolume_StudentStation(real(MudSystem%ReserveTankVolume/42.,8)) ! 42: gal to bbl - call Set_ReserveDensity_StudentStation(real(MudSystem%ReserveTankDensity,8)) - DrillingWatch%KillMudVolume= MudSystem%ReserveTankVolume/42. ! for DrillWatch + call Set_ActiveMudVolume_StudentStation(real(data%State%MudSystem%ActiveTankVolume/42.,8)) ! 42: gal to bbl + call Set_ActiveDensity_StudentStation(real(data%State%MudSystem%ActiveTankDensity,8)) + call Set_ReserveMudVolume_StudentStation(real(data%State%MudSystem%ReserveTankVolume/42.,8)) ! 42: gal to bbl + call Set_ReserveDensity_StudentStation(real(data%State%MudSystem%ReserveTankDensity,8)) + data%EquipmentControl%DrillingWatch%KillMudVolume= data%State%MudSystem%ReserveTankVolume/42. ! for DrillWatch !PitGainLose= @@ -2020,59 +2029,59 @@ module MudSystemModule !!====================================================================== - IF (DataDisplayConsole%TotalStrokeCounterResetSwitch == 1) then !for drilling data display - MudSystem%TotalStrokesPump1=0. - MudSystem%TotalStrokesPump2=0. + IF (data%EquipmentControl%DataDisplayConsole%TotalStrokeCounterResetSwitch == 1) then !for drilling data display + data%State%MudSystem%TotalStrokesPump1=0. + data%State%MudSystem%TotalStrokesPump2=0. ENDIF - MudSystem%TotalStrokesPump1=MudSystem%TotalStrokesPump1+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display - MudSystem%TotalStrokesPump2=MudSystem%TotalStrokesPump2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display - MudSystem%GraphTotalStrokes=MudSystem%GraphTotalStrokes+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline + data%State%MudSystem%TotalStrokesPump1=data%State%MudSystem%TotalStrokesPump1+((data%EquipmentControl%DataDisplayConsole%MP1SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline !for drilling data display + data%State%MudSystem%TotalStrokesPump2=data%State%MudSystem%TotalStrokesPump2+((data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline !for drilling data display + data%State%MudSystem%GraphTotalStrokes=data%State%MudSystem%GraphTotalStrokes+((data%EquipmentControl%DataDisplayConsole%MP1SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline+((data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline - MPumps%Total_Stroke_Counter_For_Plot = MPumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * MudSystem%DeltaT_Mudline + data%State%MPumps%Total_Stroke_Counter_For_Plot = data%State%MPumps%Total_Stroke_Counter_For_Plot + ((data%EquipmentControl%DataDisplayConsole%MP1SPMGauge + data%EquipmentControl%DataDisplayConsole%MP2SPMGauge) / 60.0) * data%State%MudSystem%DeltaT_Mudline - ! CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot)) + ! CALL SetTotalStrokes(INT(data%State%MPumps%Total_Stroke_Counter_For_Plot)) - DataDisplayConsole%TotalStrokeCounter= real(nint(MudSystem%TotalStrokesPump1+MudSystem%TotalStrokesPump2)) !for drilling data display + data%EquipmentControl%DataDisplayConsole%TotalStrokeCounter= real(nint(data%State%MudSystem%TotalStrokesPump1+data%State%MudSystem%TotalStrokesPump2)) !for drilling data display !=========================================================================== ! MUD PUMP STROKES ! & TOTAL STROKE- CHOKE CONTROL PANEL !=========================================================================== !write(*,*) 'a)))' , ChokePanelStrokeResetSwitch - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - IF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + IF (data%EquipmentControl%ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN !write(*,*) '1 reset' - Choke%TotalStrokes1 =0. - elseif (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN + data%State%Choke%TotalStrokes1 =0. + elseif (data%EquipmentControl%ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN !write(*,*) '2 reset' - Choke%TotalStrokes2 =0. + data%State%Choke%TotalStrokes2 =0. else !write(*,*) 'both reset' - Choke%TotalStrokes1 =0. - Choke%TotalStrokes2 =0. + data%State%Choke%TotalStrokes1 =0. + data%State%Choke%TotalStrokes2 =0. endif endif !write(*,*) 'b)))' , ChokePanelStrokeResetSwitch - Choke%TotalStrokes1= Choke%TotalStrokes1+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline - Choke%TotalStrokes2= Choke%TotalStrokes2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline + data%State%Choke%TotalStrokes1= data%State%Choke%TotalStrokes1+((data%EquipmentControl%DataDisplayConsole%MP1SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline + data%State%Choke%TotalStrokes2= data%State%Choke%TotalStrokes2+((data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline - IF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN - ChokeControlPanel%ChokePanelSPMCounter = real(nint(DataDisplayConsole%MP1SPMGauge)) - ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes1)) - ELSEIF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN - ChokeControlPanel%ChokePanelSPMCounter = real(nint(DataDisplayConsole%MP2SPMGauge)) - ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes2)) + IF (data%EquipmentControl%ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN + data%EquipmentControl%ChokeControlPanel%ChokePanelSPMCounter = real(nint(data%EquipmentControl%DataDisplayConsole%MP1SPMGauge)) + data%EquipmentControl%ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(data%State%Choke%TotalStrokes1)) + ELSEIF (data%EquipmentControl%ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN + data%EquipmentControl%ChokeControlPanel%ChokePanelSPMCounter = real(nint(data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)) + data%EquipmentControl%ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(data%State%Choke%TotalStrokes2)) ELSE - ChokeControlPanel%ChokePanelSPMCounter= real(nint(DataDisplayConsole%MP1SPMGauge+DataDisplayConsole%MP2SPMGauge)) - ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes1+Choke%TotalStrokes2)) + data%EquipmentControl%ChokeControlPanel%ChokePanelSPMCounter= real(nint(data%EquipmentControl%DataDisplayConsole%MP1SPMGauge+data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)) + data%EquipmentControl%ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(data%State%Choke%TotalStrokes1+data%State%Choke%TotalStrokes2)) ENDIF ! ChokePanelStrokeResetSwitch = 0 @@ -2083,25 +2092,25 @@ module MudSystemModule !!====================================================================== - DrillingWatch%PitVolume= MudSystem%ActiveTankVolume/42.d0 !(bbl) For DrillWatch Display + data%EquipmentControl%DrillingWatch%PitVolume= data%State%MudSystem%ActiveTankVolume/42.d0 !(bbl) For DrillWatch Display !write(*,*) 'PitVolume,ActiveTankVolume=' ,PitVolume,ActiveTankVolume - MudSystem%MudTank1_vol= MudSystem%ActiveTankVolume/3. ! (gal) - MudSystem%MudTank2_vol= MudSystem%ActiveTankVolume/3. ! (gal) - MudSystem%MudTank3_vol= MudSystem%ActiveTankVolume/3. ! (gal) - MudSystem%MudTank4_vol= MudSystem%TripTankVolumeCalc + data%State%MudSystem%MudTank1_vol= data%State%MudSystem%ActiveTankVolume/3. ! (gal) + data%State%MudSystem%MudTank2_vol= data%State%MudSystem%ActiveTankVolume/3. ! (gal) + data%State%MudSystem%MudTank3_vol= data%State%MudSystem%ActiveTankVolume/3. ! (gal) + data%State%MudSystem%MudTank4_vol= data%State%MudSystem%TripTankVolumeCalc - IF (DataDisplayConsole%MVTPowerSwitch==1) THEN - DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%MudTanksVolumeGaugeMalf) *((MudSystem%MudTank1_vol*DataDisplayConsole%MudTank1Switch)+(MudSystem%MudTank2_vol*DataDisplayConsole%MudTank2Switch)+ & - (MudSystem%MudTank3_vol*DataDisplayConsole%MudTank3Switch)+(MudSystem%MudTank4_vol*DataDisplayConsole%MudTank4Switch)+MudSystem%ActiveTankSettled) !(gal) - ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN - DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%MudTanksVolumeGaugeMalf) *0. + IF (data%EquipmentControl%DataDisplayConsole%MVTPowerSwitch==1) THEN + data%EquipmentControl%DataDisplayConsole%MudTanksVolumeGauge= (1 - data%State%MudSystem%MudTanksVolumeGaugeMalf) *((data%State%MudSystem%MudTank1_vol*data%EquipmentControl%DataDisplayConsole%MudTank1Switch)+(data%State%MudSystem%MudTank2_vol*data%EquipmentControl%DataDisplayConsole%MudTank2Switch)+ & + (data%State%MudSystem%MudTank3_vol*data%EquipmentControl%DataDisplayConsole%MudTank3Switch)+(data%State%MudSystem%MudTank4_vol*data%EquipmentControl%DataDisplayConsole%MudTank4Switch)+data%State%MudSystem%ActiveTankSettled) !(gal) + ELSEIF (data%EquipmentControl%DataDisplayConsole%MVTPowerSwitch==0) THEN + data%EquipmentControl%DataDisplayConsole%MudTanksVolumeGauge= (1 - data%State%MudSystem%MudTanksVolumeGaugeMalf) *0. ENDIF !!====================================================================== @@ -2111,27 +2120,27 @@ module MudSystemModule - ! IF (DataDisplayConsole%MVTPowerSwitch==1 .and. IsPortable==.false.) THEN + ! IF (data%EquipmentControl%DataDisplayConsole%MVTPowerSwitch==1 .and. IsPortable==.false.) THEN - ! IF (DataDisplayConsole%MVTSetAlarmSwitch==0) THEN + ! IF (data%EquipmentControl%DataDisplayConsole%MVTSetAlarmSwitch==0) THEN - ! DataDisplayConsole%PitGainLossGauge= ( ((ActiveTankVolume/42.) - RefrencePitVolume)) - PitGainLossGaugeMalf*(( ((ActiveTankVolume/42.) - RefrencePitVolume))+50) !(bbl) + ! data%EquipmentControl%DataDisplayConsole%PitGainLossGauge= ( ((ActiveTankVolume/42.) - RefrencePitVolume)) - PitGainLossGaugeMalf*(( ((ActiveTankVolume/42.) - RefrencePitVolume))+50) !(bbl) - ! ELSEIF (DataDisplayConsole%MVTSetAlarmSwitch==-1) THEN + ! ELSEIF (data%EquipmentControl%DataDisplayConsole%MVTSetAlarmSwitch==-1) THEN - ! MVT_MinVol_Allowded= PitGainLossZero+ MIN(0.,(DataDisplayConsole%MVTSetAlarmLowKnob-50))-0.1 - ! DataDisplayConsole%PitGainLossGauge= MVT_MinVol_Allowded - PitGainLossGaugeMalf*(MVT_MinVol_Allowded+50) + ! MVT_MinVol_Allowded= PitGainLossZero+ MIN(0.,(data%EquipmentControl%DataDisplayConsole%MVTSetAlarmLowKnob-50))-0.1 + ! data%EquipmentControl%DataDisplayConsole%PitGainLossGauge= MVT_MinVol_Allowded - PitGainLossGaugeMalf*(MVT_MinVol_Allowded+50) ! ! - PitGainLossGaugeMalf*(MVT_MinVol_Allowded+50) : Malf effect ! !PitGainLose=(MVT_MinVol_Allowded) ! DrillWatch (incorrect) ! !RefrencePitVolume= ActiveTankVolume/42. !(bbl) ! ELSE !(MVTSetAlarmSwitch==1) - ! MVT_MaxVol_Allowded= PitGainLossZero+ MAX(0., (DataDisplayConsole%MVTSetAlarmHighKnob-50.))+0.1 - ! DataDisplayConsole%PitGainLossGauge= MVT_MaxVol_Allowded - PitGainLossGaugeMalf*(MVT_MaxVol_Allowded+50) + ! MVT_MaxVol_Allowded= PitGainLossZero+ MAX(0., (data%EquipmentControl%DataDisplayConsole%MVTSetAlarmHighKnob-50.))+0.1 + ! data%EquipmentControl%DataDisplayConsole%PitGainLossGauge= MVT_MaxVol_Allowded - PitGainLossGaugeMalf*(MVT_MaxVol_Allowded+50) ! ! - PitGainLossGaugeMalf*(MVT_MaxVol_Allowded+50) : Malf effect ! !PitGainLose=(MVT_MaxVol_Allowded) ! DrillWatch (incorrect) ! !RefrencePitVolume= ActiveTankVolume/42. !(bbl) @@ -2146,25 +2155,25 @@ module MudSystemModule ! IF ( ActiveTankVolume/42. < (RefrencePitVolume-ABS(MVT_MinVol_Allowded)) .OR. ActiveTankVolume/42. > (RefrencePitVolume+ABS(MVT_MaxVol_Allowded)) ) THEN - ! DataDisplayConsole%MVTAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%MVTHornSwitch) THEN - ! DataDisplayConsole%Buzzer2= .TRUE. + ! data%EquipmentControl%DataDisplayConsole%MVTAlarmLED = 1 !(blinking) + ! IF (data%EquipmentControl%DataDisplayConsole%MVTHornSwitch) THEN + ! data%EquipmentControl%DataDisplayConsole%Buzzer2= .TRUE. ! ELSE - ! DataDisplayConsole%Buzzer2= .FALSE. + ! data%EquipmentControl%DataDisplayConsole%Buzzer2= .FALSE. ! ENDIF ! ELSE - ! DataDisplayConsole%MVTAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer2= .false. + ! data%EquipmentControl%DataDisplayConsole%MVTAlarmLED = 0 !(OFF) + ! data%EquipmentControl%DataDisplayConsole%Buzzer2= .false. ! ENDIF - ! ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN + ! ELSEIF (data%EquipmentControl%DataDisplayConsole%MVTPowerSwitch==0) THEN ! !MudTanksVolumeGauge= 0. - ! DataDisplayConsole%PitGainLossGauge= -50 - ! DataDisplayConsole%MVTAlarmLED= 0 - ! DataDisplayConsole%Buzzer2= .false. + ! data%EquipmentControl%DataDisplayConsole%PitGainLossGauge= -50 + ! data%EquipmentControl%DataDisplayConsole%MVTAlarmLED= 0 + ! data%EquipmentControl%DataDisplayConsole%Buzzer2= .false. ! ENDIF @@ -2176,16 +2185,16 @@ module MudSystemModule - DrillingWatch%PercentFlow= (MudSystem%ReturnFlowRate/MudSystem%PedalMeter) *100. !(percent) ! for DrillWatch display - if (abs(DrillingWatch%PercentFlow - unityreturn) > 1.0) then + data%EquipmentControl%DrillingWatch%PercentFlow= (data%State%MudSystem%ReturnFlowRate/data%State%MudSystem%PedalMeter) *100. !(percent) ! for DrillWatch display + if (abs(data%EquipmentControl%DrillingWatch%PercentFlow - unityreturn) > 1.0) then - write(*,*) 'PercentFlow,ReturnFlowRate,PedalMeter=' , DrillingWatch%PercentFlow,MudSystem%ReturnFlowRate,MudSystem%PedalMeter + write(*,*) 'PercentFlow,ReturnFlowRate,PedalMeter=' , data%EquipmentControl%DrillingWatch%PercentFlow,data%State%MudSystem%ReturnFlowRate,data%State%MudSystem%PedalMeter write(*,*) 'unityreturn=' , unityreturn endif ! ReturnFlowRate=800. set in startup as initial value - MudSystem%ReturnFlowPercent= (MudSystem%ReturnFlowRate/MudSystem%PedalMeter) *100. !(percent) + data%State%MudSystem%ReturnFlowPercent= (data%State%MudSystem%ReturnFlowRate/data%State%MudSystem%PedalMeter) *100. !(percent) !write(*,*) 'ReturnFlowPercent,ReturnFlowRate=' , ReturnFlowPercent,ReturnFlowRate ! if ReturnFlowRate>PedalMeter, excess value(ReturnFlowRate-PedalMeter) is dumped in the code before @@ -2194,40 +2203,40 @@ module MudSystemModule !! DRILL WATCH !!====================================================================== - DrillingWatch%PitGainLose= ((MudSystem%ActiveTankVolume/42.) - MudSystem%RefrencePitVolume_DrillWatch) ! DrillWatch + data%EquipmentControl%DrillingWatch%PitGainLose= ((data%State%MudSystem%ActiveTankVolume/42.) - data%State%MudSystem%RefrencePitVolume_DrillWatch) ! DrillWatch !write(*,*) 'PitGainLose galon' , PitGainLose*42. ! if (IsPortable) then - ! MVT_MinVol_Allowded= DataDisplayConsole%PitAlarmLow - ! MVT_MaxVol_Allowded= DataDisplayConsole%PitAlarmHigh + ! MVT_MinVol_Allowded= data%EquipmentControl%DataDisplayConsole%PitAlarmLow + ! MVT_MaxVol_Allowded= data%EquipmentControl%DataDisplayConsole%PitAlarmHigh ! IF ( ActiveTankVolume/42. < (RefrencePitVolume-ABS(MVT_MinVol_Allowded)) .OR. ActiveTankVolume/42. > (RefrencePitVolume+ABS(MVT_MaxVol_Allowded)) ) THEN - ! DataDisplayConsole%MVTAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%MVTHornSwitch) THEN - ! DataDisplayConsole%Buzzer2= .TRUE. + ! data%EquipmentControl%DataDisplayConsole%MVTAlarmLED = 1 !(blinking) + ! IF (data%EquipmentControl%DataDisplayConsole%MVTHornSwitch) THEN + ! data%EquipmentControl%DataDisplayConsole%Buzzer2= .TRUE. ! ELSE - ! DataDisplayConsole%Buzzer2= .FALSE. + ! data%EquipmentControl%DataDisplayConsole%Buzzer2= .FALSE. ! ENDIF ! ELSE - ! DataDisplayConsole%MVTAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer2= .false. + ! data%EquipmentControl%DataDisplayConsole%MVTAlarmLED = 0 !(OFF) + ! data%EquipmentControl%DataDisplayConsole%Buzzer2= .false. ! ENDIF ! endif - if (StudentStation%PitGainLossZero) then + if (data%State%StudentStation%PitGainLossZero) then - DrillingWatch%PitGainLose= 0.d0 !DrillWatch - MudSystem%RefrencePitVolume_DrillWatch= MudSystem%ActiveTankVolume/42. !(bbl) !DrillWatch + data%EquipmentControl%DrillingWatch%PitGainLose= 0.d0 !DrillWatch + data%State%MudSystem%RefrencePitVolume_DrillWatch= data%State%MudSystem%ActiveTankVolume/42. !(bbl) !DrillWatch !********************************************* - DataDisplayConsole%PitGainLossGauge= 0. !MFF Indicator - MudSystem%RefrencePitVolume= MudSystem%ActiveTankVolume/42. !(bbl) !MFF Indicator + data%EquipmentControl%DataDisplayConsole%PitGainLossGauge= 0. !MFF Indicator + data%State%MudSystem%RefrencePitVolume= data%State%MudSystem%ActiveTankVolume/42. !(bbl) !MFF Indicator endif @@ -2241,85 +2250,85 @@ module MudSystemModule !! MUD FLOW-FILL INDICATOR !!====================================================================== - IF (DataDisplayConsole%MFFIPowerSwitch==1 ) THEN !.and. IsPortable==.false. + IF (data%EquipmentControl%DataDisplayConsole%MFFIPowerSwitch==1 ) THEN !.and. IsPortable==.false. !====================TotalStrokes Reset and Calculate====================== - if (DataDisplayConsole%MFFIResetTotalStrokes == 1) then - IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN - MudSystem%TotalStrokes1MFFI =0. - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN - MudSystem%TotalStrokes2MFFI =0. + if (data%EquipmentControl%DataDisplayConsole%MFFIResetTotalStrokes == 1) then + IF (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN + data%State%MudSystem%TotalStrokes1MFFI =0. + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN + data%State%MudSystem%TotalStrokes2MFFI =0. else - MudSystem%TotalStrokes1MFFI =0. - MudSystem%TotalStrokes2MFFI =0. + data%State%MudSystem%TotalStrokes1MFFI =0. + data%State%MudSystem%TotalStrokes2MFFI =0. endif endif - MudSystem%TotalStrokes1MFFI= MudSystem%TotalStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline - MudSystem%TotalStrokes2MFFI= MudSystem%TotalStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline + data%State%MudSystem%TotalStrokes1MFFI= data%State%MudSystem%TotalStrokes1MFFI+((data%EquipmentControl%DataDisplayConsole%MP1SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline + data%State%MudSystem%TotalStrokes2MFFI= data%State%MudSystem%TotalStrokes2MFFI+((data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline !==================FillStrokes Reset and Calculate========================= - if (DataDisplayConsole%MFFIResetFillCounter == 1) then - IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN - MudSystem%TotalFillStrokes1MFFI =0. - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN - MudSystem%TotalFillStrokes2MFFI =0. + if (data%EquipmentControl%DataDisplayConsole%MFFIResetFillCounter == 1) then + IF (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN + data%State%MudSystem%TotalFillStrokes1MFFI =0. + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN + data%State%MudSystem%TotalFillStrokes2MFFI =0. else - MudSystem%TotalFillStrokes1MFFI =0. - MudSystem%TotalFillStrokes2MFFI =0. + data%State%MudSystem%TotalFillStrokes1MFFI =0. + data%State%MudSystem%TotalFillStrokes2MFFI =0. endif endif - MudSystem%TotalFillStrokes1MFFI= MudSystem%TotalFillStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline - MudSystem%TotalFillStrokes2MFFI= MudSystem%TotalFillStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline + data%State%MudSystem%TotalFillStrokes1MFFI= data%State%MudSystem%TotalFillStrokes1MFFI+((data%EquipmentControl%DataDisplayConsole%MP1SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline + data%State%MudSystem%TotalFillStrokes2MFFI= data%State%MudSystem%TotalFillStrokes2MFFI+((data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)/60.)*data%State%MudSystem%DeltaT_Mudline !=================================================================== - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI)) !TotalStroke LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes2MFFI)) !TotalStroke LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI+MudSystem%TotalStrokes2MFFI)) !TotalStroke LED + if (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then + data%EquipmentControl%DataDisplayConsole%MFFITotalStrokeCounter = real(nint(data%State%MudSystem%TotalStrokes1MFFI)) !TotalStroke LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then + data%EquipmentControl%DataDisplayConsole%MFFITotalStrokeCounter = real(nint(data%State%MudSystem%TotalStrokes2MFFI)) !TotalStroke LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then + data%EquipmentControl%DataDisplayConsole%MFFITotalStrokeCounter = real(nint(data%State%MudSystem%TotalStrokes1MFFI+data%State%MudSystem%TotalStrokes2MFFI)) !TotalStroke LED endif - IF (DataDisplayConsole%MFFIFillSPMSelectorSwitch== .false.) THEN !(spm mode) - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = real(nint(DataDisplayConsole%MP1SPMGauge)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = real(nint(DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= real(nint(DataDisplayConsole%MP1SPMGauge+DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED + IF (data%EquipmentControl%DataDisplayConsole%MFFIFillSPMSelectorSwitch== .false.) THEN !(spm mode) + if (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter = real(nint(data%EquipmentControl%DataDisplayConsole%MP1SPMGauge)) !Fill or SPM LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter = real(nint(data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter= real(nint(data%EquipmentControl%DataDisplayConsole%MP1SPMGauge+data%EquipmentControl%DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED endif ELSE ! (MFFIFillSPMSelectorSwitch== .true.) then !(fill mode) - if (MudSystem%ReturnFlowRate== 0) then - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes1MFFI)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED + if (data%State%MudSystem%ReturnFlowRate== 0) then + if (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter = real(nint(data%State%MudSystem%TotalFillStrokes1MFFI)) !Fill or SPM LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter = real(nint(data%State%MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter= real(nint(data%State%MudSystem%TotalFillStrokes1MFFI+data%State%MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED endif - MudSystem%TotalFilledStrokesBy1MFFI = real(nint(MudSystem%TotalFillStrokes1MFFI))! for values=fix on LED after the well filled - MudSystem%TotalFilledStrokesBy2MFFI = real(nint(MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled - MudSystem%TotalFilledStrokesBy1and2MFFI= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled + data%State%MudSystem%TotalFilledStrokesBy1MFFI = real(nint(data%State%MudSystem%TotalFillStrokes1MFFI))! for values=fix on LED after the well filled + data%State%MudSystem%TotalFilledStrokesBy2MFFI = real(nint(data%State%MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled + data%State%MudSystem%TotalFilledStrokesBy1and2MFFI= real(nint(data%State%MudSystem%TotalFillStrokes1MFFI+data%State%MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled else !(ReturnFlowRate>0) ! these values=fix on LED after the well filled - if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then - DataDisplayConsole%FillStrokeCounter = MudSystem%TotalFilledStrokesBy1MFFI !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then - DataDisplayConsole%FillStrokeCounter = MudSystem%TotalFilledStrokesBy2MFFI !Fill or SPM LED - elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then - DataDisplayConsole%FillStrokeCounter= MudSystem%TotalFilledStrokesBy1and2MFFI !Fill or SPM LED + if (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter = data%State%MudSystem%TotalFilledStrokesBy1MFFI !Fill or SPM LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter = data%State%MudSystem%TotalFilledStrokesBy2MFFI !Fill or SPM LED + elseif (data%EquipmentControl%DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter= data%State%MudSystem%TotalFilledStrokesBy1and2MFFI !Fill or SPM LED endif endif @@ -2333,70 +2342,70 @@ module MudSystemModule - if (MudSystem%ReturnFlowRate>0) then - DataDisplayConsole%MFFIPumpLED=1 !(Returns Lamp) + if (data%State%MudSystem%ReturnFlowRate>0) then + data%EquipmentControl%DataDisplayConsole%MFFIPumpLED=1 !(Returns Lamp) else - DataDisplayConsole%MFFIPumpLED=0 !(Returns Lamp) + data%EquipmentControl%DataDisplayConsole%MFFIPumpLED=0 !(Returns Lamp) endif - IF (DataDisplayConsole%MFFISetAlarmSwitch==0) THEN + IF (data%EquipmentControl%DataDisplayConsole%MFFISetAlarmSwitch==0) THEN - DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%ReturnFlowPercent !(percent) + data%EquipmentControl%DataDisplayConsole%ReturnMudFlowGauge= (1 - data%State%MudSystem%ReturnMudFlowGaugeMalf)*data%State%MudSystem%ReturnFlowPercent !(percent) - ELSEIF (DataDisplayConsole%MFFISetAlarmSwitch==-1) THEN - MudSystem%MFFI_MinPercent_Allowded=DataDisplayConsole%MFFISetAlarmLowKnob - DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MinPercent_Allowded + ELSEIF (data%EquipmentControl%DataDisplayConsole%MFFISetAlarmSwitch==-1) THEN + data%State%MudSystem%MFFI_MinPercent_Allowded=data%EquipmentControl%DataDisplayConsole%MFFISetAlarmLowKnob + data%EquipmentControl%DataDisplayConsole%ReturnMudFlowGauge= (1 - data%State%MudSystem%ReturnMudFlowGaugeMalf)*data%State%MudSystem%MFFI_MinPercent_Allowded ELSE !(MFFISetAlarmSwitch==1) - MudSystem%MFFI_MaxPercent_Allowded=DataDisplayConsole%MFFISetAlarmHighKnob - DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MaxPercent_Allowded + data%State%MudSystem%MFFI_MaxPercent_Allowded=data%EquipmentControl%DataDisplayConsole%MFFISetAlarmHighKnob + data%EquipmentControl%DataDisplayConsole%ReturnMudFlowGauge= (1 - data%State%MudSystem%ReturnMudFlowGaugeMalf)*data%State%MudSystem%MFFI_MaxPercent_Allowded ENDIF - IF (MudSystem%ReturnFlowPercentMudSystem%MFFI_MaxPercent_Allowded) THEN + IF (data%State%MudSystem%ReturnFlowPercentdata%State%MudSystem%MFFI_MaxPercent_Allowded) THEN !write(*,*) 'alarm return:' , ReturnFlowRate - DataDisplayConsole%MFFIAlarmLED = 2 !(blinking) - IF (DataDisplayConsole%MFFIHornSwitch) THEN - DataDisplayConsole%Buzzer3= .true. + data%EquipmentControl%DataDisplayConsole%MFFIAlarmLED = 2 !(blinking) + IF (data%EquipmentControl%DataDisplayConsole%MFFIHornSwitch) THEN + data%EquipmentControl%DataDisplayConsole%Buzzer3= .true. ELSE - DataDisplayConsole%Buzzer3= .FALSE. + data%EquipmentControl%DataDisplayConsole%Buzzer3= .FALSE. ENDIF ELSE - DataDisplayConsole%MFFIAlarmLED = 0 !(OFF) - DataDisplayConsole%Buzzer3= .false. + data%EquipmentControl%DataDisplayConsole%MFFIAlarmLED = 0 !(OFF) + data%EquipmentControl%DataDisplayConsole%Buzzer3= .false. ENDIF !=================================================================================== - ELSEIF (DataDisplayConsole%MFFIPowerSwitch==0) THEN - DataDisplayConsole%ReturnMudFlowGauge= 0. - DataDisplayConsole%FillStrokeCounter= 0 - DataDisplayConsole%MFFITotalStrokeCounter= 0 - DataDisplayConsole%MFFIAlarmLED= 0 - DataDisplayConsole%Buzzer3= .false. + ELSEIF (data%EquipmentControl%DataDisplayConsole%MFFIPowerSwitch==0) THEN + data%EquipmentControl%DataDisplayConsole%ReturnMudFlowGauge= 0. + data%EquipmentControl%DataDisplayConsole%FillStrokeCounter= 0 + data%EquipmentControl%DataDisplayConsole%MFFITotalStrokeCounter= 0 + data%EquipmentControl%DataDisplayConsole%MFFIAlarmLED= 0 + data%EquipmentControl%DataDisplayConsole%Buzzer3= .false. ENDIF ! if ( IsPortable ) then - ! MFFI_MinPercent_Allowded=DataDisplayConsole%RetFlowAlarmLow - ! MFFI_MaxPercent_Allowded=DataDisplayConsole%RetFlowAlarmHigh + ! MFFI_MinPercent_Allowded=data%EquipmentControl%DataDisplayConsole%RetFlowAlarmLow + ! MFFI_MaxPercent_Allowded=data%EquipmentControl%DataDisplayConsole%RetFlowAlarmHigh ! IF (ReturnFlowPercentMFFI_MaxPercent_Allowded) THEN - ! DataDisplayConsole%MFFIAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%MFFIHornSwitch) THEN - ! DataDisplayConsole%Buzzer3= .true. + ! data%EquipmentControl%DataDisplayConsole%MFFIAlarmLED = 1 !(blinking) + ! IF (data%EquipmentControl%DataDisplayConsole%MFFIHornSwitch) THEN + ! data%EquipmentControl%DataDisplayConsole%Buzzer3= .true. ! ELSE - ! DataDisplayConsole%Buzzer3= .FALSE. + ! data%EquipmentControl%DataDisplayConsole%Buzzer3= .FALSE. ! ENDIF ! ELSE - ! DataDisplayConsole%MFFIAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer3= .false. + ! data%EquipmentControl%DataDisplayConsole%MFFIAlarmLED = 0 !(OFF) + ! data%EquipmentControl%DataDisplayConsole%Buzzer3= .false. ! ENDIF ! endif @@ -2406,66 +2415,66 @@ module MudSystemModule !! TRIP TANK PANEL DISPLAY VALUES !!====================================================================== - Tank%TripTankVolume = MudSystem%TripTankVolumeCalc/42. !(Drill Watch display) - Tank%TripTankDensity= MudSystem%TripTankDensityCalc !(display) + data%EquipmentControl%Tank%TripTankVolume = data%State%MudSystem%TripTankVolumeCalc/42. !(Drill Watch display) + data%EquipmentControl%Tank%TripTankDensity= data%State%MudSystem%TripTankDensityCalc !(display) - IF (DataDisplayConsole%TripTankPowerSwitch==1 ) THEN !.and. IsPortable==.false. + IF (data%EquipmentControl%DataDisplayConsole%TripTankPowerSwitch==1 ) THEN !.and. IsPortable==.false. - IF (DataDisplayConsole%TripTankSetAlarmSwitch==0) THEN + IF (data%EquipmentControl%DataDisplayConsole%TripTankSetAlarmSwitch==0) THEN - DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTankVolumeCalc ! (gal) - ELSEIF (DataDisplayConsole%TripTankSetAlarmSwitch==-1) THEN + data%EquipmentControl%DataDisplayConsole%TripTankGauge= (1 - data%State%MudSystem%TripTankPressure_DataDisplayMalf) * data%State%MudSystem%TripTankVolumeCalc ! (gal) + ELSEIF (data%EquipmentControl%DataDisplayConsole%TripTankSetAlarmSwitch==-1) THEN - MudSystem%TripTank_MinVol_Allowded= DataDisplayConsole%TripTankSetAlarmLow/2. ! 2: because knob input is 0-100 but gauge is 0-50 - DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MinVol_Allowded + data%State%MudSystem%TripTank_MinVol_Allowded= data%EquipmentControl%DataDisplayConsole%TripTankSetAlarmLow/2. ! 2: because knob input is 0-100 but gauge is 0-50 + data%EquipmentControl%DataDisplayConsole%TripTankGauge= (1 - data%State%MudSystem%TripTankPressure_DataDisplayMalf) * data%State%MudSystem%TripTank_MinVol_Allowded ELSE !(TripTankSetAlarmSwitch==1) - MudSystem%TripTank_MaxVol_Allowded= DataDisplayConsole%TripTankSetAlarmHigh/2. ! 2: because knob input is 0-100 but gauge is 0-50 - DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MaxVol_Allowded + data%State%MudSystem%TripTank_MaxVol_Allowded= data%EquipmentControl%DataDisplayConsole%TripTankSetAlarmHigh/2. ! 2: because knob input is 0-100 but gauge is 0-50 + data%EquipmentControl%DataDisplayConsole%TripTankGauge= (1 - data%State%MudSystem%TripTankPressure_DataDisplayMalf) * data%State%MudSystem%TripTank_MaxVol_Allowded ENDIF - IF ((MudSystem%TripTankVolumeCalc < MudSystem%TripTank_MinVol_Allowded) .OR. (MudSystem%TripTankVolumeCalc > MudSystem%TripTank_MaxVol_Allowded)) THEN - DataDisplayConsole%TripTankAlarmLED = 2 !(blinking) - IF (DataDisplayConsole%TripTankHornSwitch) THEN - DataDisplayConsole%Buzzer1= .true. + IF ((data%State%MudSystem%TripTankVolumeCalc < data%State%MudSystem%TripTank_MinVol_Allowded) .OR. (data%State%MudSystem%TripTankVolumeCalc > data%State%MudSystem%TripTank_MaxVol_Allowded)) THEN + data%EquipmentControl%DataDisplayConsole%TripTankAlarmLED = 2 !(blinking) + IF (data%EquipmentControl%DataDisplayConsole%TripTankHornSwitch) THEN + data%EquipmentControl%DataDisplayConsole%Buzzer1= .true. ELSE - DataDisplayConsole%Buzzer1= .false. + data%EquipmentControl%DataDisplayConsole%Buzzer1= .false. ENDIF ELSE - DataDisplayConsole%TripTankAlarmLED = 0 !(OFF) - DataDisplayConsole%Buzzer1= .false. + data%EquipmentControl%DataDisplayConsole%TripTankAlarmLED = 0 !(OFF) + data%EquipmentControl%DataDisplayConsole%Buzzer1= .false. ENDIF - DataDisplayConsole%TripTankPumpLED= DataDisplayConsole%TripTankPumpSwitch + data%EquipmentControl%DataDisplayConsole%TripTankPumpLED= data%EquipmentControl%DataDisplayConsole%TripTankPumpSwitch - ELSEIF (DataDisplayConsole%TripTankPowerSwitch==0) THEN - DataDisplayConsole%TripTankGauge= 0. !(gal) - DataDisplayConsole%TripTankAlarmLED= 0 - DataDisplayConsole%TripTankPumpLED= 0 - DataDisplayConsole%Buzzer1= .false. + ELSEIF (data%EquipmentControl%DataDisplayConsole%TripTankPowerSwitch==0) THEN + data%EquipmentControl%DataDisplayConsole%TripTankGauge= 0. !(gal) + data%EquipmentControl%DataDisplayConsole%TripTankAlarmLED= 0 + data%EquipmentControl%DataDisplayConsole%TripTankPumpLED= 0 + data%EquipmentControl%DataDisplayConsole%Buzzer1= .false. ENDIF ! if ( IsPortable ) then - ! TripTank_MinVol_Allowded= DataDisplayConsole%TripAlarmLow - ! TripTank_MaxVol_Allowded= DataDisplayConsole%TripAlarmHigh + ! TripTank_MinVol_Allowded= data%EquipmentControl%DataDisplayConsole%TripAlarmLow + ! TripTank_MaxVol_Allowded= data%EquipmentControl%DataDisplayConsole%TripAlarmHigh ! IF ((TripTankVolumeCalc < TripTank_MinVol_Allowded) .OR. (TripTankVolumeCalc > TripTank_MaxVol_Allowded)) THEN - ! DataDisplayConsole%TripTankAlarmLED = 1 !(blinking) - ! IF (DataDisplayConsole%TripTankHornSwitch) THEN - ! DataDisplayConsole%Buzzer1= .true. + ! data%EquipmentControl%DataDisplayConsole%TripTankAlarmLED = 1 !(blinking) + ! IF (data%EquipmentControl%DataDisplayConsole%TripTankHornSwitch) THEN + ! data%EquipmentControl%DataDisplayConsole%Buzzer1= .true. ! ELSE - ! DataDisplayConsole%Buzzer1= .false. + ! data%EquipmentControl%DataDisplayConsole%Buzzer1= .false. ! ENDIF ! ELSE - ! DataDisplayConsole%TripTankAlarmLED = 0 !(OFF) - ! DataDisplayConsole%Buzzer1= .false. + ! data%EquipmentControl%DataDisplayConsole%TripTankAlarmLED = 0 !(OFF) + ! data%EquipmentControl%DataDisplayConsole%Buzzer1= .false. ! ENDIF ! endif @@ -2493,7 +2502,7 @@ module MudSystemModule implicit none real(8), intent (in) :: v !call Log_4('ActiveMudVolumeChanged=', v) - MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! update from student input + data%State%MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! update from student input end subroutine subroutine ActiveDensityChanged(v) @@ -2501,7 +2510,7 @@ module MudSystemModule implicit none real(8), intent (in) :: v !call Log_4('ActiveDensityChanged=', v) - MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! update from student input + data%State%MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! update from student input end subroutine subroutine ReserveMudVolumeChanged(v) @@ -2509,7 +2518,7 @@ module MudSystemModule implicit none real(8), intent (in) :: v !call Log_4('ReserveMudVolumeChanged=', v) - MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! update from student input + data%State%MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! update from student input end subroutine subroutine ReserveDensityChanged(v) @@ -2517,7 +2526,7 @@ module MudSystemModule implicit none real(8), intent (in) :: v !call Log_4('ReserveDensityChanged=', v) - MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! update from student input + data%State%MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! update from student input end subroutine ! subroutine SetupMudSystem() @@ -2692,7 +2701,7 @@ module MudSystemModule end subroutine subroutine WhenPathOpen(valves) - use Pumps_VARIABLES + use ConfigurationVariables implicit none integer, allocatable, intent (in) :: valves(:) integer :: first, last @@ -2709,9 +2718,9 @@ module MudSystemModule first = 1 last = size(valves) - MP1_Q = PUMP(1)%Flow_Rate - MP2_Q = PUMP(2)%Flow_Rate - MP3_Q = PUMP(3)%Flow_Rate + MP1_Q = data%State%Pump(1)%Flow_Rate + MP2_Q = data%State%Pump(2)%Flow_Rate + MP3_Q = data%State%Pump(3)%Flow_Rate @@ -2979,7 +2988,7 @@ module MudSystemModule !Mp1_NoPath= 0 condition32 = .false. endif - MudSystem%condition32Final = condition32 + data%State%MudSystem%condition32Final = condition32 !================================================ @@ -2989,7 +2998,7 @@ module MudSystemModule !Mp2_NoPath= 0 condition33 = .false. endif - MudSystem%condition33Final= condition33 + data%State%MudSystem%condition33Final= condition33 !================================================ @@ -2998,7 +3007,7 @@ module MudSystemModule !Cp_NoPath= 1 condition34 = .false. endif - MudSystem%condition34Final = condition34 + data%State%MudSystem%condition34Final = condition34 !================================================ diff --git a/Equipments/MudSystem/MudSystemStartup.f90 b/Equipments/MudSystem/MudSystemStartup.f90 index 3a09bf9..bddd079 100644 --- a/Equipments/MudSystem/MudSystemStartup.f90 +++ b/Equipments/MudSystem/MudSystemStartup.f90 @@ -1,13 +1,15 @@ SUBROUTINE NormalCirculation_StartUp() ! is called in module FluidFlowMain USE MudSystemVARIABLES - use CTanksVariables +use ConfigurationVariables !@@@ + use CTanks + use ConfigurationVariables USE CMudPropertiesVariables Use GeoElements_FluidModule use KickVARIABLESModule Use CUnityOutputs Use CShoeVariables - USE Pumps_VARIABLES + use ConfigurationVariables implicit none @@ -20,88 +22,88 @@ !Pump2BlownStarted = .FALSE. !Pump3BlownStarted = .FALSE. - MudSystem%Pump1BlownCount = 0 - MudSystem%Pump2BlownCount = 0 - MudSystem%Pump3BlownCount = 0 + data%State%MudSystem%Pump1BlownCount = 0 + data%State%MudSystem%Pump2BlownCount = 0 + data%State%MudSystem%Pump3BlownCount = 0 -MudSystem%DeltaWellCap=0. -MudSystem%WellCapOld = 0. -MudSystem%AnnCapOld=0. -MudSystem%DeltaAnnCap=0. +data%State%MudSystem%DeltaWellCap=0. +data%State%MudSystem%WellCapOld = 0. +data%State%MudSystem%AnnCapOld=0. +data%State%MudSystem%DeltaAnnCap=0. -MPumps%Total_Stroke_Counter_For_Plot = 0.0 +data%State%MPumps%Total_Stroke_Counter_For_Plot = 0.0 - MudSystem%DeltaT_Mudline=0.1 !second + data%State%MudSystem%DeltaT_Mudline=0.1 !second Call Set_FlowKellyDisconnect(.false.) Call Set_FlowPipeDisconnect(.false.) !HZ_ADD= 0.d0 -MudSystem%Flow_timeCounter= 0 -MudSystem%MudSys_timeCounter= 0 -MudSystem%FluidFlowCounter = 0 +data%State%MudSystem%Flow_timeCounter= 0 +data%State%MudSystem%MudSys_timeCounter= 0 +data%State%MudSystem%FluidFlowCounter = 0 !======================================================================== ! MUD CIRCULATION STARTUP !======================================================================== - MudSystem%FormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth - MudSystem%ShoeFractured= .false. + data%State%MudSystem%FormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth + data%State%MudSystem%ShoeFractured= .false. - MudSystem%UGBOSuccessionCounter = 0 ! also in starup - MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup + data%State%MudSystem%UGBOSuccessionCounter = 0 ! also in starup + data%State%MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup - MudSystem%ChokeLineFlowRate= 0.0 - MudSystem%StringFlowRate= 0.0 - MudSystem%AnnulusFlowRate= 0.0 + data%State%MudSystem%ChokeLineFlowRate= 0.0 + data%State%MudSystem%StringFlowRate= 0.0 + data%State%MudSystem%AnnulusFlowRate= 0.0 - MudSystem%MudVolume_InjectedFromAnn= 0.D0 - MudSystem%MudVolume_InjectedToBH= 0.D0 + data%State%MudSystem%MudVolume_InjectedFromAnn= 0.D0 + data%State%MudSystem%MudVolume_InjectedToBH= 0.D0 - MudSystem%DensityMixTol= 0.1 !(ppg) - MudSystem%CuttingDensityMixTol= 0.5 - MudSystem%NewPipeFilling= 1 - MudSystem%UtubeFilling= 1 - MudSystem%UtubeEmptyVolume= 0.0 + data%State%MudSystem%DensityMixTol= 0.1 !(ppg) + data%State%MudSystem%CuttingDensityMixTol= 0.5 + data%State%MudSystem%NewPipeFilling= 1 + data%State%MudSystem%UtubeFilling= 1 + data%State%MudSystem%UtubeEmptyVolume= 0.0 - MudSystem%UtubeMode1Activated= .false. - MudSystem%UtubeMode2Activated= .false. - MudSystem%UtubePossibility= .false. + data%State%MudSystem%UtubeMode1Activated= .false. + data%State%MudSystem%UtubeMode2Activated= .false. + data%State%MudSystem%UtubePossibility= .false. !KickMigration_2SideBit = .FALSE. - MudSystem%KickDx= (Reservoir%AutoMigrationRate/3600.)*MudSystem%DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline + data%State%MudSystem%KickDx= (Reservoir%AutoMigrationRate/3600.)*data%State%MudSystem%DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline - MudSystem%NewInfluxElementCreated= 0 - MudSystem%NewInfluxNumber= 0 + data%State%MudSystem%NewInfluxElementCreated= 0 + data%State%MudSystem%NewInfluxNumber= 0 !KickVolumeinAnnulus= 0.0 - MudSystem%KickDeltaVinAnnulus= 0.0 + data%State%MudSystem%KickDeltaVinAnnulus= 0.0 KickVARIABLES%GasKickPumpFlowRate= 0.0 - MudSystem%FirstMudSet= 0 - MudSystem%FirstSetUtube1=0 - MudSystem%FirstSetUtube2=0 - MudSystem%SuctionMud=1 - MudSystem%ImudCount= 1 + data%State%MudSystem%FirstMudSet= 0 + data%State%MudSystem%FirstSetUtube1=0 + data%State%MudSystem%FirstSetUtube2=0 + data%State%MudSystem%SuctionMud=1 + data%State%MudSystem%ImudCount= 1 imud=1 - MudSystem%iLoc= 1 ! for Kick + data%State%MudSystem%iLoc= 1 ! for Kick - MudSystem%Suction_Density_MudSystem= MudProperties%ActiveDensity - MudSystem%SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystem%StringDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystem%AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystem%ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + data%State%MudSystem%Suction_Density_MudSystem= MudProperties%ActiveDensity + data%State%MudSystem%SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + data%State%MudSystem%StringDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + data%State%MudSystem%AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg) + data%State%MudSystem%ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg) - MudSystem%TotalAddedVolume= 0. + data%State%MudSystem%TotalAddedVolume= 0. - MudSystem%xx=0. + data%State%MudSystem%xx=0. @@ -116,12 +118,17 @@ MudSystem%FluidFlowCounter = 0 SUBROUTINE MudSystem_StartUp() USE CMudPropertiesVariables USE MudSystemVARIABLES - USE CDataDisplayConsoleVariables +use ConfigurationVariables !@@@ + use CDataDisplayConsole + use ConfigurationVariables USE CHOKEVARIABLES - USE Pumps_VARIABLES +use ConfigurationVariables !@ + use ConfigurationVariables USE CBopStackVariables - USE CPumpsVariables - use CTanksVariables + use CPumpsVariables + use CPumps + use CTanks + use ConfigurationVariables use KickVARIABLESModule implicit none @@ -131,128 +138,129 @@ MudSystem%FluidFlowCounter = 0 CALL MUDLINE_LOSS_INPUTS() -!MPumps%Total_Pump_GPM=10. ! Initial Value - MUD%Q=0. ! Initial Value +!data%State%MPumps%Total_Pump_GPM=10. ! Initial Value - MudSystem%Q_flow32=0. - MudSystem%Q_flow33=0. - MudSystem%Q_flow34=0. - MudSystem%Q_flow35=0. + data%State%MUD%Q=0. ! Commented by mahmood - MudSystem%DeltaT_Mudline=0.1 !second + data%State%MudSystem%Q_flow32=0. + data%State%MudSystem%Q_flow33=0. + data%State%MudSystem%Q_flow34=0. + data%State%MudSystem%Q_flow35=0. + + data%State%MudSystem%DeltaT_Mudline=0.1 !second KickVARIABLES%GasKickPumpFlowRate= 0. - MudSystem%BellNippleVolume= 0. - MudSystem%BellNippleDensity= 0. - MudSystem%MudBucketVolume= 0. - MudSystem%MudBucketDensity= 0. - MudSystem%BellNippleDumpVolume= 0. + data%State%MudSystem%BellNippleVolume= 0. + data%State%MudSystem%BellNippleDensity= 0. + data%State%MudSystem%MudBucketVolume= 0. + data%State%MudSystem%MudBucketDensity= 0. + data%State%MudSystem%BellNippleDumpVolume= 0. !BellNippleDumpRate= 0. !BellNippleToPitsRate= 0.0 - MudSystem%MudChecked= .true. + data%State%MudSystem%MudChecked= .true. - MudSystem%condition32Final= .TRUE. - MudSystem%condition33Final= .TRUE. - MudSystem%condition34Final= .TRUE. + data%State%MudSystem%condition32Final= .TRUE. + data%State%MudSystem%condition33Final= .TRUE. + data%State%MudSystem%condition34Final= .TRUE. -MudSystem%PressureGauge75= 0.0 -MudSystem%PressureGauge76 = 0.0 +data%State%MudSystem%PressureGauge75= 0.0 +data%State%MudSystem%PressureGauge76 = 0.0 !!====================================================================== !! TRIP TANK !!====================================================================== - MudSystem%TripTank_MinVol_Allowded= 50.*42. !(bbl to gal, initial value) - MudSystem%TripTank_MaxVol_Allowded= 50. *42. !(bbl to gal, initial value) + data%State%MudSystem%TripTank_MinVol_Allowded= 50.*42. !(bbl to gal, initial value) + data%State%MudSystem%TripTank_MaxVol_Allowded= 50. *42. !(bbl to gal, initial value) -MudSystem%ActiveTankFloorArea= (MudProperties%ActiveTotalTankCapacityGal) / (7.48051948*100./12.) ! (ft^2) - Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 -MudSystem%TripTankFloorArea= (50.*42.) / (7.48051948*100./12.) ! (ft^2) - 50.*42.=Trip Tank Capacity in BBl*42= Gal , Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 +data%State%MudSystem%ActiveTankFloorArea= (MudProperties%ActiveTotalTankCapacityGal) / (7.48051948*100./12.) ! (ft^2) - Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 +data%State%MudSystem%TripTankFloorArea= (50.*42.) / (7.48051948*100./12.) ! (ft^2) - 50.*42.=Trip Tank Capacity in BBl*42= Gal , Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3 -MudSystem%TripTank_Vol= MudProperties%InitialTripTankMudVolumeGal !(gal) -MudSystem%TripTank_Dens= 1. -DataDisplayConsole%TripTankGauge=0. +data%State%MudSystem%TripTank_Vol= MudProperties%InitialTripTankMudVolumeGal !(gal) +data%State%MudSystem%TripTank_Dens= 1. +data%EquipmentControl%DataDisplayConsole%TripTankGauge=0. -MudSystem%ReturnToTrip_Q= 1. -MudSystem%ActiveToTrip_Q= 1. +data%State%MudSystem%ReturnToTrip_Q= 1. +data%State%MudSystem%ActiveToTrip_Q= 1. -MudSystem%TripTankPump_Q= .8 +data%State%MudSystem%TripTankPump_Q= .8 -MudSystem%ReturnToTrip_Dens=1.0 ! ppg(lbm/gal) -MudSystem%ActiveToTrip_Dens=1.0 +data%State%MudSystem%ReturnToTrip_Dens=1.0 ! ppg(lbm/gal) +data%State%MudSystem%ActiveToTrip_Dens=1.0 !!====================================================================== !! MUD VOLUME TOTALIZER !!====================================================================== -MudSystem%Mp1Density= 0.0 !(VALVE82) -MudSystem%Mp2Density= 0.0 !(VALVE83) -MudSystem%Mp3Density= 0.0 !(VALVE84) +data%State%MudSystem%Mp1Density= 0.0 !(VALVE82) +data%State%MudSystem%Mp2Density= 0.0 !(VALVE83) +data%State%MudSystem%Mp3Density= 0.0 !(VALVE84) -MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! initial volume (gal) -MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! initial +data%State%MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! initial volume (gal) +data%State%MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! initial -MudSystem%CementTankVolumeCalc= Tank%CementTankVolume !movaghat--- initial volume (gal) -MudSystem%CementTankDensityCalc= Tank%CementTankDensity !movaghat--- initial +data%State%MudSystem%CementTankVolumeCalc= data%EquipmentControl%Tank%CementTankVolume !movaghat--- initial volume (gal) +data%State%MudSystem%CementTankDensityCalc= data%EquipmentControl%Tank%CementTankDensity !movaghat--- initial -MudSystem%PumpsDumpVolume=0.0 -MudSystem%PumpsDumpFlowRate= 0.0 +data%State%MudSystem%PumpsDumpVolume=0.0 +data%State%MudSystem%PumpsDumpFlowRate= 0.0 -MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! initial volume (gal) -MudSystem%RefrencePitVolume= MudSystem%ActiveTankVolume/42. !(bbl) -MudSystem%RefrencePitVolume_DrillWatch= MudSystem%ActiveTankVolume/42. !(bbl) +data%State%MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! initial volume (gal) +data%State%MudSystem%RefrencePitVolume= data%State%MudSystem%ActiveTankVolume/42. !(bbl) +data%State%MudSystem%RefrencePitVolume_DrillWatch= data%State%MudSystem%ActiveTankVolume/42. !(bbl) -MudSystem%MVT_MinVol_Allowded= 0. -MudSystem%MVT_MaxVol_Allowded= 0. +data%State%MudSystem%MVT_MinVol_Allowded= 0. +data%State%MudSystem%MVT_MaxVol_Allowded= 0. -MudSystem%MudTank1_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudSystem%MudTank2_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudSystem%MudTank3_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) -MudSystem%ActiveTankSettled= MudProperties%ActiveSettledContentsGal ! (gal) -MudSystem%MudTank4_vol= MudProperties%InitialTripTankMudVolumeGal ! (gal) +data%State%MudSystem%MudTank1_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) +data%State%MudSystem%MudTank2_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) +data%State%MudSystem%MudTank3_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal) +data%State%MudSystem%ActiveTankSettled= MudProperties%ActiveSettledContentsGal ! (gal) +data%State%MudSystem%MudTank4_vol= MudProperties%InitialTripTankMudVolumeGal ! (gal) -MudSystem%TripTankVolumeCalc= MudProperties%InitialTripTankMudVolumeGal ! initial volume (gal) -MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! initial(ppg) -MudSystem%TripTankDensityCalc= Tank%TripTankDensity ! initial(ppg) +data%State%MudSystem%TripTankVolumeCalc= MudProperties%InitialTripTankMudVolumeGal ! initial volume (gal) +data%State%MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! initial(ppg) +data%State%MudSystem%TripTankDensityCalc= data%EquipmentControl%Tank%TripTankDensity ! initial(ppg) -MudSystem%ChokeManifoldDumpVolume= 0.0 +data%State%MudSystem%ChokeManifoldDumpVolume= 0.0 -MudSystem%PitGainLossZero= 0. -MudSystem%PitGainLossZero_Old= MudSystem%PitGainLossZero -MudSystem%MVTCoarseKnob_Old= DataDisplayConsole%MVTCoarseKnob -MudSystem%MVTFineKnob_Old= DataDisplayConsole%MVTFineKnob -MudSystem%FirstSet_Time= .true. +data%State%MudSystem%PitGainLossZero= 0. +data%State%MudSystem%PitGainLossZero_Old= data%State%MudSystem%PitGainLossZero +data%State%MudSystem%MVTCoarseKnob_Old= data%EquipmentControl%DataDisplayConsole%MVTCoarseKnob +data%State%MudSystem%MVTFineKnob_Old= data%EquipmentControl%DataDisplayConsole%MVTFineKnob +data%State%MudSystem%FirstSet_Time= .true. -MudSystem%PedalMeter= MudProperties%PedalFlowMeter !1600. !(gpm) -MudSystem%ReturnFlowRate=0. +data%State%MudSystem%PedalMeter= MudProperties%PedalFlowMeter !1600. !(gpm) +data%State%MudSystem%ReturnFlowRate=0. - MudSystem%TotalStrokes1MFFI =0. - MudSystem%TotalStrokes2MFFI =0. + data%State%MudSystem%TotalStrokes1MFFI =0. + data%State%MudSystem%TotalStrokes2MFFI =0. - MudSystem%TotalStrokesPump1=0. - MudSystem%TotalStrokesPump2=0. - MudSystem%GraphTotalStrokes=0. + data%State%MudSystem%TotalStrokesPump1=0. + data%State%MudSystem%TotalStrokesPump2=0. + data%State%MudSystem%GraphTotalStrokes=0. - Choke%TotalStrokes1 =0. - Choke%TotalStrokes2 =0. + data%State%Choke%TotalStrokes1 =0. + data%State%Choke%TotalStrokes2 =0. @@ -273,8 +281,10 @@ MudSystem%ReturnFlowRate=0. SUBROUTINE MUDLINE_LOSS_INPUTS() USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE CBopStackVariables -USE CPumpsVariables +use CPumpsVariables + use CPumps implicit none INTEGER I @@ -284,71 +294,71 @@ INTEGER I ! MUDLINE MINOR LOSSES INPUT !=========================================================================== -MudSystem%NO_MudMinors=4 +data%State%MudSystem%NO_MudMinors=4 -ALLOCATE (MudSystem%MudMinors(MudSystem%NO_MudMinors,4)) +ALLOCATE (data%State%MudSystem%MudMinors(data%State%MudSystem%NO_MudMinors,4)) ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION -MudSystem%MudMinors(1,1)= PumpsSpecification%MudPump1Output -MudSystem%MudMinors(1,2:4)= (/1.5*8., 0., 0./) !elbow (MLnumber=1,,PumpsToString) -MudSystem%MudMinors(2,1)= PumpsSpecification%MudPump1Output -MudSystem%MudMinors(2,2:4)= (/1.5*6., 0., 0./) !elbow (MLnumber=2,,STGaugeToString) -MudSystem%MudMinors(3,1:4)= (/0., 0., 0., 0./) !elbow (MLnumber=3,,WellToPits) -MudSystem%MudMinors(4,1)= BopStackSpecification%ChokeLineId -MudSystem%MudMinors(4,2:4)= (/1.5*7., 0., 0./) !elbow (MLnumber=4,,WellToChokeManifold) +data%State%MudSystem%MudMinors(1,1)= PumpsSpecification%MudPump1Output +data%State%MudSystem%MudMinors(1,2:4)= (/1.5*8., 0., 0./) !elbow (MLnumber=1,,PumpsToString) +data%State%MudSystem%MudMinors(2,1)= PumpsSpecification%MudPump1Output +data%State%MudSystem%MudMinors(2,2:4)= (/1.5*6., 0., 0./) !elbow (MLnumber=2,,STGaugeToString) +data%State%MudSystem%MudMinors(3,1:4)= (/0., 0., 0., 0./) !elbow (MLnumber=3,,WellToPits) +data%State%MudSystem%MudMinors(4,1)= BopStackSpecification%ChokeLineId +data%State%MudSystem%MudMinors(4,2:4)= (/1.5*7., 0., 0./) !elbow (MLnumber=4,,WellToChokeManifold) -ALLOCATE (MudSystem%MINORDIAMETER_MUDLINE(MudSystem%NO_MudMinors),MudSystem%AREAMINOR_MUDLINE(MudSystem%NO_MudMinors),MudSystem%LF_MUDLINE(MudSystem%NO_MudMinors),MudSystem%CV_MUDLINE(MudSystem%NO_MudMinors) & - ,MudSystem%NOTE_MUDLINE(MudSystem%NO_MudMinors)) +ALLOCATE (data%State%MudSystem%MINORDIAMETER_MUDLINE(data%State%MudSystem%NO_MudMinors),data%State%MudSystem%AREAMINOR_MUDLINE(data%State%MudSystem%NO_MudMinors),data%State%MudSystem%LF_MUDLINE(data%State%MudSystem%NO_MudMinors),data%State%MudSystem%CV_MUDLINE(data%State%MudSystem%NO_MudMinors) & + ,data%State%MudSystem%NOTE_MUDLINE(data%State%MudSystem%NO_MudMinors)) -DO I=1,MudSystem%NO_MudMinors - MudSystem%MINORDIAMETER_MUDLINE(I)=MudSystem%MudMinors(I,1) - MudSystem%LF_MUDLINE(I)=MudSystem%MudMinors(I,2) - MudSystem%CV_MUDLINE(I)=MudSystem%MudMinors(I,3) - MudSystem%NOTE_MUDLINE(I)=MudSystem%MudMinors(I,4) +DO I=1,data%State%MudSystem%NO_MudMinors + data%State%MudSystem%MINORDIAMETER_MUDLINE(I)=data%State%MudSystem%MudMinors(I,1) + data%State%MudSystem%LF_MUDLINE(I)=data%State%MudSystem%MudMinors(I,2) + data%State%MudSystem%CV_MUDLINE(I)=data%State%MudSystem%MudMinors(I,3) + data%State%MudSystem%NOTE_MUDLINE(I)=data%State%MudSystem%MudMinors(I,4) - MudSystem%AREAMINOR_MUDLINE(I)=PII*(MudSystem%MINORDIAMETER_MUDLINE(I)*0.0254)**2/4. !D(in), AREA(m^2) + data%State%MudSystem%AREAMINOR_MUDLINE(I)=PII*(data%State%MudSystem%MINORDIAMETER_MUDLINE(I)*0.0254)**2/4. !D(in), AREA(m^2) ENDDO !=========================================================================== ! MUDLINE PIPNING LOSSES INPUT !=========================================================================== -MudSystem%NO_PIPINGSMUDLINE=4 +data%State%MudSystem%NO_PIPINGSMUDLINE=4 -ALLOCATE (MudSystem%PIPINGS_MUDLINE(MudSystem%NO_PIPINGSMUDLINE,3)) +ALLOCATE (data%State%MudSystem%PIPINGS_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE,3)) ! ID(INCH) L(FEET) ROUGHNESS(MM)=e DESCRIPTION -MudSystem%PIPINGS_MUDLINE(1,1)= PumpsSpecification%MudPump1Output -MudSystem%PIPINGS_MUDLINE(1,2:3)= (/265., 0.03/) !(MLnumber=1,,PumpsToString) -MudSystem%PIPINGS_MUDLINE(2,1)= PumpsSpecification%MudPump1Output -MudSystem%PIPINGS_MUDLINE(2,2:3)= (/100., 0.03/) !(MLnumber=2,,STGaugeToString) -MudSystem%PIPINGS_MUDLINE(3,1:3)= (/0., 0., 0./) !(MLnumber=3,,WellToPits) -MudSystem%PIPINGS_MUDLINE(4,1)= BopStackSpecification%ChokeLineId -MudSystem%PIPINGS_MUDLINE(4,2)= BopStackSpecification%ChokeLineLength -MudSystem%PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold) +data%State%MudSystem%PIPINGS_MUDLINE(1,1)= PumpsSpecification%MudPump1Output +data%State%MudSystem%PIPINGS_MUDLINE(1,2:3)= (/265., 0.03/) !(MLnumber=1,,PumpsToString) +data%State%MudSystem%PIPINGS_MUDLINE(2,1)= PumpsSpecification%MudPump1Output +data%State%MudSystem%PIPINGS_MUDLINE(2,2:3)= (/100., 0.03/) !(MLnumber=2,,STGaugeToString) +data%State%MudSystem%PIPINGS_MUDLINE(3,1:3)= (/0., 0., 0./) !(MLnumber=3,,WellToPits) +data%State%MudSystem%PIPINGS_MUDLINE(4,1)= BopStackSpecification%ChokeLineId +data%State%MudSystem%PIPINGS_MUDLINE(4,2)= BopStackSpecification%ChokeLineLength +data%State%MudSystem%PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold) -MudSystem%Area_ChokeLineFt= PII*((BopStackSpecification%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2) -MudSystem%ChokeLine_VolumeCapacity= MudSystem%Area_ChokeLineFt* BopStackSpecification%ChokeLineLength* 7.48051948 ! (gal) +data%State%MudSystem%Area_ChokeLineFt= PII*((BopStackSpecification%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2) +data%State%MudSystem%ChokeLine_VolumeCapacity= data%State%MudSystem%Area_ChokeLineFt* BopStackSpecification%ChokeLineLength* 7.48051948 ! (gal) - ALLOCATE (MudSystem%DIAM_MUDLINE_INCH(MudSystem%NO_PIPINGSMUDLINE), & - MudSystem%AREA_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%LENGT_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%ROUGHNESS_MUDLINE(MudSystem%NO_PIPINGSMUDLINE),MudSystem%RELROUGH_MUDLINE(MudSystem%NO_PIPINGSMUDLINE)) + ALLOCATE (data%State%MudSystem%DIAM_MUDLINE_INCH(data%State%MudSystem%NO_PIPINGSMUDLINE), & + data%State%MudSystem%AREA_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE),data%State%MudSystem%LENGT_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE),data%State%MudSystem%ROUGHNESS_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE),data%State%MudSystem%RELROUGH_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE)) -DO I=1,MudSystem%NO_PIPINGSMUDLINE - MudSystem%DIAM_MUDLINE_INCH(I)=MudSystem%PIPINGS_MUDLINE(I,1) - MudSystem%LENGT_MUDLINE(I)=MudSystem%PIPINGS_MUDLINE(I,2) - MudSystem%ROUGHNESS_MUDLINE(I)=MudSystem%PIPINGS_MUDLINE(I,3) +DO I=1,data%State%MudSystem%NO_PIPINGSMUDLINE + data%State%MudSystem%DIAM_MUDLINE_INCH(I)=data%State%MudSystem%PIPINGS_MUDLINE(I,1) + data%State%MudSystem%LENGT_MUDLINE(I)=data%State%MudSystem%PIPINGS_MUDLINE(I,2) + data%State%MudSystem%ROUGHNESS_MUDLINE(I)=data%State%MudSystem%PIPINGS_MUDLINE(I,3) - MudSystem%AREA_MUDLINE(I)=PII*(MudSystem%DIAM_MUDLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m^2) - MudSystem%RELROUGH_MUDLINE(I)=MudSystem%ROUGHNESS_MUDLINE(I)/(MudSystem%DIAM_MUDLINE_INCH(I)*25.4) !e/D + data%State%MudSystem%AREA_MUDLINE(I)=PII*(data%State%MudSystem%DIAM_MUDLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m^2) + data%State%MudSystem%RELROUGH_MUDLINE(I)=data%State%MudSystem%ROUGHNESS_MUDLINE(I)/(data%State%MudSystem%DIAM_MUDLINE_INCH(I)*25.4) !e/D !DIAM_MUDLINE_MM(I)=DIAM_MUDLINE_MM(I)*.001 ! (m) - MudSystem%LENGT_MUDLINE(I)=MudSystem%LENGT_MUDLINE(I)*.3048 ! (m) + data%State%MudSystem%LENGT_MUDLINE(I)=data%State%MudSystem%LENGT_MUDLINE(I)*.3048 ! (m) ENDDO @@ -357,11 +367,11 @@ ENDDO !=========================================================================== ! Height are in (meter) -MudSystem%Pumps_Height= 0. -MudSystem%STpipeGauge_Height= 2. !(m) -MudSystem%Pits_Height= 1. !(m) -MudSystem%ChokeManifold_Height= 1.*0.3048 !(ft to meter) -MudSystem%WellChokeExit_Height= BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight +data%State%MudSystem%Pumps_Height= 0. +data%State%MudSystem%STpipeGauge_Height= 2. !(m) +data%State%MudSystem%Pits_Height= 1. !(m) +data%State%MudSystem%ChokeManifold_Height= 1.*0.3048 !(ft to meter) +data%State%MudSystem%WellChokeExit_Height= BopStackSpecification%GroundLevel-BopStackSpecification%KillHeight @@ -382,56 +392,57 @@ MudSystem%WellChokeExit_Height= BopStackSpecification%GroundLevel-BopStackSpecif SUBROUTINE MUDLINE_LOSSES(MLnumber) - USE MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none integer I INTEGER MLnumber !===============================PIPE LOSS=================================== - MUD(MLnumber)%Re_MUDline=MUD(MLnumber)%Q*6.30902e-5*MudSystem%DIAM_MUDLINE_INCH(MLnumber)*0.0254/(MudSystem%AREA_MUDLINE(MLnumber)*MUD(MLnumber)%nu) !<<<<<< nu: DOROST SHAVAD.ALAN DAR STARTUP SET SHODE -!write(*,*) 'MUD(MLnumber)%Re_MUDline=' , MUD(MLnumber)%Re_MUDline + data%State%MUD(MLnumber)%Re_MUDline=data%State%MUD(MLnumber)%Q*6.30902e-5*data%State%MudSystem%DIAM_MUDLINE_INCH(MLnumber)*0.0254/(data%State%MudSystem%AREA_MUDLINE(MLnumber)*data%State%MUD(MLnumber)%nu) !<<<<<< nu: DOROST SHAVAD.ALAN DAR STARTUP SET SHODE +!write(*,*) 'data%State%MUD(MLnumber)%Re_MUDline=' , data%State%MUD(MLnumber)%Re_MUDline ! Q*6.30902e-5 for (gpm) to (m^3/sec) - if ( MUD(MLnumber)%Re_MUDlineStandPipePressure + USE CHOKEVARIABLES +!use ConfigurationVariables !@ + !use CDataDisplayConsole + !@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES + use ConfigurationVariables !@ + USE CHOKEVARIABLES +!use ConfigurationVariables !@ !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity + use ConfigurationVariables + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule - USE CKellyConnectionEnumVariables + use OperationScenariosModule use UTUBEVARSModule + use DownHoleModule use CLog1 Use CError Use , intrinsic :: IEEE_Arithmetic @@ -30,28 +37,28 @@ subroutine PlotFinalMudElements ! is called in subroutine CirculationCodeSel - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - write(*,*) 'well cap=' , sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - MudSystem%DeltaWellCap= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - MudSystem%WellCapOld - MudSystem%WellCapOld= sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) + sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - write(*,*) 'cap_reset,DeltaWellCap=' , MudSystem%DeltaWellCap + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + write(*,*) 'well cap=' , sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) + data%State%MudSystem%DeltaWellCap= sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) - data%State%MudSystem%WellCapOld + data%State%MudSystem%WellCapOld= sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) + write(*,*) 'cap_reset,DeltaWellCap=' , data%State%MudSystem%DeltaWellCap endif !========================ANNULUS END================= -if ((MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) > 0.8 .or. MudSystem%Ann_Density%Last()==0.0) then ! for Line (BellNippleToWell-NonFullWell) - MudSystem%WellisNOTFull= .true. +if ((data%State%MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight) > 0.8 .or. data%State%MudSystem%Ann_Density%Last()==0.0) then ! for Line (BellNippleToWell-NonFullWell) + data%State%MudSystem%WellisNOTFull= .true. else - MudSystem%WellisNOTFull= .false. + data%State%MudSystem%WellisNOTFull= .false. endif !WRITE(*,*) 'Ann_Mud_Forehead_X%Last() , KillHeight', Ann_Mud_Forehead_X%Last() , KillHeight -if ((MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%KillHeight)>0.8 .or. MudSystem%Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26) - MudSystem%ChokeLineNOTFull= .true. +if ((data%State%MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%KillHeight)>0.8 .or. data%State%MudSystem%Ann_Density%Last()==0.0) then ! for Line j4 , WellToChokeManifold(Through 26) + data%State%MudSystem%ChokeLineNOTFull= .true. else - MudSystem%ChokeLineNOTFull= .false. + data%State%MudSystem%ChokeLineNOTFull= .false. endif !========================================================= @@ -62,33 +69,33 @@ endif - call MudSystem%Xend_MudElement%Empty() - call MudSystem%TVDend_MudElement%Empty() - call MudSystem%Density_MudElement%Empty() - call MudSystem%MudGeoType%Empty() - call MudSystem%PipeID_MudElement%Empty() - call MudSystem%PipeOD_MudElement%Empty() + call data%State%MudSystem%Xend_MudElement%Empty() + call data%State%MudSystem%TVDend_MudElement%Empty() + call data%State%MudSystem%Density_MudElement%Empty() + call data%State%MudSystem%MudGeoType%Empty() + call data%State%MudSystem%PipeID_MudElement%Empty() + call data%State%MudSystem%PipeOD_MudElement%Empty() !call Angle_MudElement%Empty() - call MudSystem%MudType_MudElement%Empty() + call data%State%MudSystem%MudType_MudElement%Empty() - DO WHILE(jmud <= MudSystem%Hz_Mud_Forehead_X%Length() .and. jsection<=1) + DO WHILE(jmud <= data%State%MudSystem%Hz_Mud_Forehead_X%Length() .and. jsection<=1) jelement= jelement+1 - MudSystem%TrueMinValue= min(MudSystem%Hz_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) + data%State%MudSystem%TrueMinValue= min(data%State%MudSystem%Hz_Mud_Forehead_X%Array(jmud), data%State%MudSystem%Xend_PipeSection(jsection)) - call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_MudElement%Add(MudSystem%Hz_Density%Array(jmud)) - call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) - call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) + call data%State%MudSystem%Xend_MudElement%Add(data%State%MudSystem%TrueMinValue) + call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDend_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%Density_MudElement%Add(data%State%MudSystem%Hz_Density%Array(jmud)) + call data%State%MudSystem%PipeID_MudElement%Add(data%State%MudSystem%ID_PipeSectionInch(jsection)) + call data%State%MudSystem%PipeOD_MudElement%Add(data%State%MudSystem%OD_PipeSectionInch(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudSystem%MudType_MudElement%Add(MudSystem%Hz_MudOrKick%Array(jmud)) + call data%State%MudSystem%MudType_MudElement%Add(data%State%MudSystem%Hz_MudOrKick%Array(jmud)) - if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%Hz_Mud_Forehead_X%Array(jmud)) then + if (data%State%MudSystem%Xend_MudElement%Array(jelement)== data%State%MudSystem%Hz_Mud_Forehead_X%Array(jmud)) then jmud= jmud+1 else jsection= jsection+1 @@ -96,7 +103,7 @@ endif ENDDO - MudSystem%NoHorizontalMudElements= jelement + data%State%MudSystem%NoHorizontalMudElements= jelement @@ -104,22 +111,22 @@ endif jmud= 1 jsection= 2 - DO WHILE(jmud <= MudSystem%St_Mud_Forehead_X%Length() .and. jsection<=F_Counts%StringIntervalCounts) + DO WHILE(jmud <= data%State%MudSystem%St_Mud_Forehead_X%Length() .and. jsection<=data%State%F_Counts%StringIntervalCounts) jelement= jelement+1 - MudSystem%TrueMinValue= min(MudSystem%St_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) + data%State%MudSystem%TrueMinValue= min(data%State%MudSystem%St_Mud_Forehead_X%Array(jmud), data%State%MudSystem%Xend_PipeSection(jsection)) - call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_MudElement%Add(MudSystem%St_Density%Array(jmud)) - call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) - call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) + call data%State%MudSystem%Xend_MudElement%Add(data%State%MudSystem%TrueMinValue) + call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDend_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%Density_MudElement%Add(data%State%MudSystem%St_Density%Array(jmud)) + call data%State%MudSystem%PipeID_MudElement%Add(data%State%MudSystem%ID_PipeSectionInch(jsection)) + call data%State%MudSystem%PipeOD_MudElement%Add(data%State%MudSystem%OD_PipeSectionInch(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudSystem%MudType_MudElement%Add(MudSystem%St_MudOrKick%Array(jmud)) + call data%State%MudSystem%MudType_MudElement%Add(data%State%MudSystem%St_MudOrKick%Array(jmud)) - if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%St_Mud_Forehead_X%Array(jmud)) then + if (data%State%MudSystem%Xend_MudElement%Array(jelement)== data%State%MudSystem%St_Mud_Forehead_X%Array(jmud)) then jmud= jmud+1 else jsection= jsection+1 @@ -127,30 +134,30 @@ endif ENDDO - MudSystem%NoStringMudElements= jelement- MudSystem%NoHorizontalMudElements + data%State%MudSystem%NoStringMudElements= jelement- data%State%MudSystem%NoHorizontalMudElements jmud= 1 - jsection= F_Counts%StringIntervalCounts+1 - DO WHILE(jmud<= MudSystem%Ann_Mud_Forehead_X%Length() .and. jsection<=MudSystem%NoPipeSections) + jsection= data%State%F_Counts%StringIntervalCounts+1 + DO WHILE(jmud<= data%State%MudSystem%Ann_Mud_Forehead_X%Length() .and. jsection<=data%State%MudSystem%NoPipeSections) jelement= jelement+1 - MudSystem%TrueMinValue= max(MudSystem%Ann_Mud_Forehead_X%Array(jmud), MudSystem%Xend_PipeSection(jsection)) + data%State%MudSystem%TrueMinValue= max(data%State%MudSystem%Ann_Mud_Forehead_X%Array(jmud), data%State%MudSystem%Xend_PipeSection(jsection)) - call MudSystem%Xend_MudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_MudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_MudElement%Add(MudSystem%Ann_Density%Array(jmud)) - call MudSystem%PipeID_MudElement%Add(MudSystem%ID_PipeSectionInch(jsection)) - call MudSystem%PipeOD_MudElement%Add(MudSystem%OD_PipeSectionInch(jsection)) + call data%State%MudSystem%Xend_MudElement%Add(data%State%MudSystem%TrueMinValue) + call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDend_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%Density_MudElement%Add(data%State%MudSystem%Ann_Density%Array(jmud)) + call data%State%MudSystem%PipeID_MudElement%Add(data%State%MudSystem%ID_PipeSectionInch(jsection)) + call data%State%MudSystem%PipeOD_MudElement%Add(data%State%MudSystem%OD_PipeSectionInch(jsection)) !call Angle_MudElement%Add(Angle_PipeSection(jsection)) - call MudSystem%MudType_MudElement%Add(MudSystem%Ann_MudOrKick%Array(jmud)) + call data%State%MudSystem%MudType_MudElement%Add(data%State%MudSystem%Ann_MudOrKick%Array(jmud)) - if (MudSystem%Xend_MudElement%Array(jelement)== MudSystem%Ann_Mud_Forehead_X%Array(jmud)) then + if (data%State%MudSystem%Xend_MudElement%Array(jelement)== data%State%MudSystem%Ann_Mud_Forehead_X%Array(jmud)) then jmud= jmud+1 else jsection= jsection+1 @@ -158,41 +165,41 @@ endif ENDDO - do i= 2, MudSystem%Xend_MudElement%Length() - if ( i== MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+1) then - call MudSystem%Xstart_MudElement%Add (MudSystem%Ann_Mud_Backhead_X%Array(1)) ! start of annulus - call TVD_Calculator(MudSystem%Ann_Mud_Backhead_X%Array(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) - elseif ( i== MudSystem%NoHorizontalMudElements+1 ) then - call MudSystem%Xstart_MudElement%Add (MudSystem%St_Mud_Backhead_X%Array(1)) ! start of stirng - call TVD_Calculator(MudSystem%St_Mud_Backhead_X%Array(1),MudSystem%MudCircVerticalDepth) - call MudSystem%TVDstart_MudElement%Add(MudSystem%MudCircVerticalDepth) + do i= 2, data%State%MudSystem%Xend_MudElement%Length() + if ( i== data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+1) then + call data%State%MudSystem%Xstart_MudElement%Add (data%State%MudSystem%Ann_Mud_Backhead_X%Array(1)) ! start of annulus + call TVD_Calculator(data%State%MudSystem%Ann_Mud_Backhead_X%Array(1),data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDstart_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth) + elseif ( i== data%State%MudSystem%NoHorizontalMudElements+1 ) then + call data%State%MudSystem%Xstart_MudElement%Add (data%State%MudSystem%St_Mud_Backhead_X%Array(1)) ! start of stirng + call TVD_Calculator(data%State%MudSystem%St_Mud_Backhead_X%Array(1),data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDstart_MudElement%Add(data%State%MudSystem%MudCircVerticalDepth) else - call MudSystem%Xstart_MudElement%Add(MudSystem%Xend_MudElement%Array(i-1)) ! normal calculation - call MudSystem%TVDstart_MudElement%Add(MudSystem%TVDend_MudElement%Array(i-1)) ! normal calculation + call data%State%MudSystem%Xstart_MudElement%Add(data%State%MudSystem%Xend_MudElement%Array(i-1)) ! normal calculation + call data%State%MudSystem%TVDstart_MudElement%Add(data%State%MudSystem%TVDend_MudElement%Array(i-1)) ! normal calculation endif enddo - MudSystem%NoCasingMudElements = jelement- MudSystem%NoStringMudElements- MudSystem%NoHorizontalMudElements + data%State%MudSystem%NoCasingMudElements = jelement- data%State%MudSystem%NoStringMudElements- data%State%MudSystem%NoHorizontalMudElements !=========================For Torque and Drag======================== - if (allocated(MudSystem%TDXstart_MudElementArray)) deallocate(MudSystem%TDXstart_MudElementArray) - allocate(MudSystem%TDXstart_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) - if (allocated(MudSystem%TDXend_MudElementArray)) deallocate(MudSystem%TDXend_MudElementArray) - allocate(MudSystem%TDXend_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) - if (allocated(MudSystem%TDDensity_MudElementArray)) deallocate(MudSystem%TDDensity_MudElementArray) - allocate(MudSystem%TDDensity_MudElementArray(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+MudSystem%NoCasingMudElements)) + if (allocated(data%State%MudSystem%TDXstart_MudElementArray)) deallocate(data%State%MudSystem%TDXstart_MudElementArray) + allocate(data%State%MudSystem%TDXstart_MudElementArray(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+data%State%MudSystem%NoCasingMudElements)) + if (allocated(data%State%MudSystem%TDXend_MudElementArray)) deallocate(data%State%MudSystem%TDXend_MudElementArray) + allocate(data%State%MudSystem%TDXend_MudElementArray(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+data%State%MudSystem%NoCasingMudElements)) + if (allocated(data%State%MudSystem%TDDensity_MudElementArray)) deallocate(data%State%MudSystem%TDDensity_MudElementArray) + allocate(data%State%MudSystem%TDDensity_MudElementArray(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+data%State%MudSystem%NoCasingMudElements)) - MudSystem%TDNoHorizontalMudElements= MudSystem%NoHorizontalMudElements - MudSystem%TDNoStringMudElements= MudSystem%NoStringMudElements - MudSystem%TDNoCasingMudElements= MudSystem%NoCasingMudElements + data%State%MudSystem%TDNoHorizontalMudElements= data%State%MudSystem%NoHorizontalMudElements + data%State%MudSystem%TDNoStringMudElements= data%State%MudSystem%NoStringMudElements + data%State%MudSystem%TDNoCasingMudElements= data%State%MudSystem%NoCasingMudElements - MudSystem%TDXstart_MudElementArray(:) = MudSystem%Xstart_MudElement%Array(:) - MudSystem%TDXend_MudElementArray(:) = MudSystem%Xend_MudElement%Array(:) - MudSystem%TDDensity_MudElementArray(:) = MudSystem%Density_MudElement%Array(:) + data%State%MudSystem%TDXstart_MudElementArray(:) = data%State%MudSystem%Xstart_MudElement%Array(:) + data%State%MudSystem%TDXend_MudElementArray(:) = data%State%MudSystem%Xend_MudElement%Array(:) + data%State%MudSystem%TDDensity_MudElementArray(:) = data%State%MudSystem%Density_MudElement%Array(:) !===================================================================== @@ -210,31 +217,31 @@ endif jopelement= 0 ! number of final mud elements - call MudSystem%Xend_OpMudElement%Empty() - call MudSystem%TVDend_OpMudElement%Empty() - call MudSystem%Density_OpMudElement%Empty() - call MudSystem%PipeID_OpMudElement%Empty() - call MudSystem%PipeOD_OpMudElement%Empty() + call data%State%MudSystem%Xend_OpMudElement%Empty() + call data%State%MudSystem%TVDend_OpMudElement%Empty() + call data%State%MudSystem%Density_OpMudElement%Empty() + call data%State%MudSystem%PipeID_OpMudElement%Empty() + call data%State%MudSystem%PipeOD_OpMudElement%Empty() !call Angle_OpMudElement%Empty() - call MudSystem%MudTypeOp_MudElement%Empty() + call data%State%MudSystem%MudTypeOp_MudElement%Empty() - DO WHILE(jopmud<= MudSystem%Op_Mud_Forehead_X%Length() .and. jopsection<=F_Counts%BottomHoleIntervalCounts) + DO WHILE(jopmud<= data%State%MudSystem%Op_Mud_Forehead_X%Length() .and. jopsection<=data%State%F_Counts%BottomHoleIntervalCounts) jopelement= jopelement+1 - MudSystem%TrueMinValue= max(MudSystem%Op_Mud_Forehead_X%Array(jopmud), MudSystem%Xend_OpSection(jopsection)) - call MudSystem%Xend_OpMudElement%Add(MudSystem%TrueMinValue) - call TVD_Calculator(MudSystem%TrueMinValue,MudSystem%MudCircVerticalDepth) - call MudSystem%TVDend_OpMudElement%Add(MudSystem%MudCircVerticalDepth) - call MudSystem%Density_OpMudElement%Add(MudSystem%Op_Density%Array(jopmud)) - call MudSystem%PipeID_OpMudElement%Add(MudSystem%ID_OpSectionInch(jopsection)) - call MudSystem%PipeOD_OpMudElement%Add(MudSystem%OD_OpSectionInch(jopsection)) + data%State%MudSystem%TrueMinValue= max(data%State%MudSystem%Op_Mud_Forehead_X%Array(jopmud), data%State%MudSystem%Xend_OpSection(jopsection)) + call data%State%MudSystem%Xend_OpMudElement%Add(data%State%MudSystem%TrueMinValue) + call TVD_Calculator(data%State%MudSystem%TrueMinValue,data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%TVDend_OpMudElement%Add(data%State%MudSystem%MudCircVerticalDepth) + call data%State%MudSystem%Density_OpMudElement%Add(data%State%MudSystem%Op_Density%Array(jopmud)) + call data%State%MudSystem%PipeID_OpMudElement%Add(data%State%MudSystem%ID_OpSectionInch(jopsection)) + call data%State%MudSystem%PipeOD_OpMudElement%Add(data%State%MudSystem%OD_OpSectionInch(jopsection)) !call Angle_MudElement%Add(Angle_PipeSection(jopsection)) - call MudSystem%MudTypeOp_MudElement%Add(MudSystem%Op_MudOrKick%Array(jopmud)) + call data%State%MudSystem%MudTypeOp_MudElement%Add(data%State%MudSystem%Op_MudOrKick%Array(jopmud)) - if (MudSystem%Xend_OpMudElement%Array(jopelement)== MudSystem%Op_Mud_Forehead_X%Array(jopmud)) then + if (data%State%MudSystem%Xend_OpMudElement%Array(jopelement)== data%State%MudSystem%Op_Mud_Forehead_X%Array(jopmud)) then jopmud= jopmud+1 else jopsection= jopsection+1 @@ -242,34 +249,34 @@ endif ENDDO - do i= 2, MudSystem%Xend_OpMudElement%Length() - call MudSystem%Xstart_OpMudElement%Add(MudSystem%Xend_OpMudElement%Array(i-1)) - call MudSystem%TVDstart_OpMudElement%Add(MudSystem%TVDend_OpMudElement%Array(i-1)) + do i= 2, data%State%MudSystem%Xend_OpMudElement%Length() + call data%State%MudSystem%Xstart_OpMudElement%Add(data%State%MudSystem%Xend_OpMudElement%Array(i-1)) + call data%State%MudSystem%TVDstart_OpMudElement%Add(data%State%MudSystem%TVDend_OpMudElement%Array(i-1)) enddo - MudSystem%NoBottomHoleMudElements = jopelement + data%State%MudSystem%NoBottomHoleMudElements = jopelement !================================================================ - if(allocated(MudSystem%StringMudElement)) deallocate(MudSystem%StringMudElement) - allocate(MudSystem%StringMudElement(MudSystem%NoStringMudElements)) + if(allocated(data%State%MudSystem%StringMudElement)) deallocate(data%State%MudSystem%StringMudElement) + allocate(data%State%MudSystem%StringMudElement(data%State%MudSystem%NoStringMudElements)) - if(allocated(MudSystem%CasingMudElement)) deallocate(MudSystem%CasingMudElement) - allocate(MudSystem%CasingMudElement(MudSystem%NoCasingMudElements+MudSystem%NoBottomHoleMudElements)) + if(allocated(data%State%MudSystem%CasingMudElement)) deallocate(data%State%MudSystem%CasingMudElement) + allocate(data%State%MudSystem%CasingMudElement(data%State%MudSystem%NoCasingMudElements+data%State%MudSystem%NoBottomHoleMudElements)) - MudSystem%istring=0 - MudSystem%icasing=0 + data%State%MudSystem%istring=0 + data%State%MudSystem%icasing=0 - MudSystem%BitMudDensity= MudSystem%Density_MudElement%Array(MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements) ! (for ROP module) + data%State%MudSystem%BitMudDensity= data%State%MudSystem%Density_MudElement%Array(data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements) ! (for ROP module) !================================================================ !============================ UTUBE ============================= !IF (UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadIsOpen) THEN - IF (MudSystem%UtubePossibility== .true. .and. TD_StConn%FluidStringConnectionMode==0 .and. MudSystem%WellHeadIsOpen .AND. KickVARIABLES%NoGasPocket == 0) THEN + IF (data%State%MudSystem%UtubePossibility== .true. .and. data%State%TD_StConn%FluidStringConnectionMode==0 .and. data%State%MudSystem%WellHeadIsOpen .AND. KickVARIABLES%NoGasPocket == 0) THEN CALL WellPressureDataTransfer !WRITE (*,*) ' U-Tube Done 1' CALL Utube @@ -292,17 +299,17 @@ endif !enddo - IF (ANY(IEEE_Is_NaN(MudSystem%Op_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystem%Op_MudDischarged_Volume%Array(:) <= 0.0)) THEN - do i = 1 , MudSystem%Op_MudOrKick%Length() - write(*,555) i,'Op_Volume(i), type=' ,MudSystem%Op_MudDischarged_Volume%Array(i) , MudSystem%Op_MudOrKick%Array(i) , MudSystem%Op_Density%Array(i) + IF (ANY(IEEE_Is_NaN(data%State%MudSystem%Op_MudDischarged_Volume%Array(:))) .OR. ANY(data%State%MudSystem%Op_MudDischarged_Volume%Array(:) <= 0.0)) THEN + do i = 1 , data%State%MudSystem%Op_MudOrKick%Length() + write(*,555) i,'Op_Volume(i), type=' ,data%State%MudSystem%Op_MudDischarged_Volume%Array(i) , data%State%MudSystem%Op_MudOrKick%Array(i) , data%State%MudSystem%Op_Density%Array(i) end do call ErrorStop('NaN in Op Volume-Plot or Op Volume <=0') END IF - IF (ANY(IEEE_Is_NaN(MudSystem%Ann_MudDischarged_Volume%Array(:))) .OR. ANY(MudSystem%Ann_MudDischarged_Volume%Array(:) <= 0.0)) THEN - do i = 1 , MudSystem%Ann_MudOrKick%Length() - write(*,555) i,'Ann_Volume(i), type=' ,MudSystem%Ann_MudDischarged_Volume%Array(i) , MudSystem%Ann_MudOrKick%Array(i) , MudSystem%Ann_Density%Array(i) + IF (ANY(IEEE_Is_NaN(data%State%MudSystem%Ann_MudDischarged_Volume%Array(:))) .OR. ANY(data%State%MudSystem%Ann_MudDischarged_Volume%Array(:) <= 0.0)) THEN + do i = 1 , data%State%MudSystem%Ann_MudOrKick%Length() + write(*,555) i,'Ann_Volume(i), type=' ,data%State%MudSystem%Ann_MudDischarged_Volume%Array(i) , data%State%MudSystem%Ann_MudOrKick%Array(i) , data%State%MudSystem%Ann_Density%Array(i) end do call ErrorStop('NaN in Ann Volume-Plot or Ann Volume <=0') END IF @@ -316,74 +323,74 @@ endif 555 FORMAT(I3,5X,A42,(f12.5),5X,I3,5X,(f12.5)) - MudSystem%NoStringMudElementsForPlot= MudSystem%NoStringMudElements + data%State%MudSystem%NoStringMudElementsForPlot= data%State%MudSystem%NoStringMudElements ! 1-Horizontal Mud Elements are not shown !write(*,333) 'Horiz:', 1,'Xstart\=', Xstart_MudElement%Array(1), 'Xend=' , Xend_MudElement%Array(1), 'Density=' , Density_MudElement%Array(1), 'MudType=' , MudType_MudElement%Array(1) - do i=MudSystem%NoHorizontalMudElements+1, MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements ! 2-string elements - if (MudSystem%Xend_MudElement%Array(i) <= 0.0) then - MudSystem%NoStringMudElementsForPlot= MudSystem%NoStringMudElementsForPlot-1 + do i=data%State%MudSystem%NoHorizontalMudElements+1, data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements ! 2-string elements + if (data%State%MudSystem%Xend_MudElement%Array(i) <= 0.0) then + data%State%MudSystem%NoStringMudElementsForPlot= data%State%MudSystem%NoStringMudElementsForPlot-1 cycle endif - MudSystem%istring= MudSystem%istring+1 - MudSystem%StringMudElement(MudSystem%istring)%StartMd = MudSystem%Xstart_MudElement%Array(i) - MudSystem%StringMudElement(MudSystem%istring)%EndMd = MudSystem%Xend_MudElement%Array(i) + data%State%MudSystem%istring= data%State%MudSystem%istring+1 + data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%StartMd = data%State%MudSystem%Xstart_MudElement%Array(i) + data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%EndMd = data%State%MudSystem%Xend_MudElement%Array(i) !StringMudElement(istring)%Id = PipeID_MudElement%Array(i) !StringMudElement(istring)%Od = PipeOD_MudElement%Array(i) - MudSystem%StringMudElement(MudSystem%istring)%Density = MudSystem%Density_MudElement%Array(i) + data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%Density = data%State%MudSystem%Density_MudElement%Array(i) - if (MudSystem%MudType_MudElement%Array(i) == 104) then - MudSystem%MudType_MudElement%Array(i)= 4 ! air - elseif (MudSystem%MudType_MudElement%Array(i) > 0 .and. MudSystem%MudType_MudElement%Array(i) < 100) then ! all kicks - MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick + if (data%State%MudSystem%MudType_MudElement%Array(i) == 104) then + data%State%MudSystem%MudType_MudElement%Array(i)= 4 ! air + elseif (data%State%MudSystem%MudType_MudElement%Array(i) > 0 .and. data%State%MudSystem%MudType_MudElement%Array(i) < 100) then ! all kicks + data%State%MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick endif - MudSystem%StringMudElement(MudSystem%istring)%MudType = MudSystem%MudType_MudElement%Array(i) + data%State%MudSystem%StringMudElement(data%State%MudSystem%istring)%MudType = data%State%MudSystem%MudType_MudElement%Array(i) !write(*,333) 'STRING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i) enddo - do i=MudSystem%Xend_MudElement%Length(), MudSystem%NoHorizontalMudElements+MudSystem%NoStringMudElements+1 , -1 ! 3-casing elements - MudSystem%icasing= MudSystem%icasing+1 - MudSystem%CasingMudElement(MudSystem%icasing)%StartMd = MudSystem%Xend_MudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%EndMd = MudSystem%Xstart_MudElement%Array(i) + do i=data%State%MudSystem%Xend_MudElement%Length(), data%State%MudSystem%NoHorizontalMudElements+data%State%MudSystem%NoStringMudElements+1 , -1 ! 3-casing elements + data%State%MudSystem%icasing= data%State%MudSystem%icasing+1 + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%StartMd = data%State%MudSystem%Xend_MudElement%Array(i) + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%EndMd = data%State%MudSystem%Xstart_MudElement%Array(i) !CasingMudElement(icasing)%Id = PipeID_MudElement%Array(i) !CasingMudElement(icasing)%Od = PipeOD_MudElement%Array(i) !write(*,333) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'Density=' , Density_MudElement%Array(i), 'MudType=' , MudType_MudElement%Array(i) !call Log_1(temp1) !write(*,444) 'CASING:', i,'Xstart\=', Xstart_MudElement%Array(i), 'Xend=' , Xend_MudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%Density = MudSystem%Density_MudElement%Array(i) + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%Density = data%State%MudSystem%Density_MudElement%Array(i) - if (MudSystem%MudType_MudElement%Array(i) == 104) then - MudSystem%MudType_MudElement%Array(i)= 4 ! air - elseif (MudSystem%MudType_MudElement%Array(i) > 0 .and. MudSystem%MudType_MudElement%Array(i) < 100) then - MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick + if (data%State%MudSystem%MudType_MudElement%Array(i) == 104) then + data%State%MudSystem%MudType_MudElement%Array(i)= 4 ! air + elseif (data%State%MudSystem%MudType_MudElement%Array(i) > 0 .and. data%State%MudSystem%MudType_MudElement%Array(i) < 100) then + data%State%MudSystem%MudType_MudElement%Array(i)= 1 ! gas kick endif - MudSystem%CasingMudElement(MudSystem%icasing)%MudType = MudSystem%MudType_MudElement%Array(i) + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%MudType = data%State%MudSystem%MudType_MudElement%Array(i) enddo - do i= MudSystem%NoBottomHoleMudElements, 1 , -1 ! 4-open hole elements - MudSystem%icasing= MudSystem%icasing+1 - MudSystem%CasingMudElement(MudSystem%icasing)%StartMd = MudSystem%Xend_OpMudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%EndMd = MudSystem%Xstart_OpMudElement%Array(i) + do i= data%State%MudSystem%NoBottomHoleMudElements, 1 , -1 ! 4-open hole elements + data%State%MudSystem%icasing= data%State%MudSystem%icasing+1 + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%StartMd = data%State%MudSystem%Xend_OpMudElement%Array(i) + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%EndMd = data%State%MudSystem%Xstart_OpMudElement%Array(i) !CasingMudElement(icasing)%Id = PipeID_OpMudElement%Array(i) !CasingMudElement(icasing)%Od = PipeOD_OpMudElement%Array(i) !write(*,333) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'Density=' , Density_OpMudElement%Array(i), 'MudType=' , MudTypeOp_MudElement%Array(i) !call Log_1(temp2) !write(*,444) 'OpenHole:',i,'Xstart\=', Xstart_OpMudElement%Array(i), 'Xend=' , Xend_OpMudElement%Array(i), 'PipeID_MudElement%Array(i)=' , PipeID_MudElement%Array(i), 'PipeOD_MudElement%Array(i)=' , PipeOD_MudElement%Array(i) - MudSystem%CasingMudElement(MudSystem%icasing)%Density = MudSystem%Density_OpMudElement%Array(i) + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%Density = data%State%MudSystem%Density_OpMudElement%Array(i) - if (MudSystem%MudTypeOp_MudElement%Array(i) == 104) then - MudSystem%MudTypeOp_MudElement%Array(i)= 4 ! air - elseif (MudSystem%MudTypeOp_MudElement%Array(i) > 0 .and. MudSystem%MudTypeOp_MudElement%Array(i) < 100) then - MudSystem%MudTypeOp_MudElement%Array(i)= 1 ! gas kick + if (data%State%MudSystem%MudTypeOp_MudElement%Array(i) == 104) then + data%State%MudSystem%MudTypeOp_MudElement%Array(i)= 4 ! air + elseif (data%State%MudSystem%MudTypeOp_MudElement%Array(i) > 0 .and. data%State%MudSystem%MudTypeOp_MudElement%Array(i) < 100) then + data%State%MudSystem%MudTypeOp_MudElement%Array(i)= 1 ! gas kick endif - MudSystem%CasingMudElement(MudSystem%icasing)%MudType = MudSystem%MudTypeOp_MudElement%Array(i) + data%State%MudSystem%CasingMudElement(data%State%MudSystem%icasing)%MudType = data%State%MudSystem%MudTypeOp_MudElement%Array(i) enddo @@ -396,8 +403,8 @@ endif ! shomare gozari be tartib HZ mud, ST mud, Casing ! shomare gzari OpenHole jodagane ast az 1 - call SetStringFluids(MudSystem%NoStringMudElementsForPlot, MudSystem%StringMudElement) !for data display in string - call SetAnnalusFluids(MudSystem%NoCasingMudElements+MudSystem%NoBottomHoleMudElements, MudSystem%CasingMudElement) !for data display in casing + call SetStringFluids(data%State%MudSystem%NoStringMudElementsForPlot, data%State%MudSystem%StringMudElement) !for data display in string + call SetAnnalusFluids(data%State%MudSystem%NoCasingMudElements+data%State%MudSystem%NoBottomHoleMudElements, data%State%MudSystem%CasingMudElement) !for data display in casing !=========================================================================================================================== diff --git a/Equipments/MudSystem/Pump_and_Trip_In.f90 b/Equipments/MudSystem/Pump_and_Trip_In.f90 index 11e87d8..5f2e065 100644 --- a/Equipments/MudSystem/Pump_and_Trip_In.f90 +++ b/Equipments/MudSystem/Pump_and_Trip_In.f90 @@ -3,14 +3,20 @@ subroutine Pump_and_TripIn ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure +use ConfigurationVariables !@@@ + use ConfigurationVariables + USE CHOKEVARIABLES +!use ConfigurationVariables !@ + !use CDataDisplayConsole + !@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES + use ConfigurationVariables !@ + USE CHOKEVARIABLES +!use ConfigurationVariables !@ !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity + use ConfigurationVariables + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule @@ -24,8 +30,8 @@ integer i,ii,AddLocation !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystem%StringFlowRate= MUD(2)%Q - MudSystem%AnnulusFlowRate= MUD(2)%Q + data%State%MudSystem%StringFlowRate= data%State%MUD(2)%Q + data%State%MudSystem%AnnulusFlowRate= data%State%MUD(2)%Q !write(*,*) 'Trip In' @@ -33,87 +39,87 @@ integer i,ii,AddLocation !========================Horizontal PIPE ENTRANCE================= - if (ABS(MudSystem%SuctionDensity_Old - MudSystem%Suction_Density_MudSystem) >= MudSystem%DensityMixTol) then ! new mud is pumped + if (ABS(data%State%MudSystem%SuctionDensity_Old - data%State%MudSystem%Suction_Density_MudSystem) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%Hz_Density%AddToFirst (MudSystem%Suction_Density_MudSystem) - call MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Hz_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Hz_Density%AddToFirst (data%State%MudSystem%Suction_Density_MudSystem) + call data%State%MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(1)) + call data%State%MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%Hz_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(1)) + call data%State%MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_MudOrKick%AddToFirst (0) - MudSystem%SuctionDensity_Old= MudSystem%Suction_Density_MudSystem + data%State%MudSystem%SuctionDensity_Old= data%State%MudSystem%Suction_Density_MudSystem endif !========================Horizontal PIPE STRING================= - MudSystem%Hz_MudDischarged_Volume%Array(1)= MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + data%State%MudSystem%Hz_MudDischarged_Volume%Array(1)= data%State%MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) - MudSystem%total_add = MudSystem%total_add + ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%total_add = data%State%MudSystem%total_add + ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_add= 0. + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + data%State%MudSystem%total_add= 0. endif !write(*,*) ' total decrease(add to HZ)=' , total_add - !write(*,*) ' add to HZ=' , ((MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) + !write(*,*) ' add to HZ=' , ((data%State%MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) imud=0 - do while (imud < MudSystem%Hz_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Hz_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Hz_Mud_Backhead_X%Array(imud)= MudSystem%Hz_Mud_Forehead_X%Array(imud-1) - MudSystem%Hz_Mud_Backhead_section%Array(imud)= MudSystem%Hz_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Hz_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))- MudSystem%Hz_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Hz_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Hz_MudDischarged_Volume%Array(imud) <= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%Hz_Mud_Backhead_section%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Hz_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Hz_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)) else - MudSystem%isection= MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > 1) then ! (horizontal pipe exit) - MudSystem%Hz_MudDischarged_Volume%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(1) - MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 + if (data%State%MudSystem%isection > 1) then ! (horizontal pipe exit) + data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(1) + data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 - if (MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + if (data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string call RemoveHzMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Hz_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -130,7 +136,7 @@ imud=0 !if (UtubeMode1Activated== .true.) then ! StringUpdate == .true. ! ! - ! !StringDensity_Old=MudSystem%St_Density%Array(2) + ! !StringDensity_Old=data%State%MudSystem%St_Density%Array(2) ! ! write(*,*) 'StringDensity_Old=' , StringDensity_Old ! @@ -156,25 +162,25 @@ imud=0 !========================New Pipe Filling================= !if (F_StringIntervalCounts > F_StringIntervalCountsOld) then ! StringUpdate == .true. - if (MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. + if (data%State%MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. - !NoPipeAdded= F_Counts%StringIntervalCounts - F_StringIntervalCountsOld + !NoPipeAdded= data%State%F_Counts%StringIntervalCounts - F_StringIntervalCountsOld - MudSystem%NewPipeFilling=0 + data%State%MudSystem%NewPipeFilling=0 - IF (MudSystem%St_MudOrKick%First() == 104) then - MudSystem%St_MudDischarged_Volume%Array(1) = MudSystem%St_MudDischarged_Volume%Array(1) + sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString)) ! new pipe is filled by air + IF (data%State%MudSystem%St_MudOrKick%First() == 104) then + data%State%MudSystem%St_MudDischarged_Volume%Array(1) = data%State%MudSystem%St_MudDischarged_Volume%Array(1) + sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:1+data%State%MudSystem%AddedElementsToString)) ! new pipe is filled by air else - call MudSystem%St_Density%AddToFirst (0.d0) - call MudSystem%St_MudDischarged_Volume%AddToFirst (sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString))) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) - call MudSystem%St_MudOrKick%AddToFirst (104) + call data%State%MudSystem%St_Density%AddToFirst (0.d0) + call data%State%MudSystem%St_MudDischarged_Volume%AddToFirst (sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:1+data%State%MudSystem%AddedElementsToString))) + call data%State%MudSystem%St_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call data%State%MudSystem%St_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) + call data%State%MudSystem%St_MudOrKick%AddToFirst (104) endif endif @@ -183,46 +189,46 @@ imud=0 - if (MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) + if (data%State%MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) - MudSystem%LackageMudVolume= MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element + data%State%MudSystem%LackageMudVolume= data%State%MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element - write(*,*) 'LackageMudVolume=' , MudSystem%LackageMudVolume + write(*,*) 'LackageMudVolume=' , data%State%MudSystem%LackageMudVolume - if (ABS(MudSystem%St_Density%Array(2) - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddTo (2,MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddTo (2, 0.d0) - call MudSystem%St_Mud_Forehead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) - call MudSystem%St_Mud_Backhead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) - call MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) - call MudSystem%St_MudOrKick%AddTo (2,0) + if (ABS(data%State%MudSystem%St_Density%Array(2) - data%State%MudSystem%Hz_Density%Last()) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped + call data%State%MudSystem%St_Density%AddTo (2,data%State%MudSystem%Hz_Density%Last()) + call data%State%MudSystem%St_MudDischarged_Volume%AddTo (2, 0.d0) + call data%State%MudSystem%St_Mud_Forehead_X%AddTo (2,data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) + call data%State%MudSystem%St_Mud_Backhead_X%AddTo (2,data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) + call data%State%MudSystem%St_MudOrKick%AddTo (2,0) !StringDensity_Old= Hz_Density%Last() endif - MudSystem%St_MudDischarged_Volume%Array(2)= MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) !(gal) + data%State%MudSystem%St_MudDischarged_Volume%Array(2)= data%State%MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline), data%State%MudSystem%LackageMudVolume) !(gal) - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)- min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) ! air(gal) + data%State%MudSystem%St_MudDischarged_Volume%Array(1)= data%State%MudSystem%St_MudDischarged_Volume%Array(1)- min( ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline), data%State%MudSystem%LackageMudVolume) ! air(gal) !LackageMudVolumeAfterFilling= sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) - sum(St_MudDischarged_Volume%Array(:)) - MudSystem%LackageMudVolumeAfterFilling= MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero + data%State%MudSystem%LackageMudVolumeAfterFilling= data%State%MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero - if (MudSystem%LackageMudVolumeAfterFilling == 0.) then - MudSystem%NewPipeFilling= 1 + if (data%State%MudSystem%LackageMudVolumeAfterFilling == 0.) then + data%State%MudSystem%NewPipeFilling= 1 call RemoveStringMudArrays(1) - MudSystem%St_Mud_Backhead_X%Array(1) = MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(1) = 2 + data%State%MudSystem%St_Mud_Backhead_X%Array(1) = data%State%MudSystem%Xstart_PipeSection(2) + data%State%MudSystem%St_Mud_Backhead_section%Array(1) = 2 endif endif @@ -232,71 +238,71 @@ imud=0 - if (MudSystem%NewPipeFilling == 0) then - MudSystem%StringFlowRate= 0. - MudSystem%AnnulusFlowRate= 0. + if (data%State%MudSystem%NewPipeFilling == 0) then + data%State%MudSystem%StringFlowRate= 0. + data%State%MudSystem%AnnulusFlowRate= 0. endif - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate + data%State%MudSystem%StringFlowRateFinal= data%State%MudSystem%StringFlowRate + data%State%MudSystem%AnnulusFlowRateFinal= data%State%MudSystem%AnnulusFlowRate !========================STRING ENTRANCE================= - if (MudSystem%StringFlowRateFinal > 0.0 .and. ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (0) + if (data%State%MudSystem%StringFlowRateFinal > 0.0 .and. ABS(data%State%MudSystem%St_Density%First() - data%State%MudSystem%Hz_Density%Last()) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped + call data%State%MudSystem%St_Density%AddToFirst (data%State%MudSystem%Hz_Density%Last()) + call data%State%MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) + call data%State%MudSystem%St_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call data%State%MudSystem%St_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%St_MudOrKick%AddToFirst (0) !StringDensity_Old= Hz_Density%Last() endif - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + data%State%MudSystem%St_MudDischarged_Volume%Array(1)= data%State%MudSystem%St_MudDischarged_Volume%Array(1)+ ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) !=============== save String Mud data=========== - MudSystem%StMudVolumeSum= 0.d0 + data%State%MudSystem%StMudVolumeSum= 0.d0 !St_MudSaved_Density= 0.d0 - MudSystem%St_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%St_Saved_MudDischarged_Volume= 0.d0 !Saved_St_MudOrKick= 0 !Ann_to_Choke_2mud= .false. - do imud=1, MudSystem%St_MudDischarged_Volume%Length() + do imud=1, data%State%MudSystem%St_MudDischarged_Volume%Length() - MudSystem%StMudVolumeSum = MudSystem%StMudVolumeSum + MudSystem%St_MudDischarged_Volume%Array(imud) + data%State%MudSystem%StMudVolumeSum = data%State%MudSystem%StMudVolumeSum + data%State%MudSystem%St_MudDischarged_Volume%Array(imud) - if ( MudSystem%StMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) ) then + if ( data%State%MudSystem%StMudVolumeSum > sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:data%State%F_Counts%StringIntervalCounts)) ) then !IF (St_MudOrKick%Array(imud) == 0) THEN - MudSystem%St_MudSaved_Density =MudSystem%St_Density%Array(imud) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%StMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) + data%State%MudSystem%St_MudSaved_Density =data%State%MudSystem%St_Density%Array(imud) + data%State%MudSystem%St_Saved_MudDischarged_Volume = data%State%MudSystem%StMudVolumeSum - sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:data%State%F_Counts%StringIntervalCounts)) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = StMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ! Saved_St_MudOrKick= St_MudOrKick%Array (imud) - ! St_KickSaved_Density=MudSystem%St_Density%Array(imud) + ! St_KickSaved_Density=data%State%MudSystem%St_Density%Array(imud) !END IF - do ii= imud + 1, MudSystem%St_MudDischarged_Volume%Length() + do ii= imud + 1, data%State%MudSystem%St_MudDischarged_Volume%Length() !IF (St_MudOrKick%Array(ii) == 0) THEN - MudSystem%St_MudSaved_Density = ((MudSystem%St_MudSaved_Density * MudSystem%St_Saved_MudDischarged_Volume) + (MudSystem%St_Density%Array(ii) * MudSystem%St_MudDischarged_Volume%Array(ii))) / (MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii)) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii) + data%State%MudSystem%St_MudSaved_Density = ((data%State%MudSystem%St_MudSaved_Density * data%State%MudSystem%St_Saved_MudDischarged_Volume) + (data%State%MudSystem%St_Density%Array(ii) * data%State%MudSystem%St_MudDischarged_Volume%Array(ii))) / (data%State%MudSystem%St_Saved_MudDischarged_Volume + data%State%MudSystem%St_MudDischarged_Volume%Array(ii)) + data%State%MudSystem%St_Saved_MudDischarged_Volume = data%State%MudSystem%St_Saved_MudDischarged_Volume + data%State%MudSystem%St_MudDischarged_Volume%Array(ii) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = St_Kick_Saved_Volume + St_MudDischarged_Volume%Array(ii) ! Saved_St_MudOrKick= St_MudOrKick%Array (ii) - ! St_KickSaved_Density=MudSystem%St_Density%Array(ii) + ! St_KickSaved_Density=data%State%MudSystem%St_Density%Array(ii) !END IF enddo @@ -307,30 +313,30 @@ imud=0 endif enddo -MudSystem%St_Saved_MudDischarged_Volume_Final = MudSystem%St_Saved_MudDischarged_Volume +data%State%MudSystem%St_Saved_MudDischarged_Volume_Final = data%State%MudSystem%St_Saved_MudDischarged_Volume -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final +IF (data%State%MudSystem%WellHeadIsOpen) data%State%MudSystem%MudVolume_InjectedToBH = data%State%MudSystem%St_Saved_MudDischarged_Volume_Final !====================================================================== !========================STRING================= imud=0 - do while (imud < MudSystem%St_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%St_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%St_Mud_Backhead_X%Array(imud)= data%State%MudSystem%St_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%St_Mud_Backhead_section%Array(imud)= data%State%MudSystem%St_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))- data%State%MudSystem%St_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal !write(*,*) 'St_Mud_Backhead_section%Array(1)=' , St_Mud_Backhead_section%Array(1) @@ -340,38 +346,38 @@ imud=0 !write(*,*) 'St_Mud_Backhead_X%Array(1)=' , St_Mud_Backhead_X%Array(1) - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%St_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%MudSystem%St_Mud_Backhead_section%Array(imud) + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= data%State%MudSystem%St_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%St_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > F_Counts%StringIntervalCounts) then ! last pipe section(string exit) F_Counts%StringIntervalCounts includes Horizontal line - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Forehead_section%Array(imud)= F_Counts%StringIntervalCounts + if (data%State%MudSystem%isection > data%State%F_Counts%StringIntervalCounts) then ! last pipe section(string exit) data%State%F_Counts%StringIntervalCounts includes Horizontal line + data%State%MudSystem%St_MudDischarged_Volume%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts) + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%F_Counts%StringIntervalCounts - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + if (data%State%MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string call RemoveStringMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -402,49 +408,49 @@ imud=0 !========================STRING END================= - IF (MudSystem%Op_MudOrKick%Last() /= 0 .and. MudSystem%Op_MudOrKick%Last()==MudSystem%Ann_MudOrKick%First()) MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick + IF (data%State%MudSystem%Op_MudOrKick%Last() /= 0 .and. data%State%MudSystem%Op_MudOrKick%Last()==data%State%MudSystem%Ann_MudOrKick%First()) data%State%MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick !write(*,*) ' iloc (b): ' , iloc !=============================Add PumpFlowRate to Bottom Hole ============================== - !if ( MudSystem%AnnulusFlowRate>0.0 ) then - if ( MudSystem%MudVolume_InjectedToBH > 0.0 ) then + !if ( data%State%MudSystem%AnnulusFlowRate>0.0 ) then + if ( data%State%MudSystem%MudVolume_InjectedToBH > 0.0 ) then if (KickVARIABLES%KickOffBottom) then ! (kickOffBottom = F) means kick is next to the bottom hole and usually kick is entering the - AddLocation= MudSystem%Op_Density%Length()-MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick + AddLocation= data%State%MudSystem%Op_Density%Length()-data%State%MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick else - AddLocation= MudSystem%Op_Density%Length()+1 + AddLocation= data%State%MudSystem%Op_Density%Length()+1 endif !write(*,*) 'AddLocation====' , AddLocation if ( AddLocation== 0) CALL ErrorStop ('AddLocation=0') - if ( ABS(MudSystem%St_Density%Last() - MudSystem%Op_Density%Array(AddLocation-1)) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%St_Density%Last() - data%State%MudSystem%Op_Density%Array(AddLocation-1)) >= data%State%MudSystem%DensityMixTol ) then !write(*,*) 'new pocket**' - !write(*,*) MudSystem%St_Density%Last()=' ,MudSystem%St_Density%Last() + !write(*,*) data%State%MudSystem%St_Density%Last()=' ,data%State%MudSystem%St_Density%Last() !write(*,*) 'Op_Density%Array(AddLocation-1)=' , Op_Density%Array(AddLocation-1) - call MudSystem%Op_Density% AddTo (AddLocation,MudSystem%St_Density%Last()) - !call Op_MudDischarged_Volume%AddTo (AddLocation,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - call MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,MudSystem%MudVolume_InjectedToBH) - call MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) - call MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (AddLocation,0) + call data%State%MudSystem%Op_Density% AddTo (AddLocation,data%State%MudSystem%St_Density%Last()) + !call Op_MudDischarged_Volume%AddTo (AddLocation,((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,data%State%MudSystem%MudVolume_InjectedToBH) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,data%State%MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,data%State%MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (AddLocation,0) else !write(*,*) 'merge**' !write(*,*) 'density before=' , Op_Density%Array(AddLocation-1) - !write(*,*) MudSystem%St_Density%Last() for mix=' ,MudSystem%St_Density%Last() + !write(*,*) data%State%MudSystem%St_Density%Last() for mix=' ,data%State%MudSystem%St_Density%Last() - !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) + !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)data%State%MudSystem%St_Density%Last()*((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystem%Op_Density%Array(AddLocation-1)= (MudSystem%Op_Density%Array(AddLocation-1)*MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*MudSystem%MudVolume_InjectedToBH)/(MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%MudVolume_InjectedToBH) - MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + MudSystem%MudVolume_InjectedToBH + data%State%MudSystem%Op_Density%Array(AddLocation-1)= (data%State%MudSystem%Op_Density%Array(AddLocation-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+data%State%MudSystem%St_Density%Last()*data%State%MudSystem%MudVolume_InjectedToBH)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+data%State%MudSystem%MudVolume_InjectedToBH) + data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + data%State%MudSystem%MudVolume_InjectedToBH !write(*,*) 'density after=' , Op_Density%Array(AddLocation-1) endif @@ -456,12 +462,12 @@ imud=0 !=============== save OP Mud data to transfer to the annulus enterance due to tripin or kick - MudSystem%OpMudVolumeSum= 0.d0 + data%State%MudSystem%OpMudVolumeSum= 0.d0 !Op_MudSaved_Density= 0.d0 !Op_KickSaved_Density= 0.d0 - MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Op_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Op_MudOrKick= 0 + data%State%MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%Op_Kick_Saved_Volume= 0.d0 + data%State%MudSystem%Saved_Op_MudOrKick= 0 @@ -469,34 +475,34 @@ imud=0 !write(*,*) 'Op_MudDischarged_Volume%Length()===' , Op_MudDischarged_Volume%Length() ! - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() + do imud=1, data%State%MudSystem%Op_MudDischarged_Volume%Length() !write(*,*) 'imud, Op_MudDischarged_Volume%Array(imud)=' , imud,Op_MudDischarged_Volume%Array(imud) - MudSystem%OpMudVolumeSum= MudSystem%OpMudVolumeSum + MudSystem%Op_MudDischarged_Volume%Array(imud) + data%State%MudSystem%OpMudVolumeSum= data%State%MudSystem%OpMudVolumeSum + data%State%MudSystem%Op_MudDischarged_Volume%Array(imud) - if ( MudSystem%OpMudVolumeSum > sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then + if ( data%State%MudSystem%OpMudVolumeSum > sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) ) then - IF (MudSystem%Op_MudOrKick%Array(imud) == 0) THEN - MudSystem%Op_MudSaved_Density = MudSystem%Op_Density%Array(imud) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) + IF (data%State%MudSystem%Op_MudOrKick%Array(imud) == 0) THEN + data%State%MudSystem%Op_MudSaved_Density = data%State%MudSystem%Op_Density%Array(imud) + data%State%MudSystem%Op_Saved_MudDischarged_Volume = data%State%MudSystem%OpMudVolumeSum - sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) ELSE - MudSystem%Op_Kick_Saved_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) + data%State%MudSystem%Op_Kick_Saved_Volume = data%State%MudSystem%OpMudVolumeSum - sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) !write(*,*) 'cond 1- Op_MudOrKick%Array (imud),Op_Density%Array(imud):' ,Op_MudOrKick%Array (imud),Op_Density%Array(imud) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (imud) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(imud) - MudSystem%iLoc= 2 + data%State%MudSystem%Saved_Op_MudOrKick= data%State%MudSystem%Op_MudOrKick%Array (imud) + data%State%MudSystem%Op_KickSaved_Density= data%State%MudSystem%Op_Density%Array(imud) + data%State%MudSystem%iLoc= 2 END IF - do ii= imud + 1, MudSystem%Op_MudDischarged_Volume%Length() - IF (MudSystem%Op_MudOrKick%Array(ii) == 0) THEN - MudSystem%Op_MudSaved_Density = ((MudSystem%Op_MudSaved_Density * MudSystem%Op_Saved_MudDischarged_Volume) + (MudSystem%Op_Density%Array(ii) * MudSystem%Op_MudDischarged_Volume%Array(ii))) / (MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii)) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) + do ii= imud + 1, data%State%MudSystem%Op_MudDischarged_Volume%Length() + IF (data%State%MudSystem%Op_MudOrKick%Array(ii) == 0) THEN + data%State%MudSystem%Op_MudSaved_Density = ((data%State%MudSystem%Op_MudSaved_Density * data%State%MudSystem%Op_Saved_MudDischarged_Volume) + (data%State%MudSystem%Op_Density%Array(ii) * data%State%MudSystem%Op_MudDischarged_Volume%Array(ii))) / (data%State%MudSystem%Op_Saved_MudDischarged_Volume + data%State%MudSystem%Op_MudDischarged_Volume%Array(ii)) + data%State%MudSystem%Op_Saved_MudDischarged_Volume = data%State%MudSystem%Op_Saved_MudDischarged_Volume + data%State%MudSystem%Op_MudDischarged_Volume%Array(ii) ELSE - MudSystem%Op_Kick_Saved_Volume = MudSystem%Op_Kick_Saved_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) + data%State%MudSystem%Op_Kick_Saved_Volume = data%State%MudSystem%Op_Kick_Saved_Volume + data%State%MudSystem%Op_MudDischarged_Volume%Array(ii) !write(*,*) 'cond 2- Op_MudOrKick%Array (ii),Op_Density%Array(ii):' ,Op_MudOrKick%Array (ii),Op_Density%Array(ii) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (ii) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(ii) - MudSystem%iLoc= 2 + data%State%MudSystem%Saved_Op_MudOrKick= data%State%MudSystem%Op_MudOrKick%Array (ii) + data%State%MudSystem%Op_KickSaved_Density= data%State%MudSystem%Op_Density%Array(ii) + data%State%MudSystem%iLoc= 2 END IF enddo @@ -517,8 +523,8 @@ imud=0 !if (iLoc == 1) then - MudSystem%MudSection= F_Counts%StringIntervalCounts+1 - MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) + data%State%MudSystem%MudSection= data%State%F_Counts%StringIntervalCounts+1 + data%State%MudSystem%BackheadX= data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1) !elseif (iLoc == 2) then ! MudSection= Kick_Forehead_section ! BackheadX= Kick_Forehead_X @@ -526,8 +532,8 @@ imud=0 !========================ANNULUS ENTRANCE==================== !if (KickMigration_2SideBit == .FALSE.) then ! because its effect is applied in Migration Code - ! !write(*,*) 'iloc=====' , iLoc bejaye ROP_Bit%RateOfPenetration ==0. in bude: DeltaVolumeOp == 0.0 - ! if (ABS(AnnulusSuctionDensity_OldMudSystem%St_Density%Last()) >= DensityMixTol .OR. (DeltaVolumeOp == 0.0 .and. ABS(Ann_Density%Array(iLoc)MudSystem%St_Density%Last())>=DensityMixTol .and. MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped + ! !write(*,*) 'iloc=====' , iLoc bejaye data%State%ROP_Bit%RateOfPenetration ==0. in bude: DeltaVolumeOp == 0.0 + ! if (ABS(AnnulusSuctionDensity_OldMudSystem%St_Density%Last()) >= DensityMixTol .OR. (DeltaVolumeOp == 0.0 .and. ABS(Ann_Density%Array(iLoc)data%State%MudSystem%St_Density%Last())>=DensityMixTol .and. data%State%MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped ! call Ann_Density%AddTo (iLocMudSystem%St_Density%Last()) ! call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0) ! call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) @@ -540,12 +546,12 @@ imud=0 ! call Ann_CuttingMud%AddTo (iLoc,0) ! !write(*,*) 'c) annLength=' , Ann_Density%Length() ! - ! AnnulusSuctionDensity_Old=MudSystem%St_Density%Last() + ! AnnulusSuctionDensity_Old=data%State%MudSystem%St_Density%Last() ! ! MudIsChanged= .true. ! endif ! - ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) !(gal) + ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) !(gal) ! !endif @@ -554,8 +560,8 @@ imud=0 - MudSystem%Ann_Mud_Backhead_section%Array(1)= MudSystem%MudSection !it is needed to be updated for a condition that one pipe is removed from Annulus due to trip out - MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(1)= data%State%MudSystem%MudSection !it is needed to be updated for a condition that one pipe is removed from Annulus due to trip out + data%State%MudSystem%Ann_Mud_Backhead_X%Array(1)= data%State%MudSystem%BackheadX @@ -579,7 +585,7 @@ imud=0 !========================Tripping In==================== !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - if (ROP_Bit%RateOfPenetration==0.) then ! .and. Op_MudOrKick%Last() == 0) then ! trip in mode(loole paeen) Mud + if (data%State%ROP_Bit%RateOfPenetration==0.) then ! .and. Op_MudOrKick%Last() == 0) then ! trip in mode(loole paeen) Mud !write(*,*) 'Tripping In' !write(*,*) 'before' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) @@ -589,56 +595,56 @@ imud=0 !endif - if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then + if (data%State%MudSystem%Op_Kick_Saved_Volume > 0.0 .and. data%State%MudSystem%Ann_MudOrKick%First() == 0) then write(*,*) 'Kick influx enters Annulus' - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< - call MudSystem%Ann_CuttingMud%AddToFirst (0) - elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume + call data%State%MudSystem%Ann_Density%AddToFirst (data%State%MudSystem%Op_KickSaved_Density) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddToFirst (data%State%MudSystem%Op_Kick_Saved_Volume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddToFirst (data%State%MudSystem%Saved_Op_MudOrKick) !<<<<<<<< + call data%State%MudSystem%Ann_CuttingMud%AddToFirst (0) + elseif (data%State%MudSystem%Op_Kick_Saved_Volume > 0.0 .and. data%State%MudSystem%Ann_MudOrKick%First() /= 0) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) + data%State%MudSystem%Op_Kick_Saved_Volume endif - if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then - MudSystem%NewDensity= MudSystem%Op_MudSaved_Density - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume + if (data%State%MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then + data%State%MudSystem%NewDensity= data%State%MudSystem%Op_MudSaved_Density + data%State%MudSystem%NewVolume= data%State%MudSystem%Op_Saved_MudDischarged_Volume !write(*,*) 'NewVolume=' , NewVolume !write(*,*) 'iloc=' , iloc,'Ann_MudDischarged_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - if ((ROP_Bit%RateOfPenetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged + if ((data%State%ROP_Bit%RateOfPenetration==0 .and. abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%DensityMixTol) & + .or. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==1 .and. abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%CuttingDensityMixTol) & + .or. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==0 .and. data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)= (data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%iLoc)= (0.0d0) !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%iLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%iLoc,0) !write(*,*) 'd) annLength=' , Ann_Density%Length() !write(*,*) 'new' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) @@ -651,7 +657,7 @@ imud=0 !========================Drilling Mode======================== - if (ROP_Bit%RateOfPenetration>0. .and. MudSystem%DeltaVolumeOp>0.0) then ! trip in mode(loole paeen) DrillingMode== .true. + if (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%DeltaVolumeOp>0.0) then ! trip in mode(loole paeen) DrillingMode== .true. !write(*,*) 'Drilling Mode' !if ( MudIsChanged== .true. ) then @@ -660,78 +666,78 @@ imud=0 !write(*,*) 'before' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - !MudSystem%NewDensity= MudSystem%St_Density%Last() * MudSystem%AnnulusFlowRate + 141.4296E-4*ROP_Bit%RateOfPenetration*ROP_Spec%DiameterOfBit**2)/(MudSystem%AnnulusFlowRate+6.7995E-4*ROP_Bit%RateOfPenetration*Diameter_of_Bit**2) + !data%State%MudSystem%NewDensity= data%State%MudSystem%St_Density%Last() * data%State%MudSystem%AnnulusFlowRate + 141.4296E-4*data%State%ROP_Bit%RateOfPenetration*data%State%ROP_Spec%DiameterOfBit**2)/(data%State%MudSystem%AnnulusFlowRate+6.7995E-4*data%State%ROP_Bit%RateOfPenetration*Diameter_of_Bit**2) - MudSystem%NewDensity=MudSystem%St_Density%Last() + data%State%MudSystem%NewDensity=data%State%MudSystem%St_Density%Last() - !NewVolume= ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp + !NewVolume= ((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp !!! Density in ppg, flow rate in gpm, ROP in ft/s, bit diameter in inch - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - if ( MudSystem%Op_MudOrKick%Array(imud) == 0 ) then - MudSystem%Op_Density%Array(imud)= MudSystem%NewDensity + do imud=1, data%State%MudSystem%Op_MudDischarged_Volume%Length() + if ( data%State%MudSystem%Op_MudOrKick%Array(imud) == 0 ) then + data%State%MudSystem%Op_Density%Array(imud)= data%State%MudSystem%NewDensity endif enddo - if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then + if (data%State%MudSystem%Op_Kick_Saved_Volume > 0.0 .and. data%State%MudSystem%Ann_MudOrKick%First() == 0) then write(*,*) 'Kick influx enters Annulus first time' !write(*,*) 'Saved_Op_MudOrKick=',Saved_Op_MudOrKick - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< - call MudSystem%Ann_CuttingMud%AddToFirst (0) - elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume + call data%State%MudSystem%Ann_Density%AddToFirst (data%State%MudSystem%Op_KickSaved_Density) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddToFirst (data%State%MudSystem%Op_Kick_Saved_Volume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddToFirst (data%State%MudSystem%Saved_Op_MudOrKick) !<<<<<<<< + call data%State%MudSystem%Ann_CuttingMud%AddToFirst (0) + elseif (data%State%MudSystem%Op_Kick_Saved_Volume > 0.0 .and. data%State%MudSystem%Ann_MudOrKick%First() /= 0) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) + data%State%MudSystem%Op_Kick_Saved_Volume endif - if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then + if (data%State%MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then !write(*,*) 'Op_Saved_Mud added' - MudSystem%NewDensity= MudSystem%NewDensity !(drilling density) - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%DeltaVolumeOp ! (DeltaVolumeOp: for Cuttings Volume) + data%State%MudSystem%NewDensity= data%State%MudSystem%NewDensity !(drilling density) + data%State%MudSystem%NewVolume= data%State%MudSystem%Op_Saved_MudDischarged_Volume + data%State%MudSystem%DeltaVolumeOp ! (DeltaVolumeOp: for Cuttings Volume) !write(*,*) 'NewVolume=' , NewVolume !write(*,*) 'iloc=' , iloc,'Ann_MudDischarged_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) - if ( (MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol ) & - .or. (MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged + if ( (data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==1 .and. abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%CuttingDensityMixTol ) & + .or. (data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==0 .and. data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)= 1 + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)= (data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)= 1 !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) else ! 2-Merging conditions are not meeted, so new pocket - !write(*,*) 'before e) ', iloc, Ann_Density%Array(iLoc),MudSystem%NewDensity + !write(*,*) 'before e) ', iloc, Ann_Density%Array(iLoc),data%State%MudSystem%NewDensity !write(*,*) 'before e) Ann_MudDischarged_Volume%Array(iLoc)=' , Ann_MudDischarged_Volume%Array(iLoc) - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,1) ! 1= cutting 0= mud + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%iLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%iLoc,1) ! 1= cutting 0= mud !write(*,*) 'new' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) !write(*,*) 'e) annLength=' , Ann_Density%Length() @@ -757,52 +763,52 @@ imud=0 ! !write(*,*) '==after add to ann' - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume + data%State%MudSystem%NewVolume= ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) - data%State%MudSystem%Op_Saved_MudDischarged_Volume - if (MudSystem%iLoc==2 .and. MudSystem%Op_MudOrKick%Last()==0 .and. MudSystem%NewVolume > 0.d0 ) then ! for avoid kick separation + if (data%State%MudSystem%iLoc==2 .and. data%State%MudSystem%Op_MudOrKick%Last()==0 .and. data%State%MudSystem%NewVolume > 0.d0 ) then ! for avoid kick separation !write(*,*) 'avoid kick separation' - MudSystem%NewDensity= MudSystem%Op_MudSaved_Density + data%State%MudSystem%NewDensity= data%State%MudSystem%Op_MudSaved_Density - call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann - if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)- MudSystem%Op_Saved_MudDischarged_Volume) then! 1st in Ann = kick + call RemoveOpMudArrays(data%State%MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) > ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline)- data%State%MudSystem%Op_Saved_MudDischarged_Volume) then! 1st in Ann = kick !write(*,*) 'mode1' - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) -MudSystem%Op_Saved_MudDischarged_Volume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) !kick + data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) - (((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) -data%State%MudSystem%Op_Saved_MudDischarged_Volume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())+ (((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) - data%State%MudSystem%Op_Saved_MudDischarged_Volume) !kick else call RemoveAnnulusMudArrays(1) !kick is removed - MudSystem%iLoc= 1 - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) + data%State%MudSystem%iLoc= 1 + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())+ (((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) - data%State%MudSystem%Op_Saved_MudDischarged_Volume) !write(*,*) 'mode2' ! including a little expand endif - if ((ROP_Bit%RateOfPenetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged + if ((data%State%ROP_Bit%RateOfPenetration==0 .and. abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%DensityMixTol) & + .or. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==1 .and. abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%CuttingDensityMixTol) & + .or. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==0 .and. data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)= (data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%iLoc)= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%iLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%iLoc,0) !write(*,*) 'd) annLength=' , Ann_Density%Length() endif @@ -810,26 +816,26 @@ imud=0 endif !=================================================================== - if( MudSystem%Op_MudOrKick%Last() == 1 .and. MudSystem%Ann_MudOrKick%First() == 0 ) then + if( data%State%MudSystem%Op_MudOrKick%Last() == 1 .and. data%State%MudSystem%Ann_MudOrKick%First() == 0 ) then write(*,*) '***error2****==' - write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , MudSystem%Op_Kick_Saved_Volume,MudSystem%Op_Saved_MudDischarged_Volume + write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , data%State%MudSystem%Op_Kick_Saved_Volume,data%State%MudSystem%Op_Saved_MudDischarged_Volume write(*,*) 'after add to ann==' - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - write(*,*) 'Op:', imud, MudSystem%Op_MudDischarged_Volume%Array(imud), MudSystem%Op_Density%Array(imud) ,MudSystem%Op_MudOrKick%Array(imud) + do imud=1, data%State%MudSystem%Op_MudDischarged_Volume%Length() + write(*,*) 'Op:', imud, data%State%MudSystem%Op_MudDischarged_Volume%Array(imud), data%State%MudSystem%Op_Density%Array(imud) ,data%State%MudSystem%Op_MudOrKick%Array(imud) enddo - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - write(*,*) 'Ann:', imud, MudSystem%Ann_MudDischarged_Volume%Array(imud), MudSystem%Ann_Density%Array(imud) ,MudSystem%Ann_MudOrKick%Array(imud) + do imud=1, data%State%MudSystem%Ann_MudDischarged_Volume%Length() + write(*,*) 'Ann:', imud, data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud), data%State%MudSystem%Ann_Density%Array(imud) ,data%State%MudSystem%Ann_MudOrKick%Array(imud) enddo write(*,*) '==after add to ann' - write(*,*) 'NewVolume,Op_MudOrKick%Last=' , MudSystem%NewVolume,MudSystem%Op_MudOrKick%Last() + write(*,*) 'NewVolume,Op_MudOrKick%Last=' , data%State%MudSystem%NewVolume,data%State%MudSystem%Op_MudOrKick%Last() write(*,*) '==***error2****' endif @@ -839,41 +845,41 @@ imud=0 !=============== save Ann Mud data to transfer to the ChokeLine enterance - MudSystem%AnnMudVolumeSum= 0.d0 + data%State%MudSystem%AnnMudVolumeSum= 0.d0 !Ann_MudSaved_Density= 0.d0 !Ann_KickSaved_Density= 0.d0 - MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Ann_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Ann_MudOrKick= 0 - MudSystem%Ann_to_Choke_2mud= .false. + data%State%MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%Ann_Kick_Saved_Volume= 0.d0 + data%State%MudSystem%Saved_Ann_MudOrKick= 0 + data%State%MudSystem%Ann_to_Choke_2mud= .false. - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() + do imud=1, data%State%MudSystem%Ann_MudDischarged_Volume%Length() - MudSystem%AnnMudVolumeSum= MudSystem%AnnMudVolumeSum + MudSystem%Ann_MudDischarged_Volume%Array(imud) + data%State%MudSystem%AnnMudVolumeSum= data%State%MudSystem%AnnMudVolumeSum + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) - if ( MudSystem%AnnMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) ) then + if ( data%State%MudSystem%AnnMudVolumeSum > sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) ) then - IF (MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN - MudSystem%Ann_MudSaved_Density = MudSystem%Ann_Density%Array(imud) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - ELSEIF (MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (imud) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(imud) + IF (data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN + data%State%MudSystem%Ann_MudSaved_Density = data%State%MudSystem%Ann_Density%Array(imud) + data%State%MudSystem%Ann_Saved_MudDischarged_Volume = data%State%MudSystem%AnnMudVolumeSum - sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + ELSEIF (data%State%MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. data%State%MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR + data%State%MudSystem%Ann_Kick_Saved_Volume = data%State%MudSystem%AnnMudVolumeSum - sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + data%State%MudSystem%Saved_Ann_MudOrKick= data%State%MudSystem%Ann_MudOrKick%Array (imud) + data%State%MudSystem%Ann_KickSaved_Density= data%State%MudSystem%Ann_Density%Array(imud) END IF - do ii= imud + 1, MudSystem%Ann_MudDischarged_Volume%Length() - IF (MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN - MudSystem%Ann_MudSaved_Density = ((MudSystem%Ann_MudSaved_Density * MudSystem%Ann_Saved_MudDischarged_Volume) + (MudSystem%Ann_Density%Array(ii) * MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii)) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Ann_to_Choke_2mud= .true. - ELSEIF (MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%Ann_Kick_Saved_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (ii) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(ii) + do ii= imud + 1, data%State%MudSystem%Ann_MudDischarged_Volume%Length() + IF (data%State%MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN + data%State%MudSystem%Ann_MudSaved_Density = ((data%State%MudSystem%Ann_MudSaved_Density * data%State%MudSystem%Ann_Saved_MudDischarged_Volume) + (data%State%MudSystem%Ann_Density%Array(ii) * data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (data%State%MudSystem%Ann_Saved_MudDischarged_Volume + data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii)) + data%State%MudSystem%Ann_Saved_MudDischarged_Volume = data%State%MudSystem%Ann_Saved_MudDischarged_Volume + data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii) + data%State%MudSystem%Ann_to_Choke_2mud= .true. + ELSEIF (data%State%MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. data%State%MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR + data%State%MudSystem%Ann_Kick_Saved_Volume = data%State%MudSystem%Ann_Kick_Saved_Volume + data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii) + data%State%MudSystem%Saved_Ann_MudOrKick= data%State%MudSystem%Ann_MudOrKick%Array (ii) + data%State%MudSystem%Ann_KickSaved_Density= data%State%MudSystem%Ann_Density%Array(ii) END IF enddo @@ -884,24 +890,24 @@ imud=0 endif enddo -MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume !+ Ann_Kick_Saved_Volume -MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final -((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) -!WRITE (*,*) 'MudSystem%MudVolume_InjectedFromAnn=', MudSystem%MudVolume_InjectedFromAnn +data%State%MudSystem%Ann_Saved_MudDischarged_Volume_Final= data%State%MudSystem%Ann_Saved_MudDischarged_Volume !+ Ann_Kick_Saved_Volume +data%State%MudSystem%Ann_Kick_Saved_Volume_Final= data%State%MudSystem%Ann_Kick_Saved_Volume +IF (data%State%MudSystem%WellHeadIsOpen) data%State%MudSystem%MudVolume_InjectedFromAnn = data%State%MudSystem%Ann_Saved_MudDischarged_Volume_Final -((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) +!WRITE (*,*) 'data%State%MudSystem%MudVolume_InjectedFromAnn=', data%State%MudSystem%MudVolume_InjectedFromAnn !====================================================================== !write(*,*) 'c)Ann_Mud sum=' , sum(Ann_MudDischarged_Volume%Array(:)) !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) !write(*,*) 'Ann_Saved_Mud=' , Ann_Saved_MudDischarged_Volume - MudSystem%total_injected = MudSystem%total_injected + MudSystem%MudVolume_InjectedFromAnn + data%State%MudSystem%total_injected = data%State%MudSystem%total_injected + data%State%MudSystem%MudVolume_InjectedFromAnn - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_injected= 0. + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + data%State%MudSystem%total_injected= 0. endif !write(*,*) ' total injected-tripin =' , total_injected - !write(*,*) 'injected-tripin =' , MudSystem%MudVolume_InjectedFromAnn + !write(*,*) 'injected-tripin =' , data%State%MudSystem%MudVolume_InjectedFromAnn @@ -913,21 +919,21 @@ IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSys imud= 0 - do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Ann_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud-1) endif ! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then + IF ( data%State%MudSystem%ShoeLost .and. Shoe%ShoeDepth < data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)-((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud call RemoveAnnulusMudArrays(imud) imud= imud-1 @@ -938,48 +944,48 @@ imud= 0 ! Fracture Shoe Lost >>> - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections + if (data%State%MudSystem%isection > data%State%MudSystem%NoPipeSections) then ! last pipe section(well exit) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections) + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%NoPipeSections - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well !write(*,*) 'remove******' call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -1002,8 +1008,8 @@ imud= 0 enddo - if (MudSystem%Ann_Mud_Forehead_X%Last() < MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) then - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length()) = MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) ! for error preventing + if (data%State%MudSystem%Ann_Mud_Forehead_X%Last() < data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections)) then + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%Ann_Mud_Forehead_X%Length()) = data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections) ! for error preventing endif !========================ANNULUS END================= @@ -1022,59 +1028,59 @@ imud= 0 !========================Bottom Hole================= imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Op_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif !write(*,*) 'imud**=' , imud - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Op_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal !write(*,*) ' Op_EmptyVolume_inBackheadLocation%Array(1) =' , Op_EmptyVolume_inBackheadLocation%Array(1) - if ( MudSystem%Op_EmptyVolume_inBackheadLocation%Array(1) < 0.0) CALL ErrorStop1 ('Negative Empty volume') + if ( data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(1) < 0.0) CALL ErrorStop1 ('Negative Empty volume') - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Op_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) + if (data%State%MudSystem%isection > data%State%F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) !if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts + data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts) + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%F_Counts%BottomHoleIntervalCounts - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveOpMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection) exit else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -1083,13 +1089,13 @@ imud=0 endif ! for OP remove: - if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then - MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() - do while(imud < MudSystem%totalLength) + if (data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)== data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts)) then + data%State%MudSystem%totalLength = data%State%MudSystem%Op_MudDischarged_Volume%Length() + do while(imud < data%State%MudSystem%totalLength) !imud = imud + 1 - call RemoveOpMudArrays(MudSystem%totalLength) - MudSystem%totalLength = MudSystem%totalLength - 1 + call RemoveOpMudArrays(data%State%MudSystem%totalLength) + data%State%MudSystem%totalLength = data%State%MudSystem%totalLength - 1 enddo @@ -1101,7 +1107,7 @@ imud=0 - !if (Op_Mud_Forehead_X%Array(imud)== Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then + !if (Op_Mud_Forehead_X%Array(imud)== Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts)) then ! totalLength = Op_MudDischarged_Volume%Length() ! do while(imud <= totalLength) ! @@ -1146,7 +1152,7 @@ imud=0 ! write(*,*) 'after sorting st==' ! ! do imud=1, st_MudDischarged_Volume%Length() - ! write(*,*) 'st-plot:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud)MudSystem%St_Density%Array(imud) + ! write(*,*) 'st-plot:', imud, St_MudDischarged_Volume%Array(imud), St_Mud_Backhead_X%Array(imud) ,St_Mud_Forehead_X%Array(imud)data%State%MudSystem%St_Density%Array(imud) ! enddo ! !write(*,*) '==after sorting st' @@ -1154,7 +1160,7 @@ imud=0 - !write(*,*) '**Ann_Kick_Saved_Final,Mud_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn + !write(*,*) '**Ann_Kick_Saved_Final,Mud_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,data%State%MudSystem%MudVolume_InjectedFromAnn end subroutine Pump_and_TripIn @@ -1173,14 +1179,20 @@ imud=0 Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure +use ConfigurationVariables !@@@ + use ConfigurationVariables + USE CHOKEVARIABLES +!use ConfigurationVariables !@ + !use CDataDisplayConsole + !@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES + use ConfigurationVariables !@ + USE CHOKEVARIABLES +!use ConfigurationVariables !@ !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity + use ConfigurationVariables + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule @@ -1207,7 +1219,7 @@ imud=0 - !write(*,*) 'Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,MudSystem%MudVolume_InjectedFromAnn + !write(*,*) 'Ann_Kick_Saved_Volume_Final,data%State%MudSystem%MudVolume_InjectedFromAnn' , Ann_Kick_Saved_Volume_Final,data%State%MudSystem%MudVolume_InjectedFromAnn !write(*,*) 'begining chokeline==' @@ -1217,17 +1229,17 @@ imud=0 - MudSystem%ChokeLineFlowRate = MUD(4)%Q - !WRITE (*,*) 'MUD(4)%Q', MUD(4)%Q + data%State%MudSystem%ChokeLineFlowRate = data%State%MUD(4)%Q + !WRITE (*,*) 'data%State%MUD(4)%Q', data%State%MUD(4)%Q - if (MudSystem%NewPipeFilling == 0) then ! .or. UtubeFilling==0) then - MudSystem%ChokeLineFlowRate= 0. + if (data%State%MudSystem%NewPipeFilling == 0) then ! .or. UtubeFilling==0) then + data%State%MudSystem%ChokeLineFlowRate= 0. endif - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then + do imud=1, data%State%MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 1' error_occured = 1 endif @@ -1244,32 +1256,32 @@ imud=0 !========================CHOKE LINE ENTRANCE================= !if ( Ann_Kick_Saved_Volume > 0.0 .and. ( Ann_Saved_MudDischarged_Volume-((Qlost/60.0d0)*DeltaT_Mudline) ) == 0.0 ) then - if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( MudSystem%MudVolume_InjectedFromAnn ) <= 1.0e-5 ) then + if ( data%State%MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( data%State%MudSystem%MudVolume_InjectedFromAnn ) <= 1.0e-5 ) then !WRITE (*,*) 'only kick enters to chokeline, Casing pressure = ', PressureGauges(2) - if (MudSystem%ChokeLine_MudOrKick%First() == 0) then - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_KickSaved_Density) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.d0) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (MudSystem%Saved_Ann_MudOrKick) + if (data%State%MudSystem%ChokeLine_MudOrKick%First() == 0) then + call data%State%MudSystem%ChokeLine_Density%AddToFirst (data%State%MudSystem%Ann_KickSaved_Density) + call data%State%MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.d0) + call data%State%MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_MudOrKick%AddToFirst (data%State%MudSystem%Saved_Ann_MudOrKick) - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_KickSaved_Density + data%State%MudSystem%ChokeLineDensity_Old= data%State%MudSystem%Ann_KickSaved_Density endif - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ MudSystem%Ann_Kick_Saved_Volume !(gal) + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ data%State%MudSystem%Ann_Kick_Saved_Volume !(gal) endif - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then + do imud=1, data%State%MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 2' error_occured = 1 @@ -1280,27 +1292,27 @@ imud=0 !if ( Ann_Kick_Saved_Volume == 0.0 .and. ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 ) then - if ( MudSystem%Ann_Kick_Saved_Volume <= 1.0e-5 .and. MudSystem%MudVolume_InjectedFromAnn > 1.0e-5 ) then + if ( data%State%MudSystem%Ann_Kick_Saved_Volume <= 1.0e-5 .and. data%State%MudSystem%MudVolume_InjectedFromAnn > 1.0e-5 ) then !WRITE (*,*) 'only mud enters to chokeline' - if ((MudSystem%Ann_to_Choke_2mud == .false. .and. ABS(MudSystem%ChokeLineDensity_Old - MudSystem%Ann_MudSaved_Density) >= MudSystem%DensityMixTol) .or. MudSystem%ChokeLine_MudOrKick%First() /= 0) then ! new mud is pumped - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_MudSaved_Density) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) + if ((data%State%MudSystem%Ann_to_Choke_2mud == .false. .and. ABS(data%State%MudSystem%ChokeLineDensity_Old - data%State%MudSystem%Ann_MudSaved_Density) >= data%State%MudSystem%DensityMixTol) .or. data%State%MudSystem%ChokeLine_MudOrKick%First() /= 0) then ! new mud is pumped + call data%State%MudSystem%ChokeLine_Density%AddToFirst (data%State%MudSystem%Ann_MudSaved_Density) + call data%State%MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_MudSaved_Density + data%State%MudSystem%ChokeLineDensity_Old= data%State%MudSystem%Ann_MudSaved_Density endif !ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1)+ (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) !(gal) - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ (MudSystem%MudVolume_InjectedFromAnn) !(gal) + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ (data%State%MudSystem%MudVolume_InjectedFromAnn) !(gal) @@ -1308,8 +1320,8 @@ imud=0 - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then + do imud=1, data%State%MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 3' error_occured = 1 @@ -1318,60 +1330,60 @@ imud=0 !if ( Ann_Kick_Saved_Volume > 0.0 .and. (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 .and. ChokeLine_MudOrKick%First() /= 0 ) then - if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. (MudSystem%MudVolume_InjectedFromAnn) > 1.0e-5 .and. MudSystem%ChokeLine_MudOrKick%First() /= 0 ) then + if ( data%State%MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. (data%State%MudSystem%MudVolume_InjectedFromAnn) > 1.0e-5 .and. data%State%MudSystem%ChokeLine_MudOrKick%First() /= 0 ) then WRITE (*,*) 'Kick Enters Choke line Last Time' - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ MudSystem%Ann_Kick_Saved_Volume !(gal) + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ data%State%MudSystem%Ann_Kick_Saved_Volume !(gal) - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_MudSaved_Density) + call data%State%MudSystem%ChokeLine_Density%AddToFirst (data%State%MudSystem%Ann_MudSaved_Density) !call ChokeLine_MudDischarged_Volume%AddToFirst (Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (MudSystem%MudVolume_InjectedFromAnn) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (0) + call data%State%MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (data%State%MudSystem%MudVolume_InjectedFromAnn) + call data%State%MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_MudOrKick%AddToFirst (0) - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_MudSaved_Density + data%State%MudSystem%ChokeLineDensity_Old= data%State%MudSystem%Ann_MudSaved_Density !ELSE if ( Ann_Kick_Saved_Volume > 0.0 .and. ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) > 0.0 .and. ChokeLine_MudOrKick%First() == 0 ) then - ELSE if ( MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( MudSystem%MudVolume_InjectedFromAnn ) > 1.0e-5 .and. MudSystem%ChokeLine_MudOrKick%First() == 0 ) then + ELSE if ( data%State%MudSystem%Ann_Kick_Saved_Volume > 1.0e-5 .and. ( data%State%MudSystem%MudVolume_InjectedFromAnn ) > 1.0e-5 .and. data%State%MudSystem%ChokeLine_MudOrKick%First() == 0 ) then WRITE (*,*) 'Kick Enters Choke line First Time' !ChokeLine_MudDischarged_Volume%Array(1)= ChokeLine_MudDischarged_Volume%Array(1)+ ( Ann_Saved_MudDischarged_Volume - ((Qlost/60.0d0)*DeltaT_Mudline) ) !(gal) - MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ ( MudSystem%MudVolume_InjectedFromAnn ) !(gal) + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(1)+ ( data%State%MudSystem%MudVolume_InjectedFromAnn ) !(gal) - call MudSystem%ChokeLine_Density%AddToFirst (MudSystem%Ann_KickSaved_Density) - call MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (MudSystem%Ann_Kick_Saved_Volume) - call MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) - call MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) - call MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%ChokeLine_MudOrKick%AddToFirst (MudSystem%Saved_Ann_MudOrKick) + call data%State%MudSystem%ChokeLine_Density%AddToFirst (data%State%MudSystem%Ann_KickSaved_Density) + call data%State%MudSystem%ChokeLine_MudDischarged_Volume%AddToFirst (data%State%MudSystem%Ann_Kick_Saved_Volume) + call data%State%MudSystem%ChokeLine_Mud_Forehead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_Mud_Backhead_X%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%ChokeLine_MudOrKick%AddToFirst (data%State%MudSystem%Saved_Ann_MudOrKick) - MudSystem%ChokeLineDensity_Old= MudSystem%Ann_KickSaved_Density + data%State%MudSystem%ChokeLineDensity_Old= data%State%MudSystem%Ann_KickSaved_Density endif - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 - if ( MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then + do imud=1, data%State%MudSystem%ChokeLine_MudDischarged_Volume%Length()-2 + if ( data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) ==1 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+1) ==0 .and. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud+2) ==1 ) then write(*,*) 'error_location is 4' error_occured = 1 @@ -1380,8 +1392,8 @@ imud=0 if (error_occured == 1) then - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length() - write(*,*) 'ChokeLine:', imud, MudSystem%ChokeLine_Density%Array(imud) ,MudSystem%ChokeLine_MudOrKick%Array(imud) + do imud=1, data%State%MudSystem%ChokeLine_MudDischarged_Volume%Length() + write(*,*) 'ChokeLine:', imud, data%State%MudSystem%ChokeLine_Density%Array(imud) ,data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) enddo endif @@ -1402,40 +1414,40 @@ imud=0 !=============== save Choke Mud data========================== - MudSystem%ChokeMudVolumeSum= 0.d0 + data%State%MudSystem%ChokeMudVolumeSum= 0.d0 !Ann_MudSaved_Density= 0.d0 !Ann_KickSaved_Density= 0.d0 - MudSystem%Choke_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Choke_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Choke_MudOrKick= 0 + data%State%MudSystem%Choke_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%Choke_Kick_Saved_Volume= 0.d0 + data%State%MudSystem%Saved_Choke_MudOrKick= 0 - do imud=1, MudSystem%ChokeLine_MudDischarged_Volume%Length() + do imud=1, data%State%MudSystem%ChokeLine_MudDischarged_Volume%Length() - MudSystem%ChokeMudVolumeSum= MudSystem%ChokeMudVolumeSum + MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) + data%State%MudSystem%ChokeMudVolumeSum= data%State%MudSystem%ChokeMudVolumeSum + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) - if ( MudSystem%ChokeMudVolumeSum > MudSystem%ChokeLine_VolumeCapacity ) then + if ( data%State%MudSystem%ChokeMudVolumeSum > data%State%MudSystem%ChokeLine_VolumeCapacity ) then - IF (MudSystem%ChokeLine_MudOrKick%Array(imud) == 0) THEN - MudSystem%Choke_MudSaved_Density = MudSystem%ChokeLine_Density%Array(imud) - MudSystem%Choke_Saved_MudDischarged_Volume = MudSystem%ChokeMudVolumeSum - MudSystem%ChokeLine_VolumeCapacity - ELSEIF (MudSystem%ChokeLine_MudOrKick%Array(imud) > 0 .AND. MudSystem%ChokeLine_MudOrKick%Array(imud) <100) THEN ! 104= AIR - MudSystem%Choke_Kick_Saved_Volume = MudSystem%ChokeMudVolumeSum - MudSystem%ChokeLine_VolumeCapacity - MudSystem%Saved_Choke_MudOrKick= MudSystem%ChokeLine_MudOrKick%Array (imud) - MudSystem%Choke_KickSaved_Density= MudSystem%ChokeLine_Density%Array(imud) + IF (data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) == 0) THEN + data%State%MudSystem%Choke_MudSaved_Density = data%State%MudSystem%ChokeLine_Density%Array(imud) + data%State%MudSystem%Choke_Saved_MudDischarged_Volume = data%State%MudSystem%ChokeMudVolumeSum - data%State%MudSystem%ChokeLine_VolumeCapacity + ELSEIF (data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) > 0 .AND. data%State%MudSystem%ChokeLine_MudOrKick%Array(imud) <100) THEN ! 104= AIR + data%State%MudSystem%Choke_Kick_Saved_Volume = data%State%MudSystem%ChokeMudVolumeSum - data%State%MudSystem%ChokeLine_VolumeCapacity + data%State%MudSystem%Saved_Choke_MudOrKick= data%State%MudSystem%ChokeLine_MudOrKick%Array (imud) + data%State%MudSystem%Choke_KickSaved_Density= data%State%MudSystem%ChokeLine_Density%Array(imud) END IF - do ii= imud + 1, MudSystem%ChokeLine_MudDischarged_Volume%Length() - - IF (MudSystem%ChokeLine_MudOrKick%Array(ii) == 0) THEN - MudSystem%Choke_MudSaved_Density = ((MudSystem%Choke_MudSaved_Density * MudSystem%Choke_Saved_MudDischarged_Volume) + (MudSystem%ChokeLine_Density%Array(ii) * MudSystem%ChokeLine_MudDischarged_Volume%Array(ii))) / (MudSystem%Choke_Saved_MudDischarged_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii)) - MudSystem%Choke_Saved_MudDischarged_Volume = MudSystem%Choke_Saved_MudDischarged_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) - ELSEIF (MudSystem%ChokeLine_MudOrKick%Array(ii) > 0 .AND. MudSystem%ChokeLine_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystem%Choke_Kick_Saved_Volume = MudSystem%Choke_Kick_Saved_Volume + MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Choke_MudOrKick= MudSystem%ChokeLine_MudOrKick%Array (ii) - MudSystem%Choke_KickSaved_Density= MudSystem%ChokeLine_Density%Array(ii) + do ii= imud + 1, data%State%MudSystem%ChokeLine_MudDischarged_Volume%Length() + + IF (data%State%MudSystem%ChokeLine_MudOrKick%Array(ii) == 0) THEN + data%State%MudSystem%Choke_MudSaved_Density = ((data%State%MudSystem%Choke_MudSaved_Density * data%State%MudSystem%Choke_Saved_MudDischarged_Volume) + (data%State%MudSystem%ChokeLine_Density%Array(ii) * data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(ii))) / (data%State%MudSystem%Choke_Saved_MudDischarged_Volume + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(ii)) + data%State%MudSystem%Choke_Saved_MudDischarged_Volume = data%State%MudSystem%Choke_Saved_MudDischarged_Volume + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) + ELSEIF (data%State%MudSystem%ChokeLine_MudOrKick%Array(ii) > 0 .AND. data%State%MudSystem%ChokeLine_MudOrKick%Array(ii) <100) THEN ! 104= AIR + data%State%MudSystem%Choke_Kick_Saved_Volume = data%State%MudSystem%Choke_Kick_Saved_Volume + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(ii) + data%State%MudSystem%Saved_Choke_MudOrKick= data%State%MudSystem%ChokeLine_MudOrKick%Array (ii) + data%State%MudSystem%Choke_KickSaved_Density= data%State%MudSystem%ChokeLine_Density%Array(ii) END IF enddo @@ -1446,8 +1458,8 @@ imud=0 endif enddo -MudSystem%Choke_Saved_MudDischarged_Volume_Final= MudSystem%Choke_Saved_MudDischarged_Volume !+ Choke_Kick_Saved_Volume -MudSystem%Choke_Kick_Saved_Volume_Final= MudSystem%Choke_Kick_Saved_Volume +data%State%MudSystem%Choke_Saved_MudDischarged_Volume_Final= data%State%MudSystem%Choke_Saved_MudDischarged_Volume !+ Choke_Kick_Saved_Volume +data%State%MudSystem%Choke_Kick_Saved_Volume_Final= data%State%MudSystem%Choke_Kick_Saved_Volume !====================================================================== @@ -1467,12 +1479,12 @@ MudSystem%Choke_Kick_Saved_Volume_Final= MudSystem%Choke_Kick_Saved_Volume !========================Choke Line================= imud=0 - do while (imud < MudSystem%ChokeLine_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%ChokeLine_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)= MudSystem%ChokeLine_Mud_Forehead_X%Array(imud-1) - MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)= MudSystem%ChokeLine_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)= data%State%MudSystem%ChokeLine_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)= data%State%MudSystem%ChokeLine_Mud_Forehead_section%Array(imud-1) endif @@ -1481,49 +1493,49 @@ imud=0 ! +1 for string , -1 for annulus - MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= (BopStackSpecification%ChokeLineLength- MudSystem%ChokeLine_Mud_Backhead_X%Array(imud))* MudSystem%Area_ChokeLineFt !(ft^3) + data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= (BopStackSpecification%ChokeLineLength- data%State%MudSystem%ChokeLine_Mud_Backhead_X%Array(imud))* data%State%MudSystem%Area_ChokeLineFt !(ft^3) - MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) <= MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= MudSystem%ChokeLine_Mud_Backhead_section%Array(imud) - MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)+ (MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_ChokeLineFt + if ( data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= data%State%MudSystem%ChokeLine_Mud_Backhead_section%Array(imud) + data%State%MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= data%State%MudSystem%ChokeLine_Mud_Backhead_X%Array(imud)+ (data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_ChokeLineFt ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)+1 - MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%ChokeLine_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > 1) then ! last pipe section(Chokeline exit) - MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)= MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud) - MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= BopStackSpecification%ChokeLineLength - MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= 1 - if (MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string - call MudSystem%ChokeLine_MudDischarged_Volume%Remove (imud) - call MudSystem%ChokeLine_Mud_Backhead_X%Remove (imud) - call MudSystem%ChokeLine_Mud_Backhead_section%Remove (imud) - call MudSystem%ChokeLine_Mud_Forehead_X%Remove (imud) - call MudSystem%ChokeLine_Mud_Forehead_section%Remove (imud) - call MudSystem%ChokeLine_Density%Remove (imud) - call MudSystem%ChokeLine_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%ChokeLine_MudOrKick%Remove (imud) + if (data%State%MudSystem%isection > 1) then ! last pipe section(Chokeline exit) + data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)= data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)- data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= BopStackSpecification%ChokeLineLength + data%State%MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= 1 + if (data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + call data%State%MudSystem%ChokeLine_MudDischarged_Volume%Remove (imud) + call data%State%MudSystem%ChokeLine_Mud_Backhead_X%Remove (imud) + call data%State%MudSystem%ChokeLine_Mud_Backhead_section%Remove (imud) + call data%State%MudSystem%ChokeLine_Mud_Forehead_X%Remove (imud) + call data%State%MudSystem%ChokeLine_Mud_Forehead_section%Remove (imud) + call data%State%MudSystem%ChokeLine_Density%Remove (imud) + call data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Remove (imud) + call data%State%MudSystem%ChokeLine_EmptyVolume_inBackheadLocation%Remove (imud) + call data%State%MudSystem%ChokeLine_MudOrKick%Remove (imud) endif exit endif - MudSystem%xx= MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%ChokeLine_VolumeCapacity !(gal) + data%State%MudSystem%xx= data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%ChokeLine_VolumeCapacity !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= MudSystem%xx * BopStackSpecification%ChokeLineLength + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%ChokeLine_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%ChokeLine_Mud_Forehead_X%Array(imud)= data%State%MudSystem%xx * BopStackSpecification%ChokeLineLength exit else - MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)- MudSystem%ChokeLine_VolumeCapacity - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%ChokeLine_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%ChokeLine_VolumeCapacity + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -1539,17 +1551,17 @@ imud=0 ! write(*,*) 'b)ChokeLine:', imud, ChokeLine_MudDischarged_Volume%Array(imud) ,ChokeLine_MudOrKick%Array(imud) !enddo - MudSystem%ChokeOutletDensity= MudSystem%ChokeLine_Density%Last() ! used in MudSystem + data%State%MudSystem%ChokeOutletDensity= data%State%MudSystem%ChokeLine_Density%Last() ! used in MudSystem - do i=1, MudSystem%ChokeLine_MudOrKick%Length() + do i=1, data%State%MudSystem%ChokeLine_MudOrKick%Length() !write(*,555) i,'Choke_Volume(i), type=' ,ChokeLine_MudDischarged_Volume%Array(i),ChokeLine_MudOrKick%Array(i) - IF (IEEE_Is_NaN(MudSystem%ChokeLine_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in Choke Volume-Plot') - IF (MudSystem%ChokeLine_MudDischarged_Volume%Array(i)<=0.) call ErrorStop('Choke Volume= <=0' , MudSystem%ChokeLine_MudDischarged_Volume%Array(i)) + IF (IEEE_Is_NaN(data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(i))) call ErrorStop('NaN in Choke Volume-Plot') + IF (data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(i)<=0.) call ErrorStop('Choke Volume= <=0' , data%State%MudSystem%ChokeLine_MudDischarged_Volume%Array(i)) enddo 555 FORMAT(I3,5X,A42,(f12.5),5X,I3) @@ -1587,14 +1599,20 @@ use CSounds !Use GeoElements_FluidModule !USE CMudPropertiesVariables USE MudSystemVARIABLES - !USE Pumps_VARIABLES - !!USE CHOKEVARIABLES - !!USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure +use ConfigurationVariables !@@@ + !use ConfigurationVariables + !USE CHOKEVARIABLES +!use ConfigurationVariables !@ + !!use CDataDisplayConsole + !@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure !!use CManifolds - !use CDrillWatchVariables - !!use CHOKEVARIABLES + !use ConfigurationVariables !@ + !USE CHOKEVARIABLES +!use ConfigurationVariables !@ !!use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => TripTankVolume, TripTankDensity2 => TripTankDensity + use ConfigurationVariables + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => TripTankVolume, TripTankDensity2 => TripTankDensity !USE sROP_Other_Variables !USE sROP_Variables !use KickVARIABLESModule @@ -1606,22 +1624,22 @@ use CSounds - if ( MudSystem%ChokeLine_MudOrKick%Last() > 0 .AND. MudSystem%WellToChokeManifoldOpen == .true.) then + if ( data%State%MudSystem%ChokeLine_MudOrKick%Last() > 0 .AND. data%State%MudSystem%WellToChokeManifoldOpen == .true.) then !WellToChokeManifoldWasOpen - MudSystem%SoundGasThroughChoke = 100 !100:chon dar adadhaye kamtar az 100 seda ghaat mishavad. eslah shavad.5.8.98 !int (min(ChokeLineFlowRate/2. , 100.)) - print* , 'SoundGasThroughChoke1=', MudSystem%SoundGasThroughChoke + data%State%MudSystem%SoundGasThroughChoke = 100 !100:chon dar adadhaye kamtar az 100 seda ghaat mishavad. eslah shavad.5.8.98 !int (min(ChokeLineFlowRate/2. , 100.)) + print* , 'SoundGasThroughChoke1=', data%State%MudSystem%SoundGasThroughChoke !WRITE (*,*) 'WellToChokeManifoldWasOpen-Sound', WellToChokeManifoldWasOpen - WRITE (*,*) 'WellToChokeManifoldOpen', MudSystem%WellToChokeManifoldOpen + WRITE (*,*) 'WellToChokeManifoldOpen', data%State%MudSystem%WellToChokeManifoldOpen else - MudSystem%SoundGasThroughChoke = 0 - print* , 'SoundGasThroughChoke2=', MudSystem%SoundGasThroughChoke + data%State%MudSystem%SoundGasThroughChoke = 0 + print* , 'SoundGasThroughChoke2=', data%State%MudSystem%SoundGasThroughChoke endif !print* , 'SoundGasThroughChoke3=', SoundGasThroughChoke - call SetSoundGasThroughChoke(MudSystem%SoundGasThroughChoke) + call SetSoundGasThroughChoke(data%State%MudSystem%SoundGasThroughChoke) end subroutine Choke_GasSound \ No newline at end of file diff --git a/Equipments/MudSystem/Trip_Out_andPump.f90 b/Equipments/MudSystem/Trip_Out_andPump.f90 index 2defaab..1102c6e 100644 --- a/Equipments/MudSystem/Trip_Out_andPump.f90 +++ b/Equipments/MudSystem/Trip_Out_andPump.f90 @@ -3,14 +3,20 @@ subroutine TripOut_and_Pump ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - !USE CHOKEVARIABLES - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure +use ConfigurationVariables !@@@ + use ConfigurationVariables + USE CHOKEVARIABLES +!use ConfigurationVariables !@ + !use CDataDisplayConsole + !!@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure !use CManifolds - use CDrillWatchVariables - !use CHOKEVARIABLES + use ConfigurationVariables !@ + USE CHOKEVARIABLES +!use ConfigurationVariables !@ !use CChokeManifoldVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity + use ConfigurationVariables + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables use KickVARIABLESModule @@ -25,9 +31,9 @@ Real(8) ExcessMudVolume_Remained,SavedDensityForOp !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystem%StringFlowRate= MUD(2)%Q - MudSystem%AnnulusFlowRate= MUD(2)%Q - !write(*,*) 'MUD(2)%Q=====' , MUD(2)%Q + data%State%MudSystem%StringFlowRate= data%State%MUD(2)%Q + data%State%MudSystem%AnnulusFlowRate= data%State%MUD(2)%Q + !write(*,*) 'data%State%MUD(2)%Q=====' , data%State%MUD(2)%Q write(*,*) 'Trip Out' @@ -48,90 +54,90 @@ Real(8) ExcessMudVolume_Remained,SavedDensityForOp !========================Horizontal PIPE ENTRANCE================= - if (ABS(MudSystem%SuctionDensity_Old - MudSystem%Suction_Density_MudSystem) >= MudSystem%DensityMixTol) then ! new mud is pumped + if (ABS(data%State%MudSystem%SuctionDensity_Old - data%State%MudSystem%Suction_Density_MudSystem) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%Hz_Density%AddToFirst (MudSystem%Suction_Density_MudSystem) - call MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%Hz_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) - call MudSystem%Hz_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(1)) - call MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) - call MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Hz_MudOrKick%AddToFirst (0) + call data%State%MudSystem%Hz_Density%AddToFirst (data%State%MudSystem%Suction_Density_MudSystem) + call data%State%MudSystem%Hz_MudDischarged_Volume%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(1)) + call data%State%MudSystem%Hz_Mud_Forehead_section%AddToFirst (1) + call data%State%MudSystem%Hz_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(1)) + call data%State%MudSystem%Hz_Mud_Backhead_section%AddToFirst (1) + call data%State%MudSystem%Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Hz_MudOrKick%AddToFirst (0) - MudSystem%SuctionDensity_Old= MudSystem%Suction_Density_MudSystem + data%State%MudSystem%SuctionDensity_Old= data%State%MudSystem%Suction_Density_MudSystem endif !========================Horizontal PIPE STRING================= - MudSystem%Hz_MudDischarged_Volume%Array(1)= MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + data%State%MudSystem%Hz_MudDischarged_Volume%Array(1)= data%State%MudSystem%Hz_MudDischarged_Volume%Array(1)+ ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) - MudSystem%total_add = MudSystem%total_add + ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%total_add = data%State%MudSystem%total_add + ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_add= 0. + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + data%State%MudSystem%total_add= 0. endif !write(*,*) ' total decrease(add to HZ)=' , total_add - !write(*,*) ' add to HZ=' , ((MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) + !write(*,*) ' add to HZ=' , ((data%State%MudSystem%StringFlowRate/60.0d0)*DeltaT_Mudline) imud=0 - do while (imud < MudSystem%Hz_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Hz_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Hz_Mud_Backhead_X%Array(imud)= MudSystem%Hz_Mud_Forehead_X%Array(imud-1) - MudSystem%Hz_Mud_Backhead_section%Array(imud)= MudSystem%Hz_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Hz_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Hz_Mud_Backhead_section%Array(imud))- MudSystem%Hz_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Hz_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Hz_MudDischarged_Volume%Array(imud) <= MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%Hz_Mud_Backhead_section%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Hz_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Hz_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Hz_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)) else - MudSystem%isection= MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Hz_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Hz_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > 1) then ! (horizontal pipe exit) - MudSystem%Hz_MudDischarged_Volume%Array(imud)= MudSystem%Hz_MudDischarged_Volume%Array(imud)- MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Hz_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(1) - MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 + if (data%State%MudSystem%isection > 1) then ! (horizontal pipe exit) + data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(1) + data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud)= 1 - if (MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + if (data%State%MudSystem%Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string call RemoveHzMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Hz_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Hz_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Hz_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Hz_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Hz_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -148,7 +154,7 @@ imud=0 !if (UtubeMode1Activated== .true.) then ! StringUpdate == .true. ! - ! StringDensity_Old= MudSystem%St_Density%Array(2) + ! StringDensity_Old= data%State%MudSystem%St_Density%Array(2) ! ! UtubeMode1Activated= .false. !endif @@ -158,14 +164,14 @@ imud=0 !========================Utube2 Removing from Annulus================= - if (MudSystem%UtubeMode2Activated== .true.) then ! StringUpdate == .true. - MudSystem%TotalAddedVolume=0. + if (data%State%MudSystem%UtubeMode2Activated== .true.) then ! StringUpdate == .true. + data%State%MudSystem%TotalAddedVolume=0. - if (MudSystem%Ann_MudOrKick%Last() == 104) then !movaghati. albate age merge anjam shode bashe moshkeli nist - call RemoveAnnulusMudArrays(MudSystem%Ann_MudOrKick%Length()) + if (data%State%MudSystem%Ann_MudOrKick%Last() == 104) then !movaghati. albate age merge anjam shode bashe moshkeli nist + call RemoveAnnulusMudArrays(data%State%MudSystem%Ann_MudOrKick%Length()) endif - MudSystem%UtubeMode2Activated= .false. + data%State%MudSystem%UtubeMode2Activated= .false. endif @@ -173,25 +179,25 @@ imud=0 !========================New Pipe Filling================= - if (MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. + if (data%State%MudSystem%AddedElementsToString > 0) then ! StringUpdate == .true. !NoPipeAdded= F_StringIntervalCounts - F_StringIntervalCountsOld - MudSystem%NewPipeFilling=0 + data%State%MudSystem%NewPipeFilling=0 - IF (MudSystem%St_MudOrKick%First() == 104) then - MudSystem%St_MudDischarged_Volume%Array(1) = MudSystem%St_MudDischarged_Volume%Array(1) + sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString)) ! new pipe is filled by air + IF (data%State%MudSystem%St_MudOrKick%First() == 104) then + data%State%MudSystem%St_MudDischarged_Volume%Array(1) = data%State%MudSystem%St_MudDischarged_Volume%Array(1) + sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:1+data%State%MudSystem%AddedElementsToString)) ! new pipe is filled by air else - call MudSystem%St_Density%AddToFirst (0.d0) - call MudSystem%St_MudDischarged_Volume%AddToFirst (sum(MudSystem%PipeSection_VolumeCapacity(2:1+MudSystem%AddedElementsToString))) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) - call MudSystem%St_MudOrKick%AddToFirst (104) + call data%State%MudSystem%St_Density%AddToFirst (0.d0) + call data%State%MudSystem%St_MudDischarged_Volume%AddToFirst (sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:1+data%State%MudSystem%AddedElementsToString))) + call data%State%MudSystem%St_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call data%State%MudSystem%St_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.d0) + call data%State%MudSystem%St_MudOrKick%AddToFirst (104) endif endif @@ -200,46 +206,46 @@ imud=0 - if (MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) + if (data%State%MudSystem%NewPipeFilling == 0) then ! 2= is the first element of string (1= is for Hz pipe) - MudSystem%LackageMudVolume= MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element + data%State%MudSystem%LackageMudVolume= data%State%MudSystem%St_MudDischarged_Volume%Array(1) ! = Air element !write(*,*) 'LackageMudVolume=' , LackageMudVolume - if (ABS(MudSystem%St_Density%Array(2) - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddTo (2,MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddTo (2,0.d0) - call MudSystem%St_Mud_Forehead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) - call MudSystem%St_Mud_Backhead_X%AddTo (2,MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) - call MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) - call MudSystem%St_MudOrKick%AddTo (2,0) + if (ABS(data%State%MudSystem%St_Density%Array(2) - data%State%MudSystem%Hz_Density%Last()) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped + call data%State%MudSystem%St_Density%AddTo (2,data%State%MudSystem%Hz_Density%Last()) + call data%State%MudSystem%St_MudDischarged_Volume%AddTo (2,0.d0) + call data%State%MudSystem%St_Mud_Forehead_X%AddTo (2,data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Forehead_section%AddTo (2 , 2) + call data%State%MudSystem%St_Mud_Backhead_X%AddTo (2,data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddTo (2 ,2) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddTo (2,0.d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddTo (2,0.d0) + call data%State%MudSystem%St_MudOrKick%AddTo (2,0) !StringDensity_Old= Hz_Density%Last() endif - MudSystem%St_MudDischarged_Volume%Array(2)= MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) !(gal) + data%State%MudSystem%St_MudDischarged_Volume%Array(2)= data%State%MudSystem%St_MudDischarged_Volume%Array(2)+ min( ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline), data%State%MudSystem%LackageMudVolume) !(gal) - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)- min( ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline), MudSystem%LackageMudVolume) ! air(gal) + data%State%MudSystem%St_MudDischarged_Volume%Array(1)= data%State%MudSystem%St_MudDischarged_Volume%Array(1)- min( ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline), data%State%MudSystem%LackageMudVolume) ! air(gal) !LackageMudVolumeAfterFilling= sum(PipeSection_VolumeCapacity(2:F_StringIntervalCounts)) - sum(St_MudDischarged_Volume%Array(:)) - MudSystem%LackageMudVolumeAfterFilling= MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero + data%State%MudSystem%LackageMudVolumeAfterFilling= data%State%MudSystem%St_MudDischarged_Volume%Array(1) ! last time it should be zero - if (MudSystem%LackageMudVolumeAfterFilling == 0.) then - MudSystem%NewPipeFilling= 1 + if (data%State%MudSystem%LackageMudVolumeAfterFilling == 0.) then + data%State%MudSystem%NewPipeFilling= 1 call RemoveStringMudArrays(1) - MudSystem%St_Mud_Backhead_X%Array(1) = MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(1) = 2 + data%State%MudSystem%St_Mud_Backhead_X%Array(1) = data%State%MudSystem%Xstart_PipeSection(2) + data%State%MudSystem%St_Mud_Backhead_section%Array(1) = 2 endif endif @@ -247,60 +253,60 @@ imud=0 !========================New Pipe Filling End================= - if (MudSystem%NewPipeFilling == 0) then - MudSystem%StringFlowRate= 0. - MudSystem%AnnulusFlowRate= 0. + if (data%State%MudSystem%NewPipeFilling == 0) then + data%State%MudSystem%StringFlowRate= 0. + data%State%MudSystem%AnnulusFlowRate= 0. endif - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate + data%State%MudSystem%StringFlowRateFinal= data%State%MudSystem%StringFlowRate + data%State%MudSystem%AnnulusFlowRateFinal= data%State%MudSystem%AnnulusFlowRate !========================STRING ENTRANCE================= - if (MudSystem%StringFlowRateFinal > 0.0 .and. ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density%Last()) >= MudSystem%DensityMixTol) then ! new mud is pumped + if (data%State%MudSystem%StringFlowRateFinal > 0.0 .and. ABS(data%State%MudSystem%St_Density%First() - data%State%MudSystem%Hz_Density%Last()) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped !if (ABS(StringDensity_Old - Hz_Density%Last()) >= DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density%Last()) - call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (0) + call data%State%MudSystem%St_Density%AddToFirst (data%State%MudSystem%Hz_Density%Last()) + call data%State%MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) + call data%State%MudSystem%St_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call data%State%MudSystem%St_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%St_MudOrKick%AddToFirst (0) !StringDensity_Old= Hz_Density%Last() endif - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + data%State%MudSystem%St_MudDischarged_Volume%Array(1)= data%State%MudSystem%St_MudDischarged_Volume%Array(1)+ ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) !=============== save String Mud data=========== - MudSystem%StMudVolumeSum= 0.d0 + data%State%MudSystem%StMudVolumeSum= 0.d0 !St_MudSaved_Density= 0.d0 - MudSystem%St_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%St_Saved_MudDischarged_Volume= 0.d0 !Saved_St_MudOrKick= 0 !Ann_to_Choke_2mud= .false. - do imud=1, MudSystem%St_MudDischarged_Volume%Length() - MudSystem%StMudVolumeSum= MudSystem%StMudVolumeSum + MudSystem%St_MudDischarged_Volume%Array(imud) - if ( MudSystem%StMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) ) then + do imud=1, data%State%MudSystem%St_MudDischarged_Volume%Length() + data%State%MudSystem%StMudVolumeSum= data%State%MudSystem%StMudVolumeSum + data%State%MudSystem%St_MudDischarged_Volume%Array(imud) + if ( data%State%MudSystem%StMudVolumeSum > sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:data%State%F_Counts%StringIntervalCounts)) ) then !IF (St_MudOrKick%Array(imud) == 0) THEN - MudSystem%St_MudSaved_Density = MudSystem%St_Density%Array(imud) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%StMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(2:F_Counts%StringIntervalCounts)) + data%State%MudSystem%St_MudSaved_Density = data%State%MudSystem%St_Density%Array(imud) + data%State%MudSystem%St_Saved_MudDischarged_Volume = data%State%MudSystem%StMudVolumeSum - sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:data%State%F_Counts%StringIntervalCounts)) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = StMudVolumeSum - sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) ! Saved_St_MudOrKick= St_MudOrKick%Array (imud) - ! St_KickSaved_Density= MudSystem%St_Density%Array(imud) + ! St_KickSaved_Density= data%State%MudSystem%St_Density%Array(imud) !END IF - do ii= imud + 1, MudSystem%St_MudDischarged_Volume%Length() + do ii= imud + 1, data%State%MudSystem%St_MudDischarged_Volume%Length() !IF (St_MudOrKick%Array(ii) == 0) THEN - MudSystem%St_MudSaved_Density = ((MudSystem%St_MudSaved_Density * MudSystem%St_Saved_MudDischarged_Volume) + (MudSystem%St_Density%Array(ii) * MudSystem%St_MudDischarged_Volume%Array(ii))) / (MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii)) - MudSystem%St_Saved_MudDischarged_Volume = MudSystem%St_Saved_MudDischarged_Volume + MudSystem%St_MudDischarged_Volume%Array(ii) + data%State%MudSystem%St_MudSaved_Density = ((data%State%MudSystem%St_MudSaved_Density * data%State%MudSystem%St_Saved_MudDischarged_Volume) + (data%State%MudSystem%St_Density%Array(ii) * data%State%MudSystem%St_MudDischarged_Volume%Array(ii))) / (data%State%MudSystem%St_Saved_MudDischarged_Volume + data%State%MudSystem%St_MudDischarged_Volume%Array(ii)) + data%State%MudSystem%St_Saved_MudDischarged_Volume = data%State%MudSystem%St_Saved_MudDischarged_Volume + data%State%MudSystem%St_MudDischarged_Volume%Array(ii) !ELSEIF (St_MudOrKick%Array(imud) > 0 .AND. St_MudOrKick%Array(imud) <100) THEN ! 104= AIR ! St_Kick_Saved_Volume = St_Kick_Saved_Volume + St_MudDischarged_Volume%Array(ii) ! Saved_St_MudOrKick= St_MudOrKick%Array (ii) - ! St_KickSaved_Density= MudSystem%St_Density%Array(ii) + ! St_KickSaved_Density= data%State%MudSystem%St_Density%Array(ii) !END IF enddo @@ -311,9 +317,9 @@ imud=0 endif enddo -MudSystem%St_Saved_MudDischarged_Volume_Final= MudSystem%St_Saved_MudDischarged_Volume +data%State%MudSystem%St_Saved_MudDischarged_Volume_Final= data%State%MudSystem%St_Saved_MudDischarged_Volume -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final +IF (data%State%MudSystem%WellHeadIsOpen) data%State%MudSystem%MudVolume_InjectedToBH = data%State%MudSystem%St_Saved_MudDischarged_Volume_Final !====================================================================== @@ -321,55 +327,55 @@ IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedToBH = MudSystem%S !========================STRING================= imud=0 - do while (imud < MudSystem%St_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%St_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%St_Mud_Backhead_X%Array(imud)= data%State%MudSystem%St_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%St_Mud_Backhead_section%Array(imud)= data%State%MudSystem%St_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))- data%State%MudSystem%St_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%St_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%MudSystem%St_Mud_Backhead_section%Array(imud) + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= data%State%MudSystem%St_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%St_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > F_Counts%StringIntervalCounts) then ! last pipe section(string exit) - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Forehead_section%Array(imud)= F_Counts%StringIntervalCounts + if (data%State%MudSystem%isection > data%State%F_Counts%StringIntervalCounts) then ! last pipe section(string exit) + data%State%MudSystem%St_MudDischarged_Volume%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts) + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%F_Counts%StringIntervalCounts - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + if (data%State%MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string call RemoveStringMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -399,17 +405,17 @@ imud=0 iloc_changedTo2 = 0 - IF (MudSystem%Op_MudOrKick%Last() /= 0 .and. MudSystem%Op_MudOrKick%Last()==MudSystem%Ann_MudOrKick%First()) then - MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick + IF (data%State%MudSystem%Op_MudOrKick%Last() /= 0 .and. data%State%MudSystem%Op_MudOrKick%Last()==data%State%MudSystem%Ann_MudOrKick%First()) then + data%State%MudSystem%iLoc=2 ! it may be 1,2,3 or more, all of them are kick iloc_changedTo2= 1 endif iloc_edited= 0 - !write(*,*) sum(Op_MudDischarged_Volume%Array(:)) , ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) , Ann_MudDischarged_Volume%First() , sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) - if (MudSystem%iLoc==2 .and. sum(MudSystem%Op_MudDischarged_Volume%Array(:))+((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)+MudSystem%Ann_MudDischarged_Volume%First() < sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then - MudSystem%iLoc = 1 + !write(*,*) sum(Op_MudDischarged_Volume%Array(:)) , ((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) , Ann_MudDischarged_Volume%First() , sum(OpSection_VolumeCapacity(1:F_BottomHoleIntervalCounts)) + if (data%State%MudSystem%iLoc==2 .and. sum(data%State%MudSystem%Op_MudDischarged_Volume%Array(:))+((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline)+data%State%MudSystem%Ann_MudDischarged_Volume%First() < sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) ) then + data%State%MudSystem%iLoc = 1 iloc_edited = 1 !write(*,*) 'hellooooooo' endif @@ -423,45 +429,45 @@ imud=0 !=============================Add PumpFlowRate to Bottom Hole ============================== - !if ( MudSystem%AnnulusFlowRate>0.0 ) then - if ( MudSystem%MudVolume_InjectedToBH > 0.0 ) then + !if ( data%State%MudSystem%AnnulusFlowRate>0.0 ) then + if ( data%State%MudSystem%MudVolume_InjectedToBH > 0.0 ) then if (KickVARIABLES%KickOffBottom) then ! (kickOffBottom = F) means kick is next to the bottom hole and usually kick is entering the - AddLocation= MudSystem%Op_Density%Length()-MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick + AddLocation= data%State%MudSystem%Op_Density%Length()-data%State%MudSystem%iLoc+1+1 ! well, thus pumped mud should be placed above the kick else - AddLocation= MudSystem%Op_Density%Length()+1 + AddLocation= data%State%MudSystem%Op_Density%Length()+1 endif !write(*,*) 'AddLocation====' , AddLocation if ( AddLocation== 0) CALL ErrorStop ('AddLocation=0') - if ( ABS(MudSystem%St_Density%Last() - MudSystem%Op_Density%Array(AddLocation-1)) >= MudSystem%DensityMixTol ) then + if ( ABS(data%State%MudSystem%St_Density%Last() - data%State%MudSystem%Op_Density%Array(AddLocation-1)) >= data%State%MudSystem%DensityMixTol ) then !write(*,*) 'new pocket**' - !write(*,*) 'MudSystem%St_Density%Last()=' , MudSystem%St_Density%Last() + !write(*,*) 'data%State%MudSystem%St_Density%Last()=' , data%State%MudSystem%St_Density%Last() !write(*,*) 'Op_Density%Array(AddLocation-1)=' , Op_Density%Array(AddLocation-1) - call MudSystem%Op_Density% AddTo (AddLocation,MudSystem%St_Density%Last()) - !call Op_MudDischarged_Volume%AddTo (AddLocation,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - call MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,MudSystem%MudVolume_InjectedToBH) - call MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) - call MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,MudSystem%Xstart_OpSection(1)) - call MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) - call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) - call MudSystem%Op_MudOrKick%AddTo (AddLocation,0) + call data%State%MudSystem%Op_Density% AddTo (AddLocation,data%State%MudSystem%St_Density%Last()) + !call Op_MudDischarged_Volume%AddTo (AddLocation,((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + call data%State%MudSystem%Op_MudDischarged_Volume%AddTo (AddLocation,data%State%MudSystem%MudVolume_InjectedToBH) + call data%State%MudSystem%Op_Mud_Forehead_X%AddTo (AddLocation,data%State%MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Op_Mud_Forehead_section%AddTo (AddLocation,1) + call data%State%MudSystem%Op_Mud_Backhead_X%AddTo (AddLocation,data%State%MudSystem%Xstart_OpSection(1)) + call data%State%MudSystem%Op_Mud_Backhead_section%AddTo (AddLocation,1) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddTo (AddLocation,0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (AddLocation,0.0d0) + call data%State%MudSystem%Op_MudOrKick%AddTo (AddLocation,0) else !write(*,*) 'merge**' !write(*,*) 'density before=' , Op_Density%Array(AddLocation-1) - !write(*,*) 'MudSystem%St_Density%Last() for mix=' , MudSystem%St_Density%Last() + !write(*,*) 'data%State%MudSystem%St_Density%Last() for mix=' , data%State%MudSystem%St_Density%Last() - !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) - !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) + !Op_Density%Array(AddLocation-1)= (Op_Density%Array(AddLocation-1)*Op_MudDischarged_Volume%Array(AddLocation-1)+data%State%MudSystem%St_Density%Last()*((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline))/(Op_MudDischarged_Volume%Array(AddLocation-1)+((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)) + !Op_MudDischarged_Volume%Array(AddLocation-1)= Op_MudDischarged_Volume%Array(AddLocation-1) + ((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) - MudSystem%Op_Density%Array(AddLocation-1)= (MudSystem%Op_Density%Array(AddLocation-1)*MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%St_Density%Last()*MudSystem%MudVolume_InjectedToBH)/(MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+MudSystem%MudVolume_InjectedToBH) - MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + MudSystem%MudVolume_InjectedToBH + data%State%MudSystem%Op_Density%Array(AddLocation-1)= (data%State%MudSystem%Op_Density%Array(AddLocation-1)*data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+data%State%MudSystem%St_Density%Last()*data%State%MudSystem%MudVolume_InjectedToBH)/(data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)+data%State%MudSystem%MudVolume_InjectedToBH) + data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(AddLocation-1) + data%State%MudSystem%MudVolume_InjectedToBH !write(*,*) 'density after=' , Op_Density%Array(AddLocation-1) endif @@ -488,44 +494,44 @@ imud=0 !=============== save OP Mud data to transfer to the annulus enterance due to tripin or kick - MudSystem%OpMudVolumeSum= 0.d0 + data%State%MudSystem%OpMudVolumeSum= 0.d0 !Op_MudSaved_Density= 0.d0 !Op_KickSaved_Density= 0.d0 - MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Op_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Op_MudOrKick= 0 - MudSystem%Op_NeededVolume_ToFill= 0.d0 + data%State%MudSystem%Op_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%Op_Kick_Saved_Volume= 0.d0 + data%State%MudSystem%Saved_Op_MudOrKick= 0 + data%State%MudSystem%Op_NeededVolume_ToFill= 0.d0 - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() + do imud=1, data%State%MudSystem%Op_MudDischarged_Volume%Length() - MudSystem%OpMudVolumeSum= MudSystem%OpMudVolumeSum + MudSystem%Op_MudDischarged_Volume%Array(imud) + data%State%MudSystem%OpMudVolumeSum= data%State%MudSystem%OpMudVolumeSum + data%State%MudSystem%Op_MudDischarged_Volume%Array(imud) - if ( MudSystem%OpMudVolumeSum > sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then !1st mode + if ( data%State%MudSystem%OpMudVolumeSum > sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) ) then !1st mode - IF (MudSystem%Op_MudOrKick%Array(imud) == 0) THEN - MudSystem%Op_MudSaved_Density = MudSystem%Op_Density%Array(imud) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) + IF (data%State%MudSystem%Op_MudOrKick%Array(imud) == 0) THEN + data%State%MudSystem%Op_MudSaved_Density = data%State%MudSystem%Op_Density%Array(imud) + data%State%MudSystem%Op_Saved_MudDischarged_Volume = data%State%MudSystem%OpMudVolumeSum - sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) ELSE - MudSystem%Op_Kick_Saved_Volume = MudSystem%OpMudVolumeSum - sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (imud) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(imud) - MudSystem%iLoc= 2 + data%State%MudSystem%Op_Kick_Saved_Volume = data%State%MudSystem%OpMudVolumeSum - sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) + data%State%MudSystem%Saved_Op_MudOrKick= data%State%MudSystem%Op_MudOrKick%Array (imud) + data%State%MudSystem%Op_KickSaved_Density= data%State%MudSystem%Op_Density%Array(imud) + data%State%MudSystem%iLoc= 2 iloc_changedTo2= 2 END IF - do ii= imud + 1, MudSystem%Op_MudDischarged_Volume%Length() - IF (MudSystem%Op_MudOrKick%Array(ii) == 0) THEN - MudSystem%Op_MudSaved_Density = ((MudSystem%Op_MudSaved_Density * MudSystem%Op_Saved_MudDischarged_Volume) + (MudSystem%Op_Density%Array(ii) * MudSystem%Op_MudDischarged_Volume%Array(ii))) / (MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii)) - MudSystem%Op_Saved_MudDischarged_Volume = MudSystem%Op_Saved_MudDischarged_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) + do ii= imud + 1, data%State%MudSystem%Op_MudDischarged_Volume%Length() + IF (data%State%MudSystem%Op_MudOrKick%Array(ii) == 0) THEN + data%State%MudSystem%Op_MudSaved_Density = ((data%State%MudSystem%Op_MudSaved_Density * data%State%MudSystem%Op_Saved_MudDischarged_Volume) + (data%State%MudSystem%Op_Density%Array(ii) * data%State%MudSystem%Op_MudDischarged_Volume%Array(ii))) / (data%State%MudSystem%Op_Saved_MudDischarged_Volume + data%State%MudSystem%Op_MudDischarged_Volume%Array(ii)) + data%State%MudSystem%Op_Saved_MudDischarged_Volume = data%State%MudSystem%Op_Saved_MudDischarged_Volume + data%State%MudSystem%Op_MudDischarged_Volume%Array(ii) ELSE - MudSystem%Op_Kick_Saved_Volume = MudSystem%Op_Kick_Saved_Volume + MudSystem%Op_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Op_MudOrKick= MudSystem%Op_MudOrKick%Array (ii) - MudSystem%Op_KickSaved_Density= MudSystem%Op_Density%Array(ii) - MudSystem%iLoc= 2 + data%State%MudSystem%Op_Kick_Saved_Volume = data%State%MudSystem%Op_Kick_Saved_Volume + data%State%MudSystem%Op_MudDischarged_Volume%Array(ii) + data%State%MudSystem%Saved_Op_MudOrKick= data%State%MudSystem%Op_MudOrKick%Array (ii) + data%State%MudSystem%Op_KickSaved_Density= data%State%MudSystem%Op_Density%Array(ii) + data%State%MudSystem%iLoc= 2 iloc_changedTo2= 3 END IF enddo @@ -536,9 +542,9 @@ imud=0 enddo - if ( sum(MudSystem%Op_MudDischarged_Volume%Array(:)) < sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) ) then !2nd & 3rd mode + if ( sum(data%State%MudSystem%Op_MudDischarged_Volume%Array(:)) < sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) ) then !2nd & 3rd mode - MudSystem%Op_NeededVolume_ToFill= sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) - sum(MudSystem%Op_MudDischarged_Volume%Array(:)) + data%State%MudSystem%Op_NeededVolume_ToFill= sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) - sum(data%State%MudSystem%Op_MudDischarged_Volume%Array(:)) endif @@ -563,52 +569,52 @@ imud=0 - if ( (MudSystem%Op_Kick_Saved_Volume > 0.0 .or. MudSystem%Op_Saved_MudDischarged_Volume> 0.0) .or. & ! 1st Mode-Pump flow is more than trip out so fluid Level in Annulus Increases - (MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity)) ) then !3rd Mode-fluid Level in Annulus Increases + if ( (data%State%MudSystem%Op_Kick_Saved_Volume > 0.0 .or. data%State%MudSystem%Op_Saved_MudDischarged_Volume> 0.0) .or. & ! 1st Mode-Pump flow is more than trip out so fluid Level in Annulus Increases + (data%State%MudSystem%Op_NeededVolume_ToFill < ABS(data%State%MudSystem%DeltaVolumeAnnulusCapacity)) ) then !3rd Mode-fluid Level in Annulus Increases !if ( Op_Kick_Saved_Volume > 0.0 .or. Op_Saved_MudDischarged_Volume> 0.0 ) write(*,*) 'trip out 1st mode' - if ( MudSystem%Op_NeededVolume_ToFill > 0.0 .and. MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity) ) then + if ( data%State%MudSystem%Op_NeededVolume_ToFill > 0.0 .and. data%State%MudSystem%Op_NeededVolume_ToFill < ABS(data%State%MudSystem%DeltaVolumeAnnulusCapacity) ) then ! write(*,*) 'trip out 3rd mode' - MudSystem%NewVolume= 0.d0 ! for condition iloc=1 + data%State%MudSystem%NewVolume= 0.d0 ! for condition iloc=1 - SavedDensityForOp= MudSystem%Ann_Density%Array(1) + SavedDensityForOp= data%State%MudSystem%Ann_Density%Array(1) - ExcessMudVolume_Remained= MudSystem%Op_NeededVolume_ToFill + ExcessMudVolume_Remained= data%State%MudSystem%Op_NeededVolume_ToFill imud=1 Do - if(MudSystem%Ann_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then - ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystem%Ann_MudDischarged_Volume%Array(imud) - call MudSystem%Ann_MudDischarged_Volume%Remove (imud) - call MudSystem%Ann_Mud_Backhead_X%Remove (imud) - call MudSystem%Ann_Mud_Backhead_section%Remove (imud) - call MudSystem%Ann_Mud_Forehead_X%Remove (imud) - call MudSystem%Ann_Mud_Forehead_section%Remove (imud) - call MudSystem%Ann_Density%Remove (imud) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%Ann_MudOrKick%Remove (imud) + if(data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then + ExcessMudVolume_Remained= ExcessMudVolume_Remained- data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) + call data%State%MudSystem%Ann_MudDischarged_Volume%Remove (imud) + call data%State%MudSystem%Ann_Mud_Backhead_X%Remove (imud) + call data%State%MudSystem%Ann_Mud_Backhead_section%Remove (imud) + call data%State%MudSystem%Ann_Mud_Forehead_X%Remove (imud) + call data%State%MudSystem%Ann_Mud_Forehead_section%Remove (imud) + call data%State%MudSystem%Ann_Density%Remove (imud) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) + call data%State%MudSystem%Ann_MudOrKick%Remove (imud) - elseif(MudSystem%Ann_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained + elseif(data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained exit else !(Ann_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) - call MudSystem%Ann_MudDischarged_Volume%Remove (imud) - call MudSystem%Ann_Mud_Backhead_X%Remove (imud) - call MudSystem%Ann_Mud_Backhead_section%Remove (imud) - call MudSystem%Ann_Mud_Forehead_X%Remove (imud) - call MudSystem%Ann_Mud_Forehead_section%Remove (imud) - call MudSystem%Ann_Density%Remove (imud) - call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%Ann_MudOrKick%Remove (imud) + call data%State%MudSystem%Ann_MudDischarged_Volume%Remove (imud) + call data%State%MudSystem%Ann_Mud_Backhead_X%Remove (imud) + call data%State%MudSystem%Ann_Mud_Backhead_section%Remove (imud) + call data%State%MudSystem%Ann_Mud_Forehead_X%Remove (imud) + call data%State%MudSystem%Ann_Mud_Forehead_section%Remove (imud) + call data%State%MudSystem%Ann_Density%Remove (imud) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Remove (imud) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (imud) + call data%State%MudSystem%Ann_MudOrKick%Remove (imud) exit endif @@ -626,11 +632,11 @@ imud=0 endif - ! (MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) - DeltaVolumeOp will be added to annulus + ! (data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) - DeltaVolumeOp will be added to annulus !if (iLoc == 1) then - MudSystem%MudSection= F_Counts%StringIntervalCounts+1 - MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) + data%State%MudSystem%MudSection= data%State%F_Counts%StringIntervalCounts+1 + data%State%MudSystem%BackheadX= data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1) !elseif (iLoc == 2) then ! MudSection= Kick_Forehead_section ! BackheadX= Kick_Forehead_X @@ -638,8 +644,8 @@ imud=0 !========================ANNULUS ENTRANCE==================== !if (KickMigration_2SideBit == .FALSE.) then - ! if ( ABS(AnnulusSuctionDensity_Old - MudSystem%St_Density%Last()) >= DensityMixTol ) then ! new mud is pumped - ! call Ann_Density%AddTo (iLoc,MudSystem%St_Density%Last()) + ! if ( ABS(AnnulusSuctionDensity_Old - data%State%MudSystem%St_Density%Last()) >= DensityMixTol ) then ! new mud is pumped + ! call Ann_Density%AddTo (iLoc,data%State%MudSystem%St_Density%Last()) ! call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0) ! call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) ! call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection) @@ -650,20 +656,20 @@ imud=0 ! call Ann_MudOrKick%AddTo (iLoc,0) ! call Ann_CuttingMud%AddTo (iLoc,0) ! - ! AnnulusSuctionDensity_Old= MudSystem%St_Density%Last() + ! AnnulusSuctionDensity_Old= data%State%MudSystem%St_Density%Last() ! ! MudIsChanged= .true. ! endif ! - ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) - ((2-iloc)*ABS(DeltaVolumePipe)) !(gal) + ! Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((data%State%MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) - ((2-iloc)*ABS(DeltaVolumePipe)) !(gal) ! !endif - MudSystem%Ann_Mud_Backhead_section%Array(1)= MudSystem%MudSection !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) - MudSystem%Ann_Mud_Backhead_X%Array(1)= MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(1)= data%State%MudSystem%MudSection !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(1)= data%State%MudSystem%BackheadX @@ -675,67 +681,67 @@ imud=0 !write(*,*) 'Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume=' , Op_Kick_Saved_Volume,Op_Saved_MudDischarged_Volume - if (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() == 0) then !1st Mode + if (data%State%MudSystem%Op_Kick_Saved_Volume > 0.0 .and. data%State%MudSystem%Ann_MudOrKick%First() == 0) then !1st Mode write(*,*) 'Kick influx enters Annulus' - call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_KickSaved_Density) - call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%Op_Kick_Saved_Volume) - call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1)) - call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%Ann_MudOrKick%AddToFirst (MudSystem%Saved_Op_MudOrKick) !<<<<<<<< - call MudSystem%Ann_CuttingMud%AddToFirst (0) - elseif (MudSystem%Op_Kick_Saved_Volume > 0.0 .and. MudSystem%Ann_MudOrKick%First() /= 0) then - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) + MudSystem%Op_Kick_Saved_Volume + call data%State%MudSystem%Ann_Density%AddToFirst (data%State%MudSystem%Op_KickSaved_Density) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddToFirst (data%State%MudSystem%Op_Kick_Saved_Volume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1)) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddToFirst (data%State%F_Counts%StringIntervalCounts+1) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddToFirst (data%State%MudSystem%Saved_Op_MudOrKick) !<<<<<<<< + call data%State%MudSystem%Ann_CuttingMud%AddToFirst (0) + elseif (data%State%MudSystem%Op_Kick_Saved_Volume > 0.0 .and. data%State%MudSystem%Ann_MudOrKick%First() /= 0) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) + data%State%MudSystem%Op_Kick_Saved_Volume endif - if ( MudSystem%Op_NeededVolume_ToFill > 0.0 .and. (MudSystem%Op_NeededVolume_ToFill < ABS(MudSystem%DeltaVolumeAnnulusCapacity)) .and. MudSystem%Op_MudOrKick%Last() == 0 .and. (MudSystem%iLoc==2 .or. iloc_edited==1)) then !3rd Mode + if ( data%State%MudSystem%Op_NeededVolume_ToFill > 0.0 .and. (data%State%MudSystem%Op_NeededVolume_ToFill < ABS(data%State%MudSystem%DeltaVolumeAnnulusCapacity)) .and. data%State%MudSystem%Op_MudOrKick%Last() == 0 .and. (data%State%MudSystem%iLoc==2 .or. iloc_edited==1)) then !3rd Mode !write(*,*) 'checkpoint 0' !! for avoid kick separation -Op_MudOrKick%Last() == 0: because of pump - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ! =volume that should be added to iloc=2 in Ann - call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann in %%1 section - if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ) then! 1st in Ann = kick ,, we expect: ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)= OpMudVolLast - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) ! kick + data%State%MudSystem%NewVolume= ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! =volume that should be added to iloc=2 in Ann + call RemoveOpMudArrays(data%State%MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann in %%1 section + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) > ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) ) then! 1st in Ann = kick ,, we expect: ((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline)= OpMudVolLast + data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) - ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())+ ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) ! kick else call RemoveAnnulusMudArrays(1) !kick is removed - MudSystem%iLoc= 1 - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) + data%State%MudSystem%iLoc= 1 + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())+ ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) write(*,*) 'little expand' ! including a little expand endif endif - if (MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then !1st Mode - MudSystem%NewDensity= MudSystem%Op_MudSaved_Density - !write(*,*) 'iloc,...' , iloc,((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline),Op_Saved_MudDischarged_Volume - if (MudSystem%iLoc==1) then + if (data%State%MudSystem%Op_Saved_MudDischarged_Volume> 0.0) then !1st Mode + data%State%MudSystem%NewDensity= data%State%MudSystem%Op_MudSaved_Density + !write(*,*) 'iloc,...' , iloc,((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline),Op_Saved_MudDischarged_Volume + if (data%State%MudSystem%iLoc==1) then !write(*,*) 'checkpoint 1' - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume - elseif (real(((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline)) - real(MudSystem%Op_Saved_MudDischarged_Volume) > 0.d0 ) then ! for avoid kick separation + data%State%MudSystem%NewVolume= data%State%MudSystem%Op_Saved_MudDischarged_Volume + elseif (real(((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline)) - real(data%State%MudSystem%Op_Saved_MudDischarged_Volume) > 0.d0 ) then ! for avoid kick separation !write(*,*) 'checkpoint 2' - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) !- Op_Saved_MudDischarged_Volume - call RemoveOpMudArrays(MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann - if ( MudSystem%Ann_MudDischarged_Volume%Array(1) > (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) ) then! 1st in Ann = kick - MudSystem%Ann_MudDischarged_Volume%Array(1)= MudSystem%Ann_MudDischarged_Volume%Array(1) - (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) !kick + data%State%MudSystem%NewVolume= ((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) !- Op_Saved_MudDischarged_Volume + call RemoveOpMudArrays(data%State%MudSystem%Op_Density%Length()) ! mud here is removed and then will be added to iloc=2 in Ann + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) > (((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) - data%State%MudSystem%Op_Saved_MudDischarged_Volume) ) then! 1st in Ann = kick + data%State%MudSystem%Ann_MudDischarged_Volume%Array(1)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(1) - (((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) - data%State%MudSystem%Op_Saved_MudDischarged_Volume) + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())+ (((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) - data%State%MudSystem%Op_Saved_MudDischarged_Volume) !kick else call RemoveAnnulusMudArrays(1) !kick is removed - MudSystem%iLoc =1 - MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_Density%Length())+ (((MudSystem%AnnulusFlowRate/60.d0)*MudSystem%DeltaT_Mudline) - MudSystem%Op_Saved_MudDischarged_Volume) + data%State%MudSystem%iLoc =1 + data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array(data%State%MudSystem%Op_Density%Length())+ (((data%State%MudSystem%AnnulusFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) - data%State%MudSystem%Op_Saved_MudDischarged_Volume) write(*,*) 'little expand' ! including a little expand endif - else ! iloc==2 , ((MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) == Op_Saved_MudDischarged_Volume + else ! iloc==2 , ((data%State%MudSystem%AnnulusFlowRate/60.d0)*DeltaT_Mudline) == Op_Saved_MudDischarged_Volume !write(*,*) 'checkpoint 3' - MudSystem%NewVolume= MudSystem%Op_Saved_MudDischarged_Volume ! it is normal mode + data%State%MudSystem%NewVolume= data%State%MudSystem%Op_Saved_MudDischarged_Volume ! it is normal mode endif @@ -744,23 +750,23 @@ imud=0 !write(*,*) 'NewVolume=' ,NewVolume - if( MudSystem%Ann_Density%Length() == 1 .and. MudSystem%iLoc ==2 ) then + if( data%State%MudSystem%Ann_Density%Length() == 1 .and. data%State%MudSystem%iLoc ==2 ) then write(*,*) '***errorb****==' write(*,*) 'iloc_edited=' , iloc_edited write(*,*) 'iloc_changedTo2=' , iloc_changedTo2 - write(*,*) 'Op_Capacity===' , sum(MudSystem%OpSection_VolumeCapacity(1:F_Counts%BottomHoleIntervalCounts)) + write(*,*) 'Op_Capacity===' , sum(data%State%MudSystem%OpSection_VolumeCapacity(1:data%State%F_Counts%BottomHoleIntervalCounts)) - WRITE (*,*) 'Op_Saved_MudDischarged_Volume, Op_Kick_Saved_Volume',MudSystem%Op_Saved_MudDischarged_Volume, MudSystem%Op_Kick_Saved_Volume + WRITE (*,*) 'Op_Saved_MudDischarged_Volume, Op_Kick_Saved_Volume',data%State%MudSystem%Op_Saved_MudDischarged_Volume, data%State%MudSystem%Op_Kick_Saved_Volume - do imud=1, MudSystem%Op_MudDischarged_Volume%Length() - write(*,*) 'Op:', imud, MudSystem%Op_MudDischarged_Volume%Array(imud), MudSystem%Op_Density%Array(imud) ,MudSystem%Op_MudOrKick%Array(imud) + do imud=1, data%State%MudSystem%Op_MudDischarged_Volume%Length() + write(*,*) 'Op:', imud, data%State%MudSystem%Op_MudDischarged_Volume%Array(imud), data%State%MudSystem%Op_Density%Array(imud) ,data%State%MudSystem%Op_MudOrKick%Array(imud) enddo - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() - write(*,*) 'Ann:', imud, MudSystem%Ann_MudDischarged_Volume%Array(imud), MudSystem%Ann_Density%Array(imud) ,MudSystem%Ann_MudOrKick%Array(imud) + do imud=1, data%State%MudSystem%Ann_MudDischarged_Volume%Length() + write(*,*) 'Ann:', imud, data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud), data%State%MudSystem%Ann_Density%Array(imud) ,data%State%MudSystem%Ann_MudOrKick%Array(imud) enddo @@ -772,31 +778,31 @@ imud=0 - if ((ROP_Bit%RateOfPenetration==0 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) & !%%1 section - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==1 .and. abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%CuttingDensityMixTol) & - .or. (ROP_Bit%RateOfPenetration>0. .and. MudSystem%Ann_CuttingMud%Array(MudSystem%iLoc)==0 .and. MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged + if ((data%State%ROP_Bit%RateOfPenetration==0 .and. abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%DensityMixTol) & !%%1 section + .or. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==1 .and. abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%CuttingDensityMixTol) & + .or. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%Ann_CuttingMud%Array(data%State%MudSystem%iLoc)==0 .and. data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc) < 42.) ) then ! 1-Pockets are Merged !write(*,*) '%%1 section a)' - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)= (data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%iLoc)= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket !write(*,*) '%%1 section b)' - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%iLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%iLoc,0) !write(*,*) 'd) annLength=' , Ann_Density%Length() endif @@ -826,41 +832,41 @@ imud=0 !write(*,*) '2======no' !=============== save Ann Mud data to transfer to the ChokeLine enterance - MudSystem%AnnMudVolumeSum= 0.d0 + data%State%MudSystem%AnnMudVolumeSum= 0.d0 !Ann_MudSaved_Density= 0.d0 !Ann_KickSaved_Density= 0.d0 - MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Ann_Kick_Saved_Volume= 0.d0 - MudSystem%Saved_Ann_MudOrKick= 0 - MudSystem%Ann_to_Choke_2mud= .false. + data%State%MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%Ann_Kick_Saved_Volume= 0.d0 + data%State%MudSystem%Saved_Ann_MudOrKick= 0 + data%State%MudSystem%Ann_to_Choke_2mud= .false. - do imud=1, MudSystem%Ann_MudDischarged_Volume%Length() + do imud=1, data%State%MudSystem%Ann_MudDischarged_Volume%Length() - MudSystem%AnnMudVolumeSum= MudSystem%AnnMudVolumeSum + MudSystem%Ann_MudDischarged_Volume%Array(imud) + data%State%MudSystem%AnnMudVolumeSum= data%State%MudSystem%AnnMudVolumeSum + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) - if ( MudSystem%AnnMudVolumeSum > sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) ) then + if ( data%State%MudSystem%AnnMudVolumeSum > sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) ) then - IF (MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN - MudSystem%Ann_MudSaved_Density = MudSystem%Ann_Density%Array(imud) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - ELSEIF (MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%AnnMudVolumeSum - sum(MudSystem%PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:MudSystem%NoPipeSections)) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (imud) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(imud) + IF (data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0) THEN + data%State%MudSystem%Ann_MudSaved_Density = data%State%MudSystem%Ann_Density%Array(imud) + data%State%MudSystem%Ann_Saved_MudDischarged_Volume = data%State%MudSystem%AnnMudVolumeSum - sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + ELSEIF (data%State%MudSystem%Ann_MudOrKick%Array(imud) > 0 .AND. data%State%MudSystem%Ann_MudOrKick%Array(imud) <100) THEN ! 104= AIR + data%State%MudSystem%Ann_Kick_Saved_Volume = data%State%MudSystem%AnnMudVolumeSum - sum(data%State%MudSystem%PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:data%State%MudSystem%NoPipeSections)) + data%State%MudSystem%Saved_Ann_MudOrKick= data%State%MudSystem%Ann_MudOrKick%Array (imud) + data%State%MudSystem%Ann_KickSaved_Density= data%State%MudSystem%Ann_Density%Array(imud) END IF - do ii= imud + 1, MudSystem%Ann_MudDischarged_Volume%Length() - IF (MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN - MudSystem%Ann_MudSaved_Density = ((MudSystem%Ann_MudSaved_Density * MudSystem%Ann_Saved_MudDischarged_Volume) + (MudSystem%Ann_Density%Array(ii) * MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii)) - MudSystem%Ann_Saved_MudDischarged_Volume = MudSystem%Ann_Saved_MudDischarged_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Ann_to_Choke_2mud= .true. - ELSEIF (MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR - MudSystem%Ann_Kick_Saved_Volume = MudSystem%Ann_Kick_Saved_Volume + MudSystem%Ann_MudDischarged_Volume%Array(ii) - MudSystem%Saved_Ann_MudOrKick= MudSystem%Ann_MudOrKick%Array (ii) - MudSystem%Ann_KickSaved_Density= MudSystem%Ann_Density%Array(ii) + do ii= imud + 1, data%State%MudSystem%Ann_MudDischarged_Volume%Length() + IF (data%State%MudSystem%Ann_MudOrKick%Array(ii) == 0) THEN + data%State%MudSystem%Ann_MudSaved_Density = ((data%State%MudSystem%Ann_MudSaved_Density * data%State%MudSystem%Ann_Saved_MudDischarged_Volume) + (data%State%MudSystem%Ann_Density%Array(ii) * data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii))) / (data%State%MudSystem%Ann_Saved_MudDischarged_Volume + data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii)) + data%State%MudSystem%Ann_Saved_MudDischarged_Volume = data%State%MudSystem%Ann_Saved_MudDischarged_Volume + data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii) + data%State%MudSystem%Ann_to_Choke_2mud= .true. + ELSEIF (data%State%MudSystem%Ann_MudOrKick%Array(ii) > 0 .AND. data%State%MudSystem%Ann_MudOrKick%Array(ii) <100) THEN ! 104= AIR + data%State%MudSystem%Ann_Kick_Saved_Volume = data%State%MudSystem%Ann_Kick_Saved_Volume + data%State%MudSystem%Ann_MudDischarged_Volume%Array(ii) + data%State%MudSystem%Saved_Ann_MudOrKick= data%State%MudSystem%Ann_MudOrKick%Array (ii) + data%State%MudSystem%Ann_KickSaved_Density= data%State%MudSystem%Ann_Density%Array(ii) END IF enddo @@ -870,12 +876,12 @@ imud=0 enddo -MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume -MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume - !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_Counts%StringIntervalCounts+1:NoPipeSections)) +data%State%MudSystem%Ann_Saved_MudDischarged_Volume_Final= data%State%MudSystem%Ann_Saved_MudDischarged_Volume +data%State%MudSystem%Ann_Kick_Saved_Volume_Final= data%State%MudSystem%Ann_Kick_Saved_Volume + !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(data%State%F_Counts%StringIntervalCounts+1:NoPipeSections)) !write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) +IF (data%State%MudSystem%WellHeadIsOpen) data%State%MudSystem%MudVolume_InjectedFromAnn = data%State%MudSystem%Ann_Saved_MudDischarged_Volume_Final-((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !NoGasPocket !write(*,*) 'Ann_Saved_Mud_Vol,Ann_Kick_Saved_Vol=' , Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume @@ -889,60 +895,60 @@ IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSys imud= 0 - do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Ann_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud-1) endif ! write(*,*) 'imud==' , imud !write(*,*) '***)Ann_Mud_Backhead_section(imud)= ' , Ann_Mud_Backhead_section%Array(imud), Ann_density%Array(imud) - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections + if (data%State%MudSystem%isection > data%State%MudSystem%NoPipeSections) then ! last pipe section(well exit) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections) + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%NoPipeSections - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -952,8 +958,8 @@ imud= 0 enddo - if (MudSystem%Ann_Mud_Forehead_X%Last() < MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) then - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length()) = MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) ! for error preventing + if (data%State%MudSystem%Ann_Mud_Forehead_X%Last() < data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections)) then + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%Ann_Mud_Forehead_X%Length()) = data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections) ! for error preventing endif !========================ANNULUS END================= @@ -965,70 +971,70 @@ imud= 0 !========================Tripping Out- 2nd Mode==================== - elseif ( MudSystem%Op_NeededVolume_ToFill > ABS(MudSystem%DeltaVolumeAnnulusCapacity) ) then !pump is off or Pump flow is less than trip out so fluid Level in Annulus decreases + elseif ( data%State%MudSystem%Op_NeededVolume_ToFill > ABS(data%State%MudSystem%DeltaVolumeAnnulusCapacity) ) then !pump is off or Pump flow is less than trip out so fluid Level in Annulus decreases !write(*,*) 'trip out 2nd mode' - SavedDensityForOp= MudSystem%Ann_Density%Array(1) + SavedDensityForOp= data%State%MudSystem%Ann_Density%Array(1) !========================ANNULUS ENTRANCE==================== ! <<< SIMILAR TO UTUBE 2 >>> - if ( MudSystem%Ann_Density%Last() /= 0.0 ) then ! new mud is pumped - call MudSystem%Ann_Density%Add (0.0d0) - call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) - call MudSystem%Ann_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Forehead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Backhead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Ann_MudOrKick%Add (104) - call MudSystem%Ann_CuttingMud%Add (0) + if ( data%State%MudSystem%Ann_Density%Last() /= 0.0 ) then ! new mud is pumped + call data%State%MudSystem%Ann_Density%Add (0.0d0) + call data%State%MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) + call data%State%MudSystem%Ann_Mud_Forehead_X%Add (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections)) + call data%State%MudSystem%Ann_Mud_Forehead_section%Add (data%State%MudSystem%NoPipeSections) + call data%State%MudSystem%Ann_Mud_Backhead_X%Add (data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%NoPipeSections)) + call data%State%MudSystem%Ann_Mud_Backhead_section%Add (data%State%MudSystem%NoPipeSections) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%Add (104) + call data%State%MudSystem%Ann_CuttingMud%Add (0) !AnnulusSuctionDensity_Old= Hz_Density%Last() endif - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_Mud_Forehead_section%Length())= MudSystem%NoPipeSections !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%Ann_Mud_Forehead_X%Length())= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%Ann_Mud_Forehead_section%Length())= data%State%MudSystem%NoPipeSections !it is needed to be updated for (a condition that one pipe is removed from Annulus due to trip out)- (and add pipe) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%Ann_Mud_Forehead_X%Length())= data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Last()+ (MudSystem%Op_NeededVolume_ToFill - ABS(MudSystem%DeltaVolumeAnnulusCapacity)) ! Op_NeededVolume_ToFill !ABS(DeltaVolumePipe) - ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) !(gal) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length())= data%State%MudSystem%Ann_MudDischarged_Volume%Last()+ (data%State%MudSystem%Op_NeededVolume_ToFill - ABS(data%State%MudSystem%DeltaVolumeAnnulusCapacity)) ! Op_NeededVolume_ToFill !ABS(DeltaVolumePipe) - ((data%State%MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) !(gal) !=================================================================== - if ( (MudSystem%iLoc==2 .or. iloc_edited==1) .and. MudSystem%Op_MudOrKick%Last()==0 ) then ! for avoid kick separation + if ( (data%State%MudSystem%iLoc==2 .or. iloc_edited==1) .and. data%State%MudSystem%Op_MudOrKick%Last()==0 ) then ! for avoid kick separation !write(*,*) 'here mud should be removed from Op last' - if (abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%Op_Density%Last())< MudSystem%DensityMixTol) then + if (abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%Op_Density%Last())< data%State%MudSystem%DensityMixTol) then - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_Density%Last()*MudSystem%Op_MudDischarged_Volume%Last())/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_MudDischarged_Volume%Last()) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)= (data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%Op_Density%Last()*data%State%MudSystem%Op_MudDischarged_Volume%Last())/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%Op_MudDischarged_Volume%Last()) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is data%State%MUD(effect of pump added mud) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%iLoc)= (0.0d0) !write(*,*) 'merge' ,'Ann_Volume%Array(1)=' , Ann_MudDischarged_Volume%Array(1) else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%Op_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%Op_MudDischarged_Volume%Last()) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%Op_Density%Last()) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%Op_MudDischarged_Volume%Last()) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%iLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%iLoc,0) endif - MudSystem%Op_NeededVolume_ToFill= MudSystem%Op_NeededVolume_ToFill + MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is mud(effect of pump added mud) + data%State%MudSystem%Op_NeededVolume_ToFill= data%State%MudSystem%Op_NeededVolume_ToFill + data%State%MudSystem%Op_MudDischarged_Volume%Last() ! OP_Last is data%State%MUD(effect of pump added mud) - call RemoveOpMudArrays(MudSystem%Op_MudOrKick%Length()) + call RemoveOpMudArrays(data%State%MudSystem%Op_MudOrKick%Length()) endif @@ -1039,8 +1045,8 @@ imud= 0 !AnnMudVolumeSum= 0.d0 !!Ann_MudSaved_Density= 0.d0 !!Ann_KickSaved_Density= 0.d0 - MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 - MudSystem%Ann_Kick_Saved_Volume= 0.d0 + data%State%MudSystem%Ann_Saved_MudDischarged_Volume= 0.d0 + data%State%MudSystem%Ann_Kick_Saved_Volume= 0.d0 !Saved_Ann_MudOrKick= 0 !Ann_to_Choke_2mud= .false. @@ -1099,8 +1105,8 @@ imud= 0 -MudSystem%Ann_Saved_MudDischarged_Volume_Final= MudSystem%Ann_Saved_MudDischarged_Volume -MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume +data%State%MudSystem%Ann_Saved_MudDischarged_Volume_Final= data%State%MudSystem%Ann_Saved_MudDischarged_Volume +data%State%MudSystem%Ann_Kick_Saved_Volume_Final= data%State%MudSystem%Ann_Kick_Saved_Volume !write(*,*) 'Ann cap=' , sum(PipeSection_VolumeCapacity(F_StringIntervalCounts+1:NoPipeSections)) !write(*,*) 'Ann mud sum vol=' , sum(Ann_MudDischarged_Volume%Array(:)) @@ -1108,7 +1114,7 @@ MudSystem%Ann_Kick_Saved_Volume_Final= MudSystem%Ann_Kick_Saved_Volume -IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSystem%Ann_Saved_MudDischarged_Volume_Final-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) +IF (data%State%MudSystem%WellHeadIsOpen) data%State%MudSystem%MudVolume_InjectedFromAnn = data%State%MudSystem%Ann_Saved_MudDischarged_Volume_Final-((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !! NoGasPocket > 0 .AND. !write(*,*) 'Ann_Saved_Mud_Vol,Ann_Kick_Saved_Vol=' , Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume @@ -1120,28 +1126,28 @@ IF (MudSystem%WellHeadIsOpen) MudSystem%MudVolume_InjectedFromAnn = MudSys ! <<< SIMILAR TO UTUBE 2 >>> !write(*,*) Ann_MudOrKick%Last(), 'DeltaVolumePipe , after volume=' ,ABS(DeltaVolumePipe), Ann_MudDischarged_Volume%Last() -imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 +imud= data%State%MudSystem%Ann_Mud_Forehead_X%Length() + 1 do while (imud > 1) imud = imud - 1 - if (imud< MudSystem%Ann_Mud_Forehead_X%Length()) then - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud+1) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud+1) + if (imud< data%State%MudSystem%Ann_Mud_Forehead_X%Length()) then + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud+1) + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud+1) endif ! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then + IF ( data%State%MudSystem%ShoeLost .and. Shoe%ShoeDepth < data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)-((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud call RemoveAnnulusMudArrays(imud) imud= imud-1 cycle endif - MudSystem%LostInTripOutIsDone= .true. + data%State%MudSystem%LostInTripOutIsDone= .true. ENDIF ! Fracture Shoe Lost >>> @@ -1154,46 +1160,46 @@ imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 !write(*,*) 'a)imud,Ann_Mud_Forehead_section=',imud,Ann_Mud_Forehead_section%Array(imud) - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))) ! +1 for string , -1 for annulus !write(*,*) 'b)imud,Forehead_X,Xstart_PipeSection=',imud,Ann_Mud_Forehead_X%Array(imud),Xstart_PipeSection(Ann_Mud_Forehead_section%Array(imud)) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)- data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystem%isection= MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection < F_Counts%StringIntervalCounts+1) then ! last pipe section(well exit) F_Counts%StringIntervalCounts+1 is the first section in Annulus - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= F_Counts%StringIntervalCounts+1 + if (data%State%MudSystem%isection < data%State%F_Counts%StringIntervalCounts+1) then ! last pipe section(well exit) data%State%F_Counts%StringIntervalCounts+1 is the first section in Annulus + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1) + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%F_Counts%StringIntervalCounts+1 - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection- 1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection- 1 endif @@ -1217,28 +1223,28 @@ imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 !======================== Bottom Hole Entrance ========================== !if (iloc == 1) then - if ( MudSystem%Op_NeededVolume_ToFill > 0.0 ) then ! it is needed for 2nd & 3rd mode + if ( data%State%MudSystem%Op_NeededVolume_ToFill > 0.0 ) then ! it is needed for 2nd & 3rd mode !write(*,*) 'op add for 2nd & 3rd mode done' - if ( ABS(MudSystem%Op_Density%Last() - SavedDensityForOp ) >= MudSystem%DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Last()>42.) ) then ! 1-Merging conditions are not meeted, so new pocket + if ( ABS(data%State%MudSystem%Op_Density%Last() - SavedDensityForOp ) >= data%State%MudSystem%DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Last()>42.) ) then ! 1-Merging conditions are not meeted, so new pocket - call MudSystem%Op_Density%Add (SavedDensityForOp) - call MudSystem%Op_MudDischarged_Volume%Add (MudSystem%Op_NeededVolume_ToFill) - call MudSystem%Op_Mud_Forehead_X%Add (0.0d0) - call MudSystem%Op_Mud_Forehead_section%Add (1) - call MudSystem%Op_Mud_Backhead_X%Add (0.0d0) - call MudSystem%Op_Mud_Backhead_section%Add (1) - call MudSystem%Op_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Op_MudOrKick%Add (MudSystem%Ann_MudOrKick%Array(1)) + call data%State%MudSystem%Op_Density%Add (SavedDensityForOp) + call data%State%MudSystem%Op_MudDischarged_Volume%Add (data%State%MudSystem%Op_NeededVolume_ToFill) + call data%State%MudSystem%Op_Mud_Forehead_X%Add (0.0d0) + call data%State%MudSystem%Op_Mud_Forehead_section%Add (1) + call data%State%MudSystem%Op_Mud_Backhead_X%Add (0.0d0) + call data%State%MudSystem%Op_Mud_Backhead_section%Add (1) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Add (0.0d0) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Add (0.0d0) + call data%State%MudSystem%Op_MudOrKick%Add (data%State%MudSystem%Ann_MudOrKick%Array(1)) else ! 2-Pockets are Merged - MudSystem%Op_Density%Array (MudSystem%Op_Density%Length())= (SavedDensityForOp*MudSystem%Op_NeededVolume_ToFill+MudSystem%Op_Density%Last()*MudSystem%Op_MudDischarged_Volume%Last())/(MudSystem%Op_MudDischarged_Volume%Last()+MudSystem%Op_NeededVolume_ToFill) - MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_Density%Length())= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_Density%Length()) + MudSystem%Op_NeededVolume_ToFill - MudSystem%Op_RemainedVolume_in_LastSection%Array (MudSystem%Op_Density%Length())= 0.0 - MudSystem%Op_EmptyVolume_inBackheadLocation%Array (MudSystem%Op_Density%Length())= 0.0 + data%State%MudSystem%Op_Density%Array (data%State%MudSystem%Op_Density%Length())= (SavedDensityForOp*data%State%MudSystem%Op_NeededVolume_ToFill+data%State%MudSystem%Op_Density%Last()*data%State%MudSystem%Op_MudDischarged_Volume%Last())/(data%State%MudSystem%Op_MudDischarged_Volume%Last()+data%State%MudSystem%Op_NeededVolume_ToFill) + data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_Density%Length())= data%State%MudSystem%Op_MudDischarged_Volume%Array (data%State%MudSystem%Op_Density%Length()) + data%State%MudSystem%Op_NeededVolume_ToFill + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array (data%State%MudSystem%Op_Density%Length())= 0.0 + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array (data%State%MudSystem%Op_Density%Length())= 0.0 endif @@ -1250,67 +1256,67 @@ imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 !============================= Bottom Hole ============================== imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Op_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Op_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Op_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) + if (data%State%MudSystem%isection > data%State%F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) !if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts + data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts) + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%F_Counts%BottomHoleIntervalCounts - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well - call MudSystem%Op_MudDischarged_Volume%Remove (imud) - call MudSystem%Op_Mud_Backhead_X%Remove (imud) - call MudSystem%Op_Mud_Backhead_section%Remove (imud) - call MudSystem%Op_Mud_Forehead_X%Remove (imud) - call MudSystem%Op_Mud_Forehead_section%Remove (imud) - call MudSystem%Op_Density%Remove (imud) - call MudSystem%Op_RemainedVolume_in_LastSection%Remove (imud) - call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (imud) - call MudSystem%Op_MudOrKick%Remove (imud) + if (data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + call data%State%MudSystem%Op_MudDischarged_Volume%Remove (imud) + call data%State%MudSystem%Op_Mud_Backhead_X%Remove (imud) + call data%State%MudSystem%Op_Mud_Backhead_section%Remove (imud) + call data%State%MudSystem%Op_Mud_Forehead_X%Remove (imud) + call data%State%MudSystem%Op_Mud_Forehead_section%Remove (imud) + call data%State%MudSystem%Op_Density%Remove (imud) + call data%State%MudSystem%Op_RemainedVolume_in_LastSection%Remove (imud) + call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (imud) + call data%State%MudSystem%Op_MudOrKick%Remove (imud) endif exit endif - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection) exit else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -1342,15 +1348,15 @@ imud=0 !========================================================= - MudSystem%total_injected = MudSystem%total_injected + MudSystem%MudVolume_InjectedFromAnn + data%State%MudSystem%total_injected = data%State%MudSystem%total_injected + data%State%MudSystem%MudVolume_InjectedFromAnn - if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then - MudSystem%total_injected= 0. + if (data%EquipmentControl%ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then + data%State%MudSystem%total_injected= 0. endif - !write(*,*) ' MudSystem%MudVolume_InjectedFromAnn =' , MudSystem%MudVolume_InjectedFromAnn + !write(*,*) ' data%State%MudSystem%MudVolume_InjectedFromAnn =' , data%State%MudSystem%MudVolume_InjectedFromAnn !write(*,*) ' total injected-tripout =' , total_injected - !write(*,*) ' injected-tripout =' , MudSystem%MudVolume_InjectedFromAnn + !write(*,*) ' injected-tripout =' , data%State%MudSystem%MudVolume_InjectedFromAnn diff --git a/Equipments/MudSystem/Utube1_and_Trip_In.f90 b/Equipments/MudSystem/Utube1_and_Trip_In.f90 index b7aa404..669944c 100644 --- a/Equipments/MudSystem/Utube1_and_Trip_In.f90 +++ b/Equipments/MudSystem/Utube1_and_Trip_In.f90 @@ -4,10 +4,12 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES +use ConfigurationVariables !@@@ + use ConfigurationVariables USE sROP_Variables - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity + use ConfigurationVariables !@ + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity Use CShoeVariables Use CUnityOutputs @@ -16,26 +18,26 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect write(*,*) 'Utube1 code' !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystem%UtubeMode1Activated= .true. + data%State%MudSystem%UtubeMode1Activated= .true. !write(*,*) 'QUTubeInput=' , QUTubeInput !Qinput=5000. - MudSystem%StringFlowRate= UTUBEVARS%QUTubeInput ! (gpm) - MudSystem%AnnulusFlowRate= UTUBEVARS%QUTubeInput - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate + data%State%MudSystem%StringFlowRate= UTUBEVARS%QUTubeInput ! (gpm) + data%State%MudSystem%AnnulusFlowRate= UTUBEVARS%QUTubeInput + data%State%MudSystem%StringFlowRateFinal= data%State%MudSystem%StringFlowRate + data%State%MudSystem%AnnulusFlowRateFinal= data%State%MudSystem%AnnulusFlowRate !=========================================== - if (MudSystem%FirstSetUtube1==0) then - ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial + if (data%State%MudSystem%FirstSetUtube1==0) then + ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(data%State%F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial ! call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) ! call St_Mud_Backhead_section%AddToFirst (1) ! call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts)) ! call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) - ! call MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) + ! call data%State%MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) ! call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! - ! call Ann_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval((F_StringIntervalCounts+F_BottomHoleIntervalCounts+1):F_IntervalsTotalCounts)%Volume))) !startup initial + ! call Ann_MudDischarged_Volume%AddToFirst (REAL(sum(data%State%F_Interval((F_StringIntervalCounts+F_BottomHoleIntervalCounts+1):F_IntervalsTotalCounts)%Volume))) !startup initial ! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) ! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) ! call Ann_Mud_Forehead_X%AddToFirst (Xend_PipeSection(NoPipeSections)) @@ -46,10 +48,10 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect !Hz_Density%Array(:)= 0.0 !commented !Hz_MudOrKick%Array(:)= 104 !commented - MudSystem%Hz_Density_Utube= 0.0 - MudSystem%Hz_MudOrKick_Utube= 104 + data%State%MudSystem%Hz_Density_Utube= 0.0 + data%State%MudSystem%Hz_MudOrKick_Utube= 104 - MudSystem%FirstSetUtube1= 1 + data%State%MudSystem%FirstSetUtube1= 1 endif @@ -77,7 +79,7 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect !commented -! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) +! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((data%State%MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) ! !imud=0 ! do while (imud < Hz_Mud_Forehead_X%Length()) @@ -152,80 +154,80 @@ SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect !========================Horizontal PIPE END================= !========================STRING ENTRANCE================= - !write(*,*) 'a) MudSystem%St_Density%Length()=' , MudSystem%St_Density%Length() + !write(*,*) 'a) data%State%MudSystem%St_Density%Length()=' , data%State%MudSystem%St_Density%Length() - if (ABS(MudSystem%St_Density%First() - MudSystem%Hz_Density_Utube) >= MudSystem%DensityMixTol) then ! new mud is pumped - call MudSystem%St_Density%AddToFirst (MudSystem%Hz_Density_Utube) - call MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) - call MudSystem%St_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Forehead_section%AddToFirst (2) - call MudSystem%St_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(2)) - call MudSystem%St_Mud_Backhead_section%AddToFirst (2) - call MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) - call MudSystem%St_MudOrKick%AddToFirst (MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 + if (ABS(data%State%MudSystem%St_Density%First() - data%State%MudSystem%Hz_Density_Utube) >= data%State%MudSystem%DensityMixTol) then ! new mud is pumped + call data%State%MudSystem%St_Density%AddToFirst (data%State%MudSystem%Hz_Density_Utube) + call data%State%MudSystem%St_MudDischarged_Volume%AddToFirst (0.0d0) + call data%State%MudSystem%St_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Forehead_section%AddToFirst (2) + call data%State%MudSystem%St_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_PipeSection(2)) + call data%State%MudSystem%St_Mud_Backhead_section%AddToFirst (2) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) + call data%State%MudSystem%St_MudOrKick%AddToFirst (data%State%MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 !StringDensity_Old= Hz_Density_Utube endif - !write(*,*) 'b) MudSystem%St_Density%Length()=' , MudSystem%St_Density%Length() - !write(*,*) 'b) MudSystem%St_Density%Array(1)=' , MudSystem%St_Density%Array(1) + !write(*,*) 'b) data%State%MudSystem%St_Density%Length()=' , data%State%MudSystem%St_Density%Length() + !write(*,*) 'b) data%State%MudSystem%St_Density%Array(1)=' , data%State%MudSystem%St_Density%Array(1) !write(*,*) 'b) St_MudOrKick%Array(1)=' , St_MudOrKick%Array(1) !========================STRING================= - !WRITE (*,*) 'Utube1 MudSystem%StringFlowRate', MudSystem%StringFlowRate - MudSystem%St_MudDischarged_Volume%Array(1)= MudSystem%St_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.d0)*MudSystem%DeltaT_Mudline) !(gal) + !WRITE (*,*) 'Utube1 data%State%MudSystem%StringFlowRate', data%State%MudSystem%StringFlowRate + data%State%MudSystem%St_MudDischarged_Volume%Array(1)= data%State%MudSystem%St_MudDischarged_Volume%Array(1)+ ((data%State%MudSystem%StringFlowRate/60.d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) imud=0 - do while (imud < MudSystem%St_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%St_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud-1) - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%St_Mud_Backhead_X%Array(imud)= data%State%MudSystem%St_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%St_Mud_Backhead_section%Array(imud)= data%State%MudSystem%St_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Backhead_section%Array(imud))- MudSystem%St_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Backhead_section%Array(imud))- data%State%MudSystem%St_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%St_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%MudSystem%St_Mud_Backhead_section%Array(imud) + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= data%State%MudSystem%St_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)+1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%St_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > F_Counts%StringIntervalCounts) then ! last pipe section(string exit) F_Counts%StringIntervalCounts includes Horizontal line - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Forehead_section%Array(imud)= F_Counts%StringIntervalCounts + if (data%State%MudSystem%isection > data%State%F_Counts%StringIntervalCounts) then ! last pipe section(string exit) data%State%F_Counts%StringIntervalCounts includes Horizontal line + data%State%MudSystem%St_MudDischarged_Volume%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts) + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%F_Counts%StringIntervalCounts - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + if (data%State%MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string call RemoveStringMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -260,59 +262,59 @@ imud=0 !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((KickVARIABLES%GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Op_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Op_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Op_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) - if( imud==1) MudSystem%KickDeltaVinAnnulus= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts + if (data%State%MudSystem%isection > data%State%F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) + if( imud==1) data%State%MudSystem%KickDeltaVinAnnulus= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space + data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts) + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%F_Counts%BottomHoleIntervalCounts - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveOpMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection) exit else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -321,13 +323,13 @@ imud=0 endif - if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then - MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() - do while(imud < MudSystem%totalLength) + if (data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)== data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts)) then + data%State%MudSystem%totalLength = data%State%MudSystem%Op_MudDischarged_Volume%Length() + do while(imud < data%State%MudSystem%totalLength) !imud = imud + 1 - call RemoveOpMudArrays(MudSystem%totalLength) - MudSystem%totalLength = MudSystem%totalLength - 1 + call RemoveOpMudArrays(data%State%MudSystem%totalLength) + data%State%MudSystem%totalLength = data%State%MudSystem%totalLength - 1 enddo @@ -352,81 +354,81 @@ imud=0 ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(2)' , Op_Mud_Forehead_X%Array(2) !========================Bottom Hole END================= - if (MudSystem%iLoc == 1) then - MudSystem%MudSection= F_Counts%StringIntervalCounts+1 - MudSystem%BackheadX= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - elseif (MudSystem%iLoc == 2) then - MudSystem%MudSection= MudSystem%Kick_Forehead_section - MudSystem%BackheadX= MudSystem%Kick_Forehead_X + if (data%State%MudSystem%iLoc == 1) then + data%State%MudSystem%MudSection= data%State%F_Counts%StringIntervalCounts+1 + data%State%MudSystem%BackheadX= data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1) + elseif (data%State%MudSystem%iLoc == 2) then + data%State%MudSystem%MudSection= data%State%MudSystem%Kick_Forehead_section + data%State%MudSystem%BackheadX= data%State%MudSystem%Kick_Forehead_X endif !========================ANNULUS ENTRANCE==================== !write(*,*) 'iloc=====' , iLoc - if ((ABS(MudSystem%AnnulusSuctionDensity_Old - MudSystem%St_Density%Last()) >= MudSystem%DensityMixTol) .OR. (MudSystem%DeltaVolumeOp == 0.0 .and. ABS(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%St_Density%Last())>=MudSystem%DensityMixTol .and. MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%St_Density%Last()) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) + if ((ABS(data%State%MudSystem%AnnulusSuctionDensity_Old - data%State%MudSystem%St_Density%Last()) >= data%State%MudSystem%DensityMixTol) .OR. (data%State%MudSystem%DeltaVolumeOp == 0.0 .and. ABS(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%St_Density%Last())>=data%State%MudSystem%DensityMixTol .and. data%State%MudSystem%AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%St_Density%Last()) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%iLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%iLoc,0) - MudSystem%AnnulusSuctionDensity_Old= MudSystem%St_Density%Last() + data%State%MudSystem%AnnulusSuctionDensity_Old= data%State%MudSystem%St_Density%Last() - MudSystem%MudIsChanged= .true. + data%State%MudSystem%MudIsChanged= .true. endif - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+ ((MudSystem%AnnulusFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+ ((data%State%MudSystem%AnnulusFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) !========================Tripping In==================== !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp - if (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) + if (data%State%MudSystem%DeltaVolumeOp > 0.0 .and. data%State%MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) !write(*,*) 'Tripping In' - MudSystem%NewDensity= (MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline)+MudSystem%Op_Density%Last()*MudSystem%DeltaVolumeOp)/(((MudSystem%AnnulusFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp) - MudSystem%NewVolume= ((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp + data%State%MudSystem%NewDensity= (data%State%MudSystem%St_Density%Last()*((data%State%MudSystem%AnnulusFlowRate/60.)*data%State%MudSystem%DeltaT_Mudline)+data%State%MudSystem%Op_Density%Last()*data%State%MudSystem%DeltaVolumeOp)/(((data%State%MudSystem%AnnulusFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline)+data%State%MudSystem%DeltaVolumeOp) + data%State%MudSystem%NewVolume= ((data%State%MudSystem%AnnulusFlowRate/60.)*data%State%MudSystem%DeltaT_Mudline)+data%State%MudSystem%DeltaVolumeOp !write(*,*) 'Ann_MudDischarged_Volume%Array(1)=', Ann_MudDischarged_Volume%Array(1), 'NewVolume=', NewVolume - if (abs(MudSystem%Ann_Density%Array(MudSystem%iLoc)-MudSystem%NewDensity)< MudSystem%DensityMixTol) then ! 1-Pockets are Merged - (ROP is 0) - MudSystem%Ann_Density%Array(MudSystem%iLoc)= (MudSystem%Ann_Density%Array(MudSystem%iLoc)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%NewVolume) - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)+MudSystem%DeltaVolumeOp - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) + if (abs(data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)-data%State%MudSystem%NewDensity)< data%State%MudSystem%DensityMixTol) then ! 1-Pockets are Merged - (ROP is 0) + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)= (data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)*data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%NewVolume) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)+data%State%MudSystem%DeltaVolumeOp + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%iLoc)= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%Ann_Density%AddTo (MudSystem%iLoc,MudSystem%NewDensity) - call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%iLoc,MudSystem%NewVolume) - call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%iLoc,MudSystem%BackheadX) - call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%iLoc,MudSystem%MudSection) - call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%iLoc,0.0d0) - call MudSystem%Ann_MudOrKick%AddTo (MudSystem%iLoc,0) - call MudSystem%Ann_CuttingMud%AddTo (MudSystem%iLoc,0) + call data%State%MudSystem%Ann_Density%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewDensity) + call data%State%MudSystem%Ann_MudDischarged_Volume%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%NewVolume) + call data%State%MudSystem%Ann_Mud_Forehead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Forehead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_Mud_Backhead_X%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%BackheadX) + call data%State%MudSystem%Ann_Mud_Backhead_section%AddTo (data%State%MudSystem%iLoc,data%State%MudSystem%MudSection) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (data%State%MudSystem%iLoc,0.0d0) + call data%State%MudSystem%Ann_MudOrKick%AddTo (data%State%MudSystem%iLoc,0) + call data%State%MudSystem%Ann_CuttingMud%AddTo (data%State%MudSystem%iLoc,0) endif - elseif (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .true. .and. ROP_Bit%RateOfPenetration==0.) then - MudSystem%Ann_Density%Array(MudSystem%iLoc)= MudSystem%NewDensity - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%iLoc)= MudSystem%NewVolume - MudSystem%Ann_Mud_Forehead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_Mud_Backhead_X%Array(MudSystem%iLoc)= MudSystem%BackheadX - MudSystem%Ann_Mud_Backhead_section%Array(MudSystem%iLoc)= MudSystem%MudSection - MudSystem%Ann_RemainedVolume_in_LastSection%Array(MudSystem%iLoc)= (0.0d0) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(MudSystem%iLoc)= (0.0d0) + elseif (data%State%MudSystem%DeltaVolumeOp > 0.0 .and. data%State%MudSystem%MudIsChanged== .true. .and. data%State%ROP_Bit%RateOfPenetration==0.) then + data%State%MudSystem%Ann_Density%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%NewDensity + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%NewVolume + data%State%MudSystem%Ann_Mud_Forehead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Forehead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%BackheadX + data%State%MudSystem%Ann_Mud_Backhead_section%Array(data%State%MudSystem%iLoc)= data%State%MudSystem%MudSection + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(data%State%MudSystem%iLoc)= (0.0d0) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%iLoc)= (0.0d0) endif @@ -435,24 +437,24 @@ imud=0 !======================== ANNULUS ==================== - MudSystem%MudIsChanged= .false. + data%State%MudSystem%MudIsChanged= .false. imud= 0 - do while (imud < MudSystem%Ann_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Ann_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud-1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud-1) endif ! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then + IF ( data%State%MudSystem%ShoeLost .and. data%State%MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)-((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud call RemoveAnnulusMudArrays(imud) imud= imud-1 @@ -468,48 +470,48 @@ imud= 0 - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Backhead_section%Array(imud))- MudSystem%Ann_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else - MudSystem%isection= MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > MudSystem%NoPipeSections) then ! last pipe section(well exit) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Xend_PipeSection(MudSystem%NoPipeSections) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%NoPipeSections + if (data%State%MudSystem%isection > data%State%MudSystem%NoPipeSections) then ! last pipe section(well exit) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections) + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%NoPipeSections - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_PipeSection(MudSystem%isection)- MudSystem%Xstart_PipeSection(MudSystem%isection)))+ MudSystem%Xstart_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -521,8 +523,8 @@ imud= 0 !========================ANNULUS END================= !if ( WellisNOTFull == .false. ) then - ! write(*,*) 'MudSystem%AnnulusFlowRate==' , MudSystem%AnnulusFlowRate - ! call Set_FlowRate(real(100.*min(MudSystem%AnnulusFlowRate,PedalMeter)/(PedalMeter/10.), 8)) + ! write(*,*) 'data%State%MudSystem%AnnulusFlowRate==' , data%State%MudSystem%AnnulusFlowRate + ! call Set_FlowRate(real(100.*min(data%State%MudSystem%AnnulusFlowRate,PedalMeter)/(PedalMeter/10.), 8)) ! ! !endif diff --git a/Equipments/MudSystem/Utube2_and_Trip_In.f90 b/Equipments/MudSystem/Utube2_and_Trip_In.f90 index 4ba0011..f530b13 100644 --- a/Equipments/MudSystem/Utube2_and_Trip_In.f90 +++ b/Equipments/MudSystem/Utube2_and_Trip_In.f90 @@ -4,9 +4,11 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES - USE Pumps_VARIABLES - use CDrillWatchVariables - !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity +use ConfigurationVariables !@@@ + use ConfigurationVariables + use ConfigurationVariables !@ + !use CTanks + !@use ConfigurationVariables, TripTankVolume2 => data%EquipmentControl%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity Use CShoeVariables implicit none @@ -16,26 +18,26 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !===========================================================WELL============================================================ !===========================================================WELL============================================================ - MudSystem%UtubeMode2Activated= .true. + data%State%MudSystem%UtubeMode2Activated= .true. write(*,*) 'QUtubeOutput=' , UTUBEVARS%QUtubeOutput !QUTubeInput=5000. - MudSystem%StringFlowRate= UTUBEVARS%QUtubeOutput ! (gpm) - MudSystem%AnnulusFlowRate= UTUBEVARS%QUtubeOutput - MudSystem%StringFlowRateFinal= MudSystem%StringFlowRate - MudSystem%AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate + data%State%MudSystem%StringFlowRate= UTUBEVARS%QUtubeOutput ! (gpm) + data%State%MudSystem%AnnulusFlowRate= UTUBEVARS%QUtubeOutput + data%State%MudSystem%StringFlowRateFinal= data%State%MudSystem%StringFlowRate + data%State%MudSystem%AnnulusFlowRateFinal= data%State%MudSystem%AnnulusFlowRate !=========================================== - if (MudSystem%FirstSetUtube2==0) then - ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial + if (data%State%MudSystem%FirstSetUtube2==0) then + ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(data%State%F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial ! call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) ! call St_Mud_Backhead_section%AddToFirst (1) ! call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts)) ! call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) - ! call MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) + ! call data%State%MudSystem%St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) ! call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! - ! call Ann_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval((F_StringIntervalCounts+F_BottomHoleIntervalCounts+1):F_IntervalsTotalCounts)%Volume))) !startup initial + ! call Ann_MudDischarged_Volume%AddToFirst (REAL(sum(data%State%F_Interval((F_StringIntervalCounts+F_BottomHoleIntervalCounts+1):F_IntervalsTotalCounts)%Volume))) !startup initial ! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) ! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) ! call Ann_Mud_Forehead_X%AddToFirst (Xend_PipeSection(NoPipeSections)) @@ -46,10 +48,10 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !Hz_Density%Array(:)= 0.0 !Hz_MudOrKick%Array(:)= 104 - MudSystem%Hz_Density_Utube= 0.0 - MudSystem%Hz_MudOrKick_Utube= 104 + data%State%MudSystem%Hz_Density_Utube= 0.0 + data%State%MudSystem%Hz_MudOrKick_Utube= 104 - MudSystem%FirstSetUtube2= 1 + data%State%MudSystem%FirstSetUtube2= 1 endif @@ -79,7 +81,7 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !commented -! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) +! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((data%State%MudSystem%StringFlowRate/60.)*DeltaT_Mudline) !(gal) ! !imud=0 ! do while (imud < Hz_Mud_Forehead_X%Length()) @@ -154,40 +156,40 @@ SUBROUTINE Utube2_and_TripIn ! is called in subroutine CirculationCodeSelect !========================ANNULUS ENTRANCE==================== - if (ABS(MudSystem%AnnulusSuctionDensity_Old - MudSystem%Hz_Density_Utube) >= MudSystem%DensityMixTol ) then ! new mud is pumped - call MudSystem%Ann_Density%Add (MudSystem%Hz_Density_Utube) - call MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) - call MudSystem%Ann_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Forehead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(MudSystem%NoPipeSections)) - call MudSystem%Ann_Mud_Backhead_section%Add (MudSystem%NoPipeSections) - call MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%Ann_MudOrKick%Add (MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 - call MudSystem%Ann_CuttingMud%Add (0) + if (ABS(data%State%MudSystem%AnnulusSuctionDensity_Old - data%State%MudSystem%Hz_Density_Utube) >= data%State%MudSystem%DensityMixTol ) then ! new mud is pumped + call data%State%MudSystem%Ann_Density%Add (data%State%MudSystem%Hz_Density_Utube) + call data%State%MudSystem%Ann_MudDischarged_Volume%Add (0.0d0) + call data%State%MudSystem%Ann_Mud_Forehead_X%Add (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%NoPipeSections)) + call data%State%MudSystem%Ann_Mud_Forehead_section%Add (data%State%MudSystem%NoPipeSections) + call data%State%MudSystem%Ann_Mud_Backhead_X%Add (data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%NoPipeSections)) + call data%State%MudSystem%Ann_Mud_Backhead_section%Add (data%State%MudSystem%NoPipeSections) + call data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Add (0.0d0) + call data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Add (0.0d0) + call data%State%MudSystem%Ann_MudOrKick%Add (data%State%MudSystem%Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 + call data%State%MudSystem%Ann_CuttingMud%Add (0) - MudSystem%AnnulusSuctionDensity_Old= MudSystem%Hz_Density_Utube + data%State%MudSystem%AnnulusSuctionDensity_Old= data%State%MudSystem%Hz_Density_Utube endif !========================ANNULUS==================== - MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_MudDischarged_Volume%Length())= MudSystem%Ann_MudDischarged_Volume%Last()+ ((MudSystem%AnnulusFlowRate/60.)*MudSystem%DeltaT_Mudline) !(gal) + data%State%MudSystem%Ann_MudDischarged_Volume%Array(data%State%MudSystem%Ann_MudDischarged_Volume%Length())= data%State%MudSystem%Ann_MudDischarged_Volume%Last()+ ((data%State%MudSystem%AnnulusFlowRate/60.)*data%State%MudSystem%DeltaT_Mudline) !(gal) -imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 +imud= data%State%MudSystem%Ann_Mud_Forehead_X%Length() + 1 do while (imud > 1) imud = imud - 1 - if (imud< MudSystem%Ann_Mud_Forehead_X%Length()) then - MudSystem%Ann_Mud_Forehead_X%Array(imud)= MudSystem%Ann_Mud_Backhead_X%Array(imud+1) - MudSystem%Ann_Mud_Forehead_section%Array(imud)= MudSystem%Ann_Mud_Backhead_section%Array(imud+1) + if (imud< data%State%MudSystem%Ann_Mud_Forehead_X%Length()) then + data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud+1) + data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud+1) endif ! <<< Fracture Shoe Lost - IF ( MudSystem%ShoeLost .and. MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then + IF ( data%State%MudSystem%ShoeLost .and. data%State%MudSystem%LostInTripOutIsDone== .false. .and. Shoe%ShoeDepth < data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. Shoe%ShoeDepth >= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)-((MudSystem%Qlost/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) - if (MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)-((data%State%MudSystem%Qlost/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud call RemoveAnnulusMudArrays(imud) imud= imud-1 @@ -197,47 +199,47 @@ imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 ! Fracture Shoe Lost >>> - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & - MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) - MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Ann_MudDischarged_Volume%Array(imud) <= MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%Ann_Mud_Forehead_section%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Ann_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(imud)) + if ( data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud)- data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystem%isection= MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Ann_Mud_Forehead_section%Array(imud)-1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection < F_Counts%StringIntervalCounts+1) then ! last pipe section(well exit) F_Counts%StringIntervalCounts+1 is the first section in Annulus - MudSystem%Ann_MudDischarged_Volume%Array(imud)= MudSystem%Ann_MudDischarged_Volume%Array(imud)- MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Ann_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1) - MudSystem%Ann_Mud_Backhead_section%Array(imud)= F_Counts%StringIntervalCounts+1 + if (data%State%MudSystem%isection < data%State%F_Counts%StringIntervalCounts+1) then ! last pipe section(well exit) data%State%F_Counts%StringIntervalCounts+1 is the first section in Annulus + data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts+1) + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%F_Counts%StringIntervalCounts+1 - if (MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveAnnulusMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Ann_Mud_Backhead_section%Array(imud)= MudSystem%isection - MudSystem%Ann_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Ann_Mud_Backhead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection- 1 + data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Ann_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection- 1 endif @@ -272,59 +274,59 @@ imud= MudSystem%Ann_Mud_Forehead_X%Length() + 1 !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((KickVARIABLES%GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux imud=0 - do while (imud < MudSystem%Op_Mud_Forehead_X%Length()) + do while (imud < data%State%MudSystem%Op_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then - MudSystem%Op_Mud_Backhead_X%Array(imud)= MudSystem%Op_Mud_Forehead_X%Array(imud-1) - MudSystem%Op_Mud_Backhead_section%Array(imud)= MudSystem%Op_Mud_Forehead_section%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_X%Array(imud-1) + data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)= data%State%MudSystem%Op_Mud_Forehead_section%Array(imud-1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) & - / ABS(MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))-MudSystem%Xstart_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))-data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%Xend_OpSection(MudSystem%Op_Mud_Backhead_section%Array(imud))- MudSystem%Op_Mud_Backhead_X%Array(imud))* & - MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud))- data%State%MudSystem%Op_Mud_Backhead_X%Array(imud))* & + data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%Op_MudDischarged_Volume%Array(imud) <= MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%Op_Mud_Backhead_section%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Op_Mud_Backhead_X%Array(imud)+ MudSystem%DirectionCoef*(MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Backhead_section%Array(imud)) + if ( data%State%MudSystem%Op_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Op_Mud_Backhead_X%Array(imud)+ data%State%MudSystem%DirectionCoef*(data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_OpSectionFt(data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystem%isection= MudSystem%Op_Mud_Backhead_section%Array(imud)+1 - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%Op_Mud_Backhead_section%Array(imud)+1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection > F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) - if( imud==1) MudSystem%KickDeltaVinAnnulus= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space - MudSystem%Op_MudDischarged_Volume%Array(imud)= MudSystem%Op_MudDischarged_Volume%Array(imud)- MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) - MudSystem%Op_Mud_Forehead_X%Array(imud)= MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts) - MudSystem%Op_Mud_Forehead_section%Array(imud)= F_Counts%BottomHoleIntervalCounts + if (data%State%MudSystem%isection > data%State%F_Counts%BottomHoleIntervalCounts) then ! last pipe section(well exit) + if( imud==1) data%State%MudSystem%KickDeltaVinAnnulus= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space + data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)= data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)- data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts) + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%F_Counts%BottomHoleIntervalCounts - if (MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well + if (data%State%MudSystem%Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveOpMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%OpSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%Op_Mud_Forehead_section%Array(imud)= MudSystem%isection - MudSystem%Op_Mud_Forehead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xend_OpSection(MudSystem%isection)- MudSystem%Xstart_OpSection(MudSystem%isection)))+ MudSystem%Xstart_OpSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%Op_Mud_Forehead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xend_OpSection(data%State%MudSystem%isection)- data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xstart_OpSection(data%State%MudSystem%isection) exit else - MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- MudSystem%OpSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection+ 1 + data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%Op_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%OpSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection+ 1 endif @@ -332,13 +334,13 @@ imud=0 endif - if (MudSystem%Op_Mud_Forehead_X%Array(imud)== MudSystem%Xend_OpSection(F_Counts%BottomHoleIntervalCounts)) then - MudSystem%totalLength = MudSystem%Op_MudDischarged_Volume%Length() - do while(imud < MudSystem%totalLength) + if (data%State%MudSystem%Op_Mud_Forehead_X%Array(imud)== data%State%MudSystem%Xend_OpSection(data%State%F_Counts%BottomHoleIntervalCounts)) then + data%State%MudSystem%totalLength = data%State%MudSystem%Op_MudDischarged_Volume%Length() + do while(imud < data%State%MudSystem%totalLength) !imud = imud + 1 - call RemoveOpMudArrays(MudSystem%totalLength) - MudSystem%totalLength = MudSystem%totalLength - 1 + call RemoveOpMudArrays(data%State%MudSystem%totalLength) + data%State%MudSystem%totalLength = data%State%MudSystem%totalLength - 1 enddo @@ -375,70 +377,70 @@ imud=0 !========================STRING ENTRANCE================= - if ((ABS(MudSystem%St_Density%Last() - MudSystem%Ann_Density%First()) >= MudSystem%DensityMixTol) .OR. (MudSystem%DeltaVolumeOp == 0.0 .and. MudSystem%St_Density%Last() /= MudSystem%Ann_Density%Array(1) .and. MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped + if ((ABS(data%State%MudSystem%St_Density%Last() - data%State%MudSystem%Ann_Density%First()) >= data%State%MudSystem%DensityMixTol) .OR. (data%State%MudSystem%DeltaVolumeOp == 0.0 .and. data%State%MudSystem%St_Density%Last() /= data%State%MudSystem%Ann_Density%Array(1) .and. data%State%MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped - !if ((ABS(StringDensity_Old - Ann_Density%First()) >= DensityMixTol) .OR. (DeltaVolumeOp == 0.0 .and. MudSystem%St_Density%Last() /= Ann_Density%Array(1) .and. MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped - call MudSystem%St_Density%Add (MudSystem%Ann_Density%First()) - call MudSystem%St_MudDischarged_Volume%Add (0.0d0) - call MudSystem%St_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Forehead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Backhead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%St_MudOrKick%Add (0) + !if ((ABS(StringDensity_Old - Ann_Density%First()) >= DensityMixTol) .OR. (DeltaVolumeOp == 0.0 .and. data%State%MudSystem%St_Density%Last() /= Ann_Density%Array(1) .and. data%State%MudSystem%StringFlowRate/=0.0d0)) then ! new mud is pumped + call data%State%MudSystem%St_Density%Add (data%State%MudSystem%Ann_Density%First()) + call data%State%MudSystem%St_MudDischarged_Volume%Add (0.0d0) + call data%State%MudSystem%St_Mud_Forehead_X%Add (data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)) + call data%State%MudSystem%St_Mud_Forehead_section%Add (data%State%F_Counts%StringIntervalCounts) + call data%State%MudSystem%St_Mud_Backhead_X%Add (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts)) + call data%State%MudSystem%St_Mud_Backhead_section%Add (data%State%F_Counts%StringIntervalCounts) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) + call data%State%MudSystem%St_MudOrKick%Add (0) !StringDensity_Old= Ann_Density%First() - MudSystem%MudIsChanged= .true. + data%State%MudSystem%MudIsChanged= .true. endif - MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_MudDischarged_Volume%Length())= MudSystem%St_MudDischarged_Volume%Last()+ ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline) !(gal) + data%State%MudSystem%St_MudDischarged_Volume%Array(data%State%MudSystem%St_MudDischarged_Volume%Length())= data%State%MudSystem%St_MudDischarged_Volume%Last()+ ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) !========================Tripping In==================== !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp -write(*,*) 'DeltaVolumeOp=' , MudSystem%DeltaVolumeOp - if (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) +write(*,*) 'DeltaVolumeOp=' , data%State%MudSystem%DeltaVolumeOp + if (data%State%MudSystem%DeltaVolumeOp > 0.0 .and. data%State%MudSystem%MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) !write(*,*) 'Tripping In' - MudSystem%NewDensity= (MudSystem%Ann_Density%First()*((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%Op_Density%Last()*MudSystem%DeltaVolumeOp)/(((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp) - MudSystem%NewVolume= ((MudSystem%StringFlowRate/60.0d0)*MudSystem%DeltaT_Mudline)+MudSystem%DeltaVolumeOp + data%State%MudSystem%NewDensity= (data%State%MudSystem%Ann_Density%First()*((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline)+data%State%MudSystem%Op_Density%Last()*data%State%MudSystem%DeltaVolumeOp)/(((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline)+data%State%MudSystem%DeltaVolumeOp) + data%State%MudSystem%NewVolume= ((data%State%MudSystem%StringFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline)+data%State%MudSystem%DeltaVolumeOp !write(*,*) 'St_MudDischarged_Volume%Last()=', St_MudDischarged_Volume%Last(), 'NewVolume=', NewVolume - if (abs(MudSystem%St_Density%Last()-MudSystem%NewDensity)< MudSystem%DensityMixTol) then ! .OR. (St_MudDischarged_Volume%Last()< 42.) ) then !+ NewVolume)< 42.) then ! 1-Pockets are Merged - MudSystem%St_Density%Array(MudSystem%St_Density%Length())= (MudSystem%St_Density%Last()*MudSystem%St_MudDischarged_Volume%Last()+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%St_MudDischarged_Volume%Last()+MudSystem%NewVolume) - MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_Density%Length())= MudSystem%St_MudDischarged_Volume%Last()+MudSystem%DeltaVolumeOp - MudSystem%St_Mud_Forehead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Forehead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Backhead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Backhead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_RemainedVolume_in_LastSection%Array(MudSystem%St_Density%Length())= (0.0d0) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(MudSystem%St_Density%Length())= (0.0d0) + if (abs(data%State%MudSystem%St_Density%Last()-data%State%MudSystem%NewDensity)< data%State%MudSystem%DensityMixTol) then ! .OR. (St_MudDischarged_Volume%Last()< 42.) ) then !+ NewVolume)< 42.) then ! 1-Pockets are Merged + data%State%MudSystem%St_Density%Array(data%State%MudSystem%St_Density%Length())= (data%State%MudSystem%St_Density%Last()*data%State%MudSystem%St_MudDischarged_Volume%Last()+data%State%MudSystem%NewDensity*data%State%MudSystem%NewVolume)/(data%State%MudSystem%St_MudDischarged_Volume%Last()+data%State%MudSystem%NewVolume) + data%State%MudSystem%St_MudDischarged_Volume%Array(data%State%MudSystem%St_Density%Length())= data%State%MudSystem%St_MudDischarged_Volume%Last()+data%State%MudSystem%DeltaVolumeOp + data%State%MudSystem%St_Mud_Forehead_X%Array(data%State%MudSystem%St_Density%Length())= (data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)) + data%State%MudSystem%St_Mud_Forehead_section%Array(data%State%MudSystem%St_Density%Length())= (data%State%F_Counts%StringIntervalCounts) + data%State%MudSystem%St_Mud_Backhead_X%Array(data%State%MudSystem%St_Density%Length())= (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts)) + data%State%MudSystem%St_Mud_Backhead_section%Array(data%State%MudSystem%St_Density%Length())= (data%State%F_Counts%StringIntervalCounts) + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(data%State%MudSystem%St_Density%Length())= (0.0d0) + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%St_Density%Length())= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket - call MudSystem%St_Density%Add (MudSystem%NewDensity) - call MudSystem%St_MudDischarged_Volume%Add (MudSystem%NewVolume) - call MudSystem%St_Mud_Forehead_X%Add (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Forehead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_Mud_Backhead_X%Add (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - call MudSystem%St_Mud_Backhead_section%Add (F_Counts%StringIntervalCounts) - call MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) - call MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) - call MudSystem%St_MudOrKick%Add (0) + call data%State%MudSystem%St_Density%Add (data%State%MudSystem%NewDensity) + call data%State%MudSystem%St_MudDischarged_Volume%Add (data%State%MudSystem%NewVolume) + call data%State%MudSystem%St_Mud_Forehead_X%Add (data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)) + call data%State%MudSystem%St_Mud_Forehead_section%Add (data%State%F_Counts%StringIntervalCounts) + call data%State%MudSystem%St_Mud_Backhead_X%Add (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts)) + call data%State%MudSystem%St_Mud_Backhead_section%Add (data%State%F_Counts%StringIntervalCounts) + call data%State%MudSystem%St_RemainedVolume_in_LastSection%Add (0.0d0) + call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Add (0.0d0) + call data%State%MudSystem%St_MudOrKick%Add (0) endif - elseif (MudSystem%DeltaVolumeOp > 0.0 .and. MudSystem%MudIsChanged== .true.) then - MudSystem%St_Density%Array(MudSystem%St_Density%Length())= MudSystem%NewDensity - MudSystem%St_MudDischarged_Volume%Array(MudSystem%St_Density%Length())= MudSystem%NewVolume - MudSystem%St_Mud_Forehead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xend_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Forehead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_Mud_Backhead_X%Array(MudSystem%St_Density%Length())= (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts)) - MudSystem%St_Mud_Backhead_section%Array(MudSystem%St_Density%Length())= (F_Counts%StringIntervalCounts) - MudSystem%St_RemainedVolume_in_LastSection%Array(MudSystem%St_Density%Length())= (0.0d0) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(MudSystem%St_Density%Length())= (0.0d0) + elseif (data%State%MudSystem%DeltaVolumeOp > 0.0 .and. data%State%MudSystem%MudIsChanged== .true.) then + data%State%MudSystem%St_Density%Array(data%State%MudSystem%St_Density%Length())= data%State%MudSystem%NewDensity + data%State%MudSystem%St_MudDischarged_Volume%Array(data%State%MudSystem%St_Density%Length())= data%State%MudSystem%NewVolume + data%State%MudSystem%St_Mud_Forehead_X%Array(data%State%MudSystem%St_Density%Length())= (data%State%MudSystem%Xend_PipeSection(data%State%F_Counts%StringIntervalCounts)) + data%State%MudSystem%St_Mud_Forehead_section%Array(data%State%MudSystem%St_Density%Length())= (data%State%F_Counts%StringIntervalCounts) + data%State%MudSystem%St_Mud_Backhead_X%Array(data%State%MudSystem%St_Density%Length())= (data%State%MudSystem%Xstart_PipeSection(data%State%F_Counts%StringIntervalCounts)) + data%State%MudSystem%St_Mud_Backhead_section%Array(data%State%MudSystem%St_Density%Length())= (data%State%F_Counts%StringIntervalCounts) + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(data%State%MudSystem%St_Density%Length())= (0.0d0) + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(data%State%MudSystem%St_Density%Length())= (0.0d0) endif @@ -447,60 +449,60 @@ write(*,*) 'DeltaVolumeOp=' , MudSystem%DeltaVolumeOp !======================== STRING ==================== - MudSystem%MudIsChanged= .false. + data%State%MudSystem%MudIsChanged= .false. - imud= MudSystem%St_Mud_Forehead_X%Length() + 1 + imud= data%State%MudSystem%St_Mud_Forehead_X%Length() + 1 do while (imud > 1) imud = imud - 1 - if (imud< MudSystem%St_Mud_Forehead_X%Length()) then - MudSystem%St_Mud_Forehead_X%Array(imud)= MudSystem%St_Mud_Backhead_X%Array(imud+1) - MudSystem%St_Mud_Forehead_section%Array(imud)= MudSystem%St_Mud_Backhead_section%Array(imud+1) + if (imud< data%State%MudSystem%St_Mud_Forehead_X%Length()) then + data%State%MudSystem%St_Mud_Forehead_X%Array(imud)= data%State%MudSystem%St_Mud_Backhead_X%Array(imud+1) + data%State%MudSystem%St_Mud_Forehead_section%Array(imud)= data%State%MudSystem%St_Mud_Backhead_section%Array(imud+1) endif - MudSystem%DirectionCoef= (MudSystem%Xend_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))) & - / ABS(MudSystem%Xend_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))-MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud))) + data%State%MudSystem%DirectionCoef= (data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Forehead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Forehead_section%Array(imud))) & + / ABS(data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%St_Mud_Forehead_section%Array(imud))-data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Forehead_section%Array(imud))) ! +1 for string , -1 for annulus - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%DirectionCoef* (MudSystem%St_Mud_Forehead_X%Array(imud)- MudSystem%Xstart_PipeSection(MudSystem%St_Mud_Forehead_section%Array(imud)))* & - MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) - MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%DirectionCoef* (data%State%MudSystem%St_Mud_Forehead_X%Array(imud)- data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%St_Mud_Forehead_section%Array(imud)))* & + data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Backhead_section%Array(imud)) !(ft^3) + data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal - if ( MudSystem%St_MudDischarged_Volume%Array(imud) <= MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%St_Mud_Forehead_section%Array(imud) - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%St_Mud_Forehead_X%Array(imud)- MudSystem%DirectionCoef*(MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/MudSystem%Area_PipeSectionFt(MudSystem%St_Mud_Forehead_section%Array(imud)) + if ( data%State%MudSystem%St_MudDischarged_Volume%Array(imud) <= data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud)) then + data%State%MudSystem%St_Mud_Backhead_section%Array(imud)= data%State%MudSystem%St_Mud_Forehead_section%Array(imud) + data%State%MudSystem%St_Mud_Backhead_X%Array(imud)= data%State%MudSystem%St_Mud_Forehead_X%Array(imud)- data%State%MudSystem%DirectionCoef*(data%State%MudSystem%St_MudDischarged_Volume%Array(imud)/7.48051948d0)/data%State%MudSystem%Area_PipeSectionFt(data%State%MudSystem%St_Mud_Forehead_section%Array(imud)) ! 7.48051948 is for gal to ft^3 else - MudSystem%isection= MudSystem%St_Mud_Backhead_section%Array(imud)-1 - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) + data%State%MudSystem%isection= data%State%MudSystem%St_Mud_Backhead_section%Array(imud)-1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Array(imud) do - if (MudSystem%isection < 1) then ! last pipe section(string exit) - MudSystem%St_MudDischarged_Volume%Array(imud)= MudSystem%St_MudDischarged_Volume%Array(imud)- MudSystem%St_RemainedVolume_in_LastSection%Array(imud) - MudSystem%St_Mud_Backhead_X%Array(imud)= MudSystem%Xstart_PipeSection(2) - MudSystem%St_Mud_Backhead_section%Array(imud)= 2 + if (data%State%MudSystem%isection < 1) then ! last pipe section(string exit) + data%State%MudSystem%St_MudDischarged_Volume%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud) + data%State%MudSystem%St_Mud_Backhead_X%Array(imud)= data%State%MudSystem%Xstart_PipeSection(2) + data%State%MudSystem%St_Mud_Backhead_section%Array(imud)= 2 - if (MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string + if (data%State%MudSystem%St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string call RemoveStringMudArrays(imud) endif exit endif - MudSystem%xx= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) !(gal) + data%State%MudSystem%xx= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)/ data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) !(gal) - if (MudSystem%xx<= 1.0) then - MudSystem%St_Mud_Backhead_section%Array(imud)= MudSystem%isection - MudSystem%St_Mud_Backhead_X%Array(imud)= (MudSystem%xx * (MudSystem%Xstart_PipeSection(MudSystem%isection)- MudSystem%Xend_PipeSection(MudSystem%isection)))+ MudSystem%Xend_PipeSection(MudSystem%isection) + if (data%State%MudSystem%xx<= 1.0) then + data%State%MudSystem%St_Mud_Backhead_section%Array(imud)= data%State%MudSystem%isection + data%State%MudSystem%St_Mud_Backhead_X%Array(imud)= (data%State%MudSystem%xx * (data%State%MudSystem%Xstart_PipeSection(data%State%MudSystem%isection)- data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection)))+ data%State%MudSystem%Xend_PipeSection(data%State%MudSystem%isection) exit else - MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- MudSystem%PipeSection_VolumeCapacity(MudSystem%isection) - MudSystem%isection= MudSystem%isection- 1 + data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)= data%State%MudSystem%St_RemainedVolume_in_LastSection%Array(imud)- data%State%MudSystem%PipeSection_VolumeCapacity(data%State%MudSystem%isection) + data%State%MudSystem%isection= data%State%MudSystem%isection- 1 endif diff --git a/Equipments/PowerLimits.f90 b/Equipments/PowerLimits.f90 deleted file mode 100644 index c657ba5..0000000 --- a/Equipments/PowerLimits.f90 +++ /dev/null @@ -1,44 +0,0 @@ -subroutine PowerLimits - !subroutine PowerLimits(Power_sigma) - - USE Pumps_VARIABLES, only: PUMP - USE Drawworks_VARIABLES, only: Drawworks - USE RTable_VARIABLES, only: RTable - USE CPowerVariables, only: Power%NumberOfgenerators, Power%GeneratorPowerRating - USE CDrillingConsoleVariables - USE equipments_PowerLimit - - IMPLICIT NONE - !integer :: ii - - - !Power_sigma=2.d0*(PUMP(1)%Vt*PUMP(1)%ia_new)+2.d0*(PUMP(2)%Vt*PUMP(2)%ia_new)+2.d0*(PUMP(3)%Vt*PUMP(3)%ia_new)+(RTable%Vt*RTable%ia_new)+2.d0*(Drawworks%Vt*Drawworks%ia_new) - !write(*,*) 'Power_sigma=', Power_sigma - - - power_num_of_Jenerators=sngl(Power%NumberOfgenerators) - Jenerator_power=Power%GeneratorPowerRating - drilling_console_Jenerators(1)=DrillingConsole%GEN1BTNLED - drilling_console_Jenerators(2)=DrillingConsole%GEN2BTNLED - drilling_console_Jenerators(3)=DrillingConsole%GEN3BTNLED - drilling_console_Jenerators(4)=DrillingConsole%GEN4BTNLED - - drilling_num_of_Jenerators=0.d0 - !do ii=1,4 - ! if (drilling_console_Jenerators(ii)=1) then - ! drilling_num_of_Jenerators=drilling_num_of_Jenerators+1. - ! end if - !end do - drilling_num_of_Jenerators=sngl(sum(drilling_console_Jenerators)) - !drilling_num_of_Jenerators=1.d0 - - if (power_num_of_Jenerators>drilling_num_of_Jenerators) then - num_of_active_Jenerators=drilling_num_of_Jenerators - else if (power_num_of_Jenerators<=drilling_num_of_Jenerators) then - num_of_active_Jenerators=power_num_of_Jenerators - end if - - max_Power_sigma=num_of_active_Jenerators*Jenerator_power - - -end subroutine PowerLimits \ No newline at end of file diff --git a/Equipments/Pumps.rar.old b/Equipments/Pumps.rar.old deleted file mode 100644 index 045fb7d..0000000 Binary files a/Equipments/Pumps.rar.old and /dev/null differ diff --git a/Equipments/Pumps/Pump1_MainSolver.f90 b/Equipments/Pumps/Pump1_MainSolver.f90 index 3e78477..ddba5dd 100644 --- a/Equipments/Pumps/Pump1_MainSolver.f90 +++ b/Equipments/Pumps/Pump1_MainSolver.f90 @@ -1,29 +1,29 @@ subroutine Pump1_MainSolver - Use Pumps_VARIABLES + use ConfigurationVariables Implicit none - if (PUMP(1)%Throttle<=0.d0) then - PUMP(1)%K_throttle = 1 + if (data%State%Pump(1)%Throttle<=0.d0) then + data%State%Pump(1)%K_throttle = 1 end if - if((any(PUMP(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (PUMP(1)%Switch==-1) .and. (PUMP(1)%K_throttle==1) .and. (PUMP(1)%PowerFailMalf==0) .and. (PUMP(1)%Failure==0)) then + if((any(data%State%Pump(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (data%State%Pump(1)%Switch==-1) .and. (data%State%Pump(1)%K_throttle==1) .and. (data%State%Pump(1)%PowerFailMalf==0) .and. (data%State%Pump(1)%Failure==0)) then - PUMP(1)%SoundBlower = .true. - PUMP(1)%BLWR = 1 + data%State%Pump(1)%SoundBlower = .true. + data%State%Pump(1)%BLWR = 1 !========================== Pump 1 Rate limit ========================== - if (((PUMP(1)%N_new-PUMP(1)%N_old)/PUMP(1)%time_step)>PUMP(1)%RateChange) then - PUMP(1)%Speed =(PUMP(1)%RateChange*PUMP(1)%time_step)+PUMP(1)%N_old ![RPM] - else if (((PUMP(1)%N_old-PUMP(1)%N_new)/PUMP(1)%time_step)>PUMP(1)%RateChange) then - PUMP(1)%Speed = (-PUMP(1)%RateChange*PUMP(1)%time_step)+PUMP(1)%N_old + if (((data%State%Pump(1)%N_new-data%State%Pump(1)%N_old)/data%State%Pump(1)%time_step)>data%State%Pump(1)%RateChange) then + data%State%Pump(1)%Speed =(data%State%Pump(1)%RateChange*data%State%Pump(1)%time_step)+data%State%Pump(1)%N_old ![RPM] + else if (((data%State%Pump(1)%N_old-data%State%Pump(1)%N_new)/data%State%Pump(1)%time_step)>data%State%Pump(1)%RateChange) then + data%State%Pump(1)%Speed = (-data%State%Pump(1)%RateChange*data%State%Pump(1)%time_step)+data%State%Pump(1)%N_old else - PUMP(1)%Speed = PUMP(1)%N_new + data%State%Pump(1)%Speed = data%State%Pump(1)%N_new end if !======================================================================= @@ -31,26 +31,26 @@ subroutine Pump1_MainSolver else - if ((any(PUMP(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (PUMP(1)%Switch==-1)) then - PUMP(1)%SoundBlower = .true. + if ((any(data%State%Pump(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (data%State%Pump(1)%Switch==-1)) then + data%State%Pump(1)%SoundBlower = .true. else - PUMP(1)%SoundBlower = .false. + data%State%Pump(1)%SoundBlower = .false. end if - if ((any(PUMP(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (PUMP(1)%Switch==-1) .and. (PUMP(1)%PowerFailMalf==0) .and. (PUMP(1)%Failure==0)) then - PUMP(1)%BLWR = 1 + if ((any(data%State%Pump(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (data%State%Pump(1)%Switch==-1) .and. (data%State%Pump(1)%PowerFailMalf==0) .and. (data%State%Pump(1)%Failure==0)) then + data%State%Pump(1)%BLWR = 1 else - PUMP(1)%BLWR = 0 + data%State%Pump(1)%BLWR = 0 end if Call Pump_OffMode_Solver(1) - PUMP(1)%K_throttle = 0 + data%State%Pump(1)%K_throttle = 0 end if - PUMP(1)%N_old = PUMP(1)%Speed + data%State%Pump(1)%N_old = data%State%Pump(1)%Speed diff --git a/Equipments/Pumps/Pump2_MainSolver.f90 b/Equipments/Pumps/Pump2_MainSolver.f90 index 98d32a6..ac5d181 100644 --- a/Equipments/Pumps/Pump2_MainSolver.f90 +++ b/Equipments/Pumps/Pump2_MainSolver.f90 @@ -1,29 +1,29 @@ subroutine Pump2_MainSolver - Use Pumps_VARIABLES + use ConfigurationVariables Implicit none - if (PUMP(2)%Throttle<=0.d0) then - PUMP(2)%K_throttle = 1 + if (data%State%Pump(2)%Throttle<=0.d0) then + data%State%Pump(2)%K_throttle = 1 end if - if((any(PUMP(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (PUMP(2)%Switch==-1) .and. (PUMP(2)%K_throttle==1) .and. (PUMP(2)%PowerFailMalf==0) .and. (PUMP(2)%Failure==0)) then + if((any(data%State%Pump(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (data%State%Pump(2)%Switch==-1) .and. (data%State%Pump(2)%K_throttle==1) .and. (data%State%Pump(2)%PowerFailMalf==0) .and. (data%State%Pump(2)%Failure==0)) then - PUMP(2)%SoundBlower = .true. - PUMP(2)%BLWR = 1 + data%State%Pump(2)%SoundBlower = .true. + data%State%Pump(2)%BLWR = 1 !========================== Pump 2 Rate limit ========================== - if (((PUMP(2)%N_new-PUMP(2)%N_old)/PUMP(2)%time_step)>PUMP(2)%RateChange) then - PUMP(2)%Speed =(PUMP(2)%RateChange*PUMP(2)%time_step)+PUMP(2)%N_old - else if (((PUMP(2)%N_old-PUMP(2)%N_new)/PUMP(2)%time_step)>PUMP(2)%RateChange) then - PUMP(2)%Speed = (-PUMP(2)%RateChange*PUMP(2)%time_step)+PUMP(2)%N_old + if (((data%State%Pump(2)%N_new-data%State%Pump(2)%N_old)/data%State%Pump(2)%time_step)>data%State%Pump(2)%RateChange) then + data%State%Pump(2)%Speed =(data%State%Pump(2)%RateChange*data%State%Pump(2)%time_step)+data%State%Pump(2)%N_old + else if (((data%State%Pump(2)%N_old-data%State%Pump(2)%N_new)/data%State%Pump(2)%time_step)>data%State%Pump(2)%RateChange) then + data%State%Pump(2)%Speed = (-data%State%Pump(2)%RateChange*data%State%Pump(2)%time_step)+data%State%Pump(2)%N_old else - PUMP(2)%Speed = PUMP(2)%N_new + data%State%Pump(2)%Speed = data%State%Pump(2)%N_new end if !======================================================================= @@ -31,26 +31,26 @@ subroutine Pump2_MainSolver else - if ((any(PUMP(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (PUMP(2)%Switch==-1)) then - PUMP(2)%SoundBlower = .true. + if ((any(data%State%Pump(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (data%State%Pump(2)%Switch==-1)) then + data%State%Pump(2)%SoundBlower = .true. else - PUMP(2)%SoundBlower = .false. + data%State%Pump(2)%SoundBlower = .false. end if - if ((any(PUMP(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (PUMP(2)%Switch==-1) .and. (PUMP(2)%PowerFailMalf==0) .and. (PUMP(2)%Failure==0)) then - PUMP(2)%BLWR = 1 + if ((any(data%State%Pump(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (data%State%Pump(2)%Switch==-1) .and. (data%State%Pump(2)%PowerFailMalf==0) .and. (data%State%Pump(2)%Failure==0)) then + data%State%Pump(2)%BLWR = 1 else - PUMP(2)%BLWR = 0 + data%State%Pump(2)%BLWR = 0 end if Call Pump_OffMode_Solver(2) - PUMP(2)%K_throttle = 0 + data%State%Pump(2)%K_throttle = 0 end if - PUMP(2)%N_old = PUMP(2)%Speed + data%State%Pump(2)%N_old = data%State%Pump(2)%Speed diff --git a/Equipments/Pumps/Pump3_MainSolver.f90 b/Equipments/Pumps/Pump3_MainSolver.f90 index 28bc99b..b3c8f17 100644 --- a/Equipments/Pumps/Pump3_MainSolver.f90 +++ b/Equipments/Pumps/Pump3_MainSolver.f90 @@ -1,26 +1,26 @@ subroutine Pump3_MainSolver - Use Pumps_VARIABLES + use ConfigurationVariables Implicit none - if (PUMP(3)%Throttle<=0.d0) then - PUMP(3)%K_throttle = 1 + if (data%State%Pump(3)%Throttle<=0.d0) then + data%State%Pump(3)%K_throttle = 1 end if - if((PUMP(3)%Switch==1) .and. (PUMP(3)%K_throttle==1) .and. (PUMP(3)%PowerFailMalf==0) .and. (PUMP(3)%Failure==0)) then + if((data%State%Pump(3)%Switch==1) .and. (data%State%Pump(3)%K_throttle==1) .and. (data%State%Pump(3)%PowerFailMalf==0) .and. (data%State%Pump(3)%Failure==0)) then !========================== Pump 3 Rate limit ========================== - if (((PUMP(3)%N_new-PUMP(3)%N_old)/PUMP(3)%time_step)>PUMP(3)%RateChange) then - PUMP(3)%Speed =(PUMP(3)%RateChange*PUMP(3)%time_step)+PUMP(3)%N_old ![RPM] - else if (((PUMP(3)%N_old-PUMP(3)%N_new)/PUMP(3)%time_step)>PUMP(3)%RateChange) then - PUMP(3)%Speed = (-PUMP(3)%RateChange*PUMP(3)%time_step)+PUMP(3)%N_old + if (((data%State%Pump(3)%N_new-data%State%Pump(3)%N_old)/data%State%Pump(3)%time_step)>data%State%Pump(3)%RateChange) then + data%State%Pump(3)%Speed =(data%State%Pump(3)%RateChange*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old ![RPM] + else if (((data%State%Pump(3)%N_old-data%State%Pump(3)%N_new)/data%State%Pump(3)%time_step)>data%State%Pump(3)%RateChange) then + data%State%Pump(3)%Speed = (-data%State%Pump(3)%RateChange*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old else - PUMP(3)%Speed = PUMP(3)%N_new + data%State%Pump(3)%Speed = data%State%Pump(3)%N_new end if !======================================================================= @@ -29,12 +29,12 @@ subroutine Pump3_MainSolver else Call Pump_OffMode_Solver(3) - PUMP(3)%K_throttle = 0 + data%State%Pump(3)%K_throttle = 0 end if - PUMP(3)%N_old = PUMP(3)%Speed + data%State%Pump(3)%N_old = data%State%Pump(3)%Speed diff --git a/Equipments/Pumps/Pump_OffMode_Solver.f90 b/Equipments/Pumps/Pump_OffMode_Solver.f90 index cb0708d..a703a56 100644 --- a/Equipments/Pumps/Pump_OffMode_Solver.f90 +++ b/Equipments/Pumps/Pump_OffMode_Solver.f90 @@ -1,41 +1,41 @@ subroutine Pump_OffMode_Solver(Pump_No) - Use Pumps_VARIABLES + use ConfigurationVariables IMPLICIT NONE INTEGER :: Pump_No - PUMP(Pump_No)%N_new = 0.d0 + data%State%Pump(Pump_No)%N_new = 0.d0 !========================== Pump Rate limit ========================== - if (((PUMP(Pump_No)%N_new-PUMP(Pump_No)%N_old)/PUMP(Pump_No)%time_step)>PUMP(Pump_No)%RateChange) then - PUMP(Pump_No)%Speed =(PUMP(Pump_No)%RateChange*PUMP(Pump_No)%time_step)+PUMP(Pump_No)%N_old - else if (((PUMP(Pump_No)%N_old-PUMP(Pump_No)%N_new)/PUMP(Pump_No)%time_step)>PUMP(Pump_No)%RateChange) then - PUMP(Pump_No)%Speed = (-PUMP(Pump_No)%RateChange*PUMP(Pump_No)%time_step)+PUMP(Pump_No)%N_old + if (((data%State%Pump(Pump_No)%N_new-data%State%Pump(Pump_No)%N_old)/data%State%Pump(Pump_No)%time_step)>data%State%Pump(Pump_No)%RateChange) then + data%State%Pump(Pump_No)%Speed =(data%State%Pump(Pump_No)%RateChange*data%State%Pump(Pump_No)%time_step)+data%State%Pump(Pump_No)%N_old + else if (((data%State%Pump(Pump_No)%N_old-data%State%Pump(Pump_No)%N_new)/data%State%Pump(Pump_No)%time_step)>data%State%Pump(Pump_No)%RateChange) then + data%State%Pump(Pump_No)%Speed = (-data%State%Pump(Pump_No)%RateChange*data%State%Pump(Pump_No)%time_step)+data%State%Pump(Pump_No)%N_old else - PUMP(Pump_No)%Speed = PUMP(Pump_No)%N_new + data%State%Pump(Pump_No)%Speed = data%State%Pump(Pump_No)%N_new end if !======================================================================= - PUMP(Pump_No)%Flow_Rate = PUMP(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*(PUMP(Pump_No)%Speed/PUMP(Pump_No)%Trans_Ratio) ![gpm] - PUMP(Pump_No)%HorsePower = ((PUMP(Pump_No)%Flow_Rate/0.01d0)*PUMP(Pump_No)%StandPipe_Pressure)/(168067.d0*PUMP(Pump_No)%Mech_Efficiency) ![HHP] - !PUMP(Pump_No)%Max_Horsepower = ((PUMP(Pump_No)%Flow_Rate/0.01d0)*PUMP(Pump_No)%Max_Pressure)/(168067.d0*PUMP(Pump_No)%Mech_Efficiency) ![HHP] - PUMP(Pump_No)%Max_Horsepower = (PUMP(Pump_No)%Flow_Rate*PUMP(Pump_No)%Max_Pressure)/(1714.d0*PUMP(Pump_No)%Mech_Efficiency) - if ( PUMP(Pump_No)%StandPipe_Pressure>PUMP(Pump_No)%Max_Pressure ) then ! in shart check shavad - !if ( (PUMP(Pump_No)%StandPipe_Pressure*PUMP(Pump_No)%Flow_Rate)>(1714.d0*PUMP(Pump_No)%Max_Horsepower*PUMP(Pump_No)%Mech_Efficiency) ) then - PUMP(Pump_No)%Flow_Rate = (1714.d0*PUMP(Pump_No)%Mech_Efficiency*PUMP(Pump_No)%Max_Horsepower)/PUMP(Pump_No)%StandPipe_Pressure ![gpm] - PUMP(Pump_No)%Speed = ( PUMP(Pump_No)%Flow_Rate/(PUMP(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0) )*PUMP(Pump_No)%Trans_Ratio ![rpm] + data%State%Pump(Pump_No)%Flow_Rate = data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) ![gpm] + data%State%Pump(Pump_No)%HorsePower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%StandPipe_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP] + !data%State%Pump(Pump_No)%Max_Horsepower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%Max_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP] + data%State%Pump(Pump_No)%Max_Horsepower = (data%State%Pump(Pump_No)%Flow_Rate*data%State%Pump(Pump_No)%Max_Pressure)/(1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency) + if ( data%State%Pump(Pump_No)%StandPipe_Pressure>data%State%Pump(Pump_No)%Max_Pressure ) then ! in shart check shavad + !if ( (data%State%Pump(Pump_No)%StandPipe_Pressure*data%State%Pump(Pump_No)%Flow_Rate)>(1714.d0*data%State%Pump(Pump_No)%Max_Horsepower*data%State%Pump(Pump_No)%Mech_Efficiency) ) then + data%State%Pump(Pump_No)%Flow_Rate = (1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency*data%State%Pump(Pump_No)%Max_Horsepower)/data%State%Pump(Pump_No)%StandPipe_Pressure ![gpm] + data%State%Pump(Pump_No)%Speed = ( data%State%Pump(Pump_No)%Flow_Rate/(data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0) )*data%State%Pump(Pump_No)%Trans_Ratio ![rpm] end if - PUMP(Pump_No)%SoundSPM = INT(PUMP(Pump_No)%Speed/PUMP(Pump_No)%Trans_Ratio) + data%State%Pump(Pump_No)%SoundSPM = INT(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) - If (PUMP(Pump_No)%Flow_Rate>0.d0) Then - PUMP(Pump_No)%Open_Close = 1 + If (data%State%Pump(Pump_No)%Flow_Rate>0.d0) Then + data%State%Pump(Pump_No)%Open_Close = 1 Else - PUMP(Pump_No)%Open_Close = 0 + data%State%Pump(Pump_No)%Open_Close = 0 End if diff --git a/Equipments/Pumps/Pump_OnMode_Solver.f90 b/Equipments/Pumps/Pump_OnMode_Solver.f90 index 4bf3712..7704a93 100644 --- a/Equipments/Pumps/Pump_OnMode_Solver.f90 +++ b/Equipments/Pumps/Pump_OnMode_Solver.f90 @@ -1,29 +1,29 @@ subroutine Pump_OnMode_Solver(Pump_No) - Use Pumps_VARIABLES + use ConfigurationVariables IMPLICIT NONE INTEGER :: Pump_No - PUMP(Pump_No)%Flow_Rate = PUMP(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*(PUMP(Pump_No)%Speed/PUMP(Pump_No)%Trans_Ratio) ![gpm] - PUMP(Pump_No)%Max_FlowRate = PUMP(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*PUMP(Pump_No)%MaxSPM ![gpm] - PUMP(Pump_No)%HorsePower = ((PUMP(Pump_No)%Flow_Rate/0.01d0)*PUMP(Pump_No)%StandPipe_Pressure)/(168067.d0*PUMP(Pump_No)%Mech_Efficiency) ![HHP] - !PUMP(Pump_No)%Max_Horsepower = ((PUMP(Pump_No)%Flow_Rate/0.01d0)*PUMP(Pump_No)%Max_Pressure)/(168067.d0*PUMP(Pump_No)%Mech_Efficiency) ![HHP] - PUMP(Pump_No)%Max_Horsepower = (PUMP(Pump_No)%Flow_Rate*PUMP(Pump_No)%Max_Pressure)/(1714.d0*PUMP(Pump_No)%Mech_Efficiency) - if ( PUMP(Pump_No)%StandPipe_Pressure>PUMP(Pump_No)%Max_Pressure ) then ! in shart check shavad - !if ( (PUMP(Pump_No)%StandPipe_Pressure*PUMP(Pump_No)%Flow_Rate)>(1714.d0*PUMP(Pump_No)%Max_Horsepower*PUMP(Pump_No)%Mech_Efficiency) ) then - PUMP(Pump_No)%Flow_Rate = (1714.d0*PUMP(Pump_No)%Mech_Efficiency*PUMP(Pump_No)%Max_Horsepower)/PUMP(Pump_No)%StandPipe_Pressure ![gpm] - PUMP(Pump_No)%Speed = ( PUMP(Pump_No)%Flow_Rate/(PUMP(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0) )*PUMP(Pump_No)%Trans_Ratio ![rpm] + data%State%Pump(Pump_No)%Flow_Rate = data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) ![gpm] + data%State%Pump(Pump_No)%Max_FlowRate = data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*data%State%Pump(Pump_No)%MaxSPM ![gpm] + data%State%Pump(Pump_No)%HorsePower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%StandPipe_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP] + !data%State%Pump(Pump_No)%Max_Horsepower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%Max_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP] + data%State%Pump(Pump_No)%Max_Horsepower = (data%State%Pump(Pump_No)%Flow_Rate*data%State%Pump(Pump_No)%Max_Pressure)/(1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency) + if ( data%State%Pump(Pump_No)%StandPipe_Pressure>data%State%Pump(Pump_No)%Max_Pressure ) then ! in shart check shavad + !if ( (data%State%Pump(Pump_No)%StandPipe_Pressure*data%State%Pump(Pump_No)%Flow_Rate)>(1714.d0*data%State%Pump(Pump_No)%Max_Horsepower*data%State%Pump(Pump_No)%Mech_Efficiency) ) then + data%State%Pump(Pump_No)%Flow_Rate = (1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency*data%State%Pump(Pump_No)%Max_Horsepower)/data%State%Pump(Pump_No)%StandPipe_Pressure ![gpm] + data%State%Pump(Pump_No)%Speed = ( data%State%Pump(Pump_No)%Flow_Rate/(data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0) )*data%State%Pump(Pump_No)%Trans_Ratio ![rpm] end if - PUMP(Pump_No)%SoundSPM = INT(PUMP(Pump_No)%Speed/PUMP(Pump_No)%Trans_Ratio) ![spm] + data%State%Pump(Pump_No)%SoundSPM = INT(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) ![spm] - If (PUMP(Pump_No)%Flow_Rate>0.d0) Then - PUMP(Pump_No)%Open_Close = 1 + If (data%State%Pump(Pump_No)%Flow_Rate>0.d0) Then + data%State%Pump(Pump_No)%Open_Close = 1 Else - PUMP(Pump_No)%Open_Close = 0 + data%State%Pump(Pump_No)%Open_Close = 0 End if diff --git a/Equipments/Pumps/PumpsMain.f90 b/Equipments/Pumps/PumpsMain.f90 index 9e89782..aaf4874 100644 --- a/Equipments/Pumps/PumpsMain.f90 +++ b/Equipments/Pumps/PumpsMain.f90 @@ -1,5 +1,5 @@ module PumpsMain - Use Pumps_VARIABLES + use ConfigurationVariables implicit none public contains @@ -78,7 +78,7 @@ module PumpsMain ! subroutine Pump2MainBody ! use ifport ! use ifmt -! use CWarningsVariables +! use CWarnings ! implicit none ! ! integer,dimension(8) :: MP_START_TIME, MP_END_TIME @@ -150,44 +150,44 @@ module PumpsMain ! ! Call sleepqq(10) ! ! ! ! !!! Pump3 Malfunction ----> Power Failure -! ! !!if (PUMP(1)%PowerFailMalf==1) then +! ! !!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. (PUMP(3)%PowerFailMalf==0) ) then +! ! !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 (PUMP(1)%PowerFailMalf==1) then +! !!!! if (data%State%Pump(1)%PowerFailMalf==1) then ! !!!! !MP1BLWR=0 ! !!!! Pump3_OffMode_Solver ! !!!! Call ClosePump1() ! !!!! exit loop2 ! !!!! end if ! !! -! !! PUMP(3)%N_new = MP1Throttle -! !! if (((PUMP(3)%N_new-PUMP(3)%N_old)/PUMP(3)%time_step)>193.) then -! !! PUMP(3)%N_ref =(193.*PUMP(3)%time_step)+PUMP(3)%N_old -! !! else if (((PUMP(3)%N_old-PUMP(3)%N_new)/PUMP(3)%time_step)>193.) then -! !! PUMP(3)%N_ref = (-193.*PUMP(3)%time_step)+PUMP(3)%N_old +! !! 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 -! !! PUMP(3)%N_ref = PUMP(3)%N_new +! !! data%State%Pump(3)%N_ref = data%State%Pump(3)%N_new ! !! end if ! !! ! !! Call Pump3_OnMode_Solver ! !! -! !! IF (PUMP(3)%Flow_Rate>0.) Then +! !! IF (data%State%Pump(3)%Flow_Rate>0.) Then ! !! Call OpenCementPump() ! !! Else ! !! Call CloseCementPump() ! !! End if ! !! -! !! PUMP(3)%N_old = PUMP(3)%N_ref +! !! 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)) diff --git a/Equipments/Pumps/Pumps_Inputs.f90 b/Equipments/Pumps/Pumps_Inputs.f90 index af31027..7097a3c 100644 --- a/Equipments/Pumps/Pumps_Inputs.f90 +++ b/Equipments/Pumps/Pumps_Inputs.f90 @@ -1,7 +1,9 @@ subroutine Pumps_Inputs - Use CDrillingConsoleVariables - Use Pumps_VARIABLES + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + use ConfigurationVariables Use MudSystemModule IMPLICIT NONE @@ -10,28 +12,28 @@ subroutine Pumps_Inputs !>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<< - !PUMP(1)%BlowPopOffMalf = 0 !??????? motaghayere voroudi + !data%State%Pump(1)%BlowPopOffMalf = 0 !??????? motaghayere voroudi - if ( PUMP(1)%BlowPopOffMalf==1 ) then ! Pump1 Malfunction ----> Blow Pop-offs (Relief Valves) - PUMP(1)%StandPipe_Pressure = 0.d0 + if ( data%State%Pump(1)%BlowPopOffMalf==1 ) then ! Pump1 Malfunction ----> Blow Pop-offs (Relief Valves) + data%State%Pump(1)%StandPipe_Pressure = 0.d0 else - PUMP(1)%StandPipe_Pressure = PumpPressure1 ![psi] - if ( PUMP(1)%StandPipe_Pressure<=14.d0 ) then - PUMP(1)%StandPipe_Pressure = 14.d0 + data%State%Pump(1)%StandPipe_Pressure = PumpPressure1 ![psi] + if ( data%State%Pump(1)%StandPipe_Pressure<=14.d0 ) then + data%State%Pump(1)%StandPipe_Pressure = 14.d0 end if end if - PUMP(1)%AssignmentSwitchh = DrillingConsole%AssignmentSwitch + data%State%Pump(1)%AssignmentSwitchh = data%EquipmentControl%DrillingConsole%AssignmentSwitch - PUMP(1)%Switch = DrillingConsole%MP1CPSwitch + data%State%Pump(1)%Switch = data%EquipmentControl%DrillingConsole%MP1CPSwitch - PUMP(1)%Throttle = DrillingConsole%MP1Throttle ![RPM] + data%State%Pump(1)%Throttle = data%EquipmentControl%DrillingConsole%MP1Throttle ![RPM] - !PUMP(1)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump1 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad + !data%State%Pump(1)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump1 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad - PUMP(1)%Failure = Warmings%Pump1Failure !(Pump1 Warning ----> Failure) + data%State%Pump(1)%Failure = data%Warnings%Pump1Failure !(Pump1 Warning ----> Failure) - PUMP(1)%N_new = PUMP(1)%Throttle + data%State%Pump(1)%N_new = data%State%Pump(1)%Throttle @@ -41,28 +43,28 @@ subroutine Pumps_Inputs !>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<< - !PUMP(2)%BlowPopOffMalf = 0 !??????? motaghayere voroudi + !data%State%Pump(2)%BlowPopOffMalf = 0 !??????? motaghayere voroudi - if ( PUMP(2)%BlowPopOffMalf==1 ) then ! Pump2 Malfunction ----> Blow Pop-offs (Relief Valves) - PUMP(2)%StandPipe_Pressure = 0.d0 + if ( data%State%Pump(2)%BlowPopOffMalf==1 ) then ! Pump2 Malfunction ----> Blow Pop-offs (Relief Valves) + data%State%Pump(2)%StandPipe_Pressure = 0.d0 else - PUMP(2)%StandPipe_Pressure = PumpPressure2 ![psi] - if ( PUMP(2)%StandPipe_Pressure<=14.d0 ) then - PUMP(2)%StandPipe_Pressure = 14.d0 + data%State%Pump(2)%StandPipe_Pressure = PumpPressure2 ![psi] + if ( data%State%Pump(2)%StandPipe_Pressure<=14.d0 ) then + data%State%Pump(2)%StandPipe_Pressure = 14.d0 end if end if - PUMP(2)%AssignmentSwitchh = DrillingConsole%AssignmentSwitch + data%State%Pump(2)%AssignmentSwitchh = data%EquipmentControl%DrillingConsole%AssignmentSwitch - PUMP(2)%Switch = DrillingConsole%MP2Switch + data%State%Pump(2)%Switch = data%EquipmentControl%DrillingConsole%MP2Switch - PUMP(2)%Throttle = DrillingConsole%MP2Throttle ![RPM] + data%State%Pump(2)%Throttle = data%EquipmentControl%DrillingConsole%MP2Throttle ![RPM] - !PUMP(2)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump2 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad + !data%State%Pump(2)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump2 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad - PUMP(2)%Failure = Warmings%Pump2Failure !(Pump2 Warning ----> Failure) + data%State%Pump(2)%Failure = data%Warnings%Pump2Failure !(Pump2 Warning ----> Failure) - PUMP(2)%N_new = PUMP(2)%Throttle + data%State%Pump(2)%N_new = data%State%Pump(2)%Throttle @@ -72,26 +74,26 @@ subroutine Pumps_Inputs !!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<< - !PUMP(3)%BlowPopOffMalf = 0 !??????? motaghayere voroudi + !data%State%Pump(3)%BlowPopOffMalf = 0 !??????? motaghayere voroudi - if ( PUMP(3)%BlowPopOffMalf==1 ) then ! Pump3 Malfunction ----> Blow Pop-offs (Relief Valves) - PUMP(3)%StandPipe_Pressure = 0.d0 + if ( data%State%Pump(3)%BlowPopOffMalf==1 ) then ! Pump3 Malfunction ----> Blow Pop-offs (Relief Valves) + data%State%Pump(3)%StandPipe_Pressure = 0.d0 else - PUMP(3)%StandPipe_Pressure = PumpPressure3 ![psi] - if ( PUMP(3)%StandPipe_Pressure<=14.d0 ) then - PUMP(3)%StandPipe_Pressure = 14.d0 + data%State%Pump(3)%StandPipe_Pressure = PumpPressure3 ![psi] + if ( data%State%Pump(3)%StandPipe_Pressure<=14.d0 ) then + data%State%Pump(3)%StandPipe_Pressure = 14.d0 end if end if - PUMP(3)%Switch = DrillingConsole%MP1CPSwitch + data%State%Pump(3)%Switch = data%EquipmentControl%DrillingConsole%MP1CPSwitch - PUMP(3)%Throttle = DrillingConsole%MP1Throttle ![RPM] + data%State%Pump(3)%Throttle = data%EquipmentControl%DrillingConsole%MP1Throttle ![RPM] - !PUMP(3)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump3 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad + !data%State%Pump(3)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump3 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad - PUMP(3)%Failure = Warmings%Pump3Failure !(Pump1 Warning ----> Failure) + data%State%Pump(3)%Failure = data%Warnings%Pump3Failure !(Pump1 Warning ----> Failure) - PUMP(3)%N_new = PUMP(3)%Throttle + data%State%Pump(3)%N_new = data%State%Pump(3)%Throttle diff --git a/Equipments/Pumps/Pumps_MainSolver.f90 b/Equipments/Pumps/Pumps_MainSolver.f90 index f5666c0..8716469 100644 --- a/Equipments/Pumps/Pumps_MainSolver.f90 +++ b/Equipments/Pumps/Pumps_MainSolver.f90 @@ -1,6 +1,6 @@ subroutine Pumps_MainSolver - Use Pumps_VARIABLES + use ConfigurationVariables Implicit none @@ -9,8 +9,6 @@ subroutine Pumps_MainSolver Call DrillingConsole_ScrLEDs !koja bezaramesh????? Call Pumps_Inputs - - Call Pump1_MainSolver diff --git a/Equipments/Pumps/Pumps_Outputs.f90 b/Equipments/Pumps/Pumps_Outputs.f90 index b321173..f757f0e 100644 --- a/Equipments/Pumps/Pumps_Outputs.f90 +++ b/Equipments/Pumps/Pumps_Outputs.f90 @@ -1,10 +1,11 @@ subroutine Pumps_Outputs - Use CDataDisplayConsoleVariables + use CDataDisplayConsole + use ConfigurationVariables ! Use CSimulationVariables - Use Pumps_VARIABLES + use ConfigurationVariables Use MudSystemModule - Use CDrillWatchVariables + use ConfigurationVariables !@ Use CSounds IMPLICIT NONE @@ -13,23 +14,23 @@ subroutine Pumps_Outputs !>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<< - If (PUMP(1)%Open_Close==1) then + If (data%State%Pump(1)%Open_Close==1) then Call OpenPump1() - Else if (PUMP(1)%Open_Close==0) then + Else if (data%State%Pump(1)%Open_Close==0) then Call ClosePump1() End if - DrillingConsole%MP1BLWR = PUMP(1)%BLWR + data%EquipmentControl%DrillingConsole%MP1BLWR = data%State%Pump(1)%BLWR - Call SetSoundBlowerMP1( PUMP(1)%SoundBlower ) !.true. or .false. - Call SetSoundMP1( PUMP(1)%SoundSPM ) ![spm] , integer + Call SetSoundBlowerMP1( data%State%Pump(1)%SoundBlower ) !.true. or .false. + Call SetSoundMP1( data%State%Pump(1)%SoundSPM ) ![spm] , integer - if ((PUMP(1)%Switch==-1) .or. (PUMP(1)%Switch==0)) then - Call Set_MP1SPMGauge( sngl(1-PUMP(1)%SPMGaugeMalf)*real((PUMP(1)%Speed/PUMP(1)%Trans_Ratio),8) ) ![spm] , real - DrillingWatch%SPM1 = DataDisplayConsole%MP1SPMGauge + if ((data%State%Pump(1)%Switch==-1) .or. (data%State%Pump(1)%Switch==0)) then + Call Set_MP1SPMGauge( sngl(1-data%State%Pump(1)%SPMGaugeMalf)*real((data%State%Pump(1)%Speed/data%State%Pump(1)%Trans_Ratio),8) ) ![spm] , real + data%EquipmentControl%DrillingWatch%SPM1 = data%EquipmentControl%DataDisplayConsole%MP1SPMGauge end if - !PUMP(1)%Flow_Rate !to other modules , [gpm] + !data%State%Pump(1)%Flow_Rate !to other modules , [gpm] @@ -39,21 +40,21 @@ subroutine Pumps_Outputs !>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<< - If (PUMP(2)%Open_Close==1) then + If (data%State%Pump(2)%Open_Close==1) then Call OpenPump2() - Else if (PUMP(2)%Open_Close==0) then + Else if (data%State%Pump(2)%Open_Close==0) then Call ClosePump2() End if - DrillingConsole%MP2BLWR = PUMP(2)%BLWR + data%EquipmentControl%DrillingConsole%MP2BLWR = data%State%Pump(2)%BLWR - Call SetSoundBlowerMP2( PUMP(2)%SoundBlower ) - Call SetSoundMP2( PUMP(2)%SoundSPM ) + Call SetSoundBlowerMP2( data%State%Pump(2)%SoundBlower ) + Call SetSoundMP2( data%State%Pump(2)%SoundSPM ) - Call Set_MP2SPMGauge( sngl(1-PUMP(2)%SPMGaugeMalf)*real((PUMP(2)%Speed/PUMP(2)%Trans_Ratio),8) ) - DrillingWatch%SPM2 = DataDisplayConsole%MP2SPMGauge + Call Set_MP2SPMGauge( sngl(1-data%State%Pump(2)%SPMGaugeMalf)*real((data%State%Pump(2)%Speed/data%State%Pump(2)%Trans_Ratio),8) ) + data%EquipmentControl%DrillingWatch%SPM2 = data%EquipmentControl%DataDisplayConsole%MP2SPMGauge - !PUMP(2)%Flow_Rate !to other modules + !data%State%Pump(2)%Flow_Rate !to other modules @@ -62,27 +63,27 @@ subroutine Pumps_Outputs !!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<< - If (PUMP(3)%Open_Close==1) then + If (data%State%Pump(3)%Open_Close==1) then Call OpenCementPump() - Else if (PUMP(3)%Open_Close==0) then + Else if (data%State%Pump(3)%Open_Close==0) then Call CloseCementPump() End if - Call SetSoundMP3( PUMP(3)%SoundSPM ) + Call SetSoundMP3( data%State%Pump(3)%SoundSPM ) - if (PUMP(3)%Switch==1) then - Call Set_MP1SPMGauge( real((PUMP(3)%Speed/PUMP(3)%Trans_Ratio),8) ) - DrillingWatch%SPM1 = DataDisplayConsole%MP1SPMGauge + if (data%State%Pump(3)%Switch==1) then + Call Set_MP1SPMGauge( real((data%State%Pump(3)%Speed/data%State%Pump(3)%Trans_Ratio),8) ) + data%EquipmentControl%DrillingWatch%SPM1 = data%EquipmentControl%DataDisplayConsole%MP1SPMGauge end if - !PUMP(3)%Flow_Rate !to other modules + !data%State%Pump(3)%Flow_Rate !to other modules !>>>>>>>>>>>>>>>>>>>>>>> Total Pumps <<<<<<<<<<<<<<<<<<<<<<<<<<< - !MPumps%Total_Pump_Gpm = 100.d0 !??????????? - !MPumps%Total_Pump_SPM = 1000.d0 !????????????? + !data%State%MPumps%Total_Pump_Gpm = 100.d0 !??????????? + !data%State%MPumps%Total_Pump_SPM = 1000.d0 !????????????? !SCR1LED=1 !SCR2LED=1 diff --git a/Equipments/Pumps/Pumps_StartUp.f90 b/Equipments/Pumps/Pumps_StartUp.f90 index f5aca06..7bfe09e 100644 --- a/Equipments/Pumps/Pumps_StartUp.f90 +++ b/Equipments/Pumps/Pumps_StartUp.f90 @@ -1,48 +1,49 @@ subroutine Pumps_StartUp - Use CPumpsVariables - Use Pumps_VARIABLES + use CPumpsVariables + use CPumps + use ConfigurationVariables IMPLICIT NONE !>>>>>>>>>>>>>>>>>>>>>>> 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 - PUMP(1)%Mech_Efficiency = PumpsSpecification%MudPump1MechanicalEfficiency ![dimensionless] - !PUMP(1)%Vol_Efficiency = MudPump1VolumetricEfficiency !bayad hazf beshe ? - PUMP(1)%Max_Pressure = 6000.d0 ![psi] !??????? motaghayere voroudi - PUMP(1)%MaxSPM = PumpsSpecification%MudPump1Maximum ![spm] - PUMP(1)%Trans_Ratio = 965.d0/PUMP(1)%MaxSPM - PUMP(1)%time_step = 0.1d0 !?????? niaz hast ya na?? + 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 = PumpsSpecification%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 = PumpsSpecification%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?? - PUMP(1)%RateChange = 193.d0!PUMP(1)%RateChange*PUMP(1)%Trans_Ratio ! [rpm/min ??] ??????????????? rpm/s - PUMP(1)%K_throttle = 0 - PUMP(1)%N_old = 0.d0 + 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 <<<<<<<<<<<<<<<<<<<<<<<<<<< - 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 - PUMP(2)%Mech_Efficiency = PumpsSpecification%MudPump2MechanicalEfficiency ![dimensionless] - !PUMP(2)%Vol_Efficiency = MudPump2VolumetricEfficiency !bayad hazf beshe ? - PUMP(2)%Max_Pressure = 6000.d0 ![psi] !??????? motaghayere voroudi - 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 + 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 = PumpsSpecification%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 = PumpsSpecification%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 <<<<<<<<<<<<<<<<<<<<<<<<<<< - 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 - PUMP(3)%Mech_Efficiency = PumpsSpecification%CementPumpMechanicalEfficiency ![dimensionless] - !PUMP(3)%Vol_Efficiency = CementPumpVolumetricEfficiency !bayad hazf beshe ? - PUMP(3)%Max_Pressure = 6000.d0 ![psi] !??????? motaghayere voroudi - 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 + 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 = PumpsSpecification%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 = PumpsSpecification%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 \ No newline at end of file diff --git a/Equipments/Pumps/Pumps_TotalSolver.f90 b/Equipments/Pumps/Pumps_TotalSolver.f90 index cfaa29a..1b513a1 100644 --- a/Equipments/Pumps/Pumps_TotalSolver.f90 +++ b/Equipments/Pumps/Pumps_TotalSolver.f90 @@ -1,13 +1,13 @@ subroutine Pumps_TotalSolver - Use Pumps_VARIABLES + use ConfigurationVariables Implicit none - MPumps%Total_Pump_Gpm = PUMP(1)%Flow_Rate+PUMP(2)%Flow_Rate+PUMP(3)%Flow_Rate ![gpm] - MPumps%Total_Pump_SPM = (PUMP(1)%Speed/PUMP(1)%Trans_Ratio)+(PUMP(2)%Speed/PUMP(2)%Trans_Ratio)+(PUMP(3)%Speed/PUMP(3)%Trans_Ratio) ![stk/min] + data%State%MPumps%Total_Pump_Gpm = data%State%Pump(1)%Flow_Rate+data%State%Pump(2)%Flow_Rate+data%State%Pump(3)%Flow_Rate ![gpm] + data%State%MPumps%Total_Pump_SPM = (data%State%Pump(1)%Speed/data%State%Pump(1)%Trans_Ratio)+(data%State%Pump(2)%Speed/data%State%Pump(2)%Trans_Ratio)+(data%State%Pump(3)%Speed/data%State%Pump(3)%Trans_Ratio) ![stk/min] diff --git a/Equipments/Pumps/Pumps_VARIABLES.f90 b/Equipments/Pumps/Pumps_VARIABLES.f90 index 81bb5b6..5ae10b5 100644 --- a/Equipments/Pumps/Pumps_VARIABLES.f90 +++ b/Equipments/Pumps/Pumps_VARIABLES.f90 @@ -6,7 +6,7 @@ MODULE Pumps_VARIABLES - REAL , PARAMETER :: pi=3.14159265d0 + ! REAL , PARAMETER :: pi=3.14159265d0 Type, public:: Pumps_Var @@ -42,7 +42,6 @@ MODULE Pumps_VARIABLES END TYPE Pump_Var - TYPE(Pump_Var), DIMENSION(1:3) :: PUMP !*********************************************************************************************** !*********************************************************************************************** diff --git a/Equipments/RotaryTable/RTable_INPUTS.f90 b/Equipments/RotaryTable/RTable_INPUTS.f90 index f0482ac..15a6722 100644 --- a/Equipments/RotaryTable/RTable_INPUTS.f90 +++ b/Equipments/RotaryTable/RTable_INPUTS.f90 @@ -1,75 +1,79 @@ subroutine RTable_INPUTS use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables ! use CSimulationVariables - use CTdsConnectionModesEnumVariables - use CTdsElevatorModesEnumVariables + use UnitySignalsModule + ! use CTdsElevatorModesEnumVariables use CHoistingVariables - use RTable_VARIABLES + use ConfigurationVariables + use ConfigurationVariables !@ use TD_DrillStemComponents use CUnityInputs - use CWarningsVariables + use CWarnings use UnitySignalVariables + use UnitySignalsModule IMPLICIT NONE integer :: i - RTable%AssignmentSwitch = DrillingConsole%AssignmentSwitch - RTable%Switch = DrillingConsole%RTSwitch - !RTable%GearsAbuse = RotaryGearsAbuse - RTable%Throttle = DrillingConsole%RTThrottle ![RPM] - RTable%String_Torque = TD_String%StringTorque*12.d0 ![lb.ft]*12 ---> [lb.in] ????????? - !RTable%RpmGaugeMalf !:dar module haye C meghdardehi mishe + data%State%RTable%AssignmentSwitch = data%EquipmentControl%DrillingConsole%AssignmentSwitch + data%State%RTable%Switch = data%EquipmentControl%DrillingConsole%RTSwitch + !data%State%RTable%GearsAbuse = RotaryGearsAbuse + data%State%RTable%Throttle = data%EquipmentControl%DrillingConsole%RTThrottle ![RPM] + data%State%RTable%String_Torque = data%State%TD_String%StringTorque*12.d0 ![lb.ft]*12 ---> [lb.in] ????????? + !data%State%RTable%RpmGaugeMalf !:dar module haye C meghdardehi mishe - RTable%N_new = RTable%Throttle - if ( RTable%MotorFaileMalf==1 ) then - RTable%N_new = 0.d0 + data%State%RTable%N_new = data%State%RTable%Throttle + if ( data%State%RTable%MotorFaileMalf==1 ) then + data%State%RTable%N_new = 0.d0 end if - RTable%String_Torque = 0.112984d0*RTable%String_Torque ![N.m] + data%State%RTable%String_Torque = 0.112984d0*data%State%RTable%String_Torque ![N.m] !===> String_JCoef Calculation - if ( Hoisting%DriveType==0 ) then + if ( data%State%Hoisting%DriveType==0 ) then if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then - RTable%RotaryMode = 1 - RTable%String_JCoef = 0.d0 - Do i = 1,TD_String%StringConfigurationCount - RTable%String_JCoef = RTable%String_JCoef+( (TD_DrillStem(i)%TotalWeight*((TD_DrillStem(i)%Id**2.d0)+(TD_DrillStem(i)%Od**2.d0)))/8.d0 ) ![lb.ft^2] , Jz=(1/2)*m*(r1^2+r2^2) + data%State%RTable%RotaryMode = 1 + data%State%RTable%String_JCoef = 0.d0 + Do i = 1,data%State%TD_String%StringConfigurationCount + data%State%RTable%String_JCoef = data%State%RTable%String_JCoef+( (data%State%TD_DrillStem(i)%TotalWeight*((data%State%TD_DrillStem(i)%Id**2.d0)+(data%State%TD_DrillStem(i)%Od**2.d0)))/8.d0 ) ![lb.ft^2] , Jz=(1/2)*m*(r1^2+r2^2) End Do - RTable%String_JCoef = RTable%String_JCoef*0.0421401d0 ![kg.m^2] + data%State%RTable%String_JCoef = data%State%RTable%String_JCoef*0.0421401d0 ![kg.m^2] else if ( Get_Slips() /= SLIPS_SET_END ) then - RTable%RotaryMode = 2 - RTable%String_JCoef = 0.d0 - RTable%String_Torque = 0.d0 + data%State%RTable%RotaryMode = 2 + data%State%RTable%String_JCoef = 0.d0 + data%State%RTable%String_Torque = 0.d0 else - RTable%RotaryMode = 3 - RTable%String_JCoef = 0.d0 - RTable%String_Torque = 0.d0 + data%State%RTable%RotaryMode = 3 + data%State%RTable%String_JCoef = 0.d0 + data%State%RTable%String_Torque = 0.d0 end if - else if ( Hoisting%DriveType==1 ) then + else if ( data%State%Hoisting%DriveType==1 ) then if ( Get_IsKellyBushingSetInTable() .or. Get_Slips() == SLIPS_SET_END ) then !if rotary connected to string - RTable%RotaryMode = 4 - RTable%String_JCoef = 0.d0 - Do i = 1,TD_String%StringConfigurationCount - RTable%String_JCoef = RTable%String_JCoef+( (TD_DrillStem(i)%TotalWeight*((TD_DrillStem(i)%Id**2.d0)+(TD_DrillStem(i)%Od**2.d0)))/8.d0 ) ![lb.ft^2] , Jz=(1/2)*m*(r1^2+r2^2) + data%State%RTable%RotaryMode = 4 + data%State%RTable%String_JCoef = 0.d0 + Do i = 1,data%State%TD_String%StringConfigurationCount + data%State%RTable%String_JCoef = data%State%RTable%String_JCoef+( (data%State%TD_DrillStem(i)%TotalWeight*((data%State%TD_DrillStem(i)%Id**2.d0)+(data%State%TD_DrillStem(i)%Od**2.d0)))/8.d0 ) ![lb.ft^2] , Jz=(1/2)*m*(r1^2+r2^2) End Do - RTable%String_JCoef = RTable%String_JCoef*0.0421401e0 ![kg.m^2] + data%State%RTable%String_JCoef = data%State%RTable%String_JCoef*0.0421401e0 ![kg.m^2] else - RTable%RotaryMode = 5 - RTable%String_JCoef = 0.d0 - RTable%String_Torque = 0.d0 + data%State%RTable%RotaryMode = 5 + data%State%RTable%String_JCoef = 0.d0 + data%State%RTable%String_Torque = 0.d0 end if end if !===> Transmission Mode - RTable%Conv_Ratio = RTable%High_Conv_Ratio + data%State%RTable%Conv_Ratio = data%State%RTable%High_Conv_Ratio diff --git a/Equipments/RotaryTable/RTable_OffModeSolver.f90 b/Equipments/RotaryTable/RTable_OffModeSolver.f90 index bd359c1..4edb274 100644 --- a/Equipments/RotaryTable/RTable_OffModeSolver.f90 +++ b/Equipments/RotaryTable/RTable_OffModeSolver.f90 @@ -1,6 +1,6 @@ subroutine RTable_OffMode - use RTable_VARIABLES + use ConfigurationVariables !@ IMPLICIT NONE @@ -8,52 +8,52 @@ subroutine RTable_OffMode - RT_OldSpeed = RTable%Speed - RT_OldRpmGauge = RTable%RpmGaugeOutput - RTable%N_new = 0.d0 + RT_OldSpeed = data%State%RTable%Speed + RT_OldRpmGauge = data%State%RTable%RpmGaugeOutput + data%State%RTable%N_new = 0.d0 !======================= Rotary Table Rate_limit ======================= - if (((RTable%N_new-RTable%N_old)/RTable%time_step)>RTable%RateChange) then - RTable%N_ref = (RTable%RateChange*RTable%time_step)+RTable%N_old - else if (((RTable%N_old-RTable%N_new)/RTable%time_step)>RTable%RateChange) then - RTable%N_ref = (-RTable%RateChange*RTable%time_step)+RTable%N_old + if (((data%State%RTable%N_new-data%State%RTable%N_old)/data%State%RTable%time_step)>data%State%RTable%RateChange) then + data%State%RTable%N_ref = (data%State%RTable%RateChange*data%State%RTable%time_step)+data%State%RTable%N_old + else if (((data%State%RTable%N_old-data%State%RTable%N_new)/data%State%RTable%time_step)>data%State%RTable%RateChange) then + data%State%RTable%N_ref = (-data%State%RTable%RateChange*data%State%RTable%time_step)+data%State%RTable%N_old else - RTable%N_ref = RTable%N_new + data%State%RTable%N_ref = data%State%RTable%N_new end if !======================================================================= - if ( any(RTable%RotaryMode==(/1,4/)) ) then !if rotary connected to string + if ( any(data%State%RTable%RotaryMode==(/1,4/)) ) then !if rotary connected to string !==> RPM - RTable%Speed = RTable%N_ref/RTable%Conv_Ratio - RTable%Speed = min(RTable%Speed,RTable%MaxRPM) !Speed [RPM] - RTable%RpmGaugeOutput = RTable%Speed + data%State%RTable%Speed = data%State%RTable%N_ref/data%State%RTable%Conv_Ratio + data%State%RTable%Speed = min(data%State%RTable%Speed,data%State%RTable%MaxRPM) !Speed [RPM] + data%State%RTable%RpmGaugeOutput = data%State%RTable%Speed !==> Sound - RTable%SoundRPM = INT(RTable%Speed) + data%State%RTable%SoundRPM = INT(data%State%RTable%Speed) !==> Torque - RTable%Torque = ( ((RTable%J_coef+RTable%String_JCoef)*((((pi*RTable%Speed)/30.d0)-((pi*RT_OldSpeed)/30.d0))/RTable%time_step))+(RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] - RTable%Torque = min(RTable%Torque,RTable%MaxTorque) - RTable%TorqueGaugeOutput = RTable%Torque - else if ( any(RTable%RotaryMode==(/2,5/)) ) then + data%State%RTable%Torque = ( ((data%State%RTable%J_coef+data%State%RTable%String_JCoef)*((((pi*data%State%RTable%Speed)/30.d0)-((pi*RT_OldSpeed)/30.d0))/data%State%RTable%time_step))+(data%State%RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] + data%State%RTable%Torque = min(data%State%RTable%Torque,data%State%RTable%MaxTorque) + data%State%RTable%TorqueGaugeOutput = data%State%RTable%Torque + else if ( any(data%State%RTable%RotaryMode==(/2,5/)) ) then !==> RPM - RTable%Speed = 0.d0 - RTable%RpmGaugeOutput = RTable%N_ref/RTable%Conv_Ratio - RTable%RpmGaugeOutput = min(RTable%RpmGaugeOutput,RTable%MaxRPM) + data%State%RTable%Speed = 0.d0 + data%State%RTable%RpmGaugeOutput = data%State%RTable%N_ref/data%State%RTable%Conv_Ratio + data%State%RTable%RpmGaugeOutput = min(data%State%RTable%RpmGaugeOutput,data%State%RTable%MaxRPM) !==> Sound - RTable%SoundRPM = INT(RTable%RpmGaugeOutput) + data%State%RTable%SoundRPM = INT(data%State%RTable%RpmGaugeOutput) !==> Torque - RTable%Torque = 0.d0 - RTable%TorqueGaugeOutput = ( ((RTable%J_coef+RTable%String_JCoef)*((((pi*RTable%RpmGaugeOutput)/30.d0)-((pi*RT_OldRpmGauge)/30.d0))/RTable%time_step))+(RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] - RTable%TorqueGaugeOutput = min(RTable%TorqueGaugeOutput,RTable%MaxTorque) - else if ( RTable%RotaryMode==3 ) then + data%State%RTable%Torque = 0.d0 + data%State%RTable%TorqueGaugeOutput = ( ((data%State%RTable%J_coef+data%State%RTable%String_JCoef)*((((pi*data%State%RTable%RpmGaugeOutput)/30.d0)-((pi*RT_OldRpmGauge)/30.d0))/data%State%RTable%time_step))+(data%State%RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] + data%State%RTable%TorqueGaugeOutput = min(data%State%RTable%TorqueGaugeOutput,data%State%RTable%MaxTorque) + else if ( data%State%RTable%RotaryMode==3 ) then !==> RPM - RTable%Speed = 0.d0 - RTable%RpmGaugeOutput = 0.d0 + data%State%RTable%Speed = 0.d0 + data%State%RTable%RpmGaugeOutput = 0.d0 !==> Sound - RTable%SoundRPM = INT(RTable%RpmGaugeOutput) + data%State%RTable%SoundRPM = INT(data%State%RTable%RpmGaugeOutput) !==> Torque - RTable%Torque = 0.d0 - RTable%TorqueGaugeOutput = 0.d0 + data%State%RTable%Torque = 0.d0 + data%State%RTable%TorqueGaugeOutput = 0.d0 end if diff --git a/Equipments/RotaryTable/RTable_OnModeSolver.f90 b/Equipments/RotaryTable/RTable_OnModeSolver.f90 index 0828454..90da3a6 100644 --- a/Equipments/RotaryTable/RTable_OnModeSolver.f90 +++ b/Equipments/RotaryTable/RTable_OnModeSolver.f90 @@ -1,6 +1,6 @@ subroutine RTable_OnModeSolver - Use RTable_VARIABLES + use ConfigurationVariables !@ IMPLICIT NONE @@ -8,42 +8,42 @@ subroutine RTable_OnModeSolver - RT_OldSpeed = RTable%Speed - RT_OldRpmGauge = RTable%RpmGaugeOutput + RT_OldSpeed = data%State%RTable%Speed + RT_OldRpmGauge = data%State%RTable%RpmGaugeOutput - if ( any(RTable%RotaryMode==(/1,4/)) ) then !if rotary connected to string + if ( any(data%State%RTable%RotaryMode==(/1,4/)) ) then !if rotary connected to string !==> RPM - RTable%Speed = RTable%N_ref/RTable%Conv_Ratio - RTable%Speed = min(RTable%Speed,RTable%MaxRPM) !Speed [RPM] - RTable%RpmGaugeOutput = RTable%Speed + data%State%RTable%Speed = data%State%RTable%N_ref/data%State%RTable%Conv_Ratio + data%State%RTable%Speed = min(data%State%RTable%Speed,data%State%RTable%MaxRPM) !Speed [RPM] + data%State%RTable%RpmGaugeOutput = data%State%RTable%Speed !==> Sound - RTable%SoundRPM = INT(RTable%Speed) + data%State%RTable%SoundRPM = INT(data%State%RTable%Speed) !==> Torque - RTable%Torque = ( ((RTable%J_coef+RTable%String_JCoef)*((((pi*RTable%Speed)/30.d0)-((pi*RT_OldSpeed)/30.d0))/RTable%time_step))+(RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] - RTable%Torque = min(RTable%Torque,RTable%MaxTorque) - RTable%TorqueGaugeOutput = RTable%Torque - else if ( any(RTable%RotaryMode==(/2,5/)) ) then + data%State%RTable%Torque = ( ((data%State%RTable%J_coef+data%State%RTable%String_JCoef)*((((pi*data%State%RTable%Speed)/30.d0)-((pi*RT_OldSpeed)/30.d0))/data%State%RTable%time_step))+(data%State%RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] + data%State%RTable%Torque = min(data%State%RTable%Torque,data%State%RTable%MaxTorque) + data%State%RTable%TorqueGaugeOutput = data%State%RTable%Torque + else if ( any(data%State%RTable%RotaryMode==(/2,5/)) ) then !==> RPM - RTable%Speed = 0.d0 - RTable%RpmGaugeOutput = RTable%N_ref/RTable%Conv_Ratio - RTable%RpmGaugeOutput = min(RTable%RpmGaugeOutput,RTable%MaxRPM) !inja bayad bashe ya na??? + data%State%RTable%Speed = 0.d0 + data%State%RTable%RpmGaugeOutput = data%State%RTable%N_ref/data%State%RTable%Conv_Ratio + data%State%RTable%RpmGaugeOutput = min(data%State%RTable%RpmGaugeOutput,data%State%RTable%MaxRPM) !inja bayad bashe ya na??? !==> Sound - RTable%SoundRPM = INT(RTable%RpmGaugeOutput) + data%State%RTable%SoundRPM = INT(data%State%RTable%RpmGaugeOutput) !==> Torque - RTable%Torque = 0.d0 - RTable%TorqueGaugeOutput = ( ((RTable%J_coef+RTable%String_JCoef)*((((pi*RTable%RpmGaugeOutput)/30.d0)-((pi*RT_OldRpmGauge)/30.d0))/RTable%time_step))+(RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] - RTable%TorqueGaugeOutput = min(RTable%TorqueGaugeOutput,RTable%MaxTorque) - else if ( RTable%RotaryMode==3 ) then + data%State%RTable%Torque = 0.d0 + data%State%RTable%TorqueGaugeOutput = ( ((data%State%RTable%J_coef+data%State%RTable%String_JCoef)*((((pi*data%State%RTable%RpmGaugeOutput)/30.d0)-((pi*RT_OldRpmGauge)/30.d0))/data%State%RTable%time_step))+(data%State%RTable%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] ![kg.m^2]*[radians/s^2]+[N.m]=[N.m] + data%State%RTable%TorqueGaugeOutput = min(data%State%RTable%TorqueGaugeOutput,data%State%RTable%MaxTorque) + else if ( data%State%RTable%RotaryMode==3 ) then !==> RPM - RTable%Speed = 0.d0 - RTable%RpmGaugeOutput = 0.d0 + data%State%RTable%Speed = 0.d0 + data%State%RTable%RpmGaugeOutput = 0.d0 !==> Sound - RTable%SoundRPM = INT(RTable%RpmGaugeOutput) + data%State%RTable%SoundRPM = INT(data%State%RTable%RpmGaugeOutput) !==> Torque - RTable%Torque = 0.d0 - RTable%TorqueGaugeOutput = 0.d0 + data%State%RTable%Torque = 0.d0 + data%State%RTable%TorqueGaugeOutput = 0.d0 end if diff --git a/Equipments/RotaryTable/RTable_Outputs.f90 b/Equipments/RotaryTable/RTable_Outputs.f90 index d8d08a1..d0cf4e6 100644 --- a/Equipments/RotaryTable/RTable_Outputs.f90 +++ b/Equipments/RotaryTable/RTable_Outputs.f90 @@ -1,28 +1,31 @@ subroutine RTable_Outputs - Use CDrillingConsoleVariables - Use CDataDisplayConsoleVariables - Use RTable_VARIABLES - Use CDrillWatchVariables + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + use CDataDisplayConsole + use ConfigurationVariables + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use CSounds IMPLICIT NONE - DrillingConsole%RTBLWR = RTable%BLWR + data%EquipmentControl%DrillingConsole%RTBLWR = data%State%RTable%BLWR - Call SetSoundBlowerRT(RTable%SoundBlower) !.true. or .false. - Call SetSoundRT( RTable%SoundRPM ) ![RPM] , integer + Call SetSoundBlowerRT(data%State%RTable%SoundBlower) !.true. or .false. + Call SetSoundRT( data%State%RTable%SoundRPM ) ![RPM] , integer - !RTable%Speed !to other modules - Call Set_RotaryRPMGauge( sngl(1-RTable%RpmGaugeMalf)*real(RTable%RpmGaugeOutput,8) ) ![RPM] + !data%State%RTable%Speed !to other modules + Call Set_RotaryRPMGauge( sngl(1-data%State%RTable%RpmGaugeMalf)*real(data%State%RTable%RpmGaugeOutput,8) ) ![RPM] - DataDisplayConsole%RotaryTorqueGauge = RTable%TorqueGaugeOutput ![ft.lbf] - DrillingWatch%Torque = RTable%TorqueGaugeOutput - Call Set_RotaryTorque(sngl(1-RTable%TorqueGaugeMalf)*real(RTable%TorqueGaugeOutput,8)) ![ft.lbf] + data%EquipmentControl%DataDisplayConsole%RotaryTorqueGauge = data%State%RTable%TorqueGaugeOutput ![ft.lbf] + data%EquipmentControl%DrillingWatch%Torque = data%State%RTable%TorqueGaugeOutput + Call Set_RotaryTorque(sngl(1-data%State%RTable%TorqueGaugeMalf)*real(data%State%RTable%TorqueGaugeOutput,8)) ![ft.lbf] - !RT_RPMUnityOutput = sngl(RTable%Switch)*-1.d0*RotaryRPMGauge + !RT_RPMUnityOutput = sngl(data%State%RTable%Switch)*-1.d0*RotaryRPMGauge diff --git a/Equipments/RotaryTable/RTable_StartUp.f90 b/Equipments/RotaryTable/RTable_StartUp.f90 index 0f596f0..7d7243d 100644 --- a/Equipments/RotaryTable/RTable_StartUp.f90 +++ b/Equipments/RotaryTable/RTable_StartUp.f90 @@ -1,30 +1,30 @@ subroutine RTable_StartUp - Use RTable_VARIABLES + Use ConfigurationVariables IMPLICIT NONE - RTable%Inertia_Moment = 23.261341d0 ! 23.261341[kg.m^2] = 552[lb.ft^2] - RTable%Mech_Efficiency = 0.93d0 - RTable%RateChange = 1.d0 ![Hz/s] !??????? motaghayere voroudi - RTable%High_Conv_Ratio = 4.825d0 - RTable%Low_Conv_Ratio = 7.31d0 - RTable%time_step = 0.1d0 ![s] - RTable%MaxRPM = 200.d0 ![RPM] !??????? motaghayere voroudi - RTable%MaxTorque = 1500.d0 ![ft.lbf] !??????? motaghayere voroudi - - - - RTable%RateChange = RTable%RateChange*60.d0 ![RPM/s] ![cycle/min]=[RPM] !1[Hz]=60[RPM] - RTable%J_coef = RTable%Inertia_Moment+(1.d0*(RTable%Inertia_Moment)) - RTable%Conv_Ratio = RTable%Low_Conv_Ratio - RTable%String_JCoef = 0.d0 - RTable%Torque = 0.d0 - RTable%K_throttle = 0 - RTable%Speed = 0.d0 - RTable%TorqueGaugeOutput = 0.d0 + data%State%RTable%Inertia_Moment = 23.261341d0 ! 23.261341[kg.m^2] = 552[lb.ft^2] + data%State%RTable%Mech_Efficiency = 0.93d0 + data%State%RTable%RateChange = 1.d0 ![Hz/s] !??????? motaghayere voroudi + data%State%RTable%High_Conv_Ratio = 4.825d0 + data%State%RTable%Low_Conv_Ratio = 7.31d0 + data%State%RTable%time_step = 0.1d0 ![s] + data%State%RTable%MaxRPM = 200.d0 ![RPM] !??????? motaghayere voroudi + data%State%RTable%MaxTorque = 1500.d0 ![ft.lbf] !??????? motaghayere voroudi + + + + data%State%RTable%RateChange = data%State%RTable%RateChange*60.d0 ![RPM/s] ![cycle/min]=[RPM] !1[Hz]=60[RPM] + data%State%RTable%J_coef = data%State%RTable%Inertia_Moment+(1.d0*(data%State%RTable%Inertia_Moment)) + data%State%RTable%Conv_Ratio = data%State%RTable%Low_Conv_Ratio + data%State%RTable%String_JCoef = 0.d0 + data%State%RTable%Torque = 0.d0 + data%State%RTable%K_throttle = 0 + data%State%RTable%Speed = 0.d0 + data%State%RTable%TorqueGaugeOutput = 0.d0 call RTable_OffMode diff --git a/Equipments/RotaryTable/RTable_VARIABLES.f90 b/Equipments/RotaryTable/RTable_VARIABLES.f90 index d73cf16..85717bf 100644 --- a/Equipments/RotaryTable/RTable_VARIABLES.f90 +++ b/Equipments/RotaryTable/RTable_VARIABLES.f90 @@ -4,7 +4,7 @@ MODULE RTable_VARIABLES PUBLIC - REAL, PARAMETER :: pi=3.14159265 + ! REAL, PARAMETER :: pi=3.14159265 @@ -32,16 +32,9 @@ MODULE RTable_VARIABLES !************* Sound_VARIABLES ********************** INTEGER :: SoundRPM Logical :: SoundBlower - - - END TYPE RTable_Var - TYPE(RTable_Var) :: RTable !*********************************************************************************************** !**************************************************************************************************** - - - END MODULE RTable_VARIABLES \ No newline at end of file diff --git a/Equipments/RotaryTable/RotaryTableMain.f90 b/Equipments/RotaryTable/RotaryTableMain.f90 index 0b64c9e..6b9db93 100644 --- a/Equipments/RotaryTable/RotaryTableMain.f90 +++ b/Equipments/RotaryTable/RotaryTableMain.f90 @@ -27,7 +27,7 @@ module RotaryTableMain subroutine RotaryTableMainBody - Use RTable_VARIABLES + use ConfigurationVariables !@ implicit none diff --git a/Equipments/RotaryTable/Rtable_MainSolver.f90 b/Equipments/RotaryTable/Rtable_MainSolver.f90 index 0baf2b9..8febb38 100644 --- a/Equipments/RotaryTable/Rtable_MainSolver.f90 +++ b/Equipments/RotaryTable/Rtable_MainSolver.f90 @@ -1,66 +1,66 @@ subroutine RTable_MainSolver - Use RTable_VARIABLES + use ConfigurationVariables !@ IMPLICIT NONE Call RTable_Inputs - if (RTable%Throttle<=0.d0) then - RTable%K_throttle = 1 + if (data%State%RTable%Throttle<=0.d0) then + data%State%RTable%K_throttle = 1 end if - if ( (any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTable%Switch==-1) ) then + if ( (any(data%State%RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (data%State%RTable%Switch==-1) ) then - RTable%SoundBlower = .true. - RTable%BLWR = 1 + data%State%RTable%SoundBlower = .true. + data%State%RTable%BLWR = 1 !======================= Rotary Table Rate_limit ======================= - if (((RTable%N_new-RTable%N_old)/RTable%time_step)>RTable%RateChange) then - RTable%N_ref = (RTable%RateChange*RTable%time_step)+RTable%N_old - else if (((RTable%N_old-RTable%N_new)/RTable%time_step)>RTable%RateChange) then - RTable%N_ref = (-RTable%RateChange*RTable%time_step)+RTable%N_old + if (((data%State%RTable%N_new-data%State%RTable%N_old)/data%State%RTable%time_step)>data%State%RTable%RateChange) then + data%State%RTable%N_ref = (data%State%RTable%RateChange*data%State%RTable%time_step)+data%State%RTable%N_old + else if (((data%State%RTable%N_old-data%State%RTable%N_new)/data%State%RTable%time_step)>data%State%RTable%RateChange) then + data%State%RTable%N_ref = (-data%State%RTable%RateChange*data%State%RTable%time_step)+data%State%RTable%N_old else - RTable%N_ref = RTable%N_new + data%State%RTable%N_ref = data%State%RTable%N_new end if !======================================================================= CALL RTable_OnModeSolver - else if ( (any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTable%Switch==1) .and. (RTable%K_throttle==1) ) then + else if ( (any(data%State%RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (data%State%RTable%Switch==1) .and. (data%State%RTable%K_throttle==1) ) then - RTable%SoundBlower = .true. - RTable%BLWR = 1 + data%State%RTable%SoundBlower = .true. + data%State%RTable%BLWR = 1 !======================= Rotary Table Rate_limit ======================= - if (((RTable%N_new-RTable%N_old)/RTable%time_step)>RTable%RateChange) then - RTable%N_ref = (RTable%RateChange*RTable%time_step)+RTable%N_old - else if (((RTable%N_old-RTable%N_new)/RTable%time_step)>RTable%RateChange) then - RTable%N_ref = (-RTable%RateChange*RTable%time_step)+RTable%N_old + if (((data%State%RTable%N_new-data%State%RTable%N_old)/data%State%RTable%time_step)>data%State%RTable%RateChange) then + data%State%RTable%N_ref = (data%State%RTable%RateChange*data%State%RTable%time_step)+data%State%RTable%N_old + else if (((data%State%RTable%N_old-data%State%RTable%N_new)/data%State%RTable%time_step)>data%State%RTable%RateChange) then + data%State%RTable%N_ref = (-data%State%RTable%RateChange*data%State%RTable%time_step)+data%State%RTable%N_old else - RTable%N_ref = RTable%N_new + data%State%RTable%N_ref = data%State%RTable%N_new end if !======================================================================= CALL RTable_OnModeSolver else - if((any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTable%Switch/=0)) then - RTable%SoundBlower = .true. - RTable%BLWR = 1 + if((any(data%State%RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (data%State%RTable%Switch/=0)) then + data%State%RTable%SoundBlower = .true. + data%State%RTable%BLWR = 1 else - RTable%SoundBlower = .false. - RTable%BLWR = 0 + data%State%RTable%SoundBlower = .false. + data%State%RTable%BLWR = 0 end if Call RTable_OffMode - RTable%K_throttle = 0 + data%State%RTable%K_throttle = 0 end if Call RTable_Outputs - RTable%N_old = RTable%N_ref + data%State%RTable%N_old = data%State%RTable%N_ref diff --git a/Equipments/TopDrive/TopDriveMain.f90 b/Equipments/TopDrive/TopDriveMain.f90 index ea8bb91..4290ad9 100644 --- a/Equipments/TopDrive/TopDriveMain.f90 +++ b/Equipments/TopDrive/TopDriveMain.f90 @@ -35,11 +35,12 @@ module TopDriveMain subroutine TopDriveMainBody ! use CSimulationVariables - use TopDrive_VARIABLES - use CDrillWatchVariables - use CWarningsVariables + use ConfigurationVariables + use ConfigurationVariables !@ + use CWarnings use CSounds use CTopDrivePanelVariables + use ConfigurationVariables implicit none diff --git a/Equipments/TopDrive/TopDrive_INPUTS.f90 b/Equipments/TopDrive/TopDrive_INPUTS.f90 index 6df12bc..68eeb3d 100644 --- a/Equipments/TopDrive/TopDrive_INPUTS.f90 +++ b/Equipments/TopDrive/TopDrive_INPUTS.f90 @@ -1,9 +1,10 @@ subroutine TopDrive_Inputs ! Use CSimulationVariables - Use CTopDrivePanelVariables - Use CTdsConnectionModesEnumVariables - Use TopDrive_VARIABLES + use CTopDrivePanelVariables + use ConfigurationVariables + use UnitySignalsModule + use ConfigurationVariables Use TD_DrillStemComponents IMPLICIT NONE @@ -12,30 +13,30 @@ subroutine TopDrive_Inputs - TDS%String_Torque = TD_String%StringTorque*12.d0 ![lb.ft]*12 ---> [lb.in] ????????? - !TDS%String_Torque = 20000. - TDS%String_Torque = 0.112984829d0*TDS%String_Torque ![N.m] - TDS%PowerState = TopDrivePanel%TopDriveTdsPowerState - TDS%RpmKnob = TopDrivePanel%RpmKnob - !TDS%MotorFaileMalf ! jayi meghdardehi nashode ?????????????????? - TDS%RateChange = 193.d0 ![RPM/s] motaghayere voroudi ??? - TDS%DrillTorqueState = TopDrivePanel%TopDriveDrillTorqueState - TDS%TorqueLimitKnob = TopDrivePanel%TopDriveTorqueLimitKnob ! bayad hazf shavad??????????????/ + data%State%TDS%String_Torque = data%State%TD_String%StringTorque*12.d0 ![lb.ft]*12 ---> [lb.in] ????????? + !data%State%TDS%String_Torque = 20000. + data%State%TDS%String_Torque = 0.112984829d0*data%State%TDS%String_Torque ![N.m] + data%State%TDS%PowerState = data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState + data%State%TDS%RpmKnob = data%EquipmentControl%TopDrivePanel%RpmKnob + !data%State%TDS%MotorFaileMalf ! jayi meghdardehi nashode ?????????????????? + data%State%TDS%RateChange = 193.d0 ![RPM/s] motaghayere voroudi ??? + data%State%TDS%DrillTorqueState = data%EquipmentControl%TopDrivePanel%TopDriveDrillTorqueState + data%State%TDS%TorqueLimitKnob = data%EquipmentControl%TopDrivePanel%TopDriveTorqueLimitKnob ! bayad hazf shavad??????????????/ - !===> TDS%String_JCoef Calculation - if ( (TDS%DrillTorqueState==-1) .and. ((Get_TdsConnectionModes()==TDS_CONNECTION_STRING).or.(Get_TdsConnectionModes()==TDS_CONNECTION_SPINE)) ) then !if TopDrive connected to string - TDS%String_JCoef = 0.d0 - Do i = 1,TD_String%StringConfigurationCount - TDS%String_JCoef = TDS%String_JCoef+( (TD_DrillStem(i)%TotalWeight*((TD_DrillStem(i)%Id**2.d0)+(TD_DrillStem(i)%Od**2.d0)))/8.d0 ) ![lb.ft^2] , Jz=(1/2)*m*(r1^2+r2^2) + !===> data%State%TDS%String_JCoef Calculation + if ( (data%State%TDS%DrillTorqueState==-1) .and. ((Get_TdsConnectionModes()==TDS_CONNECTION_STRING).or.(Get_TdsConnectionModes()==TDS_CONNECTION_SPINE)) ) then !if TopDrive connected to string + data%State%TDS%String_JCoef = 0.d0 + Do i = 1,data%State%TD_String%StringConfigurationCount + data%State%TDS%String_JCoef = data%State%TDS%String_JCoef+( (data%State%TD_DrillStem(i)%TotalWeight*((data%State%TD_DrillStem(i)%Id**2.d0)+(data%State%TD_DrillStem(i)%Od**2.d0)))/8.d0 ) ![lb.ft^2] , Jz=(1/2)*m*(r1^2+r2^2) End Do - TDS%String_JCoef = TDS%String_JCoef*0.0421401d0 ![kg.m^2] + data%State%TDS%String_JCoef = data%State%TDS%String_JCoef*0.0421401d0 ![kg.m^2] else - TDS%String_JCoef = 0.d0 - TDS%String_Torque = 0.d0 + data%State%TDS%String_JCoef = 0.d0 + data%State%TDS%String_Torque = 0.d0 end if - TDS%String_JCoef = TDS%String_JCoef/10.d0 !???????? /10: bi dalil, check it + data%State%TDS%String_JCoef = data%State%TDS%String_JCoef/10.d0 !???????? /10: bi dalil, check it diff --git a/Equipments/TopDrive/TopDrive_MainSolver.f90 b/Equipments/TopDrive/TopDrive_MainSolver.f90 index f01f021..057f4eb 100644 --- a/Equipments/TopDrive/TopDrive_MainSolver.f90 +++ b/Equipments/TopDrive/TopDrive_MainSolver.f90 @@ -1,7 +1,7 @@ subroutine TopDrive_MainSolver - Use TopDrive_VARIABLES + use ConfigurationVariables IMPLICIT NONE @@ -10,49 +10,49 @@ subroutine TopDrive_MainSolver CALL TopDrive_Inputs - if ( (TDS%PowerState==-1) ) then !FWD + if ( (data%State%TDS%PowerState==-1) ) then !FWD - TDS%SoundBlower = .true. - TDS%PowerLed = 1 + data%State%TDS%SoundBlower = .true. + data%State%TDS%PowerLed = 1 - TDS%N_new = (TDS%RpmKnob/250.d0)*965.d0 ! 0 Top Drive Malfunction ----> Drive Motor Failure - if ( TDS%MotorFaileMalf==1 ) then - TDS%N_new = 0.d0 + if ( data%State%TDS%MotorFaileMalf==1 ) then + data%State%TDS%N_new = 0.d0 end if !========================== Top Drive Rate limit ========================== - if (((TDS%N_new-TDS%N_old)/TDS%time_step)>TDS%RateChange) then - TDS%N_ref = (TDS%RateChange*TDS%time_step)+TDS%N_old - else if (((TDS%N_old-TDS%N_new)/TDS%time_step)>TDS%RateChange) then - TDS%N_ref = (-TDS%RateChange*TDS%time_step)+TDS%N_old + if (((data%State%TDS%N_new-data%State%TDS%N_old)/data%State%TDS%time_step)>data%State%TDS%RateChange) then + data%State%TDS%N_ref = (data%State%TDS%RateChange*data%State%TDS%time_step)+data%State%TDS%N_old + else if (((data%State%TDS%N_old-data%State%TDS%N_new)/data%State%TDS%time_step)>data%State%TDS%RateChange) then + data%State%TDS%N_ref = (-data%State%TDS%RateChange*data%State%TDS%time_step)+data%State%TDS%N_old else - TDS%N_ref = TDS%N_new + data%State%TDS%N_ref = data%State%TDS%N_new end if !========================================================================== CALL TopDrive_Solver - else if ( (TDS%PowerState==1) ) then !REV + else if ( (data%State%TDS%PowerState==1) ) then !REV - TDS%SoundBlower = .true. - TDS%PowerLed = 1 + data%State%TDS%SoundBlower = .true. + data%State%TDS%PowerLed = 1 - TDS%N_new = (TDS%RpmKnob/250.d0)*965.d0 + data%State%TDS%N_new = (data%State%TDS%RpmKnob/250.d0)*965.d0 !===> Top Drive Malfunction ----> Drive Motor Failure - if ( TDS%MotorFaileMalf==1 ) then - TDS%N_new = 0.d0 + if ( data%State%TDS%MotorFaileMalf==1 ) then + data%State%TDS%N_new = 0.d0 end if !========================== Top Drive Rate limit ========================== - if (((TDS%N_new-TDS%N_old)/TDS%time_step)>TDS%RateChange) then - TDS%N_ref =(TDS%RateChange*TDS%time_step)+TDS%N_old - else if (((TDS%N_old-TDS%N_new)/TDS%time_step)>TDS%RateChange) then - TDS%N_ref = (-TDS%RateChange*TDS%time_step)+TDS%N_old + if (((data%State%TDS%N_new-data%State%TDS%N_old)/data%State%TDS%time_step)>data%State%TDS%RateChange) then + data%State%TDS%N_ref =(data%State%TDS%RateChange*data%State%TDS%time_step)+data%State%TDS%N_old + else if (((data%State%TDS%N_old-data%State%TDS%N_new)/data%State%TDS%time_step)>data%State%TDS%RateChange) then + data%State%TDS%N_ref = (-data%State%TDS%RateChange*data%State%TDS%time_step)+data%State%TDS%N_old else - TDS%N_ref = TDS%N_new + data%State%TDS%N_ref = data%State%TDS%N_new end if !========================================================================== @@ -60,12 +60,12 @@ subroutine TopDrive_MainSolver else - if( (TDS%PowerState /= 0) ) then - TDS%SoundBlower = .true. - TDS%PowerLed = 1 + if( (data%State%TDS%PowerState /= 0) ) then + data%State%TDS%SoundBlower = .true. + data%State%TDS%PowerLed = 1 else - TDS%SoundBlower = .false. - TDS%PowerLed = 0 + data%State%TDS%SoundBlower = .false. + data%State%TDS%PowerLed = 0 end if Call TopDrive_OffMode @@ -75,7 +75,7 @@ subroutine TopDrive_MainSolver Call TopDrive_Outputs - TDS%N_old = TDS%N_ref + data%State%TDS%N_old = data%State%TDS%N_ref diff --git a/Equipments/TopDrive/TopDrive_OffMode.f90 b/Equipments/TopDrive/TopDrive_OffMode.f90 index 7fb506b..9f1dd08 100644 --- a/Equipments/TopDrive/TopDrive_OffMode.f90 +++ b/Equipments/TopDrive/TopDrive_OffMode.f90 @@ -1,37 +1,37 @@ subroutine TopDrive_OffMode - Use TopDrive_VARIABLES + use ConfigurationVariables IMPLICIT NONE - TDS%N_new = 0.d0 + data%State%TDS%N_new = 0.d0 !================================================================== ! Rate limit for off Mode - if (((TDS%N_old-TDS%N_new)/TDS%time_step)>(2.d0*TDS%RateChange)) then ! baraye 0 shodan RateChange ro *2 karde ??? - TDS%N_ref = (-(2.d0*TDS%RateChange)*TDS%time_step)+TDS%N_old + if (((data%State%TDS%N_old-data%State%TDS%N_new)/data%State%TDS%time_step)>(2.d0*data%State%TDS%RateChange)) then ! baraye 0 shodan RateChange ro *2 karde ??? + data%State%TDS%N_ref = (-(2.d0*data%State%TDS%RateChange)*data%State%TDS%time_step)+data%State%TDS%N_old Call TopDrive_Solver !================================================================== else - TDS%N_ref = 0.d0 - TDS%N_new = 0.d0 - TDS%N_old = 0.d0 - TDS%Speed = 0.d0 - TDS%TDS_wOld = 0.d0 + data%State%TDS%N_ref = 0.d0 + data%State%TDS%N_new = 0.d0 + data%State%TDS%N_old = 0.d0 + data%State%TDS%Speed = 0.d0 + data%State%TDS%TDS_wOld = 0.d0 - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = 1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = 1 - TDS%OldPowerMode = 0 + data%State%TDS%OldPowerMode = 0 End if diff --git a/Equipments/TopDrive/TopDrive_Outputs.f90 b/Equipments/TopDrive/TopDrive_Outputs.f90 index ad4d0d4..972dd4a 100644 --- a/Equipments/TopDrive/TopDrive_Outputs.f90 +++ b/Equipments/TopDrive/TopDrive_Outputs.f90 @@ -1,22 +1,23 @@ Subroutine TopDrive_Outputs - Use TopDrive_VARIABLES - Use CTopDrivePanelVariables + use ConfigurationVariables + use CTopDrivePanelVariables + use ConfigurationVariables IMPLICIT NONE - TopDrivePanel%TopDriveTdsPowerLed = TDS%PowerLed - TopDrivePanel%TopDriveOperationFaultLed = TDS%OperationFaultLed + data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerLed = data%State%TDS%PowerLed + data%EquipmentControl%TopDrivePanel%TopDriveOperationFaultLed = data%State%TDS%OperationFaultLed - !TDS%Speed ! to other modules ![RPM] - TopDrivePanel%TopDriveRpmGauge = TDS%RpmGaugeOutput ![RPM] + !data%State%TDS%Speed ! to other modules ![RPM] + data%EquipmentControl%TopDrivePanel%TopDriveRpmGauge = data%State%TDS%RpmGaugeOutput ![RPM] - TopDrivePanel%TopDriveTorqueGauge = TDS%TorqueGaugeOutput ![ft.lbf] + data%EquipmentControl%TopDrivePanel%TopDriveTorqueGauge = data%State%TDS%TorqueGaugeOutput ![ft.lbf] - !TDS%SoundBlower - !TDS%RPMUnityOutput + !data%State%TDS%SoundBlower + !data%State%TDS%RPMUnityOutput diff --git a/Equipments/TopDrive/TopDrive_Solver.f90 b/Equipments/TopDrive/TopDrive_Solver.f90 index 5ba3dcc..2250170 100644 --- a/Equipments/TopDrive/TopDrive_Solver.f90 +++ b/Equipments/TopDrive/TopDrive_Solver.f90 @@ -1,239 +1,239 @@ subroutine TopDrive_Solver - Use TopDrive_VARIABLES - Use CTdsConnectionModesEnumVariables + use ConfigurationVariables + use UnitySignalsModule IMPLICIT NONE - TDS%TDS_wOld = ((pi*TDS%Speed)/30.d0) ![rad/s] + data%State%TDS%TDS_wOld = ((pi*data%State%TDS%Speed)/30.d0) ![rad/s] !****************************************************************** - if ( TDS%PowerState==-1 .or. TDS%OldPowerMode==-1 ) then !FWD + if ( data%State%TDS%PowerState==-1 .or. data%State%TDS%OldPowerMode==-1 ) then !FWD - if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = 30.d0 - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 30 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 - TDS%OldPowerMode = -1 - else if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 1000.d0 - TDS%OldPowerMode = -1 - else if ( TDS%DrillTorqueState==1 ) then ! TdsMu_Torque - if ( TDS%RpmKnob>0. ) then - TDS%OperationFaultLed = 1 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = 30.d0 + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 30 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 + data%State%TDS%OldPowerMode = -1 + else if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 1000.d0 + data%State%TDS%OldPowerMode = -1 + else if ( data%State%TDS%DrillTorqueState==1 ) then ! TdsMu_Torque + if ( data%State%TDS%RpmKnob>0. ) then + data%State%TDS%OperationFaultLed = 1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 else - TDS%OperationFaultLed = 0 + data%State%TDS%OperationFaultLed = 0 if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = max( 1000.d0,((TDS%TorqueLimitKnob/10.d0)*60000.d0) ) ![ft.lbf] ???? - TDS%OldPowerMode = -1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = max( 1000.d0,((data%State%TDS%TorqueLimitKnob/10.d0)*60000.d0) ) ![ft.lbf] ???? + data%State%TDS%OldPowerMode = -1 else if ( Get_TdsConnectionModes()==Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 end if end if - else if ( TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL + else if ( data%State%TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then - TDS%OperationFaultLed = 0 - TDS%Speed = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM] - TDS%Speed = min(TDS%Speed,TDS%MaxRPM) - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = INT(TDS%Speed) - TDS%Torque = ( ((TDS%J_coef+TDS%String_JCoef)*(((((pi*TDS%N_ref)/30.d0)/TDS%Conv_Ratio)-TDS%TDS_wOld)/TDS%time_step))+(TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] - TDS%Torque = min(TDS%Torque,TDS%MaxTorque) ! [ft.lbf] - TDS%TorqueGaugeOutput = TDS%Torque - TDS%OldPowerMode = -1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM] + data%State%TDS%Speed = min(data%State%TDS%Speed,data%State%TDS%MaxRPM) + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = INT(data%State%TDS%Speed) + data%State%TDS%Torque = ( ((data%State%TDS%J_coef+data%State%TDS%String_JCoef)*(((((pi*data%State%TDS%N_ref)/30.d0)/data%State%TDS%Conv_Ratio)-data%State%TDS%TDS_wOld)/data%State%TDS%time_step))+(data%State%TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] + data%State%TDS%Torque = min(data%State%TDS%Torque,data%State%TDS%MaxTorque) ! [ft.lbf] + data%State%TDS%TorqueGaugeOutput = data%State%TDS%Torque + data%State%TDS%OldPowerMode = -1 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then - TDS%OperationFaultLed = 0 - TDS%Speed = 0.0d0 - TDS%RpmGaugeOutput = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM] - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = INT(TDS%N_ref/TDS%Conv_Ratio) - TDS%Torque = 0.0d0 - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.0d0 + data%State%TDS%RpmGaugeOutput = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM] + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = INT(data%State%TDS%N_ref/data%State%TDS%Conv_Ratio) + data%State%TDS%Torque = 0.0d0 + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then - if ( TDS%RpmKnob>0. ) then - TDS%OperationFaultLed = 1 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + if ( data%State%TDS%RpmKnob>0. ) then + data%State%TDS%OperationFaultLed = 1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 else - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 end if end if else - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 end if - else if ( TDS%PowerState==1 .or. TDS%OldPowerMode==1 ) then !REV + else if ( data%State%TDS%PowerState==1 .or. data%State%TDS%OldPowerMode==1 ) then !REV - if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = 30.d0 - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 30 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 - TDS%OldPowerMode = 1 - else if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = 30.d0 - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 1000.d0 - TDS%OldPowerMode = 1 - else if ( TDS%DrillTorqueState==1 ) then ! TdsMu_Torque - if ( TDS%RpmKnob>0.d0 ) then - TDS%OperationFaultLed = 1 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = 1 + if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = 30.d0 + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 30 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 + data%State%TDS%OldPowerMode = 1 + else if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = 30.d0 + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 1000.d0 + data%State%TDS%OldPowerMode = 1 + else if ( data%State%TDS%DrillTorqueState==1 ) then ! TdsMu_Torque + if ( data%State%TDS%RpmKnob>0.d0 ) then + data%State%TDS%OperationFaultLed = 1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = 1 else - TDS%OperationFaultLed = 0 + data%State%TDS%OperationFaultLed = 0 if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 2000.d0 - TDS%OldPowerMode = 1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 2000.d0 + data%State%TDS%OldPowerMode = 1 else if ( Get_TdsConnectionModes()==Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = 1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = 1 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf] - TDS%OldPowerMode = -1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = -1 end if end if - else if ( TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL + else if ( data%State%TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then - TDS%OperationFaultLed = 0 - TDS%Speed = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM] - TDS%Speed = min(TDS%Speed,TDS%MaxRPM) - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = INT(TDS%Speed) - TDS%Torque = ( ((TDS%J_coef+TDS%String_JCoef)*(((((pi*TDS%N_ref)/30.d0)/TDS%Conv_Ratio)-TDS%TDS_wOld)/TDS%time_step))+(TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] - TDS%Torque = min(TDS%Torque,TDS%MaxTorque) ! [ft.lbf] - TDS%TorqueGaugeOutput = TDS%Torque - TDS%OldPowerMode = 1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM] + data%State%TDS%Speed = min(data%State%TDS%Speed,data%State%TDS%MaxRPM) + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = INT(data%State%TDS%Speed) + data%State%TDS%Torque = ( ((data%State%TDS%J_coef+data%State%TDS%String_JCoef)*(((((pi*data%State%TDS%N_ref)/30.d0)/data%State%TDS%Conv_Ratio)-data%State%TDS%TDS_wOld)/data%State%TDS%time_step))+(data%State%TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf] + data%State%TDS%Torque = min(data%State%TDS%Torque,data%State%TDS%MaxTorque) ! [ft.lbf] + data%State%TDS%TorqueGaugeOutput = data%State%TDS%Torque + data%State%TDS%OldPowerMode = 1 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then - TDS%OperationFaultLed = 0 - TDS%Speed = 0.0d0 - TDS%RpmGaugeOutput = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM] - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = INT(TDS%N_ref/TDS%Conv_Ratio) - TDS%Torque = 0.0d0 - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = 1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.0d0 + data%State%TDS%RpmGaugeOutput = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM] + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = INT(data%State%TDS%N_ref/data%State%TDS%Conv_Ratio) + data%State%TDS%Torque = 0.0d0 + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = 1 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then - if ( TDS%RpmKnob>0. ) then - TDS%OperationFaultLed = 1 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = 1 + if ( data%State%TDS%RpmKnob>0. ) then + data%State%TDS%OperationFaultLed = 1 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = 1 else - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = 1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = 1 end if end if else - TDS%OperationFaultLed = 0 - TDS%Speed = 0.d0 !Speed [RPM] - TDS%RpmGaugeOutput = TDS%Speed - TDS%RPMUnityOutput = -TDS%RpmGaugeOutput - TDS%SoundRPM = 0 - TDS%Torque = 0.d0 ![ft.lbf] - TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] - TDS%OldPowerMode = 1 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%Speed = 0.d0 !Speed [RPM] + data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed + data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput + data%State%TDS%SoundRPM = 0 + data%State%TDS%Torque = 0.d0 ![ft.lbf] + data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf] + data%State%TDS%OldPowerMode = 1 end if end if diff --git a/Equipments/TopDrive/TopDrive_StartUp.f90 b/Equipments/TopDrive/TopDrive_StartUp.f90 index 0809728..f0dd614 100644 --- a/Equipments/TopDrive/TopDrive_StartUp.f90 +++ b/Equipments/TopDrive/TopDrive_StartUp.f90 @@ -1,28 +1,28 @@ subroutine TopDrive_StartUp - Use TopDrive_VARIABLES + use ConfigurationVariables IMPLICIT NONE - TDS%MaxRPM = 200.d0 ![RPM] !??????? motaghayere voroudi - TDS%MaxTorque = 1500.d0 ![ft.lbf] !??????? motaghayere voroudi - TDS%time_step = 0.10d0 ![s] + data%State%TDS%MaxRPM = 200.d0 ![RPM] !??????? motaghayere voroudi + data%State%TDS%MaxTorque = 1500.d0 ![ft.lbf] !??????? motaghayere voroudi + data%State%TDS%time_step = 0.10d0 ![s] - TDS%Inertia_Moment = 23.261341d0 ! 23.261341 [kg.m^2] = 552 [lb.ft^2] - TDS%J_coef = TDS%Inertia_Moment+(1.d0*(TDS%Inertia_Moment)) ! [kg.m^2]??????????? - TDS%String_JCoef = 0.d0 - !TDS%Mech_Efficiency = 0.930d0 - TDS%Torque = 0.d0 - TDS%Speed = 0.d0 - TDS%OperationFaultLed = 0 - TDS%OldPowerMode = 0 - TDS%MotorFaileMalf = 0 + data%State%TDS%Inertia_Moment = 23.261341d0 ! 23.261341 [kg.m^2] = 552 [lb.ft^2] + data%State%TDS%J_coef = data%State%TDS%Inertia_Moment+(1.d0*(data%State%TDS%Inertia_Moment)) ! [kg.m^2]??????????? + data%State%TDS%String_JCoef = 0.d0 + !data%State%TDS%Mech_Efficiency = 0.930d0 + data%State%TDS%Torque = 0.d0 + data%State%TDS%Speed = 0.d0 + data%State%TDS%OperationFaultLed = 0 + data%State%TDS%OldPowerMode = 0 + data%State%TDS%MotorFaileMalf = 0 - TDS%High_Conv_Ratio = 4.825d0 - TDS%Low_Conv_Ratio = 7.310d0 - TDS%Conv_Ratio = TDS%High_Conv_Ratio + data%State%TDS%High_Conv_Ratio = 4.825d0 + data%State%TDS%Low_Conv_Ratio = 7.310d0 + data%State%TDS%Conv_Ratio = data%State%TDS%High_Conv_Ratio Call TopDrive_OffMode diff --git a/Equipments/TopDrive/TopDrive_VARIABLES.f90 b/Equipments/TopDrive/TopDrive_VARIABLES.f90 index b69bfce..6539c58 100644 --- a/Equipments/TopDrive/TopDrive_VARIABLES.f90 +++ b/Equipments/TopDrive/TopDrive_VARIABLES.f90 @@ -4,7 +4,7 @@ MODULE TopDrive_VARIABLES PUBLIC - REAL, PARAMETER :: pi=3.14159265d0 + ! REAL, PARAMETER :: pi=3.14159265d0 !**************************************************************************************************** @@ -32,7 +32,6 @@ MODULE TopDrive_VARIABLES END TYPE TDS_Var - TYPE(TDS_Var) :: TDS !*********************************************************************************************** !**************************************************************************************************** diff --git a/Equipments/equipments_PowerLimit.f90 b/Equipments/equipments_PowerLimit.f90 deleted file mode 100644 index a92bb9a..0000000 --- a/Equipments/equipments_PowerLimit.f90 +++ /dev/null @@ -1,60 +0,0 @@ -MODULE equipments_PowerLimit - - - IMPLICIT NONE - PUBLIC - - real(8) :: Power_sigma, max_Power_sigma - real(8) :: num_of_active_Jenerators, Jenerator_power - real(8) :: power_num_of_Jenerators, drilling_num_of_Jenerators - real(8), dimension(4) :: drilling_console_Jenerators - - !contains - -!------------------------------------------------------------ - ! subroutine PowerLimits - ! !subroutine PowerLimits(Power_sigma) - ! - ! USE Pumps_VARIABLES - ! USE Drawworks_VARIABLES - ! USE RTable_VARIABLES - ! USE CPowerVariables - ! USE CDrillingConsoleVariables - ! !use equipments_PowerLimit - !! - !IMPLICIT NONE - ! !integer :: ii - ! - ! - ! Power_sigma=2.*(PUMP(1)%Vt*PUMP(1)%ia_new)+2.*(PUMP(2)%Vt*PUMP(2)%ia_new)+2.*(PUMP(3)%Vt*PUMP(3)%ia_new)+(RTable%Vt*RTable%ia_new)+2.*(Drawworks%Vt*Drawworks%ia_new) - ! !write(*,*) 'Power_sigma=', Power_sigma - ! - ! - ! power_num_of_Jenerators=sngl(NumberOfgenerators) - ! Jenerator_power=GeneratorPowerRating - ! drilling_console_Jenerators(1)=GEN1BTNLED - ! drilling_console_Jenerators(2)=GEN2BTNLED - ! drilling_console_Jenerators(3)=GEN3BTNLED - ! drilling_console_Jenerators(4)=GEN4BTNLED - ! - ! drilling_num_of_Jenerators=0. - ! !do ii=1,4 - ! ! if (drilling_console_Jenerators(ii)=1) then - ! ! drilling_num_of_Jenerators=drilling_num_of_Jenerators+1. - ! ! end if - ! !end do - ! drilling_num_of_Jenerators=sngl(sum(drilling_console_Jenerators)) - ! - ! if (power_num_of_Jenerators>drilling_num_of_Jenerators) then - ! num_of_active_Jenerators=drilling_num_of_Jenerators - ! else if (power_num_of_Jenerators<=drilling_num_of_Jenerators) then - ! num_of_active_Jenerators=power_num_of_Jenerators - ! end if - ! - ! max_Power_sigma=num_of_active_Jenerators*Jenerator_power - ! - ! - ! end subroutine PowerLimits -!------------------------------------------------------------ - -End MODULE equipments_PowerLimit \ No newline at end of file diff --git a/FluidFlow-old/Annulus_Property_Calculator.f90 b/FluidFlow-old/Annulus_Property_Calculator.f90 deleted file mode 100644 index 3ddb313..0000000 --- a/FluidFlow-old/Annulus_Property_Calculator.f90 +++ /dev/null @@ -1,45 +0,0 @@ -SUBROUTINE AnnulusPropertyCalculator (md, den, pre, tem) - - !!! This subroutine gets location of a guage or an observation point and determines information of that point such as pressure, density, velocity and temperature later. - use PressureDisplayVARIABLESModule - USE Fluid_Flow_Startup_Vars - USE MudSystemVARIABLES - USE FricPressDropVarsModule - USE CDrillWatchVariables - - IMPLICIT NONE - INTEGER, intent(in) :: md ! input - REAL(8) :: TVD - real(8), intent(inout) :: den ! output - real(8), intent(inout) :: pre ! output - real(8), intent(inout) :: tem ! output - - - INTEGER :: ilocal - - CALL TVD_Calculator(md * 1.d0 , TVD) - - IF (md <= INT(FinalFlowEl(AnnulusFirstEl)%StartX)) THEN !! mouse pointer is in the annulus space - DO ilocal = AnnulusFirstEl , AnnulusLastEl - IF (INT(FinalFlowEl(ilocal)%EndX) <= md) EXIT - END DO - - ELSE IF (md > INT(FinalFlowEl(NumbEl)%EndX)) THEN ! mouse pointer is in the open hole space - DO ilocal = OpenholeFirstEl , NumbEl - IF (INT(FinalFlowEl(ilocal)%EndX) <= md) EXIT - END DO - - ELSE - WRITE (*,*) ' Error in calculating annulus observation point ' - END IF - pre = FinalFlowEl(ilocal)%StartPress - (FinalFlowEl(ilocal)%StartX - md) * FinalFlowEl(ilocal)%dPdLfric & - - (FinalFlowEl(ilocal)%StartTVD - TVD) * FinalFlowEl(ilocal)%dPdLGrav - !write(*,*) ' md, ilocal', md, ilocal - !WRITE (*,*) ' FlowEl dPdLfric , dPdLGrav', FlowEl(ilocal)%dPdLfric , FlowEl(ilocal)%dPdLGrav - - den = FinalFlowEl(ilocal)%Density - - !tem = 500 - - - END SUBROUTINE \ No newline at end of file diff --git a/FluidFlow-old/Annulus_and_Openhole_Pressure_Distribution.f90 b/FluidFlow-old/Annulus_and_Openhole_Pressure_Distribution.f90 deleted file mode 100644 index 56478cb..0000000 --- a/FluidFlow-old/Annulus_and_Openhole_Pressure_Distribution.f90 +++ /dev/null @@ -1,337 +0,0 @@ -SUBROUTINE PressureAnnAndOHDistribution - - !! Record of revisions - !! Date Programmer Discription of change - !! ------ ------------ ----------------------- - !! 1396/07/30 Sheikh Original code - !! - - USE FricPressDropVarsModule - USE MudSystemVARIABLES - use PressureDisplayVARIABLESModule - USE GeoElements_FluidModule - USE Fluid_Flow_Startup_Vars - use KickVARIABLESModule - USE CMudPropertiesVariables - USE TD_WellGeometry - USE CReservoirVariables - use MudSystemModule - USE CHOKEVARIABLES - USE CChokeManifoldVariables - USE VARIABLES - USE CError - USE , INTRINSIC :: IEEE_ARITHMETIC - - - IMPLICIT NONE - - INTEGER :: i , j , k , l - INTEGER :: ifric - REAL :: Fraction - - - KBOP = 0.0 - - - -IF (WellHeadOpen .OR. NoGasPocket == 0) THEN !! (mud circulation is normal wellhead may be open or closed) OR (kick is in the well and well head is open) - - - !!!!! Determining flow rate in each section - i = AnnulusFirstEl - j = OpenholeFirstEl - 1 - - !!!!!!!!!!!!!!!!!!!!!!!!! flowrates due to external sources like pump and tripping - !WRITE (*,*) 'MudSystem%StringFlowRate', MudSystem%StringFlowRate - FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = (ClingingFactor * FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%Area + FlowEl(StringFirstEl)%Area) * DrillStringSpeed * ConvMintoSec * Convft3toUSgal ! flowrate in annulus due to tripping - - FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate + REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump - !WRITE (*,*) 'Drillstring speed (ft/s)' , FlowEl(j)%FlowRate - - !IF (NoWellToChokeEl > 0) THEN ! flowrate in choke line - ! FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + 1 : NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%FlowRate = MudSystem%AnnulusFlowRate + (DeltaVolumePipe * ConvMinToSec / dt) - !END IF - - IF (MudSystem%ShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation - - !WRITE (*,*) ' SHoe fractured', PressureGauges(5), FlowEl(ShoeFlowElNo)%FlowRate - IF (ShoeFlowElNo > AnnulusLastEl) THEN ! shoe is in openhole - FlowEl(ShoeFlowElNo : NumbEl)%FlowRate = - MudSystem%Qlost - FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost - ELSE ! shoe is in annulus - FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost - END IF - END IF - - - !!!!!!!!!!!!!!!!!!!!!!!!! - !!!!!!!!!!!!!!!!!!!!!!!!! initial guess flowrates for opening BOP or choke line - IF (WellHeadWasOpen == .FALSE. .AND. NoGasPocket > 0 .AND. KickIteration == 1) THEN - IF (ChokeKroneckerDelta == 1) THEN ! flow on choke line - IF (TotalOpenChokeArea < 0.01 * Choke%ChokeAreaFullyOpen) THEN - WRITE (*,*) 'density , TotalOpenChokeArea' , DownHole%Density, TotalOpenChokeArea - TotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen - END IF - Kchoke = (ChokeDensity / ((2.0 * 89158.0) * (0.26 * 0.61 * TotalOpenChokeArea)**2)) * 4.0 ! *4.d0: seyyed gofte - GasPocketFlowInduced%Array(:) = MIN((0.6 / NoGasPocket * SQRT(PressureGauges(2) / Kchoke)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) - WRITE (*,*) ' PressureGauges(2) , Kchoke' , PressureGauges(2) , Kchoke - WRITE (*,*) 'Initial guess after opening choke =', GasPocketFlowInduced%Array(1) - - WRITE (*,*) ' valve 49 ', Manifold%Valve(49)%Status - WRITE (*,*) ' valve 47 ', Manifold%Valve(47)%Status - WRITE (*,*) ' valve 26 ', Manifold%Valve(26)%Status - WRITE (*,*) ' valve 30 ', Manifold%Valve(30)%Status - WRITE (*,*) ' valve 34 ', Manifold%Valve(34)%Status - WRITE (*,*) ' valve 63 ', Manifold%Valve(63)%Status - WRITE (*,*) ' valve 28 ', Manifold%Valve(28)%Status - WRITE (*,*) ' valve 33 ', Manifold%Valve(33)%Status - WRITE (*,*) ' valve 62 ', Manifold%Valve(62)%Status - WRITE (*,*) ' valve 36 ', Manifold%Valve(36)%Status - WRITE (*,*) ' valve 38 ', Manifold%Valve(38)%Status - - ELSE ! flow through bell nipple - k = NoHorizontalEl + NoStringEl + NoAnnulusEl - KBOP = FlowEl(AnnulusLastEl)%Density / ((2.0 * 89158.0) * (0.26 * 0.61 * ShearRam%MinimumOpenArea_InBOP)**2) - GasPocketFlowInduced%Array(:) = MIN((0.1 / NoGasPocket * SQRT(PressureGauges(6) / KBOP)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) - WRITE (*,*) 'PressureGauges(6), KBOP', PressureGauges(6), KBOP - WRITE (*,*) 'Initial guess after opening BOP =', GasPocketFlowInduced%Array(1) - END IF - END IF - !!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!! flowrates due to expansion of gas pockets or kick influx - !i = AnnulusFirstEl - !j = OpenholeFirstEl - 1 - IF (NoGasPocket > 0) THEN - DO l = 1 , NoGasPocket !GasPocketFlowEl - k = GasPocketFlowEl(l , 1) - !WRITE (*,*) 'GasPocketFlowEl(l , 1)', l, k, j - IF (k == 0) CALL ERRORSTOP('GasPocketFlowEl(l , 1) == 0', l) - - IF (k >= OpenholeFirstEl) THEN ! gas pocket is in open hole only - FlowEl(k : NumbEl)%FlowRate = FlowEl(k : NumbEl)%FlowRate + GasPocketFlowInduced%Array(l) ! openhole elements above pocket - FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate = FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus and choke line elements - ELSE IF (k < OpenholeFirstEl) THEN ! gas pocket is in annulus ond/or choke line only - FlowEl(k : OpenholeFirstEl - 1)%FlowRate = FlowEl(k : OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus or choke line elements above pocket - END IF - END DO - END IF - !IF (ChokeKroneckerDelta == 1 .AND. ABS(FlowEl(i + NoAnnulusEl)%FlowRate / 600.0 - Ann_Saved_MudDischarged_Volume_Final) > 0.05) THEN - ! WRITE (*,*) 'Difference between flowrates', FlowEl(i + NoAnnulusEl + 1)%FlowRate / 600.0, Ann_Saved_MudDischarged_Volume_Final - !END IF - - !!!!!!!!!!!!!!!!!!!!!!!!! - !!!!! END - Determining flow rate in each section - - !!!!!!!!!!!!!!!!!!!!!!!!! effect of surge and swab on frictional pressure drop direction - DO l = AnnulusFirstEl , OpenholeFirstEl - 1 - IF (FlowEl(l)%FlowRate < 0.0) THEN - FlowEl(l)%FrictionDirection = -1 - IF (FlowEl(l)%FlowRate > -1.0 * PressFlowrateTolerance .AND. ALLOCATED(GasPocketWeight%Array)) FlowEl(l)%FlowRate = - PressFlowrateTolerance - ELSE - FlowEl(l)%FrictionDirection = 1 - IF (FlowEl(l)%FlowRate < PressFlowrateTolerance .AND. ALLOCATED(GasPocketWeight%Array)) FlowEl(l)%FlowRate = PressFlowrateTolerance - END IF - END DO - !!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!! Calculating Back Pressure, in well to pit path back pressure = 0 - ! in well to choke manifold path back pressure is equal to pressure before choke not casing pressure - IF (ChokeKroneckerDelta == 1) THEN - - IF (FlowEl(OpenholeFirstEl - 1)%FlowRate < 0.0) THEN - WRITE (*,*) ' Negative choke flowrate' - FlowEl(OpenholeFirstEl - 1)%FlowRate = MAX((REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0) - END IF - !Kchoke = ChokeDensity / ((2. * 89158.0) * (0.26 * 0.61 * TotalOpenChokeArea)**2) - MudSystem%deltaPchoke = (Kchoke * FlowEl(OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(OpenholeFirstEl - 1)%FlowRate)) * 1.d0 - !WRITE (*,*) '**deltaPchoke , Kchoke, choke flowrate' , deltaPchoke , Kchoke, FlowEl(i)%FlowRate - !WRITE (*,*) '**TotalOpenChokeArea , Total Open Choke Area Percent' , TotalOpenChokeArea , TotalOpenChokeArea / 4.0 * ChokeAreaFullyOpen - IF (MudSystem%deltaPchoke < 0.d0) MudSystem%deltaPchoke = 0.d0 - BackPressure = REAL(MudSystem%deltaPchoke) - !WRITE (*,*) ' Choke inlet FlowRate, Density, pressure' , FlowEl(j)%FlowRate, FlowEl(j)%Density, FlowEl(j)%StartPress - !WRITE (*,*) ' Choke outlet Density' , FlowEl(i)%Density - !WRITE (*,*) ' deltaPchoke , choke flowrate' , deltaPchoke , FlowEl(i)%FlowRate - !WRITE (*,*) 'Total Open Choke Area Percent' , TotalOpenChokeArea / 4.0 * ChokeAreaFullyOpen - ELSE - BackPressure = 0.0 - END IF - IF (IEEE_IS_NaN(BackPressure)) CALL ErrorStop('NaN in calculating back pressure' , FlowEl(j)%FlowRate) - !write(*,*) 'BackPressure=' , BackPressure - - !!!!!!!!!!!!!!!!!!!!!!!!! when flow passes through choke manifold, solution process may be unstable - IF (ChokeKroneckerDelta == 1) THEN ! thus we should stabilize solution - IF (TotalOpenChokeArea > 0.5 * Choke%ChokeAreaFullyOpen) THEN - KickCorrectionUnderRelaxation = 0.6 - ELSE IF (TotalOpenChokeArea > 0.1 * Choke%ChokeAreaFullyOpen) THEN - KickCorrectionUnderRelaxation = 0.5 - ELSE ! TotalOpenChokeArea < 0.1 * ChokeAreaFullyOpen - KickCorrectionUnderRelaxation = 0.4 - END IF - ELSE - KickCorrectionUnderRelaxation = 0.6 - END IF - !!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!! calculating frictional pressure drop in annulus, chooke line and open hole elements - DO ifric = AnnulusFirstEl , NumbEl - CALL FricPressDrop(ifric) - !WRITE (*,*) ' element No, FlowRate , Density, FricPressLoss', ifric, FlowEl(ifric)%FlowRate, FlowEl(ifric)%Density, FlowEl(ifric)%FricPressLoss - IF (IEEE_IS_NaN(FlowEl(ifric)%FricPressLoss)) THEN - WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl - WRITE (*,*) 'Ann/Op start, end, density, Q, mu, Type' , FlowEl(ifric)%StartX, FlowEl(ifric)%EndX, FlowEl(ifric)%Density, FlowEl(ifric)%FlowRate, FlowEl(ifric)%mueff, FlowEl(ifric)%MaterialType - CALL ErrorStop('NaN in calculating pressure drop' , ifric) - END IF - - END DO - !IF (ChokeKroneckerDelta == 1) THEN - !WRITE (*,*) ' velocity and flowrate', FlowEl(i)%vel, FlowEl(i)%flowrate - !WRITE (*,*) ' Theta600, Theta300', FlowEl(i)%Theta600 , FlowEl(i)%Theta300 - !WRITE (*,*) ' kIndex , nIndex', FlowEl(i)%kIndex, FlowEl(i)%nIndex - !WRITE (*,*) ' last el. mueff, gen. Rey.', i, FlowEl(i)%mueff, FlowEl(i)%GenRe - !END IF - - !!!!!!!!!!!!!!!!!!!!!!!!! Pressure distribution in annulus - j = OpenholeFirstEl - 1 - FlowEl(OpenholeFirstEl - 1)%EndPress = BackPressure - FlowEl(OpenholeFirstEl - 1)%StartPress = FlowEl(OpenholeFirstEl - 1)%EndPress + FlowEl(OpenholeFirstEl - 1)%FricPressLoss + FlowEl(OpenholeFirstEl - 1)%StaticPressDiff - - !write(*,*) 'FlowEl(j)%StartPress=' ,j, FlowEl(j)%StartPress - !write(*,*) 'FlowEl(j)%Length=' ,j, FlowEl(j)%Length, FlowEl(j)%EndX - !write(*,*) 'FlowEl(i)%dPdLFric=' ,i, FlowEl(i)%dPdLFric - - DO l = OpenholeFirstEl - 2 , AnnulusFirstEl , -1 - !WRITE (*,*) '123' - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%FricPressLoss + FlowEl(l)%StaticPressDiff - !WRITE(*,*) "ANNULUS: bottom , top Pressure", l , FlowEl(l)%StartPress , FlowEl(l)%EndPress , FlowEl(l)%fricPressLoss - !WRITE(*,*) "ANNULUS: Start , End X", FlowEl(l)%StartX , FlowEl(l)%EndX - - - !write(*,*) 'FlowEl(i)%StartPress=' ,i, FlowEl(i)%StartPress - !WRITE (*,*) ' FlowEl(i)%GenRe, FlowEl(i)%ReCritLam ' , FlowEl(i)%GenRe , FlowEl(i)%ReCritLam - END DO - - - !!!!!!!!!!!!!!!!! Pressure distribution in Open Hole - FlowEl(NumbEl)%EndPress = FlowEl(AnnulusFirstEl)%StartPress - FlowEl(NumbEl)%StartPress = FlowEl(NumbEl)%EndPress + FlowEl(NumbEl)%FricPressLoss + FlowEl(NumbEl)%StaticPressDiff - !WRITE (*,*) 'op top and op down' , FlowEl(NumbEl)%EndPress, FlowEl(j + 1)%StartPress - !write(*,*) 'FlowEl(NumbEl)%dPdLFric=' , FlowEl(NumbEl)%dPdLFric - !write(*,*) 'FlowEl(NumbEl)%dPdLGrav=' , FlowEl(NumbEl)%dPdLGrav - - DO l = NumbEl - 1 , OpenholeFirstEl , -1 - !WRITE(*,*) ' ope' - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - !IF (FlowEl(i)%FlowRate < 0.0d0) THEN - ! FlowEl(i)%StartPress = FlowEl(i)%EndPress - FlowEl(i)%FricPressLoss + FlowEl(i)%StaticPressDiff - !ELSE - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%FricPressLoss + FlowEl(l)%StaticPressDiff - !WRITE (*,*) ' Length, static, frictional open' , FlowEl(i)%Length, FlowEl(i)%StaticPressDiff, FlowEl(i)%FricPressLoss - - !END IF - END DO - -ELSE ! wellhead is closed and kick is in the well - !WRITE (*,*) ' well head is closed' - k = GasPocketFlowEl(NoGasPocket , 1) - !WRITE (*,*) 'k, Pocket Press', k, GasPocketOldPress%Array(NoGasPocket) - StandardPress - i = AnnulusFirstEl - j = OpenholeFirstEl - 1 - FlowEl(k)%StartPress = GasPocketOldPress%Array(NoGasPocket) - StandardPress - FlowEl(k)%EndPress = GasPocketOldPress%Array(NoGasPocket) - StandardPress - IF (k > OpenholeFirstEl - 1) THEN ! Top pocket StartX is in Open hole - !WRITE (*,*) 'here 1' - DO l = k - 1 , OpenholeFirstEl , -1 ! below elements in openhole - !WRITE (*,*) 'here 1-1' - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff - END DO - - DO l = k + 1 , NumbEl ! Above elements in openhole - !WRITE (*,*) 'here 1-2' - FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress - FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff - END DO - - FlowEl(AnnulusFirstEl)%StartPress = FlowEl(NumbEl)%EndPress - FlowEl(AnnulusFirstEl)%EndPress = FlowEl(AnnulusFirstEl)%StartPress - FlowEl(AnnulusFirstEl)%StaticPressDiff - - DO l = AnnulusFirstEl + 1 , OpenholeFirstEl - 1 - FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress - FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff - END DO - - ELSE ! Top pocket StartX is in annulus or choke line - - DO l = k - 1 , AnnulusFirstEl , -1 ! below elements in annnulus - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff - END DO - - DO l = k + 1 , OpenholeFirstEl - 1 ! Above elements in annulus - FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress - FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff - END DO - - FlowEl(NumbEl)%EndPress = FlowEl(AnnulusFirstEl)%StartPress - FlowEl(NumbEl)%StartPress = FlowEl(NumbEl)%EndPress + FlowEl(NumbEl)%StaticPressDiff - - DO l = NumbEl - 1 , OpenholeFirstEl , -1 - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff - END DO - - END IF - - ! - ! !WRITE (*,*) ' first annulus bottom pressure ' , FlowEl(NoHorizontalEl + NoStringEl + 1)%StartPress - ! !WRITE (*,*) ' last OpenHole bottom pressure' , FlowEl(NumbEl)%StartPress - ! !WRITE (*,*) ' Gas Pocket pressure' , GasPocket%NewPress -END IF - - !!!!!!!!!!!!!!!!!!!!!! checking pressure for preventing NaN in pressures - DO l = OpenholeFirstEl - 1 , AnnulusFirstEl , -1 ! annulus or choke elements - !WRITE (*,*) 'start, end' , FlowEl(i)%StartX, FlowEl(i)%EndX - IF (IEEE_IS_NaN(FlowEl(l)%EndPress)) THEN - WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl - WRITE (*,*) 'Ann/Ch start, end, density, Q, mu' , FlowEl(l)%StartX, FlowEl(l)%EndX, FlowEl(l)%Density, FlowEl(l)%FlowRate, FlowEl(l)%mueff, FlowEl(l)%MaterialType - CALL ERRORSTOP('NaN in EndPress', l) - END IF - END DO - - DO l = NumbEl , OpenholeFirstEl - 1 , -1 ! op elements - !WRITE (*,*) 'start, end' , FlowEl(i)%StartX, FlowEl(i)%EndX - IF (IEEE_IS_NaN(FlowEl(l)%EndPress)) THEN - WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl - WRITE (*,*) 'Op start, end, density, Q, mu' , FlowEl(l)%StartX, FlowEl(l)%EndX, FlowEl(l)%Density, FlowEl(l)%FlowRate, FlowEl(l)%mueff, FlowEl(l)%MaterialType - CALL ERRORSTOP('NaN in EndPress', l) - END IF - END DO - !!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!! - BottomHolePress = FlowEl(OpenholeFirstEl)%StartPress - !DO i = 1 , NoGasPocket - ! WRITE (*,*) ' Pocket, Pressure, Vol, Flow Induced, FlowElPress', i, REAL(GasPocketNewPress%Array(i)), REAL(GasPocketNewVol%Array(i)), GasPocketFlowInduced%Array(i), FlowEl(GasPocketFlowEl(i , 1))%StartPress - !END DO - !WRITE (*,*) ' BottomHolePress =' , BottomHolePress - !!!!!!!!!!!!!!!!!!!!!! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !IF (ChokeKroneckerDelta == 1) THEN - ! WRITE (*,*) ' ChokeLine flowrate' , FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%FlowRate , MudSystem%StringFlowRate - ! !i = NoHorizontalEl + NoStringEl + NoAnnulusEl - ! !j = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl - ! !WRITE (*,*) ' Well Outlet and Chokeline Outlet Pressure' , FlowEl(i)%EndPress, FlowEl(j)%EndPress - !END IF - - !IF (GasPocket%ElementNo == 0) THEN - ! KickUnknownVector(2) = BottomHolePress - !!ELSE - !! KickUnknownVector(2) = FlowEl(GasPocket%ElementNo)%StartPress - !END IF - !IF (WellHeadOpen) - ! GasPocket%NewPress = KickUnknownVector(2) - !END IF - !WRITE (*,*) 'Ann End' -END SUBROUTINE \ No newline at end of file diff --git a/FluidFlow-old/Flow_Startup.f90 b/FluidFlow-old/Flow_Startup.f90 deleted file mode 100644 index f7704a7..0000000 --- a/FluidFlow-old/Flow_Startup.f90 +++ /dev/null @@ -1,118 +0,0 @@ -SUBROUTINE FlowStartup - Use ConfigurationVariables - USE Fluid_Flow_Startup_Vars - USE CStringConfigurationVariables - USE CMudPropertiesVariables - USE FricPressDropVarsModule - use KickVARIABLESModule - USE MudSystemVARIABLES - use PressureDisplayVARIABLESModule - USE CShoeVariables - USE TD_DrillStemComponents - USE TD_WellGeometry, pi3 => pi - USE CPathGenerationVariables - USE CWellSurveyDataVariables - Use CHOKEVARIABLES, pi4 => pi - - - IMPLICIT NONE - - INTEGER :: i - - PressureGauges(:) = 0.0 - - KickSinglePocket = Reservoir%MakeKickSinglePacket - IF (KickSinglePocket) THEN - MaxGasPocket = 1 - ELSE - MaxGasPocket = 4 - END IF - MaxChokeDensityChange = 25.0 ! [ppg/min] - ChokeMinDensity = 2.0 - - ChokeDensity = MudProperties%ActiveDensity - - MinKickVol = 0.5 ! USGal - - SecondaryKickVol = 0.0 - SecondaryKickWeight = 0.0 - - NoGasPocket = 0 ! No Kick - WellHeadOpen = .TRUE. - WellHeadWasOpen = .TRUE. - BackPressure = 0.0 - GasKickPumpFlowRate = 0.0 - DownHole%KickVolume = 0.0 - DownHole%InfluxRate = 0.0 - ExitMass = 0.0 - MinAllowableKickVol = 1.0 * (42.0 / Convft3toUSgal) ! 1 bbl * 42 gal/bbl / 7.48 gal/ft^3 = ... ft^3 - StCompressedMudVol = 0.0 - AnnCompressedMudVol = 0.0 - KickFlux = .FALSE. - KickOffBottom = .FALSE. - KickWasExitingThroughChoke = .FALSE. - FloatValveOpen = .TRUE. - - Choke%ChokeAreaFullyOpen = 123.0 / 64.0 ! fully open area is 123/64 in^2 = 0.01334635 ft^2 - ChokeBypassArea = PI / 4.0 * BopStackSpecification%ChokeLineId**2 - BHPSafetyMargin = 150.0 - AChBHPTol = 15.0 - - - ManChoke1Plug = 0 - ManChoke2Plug = 0 - ManChoke1Washout = 0 - ManChoke2Washout = 0 - BitJetsPlugged = 0 - BitJetsWashedOut = 0 - CasingPressure_DataDisplayMalF = 0 - - SoundSpeed = 1530.0 / Convfttom - PressureTimeStepDelay(1) = INT(2.0 * SUM(Configuration%StringConfiguration%StringConfigurations(2:)%ComponentLength) / SoundSpeed / dt) - PressureTimeStepDelay(2) = INT(PathGeneration%Items(SIZE(PathGeneration%Items))%MeasuredDepth / SoundSpeed / dt) - PressureTimeStepDelay(3) = INT(Shoe%ShoeDepth / SoundSpeed / dt) - - !WRITE (*,*) SUM(StringConfigurations(2:)%ComponentLength), PathGenerations(SIZE(PathGenerations))%TotalVerticalDepth!, WellSurveyData(SIZE(WellSurveyData))%TotalVerticalDepth - !WRITE (*,*) PathGenerations(SIZE(PathGenerations))%MeasuredDepth!, WellSurveyData(SIZE(WellSurveyData))%MeasuredDepth - WRITE (*,*) 'time step delay', PressureTimeStepDelay - - DO i = 1 , PressureTimeStepDelay(1) - CALL PumpPressureDelay%AddToFirst(0.0) - END DO - - DO i = 1 , PressureTimeStepDelay(2) - CALL BottomHolePressureDelay%AddToFirst(REAL(0.052 * MudProperties%ActiveDensity * PathGeneration%Items(SIZE(PathGeneration%Items))%TotalVerticalDepth)) - END DO - - DO i = 1 , PressureTimeStepDelay(3) - CALL ShoePressureDelay%AddToFirst(REAL(0.052 * MudProperties%ActiveDensity * Shoe%ShoeDepth)) - END DO - - - !!!!!!! Methane Information - GasType(1)%CritPress = 673.0 - GasType(1)%CritTemp = 344.0 - GasType(1)%MolarWt = 16.04 - GasType(1)%StDensity = 0.04238 - GasType(1)%GasConstant = RUniversal / GasType(1)%MolarWt - - !!!!!!!! H2S Information - GasType(2)%CritPress = 1306.0 - GasType(2)%CritTemp = 673.0 - GasType(2)%MolarWt = 34.08 - GasType(2)%StDensity = 0.09087 - GasType(2)%GasConstant = RUniversal / GasType(2)%MolarWt - - !!!!!!!! CO2 Information - GasType(3)%CritPress = 1072.0 - GasType(3)%CritTemp = 548.0 - GasType(3)%MolarWt = 44.01 - !GasType(3)%StDensity = 00 - GasType(3)%GasConstant = RUniversal / GasType(2)%MolarWt - - !!!!!!!! Mud density and viscosity - Theta600Refrence = MudProperties%ActiveThetaSixHundred - Theta300Refrence = MudProperties%ActiveThetaThreeHundred - DensityRefrence = MudProperties%ActiveDensity - - END SUBROUTINE \ No newline at end of file diff --git a/FluidFlow-old/Flow_Startup_VARIABLES.f90 b/FluidFlow-old/Flow_Startup_VARIABLES.f90 deleted file mode 100644 index f47a842..0000000 --- a/FluidFlow-old/Flow_Startup_VARIABLES.f90 +++ /dev/null @@ -1,64 +0,0 @@ -MODULE Fluid_Flow_Startup_Vars - - !!! In this module constants and conversion factors are stated - - - REAL , PARAMETER :: RUniversal = 10.73159 ! [psia.ft^3/(lbmole.R)] - REAL , PARAMETER :: RUniversalSI = 8.314 * 10**6 ! [Pa.cm^3/(mole.K)] - REAL , PARAMETER :: PI = 3.141593 ! Pi number - REAL , PARAMETER :: StandardPress = 14.7 ! [psia] - REAL , PARAMETER :: StandardTemp = 519.67 ! 60 F [R] , Temp F = Temp R + 459.67 - REAL , PARAMETER :: dt = 0.1 ! time step = 0.1 [s] - REAL , PARAMETER :: GasDensityRefrence = 28.96 ! molar weight of air [lbm/lbmole] - - !! Tolerance and convergence or error criteria - REAL , PARAMETER :: UTubePressTolerance = 4 ! minimum pressure tolerance between two arms of U tube for which calculations will stop [psi] - !REAL , PARAMETER :: PressDensityTolerance = 2 ! Pressure Density Tolerance: for flow elements with density below this amount (usually gas pockets), - ! frictional and gravitional pressure gradients are neglected [ppg] - REAL , PARAMETER :: PressLengthTolerance = 0.0 ! Pressure Length Tolerance: for flow elements with length below this amount, - ! frictional and gravitional pressure gradients are neglected [ft] - REAL , PARAMETER :: PressFlowrateTolerance = 0.2 ! Pressure Flowrate Tolerance: for flow elements with flowrates below this amount, - ! frictional pressure gradients are neglected [gpm] - REAL , PARAMETER :: KickConvergenceTolerance = 0.05 ! absolute value of maximum error in calculation of gas kick pressure and flowrate - - !!!!!!!!!!!!!!!!!! Conversion factors - REAL , PARAMETER :: Convlbftolbm = 32.174 ! 1 lbf = 32.174 lbm*ft/s^2 - REAL , PARAMETER :: Convft3toUSgal = 7.48052 ! 1 ft^3 = 7.48052 US gal - REAL , PARAMETER :: Convfttom = 0.3048 ! 1 ft = 0.3048 m - REAL , PARAMETER :: Convfttoinch = 12.0 ! 1 ft = 12 inch - REAL , PARAMETER :: Convdaytohour = 24.0 ! 1 day = 24 hour - REAL , PARAMETER :: Convhourtomin = 60.0 ! 1 hour = 60 min - REAL , PARAMETER :: Convmintosec = 60.0 ! 1 min = 60 sec - REAL , PARAMETER :: ConvpsitoPa = 6894.76 ! 1 psi = 6894.76 pa - REAL , PARAMETER :: ConvRtoK = 0.555556 ! 1 R = 0.555556 K - REAL , PARAMETER :: Convpcftogpcm3 = 0.0160185 ! 1 lbm/ft^3 = 0.0160185 gr/cm^3 - !!!!!!!!!!!!!!!!! - - !!!!!!! Bit data !!!!!! - ! Type :: BitDataType - LOGICAL :: BitTrue ! bit may be present (.TRUE.) or may be absent(.FALSE.) - REAL :: BitNozzleArea ! area of a nozzle - INTEGER :: BitNozzleNum ! Number of bit nozzles - REAL :: BitNozzDia ! nozzle diameter in 1/32 in - REAL :: BitTotNozzArea ! Total bit area - REAL :: BitCd ! Discharge coefficient - REAL :: BitPressLoss ! bit pressure loss [psi] - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - REAL :: Theta600Refrence , Theta300Refrence ! Fann data (Theta600 and Theta300) of active tank (input from panel) - REAL :: DensityRefrence ! Density of active tank mud (input from panel) [gpm] - ! End Type BitDataType - ! Type(BitDataType)::BitData - - TYPE, PUBLIC :: GasData - REAL :: CritPress ! critical pressure [psia] - REAL :: CritTemp ! critical temperature [R] - REAL :: MolarWt ! molar weight [lbm/lbmole] - REAL :: StDensity ! density at standard pressure (14.7 psi) and temperature (60 F = 520 Ra) [lbm/ft^3] - REAL :: GasConstant ! Gas constant = RUniversal/MolarWt [psia.ft^3/(R.lbm)] - END TYPE GasData - TYPE(GasData) :: GasType(3) ! 1 = methane , 2 = Hydrogen sulfide , 3 = Carbon dioxid - - - END MODULE - \ No newline at end of file diff --git a/FluidFlow-old/FluidFlowMain.f90 b/FluidFlow-old/FluidFlowMain.f90 deleted file mode 100644 index a91cc79..0000000 --- a/FluidFlow-old/FluidFlowMain.f90 +++ /dev/null @@ -1,147 +0,0 @@ -module FluidFlowMain - implicit none - public - contains -! - ! subroutine FluidFlow_Setup() - ! ! use CSimulationVariables - ! implicit none - ! !call OnSimulationInitialization%Add(FluidFlow_Init) - ! call OnSimulationStop%Add(FluidFlow_Stop) - ! call OnFluidFlowStart%Add(FluidFlow_Start) - ! call OnFluidFlowStep%Add(FluidFlow_Step) - ! !call OnFluidFlowOutput%Add(FluidFlow_Output) - ! 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_Init - USE Fluid_Flow_Startup_Vars - implicit none - !WRITE (*,*) ' fluid flow done_Start' - CALL NormalCirculation_StartUp() - CALL FlowStartup - - Call TD_StartUp - Call TD_WellReadData - Call TD_WellElementsReadData - Call TD_DrillStemReadData - Call TD_PipePropertiesReadData - end subroutine FluidFlow_Init - - subroutine FluidFlow_Step - implicit none - integer :: i, FlowDuration, SimulationStateOld - integer,dimension(8) :: FlowStartTime,FlowEndTime - - !WRITE (*,*) ' fluid flow done_Step' - !call Fluid_Flow_Solver - - - - - - - CALL DATE_AND_TIME(values=FlowStartTime) - call Fluid_Flow_Solver - - CALL DATE_AND_TIME(values=FlowEndTime) - - FlowDuration = 3600000 * (FlowEndTime(5) - FlowStartTime(5)) + 60000 * (FlowEndTime(6) - FlowStartTime(6)) + 1000 * (FlowEndTime(7) - FlowStartTime(7)) + (FlowEndTime(8) - FlowStartTime(8)) - - WRITE (*,*) 'FlowDuration (ms)=' , FlowDuration - - end subroutine FluidFlow_Step - - !subroutine FluidFlow_Output - ! implicit none - !end subroutine FluidFlow_Output - -! subroutine FluidFlowMainBody -! ! -! use ifport -! use ifmt -! ! use CSimulationVariables -! USE Fluid_Flow_Startup_Vars -! !use general_info, only : reset_data -! !use well_info -! !use drilling_info -! use CLog1 -! ! -! implicit none - - !integer :: i, FlowDuration, SimulationStateOld - !integer,dimension(8) :: FlowStartTime,FlowEndTime - ! - ! - !CALL NormalCirculation_StartUp() - !CALL FlowStartup - ! - !Call TD_StartUp - !Call TD_WellReadData - !Call TD_WellElementsReadData - !Call TD_DrillStemReadData - !Call TD_PipePropertiesReadData - ! - ! - !LoopSimulation: do - ! !WRITE (*,*) ' fluid flow done 0' - !! - ! CALL DATE_AND_TIME(values=FlowStartTime) - ! !WRITE (*,*) 'FlowStartTime=', FlowStartTime - !! - ! call Fluid_Flow_Solver - ! - !! - ! CALL DATE_AND_TIME(values=FlowEndTime) - !! - ! !WRITE (*,*) ' fluid flow done 1' - ! - ! - ! - ! FlowDuration = 3600000 * (FlowEndTime(5) - FlowStartTime(5)) + 60000 * (FlowEndTime(6) - FlowStartTime(6)) + 1000 * (FlowEndTime(7) - FlowStartTime(7)) + (FlowEndTime(8) - FlowStartTime(8)) - ! - ! - ! !call Log_1('FlowDuration=', FlowDuration) - ! !WRITE (*,*) 'FlowDuration (ms)=' , FlowDuration - ! - ! if ((100 - FlowDuration) > 0) then - ! !WRITE (*,*) 'fluid flow done 2' - ! call sleepqq(100 - FlowDuration) - ! !WRITE (*,*) ' fluid flow done 3' - ! - ! end if - ! !WRITE (*,*) ' fluid flow done 4' - ! - ! - ! - ! !WRITE (*,*) "FlowDuration", FlowDuration - ! !if(IsStopped) then - ! ! EXIT LoopSimulation - ! !ENDIF - ! !write(*,*) 'IsStopped=' , IsStopped - ! - ! if(IsStopped) then - ! !write(*,*) '44444444444' - ! - ! call DEALLOCATE_ARRAYS_NormalCirculation() - ! CALL DeallocateFlowTypes - ! call Quit() - ! end if - ! ! - ! ! if(IsStopped) exit LoopSimulation - ! ! - !end do LoopSimulation - !!call DEALLOCATE_ARRAYS_NormalCirculation() - !!CALL DeallocateFlowTypes - ! -! - ! end subroutine FluidFlowMainBody - -end module FluidFlowMain \ No newline at end of file diff --git a/FluidFlow-old/Fluid_Flow_Solver.f90 b/FluidFlow-old/Fluid_Flow_Solver.f90 deleted file mode 100644 index 4f75657..0000000 --- a/FluidFlow-old/Fluid_Flow_Solver.f90 +++ /dev/null @@ -1,58 +0,0 @@ -subroutine Fluid_Flow_Solver - - Use GeoElements_FluidModule - use UTUBEVARSModule - use KickVARIABLESModule - use PressureDisplayVARIABLESModule - USE FricPressDropVarsModule - USE MudSystemVARIABLES - USE Fluid_Flow_Startup_Vars - USE CError - - implicit none - INTEGER :: FlowDuration - Integer :: qwer - integer,dimension(8) :: FlowStartTime,FlowEndTime - - !WRITE (*,*) ' fluid flow pointer 1' - CALL TD_MainCalculations - - Call MeshGeneration_FluidModule - - !WRITE (*,*) ' fluid flow pointer 2' - - MudSystem%FluidFlowCounter = MudSystem%FluidFlowCounter + 1 - - call CirculationCodeSelect - - - CALL WellPressureDataTransfer - - CALL FormationInformationCalculator - - DO KickIteration = 1 , 40 - - !WRITE (*,*) ' Kick Iteration', KickIteration - - CALL PressureAnnAndOHDistribution - - IF (NoGasPocket > 0) THEN - !KickCorrectionVector(:) = 1. - CALL GasKickCalculator - END IF - - IF (NoGasPocket == 0 .OR. NOT(WellHeadOpen)) EXIT - IF(MAXVAL(ABS(KickVandPFunction(:))) < KickConvergenceTolerance) EXIT - !IF(MAXVAL(ABS(KickCorrectionVector(:))) < KickConvergenceTolerance) EXIT - - - END DO - - CALL PressureHorizAndStringDistribution - - IF (KickIteration == 41) THEN - WRITE (*,*) ' KickCorrectionVector ' , KickCorrectionVector - WRITE (*,*) ' Kick Jacobian = ', KickJacobian - END IF - -end subroutine \ No newline at end of file diff --git a/FluidFlow-old/Frictional_Press_Drop_Calc.f90 b/FluidFlow-old/Frictional_Press_Drop_Calc.f90 deleted file mode 100644 index c1659e8..0000000 --- a/FluidFlow-old/Frictional_Press_Drop_Calc.f90 +++ /dev/null @@ -1,230 +0,0 @@ -SUBROUTINE FricPressDrop(iloc) - - - - !! Record of revisions - !! Date Programmer Discription of change - !! ------ ------------ ----------------------- - !! 1396/07/23 Sheikh Original code - !! - - - - USE FricPressDropVarsModule - USE CMudPropertiesVariables - 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 (MudProperties%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 (MudProperties%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 (MudProperties%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 (MudProperties%ActiveRheologyModel == PowerLaw_RheologyModel .OR. MudProperties%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 (MudProperties%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 (MudProperties%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 CMudPropertiesVariables - 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 (MudProperties%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 (MudProperties%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 \ No newline at end of file diff --git a/FluidFlow-old/Horizontal_and_String_Pressure_Distribution.f90 b/FluidFlow-old/Horizontal_and_String_Pressure_Distribution.f90 deleted file mode 100644 index c05dd9b..0000000 --- a/FluidFlow-old/Horizontal_and_String_Pressure_Distribution.f90 +++ /dev/null @@ -1,799 +0,0 @@ -SUBROUTINE PressureHorizAndStringDistribution - - - !! Record of revisions - !! Date Programmer Discription of change - !! ------ ------------ ----------------------- - !! 1396/07/30 Sheikh Original code - !! - - USE FricPressDropVarsModule - use PressureDisplayVARIABLESModule - USE MudSystemVARIABLES - USE GeoElements_FluidModule - USE Fluid_Flow_Startup_Vars - use KickVARIABLESModule - USE CMudPropertiesVariables - USE CDataDisplayConsoleVariables !, StandPipePressureDataDisplay=> ChokeControlPanel%StandPipePressure - USE CDataDisplayConsoleVariables !, CasingPressureDataDisplay=> CasingPressure - USE CDrillWatchVariables - USE CShoeVariables - USE CDownHoleVariables! , OperationScenarioCommon%ElevatorConnection => DownHole%CasingPressure - USE TD_WellGeometry - USE CManifolds - USE VARIABLES - USE CError - use UTUBEVARSModule - USE CKellyConnectionEnumVariables - USE Pumps_VARIABLES - USE , INTRINSIC :: IEEE_ARITHMETIC - Use TD_DrillStemComponents - Use sROP_Variables - - - - IMPLICIT NONE - - INTEGER :: i , j , l - INTEGER :: ifric - INTEGER :: OldCasingPressure - REAL :: PressBelowFloatValve , PressAboveFloatValve ![psi] - REAL :: PumpMinDischargedVol = 0.0050 ! [gal] - REAL :: FloatValveBottomToUpAreaRatio = 1.1 ![-] - REAL :: ZeroHeight , StaticHeadOnBit - REAL(8) :: ShoeTVD - !REAL(8) , DIMENSION(5) :: MDObserve , TVDObserve , StPressObserve , AnnPressObserve , NomMD - - ExitMass = 0.0 - BitPressLoss = 0.0 - - WellHeadWasOpen = WellHeadOpen - WellToChokeManifoldWasOpen = MudSystem%WellToChokeManifoldOpen - KickWasExitingThroughChoke = .FALSE. - - - IF (MudSystem%UtubeMode1Activated .OR. FloatValveWasOpen == .FALSE.) THEN ! Horizontal line flow rate - FlowEl(1 : NoHorizontalEl)%FlowRate = 0.0 - ELSE ! connection and line is open - FlowEl(1 : NoHorizontalEl)%FlowRate = MudSystem%StringFlowRate ! pump flow rate [gpm] - END IF - - !WRITE (*,*) 'a)A/B P Bit', StaticHeadOnBit , FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) - !IF (FloatValveIn == .FALSE.) FloatValveOpen = .TRUE. - FloatValveWasOpen = FloatValveOpen - - PressBelowFloatValve = FlowEl(AnnulusFirstEl)%StartPress - - StMudVol = SUM(FlowEl(1 : StringLastEl)%Volume) * Convft3toUSGal - StDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * StMudVol) - - AnnMudVol = SUM(FlowEl(AnnulusFirstEl : NumbEl)%Volume) * Convft3toUSGal - !StCompressedMudVol = StCompressedMudVol + REAL(St_Saved_MudDischarged_Volume_Final) - !WRITE (*,*) 'St_Saved_MudDischarged_Volume_Final', REAL(St_Saved_MudDischarged_Volume_Final) - !StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) - !PressAboveFloatValve = StDeltaPDueToCompressibility + SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) !!FlowEl(StringLastEl)%EndPress - - !IF (NoGasPocket > 0) THEN ! mud exprience no comressibility - !IF (KickVolume > 2.0) THEN - IF ( (DownHole%KickVolume > 2.0) .or. (NoGasPocket>1) .or. (any(FlowEl(OpenholeFirstEl:NumbEl)%Materialtype==1)) .or. (ROP_bit%RateofPenetration > 0.0) ) THEN - AnnCompressedMudVol = 0.0 - AnnDeltaPDueToCompressibility = 0.0 - - ELSE IF (WellHeadOpen) THEN - AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * AnnMudVol) - - AnnCompressedMudVol = BackPressure / AnnDeltaPtoDeltaVCompressibility - AnnDeltaPDueToCompressibility = AnnCompressedMudVol / (MudCompressibility * AnnMudVol) - - ELSE ! No gas pocket, wellhead is closed and mud is compressed based on volume pumped into annulus - AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * AnnMudVol) - AnnCompressedMudVol = AnnCompressedMudVol + REAL(MudSystem%Ann_Saved_MudDischarged_Volume_Final) !!!!!!!!! - AnnCompressedMudVol = MAX((AnnCompressedMudVol - REAL(MudSystem%Qlost / ConvMinToSec / dt)) , 0.0) - AnnDeltaPDueToCompressibility = AnnCompressedMudVol / (MudCompressibility * AnnMudVol) - END IF - - IF (FloatValveIn == .FALSE. .OR. NoGasPocket == 0 .OR. (FloatValveWasOpen .AND. REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol)) THEN ! float valve remains open - FloatValveOpen = .TRUE. - - FlowEl(StringFirstEl : StringLastEl)%FlowRate = REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) / dt * ConvMinToSec !MudSystem%StringFlowRate ! String flow rate pump flow rate [gpm] - - !!!!!!!!!!!!!!! Calculating frictional pressure loss - IF (WellHeadOpen) THEN - DO ifric = 1 , StringLastEl - CALL FricPressDrop(ifric) - !WRITE (*,*) ' element No, FlowRate , Density, FricPressLoss', ifric, FlowEl(ifric)%FlowRate, FlowEl(ifric)%Density, FlowEl(ifric)%FricPressLoss - IF (IEEE_IS_NaN(FlowEl(ifric)%FricPressLoss)) THEN - WRITE (*,*) 'Hz/St start, end, density, Q, mu, Type' , FlowEl(ifric)%StartX, FlowEl(ifric)%EndX, FlowEl(ifric)%Density, FlowEl(ifric)%FlowRate, FlowEl(ifric)%mueff, FlowEl(ifric)%MaterialType - CALL ErrorStop('NaN in calculating pressure drop' , ifric) - END IF - END DO - END IF - - !!!!!!!!!!!!!!! - - - !IF (ABS(MudVolume_InjectedToBH - St_Saved_MudDischarged_Volume_Final)> PumpMinDischargedVol) WRITE (*,*) 'Injected to BH & St Saved Mud', MudVolume_InjectedToBH , St_Saved_MudDischarged_Volume_Final - IF (BitTotallyPluged) THEN - MudSystem%MudVolume_InjectedToBH = 0.d0 - StCompressedMudVol = StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) - StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility - - ELSE IF (WellHeadOpen .OR. NoGasPocket > 0) THEN - IF (REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN - - MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final - !WRITE (*,*) 'MudVolume_InjectedToBH,BitTrue', MudVolume_InjectedToBH - - !IF (BitTrue .AND. UtubeMode1Activated == .FALSE.) THEN - IF (BitTrue) THEN - BitPressLoss = KBit * (MudSystem%MudVolume_InjectedToBH * ConvMinToSec / dt)**2 - !WRITE (*,*) 'BitPressLoss', BitPressLoss - END IF - - StCompressedMudVol = BitPressLoss / StDeltaPtoDeltaVCompressibility - - ELSE - MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility + SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & - / StDeltaPtoDeltaVCompressibility ) * 1.d0)) - MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , StCompressedMudVol) - StCompressedMudVol = StCompressedMudVol - MudSystem%MudVolume_InjectedToBH - - END IF - - StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) - - ELSE ! IF (NoGasPocket == 0 .AND. WellHeadOpen == .FALSE.) THEN - StCompressedMudVol = StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) - StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility - MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & - / (StDeltaPtoDeltaVCompressibility + AnnDeltaPtoDeltaVCompressibility)) * 1.d0) - MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , StCompressedMudVol) - StCompressedMudVol = StCompressedMudVol - REAL(MudSystem%MudVolume_InjectedToBH) - StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) - FlowEl(AnnulusFirstEl : NumbEl)%StartPress = FlowEl(AnnulusFirstEl : NumbEl)%StartPress + StDeltaPDueToCompressibility - FlowEl(AnnulusFirstEl : NumbEl)%EndPress = FlowEl(AnnulusFirstEl : NumbEl)%EndPress + StDeltaPDueToCompressibility - - !WRITE (*,*) 'WellHeadOpen', WellHeadOpen - !WRITE (*,*) ' StCompressedMudVol, StDeltaPDueToCompressibility',StCompressedMudVol, StDeltaPDueToCompressibility - !WRITE (*,*) ' AnnCompressedMudVol, AnnDeltaPDueToCompressibility',AnnCompressedMudVol, AnnDeltaPDueToCompressibility - END IF - - - - FlowEl(StringLastEl)%EndPress = FlowEl(AnnulusFirstEl)%StartPress + BitPressLoss + FloatValveMinOpenPressure - !WRITE (*,*) 'BitPressLoss=', BitPressLoss - FlowEl(StringLastEl)%StartPress = FlowEl(StringLastEl)%EndPress + FlowEl(StringLastEl)%FricPressLoss - FlowEl(StringLastEl)%StaticPressDiff - DO i = StringLastEl - 1 , StringFirstEl , -1 - FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress - FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss - FlowEl(i)%StaticPressDiff - !WRITE(*,*) "STRING: Start , End Pressure", FlowEl(i)%StartPress , FlowEl(i)%EndPress - !WRITE(*,*) "STRING: Start , End X", FlowEl(i)%StartX , FlowEl(i)%EndX - END DO - - !FlowEl(NoHorizontalEl)%EndPress = FlowEl(StringFirstEl)%StartPress - FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD - !WRITE (*,*) '- FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD1=', - FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD - !FlowEl(NoHorizontalEl)%StartPress = FlowEl(NoHorizontalEl)%EndPress + FlowEl(StringLastEl)%FricPressLoss - !DO i = NoHorizontalEl - 1 , 1 , -1 - ! FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress - ! FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss - ! !WRITE(*,*) "HORIZONTAL: Start , End Pressure", FlowEl(i)%StartPress , FlowEl(i)%EndPress - ! !WRITE(*,*) "HORIZONTAL: Start , End X", FlowEl(i)%StartX , FlowEl(i)%EndX - !END DO - - !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open and remains open - - ELSE IF (REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) < PumpMinDischargedVol) THEN ! NoGasPocket > 0 - FloatValveOpen = FloatValveWasOpen ! remains in its former status - - IF (FloatValveOpen) THEN - PressAboveFloatValve = MAX(FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(StringFirstEl)%Density * FlowEl(StringFirstEl)%StartTVD) - ELSE - PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility - MudSystem%MudVolume_InjectedToBH = 0.d0 - END IF - - - IF (PressBelowFloatValve >= PressAboveFloatValve .AND. KickFlux) THEN - FloatValveOpen = .FALSE. - IF (FloatValveOpen /= FloatValveWasOpen) THEN ! float valve was open and now closed - WRITE (*,*) 'Float valve was open and now closed' - WRITE (*,*) 'PressAboveFloatValve=', PressAboveFloatValve - WRITE (*,*) 'PressBelowFloatValve=', PressBelowFloatValve - END IF - - END IF - - IF (FloatValveOpen) THEN - MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , 0.1 * REAL((PressAboveFloatValve - PressBelowFloatValve - AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & - / StDeltaPtoDeltaVCompressibility ) * 1.d0) - MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , StCompressedMudVol) - !WRITE (*,*) 'MudVolume_InjectedToBH (No Pump)', MudVolume_InjectedToBH - - StCompressedMudVol = StCompressedMudVol - MudSystem%MudVolume_InjectedToBH - StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) - !WRITE (*,*) 'StDeltaPDueToCompressibility(No Pump)', StDeltaPDueToCompressibility - - END IF - - IF (NoGasPocket == 0 .AND. WellHeadOpen == .FALSE.) THEN !*********** - FlowEl(AnnulusFirstEl : NumbEl)%StartPress = FlowEl(AnnulusFirstEl : NumbEl)%StartPress + AnnDeltaPDueToCompressibility - FlowEl(AnnulusFirstEl : NumbEl)%EndPress = FlowEl(AnnulusFirstEl : NumbEl)%EndPress + AnnDeltaPDueToCompressibility - END IF - - - - IF (FloatValveOpen) THEN - FlowEl(StringLastEl)%EndPress = MAX(FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(StringFirstEl)%Density * FlowEl(StringFirstEl)%StartTVD) - ELSE - FlowEl(StringLastEl)%EndPress = StDeltaPDueToCompressibility + SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) - END IF - - FlowEl(StringLastEl)%StartPress = FlowEl(StringLastEl)%EndPress - FlowEl(StringLastEl)%StaticPressDiff - DO i = StringLastEl - 1 , StringFirstEl , -1 - FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress - FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss - FlowEl(i)%StaticPressDiff - !WRITE(*,*) "STRING: Start , End Pressure", FlowEl(i)%StartPress , FlowEl(i)%EndPress - !WRITE(*,*) "STRING: Start , End X", FlowEl(i)%StartX , FlowEl(i)%EndX - END DO - - !FlowEl(NoHorizontalEl)%EndPress = FlowEl(StringFirstEl)%StartPress - FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD - !WRITE (*,*) '- FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD2=', - FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD - !FlowEl(NoHorizontalEl)%StartPress = FlowEl(NoHorizontalEl)%EndPress + FlowEl(StringLastEl)%FricPressLoss - !DO i = NoHorizontalEl - 1 , 1 , -1 - ! FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress - ! FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss - ! !WRITE(*,*) "HORIZONTAL: Start , End Pressure", FlowEl(i)%StartPress , FlowEl(i)%EndPress - ! !WRITE(*,*) "HORIZONTAL: Start , End X", FlowEl(i)%StartX , FlowEl(i)%EndX - !END DO - - - !WRITE (*,*) ' StCompressedMudVol, StDeltaPDueToCompressibility',StCompressedMudVol, StDeltaPDueToCompressibility - !WRITE (*,*) ' AnnCompressedMudVol, AnnDeltaPDueToCompressibility',AnnCompressedMudVol, AnnDeltaPDueToCompressibility - !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open (close) and maybe remains open (close) or maybe closed - - ELSE IF(FloatValveWasOpen == .FALSE. .AND. REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN - FloatValveOpen = .FALSE. - MudSystem%MudVolume_InjectedToBH = 0.d0 - - StCompressedMudVol = StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) - StDeltaPDueToCompressibility = StCompressedMudVol * StDeltaPtoDeltaVCompressibility - PressAboveFloatValve = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) + StDeltaPDueToCompressibility - - - - - IF (PressAboveFloatValve > FloatValveBottomToUpAreaRatio * PressBelowFloatValve) THEN ! float valve was open and now closed - FloatValveOpen = .TRUE. - WRITE (*,*) 'Float valve was closed and now opened' - WRITE (*,*) 'PressAboveFloatValve=', PressAboveFloatValve - WRITE (*,*) 'PressBelowFloatValve=', PressBelowFloatValve - END IF - - - FlowEl(StringLastEl)%EndPress = PressAboveFloatValve - FlowEl(StringLastEl)%StartPress = FlowEl(StringLastEl)%EndPress - FlowEl(StringLastEl)%StaticPressDiff - DO i = StringLastEl - 1 , StringFirstEl , -1 - FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress - FlowEl(i)%StartPress = FlowEl(i)%EndPress - FlowEl(i)%StaticPressDiff - !WRITE(*,*) "STRING: Start , End Pressure", FlowEl(i)%StartPress , FlowEl(i)%EndPress - !WRITE(*,*) "STRING: Start , End X", FlowEl(i)%StartX , FlowEl(i)%EndX - END DO - - - - - END IF - - IF ((MudSystem%UtubePossibility == .TRUE. .AND. Get_KellyConnection() /= KELLY_CONNECTION_STRING) .OR. MudSystem%NewPipeFilling == 0) THEN - FlowEl(NoHorizontalEl)%EndPress = 0.0 - ELSE IF (WellHeadOpen == .FALSE.) THEN - FlowEl(NoHorizontalEl)%EndPress = FlowEl(StringFirstEl)%StartPress - 0.052 * FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD - !WRITE (*,*) 'Density , StartX= , StartPress', FlowEl(NoHorizontalEl)%Density , FlowEl(StringFirstEl)%StartTVD - ELSE IF (WellHeadOpen) THEN - FlowEl(NoHorizontalEl)%EndPress = FlowEl(StringFirstEl)%StartPress - 2.0 * 0.052 * FlowEl(NoHorizontalEl)%Density * FlowEl(StringFirstEl)%StartTVD - END IF - - FlowEl(NoHorizontalEl)%StartPress = FlowEl(NoHorizontalEl)%EndPress + FlowEl(NoHorizontalEl)%FricPressLoss - DO i = NoHorizontalEl - 1 , 1 , -1 - FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress - FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss - !WRITE(*,*) "HORIZONTAL: Start , End Pressure", FlowEl(i)%StartPress , FlowEl(i)%EndPress - !WRITE(*,*) "HORIZONTAL: Start , End X", FlowEl(i)%StartX , FlowEl(i)%EndX - END DO - - - !WRITE (*,*) 'MudVolume_InjectedToBH==', MudVolume_InjectedToBH - !WRITE (*,*) 'Ann_Saved_MudDischarged_Volume_Final==', Ann_Saved_MudDischarged_Volume_Final - -!!!!!!!!!!!!!!!!!!!!! Pressure distribution in string and horizontal pump to string line - - - IF (RamLine%ShearBop_Situation_forTD == 1) THEN - FlowEl(1 : NoHorizontalEl)%EndPress = 0.0 - FlowEl(1 : NoHorizontalEl)%StartPress = 0.0 - FlowEl(1 : NoHorizontalEl)%FricPressLoss = 0.0 - END IF - -!!!!!!!!!!!!!!!!!!!!!!!!! - - - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - - - !IF (NoGasPocket == 0 .AND. WellHeadOpen) THEN - ! FlowEl(1 : NoHorizontalEl + NoStringEl)%EndPress = FlowEl(1 : NoHorizontalEl + NoStringEl)%EndPress + StDeltaPDueToCompressibility + AnnDeltaPDueToCompressibility - ! FlowEl(1 : NoHorizontalEl + NoStringEl)%StartPress = FlowEl(1 : NoHorizontalEl + NoStringEl)%StartPress + StDeltaPDueToCompressibility + AnnDeltaPDueToCompressibility - ! FlowEl(NoHorizontalEl + NoStringEl +1 : NumbEl)%EndPress = FlowEl(NoHorizontalEl + NoStringEl +1 : NumbEl)%EndPress + AnnDeltaPDueToCompressibility - ! FlowEl(NoHorizontalEl + NoStringEl + 1 : NumbEl)%StartPress = FlowEl(NoHorizontalEl + NoStringEl + 1 : NumbEl)%StartPress + AnnDeltaPDueToCompressibility - !ELSE - !IF (NoGasPocket == 0 .AND. WellHeadOpen == .FALSE.) THEN - ! FlowEl(1 : StringLastEl)%EndPress = FlowEl(1 : StringLastEl)%EndPress + StDeltaPDueToCompressibility + 30.0 ! badan eslah shavad - ! FlowEl(1 : StringLastEl)%StartPress = FlowEl(1 : NoHorizontalEl + NoStringEl)%StartPress + StDeltaPDueToCompressibility + 30.0 - ! FlowEl(AnnulusFirstEl : NumbEl)%EndPress = FlowEl(AnnulusFirstEl : NumbEl)%EndPress + AnnDeltaPDueToCompressibility - ! FlowEl(AnnulusFirstEl : NumbEl)%StartPress = FlowEl(AnnulusFirstEl : NumbEl)%StartPress + AnnDeltaPDueToCompressibility - !END IF - - - IF (MudSystem%UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. WellHeadOpen) THEN - MudSystem%MudVolume_InjectedToBH = 0.d0 - MudSystem%MudVolume_InjectedFromAnn = 0.d0 - - !ELSE - ! - ! IF (FloatValveOpen .AND. WellHeadOpen .AND. NoGasPocket == 0) THEN - ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((StDeltaPDueToCompressibility - FloatValveMinOpenPressure) / StDeltaPtoDeltaVCompressibility) * 1.d0) - ! !MudSystem%MudVolume_InjectedFromAnn = Ann_Saved_MudDischarged_Volume_Final !REAL((AnnDeltaPDueToCompressibility - BackPressure) / AnnDeltaPtoDeltaVCompressibility) * 1.d0 - ! !WRITE (*,*) 'Pressure above/under bit', FlowEl(NoHorizontalEl + NoStringEl)%EndPress, FlowEl(1 + NoHorizontalEl + NoStringEl)%StartPress - ! IF (MudVolume_InjectedToBH <= 0) MudVolume_InjectedToBH = 0.d0 - ! !IF (MudSystem%MudVolume_InjectedFromAnn <= 0) MudSystem%MudVolume_InjectedFromAnn = 0.d0 - ! ELSE IF (FloatValveOpen .AND. WellHeadOpen == .FALSE. .AND. NoGasPocket == 0) THEN - ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((PressAboveFloatValve + StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - PressBelowFloatValve - FloatValveMinOpenPressure) & - ! / (StDeltaPtoDeltaVCompressibility - AnnDeltaPtoDeltaVCompressibility)) * 1.d0) - ! MudSystem%MudVolume_InjectedFromAnn = 0.d0 - ! ELSE IF (FloatValveOpen .AND. WellHeadOpen .AND. NoGasPocket > 0) THEN - ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((PressAboveFloatValve + StDeltaPDueToCompressibility - PressBelowFloatValve - FloatValveMinOpenPressure) / StDeltaPtoDeltaVCompressibility) * 1.d0) - ! ! MudSystem%MudVolume_InjectedFromAnn = REAL(Ann_Saved_MudDischarged_Volume_Final) * 1.d0 - ! ELSE IF (FloatValveOpen .AND. WellHeadOpen == .FALSE. .AND. NoGasPocket > 0) THEN - ! MudVolume_InjectedToBH = MAX( 0.d0 , REAL((PressAboveFloatValve + StDeltaPDueToCompressibility - AnnDeltaPDueToCompressibility - PressBelowFloatValve - FloatValveMinOpenPressure) & - ! / (StDeltaPtoDeltaVCompressibility - AnnDeltaPtoDeltaVCompressibility)) * 1.d0) - ! MudSystem%MudVolume_InjectedFromAnn = 0.d0 - ! END IF - !StCompressedMudVol = MAX(StCompressedMudVol - REAL(MudVolume_InjectedToBH) , 0.0) - !AnnCompressedMudVol = MAX(AnnCompressedMudVol - REAL(MudSystem%MudVolume_InjectedFromAnn) , 0.0) - !StDeltaPDueToCompressibility = StCompressedMudVol / (MudCompressibility * StMudVol) - !AnnDeltaPDueToCompressibility = AnnCompressedMudVol / (MudCompressibility * AnnMudVol) - END IF - - - !MudVolume_InjectedToBH = 0.0 - !MudVolume_InjectedToBH = St_Saved_MudDischarged_Volume_Final - !WRITE (*,*) 'CompMudVol, DeltaP, MudVolumeInjected' - !WRITE (*,*) StCompressedMudVol, StDeltaPDueToCompressibility, REAL(MudVolume_InjectedToBH) - !WRITE (*,*) AnnCompressedMudVol, AnnDeltaPDueToCompressibility, REAL(MudSystem%MudVolume_InjectedFromAnn) - !WRITE (*,*) 'Press above/Below Float valve ', FlowEl(NoHorizontalEl + NoStringEl)%EndPress , FlowEl(NoHorizontalEl + NoStringEl + 1)%StartPress - !write(*,*) 'MudSystem%MudVolume_InjectedFromAnn***=' , MudSystem%MudVolume_InjectedFromAnn, Ann_Saved_MudDischarged_Volume_Final - -110 FORMAT (I6 , 4X , F6.2 , 7X , F4.2 , 3X , F4.1 , 2X , F4.2) - - - !DO i = NumbEl , NumbEl - NoOpenHoleEl + 1 , -1 ! op elements - ! WRITE (*,*) 'el no, start, end' , i, FlowEl(i)%StartPress, FlowEl(i)%EndPress - !END DO - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !!!! Kick Information Reports - - -!!!!!!!!!!!!!!!!! 1- Stand pipe pressure gauge PressureGauges(1) - - !ElementTrueDepth = STpipeGauge_Height/Convfttom - !DistancetoRefrence = -170.7 ! 165 ft after pump and 100 ft before string - i = 1 - DO WHILE (NOT(FlowEl(i)%EndX >= -170 .AND. FlowEl(i)%StartX <= -170)) - i = i + 1 - IF (i > NoHorizontalEl) EXIT - END DO - CALL PumpPressureDelay%AddToFirst(REAL(FlowEl(i)%StartPress - 0.052 * (MudSystem%STpipeGauge_Height / Convfttom) * FlowEl(i)%Density + (FlowEl(i)%StartX + 170) * FlowEl(i)%dPdLFric)) - CALL PumpPressureDelay%Remove(PressureTimeStepDelay(1) + 1) - !IF (ANY(PUMP(:)%PowerFailMalf == 1)) PumpPressureDelay%Array(1 : PressureTimeStepDelay(1) / 2) = 0.0 !seyyed goft vaghti pumpfailure mishavad feshar dasti 0 nashavad, be in dalil in khat comment shod. - - DO j = PressureTimeStepDelay(1) , 1 , -1 - IF (NOT(IEEE_IS_NaN(PumpPressureDelay%Array(j)))) THEN - PressureGauges(1) = INT(PumpPressureDelay%Array(j)) - EXIT - END IF - END DO - - !PressureGauges(1) = INT(PumpPressureDelay%Array(PressureTimeStepDelay(1))) - - IF (i > NoHorizontalEl) THEN - WRITE (*,*) ' Error in calculating standpipe pressure ' - END IF - - IF (PressureGauges(1) < 0) THEN - !CALL Set_StandPipePressure(real(PressureGauges(1) , 8)) ! for display console - PressureGauges(1) = 0.0 - !CALL Set_StandPipePressure(0.0d0) !StandPipePressureGauge = 0 - END IF - DownHole%DrillPipePressure = real(PressureGauges(1), 8) - !WRITE (*,*) 'Drillpipe Pressure', PressureGauges(1) - -!!!!!!!!!!!!!!!!! 2- Casing pressure gauge PressureGauge(2) - !WRITE (*,*) 'here 1', (WelltoPitsOpen == .FALSE. .AND. WellToChokeManifoldOpen) , (Valve(26)%Status == .TRUE. .AND. Valve(47)%Status == .TRUE. .AND. Valve(49)%Status == .TRUE.), BackPressure - !WRITE (*,*) Valve(26)%Status , Valve(47)%Status , Valve(49)%Status - !WRITE (*,*) (Valve(26)%Status == .TRUE.) , (Valve(47)%Status == .TRUE.) , (Valve(49)%Status == .TRUE.) - - !!! in normal mode changes in choke position immidiately observes in casing pressure - !! but when pumps off due to failure, casing pressure will drop after a delay time - IF (MudSystem%WellToChokeManifoldOpen .OR. MudSystem%WellToChokeLineGauge) THEN - !WRITE (*,*) 'Here 1' - CALL CasingPressureDelay%AddToFirst(FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl)%EndPress) - CALL CasingPressureDelay%Remove(PressureTimeStepDelay(1) + 1) - - DO j = 1 , PressureTimeStepDelay(1) - IF (NOT(IEEE_IS_NaN(CasingPressureDelay%Array(j)))) THEN - PressureGauges(2) = INT(CasingPressureDelay%Array(j)) - EXIT - END IF - END DO - - !PressureGauges(2) = INT(CasingPressureDelay%Array(1)) - IF (ANY(PUMP(:)%PowerFailMalf == 1)) THEN - DO j = PressureTimeStepDelay(1) , 1 , -1 - IF (NOT(IEEE_IS_NaN(CasingPressureDelay%Array(j)))) THEN - PressureGauges(2) = INT(CasingPressureDelay%Array(j)) - EXIT - END IF - END DO - END IF - - - - - !IF (ANY(PUMP(:)%PowerFailMalf == 1)) PressureGauges(2) = INT(CasingPressureDelay%Array(PressureTimeStepDelay(1))) - - ELSE !IF (ChokeLineGaugeToTanks) THEN - PressureGauges(2) = 0 - !WRITE (*,*) 'Here 2' - END IF - - - !WRITE (*,*) 'GaugePoint(2)%Pressure =' , GaugePoint(2)%Pressure - !IF (PressureGauges(2) < 0) THEN - ! PressureGauges(2) = 0.0 - !END IF - CALL Set_CasingPressure(real(PressureGauges(2) , 8)) ! for display console - Downhole%CasingPressure = real(PressureGauges(2) , 8) - !IF (PressureGauges(2) > 3000.0) THEN - ! !CALL Error(' High Casing Pressure') - !END IF - !WRITE (*,*) 'Casing Pressure=' , PressureGauges(2) - - - -!!!!!!!!!!!!!!!!! 3- Bottom Hole Pressure PressureGauge(3) - - CALL BottomHolePressureDelay%AddToFirst(FlowEl(OpenholeFirstEl)%StartPress) - CALL BottomHolePressureDelay%Remove(PressureTimeStepDelay(2) + 1) - !PressureGauges(3) = INT(BottomHolePressureDelay%Array(PressureTimeStepDelay(2))) - - DO j = PressureTimeStepDelay(2) , 1 , -1 - IF (NOT(IEEE_IS_NaN(BottomHolePressureDelay%Array(j)))) THEN - PressureGauges(3) = INT(BottomHolePressureDelay%Array(j)) - EXIT - END IF - END DO - - - BottomHolePress = BottomHolePressureDelay%Array(PressureTimeStepDelay(2)) - - DownHole%BottomHolePressure = REAL(PressureGauges(3) , 8) -!!!!!!!!!!!!!!!!! 4- Under Bit Pressure PressureGauges(4) - - PressureGauges(4) = FlowEl(AnnulusFirstEl)%StartPress - -!!!!!!!!!!!!!!!!! - - -!!!!!!!!!!!!!!!!! 5- Casing Shoe Pressure PressureGauges(5) - - !IF (ShoeDepth <= FlowEl(NoHorizontalEl + NoStringEl + 1)%StartX) THEN - DO ShoeFlowElNo = AnnulusFirstEl , NumbEl - IF (FlowEl(ShoeFlowElNo)%StartX >= Shoe%ShoeDepth .AND. FlowEl(ShoeFlowElNo)%EndX < Shoe%ShoeDepth) EXIT - END DO - CALL TVD_Calculator(Shoe%ShoeDepth , ShoeTVD) - - IF (ShoeFlowElNo > NumbEl) THEN - WRITE (*,*) 'ShoeDepth =', Shoe%ShoeDepth - DO i = AnnulusFirstEl , NumbEl - WRITE (*,*) 'i, StartX, EndX', i, FlowEl(i)%StartX, FlowEl(i)%EndX - END DO - - CALL ErrorSTOP ('Error in finding location of shoe') - END IF - - !ELSE - ! WRITE (*,*) ' Error in calculating shoe pressure ' - !END IF - - CALL ShoePressureDelay%AddToFirst(REAL(FlowEl(ShoeFlowElNo)%StartPress & - - (FlowEl(ShoeFlowElNo)%StartX - Shoe%ShoeDepth) * FlowEl(ShoeFlowElNo)%dPdLfric & - - (FlowEl(ShoeFlowElNo)%StartTVD - ShoeTVD) * FlowEl(ShoeFlowElNo)%dPdLGrav)) - CALL ShoePressureDelay%Remove(PressureTimeStepDelay(3) + 1) - - !FlowrateNearShoe = FlowEl(ShoeFlowElNo)%FlowRate - DO j = PressureTimeStepDelay(3) , 1 , -1 - IF (NOT(IEEE_IS_NaN(ShoePressureDelay%Array(j)))) THEN - PressureGauges(5) = INT(ShoePressureDelay%Array(j)) - EXIT - END IF - END DO - - - !PressureGauges(5) = INT(ShoePressureDelay%Array(PressureTimeStepDelay(3))) - DownHole%ShoePressure = real(PressureGauges(5), 8) - - - - !IF (PressureGauges(5) >= FormationLostPressure) WRITE (*,*) 'Near Shoe Flowrate', FlowEl(ShoeFlowElNo)%FlowRate - - MudSystem%ShoeMudViscosity = FlowEl(ShoeFlowElNo)%MuEff - MudSystem%ShoeMudDensity = FlowEl(ShoeFlowElNo)%Density - - !WRITE (*,*) 'Drillstring speed (ft/s)' , DrillStringSpeed - !WRITE (*,*) 'shoe mud speed ', FlowEl(ShoeFlowElNo - 1)%vel - !WRITE (*,*) 'Shoe pressure (psi)', ShoePressureDelay%Array(1) - - - - -!!!!!!!!!!!!!!!!! - -!!!!!!!!! 6- Pressure Before Bop - - PressureGauges(6) = FlowEl(NoHorizontalEl + NoStringEl + NoAnnulusEl)%EndPress - -!!!!!!!!!!!!!!!!! -101 FORMAT(4X, I2, 8X, (F8.1), 12X, (F8.3), 7X, (F8.2)) - - !WRITE (*,*) ' Pump Pressure Delay', PumpPressureDelay%Array(1) - !WRITE (*,*) ' Bottom Hole Pressure Delay', BottomHolePressureDelay%Array(1) - !WRITE (*,*) ' Shoe Pressure Delay', ShoePressureDelay%Array(1) - - !IF (ALLOCATED(GasPocketWeight%Array) .AND. ChokeKroneckerDelta == 1) THEN - !WRITE (*,*) 'Pocket No , Gas Pocket (psia) , Volume (gal) , Flow Induced (gpm) ' - - !DO i = 1 , NoGasPocket - ! WRITE (*,101) i, GasPocketNewPress%Array(i), GasPocketNewVol%Array(i) * ConvFt3toUSGal, GasPocketFlowInduced%Array(i) - !END DO - ! WRITE (*,*) 'Kchoke =', Kchoke, FlowEl(OpenholeFirstEl - 1)%FlowRate - - !DO i = 1 , NoGasPocket - ! WRITE (*,*) 'Gas Kick Vol (gal)=' , GasPocketNewVol%Array(i) * ConvFt3toUSGal , GasPocketDeltaVol%Array(i) * ConvFt3toUSGal , GasPocketNewPress%Array(i) - !END DO - - !WRITE (*,*) 'BHP (psig)=', BottomHolePress - - IF (ChokeKroneckerDelta == 1) THEN - !WRITE (*,*) 'Casing Pressure' , PressureGauges(2) - !WRITE (*,*) 'Below Bit' , FlowEl(AnnulusFirstEl)%StartPress - !WRITE (*,*) 'Above Bit' , FlowEl(StringLastEl)%EndPress - !WRITE (*,*) 'Pump Pressure' , PressureGauges(1) - - - - !WRITE (*,*) ' Kick Iteration', KickIteration - !WRITE (*,*) ' Kchoke, Q =', Kchoke, FlowEl(j)%Flowrate !, REAL((DeltaVolumePipe * ConvMinToSec / dt) + MudSystem%StringFlowRate) - !DO l = NoHorizontalEl + NoStringEl + 1 , NumbEl - ! WRITE (*,*) 'El No, Fric Press Loss, density , Q', l, FlowEl(l)%FricPressLoss, FlowEl(l)%StaticPressDiff, FlowEl(l)%Density, FlowEl(l)%Flowrate - !END DO - !write(*,*) 'BackPressure=' , BackPressure - - !WRITE (*,*) ' Kick Jacobian ', REAL(KickJacobian) - !WRITE (*,*) ' KickVandPFunction = ' , REAL(-KickVandPFunction) - !WRITE (*,*) ' Kick Unknown Vector = ' , REAL(KickUnknownVector) - !WRITE (*,*) 'SUM(StaticPressDiff) , SUM(FricPressLoss)', SUM(FlowEl(GasPocketElementNo(1) : i)%FricPressLoss) , SUM(FlowEl(GasPocketElementNo(1) : i)%StaticPressDiff) - !WRITE (*,*) 'Drillpipe, casing pressure', PressureGauges(1), PressureGauges(2) - END IF - - !IF (NoWelltoChokeEl > 0 .AND. FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .AND. WellHeadOpen) THEN ! kick is last element in choke line and does not exit. - ! KickWasExitingThroughChoke = .TRUE. - ! GasPocketDensity%Array(NoGasPocket) = (GasPocketweight%Array(NoGasPocket) / GasPocketModifiedVol%Array(NoGasPocket)) / convft3toUSgal ! [lbm/ft^3 to ppg] - ! ExitMass = (1.0 - (GasPocketModifiedVol%Array(NoGasPocket) / GasPocketNewVol%Array(NoGasPocket))) * GasPocketWeight%Array(NoGasPocket) ! exit mass due to expand - ! WRITE (*,*) ' ExitMass due to expand = ', GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal , ExitMass - !END IF - - !WRITE (*,*) 'Horiz 1' - - KickInFluxConditions = (Reservoir%FormationTop < TD_WellGeneral%WellTotalVerticalLength) .AND. (NOT(Reservoir%InactiveInflux)) .AND. (FormPressure > BottomHolePress + 5.0) - IF (KickInFluxConditions) THEN - KickFlux = .TRUE. - - CALL NewGasKick - - !WRITE (*,*) 'Kick Flux top' , KickFlux - !WRITE (*,*) 'FormPressure, BottomHolePress, FormationTop, TD_WellGeneral%WellTotalVerticalLength' , FormPressure, BottomHolePress, FormationTop, TD_WellGeneral%WellTotalVerticalLength - - ELSE - IF (ALLOCATED(GasPocketWeight%Array) .AND. KickFlux) THEN - KickOffBottom = .TRUE. - WRITE (*,*) 'Kick Off Bottom' - WRITE (*,*) 'FormPressure , BottomHolePress' , FormPressure , BottomHolePress - !WRITE (*,*) 'No Press(psia) Vol(gal) Weight(lbm) Flow Induced(gpm) Flow El Press(psia)' - DO i = 1 , NoGasPocket - WRITE (*,102) i , GasPocketNewPress%Array(i), GasPocketNewVol%Array(i) * Convft3toUSgal, GasPocketWeight%Array(i), GasPocketFlowInduced%Array(i), FlowEl(GasPocketFlowEl(i , 1))%StartPress + StandardPress - END DO - END IF - KickFlux = .FALSE. - END IF - - IF (ALLOCATED(KickJacobian)) OldKickJacobian = KickJacobian - -102 FORMAT (I2, 3X, (F8.1), 2X, (F8.2), 2X, (F8.3), 8X, (F8.2), 10X, (F8.1)) - - !!!!!!!! Auto Choke Procedure - ! DO i = 1 , 5 - ! AreaChange = -1.0 * (BottomHolePressure - (FormPressure + BHPSafetyMargin)) / FlowEl(OpenholeFirstEl - 1)%Flowrare**2 * 89158.0 & - ! * (0.26 * 0.61)**2 * TotalOpenChokeArea**3 / (4.0 * ChokeDensity) - ! CHOOKE(1)%AreaChokeFinal = CHOOKE(1)%AreaChokeFinal + AreaChange / * Convfttoinch**2 - ! - ! - ! - ! END DO - ! - ! - ! - ! - ! - - - !WRITE (*,*) ' SecondaryKickWeight', SecondaryKickWeight - !WRITE (*,*) ' SecondaryKickVol', SecondaryKickVol - DownHole%SecondKickVolume = SecondaryKickVol - - - - IF (WellHeadOpen == .FALSE. .OR. (FlowEl(OpenholeFirstEl - 1)%Flowrate < PressFlowrateTolerance .AND. FlowEl(AnnulusLastEl)%Flowrate < PressFlowrateTolerance)) THEN - OnShakerDensity = 0.0 - ELSE IF (FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .AND. ChokeKroneckerDelta == 1) THEN - OnShakerDensity = 2.0 - ELSE IF (ChokeKroneckerDelta == 0) THEN - OnShakerDensity = FlowEl(AnnulusLastEl)%Density - ELSE IF (ChokeKroneckerDelta == 1) THEN !!!(FlowEl(OpenholeFirstEl - 1)%Flowrate > PressFlowrateTolerance .AND. FlowEl(AnnulusLastEl)%Flowrate < PressFlowrateTolerance) THEN - OnShakerDensity = FlowEl(OpenholeFirstEl - 1)%Density - ELSE - OnShakerDensity = (FlowEl(OpenholeFirstEl - 1)%Density * FlowEl(OpenholeFirstEl - 1)%Flowrate & - + FlowEl(AnnulusLastEl)%Density * FlowEl(AnnulusLastEl)%Flowrate) / (FlowEl(OpenholeFirstEl - 1)%Flowrate + FlowEl(AnnulusLastEl)%Flowrate) - END IF - !WRITE (*,*) 'ANINT(OnShakerDensity * 100) / 100', ANINT(OnShakerDensity * 100) / 100 , OnShakerDensity - CALL Set_MudWeightOut(ANINT(OnShakerDensity * 100) / 100) - - - IF (ALLOCATED(FinalFlowEl)) DEALLOCATE(FinalFlowEl) - ALLOCATE(FinalFlowEl(NumbEl)) - - FinalFlowEl(:)%StartX = FlowEl(:)%StartX - FinalFlowEl(:)%EndX = FlowEl(:)%EndX - FinalFlowEl(:)%StartTVD = FlowEl(:)%StartTVD - FinalFlowEl(:)%EndTVD = FlowEl(:)%EndTVD - FinalFlowEl(:)%Length = FlowEl(:)%Length - FinalFlowEl(:)%DepthDiff = FlowEl(:)%DepthDiff - FinalFlowEl(:)%density = FlowEl(:)%density - FinalFlowEl(:)%StartPress = FlowEl(:)%StartPress - FinalFlowEl(:)%EndPress = FlowEl(:)%EndPress - FinalFlowEl(:)%dPdLFric = FlowEl(:)%dPdLFric - FinalFlowEl(:)%dPdLGrav = FlowEl(:)%dPdLGrav - - !WRITE (*,*) 'FlowRate=', FlowEl(AnnulusFirstEl)%FlowRate - !WRITE (*,*) 'Pressure Loss in Drill String', SUM(FlowEl(StringFirstEl : StringLastEl)%FricPressLoss) - !WRITE (*,*) 'Pressure Loss in Annulus', SUM(FlowEl(AnnulusFirstEl : AnnulusLastEl)%FricPressLoss) - !MDObserve(:) = [3000.0 , 4349.0 , 11880.0 , 19880.0 , 21680.0] - !NomMd (:) = [3000 , 4298 , 11690 , 19690 , 21490] - !DO i = 1 , 5 - ! CALL TVD_Calculator(MDObserve(i) , TVDObserve(i)) - !END DO - ! - !DO i = 1 , 5 - ! - ! WRITE (*,*) 'MDObserve(i)', INT(NomMD(i)) - ! WRITE (*,*) 'TVDObserve(i)', INT(TVDObserve(i)) - ! - ! DO j = StringFirstEl , StringLastEl - ! IF (INT(MDObserve(i)) < INT(FinalFlowEl(j)%EndX)) EXIT - ! END DO - ! StPressObserve(i) = FlowEl(j)%StartPress - (MDObserve(i) - FlowEl(j)%StartX) * FlowEl(j)%dPdLfric + (TVDObserve(i) - FlowEl(j)%StartTVD) * FlowEl(j)%dPdLGrav - ! WRITE (*,*) 'String Pressure', INT(StPressObserve(i)) - ! - ! - ! - ! IF (INT(MDObserve(i)) <= INT(FlowEl(AnnulusFirstEl)%StartX)) THEN !! mouse pointer is in the annulus space - ! DO j = AnnulusFirstEl , AnnulusLastEl - ! IF (INT(FlowEl(j)%EndX) <= INT(MDObserve(i))) EXIT - ! END DO - ! ELSE IF (INT(MDObserve(i)) > INT(FinalFlowEl(NumbEl)%EndX)) THEN ! mouse pointer is in the open hole space - ! DO j = OpenholeFirstEl , NumbEl - ! IF (INT(FinalFlowEl(j)%EndX) <= INT(MDObserve(i))) EXIT - ! END DO - ! END IF - ! AnnPressObserve(i) = FlowEl(j)%StartPress - (FlowEl(j)%StartX - MDObserve(i)) * FlowEl(j)%dPdLfric & - ! - (FlowEl(j)%StartTVD - TVDObserve(i)) * FlowEl(j)%dPdLGrav - ! WRITE (*,*) 'Annulus Pressure', INT(AnnPressObserve(i)) - ! - ! - !END DO - - - - - END SUBROUTINE - - - -SUBROUTINE SOLVE_LINEAR_EQUATIONS(A , x , b , error, dim) - - !!! This subroutine solves a linear systems of equations Ax=b - !! if vaiable erorr changed its value to .FALSE. means that the system of equations cab not be solved - !! I use this subroutine to solve the linearized equations which uprising in calculation of volume and pressure of gas kick pockets - - use KickVARIABLESModule - - IMPLICIT NONE - INTEGER , INTENT(IN) :: dim - REAL(8) , DIMENSION(dim,dim) , INTENT(in) :: A - REAL , DIMENSION(dim) , INTENT(OUT) :: x - REAL(8) , DIMENSION(dim) , INTENT(in) :: b - LOGICAL , INTENT(OUT) :: error - REAL(8) , DIMENSION(:,:) , ALLOCATABLE :: m - INTEGER , DIMENSION(1) :: max_loc - REAL(8) , DIMENSION(:) , ALLOCATABLE :: temp_row - INTEGER :: n , k - - !WRITE (*,*) 'SIZE(A , dim = 1), SIZE(A , dim = 2), SIZE(b)', SIZE(A , dim = 1), SIZE(A , dim = 2), SIZE(b) - error = (SIZE(A , dim = 1) /= SIZE(b)) .OR. (SIZE(A , dim = 2) /= SIZE(b)) - !WRITE (*,*) 'SOLVE_LINEAR_EQUATIONS 1' , error - - IF (error) THEN - x = 0.0d0 - RETURN - END IF - n = SIZE(b) - - ALLOCATE (m(n , n + 1) , temp_row(n + 1)) - m(1:n , 1:n) = A - m(1:n , n + 1) = b - !WRITE (*,*) 'SOLVE_LINEAR_EQUATIONS 2' , m - ! Triangularization phase - TRIANG_LOOP: DO k = 1 , n - max_loc = MAXLOC(ABS(m(k:n , k))) - temp_row(k:n + 1) = m(k , k:n + 1) - m(k , k:n+1) = m(k-1+max_loc(1) , k:n+1) - m(k - 1 + max_loc(1) , k:n + 1) = temp_row(k:n + 1) - !WRITE (*,*) 'SOLVE_LINEAR_EQUATIONS 3' , max_loc - - IF (m(k , k) == 0) THEN - error = .TRUE. - !WRITE (*,*) 'SOLVE_LINEAR_EQUATIONS 4' - EXIT TRIANG_LOOP - ELSE - !WRITE (*,*) 'SOLVE_LINEAR_EQUATIONS 5' - m(k , k : n + 1) = m(k , k : n + 1) / m(k , k) - m(k + 1 : n , k + 1 : n + 1) = m(k + 1 : n , k + 1 : n + 1) - SPREAD(m(k , k + 1:n + 1) , 1, n - k) * SPREAD(m(k + 1:n , k) , 2 , n - k + 1) - END IF - END DO TRIANG_LOOP - !WRITE (*,*) 'SOLVE_LINEAR_EQUATIONS 6' - - ! Back substitution phase - IF (error) THEN - x = 0.0 - ELSE - DO k = n , 1 , -1 - x(k) = REAL(m(k , n + 1) - SUM(m(k , k + 1 : n) * x(k + 1 : n))) - !WRITE (*,*) 'SOLVE_LINEAR_EQUATIONS 7' - END DO - END IF - - DEALLOCATE(m , temp_row) - -END SUBROUTINE solve_linear_equations - \ No newline at end of file diff --git a/FluidFlow-old/Pressure_Display_VARIABLES.f90 b/FluidFlow-old/Pressure_Display_VARIABLES.f90 deleted file mode 100644 index dc7e9ce..0000000 --- a/FluidFlow-old/Pressure_Display_VARIABLES.f90 +++ /dev/null @@ -1,32 +0,0 @@ -MODULE PressureDisplayVARIABLES - - USE DynamicRealArray - - IMPLICIT NONE - - - INTEGER :: NoGauges - REAL , DIMENSION(6) :: PressureGauges - INTEGER :: SoundSpeed ! speed of sound [ft/s] - INTEGER , DIMENSION(3) :: PressureTimeStepDelay - TYPE(DynamicRealArrayType) :: PumpPressureDelay - TYPE(DynamicRealArrayType) :: CasingPressureDelay - TYPE(DynamicRealArrayType) :: BottomHolePressureDelay - TYPE(DynamicRealArrayType) :: ShoePressureDelay - - - - TYPE :: ObservationAndGaugePointsInformations ! We have some gauges and may be have many observation points like casing shoe, bottomhole , etc. - ! This module stores information of these points to calculate pressure, density and other desired properties - ! at these points - ! Locations: 1: Stand Pipe , 2: Choke Manifold, 3: Botton Hole, 4: Under Bit, 5: Shoe, 6: Before BOP - INTEGER :: ElementNo ! Element Nubmer based on mud elements - REAL :: DistancetoRefrence ! Distance from pump or the end of fluid path [ft] - REAL :: ElementTrueDepth ! True depth of point or gauge [ft] - REAL :: Pressure ! Pressure [psi] - END TYPE - - !TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: GaugePoint(:) - TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: ObservationPoint(:) - - END MODULE \ No newline at end of file diff --git a/FluidFlow-old/Pressure_Distribution_VARIABLES.f90 b/FluidFlow-old/Pressure_Distribution_VARIABLES.f90 deleted file mode 100644 index b4f52b5..0000000 --- a/FluidFlow-old/Pressure_Distribution_VARIABLES.f90 +++ /dev/null @@ -1,178 +0,0 @@ -MODULE FricPressDropVars - - - !! Record of revisions - !! Date Programmer Discription of change - !! ------ ------------ ----------------------- - !! 1396/07/26 Sheikh Original code - !! - - IMPLICIT NONE - - - - REAL :: TotFricPressLoss ! Total Frictional Pressure Loss [psi] - REAL :: FlowrateNearShoe - INTEGER :: NoHorizontalEl ! number of elements in horizontal pump to string line - INTEGER :: NoStringEl ! number of elements in string - INTEGER :: NoAnnulusEl ! number of elements in annulus space - INTEGER :: NoWellToChokeEl ! number of elements in well head to choke manifold - INTEGER :: NoOpenHoleEl ! number of elements in openhole - INTEGER :: NumbEl ! number of flow elements in horizontal line, string, annulus and openhole - INTEGER :: StringFirstEl ! number of first string element - INTEGER :: StringLastEl ! number of last string element - INTEGER :: AnnulusFirstEl ! number of first annulus element - INTEGER :: AnnulusLastEl ! number of last annulus element - INTEGER :: ChokeFirstEl ! number of first choke element - INTEGER :: ChokeLastEl ! number of last choke element - INTEGER :: OpenholeFirstEl ! number of first openhole element - INTEGER :: ShoeFlowElNo ! the flow element that starts from shoe, in other word the number of upper element adjacent to shoe - REAL :: KBOP ! DeltaPBOP = KBOP * Q**2 [psi * min^2 / gal^2] - REAL :: KBit ! DeltaPBit = KBit * Q**2 [psi * min^2 / gal^2] - - !!!! Choke Variables - REAL :: BackPressure , NewBackPressure ! back pressure at riser or choke line [psi] - REAL :: Kchoke ! DeltaPchoke = Kchoke * Q**2 [psi * min^2 / gal^2] - REAL :: TotalOpenChokeArea , OldTotalOpenChokeArea , ChokeBypassArea , NewTotalOpenChokeArea , AreaChange - REAL :: BHPSafetyMargin , AChBHPTol ! BHP safety margin and BHP Tolerance in Auto Choke mode [psi] - REAL(8) :: OnShakerDensity ! Outlet Density of well for displaying in drillwatch and data [ppg] - - LOGICAL :: FloatValveIn - LOGICAL :: FloatValveOpen , FloatValveWasOpen - LOGICAL :: BitTotallyPluged - - REAL :: ClingingFactor = 0.45 ! in calculating surge and swab pressure changes - REAL :: MudCompressibility = 2.7E-6 ! Volumne change relative to Volume/1psi, for example for change of 1000 psi in pressure, volume changes 0.27% [1/psi] - REAL :: FloatValveMinOpenPressure = 1.0 ! minimum pressure that opens the float valve [psi] - REAL :: StMudVol ! Total mud volume of Horizontal and String that may be compressed [gal] - REAL :: AnnMudVol ! Total mud volume of Bottom hole, Annulus and Choke line that may be compressed [gal] - REAL :: PumpToManifoldMudVol - REAL :: StCompressedMudVol ! Compressed mud volume in Horizontal and String [gal] - REAL :: AnnCompressedMudVol ! Compressed mud volume in Bottom hole, Annulus and Choke line [gal] - REAL :: PumpToManifoldCompressedMudVol - REAL :: StDeltaPDueToCompressibility ! Pressure increase due to mud compressibility in Horizontal and String [psi] - REAL :: AnnDeltaPDueToCompressibility ! Pressure increase due to mud compressibility in Bottom hole, Annulus and Choke line [psi] (usually when wellhead is closed) - REAL :: PumpToManifoldDeltaPDueToCompressibility - REAL :: StDeltaPtoDeltaVCompressibility ! string pressure change due to compressibility [psi/gal] - REAL :: AnnDeltaPtoDeltaVCompressibility ! annulus and openhole pressure change due to compressibility [psi/gal] - - - !!!! Problem Variables (Choke and Bit) - - INTEGER :: ManChoke1Plug , ManChoke2Plug ! = 1 if choke is plugged , = 0 else - INTEGER :: ManChoke1Washout , ManChoke2Washout ! = 1 if choke is washed out , = 0 else - INTEGER :: BitJetsPlugged , BitJetsWashedOut - INTEGER :: CasingPressure_DataDisplayMalF, CasingPressure_ChokeMalF - - !!!!!! Note that bit is not an element in these calculations - - - TYPE, PUBLIC :: PressDropCalcElemInfo - - !! Geometrical variables - REAL(8) :: Length ! Length of a Flow element [ft] - REAL(8) :: DepthDiff ! Difference between depth of start and end of element [ft] - REAL(8) :: StartX , EndX ! start and end point (measured depth) of flow element [ft] - REAL(8) :: StartTVD , EndTVD ! Start and End point True Vertical Depth of flow element [ft] - REAL :: Od , Id , Dhyd ! Outer, Inner and hydraulic diameter of flow element [in] - REAL :: Area ! area of element [ft^2] - INTEGER :: alpha ! geometry factor: 0 = pipe (ID=0) , 1 = annulus - INTEGER :: FrictionDirection ! = 1 if flowrate is positive, so frictional pressure gradient is in direction of preassumed - ! flowrate, = -1 if not above condition usually in Swab conditions - !! Flow variables - INTEGER :: MaterialType ! = 0 for mud , = 2 for gas - REAL :: volume , vel , density , FlowRate ! volume [ft^3], velocity [ft/s], density of fluid flow [ppg], flow rate [gpm] - REAL :: Gf ! geometry shear rate correction [-] - !! Rheological and frictional variables - REAL :: Theta600 , Theta300 ! Fann data at 600 and 300 rpm as rheological data - ! REAL(8) :: VelCritBing , VelCritPow ! critical velocity in Bingham Plastic and Power law model [ft/min] - REAL :: muPlastic , YieldP ! plastic viscosity [cp] and yield point [lbf/(100*ft^2)] - REAL :: mueff ! Effective or apparent viscosity which is used in calculation of generalized Reynolds number - REAL :: nIndex , kIndex ! n: flow behaivior index [-] and k: consistency factor [lbf*s^n/(100*ft^2)] - REAL :: gammaW , tauW ! shear rate at the wall [1/s] and wall shear stress [lbf/(100*ft^2)] - REAL :: GenRe ! generalized Reynolds number in power law model [-] - REAL :: ReCrit = 2100.0 ! Critical Reynolds number for Newtonian model and Bingham plastic model - REAL :: ReCritLam , ReCritTurb ! laminar and turbulent critical Reynolds - REAL :: f ! Fanning friction factor [-] - REAL :: a , b ! parameters for calculationg friction factor in turbulent regime for power law model [-] - LOGICAL :: LaminarRegime ! = .TRUE. if flow regime is laminar and = .FALSE. if flowregime is not - LOGICAL :: TurbulentRegime ! = .TRUE. if flow regime is turbulent and = .FALSE. if flowregime is not - !! Pressure change variables - REAL :: StartPress , EndPress ! Pressure at start and end of an element [psi] - REAL :: dPdLFric ! frictional pressure drop gradient in each element [psi/ft] - REAL :: dPdLGrav ! gravitional pressure gradient = 0.052 * Density [psi/ft] - REAL :: FricPressLoss ! frictional pressure loss in each element [psi] - REAL :: StaticPressDiff ! static pressure difference between top and bottom of a pocket [psi] always positive - REAL :: FricToQPartialDiff ! partial differentiation of friction relative to volume flow rate - - - - END TYPE PressDropCalcElemInfo - - TYPE (PressDropCalcElemInfo) , ALLOCATABLE :: FlowEl(:) ! FlowEl: Pressure Drop Calculation Elements The dimension is equal to the number of flow elements - - - - - TYPE, PUBLIC :: FinalPressDropCalcElemInfo - - !!! for use in calculationg properties of a point in 'downhole view' page - - REAL(8) :: StartX , EndX , StartTVD , EndTVD , Length , DepthDiff ! start and end point of flow element [ft] - REAL :: density ! density of fluid flow [ppg], flow rate [gpm] - REAL :: StartPress ! Pressure at start of an element [psi] - REAL :: EndPress ! Pressure at end of an element [psi] - REAL :: dPdLFric ! frictional pressure drop gradient in each element [psi/ft] - REAL :: dPdLGrav ! gravitional pressure gradient = 0.052 * Density [psi/ft] - - END TYPE FinalPressDropCalcElemInfo - - TYPE (FinalPressDropCalcElemInfo) , ALLOCATABLE :: FinalFlowEl(:) ! FlowEl: Pressure Drop Calculation Elements The dimension is equal to the number of flow elements - - - - - END MODULE FricPressDropVars - - MODULE UTUBEVARS - - REAL :: QUTubeInput ! flow rate from string to annulus which caused by head difference at two sides of U-tube [gpm] - REAL :: QUtubeOutput ! flow rate from annulus to string which caused by head difference at two sides of U-tube [gpm] - REAL :: PressureDp ! pressure at bit or end of drill string from drill string path [psi] - REAL :: PressureAnn ! pressure at bit or end of drill string from annular path [psi] - - END MODULE - - SUBROUTINE DeallocateFlowTypes - - USE FricPressDropVarsModule - use PressureDisplayVARIABLESModule - use KickVARIABLESModule - - IMPLICIT NONE - - - IF (ALLOCATED(FlowEl)) DEALLOCATE(FlowEl) - IF (ALLOCATED(FinalFlowEl)) DEALLOCATE(FinalFlowEl) - IF (ALLOCATED(GasPocketWeight%Array)) CALL GasPocketWeight%Empty() - IF (ALLOCATED(GasPocketNewPress%Array)) CALL GasPocketNewPress%Empty() - IF (ALLOCATED(GasPocketOldPress%Array)) CALL GasPocketOldPress%Empty() - IF (ALLOCATED(GasPocketNewTemp%Array)) CALL GasPocketNewTemp%Empty() - IF (ALLOCATED(GasPocketOldTemp%Array)) CALL GasPocketOldTemp%Empty() - IF (ALLOCATED(GasPocketNewVol%Array)) CALL GasPocketNewVol%Empty() - IF (ALLOCATED(GasPocketOldVol%Array)) CALL GasPocketOldVol%Empty() - IF (ALLOCATED(GasPocketdeltaVol%Array)) CALL GasPocketdeltaVol%Empty() - IF (ALLOCATED(GasPocketModifiedVol%Array)) CALL GasPocketModifiedVol%Empty() - IF (ALLOCATED(GasPocketFlowInduced%Array)) CALL GasPocketFlowInduced%Empty() - IF (ALLOCATED(GasPocketDensity%Array)) CALL GasPocketDensity%Empty() - IF (ALLOCATED(GasPocketCompressibility%Array)) CALL GasPocketCompressibility%Empty() - IF (ALLOCATED(GasPocketFlowEl)) DEALLOCATE(GasPocketFlowEl) - IF (ALLOCATED(KickJacobian)) DEALLOCATE(KickJacobian) - IF (ALLOCATED(OldKickJacobian)) DEALLOCATE(OldKickJacobian) - IF (ALLOCATED(KickVandPFunction)) DEALLOCATE(KickVandPFunction) - IF (ALLOCATED(KickUnknownVector)) DEALLOCATE(KickUnknownVector) - IF (ALLOCATED(KickCorrectionVector)) DEALLOCATE(KickCorrectionVector) - - - END SUBROUTINE - \ No newline at end of file diff --git a/FluidFlow-old/String_Property_Calculator.f90 b/FluidFlow-old/String_Property_Calculator.f90 deleted file mode 100644 index cdd609a..0000000 --- a/FluidFlow-old/String_Property_Calculator.f90 +++ /dev/null @@ -1,31 +0,0 @@ -SUBROUTINE StringPropertyCalculator (md, den, pre, tem) - - !!! This subroutine gets location of a guage or an observation point and determines information of that point such as pressure, density, velocity and temperature later. - use PressureDisplayVARIABLESModule - USE Fluid_Flow_Startup_Vars - !USE MudSystemVARIABLES - USE FricPressDropVarsModule - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure - !USE CDataDisplayConsoleVariables , CasingPressureDataDisplay=>CasingPressure!, StandPipePressureDataDisplay=>StandPipePressure - USE CDrillWatchVariables - - IMPLICIT NONE - INTEGER, intent(in) :: md ! input - REAL(8) :: TVD - real(8), intent(inout) :: den ! output - real(8), intent(inout) :: pre ! output - real(8), intent(inout) :: tem ! output - - INTEGER :: ilocal - - CALL TVD_Calculator(md * 1.d0 , TVD) - - DO ilocal = StringFirstEl , StringLastEl - IF (md < INT(FinalFlowEl(ilocal)%EndX)) EXIT - END DO - den = FinalFlowEl(ilocal)%Density - pre = FinalFlowEl(ilocal)%StartPress - (md - FinalFlowEl(ilocal)%StartX) * FinalFlowEl(ilocal)%dPdLfric & - + (TVD - FinalFlowEl(ilocal)%StartTVD) * FinalFlowEl(ilocal)%dPdLGrav - tem = 500 - - END SUBROUTINE \ No newline at end of file diff --git a/FluidFlow-old/Utube.f90 b/FluidFlow-old/Utube.f90 deleted file mode 100644 index 5d4167a..0000000 --- a/FluidFlow-old/Utube.f90 +++ /dev/null @@ -1,117 +0,0 @@ -SUBROUTINE Utube - - !! This subroutine calculates flow rate when pump is off, pump is disconnected from drill pipe - !! and both annulus and drill pipe are exposed to atmosphere pressure and thus a U-tube situation is occurs - - !! Record of revisions - !! Date Programmer Discription of change - !! ------ ------------ ----------------------- - !! 1396/07/29 Sheikh Original code - !! 1396/08/09 Sheikh Two-side U-tube - !! - - USE FricPressDropVarsModule - USE MudSystemVARIABLES - use UTUBEVARSModule - USE Fluid_Flow_Startup_Vars - - IMPLICIT NONE - - - - INTEGER :: i ,j, ibit , ij , ijk - REAL :: AreaBeforeBit !!! Area of element before bit in U-Tube condition [in^2] - - QUTubeInput = 1.0 - QUTubeOutput = 1.0 - TotFricPressLoss = 0 - BitPressLoss = 0 - PressureDp = 0 - PressureAnn = 0 -!!!!!!!!!!!!!!!!!!!!!! Bit -!!!!!!!!!!!! Calculating Pressure at the bottom of drill string from mud columns in drill pipes and annulus space - - PressureDp = SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) - - PressureAnn = SUM(FlowEl(AnnulusFirstEl : AnnulusLastEl)%StaticPressDiff) -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!!!!!!!!!!!! U tube:: flow from string to annulus - IF ((PressureDp - PressureAnn) > UTubePressTolerance) THEN - DO ijk = 1 , 10 - FlowEl(StringFirstEl : AnnulusLastEl)%Flowrate = QUTubeInput - !WRITE (*,*) 'QUTubeInput', FlowEl(AnnulusLastEl)%Flowrate - DO ij = StringFirstEl , AnnulusLastEl !!!!! Updating values of flowrates - CALL FricPressDrop(ij) - CALL PartialDerivativeFricToFlowRate(ij) - !WRITE (*,*) 'FricPressDrop, PartialDerivative', FlowEl(ij)%FricPressLoss, FlowEl(ij)%FricToQPartialDiff, FlowEl(ij)%Length - END DO - - !!!!!!!!!!!!!! Bit pressure drop calculation - IF (BitTrue) THEN - i = NoHorizontalEl + NoStringEl - AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2 - BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2 - END IF - - !!!!!!!!!!!!!!!!!!!!!!!!!!! - i = NoHorizontalEl + 1 - j = NoHorizontalEl + NoStringEl + NoAnnulusEl - !IF (ALLOCATED(FlowEl)) THEN - ! WRITE (*,*) ' H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl - !END IF - - TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss - IF (ABS((PressureDp - PressureAnn) - TotFricPressLoss) <= UTubePressTolerance .OR. QUTubeInput < 1.0) EXIT ! tolerance set to 1.0 psi - IF ((PressureDp - PressureAnn) > TotFricPressLoss) THEN - QUTubeInput = QUTubeInput + ((PressureDp - PressureAnn) - TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) - ELSE IF ((PressureDp - PressureAnn) < TotFricPressLoss) THEN - QUTubeInput = QUTubeInput + ((PressureDp - PressureAnn) - TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) - END IF - !WRITE (*,*) 'QUTubeInput, TotFricPressLoss', QUTubeInput, TotFricPressLoss - !WRITE (*,*) '1) PressureDp, PressureAnn', PressureDp, PressureAnn, TotFricPressLoss, QUTubeInput - - END DO - QUTubeOutput = 0.0 -!!!!!!!!!!!!!!!!!!!!!!!! -!!!!!!!!!!!! U tube:: flow from annulus to string - ELSE IF ((PressureAnn - PressureDp) > UTubePressTolerance) THEN - DO ijk = 1 , 10 - DO ij = NoHorizontalEl + 1 , NoHorizontalEl + NoStringEl + NoAnnulusEl !!!!! Updating values of flowrates - FlowEl(ij)%Flowrate = QUTubeOutput - CALL FricPressDrop(ij) - CALL PartialDerivativeFricToFlowRate(ij) - END DO - - !!!!!!!!!!!!!! Bit pressure drop calculation - IF (BitTrue) THEN - !DO i = NumbEl , 1 , -1 !! This loop starts from the first elements of string and check the elements to reach the bit at the bottom of string - ! IF (FlowEl(i)%Id==0) CYCLE - i = NoHorizontalEl + NoStringEl + 1 - AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2 - BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2 - !IF (FlowEl(i)%Id>0) EXIT - !END DO - END IF - !!!!!!!!!!!!!!!!!!!!!!!!!!! - i = NoHorizontalEl + 1 - j = NoHorizontalEl + NoStringEl + NoAnnulusEl - TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss - - IF (ABS((PressureDp - PressureAnn) - TotFricPressLoss) <= UTubePressTolerance) EXIT ! tolerance set to 1.0 psi - IF ((PressureAnn - PressureDp) > TotFricPressLoss) THEN - QUTubeOutput = QUTubeOutput - (((PressureAnn - PressureDp) - TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) - ELSE IF ((PressureAnn - PressureDp) < TotFricPressLoss) THEN - QUTubeOutput = QUTubeOutput + (((PressureAnn - PressureDp) - TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) - END IF - !WRITE (*,*) 'QUTubeOutput, TotFricPressLoss', QUTubeOutput, TotFricPressLoss - - WRITE (*,*) '2) PressureDp, PressureAnn', PressureDp, PressureAnn, TotFricPressLoss - END DO - QUTubeInput = 0.0 -!!!!!!!!!!!! No U-Tube - ELSE - QUTubeInput = 0.0 - QUTubeOutput = 0.0 - END IF - -END SUBROUTINE \ No newline at end of file diff --git a/FluidFlow-old/Well_Pressure_Data_Transfer.f90 b/FluidFlow-old/Well_Pressure_Data_Transfer.f90 deleted file mode 100644 index b07a903..0000000 --- a/FluidFlow-old/Well_Pressure_Data_Transfer.f90 +++ /dev/null @@ -1,775 +0,0 @@ -SUBROUTINE WellPressureDataTransfer - - !! This subroutine calculates pressure distribution in well - !! We divide well hydraulic system to 4 zones. 1- pump to string zone; this zone is horizontal - !! 2- string zone; this zone includes drill pipes and collars and is vertical or neraly vertical - !! 3- annulus zone; this zone includes annulus space between string and openhole or casing - !! 4- Openhole zone; this zone includes spaces under bit to bottom of the wellbore - !! The last two zone includes annulus space and open hole, are influenced by kicks and have crucial role in - !! computing pressure distribution because reference point (back pressure in well head open condition - !! and bottomhole pressure in well head closed condition) are in one of them. because of this, pressure - !! distribution calculates in two subroutines : PressureAnnAndOHDistribution and PressurePumptoBitDistribution - !! pressure change through well consist of pressure change due to friction, change of elevation and acceleration - !! frictional pressure drop calculated by subroutine Sub_Press_Drop_Calculator - !! This subroutine includes hydrostatic pressure and later will include effect of corss-section area change - !! which causes acceleration or decceleration of flow - Use ConfigurationVariables - USE FricPressDropVarsModule - use MudSystemModule - USE MudSystemVARIABLES - USE GeoElements_FluidModule - USE Fluid_Flow_Startup_Vars - use KickVARIABLESModule - USE CMudPropertiesVariables - USE CBopStackVariables - USE sROP_Variables - USE CHOKEVARIABLES, PI2 => PI - USE CChokeManifoldVariables - USE CBitProblemsVariables - USE CChokeProblemsVariables - USE CStringConfigurationVariables - USE CDrillWatchVariables - USE CDataDisplayConsoleVariables - - - IMPLICIT NONE - - INTEGER :: i , j - REAL :: InstantaneousTotalOpenChokeArea , VolumeDensityProduct - - ChokeIsClosing = .FALSE. - Kchoke = 0.0 - KBit = 0.0 - - - !!!!!!!!!!!!!!!! bit is present - BitTrue = Configuration%StringConfiguration%StringConfigurations(1)%ComponentType == Bit_ComponentType ! Bit_ComponentType = 0 - BitCd = 0.98 - BitNozzDia = 32.0 * Configuration%StringConfiguration%BitDefinition%BitNozzleSize ! nozzle diameter in 1/32 in - BitNozzleArea = 7.6699E-4 * BitNozzDia**2 - BitNozzleNum = Configuration%StringConfiguration%BitDefinition%BitNozzleNo - BitJetsPlugged * BitProblems%PlugJetsCount - BitTotNozzArea = BitNozzleNum * BitNozzleArea + 0.5 * BitJetsWashedOut * BitProblems%JetWashoutCount * BitNozzleArea - IF (BitNozzleNum == 0) THEN - BitTotallyPluged = .TRUE. - ELSE - BitTotallyPluged = .FALSE. - END IF - - FloatValveIn = Configuration%StringConfiguration%BitDefinition%FloatValve - !FloatValveOpen = .TRUE. - !IF (JetWashoutCount > 0 .OR. PlugJetsCount > 0) THEN - ! WRITE (*,*) 'PlugJetsCount' , PlugJetsCount - ! WRITE (*,*) 'JetWashoutCount', JetWashoutCount - !END IF - - !WRITE (*,*) 'BitNozzleNum', BitNozzleNum - !WRITE (*,*) 'BitTotNozzArea', BitTotNozzArea - !WRITE (*,*) 'Float Valve??', BitDefinition%FloatValve - - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - IF(ALLOCATED(GasPocketFlowEl)) DEALLOCATE(GasPocketFlowEl) - -!!!!!!!!!!!!!!!!!!!! Well Head Condition ( Open or Closed ) - ChokeKroneckerDelta = 0 - - - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN - - WellHeadOpen = .FALSE. - !WRITE (*,*) ' Well Head is closed ' - ELSE - WellHeadOpen = .TRUE. - END IF - - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen) ChokeKroneckerDelta = 1 - !WRITE (*,*) ' WelltoPitsOpen=' , WelltoPitsOpen, 'WellToChokeManifoldOpen= ' , WellToChokeManifoldOpen - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - - NoHorizontalEl = MudSystem%NoHorizontalMudElements - NoStringEl = MudSystem%NoStringMudElements - NoAnnulusEl = MudSystem%NoCasingMudElements - NoWellToChokeEl = 0 - IF (ChokeKroneckerDelta == 1) NoWellToChokeEl = MudSystem%ChokeLine_Density%Length() - NoOpenHoleEl = MudSystem%NoBottomHoleMudElements - NumbEl = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWellToChokeEl + NoOpenHoleEl - !WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , NoStringEl , NoAnnulusEl , NoWellToChokeEl , NoOpenHoleEl - IF(ALLOCATED(FlowEl)) DEALLOCATE(FlowEl) - ALLOCATE(FlowEl(NumbEl)) - - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Transfering Data from module:MudSystemVARIABLES to module:FricPressDropVars to calculate Pressure distribution in flow path - !!!!!!!!!!!!!!!!!!!!!!! Horizontal line - !WRITE (*,*) 'H', NoHorizontalEl - DO i = 1 , NoHorizontalEl - FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) - FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) - FlowEl(i)%StartTVD = 0.d0 - FlowEl(i)%EndTVD = 0.d0 - FlowEl(i)%Id = 0.0 - FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) - FlowEl(i)%density = MudSystem%Density_MudElement%Array(i) - - FlowEl(i)%Dhyd = FlowEl(i)%Od - FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) - FlowEl(i)%DepthDiff = 0.d0 - FlowEl(i)%Volume = PI / 4.0 * FlowEl(i)%Od**2 * REAL(FlowEl(i)%Length) / Convfttoinch**2 - IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air - FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN - FlowEl(i)%MaterialType = 4 - ELSE - FlowEl(i)%MaterialType = 1 - END IF - - FlowEl(i)%dPdLgrav = 0.0 - FlowEl(i)%StaticPressDiff = 0.0 - - !WRITE (*,*) 'H density, length, Type of ith element' , i, FlowEl(i)%density , FlowEl(i)%length, FlowEl(i)%MaterialType - - - END DO - !WRITE (*,*) 'inlet and outlet mud theta600' , FlowEl(1)%Theta600 , FlowEl(NumbEl)%Theta600 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!! String - !WRITE (*,*) 'S', NoStringEl - StringFirstEl = NoHorizontalEl + 1 - StringLastEl = NoHorizontalEl + NoStringEl - DO i = NoHorizontalEl + 1 , NoHorizontalEl + NoStringEl - !WRITE (*,*) 'ST , i' , i - FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) - !WRITE (*,*) 'StartX', FlowEl(i)%StartX - FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) - !WRITE (*,*) 'EndX', FlowEl(i)%EndX - FlowEl(i)%StartTVD = MudSystem%TVDstart_MudElement%Array(i) - !WRITE (*,*) 'StartTVD', FlowEl(i)%StartTVD - FlowEl(i)%EndTVD = MudSystem%TVDend_MudElement%Array(i) - !WRITE (*,*) 'EndTVD', FlowEl(i)%EndTVD - FlowEl(i)%Id = 0.0 - !WRITE (*,*) 'Id', FlowEl(i)%Id - FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) - !WRITE (*,*) 'Od', FlowEl(i)%Od - FlowEl(i)%Density = MudSystem%Density_MudElement%Array(i) - !WRITE (*,*) 'Density', FlowEl(i)%Density - - - FlowEl(i)%Dhyd = FlowEl(i)%Od - FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) - !WRITE (*,*) 'Length', FlowEl(i)%Length - FlowEl(i)%DepthDiff = ABS(FlowEl(i)%StartTVD - FlowEl(i)%EndTVD) - !WRITE (*,*) 'DepthDiff', FlowEl(i)%DepthDiff - FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 - FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air - FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN - FlowEl(i)%MaterialType = 4 - ELSE - FlowEl(i)%MaterialType = 1 - END IF - - IF (FlowEl(i)%MaterialType == 1 .OR. FlowEl(i)%MaterialType == 4) THEN - FlowEl(i)%dPdLgrav = 0.0 - ELSE - FlowEl(i)%dPdLgrav = 0.052 * FlowEl(i)%Density - END IF - FlowEl(i)%StaticPressDiff = FlowEl(i)%dPdLgrav * REAL(FlowEl(i)%DepthDiff) - - !WRITE (*,*) 'S density, length, DeltaPStatic' , i, FlowEl(i)%density , FlowEl(i)%length, FlowEl(i)%StaticPressDiff, FlowEl(i)%MaterialType - - - - END DO - !WRITE (*,*) 'inlet and outlet mud theta600' , FlowEl(1)%Theta600 , FlowEl(NumbEl)%Theta600 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!!!!! Annulus - !WRITE (*,*) 'A', NoAnnulusEl - AnnulusFirstEl = NoHorizontalEl + NoStringEl + 1 - AnnulusLastEl = NoHorizontalEl + NoStringEl + NoAnnulusEl - DO i = NoHorizontalEl + NoStringEl + 1 , NoHorizontalEl + NoStringEl + NoAnnulusEl - FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) - FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) - FlowEl(i)%StartTVD = MudSystem%TVDstart_MudElement%Array(i) - FlowEl(i)%EndTVD = MudSystem%TVDend_MudElement%Array(i) - FlowEl(i)%Id = MudSystem%PipeID_MudElement%Array(i) - FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) - FlowEl(i)%Density = MudSystem%Density_MudElement%Array(i) - - FlowEl(i)%Dhyd = FlowEl(i)%Od - FlowEl(i)%Id - FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) - FlowEl(i)%DepthDiff = ABS(FlowEl(i)%StartTVD - FlowEl(i)%EndTVD) - FlowEl(i)%Area = PI / 4.0 * (FlowEl(i)%Od**2 - FlowEl(i)%Id**2) / Convfttoinch**2 - FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air - FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN - FlowEl(i)%MaterialType = 4 - ELSE - FlowEl(i)%MaterialType = 1 - END IF - - IF (FlowEl(i)%MaterialType == 1 .OR. FlowEl(i)%MaterialType == 4) THEN - FlowEl(i)%dPdLgrav = 0.0 - ELSE - FlowEl(i)%dPdLgrav = 0.052 * FlowEl(i)%density - END IF - FlowEl(i)%StaticPressDiff = FlowEl(i)%dPdLgrav * REAL(FlowEl(i)%DepthDiff) - - !WRITE (*,*) 'A density, length, Type of ith element' , i, FlowEl(i)%density , FlowEl(i)%length, FlowEl(i)%MaterialType - - - END DO - !WRITE (*,*) 'inlet and outlet mud theta600' , FlowEl(1)%Theta600 , FlowEl(NumbEl)%Theta600 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!! Well to choke manifold path - !ChokeFirstEl = AnnulusLastEl + 1 - !ChokeLastEl = OpenholeFirstEl - 1 - j = 1 - DO i = NoHorizontalEl + NoStringEl + NoAnnulusEl + 1 , NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWelltoChokeEl - FlowEl(i)%StartX = MudSystem%ChokeLine_Mud_Backhead_X%Array(j) - FlowEl(i)%EndX = MudSystem%ChokeLine_Mud_Forehead_X%Array(j) - FlowEl(i)%StartTVD = 0.d0 - FlowEl(i)%EndTVD = 0.d0 - FlowEl(i)%Id = 0.0 - FlowEl(i)%Od = BopStackSpecification%ChokeLineId - FlowEl(i)%density = MudSystem%ChokeLine_Density%Array(j) - - FlowEl(i)%Dhyd = FlowEl(i)%Od - FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) - FlowEl(i)%DepthDiff = 0.d0 - FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 - FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%ChokeLine_MudOrKick%Array(j) == 0 .OR. MudSystem%ChokeLine_MudOrKick%Array(j) == 4) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air - FlowEl(i)%MaterialType = MudSystem%ChokeLine_MudOrKick%Array(j) - ELSE - FlowEl(i)%MaterialType = 1 - END IF - - - FlowEl(i)%dPdLgrav = 0.0 - FlowEl(i)%StaticPressDiff = 0.0 - - !WRITE (*,*) 'Ch density, length, Type' , i, FlowEl(i)%density , FlowEl(i)%length, FlowEl(i)%MaterialType - - j = j + 1 - - END DO - - !WRITE (*,*) 'inlet and outlet mud theta600' , FlowEl(1)%Theta600 , FlowEl(NumbEl)%Theta600 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!! Open Hole - OpenholeFirstEl = NoHorizontalEl + NoStringEl + NoAnnulusEl + NoWelltoChokeEl + 1 - j = 1 - DO i = OpenholeFirstEl , NumbEl ! = NoHorizontalEl + NoStringEl + NoCasingEl + NoOpenHoleEl - FlowEl(i)%StartX = MudSystem%Xstart_OpMudElement%Array(j) - FlowEl(i)%EndX = MudSystem%Xend_OpMudElement%Array(j) - FlowEl(i)%StartTVD = MudSystem%TVDstart_OpMudElement%Array(j) - FlowEl(i)%EndTVD = MudSystem%TVDend_OpMudElement%Array(j) - FlowEl(i)%Id = 0.0 - FlowEl(i)%Od = MudSystem%PipeOD_OpMudElement%Array(j) - FlowEl(i)%density = MudSystem%Density_OpMudElement%Array(j) - FlowEl(i)%MaterialType = MudSystem%MudTypeOp_MudElement%Array(j) ! = 0 for mud, = 1 for gas kick, = 4 for air - - FlowEl(i)%Dhyd = FlowEl(i)%Od - FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) - FlowEl(i)%DepthDiff = ABS(FlowEl(i)%StartTVD - FlowEl(i)%EndTVD) - FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 - FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%MudTypeOp_MudElement%Array(j) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air - FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudTypeOp_MudElement%Array(j) == 4) THEN - FlowEl(i)%MaterialType = 4 - ELSE - FlowEl(i)%MaterialType = 1 - END IF - - j = j + 1 - IF (FlowEl(i)%MaterialType == 1) THEN - FlowEl(i)%dPdLgrav = 0.0 - ELSE - FlowEl(i)%dPdLgrav = 0.052 * FlowEl(i)%density - END IF - FlowEl(i)%StaticPressDiff = FlowEl(i)%dPdLgrav * REAL(FlowEl(i)%DepthDiff) - - !WRITE (*,*) 'O density, length, Type of ith element' , i, FlowEl(i)%density , FlowEl(i)%length, FlowEl(i)%MaterialType - - END DO - !WRITE (*,*) 'inlet and outlet mud theta600' , FlowEl(1)%Theta600 , FlowEl(NumbEl)%Theta600 - - !DO i = NoHorizontalEl + 1, NoHorizontalEl + NoStringEl - ! WRITE (*,*) 'element No, Start , Length, DeltaPSt', i, FlowEl(i)%StartX, FlowEl(i)%Length, FlowEl(i)%StaticPressDiff - !END DO -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -!!!!!!!!!!!!!!!!!! Mud Element Viscosity Calculation - - DO i = 1 , NumbEl - IF (FlowEl(i)%MaterialType /= 0) CYCLE - IF (FlowEl(i)%density < 8.33) THEN - WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , StringFirstEl , AnnulusFirstEl , NoWellToChokeEl , OpenHoleFirstEl - - WRITE (*,*) 'Element No, Volume(gal), Density(ppg), Type' - DO j = 1 , NumbEl - WRITE (*,*) j, FlowEl(j)%Volume * ConvFt3toUSGal , FlowEl(j)%Density, FlowEl(j)%MaterialType - END DO - - CALL ErrorStop('Density below water density (8.33)', i) - CYCLE - END IF - - FlowEl(i)%Theta600 = Theta600Refrence + 11.0 * (MAX(FlowEl(i)%density , 8.33) - DensityRefrence) - FlowEl(i)%Theta300 = Theta300Refrence + 6.0 * (MAX(FlowEl(i)%density , 8.33) - DensityRefrence) - !WRITE (*,*) 'i, Theta600, Theta600', i, FlowEl(i)%Theta600, FlowEl(i)%Theta300 - END DO -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - - FlowEl(:)%FlowRate = 0.0 - FlowEl(:)%StartPress = 0.0 - FlowEl(:)%EndPress = 0.0 - - !WRITE (*,*) 'NoGasPocket=' , SIZE(GasPocketWeight%Array) - - - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - MudSystem%OpenArea32 = ((ChokeManifold%LeftManualChoke * (1.0 - ManChoke1Plug * REAL(ChokeProblems%ManualChoke1PluggedPercent)) / 100.0) + 0.5 * ManChoke1Washout) * Choke%ChokeAreaFullyOpen - MudSystem%OpenArea33 = CHOOKE(1)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(1)%PercentClose) * ChokeAreaFullyOpen - MudSystem%OpenArea34 = CHOOKE(2)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(2)%PercentClose) * ChokeAreaFullyOpen - MudSystem%OpenArea35 = ((ChokeManifold%RightManualChoke * (1.0 - ManChoke2Plug * REAL(ChokeProblems%ManualChoke2PluggedPercent)) / 100.0) + 0.5 * ManChoke2Washout) * Choke%ChokeAreaFullyOpen - !write(*,*) 'OpenArea32=' , OpenArea32, active32, ManChoke1Plug, ManualChoke1PluggedPercent, ManChoke1Washout - !write(*,*) 'OpenArea33=' , OpenArea33, active33 - !write(*,*) 'OpenArea34=' , OpenArea34, active34, !HydraulicChoke2PluggedPercent - !write(*,*) 'OpenArea35=' , OpenArea35, active35, ManChoke2Plug, ManualChoke2PluggedPercent, ManChoke2Washout - InstantaneousTotalOpenChokeArea = MudSystem%OpenArea32 * active32 + MudSystem%OpenArea33 * active33 + MudSystem%OpenArea34 * active34 + MudSystem%OpenArea35 * active35 + ChokeBypassArea * active29 - OldTotalOpenChokeArea = TotalOpenChokeArea - !WRITE (*,*) 'Instantaneous / Old TotalOpenChokeArea', InstantaneousTotalOpenChokeArea, OldTotalOpenChokeArea - IF (OldTotalOpenChokeArea <= 0.01 * Choke%ChokeAreaFullyOpen) OldTotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen - IF (InstantaneousTotalOpenChokeArea <= 0.01 * Choke%ChokeAreaFullyOpen) THEN - MudSystem%WellToChokeManifoldOpen = .FALSE. - OldTotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen - !WRITE (*,*) ' Choke Controler Here 2' - - ELSE IF (InstantaneousTotalOpenChokeArea > 0.5 * Choke%ChokeAreaFullyOpen .OR. MudSystem%WellToPitsOpen) THEN - ! mud flows through well to bell nipple, or choke is rather open - TotalOpenChokeArea = InstantaneousTotalOpenChokeArea - !WRITE (*,*) ' Choke Controler Here 1' - ELSE - IF (InstantaneousTotalOpenChokeArea > OldTotalOpenChokeArea) THEN - TotalOpenChokeArea = MIN(1.1 * OldTotalOpenChokeArea , InstantaneousTotalOpenChokeArea) - WRITE (*,*) ' Choke is opening' !, TotalOpenChokeArea, OldTotalOpenChokeArea, InstantaneousTotalOpenChokeArea - ELSE IF (InstantaneousTotalOpenChokeArea < OldTotalOpenChokeArea) THEN - TotalOpenChokeArea = MAX(0.9 * OldTotalOpenChokeArea , InstantaneousTotalOpenChokeArea) - WRITE (*,*) ' Choke is closing' !, TotalOpenChokeArea, OldTotalOpenChokeArea, InstantaneousTotalOpenChokeArea - !ExitMass = 0.1 * ExitMass ! for decreasing mass exit due to expansion - ELSE - TotalOpenChokeArea = InstantaneousTotalOpenChokeArea - END IF - END IF - !WRITE (*,*) 'TotalOpenChokeArea=', TotalOpenChokeArea - - - - - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -!!!!!!!!!!!!!!!!!!!! Well Head Condition ( Open or Closed ) - ChokeKroneckerDelta = 0 - !WRITE (*,*) ' WelltoPitsOpen = ', WelltoPitsOpen - !WRITE (*,*) ' WellToChokeManifoldOpen = ', WellToChokeManifoldOpen - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN - !WRITE (*,*) ' WelltoPitsOpen = ', WelltoPitsOpen - !WRITE (*,*) ' WellToChokeManifoldOpen = ', WellToChokeManifoldOpen - - WellHeadOpen = .FALSE. - !WRITE (*,*) ' Well Head is closed ' - ELSE - WellHeadOpen = .TRUE. - END IF - - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen) ChokeKroneckerDelta = 1 - !WRITE (*,*) ' WelltoPitsOpen=' , WelltoPitsOpen, 'WellToChokeManifoldOpen= ' , WellToChokeManifoldOpen - !WRITE (*,*) 'WellToChokeOpen , WellToChokeWasOpen', WellToChokeManifoldOpen, WellToChokeManifoldWasOpen -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - IF (NoGasPocket > 0) THEN - !IF (NoWelltoChokeEl > 0 .AND. (FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .OR. KickWasExitingThroughChoke) .AND. WellHeadOpen) THEN - IF (MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0) THEN - !WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', Choke_Kick_Saved_Volume_Final, (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal) - ExitMass = REAL(MudSystem%Choke_Kick_Saved_Volume_Final / (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal)) * GasPocketWeight%Array(NoGasPocket) - !IF (NoGasPocket > 1) ExitMass = ExitMass + (SUM(GasPocketDeltaVol%Array(1 : NoGasPocket - 1)) / GasPocketNewVol%Array(NoGasPocket)) * GasPocketWeight%Array(NoGasPocket) - !WRITE (*,*) 'Total Exit mass=' , ExitMass !, DeltaVolumePipe, MudSystem%StringFlowRate * dt / ConvMinToSec - IF (FlowEl(OpenholeFirstEl - 1)%MaterialType /= 1) THEN - CALL RemoveGasPocket(NoGasPocket) - WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', MudSystem%Choke_Kick_Saved_Volume_Final - END IF - - END IF - - - !NoGasPocket = SIZE(GasPocketWeight%Array) - IF (NoGasPocket > 0) CALL GasPocketFlowElementTransformer - END IF - - IF (NoWelltoChokeEl > 0) THEN - OldChokeDensity = ChokeDensity - !ChokeDensity = SUM(FlowEl(AnnulusLastEl + 1 : OpenholeFirstEl - 1)%Density * FlowEl(AnnulusLastEl + 1 : OpenholeFirstEl - 1)%Volume) / SUM(FlowEl(AnnulusLastEl + 1 : OpenholeFirstEl - 1)%Volume) - !ChokeDensity = MAX(ChokeDensity , ChokeMinDensity) - VolumeDensityProduct = 0.0 - Do i = AnnulusLastEl + 1 , OpenholeFirstEl - 1 - VolumeDensityProduct = VolumeDensityProduct + ((MAX(FlowEl(i)%Density , ChokeMinDensity)) * FlowEl(i)%Volume) - End Do - ChokeDensity = VolumeDensityProduct / SUM(FlowEl(AnnulusLastEl + 1 : OpenholeFirstEl - 1)%Volume) - - !IF ((ChokeDensity - OldChokeDensity) > (MaxChokeDensityChange * dt / Convmintosec)) THEN - ! ChokeDensity = OldChokeDensity + (MaxChokeDensityChange * dt / Convmintosec) - !ELSE IF ((OldChokeDensity - ChokeDensity) > (MaxChokeDensityChange * dt / Convmintosec)) THEN - ! ChokeDensity = OldChokeDensity - (MaxChokeDensityChange * dt / Convmintosec) - !END IF - - !WRITE (*,*) 'ChokeDensity=', ChokeDensity - Kchoke = (ChokeDensity / ((2.0 * 89158.0) * (0.26 * 0.61 * TotalOpenChokeArea)**2)) * 4.d0 ! *4.d0: seyyed gofte - END IF - - IF (BitTotallyPluged == .FALSE.) THEN - KBit = FlowEl(StringLastEl)%density / 12042.0 / BitCd**2 / BitTotNozzArea**2 - END IF - - - -END SUBROUTINE WellPressureDataTransfer - - -SUBROUTINE GasPocketFlowElementTransformer - - !! This Subroutine makes relationship between fluid flow elements and gas pocket elements - !! The main variable of this subroutine is GasPocketFlowEl - !! For each gas pocket, GasPocketFlowEl has a row, which columns are numbers of flow elements which are contains that gas pocket - !! For example, if we have two gas pockets and they are in (7,8) and (12,3,4) flow elements respectively, - !! GasPocketFlowEl(1,:) = [12 , 3 , 4] and GasPocketFlowEl(2,:) = [7 , 8 , 0] - - - USE FricPressDropVarsModule - USE MudSystemVARIABLES - USE GeoElements_FluidModule - USE Fluid_Flow_Startup_Vars - use KickVARIABLESModule - USE CMudPropertiesVariables - USE CBopStackVariables - USE CDownHoleVariables - USE CError - - IMPLICIT NONE - - INTEGER :: i , j , k - REAL :: PressureCorrection - PressureCorrection = 1.0 - - ALLOCATE(GasPocketFlowEl(NoGasPocket , 1)) - GasPocketFlowEl(:,:) = 0 - !WRITE (*,*) 'NoGasPocket=' , NoGasPocket - - i = 1 - j = 1 - DO k = OpenholeFirstEl , NumbEl - IF (FlowEl(k)%MaterialType == 1) THEN - IF (j > 1) THEN - IF (GasPocketFlowEl(i , j - 1) /= k - 1) THEN - i = i + 1 - j = 1 - END IF - END IF - - IF (SIZE(GasPocketFlowEl , dim = 2) < j) THEN - ALLOCATE(tempGasPocketFlowEl(SIZE(GasPocketFlowEl , dim = 1) , SIZE(GasPocketFlowEl , dim = 2))) - tempGasPocketFlowEl = GasPocketFlowEl - DEALLOCATE(GasPocketFlowEl) - ALLOCATE(GasPocketFlowEl(SIZE(tempGasPocketFlowEl , dim = 1) , SIZE(tempGasPocketFlowEl , dim = 2) + 1)) - GasPocketFlowEl(: , 1 : SIZE(tempGasPocketFlowEl , dim = 2)) = tempGasPocketFlowEl - GasPocketFlowEl(: , SIZE(GasPocketFlowEl , dim = 2)) = 0 - DEALLOCATE(tempGasPocketFlowEl) - END IF - - GasPocketFlowEl(i , j) = k - j = j + 1 - END IF - END DO - !WRITE (*,*) 'GasPocketFlowEl=' , GasPocketFlowEl - - DO k = AnnulusFirstEl , OpenholeFirstEl - 1 - IF (FlowEl(k)%MaterialType == 1) THEN - IF (j > 1) THEN - IF (k == AnnulusFirstEl .AND. GasPocketFlowEl(i , j - 1) == NumbEl) THEN - !WRITE (*,*) 'Kick is Around Bit' - ELSE IF (GasPocketFlowEl(i , j - 1) /= k - 1) THEN - i = i + 1 - j = 1 - !WRITE (*,*) 'i, j, k', i, j, k, FlowEl(k)%MaterialType - END IF - END IF - - IF (j > SIZE(GasPocketFlowEl , dim = 2)) THEN - ALLOCATE(tempGasPocketFlowEl(SIZE(GasPocketFlowEl , dim = 1) , SIZE(GasPocketFlowEl , dim = 2))) - tempGasPocketFlowEl = GasPocketFlowEl - DEALLOCATE(GasPocketFlowEl) - ALLOCATE(GasPocketFlowEl(SIZE(tempGasPocketFlowEl , dim = 1) , SIZE(tempGasPocketFlowEl , dim = 2) + 1)) - GasPocketFlowEl(: , 1 : SIZE(tempGasPocketFlowEl , dim = 2)) = tempGasPocketFlowEl - GasPocketFlowEl(: , SIZE(GasPocketFlowEl , dim = 2)) = 0 - DEALLOCATE(tempGasPocketFlowEl) - END IF - IF (i > NoGasPocket) THEN - WRITE (*,*) 'GasPocketFlowEl', GasPocketFlowEl - WRITE (*,*) 'i , j , k', i, j, k - WRITE (*,*) 'H, S, A, Ch, O', NoHorizontalEl , StringFirstEl , AnnulusFirstEl , NoWellToChokeEl , OpenHoleFirstEl - - WRITE (*,*) 'Element No, Volume(gal), Density(ppg), Type' - DO j = 1 , NumbEl - WRITE (*,*) j, FlowEl(j)%Volume * ConvFt3toUSGal , FlowEl(j)%Density, FlowEl(j)%MaterialType - END DO - !WRITE (*,*) 'Op Last: Volume(gal), Type', NumbEl, FlowEl(NumbEl)%Volume * ConvFt3ToUSgal , FlowEl(NumbEl)%MaterialType - !WRITE (*,*) 'Ann First: Volume(gal), Type', AnnulusFirstEl, FlowEl(AnnulusFirstEl)%Volume * ConvFt3ToUSgal , FlowEl(AnnulusFirstEl)%MaterialType - !IF (ChokeKroneckerDelta == 1) THEN - ! WRITE (*,*) 'Ann Last: Volume(gal), Type', AnnulusLastEl, FlowEl(AnnulusLastEl)%Volume * ConvFt3ToUSgal , FlowEl(AnnulusLastEl)%MaterialType - ! WRITE (*,*) 'Ch First: Volume(gal), Type', AnnulusLastEl + 1 , FlowEl(AnnulusLastEl + 1)%Volume * ConvFt3ToUSgal , FlowEl(AnnulusLastEl + 1)%MaterialType - !END IF - - CALL ErrorStop('Error in calculating GasPocketFlowEl') - END IF - - GasPocketFlowEl(i , j) = k - !WRITE (*,*) 'GasPocketFlowEl=' , GasPocketFlowEl - j = j + 1 - - END IF - !IF (i > NoGasPocket) CALL ErrorStop('Error in GasPocketFlowEl' , i) - END DO - - !i = SIZE(GasPocketFlowEl , dim = 1) - !j = SIZE(GasPocketFlowEl , dim = 2) - !WRITE(*,*) 'GasPocketFlowEl Data' , GasPocketFlowEl - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - GasPocketModifiedVol%Array(:) = 0.d0 - - DO i = 1 , NoGasPocket - !WRITE(*,*) 'GasPocketFlowEl Data' , i , GasPocketFlowEl(: , i) - DO j = 1 , SIZE(GasPocketFlowEl , dim = 2) - IF (GasPocketFlowEl(i , j) > 0) GasPocketModifiedVol%Array(i) = GasPocketModifiedVol%Array(i) + FlowEl(GasPocketFlowEl(i , j))%Volume - END DO - END DO - i = AnnulusLastEl - j = OpenholeFirstEl - 1 - !WRITE (*,*) ' b) GasPocketModifiedVol (ft3)=', GasPocketModifiedVol(1) - !WRITE (*,*) ' b) GasPocketModifiedVol (gal)=' , GasPocketModifiedVol(1) * 7.48 - !IF (NoWelltoChokeEl > 0 .AND. ANY(FlowEl(i : j)%MaterialType == 1) .AND. FlowEl(j)%MaterialType == 0) THEN - ! BehindKickMudDensity = FlowEl(GasPocketFlowEl(NoGasPocket , 1) - 1)%Density - ! FrontKickMudDensity = FlowEl(MAXVAL(GasPocketFlowEl(NoGasPocket , :)) + 1)%Density - ! KickVolBeforeChoke = REAL(GasPocketModifiedVol%Array(NoGasPocket)) - ! WRITE (*,*) 'BehindKickMudDensity', BehindKickMudDensity - ! WRITE (*,*) 'FrontKickMudDensity' , FrontKickMudDensity - ! WRITE (*,*) 'KickVolBeforeChoke', KickVolBeforeChoke - !END IF - - - GasPocketOldVol%Array(:) = GasPocketModifiedVol%Array(:) - - GasPocketOldPress%Array(:) = GasPocketNewPress%Array(:) - !WRITE (*,*) ' GasPocketweight%Array(1)', GasPocketweight%Array(1) - IF (GasPocketWeight%Array(1) < 0.0) CALL ErrorStop(' Error in Calculating Mass ' , KickmdotBCoef) - - - GasPocketDensity%Array(:) = (GasPocketweight%Array(:) / GasPocketModifiedVol%Array(:)) / convft3toUSgal ! [lbm/ft^3 to ppg] - DO i = 1 , SIZE(GasPocketFlowEl , dim = 1) - DO j = 1 , SIZE(GasPocketFlowEl , dim = 2) - IF (GasPocketFlowEl(i , j) > 0) FlowEl(GasPocketFlowEl(i , j))%Density = GasPocketDensity%Array(i) - END DO - END DO - - - !WRITE (*,*) 'Kick density (ppg)=' , GasPocketDensity(1) - DownHole%InfluxRate = MAX(((KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1))) / GasPocketDensity%Array(1) * ConvMinToSec) , 0.0) - !WRITE (*,*) ' InfluxRate (gpm) =', InfluxRate - - i = OpenholeFirstEl - 1 - !WRITE (*,*) 'MaterialType, NoWelltoChokeEl', FlowEl(i)%MaterialType , NoWelltoChokeEl - !IF (NoWelltoChokeEl > 0 .AND. FlowEl(OpenholeFirstEl - 1)%MaterialType == 1 .AND. WellHeadOpen) THEN ! kick is last element in choke line and does not exit. - IF (MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0 .AND. WellHeadOpen) THEN - WRITE (*,*) 'Kick is exiting through the choke' - !ExitMass = GasPocketDensity%Array(NoGasPocket) * (SUM(GasPocketFlowInduced%Array(:)) + (DeltaVolumePipe * ConvMinToSec / dt) + MudSystem%StringFlowRate) / ConvMinToSec * dt - GasPocketWeight%Array(NoGasPocket) = GasPocketweight%Array(NoGasPocket) - ExitMass - IF (GasPocketWeight%Array(NoGasPocket) > 0.0) THEN - GasPocketOldPress%Array(NoGasPocket) = GasPocketWeight%Array(NoGasPocket) * GasType(KickGasType)%GasConstant * & - GasPocketCompressibility%Array(NoGasPocket) * GasPocketNewTemp%Array(NoGasPocket) / GasPocketModifiedVol%Array(NoGasPocket) - GasPocketDensity%Array(NoGasPocket) = (GasPocketweight%Array(NoGasPocket) / GasPocketModifiedVol%Array(NoGasPocket)) / convft3toUSgal - GasPocketNewVol%Array(:) = GasPocketOldVol%Array(:) - !FlowEl(i)%Density = GasPocketDensity%Array(NoGasPocket) ! for choke pressure drop calculation - !WRITE (*,*) 'kick weight, pressure & density', GasPocketWeight%Array(NoGasPocket), GasPocketOldPress%Array(NoGasPocket), FlowEl(i)%Density - ELSE ! gas pocket is escaped from the well completely - WRITE (*,*) ' Last Pocket Removed' - WRITE (*,*) ' GasPocketFlowEl', GasPocketFlowEl - CALL RemoveGasPocket(NoGasPocket) - - !WRITE (*,*) ' GasPocketFlowEl', GasPocketFlowEl - - END IF - - ELSE IF (NoGasPocket == 1 .OR. WellHeadOpen) THEN ! kick is not last element of choke line or well head is closed - !WRITE (*,*) ' Gas Kick Pressure (psi) (before) = ' , GasPocketNewPress(1) - !DO j = 1 , NoGasPocket - GasPocketNewPress%Array(:) = GasPocketNewPress%Array(:) * REAL(GasPocketNewVol%Array(:) / GasPocketOldVol%Array(:)) - GasPocketOldPress%Array(:) = GasPocketNewPress%Array(:) - GasPocketNewVol%Array(:) = GasPocketOldVol%Array(:) - !WRITE (*,*) ' Gas Kick Pressure (psi) (after) = ' , GasPocketOldPress(1), REAL(GasPocketNewVol(1) / GasPocketOldVol(1)) - !END DO - - ELSE ! Many gas pocket is in the well and well head is closed - -103 FORMAT (2I, 4X, (F9.3), 5X, (F9.3)) - - !WRITE (*,*) 'Before 0' - !DO i = 1 , NoGasPocket - ! WRITE (*,*) i, REAL(GasPocketNewPress%Array(i)), REAL(GasPocketNewVol%Array(i) * Convft3toUSgal), REAL(GasPocketOldVol%Array(i) * Convft3toUSgal) - !END DO - GasPocketNewPress%Array(NoGasPocket) = GasPocketOldPress%Array(NoGasPocket) - GasPocketNewVol%Array(NoGasPocket) = GasPocketCompressibility%Array(NoGasPocket) * GasType(KickGasType)%GasConstant * & - GasPocketNewTemp%Array(NoGasPocket) * GasPocketWeight%Array(NoGasPocket) / GasPocketNewPress%Array(NoGasPocket) - - - !GasPocketNewPress%Array(:) = GasPocketNewPress%Array(:) * REAL(GasPocketNewVol%Array(:) / GasPocketOldVol%Array(:)) - !GasPocketOldPress%Array(:) = GasPocketNewPress%Array(:) - - !WRITE (*,*) 'Before 1' - !DO i = 1 , NoGasPocket - ! WRITE (*,*) i, REAL(GasPocketNewPress%Array(i)), REAL((GasPocketNewVol%Array(i) * Convft3toUSgal)) - !END DO - - !WRITE (*,*) 'Mid' - DO WHILE (ABS(PressureCorrection * 10.0) > KickConvergenceTolerance) - DO j = NoGasPocket - 1 , 1 , -1 - CALL KickFunctionsCalculator(GasPocketNewPress%Array(j) , j , 5) - GasPocketNewVol%Array(j) = GasPocketCompressibility%Array(j) * GasType(KickGasType)%GasConstant * & - GasPocketNewTemp%Array(j) * GasPocketWeight%Array(j) / GasPocketNewPress%Array(j) - !WRITE (*,*) j, REAL(GasPocketNewPress%Array(j)), REAL(GasPocketNewVol%Array(j) * Convft3toUSgal) - END DO - PressureCorrection = (SUM(GasPocketNewVol%Array(:)) - SUM(GasPocketOldVol%Array(:))) / SUM(GasPocketNewVol%Array(:) / GasPocketNewPress%Array(:)) - GasPocketNewPress%Array(NoGasPocket) = GasPocketNewPress%Array(NoGasPocket) + PressureCorrection - GasPocketNewVol%Array(NoGasPocket) = GasPocketCompressibility%Array(NoGasPocket) * GasType(KickGasType)%GasConstant * & - GasPocketNewTemp%Array(NoGasPocket) * GasPocketWeight%Array(NoGasPocket) / GasPocketNewPress%Array(NoGasPocket) - j = NoGasPocket - !WRITE (*,*) j, REAL(GasPocketNewPress%Array(j)), REAL(GasPocketNewVol%Array(j) * Convft3toUSgal) - END DO - - !WRITE (*,*) 'Pressure Correction = ', PressureCorrection - WRITE (*,*) 'After' - DO i = 1 , NoGasPocket - WRITE (*,*) i, REAL(GasPocketNewPress%Array(i)), REAL((GasPocketNewVol%Array(i) * Convft3toUSgal)) - END DO - - GasPocketOldPress%Array(:) = GasPocketNewPress%Array(:) - - END IF - - - IF (GasPocketFlowEl(NoGasPocket , 1) == 0) THEN - CALL RemoveGasPocket(1) - - !WRITE (*,*) 'GasPocketFlowEl', GasPocketFlowEl - WRITE (*,*) 'First Pocket Removed' - !WRITE (*,*) 'GasPocketFlowEl', GasPocketFlowEl - END IF - - - - DownHole%KickVolume = INT(SUM(GasPocketOldVol%Array(:)) * convft3toUSgal / 42. * 10.0) / 10.0 - - - !WRITE (*,*) ' Gas Kick Pressure (psi) = ' , GasPocketOldPress(1) , INT((GasPocketNewVol(1) / GasPocketOldVol(1)) * 1000.d0) / 1000.d0 - !WRITE (*,*) ' b) GasPocketNewVol (ft^3) = ' , GasPocketOldVol(1) - - - - END SUBROUTINE - - -SUBROUTINE RemoveGasPocket(ilocal) - - use KickVARIABLESModule - USE MudSystemVARIABLES - - IMPLICIT NONE - - INTEGER :: ilocal - - DEALLOCATE(KickJacobian , OldKickJacobian , KickVandPFunction , KickUnknownVector , KickCorrectionVector) - - - WRITE (*,*) 'Gas Pocket Will be Removed', ilocal - call GasPocketOldPress%Remove(ilocal) - call GasPocketNewPress%Remove(ilocal) - call GasPocketOldTemp%Remove(ilocal) - call GasPocketNewTemp%Remove(ilocal) - call GasPocketOldVol%Remove(ilocal) - call GasPocketNewVol%Remove(ilocal) - call GasPocketDeltaVol%Remove(ilocal) - call GasPocketFlowInduced%Remove(ilocal) - call GasPocketModifiedVol%Remove(ilocal) - call GasPocketWeight%Remove(ilocal) - call GasPocketDensity%Remove(ilocal) - call GasPocketCompressibility%Remove(ilocal) - - NoGasPocket = NoGasPocket - 1 - - IF (NoGasPocket > 0) THEN - ALLOCATE(KickJacobian(2 * NoGasPocket , 2 * NoGasPocket) , OldKickJacobian(2 * NoGasPocket , 2 * NoGasPocket) , KickVandPFunction(2 * NoGasPocket)) - ALLOCATE(KickUnknownVector(2 * NoGasPocket) , KickCorrectionVector(2 * NoGasPocket)) - - IF (ALLOCATED(GasPocketFlowEl)) THEN - ALLOCATE(tempGasPocketFlowEl(NoGasPocket , SIZE(GasPocketFlowEl , dim = 2))) - tempGasPocketFlowEl = GasPocketFlowEl(1 : NoGasPocket , :) - DEALLOCATE(GasPocketFlowEl) - ALLOCATE(GasPocketFlowEl(SIZE(tempGasPocketFlowEl , dim = 1) , SIZE(tempGasPocketFlowEl , dim = 2))) - GasPocketFlowEl = tempGasPocketFlowEl - DEALLOCATE(tempGasPocketFlowEl) - END IF - - ELSE ! NoGasPocket = 0 - - - CALL GasPocketOldPress%Empty - CALL GasPocketNewPress%Empty - CALL GasPocketOldTemp%Empty - CALL GasPocketNewTemp%Empty - CALL GasPocketOldVol%Empty - CALL GasPocketNewVol%Empty - CALL GasPocketDeltaVol%Empty - CALL GasPocketFlowInduced%Empty - CALL GasPocketModifiedVol%Empty - CALL GasPocketWeight%Empty - CALL GasPocketDensity%Empty - - DownHole%InfluxRate = 0.0 - DownHole%KickVolume = 0.0 - - END IF - - !WRITE (*,*) 'Gas Pocket Removed', NoGasPocket + 1, ALLOCATED(GasPocketWeight%Array) - -END SUBROUTINE - - - - - - - \ No newline at end of file diff --git a/FluidFlow-old/fricpressdropvars.mod b/FluidFlow-old/fricpressdropvars.mod deleted file mode 100644 index 1300662..0000000 Binary files a/FluidFlow-old/fricpressdropvars.mod and /dev/null differ diff --git a/FluidFlow-old/kick/Formation_Information.f90 b/FluidFlow-old/kick/Formation_Information.f90 deleted file mode 100644 index d6df9d7..0000000 --- a/FluidFlow-old/kick/Formation_Information.f90 +++ /dev/null @@ -1,125 +0,0 @@ -SUBROUTINE FormationInformationCalculator - - use KickVARIABLESModule - Use TD_WellGeometry - Use CReservoirVariables - Use CFormationVariables - Use ConfigurationVariables - USE Fluid_Flow_Startup_Vars - USE CLog2 - USE CDownHoleVariables - USE MudSystemVARIABLES - - - IMPLICIT NONE - - INTEGER :: i - REAL(8) :: WellGeoTopTVD - - KickGasType = 1 ! methane - -!==================================================== -! Formation Length Calculation -!==================================================== - - WellGeoTopTVD = 0. - KickFormTopMD = 0. - KickFormDownMD = 0. - !===> Top Measured Depth of Formation - Do i = 1 , TD_WellGeneral%WellIntervalsCount - if ( Reservoir%FormationTop >= TD_WellGeo(i)%VerticalDepth ) then - KickFormTopMD = KickFormTopMD + TD_WellGeo(i)%IntervalLength - !WRITE (*,*) ' here 11' , TD_WellGeo(i)%IntervalLength - !WRITE (*,*) ' here v11' , TD_WellGeo(i)%VerticalDepth - - WellGeoTopTVD = TD_WellGeo(i)%VerticalDepth - else if ( Reservoir%FormationTop < TD_WellGeo(i)%VerticalDepth ) then - if ( TD_WellGeo(i)%HoleType == 0 ) then - KickFormTopMD = KickFormTopMD + ((Reservoir%FormationTop - WellGeoTopTVD)& - / cos(TD_WellGeo(i)%StartAngle)) - !WRITE (*,*) ' here 12' , (FormationTop - WellGeoTopTVD) / cos(TD_WellGeo(i)%StartAngle) - - else - KickFormTopMD = KickFormTopMD + (TD_WellGeo(i)%RCurvature & - * Asin((Reservoir%FormationTop - WellGeoTopTVD) / TD_WellGeo(i)%RCurvature)) - !WRITE (*,*) ' here 13' , TD_WellGeo(i)%RCurvature * Asin((FormationTop - WellGeoTopTVD) / TD_WellGeo(i)%RCurvature) - - end if - exit - end if - End Do - - !!===> Down Measured Depth of Formation - WellGeoTopTVD = 0. - Do i = 1 , TD_WellGeneral%WellIntervalsCount - if ( (Reservoir%FormationTop + Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness)>=TD_WellGeo(i)%VerticalDepth ) then - KickFormDownMD = KickFormDownMD + TD_WellGeo(i)%IntervalLength - WellGeoTopTVD = TD_WellGeo(i)%VerticalDepth - else if ( (Reservoir%FormationTop+Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness) Determination of Formation Length for Kick Modeling - if (TD_WellGeneral%WellTotalVerticalLength >= Reservoir%FormationTop .AND. TD_WellGeneral%WellTotalVerticalLength < (Reservoir%FormationTop+Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness)) then - KickFormLength = TD_WellGeneral%WellTotalLength - KickFormTopMD ![ft] - else if ( TD_WellGeneral%WellTotalVerticalLength >= (Reservoir%FormationTop + Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness) ) then - KickFormLength = KickFormDownMD - KickFormTopMD ![ft] - else - KickFormLength = 0. - end if - - !PermeabilityExposedHeight = KickFormLength * FormationPermeability - DownHole%PermeabilityExposedHeight = MudSystem%FluidFlowCounter - MudSystem%MudSys_timeCounter -!==================================================== -! Reservoir Data -!==================================================== - FormPermeability = Reservoir%FormationPermeability ! [mD] - - FormPressure = TD_WellGeneral%WellTotalVerticalLength * Configuration%Formation%Formations(Reservoir%FormationNo)%PorePressureGradient ![psia] - DownHole%FormationPressure = INT(FormPressure) - !CALL Log_2('FormPressure =' , FormPressure) - !print*, 'Formations(FormationNo)%PorePressureGradient=', Formations(FormationNo)%PorePressureGradient - !print * , 'FormationNo=' , FormationNo - !print * , 'TD_WellGeneral%WellTotalVerticalLength=' , TD_WellGeneral%WellTotalVerticalLength - FormTemperature = 600 ! [Ra] - !WRITE (*,*) ' Formation pressure ' , FormPressure - - -!==================================================== -! Gas Properties (Methane Gas) -!==================================================== - - GasResTemperature = FormTemperature - GasResPressure = FormPressure - - !!!! Methane , Gas type =1 - GasKickMolarMass = GasType(KickGasType)%MolarWt ! Methane Gas [gr/mol] - GasSpecGravity = GasKickMolarMass / GasDensityRefrence - - KickTc = GasType(KickGasType)%CritTemp - KickPc = GasType(KickGasType)%CritPress - - !!!!!!!! Calculating Compressibility, viscosity for influx condition (Average of reservoir and bottomhole) - KickTr = GasResTemperature / KickTc - KickPr = GasResPressure / KickPc - - K_A_Res = 3.53 * KickPr - K_B_Res = 10.0**(0.9813 * KickTr) - K_C_Res = 0.274 * (KickPr**2) - K_D_Res = 10.0**(0.8157 * KickTr) - - GasResCompressibility = 0.98 !1. - (K_A_Res / K_B_Res) + (K_C_Res / K_D_Res) - - GasReservoirDensity = GasResPressure / (GasResCompressibility * & - GasResTemperature * GasType(KickGasType)%GasConstant) / Convft3toUSgal ! [ppg] - -END SUBROUTINE - \ No newline at end of file diff --git a/FluidFlow-old/kick/Gas_Kick_Calculator.f90 b/FluidFlow-old/kick/Gas_Kick_Calculator.f90 deleted file mode 100644 index 7c9b035..0000000 --- a/FluidFlow-old/kick/Gas_Kick_Calculator.f90 +++ /dev/null @@ -1,566 +0,0 @@ -SUBROUTINE GasKickCalculator - - use KickVARIABLESModule - Use TD_WellGeometry - Use CReservoirVariables - Use CFormationVariables - USE Fluid_Flow_Startup_Vars - use PressureDisplayVARIABLESModule - USE FricPressDropVarsModule - USE MudSystemVARIABLES - USE CMudPropertiesVariables - USE CError - USE , INTRINSIC :: IEEE_ARITHMETIC - - - !! Note: a subject that may be confusing is that when we use gauge pressure and when're using absolute pressure?! - !! all stated pressure are gauge pressure, so I do like this. - !! only when we want to use a state equation (like ideal gas equation), we should use absolute equation and so I do this. - !! Thus gas pocket pressure are all absolute pressure. - - IMPLICIT NONE - - INTEGER :: i , j , k , l - - SolvingEquationError = .FALSE. - KickVandPFunction(:) = 0.d0 - KickJacobian(: , :) = 0.d0 - -!==================================================== -! Gas Properties (Methane Gas) -!==================================================== - !GasPocketNewTemp%Array(1) = 600 - BottomHoleTemperature = 600 - KickFluxAvgPressure = (BottomHolePress + FormPressure) / 2 + StandardPress - KickFluxAvgTemperature = (FormTemperature + BottomHoleTemperature) / 2 - KickFluxAvgCompressibility = 0.98d0 - - K_Aa = (5.8742362 * 10.**(-3) * KickFluxAvgTemperature**1.2288) / (511.1728532 + KickFluxAvgTemperature) - K_Bb = 5.5565586 + (1000.01 / KickFluxAvgTemperature) - K_Cc = 2.47862 - 0.12294 * K_Bb - GasKickSIDensity = KickFluxAvgPressure / (KickFluxAvgCompressibility * & - KickFluxAvgTemperature * GasType(KickGasType)%GasConstant) * Convpcftogpcm3 - - GasKickViscosity = K_Aa * EXP(K_Bb * GasKickSIDensity**K_Cc) - !!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!! Calculating compressibility for bottom hole condition - !K_BHTpr = BottomHoleTemperature / KickTc - !K_BHPpr = (BottomHolePress + StandardPress) / KickPc - - !K_A_Bottomhole = 3.53 * K_BHPpr - !K_B_Bottomhole = 10.0**(0.9813 * K_BHTpr) - !K_C_Bottomhole = 0.274 * (K_BHPpr**2) - !K_D_Bottomhole = 10.0**(0.8157 * K_BHTpr) - - BottomHoleCompressibility = 0.98d0 !1. - (K_A_Bottomhole / K_B_Bottomhole) + (K_C_Bottomhole / K_D_Bottomhole) - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - GasKickBg = 0.00504 * KickFluxAvgCompressibility * KickFluxAvgTemperature / KickFluxAvgPressure ![bbl/SCF] - - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !WRITE (*,*) 'Gas Kick Top' -!===> Kick Flow Rate Calculation - IF (FormPressure > BottomHolePress) THEN - KickmdotACoef = 10.0**(-8) * 1.15741d0 * 7.080 * FormPermeability * REAL(KickFormLength) * GasType(KickGasType)%StDensity / & - (GasKickViscosity * GasKickBg * LOG(10000.0)) - !IF (WellHeadOpen .AND. NoGasPocket == 1) KickmdotACoef = (1.d0 + 2.d0) * KickmdotACoef - ELSE - KickmdotACoef = 0.0 - END IF - - i = StringLastEl - j = OpenholeFirstEl - 1 - k = GasPocketFlowEl(1 , 1) - KickmdotBCoef = FormPressure + StandardPress !! - Sum(static and friction pressure loss) of flow elements below gas pocket, see below - IF (FormPressure > BottomHolePress) THEN - - !WRITE (*,*) 'k , i, j' , k , i, j - IF (k >= OpenholeFirstEl) THEN ! Bottom of active kick is in openhole - KickmdotBCoef = KickmdotBCoef - (SUM(FlowEl(OpenholeFirstEl : k)%StaticPressDiff)) !+ SUM(FlowEl(j + 1 : GasPocketFlowEl(1 , 1) - 1)%FricPressLoss - !WRITE (*,*) '1 SUM(FlowEl(j + 1 : k)%FricPressLoss', k, SUM(FlowEl(j + 1 : k)%FricPressLoss) - ELSE IF (k < OpenholeFirstEl) THEN ! bottom of 1st gas pocket (active kick) is in annulus ond/or choke line only - KickmdotBCoef = KickmdotBCoef - SUM(FlowEl(OpenholeFirstEl : NumbEl)%StaticPressDiff) & - - (SUM(FlowEl(AnnulusFirstEl : k)%StaticPressDiff) + SUM(FlowEl(AnnulusFirstEl : k)%FricPressLoss)) - !WRITE (*,*) '2 SUM(FlowEl(j + 1 : NumbEl)%FricPressLoss', k, SUM(FlowEl(j + 1 : NumbEl)%FricPressLoss) - END IF - !WRITE (*,*) ' KickmdotBCoef=', KickmdotBCoef - END IF - !WRITE (*,*) 'Kick A, B', KickmdotACoef, KickmdotBCoef - - DO l = 1 , NoGasPocket - KickUnknownVector(2 * l - 1) = GasPocketNewVol%Array(l) - KickUnknownVector(2 * l) = GasPocketNewPress%Array(l) - END DO - - IF (WellHeadOpen) THEN - !!!!!!!!!! Calculation of functions of pocket Pressure and gas Volumes - !IF (GasPocketElementNo(1) > 0) WRITE (*,*) ' GasPocketElementNo(1) ' , GasPocketElementNo(1) - !WRITE (*,*) ' Kick Unknown Vector' , KickUnknownVector!(1) , KickUnknownVector(2) - IF (KickIteration == 1) THEN ! updating initial guess based on previous time step data - DO l = 1 , NoGasPocket - KickUnknownVector(2 * l - 1) = KickUnknownVector(2 * l - 1) + GasPocketDeltaVol%Array(l) - END DO - END IF - - KickVandPFunction(1) = KickUnknownVector(1) - GasPocketCompressibility%Array(1) * GasType(KickGasType)%GasConstant * & ! VandP(1) = V(1) - GasPocketNewTemp%Array(1) * (GasPocketWeight%Array(1) + KickmdotACoef * MAX(((KickmdotBCoef - KickUnknownVector(2)) * dt) , 0.0)) / KickUnknownVector(2) - !WRITE (*,*) 'KickVandPFunction(1)',KickVandPFunction(1) - l = 2 * NoGasPocket - CALL KickFunctionsCalculator(KickVandPFunction(l) , NoGasPocket , 2) ! VandP(last) = P(last) - !WRITE (*,*) 'KickVandPFunction(l)', l, KickVandPFunction(l) - DO l = 2 , NoGasPocket ! VandP(Odd) = V(l, l > 1) - KickVandPFunction(2 * l - 1) = KickUnknownVector(2 * l - 1) - GasPocketCompressibility%Array(l) * GasType(KickGasType)%GasConstant * & - GasPocketNewTemp%Array(l) * GasPocketWeight%Array(l) / KickUnknownVector(2 * l) - !WRITE(*,*) 'KickVandPFunction(V)', l, KickVandPFunction(2 * l - 1) - END DO - - DO l = NoGasPocket - 1 , 1 , -1 - CALL KickFunctionsCalculator(KickVandPFunction(2 * l) , l , 1) ! VandP(Even) = P(l, l < NoGasPocket) - !WRITE(*,*) 'KickVandPFunction(P)', l , KickVandPFunction(2 * l) - END DO - !!!!!!!!!! END - Calculation of functions of pocket Pressure and gas Volumes - - !!!!!!!!!! Calculation of Jacobian - DO k = 1 , 2 * NoGasPocket ! Main Diagonal - KickJacobian(k , k) = 1.d0 - END DO - - KickJacobian(1,2) = (GasPocketCompressibility%Array(1) * GasType(KickGasType)%GasConstant * GasPocketNewTemp%Array(1) & - * (GasPocketWeight%Array(1) + KickmdotACoef * KickmdotBCoef * dt) / KickUnknownVector(2)**2) ! Row 1 Finished - IF (KickJacobian(1,2) == 0.d0) THEN - CALL Error('KickJacobian(1,2) = 0.0') - KickJacobian(1,2) = OldKickJacobian(1,2) - END IF - - !WRITE(*,*) 'KickJacobian(1,2)', KickJacobian(1,2) - - l = NoGasPocket - CALL KickFunctionsCalculator(KickJacobian(2 * l , 2 * l - 1) , NoGasPocket , 4) ! for last Row - IF (KickJacobian(2 * l , 2 * l - 1) == 0.d0) THEN - CALL Error ('KickJacobian(Last,Odd) = 0.0') - KickJacobian(2 * l , 2 * l - 1) = OldKickJacobian(2 * l , 2 * l - 1) - END IF - - DO k = NoGasPocket - 1 , 1 , -1 - KickJacobian(2 * l , 2 * k - 1) = KickJacobian(2 * l , 2 * l - 1) - END DO ! Last Row Finished - !WRITE(*,*) 'KickJacobian(2,1)', KickJacobian(2,1) - - - DO k = 2 , NoGasPocket - KickJacobian(2 * k - 1 , 2 * k) = GasPocketCompressibility%Array(k) * GasType(KickGasType)%GasConstant * GasPocketNewTemp%Array(k) & - * GasPocketWeight%Array(k) / KickUnknownVector(2 * k)**2 - - END DO ! Odd Rows (V equations) Finished - - DO k = 1 , NoGasPocket - 1 - KickJacobian(2 * k , 2 * k + 2) = -1.d0 - END DO ! Even Rows (P equations) effect of upper pocket - - DO k = 2 , 2 * (NoGasPocket - 1) , 2 - DO l = 1 , k - 1 , 2 - CALL KickFunctionsCalculator(KickJacobian(k , l) , k / 2 , 3) - IF (KickJacobian(k , l) == 0.d0) THEN - WRITE (*,*) 'Jacobian Array = 0.0', k , l - CALL Error ('KickJacobian(k , l) = 0.0') - KickJacobian(k , l) = OldKickJacobian(k , l) - END IF - END DO - END DO - - IF (ANY(IEEE_IS_NaN(KickJacobian))) CALL ErrorStop ('NaN in calculating Kick Jacobian, Call your Service Provider') - - !!!!!!!!!! Solving linear equation in order to finding correction vector for correcting pocket pressure and gas induced flowrates - KickVandPFunction = -1.d0 * KickVandPFunction - !WRITE (*,*) 'Max Remainder', MAXVAL(ABS(KickVandPFunction)) , MAXLOC(ABS(KickVandPFunction)) - !WRITE (*,*) 'SIZE(A , dim = 1), SIZE(A , dim = 2), SIZE(b)', SIZE(KickJacobian , dim = 1), SIZE(KickJacobian , dim = 2), SIZE(KickVandPFunction) - CALL SOLVE_LINEAR_EQUATIONS(KickJacobian , KickCorrectionVector , KickVandPFunction , SolvingEquationError, SIZE(KickCorrectionVector)) - IF (SolvingEquationError) CALL ErrorStop( ' Error in solving kick equation ' ) - - KickUnknownVector = KickUnknownVector + KickCorrectionUnderRelaxation * KickCorrectionVector - - DO l = 1 , NoGasPocket - GasPocketNewVol%Array(l) = KickUnknownVector(2 * l - 1) - IF (IEEE_IS_NaN(GasPocketNewVol%Array(l))) CALL ErrorStop('Volume of this pocket is Not a Number:', l) - IF (GasPocketNewVol%Array(l) <= 0.d0) CALL Error('Volume of this pocket is Negative or Zero:', l) - GasPocketNewPress%Array(l) = KickUnknownVector(2 * l) - IF (IEEE_IS_NaN(GasPocketNewPress%Array(l))) CALL ErrorStop('Pressure of this Pocket is Not a Number:', l) - IF (GasPocketNewPress%Array(l) <= 0.d0) CALL ErrorStop('Pressure of this Pocket is Negative or Zero:', l) - END DO - - - !WRITE(*,*) 'GasPocketDeltaVol (gal)' , GasPocketDeltaVol(1) * 7.48 - !WRITE (*,*) 'GasPocketFlowInduced (gpm), GasPocketNewVol' , GasPocketFlowInduced(1), GasPocketNewVol(1) - !IF (Kchoke > 0.0) - !WRITE(*,*) ' New Vol (ft3), New Press (psi)', GasPocketNewVol(1), GasPocketNewPress(1) - - ELSE ! well haed is closed, so build up process or migration occurs - - !WRITE (*,*) 'GasPocketOldPress (before)' , GasPocketOldPress(1) - GasPocketNewPress%Array(1) = GasPocketOldPress%Array(1) * & - (REAL((GasPocketWeight%Array(1) + KickmdotACoef * KickmdotBCoef * dt) / (GasPocketWeight%Array(1) + KickmdotACoef * GasPocketOldPress%Array(1) * dt))) - !WRITE (*,*) 'GasPocketNewPress (after)' , GasPocketNewPress(1), ((GasPocketWeight(1) + KickmdotACoef * KickmdotBCoef * dt) / (GasPocketWeight(1) + KickmdotACoef * GasPocketOldPress(1) * dt)) - - - !WRITE (*,*) ' Well head is closed, GasPocketNewPress =' , GasPocketNewPress(1) - !WRITE (*,*) 'Old Press, Weight, A, B' , GasPocketOldPress(1), GasPocketWeight(1), KickmdotACoef, KickmdotBCoef - !WRITE (*,*) 'Numerator and denumerator Gas kick' , KickmdotACoef * KickmdotBCoef * dt , KickmdotACoef * GasPocketOldPress(1) * dt - - !WRITE (*,*) ' Gas Kick Volume (ft^3) = ' , GasPocketNewVol(1) - - END IF - - !DO l = 1 , NoGasPocket - GasPocketDeltaVol%Array(:) = GasPocketNewVol%Array(:) - GasPocketOldVol%Array(:) - GasPocketFlowInduced%Array(:) = (GasPocketDeltaVol%Array(:)) / dt * 448.8 ! gpm - !END DO - - GasKickPumpFlowRate = 0.0 - IF (NOT(KickOffBottom) .AND. WellHeadOpen) GasKickPumpFlowRate = GasPocketFlowInduced%Array(1) - - !WRITE (*,*) ' No Iteration, KickCorrectionVector =' , KickIteration , KickCorrectionVector(1) , KickCorrectionVector(2) - !WRITE (*,*) ' Kick Jacobian ', REAL(KickJacobian) - !WRITE (*,*) ' KickVandPFunction = ' , REAL(KickVandPFunction) - !WRITE (*,*) ' Kick Unknown Vector = ' , REAL(-KickUnknownVector) - - - - !WRITE (*,*) 'Gas Kick Bottom' - - - END SUBROUTINE - - - SUBROUTINE KickFunctionsCalculator(ExitValue , GasPocketNo , CalcMode) - - - use KickVARIABLESModule - USE FricPressDropVarsModule - USE Fluid_Flow_Startup_Vars - USE CError - USE , INTRINSIC :: IEEE_Arithmetic - - - IMPLICIT NONE - - REAL(8) :: ExitValue - INTEGER :: GasPocketNo , CalcMode - INTEGER :: x - INTEGER :: y - INTEGER :: z , i , j - - x = GasPocketFlowEl(GasPocketNo , 1) - IF (GasPocketNo < NoGasPocket) y = GasPocketFlowEl(GasPocketNo + 1 , 1) - i = StringLastEl - j = OpenholeFirstEl - 1 - - ! Case 1: gas pocket is completely in OP and STARTX of upper gas pocket is also - ! Case 2: gas pocket is completely in OP and STARTX of upper gas pocket is above Bit - ! Case 3: gas pocket is AROUNDBIT and so upper gas pocket is in ANN (or Choke line) - ! Case 4: gas pocket is completely in ANN and upper gas pocket is also - - ! CalcMode 1: KickVandPFunction between 2 pocket - ! CalcMode 2: KickVandPFunction for top gas pocket - ! CalcMode 3: KickJacobian between 2 Pocket - ! CalcMode 4: KickJacobian for top (last) gas pocket - ! CalcMode 5: Calculating pressure of bottom pocket based on upper pocket - - - IF (CalcMode == 1) THEN ! calculating pressure difference between two pocket, include static pressure difference and frictional - ! pressure difference, use in calculating 'KickVandPFunction' - ExitValue = KickUnknownVector(2 * GasPocketNo) - KickUnknownVector(2 * GasPocketNo + 2) - IF (x >= OpenholeFirstEl .AND. y < OpenholeFirstEl) THEN ! Case 2 , Case 3 - ExitValue = ExitValue - SUM(FlowEl(x : NumbEl)%StaticPressDiff) - SUM(FlowEl(x : NumbEl)%FricPressLoss) & - - SUM(FlowEl(AnnulusFirstEl : y)%StaticPressDiff) - SUM(FlowEl(AnnulusFirstEl : y)%FricPressLoss) - ELSE ! Case 1 , Case 4 - ExitValue = ExitValue - SUM(FlowEl(x : y)%StaticPressDiff) - SUM(FlowEl(x : y)%FricPressLoss) - END IF - - - ELSE IF (CalcMode == 2) THEN - ExitValue = KickUnknownVector(2 * GasPocketNo) - StandardPress - Kchoke * FlowEl(OpenholeFirstEl - 1)%Flowrate**2 - IF (x >= OpenholeFirstEl) THEN ! Gas Pocket is in Openhole - ExitValue = ExitValue - SUM(FlowEl(x : NumbEl)%StaticPressDiff) - SUM(FlowEl(x : NumbEl)%FricPressLoss) & - - SUM(FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%StaticPressDiff) - SUM(FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FricPressLoss) - ELSE ! Gas Pocket is in Annulus - ExitValue = ExitValue - SUM(FlowEl(x : OpenholeFirstEl - 1)%StaticPressDiff) - SUM(FlowEl(x : OpenholeFirstEl - 1)%FricPressLoss) - END IF - - - ELSE IF (CalcMode == 3) THEN ! calculating derivative of pressure difference between two pocket, relative to change in flowrate - ! use in calculating 'KickJacobian' - IF (x >= OpenholeFirstEl .AND. y < OpenholeFirstEl) THEN ! Top kick STARTX is in Annulus - DO z = x , NumbEl ! open hole elements - CALL PartialDerivativeFricToFlowRate(z) - IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN - WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe - WRITE (*,*) ' Op start, end, density, Q, mu' , FlowEl(z)%StartX, FlowEl(z)%EndX, FlowEl(z)%Density, FlowEl(z)%FlowRate, FlowEl(z)%mueff - CALL ErrorStop('NaN in calculating partial derivative') - END IF - END DO - DO z = AnnulusFirstEl , y ! Annulus elements - CALL PartialDerivativeFricToFlowRate(z) - IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN - WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe - WRITE (*,*) ' Op start, end, density, Q, mu' , FlowEl(z)%StartX, FlowEl(z)%EndX, FlowEl(z)%Density, FlowEl(z)%FlowRate, FlowEl(z)%mueff - CALL ErrorStop('NaN in calculating partial derivative') - END IF - END DO - ExitValue = ExitValue - (SUM(FlowEl(x : NumbEl)%FricToQPartialDiff) + SUM(FlowEl(AnnulusFirstEl : y)%FricToQPartialDiff)) * 448.8 / dt - ELSE ! both pockets are one side of bit - DO z = x , y - CALL PartialDerivativeFricToFlowRate(z) - IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN - WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe - WRITE (*,*) ' Op start, end, density, Q, mu' , FlowEl(z)%StartX, FlowEl(z)%EndX, FlowEl(z)%Density, FlowEl(z)%FlowRate, FlowEl(z)%mueff - CALL ErrorStop('NaN in calculating partial derivative') - END IF - END DO - ExitValue = ExitValue - SUM(FlowEl(x : y)%FricToQPartialDiff) * 448.8 / dt - END IF - - - ELSE IF (CalcMode == 4) THEN ! partial derivative of frictional pressure drop relative to flowrate for top gas pocket - ExitValue = - 2.d0 * Kchoke * FlowEl(OpenholeFirstEl - 1)%Flowrate * 448.8 / dt - IF (x >= OpenholeFirstEl) THEN ! kick STARTX is in openhole - DO z = x , NumbEl ! open hole elements - CALL PartialDerivativeFricToFlowRate(z) - IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN - WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe - WRITE (*,*) ' Op start, end, density, Q, mu' , FlowEl(z)%StartX, FlowEl(z)%EndX, FlowEl(z)%Density, FlowEl(z)%FlowRate, FlowEl(z)%mueff - CALL ErrorStop('NaN in calculating partial derivative') - END IF - END DO - DO z = AnnulusFirstEl , OpenholeFirstEl - 1 ! Annulus elements - CALL PartialDerivativeFricToFlowRate(z) - IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN - WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe - WRITE (*,*) ' Op start, end, density, Q, mu' , FlowEl(z)%StartX, FlowEl(z)%EndX, FlowEl(z)%Density, FlowEl(z)%FlowRate, FlowEl(z)%mueff - CALL ErrorStop('NaN in calculating partial derivative') - END IF - END DO - ExitValue = ExitValue - (SUM(FlowEl(x : NumbEl)%FricToQPartialDiff) + SUM(FlowEl(AnnulusFirstEl : OpenholeFirstEl - 1)%FricToQPartialDiff)) * 448.8 / dt - ELSE - DO z = x , OpenholeFirstEl - 1 ! Annulus elements - CALL PartialDerivativeFricToFlowRate(z) - IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN - WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe - WRITE (*,*) ' Op start, end, density, Q, mu' , FlowEl(z)%StartX, FlowEl(z)%EndX, FlowEl(z)%Density, FlowEl(z)%FlowRate, FlowEl(z)%mueff - CALL ErrorStop('NaN in calculating partial derivative') - END IF - END DO - ExitValue = ExitValue - SUM(FlowEl(x : OpenholeFirstEl - 1)%FricToQPartialDiff) * 448.8 / dt - END IF - - - ELSE IF (CalcMode == 5) THEN - IF (x >= OpenholeFirstEl .AND. y < OpenholeFirstEl) THEN ! Gas Pocket is in Openhole and upper pocket is in annulus - !WRITE (*,*) 'x , y 1' , x, y - ExitValue = GasPocketNewPress%Array(GasPocketNo + 1) + SUM(FlowEl(x : NumbEl)%StaticPressDiff) + SUM(FlowEl(AnnulusFirstEl : y)%StaticPressDiff) - ELSE ! Both gas pockets are in Annulus or openhole - !WRITE (*,*) 'x , y 2' , x, y - ExitValue = GasPocketNewPress%Array(GasPocketNo + 1) + SUM(FlowEl(x : y)%StaticPressDiff) - END IF - END IF - - - - END SUBROUTINE - - - -SUBROUTINE NewGasKick - - use KickVARIABLESModule - Use TD_WellGeometry - Use CReservoirVariables - Use CFormationVariables - USE Fluid_Flow_Startup_Vars - use PressureDisplayVARIABLESModule - USE FricPressDropVarsModule - USE MudSystemVARIABLES - USE CMudPropertiesVariables - USE CError - USE , INTRINSIC :: IEEE_ARITHMETIC - - - !! Note: a subject that may be confusing is that when we use gauge pressure and when using absolute pressure?! - !! all stated pressure are gauge pressure, so I do like this. - !! only when we want to use a state equation (like ideal gas equation), we should use absolute equation and so I do this. - !! Thus gas pocket pressure are all absolute pressure. - - IMPLICIT NONE - - INTEGER :: i , j , k , l - - IF (NOT(ALLOCATED(GasPocketWeight%Array))) THEN ! 1st kick - WRITE (*,*) ' New Influx 1' - - NoGasPocket = 1 - MudSystem%NewInfluxNumber = MudSystem%NewInfluxNumber + 1 - - MudSystem%NewInfluxElementCreated = 0 - KickOffBottom = .FALSE. - - - CALL GasPocketOldPress%AddToFirst((BottomHolePress + StandardPress) * 1.d0) - CALL GasPocketNewPress%AddToFirst((BottomHolePress + StandardPress) * 1.d0) - CALL GasPocketOldTemp%AddToFirst(600.0) - CALL GasPocketNewTemp%AddToFirst(600.0) - CALL GasPocketOldVol%AddToFirst(0.d0) - CALL GasPocketNewVol%AddToFirst(0.d0) - CALL GasPocketdeltaVol%AddToFirst(0.0) - CALL GasPocketFlowInduced%AddToFirst(0.0) - CALL GasPocketModifiedVol%AddToFirst(0.0) - CALL GasPocketWeight%AddToFirst(0.0) - CALL GasPocketDensity%AddToFirst(2.0) - CALL GasPocketCompressibility%AddToFirst(0.98) - - ALLOCATE(KickJacobian(2 , 2) , OldKickJacobian(2 , 2) , KickVandPFunction(2) , KickUnknownVector(2) , KickCorrectionVector(2)) - - BottomHoleTemperature = 600 - KickFluxAvgPressure = (BottomHolePress + FormPressure) / 2 + StandardPress - KickFluxAvgTemperature = (FormTemperature + BottomHoleTemperature) / 2 - KickFluxAvgCompressibility = 0.98 - - !K_Aa = (5.8742362 * 10.**(-3) * KickFluxAvgTemperature**1.2288) / (511.1728532 + KickFluxAvgTemperature) - !K_Bb = 5.5565586 + (1000.01 / KickFluxAvgTemperature) - !K_Cc = 2.47862 - 0.12294 * K_Bb - GasKickSIDensity = KickFluxAvgPressure / (KickFluxAvgCompressibility * & - KickFluxAvgTemperature * GasType(KickGasType)%GasConstant) * Convpcftogpcm3 - GasKickDensity = GasKickSIDensity * 8.3523 - - !GasKickViscosity = K_Aa * EXP(K_Bb * GasKickSIDensity**K_Cc) - ! - !K_BHTpr = BottomHoleTemperature / KickTc - !K_BHPpr = (BottomHolePress + StandardPress) / KickPc - ! - !K_A_Bottomhole = 3.53 * K_BHPpr - !K_B_Bottomhole = 10.0**(0.9813 * K_BHTpr) - !K_C_Bottomhole = 0.274 * (K_BHPpr**2) - !K_D_Bottomhole = 10.0**(0.8157 * K_BHTpr) - ! - !BottomHoleCompressibility = 0.98 !1. - (K_A_Bottomhole / K_B_Bottomhole) + (K_C_Bottomhole / K_D_Bottomhole) - ! - !GasKickBg = 0.00504 * KickFluxAvgCompressibility * KickFluxAvgTemperature / KickFluxAvgPressure ![bbl/SCF] - - - !KickmdotACoef = 10.**(-8) * 1.15741d0 * 7.08d0 * FormPermeability * REAL(KickFormLength) * GasType(KickGasType)%StDensity / & - !(GasKickViscosity * GasKickBg * LOG(10000.d0)) - !IF (WellHeadOpen) KickmdotACoef = (1.0 + 2.0) * KickmdotACoef - - !KickmdotBCoef = FormPressure + StandardPress !! - Sum(static and friction pressure loss) of flow elements below gas pocket, see below - - !GasPocketWeight%Array(1) = GasKickDensity * 0.05 !KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - GasPocketWeight%Array(1) = GasKickDensity * MinKickVol !1.0:seyyed gofte !KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - - GasPocketNewVol%Array(1) = GasPocketCompressibility%Array(1) * GasType(KickGasType)%GasConstant * & - GasPocketNewTemp%Array(1) * GasPocketWeight%Array(1) / GasPocketNewPress%Array(1) - - GasPocketDeltaVol%Array(1) = 0.05 !GasPocketNewVol%Array(1) - GasPocketFlowInduced%Array(1) = (GasPocketDeltaVol%Array(1)) / dt * 448.8 ! gpm - GasKickPumpFlowRate = GasPocketFlowInduced%Array(1) - - WRITE (*,*) ' FormPressure , BottomHolePress' , FormPressure , BottomHolePress, GasKickDensity - WRITE (*,*) ' No Press(psia) Vol(gal) Weight(lbm) Flow Induced(gpm)' - DO i = 1 , NoGasPocket - WRITE (*,102) i , GasPocketNewPress%Array(i), GasPocketNewVol%Array(i) * Convft3toUSgal, GasPocketWeight%Array(i), GasPocketFlowInduced%Array(i) - END DO - - !ELSE IF (NoGasPocket < MaxGasPocket .AND. KickOffBottom .AND. (GasPocketNewVol%Array(1) > MinAllowableKickVol .OR. KickWasExitingThroughChoke)) THEN - ELSE IF (NoGasPocket < MaxGasPocket .AND. KickOffBottom .AND. (GasPocketNewVol%Array(1) > MinAllowableKickVol .OR. ANY(GasPocketFlowEl(1 , :) == OpenholeFirstEl - 1))) THEN - WRITE (*,*) ' New Influx', NoGasPocket + 1 - -102 FORMAT (I2, 4X, (F8.1), 3X, (F8.3), 2X, (F8.3), 8X, (F8.3)) - - - NoGasPocket = NoGasPocket + 1 - MudSystem%NewInfluxNumber = MudSystem%NewInfluxNumber + 1 - - MudSystem%NewInfluxElementCreated = 0 - KickOffBottom = .FALSE. - - CALL GasPocketOldPress%AddToFirst((BottomHolePress + StandardPress) * 1.d0) - CALL GasPocketNewPress%AddToFirst((BottomHolePress + StandardPress) * 1.d0) - CALL GasPocketOldTemp%AddToFirst(600.0) - CALL GasPocketNewTemp%AddToFirst(600.0) - CALL GasPocketOldVol%AddToFirst(0.d0) - CALL GasPocketNewVol%AddToFirst(0.d0) - CALL GasPocketdeltaVol%AddToFirst(0.0) - CALL GasPocketFlowInduced%AddToFirst(0.0) - CALL GasPocketModifiedVol%AddToFirst(0.0) - CALL GasPocketWeight%AddToFirst(0.0) - CALL GasPocketDensity%AddToFirst(2.0) - CALL GasPocketCompressibility%AddToFirst(0.98) - - DEALLOCATE(KickJacobian , OldKickJacobian , KickVandPFunction , KickUnknownVector , KickCorrectionVector) - - ALLOCATE(KickJacobian(2 * NoGasPocket , 2 * NoGasPocket) , OldKickJacobian(2 * NoGasPocket , 2 * NoGasPocket)) - ALLOCATE(KickUnknownVector(2 * NoGasPocket) , KickCorrectionVector(2 * NoGasPocket) , KickVandPFunction(2 * NoGasPocket)) - - - BottomHoleTemperature = 600 - KickFluxAvgPressure = (BottomHolePress + FormPressure) / 2 + StandardPress - KickFluxAvgTemperature = (FormTemperature + BottomHoleTemperature) / 2 - KickFluxAvgCompressibility = 0.98 - - !K_Aa = (5.8742362 * 10.**(-3) * KickFluxAvgTemperature**1.2288) / (511.1728532 + KickFluxAvgTemperature) - !K_Bb = 5.5565586 + (1000.01 / KickFluxAvgTemperature) - !K_Cc = 2.47862 - 0.12294 * K_Bb - GasKickSIDensity = KickFluxAvgPressure / (KickFluxAvgCompressibility * & - KickFluxAvgTemperature * GasType(KickGasType)%GasConstant) * Convpcftogpcm3 - GasKickDensity = GasKickSIDensity * 8.3523 - - !GasKickViscosity = K_Aa * EXP(K_Bb * GasKickSIDensity**K_Cc) - ! - !K_BHTpr = BottomHoleTemperature / KickTc - !K_BHPpr = (BottomHolePress + StandardPress) / KickPc - ! - !K_A_Bottomhole = 3.53 * K_BHPpr - !K_B_Bottomhole = 10.0**(0.9813 * K_BHTpr) - !K_C_Bottomhole = 0.274 * (K_BHPpr**2) - !K_D_Bottomhole = 10.0**(0.8157 * K_BHTpr) - ! - !BottomHoleCompressibility = 0.98 !1. - (K_A_Bottomhole / K_B_Bottomhole) + (K_C_Bottomhole / K_D_Bottomhole) - ! - !GasKickBg = 0.00504 * KickFluxAvgCompressibility * KickFluxAvgTemperature / KickFluxAvgPressure ![bbl/SCF] - ! - ! - !KickmdotACoef = 10.**(-8) * 1.15741d0 * 7.08d0 * FormPermeability * REAL(KickFormLength) * GasType(KickGasType)%StDensity / & - ! (GasKickViscosity * GasKickBg * LOG(10000.d0)) - !IF (WellHeadOpen) KickmdotACoef = (1.0 + 2.0) * KickmdotACoef - ! - !KickmdotBCoef = FormPressure + StandardPress !! - Sum(static and friction pressure loss) of flow elements below gas pocket, see below - - !GasPocketWeight%Array(1) = GasKickDensity * 0.05 !KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - GasPocketWeight%Array(1) = GasKickDensity * MinKickVol !1.0:seyyed gofte !KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - - GasPocketNewVol%Array(1) = GasPocketCompressibility%Array(1) * GasType(KickGasType)%GasConstant * & - GasPocketNewTemp%Array(1) * GasPocketWeight%Array(1) / GasPocketNewPress%Array(1) - - GasPocketDeltaVol%Array(1) = 0.05 !GasPocketNewVol%Array(1) - GasPocketFlowInduced%Array(1) = (GasPocketDeltaVol%Array(1)) / dt * 448.8 ! gpm - GasKickPumpFlowRate = GasPocketFlowInduced%Array(1) - - WRITE (*,*) ' FormPressure , BottomHolePress' , FormPressure , BottomHolePress, GasKickDensity - WRITE (*,*) ' No Press(psia) Vol(gal) Weight(lbm) Flow Induced(gpm)' - DO i = 1 , NoGasPocket - WRITE (*,102) i , GasPocketNewPress%Array(i), GasPocketNewVol%Array(i) * Convft3toUSgal, GasPocketWeight%Array(i), GasPocketFlowInduced%Array(i) - END DO - - ELSE ! no new kick, so mass of 1st kick should increase - GasPocketWeight%Array(1) = GasPocketweight%Array(1) + KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - GasKickPumpFlowRate = GasPocketFlowInduced%Array(1) - - IF (NoGasPocket > 1 .OR. SecondaryKickWeight > 0.0) THEN - SecondaryKickWeight = SecondaryKickWeight + KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - SecondaryKickVol = SecondaryKickWeight / GasReservoirDensity / 42.0 ! 42 USGal = 1bbl - END IF - - END IF - - -END SUBROUTINE - \ No newline at end of file diff --git a/FluidFlow-old/kick/Kick_VARIABLES.f90 b/FluidFlow-old/kick/Kick_VARIABLES.f90 deleted file mode 100644 index b7efd7f..0000000 --- a/FluidFlow-old/kick/Kick_VARIABLES.f90 +++ /dev/null @@ -1,95 +0,0 @@ -MODULE KickVARIABLES - - USE DynamicDoubleArray - USE DynamicIntegerArray - USE DynamicRealArray - - IMPLICIT NONE - - - REAL :: DrillStringSpeed ! drill string speed during surge and swab [ft/s] - - REAL :: ChokeDensity , OldChokeDensity ! density of fluid that exits through choke [ppg] - REAL :: ChokeMinDensity ! [ppg] - REAL :: MaxChokeDensityChange ! [ppg/min] - - - INTEGER :: TotalGasKicks ! Number of gas kicks enetered well - REAL :: GasKickMolarMass ! molar mass of gas kick [lbm/lbmole] - REAL :: GasKickBg ! Gas formation volume factor [bbl/SCF] - REAL :: GasResPressure , GasResTemperature , GasResCompressibility ! pressure [psi] , temperature [R] and compressibility [-] at reservoir condition - REAL :: GasReservoirDensity ! density of gas kick in reservoir condition [ppg] - REAL :: BottomHolePress , BottomHoleTemperature , BottomHoleCompressibility ! pressure [psi] , temperature [R] and compressibility [-] at bottom hole condition - REAL :: KickFluxAvgTemperature , KickFluxAvgPressure , KickFluxAvgCompressibility ! Average pressure [psia] and temperature [R] for calculating gas kick flux - REAL :: GasKickViscosity ! Gas kick viscosity at average condition [cp] - REAL :: GasKickSIDensity ! density of gas kick in average condition and in SI units [gr/cm^3] - REAL :: GasKickDensity ! [ppg] - REAL :: GasKickPumpFlowRate ! change of volume of gas kick in sense of flow rate [gpm] - REAL :: FormPressure , FormTemperature - REAL(8) :: KickFormLength , KickFormTopMD , KickFormDownMD ! [ft] - REAL :: FormPermeability ! formation permeability [mD] - REAL :: GasSpecGravity ! specific gravity of gas kick relative to air [-] - REAL :: KickTc , KickPc ! critical temperature [R] and pressure [psi] of gas kick - REAL :: KickTr , KickPr ! Reduced temperature and pressure of gas kick at reservoir condition - REAL :: K_BHTpr , K_BHPpr ! Reduced temperature and pressure of gas kick at bottom hole condition - REAL :: K_A_Res , K_B_Res , K_C_Res , K_D_Res ! Coefficients in calculating compressibility at reservoir condition - REAL :: K_A_Bottomhole , K_B_Bottomhole , K_C_Bottomhole , K_D_Bottomhole - ! Coefficients in calculating compressibility at bottomhole condition - REAL :: K_Aa , K_Bb , K_Cc ! Coefficient in calculating gas viscosity at reservoir condition - REAL :: MinKickVol ! minimum of kick volume at the beginning of entrance to wellbore [gal] - REAL :: MinAllowableKickVol ! minimum allowable kick volume [ft^3] - REAL :: SecondaryKickVol ! Volume of kicks other than first kick in reservoir condition [bbl] - REAL :: SecondaryKickWeight ! Weight of kicks other than first kick in reservoir condition [lbm] - - - REAL :: Kickmdot ! mass flow rate of kick [lbm/sec] - REAL :: ExitMass ! escaped mass from choke [lbm] - REAL :: KickmdotACoef ! coefficient in calculating mdot of kick, Eqn. 5 handnote [lbm/(sec.psi)] - REAL :: KickmdotBCoef ! coefficient in calculating mdot of kick, Eqn. 5 handnote [psi] - - LOGICAL :: KickFlux ! .TRUE. = Bottomhole pressure is lower than reservoir pressure and thus gas - ! enters the bottomhole. - LOGICAL :: KickInFluxConditions ! a set of conditions, when all are true, this variable will become true - LOGICAL :: WellHeadOpen ! .TRUE. = wellhead is open or flow on choke line - ! .FALSE. = wellhead is close and no fluid flow out - LOGICAL :: WellHeadWasOpen ! well Head Condition in last time step - LOGICAL :: WellToChokeManifoldWasOpen - LOGICAL :: KickOffBottom ! .TRUE. = kick starts to rise up - LOGICAL :: KickSinglePocket ! when 'MakeKickSinglePacket' is active, only one pocket of kick exists in the well. - LOGICAL :: SolvingEquationError - LOGICAL :: KickWasExitingThroughChoke - LOGICAL :: ChokeIsClosing - - INTEGER :: NoGasPocket ! number of gas pockets (not gas kick) in wellbore which may migrate or expand - INTEGER :: KickIteration ! the number of itertion for calculating pressure and flowrate, when kick is in the well - INTEGER :: KickType ! = 0 for gas kicks , = 1 for oil kicks and = 2 for water kicks - INTEGER :: KickGasType ! = 1 for methane , = 2 for Hydrogen sulfide - INTEGER :: ChokeKroneckerDelta ! if well to choke manifold is open and well to pit is closed ChokeKroneckerDelta = 1 - INTEGER :: MaxGasPocket ! = 1 if 'single pocket model' is on and = 15 if 'single pocket model' is off - - !!!!!!!!!!!!!!!!!!!!!!! Gas Pockets Data - TYPE(DynamicDoubleArrayType) :: GasPocketOldPress , GasPocketOldVol ! pressure and volume of gas pocket at the beginning of time step [psia , ft^3] - TYPE(DynamicDoubleArrayType) :: GasPocketNewPress , GasPocketNewVol ! pressure and volume of gas pocket at the end of time step [psia , ft^3] - TYPE(DynamicRealArrayType) :: GasPocketOldTemp , GasPocketNewTemp ! temperature at the beginning (old) and at the end of time step [R] - TYPE(DynamicRealArrayType) :: GasPocketFlowInduced , GasPocketDeltaVol ! flowrate in elements above gas pocket due to mass influx and expansion [gpm] - TYPE(DynamicRealArrayType) :: GasPocketModifiedVol ! in some situation in migration process, or entering kick in a new space type - ! such as entering annulus from openhole, or entering ckokeline from annulus, - ! volume of gas pocket changes due to calculation process, and thus volume of - ! gas pocket should be modified [10^-3 ft^3] - TYPE(DynamicRealArrayType) :: GasPocketWeight ! weight of pocket [lbm] - TYPE(DynamicRealArrayType) :: GasPocketDensity ! density of gas pocket [ppg] - TYPE(DynamicRealArrayType) :: GasPocketCompressibility ! compressibility as a measure of deviation from ideal gas behavior [-] - INTEGER , DIMENSION(:,:) , ALLOCATABLE :: GasPocketFlowEl ! This matrix makes relationship between gas pockets and flow elements, - ! Further information in SUBROUTINE GasPocketFlowElementTransformer - INTEGER , DIMENSION(:,:) , ALLOCATABLE :: tempGasPocketFlowEl ! a temperorary matrix using for data saving during GasPocketFlowEl manipulation - !INTEGER , DIMENSION(:) , ALLOCATABLE :: GasPocketGasType ! = 1 for methane , = 2 for Hydrogen Sulfide - - REAL(8) , DIMENSION(:,:) , ALLOCATABLE :: KickJacobian , OldKickJacobian ! a matrix in which jacibian elements stored - REAL(8) , DIMENSION(:) , ALLOCATABLE :: KickVandPFunction - REAL(8) , DIMENSION(:) , ALLOCATABLE :: KickUnknownVector ! (2*n - 1) elements are flowrate and (2*n) elements are pressure of pockets (n >= 1) - REAL , DIMENSION(:) , ALLOCATABLE :: KickCorrectionVector - REAL :: KickCorrectionUnderRelaxation ! under relaxation parameter for correcting gas Kick Unknown Vector (0,1) - ! = 0 means no correction between two step - ! = 1 for direct correcting and no under relaxation - - END MODULE \ No newline at end of file diff --git a/FluidFlow-sh/Annulus_and_Openhole_Pressure_Distribution.f90 b/FluidFlow-sh/Annulus_and_Openhole_Pressure_Distribution.f90 deleted file mode 100644 index bdc2fe3..0000000 --- a/FluidFlow-sh/Annulus_and_Openhole_Pressure_Distribution.f90 +++ /dev/null @@ -1,278 +0,0 @@ -SUBROUTINE PressureAnnAndOHDistribution - - !! Record of revisions - !! Date Programmer Discription of change - !! ------ ------------ ----------------------- - !! 1396/07/30 Sheikh Original code - !! - - USE FricPressDropVarsModule - USE MudSystemVARIABLES - use PressureDisplayVARIABLESModule - USE GeoElements_FluidModule - USE Fluid_Flow_Startup_Vars - use KickVARIABLESModule - USE CMudPropertiesVariables - USE TD_WellGeometry - USE CReservoirVariables - use MudSystemModule - USE CHOKEVARIABLES - USE CChokeManifoldVariables - USE VARIABLES - USE CError - USE , INTRINSIC :: IEEE_ARITHMETIC - - - IMPLICIT NONE - - INTEGER :: i , j , k , l - INTEGER :: ifric - REAL :: Fraction - - - FricPressDropVars%KBOP = 0.0 - - - -IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! (mud circulation is normal wellhead may be open or closed) OR (kick is in the well and well head is open) - - - !!!!! Determining flow rate in each section - i = FricPressDropVars%AnnulusFirstEl - j = FricPressDropVars%OpenholeFirstEl - 1 - - !!!!!!!!!!!!!!!!!!!!!!!!! flowrates due to external sources like pump and tripping - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = (ClingingFactor * FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%Area + FlowEl(FricPressDropVars%StringFirstEl)%Area) * KickVARIABLES%DrillStringSpeed * ConvMintoSec * Convft3toUSgal ! flowrate in annulus due to tripping - - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate + REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump - - IF (MudSystem%ShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation - - IF (ShoeFlowElNo > FricPressDropVars%AnnulusLastEl) THEN ! shoe is in openhole - FlowEl(ShoeFlowElNo : FricPressDropVars%NumbEl)%FlowRate = - MudSystem%Qlost - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost - ELSE ! shoe is in annulus - FlowEl(ShoeFlowElNo : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost - END IF - END IF - - - !!!!!!!!!!!!!!!!!!!!!!!!! - !!!!!!!!!!!!!!!!!!!!!!!!! initial guess flowrates for opening BOP or choke line - IF (KickVARIABLES%WellHeadWasOpen == .FALSE. .AND. KickVARIABLES%NoGasPocket > 0 .AND. KickVARIABLES%KickIteration == 1) THEN - IF (KickVARIABLES%ChokeKroneckerDelta == 1) THEN ! flow on choke line - IF (FricPressDropVars%TotalOpenChokeArea < 0.01 * Choke%ChokeAreaFullyOpen) THEN - WRITE (*,*) 'density , TotalOpenChokeArea' , DownHole%Density, FricPressDropVars%TotalOpenChokeArea - FricPressDropVars%TotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen - END IF - FricPressDropVars%Kchoke = (KickVARIABLES%ChokeDensity / ((2.0 * 89158.0) * (0.26 * 0.61 * FricPressDropVars%TotalOpenChokeArea)**2)) * 4.0 ! *4.d0: seyyed gofte - GasPocketFlowInduced%Array(:) = MIN((0.6 / KickVARIABLES%NoGasPocket * SQRT(PressureGauges(2) / FricPressDropVars%Kchoke)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) - WRITE (*,*) ' PressureGauges(2) , Kchoke' , PressureDisplayVARIABLES%PressureGauges(2) , FricPressDropVars%Kchoke - WRITE (*,*) 'Initial guess after opening choke =', GasPocketFlowInduced%Array(1) - - WRITE (*,*) ' valve 49 ', Manifold%Valve(49)%Status - WRITE (*,*) ' valve 47 ', Manifold%Valve(47)%Status - WRITE (*,*) ' valve 26 ', Manifold%Valve(26)%Status - WRITE (*,*) ' valve 30 ', Manifold%Valve(30)%Status - WRITE (*,*) ' valve 34 ', Manifold%Valve(34)%Status - WRITE (*,*) ' valve 63 ', Manifold%Valve(63)%Status - WRITE (*,*) ' valve 28 ', Manifold%Valve(28)%Status - WRITE (*,*) ' valve 33 ', Manifold%Valve(33)%Status - WRITE (*,*) ' valve 62 ', Manifold%Valve(62)%Status - WRITE (*,*) ' valve 36 ', Manifold%Valve(36)%Status - WRITE (*,*) ' valve 38 ', Manifold%Valve(38)%Status - - ELSE ! flow through bell nipple - k = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl - FricPressDropVars%KBOP = FlowEl(FricPressDropVars%AnnulusLastEl)%Density / ((2.0 * 89158.0) * (0.26 * 0.61 * ShearRam%MinimumOpenArea_InBOP)**2) - GasPocketFlowInduced%Array(:) = MIN((0.1 / KickVARIABLES%NoGasPocket * SQRT(PressureDisplayVARIABLES%PressureGauges(6) / FricPressDropVars%KBOP)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) - WRITE (*,*) 'PressureGauges(6), KBOP', PressureDisplayVARIABLES%PressureGauges(6), FricPressDropVars%KBOP - WRITE (*,*) 'Initial guess after opening BOP =', GasPocketFlowInduced%Array(1) - END IF - END IF - !!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!! flowrates due to expansion of gas pockets or kick influx - !i = AnnulusFirstEl - !j = OpenholeFirstEl - 1 - IF (KickVARIABLES%NoGasPocket > 0) THEN - DO l = 1 , KickVARIABLES%NoGasPocket !GasPocketFlowEl - k = KickVARIABLES%GasPocketFlowEl(l , 1) - !WRITE (*,*) 'KickVARIABLES%GasPocketFlowEl(l , 1)', l, k, j - IF (k == 0) CALL ERRORSTOP('GasPocketFlowEl(l , 1) == 0', l) - - IF (k >= FricPressDropVars%OpenholeFirstEl) THEN ! gas pocket is in open hole only - FlowEl(k : FricPressDropVars%NumbEl)%FlowRate = FlowEl(k : FricPressDropVars%NumbEl)%FlowRate + GasPocketFlowInduced%Array(l) ! openhole elements above pocket - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus and choke line elements - ELSE IF (k < FricPressDropVars%OpenholeFirstEl) THEN ! gas pocket is in annulus ond/or choke line only - FlowEl(k : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(k : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus or choke line elements above pocket - END IF - END DO - END IF - - - !!!!!!!!!!!!!!!!!!!!!!!!! - !!!!! END - Determining flow rate in each section - - !!!!!!!!!!!!!!!!!!!!!!!!! effect of surge and swab on frictional pressure drop direction - DO l = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%OpenholeFirstEl - 1 - IF (FlowEl(l)%FlowRate < 0.0) THEN - FlowEl(l)%FrictionDirection = -1 - IF (FlowEl(l)%FlowRate > -1.0 * PressFlowrateTolerance .AND. ALLOCATED(GasPocketWeight%Array)) FlowEl(l)%FlowRate = - PressFlowrateTolerance - ELSE - FlowEl(l)%FrictionDirection = 1 - IF (FlowEl(l)%FlowRate < PressFlowrateTolerance .AND. ALLOCATED(GasPocketWeight%Array)) FlowEl(l)%FlowRate = PressFlowrateTolerance - END IF - END DO - !!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!! Calculating Back Pressure, in well to pit path back pressure = 0 - ! in well to choke manifold path back pressure is equal to pressure before choke not casing pressure - IF (KickVARIABLES%ChokeKroneckerDelta == 1) THEN - - IF (FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate < 0.0) THEN - WRITE (*,*) ' Negative choke flowrate' - FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = MAX((REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0) - END IF - MudSystem%deltaPchoke = (FricPressDropVars%Kchoke * FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate)) * 1.d0 - IF (MudSystem%deltaPchoke < 0.d0) MudSystem%deltaPchoke = 0.d0 - FricPressDropVars%BackPressure = REAL(MudSystem%deltaPchoke) - ELSE - FricPressDropVars%BackPressure = 0.0 - END IF - IF (IEEE_IS_NaN(FricPressDropVars%BackPressure)) CALL ErrorStop('NaN in calculating back pressure' , FlowEl(j)%FlowRate) - !write(*,*) 'BackPressure=' , BackPressure - - !!!!!!!!!!!!!!!!!!!!!!!!! when flow passes through choke manifold, solution process may be unstable - IF (KickVARIABLES%ChokeKroneckerDelta == 1) THEN ! thus we should stabilize solution - IF (FricPressDropVars%TotalOpenChokeArea > 0.5 * Choke%ChokeAreaFullyOpen) THEN - KickVARIABLES%KickCorrectionUnderRelaxation = 0.6 - ELSE IF (FricPressDropVars%TotalOpenChokeArea > 0.1 * Choke%ChokeAreaFullyOpen) THEN - KickVARIABLES%KickCorrectionUnderRelaxation = 0.5 - ELSE ! TotalOpenChokeArea < 0.1 * ChokeAreaFullyOpen - KickVARIABLES%KickCorrectionUnderRelaxation = 0.4 - END IF - ELSE - KickVARIABLES%KickCorrectionUnderRelaxation = 0.6 - END IF - !!!!!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!!!!! calculating frictional pressure drop in annulus, chooke line and open hole elements - DO ifric = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%NumbEl - CALL FricPressDrop(ifric) - !WRITE (*,*) ' element No, FlowRate , Density, FricPressLoss', ifric, FlowEl(ifric)%FlowRate, FlowEl(ifric)%Density, FlowEl(ifric)%FricPressLoss - IF (IEEE_IS_NaN(FlowEl(ifric)%FricPressLoss)) THEN - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%NoStringEl , FricPressDropVars%NoAnnulusEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%NoOpenHoleEl - WRITE (*,*) 'Ann/Op start, end, density, Q, mu, Type' , FlowEl(ifric)%StartX, FlowEl(ifric)%EndX, FlowEl(ifric)%Density, FlowEl(ifric)%FlowRate, FlowEl(ifric)%mueff, FlowEl(ifric)%MaterialType - CALL ErrorStop('NaN in calculating pressure drop' , ifric) - END IF - - END DO - - - !!!!!!!!!!!!!!!!!!!!!!!!! Pressure distribution in annulus - j = FricPressDropVars%OpenholeFirstEl - 1 - FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%EndPress = FricPressDropVars%BackPressure - FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%StartPress = FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%EndPress + FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FricPressLoss + FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%StaticPressDiff - - - DO l = FricPressDropVars%OpenholeFirstEl - 2 , FricPressDropVars%AnnulusFirstEl , -1 - !WRITE (*,*) '123' - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%FricPressLoss + FlowEl(l)%StaticPressDiff - END DO - - - !!!!!!!!!!!!!!!!! Pressure distribution in Open Hole - FlowEl(FricPressDropVars%NumbEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress - FlowEl(FricPressDropVars%NumbEl)%StartPress = FlowEl(FricPressDropVars%NumbEl)%EndPress + FlowEl(FricPressDropVars%NumbEl)%FricPressLoss + FlowEl(FricPressDropVars%NumbEl)%StaticPressDiff - - DO l = FricPressDropVars%NumbEl - 1 , FricPressDropVars%OpenholeFirstEl , -1 - !WRITE(*,*) ' ope' - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%FricPressLoss + FlowEl(l)%StaticPressDiff - !WRITE (*,*) ' Length, static, frictional open' , FlowEl(i)%Length, FlowEl(i)%StaticPressDiff, FlowEl(i)%FricPressLoss - - !END IF - END DO - -ELSE ! wellhead is closed and kick is in the well - !WRITE (*,*) ' well head is closed' - k = KickVARIABLES%GasPocketFlowEl(KickVARIABLES%NoGasPocket , 1) - !WRITE (*,*) 'k, Pocket Press', k, GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) - StandardPress - i = FricPressDropVars%AnnulusFirstEl - j = FricPressDropVars%OpenholeFirstEl - 1 - FlowEl(k)%StartPress = GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) - StandardPress - FlowEl(k)%EndPress = GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) - StandardPress - IF (k > FricPressDropVars%OpenholeFirstEl - 1) THEN ! Top pocket StartX is in Open hole - !WRITE (*,*) 'here 1' - DO l = k - 1 , FricPressDropVars%OpenholeFirstEl , -1 ! below elements in openhole - !WRITE (*,*) 'here 1-1' - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff - END DO - - DO l = k + 1 , FricPressDropVars%NumbEl ! Above elements in openhole - !WRITE (*,*) 'here 1-2' - FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress - FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff - END DO - - FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress = FlowEl(FricPressDropVars%NumbEl)%EndPress - FlowEl(FricPressDropVars%AnnulusFirstEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress - FlowEl(FricPressDropVars%AnnulusFirstEl)%StaticPressDiff - - DO l = FricPressDropVars%AnnulusFirstEl + 1 , FricPressDropVars%OpenholeFirstEl - 1 - FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress - FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff - END DO - - ELSE ! Top pocket StartX is in annulus or choke line - - DO l = k - 1 , FricPressDropVars%AnnulusFirstEl , -1 ! below elements in annnulus - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff - END DO - - DO l = k + 1 , FricPressDropVars%OpenholeFirstEl - 1 ! Above elements in annulus - FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress - FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff - END DO - - FlowEl(FricPressDropVars%NumbEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress - FlowEl(FricPressDropVars%NumbEl)%StartPress = FlowEl(FricPressDropVars%NumbEl)%EndPress + FlowEl(FricPressDropVars%NumbEl)%StaticPressDiff - - DO l = FricPressDropVars%NumbEl - 1 , FricPressDropVars%OpenholeFirstEl , -1 - FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress - FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff - END DO - - END IF - -END IF - - !!!!!!!!!!!!!!!!!!!!!! checking pressure for preventing NaN in pressures - DO l = FricPressDropVars%OpenholeFirstEl - 1 , FricPressDropVars%AnnulusFirstEl , -1 ! annulus or choke elements - !WRITE (*,*) 'start, end' , FlowEl(i)%StartX, FlowEl(i)%EndX - IF (IEEE_IS_NaN(FlowEl(l)%EndPress)) THEN - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%NoStringEl , FricPressDropVars%NoAnnulusEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%NoOpenHoleEl - WRITE (*,*) 'Ann/Ch start, end, density, Q, mu' , FlowEl(l)%StartX, FlowEl(l)%EndX, FlowEl(l)%Density, FlowEl(l)%FlowRate, FlowEl(l)%mueff, FlowEl(l)%MaterialType - CALL ERRORSTOP('NaN in EndPress', l) - END IF - END DO - - DO l = FricPressDropVars%NumbEl , FricPressDropVars%OpenholeFirstEl - 1 , -1 ! op elements - !WRITE (*,*) 'start, end' , FlowEl(i)%StartX, FlowEl(i)%EndX - IF (IEEE_IS_NaN(FlowEl(l)%EndPress)) THEN - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%NoStringEl , FricPressDropVars%NoAnnulusEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%NoOpenHoleEl - WRITE (*,*) 'Op start, end, density, Q, mu' , FlowEl(l)%StartX, FlowEl(l)%EndX, FlowEl(l)%Density, FlowEl(l)%FlowRate, FlowEl(l)%mueff, FlowEl(l)%MaterialType - CALL ERRORSTOP('NaN in EndPress', l) - END IF - END DO - !!!!!!!!!!!!!!!!!!!!!! - - !!!!!!!!!!!!!!!!!!!!!! - KickVARIABLES%BottomHolePress = FlowEl(FricPressDropVars%OpenholeFirstEl)%StartPress - - !!!!!!!!!!!!!!!!!!!!!! - -END SUBROUTINE \ No newline at end of file diff --git a/FluidFlow/Annulus_Property_Calculator.f90 b/FluidFlow/Annulus_Property_Calculator.f90 index 7fc4c10..7c34b66 100644 --- a/FluidFlow/Annulus_Property_Calculator.f90 +++ b/FluidFlow/Annulus_Property_Calculator.f90 @@ -4,8 +4,10 @@ SUBROUTINE AnnulusPropertyCalculator (md, den, pre, tem) use PressureDisplayVARIABLESModule USE Fluid_Flow_Startup_Vars USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE FricPressDropVarsModule - USE CDrillWatchVariables + ! use ConfigurationVariables !@ + use ConfigurationVariables IMPLICIT NONE INTEGER, intent(in) :: md ! input @@ -19,13 +21,13 @@ SUBROUTINE AnnulusPropertyCalculator (md, den, pre, tem) CALL TVD_Calculator(md * 1.d0 , TVD) - IF (md <= INT(FinalFlowEl(FricPressDropVars%AnnulusFirstEl)%StartX)) THEN !! mouse pointer is in the annulus space - DO ilocal = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%AnnulusLastEl + IF (md <= INT(FinalFlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartX)) THEN !! mouse pointer is in the annulus space + DO ilocal = data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%AnnulusLastEl IF (INT(FinalFlowEl(ilocal)%EndX) <= md) EXIT END DO - ELSE IF (md > INT(FinalFlowEl(FricPressDropVars%NumbEl)%EndX)) THEN ! mouse pointer is in the open hole space - DO ilocal = FricPressDropVars%OpenholeFirstEl , FricPressDropVars%NumbEl + ELSE IF (md > INT(FinalFlowEl(data%State%FricPressDrop%NumbEl)%EndX)) THEN ! mouse pointer is in the open hole space + DO ilocal = data%State%FricPressDrop%OpenholeFirstEl , data%State%FricPressDrop%NumbEl IF (INT(FinalFlowEl(ilocal)%EndX) <= md) EXIT END DO diff --git a/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 b/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 index 8e37a58..a48750d 100644 --- a/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 +++ b/FluidFlow/Annulus_and_Openhole_Pressure_Distribution.f90 @@ -8,17 +8,20 @@ SUBROUTINE PressureAnnAndOHDistribution USE FricPressDropVarsModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ use PressureDisplayVARIABLESModule USE GeoElements_FluidModule USE Fluid_Flow_Startup_Vars use KickVARIABLESModule USE CMudPropertiesVariables - USE TD_WellGeometry + use ConfigurationVariables !@ USE CReservoirVariables use MudSystemModule USE CHOKEVARIABLES - USE CChokeManifoldVariables - USE VARIABLES +use ConfigurationVariables !@ + use CChokeManifoldVariables + use ConfigurationVariables + use ConfigurationVariables USE CError USE , INTRINSIC :: IEEE_ARITHMETIC @@ -30,7 +33,7 @@ SUBROUTINE PressureAnnAndOHDistribution REAL :: Fraction - FricPressDropVars%KBOP = 0.0 + data%State%FricPressDrop%KBOP = 0.0 @@ -38,21 +41,21 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( !!!!! Determining flow rate in each section - i = FricPressDropVars%AnnulusFirstEl - j = FricPressDropVars%OpenholeFirstEl - 1 + i = data%State%FricPressDrop%AnnulusFirstEl + j = data%State%FricPressDrop%OpenholeFirstEl - 1 !!!!!!!!!!!!!!!!!!!!!!!!! flowrates due to external sources like pump and tripping - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = (ClingingFactor * FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%Area + FlowEl(FricPressDropVars%StringFirstEl)%Area) * KickVARIABLES%DrillStringSpeed * ConvMintoSec * Convft3toUSgal ! flowrate in annulus due to tripping + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate = (ClingingFactor * FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%Area + FlowEl(data%State%FricPressDrop%StringFirstEl)%Area) * KickVARIABLES%DrillStringSpeed * ConvMintoSec * Convft3toUSgal ! flowrate in annulus due to tripping - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate + REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate = FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate + REAL(data%State%MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt ! flowrate in annulus due to pump - IF (MudSystem%ShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation + IF (data%State%MudSystem%ShoeFractured) THEN ! reduction of flowrate due to formation fracture and lost circulation - IF (ShoeFlowElNo > FricPressDropVars%AnnulusLastEl) THEN ! shoe is in openhole - FlowEl(ShoeFlowElNo : FricPressDropVars%NumbEl)%FlowRate = - MudSystem%Qlost - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost + IF (ShoeFlowElNo > data%State%FricPressDrop%AnnulusLastEl) THEN ! shoe is in openhole + FlowEl(ShoeFlowElNo : data%State%FricPressDrop%NumbEl)%FlowRate = - data%State%MudSystem%Qlost + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate = FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate - data%State%MudSystem%Qlost ELSE ! shoe is in annulus - FlowEl(ShoeFlowElNo : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate - MudSystem%Qlost + FlowEl(ShoeFlowElNo : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate = FlowEl(ShoeFlowElNo : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate - data%State%MudSystem%Qlost END IF END IF @@ -61,13 +64,13 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( !!!!!!!!!!!!!!!!!!!!!!!!! initial guess flowrates for opening BOP or choke line IF (KickVARIABLES%WellHeadWasOpen == .FALSE. .AND. KickVARIABLES%NoGasPocket > 0 .AND. KickIteration == 1) THEN IF (KickVARIABLES%ChokeKroneckerDelta == 1) THEN ! flow on choke line - IF (FricPressDropVars%TotalOpenChokeArea < 0.01 * Choke%ChokeAreaFullyOpen) THEN - WRITE (*,*) 'density , TotalOpenChokeArea' , DownHole%Density, FricPressDropVars%TotalOpenChokeArea - FricPressDropVars%TotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen + IF (data%State%FricPressDrop%TotalOpenChokeArea < 0.01 * data%State%Choke%ChokeAreaFullyOpen) THEN + WRITE (*,*) 'density , TotalOpenChokeArea' , DownHole%Density, data%State%FricPressDrop%TotalOpenChokeArea + data%State%FricPressDrop%TotalOpenChokeArea = 0.01 * data%State%Choke%ChokeAreaFullyOpen END IF - FricPressDropVars%Kchoke = (KickVARIABLES%ChokeDensity / ((2.0 * 89158.0) * (0.26 * 0.61 * FricPressDropVars%TotalOpenChokeArea)**2)) * 4.0 ! *4.d0: seyyed gofte - GasPocketFlowInduced%Array(:) = MIN((0.6 / KickVARIABLES%NoGasPocket * SQRT(PressureDisplayVARIABLES%PressureGauges(2) / FricPressDropVars%Kchoke)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) - WRITE (*,*) ' PressureGauges(2) , Kchoke' , PressureDisplayVARIABLES%PressureGauges(2) , FricPressDropVars%Kchoke + data%State%FricPressDrop%Kchoke = (KickVARIABLES%ChokeDensity / ((2.0 * 89158.0) * (0.26 * 0.61 * data%State%FricPressDrop%TotalOpenChokeArea)**2)) * 4.0 ! *4.d0: seyyed gofte + GasPocketFlowInduced%Array(:) = MIN((0.6 / KickVARIABLES%NoGasPocket * SQRT(data%State%PressureDisplay%PressureGauges(2) / data%State%FricPressDrop%Kchoke)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) + WRITE (*,*) ' PressureGauges(2) , Kchoke' , data%State%PressureDisplay%PressureGauges(2) , data%State%FricPressDrop%Kchoke WRITE (*,*) 'Initial guess after opening choke =', GasPocketFlowInduced%Array(1) WRITE (*,*) ' valve 49 ', Manifold%Valve(49)%Status @@ -83,10 +86,10 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( WRITE (*,*) ' valve 38 ', Manifold%Valve(38)%Status ELSE ! flow through bell nipple - k = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl - FricPressDropVars%KBOP = FlowEl(FricPressDropVars%AnnulusLastEl)%Density / ((2.0 * 89158.0) * (0.26 * 0.61 * ShearRam%MinimumOpenArea_InBOP)**2) - GasPocketFlowInduced%Array(:) = MIN((0.1 / KickVARIABLES%NoGasPocket * SQRT(PressureDisplayVARIABLES%PressureGauges(6) / FricPressDropVars%KBOP)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) - WRITE (*,*) 'PressureGauges(6), KBOP', PressureDisplayVARIABLES%PressureGauges(6), FricPressDropVars%KBOP + k = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + data%State%FricPressDrop%KBOP = FlowEl(data%State%FricPressDrop%AnnulusLastEl)%Density / ((2.0 * 89158.0) * (0.26 * 0.61 * data%State%ShearRAM%MinimumOpenArea_InBOP)**2) + GasPocketFlowInduced%Array(:) = MIN((0.1 / KickVARIABLES%NoGasPocket * SQRT(data%State%PressureDisplay%PressureGauges(6) / data%State%FricPressDrop%KBOP)) , (0.05 * GasPocketNewVol%Array(:) * ConvFt3toUSgal / 60 / dt)) + WRITE (*,*) 'PressureGauges(6), KBOP', data%State%PressureDisplay%PressureGauges(6), data%State%FricPressDrop%KBOP WRITE (*,*) 'Initial guess after opening BOP =', GasPocketFlowInduced%Array(1) END IF END IF @@ -101,11 +104,11 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( !WRITE (*,*) 'KickVARIABLES%GasPocketFlowEl(l , 1)', l, k, j IF (k == 0) CALL ERRORSTOP('GasPocketFlowEl(l , 1) == 0', l) - IF (k >= FricPressDropVars%OpenholeFirstEl) THEN ! gas pocket is in open hole only - FlowEl(k : FricPressDropVars%NumbEl)%FlowRate = FlowEl(k : FricPressDropVars%NumbEl)%FlowRate + GasPocketFlowInduced%Array(l) ! openhole elements above pocket - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus and choke line elements - ELSE IF (k < FricPressDropVars%OpenholeFirstEl) THEN ! gas pocket is in annulus ond/or choke line only - FlowEl(k : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = FlowEl(k : FricPressDropVars%OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus or choke line elements above pocket + IF (k >= data%State%FricPressDrop%OpenholeFirstEl) THEN ! gas pocket is in open hole only + FlowEl(k : data%State%FricPressDrop%NumbEl)%FlowRate = FlowEl(k : data%State%FricPressDrop%NumbEl)%FlowRate + GasPocketFlowInduced%Array(l) ! openhole elements above pocket + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate = FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus and choke line elements + ELSE IF (k < data%State%FricPressDrop%OpenholeFirstEl) THEN ! gas pocket is in annulus ond/or choke line only + FlowEl(k : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate = FlowEl(k : data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate + GasPocketFlowInduced%Array(l) ! annulus or choke line elements above pocket END IF END DO END IF @@ -115,7 +118,7 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( !!!!! END - Determining flow rate in each section !!!!!!!!!!!!!!!!!!!!!!!!! effect of surge and swab on frictional pressure drop direction - DO l = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%OpenholeFirstEl - 1 + DO l = data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%OpenholeFirstEl - 1 IF (FlowEl(l)%FlowRate < 0.0) THEN FlowEl(l)%FrictionDirection = -1 IF (FlowEl(l)%FlowRate > -1.0 * PressFlowrateTolerance .AND. ALLOCATED(GasPocketWeight%Array)) FlowEl(l)%FlowRate = - PressFlowrateTolerance @@ -130,24 +133,24 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( ! in well to choke manifold path back pressure is equal to pressure before choke not casing pressure IF (KickVARIABLES%ChokeKroneckerDelta == 1) THEN - IF (FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate < 0.0) THEN + IF (FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate < 0.0) THEN WRITE (*,*) ' Negative choke flowrate' - FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate = MAX((REAL(MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0) + FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate = MAX((REAL(data%State%MudSystem%MudVolume_InjectedToBH) * ConvMintoSec / dt) , 10.0) END IF - MudSystem%deltaPchoke = (FricPressDropVars%Kchoke * FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FlowRate)) * 1.d0 - IF (MudSystem%deltaPchoke < 0.d0) MudSystem%deltaPchoke = 0.d0 - FricPressDropVars%BackPressure = REAL(MudSystem%deltaPchoke) + data%State%MudSystem%deltaPchoke = (data%State%FricPressDrop%Kchoke * FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate * ABS(FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%FlowRate)) * 1.d0 + IF (data%State%MudSystem%deltaPchoke < 0.d0) data%State%MudSystem%deltaPchoke = 0.d0 + data%State%FricPressDrop%BackPressure = REAL(data%State%MudSystem%deltaPchoke) ELSE - FricPressDropVars%BackPressure = 0.0 + data%State%FricPressDrop%BackPressure = 0.0 END IF - IF (IEEE_IS_NaN(FricPressDropVars%BackPressure)) CALL ErrorStop('NaN in calculating back pressure' , FlowEl(j)%FlowRate) + IF (IEEE_IS_NaN(data%State%FricPressDrop%BackPressure)) CALL ErrorStop('NaN in calculating back pressure' , FlowEl(j)%FlowRate) !write(*,*) 'BackPressure=' , BackPressure !!!!!!!!!!!!!!!!!!!!!!!!! when flow passes through choke manifold, solution process may be unstable IF (KickVARIABLES%ChokeKroneckerDelta == 1) THEN ! thus we should stabilize solution - IF (FricPressDropVars%TotalOpenChokeArea > 0.5 * Choke%ChokeAreaFullyOpen) THEN + IF (data%State%FricPressDrop%TotalOpenChokeArea > 0.5 * data%State%Choke%ChokeAreaFullyOpen) THEN KickVARIABLES%KickCorrectionUnderRelaxation = 0.6 - ELSE IF (FricPressDropVars%TotalOpenChokeArea > 0.1 * Choke%ChokeAreaFullyOpen) THEN + ELSE IF (data%State%FricPressDrop%TotalOpenChokeArea > 0.1 * data%State%Choke%ChokeAreaFullyOpen) THEN KickVARIABLES%KickCorrectionUnderRelaxation = 0.5 ELSE ! TotalOpenChokeArea < 0.1 * ChokeAreaFullyOpen KickVARIABLES%KickCorrectionUnderRelaxation = 0.4 @@ -158,11 +161,11 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( !!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!! calculating frictional pressure drop in annulus, chooke line and open hole elements - DO ifric = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%NumbEl + DO ifric = data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%NumbEl CALL FricPressDrop(ifric) !WRITE (*,*) ' element No, FlowRate , Density, FricPressLoss', ifric, FlowEl(ifric)%FlowRate, FlowEl(ifric)%Density, FlowEl(ifric)%FricPressLoss IF (IEEE_IS_NaN(FlowEl(ifric)%FricPressLoss)) THEN - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%NoStringEl , FricPressDropVars%NoAnnulusEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%NoOpenHoleEl + WRITE (*,*) 'H, S, A, Ch, O', data%State%FricPressDrop%NoHorizontalEl , data%State%FricPressDrop%NoStringEl , data%State%FricPressDrop%NoAnnulusEl , data%State%FricPressDrop%NoWellToChokeEl , data%State%FricPressDrop%NoOpenHoleEl WRITE (*,*) 'Ann/Op start, end, density, Q, mu, Type' , FlowEl(ifric)%StartX, FlowEl(ifric)%EndX, FlowEl(ifric)%Density, FlowEl(ifric)%FlowRate, FlowEl(ifric)%mueff, FlowEl(ifric)%MaterialType CALL ErrorStop('NaN in calculating pressure drop' , ifric) END IF @@ -171,12 +174,12 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( !!!!!!!!!!!!!!!!!!!!!!!!! Pressure distribution in annulus - j = FricPressDropVars%OpenholeFirstEl - 1 - FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%EndPress = FricPressDropVars%BackPressure - FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%StartPress = FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%EndPress + FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%FricPressLoss + FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%StaticPressDiff + j = data%State%FricPressDrop%OpenholeFirstEl - 1 + FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%EndPress = data%State%FricPressDrop%BackPressure + FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%StartPress = FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%EndPress + FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%FricPressLoss + FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%StaticPressDiff - DO l = FricPressDropVars%OpenholeFirstEl - 2 , FricPressDropVars%AnnulusFirstEl , -1 + DO l = data%State%FricPressDrop%OpenholeFirstEl - 2 , data%State%FricPressDrop%AnnulusFirstEl , -1 !WRITE (*,*) '123' FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%FricPressLoss + FlowEl(l)%StaticPressDiff @@ -184,10 +187,10 @@ IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket == 0) THEN !! ( !!!!!!!!!!!!!!!!! Pressure distribution in Open Hole - FlowEl(FricPressDropVars%NumbEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress - FlowEl(FricPressDropVars%NumbEl)%StartPress = FlowEl(FricPressDropVars%NumbEl)%EndPress + FlowEl(FricPressDropVars%NumbEl)%FricPressLoss + FlowEl(FricPressDropVars%NumbEl)%StaticPressDiff + FlowEl(data%State%FricPressDrop%NumbEl)%EndPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress + FlowEl(data%State%FricPressDrop%NumbEl)%StartPress = FlowEl(data%State%FricPressDrop%NumbEl)%EndPress + FlowEl(data%State%FricPressDrop%NumbEl)%FricPressLoss + FlowEl(data%State%FricPressDrop%NumbEl)%StaticPressDiff - DO l = FricPressDropVars%NumbEl - 1 , FricPressDropVars%OpenholeFirstEl , -1 + DO l = data%State%FricPressDrop%NumbEl - 1 , data%State%FricPressDrop%OpenholeFirstEl , -1 !WRITE(*,*) ' ope' FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%FricPressLoss + FlowEl(l)%StaticPressDiff @@ -200,48 +203,48 @@ ELSE ! wellhead is closed and kick is in the well !WRITE (*,*) ' well head is closed' k = KickVARIABLES%GasPocketFlowEl(KickVARIABLES%NoGasPocket , 1) !WRITE (*,*) 'k, Pocket Press', k, GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) - StandardPress - i = FricPressDropVars%AnnulusFirstEl - j = FricPressDropVars%OpenholeFirstEl - 1 + i = data%State%FricPressDrop%AnnulusFirstEl + j = data%State%FricPressDrop%OpenholeFirstEl - 1 FlowEl(k)%StartPress = GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) - StandardPress FlowEl(k)%EndPress = GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) - StandardPress - IF (k > FricPressDropVars%OpenholeFirstEl - 1) THEN ! Top pocket StartX is in Open hole + IF (k > data%State%FricPressDrop%OpenholeFirstEl - 1) THEN ! Top pocket StartX is in Open hole !WRITE (*,*) 'here 1' - DO l = k - 1 , FricPressDropVars%OpenholeFirstEl , -1 ! below elements in openhole + DO l = k - 1 , data%State%FricPressDrop%OpenholeFirstEl , -1 ! below elements in openhole !WRITE (*,*) 'here 1-1' FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff END DO - DO l = k + 1 , FricPressDropVars%NumbEl ! Above elements in openhole + DO l = k + 1 , data%State%FricPressDrop%NumbEl ! Above elements in openhole !WRITE (*,*) 'here 1-2' FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff END DO - FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress = FlowEl(FricPressDropVars%NumbEl)%EndPress - FlowEl(FricPressDropVars%AnnulusFirstEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress - FlowEl(FricPressDropVars%AnnulusFirstEl)%StaticPressDiff + FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress = FlowEl(data%State%FricPressDrop%NumbEl)%EndPress + FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%EndPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress - FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StaticPressDiff - DO l = FricPressDropVars%AnnulusFirstEl + 1 , FricPressDropVars%OpenholeFirstEl - 1 + DO l = data%State%FricPressDrop%AnnulusFirstEl + 1 , data%State%FricPressDrop%OpenholeFirstEl - 1 FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff END DO ELSE ! Top pocket StartX is in annulus or choke line - DO l = k - 1 , FricPressDropVars%AnnulusFirstEl , -1 ! below elements in annnulus + DO l = k - 1 , data%State%FricPressDrop%AnnulusFirstEl , -1 ! below elements in annnulus FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff END DO - DO l = k + 1 , FricPressDropVars%OpenholeFirstEl - 1 ! Above elements in annulus + DO l = k + 1 , data%State%FricPressDrop%OpenholeFirstEl - 1 ! Above elements in annulus FlowEl(l)%StartPress = FlowEl(l - 1)%EndPress FlowEl(l)%EndPress = FlowEl(l)%StartPress - FlowEl(l)%StaticPressDiff END DO - FlowEl(FricPressDropVars%NumbEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress - FlowEl(FricPressDropVars%NumbEl)%StartPress = FlowEl(FricPressDropVars%NumbEl)%EndPress + FlowEl(FricPressDropVars%NumbEl)%StaticPressDiff + FlowEl(data%State%FricPressDrop%NumbEl)%EndPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress + FlowEl(data%State%FricPressDrop%NumbEl)%StartPress = FlowEl(data%State%FricPressDrop%NumbEl)%EndPress + FlowEl(data%State%FricPressDrop%NumbEl)%StaticPressDiff - DO l = FricPressDropVars%NumbEl - 1 , FricPressDropVars%OpenholeFirstEl , -1 + DO l = data%State%FricPressDrop%NumbEl - 1 , data%State%FricPressDrop%OpenholeFirstEl , -1 FlowEl(l)%EndPress = FlowEl(l + 1)%StartPress FlowEl(l)%StartPress = FlowEl(l)%EndPress + FlowEl(l)%StaticPressDiff END DO @@ -251,19 +254,19 @@ ELSE ! wellhead is closed and kick is in the well END IF !!!!!!!!!!!!!!!!!!!!!! checking pressure for preventing NaN in pressures - DO l = FricPressDropVars%OpenholeFirstEl - 1 , FricPressDropVars%AnnulusFirstEl , -1 ! annulus or choke elements + DO l = data%State%FricPressDrop%OpenholeFirstEl - 1 , data%State%FricPressDrop%AnnulusFirstEl , -1 ! annulus or choke elements !WRITE (*,*) 'start, end' , FlowEl(i)%StartX, FlowEl(i)%EndX IF (IEEE_IS_NaN(FlowEl(l)%EndPress)) THEN - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%NoStringEl , FricPressDropVars%NoAnnulusEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%NoOpenHoleEl + WRITE (*,*) 'H, S, A, Ch, O', data%State%FricPressDrop%NoHorizontalEl , data%State%FricPressDrop%NoStringEl , data%State%FricPressDrop%NoAnnulusEl , data%State%FricPressDrop%NoWellToChokeEl , data%State%FricPressDrop%NoOpenHoleEl WRITE (*,*) 'Ann/Ch start, end, density, Q, mu' , FlowEl(l)%StartX, FlowEl(l)%EndX, FlowEl(l)%Density, FlowEl(l)%FlowRate, FlowEl(l)%mueff, FlowEl(l)%MaterialType CALL ERRORSTOP('NaN in EndPress', l) END IF END DO - DO l = FricPressDropVars%NumbEl , FricPressDropVars%OpenholeFirstEl - 1 , -1 ! op elements + DO l = data%State%FricPressDrop%NumbEl , data%State%FricPressDrop%OpenholeFirstEl - 1 , -1 ! op elements !WRITE (*,*) 'start, end' , FlowEl(i)%StartX, FlowEl(i)%EndX IF (IEEE_IS_NaN(FlowEl(l)%EndPress)) THEN - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%NoStringEl , FricPressDropVars%NoAnnulusEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%NoOpenHoleEl + WRITE (*,*) 'H, S, A, Ch, O', data%State%FricPressDrop%NoHorizontalEl , data%State%FricPressDrop%NoStringEl , data%State%FricPressDrop%NoAnnulusEl , data%State%FricPressDrop%NoWellToChokeEl , data%State%FricPressDrop%NoOpenHoleEl WRITE (*,*) 'Op start, end, density, Q, mu' , FlowEl(l)%StartX, FlowEl(l)%EndX, FlowEl(l)%Density, FlowEl(l)%FlowRate, FlowEl(l)%mueff, FlowEl(l)%MaterialType CALL ERRORSTOP('NaN in EndPress', l) END IF @@ -271,7 +274,7 @@ END IF !!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!! - KickVARIABLES%BottomHolePress = FlowEl(FricPressDropVars%OpenholeFirstEl)%StartPress + KickVARIABLES%BottomHolePress = FlowEl(data%State%FricPressDrop%OpenholeFirstEl)%StartPress !!!!!!!!!!!!!!!!!!!!!! diff --git a/FluidFlow/Flow_Startup.f90 b/FluidFlow/Flow_Startup.f90 index 928df7b..3411798 100644 --- a/FluidFlow/Flow_Startup.f90 +++ b/FluidFlow/Flow_Startup.f90 @@ -6,20 +6,22 @@ SUBROUTINE FlowStartup USE FricPressDropVarsModule use KickVARIABLESModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ use PressureDisplayVARIABLESModule USE CShoeVariables USE TD_DrillStemComponents - USE TD_WellGeometry, pi3 => pi - USE CPathGenerationVariables + use ConfigurationVariables !@, pi3 => pi + use ConfigurationVariables !@ USE CWellSurveyDataVariables - Use CHOKEVARIABLES, pi4 => pi + USE CHOKEVARIABLES +use ConfigurationVariables !@, pi4 => pi use ConfigurationVariables IMPLICIT NONE INTEGER :: i - PressureDisplayVARIABLES%PressureGauges(:) = 0.0 + data%State%PressureDisplay%PressureGauges(:) = 0.0 KickVARIABLES%KickSinglePocket = Reservoir%MakeKickSinglePacket IF (KickVARIABLES%KickSinglePocket) THEN @@ -40,75 +42,75 @@ SUBROUTINE FlowStartup KickVARIABLES%NoGasPocket = 0 ! No Kick KickVARIABLES%WellHeadOpen = .TRUE. KickVARIABLES%WellHeadWasOpen = .TRUE. - FricPressDropVars%BackPressure = 0.0 + data%State%FricPressDrop%BackPressure = 0.0 KickVARIABLES%GasKickPumpFlowRate = 0.0 DownHole%KickVolume = 0.0 DownHole%InfluxRate = 0.0 KickVARIABLES%ExitMass = 0.0 KickVARIABLES%MinAllowableKickVol = 1.0 * (42.0 / Convft3toUSgal) ! 1 bbl * 42 gal/bbl / 7.48 gal/ft^3 = ... ft^3 - FricPressDropVars%StCompressedMudVol = 0.0 - FricPressDropVars%AnnCompressedMudVol = 0.0 + data%State%FricPressDrop%StCompressedMudVol = 0.0 + data%State%FricPressDrop%AnnCompressedMudVol = 0.0 KickVARIABLES%KickFlux = .FALSE. KickVARIABLES%KickOffBottom = .FALSE. KickVARIABLES%KickWasExitingThroughChoke = .FALSE. - FricPressDropVars%FloatValveOpen = .TRUE. + data%State%FricPressDrop%FloatValveOpen = .TRUE. - Choke%ChokeAreaFullyOpen = 123.0 / 64.0 ! fully open area is 123/64 in^2 = 0.01334635 ft^2 - FricPressDropVars%ChokeBypassArea = PI / 4.0 * BopStackSpecification%ChokeLineId**2 - FricPressDropVars%BHPSafetyMargin = 150.0 - FricPressDropVars%AChBHPTol = 15.0 + data%State%Choke%ChokeAreaFullyOpen = 123.0 / 64.0 ! fully open area is 123/64 in^2 = 0.01334635 ft^2 + data%State%FricPressDrop%ChokeBypassArea = PI / 4.0 * BopStackSpecification%ChokeLineId**2 + data%State%FricPressDrop%BHPSafetyMargin = 150.0 + data%State%FricPressDrop%AChBHPTol = 15.0 - FricPressDropVars%ManChoke1Plug = 0 - FricPressDropVars%ManChoke2Plug = 0 - FricPressDropVars%ManChoke1Washout = 0 - FricPressDropVars%ManChoke2Washout = 0 - FricPressDropVars%BitJetsPlugged = 0 - FricPressDropVars%BitJetsWashedOut = 0 - FricPressDropVars%CasingPressure_DataDisplayMalF = 0 + data%State%FricPressDrop%ManChoke1Plug = 0 + data%State%FricPressDrop%ManChoke2Plug = 0 + data%State%FricPressDrop%ManChoke1Washout = 0 + data%State%FricPressDrop%ManChoke2Washout = 0 + data%State%FricPressDrop%BitJetsPlugged = 0 + data%State%FricPressDrop%BitJetsWashedOut = 0 + data%State%FricPressDrop%CasingPressure_DataDisplayMalF = 0 SoundSpeed = 1530.0 / Convfttom - PressureDisplayVARIABLES%PressureTimeStepDelay(1) = INT(2.0 * SUM(Configuration%StringConfiguration%StringConfigurations(2:)%ComponentLength) / SoundSpeed / dt) - PressureDisplayVARIABLES%PressureTimeStepDelay(2) = INT(PathGeneration%Items(SIZE(PathGeneration%Items))%MeasuredDepth / SoundSpeed / dt) - PressureDisplayVARIABLES%PressureTimeStepDelay(3) = INT(Shoe%ShoeDepth / SoundSpeed / dt) + data%State%PressureDisplay%PressureTimeStepDelay(1) = INT(2.0 * SUM(data%Configuration%StringConfiguration%StringConfigurations(2:)%ComponentLength) / SoundSpeed / dt) + data%State%PressureDisplay%PressureTimeStepDelay(2) = INT(PathGeneration%Items(SIZE(PathGeneration%Items))%MeasuredDepth / SoundSpeed / dt) + data%State%PressureDisplay%PressureTimeStepDelay(3) = INT(Shoe%ShoeDepth / SoundSpeed / dt) !WRITE (*,*) SUM(StringConfigurations(2:)%ComponentLength), PathGenerations(SIZE(PathGenerations))%TotalVerticalDepth!, WellSurveyData(SIZE(WellSurveyData))%TotalVerticalDepth !WRITE (*,*) PathGenerations(SIZE(PathGenerations))%MeasuredDepth!, WellSurveyData(SIZE(WellSurveyData))%MeasuredDepth - WRITE (*,*) 'time step delay', PressureDisplayVARIABLES%PressureTimeStepDelay + WRITE (*,*) 'time step delay', data%State%PressureDisplay%PressureTimeStepDelay - DO i = 1 , PressureDisplayVARIABLES%PressureTimeStepDelay(1) + DO i = 1 , data%State%PressureDisplay%PressureTimeStepDelay(1) CALL PumpPressureDelay%AddToFirst(0.0) END DO - DO i = 1 , PressureDisplayVARIABLES%PressureTimeStepDelay(2) + DO i = 1 , data%State%PressureDisplay%PressureTimeStepDelay(2) CALL BottomHolePressureDelay%AddToFirst(REAL(0.052 * MudProperties%ActiveDensity * PathGeneration%Items(SIZE(PathGeneration%Items))%TotalVerticalDepth)) END DO - DO i = 1 , PressureDisplayVARIABLES%PressureTimeStepDelay(3) + DO i = 1 , data%State%PressureDisplay%PressureTimeStepDelay(3) CALL ShoePressureDelay%AddToFirst(REAL(0.052 * MudProperties%ActiveDensity * Shoe%ShoeDepth)) END DO !!!!!!! Methane Information - GasType(1)%CritPress = 673.0 - GasType(1)%CritTemp = 344.0 - GasType(1)%MolarWt = 16.04 - GasType(1)%StDensity = 0.04238 - GasType(1)%GasConstant = RUniversal / GasType(1)%MolarWt + data%State%GasType(1)%CritPress = 673.0 + data%State%GasType(1)%CritTemp = 344.0 + data%State%GasType(1)%MolarWt = 16.04 + data%State%GasType(1)%StDensity = 0.04238 + data%State%GasType(1)%GasConstant = RUniversal / data%State%GasType(1)%MolarWt !!!!!!!! H2S Information - GasType(2)%CritPress = 1306.0 - GasType(2)%CritTemp = 673.0 - GasType(2)%MolarWt = 34.08 - GasType(2)%StDensity = 0.09087 - GasType(2)%GasConstant = RUniversal / GasType(2)%MolarWt + data%State%GasType(2)%CritPress = 1306.0 + data%State%GasType(2)%CritTemp = 673.0 + data%State%GasType(2)%MolarWt = 34.08 + data%State%GasType(2)%StDensity = 0.09087 + data%State%GasType(2)%GasConstant = RUniversal / data%State%GasType(2)%MolarWt !!!!!!!! CO2 Information - GasType(3)%CritPress = 1072.0 - GasType(3)%CritTemp = 548.0 - GasType(3)%MolarWt = 44.01 - !GasType(3)%StDensity = 00 - GasType(3)%GasConstant = RUniversal / GasType(2)%MolarWt + data%State%GasType(3)%CritPress = 1072.0 + data%State%GasType(3)%CritTemp = 548.0 + data%State%GasType(3)%MolarWt = 44.01 + !data%State%GasType(3)%StDensity = 00 + data%State%GasType(3)%GasConstant = RUniversal / data%State%GasType(2)%MolarWt !!!!!!!! Mud density and viscosity Theta600Refrence = MudProperties%ActiveThetaSixHundred diff --git a/FluidFlow/Flow_Startup_VARIABLES.f90 b/FluidFlow/Flow_Startup_VARIABLES.f90 index f47a842..399c9c6 100644 --- a/FluidFlow/Flow_Startup_VARIABLES.f90 +++ b/FluidFlow/Flow_Startup_VARIABLES.f90 @@ -2,10 +2,9 @@ MODULE Fluid_Flow_Startup_Vars !!! In this module constants and conversion factors are stated - REAL , PARAMETER :: RUniversal = 10.73159 ! [psia.ft^3/(lbmole.R)] REAL , PARAMETER :: RUniversalSI = 8.314 * 10**6 ! [Pa.cm^3/(mole.K)] - REAL , PARAMETER :: PI = 3.141593 ! Pi number + ! REAL , PARAMETER :: PI = 3.141593 ! Pi number REAL , PARAMETER :: StandardPress = 14.7 ! [psia] REAL , PARAMETER :: StandardTemp = 519.67 ! 60 F [R] , Temp F = Temp R + 459.67 REAL , PARAMETER :: dt = 0.1 ! time step = 0.1 [s] @@ -56,8 +55,7 @@ MODULE Fluid_Flow_Startup_Vars REAL :: MolarWt ! molar weight [lbm/lbmole] REAL :: StDensity ! density at standard pressure (14.7 psi) and temperature (60 F = 520 Ra) [lbm/ft^3] REAL :: GasConstant ! Gas constant = RUniversal/MolarWt [psia.ft^3/(R.lbm)] - END TYPE GasData - TYPE(GasData) :: GasType(3) ! 1 = methane , 2 = Hydrogen sulfide , 3 = Carbon dioxid + END TYPE GasData END MODULE diff --git a/FluidFlow/Fluid_Flow_Solver.f90 b/FluidFlow/Fluid_Flow_Solver.f90 index db5a7a5..de8cd40 100644 --- a/FluidFlow/Fluid_Flow_Solver.f90 +++ b/FluidFlow/Fluid_Flow_Solver.f90 @@ -6,6 +6,7 @@ subroutine Fluid_Flow_Solver use PressureDisplayVARIABLESModule USE FricPressDropVarsModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE Fluid_Flow_Startup_Vars USE CError @@ -21,7 +22,7 @@ subroutine Fluid_Flow_Solver !WRITE (*,*) ' fluid flow pointer 2' - MudSystem%FluidFlowCounter = MudSystem%FluidFlowCounter + 1 + data%State%MudSystem%FluidFlowCounter = data%State%MudSystem%FluidFlowCounter + 1 call CirculationCodeSelect diff --git a/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 b/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 index 2bf6449..f26ed0a 100644 --- a/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 +++ b/FluidFlow/Horizontal_and_String_Pressure_Distribution.f90 @@ -10,22 +10,25 @@ SUBROUTINE PressureHorizAndStringDistribution USE FricPressDropVarsModule use PressureDisplayVARIABLESModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE GeoElements_FluidModule USE Fluid_Flow_Startup_Vars use KickVARIABLESModule USE CMudPropertiesVariables - USE CDataDisplayConsoleVariables !, StandPipePressureDataDisplay=> ChokeControlPanel%StandPipePressure - USE CDataDisplayConsoleVariables !, CasingPressureDataDisplay=> CasingPressure - USE CDrillWatchVariables + use CDataDisplayConsole + use ConfigurationVariables !, StandPipePressureDataDisplay=> data%EquipmentControl%ChokeControlPanel%StandPipePressure + use CDataDisplayConsole + use ConfigurationVariables !, CasingPressureDataDisplay=> CasingPressure + use ConfigurationVariables !@ USE CShoeVariables USE CDownHoleVariables! , OperationScenarioCommon%ElevatorConnection => DownHole%CasingPressure - USE TD_WellGeometry + use ConfigurationVariables !@ USE CManifolds - USE VARIABLES + use ConfigurationVariables USE CError use UTUBEVARSModule - USE CKellyConnectionEnumVariables - USE Pumps_VARIABLES + use OperationScenariosModule + use ConfigurationVariables USE , INTRINSIC :: IEEE_ARITHMETIC Use TD_DrillStemComponents Use sROP_Variables @@ -48,52 +51,52 @@ SUBROUTINE PressureHorizAndStringDistribution BitPressLoss = 0.0 KickVARIABLES%WellHeadWasOpen = KickVARIABLES%WellHeadOpen - KickVARIABLES%WellToChokeManifoldWasOpen = MudSystem%WellToChokeManifoldOpen + KickVARIABLES%WellToChokeManifoldWasOpen = data%State%MudSystem%WellToChokeManifoldOpen KickVARIABLES%KickWasExitingThroughChoke = .FALSE. - IF (MudSystem%UtubeMode1Activated .OR. FricPressDropVars%FloatValveWasOpen == .FALSE.) THEN ! Horizontal line flow rate - FlowEl(1 : FricPressDropVars%NoHorizontalEl)%FlowRate = 0.0 + IF (data%State%MudSystem%UtubeMode1Activated .OR. data%State%FricPressDrop%FloatValveWasOpen == .FALSE.) THEN ! Horizontal line flow rate + FlowEl(1 : data%State%FricPressDrop%NoHorizontalEl)%FlowRate = 0.0 ELSE ! connection and line is open - FlowEl(1 : FricPressDropVars%NoHorizontalEl)%FlowRate = MudSystem%StringFlowRate ! pump flow rate [gpm] + FlowEl(1 : data%State%FricPressDrop%NoHorizontalEl)%FlowRate = data%State%MudSystem%StringFlowRate ! pump flow rate [gpm] END IF !WRITE (*,*) 'a)A/B P Bit', StaticHeadOnBit , FlowEl(AnnulusFirstEl)%StartPress , SUM(FlowEl(StringFirstEl : StringLastEl)%StaticPressDiff) !IF (FloatValveIn == .FALSE.) FloatValveOpen = .TRUE. - FricPressDropVars%FloatValveWasOpen = FricPressDropVars%FloatValveOpen + data%State%FricPressDrop%FloatValveWasOpen = data%State%FricPressDrop%FloatValveOpen - PressBelowFloatValve = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress + PressBelowFloatValve = FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress - FricPressDropVars%StMudVol = SUM(FlowEl(1 : FricPressDropVars%StringLastEl)%Volume) * Convft3toUSGal - FricPressDropVars%StDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * FricPressDropVars%StMudVol) + data%State%FricPressDrop%StMudVol = SUM(FlowEl(1 : data%State%FricPressDrop%StringLastEl)%Volume) * Convft3toUSGal + data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * data%State%FricPressDrop%StMudVol) - FricPressDropVars%AnnMudVol = SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%Volume) * Convft3toUSGal + data%State%FricPressDrop%AnnMudVol = SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%Volume) * Convft3toUSGal - IF ( (DownHole%KickVolume > 2.0) .or. (KickVARIABLES%NoGasPocket>1) .or. (any(FlowEl(FricPressDropVars%OpenholeFirstEl:FricPressDropVars%NumbEl)%Materialtype==1)) .or. (ROP_bit%RateofPenetration > 0.0) ) THEN - FricPressDropVars%AnnCompressedMudVol = 0.0 - FricPressDropVars%AnnDeltaPDueToCompressibility = 0.0 + IF ( (DownHole%KickVolume > 2.0) .or. (KickVARIABLES%NoGasPocket>1) .or. (any(FlowEl(data%State%FricPressDrop%OpenholeFirstEl:data%State%FricPressDrop%NumbEl)%Materialtype==1)) .or. (data%State%ROP_Bit%RateofPenetration > 0.0) ) THEN + data%State%FricPressDrop%AnnCompressedMudVol = 0.0 + data%State%FricPressDrop%AnnDeltaPDueToCompressibility = 0.0 ELSE IF (KickVARIABLES%WellHeadOpen) THEN - FricPressDropVars%AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * FricPressDropVars%AnnMudVol) + data%State%FricPressDrop%AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * data%State%FricPressDrop%AnnMudVol) - FricPressDropVars%AnnCompressedMudVol = FricPressDropVars%BackPressure / FricPressDropVars%AnnDeltaPtoDeltaVCompressibility - FricPressDropVars%AnnDeltaPDueToCompressibility = FricPressDropVars%AnnCompressedMudVol / (MudCompressibility * FricPressDropVars%AnnMudVol) + data%State%FricPressDrop%AnnCompressedMudVol = data%State%FricPressDrop%BackPressure / data%State%FricPressDrop%AnnDeltaPtoDeltaVCompressibility + data%State%FricPressDrop%AnnDeltaPDueToCompressibility = data%State%FricPressDrop%AnnCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%AnnMudVol) ELSE ! No gas pocket, wellhead is closed and mud is compressed based on volume pumped into annulus - FricPressDropVars%AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * FricPressDropVars%AnnMudVol) - FricPressDropVars%AnnCompressedMudVol = FricPressDropVars%AnnCompressedMudVol + REAL(MudSystem%Ann_Saved_MudDischarged_Volume_Final) !!!!!!!!! - FricPressDropVars%AnnCompressedMudVol = MAX((FricPressDropVars%AnnCompressedMudVol - REAL(MudSystem%Qlost / ConvMinToSec / dt)) , 0.0) - FricPressDropVars%AnnDeltaPDueToCompressibility = FricPressDropVars%AnnCompressedMudVol / (MudCompressibility * FricPressDropVars%AnnMudVol) + data%State%FricPressDrop%AnnDeltaPtoDeltaVCompressibility = 1.0 / (MudCompressibility * data%State%FricPressDrop%AnnMudVol) + data%State%FricPressDrop%AnnCompressedMudVol = data%State%FricPressDrop%AnnCompressedMudVol + REAL(data%State%MudSystem%Ann_Saved_MudDischarged_Volume_Final) !!!!!!!!! + data%State%FricPressDrop%AnnCompressedMudVol = MAX((data%State%FricPressDrop%AnnCompressedMudVol - REAL(data%State%MudSystem%Qlost / ConvMinToSec / dt)) , 0.0) + data%State%FricPressDrop%AnnDeltaPDueToCompressibility = data%State%FricPressDrop%AnnCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%AnnMudVol) END IF - IF (FricPressDropVars%FloatValveIn == .FALSE. .OR. KickVARIABLES%NoGasPocket == 0 .OR. (FricPressDropVars%FloatValveWasOpen .AND. REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol)) THEN ! float valve remains open - FricPressDropVars%FloatValveOpen = .TRUE. + IF (data%State%FricPressDrop%FloatValveIn == .FALSE. .OR. KickVARIABLES%NoGasPocket == 0 .OR. (data%State%FricPressDrop%FloatValveWasOpen .AND. REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol)) THEN ! float valve remains open + data%State%FricPressDrop%FloatValveOpen = .TRUE. - FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%FlowRate = REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) / dt * ConvMinToSec !MudSystem%StringFlowRate ! String flow rate pump flow rate [gpm] + FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%FlowRate = REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) / dt * ConvMinToSec !data%State%MudSystem%StringFlowRate ! String flow rate pump flow rate [gpm] !!!!!!!!!!!!!!! Calculating frictional pressure loss IF (KickVARIABLES%WellHeadOpen) THEN - DO ifric = 1 , FricPressDropVars%StringLastEl + DO ifric = 1 , data%State%FricPressDrop%StringLastEl CALL FricPressDrop(ifric) !WRITE (*,*) ' element No, FlowRate , Density, FricPressLoss', ifric, FlowEl(ifric)%FlowRate, FlowEl(ifric)%Density, FlowEl(ifric)%FricPressLoss IF (IEEE_IS_NaN(FlowEl(ifric)%FricPressLoss)) THEN @@ -107,72 +110,72 @@ SUBROUTINE PressureHorizAndStringDistribution !IF (ABS(MudVolume_InjectedToBH - St_Saved_MudDischarged_Volume_Final)> PumpMinDischargedVol) WRITE (*,*) 'Injected to BH & St Saved Mud', MudVolume_InjectedToBH , St_Saved_MudDischarged_Volume_Final - IF (FricPressDropVars%BitTotallyPluged) THEN - MudSystem%MudVolume_InjectedToBH = 0.d0 - FricPressDropVars%StCompressedMudVol = FricPressDropVars%StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) - FricPressDropVars%StDeltaPDueToCompressibility = FricPressDropVars%StCompressedMudVol * FricPressDropVars%StDeltaPtoDeltaVCompressibility + IF (data%State%FricPressDrop%BitTotallyPluged) THEN + data%State%MudSystem%MudVolume_InjectedToBH = 0.d0 + data%State%FricPressDrop%StCompressedMudVol = data%State%FricPressDrop%StCompressedMudVol + REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) + data%State%FricPressDrop%StDeltaPDueToCompressibility = data%State%FricPressDrop%StCompressedMudVol * data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility ELSE IF (KickVARIABLES%WellHeadOpen .OR. KickVARIABLES%NoGasPocket > 0) THEN - IF (REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN + IF (REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN - MudSystem%MudVolume_InjectedToBH = MudSystem%St_Saved_MudDischarged_Volume_Final + data%State%MudSystem%MudVolume_InjectedToBH = data%State%MudSystem%St_Saved_MudDischarged_Volume_Final !WRITE (*,*) 'MudVolume_InjectedToBH,BitTrue', MudVolume_InjectedToBH !IF (BitTrue .AND. UtubeMode1Activated == .FALSE.) THEN IF (BitTrue) THEN - BitPressLoss = FricPressDropVars%KBit * (MudSystem%MudVolume_InjectedToBH * ConvMinToSec / dt)**2 + BitPressLoss = data%State%FricPressDrop%KBit * (data%State%MudSystem%MudVolume_InjectedToBH * ConvMinToSec / dt)**2 !WRITE (*,*) 'BitPressLoss', BitPressLoss END IF - FricPressDropVars%StCompressedMudVol = BitPressLoss / FricPressDropVars%StDeltaPtoDeltaVCompressibility + data%State%FricPressDrop%StCompressedMudVol = BitPressLoss / data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility ELSE - MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((FricPressDropVars%StDeltaPDueToCompressibility + SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff - PressBelowFloatValve - FricPressDropVars%AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & - / FricPressDropVars%StDeltaPtoDeltaVCompressibility ) * 1.d0)) - MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , FricPressDropVars%StCompressedMudVol) - FricPressDropVars%StCompressedMudVol = FricPressDropVars%StCompressedMudVol - MudSystem%MudVolume_InjectedToBH + data%State%MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((data%State%FricPressDrop%StDeltaPDueToCompressibility + SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff - PressBelowFloatValve - data%State%FricPressDrop%AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & + / data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility ) * 1.d0)) + data%State%MudSystem%MudVolume_InjectedToBH = MIN(data%State%MudSystem%MudVolume_InjectedToBH , data%State%FricPressDrop%StCompressedMudVol) + data%State%FricPressDrop%StCompressedMudVol = data%State%FricPressDrop%StCompressedMudVol - data%State%MudSystem%MudVolume_InjectedToBH END IF - FricPressDropVars%StDeltaPDueToCompressibility = FricPressDropVars%StCompressedMudVol / (MudCompressibility * FricPressDropVars%StMudVol) + data%State%FricPressDrop%StDeltaPDueToCompressibility = data%State%FricPressDrop%StCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%StMudVol) ELSE ! IF (NoGasPocket == 0 .AND. WellHeadOpen == .FALSE.) THEN - FricPressDropVars%StCompressedMudVol = FricPressDropVars%StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) - FricPressDropVars%StDeltaPDueToCompressibility = FricPressDropVars%StCompressedMudVol * FricPressDropVars%StDeltaPtoDeltaVCompressibility - MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((FricPressDropVars%StDeltaPDueToCompressibility - FricPressDropVars%AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & - / (FricPressDropVars%StDeltaPtoDeltaVCompressibility + FricPressDropVars%AnnDeltaPtoDeltaVCompressibility)) * 1.d0) - MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , FricPressDropVars%StCompressedMudVol) - FricPressDropVars%StCompressedMudVol = FricPressDropVars%StCompressedMudVol - REAL(MudSystem%MudVolume_InjectedToBH) - FricPressDropVars%StDeltaPDueToCompressibility = FricPressDropVars%StCompressedMudVol / (MudCompressibility * FricPressDropVars%StMudVol) - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%StartPress = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%StartPress + FricPressDropVars%StDeltaPDueToCompressibility - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%EndPress + FricPressDropVars%StDeltaPDueToCompressibility + data%State%FricPressDrop%StCompressedMudVol = data%State%FricPressDrop%StCompressedMudVol + REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) + data%State%FricPressDrop%StDeltaPDueToCompressibility = data%State%FricPressDrop%StCompressedMudVol * data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility + data%State%MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , REAL((data%State%FricPressDrop%StDeltaPDueToCompressibility - data%State%FricPressDrop%AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & + / (data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility + data%State%FricPressDrop%AnnDeltaPtoDeltaVCompressibility)) * 1.d0) + data%State%MudSystem%MudVolume_InjectedToBH = MIN(data%State%MudSystem%MudVolume_InjectedToBH , data%State%FricPressDrop%StCompressedMudVol) + data%State%FricPressDrop%StCompressedMudVol = data%State%FricPressDrop%StCompressedMudVol - REAL(data%State%MudSystem%MudVolume_InjectedToBH) + data%State%FricPressDrop%StDeltaPDueToCompressibility = data%State%FricPressDrop%StCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%StMudVol) + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%StartPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%StartPress + data%State%FricPressDrop%StDeltaPDueToCompressibility + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%EndPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%EndPress + data%State%FricPressDrop%StDeltaPDueToCompressibility END IF - FlowEl(FricPressDropVars%StringLastEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress + BitPressLoss + FloatValveMinOpenPressure + FlowEl(data%State%FricPressDrop%StringLastEl)%EndPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress + BitPressLoss + FloatValveMinOpenPressure !WRITE (*,*) 'BitPressLoss=', BitPressLoss - FlowEl(FricPressDropVars%StringLastEl)%StartPress = FlowEl(FricPressDropVars%StringLastEl)%EndPress + FlowEl(FricPressDropVars%StringLastEl)%FricPressLoss - FlowEl(FricPressDropVars%StringLastEl)%StaticPressDiff - DO i = FricPressDropVars%StringLastEl - 1 , FricPressDropVars%StringFirstEl , -1 + FlowEl(data%State%FricPressDrop%StringLastEl)%StartPress = FlowEl(data%State%FricPressDrop%StringLastEl)%EndPress + FlowEl(data%State%FricPressDrop%StringLastEl)%FricPressLoss - FlowEl(data%State%FricPressDrop%StringLastEl)%StaticPressDiff + DO i = data%State%FricPressDrop%StringLastEl - 1 , data%State%FricPressDrop%StringFirstEl , -1 FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss - FlowEl(i)%StaticPressDiff END DO !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open and remains open - ELSE IF (REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) < PumpMinDischargedVol) THEN ! NoGasPocket > 0 - FricPressDropVars%FloatValveOpen = FricPressDropVars%FloatValveWasOpen ! remains in its former status + ELSE IF (REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) < PumpMinDischargedVol) THEN ! NoGasPocket > 0 + data%State%FricPressDrop%FloatValveOpen = data%State%FricPressDrop%FloatValveWasOpen ! remains in its former status - IF (FricPressDropVars%FloatValveOpen) THEN - PressAboveFloatValve = MAX(FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress , SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(FricPressDropVars%StringFirstEl)%Density * FlowEl(FricPressDropVars%StringFirstEl)%StartTVD) + IF (data%State%FricPressDrop%FloatValveOpen) THEN + PressAboveFloatValve = MAX(FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress , SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(data%State%FricPressDrop%StringFirstEl)%Density * FlowEl(data%State%FricPressDrop%StringFirstEl)%StartTVD) ELSE - PressAboveFloatValve = SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff) + FricPressDropVars%StDeltaPDueToCompressibility - MudSystem%MudVolume_InjectedToBH = 0.d0 + PressAboveFloatValve = SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff) + data%State%FricPressDrop%StDeltaPDueToCompressibility + data%State%MudSystem%MudVolume_InjectedToBH = 0.d0 END IF IF (PressBelowFloatValve >= PressAboveFloatValve .AND. KickVARIABLES%KickFlux) THEN - FricPressDropVars%FloatValveOpen = .FALSE. - IF (FricPressDropVars%FloatValveOpen /= FricPressDropVars%FloatValveWasOpen) THEN ! float valve was open and now closed + data%State%FricPressDrop%FloatValveOpen = .FALSE. + IF (data%State%FricPressDrop%FloatValveOpen /= data%State%FricPressDrop%FloatValveWasOpen) THEN ! float valve was open and now closed WRITE (*,*) 'Float valve was open and now closed' WRITE (*,*) 'PressAboveFloatValve=', PressAboveFloatValve WRITE (*,*) 'PressBelowFloatValve=', PressBelowFloatValve @@ -180,33 +183,33 @@ SUBROUTINE PressureHorizAndStringDistribution END IF - IF (FricPressDropVars%FloatValveOpen) THEN - MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , 0.1 * REAL((PressAboveFloatValve - PressBelowFloatValve - FricPressDropVars%AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & - / FricPressDropVars%StDeltaPtoDeltaVCompressibility ) * 1.d0) - MudSystem%MudVolume_InjectedToBH = MIN(MudSystem%MudVolume_InjectedToBH , FricPressDropVars%StCompressedMudVol) + IF (data%State%FricPressDrop%FloatValveOpen) THEN + data%State%MudSystem%MudVolume_InjectedToBH = MAX( 0.d0 , 0.1 * REAL((PressAboveFloatValve - PressBelowFloatValve - data%State%FricPressDrop%AnnDeltaPDueToCompressibility - FloatValveMinOpenPressure) & + / data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility ) * 1.d0) + data%State%MudSystem%MudVolume_InjectedToBH = MIN(data%State%MudSystem%MudVolume_InjectedToBH , data%State%FricPressDrop%StCompressedMudVol) !WRITE (*,*) 'MudVolume_InjectedToBH (No Pump)', MudVolume_InjectedToBH - FricPressDropVars%StCompressedMudVol = FricPressDropVars%StCompressedMudVol - MudSystem%MudVolume_InjectedToBH - FricPressDropVars%StDeltaPDueToCompressibility = FricPressDropVars%StCompressedMudVol / (MudCompressibility * FricPressDropVars%StMudVol) + data%State%FricPressDrop%StCompressedMudVol = data%State%FricPressDrop%StCompressedMudVol - data%State%MudSystem%MudVolume_InjectedToBH + data%State%FricPressDrop%StDeltaPDueToCompressibility = data%State%FricPressDrop%StCompressedMudVol / (MudCompressibility * data%State%FricPressDrop%StMudVol) !WRITE (*,*) 'StDeltaPDueToCompressibility(No Pump)', StDeltaPDueToCompressibility END IF IF (KickVARIABLES%NoGasPocket == 0 .AND. KickVARIABLES%WellHeadOpen == .FALSE.) THEN !*********** - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%StartPress = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%StartPress + FricPressDropVars%AnnDeltaPDueToCompressibility - FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%EndPress = FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%NumbEl)%EndPress + FricPressDropVars%AnnDeltaPDueToCompressibility + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%StartPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%StartPress + data%State%FricPressDrop%AnnDeltaPDueToCompressibility + FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%EndPress = FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%NumbEl)%EndPress + data%State%FricPressDrop%AnnDeltaPDueToCompressibility END IF - IF (FricPressDropVars%FloatValveOpen) THEN - FlowEl(FricPressDropVars%StringLastEl)%EndPress = MAX(FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress , SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(FricPressDropVars%StringFirstEl)%Density * FlowEl(FricPressDropVars%StringFirstEl)%StartTVD) + IF (data%State%FricPressDrop%FloatValveOpen) THEN + FlowEl(data%State%FricPressDrop%StringLastEl)%EndPress = MAX(FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress , SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff) + 0.052 * FlowEl(data%State%FricPressDrop%StringFirstEl)%Density * FlowEl(data%State%FricPressDrop%StringFirstEl)%StartTVD) ELSE - FlowEl(FricPressDropVars%StringLastEl)%EndPress = FricPressDropVars%StDeltaPDueToCompressibility + SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff) + FlowEl(data%State%FricPressDrop%StringLastEl)%EndPress = data%State%FricPressDrop%StDeltaPDueToCompressibility + SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff) END IF - FlowEl(FricPressDropVars%StringLastEl)%StartPress = FlowEl(FricPressDropVars%StringLastEl)%EndPress - FlowEl(FricPressDropVars%StringLastEl)%StaticPressDiff - DO i = FricPressDropVars%StringLastEl - 1 , FricPressDropVars%StringFirstEl , -1 + FlowEl(data%State%FricPressDrop%StringLastEl)%StartPress = FlowEl(data%State%FricPressDrop%StringLastEl)%EndPress - FlowEl(data%State%FricPressDrop%StringLastEl)%StaticPressDiff + DO i = data%State%FricPressDrop%StringLastEl - 1 , data%State%FricPressDrop%StringFirstEl , -1 FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss - FlowEl(i)%StaticPressDiff END DO @@ -215,26 +218,26 @@ SUBROUTINE PressureHorizAndStringDistribution !!!!!!!!!!!!!!!!!!!!!!!!!!!! Float valve was open (close) and maybe remains open (close) or maybe closed - ELSE IF(FricPressDropVars%FloatValveWasOpen == .FALSE. .AND. REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN - FricPressDropVars%FloatValveOpen = .FALSE. - MudSystem%MudVolume_InjectedToBH = 0.d0 + ELSE IF(data%State%FricPressDrop%FloatValveWasOpen == .FALSE. .AND. REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) >= PumpMinDischargedVol) THEN + data%State%FricPressDrop%FloatValveOpen = .FALSE. + data%State%MudSystem%MudVolume_InjectedToBH = 0.d0 - FricPressDropVars%StCompressedMudVol = FricPressDropVars%StCompressedMudVol + REAL(MudSystem%St_Saved_MudDischarged_Volume_Final) - FricPressDropVars%StDeltaPDueToCompressibility = FricPressDropVars%StCompressedMudVol * FricPressDropVars%StDeltaPtoDeltaVCompressibility - PressAboveFloatValve = SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff) + FricPressDropVars%StDeltaPDueToCompressibility + data%State%FricPressDrop%StCompressedMudVol = data%State%FricPressDrop%StCompressedMudVol + REAL(data%State%MudSystem%St_Saved_MudDischarged_Volume_Final) + data%State%FricPressDrop%StDeltaPDueToCompressibility = data%State%FricPressDrop%StCompressedMudVol * data%State%FricPressDrop%StDeltaPtoDeltaVCompressibility + PressAboveFloatValve = SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff) + data%State%FricPressDrop%StDeltaPDueToCompressibility IF (PressAboveFloatValve > FloatValveBottomToUpAreaRatio * PressBelowFloatValve) THEN ! float valve was open and now closed - FricPressDropVars%FloatValveOpen = .TRUE. + data%State%FricPressDrop%FloatValveOpen = .TRUE. WRITE (*,*) 'Float valve was closed and now opened' WRITE (*,*) 'PressAboveFloatValve=', PressAboveFloatValve WRITE (*,*) 'PressBelowFloatValve=', PressBelowFloatValve END IF - FlowEl(FricPressDropVars%StringLastEl)%EndPress = PressAboveFloatValve - FlowEl(FricPressDropVars%StringLastEl)%StartPress = FlowEl(FricPressDropVars%StringLastEl)%EndPress - FlowEl(FricPressDropVars%StringLastEl)%StaticPressDiff - DO i = FricPressDropVars%StringLastEl - 1 , FricPressDropVars%StringFirstEl , -1 + FlowEl(data%State%FricPressDrop%StringLastEl)%EndPress = PressAboveFloatValve + FlowEl(data%State%FricPressDrop%StringLastEl)%StartPress = FlowEl(data%State%FricPressDrop%StringLastEl)%EndPress - FlowEl(data%State%FricPressDrop%StringLastEl)%StaticPressDiff + DO i = data%State%FricPressDrop%StringLastEl - 1 , data%State%FricPressDrop%StringFirstEl , -1 FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress FlowEl(i)%StartPress = FlowEl(i)%EndPress - FlowEl(i)%StaticPressDiff !WRITE(*,*) "STRING: Start , End Pressure", FlowEl(i)%StartPress , FlowEl(i)%EndPress @@ -246,16 +249,16 @@ SUBROUTINE PressureHorizAndStringDistribution END IF - IF ((MudSystem%UtubePossibility == .TRUE. .AND. Get_KellyConnection() /= KELLY_CONNECTION_STRING) .OR. MudSystem%NewPipeFilling == 0) THEN - FlowEl(FricPressDropVars%NoHorizontalEl)%EndPress = 0.0 + IF ((data%State%MudSystem%UtubePossibility == .TRUE. .AND. Get_KellyConnection() /= KELLY_CONNECTION_STRING) .OR. data%State%MudSystem%NewPipeFilling == 0) THEN + FlowEl(data%State%FricPressDrop%NoHorizontalEl)%EndPress = 0.0 ELSE IF (KickVARIABLES%WellHeadOpen == .FALSE.) THEN - FlowEl(FricPressDropVars%NoHorizontalEl)%EndPress = FlowEl(FricPressDropVars%StringFirstEl)%StartPress - 0.052 * FlowEl(FricPressDropVars%NoHorizontalEl)%Density * FlowEl(FricPressDropVars%StringFirstEl)%StartTVD + FlowEl(data%State%FricPressDrop%NoHorizontalEl)%EndPress = FlowEl(data%State%FricPressDrop%StringFirstEl)%StartPress - 0.052 * FlowEl(data%State%FricPressDrop%NoHorizontalEl)%Density * FlowEl(data%State%FricPressDrop%StringFirstEl)%StartTVD ELSE IF (KickVARIABLES%WellHeadOpen) THEN - FlowEl(FricPressDropVars%NoHorizontalEl)%EndPress = FlowEl(FricPressDropVars%StringFirstEl)%StartPress - 2.0 * 0.052 * FlowEl(FricPressDropVars%NoHorizontalEl)%Density * FlowEl(FricPressDropVars%StringFirstEl)%StartTVD + FlowEl(data%State%FricPressDrop%NoHorizontalEl)%EndPress = FlowEl(data%State%FricPressDrop%StringFirstEl)%StartPress - 2.0 * 0.052 * FlowEl(data%State%FricPressDrop%NoHorizontalEl)%Density * FlowEl(data%State%FricPressDrop%StringFirstEl)%StartTVD END IF - FlowEl(FricPressDropVars%NoHorizontalEl)%StartPress = FlowEl(FricPressDropVars%NoHorizontalEl)%EndPress + FlowEl(FricPressDropVars%NoHorizontalEl)%FricPressLoss - DO i = FricPressDropVars%NoHorizontalEl - 1 , 1 , -1 + FlowEl(data%State%FricPressDrop%NoHorizontalEl)%StartPress = FlowEl(data%State%FricPressDrop%NoHorizontalEl)%EndPress + FlowEl(data%State%FricPressDrop%NoHorizontalEl)%FricPressLoss + DO i = data%State%FricPressDrop%NoHorizontalEl - 1 , 1 , -1 FlowEl(i)%EndPress = FlowEl(i + 1)%StartPress FlowEl(i)%StartPress = FlowEl(i)%EndPress + FlowEl(i)%FricPressLoss END DO @@ -265,10 +268,10 @@ SUBROUTINE PressureHorizAndStringDistribution !!!!!!!!!!!!!!!!!!!!! Pressure distribution in string and horizontal pump to string line - IF (RamLine%ShearBop_Situation_forTD == 1) THEN - FlowEl(1 : FricPressDropVars%NoHorizontalEl)%EndPress = 0.0 - FlowEl(1 : FricPressDropVars%NoHorizontalEl)%StartPress = 0.0 - FlowEl(1 : FricPressDropVars%NoHorizontalEl)%FricPressLoss = 0.0 + IF (data%State%RamLine%ShearBop_Situation_forTD == 1) THEN + FlowEl(1 : data%State%FricPressDrop%NoHorizontalEl)%EndPress = 0.0 + FlowEl(1 : data%State%FricPressDrop%NoHorizontalEl)%StartPress = 0.0 + FlowEl(1 : data%State%FricPressDrop%NoHorizontalEl)%FricPressLoss = 0.0 END IF !!!!!!!!!!!!!!!!!!!!!!!!! @@ -280,9 +283,9 @@ SUBROUTINE PressureHorizAndStringDistribution - IF (MudSystem%UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. KickVARIABLES%WellHeadOpen) THEN - MudSystem%MudVolume_InjectedToBH = 0.d0 - MudSystem%MudVolume_InjectedFromAnn = 0.d0 + IF (data%State%MudSystem%UtubePossibility== .true. .and. Get_KellyConnection() /= KELLY_CONNECTION_STRING .and. KickVARIABLES%WellHeadOpen) THEN + data%State%MudSystem%MudVolume_InjectedToBH = 0.d0 + data%State%MudSystem%MudVolume_InjectedFromAnn = 0.d0 END IF @@ -303,31 +306,31 @@ SUBROUTINE PressureHorizAndStringDistribution i = 1 DO WHILE (NOT(FlowEl(i)%EndX >= -170 .AND. FlowEl(i)%StartX <= -170)) i = i + 1 - IF (i > FricPressDropVars%NoHorizontalEl) EXIT + IF (i > data%State%FricPressDrop%NoHorizontalEl) EXIT END DO - CALL PumpPressureDelay%AddToFirst(REAL(FlowEl(i)%StartPress - 0.052 * (MudSystem%STpipeGauge_Height / Convfttom) * FlowEl(i)%Density + (FlowEl(i)%StartX + 170) * FlowEl(i)%dPdLFric)) - CALL PumpPressureDelay%Remove(PressureDisplayVARIABLES%PressureTimeStepDelay(1) + 1) - !IF (ANY(PUMP(:)%PowerFailMalf == 1)) PumpPressureDelay%Array(1 : PressureTimeStepDelay(1) / 2) = 0.0 !seyyed goft vaghti pumpfailure mishavad feshar dasti 0 nashavad, be in dalil in khat comment shod. + CALL PumpPressureDelay%AddToFirst(REAL(FlowEl(i)%StartPress - 0.052 * (data%State%MudSystem%STpipeGauge_Height / Convfttom) * FlowEl(i)%Density + (FlowEl(i)%StartX + 170) * FlowEl(i)%dPdLFric)) + CALL PumpPressureDelay%Remove(data%State%PressureDisplay%PressureTimeStepDelay(1) + 1) + !IF (ANY(data%State%Pump(:)%PowerFailMalf == 1)) PumpPressureDelay%Array(1 : PressureTimeStepDelay(1) / 2) = 0.0 !seyyed goft vaghti pumpfailure mishavad feshar dasti 0 nashavad, be in dalil in khat comment shod. - DO j = PressureDisplayVARIABLES%PressureTimeStepDelay(1) , 1 , -1 + DO j = data%State%PressureDisplay%PressureTimeStepDelay(1) , 1 , -1 IF (NOT(IEEE_IS_NaN(PumpPressureDelay%Array(j)))) THEN - PressureDisplayVARIABLES%PressureGauges(1) = INT(PumpPressureDelay%Array(j)) + data%State%PressureDisplay%PressureGauges(1) = INT(PumpPressureDelay%Array(j)) EXIT END IF END DO !PressureGauges(1) = INT(PumpPressureDelay%Array(PressureTimeStepDelay(1))) - IF (i > FricPressDropVars%NoHorizontalEl) THEN + IF (i > data%State%FricPressDrop%NoHorizontalEl) THEN WRITE (*,*) ' Error in calculating standpipe pressure ' END IF - IF (PressureDisplayVARIABLES%PressureGauges(1) < 0) THEN + IF (data%State%PressureDisplay%PressureGauges(1) < 0) THEN !CALL Set_StandPipePressure(real(PressureGauges(1) , 8)) ! for display console - PressureDisplayVARIABLES%PressureGauges(1) = 0.0 + data%State%PressureDisplay%PressureGauges(1) = 0.0 !CALL Set_StandPipePressure(0.0d0) !StandPipePressureGauge = 0 END IF - DownHole%DrillPipePressure = real(PressureDisplayVARIABLES%PressureGauges(1), 8) + DownHole%DrillPipePressure = real(data%State%PressureDisplay%PressureGauges(1), 8) !WRITE (*,*) 'Drillpipe Pressure', PressureGauges(1) !!!!!!!!!!!!!!!!! 2- Casing pressure gauge PressureGauge(2) @@ -337,23 +340,23 @@ SUBROUTINE PressureHorizAndStringDistribution !!! in normal mode changes in choke position immidiately observes in casing pressure !! but when pumps off due to failure, casing pressure will drop after a delay time - IF (MudSystem%WellToChokeManifoldOpen .OR. MudSystem%WellToChokeLineGauge) THEN + IF (data%State%MudSystem%WellToChokeManifoldOpen .OR. data%State%MudSystem%WellToChokeLineGauge) THEN !WRITE (*,*) 'Here 1' - CALL CasingPressureDelay%AddToFirst(FlowEl(FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl + FricPressDropVars%NoWellToChokeEl)%EndPress) - CALL CasingPressureDelay%Remove(PressureDisplayVARIABLES%PressureTimeStepDelay(1) + 1) + CALL CasingPressureDelay%AddToFirst(FlowEl(data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + data%State%FricPressDrop%NoWellToChokeEl)%EndPress) + CALL CasingPressureDelay%Remove(data%State%PressureDisplay%PressureTimeStepDelay(1) + 1) - DO j = 1 , PressureDisplayVARIABLES%PressureTimeStepDelay(1) + DO j = 1 , data%State%PressureDisplay%PressureTimeStepDelay(1) IF (NOT(IEEE_IS_NaN(CasingPressureDelay%Array(j)))) THEN - PressureDisplayVARIABLES%PressureGauges(2) = INT(CasingPressureDelay%Array(j)) + data%State%PressureDisplay%PressureGauges(2) = INT(CasingPressureDelay%Array(j)) EXIT END IF END DO !PressureGauges(2) = INT(CasingPressureDelay%Array(1)) - IF (ANY(PUMP(:)%PowerFailMalf == 1)) THEN - DO j = PressureDisplayVARIABLES%PressureTimeStepDelay(1) , 1 , -1 + IF (ANY(data%State%Pump(:)%PowerFailMalf == 1)) THEN + DO j = data%State%PressureDisplay%PressureTimeStepDelay(1) , 1 , -1 IF (NOT(IEEE_IS_NaN(CasingPressureDelay%Array(j)))) THEN - PressureDisplayVARIABLES%PressureGauges(2) = INT(CasingPressureDelay%Array(j)) + data%State%PressureDisplay%PressureGauges(2) = INT(CasingPressureDelay%Array(j)) EXIT END IF END DO @@ -362,10 +365,10 @@ SUBROUTINE PressureHorizAndStringDistribution - !IF (ANY(PUMP(:)%PowerFailMalf == 1)) PressureGauges(2) = INT(CasingPressureDelay%Array(PressureTimeStepDelay(1))) + !IF (ANY(data%State%Pump(:)%PowerFailMalf == 1)) PressureGauges(2) = INT(CasingPressureDelay%Array(PressureTimeStepDelay(1))) ELSE !IF (ChokeLineGaugeToTanks) THEN - PressureDisplayVARIABLES%PressureGauges(2) = 0 + data%State%PressureDisplay%PressureGauges(2) = 0 !WRITE (*,*) 'Here 2' END IF @@ -374,43 +377,43 @@ SUBROUTINE PressureHorizAndStringDistribution !IF (PressureGauges(2) < 0) THEN ! PressureGauges(2) = 0.0 !END IF - CALL Set_CasingPressure(real(PressureDisplayVARIABLES%PressureGauges(2) , 8)) ! for display console - Downhole%CasingPressure = real(PressureDisplayVARIABLES%PressureGauges(2) , 8) + CALL Set_CasingPressure(real(data%State%PressureDisplay%PressureGauges(2) , 8)) ! for display console + Downhole%CasingPressure = real(data%State%PressureDisplay%PressureGauges(2) , 8) !!!!!!!!!!!!!!!!! 3- Bottom Hole Pressure PressureGauge(3) - CALL BottomHolePressureDelay%AddToFirst(FlowEl(FricPressDropVars%OpenholeFirstEl)%StartPress) - CALL BottomHolePressureDelay%Remove(PressureDisplayVARIABLES%PressureTimeStepDelay(2) + 1) + CALL BottomHolePressureDelay%AddToFirst(FlowEl(data%State%FricPressDrop%OpenholeFirstEl)%StartPress) + CALL BottomHolePressureDelay%Remove(data%State%PressureDisplay%PressureTimeStepDelay(2) + 1) !PressureGauges(3) = INT(BottomHolePressureDelay%Array(PressureTimeStepDelay(2))) - DO j = PressureDisplayVARIABLES%PressureTimeStepDelay(2) , 1 , -1 + DO j = data%State%PressureDisplay%PressureTimeStepDelay(2) , 1 , -1 IF (NOT(IEEE_IS_NaN(BottomHolePressureDelay%Array(j)))) THEN - PressureDisplayVARIABLES%PressureGauges(3) = INT(BottomHolePressureDelay%Array(j)) + data%State%PressureDisplay%PressureGauges(3) = INT(BottomHolePressureDelay%Array(j)) EXIT END IF END DO - KickVARIABLES%BottomHolePress = BottomHolePressureDelay%Array(PressureDisplayVARIABLES%PressureTimeStepDelay(2)) + KickVARIABLES%BottomHolePress = BottomHolePressureDelay%Array(data%State%PressureDisplay%PressureTimeStepDelay(2)) - DownHole%BottomHolePressure = REAL(PressureDisplayVARIABLES%PressureGauges(3) , 8) + DownHole%BottomHolePressure = REAL(data%State%PressureDisplay%PressureGauges(3) , 8) !!!!!!!!!!!!!!!!! 4- Under Bit Pressure PressureGauges(4) - PressureDisplayVARIABLES%PressureGauges(4) = FlowEl(FricPressDropVars%AnnulusFirstEl)%StartPress + data%State%PressureDisplay%PressureGauges(4) = FlowEl(data%State%FricPressDrop%AnnulusFirstEl)%StartPress !!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!! 5- Casing Shoe Pressure PressureGauges(5) - DO ShoeFlowElNo = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%NumbEl + DO ShoeFlowElNo = data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%NumbEl IF (FlowEl(ShoeFlowElNo)%StartX >= Shoe%ShoeDepth .AND. FlowEl(ShoeFlowElNo)%EndX < Shoe%ShoeDepth) EXIT END DO CALL TVD_Calculator(Shoe%ShoeDepth , ShoeTVD) - IF (ShoeFlowElNo > FricPressDropVars%NumbEl) THEN + IF (ShoeFlowElNo > data%State%FricPressDrop%NumbEl) THEN WRITE (*,*) 'ShoeDepth =', Shoe%ShoeDepth - DO i = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%NumbEl + DO i = data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%NumbEl WRITE (*,*) 'i, StartX, EndX', i, FlowEl(i)%StartX, FlowEl(i)%EndX END DO @@ -424,25 +427,25 @@ SUBROUTINE PressureHorizAndStringDistribution CALL ShoePressureDelay%AddToFirst(REAL(FlowEl(ShoeFlowElNo)%StartPress & - (FlowEl(ShoeFlowElNo)%StartX - Shoe%ShoeDepth) * FlowEl(ShoeFlowElNo)%dPdLfric & - (FlowEl(ShoeFlowElNo)%StartTVD - ShoeTVD) * FlowEl(ShoeFlowElNo)%dPdLGrav)) - CALL ShoePressureDelay%Remove(PressureDisplayVARIABLES%PressureTimeStepDelay(3) + 1) + CALL ShoePressureDelay%Remove(data%State%PressureDisplay%PressureTimeStepDelay(3) + 1) - !FricPressDropVars%FlowrateNearShoe = FlowEl(ShoeFlowElNo)%FlowRate - DO j = PressureDisplayVARIABLES%PressureTimeStepDelay(3) , 1 , -1 + !data%State%FricPressDrop%FlowrateNearShoe = FlowEl(ShoeFlowElNo)%FlowRate + DO j = data%State%PressureDisplay%PressureTimeStepDelay(3) , 1 , -1 IF (NOT(IEEE_IS_NaN(ShoePressureDelay%Array(j)))) THEN - PressureDisplayVARIABLES%PressureGauges(5) = INT(ShoePressureDelay%Array(j)) + data%State%PressureDisplay%PressureGauges(5) = INT(ShoePressureDelay%Array(j)) EXIT END IF END DO !PressureGauges(5) = INT(ShoePressureDelay%Array(PressureTimeStepDelay(3))) - DownHole%ShoePressure = real(PressureDisplayVARIABLES%PressureGauges(5), 8) + DownHole%ShoePressure = real(data%State%PressureDisplay%PressureGauges(5), 8) - MudSystem%ShoeMudViscosity = FlowEl(ShoeFlowElNo)%MuEff - MudSystem%ShoeMudDensity = FlowEl(ShoeFlowElNo)%Density + data%State%MudSystem%ShoeMudViscosity = FlowEl(ShoeFlowElNo)%MuEff + data%State%MudSystem%ShoeMudDensity = FlowEl(ShoeFlowElNo)%Density @@ -452,7 +455,7 @@ SUBROUTINE PressureHorizAndStringDistribution !!!!!!!!! 6- Pressure Before Bop - PressureDisplayVARIABLES%PressureGauges(6) = FlowEl(FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl)%EndPress + data%State%PressureDisplay%PressureGauges(6) = FlowEl(data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl)%EndPress !!!!!!!!!!!!!!!!! 101 FORMAT(4X, I2, 8X, (F8.1), 12X, (F8.3), 7X, (F8.2)) @@ -465,14 +468,14 @@ SUBROUTINE PressureHorizAndStringDistribution !WRITE (*,*) 'Horiz 1' - KickVARIABLES%KickInFluxConditions = (Reservoir%FormationTop < TD_WellGeneral%WellTotalVerticalLength) .AND. (NOT(Reservoir%InactiveInflux)) .AND. (KickVARIABLES%FormPressure > KickVARIABLES%BottomHolePress + 5.0) + KickVARIABLES%KickInFluxConditions = (Reservoir%FormationTop < data%State%TD_WellGeneral%WellTotalVerticalLength) .AND. (NOT(Reservoir%InactiveInflux)) .AND. (KickVARIABLES%FormPressure > KickVARIABLES%BottomHolePress + 5.0) IF (KickVARIABLES%KickInFluxConditions) THEN KickVARIABLES%KickFlux = .TRUE. CALL NewGasKick !WRITE (*,*) 'Kick Flux top' , KickFlux - !WRITE (*,*) 'KickVARIABLES%FormPressure, BottomHolePress, FormationTop, TD_WellGeneral%WellTotalVerticalLength' , FormPressure, BottomHolePress, FormationTop, TD_WellGeneral%WellTotalVerticalLength + !WRITE (*,*) 'KickVARIABLES%FormPressure, BottomHolePress, FormationTop, data%State%TD_WellGeneral%WellTotalVerticalLength' , FormPressure, BottomHolePress, FormationTop, data%State%TD_WellGeneral%WellTotalVerticalLength ELSE IF (ALLOCATED(GasPocketWeight%Array) .AND. KickVARIABLES%KickFlux) THEN @@ -495,7 +498,7 @@ SUBROUTINE PressureHorizAndStringDistribution ! DO i = 1 , 5 ! AreaChange = -1.0 * (BottomHolePressure - (KickVARIABLES%FormPressure + BHPSafetyMargin)) / FlowEl(OpenholeFirstEl - 1)%Flowrare**2 * 89158.0 & ! * (0.26 * 0.61)**2 * TotalOpenChokeArea**3 / (4.0 * KickVARIABLES%ChokeDensity) - ! CHOOKE(1)%AreaChokeFinal = CHOOKE(1)%AreaChokeFinal + AreaChange / * Convfttoinch**2 + ! data%State%CHOOKE(1)%AreaChokeFinal = data%State%CHOOKE(1)%AreaChokeFinal + AreaChange / * Convfttoinch**2 ! ! ! @@ -513,24 +516,24 @@ SUBROUTINE PressureHorizAndStringDistribution - IF (KickVARIABLES%WellHeadOpen == .FALSE. .OR. (FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%Flowrate < PressFlowrateTolerance .AND. FlowEl(FricPressDropVars%AnnulusLastEl)%Flowrate < PressFlowrateTolerance)) THEN - FricPressDropVars%OnShakerDensity = 0.0 - ELSE IF (FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%MaterialType == 1 .AND. KickVARIABLES%ChokeKroneckerDelta == 1) THEN - FricPressDropVars%OnShakerDensity = 2.0 + IF (KickVARIABLES%WellHeadOpen == .FALSE. .OR. (FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%Flowrate < PressFlowrateTolerance .AND. FlowEl(data%State%FricPressDrop%AnnulusLastEl)%Flowrate < PressFlowrateTolerance)) THEN + data%State%FricPressDrop%OnShakerDensity = 0.0 + ELSE IF (FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%MaterialType == 1 .AND. KickVARIABLES%ChokeKroneckerDelta == 1) THEN + data%State%FricPressDrop%OnShakerDensity = 2.0 ELSE IF (KickVARIABLES%ChokeKroneckerDelta == 0) THEN - FricPressDropVars%OnShakerDensity = FlowEl(FricPressDropVars%AnnulusLastEl)%Density + data%State%FricPressDrop%OnShakerDensity = FlowEl(data%State%FricPressDrop%AnnulusLastEl)%Density ELSE IF (KickVARIABLES%ChokeKroneckerDelta == 1) THEN !!!(FlowEl(OpenholeFirstEl - 1)%Flowrate > PressFlowrateTolerance .AND. FlowEl(AnnulusLastEl)%Flowrate < PressFlowrateTolerance) THEN - FricPressDropVars%OnShakerDensity = FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%Density + data%State%FricPressDrop%OnShakerDensity = FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%Density ELSE - FricPressDropVars%OnShakerDensity = (FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%Density * FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%Flowrate & - + FlowEl(FricPressDropVars%AnnulusLastEl)%Density * FlowEl(FricPressDropVars%AnnulusLastEl)%Flowrate) / (FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%Flowrate + FlowEl(FricPressDropVars%AnnulusLastEl)%Flowrate) + data%State%FricPressDrop%OnShakerDensity = (FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%Density * FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%Flowrate & + + FlowEl(data%State%FricPressDrop%AnnulusLastEl)%Density * FlowEl(data%State%FricPressDrop%AnnulusLastEl)%Flowrate) / (FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%Flowrate + FlowEl(data%State%FricPressDrop%AnnulusLastEl)%Flowrate) END IF !WRITE (*,*) 'ANINT(OnShakerDensity * 100) / 100', ANINT(OnShakerDensity * 100) / 100 , OnShakerDensity - CALL Set_MudWeightOut(ANINT(FricPressDropVars%OnShakerDensity * 100) / 100) + CALL Set_MudWeightOut(ANINT(data%State%FricPressDrop%OnShakerDensity * 100) / 100) IF (ALLOCATED(FinalFlowEl)) DEALLOCATE(FinalFlowEl) - ALLOCATE(FinalFlowEl(FricPressDropVars%NumbEl)) + ALLOCATE(FinalFlowEl(data%State%FricPressDrop%NumbEl)) FinalFlowEl(:)%StartX = FlowEl(:)%StartX FinalFlowEl(:)%EndX = FlowEl(:)%EndX diff --git a/FluidFlow/Pressure_Display_VARIABLES.f90 b/FluidFlow/Pressure_Display_VARIABLES.f90 index a31bc24..bcbc340 100644 --- a/FluidFlow/Pressure_Display_VARIABLES.f90 +++ b/FluidFlow/Pressure_Display_VARIABLES.f90 @@ -1,6 +1,6 @@ module PressureDisplayVARIABLESModule - USE DynamicRealArray + USE DynamicRealArray,only:DynamicRealArrayType IMPLICIT NONE @@ -10,7 +10,6 @@ module PressureDisplayVARIABLESModule INTEGER , DIMENSION(3) :: PressureTimeStepDelay END TYPE PressureDisplayVARIABLESTYPE - TYPE(PressureDisplayVARIABLESTYPE) :: PressureDisplayVARIABLES INTEGER :: SoundSpeed ! speed of sound [ft/s] @@ -31,6 +30,5 @@ module PressureDisplayVARIABLESModule END TYPE !TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: GaugePoint(:) - TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: ObservationPoint(:) END MODULE \ No newline at end of file diff --git a/FluidFlow/Pressure_Distribution_VARIABLES.f90 b/FluidFlow/Pressure_Distribution_VARIABLES.f90 index 33ffead..607ab66 100644 --- a/FluidFlow/Pressure_Distribution_VARIABLES.f90 +++ b/FluidFlow/Pressure_Distribution_VARIABLES.f90 @@ -61,7 +61,6 @@ MODULE FricPressDropVarsModule !!!!!! Note that bit is not an element in these calculations END TYPE FricPressDropVarsTYPE - TYPE(FricPressDropVarsTYPE) :: FricPressDropVars INTEGER :: ShoeFlowElNo ! the flow element that starts from shoe, in other word the number of upper element adjacent to shoe diff --git a/FluidFlow/String_Property_Calculator.f90 b/FluidFlow/String_Property_Calculator.f90 index 9b96367..150b614 100644 --- a/FluidFlow/String_Property_Calculator.f90 +++ b/FluidFlow/String_Property_Calculator.f90 @@ -3,11 +3,15 @@ SUBROUTINE StringPropertyCalculator (md, den, pre, tem) !!! This subroutine gets location of a guage or an observation point and determines information of that point such as pressure, density, velocity and temperature later. use PressureDisplayVARIABLESModule USE Fluid_Flow_Startup_Vars + ! use ConfigurationVariables !USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE FricPressDropVarsModule - !USE CDataDisplayConsoleVariables , StandPipePressureDataDisplay=>StandPipePressure - !USE CDataDisplayConsoleVariables , CasingPressureDataDisplay=>CasingPressure!, StandPipePressureDataDisplay=>StandPipePressure - USE CDrillWatchVariables + !use CDataDisplayConsole + !@ use ConfigurationVariables , StandPipePressureDataDisplay=>StandPipePressure + !use CDataDisplayConsole + !@ use ConfigurationVariables , CasingPressureDataDisplay=>CasingPressure!, StandPipePressureDataDisplay=>StandPipePressure + use ConfigurationVariables !@ IMPLICIT NONE INTEGER, intent(in) :: md ! input @@ -20,7 +24,7 @@ SUBROUTINE StringPropertyCalculator (md, den, pre, tem) CALL TVD_Calculator(md * 1.d0 , TVD) - DO ilocal = FricPressDropVars%StringFirstEl , FricPressDropVars%StringLastEl + DO ilocal = data%State%FricPressDrop%StringFirstEl , data%State%FricPressDrop%StringLastEl IF (md < INT(FinalFlowEl(ilocal)%EndX)) EXIT END DO den = FinalFlowEl(ilocal)%Density diff --git a/FluidFlow/Utube.f90 b/FluidFlow/Utube.f90 index dfeee21..72a0ead 100644 --- a/FluidFlow/Utube.f90 +++ b/FluidFlow/Utube.f90 @@ -12,6 +12,7 @@ SUBROUTINE Utube USE FricPressDropVarsModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ use UTUBEVARSModule USE Fluid_Flow_Startup_Vars @@ -24,23 +25,23 @@ SUBROUTINE Utube UTUBEVARS%QUTubeInput = 1.0 UTUBEVARS%QUTubeOutput = 1.0 - FricPressDropVars%TotFricPressLoss = 0 + data%State%FricPressDrop%TotFricPressLoss = 0 BitPressLoss = 0 UTUBEVARS%PressureDp = 0 UTUBEVARS%PressureAnn = 0 !!!!!!!!!!!!!!!!!!!!!! Bit !!!!!!!!!!!! Calculating Pressure at the bottom of drill string from mud columns in drill pipes and annulus space - UTUBEVARS%PressureDp = SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff) + UTUBEVARS%PressureDp = SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff) - UTUBEVARS%PressureAnn = SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%AnnulusLastEl)%StaticPressDiff) + UTUBEVARS%PressureAnn = SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%AnnulusLastEl)%StaticPressDiff) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! U tube:: flow from string to annulus IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > UTubePressTolerance) THEN DO ijk = 1 , 10 - FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%AnnulusLastEl)%Flowrate = UTUBEVARS%QUTubeInput + FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%AnnulusLastEl)%Flowrate = UTUBEVARS%QUTubeInput !WRITE (*,*) 'QUTubeInput', FlowEl(AnnulusLastEl)%Flowrate - DO ij = FricPressDropVars%StringFirstEl , FricPressDropVars%AnnulusLastEl !!!!! Updating values of flowrates + DO ij = data%State%FricPressDrop%StringFirstEl , data%State%FricPressDrop%AnnulusLastEl !!!!! Updating values of flowrates CALL FricPressDrop(ij) CALL PartialDerivativeFricToFlowRate(ij) !WRITE (*,*) 'FricPressDrop, PartialDerivative', FlowEl(ij)%FricPressLoss, FlowEl(ij)%FricToQPartialDiff, FlowEl(ij)%Length @@ -48,21 +49,21 @@ SUBROUTINE Utube !!!!!!!!!!!!!! Bit pressure drop calculation IF (BitTrue) THEN - i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + i = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2 BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2 END IF !!!!!!!!!!!!!!!!!!!!!!!!!!! - i = FricPressDropVars%NoHorizontalEl + 1 - j = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl + i = data%State%FricPressDrop%NoHorizontalEl + 1 + j = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl - FricPressDropVars%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss - IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) <= UTubePressTolerance .OR. UTUBEVARS%QUTubeInput < 1.0) EXIT ! tolerance set to 1.0 psi - IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > FricPressDropVars%TotFricPressLoss) THEN - UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) - ELSE IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) < FricPressDropVars%TotFricPressLoss) THEN - UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) + data%State%FricPressDrop%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss + IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) <= UTubePressTolerance .OR. UTUBEVARS%QUTubeInput < 1.0) EXIT ! tolerance set to 1.0 psi + IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > data%State%FricPressDrop%TotFricPressLoss) THEN + UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) + ELSE IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) < data%State%FricPressDrop%TotFricPressLoss) THEN + UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) END IF !WRITE (*,*) 'QUTubeInput, TotFricPressLoss', QUTubeInput, TotFricPressLoss !WRITE (*,*) '1) PressureDp, PressureAnn', PressureDp, PressureAnn, TotFricPressLoss, QUTubeInput @@ -73,7 +74,7 @@ SUBROUTINE Utube !!!!!!!!!!!! U tube:: flow from annulus to string ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > UTubePressTolerance) THEN DO ijk = 1 , 10 - DO ij = FricPressDropVars%NoHorizontalEl + 1 , FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl !!!!! Updating values of flowrates + DO ij = data%State%FricPressDrop%NoHorizontalEl + 1 , data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl !!!!! Updating values of flowrates FlowEl(ij)%Flowrate = UTUBEVARS%QUTubeOutput CALL FricPressDrop(ij) CALL PartialDerivativeFricToFlowRate(ij) @@ -81,24 +82,24 @@ SUBROUTINE Utube !!!!!!!!!!!!!! Bit pressure drop calculation IF (BitTrue) THEN - i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + 1 + i = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + 1 AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2 BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2 END IF !!!!!!!!!!!!!!!!!!!!!!!!!!! - i = FricPressDropVars%NoHorizontalEl + 1 - j = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl - FricPressDropVars%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss + i = data%State%FricPressDrop%NoHorizontalEl + 1 + j = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + data%State%FricPressDrop%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss - IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) <= UTubePressTolerance) EXIT ! tolerance set to 1.0 psi - IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > FricPressDropVars%TotFricPressLoss) THEN - UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput - (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) - ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) < FricPressDropVars%TotFricPressLoss) THEN - UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput + (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) + IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) <= UTubePressTolerance) EXIT ! tolerance set to 1.0 psi + IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > data%State%FricPressDrop%TotFricPressLoss) THEN + UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput - (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) + ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) < data%State%FricPressDrop%TotFricPressLoss) THEN + UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput + (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) END IF !WRITE (*,*) 'QUTubeOutput, TotFricPressLoss', QUTubeOutput, TotFricPressLoss - WRITE (*,*) '2) PressureDp, PressureAnn', UTUBEVARS%PressureDp, UTUBEVARS%PressureAnn, FricPressDropVars%TotFricPressLoss + WRITE (*,*) '2) PressureDp, PressureAnn', UTUBEVARS%PressureDp, UTUBEVARS%PressureAnn, data%State%FricPressDrop%TotFricPressLoss END DO UTUBEVARS%QUTubeInput = 0.0 !!!!!!!!!!!! No U-Tube diff --git a/FluidFlow/Well_Pressure_Data_Transfer.f90 b/FluidFlow/Well_Pressure_Data_Transfer.f90 index daf9dd0..79965f7 100644 --- a/FluidFlow/Well_Pressure_Data_Transfer.f90 +++ b/FluidFlow/Well_Pressure_Data_Transfer.f90 @@ -17,19 +17,23 @@ SUBROUTINE WellPressureDataTransfer USE FricPressDropVarsModule use MudSystemModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE GeoElements_FluidModule USE Fluid_Flow_Startup_Vars use KickVARIABLESModule USE CMudPropertiesVariables USE CBopStackVariables USE sROP_Variables - USE CHOKEVARIABLES, PI2 => PI - USE CChokeManifoldVariables + USE CHOKEVARIABLES +use ConfigurationVariables !@, PI2 => PI + use CChokeManifoldVariables + use ConfigurationVariables USE CBitProblemsVariables USE CChokeProblemsVariables USE CStringConfigurationVariables - USE CDrillWatchVariables - USE CDataDisplayConsoleVariables + use ConfigurationVariables !@ + use CDataDisplayConsole + use ConfigurationVariables use ConfigurationVariables IMPLICIT NONE @@ -38,24 +42,24 @@ SUBROUTINE WellPressureDataTransfer REAL :: InstantaneousTotalOpenChokeArea , VolumeDensityProduct KickVARIABLES%ChokeIsClosing = .FALSE. - FricPressDropVars%Kchoke = 0.0 - FricPressDropVars%KBit = 0.0 + data%State%FricPressDrop%Kchoke = 0.0 + data%State%FricPressDrop%KBit = 0.0 !!!!!!!!!!!!!!!! bit is present - BitTrue = Configuration%StringConfiguration%StringConfigurations(1)%ComponentType == Bit_ComponentType ! Bit_ComponentType = 0 + BitTrue = data%Configuration%StringConfiguration%StringConfigurations(1)%ComponentType == Bit_ComponentType ! Bit_ComponentType = 0 BitCd = 0.98 - BitNozzDia = 32.0 * Configuration%StringConfiguration%BitDefinition%BitNozzleSize ! nozzle diameter in 1/32 in + BitNozzDia = 32.0 * data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize ! nozzle diameter in 1/32 in BitNozzleArea = 7.6699E-4 * BitNozzDia**2 - BitNozzleNum = Configuration%StringConfiguration%BitDefinition%BitNozzleNo - FricPressDropVars%BitJetsPlugged * BitProblems%PlugJetsCount - BitTotNozzArea = BitNozzleNum * BitNozzleArea + 0.5 * FricPressDropVars%BitJetsWashedOut * BitProblems%JetWashoutCount * BitNozzleArea + BitNozzleNum = data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo - data%State%FricPressDrop%BitJetsPlugged * data%problems%BitProblems%PlugJetsCount + BitTotNozzArea = BitNozzleNum * BitNozzleArea + 0.5 * data%State%FricPressDrop%BitJetsWashedOut * data%problems%BitProblems%JetWashoutCount * BitNozzleArea IF (BitNozzleNum == 0) THEN - FricPressDropVars%BitTotallyPluged = .TRUE. + data%State%FricPressDrop%BitTotallyPluged = .TRUE. ELSE - FricPressDropVars%BitTotallyPluged = .FALSE. + data%State%FricPressDrop%BitTotallyPluged = .FALSE. END IF - FricPressDropVars%FloatValveIn = Configuration%StringConfiguration%BitDefinition%FloatValve + data%State%FricPressDrop%FloatValveIn = data%Configuration%StringConfiguration%BitDefinition%FloatValve !FloatValveOpen = .TRUE. !IF (JetWashoutCount > 0 .OR. PlugJetsCount > 0) THEN ! WRITE (*,*) 'PlugJetsCount' , PlugJetsCount @@ -74,7 +78,7 @@ SUBROUTINE WellPressureDataTransfer KickVARIABLES%ChokeKroneckerDelta = 0 - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN + IF (data%State%MudSystem%WellToPitsOpen == .FALSE. .AND. data%State%MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN KickVARIABLES%WellHeadOpen = .FALSE. !WRITE (*,*) ' Well Head is closed ' @@ -82,41 +86,41 @@ SUBROUTINE WellPressureDataTransfer KickVARIABLES%WellHeadOpen = .TRUE. END IF - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen) KickVARIABLES%ChokeKroneckerDelta = 1 + IF (data%State%MudSystem%WellToPitsOpen == .FALSE. .AND. data%State%MudSystem%WellToChokeManifoldOpen) KickVARIABLES%ChokeKroneckerDelta = 1 !WRITE (*,*) ' WelltoPitsOpen=' , WelltoPitsOpen, 'WellToChokeManifoldOpen= ' , WellToChokeManifoldOpen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - FricPressDropVars%NoHorizontalEl = MudSystem%NoHorizontalMudElements - FricPressDropVars%NoStringEl = MudSystem%NoStringMudElements - FricPressDropVars%NoAnnulusEl = MudSystem%NoCasingMudElements - FricPressDropVars%NoWellToChokeEl = 0 - IF (KickVARIABLES%ChokeKroneckerDelta == 1) FricPressDropVars%NoWellToChokeEl = MudSystem%ChokeLine_Density%Length() - FricPressDropVars%NoOpenHoleEl = MudSystem%NoBottomHoleMudElements - FricPressDropVars%NumbEl = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl + FricPressDropVars%NoWellToChokeEl + FricPressDropVars%NoOpenHoleEl + data%State%FricPressDrop%NoHorizontalEl = data%State%MudSystem%NoHorizontalMudElements + data%State%FricPressDrop%NoStringEl = data%State%MudSystem%NoStringMudElements + data%State%FricPressDrop%NoAnnulusEl = data%State%MudSystem%NoCasingMudElements + data%State%FricPressDrop%NoWellToChokeEl = 0 + IF (KickVARIABLES%ChokeKroneckerDelta == 1) data%State%FricPressDrop%NoWellToChokeEl = data%State%MudSystem%ChokeLine_Density%Length() + data%State%FricPressDrop%NoOpenHoleEl = data%State%MudSystem%NoBottomHoleMudElements + data%State%FricPressDrop%NumbEl = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + data%State%FricPressDrop%NoWellToChokeEl + data%State%FricPressDrop%NoOpenHoleEl IF(ALLOCATED(FlowEl)) DEALLOCATE(FlowEl) - ALLOCATE(FlowEl(FricPressDropVars%NumbEl)) + ALLOCATE(FlowEl(data%State%FricPressDrop%NumbEl)) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Transfering Data from module:MudSystemVARIABLES to module:FricPressDropVars to calculate Pressure distribution in flow path !!!!!!!!!!!!!!!!!!!!!!! Horizontal line !WRITE (*,*) 'H', NoHorizontalEl - DO i = 1 , FricPressDropVars%NoHorizontalEl - FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) - FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) + DO i = 1 , data%State%FricPressDrop%NoHorizontalEl + FlowEl(i)%StartX = data%State%MudSystem%Xstart_MudElement%Array(i) + FlowEl(i)%EndX = data%State%MudSystem%Xend_MudElement%Array(i) FlowEl(i)%StartTVD = 0.d0 FlowEl(i)%EndTVD = 0.d0 FlowEl(i)%Id = 0.0 - FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) - FlowEl(i)%density = MudSystem%Density_MudElement%Array(i) + FlowEl(i)%Od = data%State%MudSystem%PipeOD_MudElement%Array(i) + FlowEl(i)%density = data%State%MudSystem%Density_MudElement%Array(i) FlowEl(i)%Dhyd = FlowEl(i)%Od FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = 0.d0 FlowEl(i)%Volume = PI / 4.0 * FlowEl(i)%Od**2 * REAL(FlowEl(i)%Length) / Convfttoinch**2 - IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (data%State%MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN + ELSE IF (data%State%MudSystem%MudType_MudElement%Array(i) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -131,23 +135,23 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!! String - FricPressDropVars%StringFirstEl = FricPressDropVars%NoHorizontalEl + 1 - FricPressDropVars%StringLastEl = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl - DO i = FricPressDropVars%NoHorizontalEl + 1 , FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + data%State%FricPressDrop%StringFirstEl = data%State%FricPressDrop%NoHorizontalEl + 1 + data%State%FricPressDrop%StringLastEl = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + DO i = data%State%FricPressDrop%NoHorizontalEl + 1 , data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl !WRITE (*,*) 'ST , i' , i - FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) + FlowEl(i)%StartX = data%State%MudSystem%Xstart_MudElement%Array(i) !WRITE (*,*) 'StartX', FlowEl(i)%StartX - FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) + FlowEl(i)%EndX = data%State%MudSystem%Xend_MudElement%Array(i) !WRITE (*,*) 'EndX', FlowEl(i)%EndX - FlowEl(i)%StartTVD = MudSystem%TVDstart_MudElement%Array(i) + FlowEl(i)%StartTVD = data%State%MudSystem%TVDstart_MudElement%Array(i) !WRITE (*,*) 'StartTVD', FlowEl(i)%StartTVD - FlowEl(i)%EndTVD = MudSystem%TVDend_MudElement%Array(i) + FlowEl(i)%EndTVD = data%State%MudSystem%TVDend_MudElement%Array(i) !WRITE (*,*) 'EndTVD', FlowEl(i)%EndTVD FlowEl(i)%Id = 0.0 !WRITE (*,*) 'Id', FlowEl(i)%Id - FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) + FlowEl(i)%Od = data%State%MudSystem%PipeOD_MudElement%Array(i) !WRITE (*,*) 'Od', FlowEl(i)%Od - FlowEl(i)%Density = MudSystem%Density_MudElement%Array(i) + FlowEl(i)%Density = data%State%MudSystem%Density_MudElement%Array(i) !WRITE (*,*) 'Density', FlowEl(i)%Density @@ -158,9 +162,9 @@ SUBROUTINE WellPressureDataTransfer !WRITE (*,*) 'DepthDiff', FlowEl(i)%DepthDiff FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (data%State%MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN + ELSE IF (data%State%MudSystem%MudType_MudElement%Array(i) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -180,25 +184,25 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!! Annulus - FricPressDropVars%AnnulusFirstEl = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + 1 - FricPressDropVars%AnnulusLastEl = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl - DO i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + 1 , FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl - FlowEl(i)%StartX = MudSystem%Xstart_MudElement%Array(i) - FlowEl(i)%EndX = MudSystem%Xend_MudElement%Array(i) - FlowEl(i)%StartTVD = MudSystem%TVDstart_MudElement%Array(i) - FlowEl(i)%EndTVD = MudSystem%TVDend_MudElement%Array(i) - FlowEl(i)%Id = MudSystem%PipeID_MudElement%Array(i) - FlowEl(i)%Od = MudSystem%PipeOD_MudElement%Array(i) - FlowEl(i)%Density = MudSystem%Density_MudElement%Array(i) + data%State%FricPressDrop%AnnulusFirstEl = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + 1 + data%State%FricPressDrop%AnnulusLastEl = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + DO i = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + 1 , data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + FlowEl(i)%StartX = data%State%MudSystem%Xstart_MudElement%Array(i) + FlowEl(i)%EndX = data%State%MudSystem%Xend_MudElement%Array(i) + FlowEl(i)%StartTVD = data%State%MudSystem%TVDstart_MudElement%Array(i) + FlowEl(i)%EndTVD = data%State%MudSystem%TVDend_MudElement%Array(i) + FlowEl(i)%Id = data%State%MudSystem%PipeID_MudElement%Array(i) + FlowEl(i)%Od = data%State%MudSystem%PipeOD_MudElement%Array(i) + FlowEl(i)%Density = data%State%MudSystem%Density_MudElement%Array(i) FlowEl(i)%Dhyd = FlowEl(i)%Od - FlowEl(i)%Id FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = ABS(FlowEl(i)%StartTVD - FlowEl(i)%EndTVD) FlowEl(i)%Area = PI / 4.0 * (FlowEl(i)%Od**2 - FlowEl(i)%Id**2) / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (data%State%MudSystem%MudType_MudElement%Array(i) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudType_MudElement%Array(i) == 4) THEN + ELSE IF (data%State%MudSystem%MudType_MudElement%Array(i) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -218,22 +222,22 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!! Well to choke manifold path j = 1 - DO i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl + 1 , FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl + FricPressDropVars%NoWelltoChokeEl - FlowEl(i)%StartX = MudSystem%ChokeLine_Mud_Backhead_X%Array(j) - FlowEl(i)%EndX = MudSystem%ChokeLine_Mud_Forehead_X%Array(j) + DO i = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + 1 , data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + data%State%FricPressDrop%NoWelltoChokeEl + FlowEl(i)%StartX = data%State%MudSystem%ChokeLine_Mud_Backhead_X%Array(j) + FlowEl(i)%EndX = data%State%MudSystem%ChokeLine_Mud_Forehead_X%Array(j) FlowEl(i)%StartTVD = 0.d0 FlowEl(i)%EndTVD = 0.d0 FlowEl(i)%Id = 0.0 FlowEl(i)%Od = BopStackSpecification%ChokeLineId - FlowEl(i)%density = MudSystem%ChokeLine_Density%Array(j) + FlowEl(i)%density = data%State%MudSystem%ChokeLine_Density%Array(j) FlowEl(i)%Dhyd = FlowEl(i)%Od FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = 0.d0 FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%ChokeLine_MudOrKick%Array(j) == 0 .OR. MudSystem%ChokeLine_MudOrKick%Array(j) == 4) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air - FlowEl(i)%MaterialType = MudSystem%ChokeLine_MudOrKick%Array(j) + IF (data%State%MudSystem%ChokeLine_MudOrKick%Array(j) == 0 .OR. data%State%MudSystem%ChokeLine_MudOrKick%Array(j) == 4) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + FlowEl(i)%MaterialType = data%State%MudSystem%ChokeLine_MudOrKick%Array(j) ELSE FlowEl(i)%MaterialType = 1 END IF @@ -251,26 +255,26 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!! Open Hole - FricPressDropVars%OpenholeFirstEl = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl + FricPressDropVars%NoWelltoChokeEl + 1 + data%State%FricPressDrop%OpenholeFirstEl = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl + data%State%FricPressDrop%NoWelltoChokeEl + 1 j = 1 - DO i = FricPressDropVars%OpenholeFirstEl , FricPressDropVars%NumbEl ! = NoHorizontalEl + NoStringEl + NoCasingEl + NoOpenHoleEl - FlowEl(i)%StartX = MudSystem%Xstart_OpMudElement%Array(j) - FlowEl(i)%EndX = MudSystem%Xend_OpMudElement%Array(j) - FlowEl(i)%StartTVD = MudSystem%TVDstart_OpMudElement%Array(j) - FlowEl(i)%EndTVD = MudSystem%TVDend_OpMudElement%Array(j) + DO i = data%State%FricPressDrop%OpenholeFirstEl , data%State%FricPressDrop%NumbEl ! = NoHorizontalEl + NoStringEl + NoCasingEl + NoOpenHoleEl + FlowEl(i)%StartX = data%State%MudSystem%Xstart_OpMudElement%Array(j) + FlowEl(i)%EndX = data%State%MudSystem%Xend_OpMudElement%Array(j) + FlowEl(i)%StartTVD = data%State%MudSystem%TVDstart_OpMudElement%Array(j) + FlowEl(i)%EndTVD = data%State%MudSystem%TVDend_OpMudElement%Array(j) FlowEl(i)%Id = 0.0 - FlowEl(i)%Od = MudSystem%PipeOD_OpMudElement%Array(j) - FlowEl(i)%density = MudSystem%Density_OpMudElement%Array(j) - FlowEl(i)%MaterialType = MudSystem%MudTypeOp_MudElement%Array(j) ! = 0 for mud, = 1 for gas kick, = 4 for air + FlowEl(i)%Od = data%State%MudSystem%PipeOD_OpMudElement%Array(j) + FlowEl(i)%density = data%State%MudSystem%Density_OpMudElement%Array(j) + FlowEl(i)%MaterialType = data%State%MudSystem%MudTypeOp_MudElement%Array(j) ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%Dhyd = FlowEl(i)%Od FlowEl(i)%Length = ABS(FlowEl(i)%EndX - FlowEl(i)%StartX) FlowEl(i)%DepthDiff = ABS(FlowEl(i)%StartTVD - FlowEl(i)%EndTVD) FlowEl(i)%Area = PI / 4.0 * FlowEl(i)%Od**2 / Convfttoinch**2 FlowEl(i)%Volume = FlowEl(i)%Area * REAL(FlowEl(i)%Length) - IF (MudSystem%MudTypeOp_MudElement%Array(j) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air + IF (data%State%MudSystem%MudTypeOp_MudElement%Array(j) == 0) THEN ! = 0 for mud, = 1 for gas kick, = 4 for air FlowEl(i)%MaterialType = 0 - ELSE IF (MudSystem%MudTypeOp_MudElement%Array(j) == 4) THEN + ELSE IF (data%State%MudSystem%MudTypeOp_MudElement%Array(j) == 4) THEN FlowEl(i)%MaterialType = 4 ELSE FlowEl(i)%MaterialType = 1 @@ -291,13 +295,13 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!!!!! Mud Element Viscosity Calculation - DO i = 1 , FricPressDropVars%NumbEl + DO i = 1 , data%State%FricPressDrop%NumbEl IF (FlowEl(i)%MaterialType /= 0) CYCLE IF (FlowEl(i)%density < 8.33) THEN - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%StringFirstEl , FricPressDropVars%AnnulusFirstEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%OpenHoleFirstEl + WRITE (*,*) 'H, S, A, Ch, O', data%State%FricPressDrop%NoHorizontalEl , data%State%FricPressDrop%StringFirstEl , data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%NoWellToChokeEl , data%State%FricPressDrop%OpenHoleFirstEl WRITE (*,*) 'Element No, Volume(gal), Density(ppg), Type' - DO j = 1 , FricPressDropVars%NumbEl + DO j = 1 , data%State%FricPressDrop%NumbEl WRITE (*,*) j, FlowEl(j)%Volume * ConvFt3toUSGal , FlowEl(j)%Density, FlowEl(j)%MaterialType END DO @@ -324,36 +328,36 @@ SUBROUTINE WellPressureDataTransfer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - MudSystem%OpenArea32 = ((ChokeManifold%LeftManualChoke * (1.0 - FricPressDropVars%ManChoke1Plug * REAL(ChokeProblems%ManualChoke1PluggedPercent)) / 100.0) + 0.5 * FricPressDropVars%ManChoke1Washout) * Choke%ChokeAreaFullyOpen - MudSystem%OpenArea33 = CHOOKE(1)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(1)%PercentClose) * ChokeAreaFullyOpen - MudSystem%OpenArea34 = CHOOKE(2)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - CHOOKE(2)%PercentClose) * ChokeAreaFullyOpen - MudSystem%OpenArea35 = ((ChokeManifold%RightManualChoke * (1.0 - FricPressDropVars%ManChoke2Plug * REAL(ChokeProblems%ManualChoke2PluggedPercent)) / 100.0) + 0.5 * FricPressDropVars%ManChoke2Washout) * Choke%ChokeAreaFullyOpen + data%State%MudSystem%OpenArea32 = ((data%EquipmentControl%ChokeManifold%LeftManualChoke * (1.0 - data%State%FricPressDrop%ManChoke1Plug * REAL(data%problems%ChokeProblems%ManualChoke1PluggedPercent)) / 100.0) + 0.5 * data%State%FricPressDrop%ManChoke1Washout) * data%State%Choke%ChokeAreaFullyOpen + data%State%MudSystem%OpenArea33 = data%State%CHOOKE(1)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - data%State%CHOOKE(1)%PercentClose) * ChokeAreaFullyOpen + data%State%MudSystem%OpenArea34 = data%State%CHOOKE(2)%AreaChokeFinal * Convfttoinch**2 ! (1.d0 - data%State%CHOOKE(2)%PercentClose) * ChokeAreaFullyOpen + data%State%MudSystem%OpenArea35 = ((data%EquipmentControl%ChokeManifold%RightManualChoke * (1.0 - data%State%FricPressDrop%ManChoke2Plug * REAL(data%problems%ChokeProblems%ManualChoke2PluggedPercent)) / 100.0) + 0.5 * data%State%FricPressDrop%ManChoke2Washout) * data%State%Choke%ChokeAreaFullyOpen !write(*,*) 'OpenArea32=' , OpenArea32, active32, ManChoke1Plug, ManualChoke1PluggedPercent, ManChoke1Washout !write(*,*) 'OpenArea33=' , OpenArea33, active33 !write(*,*) 'OpenArea34=' , OpenArea34, active34, !HydraulicChoke2PluggedPercent !write(*,*) 'OpenArea35=' , OpenArea35, active35, ManChoke2Plug, ManualChoke2PluggedPercent, ManChoke2Washout - InstantaneousTotalOpenChokeArea = MudSystem%OpenArea32 * active32 + MudSystem%OpenArea33 * active33 + MudSystem%OpenArea34 * active34 + MudSystem%OpenArea35 * active35 + FricPressDropVars%ChokeBypassArea * active29 - FricPressDropVars%OldTotalOpenChokeArea = FricPressDropVars%TotalOpenChokeArea + InstantaneousTotalOpenChokeArea = data%State%MudSystem%OpenArea32 * active32 + data%State%MudSystem%OpenArea33 * active33 + data%State%MudSystem%OpenArea34 * active34 + data%State%MudSystem%OpenArea35 * active35 + data%State%FricPressDrop%ChokeBypassArea * active29 + data%State%FricPressDrop%OldTotalOpenChokeArea = data%State%FricPressDrop%TotalOpenChokeArea !WRITE (*,*) 'Instantaneous / Old TotalOpenChokeArea', InstantaneousTotalOpenChokeArea, OldTotalOpenChokeArea - IF (FricPressDropVars%OldTotalOpenChokeArea <= 0.01 * Choke%ChokeAreaFullyOpen) FricPressDropVars%OldTotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen - IF (InstantaneousTotalOpenChokeArea <= 0.01 * Choke%ChokeAreaFullyOpen) THEN - MudSystem%WellToChokeManifoldOpen = .FALSE. - FricPressDropVars%OldTotalOpenChokeArea = 0.01 * Choke%ChokeAreaFullyOpen + IF (data%State%FricPressDrop%OldTotalOpenChokeArea <= 0.01 * data%State%Choke%ChokeAreaFullyOpen) data%State%FricPressDrop%OldTotalOpenChokeArea = 0.01 * data%State%Choke%ChokeAreaFullyOpen + IF (InstantaneousTotalOpenChokeArea <= 0.01 * data%State%Choke%ChokeAreaFullyOpen) THEN + data%State%MudSystem%WellToChokeManifoldOpen = .FALSE. + data%State%FricPressDrop%OldTotalOpenChokeArea = 0.01 * data%State%Choke%ChokeAreaFullyOpen !WRITE (*,*) ' Choke Controler Here 2' - ELSE IF (InstantaneousTotalOpenChokeArea > 0.5 * Choke%ChokeAreaFullyOpen .OR. MudSystem%WellToPitsOpen) THEN + ELSE IF (InstantaneousTotalOpenChokeArea > 0.5 * data%State%Choke%ChokeAreaFullyOpen .OR. data%State%MudSystem%WellToPitsOpen) THEN ! mud flows through well to bell nipple, or choke is rather open - FricPressDropVars%TotalOpenChokeArea = InstantaneousTotalOpenChokeArea + data%State%FricPressDrop%TotalOpenChokeArea = InstantaneousTotalOpenChokeArea !WRITE (*,*) ' Choke Controler Here 1' ELSE - IF (InstantaneousTotalOpenChokeArea > FricPressDropVars%OldTotalOpenChokeArea) THEN - FricPressDropVars%TotalOpenChokeArea = MIN(1.1 * FricPressDropVars%OldTotalOpenChokeArea , InstantaneousTotalOpenChokeArea) + IF (InstantaneousTotalOpenChokeArea > data%State%FricPressDrop%OldTotalOpenChokeArea) THEN + data%State%FricPressDrop%TotalOpenChokeArea = MIN(1.1 * data%State%FricPressDrop%OldTotalOpenChokeArea , InstantaneousTotalOpenChokeArea) WRITE (*,*) ' Choke is opening' !, TotalOpenChokeArea, OldTotalOpenChokeArea, InstantaneousTotalOpenChokeArea - ELSE IF (InstantaneousTotalOpenChokeArea < FricPressDropVars%OldTotalOpenChokeArea) THEN - FricPressDropVars%TotalOpenChokeArea = MAX(0.9 * FricPressDropVars%OldTotalOpenChokeArea , InstantaneousTotalOpenChokeArea) + ELSE IF (InstantaneousTotalOpenChokeArea < data%State%FricPressDrop%OldTotalOpenChokeArea) THEN + data%State%FricPressDrop%TotalOpenChokeArea = MAX(0.9 * data%State%FricPressDrop%OldTotalOpenChokeArea , InstantaneousTotalOpenChokeArea) WRITE (*,*) ' Choke is closing' !, TotalOpenChokeArea, OldTotalOpenChokeArea, InstantaneousTotalOpenChokeArea ELSE - FricPressDropVars%TotalOpenChokeArea = InstantaneousTotalOpenChokeArea + data%State%FricPressDrop%TotalOpenChokeArea = InstantaneousTotalOpenChokeArea END IF END IF !WRITE (*,*) 'TotalOpenChokeArea=', TotalOpenChokeArea @@ -368,7 +372,7 @@ SUBROUTINE WellPressureDataTransfer KickVARIABLES%ChokeKroneckerDelta = 0 !WRITE (*,*) ' WelltoPitsOpen = ', WelltoPitsOpen !WRITE (*,*) ' WellToChokeManifoldOpen = ', WellToChokeManifoldOpen - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN + IF (data%State%MudSystem%WellToPitsOpen == .FALSE. .AND. data%State%MudSystem%WellToChokeManifoldOpen == .FALSE.) THEN !WRITE (*,*) ' WelltoPitsOpen = ', WelltoPitsOpen !WRITE (*,*) ' WellToChokeManifoldOpen = ', WellToChokeManifoldOpen @@ -378,20 +382,20 @@ SUBROUTINE WellPressureDataTransfer KickVARIABLES%WellHeadOpen = .TRUE. END IF - IF (MudSystem%WellToPitsOpen == .FALSE. .AND. MudSystem%WellToChokeManifoldOpen) KickVARIABLES%ChokeKroneckerDelta = 1 + IF (data%State%MudSystem%WellToPitsOpen == .FALSE. .AND. data%State%MudSystem%WellToChokeManifoldOpen) KickVARIABLES%ChokeKroneckerDelta = 1 !WRITE (*,*) ' WelltoPitsOpen=' , WelltoPitsOpen, 'WellToChokeManifoldOpen= ' , WellToChokeManifoldOpen !WRITE (*,*) 'WellToChokeOpen , WellToChokeWasOpen', WellToChokeManifoldOpen, KickVARIABLES%WellToChokeManifoldWasOpen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IF (KickVARIABLES%NoGasPocket > 0) THEN - IF (MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0) THEN + IF (data%State%MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0) THEN !WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', Choke_Kick_Saved_Volume_Final, (GasPocketModifiedVol%Array(NoGasPocket) * Convft3ToUSgal) - KickVARIABLES%ExitMass = REAL(MudSystem%Choke_Kick_Saved_Volume_Final / (GasPocketModifiedVol%Array(KickVARIABLES%NoGasPocket) * Convft3ToUSgal)) * GasPocketWeight%Array(KickVARIABLES%NoGasPocket) + KickVARIABLES%ExitMass = REAL(data%State%MudSystem%Choke_Kick_Saved_Volume_Final / (GasPocketModifiedVol%Array(KickVARIABLES%NoGasPocket) * Convft3ToUSgal)) * GasPocketWeight%Array(KickVARIABLES%NoGasPocket) !IF (NoGasPocket > 1) ExitMass = ExitMass + (SUM(GasPocketDeltaVol%Array(1 : NoGasPocket - 1)) / GasPocketNewVol%Array(NoGasPocket)) * GasPocketWeight%Array(NoGasPocket) - !WRITE (*,*) 'Total Exit mass=' , ExitMass !, DeltaVolumePipe, MudSystem%StringFlowRate * dt / ConvMinToSec - IF (FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%MaterialType /= 1) THEN + !WRITE (*,*) 'Total Exit mass=' , ExitMass !, DeltaVolumePipe, data%State%MudSystem%StringFlowRate * dt / ConvMinToSec + IF (FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%MaterialType /= 1) THEN CALL RemoveGasPocket(KickVARIABLES%NoGasPocket) - WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', MudSystem%Choke_Kick_Saved_Volume_Final + WRITE (*,*) 'Choke_Kick_Saved_Volume_Final=', data%State%MudSystem%Choke_Kick_Saved_Volume_Final END IF END IF @@ -401,20 +405,20 @@ SUBROUTINE WellPressureDataTransfer IF (KickVARIABLES%NoGasPocket > 0) CALL GasPocketFlowElementTransformer END IF - IF (FricPressDropVars%NoWelltoChokeEl > 0) THEN + IF (data%State%FricPressDrop%NoWelltoChokeEl > 0) THEN KickVARIABLES%OldChokeDensity = KickVARIABLES%ChokeDensity VolumeDensityProduct = 0.0 - Do i = FricPressDropVars%AnnulusLastEl + 1 , FricPressDropVars%OpenholeFirstEl - 1 + Do i = data%State%FricPressDrop%AnnulusLastEl + 1 , data%State%FricPressDrop%OpenholeFirstEl - 1 VolumeDensityProduct = VolumeDensityProduct + ((MAX(FlowEl(i)%Density , KickVARIABLES%ChokeMinDensity)) * FlowEl(i)%Volume) End Do - KickVARIABLES%ChokeDensity = VolumeDensityProduct / SUM(FlowEl(FricPressDropVars%AnnulusLastEl + 1 : FricPressDropVars%OpenholeFirstEl - 1)%Volume) + KickVARIABLES%ChokeDensity = VolumeDensityProduct / SUM(FlowEl(data%State%FricPressDrop%AnnulusLastEl + 1 : data%State%FricPressDrop%OpenholeFirstEl - 1)%Volume) !WRITE (*,*) 'ChokeDensity=', KickVARIABLES%ChokeDensity - FricPressDropVars%Kchoke = (KickVARIABLES%ChokeDensity / ((2.0 * 89158.0) * (0.26 * 0.61 * FricPressDropVars%TotalOpenChokeArea)**2)) * 4.d0 ! *4.d0: seyyed gofte + data%State%FricPressDrop%Kchoke = (KickVARIABLES%ChokeDensity / ((2.0 * 89158.0) * (0.26 * 0.61 * data%State%FricPressDrop%TotalOpenChokeArea)**2)) * 4.d0 ! *4.d0: seyyed gofte END IF - IF (FricPressDropVars%BitTotallyPluged == .FALSE.) THEN - FricPressDropVars%KBit = FlowEl(FricPressDropVars%StringLastEl)%density / 12042.0 / BitCd**2 / BitTotNozzArea**2 + IF (data%State%FricPressDrop%BitTotallyPluged == .FALSE.) THEN + data%State%FricPressDrop%KBit = FlowEl(data%State%FricPressDrop%StringLastEl)%density / 12042.0 / BitCd**2 / BitTotNozzArea**2 END IF @@ -433,6 +437,7 @@ SUBROUTINE GasPocketFlowElementTransformer USE FricPressDropVarsModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE GeoElements_FluidModule USE Fluid_Flow_Startup_Vars use KickVARIABLESModule @@ -453,7 +458,7 @@ SUBROUTINE GasPocketFlowElementTransformer i = 1 j = 1 - DO k = FricPressDropVars%OpenholeFirstEl , FricPressDropVars%NumbEl + DO k = data%State%FricPressDrop%OpenholeFirstEl , data%State%FricPressDrop%NumbEl IF (FlowEl(k)%MaterialType == 1) THEN IF (j > 1) THEN IF (KickVARIABLES%GasPocketFlowEl(i , j - 1) /= k - 1) THEN @@ -478,10 +483,10 @@ SUBROUTINE GasPocketFlowElementTransformer END DO !WRITE (*,*) 'GasPocketFlowEl=' , GasPocketFlowEl - DO k = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%OpenholeFirstEl - 1 + DO k = data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%OpenholeFirstEl - 1 IF (FlowEl(k)%MaterialType == 1) THEN IF (j > 1) THEN - IF (k == FricPressDropVars%AnnulusFirstEl .AND. KickVARIABLES%GasPocketFlowEl(i , j - 1) == FricPressDropVars%NumbEl) THEN + IF (k == data%State%FricPressDrop%AnnulusFirstEl .AND. KickVARIABLES%GasPocketFlowEl(i , j - 1) == data%State%FricPressDrop%NumbEl) THEN !WRITE (*,*) 'Kick is Around Bit' ELSE IF (KickVARIABLES%GasPocketFlowEl(i , j - 1) /= k - 1) THEN i = i + 1 @@ -502,10 +507,10 @@ SUBROUTINE GasPocketFlowElementTransformer IF (i > KickVARIABLES%NoGasPocket) THEN WRITE (*,*) 'GasPocketFlowEl', KickVARIABLES%GasPocketFlowEl WRITE (*,*) 'i , j , k', i, j, k - WRITE (*,*) 'H, S, A, Ch, O', FricPressDropVars%NoHorizontalEl , FricPressDropVars%StringFirstEl , FricPressDropVars%AnnulusFirstEl , FricPressDropVars%NoWellToChokeEl , FricPressDropVars%OpenHoleFirstEl + WRITE (*,*) 'H, S, A, Ch, O', data%State%FricPressDrop%NoHorizontalEl , data%State%FricPressDrop%StringFirstEl , data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%NoWellToChokeEl , data%State%FricPressDrop%OpenHoleFirstEl WRITE (*,*) 'Element No, Volume(gal), Density(ppg), Type' - DO j = 1 , FricPressDropVars%NumbEl + DO j = 1 , data%State%FricPressDrop%NumbEl WRITE (*,*) j, FlowEl(j)%Volume * ConvFt3toUSGal , FlowEl(j)%Density, FlowEl(j)%MaterialType END DO @@ -532,8 +537,8 @@ SUBROUTINE GasPocketFlowElementTransformer IF (KickVARIABLES%GasPocketFlowEl(i , j) > 0) GasPocketModifiedVol%Array(i) = GasPocketModifiedVol%Array(i) + FlowEl(KickVARIABLES%GasPocketFlowEl(i , j))%Volume END DO END DO - i = FricPressDropVars%AnnulusLastEl - j = FricPressDropVars%OpenholeFirstEl - 1 + i = data%State%FricPressDrop%AnnulusLastEl + j = data%State%FricPressDrop%OpenholeFirstEl - 1 GasPocketOldVol%Array(:) = GasPocketModifiedVol%Array(:) @@ -555,13 +560,13 @@ SUBROUTINE GasPocketFlowElementTransformer DownHole%InfluxRate = MAX(((KickVARIABLES%KickmdotACoef * (KickVARIABLES%KickmdotBCoef - GasPocketNewPress%Array(1))) / GasPocketDensity%Array(1) * ConvMinToSec) , 0.0) !WRITE (*,*) ' InfluxRate (gpm) =', InfluxRate - i = FricPressDropVars%OpenholeFirstEl - 1 - IF (MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0 .AND. KickVARIABLES%WellHeadOpen) THEN + i = data%State%FricPressDrop%OpenholeFirstEl - 1 + IF (data%State%MudSystem%Choke_Kick_Saved_Volume_Final > 0.d0 .AND. KickVARIABLES%WellHeadOpen) THEN WRITE (*,*) 'Kick is exiting through the choke' - !KickVARIABLES%ExitMass = GasPocketDensity%Array(NoGasPocket) * (SUM(GasPocketFlowInduced%Array(:)) + (DeltaVolumePipe * ConvMinToSec / dt) + MudSystem%StringFlowRate) / ConvMinToSec * dt + !KickVARIABLES%ExitMass = GasPocketDensity%Array(NoGasPocket) * (SUM(GasPocketFlowInduced%Array(:)) + (DeltaVolumePipe * ConvMinToSec / dt) + data%State%MudSystem%StringFlowRate) / ConvMinToSec * dt GasPocketWeight%Array(KickVARIABLES%NoGasPocket) = GasPocketweight%Array(KickVARIABLES%NoGasPocket) - KickVARIABLES%ExitMass IF (GasPocketWeight%Array(KickVARIABLES%NoGasPocket) > 0.0) THEN - GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) = GasPocketWeight%Array(KickVARIABLES%NoGasPocket) * GasType(KickVARIABLES%KickGasType)%GasConstant * & + GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) = GasPocketWeight%Array(KickVARIABLES%NoGasPocket) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & GasPocketCompressibility%Array(KickVARIABLES%NoGasPocket) * GasPocketNewTemp%Array(KickVARIABLES%NoGasPocket) / GasPocketModifiedVol%Array(KickVARIABLES%NoGasPocket) GasPocketDensity%Array(KickVARIABLES%NoGasPocket) = (GasPocketweight%Array(KickVARIABLES%NoGasPocket) / GasPocketModifiedVol%Array(KickVARIABLES%NoGasPocket)) / convft3toUSgal GasPocketNewVol%Array(:) = GasPocketOldVol%Array(:) @@ -584,7 +589,7 @@ SUBROUTINE GasPocketFlowElementTransformer 103 FORMAT (2I, 4X, (F9.3), 5X, (F9.3)) GasPocketNewPress%Array(KickVARIABLES%NoGasPocket) = GasPocketOldPress%Array(KickVARIABLES%NoGasPocket) - GasPocketNewVol%Array(KickVARIABLES%NoGasPocket) = GasPocketCompressibility%Array(KickVARIABLES%NoGasPocket) * GasType(KickVARIABLES%KickGasType)%GasConstant * & + GasPocketNewVol%Array(KickVARIABLES%NoGasPocket) = GasPocketCompressibility%Array(KickVARIABLES%NoGasPocket) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & GasPocketNewTemp%Array(KickVARIABLES%NoGasPocket) * GasPocketWeight%Array(KickVARIABLES%NoGasPocket) / GasPocketNewPress%Array(KickVARIABLES%NoGasPocket) @@ -593,13 +598,13 @@ SUBROUTINE GasPocketFlowElementTransformer DO WHILE (ABS(PressureCorrection * 10.0) > KickConvergenceTolerance) DO j = KickVARIABLES%NoGasPocket - 1 , 1 , -1 CALL KickFunctionsCalculator(GasPocketNewPress%Array(j) , j , 5) - GasPocketNewVol%Array(j) = GasPocketCompressibility%Array(j) * GasType(KickVARIABLES%KickGasType)%GasConstant * & + GasPocketNewVol%Array(j) = GasPocketCompressibility%Array(j) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & GasPocketNewTemp%Array(j) * GasPocketWeight%Array(j) / GasPocketNewPress%Array(j) !WRITE (*,*) j, REAL(GasPocketNewPress%Array(j)), REAL(GasPocketNewVol%Array(j) * Convft3toUSgal) END DO PressureCorrection = (SUM(GasPocketNewVol%Array(:)) - SUM(GasPocketOldVol%Array(:))) / SUM(GasPocketNewVol%Array(:) / GasPocketNewPress%Array(:)) GasPocketNewPress%Array(KickVARIABLES%NoGasPocket) = GasPocketNewPress%Array(KickVARIABLES%NoGasPocket) + PressureCorrection - GasPocketNewVol%Array(KickVARIABLES%NoGasPocket) = GasPocketCompressibility%Array(KickVARIABLES%NoGasPocket) * GasType(KickVARIABLES%KickGasType)%GasConstant * & + GasPocketNewVol%Array(KickVARIABLES%NoGasPocket) = GasPocketCompressibility%Array(KickVARIABLES%NoGasPocket) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & GasPocketNewTemp%Array(KickVARIABLES%NoGasPocket) * GasPocketWeight%Array(KickVARIABLES%NoGasPocket) / GasPocketNewPress%Array(KickVARIABLES%NoGasPocket) j = KickVARIABLES%NoGasPocket !WRITE (*,*) j, REAL(GasPocketNewPress%Array(j)), REAL(GasPocketNewVol%Array(j) * Convft3toUSgal) @@ -641,6 +646,7 @@ SUBROUTINE RemoveGasPocket(ilocal) use KickVARIABLESModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ IMPLICIT NONE diff --git a/FluidFlow/kick/Formation_Information.f90 b/FluidFlow/kick/Formation_Information.f90 index b11e59e..33c1bb9 100644 --- a/FluidFlow/kick/Formation_Information.f90 +++ b/FluidFlow/kick/Formation_Information.f90 @@ -1,13 +1,14 @@ SUBROUTINE FormationInformationCalculator use KickVARIABLESModule - Use TD_WellGeometry + use ConfigurationVariables !@ Use CReservoirVariables Use CFormationVariables USE Fluid_Flow_Startup_Vars USE CLog2 USE CDownHoleVariables USE MudSystemVARIABLES +use ConfigurationVariables !@@@ use ConfigurationVariables IMPLICIT NONE @@ -25,23 +26,23 @@ SUBROUTINE FormationInformationCalculator KickVARIABLES%KickFormTopMD = 0. KickVARIABLES%KickFormDownMD = 0. !===> Top Measured Depth of Formation - Do i = 1 , TD_WellGeneral%WellIntervalsCount - if ( Reservoir%FormationTop >= TD_WellGeo(i)%VerticalDepth ) then - KickVARIABLES%KickFormTopMD = KickVARIABLES%KickFormTopMD + TD_WellGeo(i)%IntervalLength - !WRITE (*,*) ' here 11' , TD_WellGeo(i)%IntervalLength - !WRITE (*,*) ' here v11' , TD_WellGeo(i)%VerticalDepth + Do i = 1 , data%State%TD_WellGeneral%WellIntervalsCount + if ( Reservoir%FormationTop >= data%State%TD_WellGeo(i)%VerticalDepth ) then + KickVARIABLES%KickFormTopMD = KickVARIABLES%KickFormTopMD + data%State%TD_WellGeo(i)%IntervalLength + !WRITE (*,*) ' here 11' , data%State%TD_WellGeo(i)%IntervalLength + !WRITE (*,*) ' here v11' , data%State%TD_WellGeo(i)%VerticalDepth - WellGeoTopTVD = TD_WellGeo(i)%VerticalDepth - else if ( Reservoir%FormationTop < TD_WellGeo(i)%VerticalDepth ) then - if ( TD_WellGeo(i)%HoleType == 0 ) then + WellGeoTopTVD = data%State%TD_WellGeo(i)%VerticalDepth + else if ( Reservoir%FormationTop < data%State%TD_WellGeo(i)%VerticalDepth ) then + if ( data%State%TD_WellGeo(i)%HoleType == 0 ) then KickVARIABLES%KickFormTopMD = KickVARIABLES%KickFormTopMD + ((Reservoir%FormationTop - WellGeoTopTVD)& - / cos(TD_WellGeo(i)%StartAngle)) - !WRITE (*,*) ' here 12' , (FormationTop - WellGeoTopTVD) / cos(TD_WellGeo(i)%StartAngle) + / cos(data%State%TD_WellGeo(i)%StartAngle)) + !WRITE (*,*) ' here 12' , (FormationTop - WellGeoTopTVD) / cos(data%State%TD_WellGeo(i)%StartAngle) else - KickVARIABLES%KickFormTopMD = KickVARIABLES%KickFormTopMD + (TD_WellGeo(i)%RCurvature & - * Asin((Reservoir%FormationTop - WellGeoTopTVD) / TD_WellGeo(i)%RCurvature)) - !WRITE (*,*) ' here 13' , TD_WellGeo(i)%RCurvature * Asin((FormationTop - WellGeoTopTVD) / TD_WellGeo(i)%RCurvature) + KickVARIABLES%KickFormTopMD = KickVARIABLES%KickFormTopMD + (data%State%TD_WellGeo(i)%RCurvature & + * Asin((Reservoir%FormationTop - WellGeoTopTVD) / data%State%TD_WellGeo(i)%RCurvature)) + !WRITE (*,*) ' here 13' , data%State%TD_WellGeo(i)%RCurvature * Asin((FormationTop - WellGeoTopTVD) / data%State%TD_WellGeo(i)%RCurvature) end if exit @@ -50,44 +51,44 @@ SUBROUTINE FormationInformationCalculator !!===> Down Measured Depth of Formation WellGeoTopTVD = 0. - Do i = 1 , TD_WellGeneral%WellIntervalsCount - if ( (Reservoir%FormationTop + Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness)>=TD_WellGeo(i)%VerticalDepth ) then - KickVARIABLES%KickFormDownMD = KickVARIABLES%KickFormDownMD + TD_WellGeo(i)%IntervalLength - WellGeoTopTVD = TD_WellGeo(i)%VerticalDepth - else if ( (Reservoir%FormationTop+Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness)=data%State%TD_WellGeo(i)%VerticalDepth ) then + KickVARIABLES%KickFormDownMD = KickVARIABLES%KickFormDownMD + data%State%TD_WellGeo(i)%IntervalLength + WellGeoTopTVD = data%State%TD_WellGeo(i)%VerticalDepth + else if ( (Reservoir%FormationTop+data%Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness) Determination of Formation Length for Kick Modeling - if (TD_WellGeneral%WellTotalVerticalLength >= Reservoir%FormationTop .AND. TD_WellGeneral%WellTotalVerticalLength < (Reservoir%FormationTop+Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness)) then - KickVARIABLES%KickFormLength = TD_WellGeneral%WellTotalLength - KickVARIABLES%KickFormTopMD ![ft] - else if ( TD_WellGeneral%WellTotalVerticalLength >= (Reservoir%FormationTop + Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness) ) then + if (data%State%TD_WellGeneral%WellTotalVerticalLength >= Reservoir%FormationTop .AND. data%State%TD_WellGeneral%WellTotalVerticalLength < (Reservoir%FormationTop+data%Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness)) then + KickVARIABLES%KickFormLength = data%State%TD_WellGeneral%WellTotalLength - KickVARIABLES%KickFormTopMD ![ft] + else if ( data%State%TD_WellGeneral%WellTotalVerticalLength >= (Reservoir%FormationTop + data%Configuration%Formation%Formations(Reservoir%FormationNo)%Thickness) ) then KickVARIABLES%KickFormLength = KickVARIABLES%KickFormDownMD - KickVARIABLES%KickFormTopMD ![ft] else KickVARIABLES%KickFormLength = 0. end if !PermeabilityExposedHeight = KickVARIABLES%KickFormLength * FormationPermeability - DownHole%PermeabilityExposedHeight = MudSystem%FluidFlowCounter - MudSystem%MudSys_timeCounter + DownHole%PermeabilityExposedHeight = data%State%MudSystem%FluidFlowCounter - data%State%MudSystem%MudSys_timeCounter !==================================================== ! Reservoir Data !==================================================== KickVARIABLES%FormPermeability = Reservoir%FormationPermeability ! [mD] - KickVARIABLES%FormPressure = TD_WellGeneral%WellTotalVerticalLength * Configuration%Formation%Formations(Reservoir%FormationNo)%PorePressureGradient ![psia] + KickVARIABLES%FormPressure = data%State%TD_WellGeneral%WellTotalVerticalLength * data%Configuration%Formation%Formations(Reservoir%FormationNo)%PorePressureGradient ![psia] DownHole%FormationPressure = INT(KickVARIABLES%FormPressure) !CALL Log_2('FormPressure =' , KickVARIABLES%FormPressure) !print*, 'Formations(FormationNo)%PorePressureGradient=', Formations(FormationNo)%PorePressureGradient !print * , 'FormationNo=' , FormationNo - !print * , 'TD_WellGeneral%WellTotalVerticalLength=' , TD_WellGeneral%WellTotalVerticalLength + !print * , 'data%State%TD_WellGeneral%WellTotalVerticalLength=' , data%State%TD_WellGeneral%WellTotalVerticalLength KickVARIABLES%FormTemperature = 600 ! [Ra] !WRITE (*,*) ' Formation pressure ' , KickVARIABLES%FormPressure @@ -100,11 +101,11 @@ SUBROUTINE FormationInformationCalculator KickVARIABLES%GasResPressure = KickVARIABLES%FormPressure !!!! Methane , Gas type =1 - KickVARIABLES%GasKickMolarMass = GasType(KickVARIABLES%KickGasType)%MolarWt ! Methane Gas [gr/mol] + KickVARIABLES%GasKickMolarMass = data%State%GasType(KickVARIABLES%KickGasType)%MolarWt ! Methane Gas [gr/mol] KickVARIABLES%GasSpecGravity = KickVARIABLES%GasKickMolarMass / GasDensityRefrence - KickVARIABLES%KickTc = GasType(KickVARIABLES%KickGasType)%CritTemp - KickVARIABLES%KickPc = GasType(KickVARIABLES%KickGasType)%CritPress + KickVARIABLES%KickTc = data%State%GasType(KickVARIABLES%KickGasType)%CritTemp + KickVARIABLES%KickPc = data%State%GasType(KickVARIABLES%KickGasType)%CritPress !!!!!!!! Calculating Compressibility, viscosity for influx condition (Average of reservoir and bottomhole) KickVARIABLES%KickTr = KickVARIABLES%GasResTemperature / KickVARIABLES%KickTc @@ -118,7 +119,7 @@ SUBROUTINE FormationInformationCalculator KickVARIABLES%GasResCompressibility = 0.98 !1. - (K_A_Res / K_B_Res) + (K_C_Res / K_D_Res) KickVARIABLES%GasReservoirDensity = KickVARIABLES%GasResPressure / (KickVARIABLES%GasResCompressibility * & - KickVARIABLES%GasResTemperature * GasType(KickVARIABLES%KickGasType)%GasConstant) / Convft3toUSgal ! [ppg] + KickVARIABLES%GasResTemperature * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant) / Convft3toUSgal ! [ppg] END SUBROUTINE \ No newline at end of file diff --git a/FluidFlow/kick/Gas_Kick_Calculator.f90 b/FluidFlow/kick/Gas_Kick_Calculator.f90 index b2192fc..ea51954 100644 --- a/FluidFlow/kick/Gas_Kick_Calculator.f90 +++ b/FluidFlow/kick/Gas_Kick_Calculator.f90 @@ -1,13 +1,14 @@ SUBROUTINE GasKickCalculator - + use ConfigurationVariables use KickVARIABLESModule - Use TD_WellGeometry + use ConfigurationVariables !@ Use CReservoirVariables Use CFormationVariables USE Fluid_Flow_Startup_Vars use PressureDisplayVARIABLESModule USE FricPressDropVarsModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE CMudPropertiesVariables USE CError USE , INTRINSIC :: IEEE_ARITHMETIC @@ -39,7 +40,7 @@ SUBROUTINE GasKickCalculator KickVARIABLES%K_Bb = 5.5565586 + (1000.01 / KickVARIABLES%KickFluxAvgTemperature) KickVARIABLES%K_Cc = 2.47862 - 0.12294 * KickVARIABLES%K_Bb KickVARIABLES%GasKickSIDensity = KickVARIABLES%KickFluxAvgPressure / (KickVARIABLES%KickFluxAvgCompressibility * & - KickVARIABLES%KickFluxAvgTemperature * GasType(KickVARIABLES%KickGasType)%GasConstant) * Convpcftogpcm3 + KickVARIABLES%KickFluxAvgTemperature * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant) * Convpcftogpcm3 KickVARIABLES%GasKickViscosity = KickVARIABLES%K_Aa * EXP(KickVARIABLES%K_Bb * KickVARIABLES%GasKickSIDensity**KickVARIABLES%K_Cc) !!!!!!!!!!!!!!!!!!!!!!!!! @@ -57,26 +58,26 @@ SUBROUTINE GasKickCalculator !WRITE (*,*) 'Gas Kick Top' !===> Kick Flow Rate Calculation IF (KickVARIABLES%FormPressure > KickVARIABLES%BottomHolePress) THEN - KickVARIABLES%KickmdotACoef = 10.0**(-8) * 1.15741d0 * 7.080 * KickVARIABLES%FormPermeability * REAL(KickVARIABLES%KickFormLength) * GasType(KickVARIABLES%KickGasType)%StDensity / & + KickVARIABLES%KickmdotACoef = 10.0**(-8) * 1.15741d0 * 7.080 * KickVARIABLES%FormPermeability * REAL(KickVARIABLES%KickFormLength) * data%State%GasType(KickVARIABLES%KickGasType)%StDensity / & (KickVARIABLES%GasKickViscosity * KickVARIABLES%GasKickBg * LOG(10000.0)) !IF (WellHeadOpen .AND. NoGasPocket == 1) KickVARIABLES%KickmdotACoef = (1.d0 + 2.d0) * KickmdotACoef ELSE KickVARIABLES%KickmdotACoef = 0.0 END IF - i = FricPressDropVars%StringLastEl - j = FricPressDropVars%OpenholeFirstEl - 1 + i = data%State%FricPressDrop%StringLastEl + j = data%State%FricPressDrop%OpenholeFirstEl - 1 k = KickVARIABLES%GasPocketFlowEl(1 , 1) KickVARIABLES%KickmdotBCoef = KickVARIABLES%FormPressure + StandardPress !! - Sum(static and friction pressure loss) of flow elements below gas pocket, see below IF (KickVARIABLES%FormPressure > KickVARIABLES%BottomHolePress) THEN !WRITE (*,*) 'k , i, j' , k , i, j - IF (k >= FricPressDropVars%OpenholeFirstEl) THEN ! Bottom of active kick is in openhole - KickVARIABLES%KickmdotBCoef = KickVARIABLES%KickmdotBCoef - (SUM(FlowEl(FricPressDropVars%OpenholeFirstEl : k)%StaticPressDiff)) !+ SUM(FlowEl(j + 1 : GasPocketFlowEl(1 , 1) - 1)%FricPressLoss + IF (k >= data%State%FricPressDrop%OpenholeFirstEl) THEN ! Bottom of active kick is in openhole + KickVARIABLES%KickmdotBCoef = KickVARIABLES%KickmdotBCoef - (SUM(FlowEl(data%State%FricPressDrop%OpenholeFirstEl : k)%StaticPressDiff)) !+ SUM(FlowEl(j + 1 : GasPocketFlowEl(1 , 1) - 1)%FricPressLoss !WRITE (*,*) '1 SUM(FlowEl(j + 1 : k)%FricPressLoss', k, SUM(FlowEl(j + 1 : k)%FricPressLoss) - ELSE IF (k < FricPressDropVars%OpenholeFirstEl) THEN ! bottom of 1st gas pocket (active kick) is in annulus ond/or choke line only - KickVARIABLES%KickmdotBCoef = KickVARIABLES%KickmdotBCoef - SUM(FlowEl(FricPressDropVars%OpenholeFirstEl : FricPressDropVars%NumbEl)%StaticPressDiff) & - - (SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : k)%StaticPressDiff) + SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : k)%FricPressLoss)) + ELSE IF (k < data%State%FricPressDrop%OpenholeFirstEl) THEN ! bottom of 1st gas pocket (active kick) is in annulus ond/or choke line only + KickVARIABLES%KickmdotBCoef = KickVARIABLES%KickmdotBCoef - SUM(FlowEl(data%State%FricPressDrop%OpenholeFirstEl : data%State%FricPressDrop%NumbEl)%StaticPressDiff) & + - (SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : k)%StaticPressDiff) + SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : k)%FricPressLoss)) END IF END IF @@ -95,14 +96,14 @@ SUBROUTINE GasKickCalculator END DO END IF - KickVARIABLES%KickVandPFunction(1) = KickVARIABLES%KickUnknownVector(1) - GasPocketCompressibility%Array(1) * GasType(KickVARIABLES%KickGasType)%GasConstant * & ! VandP(1) = V(1) + KickVARIABLES%KickVandPFunction(1) = KickVARIABLES%KickUnknownVector(1) - GasPocketCompressibility%Array(1) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & ! VandP(1) = V(1) GasPocketNewTemp%Array(1) * (GasPocketWeight%Array(1) + KickVARIABLES%KickmdotACoef * MAX(((KickVARIABLES%KickmdotBCoef - KickVARIABLES%KickUnknownVector(2)) * dt) , 0.0)) / KickVARIABLES%KickUnknownVector(2) !WRITE (*,*) 'KickVandPFunction(1)',KickVandPFunction(1) l = 2 * KickVARIABLES%NoGasPocket CALL KickFunctionsCalculator(KickVARIABLES%KickVandPFunction(l) , KickVARIABLES%NoGasPocket , 2) ! VandP(last) = P(last) !WRITE (*,*) 'KickVandPFunction(l)', l, KickVandPFunction(l) DO l = 2 , KickVARIABLES%NoGasPocket ! VandP(Odd) = V(l, l > 1) - KickVARIABLES%KickVandPFunction(2 * l - 1) = KickVARIABLES%KickUnknownVector(2 * l - 1) - GasPocketCompressibility%Array(l) * GasType(KickVARIABLES%KickGasType)%GasConstant * & + KickVARIABLES%KickVandPFunction(2 * l - 1) = KickVARIABLES%KickUnknownVector(2 * l - 1) - GasPocketCompressibility%Array(l) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & GasPocketNewTemp%Array(l) * GasPocketWeight%Array(l) / KickVARIABLES%KickUnknownVector(2 * l) !WRITE(*,*) 'KickVandPFunction(V)', l, KickVandPFunction(2 * l - 1) END DO @@ -118,7 +119,7 @@ SUBROUTINE GasKickCalculator KickVARIABLES%KickJacobian(k , k) = 1.d0 END DO - KickVARIABLES%KickJacobian(1,2) = (GasPocketCompressibility%Array(1) * GasType(KickVARIABLES%KickGasType)%GasConstant * GasPocketNewTemp%Array(1) & + KickVARIABLES%KickJacobian(1,2) = (GasPocketCompressibility%Array(1) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * GasPocketNewTemp%Array(1) & * (GasPocketWeight%Array(1) + KickVARIABLES%KickmdotACoef * KickVARIABLES%KickmdotBCoef * dt) / KickVARIABLES%KickUnknownVector(2)**2) ! Row 1 Finished IF (KickVARIABLES%KickJacobian(1,2) == 0.d0) THEN CALL Error('KickJacobian(1,2) = 0.0') @@ -141,7 +142,7 @@ SUBROUTINE GasKickCalculator DO k = 2 , KickVARIABLES%NoGasPocket - KickVARIABLES%KickJacobian(2 * k - 1 , 2 * k) = GasPocketCompressibility%Array(k) * GasType(KickVARIABLES%KickGasType)%GasConstant * GasPocketNewTemp%Array(k) & + KickVARIABLES%KickJacobian(2 * k - 1 , 2 * k) = GasPocketCompressibility%Array(k) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * GasPocketNewTemp%Array(k) & * GasPocketWeight%Array(k) / KickVARIABLES%KickUnknownVector(2 * k)**2 END DO ! Odd Rows (V equations) Finished @@ -206,7 +207,7 @@ SUBROUTINE GasKickCalculator SUBROUTINE KickFunctionsCalculator(ExitValue , GasPocketNo , CalcMode) - + use ConfigurationVariables use KickVARIABLESModule USE FricPressDropVarsModule USE Fluid_Flow_Startup_Vars @@ -224,8 +225,8 @@ SUBROUTINE GasKickCalculator x = KickVARIABLES%GasPocketFlowEl(GasPocketNo , 1) IF (GasPocketNo < KickVARIABLES%NoGasPocket) y = KickVARIABLES%GasPocketFlowEl(GasPocketNo + 1 , 1) - i = FricPressDropVars%StringLastEl - j = FricPressDropVars%OpenholeFirstEl - 1 + i = data%State%FricPressDrop%StringLastEl + j = data%State%FricPressDrop%OpenholeFirstEl - 1 ! Case 1: gas pocket is completely in OP and STARTX of upper gas pocket is also ! Case 2: gas pocket is completely in OP and STARTX of upper gas pocket is above Bit @@ -242,28 +243,28 @@ SUBROUTINE GasKickCalculator IF (CalcMode == 1) THEN ! calculating pressure difference between two pocket, include static pressure difference and frictional ! pressure difference, use in calculating 'KickVandPFunction' ExitValue = KickVARIABLES%KickUnknownVector(2 * GasPocketNo) - KickVARIABLES%KickUnknownVector(2 * GasPocketNo + 2) - IF (x >= FricPressDropVars%OpenholeFirstEl .AND. y < FricPressDropVars%OpenholeFirstEl) THEN ! Case 2 , Case 3 - ExitValue = ExitValue - SUM(FlowEl(x : FricPressDropVars%NumbEl)%StaticPressDiff) - SUM(FlowEl(x : FricPressDropVars%NumbEl)%FricPressLoss) & - - SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : y)%StaticPressDiff) - SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : y)%FricPressLoss) + IF (x >= data%State%FricPressDrop%OpenholeFirstEl .AND. y < data%State%FricPressDrop%OpenholeFirstEl) THEN ! Case 2 , Case 3 + ExitValue = ExitValue - SUM(FlowEl(x : data%State%FricPressDrop%NumbEl)%StaticPressDiff) - SUM(FlowEl(x : data%State%FricPressDrop%NumbEl)%FricPressLoss) & + - SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : y)%StaticPressDiff) - SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : y)%FricPressLoss) ELSE ! Case 1 , Case 4 ExitValue = ExitValue - SUM(FlowEl(x : y)%StaticPressDiff) - SUM(FlowEl(x : y)%FricPressLoss) END IF ELSE IF (CalcMode == 2) THEN - ExitValue = KickVARIABLES%KickUnknownVector(2 * GasPocketNo) - StandardPress - FricPressDropVars%Kchoke * FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%Flowrate**2 - IF (x >= FricPressDropVars%OpenholeFirstEl) THEN ! Gas Pocket is in Openhole - ExitValue = ExitValue - SUM(FlowEl(x : FricPressDropVars%NumbEl)%StaticPressDiff) - SUM(FlowEl(x : FricPressDropVars%NumbEl)%FricPressLoss) & - - SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%StaticPressDiff) - SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FricPressLoss) + ExitValue = KickVARIABLES%KickUnknownVector(2 * GasPocketNo) - StandardPress - data%State%FricPressDrop%Kchoke * FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%Flowrate**2 + IF (x >= data%State%FricPressDrop%OpenholeFirstEl) THEN ! Gas Pocket is in Openhole + ExitValue = ExitValue - SUM(FlowEl(x : data%State%FricPressDrop%NumbEl)%StaticPressDiff) - SUM(FlowEl(x : data%State%FricPressDrop%NumbEl)%FricPressLoss) & + - SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%StaticPressDiff) - SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FricPressLoss) ELSE ! Gas Pocket is in Annulus - ExitValue = ExitValue - SUM(FlowEl(x : FricPressDropVars%OpenholeFirstEl - 1)%StaticPressDiff) - SUM(FlowEl(x : FricPressDropVars%OpenholeFirstEl - 1)%FricPressLoss) + ExitValue = ExitValue - SUM(FlowEl(x : data%State%FricPressDrop%OpenholeFirstEl - 1)%StaticPressDiff) - SUM(FlowEl(x : data%State%FricPressDrop%OpenholeFirstEl - 1)%FricPressLoss) END IF ELSE IF (CalcMode == 3) THEN ! calculating derivative of pressure difference between two pocket, relative to change in flowrate ! use in calculating 'KickJacobian' - IF (x >= FricPressDropVars%OpenholeFirstEl .AND. y < FricPressDropVars%OpenholeFirstEl) THEN ! Top kick STARTX is in Annulus - DO z = x , FricPressDropVars%NumbEl ! open hole elements + IF (x >= data%State%FricPressDrop%OpenholeFirstEl .AND. y < data%State%FricPressDrop%OpenholeFirstEl) THEN ! Top kick STARTX is in Annulus + DO z = x , data%State%FricPressDrop%NumbEl ! open hole elements CALL PartialDerivativeFricToFlowRate(z) IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe @@ -271,7 +272,7 @@ SUBROUTINE GasKickCalculator CALL ErrorStop('NaN in calculating partial derivative') END IF END DO - DO z = FricPressDropVars%AnnulusFirstEl , y ! Annulus elements + DO z = data%State%FricPressDrop%AnnulusFirstEl , y ! Annulus elements CALL PartialDerivativeFricToFlowRate(z) IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe @@ -279,7 +280,7 @@ SUBROUTINE GasKickCalculator CALL ErrorStop('NaN in calculating partial derivative') END IF END DO - ExitValue = ExitValue - (SUM(FlowEl(x : FricPressDropVars%NumbEl)%FricToQPartialDiff) + SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : y)%FricToQPartialDiff)) * 448.8 / dt + ExitValue = ExitValue - (SUM(FlowEl(x : data%State%FricPressDrop%NumbEl)%FricToQPartialDiff) + SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : y)%FricToQPartialDiff)) * 448.8 / dt ELSE ! both pockets are one side of bit DO z = x , y CALL PartialDerivativeFricToFlowRate(z) @@ -294,9 +295,9 @@ SUBROUTINE GasKickCalculator ELSE IF (CalcMode == 4) THEN ! partial derivative of frictional pressure drop relative to flowrate for top gas pocket - ExitValue = - 2.d0 * FricPressDropVars%Kchoke * FlowEl(FricPressDropVars%OpenholeFirstEl - 1)%Flowrate * 448.8 / dt - IF (x >= FricPressDropVars%OpenholeFirstEl) THEN ! kick STARTX is in openhole - DO z = x , FricPressDropVars%NumbEl ! open hole elements + ExitValue = - 2.d0 * data%State%FricPressDrop%Kchoke * FlowEl(data%State%FricPressDrop%OpenholeFirstEl - 1)%Flowrate * 448.8 / dt + IF (x >= data%State%FricPressDrop%OpenholeFirstEl) THEN ! kick STARTX is in openhole + DO z = x , data%State%FricPressDrop%NumbEl ! open hole elements CALL PartialDerivativeFricToFlowRate(z) IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe @@ -304,7 +305,7 @@ SUBROUTINE GasKickCalculator CALL ErrorStop('NaN in calculating partial derivative') END IF END DO - DO z = FricPressDropVars%AnnulusFirstEl , FricPressDropVars%OpenholeFirstEl - 1 ! Annulus elements + DO z = data%State%FricPressDrop%AnnulusFirstEl , data%State%FricPressDrop%OpenholeFirstEl - 1 ! Annulus elements CALL PartialDerivativeFricToFlowRate(z) IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe @@ -312,9 +313,9 @@ SUBROUTINE GasKickCalculator CALL ErrorStop('NaN in calculating partial derivative') END IF END DO - ExitValue = ExitValue - (SUM(FlowEl(x : FricPressDropVars%NumbEl)%FricToQPartialDiff) + SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%OpenholeFirstEl - 1)%FricToQPartialDiff)) * 448.8 / dt + ExitValue = ExitValue - (SUM(FlowEl(x : data%State%FricPressDrop%NumbEl)%FricToQPartialDiff) + SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%OpenholeFirstEl - 1)%FricToQPartialDiff)) * 448.8 / dt ELSE - DO z = x , FricPressDropVars%OpenholeFirstEl - 1 ! Annulus elements + DO z = x , data%State%FricPressDrop%OpenholeFirstEl - 1 ! Annulus elements CALL PartialDerivativeFricToFlowRate(z) IF (IEEE_IS_NaN(FlowEl(z)%FricToQPartialDiff)) THEN WRITE (*,*) ' FricToQPartialDiff , GenRe ' , x , FlowEl(z)%FricToQPartialDiff , FlowEl(z)%GenRe @@ -322,14 +323,14 @@ SUBROUTINE GasKickCalculator CALL ErrorStop('NaN in calculating partial derivative') END IF END DO - ExitValue = ExitValue - SUM(FlowEl(x : FricPressDropVars%OpenholeFirstEl - 1)%FricToQPartialDiff) * 448.8 / dt + ExitValue = ExitValue - SUM(FlowEl(x : data%State%FricPressDrop%OpenholeFirstEl - 1)%FricToQPartialDiff) * 448.8 / dt END IF ELSE IF (CalcMode == 5) THEN - IF (x >= FricPressDropVars%OpenholeFirstEl .AND. y < FricPressDropVars%OpenholeFirstEl) THEN ! Gas Pocket is in Openhole and upper pocket is in annulus + IF (x >= data%State%FricPressDrop%OpenholeFirstEl .AND. y < data%State%FricPressDrop%OpenholeFirstEl) THEN ! Gas Pocket is in Openhole and upper pocket is in annulus !WRITE (*,*) 'x , y 1' , x, y - ExitValue = GasPocketNewPress%Array(GasPocketNo + 1) + SUM(FlowEl(x : FricPressDropVars%NumbEl)%StaticPressDiff) + SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : y)%StaticPressDiff) + ExitValue = GasPocketNewPress%Array(GasPocketNo + 1) + SUM(FlowEl(x : data%State%FricPressDrop%NumbEl)%StaticPressDiff) + SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : y)%StaticPressDiff) ELSE ! Both gas pockets are in Annulus or openhole !WRITE (*,*) 'x , y 2' , x, y ExitValue = GasPocketNewPress%Array(GasPocketNo + 1) + SUM(FlowEl(x : y)%StaticPressDiff) @@ -343,15 +344,16 @@ SUBROUTINE GasKickCalculator SUBROUTINE NewGasKick - + use ConfigurationVariables use KickVARIABLESModule - Use TD_WellGeometry + use ConfigurationVariables !@ Use CReservoirVariables Use CFormationVariables USE Fluid_Flow_Startup_Vars use PressureDisplayVARIABLESModule USE FricPressDropVarsModule USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE CMudPropertiesVariables USE CError USE , INTRINSIC :: IEEE_ARITHMETIC @@ -370,9 +372,9 @@ SUBROUTINE NewGasKick WRITE (*,*) ' New Influx 1' KickVARIABLES%NoGasPocket = 1 - MudSystem%NewInfluxNumber = MudSystem%NewInfluxNumber + 1 + data%State%MudSystem%NewInfluxNumber = data%State%MudSystem%NewInfluxNumber + 1 - MudSystem%NewInfluxElementCreated = 0 + data%State%MudSystem%NewInfluxElementCreated = 0 KickVARIABLES%KickOffBottom = .FALSE. @@ -398,11 +400,11 @@ SUBROUTINE NewGasKick KickVARIABLES%GasKickSIDensity = KickVARIABLES%KickFluxAvgPressure / (KickVARIABLES%KickFluxAvgCompressibility * & - KickVARIABLES%KickFluxAvgTemperature * GasType(KickVARIABLES%KickGasType)%GasConstant) * Convpcftogpcm3 + KickVARIABLES%KickFluxAvgTemperature * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant) * Convpcftogpcm3 KickVARIABLES%GasKickDensity = KickVARIABLES%GasKickSIDensity * 8.3523 GasPocketWeight%Array(1) = KickVARIABLES%GasKickDensity * KickVARIABLES%MinKickVol !1.0:seyyed gofte !KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - GasPocketNewVol%Array(1) = GasPocketCompressibility%Array(1) * GasType(KickVARIABLES%KickGasType)%GasConstant * & + GasPocketNewVol%Array(1) = GasPocketCompressibility%Array(1) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & GasPocketNewTemp%Array(1) * GasPocketWeight%Array(1) / GasPocketNewPress%Array(1) GasPocketDeltaVol%Array(1) = 0.05 !GasPocketNewVol%Array(1) @@ -416,16 +418,16 @@ SUBROUTINE NewGasKick END DO !ELSE IF (NoGasPocket < MaxGasPocket .AND. KickVARIABLES%KickOffBottom .AND. (GasPocketNewVol%Array(1) > KickVARIABLES%MinAllowableKickVol .OR. KickWasExitingThroughChoke)) THEN - ELSE IF (KickVARIABLES%NoGasPocket < KickVARIABLES%MaxGasPocket .AND. KickVARIABLES%KickOffBottom .AND. (GasPocketNewVol%Array(1) > KickVARIABLES%MinAllowableKickVol .OR. ANY(KickVARIABLES%GasPocketFlowEl(1 , :) == FricPressDropVars%OpenholeFirstEl - 1))) THEN + ELSE IF (KickVARIABLES%NoGasPocket < KickVARIABLES%MaxGasPocket .AND. KickVARIABLES%KickOffBottom .AND. (GasPocketNewVol%Array(1) > KickVARIABLES%MinAllowableKickVol .OR. ANY(KickVARIABLES%GasPocketFlowEl(1 , :) == data%State%FricPressDrop%OpenholeFirstEl - 1))) THEN WRITE (*,*) ' New Influx', KickVARIABLES%NoGasPocket + 1 102 FORMAT (I2, 4X, (F8.1), 3X, (F8.3), 2X, (F8.3), 8X, (F8.3)) KickVARIABLES%NoGasPocket = KickVARIABLES%NoGasPocket + 1 - MudSystem%NewInfluxNumber = MudSystem%NewInfluxNumber + 1 + data%State%MudSystem%NewInfluxNumber = data%State%MudSystem%NewInfluxNumber + 1 - MudSystem%NewInfluxElementCreated = 0 + data%State%MudSystem%NewInfluxElementCreated = 0 KickVARIABLES%KickOffBottom = .FALSE. CALL GasPocketOldPress%AddToFirst((KickVARIABLES%BottomHolePress + StandardPress) * 1.d0) @@ -454,13 +456,13 @@ SUBROUTINE NewGasKick KickVARIABLES%GasKickSIDensity = KickVARIABLES%KickFluxAvgPressure / (KickVARIABLES%KickFluxAvgCompressibility * & - KickVARIABLES%KickFluxAvgTemperature * GasType(KickVARIABLES%KickGasType)%GasConstant) * Convpcftogpcm3 + KickVARIABLES%KickFluxAvgTemperature * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant) * Convpcftogpcm3 KickVARIABLES%GasKickDensity = KickVARIABLES%GasKickSIDensity * 8.3523 !GasPocketWeight%Array(1) = KickVARIABLES%GasKickDensity * 0.05 !KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt GasPocketWeight%Array(1) = KickVARIABLES%GasKickDensity * KickVARIABLES%MinKickVol !1.0:seyyed gofte !KickmdotACoef * (KickmdotBCoef - GasPocketNewPress%Array(1)) * dt - GasPocketNewVol%Array(1) = GasPocketCompressibility%Array(1) * GasType(KickVARIABLES%KickGasType)%GasConstant * & + GasPocketNewVol%Array(1) = GasPocketCompressibility%Array(1) * data%State%GasType(KickVARIABLES%KickGasType)%GasConstant * & GasPocketNewTemp%Array(1) * GasPocketWeight%Array(1) / GasPocketNewPress%Array(1) GasPocketDeltaVol%Array(1) = 0.05 !GasPocketNewVol%Array(1) diff --git a/FluidFlow/kick/Kick_VARIABLES.f90 b/FluidFlow/kick/Kick_VARIABLES.f90 index a96b058..cd7016d 100644 --- a/FluidFlow/kick/Kick_VARIABLES.f90 +++ b/FluidFlow/kick/Kick_VARIABLES.f90 @@ -1,8 +1,8 @@ MODULE KickVARIABLESModule - USE DynamicDoubleArray - USE DynamicIntegerArray - USE DynamicRealArray + use DynamicDoubleArray, only:DynamicDoubleArrayType + USE DynamicIntegerArray,only: DynamicIntegerArrayType + USE DynamicRealArray,only:DynamicRealArrayType IMPLICIT NONE @@ -13,7 +13,7 @@ MODULE KickVARIABLESModule REAL :: ChokeDensity , OldChokeDensity ! density of fluid that exits through choke [ppg] REAL :: ChokeMinDensity ! [ppg] REAL :: MaxChokeDensityChange ! [ppg/min] - + INTEGER :: TotalGasKicks ! Number of gas kicks enetered well REAL :: GasKickMolarMass ! molar mass of gas kick [lbm/lbmole] REAL :: GasKickBg ! Gas formation volume factor [bbl/SCF] diff --git a/Rop/Bit_Specification.f90 b/Rop/Bit_Specification.f90 index 7e8efd5..bd80edf 100644 --- a/Rop/Bit_Specification.f90 +++ b/Rop/Bit_Specification.f90 @@ -10,18 +10,18 @@ subroutine Bit_Specification integer :: i , BitClass_name real(8) :: rd - !ROP_Spec%H1=1.9 - !ROP_Spec%H2=7. - !ROP_Spec%H3=1. - !ROP_Spec%wdmax=7. + !data%State%ROP_Spec%H1=1.9 + !data%State%ROP_Spec%H2=7. + !data%State%ROP_Spec%H3=1. + !data%State%ROP_Spec%wdmax=7. - ROP_Spec%BitClass = (Configuration%StringConfiguration%BitDefinition%BitCodeHundreds*100)+(Configuration%StringConfiguration%BitDefinition%BitCodeTens*10)+Configuration%StringConfiguration%BitDefinition%BitCodeOnes - rd = SNGL(ROP_Spec%BitClass)/10.d0 - ROP_Spec%BrCoef = ( (SNGL(ROP_Spec%BitClass)/10.d0)-(DINT(rd)) )*10.d0 + data%State%ROP_Spec%BitClass = (data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds*100)+(data%Configuration%StringConfiguration%BitDefinition%BitCodeTens*10)+data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes + rd = SNGL(data%State%ROP_Spec%BitClass)/10.d0 + data%State%ROP_Spec%BrCoef = ( (SNGL(data%State%ROP_Spec%BitClass)/10.d0)-(DINT(rd)) )*10.d0 - BitClass_name = (ROP_Spec%BitClass)/10 + BitClass_name = (data%State%ROP_Spec%BitClass)/10 @@ -31,28 +31,28 @@ subroutine Bit_Specification open(unit=233,file="Bit_Database.TXT") READ (233,*) DO i=1,13!(14-1(/=10)) - READ (233,*) ROP_Spec%name, ROP_Spec%H1, ROP_Spec%H2, ROP_Spec%H3, ROP_Spec%wdmax - if ( ROP_Spec%name==BitClass_name ) then + READ (233,*) data%State%ROP_Spec%name, data%State%ROP_Spec%H1, data%State%ROP_Spec%H2, data%State%ROP_Spec%H3, data%State%ROP_Spec%wdmax + if ( data%State%ROP_Spec%name==BitClass_name ) then exit end if END DO close (233) else - ROP_Spec%H1=1.50d0 - ROP_Spec%H2=1.0d0 - ROP_Spec%H3=.020d0 - ROP_Spec%wdmax=10.0d0 + data%State%ROP_Spec%H1=1.50d0 + data%State%ROP_Spec%H2=1.0d0 + data%State%ROP_Spec%H3=.020d0 + data%State%ROP_Spec%wdmax=10.0d0 end if - !print*, 'ROP_Spec%H1=' , ROP_Spec%H1 - !print*, 'ROP_Spec%H2=' , ROP_Spec%H2 - !print*, 'ROP_Spec%H3=' , ROP_Spec%H3 - !print*, 'ROP_Spec%wdmax=' , ROP_Spec%wdmax - !print*, 'ROP_Spec%name=' , ROP_Spec%name + !print*, 'data%State%ROP_Spec%H1=' , data%State%ROP_Spec%H1 + !print*, 'data%State%ROP_Spec%H2=' , data%State%ROP_Spec%H2 + !print*, 'data%State%ROP_Spec%H3=' , data%State%ROP_Spec%H3 + !print*, 'data%State%ROP_Spec%wdmax=' , data%State%ROP_Spec%wdmax + !print*, 'data%State%ROP_Spec%name=' , data%State%ROP_Spec%name @@ -61,16 +61,16 @@ subroutine Bit_Specification ! filename = 'Bit_Database.TXT' !open (UNIT=3, FILE=filename ) - !!print*, 'ROP_Spec%wdmax1=' , ROP_Spec%wdmax - ! !print*, 'ROP_Spec%name1=' , ROP_Spec%name - !!openif: if ( ROP_Spec%status == 0 ) then - ! read (3,*,IOSTAT=ROP_Spec%status) ! Get next value + !!print*, 'data%State%ROP_Spec%wdmax1=' , data%State%ROP_Spec%wdmax + ! !print*, 'data%State%ROP_Spec%name1=' , data%State%ROP_Spec%name + !!openif: if ( data%State%ROP_Spec%status == 0 ) then + ! read (3,*,IOSTAT=data%State%ROP_Spec%status) ! Get next value ! readloop: do i=1,14 - ! read (3,*,IOSTAT=ROP_Spec%status) ROP_Spec%name, ROP_Spec%H1, ROP_Spec%H2, ROP_Spec%H3, ROP_Spec%wdmax ! Get next value - ! !print*, 'ROP_Spec%wdmax=' , ROP_Spec%wdmax - ! !print*, 'ROP_Spec%name=' , ROP_Spec%name - ! if ( ROP_Spec%status /= 0 ) exit ! EXIT if not valid. - ! if ( ROP_Spec%name == ROP_Spec%BitClass/10) exit + ! read (3,*,IOSTAT=data%State%ROP_Spec%status) data%State%ROP_Spec%name, data%State%ROP_Spec%H1, data%State%ROP_Spec%H2, data%State%ROP_Spec%H3, data%State%ROP_Spec%wdmax ! Get next value + ! !print*, 'data%State%ROP_Spec%wdmax=' , data%State%ROP_Spec%wdmax + ! !print*, 'data%State%ROP_Spec%name=' , data%State%ROP_Spec%name + ! if ( data%State%ROP_Spec%status /= 0 ) exit ! EXIT if not valid. + ! if ( data%State%ROP_Spec%name == data%State%ROP_Spec%BitClass/10) exit ! end do readloop !!endif openif diff --git a/Rop/JetImpactForce.f90 b/Rop/JetImpactForce.f90 index c0fa01f..9a8aa48 100644 --- a/Rop/JetImpactForce.f90 +++ b/Rop/JetImpactForce.f90 @@ -6,7 +6,8 @@ subroutine JetImpactForce use CformationVariables ! use CSimulationVariables use CmudPropertiesVariables - use MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none @@ -15,15 +16,15 @@ subroutine JetImpactForce - ROP_Bit%BitFlowrate = MudSystem%StringFlowRateFinal ![gpm] - !print*, 'ROP_Bit%BitFlowrate=' , ROP_Bit%BitFlowrate - !check :: ROP_Bit%MudDensity [ppg] ?????????? + data%State%ROP_Bit%BitFlowrate = data%State%MudSystem%StringFlowRateFinal ![gpm] + !print*, 'data%State%ROP_Bit%BitFlowrate=' , data%State%ROP_Bit%BitFlowrate + !check :: data%State%ROP_Bit%MudDensity [ppg] ?????????? - NozzleTotalArea = ROP_Spec%NumberOfBitNozzles*(ROP_Spec%DiameterOfBitNozzle**2)*(PI/4.d0) + NozzleTotalArea = data%State%ROP_Spec%NumberOfBitNozzles*(data%State%ROP_Spec%DiameterOfBitNozzle**2)*(PI/4.d0) - DeltaPb = (8.311d-5*ROP_Bit%MudDensity*(ROP_Bit%BitFlowrate**2))/((Cd**2)*(NozzleTotalArea**2)) + DeltaPb = (8.311d-5*data%State%ROP_Bit%MudDensity*(data%State%ROP_Bit%BitFlowrate**2))/((Cd**2)*(NozzleTotalArea**2)) - ROP_Bit%JetImpactForce = 0.01823d0*Cd*ROP_Bit%BitFlowrate*sqrt(ROP_Bit%MudDensity*DeltaPb) + data%State%ROP_Bit%JetImpactForce = 0.01823d0*Cd*data%State%ROP_Bit%BitFlowrate*sqrt(data%State%ROP_Bit%MudDensity*DeltaPb) diff --git a/Rop/ROP_MainCalculation.f90 b/Rop/ROP_MainCalculation.f90 index 3655efe..e9af37b 100644 --- a/Rop/ROP_MainCalculation.f90 +++ b/Rop/ROP_MainCalculation.f90 @@ -5,38 +5,43 @@ subroutine ROP_MainCalculation use CStringConfigurationVariables use CformationVariables ! use CSimulationVariables - use CDataDisplayConsoleVariables + use CDataDisplayConsole + use ConfigurationVariables use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables use CmudPropertiesVariables use CHoistingVariables + use ConfigurationVariables ! use CDrillingConsole - use CPathGenerationVariables - use RTable_VARIABLES, only: RTable + use ConfigurationVariables !@ + use ConfigurationVariables !@, only: RTable use TD_DrillStemComponents - use TD_WellGeometry + use ConfigurationVariables !@ use PressureDisplayVARIABLESModule - use MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ USE FricPressDropVarsModule use CReservoirVariables - use CWarningsVariables - use TopDrive_VARIABLES, only: TDS - use TD_GeneralData + use CWarnings + ! use ConfigurationVariables, only: TDS + use ConfigurationVariables !@ implicit none Integer :: i , zero_ROPcount - !Real(8) :: ROP_Bit%SetROPGauge + !Real(8) :: data%State%ROP_Bit%SetROPGauge zero_ROPcount = 0 - ROP_Bit%NoOfFormations = Configuration%Formation%Count - ROP_Bit%DrillingVerticalDepth = TD_WellGeneral%WellTotalVerticalLength + data%State%ROP_Bit%NoOfFormations = data%Configuration%Formation%Count + data%State%ROP_Bit%DrillingVerticalDepth = data%State%TD_WellGeneral%WellTotalVerticalLength !===> MaximumWellDepthExceeded Warning - if ( ROP_Bit%DrillingVerticalDepth>=(Configuration%Formation%Formations(Configuration%Formation%Count)%Top+Configuration%Formation%Formations(Configuration%Formation%Count)%Thickness) ) then - ROP_Bit%RateOfPenetration = 0.0d0 - Call Set_ROP(ROP_Bit%RateOfPenetration) + if ( data%State%ROP_Bit%DrillingVerticalDepth>=(data%Configuration%Formation%Formations(data%Configuration%Formation%Count)%Top+data%Configuration%Formation%Formations(data%Configuration%Formation%Count)%Thickness) ) then + data%State%ROP_Bit%RateOfPenetration = 0.0d0 + Call Set_ROP(data%State%ROP_Bit%RateOfPenetration) Call Activate_MaximumWellDepthExceeded() return end if @@ -44,13 +49,13 @@ subroutine ROP_MainCalculation - if ( ROP_Spec%FormationNumber/=0 .and. DrillingConsole%HideDrillingBrake==1 ) then ! Hide Drilling Brake Mode - ROP_Spec%FormationNumber = ROP_Spec%FormationNumber + if ( data%State%ROP_Spec%FormationNumber/=0 .and. data%EquipmentControl%DrillingConsole%HideDrillingBrake==1 ) then ! Hide Drilling Brake Mode + data%State%ROP_Spec%FormationNumber = data%State%ROP_Spec%FormationNumber else - do i= 1,ROP_Bit%NoOfFormations - ROP_Spec%FormationTopDepth = Configuration%Formation%Formations(i)%Top - if (ROP_Bit%DrillingVerticalDepth>=ROP_Spec%FormationTopDepth) then - ROP_Spec%FormationNumber = i + do i= 1,data%State%ROP_Bit%NoOfFormations + data%State%ROP_Spec%FormationTopDepth = data%Configuration%Formation%Formations(i)%Top + if (data%State%ROP_Bit%DrillingVerticalDepth>=data%State%ROP_Spec%FormationTopDepth) then + data%State%ROP_Spec%FormationNumber = i end if end do end if @@ -59,56 +64,56 @@ subroutine ROP_MainCalculation !!===> Hide Drilling Brake Mode - !if ( ROP_Spec%FormationNumber==FormationNo .and. HideDrillingBrake==1 ) then !???????????? - ! ROP_Spec%FormationNumber = FormationNo-1 + !if ( data%State%ROP_Spec%FormationNumber==FormationNo .and. HideDrillingBrake==1 ) then !???????????? + ! data%State%ROP_Spec%FormationNumber = FormationNo-1 !end if !!============================= - !ROP_Spec%BitClass = BitDefinition%BitCode !???????????? + !data%State%ROP_Spec%BitClass = BitDefinition%BitCode !???????????? call Bit_Specification ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$$** Variables Initialization: *$$$$$**$$$$$**$$$$$**$$$$$**$$$$$ - ROP_Spec%DiameterOfBit = Configuration%StringConfiguration%BitDefinition%BitSize ! unit : [in.] (Typical Range: 3.0 to 30.0) - ROP_Spec%NumberOfBitNozzles = Configuration%StringConfiguration%BitDefinition%BitNozzleNo ! (Typical Values: 1 to 10) - ROP_Spec%DiameterOfBitNozzle = Configuration%StringConfiguration%BitDefinition%BitNozzleSize ! unit : [inch] *** basic input: [1/32 in.] (Typical Range: 8.0 to 32.0) - ROP_Spec%CriticalMudDensity = Configuration%Formation%Formations(ROP_Spec%FormationNumber)%PorePressureGradient/.465d0*9.d0 ! ????????? delete ,unit : [ppg] or [lb/gal] (Typical Range: 0 to 10.0) - ROP_Bit%FormationMudDensity = Configuration%Formation%Formations(ROP_Spec%FormationNumber)%PorePressureGradient/0.052d0 - ROP_Bit%BottomHolePressure = PressureDisplayVARIABLES%PressureGauges(3) !5200 [psi] - ROP_Bit%ECD = ROP_Bit%BottomHolePressure/(0.052*ROP_Bit%DrillingVerticalDepth) - ROP_Spec%CriticalWeightOnBit = (Configuration%Formation%Formations(ROP_Spec%FormationNumber)%ThresholdWeight/5.d0)-(.06d0*(Configuration%Formation%Formations(ROP_Spec%FormationNumber)%ThresholdWeight-10.d0)) ! unit : [klb/in] (Typical Range: 0 to 10 ----> 0.6 to 2) + data%State%ROP_Spec%DiameterOfBit = data%Configuration%StringConfiguration%BitDefinition%BitSize ! unit : [in.] (Typical Range: 3.0 to 30.0) + data%State%ROP_Spec%NumberOfBitNozzles = data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo ! (Typical Values: 1 to 10) + data%State%ROP_Spec%DiameterOfBitNozzle = data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize ! unit : [inch] *** basic input: [1/32 in.] (Typical Range: 8.0 to 32.0) + data%State%ROP_Spec%CriticalMudDensity = data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%PorePressureGradient/.465d0*9.d0 ! ????????? delete ,unit : [ppg] or [lb/gal] (Typical Range: 0 to 10.0) + data%State%ROP_Bit%FormationMudDensity = data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%PorePressureGradient/0.052d0 + data%State%ROP_Bit%BottomHolePressure = data%State%PressureDisplay%PressureGauges(3) !5200 [psi] + data%State%ROP_Bit%ECD = data%State%ROP_Bit%BottomHolePressure/(0.052*data%State%ROP_Bit%DrillingVerticalDepth) + data%State%ROP_Spec%CriticalWeightOnBit = (data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%ThresholdWeight/5.d0)-(.06d0*(data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%ThresholdWeight-10.d0)) ! unit : [klb/in] (Typical Range: 0 to 10 ----> 0.6 to 2) !IF (ALLOCATED(FlowEl)) THEN - ! ROP_Bit%MudViscosity = FlowEl(NoHorizontalEl + NoStringEl)%mueff !13.5 [cP] - ROP_Bit%MudDensity = MudSystem%BitMudDensity ! [ppg] + ! data%State%ROP_Bit%MudViscosity = FlowEl(NoHorizontalEl + NoStringEl)%mueff !13.5 [cP] + data%State%ROP_Bit%MudDensity = data%State%MudSystem%BitMudDensity ! [ppg] !ELSE - ROP_Bit%MudViscosity = 13.5 ! [cP] - !ROP_Bit%MudDensity = 9.2 ! [ppg] + data%State%ROP_Bit%MudViscosity = 13.5 ! [cP] + !data%State%ROP_Bit%MudDensity = 9.2 ! [ppg] !END IF - ROP_Bit%MudFlowrate = MudSystem%StringFlowRateFinal ! [gpm] - ROP_Spec%ReynoldsNumber = ROP_Bit%MudFlowrate*ROP_Bit%MudDensity/(ROP_Bit%MudViscosity*ROP_Spec%NumberOfBitNozzles*ROP_Spec%DiameterOfBitNozzle) ! unit : [dimensionless] (Typical Range: 0.1 to 1000.0) + data%State%ROP_Bit%MudFlowrate = data%State%MudSystem%StringFlowRateFinal ! [gpm] + data%State%ROP_Spec%ReynoldsNumber = data%State%ROP_Bit%MudFlowrate*data%State%ROP_Bit%MudDensity/(data%State%ROP_Bit%MudViscosity*data%State%ROP_Spec%NumberOfBitNozzles*data%State%ROP_Spec%DiameterOfBitNozzle) ! unit : [dimensionless] (Typical Range: 0.1 to 1000.0) ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$ End of Variable Initialization $$$$$**$$$$$**$$$$$**$$$$$**$$$$$ - ! -----**-----**-----**-----**-----* ROP_bit%RateofPenetration Model Coefficients: *-----**-----**-----**-----**----- - ROP_Spec%a1 = log(Configuration%Formation%Formations(ROP_Spec%FormationNumber)%Drillablity) - ROP_Spec%a2 = 1.2799d-04 - ROP_Spec%a3 = 1.7952d-04 - ROP_Spec%a4 = 4.0656d-05 - ROP_Spec%a5 = 2.9021d-01 - ROP_Spec%a6 = 9.4882d-02 - ROP_Spec%a7 = 2.1837d-01 - ROP_Spec%a8 = 4.4915d-01 - ROP_Spec%dt = 0.1d0 ![s] - ROP_Spec%TouH = Configuration%Formation%Formations(ROP_Spec%FormationNumber)%Abrasiveness*3600.d0 ! [hr]--->[s] ( Typical Range: 1[s] ( Typical Range: 1=0.d0 ) then - ROP_Spec%f4 = exp(2.303d0*ROP_Spec%a4*ROP_Bit%DrillingVerticalDepth*(ROP_Bit%FormationMudDensity-ROP_Bit%ECD)) ! Underbalance Drilling Variable + if ( (2.303d0*data%State%ROP_Spec%a4*data%State%ROP_Bit%DrillingVerticalDepth*(data%State%ROP_Bit%FormationMudDensity-data%State%ROP_Bit%ECD))>=0.d0 ) then + data%State%ROP_Spec%f4 = exp(2.303d0*data%State%ROP_Spec%a4*data%State%ROP_Bit%DrillingVerticalDepth*(data%State%ROP_Bit%FormationMudDensity-data%State%ROP_Bit%ECD)) ! Underbalance Drilling Variable else - ROP_Spec%f4 = 1.0d0 + data%State%ROP_Spec%f4 = 1.0d0 end if - if (TD_String%WeightOnBit>0.d0) then - ROP_Bit%WeightOnBit = TD_String%WeightOnBit/1000.d0 ![klb] + if (data%State%TD_String%WeightOnBit>0.d0) then + data%State%ROP_Bit%WeightOnBit = data%State%TD_String%WeightOnBit/1000.d0 ![klb] else - ROP_Bit%WeightOnBit = 0.d0 + data%State%ROP_Bit%WeightOnBit = 0.d0 end if - if ( (ROP_Bit%WeightOnBit/ROP_Spec%DiameterOfBit)0.d0) then - ROP_Bit%RotarySpeed = RTable%Speed ![rpm] - else if (Hoisting%DriveType==0 .and. (TDS%Speed>0. .or. RTable%Speed>0.)) then - ROP_Bit%RotarySpeed = TDS%Speed+RTable%Speed ![rpm] + if (data%State%Hoisting%DriveType==1 .and. data%State%RTable%Speed>0.d0) then + data%State%ROP_Bit%RotarySpeed = data%State%RTable%Speed ![rpm] + else if (data%State%Hoisting%DriveType==0 .and. (data%State%TDS%Speed>0. .or. data%State%RTable%Speed>0.)) then + data%State%ROP_Bit%RotarySpeed = data%State%TDS%Speed+data%State%RTable%Speed ![rpm] else - ROP_Bit%RotarySpeed = 0.0d0 + data%State%ROP_Bit%RotarySpeed = 0.0d0 end if - ROP_Spec%f6 = (ROP_Bit%RotarySpeed/100.d0)**ROP_Spec%a6 + data%State%ROP_Spec%f6 = (data%State%ROP_Bit%RotarySpeed/100.d0)**data%State%ROP_Spec%a6 - ROP_Spec%f7 = exp(-ROP_Spec%a7*ROP_Bit%BitWearing) + data%State%ROP_Spec%f7 = exp(-data%State%ROP_Spec%a7*data%State%ROP_Bit%BitWearing) Call JetImpactForce - ROP_Spec%f8 = ROP_Bit%JetImpactForce/1000.d0 + data%State%ROP_Spec%f8 = data%State%ROP_Bit%JetImpactForce/1000.d0 - ROP_Bit%RateOfPenetration = (ROP_Spec%f1*ROP_Spec%f2*ROP_Spec%f3*ROP_Spec%f4*ROP_Spec%f5*ROP_Spec%f6*ROP_Spec%f7*ROP_Spec%f8) ![ft/h] - ROP_Bit%RateOfPenetration = (DINT(ROP_Bit%RateOfPenetration*10.d0))/10.d0 + data%State%ROP_Bit%RateOfPenetration = (data%State%ROP_Spec%f1*data%State%ROP_Spec%f2*data%State%ROP_Spec%f3*data%State%ROP_Spec%f4*data%State%ROP_Spec%f5*data%State%ROP_Spec%f6*data%State%ROP_Spec%f7*data%State%ROP_Spec%f8) ![ft/h] + data%State%ROP_Bit%RateOfPenetration = (DINT(data%State%ROP_Bit%RateOfPenetration*10.d0))/10.d0 - if ( (TD_WellGeneral%WellTotalLength==PathGeneration%Items(PathGeneration%ItemCount)%MeasuredDepth) ) then - ROP_Bit%SetROPGauge = ROP_Bit%RateOfPenetration - Call Set_ROP(ROP_Bit%SetROPGauge) ![ft/h] - ROP_Bit%OldROPValue(4) = ROP_Bit%RateOfPenetration - !print* , 'first rop=' , ROP_Bit%OldROPValue , ROP_Bit%RateOfPenetration ,& - ! zero_ROPcount , ROP_Bit%SetROPGauge , ROP_Bit%OldROPDepth , TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth - else if ( ((TD_WellGeneral%WellTotalLength+(ROP_Bit%RateOfPenetration*TD_General%TimeStep/3600.d0))-ROP_Bit%OldROPDepth)>=0.1 ) then + if ( (data%State%TD_WellGeneral%WellTotalLength==PathGeneration%Items(PathGeneration%ItemCount)%MeasuredDepth) ) then + data%State%ROP_Bit%SetROPGauge = data%State%ROP_Bit%RateOfPenetration + Call Set_ROP(data%State%ROP_Bit%SetROPGauge) ![ft/h] + data%State%ROP_Bit%OldROPValue(4) = data%State%ROP_Bit%RateOfPenetration + !print* , 'first rop=' , data%State%ROP_Bit%OldROPValue , data%State%ROP_Bit%RateOfPenetration ,& + ! zero_ROPcount , data%State%ROP_Bit%SetROPGauge , data%State%ROP_Bit%OldROPDepth , data%State%TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth + else if ( ((data%State%TD_WellGeneral%WellTotalLength+(data%State%ROP_Bit%RateOfPenetration*data%State%TD_General%TimeStep/3600.d0))-data%State%ROP_Bit%OldROPDepth)>=0.1 ) then do i= 1,4 - if ( ROP_Bit%OldROPValue(i)==0. ) then + if ( data%State%ROP_Bit%OldROPValue(i)==0. ) then zero_ROPcount = zero_ROPcount+1 end if end do - ROP_Bit%SetROPGauge = (ROP_Bit%RateOfPenetration+ROP_Bit%OldROPValue(1)+ROP_Bit%OldROPValue(2)+ROP_Bit%OldROPValue(3)+ROP_Bit%OldROPValue(4))/sngl(5-zero_ROPcount) - Call Set_ROP(ROP_Bit%SetROPGauge) ![ft/h] + data%State%ROP_Bit%SetROPGauge = (data%State%ROP_Bit%RateOfPenetration+data%State%ROP_Bit%OldROPValue(1)+data%State%ROP_Bit%OldROPValue(2)+data%State%ROP_Bit%OldROPValue(3)+data%State%ROP_Bit%OldROPValue(4))/sngl(5-zero_ROPcount) + Call Set_ROP(data%State%ROP_Bit%SetROPGauge) ![ft/h] do i= 2,4 - ROP_Bit%OldROPValue(i-1) = ROP_Bit%OldROPValue(i) + data%State%ROP_Bit%OldROPValue(i-1) = data%State%ROP_Bit%OldROPValue(i) end do - ROP_Bit%OldROPValue(4) = ROP_Bit%RateOfPenetration - ROP_Bit%OldROPDepth = TD_WellGeneral%WellTotalLength+(ROP_Bit%RateOfPenetration*TD_General%TimeStep/3600.d0) - !print* , 'new rop=' , ROP_Bit%OldROPValue , ROP_Bit%RateOfPenetration ,& - ! zero_ROPcount , ROP_Bit%SetROPGauge , ROP_Bit%OldROPDepth , TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth + data%State%ROP_Bit%OldROPValue(4) = data%State%ROP_Bit%RateOfPenetration + data%State%ROP_Bit%OldROPDepth = data%State%TD_WellGeneral%WellTotalLength+(data%State%ROP_Bit%RateOfPenetration*data%State%TD_General%TimeStep/3600.d0) + !print* , 'new rop=' , data%State%ROP_Bit%OldROPValue , data%State%ROP_Bit%RateOfPenetration ,& + ! zero_ROPcount , data%State%ROP_Bit%SetROPGauge , data%State%ROP_Bit%OldROPDepth , data%State%TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth else - Call Set_ROP(ROP_Bit%SetROPGauge) ![ft/h] - !print* , 'old rop=' , ROP_Bit%OldROPValue , ROP_Bit%RateOfPenetration ,& - ! zero_ROPcount , ROP_Bit%SetROPGauge , ROP_Bit%OldROPDepth , TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth + Call Set_ROP(data%State%ROP_Bit%SetROPGauge) ![ft/h] + !print* , 'old rop=' , data%State%ROP_Bit%OldROPValue , data%State%ROP_Bit%RateOfPenetration ,& + ! zero_ROPcount , data%State%ROP_Bit%SetROPGauge , data%State%ROP_Bit%OldROPDepth , data%State%TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth end if @@ -195,41 +200,41 @@ subroutine ROP_MainCalculation - if (ROP_Bit%RotarySpeed > 0.d0) THEN - ROP_Bit%BitTorque = ( 3.79d0 + 19.17d0*sqrt( ROP_Bit%RateOfPenetration / (ROP_Bit%RotarySpeed*ROP_Spec%DiameterOfBit)) ) * ROP_Spec%DiameterOfBit * ROP_Bit%WeightOnBit * ( 1.d0 / ( 1.d0 + 0.00021d0*ROP_Bit%DrillingVerticalDepth) ) - !ROP_Bit%BitTorque = ROP_Bit%BitTorque/3. !bi dalil taghsim bar 3 shode(chon adad bozorg bude), baadan az rabete check shavad (seyyed gofte) + if (data%State%ROP_Bit%RotarySpeed > 0.d0) THEN + data%State%ROP_Bit%BitTorque = ( 3.79d0 + 19.17d0*sqrt( data%State%ROP_Bit%RateOfPenetration / (data%State%ROP_Bit%RotarySpeed*data%State%ROP_Spec%DiameterOfBit)) ) * data%State%ROP_Spec%DiameterOfBit * data%State%ROP_Bit%WeightOnBit * ( 1.d0 / ( 1.d0 + 0.00021d0*data%State%ROP_Bit%DrillingVerticalDepth) ) + !data%State%ROP_Bit%BitTorque = data%State%ROP_Bit%BitTorque/3. !bi dalil taghsim bar 3 shode(chon adad bozorg bude), baadan az rabete check shavad (seyyed gofte) else - ROP_Bit%BitTorque = 0.d0 + data%State%ROP_Bit%BitTorque = 0.d0 end if - if ( (ROP_Bit%WeightOnBit/ROP_Spec%DiameterOfBit)<(ROP_Spec%wdmax) ) then - ROP_Bit%BitWearing = ROP_Bit%BitWearing +( (ROP_Spec%dt*ROP_Spec%H3/ROP_Spec%TouH)*((ROP_Bit%RotarySpeed/100.d0)**ROP_Spec%H1)*((ROP_Spec%wdmax-4.d0)/(ROP_Spec%wdmax-(ROP_Bit%WeightOnBit/ROP_Spec%DiameterOfBit)))*((1.d0+(ROP_Spec%H2/2.d0))/(1.d0+(ROP_Spec%H2*ROP_Bit%BitWearing))) ) + if ( (data%State%ROP_Bit%WeightOnBit/data%State%ROP_Spec%DiameterOfBit)<(data%State%ROP_Spec%wdmax) ) then + data%State%ROP_Bit%BitWearing = data%State%ROP_Bit%BitWearing +( (data%State%ROP_Spec%dt*data%State%ROP_Spec%H3/data%State%ROP_Spec%TouH)*((data%State%ROP_Bit%RotarySpeed/100.d0)**data%State%ROP_Spec%H1)*((data%State%ROP_Spec%wdmax-4.d0)/(data%State%ROP_Spec%wdmax-(data%State%ROP_Bit%WeightOnBit/data%State%ROP_Spec%DiameterOfBit)))*((1.d0+(data%State%ROP_Spec%H2/2.d0))/(1.d0+(data%State%ROP_Spec%H2*data%State%ROP_Bit%BitWearing))) ) else - ROP_Bit%BitWearing = 1.0d0 !( Typical Range: 0<=ROP_Bit%BitWearing<=1 ) + data%State%ROP_Bit%BitWearing = 1.0d0 !( Typical Range: 0<=data%State%ROP_Bit%BitWearing<=1 ) end if - ROP_Bit%BearingWear = ROP_Bit%BearingWear+(ROP_Spec%dt/3600.d0)*(ROP_Bit%RotarySpeed/100.d0/ROP_Spec%BrCoef)*((ROP_Bit%WeightOnBit/4.d0/ROP_Spec%DiameterOfBit)**1.5d0) + data%State%ROP_Bit%BearingWear = data%State%ROP_Bit%BearingWear+(data%State%ROP_Spec%dt/3600.d0)*(data%State%ROP_Bit%RotarySpeed/100.d0/data%State%ROP_Spec%BrCoef)*((data%State%ROP_Bit%WeightOnBit/4.d0/data%State%ROP_Spec%DiameterOfBit)**1.5d0) - !print*, 'ROP_Bit%RateOfPenetration=', ROP_Bit%RateOfPenetration - !!print*, 'ROP_Bit%FormationMudDensity=', ROP_Bit%FormationMudDensity - !!print*, 'ROP_Bit%ECD=', ROP_Bit%ECD - !!print*, 'ROP_Bit%DrillingVerticalDepth=', ROP_Bit%DrillingVerticalDepth - !!print*, 'power=', (2.303*ROP_Spec%a4*ROP_Bit%DrillingVerticalDepth*(ROP_Bit%FormationMudDensity-ROP_Bit%ECD)) - !print*, 'ROP_Bit%RotarySpeed=', ROP_Bit%RotarySpeed + !print*, 'data%State%ROP_Bit%RateOfPenetration=', data%State%ROP_Bit%RateOfPenetration + !!print*, 'data%State%ROP_Bit%FormationMudDensity=', data%State%ROP_Bit%FormationMudDensity + !!print*, 'data%State%ROP_Bit%ECD=', data%State%ROP_Bit%ECD + !!print*, 'data%State%ROP_Bit%DrillingVerticalDepth=', data%State%ROP_Bit%DrillingVerticalDepth + !!print*, 'power=', (2.303*data%State%ROP_Spec%a4*data%State%ROP_Bit%DrillingVerticalDepth*(data%State%ROP_Bit%FormationMudDensity-data%State%ROP_Bit%ECD)) + !print*, 'data%State%ROP_Bit%RotarySpeed=', data%State%ROP_Bit%RotarySpeed !! - !print*, 'ROP_Spec%f1=', ROP_Spec%f1 - !print*, 'ROP_Spec%f2=', ROP_Spec%f2 - !print*, 'ROP_Spec%f3=', ROP_Spec%f3 - !print*, 'ROP_Spec%f4=', ROP_Spec%f4 - !print*, 'ROP_Spec%f5=', ROP_Spec%f5 - !print*, 'ROP_Spec%f6=', ROP_Spec%f6 - !print*, 'ROP_Spec%f7=', ROP_Spec%f7 - !print*, 'ROP_Spec%f8=', ROP_Spec%f8 + !print*, 'data%State%ROP_Spec%f1=', data%State%ROP_Spec%f1 + !print*, 'data%State%ROP_Spec%f2=', data%State%ROP_Spec%f2 + !print*, 'data%State%ROP_Spec%f3=', data%State%ROP_Spec%f3 + !print*, 'data%State%ROP_Spec%f4=', data%State%ROP_Spec%f4 + !print*, 'data%State%ROP_Spec%f5=', data%State%ROP_Spec%f5 + !print*, 'data%State%ROP_Spec%f6=', data%State%ROP_Spec%f6 + !print*, 'data%State%ROP_Spec%f7=', data%State%ROP_Spec%f7 + !print*, 'data%State%ROP_Spec%f8=', data%State%ROP_Spec%f8 !print*, '***********************' diff --git a/Rop/sROP_Other_Variables.f90 b/Rop/sROP_Other_Variables.f90 index 1d6aa1d..dac3eb6 100644 --- a/Rop/sROP_Other_Variables.f90 +++ b/Rop/sROP_Other_Variables.f90 @@ -3,7 +3,7 @@ module sROP_Other_Variables implicit none - real(8), parameter :: PI = 3.1415926 ! PI Number + ! real(8), parameter :: PI = 3.1415926 ! PI Number @@ -25,16 +25,15 @@ module sROP_Other_Variables real(8) :: CriticalMudDensity ! unit : [ppg] or [lb/gal] (Typical Range: 0 to 10.0) real(8) :: CriticalWeightOnBit ! unit : [klb] (Typical Range: 0 to 10) real(8) :: ReynoldsNumber ! unit : [klb] (Typical Range: 0.1 to 1000.0) - ! -----**-----**-----**-----**-----** Other ROP_bit%RateofPenetration Model Variables: *-----**-----**-----**-----**----- + ! -----**-----**-----**-----**-----** Other data%State%ROP_Bit%RateofPenetration Model Variables: *-----**-----**-----**-----**----- real(8) :: f1, f2, f3, f4, f5, f6, f7, f8 real(8) :: a1, a2, a3, a4, a5, a6, a7, a8 real(8) :: BrCoef real(8) :: dt , TouH - ! -----**-----**-----**-----**--- End of Other ROP_bit%RateofPenetration Model Variables ---**-----**-----**-----**----- + ! -----**-----**-----**-----**--- End of Other data%State%ROP_Bit%RateofPenetration Model Variables ---**-----**-----**-----**----- ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$$** End of Variable Definition *$$$$$**$$$$$**$$$$$**$$$$$**$$$$$ END TYPE ROPSpecificationInfo - TYPE(ROPSpecificationInfo) :: ROP_Spec diff --git a/Rop/sROP_Variables.f90 b/Rop/sROP_Variables.f90 index e0e7b18..70ecc74 100644 --- a/Rop/sROP_Variables.f90 +++ b/Rop/sROP_Variables.f90 @@ -12,5 +12,4 @@ implicit none integer :: NoOfFormations END TYPE ROPInfo - TYPE(ROPInfo) :: ROP_Bit end module sROP_Variables \ No newline at end of file diff --git a/Simulation/ConfigurationVariables.f90 b/Simulation/ConfigurationVariables.f90 index b880368..d351bc5 100644 --- a/Simulation/ConfigurationVariables.f90 +++ b/Simulation/ConfigurationVariables.f90 @@ -1,4 +1,7 @@ module ConfigurationVariables + use Constants + + use COperationScenariosVariables use CStringConfigurationVariables use CFormationVariables use CReservoirVariables @@ -13,7 +16,59 @@ module ConfigurationVariables use CPathGenerationVariables use CWellSurveyDataVariables use CMudPropertiesVariables - + + use CBopControlPanelVariables + use CChokeControlPanelVariables + use CChokeManifoldVariables + use CDataDisplayConsoleVariables + use CDrillingConsoleVariables + use CHookVariables + use CStandPipeManifoldVariables + use CTopDrivePanelVariables + use CDrillWatchVariables + use CTanksVariables + use COperationScenariosVariables + use NotificationVariables + use PermissionsVariables + use UnitySignalVariables + + use CBitProblemsVariables + use CBopProblemsVariables + use CChokeProblemsVariables + use CDrillStemProblemsVariables + use CGaugesProblemsVariables + use CHoistingProblemsVariables + use CKickProblemsVariables + use CLostProblemsVariables + use CMudTreatmentProblemsVariables + use COtherProblemsVariables + use CPumpProblemsVariables + use CRotaryProblemsVariables + + use CStudentStationVariables + use CWarningsVariables + + use BopVariables + use Pumps_VARIABLES + use RTable_VARIABLES + use TopDrive_VARIABLES + use CHOKEVARIABLES + use Drawworks_VARIABLES + USE MudSystemVARIABLES + use Fluid_Flow_Startup_Vars + use PressureDisplayVARIABLESModule + use FricPressDropVarsModule + + use sROP_Other_Variables + use sROP_Variables + + use GeoElements_FluidModule + use TD_DrillStemComponents + use TD_GeneralData + use TD_StringConnectionData + use TD_WellElements + use TD_WellGeometry + type ConfigurationType Type(StringConfigurationType)::StringConfiguration Type(FormationType) :: Formation @@ -29,9 +84,127 @@ module ConfigurationVariables Type(PathGenerationType)::PathGeneration Type(WellSurveyDataType)::WellSurveyData Type(MudPropertiesType)::MudProperties - end type ConfigurationType - type(ConfigurationType)::Configuration + + type EquipmentControlType + ! Control Panels + type(BopControlPanelType) :: BopControlPanel + Type(ChokeControlPanelType)::ChokeControlPanel + Type(ChokeManifoldType)::ChokeManifold + Type(DataDisplayConsoleType) :: DataDisplayConsole + TYPE(DrillingConsoleType) :: DrillingConsole + Type(HookType)::Hook + type(StandPipeManifoldType)::StandPipeManifold + Type(TopDrivePanelType)::TopDrivePanel + ! Drill Watch + Type(DrillingWatchType)::DrillingWatch + Type(TankType)::Tank + end type EquipmentControlType + + type SimulationStateType + Type(HoistingType)::Hoisting + type(OperationScenarioType)::OperationScenario + type(NotificationType)::notifications + type(PermissionsType):: permissions + type(UnitySignalsType):: unitySignals + type(StudentStationType)::StudentStation + !Bop + type(BopStackInputType)::BopStackInput + type(BopStackAccType)::BopStackAcc + type(RamLineType)::RamLine + type(AnnularComputationalType)::AnnularComputational + type(AnnularType)::Annular + type(PipeRams1Type)::PipeRam1 + type(ShearRamType)::ShearRam + type(PipeRam2Type)::PipeRam2 + type(ChokeLineType)::ChokeLine + type(KillLineType)::KillLine + type(PumpsType)::Pumps + TYPE(BOP_TypeVars), DIMENSION(1:6) :: RAM + TYPE(BOP_TypeVars2D) :: RAMS + !Choke + type(ChokeType)::Choke + type(AirDrivenPumpType)::AirDrivenPump + type(AirPumpLineType)::AirPumpLine + TYPE(CHOKE_TypeVars), DIMENSION(1:2) :: CHOOKE + ! + !!Drawworks + TYPE(Drawworks_Var) :: Drawworks + !! + !!!MudSystem + type(MudSystemType)::MudSystem + TYPE(MUD_TypeVars), DIMENSION(1:10) :: MUD + + !!Pumps + Type(Pumps_Var) :: MPumps + TYPE(Pump_Var), DIMENSION(1:3) :: PUMP + ! + TYPE(RTable_Var) :: RTable + TYPE(TDS_Var) :: TDS + ! + !! FluidFlow + TYPE(GasData) :: GasType(3) ! 1 = methane , 2 = Hydrogen sulfide , 3 = Carbon dioxid + TYPE(PressureDisplayVARIABLESTYPE) :: PressureDisplay + ! TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: ObservationPoint(:) + TYPE(FricPressDropVarsTYPE) :: FricPressDrop + ! + !Rop + TYPE(ROPSpecificationInfo) :: ROP_Spec + TYPE(ROPInfo) :: ROP_Bit + + !TD + TYPE(Geo_Data) :: TDGeo + TYPE(F_StringData) , Allocatable :: F_String(:) + TYPE(F_IntervalsCountsData):: F_Counts + TYPE(F_IntervalData) , Allocatable :: F_Interval(:) + TYPE(OD_AnnulusData) :: OD_Annulus(4) + + TYPE(TD_DrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStem + TYPE(TD_SeparatedDrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStems + TYPE(TD_StringInfo) :: TD_String + TYPE(TD_AddRemoveInfo) :: TD_Count + TYPE(CStringComponents), ALLOCATABLE, DIMENSION(:) :: G_StringElement + TYPE(TD_RemovedVolumeInfo) :: TD_Vol + TYPE(TD_GeneralInfo) :: TD_General + TYPE(TD_BOPInfo) :: TD_BOP + TYPE(CBopElement) :: TD_BOPElement(4) + TYPE(TD_StringconnectionInfo) :: TD_StConn + TYPE(TD_LoadInfo) :: TD_Load + TYPE(TD_WellElementsInfo) :: TD_WellEl + TYPE(TD_CasingInfo), ALLOCATABLE, DIMENSION(:) :: TD_Casing + TYPE(TD_LinerInfo), ALLOCATABLE, DIMENSION(:) :: TD_Liner + TYPE(TD_OpenHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_OpenHole + TYPE(TD_ROPHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_ROPHole + TYPE(TD_WellGeneralInfo) :: TD_WellGeneral + TYPE(TD_WellGeometryData), Allocatable :: TD_WellGeo(:) + + + end type SimulationStateType + + type ProblemsType + type(BitProblemsType)::BitProblems + type(BopProblemsType)::BopProblems + type(ChokeProblemsType)::ChokeProblems + type(DrillStemProblemsType)::DrillStemProblems + type(GaugesProblemsType)::GaugesProblems + type(HoistingProblemsType):: HoistingProblems + type(KickProblemsType)::KickProblems + type(LostProblemsType)::LostProblems + type(MudTreatmentProblemsType)::MudTreatmentProblems + type(OtherProblemsType)::OtherProblems + type(PumpProblemsType)::PumpProblems + type(RotaryProblemsType)::RotaryProblems + end type ProblemsType + + type SimulationDataType + type(WarmingsType)::Warnings + type(SimulationStateType)::State + type(EquipmentControlType)::EquipmentControl + type(ConfigurationType)::Configuration + type(ProblemsType)::problems + end type SimulationDataType + + type(SimulationDataType)::data contains end module ConfigurationVariables diff --git a/Simulation/Constants.f90 b/Simulation/Constants.f90 new file mode 100644 index 0000000..a434d9a --- /dev/null +++ b/Simulation/Constants.f90 @@ -0,0 +1,5 @@ +module Constants + real,parameter::PI=3.14159265 + REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000,NU=9e-6 + +end module Constants \ No newline at end of file diff --git a/SimulationCore2.vfproj b/SimulationCore2.vfproj index 4f6f5e3..f9a7a7f 100644 --- a/SimulationCore2.vfproj +++ b/SimulationCore2.vfproj @@ -96,19 +96,23 @@ - + + + + + + - @@ -131,16 +135,11 @@ - + + - - - - - - - + @@ -157,7 +156,8 @@ - + + @@ -169,21 +169,19 @@ + - - - @@ -192,6 +190,7 @@ + @@ -299,8 +298,7 @@ - - + @@ -330,6 +328,7 @@ + diff --git a/Simulator.f90 b/Simulator.f90 index 273e850..f1d1af3 100644 --- a/Simulator.f90 +++ b/Simulator.f90 @@ -21,18 +21,19 @@ module Simulator use :: json_module, rk => json_rk implicit none - real :: t0, dt, tf, mu + ! real :: t0, dt, tf, mu real(kind=rk), allocatable :: x0(:) type(json_file) :: json logical :: is_found - + real T1,T2 contains subroutine Simulate integer :: t !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! t=0 call init_modules() - do while (t<10) + call cpu_time(T1) + do while (t<100) !!read variable from shared file call read_variables() @@ -104,14 +105,14 @@ contains !!Empty ! call Geo_Step() + !!Ahmadi + call PathFinding_Step() !! Sheikh !call FluidFlow_Step() !! Ahmadi call OperationScenarios_Step() - !!Ahmadi - call PathFinding_Step() !! Write variables to shared files call write_variables() @@ -119,6 +120,8 @@ contains print *,"t=",t t = t + 1 end do + call cpu_time(T2) + print *,"Total Execution Time =",t2-t1 end subroutine Simulate subroutine write_variables @@ -126,25 +129,25 @@ contains end subroutine subroutine read_variables - call json%initialize() + ! call json%initialize() - ! Load the file. - call json%load_file('config.json'); if (json%failed()) stop + ! ! Load the file. + ! call json%load_file('config.json'); if (json%failed()) stop - call json%get('t0', t0, is_found); if (.not. is_found) return - call json%get('dt', dt, is_found); if (.not. is_found) return - call json%get('tf', tf, is_found); if (.not. is_found) return - call json%get('mu', mu, is_found); if (.not. is_found) return - call json%get('x0', x0, is_found); if (.not. is_found) return + ! call json%get('t0', t0, is_found); if (.not. is_found) return + ! call json%get('dt', dt, is_found); if (.not. is_found) return + ! call json%get('tf', tf, is_found); if (.not. is_found) return + ! call json%get('mu', mu, is_found); if (.not. is_found) return + ! call json%get('x0', x0, is_found); if (.not. is_found) return - ! Output values. - if (is_found) then - print *, t0, dt, tf, mu - print *, x0 - end if + ! ! Output values. + ! if (is_found) then + ! print *, t0, dt, tf, mu + ! print *, x0 + ! end if - ! Clean up. - call json%destroy() + ! ! Clean up. + ! call json%destroy() end subroutine subroutine init_modules !Tarmigh @@ -171,7 +174,7 @@ contains ! call Annular_Step() !! Sheikh - call FluidFlow_Init() + !call FluidFlow_Init() !! Ahmadi call PathFinding_Init() diff --git a/TorqueDrag/TD_DrillingSubs/MeshGeneration_FluidModule.f90 b/TorqueDrag/TD_DrillingSubs/MeshGeneration_FluidModule.f90 index e6eed98..be73621 100644 --- a/TorqueDrag/TD_DrillingSubs/MeshGeneration_FluidModule.f90 +++ b/TorqueDrag/TD_DrillingSubs/MeshGeneration_FluidModule.f90 @@ -1,14 +1,15 @@ subroutine MeshGeneration_FluidModule Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData Use GeoElements_FluidModule - Use CPumpsVariables + use CPumpsVariables + use CPumps Use CStringConfigurationVariables Use CBopStackVariables - !Use Drawworks_VARIABLES , only: Drawworks + !use ConfigurationVariables !@ , only: Drawworks implicit none @@ -35,71 +36,71 @@ subroutine MeshGeneration_FluidModule ! Mesh Generation of DrillStem Components !==================================================== - !TD_String%StringConfigurationCount = StringConfigurationCount !??????????? - StringConfigCount = TD_String%StringConfigurationCount - if (allocated(F_String)) Deallocate(F_String) - if (TD_DrillStem(1)%ComponentType==0) then - Allocate (F_String(StringConfigCount-1)) + !data%State%TD_String%StringConfigurationCount = StringConfigurationCount !??????????? + StringConfigCount = data%State%TD_String%StringConfigurationCount + if (allocated(data%State%F_String)) Deallocate(data%State%F_String) + if (data%State%TD_DrillStem(1)%ComponentType==0) then + Allocate (data%State%F_String(StringConfigCount-1)) else - Allocate (F_String(StringConfigCount)) + Allocate (data%State%F_String(StringConfigCount)) end if - if (TD_DrillStem(1)%ComponentType==0) then + if (data%State%TD_DrillStem(1)%ComponentType==0) then ElementsCount = 1 Do ii=1,(StringConfigCount-1) - F_String(ii)%ID = TD_DrillStem(ii+1)%Id*12.d0 ![inch] - F_String(ii)%OD = TD_DrillStem(ii+1)%Od*12.d0 ![inch] - F_String(ii)%FirstElement = ElementsCount+1 - F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii+1)%Numbs-1) - F_String(ii)%ElType = TD_DrillStem(ii+1)%ComponentType - ElementsCount = F_String(ii)%LastElement + data%State%F_String(ii)%ID = data%State%TD_DrillStem(ii+1)%Id*12.d0 ![inch] + data%State%F_String(ii)%OD = data%State%TD_DrillStem(ii+1)%Od*12.d0 ![inch] + data%State%F_String(ii)%FirstElement = ElementsCount+1 + data%State%F_String(ii)%LastElement = data%State%F_String(ii)%FirstElement+(data%State%TD_DrillStem(ii+1)%Numbs-1) + data%State%F_String(ii)%ElType = data%State%TD_DrillStem(ii+1)%ComponentType + ElementsCount = data%State%F_String(ii)%LastElement End Do StringConfigCount = StringConfigCount-1 else ElementsCount = 0 Do ii=1,StringConfigCount - F_String(ii)%ID = TD_DrillStem(ii)%Id*12.d0 ![inch] - F_String(ii)%OD = TD_DrillStem(ii)%Od*12.d0 ![inch] - F_String(ii)%FirstElement = ElementsCount+1 - F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii)%Numbs-1) - F_String(ii)%ElType = TD_DrillStem(ii)%ComponentType - ElementsCount = F_String(ii)%LastElement + data%State%F_String(ii)%ID = data%State%TD_DrillStem(ii)%Id*12.d0 ![inch] + data%State%F_String(ii)%OD = data%State%TD_DrillStem(ii)%Od*12.d0 ![inch] + data%State%F_String(ii)%FirstElement = ElementsCount+1 + data%State%F_String(ii)%LastElement = data%State%F_String(ii)%FirstElement+(data%State%TD_DrillStem(ii)%Numbs-1) + data%State%F_String(ii)%ElType = data%State%TD_DrillStem(ii)%ComponentType + ElementsCount = data%State%F_String(ii)%LastElement End Do end if Do ii=1,StringConfigCount - F_String(ii)%TopDepth = TD_DrillStems(F_String(ii)%LastElement)%TopDepthIni ![ft] - F_String(ii)%DownDepth = TD_DrillStems(F_String(ii)%FirstElement)%DownDepthIni ![ft] + data%State%F_String(ii)%TopDepth = data%State%TD_DrillStems(data%State%F_String(ii)%LastElement)%TopDepthIni ![ft] + data%State%F_String(ii)%DownDepth = data%State%TD_DrillStems(data%State%F_String(ii)%FirstElement)%DownDepthIni ![ft] - if (F_String(ii)%DownDepth>A(1)) then + if (data%State%F_String(ii)%DownDepth>A(1)) then jj = jj+1 - A(jj) = F_String(ii)%DownDepth + A(jj) = data%State%F_String(ii)%DownDepth end if End Do !=========> Removed Volume Calculation in DrillStem - TD_ElementLength = F_String(StringConfigCount)%DownDepth-F_String(StringConfigCount)%TopDepth - if ( StringConfigCount==TD_Vol%PreCount ) then - if ( TD_Vol%PreElementLength>TD_ElementLength ) then - TD_Vol%RemoveVolume = (TD_Vol%PreElementLength-TD_ElementLength)*((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0) ![ft^3] + TD_ElementLength = data%State%F_String(StringConfigCount)%DownDepth-data%State%F_String(StringConfigCount)%TopDepth + if ( StringConfigCount==data%State%TD_Vol%PreCount ) then + if ( data%State%TD_Vol%PreElementLength>TD_ElementLength ) then + data%State%TD_Vol%RemoveVolume = (data%State%TD_Vol%PreElementLength-TD_ElementLength)*((pi*((data%State%F_String(StringConfigCount)%ID/12.d0)**2))/4.d0) ![ft^3] else - TD_Vol%RemoveVolume = 0.d0 + data%State%TD_Vol%RemoveVolume = 0.d0 end if - else if ( StringConfigCount Out of Well Intervals - F_Interval(1)%StartTVD = 0.0d0 !?????????????? - F_Interval(1)%EndTVD = -TD_StConn%ConnectionHeight - F_Interval(1)%StartAngle = 0.d0 !??????????????????????? - F_Interval(1)%EndAngle = 0.d0 !??????????????????????? - F_Counts%OutOfWellIntervalCounts = 1 + data%State%F_Interval(1)%StartTVD = 0.0d0 !?????????????? + data%State%F_Interval(1)%EndTVD = -data%State%TD_StConn%ConnectionHeight + data%State%F_Interval(1)%StartAngle = 0.d0 !??????????????????????? + data%State%F_Interval(1)%EndAngle = 0.d0 !??????????????????????? + data%State%F_Counts%OutOfWellIntervalCounts = 1 Do ii= 2 , StringConfigCount+1 - if ( F_Interval(ii)%StartDepth<=0.d0 ) then - F_Interval(ii)%StartTVD = F_Interval(ii)%StartDepth - F_Interval(ii)%StartAngle = 0.0d0 + if ( data%State%F_Interval(ii)%StartDepth<=0.d0 ) then + data%State%F_Interval(ii)%StartTVD = data%State%F_Interval(ii)%StartDepth + data%State%F_Interval(ii)%StartAngle = 0.0d0 end if - if ( F_Interval(ii)%EndDepth<=0.d0 ) then - F_Interval(ii)%EndTVD = F_Interval(ii)%EndDepth - F_Interval(ii)%EndAngle = 0.0d0 - F_Counts%OutOfWellIntervalCounts = F_Counts%OutOfWellIntervalCounts+1 + if ( data%State%F_Interval(ii)%EndDepth<=0.d0 ) then + data%State%F_Interval(ii)%EndTVD = data%State%F_Interval(ii)%EndDepth + data%State%F_Interval(ii)%EndAngle = 0.0d0 + data%State%F_Counts%OutOfWellIntervalCounts = data%State%F_Counts%OutOfWellIntervalCounts+1 end if End Do !=========> - if (allocated(TDGeo%TVD)) Deallocate(TDGeo%TVD) - Allocate (TDGeo%TVD(jj)) - if (allocated(TDGeo%Angle)) Deallocate(TDGeo%Angle) - Allocate (TDGeo%Angle(jj)) - TDGeo%TVD(1) = TD_WellGeneral%WellTotalVerticalLength !????? - !print*, 'TD_WellGeneral%WellTotalVerticalLength=' ,TD_WellGeneral%WellTotalVerticalLength - TDGeo%TVD(jj) = BopStackSpecification%AboveAnnularHeight ! WellHead[ft] !0.d0 ???????????????? + if (allocated(data%State%TDGeo%TVD)) Deallocate(data%State%TDGeo%TVD) + Allocate (data%State%TDGeo%TVD(jj)) + if (allocated(data%State%TDGeo%Angle)) Deallocate(data%State%TDGeo%Angle) + Allocate (data%State%TDGeo%Angle(jj)) + data%State%TDGeo%TVD(1) = data%State%TD_WellGeneral%WellTotalVerticalLength !????? + !print*, 'data%State%TD_WellGeneral%WellTotalVerticalLength=' ,data%State%TD_WellGeneral%WellTotalVerticalLength + data%State%TDGeo%TVD(jj) = BopStackSpecification%AboveAnnularHeight ! WellHead[ft] !0.d0 ???????????????? k = 1 mm = 0.d0 nn = 0.d0 - EndAngle = TD_WellGeo(1)%StartAngle !??????????????? - TDGeo%Angle(jj) = EndAngle + EndAngle = data%State%TD_WellGeo(1)%StartAngle !??????????????? + data%State%TDGeo%Angle(jj) = EndAngle Do ii = jj-1,1,-1 !???1or2 - do kk = k, TD_WellGeneral%WellIntervalsCount + do kk = k, data%State%TD_WellGeneral%WellIntervalsCount StartAngle = EndAngle - if ( TDGeo%MD(ii)>TD_WellGeo(kk)%TopDepth ) then - if ( TDGeo%MD(ii)>TD_WellGeo(kk)%DownDepth ) then - dl = TD_WellGeo(kk)%DownDepth-nn ![ft] - nn = TD_WellGeo(kk)%DownDepth - if ( TD_WellGeo(kk)%HoleType==0 ) then + if ( data%State%TDGeo%MD(ii)>data%State%TD_WellGeo(kk)%TopDepth ) then + if ( data%State%TDGeo%MD(ii)>data%State%TD_WellGeo(kk)%DownDepth ) then + dl = data%State%TD_WellGeo(kk)%DownDepth-nn ![ft] + nn = data%State%TD_WellGeo(kk)%DownDepth + if ( data%State%TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle !print*, 'StartAngle1=' ,ii , kk, StartAngle !print*, 'EndAngle1=' ,ii , kk, EndAngle - TDGeo%TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) ![ft] - TDGeo%Angle(ii) = EndAngle - !print*, 'TDGeo%TVD(ii)1=' ,ii , kk, TDGeo%TVD(ii) - else if ( TD_WellGeo(kk)%HoleType==1 ) then - EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !????????????????? + data%State%TDGeo%TVD(ii) = mm+(dl*cos(data%State%TD_WellGeo(kk)%StartAngle)) ![ft] + data%State%TDGeo%Angle(ii) = EndAngle + !print*, 'data%State%TDGeo%TVD(ii)1=' ,ii , kk, data%State%TDGeo%TVD(ii) + else if ( data%State%TD_WellGeo(kk)%HoleType==1 ) then + EndAngle = StartAngle+(dl/data%State%TD_WellGeo(kk)%RCurvature) !????????????????? !print*, 'StartAngle2=' ,ii , kk, StartAngle !print*, 'EndAngle2=' ,ii , kk, EndAngle - TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) - !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) - TDGeo%Angle(ii) = EndAngle - !print*, 'TDGeo%TVD(ii)2=' , ii , kk, TDGeo%TVD(ii) - else if ( TD_WellGeo(kk)%HoleType==2 ) then - EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !????????????????? + data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) + !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) + data%State%TDGeo%Angle(ii) = EndAngle + !print*, 'data%State%TDGeo%TVD(ii)2=' , ii , kk, data%State%TDGeo%TVD(ii) + else if ( data%State%TD_WellGeo(kk)%HoleType==2 ) then + EndAngle = StartAngle-(dl/data%State%TD_WellGeo(kk)%RCurvature) !????????????????? !print*, 'StartAngle22=' ,ii , kk, StartAngle !print*, 'EndAngle22=' ,ii , kk, EndAngle - TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) - !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) - TDGeo%Angle(ii) = EndAngle - !print*, 'TDGeo%TVD(ii)22=' , ii , kk, TDGeo%TVD(ii) + data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) + !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) + data%State%TDGeo%Angle(ii) = EndAngle + !print*, 'data%State%TDGeo%TVD(ii)22=' , ii , kk, data%State%TDGeo%TVD(ii) end if - mm = TDGeo%TVD(ii) + mm = data%State%TDGeo%TVD(ii) else - dl = TDGeo%MD(ii)-nn - nn = TDGeo%MD(ii) - if ( TD_WellGeo(kk)%HoleType==0 ) then + dl = data%State%TDGeo%MD(ii)-nn + nn = data%State%TDGeo%MD(ii) + if ( data%State%TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle !print*, 'StartAngle3=' ,ii , kk, StartAngle !print*, 'EndAngle3=' ,ii , kk, EndAngle - TDGeo%TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) - TDGeo%Angle(ii) = EndAngle - !print*, 'TDGeo%TVD(ii)3=' ,ii , kk, TDGeo%TVD(ii) - else if ( TD_WellGeo(kk)%HoleType==1 ) then - EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !??????????????????? + data%State%TDGeo%TVD(ii) = mm+(dl*cos(data%State%TD_WellGeo(kk)%StartAngle)) + data%State%TDGeo%Angle(ii) = EndAngle + !print*, 'data%State%TDGeo%TVD(ii)3=' ,ii , kk, data%State%TDGeo%TVD(ii) + else if ( data%State%TD_WellGeo(kk)%HoleType==1 ) then + EndAngle = StartAngle+(dl/data%State%TD_WellGeo(kk)%RCurvature) !??????????????????? !print*, 'StartAngle4=' ,ii , kk, StartAngle !print*, 'EndAngle4=' ,ii , kk, EndAngle - TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) - TDGeo%Angle(ii) = EndAngle - !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) + data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) + data%State%TDGeo%Angle(ii) = EndAngle + !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) !print*, 'mm=' ,mm - !print*, 'TDGeo%TVD(ii)4=' ,ii , kk, TDGeo%TVD(ii) - else if ( TD_WellGeo(kk)%HoleType==2 ) then - EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !??????????????????? + !print*, 'data%State%TDGeo%TVD(ii)4=' ,ii , kk, data%State%TDGeo%TVD(ii) + else if ( data%State%TD_WellGeo(kk)%HoleType==2 ) then + EndAngle = StartAngle-(dl/data%State%TD_WellGeo(kk)%RCurvature) !??????????????????? !print*, 'StartAngle44=' ,ii , kk, StartAngle !print*, 'EndAngle44=' ,ii , kk, EndAngle - TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) - TDGeo%Angle(ii) = EndAngle - !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) - !print*, 'mm=' ,mm , (TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) - !print*, 'TDGeo%TVD(ii)44=' ,ii , kk, TDGeo%TVD(ii) + data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) + data%State%TDGeo%Angle(ii) = EndAngle + !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) + !print*, 'mm=' ,mm , (data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) + !print*, 'data%State%TDGeo%TVD(ii)44=' ,ii , kk, data%State%TDGeo%TVD(ii) end if - mm = TDGeo%TVD(ii) + mm = data%State%TDGeo%TVD(ii) k = kk exit end if @@ -469,43 +470,43 @@ subroutine MeshGeneration_FluidModule - !if (F_Counts%OutOfWellIntervalCounts==1) then + !if (data%State%F_Counts%OutOfWellIntervalCounts==1) then ! s = 2 !else - ! s = F_Counts%OutOfWellIntervalCounts + ! s = data%State%F_Counts%OutOfWellIntervalCounts !end if ! - Do ii = (F_Counts%OutOfWellIntervalCounts+1),F_Counts%IntervalsTotalCounts + Do ii = (data%State%F_Counts%OutOfWellIntervalCounts+1),data%State%F_Counts%IntervalsTotalCounts do kk = jj,1,-1 - if ( F_Interval(ii)%StartDepth==TDGeo%MD(kk) ) then - F_Interval(ii)%StartTVD = TDGeo%TVD(kk) ![ft] - F_Interval(ii)%StartAngle = TDGeo%Angle(kk) ![rad] + if ( data%State%F_Interval(ii)%StartDepth==data%State%TDGeo%MD(kk) ) then + data%State%F_Interval(ii)%StartTVD = data%State%TDGeo%TVD(kk) ![ft] + data%State%F_Interval(ii)%StartAngle = data%State%TDGeo%Angle(kk) ![rad] end if - if ( F_Interval(ii)%EndDepth==TDGeo%MD(kk) ) then - F_Interval(ii)%EndTVD = TDGeo%TVD(kk) ![ft] - F_Interval(ii)%EndAngle = TDGeo%Angle(kk) ![rad] + if ( data%State%F_Interval(ii)%EndDepth==data%State%TDGeo%MD(kk) ) then + data%State%F_Interval(ii)%EndTVD = data%State%TDGeo%TVD(kk) ![ft] + data%State%F_Interval(ii)%EndAngle = data%State%TDGeo%Angle(kk) ![rad] end if end do End Do - !Do ii=1,(F_Counts%IntervalsTotalCounts) - ! print*, 'F_Interval(ii)%StartTVD=' , ii , F_Interval(ii)%StartTVD - ! print*, 'F_Interval(ii)%EndTVD=' , ii , F_Interval(ii)%EndTVD - ! print*, 'F_Interval(ii)%StartAngle=' , ii , F_Interval(ii)%StartAngle - ! print*, 'F_Interval(ii)%EndAngle=' , ii , F_Interval(ii)%EndAngle + !Do ii=1,(data%State%F_Counts%IntervalsTotalCounts) + ! print*, 'data%State%F_Interval(ii)%StartTVD=' , ii , data%State%F_Interval(ii)%StartTVD + ! print*, 'data%State%F_Interval(ii)%EndTVD=' , ii , data%State%F_Interval(ii)%EndTVD + ! print*, 'data%State%F_Interval(ii)%StartAngle=' , ii , data%State%F_Interval(ii)%StartAngle + ! print*, 'data%State%F_Interval(ii)%EndAngle=' , ii , data%State%F_Interval(ii)%EndAngle !end do ! ! - !Do ii=1,TD_WellGeneral%WellIntervalsCount - ! print*, 'TD_WellGeo(kk)%TopDepth=' , ii , TD_WellGeo(ii)%TopDepth - ! print*, 'TD_WellGeo(kk)%DownDepth=' , ii , TD_WellGeo(ii)%DownDepth - ! print*, 'TD_WellGeo(kk)%HoleType=' , ii , TD_WellGeo(ii)%HoleType - ! print*, 'TD_WellGeo(kk)%RCurvature=' , ii , TD_WellGeo(ii)%RCurvature - ! print*, 'TD_WellGeo(kk)%EndAngle=' , ii , TD_WellGeo(ii)%EndAngle - ! print*, 'TD_WellGeo(kk)%StartAngle=' , ii , TD_WellGeo(ii)%StartAngle + !Do ii=1,data%State%TD_WellGeneral%WellIntervalsCount + ! print*, 'data%State%TD_WellGeo(kk)%TopDepth=' , ii , data%State%TD_WellGeo(ii)%TopDepth + ! print*, 'data%State%TD_WellGeo(kk)%DownDepth=' , ii , data%State%TD_WellGeo(ii)%DownDepth + ! print*, 'data%State%TD_WellGeo(kk)%HoleType=' , ii , data%State%TD_WellGeo(ii)%HoleType + ! print*, 'data%State%TD_WellGeo(kk)%RCurvature=' , ii , data%State%TD_WellGeo(ii)%RCurvature + ! print*, 'data%State%TD_WellGeo(kk)%EndAngle=' , ii , data%State%TD_WellGeo(ii)%EndAngle + ! print*, 'data%State%TD_WellGeo(kk)%StartAngle=' , ii , data%State%TD_WellGeo(ii)%StartAngle !end do diff --git a/TorqueDrag/TD_DrillingSubs/TD_AddComponents.f90 b/TorqueDrag/TD_DrillingSubs/TD_AddComponents.f90 index b5ff54b..9b447bb 100644 --- a/TorqueDrag/TD_DrillingSubs/TD_AddComponents.f90 +++ b/TorqueDrag/TD_DrillingSubs/TD_AddComponents.f90 @@ -2,19 +2,21 @@ subroutine TD_AddComponents Use CStringConfigurationVariables use UnitySignalVariables + use UnitySignalsModule ! Use CStringUpdateVariables ! Use CSafetyValveEnumVariables - ! Use CIbopEnumVariables - ! Use COperationConditionEnumVariables - ! Use CKellyConnectionEnumVariables - use COperationScenariosVariables!, only: Get_ElevatorConnection - ! Use CElevatorConnectionEnumVariables - Use CHoistingVariables - ! Use CTdsConnectionModesEnumVariables + ! use UnitySignalsModule + ! use UnitySignalsModuleVariables + ! use OperationScenariosModule + use OperationScenariosModule!, only: Get_ElevatorConnection + ! use OperationScenariosModule !!CElevator... + use CHoistingVariables + use ConfigurationVariables + ! use UnitySignalsModule ! Use CTdsElevatorModesEnumVariables Use TD_DrillStemComponents - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData implicit none @@ -33,40 +35,40 @@ subroutine TD_AddComponents if ( Get_StringUpdate() == STRING_UPDATE_ADD_SINGLE ) then kk = 0 - Do i= TD_String%DrillStemComponentsNumbs , 1 , -1 - if (TD_DrillStems(i)%ComponentType==3) then + Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1 + if (data%State%TD_DrillStems(i)%ComponentType==3) then kk = i exit end if End Do ! DrillStems Array: TD_NumOfAddedComponents = 1 - Do i= (TD_String%DrillStemComponentsNumbs+1) , (TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) - TD_DrillStems(i)%ComponentType = 3 - TD_DrillStems(i)%Id = TD_DrillStems(kk)%Id - TD_DrillStems(i)%Od = TD_DrillStems(kk)%Od - TD_DrillStems(i)%Area = (pi*((TD_DrillStems(i)%Od**2)-(TD_DrillStems(i)%Id**2)))/4.d0 - TD_DrillStems(i)%RtoolJoint = TD_DrillStems(i)%Od*1.3d0/2.d0 - TD_DrillStems(i)%ToolJointRange = TD_String%ToolJointRange - TD_DrillStems(i)%Length = TD_DrillStems(kk)%LengthIni - TD_DrillStems(i)%LengthIni = TD_DrillStems(kk)%LengthIni - TD_DrillStems(i)%WeightperLength = TD_DrillStems(kk)%WeightperLength - TD_DrillStems(i)%Weight = TD_DrillStems(i)%WeightperLength*TD_DrillStems(i)%Length - TD_DrillStems(i)%Density = TD_DrillStems(kk)%Density - TD_DrillStems(i)%ElasticModule = TD_DrillStems(kk)%ElasticModule + Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) + data%State%TD_DrillStems(i)%ComponentType = 3 + data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id + data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%Od + data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.d0 + data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(i)%Od*1.3d0/2.d0 + data%State%TD_DrillStems(i)%ToolJointRange = data%State%TD_String%ToolJointRange + data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_DrillStems(i)%LengthIni = data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_DrillStems(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength + data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length + data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density + data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule End Do - TD_String%DrillStemComponentsNumbs = TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents + data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents ! DrillStem Array: - i = TD_String%StringConfigurationCount+1 - TD_DrillStem(i)%ComponentType = 3 - TD_DrillStem(i)%Numbs = 1 - TD_DrillStem(i)%Id = TD_DrillStems(kk)%Id ! [ft] - TD_DrillStem(i)%Od = TD_DrillStems(kk)%Od ! [ft] - TD_DrillStem(i)%Length = TD_DrillStems(kk)%LengthIni - TD_DrillStem(i)%WeightperLength = TD_DrillStems(kk)%WeightperLength - TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length - TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength - TD_String%StringConfigurationCount = TD_String%StringConfigurationCount+1 + i = data%State%TD_String%StringConfigurationCount+1 + data%State%TD_DrillStem(i)%ComponentType = 3 + data%State%TD_DrillStem(i)%Numbs = 1 + data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft] + data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%Od ! [ft] + data%State%TD_DrillStem(i)%Length = data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_DrillStem(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength + data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length + data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength + data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1 Call Set_StringUpdate(STRING_UPDATE_NEUTRAL) @@ -82,41 +84,41 @@ subroutine TD_AddComponents if ( Get_StringUpdate() == STRING_UPDATE_ADD_STAND ) then kk = 0 - Do i= TD_String%DrillStemComponentsNumbs , 1 , -1 - if (TD_DrillStems(i)%ComponentType==3) then + Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1 + if (data%State%TD_DrillStems(i)%ComponentType==3) then kk = i exit end if End Do ! DrillStems Array: TD_NumOfAddedComponents = 3 - Do i= (TD_String%DrillStemComponentsNumbs+1) , (TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) - TD_DrillStems(i)%ComponentType = 3 - TD_DrillStems(i)%Id = TD_DrillStems(kk)%Id - TD_DrillStems(i)%Od = TD_DrillStems(kk)%Od - TD_DrillStems(i)%Area = (pi*((TD_DrillStems(i)%Od**2)-(TD_DrillStems(i)%Id**2)))/4.0d0 - TD_DrillStems(i)%RtoolJoint = TD_DrillStems(i)%Od*1.30d0/2.0d0 - TD_DrillStems(i)%ToolJointRange = TD_String%ToolJointRange - TD_DrillStems(i)%Length = TD_DrillStems(kk)%LengthIni - TD_DrillStems(i)%LengthIni = TD_DrillStems(kk)%LengthIni - TD_DrillStems(i)%WeightperLength = TD_DrillStems(kk)%WeightperLength - TD_DrillStems(i)%Weight = TD_DrillStems(i)%WeightperLength*TD_DrillStems(i)%Length - TD_DrillStems(i)%Density = TD_DrillStems(kk)%Density - TD_DrillStems(i)%ElasticModule = TD_DrillStems(kk)%ElasticModule + Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) + data%State%TD_DrillStems(i)%ComponentType = 3 + data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id + data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%Od + data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0 + data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(i)%Od*1.30d0/2.0d0 + data%State%TD_DrillStems(i)%ToolJointRange = data%State%TD_String%ToolJointRange + data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_DrillStems(i)%LengthIni = data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_DrillStems(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength + data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length + data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density + data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule End Do - TD_String%DrillStemComponentsNumbs = TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents + data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents ! DrillStem Array: - i = TD_String%StringConfigurationCount+1 - TD_DrillStem(i)%ComponentType = 3 - TD_DrillStem(i)%Numbs = 3 - TD_DrillStem(i)%Id = TD_DrillStems(kk)%Id ! [ft] - TD_DrillStem(i)%Od = TD_DrillStems(kk)%Od ! [ft] - TD_DrillStem(i)%Length = TD_DrillStems(kk)%LengthIni - TD_DrillStem(i)%WeightperLength = TD_DrillStems(kk)%WeightperLength - TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length - TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength - TD_String%StringConfigurationCount = TD_String%StringConfigurationCount+1 + i = data%State%TD_String%StringConfigurationCount+1 + data%State%TD_DrillStem(i)%ComponentType = 3 + data%State%TD_DrillStem(i)%Numbs = 3 + data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft] + data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%Od ! [ft] + data%State%TD_DrillStem(i)%Length = data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_DrillStem(i)%WeightperLength = data%State%TD_DrillStems(kk)%WeightperLength + data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length + data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength + data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1 Call Set_StringUpdate(STRING_UPDATE_NEUTRAL) @@ -132,63 +134,63 @@ subroutine TD_AddComponents !==================================================== !if ( Get_Ibop()==IBOP_INSTALL ) then - ! TD_Count%IBOPNewAdd = 1 + ! data%State%TD_Count%IBOPNewAdd = 1 !else - ! TD_Count%IBOPNewAdd = 0 - ! TD_Count%IBOPOldAdd = 0 + ! data%State%TD_Count%IBOPNewAdd = 0 + ! data%State%TD_Count%IBOPOldAdd = 0 ! end if - if ( Get_Ibop()==IBOP_INSTALL .and. TD_Count%IBOPOldAdd==0 ) then + if ( Get_Ibop()==IBOP_INSTALL .and. data%State%TD_Count%IBOPOldAdd==0 ) then kk = 0 - Do i= TD_String%DrillStemComponentsNumbs , 1 , -1 - if (TD_DrillStems(i)%ComponentType==3) then + Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1 + if (data%State%TD_DrillStems(i)%ComponentType==3) then kk = i exit end if End Do ! DrillStems Array: TD_NumOfAddedComponents = 1 - Do i= (TD_String%DrillStemComponentsNumbs+1) , (TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) - TD_DrillStems(i)%ComponentType = 5 - TD_DrillStems(i)%Id = TD_DrillStems(kk)%Id - TD_DrillStems(i)%Od = TD_DrillStems(kk)%RtoolJoint - TD_DrillStems(i)%Area = (pi*((TD_DrillStems(i)%Od**2)-(TD_DrillStems(i)%Id**2)))/4.0d0 - TD_DrillStems(i)%RtoolJoint = TD_DrillStems(kk)%RtoolJoint - TD_DrillStems(i)%ToolJointRange = 0.0d0 - TD_DrillStems(i)%Length = TD_StConn%IBOPLength ! [ft] - TD_DrillStems(i)%LengthIni = TD_StConn%IBOPLength ! [ft] - TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft] - TD_DrillStems(i)%Weight = TD_DrillStems(i)%WeightperLength*TD_DrillStems(i)%Length - TD_DrillStems(i)%Density = TD_DrillStems(kk)%Density !???????????? - TD_DrillStems(i)%ElasticModule = TD_DrillStems(kk)%ElasticModule !???????????? + Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) + data%State%TD_DrillStems(i)%ComponentType = 5 + data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id + data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint + data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0 + data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(kk)%RtoolJoint + data%State%TD_DrillStems(i)%ToolJointRange = 0.0d0 + data%State%TD_DrillStems(i)%Length = data%State%TD_StConn%IBOPLength ! [ft] + data%State%TD_DrillStems(i)%LengthIni = data%State%TD_StConn%IBOPLength ! [ft] + data%State%TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft] + data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length + data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density !???????????? + data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule !???????????? End Do - TD_String%DrillStemComponentsNumbs = TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents + data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents ! DrillStem Array: - i = TD_String%StringConfigurationCount+1 - TD_DrillStem(i)%ComponentType = 5 - TD_DrillStem(i)%Numbs = 1 - TD_DrillStem(i)%Id = TD_DrillStems(kk)%Id ! [ft] - TD_DrillStem(i)%Od = TD_DrillStems(kk)%RtoolJoint ! [ft] - TD_DrillStem(i)%Length = 1.540d0 ! [ft] - TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft] - TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length - TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength - TD_String%StringConfigurationCount = TD_String%StringConfigurationCount+1 + i = data%State%TD_String%StringConfigurationCount+1 + data%State%TD_DrillStem(i)%ComponentType = 5 + data%State%TD_DrillStem(i)%Numbs = 1 + data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft] + data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint ! [ft] + data%State%TD_DrillStem(i)%Length = 1.540d0 ! [ft] + data%State%TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft] + data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length + data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength + data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1 - !TD_Count%IBOPOldAdd = TD_Count%IBOPNewAdd + !data%State%TD_Count%IBOPOldAdd = data%State%TD_Count%IBOPNewAdd if ( Get_ElevatorConnection() /= ELEVATOR_CONNECTION_STRING .or. (Get_TdsConnectionModes()/=TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()/=TDS_ELEVATOR_CONNECTION_STRING) ) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight+TD_DrillStem(i)%Length + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+data%State%TD_DrillStem(i)%Length end if end if if ( Get_Ibop()==IBOP_INSTALL ) then - TD_Count%IBOPOldAdd = 1 + data%State%TD_Count%IBOPOldAdd = 1 else - TD_Count%IBOPOldAdd = 0 + data%State%TD_Count%IBOPOldAdd = 0 end if @@ -198,46 +200,46 @@ subroutine TD_AddComponents ! Add Safety Valve & Kelly (OPERATION_DRILL) !==================================================== - if ( Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then - TD_Count%KellyNewAdd = 1 + if ( data%State%Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING ) then + data%State%TD_Count%KellyNewAdd = 1 else - TD_Count%KellyNewAdd = 0 - TD_Count%KellyOldAdd = 0 + data%State%TD_Count%KellyNewAdd = 0 + data%State%TD_Count%KellyOldAdd = 0 end if - if ( Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING .and. TD_Count%KellyNewAdd/=TD_Count%KellyOldAdd ) then + if ( data%State%Hoisting%DriveType==1 .and. Get_OperationCondition()==OPERATION_DRILL .and. Get_KellyConnection() == KELLY_CONNECTION_STRING .and. data%State%TD_Count%KellyNewAdd/=data%State%TD_Count%KellyOldAdd ) then ! DrillStems Array: TD_NumOfAddedComponents = 1 - Do i= (TD_String%DrillStemComponentsNumbs+1) , (TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) - TD_DrillStems(i)%ComponentType = 6 - TD_DrillStems(i)%Id = TD_StConn%KellyElementID ! [ft] - TD_DrillStems(i)%Od = TD_StConn%KellyElementOD ! [ft] - TD_DrillStems(i)%Area = (pi*((TD_DrillStems(i)%Od**2)-(TD_DrillStems(i)%Id**2)))/4.0d0 - TD_DrillStems(i)%RtoolJoint = TD_DrillStems(i)%Od*1.30d0/2.0d0 - TD_DrillStems(i)%ToolJointRange = 0.0d0 - TD_DrillStems(i)%Length = TD_StConn%KellyElementConst ! [ft] - TD_DrillStems(i)%LengthIni = TD_StConn%KellyElementConst ! [ft] - TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft] - TD_DrillStems(i)%Weight = TD_DrillStems(i)%WeightperLength*TD_DrillStems(i)%Length - TD_DrillStems(i)%Density = 7850.d0*0.06242796d0 ! [kg/m3]*0.06242796=[lb/ft3] - TD_DrillStems(i)%ElasticModule = 200.0d9*0.02088543d0 ! [lb/ft2] !200GPa=29Mpsi (steel) + Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) + data%State%TD_DrillStems(i)%ComponentType = 6 + data%State%TD_DrillStems(i)%Id = data%State%TD_StConn%KellyElementID ! [ft] + data%State%TD_DrillStems(i)%Od = data%State%TD_StConn%KellyElementOD ! [ft] + data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0 + data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(i)%Od*1.30d0/2.0d0 + data%State%TD_DrillStems(i)%ToolJointRange = 0.0d0 + data%State%TD_DrillStems(i)%Length = data%State%TD_StConn%KellyElementConst ! [ft] + data%State%TD_DrillStems(i)%LengthIni = data%State%TD_StConn%KellyElementConst ! [ft] + data%State%TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft] + data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length + data%State%TD_DrillStems(i)%Density = 7850.d0*0.06242796d0 ! [kg/m3]*0.06242796=[lb/ft3] + data%State%TD_DrillStems(i)%ElasticModule = 200.0d9*0.02088543d0 ! [lb/ft2] !200GPa=29Mpsi (steel) End Do - TD_String%DrillStemComponentsNumbs = TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents + data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents ! DrillStem Array: - i = TD_String%StringConfigurationCount+1 - TD_DrillStem(i)%ComponentType = 6 - TD_DrillStem(i)%Numbs = 1 - TD_DrillStem(i)%Id = 3.0d0/12.d0 ! [ft] - TD_DrillStem(i)%Od = 5.90d0/12.d0 ! [ft] - TD_DrillStem(i)%Length = TD_StConn%KellyElementConst ! [ft] - TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft] - TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length - TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength - TD_String%StringConfigurationCount = TD_String%StringConfigurationCount+1 + i = data%State%TD_String%StringConfigurationCount+1 + data%State%TD_DrillStem(i)%ComponentType = 6 + data%State%TD_DrillStem(i)%Numbs = 1 + data%State%TD_DrillStem(i)%Id = 3.0d0/12.d0 ! [ft] + data%State%TD_DrillStem(i)%Od = 5.90d0/12.d0 ! [ft] + data%State%TD_DrillStem(i)%Length = data%State%TD_StConn%KellyElementConst ! [ft] + data%State%TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft] + data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length + data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength + data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1 - TD_Count%KellyOldAdd = TD_Count%KellyNewAdd + data%State%TD_Count%KellyOldAdd = data%State%TD_Count%KellyNewAdd end if @@ -250,63 +252,63 @@ subroutine TD_AddComponents !==================================================== !if ( Get_OperationCondition()==OPERATION_TRIP .and. Get_SafetyValve()==SAFETY_VALVE_INSTALL ) then - ! TD_Count%SafetyValveNewAdd = 1 + ! data%State%TD_Count%SafetyValveNewAdd = 1 !else - ! TD_Count%SafetyValveNewAdd = 0 - ! TD_Count%SafetyValveOldAdd = 0 + ! data%State%TD_Count%SafetyValveNewAdd = 0 + ! data%State%TD_Count%SafetyValveOldAdd = 0 !end if - if ( TD_StConn%KellyDriveTypeMode/=0 .and. TD_StConn%OldOperationCondition/=0 .and. Get_SafetyValve()==SAFETY_VALVE_INSTALL .and. TD_Count%SafetyValveOldAdd==0 ) then + if ( data%State%TD_StConn%KellyDriveTypeMode/=0 .and. data%State%TD_StConn%OldOperationCondition/=0 .and. Get_SafetyValve()==SAFETY_VALVE_INSTALL .and. data%State%TD_Count%SafetyValveOldAdd==0 ) then kk = 0 - Do i= TD_String%DrillStemComponentsNumbs , 1 , -1 - if (TD_DrillStems(i)%ComponentType==3) then + Do i= data%State%TD_String%DrillStemComponentsNumbs , 1 , -1 + if (data%State%TD_DrillStems(i)%ComponentType==3) then kk = i exit end if End Do ! DrillStems Array: TD_NumOfAddedComponents = 1 - Do i= (TD_String%DrillStemComponentsNumbs+1) , (TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) - TD_DrillStems(i)%ComponentType = 7 - TD_DrillStems(i)%Id = TD_DrillStems(kk)%Id - TD_DrillStems(i)%Od = TD_DrillStems(kk)%RtoolJoint - TD_DrillStems(i)%Area = (pi*((TD_DrillStems(i)%Od**2)-(TD_DrillStems(i)%Id**2)))/4.0d0 - TD_DrillStems(i)%RtoolJoint = TD_DrillStems(kk)%RtoolJoint - TD_DrillStems(i)%ToolJointRange = 0.0d0 - TD_DrillStems(i)%Length = TD_StConn%SafetyValveLength ! [ft] - TD_DrillStems(i)%LengthIni = TD_StConn%SafetyValveLength ! [ft] - TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft] - TD_DrillStems(i)%Weight = TD_DrillStems(i)%WeightperLength*TD_DrillStems(i)%Length - TD_DrillStems(i)%Density = TD_DrillStems(kk)%Density !???????????? - TD_DrillStems(i)%ElasticModule = TD_DrillStems(kk)%ElasticModule !???????????? + Do i= (data%State%TD_String%DrillStemComponentsNumbs+1) , (data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents) + data%State%TD_DrillStems(i)%ComponentType = 7 + data%State%TD_DrillStems(i)%Id = data%State%TD_DrillStems(kk)%Id + data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint + data%State%TD_DrillStems(i)%Area = (pi*((data%State%TD_DrillStems(i)%Od**2)-(data%State%TD_DrillStems(i)%Id**2)))/4.0d0 + data%State%TD_DrillStems(i)%RtoolJoint = data%State%TD_DrillStems(kk)%RtoolJoint + data%State%TD_DrillStems(i)%ToolJointRange = 0.0d0 + data%State%TD_DrillStems(i)%Length = data%State%TD_StConn%SafetyValveLength ! [ft] + data%State%TD_DrillStems(i)%LengthIni = data%State%TD_StConn%SafetyValveLength ! [ft] + data%State%TD_DrillStems(i)%WeightperLength = 55.0d0 ! [lb/ft] + data%State%TD_DrillStems(i)%Weight = data%State%TD_DrillStems(i)%WeightperLength*data%State%TD_DrillStems(i)%Length + data%State%TD_DrillStems(i)%Density = data%State%TD_DrillStems(kk)%Density !???????????? + data%State%TD_DrillStems(i)%ElasticModule = data%State%TD_DrillStems(kk)%ElasticModule !???????????? End Do - TD_String%DrillStemComponentsNumbs = TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents + data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+TD_NumOfAddedComponents ! DrillStem Array: - i = TD_String%StringConfigurationCount+1 - TD_DrillStem(i)%ComponentType = 7 - TD_DrillStem(i)%Numbs = 1 - TD_DrillStem(i)%Id = TD_DrillStems(kk)%Id ! [ft] - TD_DrillStem(i)%Od = TD_DrillStems(kk)%RtoolJoint ! [ft] - TD_DrillStem(i)%Length = 1.540d0 ! [ft] - TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft] - TD_DrillStem(i)%TotalLength = TD_DrillStem(i)%Numbs*TD_DrillStem(i)%Length - TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength - TD_String%StringConfigurationCount = TD_String%StringConfigurationCount+1 + i = data%State%TD_String%StringConfigurationCount+1 + data%State%TD_DrillStem(i)%ComponentType = 7 + data%State%TD_DrillStem(i)%Numbs = 1 + data%State%TD_DrillStem(i)%Id = data%State%TD_DrillStems(kk)%Id ! [ft] + data%State%TD_DrillStem(i)%Od = data%State%TD_DrillStems(kk)%RtoolJoint ! [ft] + data%State%TD_DrillStem(i)%Length = 1.540d0 ! [ft] + data%State%TD_DrillStem(i)%WeightperLength = 55.0d0 ! [lb/ft] + data%State%TD_DrillStem(i)%TotalLength = data%State%TD_DrillStem(i)%Numbs*data%State%TD_DrillStem(i)%Length + data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength + data%State%TD_String%StringConfigurationCount = data%State%TD_String%StringConfigurationCount+1 - !TD_Count%SafetyValveOldAdd = TD_Count%SafetyValveNewAdd + !data%State%TD_Count%SafetyValveOldAdd = data%State%TD_Count%SafetyValveNewAdd if ( Get_ElevatorConnection() /= ELEVATOR_CONNECTION_STRING .or. (Get_TdsConnectionModes()/=TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()/=TDS_ELEVATOR_CONNECTION_STRING) ) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight+TD_DrillStem(i)%Length + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+data%State%TD_DrillStem(i)%Length end if end if if ( Get_SafetyValve()==SAFETY_VALVE_INSTALL ) then - TD_Count%SafetyValveOldAdd = 1 + data%State%TD_Count%SafetyValveOldAdd = 1 else - TD_Count%SafetyValveOldAdd = 0 + data%State%TD_Count%SafetyValveOldAdd = 0 end if diff --git a/TorqueDrag/TD_DrillingSubs/TD_BOPDiamCalculation.f90 b/TorqueDrag/TD_DrillingSubs/TD_BOPDiamCalculation.f90 index cf64632..443614c 100644 --- a/TorqueDrag/TD_DrillingSubs/TD_BOPDiamCalculation.f90 +++ b/TorqueDrag/TD_DrillingSubs/TD_BOPDiamCalculation.f90 @@ -1,12 +1,13 @@ subroutine TD_BOPDiamCalculation Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData Use CBopStackVariables - Use VARIABLES + use ConfigurationVariables + use DownHoleModule Integer :: i , j , n , m , TD_Numbs @@ -17,24 +18,24 @@ subroutine TD_BOPDiamCalculation - !TD_String%ToolJointRange = 0.4005d0*3.28 ! [ft] + !data%State%TD_String%ToolJointRange = 0.4005d0*3.28 ! [ft] !==================================================== ! Read BOP Data !==================================================== - TD_BOP%BOPHeight(5) = BopStackSpecification%AboveAnnularHeight - TD_BOP%BOPHeight(1) = BopStackSpecification%AnnularPreventerHeight - TD_BOP%BOPHeight(2) = BopStackSpecification%UpperRamHeight - TD_BOP%BOPHeight(3) = BopStackSpecification%BlindRamHeight - TD_BOP%BOPHeight(6) = BopStackSpecification%KillHeight - TD_BOP%BOPHeight(4) = BopStackSpecification%LowerRamHeight + data%State%TD_BOP%BOPHeight(5) = BopStackSpecification%AboveAnnularHeight + data%State%TD_BOP%BOPHeight(1) = BopStackSpecification%AnnularPreventerHeight + data%State%TD_BOP%BOPHeight(2) = BopStackSpecification%UpperRamHeight + data%State%TD_BOP%BOPHeight(3) = BopStackSpecification%BlindRamHeight + data%State%TD_BOP%BOPHeight(6) = BopStackSpecification%KillHeight + data%State%TD_BOP%BOPHeight(4) = BopStackSpecification%LowerRamHeight - TD_BOP%BOPRamDiam(1) = ShearRam%IDAnnularfinal - TD_BOP%BOPRamDiam(2) = ShearRam%IDPipeRam1final - TD_BOP%BOPRamDiam(3) = ShearRam%IDshearBopfinal - TD_BOP%BOPRamDiam(4) = ShearRam%IDPipeRam2final + data%State%TD_BOP%BOPRamDiam(1) = data%State%ShearRAM%IDAnnularfinal + data%State%TD_BOP%BOPRamDiam(2) = data%State%ShearRAM%IDPipeRam1final + data%State%TD_BOP%BOPRamDiam(3) = data%State%ShearRAM%IDshearBopfinal + data%State%TD_BOP%BOPRamDiam(4) = data%State%ShearRAM%IDPipeRam2final @@ -45,8 +46,8 @@ subroutine TD_BOPDiamCalculation ! Element Counts in BOPStack Domain !==================================================== - !if (TD_String%DrillStemComponentsNumbs>5) then - TD_Numbs = TD_String%DrillStemComponentsNumbs-7 ! 7 Elements from the Top of DrillStem + !if (data%State%TD_String%DrillStemComponentsNumbs>5) then + TD_Numbs = data%State%TD_String%DrillStemComponentsNumbs-7 ! 7 Elements from the Top of DrillStem !else ! TD_Numbs = 1 !end if @@ -63,81 +64,81 @@ subroutine TD_BOPDiamCalculation ! Determination of Elements Diameter in BOPStack Domain !==================================================== - TD_BOP%BOPDiam = 0.d0 + data%State%TD_BOP%BOPDiam = 0.d0 TD_OldFillingValue = 0.d0 - Do i = TD_String%DrillStemComponentsNumbs,TD_Numbs,-1 + Do i = data%State%TD_String%DrillStemComponentsNumbs,TD_Numbs,-1 - TD_LimitUp = TD_DrillStems(i)%TopDepth+TD_DrillStems(i)%ToolJointRange - TD_LimitDown = TD_DrillStems(i)%DownDepth-TD_DrillStems(i)%ToolJointRange - TD_ElToolJoints(1,1) = TD_DrillStems(i)%TopDepth ! TD_ElToolJoints(i,j) , i=top & down tooljoints of element , j=top & down tooljoints Depth + TD_LimitUp = data%State%TD_DrillStems(i)%TopDepth+data%State%TD_DrillStems(i)%ToolJointRange + TD_LimitDown = data%State%TD_DrillStems(i)%DownDepth-data%State%TD_DrillStems(i)%ToolJointRange + TD_ElToolJoints(1,1) = data%State%TD_DrillStems(i)%TopDepth ! TD_ElToolJoints(i,j) , i=top & down tooljoints of element , j=top & down tooljoints Depth TD_ElToolJoints(1,2) = TD_LimitUp TD_ElToolJoints(2,1) = TD_LimitDown - TD_ElToolJoints(2,2) = TD_DrillStems(i)%DownDepth + TD_ElToolJoints(2,2) = data%State%TD_DrillStems(i)%DownDepth !===> che meghdar az fazaye annular ba tooljoint por mishavad (for BOP Module) Do m = 1,2 - TD_AnnTjDiff = min(TD_ElToolJoints(m,2),(TD_BOP%BOPHeight(1)+TD_BOP%BOPThickness))-max(TD_ElToolJoints(m,1),(TD_BOP%BOPHeight(1)-TD_BOP%BOPThickness)) + TD_AnnTjDiff = min(TD_ElToolJoints(m,2),(data%State%TD_BOP%BOPHeight(1)+data%State%TD_BOP%BOPThickness))-max(TD_ElToolJoints(m,1),(data%State%TD_BOP%BOPHeight(1)-data%State%TD_BOP%BOPThickness)) if (TD_AnnTjDiff<0.) then ! tooljoint is not in the annular range TD_AnnTjDiff = 0.d0 end if - TD_AnnularFilling = TD_OldFillingValue+(TD_AnnTjDiff/(TD_BOP%BOPThickness*2.d0)) ! 0=TD_LimitUp .and. (TD_BOP%BOPHeight(j)+TD_BOP%BOPThickness)TD_LimitUp .and. (data%State%TD_BOP%BOPHeight(j)+data%State%TD_BOP%BOPThickness)0. ) then + !if ( data%State%TD_StConn%HookVelocity>0. ) then ! Print*, '*** UnSet Slips ***' !??????????????????? !end if - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst - TD_StConn%ConnectionHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst+(LengthSum+TD_StConn%ElevatorECG) !(LengthSum+TD_DrillStems(kk)%ToolJointRange) - TD_StConn%StringVelocity = TD_StConn%HookVelocity + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst+(LengthSum+data%State%TD_StConn%ElevatorECG) !(LengthSum+data%State%TD_DrillStems(kk)%ToolJointRange) + data%State%TD_StConn%StringVelocity = data%State%TD_StConn%HookVelocity end if else if ( Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING ) then - TD_StConn%StringConnectionMode = 5 - if (TD_Count%KellyOldStatus(4)==1 .and. TD_Count%KellyNewStatus(5)/=TD_Count%KellyOldStatus(5)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(5) = TD_Count%KellyNewStatus(5) - TD_Count%KellyOldStatus(4) = 0 - else if (TD_Count%KellyOldStatus(6)==1 .and. TD_Count%KellyNewStatus(5)/=TD_Count%KellyOldStatus(5)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(5) = TD_Count%KellyNewStatus(5) - TD_Count%KellyOldStatus(6) = 0 - else if (TD_Count%KellyOldStatus(7)==1 .and. TD_Count%KellyNewStatus(5)/=TD_Count%KellyOldStatus(5)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(5) = TD_Count%KellyNewStatus(5) - TD_Count%KellyOldStatus(7) = 0 - else if (TD_Count%KellyOldStatus(8)==1 .and. TD_Count%KellyNewStatus(5)/=TD_Count%KellyOldStatus(5)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(5) = TD_Count%KellyNewStatus(5) - TD_Count%KellyOldStatus(8) = 0 - else if (TD_Count%KellyOldStatus(2)==1 .and. TD_Count%KellyNewStatus(5)/=TD_Count%KellyOldStatus(5)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(5) = TD_Count%KellyNewStatus(5) - TD_Count%KellyOldStatus(2) = 0 + data%State%TD_StConn%StringConnectionMode = 5 + if (data%State%TD_Count%KellyOldStatus(4)==1 .and. data%State%TD_Count%KellyNewStatus(5)/=data%State%TD_Count%KellyOldStatus(5)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(5) = data%State%TD_Count%KellyNewStatus(5) + data%State%TD_Count%KellyOldStatus(4) = 0 + else if (data%State%TD_Count%KellyOldStatus(6)==1 .and. data%State%TD_Count%KellyNewStatus(5)/=data%State%TD_Count%KellyOldStatus(5)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(5) = data%State%TD_Count%KellyNewStatus(5) + data%State%TD_Count%KellyOldStatus(6) = 0 + else if (data%State%TD_Count%KellyOldStatus(7)==1 .and. data%State%TD_Count%KellyNewStatus(5)/=data%State%TD_Count%KellyOldStatus(5)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(5) = data%State%TD_Count%KellyNewStatus(5) + data%State%TD_Count%KellyOldStatus(7) = 0 + else if (data%State%TD_Count%KellyOldStatus(8)==1 .and. data%State%TD_Count%KellyNewStatus(5)/=data%State%TD_Count%KellyOldStatus(5)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(5) = data%State%TD_Count%KellyNewStatus(5) + data%State%TD_Count%KellyOldStatus(8) = 0 + else if (data%State%TD_Count%KellyOldStatus(2)==1 .and. data%State%TD_Count%KellyNewStatus(5)/=data%State%TD_Count%KellyOldStatus(5)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(5) = data%State%TD_Count%KellyNewStatus(5) + data%State%TD_Count%KellyOldStatus(2) = 0 end if - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND ) then - TD_StConn%StringConnectionMode = 6 - if (TD_Count%KellyOldStatus(4)==1 .and. TD_Count%KellyNewStatus(6)/=TD_Count%KellyOldStatus(6)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight-(3.*TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(6) = TD_Count%KellyNewStatus(6) - TD_Count%KellyOldStatus(4) = 0 - else if (TD_Count%KellyOldStatus(5)==1 .and. TD_Count%KellyNewStatus(6)/=TD_Count%KellyOldStatus(6)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(6) = TD_Count%KellyNewStatus(6) - TD_Count%KellyOldStatus(5) = 0 - else if (TD_Count%KellyOldStatus(7)==1 .and. TD_Count%KellyNewStatus(6)/=TD_Count%KellyOldStatus(6)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(6) = TD_Count%KellyNewStatus(6) - TD_Count%KellyOldStatus(7) = 0 - else if (TD_Count%KellyOldStatus(8)==1 .and. TD_Count%KellyNewStatus(6)/=TD_Count%KellyOldStatus(6)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(6) = TD_Count%KellyNewStatus(6) - TD_Count%KellyOldStatus(8) = 0 + data%State%TD_StConn%StringConnectionMode = 6 + if (data%State%TD_Count%KellyOldStatus(4)==1 .and. data%State%TD_Count%KellyNewStatus(6)/=data%State%TD_Count%KellyOldStatus(6)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight-(3.*data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(6) = data%State%TD_Count%KellyNewStatus(6) + data%State%TD_Count%KellyOldStatus(4) = 0 + else if (data%State%TD_Count%KellyOldStatus(5)==1 .and. data%State%TD_Count%KellyNewStatus(6)/=data%State%TD_Count%KellyOldStatus(6)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(6) = data%State%TD_Count%KellyNewStatus(6) + data%State%TD_Count%KellyOldStatus(5) = 0 + else if (data%State%TD_Count%KellyOldStatus(7)==1 .and. data%State%TD_Count%KellyNewStatus(6)/=data%State%TD_Count%KellyOldStatus(6)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(6) = data%State%TD_Count%KellyNewStatus(6) + data%State%TD_Count%KellyOldStatus(7) = 0 + else if (data%State%TD_Count%KellyOldStatus(8)==1 .and. data%State%TD_Count%KellyNewStatus(6)/=data%State%TD_Count%KellyOldStatus(6)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(6) = data%State%TD_Count%KellyNewStatus(6) + data%State%TD_Count%KellyOldStatus(8) = 0 end if - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst-(3.*TD_DrillStems(kk)%LengthIni) - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst-(3.*data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE ) then - TD_StConn%StringConnectionMode = 7 - if (TD_Count%KellyOldStatus(4)==1 .and. TD_Count%KellyNewStatus(7)/=TD_Count%KellyOldStatus(7)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight-TD_DrillStems(kk)%LengthIni - TD_Count%KellyOldStatus(7) = TD_Count%KellyNewStatus(7) - TD_Count%KellyOldStatus(4) = 0 - else if (TD_Count%KellyOldStatus(5)==1 .and. TD_Count%KellyNewStatus(7)/=TD_Count%KellyOldStatus(7)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(7) = TD_Count%KellyNewStatus(7) - TD_Count%KellyOldStatus(5) = 0 - else if (TD_Count%KellyOldStatus(6)==1 .and. TD_Count%KellyNewStatus(7)/=TD_Count%KellyOldStatus(7)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(7) = TD_Count%KellyNewStatus(7) - TD_Count%KellyOldStatus(6) = 0 - else if (TD_Count%KellyOldStatus(8)==1 .and. TD_Count%KellyNewStatus(7)/=TD_Count%KellyOldStatus(7)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(7) = TD_Count%KellyNewStatus(7) - TD_Count%KellyOldStatus(8) = 0 + data%State%TD_StConn%StringConnectionMode = 7 + if (data%State%TD_Count%KellyOldStatus(4)==1 .and. data%State%TD_Count%KellyNewStatus(7)/=data%State%TD_Count%KellyOldStatus(7)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight-data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_Count%KellyOldStatus(7) = data%State%TD_Count%KellyNewStatus(7) + data%State%TD_Count%KellyOldStatus(4) = 0 + else if (data%State%TD_Count%KellyOldStatus(5)==1 .and. data%State%TD_Count%KellyNewStatus(7)/=data%State%TD_Count%KellyOldStatus(7)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(7) = data%State%TD_Count%KellyNewStatus(7) + data%State%TD_Count%KellyOldStatus(5) = 0 + else if (data%State%TD_Count%KellyOldStatus(6)==1 .and. data%State%TD_Count%KellyNewStatus(7)/=data%State%TD_Count%KellyOldStatus(7)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(7) = data%State%TD_Count%KellyNewStatus(7) + data%State%TD_Count%KellyOldStatus(6) = 0 + else if (data%State%TD_Count%KellyOldStatus(8)==1 .and. data%State%TD_Count%KellyNewStatus(7)/=data%State%TD_Count%KellyOldStatus(7)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(7) = data%State%TD_Count%KellyNewStatus(7) + data%State%TD_Count%KellyOldStatus(8) = 0 end if - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst-TD_DrillStems(kk)%LengthIni - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst-data%State%TD_DrillStems(kk)%LengthIni + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_ElevatorConnection() == ELEVATOR_LATCH_STRING ) then - TD_StConn%StringConnectionMode = 8 - if (TD_Count%KellyOldStatus(4)==1 .and. TD_Count%KellyNewStatus(8)/=TD_Count%KellyOldStatus(8)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(8) = TD_Count%KellyNewStatus(8) - TD_Count%KellyOldStatus(4) = 0 - else if (TD_Count%KellyOldStatus(5)==1 .and. TD_Count%KellyNewStatus(8)/=TD_Count%KellyOldStatus(8)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(8) = TD_Count%KellyNewStatus(8) - TD_Count%KellyOldStatus(5) = 0 - else if (TD_Count%KellyOldStatus(6)==1 .and. TD_Count%KellyNewStatus(8)/=TD_Count%KellyOldStatus(8)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(8) = TD_Count%KellyNewStatus(8) - TD_Count%KellyOldStatus(6) = 0 - else if (TD_Count%KellyOldStatus(7)==1 .and. TD_Count%KellyNewStatus(8)/=TD_Count%KellyOldStatus(8)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(8) = TD_Count%KellyNewStatus(8) - TD_Count%KellyOldStatus(7) = 0 + data%State%TD_StConn%StringConnectionMode = 8 + if (data%State%TD_Count%KellyOldStatus(4)==1 .and. data%State%TD_Count%KellyNewStatus(8)/=data%State%TD_Count%KellyOldStatus(8)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(8) = data%State%TD_Count%KellyNewStatus(8) + data%State%TD_Count%KellyOldStatus(4) = 0 + else if (data%State%TD_Count%KellyOldStatus(5)==1 .and. data%State%TD_Count%KellyNewStatus(8)/=data%State%TD_Count%KellyOldStatus(8)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(8) = data%State%TD_Count%KellyNewStatus(8) + data%State%TD_Count%KellyOldStatus(5) = 0 + else if (data%State%TD_Count%KellyOldStatus(6)==1 .and. data%State%TD_Count%KellyNewStatus(8)/=data%State%TD_Count%KellyOldStatus(8)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(8) = data%State%TD_Count%KellyNewStatus(8) + data%State%TD_Count%KellyOldStatus(6) = 0 + else if (data%State%TD_Count%KellyOldStatus(7)==1 .and. data%State%TD_Count%KellyNewStatus(8)/=data%State%TD_Count%KellyOldStatus(8)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(8) = data%State%TD_Count%KellyNewStatus(8) + data%State%TD_Count%KellyOldStatus(7) = 0 end if - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_ElevatorConnection() == ELEVATOR_LATCH_SINGLE ) then - TD_StConn%StringConnectionMode = 18 - if (TD_Count%KellyOldStatus(5)==1 .and. TD_Count%KellyNewStatus(18)/=TD_Count%KellyOldStatus(18)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(18) = TD_Count%KellyNewStatus(18) - TD_Count%KellyOldStatus(5) = 0 - else if (TD_Count%KellyOldStatus(7)==1 .and. TD_Count%KellyNewStatus(18)/=TD_Count%KellyOldStatus(18)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(18) = TD_Count%KellyNewStatus(18) - TD_Count%KellyOldStatus(7) = 0 - else if (TD_Count%KellyOldStatus(8)==1 .and. TD_Count%KellyNewStatus(18)/=TD_Count%KellyOldStatus(18)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(18) = TD_Count%KellyNewStatus(18) - TD_Count%KellyOldStatus(8) = 0 + data%State%TD_StConn%StringConnectionMode = 18 + if (data%State%TD_Count%KellyOldStatus(5)==1 .and. data%State%TD_Count%KellyNewStatus(18)/=data%State%TD_Count%KellyOldStatus(18)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(18) = data%State%TD_Count%KellyNewStatus(18) + data%State%TD_Count%KellyOldStatus(5) = 0 + else if (data%State%TD_Count%KellyOldStatus(7)==1 .and. data%State%TD_Count%KellyNewStatus(18)/=data%State%TD_Count%KellyOldStatus(18)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(18) = data%State%TD_Count%KellyNewStatus(18) + data%State%TD_Count%KellyOldStatus(7) = 0 + else if (data%State%TD_Count%KellyOldStatus(8)==1 .and. data%State%TD_Count%KellyNewStatus(18)/=data%State%TD_Count%KellyOldStatus(18)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(18) = data%State%TD_Count%KellyNewStatus(18) + data%State%TD_Count%KellyOldStatus(8) = 0 end if - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_ElevatorConnection() == ELEVATOR_LATCH_STAND ) then - TD_StConn%StringConnectionMode = 19 - if (TD_Count%KellyOldStatus(5)==1 .and. TD_Count%KellyNewStatus(19)/=TD_Count%KellyOldStatus(19)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(19) = TD_Count%KellyNewStatus(19) - TD_Count%KellyOldStatus(5) = 0 - else if (TD_Count%KellyOldStatus(6)==1 .and. TD_Count%KellyNewStatus(19)/=TD_Count%KellyOldStatus(19)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(19) = TD_Count%KellyNewStatus(19) - TD_Count%KellyOldStatus(6) = 0 - else if (TD_Count%KellyOldStatus(8)==1 .and. TD_Count%KellyNewStatus(19)/=TD_Count%KellyOldStatus(19)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(19) = TD_Count%KellyNewStatus(19) - TD_Count%KellyOldStatus(8) = 0 + data%State%TD_StConn%StringConnectionMode = 19 + if (data%State%TD_Count%KellyOldStatus(5)==1 .and. data%State%TD_Count%KellyNewStatus(19)/=data%State%TD_Count%KellyOldStatus(19)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(19) = data%State%TD_Count%KellyNewStatus(19) + data%State%TD_Count%KellyOldStatus(5) = 0 + else if (data%State%TD_Count%KellyOldStatus(6)==1 .and. data%State%TD_Count%KellyNewStatus(19)/=data%State%TD_Count%KellyOldStatus(19)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(19) = data%State%TD_Count%KellyNewStatus(19) + data%State%TD_Count%KellyOldStatus(6) = 0 + else if (data%State%TD_Count%KellyOldStatus(8)==1 .and. data%State%TD_Count%KellyNewStatus(19)/=data%State%TD_Count%KellyOldStatus(19)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(19) = data%State%TD_Count%KellyNewStatus(19) + data%State%TD_Count%KellyOldStatus(8) = 0 end if - TD_StConn%ElevatorHeight = TD_StConn%HookHeight-TD_StConn%ElevatorConst - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%ElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%ElevatorConst + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 end if - else if ( TD_StConn%KellyDriveTypeMode==2 ) then + else if ( data%State%TD_StConn%KellyDriveTypeMode==2 ) then if( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then - TD_Count%KellyNewStatus(9) = 1 + data%State%TD_Count%KellyNewStatus(9) = 1 else - TD_Count%KellyNewStatus(9) = 0 - !TD_Count%KellyOldStatus(9) = 0 + data%State%TD_Count%KellyNewStatus(9) = 0 + !data%State%TD_Count%KellyOldStatus(9) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then - TD_Count%KellyNewStatus(10) = 1 + data%State%TD_Count%KellyNewStatus(10) = 1 else - TD_Count%KellyNewStatus(10) = 0 - !TD_Count%KellyOldStatus(10) = 0 + data%State%TD_Count%KellyNewStatus(10) = 0 + !data%State%TD_Count%KellyOldStatus(10) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STRING ) then - TD_Count%KellyNewStatus(11) = 1 + data%State%TD_Count%KellyNewStatus(11) = 1 else - TD_Count%KellyNewStatus(11) = 0 - !TD_Count%KellyOldStatus(11) = 0 + data%State%TD_Count%KellyNewStatus(11) = 0 + !data%State%TD_Count%KellyOldStatus(11) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING ) then - TD_Count%KellyNewStatus(12) = 1 + data%State%TD_Count%KellyNewStatus(12) = 1 else - TD_Count%KellyNewStatus(12) = 0 - !TD_Count%KellyOldStatus(12) = 0 + data%State%TD_Count%KellyNewStatus(12) = 0 + !data%State%TD_Count%KellyOldStatus(12) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then - TD_Count%KellyNewStatus(13) = 1 + data%State%TD_Count%KellyNewStatus(13) = 1 else - TD_Count%KellyNewStatus(13) = 0 - !TD_Count%KellyOldStatus(13) = 0 + data%State%TD_Count%KellyNewStatus(13) = 0 + !data%State%TD_Count%KellyOldStatus(13) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STAND ) then - TD_Count%KellyNewStatus(14) = 1 + data%State%TD_Count%KellyNewStatus(14) = 1 else - TD_Count%KellyNewStatus(14) = 0 - !TD_Count%KellyOldStatus(14) = 0 + data%State%TD_Count%KellyNewStatus(14) = 0 + !data%State%TD_Count%KellyOldStatus(14) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_SINGLE ) then - TD_Count%KellyNewStatus(15) = 1 + data%State%TD_Count%KellyNewStatus(15) = 1 else - TD_Count%KellyNewStatus(15) = 0 - !TD_Count%KellyOldStatus(15) = 0 + data%State%TD_Count%KellyNewStatus(15) = 0 + !data%State%TD_Count%KellyOldStatus(15) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_SINGLE ) then - TD_Count%KellyNewStatus(16) = 1 + data%State%TD_Count%KellyNewStatus(16) = 1 else - TD_Count%KellyNewStatus(16) = 0 - !TD_Count%KellyOldStatus(16) = 0 + data%State%TD_Count%KellyNewStatus(16) = 0 + !data%State%TD_Count%KellyOldStatus(16) = 0 end if if( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STAND ) then - TD_Count%KellyNewStatus(17) = 1 + data%State%TD_Count%KellyNewStatus(17) = 1 else - TD_Count%KellyNewStatus(17) = 0 - !TD_Count%KellyOldStatus(17) = 0 + data%State%TD_Count%KellyNewStatus(17) = 0 + !data%State%TD_Count%KellyOldStatus(17) = 0 end if if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then - TD_StConn%StringConnectionMode = 9 - if (TD_Count%KellyOldStatus(10)==1 .and. TD_Count%KellyNewStatus(9)/=TD_Count%KellyOldStatus(9)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(9) = TD_Count%KellyNewStatus(9) - TD_Count%KellyOldStatus(10) = 0 - else if (TD_Count%KellyOldStatus(11)==1 .and. TD_Count%KellyNewStatus(9)/=TD_Count%KellyOldStatus(9)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(9) = TD_Count%KellyNewStatus(9) - TD_Count%KellyOldStatus(11) = 0 - else if (TD_Count%KellyOldStatus(13)==1 .and. TD_Count%KellyNewStatus(9)/=TD_Count%KellyOldStatus(9)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(9) = TD_Count%KellyNewStatus(9) - TD_Count%KellyOldStatus(13) = 0 + data%State%TD_StConn%StringConnectionMode = 9 + if (data%State%TD_Count%KellyOldStatus(10)==1 .and. data%State%TD_Count%KellyNewStatus(9)/=data%State%TD_Count%KellyOldStatus(9)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(9) = data%State%TD_Count%KellyNewStatus(9) + data%State%TD_Count%KellyOldStatus(10) = 0 + else if (data%State%TD_Count%KellyOldStatus(11)==1 .and. data%State%TD_Count%KellyNewStatus(9)/=data%State%TD_Count%KellyOldStatus(9)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(9) = data%State%TD_Count%KellyNewStatus(9) + data%State%TD_Count%KellyOldStatus(11) = 0 + else if (data%State%TD_Count%KellyOldStatus(13)==1 .and. data%State%TD_Count%KellyNewStatus(9)/=data%State%TD_Count%KellyOldStatus(9)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(9) = data%State%TD_Count%KellyNewStatus(9) + data%State%TD_Count%KellyOldStatus(13) = 0 end if if ( Get_Slips() == SLIPS_SET_END ) then - !if ( TD_StConn%HookVelocity>0. ) then + !if ( data%State%TD_StConn%HookVelocity>0. ) then ! Print*, '*** UnSet Slips ***' !??????????????????? !end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength-TD_StConn%TDSToolJointLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength-data%State%TD_StConn%TDSToolJointLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength-TD_StConn%TDSToolJointLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%TDSHeight - TD_StConn%StringVelocity = TD_StConn%HookVelocity + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength-data%State%TD_StConn%TDSToolJointLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%TDSHeight + data%State%TD_StConn%StringVelocity = data%State%TD_StConn%HookVelocity end if else if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then - TD_StConn%StringConnectionMode = 10 - if (TD_Count%KellyOldStatus(9)==1 .and. TD_Count%KellyNewStatus(10)/=TD_Count%KellyOldStatus(10)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(10) = TD_Count%KellyNewStatus(10) - TD_Count%KellyOldStatus(9) = 0 + data%State%TD_StConn%StringConnectionMode = 10 + if (data%State%TD_Count%KellyOldStatus(9)==1 .and. data%State%TD_Count%KellyNewStatus(10)/=data%State%TD_Count%KellyOldStatus(10)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(10) = data%State%TD_Count%KellyNewStatus(10) + data%State%TD_Count%KellyOldStatus(9) = 0 end if if ( Get_Slips() == SLIPS_SET_END ) then - !if ( TD_StConn%HookVelocity>0. ) then + !if ( data%State%TD_StConn%HookVelocity>0. ) then ! Print*, '*** UnSet Slips ***' !??????????????????? !end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength-TD_StConn%TDSToolJointLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength-data%State%TD_StConn%TDSToolJointLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength-TD_StConn%TDSToolJointLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%TDSHeight - TD_StConn%StringVelocity = TD_StConn%HookVelocity + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength-data%State%TD_StConn%TDSToolJointLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%TDSHeight + data%State%TD_StConn%StringVelocity = data%State%TD_StConn%HookVelocity end if else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STRING ) then - TD_StConn%StringConnectionMode = 11 - if (TD_Count%KellyOldStatus(9)==1 .and. TD_Count%KellyNewStatus(11)/=TD_Count%KellyOldStatus(11)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(11) = TD_Count%KellyNewStatus(11) - TD_Count%KellyOldStatus(9) = 0 - else if (TD_Count%KellyOldStatus(12)==1 .and. TD_Count%KellyNewStatus(11)/=TD_Count%KellyOldStatus(11)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(11) = TD_Count%KellyNewStatus(11) - TD_Count%KellyOldStatus(12) = 0 - else if (TD_Count%KellyOldStatus(13)==1 .and. TD_Count%KellyNewStatus(11)/=TD_Count%KellyOldStatus(11)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(11) = TD_Count%KellyNewStatus(11) - TD_Count%KellyOldStatus(13) = 0 - else if (TD_Count%KellyOldStatus(16)==1 .and. TD_Count%KellyNewStatus(11)/=TD_Count%KellyOldStatus(11)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight+(TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(11) = TD_Count%KellyNewStatus(11) - TD_Count%KellyOldStatus(16) = 0 - else if (TD_Count%KellyOldStatus(17)==1 .and. TD_Count%KellyNewStatus(11)/=TD_Count%KellyOldStatus(11)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight+(3.d0*TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(11) = TD_Count%KellyNewStatus(11) - TD_Count%KellyOldStatus(17) = 0 + data%State%TD_StConn%StringConnectionMode = 11 + if (data%State%TD_Count%KellyOldStatus(9)==1 .and. data%State%TD_Count%KellyNewStatus(11)/=data%State%TD_Count%KellyOldStatus(11)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(11) = data%State%TD_Count%KellyNewStatus(11) + data%State%TD_Count%KellyOldStatus(9) = 0 + else if (data%State%TD_Count%KellyOldStatus(12)==1 .and. data%State%TD_Count%KellyNewStatus(11)/=data%State%TD_Count%KellyOldStatus(11)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(11) = data%State%TD_Count%KellyNewStatus(11) + data%State%TD_Count%KellyOldStatus(12) = 0 + else if (data%State%TD_Count%KellyOldStatus(13)==1 .and. data%State%TD_Count%KellyNewStatus(11)/=data%State%TD_Count%KellyOldStatus(11)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(11) = data%State%TD_Count%KellyNewStatus(11) + data%State%TD_Count%KellyOldStatus(13) = 0 + else if (data%State%TD_Count%KellyOldStatus(16)==1 .and. data%State%TD_Count%KellyNewStatus(11)/=data%State%TD_Count%KellyOldStatus(11)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+(data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(11) = data%State%TD_Count%KellyNewStatus(11) + data%State%TD_Count%KellyOldStatus(16) = 0 + else if (data%State%TD_Count%KellyOldStatus(17)==1 .and. data%State%TD_Count%KellyNewStatus(11)/=data%State%TD_Count%KellyOldStatus(11)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+(3.d0*data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(11) = data%State%TD_Count%KellyNewStatus(11) + data%State%TD_Count%KellyOldStatus(17) = 0 end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STRING ) then - TD_StConn%StringConnectionMode = 12 - if (TD_Count%KellyOldStatus(11)==1 .and. TD_Count%KellyNewStatus(12)/=TD_Count%KellyOldStatus(12)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(12) = TD_Count%KellyNewStatus(12) - TD_Count%KellyOldStatus(11) = 0 - else if (TD_Count%KellyOldStatus(14)==1 .and. TD_Count%KellyNewStatus(12)/=TD_Count%KellyOldStatus(12)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight+(3.d0*TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(12) = TD_Count%KellyNewStatus(12) - TD_Count%KellyOldStatus(14) = 0 - else if (TD_Count%KellyOldStatus(15)==1 .and. TD_Count%KellyNewStatus(12)/=TD_Count%KellyOldStatus(12)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight+(TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(12) = TD_Count%KellyNewStatus(12) - TD_Count%KellyOldStatus(15) = 0 + data%State%TD_StConn%StringConnectionMode = 12 + if (data%State%TD_Count%KellyOldStatus(11)==1 .and. data%State%TD_Count%KellyNewStatus(12)/=data%State%TD_Count%KellyOldStatus(12)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(12) = data%State%TD_Count%KellyNewStatus(12) + data%State%TD_Count%KellyOldStatus(11) = 0 + else if (data%State%TD_Count%KellyOldStatus(14)==1 .and. data%State%TD_Count%KellyNewStatus(12)/=data%State%TD_Count%KellyOldStatus(12)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+(3.d0*data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(12) = data%State%TD_Count%KellyNewStatus(12) + data%State%TD_Count%KellyOldStatus(14) = 0 + else if (data%State%TD_Count%KellyOldStatus(15)==1 .and. data%State%TD_Count%KellyNewStatus(12)/=data%State%TD_Count%KellyOldStatus(12)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+(data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(12) = data%State%TD_Count%KellyNewStatus(12) + data%State%TD_Count%KellyOldStatus(15) = 0 end if if ( Get_Slips() == SLIPS_SET_END ) then - !if ( TD_StConn%HookVelocity>0. ) then + !if ( data%State%TD_StConn%HookVelocity>0. ) then ! Print*, '*** UnSet Slips ***' !??????????????????? !end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSLength-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength+(LengthSum+TD_StConn%TDSElevatorECG) !????????????? - TD_StConn%StringVelocity = TD_StConn%HookVelocity + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength+(LengthSum+data%State%TD_StConn%TDSElevatorECG) !????????????? + data%State%TD_StConn%StringVelocity = data%State%TD_StConn%HookVelocity end if else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_NOTHING ) then - TD_StConn%StringConnectionMode = 13 - if (TD_Count%KellyOldStatus(9)==1 .and. TD_Count%KellyNewStatus(13)/=TD_Count%KellyOldStatus(13)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(13) = TD_Count%KellyNewStatus(13) - TD_Count%KellyOldStatus(9) = 0 - else if (TD_Count%KellyOldStatus(11)==1 .and. TD_Count%KellyNewStatus(13)/=TD_Count%KellyOldStatus(13)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(13) = TD_Count%KellyNewStatus(13) - TD_Count%KellyOldStatus(11) = 0 - else if (TD_Count%KellyOldStatus(12)==1 .and. TD_Count%KellyNewStatus(13)/=TD_Count%KellyOldStatus(13)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(13) = TD_Count%KellyNewStatus(13) - TD_Count%KellyOldStatus(12) = 0 - else if (TD_Count%KellyOldStatus(14)==1 .and. TD_Count%KellyNewStatus(13)/=TD_Count%KellyOldStatus(13)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(13) = TD_Count%KellyNewStatus(13) - TD_Count%KellyOldStatus(14) = 0 - else if (TD_Count%KellyOldStatus(15)==1 .and. TD_Count%KellyNewStatus(13)/=TD_Count%KellyOldStatus(13)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(13) = TD_Count%KellyNewStatus(13) - TD_Count%KellyOldStatus(15) = 0 - else if (TD_Count%KellyOldStatus(16)==1 .and. TD_Count%KellyNewStatus(13)/=TD_Count%KellyOldStatus(13)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(13) = TD_Count%KellyNewStatus(13) - TD_Count%KellyOldStatus(16) = 0 + data%State%TD_StConn%StringConnectionMode = 13 + if (data%State%TD_Count%KellyOldStatus(9)==1 .and. data%State%TD_Count%KellyNewStatus(13)/=data%State%TD_Count%KellyOldStatus(13)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(13) = data%State%TD_Count%KellyNewStatus(13) + data%State%TD_Count%KellyOldStatus(9) = 0 + else if (data%State%TD_Count%KellyOldStatus(11)==1 .and. data%State%TD_Count%KellyNewStatus(13)/=data%State%TD_Count%KellyOldStatus(13)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(13) = data%State%TD_Count%KellyNewStatus(13) + data%State%TD_Count%KellyOldStatus(11) = 0 + else if (data%State%TD_Count%KellyOldStatus(12)==1 .and. data%State%TD_Count%KellyNewStatus(13)/=data%State%TD_Count%KellyOldStatus(13)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(13) = data%State%TD_Count%KellyNewStatus(13) + data%State%TD_Count%KellyOldStatus(12) = 0 + else if (data%State%TD_Count%KellyOldStatus(14)==1 .and. data%State%TD_Count%KellyNewStatus(13)/=data%State%TD_Count%KellyOldStatus(13)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(13) = data%State%TD_Count%KellyNewStatus(13) + data%State%TD_Count%KellyOldStatus(14) = 0 + else if (data%State%TD_Count%KellyOldStatus(15)==1 .and. data%State%TD_Count%KellyNewStatus(13)/=data%State%TD_Count%KellyOldStatus(13)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(13) = data%State%TD_Count%KellyNewStatus(13) + data%State%TD_Count%KellyOldStatus(15) = 0 + else if (data%State%TD_Count%KellyOldStatus(16)==1 .and. data%State%TD_Count%KellyNewStatus(13)/=data%State%TD_Count%KellyOldStatus(13)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(13) = data%State%TD_Count%KellyNewStatus(13) + data%State%TD_Count%KellyOldStatus(16) = 0 end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_STAND ) then - TD_StConn%StringConnectionMode = 14 - if (TD_Count%KellyOldStatus(12)==1 .and. TD_Count%KellyNewStatus(14)/=TD_Count%KellyOldStatus(14)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight-(3.d0*TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(14) = TD_Count%KellyNewStatus(14) - TD_Count%KellyOldStatus(12) = 0 - else if (TD_Count%KellyOldStatus(13)==1 .and. TD_Count%KellyNewStatus(14)/=TD_Count%KellyOldStatus(14)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(14) = TD_Count%KellyNewStatus(14) - TD_Count%KellyOldStatus(13) = 0 - else if (TD_Count%KellyOldStatus(17)==1 .and. TD_Count%KellyNewStatus(14)/=TD_Count%KellyOldStatus(14)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(14) = TD_Count%KellyNewStatus(14) - TD_Count%KellyOldStatus(17) = 0 + data%State%TD_StConn%StringConnectionMode = 14 + if (data%State%TD_Count%KellyOldStatus(12)==1 .and. data%State%TD_Count%KellyNewStatus(14)/=data%State%TD_Count%KellyOldStatus(14)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight-(3.d0*data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(14) = data%State%TD_Count%KellyNewStatus(14) + data%State%TD_Count%KellyOldStatus(12) = 0 + else if (data%State%TD_Count%KellyOldStatus(13)==1 .and. data%State%TD_Count%KellyNewStatus(14)/=data%State%TD_Count%KellyOldStatus(14)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(14) = data%State%TD_Count%KellyNewStatus(14) + data%State%TD_Count%KellyOldStatus(13) = 0 + else if (data%State%TD_Count%KellyOldStatus(17)==1 .and. data%State%TD_Count%KellyNewStatus(14)/=data%State%TD_Count%KellyOldStatus(14)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(14) = data%State%TD_Count%KellyNewStatus(14) + data%State%TD_Count%KellyOldStatus(17) = 0 end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_CONNECTION_SINGLE ) then - TD_StConn%StringConnectionMode = 15 - if (TD_Count%KellyOldStatus(12)==1 .and. TD_Count%KellyNewStatus(15)/=TD_Count%KellyOldStatus(15)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight-(TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(15) = TD_Count%KellyNewStatus(15) - TD_Count%KellyOldStatus(12) = 0 - else if (TD_Count%KellyOldStatus(13)==1 .and. TD_Count%KellyNewStatus(15)/=TD_Count%KellyOldStatus(15)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(15) = TD_Count%KellyNewStatus(15) - TD_Count%KellyOldStatus(13) = 0 - else if (TD_Count%KellyOldStatus(16)==1 .and. TD_Count%KellyNewStatus(15)/=TD_Count%KellyOldStatus(15)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(15) = TD_Count%KellyNewStatus(15) - TD_Count%KellyOldStatus(16) = 0 + data%State%TD_StConn%StringConnectionMode = 15 + if (data%State%TD_Count%KellyOldStatus(12)==1 .and. data%State%TD_Count%KellyNewStatus(15)/=data%State%TD_Count%KellyOldStatus(15)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight-(data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(15) = data%State%TD_Count%KellyNewStatus(15) + data%State%TD_Count%KellyOldStatus(12) = 0 + else if (data%State%TD_Count%KellyOldStatus(13)==1 .and. data%State%TD_Count%KellyNewStatus(15)/=data%State%TD_Count%KellyOldStatus(15)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(15) = data%State%TD_Count%KellyNewStatus(15) + data%State%TD_Count%KellyOldStatus(13) = 0 + else if (data%State%TD_Count%KellyOldStatus(16)==1 .and. data%State%TD_Count%KellyNewStatus(15)/=data%State%TD_Count%KellyOldStatus(15)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(15) = data%State%TD_Count%KellyNewStatus(15) + data%State%TD_Count%KellyOldStatus(16) = 0 end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_SINGLE ) then - TD_StConn%StringConnectionMode = 16 - if (TD_Count%KellyOldStatus(11)==1 .and. TD_Count%KellyNewStatus(16)/=TD_Count%KellyOldStatus(16)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight-(TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(16) = TD_Count%KellyNewStatus(16) - TD_Count%KellyOldStatus(11) = 0 - else if (TD_Count%KellyOldStatus(13)==1 .and. TD_Count%KellyNewStatus(16)/=TD_Count%KellyOldStatus(16)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(16) = TD_Count%KellyNewStatus(16) - TD_Count%KellyOldStatus(13) = 0 - else if (TD_Count%KellyOldStatus(15)==1 .and. TD_Count%KellyNewStatus(16)/=TD_Count%KellyOldStatus(16)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_Count%KellyOldStatus(16) = TD_Count%KellyNewStatus(16) - TD_Count%KellyOldStatus(15) = 0 + data%State%TD_StConn%StringConnectionMode = 16 + if (data%State%TD_Count%KellyOldStatus(11)==1 .and. data%State%TD_Count%KellyNewStatus(16)/=data%State%TD_Count%KellyOldStatus(16)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight-(data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(16) = data%State%TD_Count%KellyNewStatus(16) + data%State%TD_Count%KellyOldStatus(11) = 0 + else if (data%State%TD_Count%KellyOldStatus(13)==1 .and. data%State%TD_Count%KellyNewStatus(16)/=data%State%TD_Count%KellyOldStatus(16)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(16) = data%State%TD_Count%KellyNewStatus(16) + data%State%TD_Count%KellyOldStatus(13) = 0 + else if (data%State%TD_Count%KellyOldStatus(15)==1 .and. data%State%TD_Count%KellyNewStatus(16)/=data%State%TD_Count%KellyOldStatus(16)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_Count%KellyOldStatus(16) = data%State%TD_Count%KellyNewStatus(16) + data%State%TD_Count%KellyOldStatus(15) = 0 end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING .and. Get_TdsElevatorModes()==TDS_ELEVATOR_LATCH_STAND ) then - TD_StConn%StringConnectionMode = 17 - if (TD_Count%KellyOldStatus(11)==1 .and. TD_Count%KellyNewStatus(17)/=TD_Count%KellyOldStatus(17)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight-(3.d0*TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(17) = TD_Count%KellyNewStatus(17) - TD_Count%KellyOldStatus(11) = 0 - else if (TD_Count%KellyOldStatus(14)==1 .and. TD_Count%KellyNewStatus(17)/=TD_Count%KellyOldStatus(17)) then - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight+(3.d0*TD_DrillStems(kk)%LengthIni) - TD_Count%KellyOldStatus(17) = TD_Count%KellyNewStatus(17) - TD_Count%KellyOldStatus(14) = 0 + data%State%TD_StConn%StringConnectionMode = 17 + if (data%State%TD_Count%KellyOldStatus(11)==1 .and. data%State%TD_Count%KellyNewStatus(17)/=data%State%TD_Count%KellyOldStatus(17)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight-(3.d0*data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(17) = data%State%TD_Count%KellyNewStatus(17) + data%State%TD_Count%KellyOldStatus(11) = 0 + else if (data%State%TD_Count%KellyOldStatus(14)==1 .and. data%State%TD_Count%KellyNewStatus(17)/=data%State%TD_Count%KellyOldStatus(17)) then + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight+(3.d0*data%State%TD_DrillStems(kk)%LengthIni) + data%State%TD_Count%KellyOldStatus(17) = data%State%TD_Count%KellyNewStatus(17) + data%State%TD_Count%KellyOldStatus(14) = 0 end if - TD_StConn%TDSHeight = TD_StConn%HookHeight-TD_StConn%TDSLength !????????????? - TD_StConn%TDSElevatorHeight = TD_StConn%HookHeight-TD_StConn%TDSElevatorLength !????????????? - TD_StConn%ConnectionHeight = TD_StConn%ConnectionHeight - TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%TDSHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSLength !????????????? + data%State%TD_StConn%TDSElevatorHeight = data%State%TD_StConn%HookHeight-data%State%TD_StConn%TDSElevatorLength !????????????? + data%State%TD_StConn%ConnectionHeight = data%State%TD_StConn%ConnectionHeight + data%State%TD_StConn%StringVelocity = 0.0d0 end if end if - !Print*, 'TD_StConn%StringConnectionMode=' , TD_StConn%StringConnectionMode - !print* , 'TD_StConn%ConnectionHeight=' , TD_StConn%ConnectionHeight - !Print*, 'TD_StConn%StringConnectionMode=' , TD_StConn%StringConnectionMode - !print*, 'TD_String%DrillStemComponentsNumbs=' , TD_String%DrillStemComponentsNumbs - !!Print*, 'TD_Count%KellyNewStatus(1)=' , TD_Count%KellyNewStatus(1) - !Print*, 'TD_Count%KellyOldStatus(1)=' , TD_Count%KellyOldStatus(1) - !Print*, 'TD_Count%KellyNewStatus(2)=' , TD_Count%KellyNewStatus(2) - !Print*, 'TD_Count%KellyOldStatus(2)=' , TD_Count%KellyOldStatus(2) - !Print*, 'TD_Count%KellyNewStatus(3)=' , TD_Count%KellyNewStatus(3) - !Print*, 'TD_Count%KellyOldStatus(3)=' , TD_Count%KellyOldStatus(3) + !Print*, 'data%State%TD_StConn%StringConnectionMode=' , data%State%TD_StConn%StringConnectionMode + !print* , 'data%State%TD_StConn%ConnectionHeight=' , data%State%TD_StConn%ConnectionHeight + !Print*, 'data%State%TD_StConn%StringConnectionMode=' , data%State%TD_StConn%StringConnectionMode + !print*, 'data%State%TD_String%DrillStemComponentsNumbs=' , data%State%TD_String%DrillStemComponentsNumbs + !!Print*, 'data%State%TD_Count%KellyNewStatus(1)=' , data%State%TD_Count%KellyNewStatus(1) + !Print*, 'data%State%TD_Count%KellyOldStatus(1)=' , data%State%TD_Count%KellyOldStatus(1) + !Print*, 'data%State%TD_Count%KellyNewStatus(2)=' , data%State%TD_Count%KellyNewStatus(2) + !Print*, 'data%State%TD_Count%KellyOldStatus(2)=' , data%State%TD_Count%KellyOldStatus(2) + !Print*, 'data%State%TD_Count%KellyNewStatus(3)=' , data%State%TD_Count%KellyNewStatus(3) + !Print*, 'data%State%TD_Count%KellyOldStatus(3)=' , data%State%TD_Count%KellyOldStatus(3) - if ( (any(TD_StConn%StringConnectionMode==(/1,9,10/))) .or. DrillingConsole%CloseSafetyValve==.true. ) then !for fluid module - TD_StConn%FluidStringConnectionMode = 1 !string is connected - !else if ( (any(TD_StConn%StringConnectionMode==(/1,9,10/))) .or. DrillingConsole%CloseSafetyValve==.true. ) then + if ( (any(data%State%TD_StConn%StringConnectionMode==(/1,9,10/))) .or. data%EquipmentControl%DrillingConsole%CloseSafetyValve==.true. ) then !for fluid module + data%State%TD_StConn%FluidStringConnectionMode = 1 !string is connected + !else if ( (any(data%State%TD_StConn%StringConnectionMode==(/1,9,10/))) .or. data%EquipmentControl%DrillingConsole%CloseSafetyValve==.true. ) then ! else - TD_StConn%FluidStringConnectionMode = 0 !string is not connected + data%State%TD_StConn%FluidStringConnectionMode = 0 !string is not connected end if @@ -813,11 +817,11 @@ subroutine TD_StringConnectionModes !==================================================== ! Zero String Speed !==================================================== - if ( abs(TD_StConn%StringVelocity)<=0.05d0 ) then ! [ft/s] - TD_Load%ZeroStringSpeed = 1 + if ( abs(data%State%TD_StConn%StringVelocity)<=0.05d0 ) then ! [ft/s] + data%State%TD_Load%ZeroStringSpeed = 1 Call Set_ZeroStringSpeed(.true.) else - TD_Load%ZeroStringSpeed = 0 + data%State%TD_Load%ZeroStringSpeed = 0 Call Set_ZeroStringSpeed(.false.) end if diff --git a/TorqueDrag/TD_DrillingSubs/TD_WellElementsConfiguration.f90 b/TorqueDrag/TD_DrillingSubs/TD_WellElementsConfiguration.f90 index ac96261..d37d215 100644 --- a/TorqueDrag/TD_DrillingSubs/TD_WellElementsConfiguration.f90 +++ b/TorqueDrag/TD_DrillingSubs/TD_WellElementsConfiguration.f90 @@ -1,8 +1,8 @@ subroutine TD_WellElementsConfiguration Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -14,11 +14,11 @@ subroutine TD_WellElementsConfiguration ! Modified Well Elements Data !==================================================== - Do i = 1 , TD_WellEl%ROPHoleNumbs - !TD_ROPHole(i)%TopDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%TopDepth - TD_ROPHole(i)%DownDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%DownDepth - TD_ROPHole(i)%Length = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%IntervalLength - TD_ROPHole(i)%Id = TD_ROPHole(i)%Id !!??????????? + Do i = 1 , data%State%TD_WellEl%ROPHoleNumbs + !data%State%TD_ROPHole(i)%TopDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth + data%State%TD_ROPHole(i)%DownDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth + data%State%TD_ROPHole(i)%Length = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength + data%State%TD_ROPHole(i)%Id = data%State%TD_ROPHole(i)%Id !!??????????? End Do diff --git a/TorqueDrag/TD_DrillingSubs/TD_WellGeoConfiguration.f90 b/TorqueDrag/TD_DrillingSubs/TD_WellGeoConfiguration.f90 index 74fb358..f983565 100644 --- a/TorqueDrag/TD_DrillingSubs/TD_WellGeoConfiguration.f90 +++ b/TorqueDrag/TD_DrillingSubs/TD_WellGeoConfiguration.f90 @@ -1,12 +1,13 @@ subroutine TD_WellGeoConfiguration Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use sROP_Variables - Use CDataDisplayConsoleVariables - Use CWarningsVariables + use CDataDisplayConsole + use ConfigurationVariables + use CWarnings @@ -19,31 +20,31 @@ subroutine TD_WellGeoConfiguration !=====> ROP Calculation - if ( TD_DrillStems(1)%ComponentType==0 .and. Warmings%MaximumWellDepthExceeded==.false. ) then + if ( data%State%TD_DrillStems(1)%ComponentType==0 .and. data%Warnings%MaximumWellDepthExceeded==.false. ) then Call ROP_MainCalculation else - ROP_Bit%RateOfPenetration = 0.d0 - Call Set_ROP(ROP_Bit%RateOfPenetration) + data%State%ROP_Bit%RateOfPenetration = 0.d0 + Call Set_ROP(data%State%ROP_Bit%RateOfPenetration) end if !=====> ROPHole Data correction - TD_WellEl%ROP = (ROP_Bit%RateOfPenetration/3600.d0) ! [ft/s] - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%VerticalDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%VerticalDepth++((TD_WellEl%ROP*TD_General%TimeStep)*cos(TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%StartAngle)) - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%IntervalLength = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%IntervalLength+(TD_WellEl%ROP*TD_General%TimeStep) !????????check - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%DownDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%TopDepth+TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%IntervalLength + data%State%TD_WellEl%ROP = (data%State%ROP_Bit%RateOfPenetration/3600.d0) ! [ft/s] + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth++((data%State%TD_WellEl%ROP*data%State%TD_General%TimeStep)*cos(data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle)) + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength+(data%State%TD_WellEl%ROP*data%State%TD_General%TimeStep) !????????check + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth+data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength !=====> Well Total Length Calculation - TD_WellGeneral%WellTotalLength = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%DownDepth - TD_WellGeneral%WellTotalVerticalLength = TD_WellGeneral%WellTotalVerticalLength+((TD_WellEl%ROP*TD_General%TimeStep)*cos(TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%StartAngle)) + data%State%TD_WellGeneral%WellTotalLength = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth + data%State%TD_WellGeneral%WellTotalVerticalLength = data%State%TD_WellGeneral%WellTotalVerticalLength+((data%State%TD_WellEl%ROP*data%State%TD_General%TimeStep)*cos(data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle)) - Call Set_TotalDepth(real(TD_WellGeneral%WellTotalLength,8)) + Call Set_TotalDepth(real(data%State%TD_WellGeneral%WellTotalLength,8)) diff --git a/TorqueDrag/TD_DrillingSubs/TVD_Calculator.f90 b/TorqueDrag/TD_DrillingSubs/TVD_Calculator.f90 index 352a701..9cd1d33 100644 --- a/TorqueDrag/TD_DrillingSubs/TVD_Calculator.f90 +++ b/TorqueDrag/TD_DrillingSubs/TVD_Calculator.f90 @@ -1,8 +1,8 @@ subroutine TVD_Calculator(MeasuredDepth,VerticalDepth) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData @@ -18,7 +18,7 @@ subroutine TVD_Calculator(MeasuredDepth,VerticalDepth) if ( MeasuredDepth<=0. ) then VerticalDepth = MeasuredDepth - !TDGeo%Angle(ii) = 0.d0 + !data%State%TDGeo%Angle(ii) = 0.d0 return end if @@ -26,44 +26,44 @@ subroutine TVD_Calculator(MeasuredDepth,VerticalDepth) mm = 0.d0 !last vertical depth nn = 0.d0 !last measured depth - EndAngle = TD_WellGeo(1)%StartAngle - !TDGeo%Angle(jj) = EndAngle + EndAngle = data%State%TD_WellGeo(1)%StartAngle + !data%State%TDGeo%Angle(jj) = EndAngle - do kk = 1, TD_WellGeneral%WellIntervalsCount + do kk = 1, data%State%TD_WellGeneral%WellIntervalsCount StartAngle = EndAngle - if ( MeasuredDepth>TD_WellGeo(kk)%TopDepth ) then - if ( MeasuredDepth>TD_WellGeo(kk)%DownDepth ) then - dl = TD_WellGeo(kk)%DownDepth-nn ![ft] - nn = TD_WellGeo(kk)%DownDepth - if ( TD_WellGeo(kk)%HoleType==0 ) then + if ( MeasuredDepth>data%State%TD_WellGeo(kk)%TopDepth ) then + if ( MeasuredDepth>data%State%TD_WellGeo(kk)%DownDepth ) then + dl = data%State%TD_WellGeo(kk)%DownDepth-nn ![ft] + nn = data%State%TD_WellGeo(kk)%DownDepth + if ( data%State%TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle - VerticalDepth = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) ![ft] - !TDGeo%Angle(ii) = EndAngle - else if ( TD_WellGeo(kk)%HoleType==1 ) then - EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !????? - VerticalDepth = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) - !TDGeo%Angle(ii) = EndAngle - else if ( TD_WellGeo(kk)%HoleType==2 ) then - EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !????? - VerticalDepth = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) - !TDGeo%Angle(ii) = EndAngle + VerticalDepth = mm+(dl*cos(data%State%TD_WellGeo(kk)%StartAngle)) ![ft] + !data%State%TDGeo%Angle(ii) = EndAngle + else if ( data%State%TD_WellGeo(kk)%HoleType==1 ) then + EndAngle = StartAngle+(dl/data%State%TD_WellGeo(kk)%RCurvature) !????? + VerticalDepth = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) + !data%State%TDGeo%Angle(ii) = EndAngle + else if ( data%State%TD_WellGeo(kk)%HoleType==2 ) then + EndAngle = StartAngle-(dl/data%State%TD_WellGeo(kk)%RCurvature) !????? + VerticalDepth = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) + !data%State%TDGeo%Angle(ii) = EndAngle end if mm = VerticalDepth else dl = MeasuredDepth-nn nn = MeasuredDepth - if ( TD_WellGeo(kk)%HoleType==0 ) then + if ( data%State%TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle - VerticalDepth = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) - !TDGeo%Angle(ii) = EndAngle - else if ( TD_WellGeo(kk)%HoleType==1 ) then - EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !????? - VerticalDepth = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) - !TDGeo%Angle(ii) = EndAngle - else if ( TD_WellGeo(kk)%HoleType==2 ) then - EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !????? - VerticalDepth = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) - !TDGeo%Angle(ii) = EndAngle + VerticalDepth = mm+(dl*cos(data%State%TD_WellGeo(kk)%StartAngle)) + !data%State%TDGeo%Angle(ii) = EndAngle + else if ( data%State%TD_WellGeo(kk)%HoleType==1 ) then + EndAngle = StartAngle+(dl/data%State%TD_WellGeo(kk)%RCurvature) !????? + VerticalDepth = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) + !data%State%TDGeo%Angle(ii) = EndAngle + else if ( data%State%TD_WellGeo(kk)%HoleType==2 ) then + EndAngle = StartAngle-(dl/data%State%TD_WellGeo(kk)%RCurvature) !????? + VerticalDepth = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) + !data%State%TDGeo%Angle(ii) = EndAngle end if mm = VerticalDepth exit diff --git a/TorqueDrag/TD_Forces/TD_BouyancyFactor.f90 b/TorqueDrag/TD_Forces/TD_BouyancyFactor.f90 index 3e3f24f..a1c2343 100644 --- a/TorqueDrag/TD_Forces/TD_BouyancyFactor.f90 +++ b/TorqueDrag/TD_Forces/TD_BouyancyFactor.f90 @@ -1,9 +1,9 @@ subroutine TD_BouyancyFactor (i) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -17,12 +17,12 @@ subroutine TD_BouyancyFactor (i) ! Bouyancy Factor Calculation !==================================================== - if ( TD_DrillStems(i)%MudDensityOut==0.d0 .or. TD_DrillStems(i)%MudDensityIn==0.d0 ) then - TD_DrillStems(i)%BouyancyFactor = 0.d0 + if ( data%State%TD_DrillStems(i)%MudDensityOut==0.d0 .or. data%State%TD_DrillStems(i)%MudDensityIn==0.d0 ) then + data%State%TD_DrillStems(i)%BouyancyFactor = 0.d0 else - TD_DrillStems(i)%BouyancyFactor = 1.d0-( ((TD_DrillStems(i)%MudDensityOut*(TD_DrillStems(i)%Od**2)/4.0d0) & - -(TD_DrillStems(i)%MudDensityIn*(TD_DrillStems(i)%Id**2)/4.0d0)) & - /(TD_DrillStems(i)%Density*((TD_DrillStems(i)%Od**2-TD_DrillStems(i)%Id**2))/4.0d0) ) + data%State%TD_DrillStems(i)%BouyancyFactor = 1.d0-( ((data%State%TD_DrillStems(i)%MudDensityOut*(data%State%TD_DrillStems(i)%Od**2)/4.0d0) & + -(data%State%TD_DrillStems(i)%MudDensityIn*(data%State%TD_DrillStems(i)%Id**2)/4.0d0)) & + /(data%State%TD_DrillStems(i)%Density*((data%State%TD_DrillStems(i)%Od**2-data%State%TD_DrillStems(i)%Id**2))/4.0d0) ) end if diff --git a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownB.f90 b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownB.f90 index 3847a2e..c8bc985 100644 --- a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownB.f90 +++ b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownB.f90 @@ -1,10 +1,10 @@ subroutine TD_ForceDownB(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -12,22 +12,22 @@ subroutine TD_ForceDownB(i,TD_SemiMudVisc) Real(8) :: TD_SemiMudVisc If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(1)%Force2 = (TD_DrillStems(1)%Force1 * exp(-(TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))) - & - (TD_DrillStems(1)%WeightperLength * TD_DrillStems(1)%RCurvature * & - (sin(TD_DrillStems(1)%EndAngle) - (exp(-(TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef) * & - (TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle)) * & - sin(TD_DrillStems(1)%StartAngle)))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(1)%Force2 = (data%State%TD_DrillStems(1)%Force1 * exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))) - & + (data%State%TD_DrillStems(1)%WeightperLength * data%State%TD_DrillStems(1)%RCurvature * & + (sin(data%State%TD_DrillStems(1)%EndAngle) - (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef) * & + (data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle)) * & + sin(data%State%TD_DrillStems(1)%StartAngle)))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = (TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) + & - (2.0d0 * TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) + & + (2.0d0 * TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) end if @@ -38,15 +38,15 @@ subroutine TD_ForceDownB(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = (TD_DrillStems(i)%Force1 * exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) - & - (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (sin(TD_DrillStems(i)%EndAngle) - (exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef) * & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) * & - sin(TD_DrillStems(i)%StartAngle)))) + data%State%TD_DrillStems(i)%Force2 = (data%State%TD_DrillStems(i)%Force1 * exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) - & + (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (sin(data%State%TD_DrillStems(i)%EndAngle) - (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef) * & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) * & + sin(data%State%TD_DrillStems(i)%StartAngle)))) @@ -55,11 +55,11 @@ subroutine TD_ForceDownB(i,TD_SemiMudVisc) ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = (TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) + & - (2.0d0 * TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) + & + (2.0d0 * TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) end subroutine \ No newline at end of file diff --git a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownBRot.f90 b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownBRot.f90 index bd84b60..73f537a 100644 --- a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownBRot.f90 +++ b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceDownBRot.f90 @@ -1,10 +1,10 @@ subroutine TD_ForceDownBRot(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -13,20 +13,20 @@ subroutine TD_ForceDownBRot(i,TD_SemiMudVisc) If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(1)%Force2 = TD_DrillStems(1)%Force1 + (TD_DrillStems(1)%Force1 * & - (exp(-(TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*abs(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(1)%CombVelRatio )) + (TD_DrillStems(1)%BouyancyFactor * & - TD_DrillStems(1)%WeightperLength * TD_DrillStems(1)%Length * & - ((sin(TD_DrillStems(1)%EndAngle)-sin(TD_DrillStems(1)%StartAngle))/ & - (TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(1)%Force2 = data%State%TD_DrillStems(1)%Force1 + (data%State%TD_DrillStems(1)%Force1 * & + (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(1)%CombVelRatio )) + (data%State%TD_DrillStems(1)%BouyancyFactor * & + data%State%TD_DrillStems(1)%WeightperLength * data%State%TD_DrillStems(1)%Length * & + ((sin(data%State%TD_DrillStems(1)%EndAngle)-sin(data%State%TD_DrillStems(1)%StartAngle))/ & + (data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end if @@ -35,22 +35,22 @@ subroutine TD_ForceDownBRot(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%Force1 * & - (exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(i)%CombVelRatio )) + (TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - ((sin(TD_DrillStems(i)%EndAngle)-sin(TD_DrillStems(i)%StartAngle))/ & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%Force1 * & + (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(i)%CombVelRatio )) + (data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + ((sin(data%State%TD_DrillStems(i)%EndAngle)-sin(data%State%TD_DrillStems(i)%StartAngle))/ & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) ! !Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end subroutine \ No newline at end of file diff --git a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpB.f90 b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpB.f90 index 0e800c9..9656a1f 100644 --- a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpB.f90 +++ b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpB.f90 @@ -1,10 +1,10 @@ subroutine TD_ForceUpB(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -12,25 +12,25 @@ subroutine TD_ForceUpB(i,TD_SemiMudVisc) Real(8) :: TD_SemiMudVisc If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(1)%Force2 = (TD_DrillStems(1)%Force1 * exp((TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))) - & - (((TD_DrillStems(1)%WeightperLength * TD_DrillStems(1)%RCurvature) / (1 + (TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)**2)) * & - (((1-(TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)**2)*(sin(TD_DrillStems(1)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle)) * sin(TD_DrillStems(1)%StartAngle))))) - & - (2.0d0* (TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*(cos(TD_DrillStems(1)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))* & - cos(TD_DrillStems(1)%StartAngle))))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(1)%Force2 = (data%State%TD_DrillStems(1)%Force1 * exp((TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))) - & + (((data%State%TD_DrillStems(1)%WeightperLength * data%State%TD_DrillStems(1)%RCurvature) / (1 + (TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)**2)) * & + (((1-(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)**2)*(sin(data%State%TD_DrillStems(1)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle)) * sin(data%State%TD_DrillStems(1)%StartAngle))))) - & + (2.0d0* (TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(cos(data%State%TD_DrillStems(1)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))* & + cos(data%State%TD_DrillStems(1)%StartAngle))))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = (TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) + & - (2.0d0 * TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) + & + (2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) end if @@ -40,35 +40,35 @@ subroutine TD_ForceUpB(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = (TD_DrillStems(i)%Force1 * exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) - & - (((TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature) / (1 + (TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)**2)) * & - (((1-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)**2)*(sin(TD_DrillStems(i)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) * sin(TD_DrillStems(i)%StartAngle))))) - & - (2.0d0* (TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(cos(TD_DrillStems(i)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))* & - cos(TD_DrillStems(i)%StartAngle))))) + data%State%TD_DrillStems(i)%Force2 = (data%State%TD_DrillStems(i)%Force1 * exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) - & + (((data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature) / (1 + (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)) * & + (((1-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)*(sin(data%State%TD_DrillStems(i)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) * sin(data%State%TD_DrillStems(i)%StartAngle))))) - & + (2.0d0* (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(cos(data%State%TD_DrillStems(i)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))* & + cos(data%State%TD_DrillStems(i)%StartAngle))))) ! ! Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length ) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = (TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) + & - (2.0d0 * TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) + & + (2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) - !!if (TD_DrillStems(i)%Torque>500.) then - ! print* , 'TD_String%TotalTorqueb=' , i , TD_String%TotalTorque , TD_DrillStems(i)%Torque , TD_String%WeightOnBit , sin(30.) , sin(3.14/6.) - ! print* , 'torquepropertiesb=' , TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint , (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - ! TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) , abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle), & - ! 2.0d0 * TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * & - ! TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature , (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle)) - ! print* , 'propertiesb=' , TD_DrillStems(i)%Force2 , TD_DrillStems(i)%Force1 , TD_DrillStems(i)%MudViscosity , TD_DrillStems(i)%EndAngle , TD_DrillStems(i)%StartAngle , TD_DrillStems(i)%WeightperLength , TD_DrillStems(i)%MudVisCorrectCoef , TD_DrillStems(i)%RCurvature + !!if (data%State%TD_DrillStems(i)%Torque>500.) then + ! print* , 'data%State%TD_String%TotalTorqueb=' , i , data%State%TD_String%TotalTorque , data%State%TD_DrillStems(i)%Torque , data%State%TD_String%WeightOnBit , sin(30.) , sin(3.14/6.) + ! print* , 'torquepropertiesb=' , data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint , (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + ! data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) , abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle), & + ! 2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * & + ! data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature , (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle)) + ! print* , 'propertiesb=' , data%State%TD_DrillStems(i)%Force2 , data%State%TD_DrillStems(i)%Force1 , data%State%TD_DrillStems(i)%MudViscosity , data%State%TD_DrillStems(i)%EndAngle , data%State%TD_DrillStems(i)%StartAngle , data%State%TD_DrillStems(i)%WeightperLength , data%State%TD_DrillStems(i)%MudVisCorrectCoef , data%State%TD_DrillStems(i)%RCurvature ! !end if diff --git a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpBRot.f90 b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpBRot.f90 index 4c7d03f..5352b53 100644 --- a/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpBRot.f90 +++ b/TorqueDrag/TD_Forces/TD_BuildArea/TD_ForceUpBRot.f90 @@ -1,10 +1,10 @@ subroutine TD_ForceUpBRot(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -13,20 +13,20 @@ subroutine TD_ForceUpBRot(i,TD_SemiMudVisc) If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(1)%Force2 = TD_DrillStems(1)%Force1 + (TD_DrillStems(1)%Force1 * & - (exp(+(TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*abs(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(1)%CombVelRatio )) + (TD_DrillStems(1)%BouyancyFactor * & - TD_DrillStems(1)%WeightperLength * TD_DrillStems(1)%Length * & - ((sin(TD_DrillStems(1)%EndAngle)-sin(TD_DrillStems(1)%StartAngle))/ & - (TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(1)%Force2 = data%State%TD_DrillStems(1)%Force1 + (data%State%TD_DrillStems(1)%Force1 * & + (exp(+(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(1)%CombVelRatio )) + (data%State%TD_DrillStems(1)%BouyancyFactor * & + data%State%TD_DrillStems(1)%WeightperLength * data%State%TD_DrillStems(1)%Length * & + ((sin(data%State%TD_DrillStems(1)%EndAngle)-sin(data%State%TD_DrillStems(1)%StartAngle))/ & + (data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end if @@ -35,22 +35,22 @@ subroutine TD_ForceUpBRot(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%Force1 * & - (exp(+(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(i)%CombVelRatio )) + (TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - ((sin(TD_DrillStems(i)%EndAngle)-sin(TD_DrillStems(i)%StartAngle))/ & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%Force1 * & + (exp(+(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(i)%CombVelRatio )) + (data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + ((sin(data%State%TD_DrillStems(i)%EndAngle)-sin(data%State%TD_DrillStems(i)%StartAngle))/ & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) ! !Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end subroutine \ No newline at end of file diff --git a/TorqueDrag/TD_Forces/TD_CombinedMotionData.f90 b/TorqueDrag/TD_Forces/TD_CombinedMotionData.f90 index d5aeb42..c8f2e1b 100644 --- a/TorqueDrag/TD_Forces/TD_CombinedMotionData.f90 +++ b/TorqueDrag/TD_Forces/TD_CombinedMotionData.f90 @@ -1,9 +1,9 @@ subroutine TD_CombinedMotionData (i) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -12,7 +12,7 @@ subroutine TD_CombinedMotionData (i) - TD_DrillStems(i)%CombVelRatio = atan( TD_String%DrillStemAxialVelocity/TD_String%DrillStemRotVelocity ) + data%State%TD_DrillStems(i)%CombVelRatio = atan( data%State%TD_String%DrillStemAxialVelocity/data%State%TD_String%DrillStemRotVelocity ) diff --git a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownD.f90 b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownD.f90 index 59b7b40..01dca98 100644 --- a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownD.f90 +++ b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownD.f90 @@ -1,10 +1,10 @@ subroutine TD_ForceDownD(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -13,23 +13,23 @@ subroutine TD_ForceDownD(i,TD_SemiMudVisc) If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(i)%Force2 = (TD_DrillStems(i)%Force1 * exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + & - (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (sin(TD_DrillStems(i)%EndAngle) - (exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef) * & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) * & - sin(TD_DrillStems(i)%StartAngle)))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(i)%Force2 = (data%State%TD_DrillStems(i)%Force1 * exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) + & + (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (sin(data%State%TD_DrillStems(i)%EndAngle) - (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef) * & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) * & + sin(data%State%TD_DrillStems(i)%StartAngle)))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = (TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) - & - (2.0d0 * TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) - & + (2.0d0 * TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) end if @@ -38,24 +38,24 @@ subroutine TD_ForceDownD(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = (TD_DrillStems(i)%Force1 * exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + & - (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (sin(TD_DrillStems(i)%EndAngle) - (exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef) * & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) * & - sin(TD_DrillStems(i)%StartAngle)))) + data%State%TD_DrillStems(i)%Force2 = (data%State%TD_DrillStems(i)%Force1 * exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) + & + (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (sin(data%State%TD_DrillStems(i)%EndAngle) - (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef) * & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) * & + sin(data%State%TD_DrillStems(i)%StartAngle)))) ! ! Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length ) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = (TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) - & - (2.0d0 * TD_SemiMudVisc * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) - & + (2.0d0 * TD_SemiMudVisc * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) end subroutine \ No newline at end of file diff --git a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownDRot.f90 b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownDRot.f90 index d3d0e05..458e582 100644 --- a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownDRot.f90 +++ b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceDownDRot.f90 @@ -1,10 +1,10 @@ subroutine TD_ForceDownDRot(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -13,20 +13,20 @@ subroutine TD_ForceDownDRot(i,TD_SemiMudVisc) If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(1)%Force2 = TD_DrillStems(1)%Force1 + (TD_DrillStems(1)%Force1 * & - (exp(-(TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*abs(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(1)%CombVelRatio )) + (TD_DrillStems(1)%BouyancyFactor * & - TD_DrillStems(1)%WeightperLength * TD_DrillStems(1)%Length * & - ((sin(TD_DrillStems(1)%EndAngle)-sin(TD_DrillStems(1)%StartAngle))/ & - (TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(1)%Force2 = data%State%TD_DrillStems(1)%Force1 + (data%State%TD_DrillStems(1)%Force1 * & + (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(1)%CombVelRatio )) + (data%State%TD_DrillStems(1)%BouyancyFactor * & + data%State%TD_DrillStems(1)%WeightperLength * data%State%TD_DrillStems(1)%Length * & + ((sin(data%State%TD_DrillStems(1)%EndAngle)-sin(data%State%TD_DrillStems(1)%StartAngle))/ & + (data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end if @@ -35,22 +35,22 @@ subroutine TD_ForceDownDRot(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%Force1 * & - (exp(-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(i)%CombVelRatio )) + (TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - ((sin(TD_DrillStems(i)%EndAngle)-sin(TD_DrillStems(i)%StartAngle))/ & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%Force1 * & + (exp(-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(i)%CombVelRatio )) + (data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + ((sin(data%State%TD_DrillStems(i)%EndAngle)-sin(data%State%TD_DrillStems(i)%StartAngle))/ & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) ! !Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end subroutine \ No newline at end of file diff --git a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpD.f90 b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpD.f90 index efda4f6..3cf15c8 100644 --- a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpD.f90 +++ b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpD.f90 @@ -1,9 +1,10 @@ subroutine TD_ForceUpD(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -13,25 +14,25 @@ subroutine TD_ForceUpD(i,TD_SemiMudVisc) If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(i)%Force2 = (TD_DrillStems(i)%Force1 * exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + & - (((TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature) / (1 + (TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)**2)) * & - (((1-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)**2)*(sin(TD_DrillStems(i)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) * sin(TD_DrillStems(i)%StartAngle))))) - & - (2.0d0* (TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(cos(TD_DrillStems(i)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))* & - cos(TD_DrillStems(i)%StartAngle))))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(i)%Force2 = (data%State%TD_DrillStems(i)%Force1 * exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) + & + (((data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature) / (1 + (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)) * & + (((1-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)*(sin(data%State%TD_DrillStems(i)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) * sin(data%State%TD_DrillStems(i)%StartAngle))))) - & + (2.0d0* (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(cos(data%State%TD_DrillStems(i)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))* & + cos(data%State%TD_DrillStems(i)%StartAngle))))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = (TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) - & - (2.0d0 * TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) - & + (2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) end if @@ -42,27 +43,27 @@ subroutine TD_ForceUpD(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = (TD_DrillStems(i)%Force1 * exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + & - (((TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature) / (1 + (TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)**2)) * & - (((1-(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)**2)*(sin(TD_DrillStems(i)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) * sin(TD_DrillStems(i)%StartAngle))))) - & - (2.0d0* (TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(cos(TD_DrillStems(i)%EndAngle) - & - (exp((TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))* & - cos(TD_DrillStems(i)%StartAngle))))) + data%State%TD_DrillStems(i)%Force2 = (data%State%TD_DrillStems(i)%Force1 * exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) + & + (((data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature) / (1 + (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)) * & + (((1-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)*(sin(data%State%TD_DrillStems(i)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) * sin(data%State%TD_DrillStems(i)%StartAngle))))) - & + (2.0d0* (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(cos(data%State%TD_DrillStems(i)%EndAngle) - & + (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))* & + cos(data%State%TD_DrillStems(i)%StartAngle))))) !Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = (TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * (TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * & - TD_DrillStems(i)%RCurvature * sin(TD_DrillStems(i)%StartAngle))) * & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)) - & - (2.0d0 * TD_DrillStems(i)%MudViscosity * TD_DrillStems(i)%RtoolJoint * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (cos(TD_DrillStems(i)%EndAngle) - cos(TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Torque = (data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * & + data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) - & + (2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))) !return end subroutine \ No newline at end of file diff --git a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpDRot.f90 b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpDRot.f90 index deb9d90..32977fc 100644 --- a/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpDRot.f90 +++ b/TorqueDrag/TD_Forces/TD_DropArea/TD_ForceUpDRot.f90 @@ -1,10 +1,10 @@ subroutine TD_ForceUpDRot(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables implicit none @@ -12,20 +12,20 @@ subroutine TD_ForceUpDRot(i,TD_SemiMudVisc) Real(8) :: TD_SemiMudVisc If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(1)%Force2 = TD_DrillStems(1)%Force1 + (TD_DrillStems(1)%Force1 * & - (exp(+(TD_SemiMudVisc*TD_DrillStems(1)%MudVisCorrectCoef)*abs(TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(1)%CombVelRatio )) + (TD_DrillStems(1)%BouyancyFactor * & - TD_DrillStems(1)%WeightperLength * TD_DrillStems(1)%Length * & - ((sin(TD_DrillStems(1)%EndAngle)-sin(TD_DrillStems(1)%StartAngle))/ & - (TD_DrillStems(1)%EndAngle-TD_DrillStems(1)%StartAngle))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(1)%Force2 = data%State%TD_DrillStems(1)%Force1 + (data%State%TD_DrillStems(1)%Force1 * & + (exp(+(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(1)%CombVelRatio )) + (data%State%TD_DrillStems(1)%BouyancyFactor * & + data%State%TD_DrillStems(1)%WeightperLength * data%State%TD_DrillStems(1)%Length * & + ((sin(data%State%TD_DrillStems(1)%EndAngle)-sin(data%State%TD_DrillStems(1)%StartAngle))/ & + (data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end if @@ -34,22 +34,22 @@ subroutine TD_ForceUpDRot(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%Force1 * & - (exp(+(TD_SemiMudVisc*TD_DrillStems(i)%MudVisCorrectCoef)*abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))-1.0d0) * & - sin(TD_DrillStems(i)%CombVelRatio )) + (TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - ((sin(TD_DrillStems(i)%EndAngle)-sin(TD_DrillStems(i)%StartAngle))/ & - (TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle))) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%Force1 * & + (exp(+(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))-1.0d0) * & + sin(data%State%TD_DrillStems(i)%CombVelRatio )) + (data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + ((sin(data%State%TD_DrillStems(i)%EndAngle)-sin(data%State%TD_DrillStems(i)%StartAngle))/ & + (data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) ! !Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = TD_SemiMudVisc*TD_DrillStems(i)%RtoolJoint*TD_DrillStems(i)%Force1* & - abs(TD_DrillStems(i)%EndAngle-TD_DrillStems(i)%StartAngle)*cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc*data%State%TD_DrillStems(i)%RtoolJoint*data%State%TD_DrillStems(i)%Force1* & + abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)*cos(data%State%TD_DrillStems(i)%CombVelRatio) end subroutine \ No newline at end of file diff --git a/TorqueDrag/TD_Forces/TD_ForceCalculation.f90 b/TorqueDrag/TD_Forces/TD_ForceCalculation.f90 index 9d4dd8f..ae08227 100644 --- a/TorqueDrag/TD_Forces/TD_ForceCalculation.f90 +++ b/TorqueDrag/TD_Forces/TD_ForceCalculation.f90 @@ -1,9 +1,9 @@ subroutine TD_ForceCalculation Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -14,75 +14,75 @@ subroutine TD_ForceCalculation - if (TD_String%DrillStemForceType == 1) then + if (data%State%TD_String%DrillStemForceType == 1) then - Do i = 1 , TD_String%DrillStemComponentsNumbs - TD_SemiMudVisc = TD_DrillStems(i)%MudViscosity - if (TD_DrillStems(i)%HoleType == 0) then + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs + TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity + if (data%State%TD_DrillStems(i)%HoleType == 0) then Call TD_ForceUpS(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 1) then + else if (data%State%TD_DrillStems(i)%HoleType == 1) then Call TD_ForceUpB(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 2) then + else if (data%State%TD_DrillStems(i)%HoleType == 2) then Call TD_ForceUpD(i,TD_SemiMudVisc) end if Call TD_StrainCalculation(i) Call TD_TorqueCalculation(i) End Do - else if (TD_String%DrillStemForceType == 2) then + else if (data%State%TD_String%DrillStemForceType == 2) then - Do i = 1 , TD_String%DrillStemComponentsNumbs - TD_SemiMudVisc = TD_DrillStems(i)%MudViscosity - if (TD_DrillStems(i)%HoleType == 0) then + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs + TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity + if (data%State%TD_DrillStems(i)%HoleType == 0) then Call TD_ForceUpSRot(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 1) then + else if (data%State%TD_DrillStems(i)%HoleType == 1) then Call TD_ForceUpBRot(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 2) then + else if (data%State%TD_DrillStems(i)%HoleType == 2) then Call TD_ForceUpDRot(i,TD_SemiMudVisc) end if Call TD_StrainCalculation(i) Call TD_TorqueCalculation(i) End Do - else if (TD_String%DrillStemForceType == 3) then + else if (data%State%TD_String%DrillStemForceType == 3) then - Do i = 1 , TD_String%DrillStemComponentsNumbs - TD_SemiMudVisc = TD_DrillStems(i)%MudViscosity - if (TD_DrillStems(i)%HoleType == 0) then + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs + TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity + if (data%State%TD_DrillStems(i)%HoleType == 0) then Call TD_ForceDownS(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 1) then + else if (data%State%TD_DrillStems(i)%HoleType == 1) then Call TD_ForceDownB(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 2) then + else if (data%State%TD_DrillStems(i)%HoleType == 2) then Call TD_ForceDownD(i,TD_SemiMudVisc) end if Call TD_StrainCalculation(i) Call TD_TorqueCalculation(i) End Do - else if (TD_String%DrillStemForceType == 4) then + else if (data%State%TD_String%DrillStemForceType == 4) then - Do i = 1 , TD_String%DrillStemComponentsNumbs - TD_SemiMudVisc = TD_DrillStems(i)%MudViscosity - if (TD_DrillStems(i)%HoleType == 0) then + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs + TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity + if (data%State%TD_DrillStems(i)%HoleType == 0) then Call TD_ForceDownSRot(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 1) then + else if (data%State%TD_DrillStems(i)%HoleType == 1) then Call TD_ForceDownBRot(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 2) then + else if (data%State%TD_DrillStems(i)%HoleType == 2) then Call TD_ForceDownDRot(i,TD_SemiMudVisc) end if Call TD_StrainCalculation(i) Call TD_TorqueCalculation(i) End Do - else if (TD_String%DrillStemForceType == 5) then + else if (data%State%TD_String%DrillStemForceType == 5) then - Do i = 1 , TD_String%DrillStemComponentsNumbs + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs TD_SemiMudVisc = 0.0d0 - if (TD_DrillStems(i)%HoleType == 0) then + if (data%State%TD_DrillStems(i)%HoleType == 0) then Call TD_ForceUpS(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 1) then + else if (data%State%TD_DrillStems(i)%HoleType == 1) then Call TD_ForceUpB(i,TD_SemiMudVisc) - else if (TD_DrillStems(i)%HoleType == 2) then + else if (data%State%TD_DrillStems(i)%HoleType == 2) then Call TD_ForceUpD(i,TD_SemiMudVisc) end if Call TD_StrainCalculation(i) @@ -95,43 +95,43 @@ subroutine TD_ForceCalculation !----------------------------------------------------------------------------------- ! - !if (TD_String%DrillStemAxialVelocity>0.) then + !if (data%State%TD_String%DrillStemAxialVelocity>0.) then ! ! i = 1 - ! TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 - TD_DrillStems(i)%Drag - ! TD_DrillStems(i)%Dl = TD_DrillStems(i)%Force2 * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - ! TD_DrillStems(i)%DlTotal = TD_DrillStems(i)%Dl + ! data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 - data%State%TD_DrillStems(i)%Drag + ! data%State%TD_DrillStems(i)%Dl = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + ! data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i)%Dl ! - ! do i = 2 , TD_String%DrillStemComponentsNumbs - ! TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 - TD_DrillStems(i)%Drag - ! TD_DrillStems(i)%Dl = TD_DrillStems(i)%Force2 * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - ! TD_DrillStems(i)%DlTotal = TD_DrillStems(i-1)%DlTotal + TD_DrillStems(i)%Dl + ! do i = 2 , data%State%TD_String%DrillStemComponentsNumbs + ! data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 - data%State%TD_DrillStems(i)%Drag + ! data%State%TD_DrillStems(i)%Dl = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + ! data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i-1)%DlTotal + data%State%TD_DrillStems(i)%Dl ! end do ! !print*, 'i=' ,i - ! !print*, 'TD_String%DrillStemComponentsNumbs=' ,TD_String%DrillStemComponentsNumbs + ! !print*, 'data%State%TD_String%DrillStemComponentsNumbs=' ,data%State%TD_String%DrillStemComponentsNumbs ! - !else if (TD_String%DrillStemAxialVelocity<0.) then + !else if (data%State%TD_String%DrillStemAxialVelocity<0.) then ! i = 1 - ! TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 + TD_DrillStems(i)%Drag - ! TD_DrillStems(i)%Dl = TD_DrillStems(i)%Force2 * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - ! TD_DrillStems(i)%DlTotal = TD_DrillStems(i)%Dl + ! data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 + data%State%TD_DrillStems(i)%Drag + ! data%State%TD_DrillStems(i)%Dl = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + ! data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i)%Dl ! - ! do i = 2 , TD_String%DrillStemComponentsNumbs - ! TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 + TD_DrillStems(i)%Drag - ! TD_DrillStems(i)%Dl = TD_DrillStems(i)%Force2 * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - ! TD_DrillStems(i)%DlTotal = TD_DrillStems(i-1)%DlTotal + TD_DrillStems(i)%Dl + ! do i = 2 , data%State%TD_String%DrillStemComponentsNumbs + ! data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 + data%State%TD_DrillStems(i)%Drag + ! data%State%TD_DrillStems(i)%Dl = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + ! data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i-1)%DlTotal + data%State%TD_DrillStems(i)%Dl ! end do !end if - TD_String%DlTotal = TD_DrillStems(TD_String%DrillStemComponentsNumbs)%DlTotal + data%State%TD_String%DlTotal = data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%DlTotal !!=====> Modified Length of the Drill Stem -! do i = 1 , TD_String%DrillStemComponentsNumbs -! TD_DrillStems(i)%Length = TD_DrillStems(i)%Length + TD_DrillStems(i)%Dl +! do i = 1 , data%State%TD_String%DrillStemComponentsNumbs +! data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(i)%Length + data%State%TD_DrillStems(i)%Dl ! end do diff --git a/TorqueDrag/TD_Forces/TD_HookLoadCalculation.f90 b/TorqueDrag/TD_Forces/TD_HookLoadCalculation.f90 index 05e76ac..13d685c 100644 --- a/TorqueDrag/TD_Forces/TD_HookLoadCalculation.f90 +++ b/TorqueDrag/TD_Forces/TD_HookLoadCalculation.f90 @@ -1,17 +1,20 @@ subroutine TD_HookLoadCalculation Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData - Use Drawworks_VARIABLES, only: Drawworks - Use CDataDisplayConsoleVariables - Use CHoistingVariables + use ConfigurationVariables !@, only: Drawworks + use CDataDisplayConsole + use ConfigurationVariables + use CHoistingVariables + use ConfigurationVariables ! Use CSlipsEnumVariables use UnitySignalVariables + use UnitySignalsModule Use CBopStackVariables - Use VARIABLES + use ConfigurationVariables Use CUnityInputs @@ -28,69 +31,69 @@ subroutine TD_HookLoadCalculation !==================================================== !=========> HookLoad - TD_String%HookLoad = TD_DrillStems(TD_String%DrillStemComponentsNumbs)%Force2 ! [lb] - !print* , 'TD_String%HookLoad1=' , TD_String%HookLoad + data%State%TD_String%HookLoad = data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%Force2 ! [lb] + !print* , 'data%State%TD_String%HookLoad1=' , data%State%TD_String%HookLoad - if ( Drawworks%motion==1 ) then - if ( PipeRam1%Situation_forTD==1 ) then !Upper Ram - TD_String%HookLoad = TD_String%HookLoad+BopStackSpecification%RamStringDrag + if ( data%State%Drawworks%motion==1 ) then + if ( data%State%PipeRam1%Situation_forTD==1 ) then !Upper Ram + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+BopStackSpecification%RamStringDrag end if - if ( PipeRam2%Situation_forTD==1 ) then !Lower Ram - TD_String%HookLoad = TD_String%HookLoad+BopStackSpecification%RamStringDrag + if ( data%State%PipeRam2%Situation_forTD==1 ) then !Lower Ram + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+BopStackSpecification%RamStringDrag end if - if ( RamLine%ShearBop_Situation_forTD==1 ) then !Blind Ram - TD_String%HookLoad = TD_String%HookLoad+BopStackSpecification%RamStringDrag !???????????????????? + if ( data%State%RamLine%ShearBop_Situation_forTD==1 ) then !Blind Ram + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+BopStackSpecification%RamStringDrag !???????????????????? end if - if ( Annular%Annular_Situation_forTD==1 ) then !Annular Preventer - TD_String%HookLoad = TD_String%HookLoad+(AnnularComputational%p_annular*BopStackSpecification%AnnularStringDrag) + if ( data%State%Annular%Annular_Situation_forTD==1 ) then !Annular Preventer + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+(data%State%AnnularComputational%p_annular*BopStackSpecification%AnnularStringDrag) end if - else if ( Drawworks%motion==-1 ) then - if ( PipeRam1%Situation_forTD==1 ) then !Upper Ram - TD_String%HookLoad = TD_String%HookLoad-BopStackSpecification%RamStringDrag + else if ( data%State%Drawworks%motion==-1 ) then + if ( data%State%PipeRam1%Situation_forTD==1 ) then !Upper Ram + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-BopStackSpecification%RamStringDrag end if - if ( PipeRam2%Situation_forTD==1 ) then !Lower Ram - TD_String%HookLoad = TD_String%HookLoad-BopStackSpecification%RamStringDrag + if ( data%State%PipeRam2%Situation_forTD==1 ) then !Lower Ram + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-BopStackSpecification%RamStringDrag end if - if ( RamLine%ShearBop_Situation_forTD==1 ) then !Blind Ram - TD_String%HookLoad = TD_String%HookLoad-BopStackSpecification%RamStringDrag !???????????????????? + if ( data%State%RamLine%ShearBop_Situation_forTD==1 ) then !Blind Ram + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-BopStackSpecification%RamStringDrag !???????????????????? end if - if ( Annular%Annular_Situation_forTD==1 ) then !Annular Preventer - TD_String%HookLoad = TD_String%HookLoad-(AnnularComputational%p_annular*BopStackSpecification%AnnularStringDrag) + if ( data%State%Annular%Annular_Situation_forTD==1 ) then !Annular Preventer + data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-(data%State%AnnularComputational%p_annular*BopStackSpecification%AnnularStringDrag) end if end if - !print* , 'TD_String%HookLoad2=' , TD_String%HookLoad + !print* , 'data%State%TD_String%HookLoad2=' , data%State%TD_String%HookLoad !if ( UpperRamClose_withPossibility==1 ) then - ! if ( Drawworks%motion==1 ) then - ! TD_String%HookLoad = TD_String%HookLoad+RamStringDrag - ! else if ( Drawworks%motion==-1 ) then - ! TD_String%HookLoad = TD_String%HookLoad-RamStringDrag + ! if ( data%State%Drawworks%motion==1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+RamStringDrag + ! else if ( data%State%Drawworks%motion==-1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-RamStringDrag ! end if !end if !if ( LowerRamClose_withPossibility==1 ) then - ! if ( Drawworks%motion==1 ) then - ! TD_String%HookLoad = TD_String%HookLoad+RamStringDrag - ! else if ( Drawworks%motion==-1 ) then - ! TD_String%HookLoad = TD_String%HookLoad-RamStringDrag + ! if ( data%State%Drawworks%motion==1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+RamStringDrag + ! else if ( data%State%Drawworks%motion==-1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-RamStringDrag ! end if !end if !if ( BlindRamClose_withPossibility==1 ) then - ! if ( Drawworks%motion==1 ) then - ! TD_String%HookLoad = TD_String%HookLoad+RamStringDrag - ! else if ( Drawworks%motion==-1 ) then - ! TD_String%HookLoad = TD_String%HookLoad-RamStringDrag + ! if ( data%State%Drawworks%motion==1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+RamStringDrag + ! else if ( data%State%Drawworks%motion==-1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-RamStringDrag ! end if !end if !if ( AnnularPreventerClose_withPossibility==1 ) then - ! if ( Drawworks%motion==1 ) then - ! TD_String%HookLoad = TD_String%HookLoad+AnnularStringDrag - ! else if ( Drawworks%motion==-1 ) then - ! TD_String%HookLoad = TD_String%HookLoad-AnnularStringDrag + ! if ( data%State%Drawworks%motion==1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad+AnnularStringDrag + ! else if ( data%State%Drawworks%motion==-1 ) then + ! data%State%TD_String%HookLoad = data%State%TD_String%HookLoad-AnnularStringDrag ! end if !end if @@ -102,8 +105,8 @@ subroutine TD_HookLoadCalculation !=========> Torque - TD_String%StringTorque = TD_String%TotalTorque ![lb.ft] ?????????? - !print* , 'TD_String%StringTorque=' , TD_String%StringTorque + data%State%TD_String%StringTorque = data%State%TD_String%TotalTorque ![lb.ft] ?????????? + !print* , 'data%State%TD_String%StringTorque=' , data%State%TD_String%StringTorque @@ -114,8 +117,8 @@ subroutine TD_HookLoadCalculation !==================================================== kk = 0 - Do i = TD_String%DrillStemComponentsNumbs , 1 , -1 - if (TD_DrillStems(i)%ComponentType==3) then + Do i = data%State%TD_String%DrillStemComponentsNumbs , 1 , -1 + if (data%State%TD_DrillStems(i)%ComponentType==3) then kk = i exit end if @@ -125,108 +128,108 @@ subroutine TD_HookLoadCalculation - if ( TD_StConn%KellyDriveTypeMode==0 ) then + if ( data%State%TD_StConn%KellyDriveTypeMode==0 ) then - if ( TD_StConn%StringConnectionMode == 1 ) then + if ( data%State%TD_StConn%StringConnectionMode == 1 ) then if ( Get_Slips() == SLIPS_SET_END ) then - TD_SumWeight = TD_Load%WeightTB+TD_Load%KellyWeight + TD_SumWeight = data%State%TD_Load%WeightTB+data%State%TD_Load%KellyWeight else - TD_SumWeight = TD_String%HookLoad+TD_Load%WeightTB+TD_Load%KellyWeight ! TD_String%HookLoad = String Weight + TD_SumWeight = data%State%TD_String%HookLoad+data%State%TD_Load%WeightTB+data%State%TD_Load%KellyWeight ! data%State%TD_String%HookLoad = String Weight end if - else if ( TD_StConn%StringConnectionMode == 2 ) then + else if ( data%State%TD_StConn%StringConnectionMode == 2 ) then if ( Get_JointConnectionPossible() ) then - TD_SumWeight = TD_Load%WeightTB + TD_SumWeight = data%State%TD_Load%WeightTB else - TD_SumWeight = TD_Load%WeightTB+TD_Load%KellyWeight + TD_SumWeight = data%State%TD_Load%WeightTB+data%State%TD_Load%KellyWeight end if - else if ( TD_StConn%StringConnectionMode == 3 ) then + else if ( data%State%TD_StConn%StringConnectionMode == 3 ) then if ( Get_JointConnectionPossible() ) then - TD_SumWeight = TD_Load%WeightTB + TD_SumWeight = data%State%TD_Load%WeightTB else - TD_SumWeight = TD_Load%WeightTB+TD_Load%KellyWeight+TD_DrillStems(kk)%Weight + TD_SumWeight = data%State%TD_Load%WeightTB+data%State%TD_Load%KellyWeight+data%State%TD_DrillStems(kk)%Weight end if end if - else if ( TD_StConn%KellyDriveTypeMode==1 ) then + else if ( data%State%TD_StConn%KellyDriveTypeMode==1 ) then - if ( TD_StConn%StringConnectionMode == 4 ) then + if ( data%State%TD_StConn%StringConnectionMode == 4 ) then if ( Get_Slips() == SLIPS_SET_END ) then - TD_SumWeight = TD_Load%WeightTB + TD_SumWeight = data%State%TD_Load%WeightTB else - TD_SumWeight = TD_String%HookLoad+TD_Load%WeightTB + TD_SumWeight = data%State%TD_String%HookLoad+data%State%TD_Load%WeightTB end if - else if ( TD_StConn%StringConnectionMode == 5 ) then - TD_SumWeight = TD_Load%WeightTB + else if ( data%State%TD_StConn%StringConnectionMode == 5 ) then + TD_SumWeight = data%State%TD_Load%WeightTB - else if ( TD_StConn%StringConnectionMode == 6 ) then + else if ( data%State%TD_StConn%StringConnectionMode == 6 ) then if ( Get_JointConnectionPossible() ) then - TD_SumWeight = TD_Load%WeightTB + TD_SumWeight = data%State%TD_Load%WeightTB else - TD_SumWeight = TD_Load%WeightTB+(3.d0*TD_DrillStems(kk)%Weight) + TD_SumWeight = data%State%TD_Load%WeightTB+(3.d0*data%State%TD_DrillStems(kk)%Weight) end if - else if ( TD_StConn%StringConnectionMode == 7 ) then + else if ( data%State%TD_StConn%StringConnectionMode == 7 ) then if ( Get_JointConnectionPossible() ) then - TD_SumWeight = TD_Load%WeightTB + TD_SumWeight = data%State%TD_Load%WeightTB else - TD_SumWeight = TD_Load%WeightTB+TD_DrillStems(kk)%Weight + TD_SumWeight = data%State%TD_Load%WeightTB+data%State%TD_DrillStems(kk)%Weight end if - else if ( TD_StConn%StringConnectionMode == 8 ) then - TD_SumWeight = TD_Load%WeightTB + else if ( data%State%TD_StConn%StringConnectionMode == 8 ) then + TD_SumWeight = data%State%TD_Load%WeightTB - else if ( TD_StConn%StringConnectionMode == 18 ) then - TD_SumWeight = TD_Load%WeightTB + else if ( data%State%TD_StConn%StringConnectionMode == 18 ) then + TD_SumWeight = data%State%TD_Load%WeightTB - else if ( TD_StConn%StringConnectionMode == 19 ) then - TD_SumWeight = TD_Load%WeightTB + else if ( data%State%TD_StConn%StringConnectionMode == 19 ) then + TD_SumWeight = data%State%TD_Load%WeightTB end if - else if ( TD_StConn%KellyDriveTypeMode==2 ) then + else if ( data%State%TD_StConn%KellyDriveTypeMode==2 ) then - if ( TD_StConn%StringConnectionMode == 9 ) then + if ( data%State%TD_StConn%StringConnectionMode == 9 ) then if ( Get_Slips() == SLIPS_SET_END ) then - TD_SumWeight = TD_Load%WeightTD + TD_SumWeight = data%State%TD_Load%WeightTD else - TD_SumWeight = TD_String%HookLoad+TD_Load%WeightTD + TD_SumWeight = data%State%TD_String%HookLoad+data%State%TD_Load%WeightTD end if - else if ( TD_StConn%StringConnectionMode == 10 ) then + else if ( data%State%TD_StConn%StringConnectionMode == 10 ) then if ( Get_Slips() == SLIPS_SET_END ) then - TD_SumWeight = TD_Load%WeightTD + TD_SumWeight = data%State%TD_Load%WeightTD else - TD_SumWeight = TD_String%HookLoad+TD_Load%WeightTD + TD_SumWeight = data%State%TD_String%HookLoad+data%State%TD_Load%WeightTD end if - else if ( TD_StConn%StringConnectionMode == 11 ) then - TD_SumWeight = TD_Load%WeightTD + else if ( data%State%TD_StConn%StringConnectionMode == 11 ) then + TD_SumWeight = data%State%TD_Load%WeightTD - else if ( TD_StConn%StringConnectionMode == 12 ) then + else if ( data%State%TD_StConn%StringConnectionMode == 12 ) then if ( Get_Slips() == SLIPS_SET_END ) then - TD_SumWeight = TD_Load%WeightTD + TD_SumWeight = data%State%TD_Load%WeightTD else - TD_SumWeight = TD_String%HookLoad+TD_Load%WeightTD + TD_SumWeight = data%State%TD_String%HookLoad+data%State%TD_Load%WeightTD end if - else if ( TD_StConn%StringConnectionMode == 13 ) then - TD_SumWeight = TD_Load%WeightTD + else if ( data%State%TD_StConn%StringConnectionMode == 13 ) then + TD_SumWeight = data%State%TD_Load%WeightTD - else if ( TD_StConn%StringConnectionMode == 14 ) then - TD_SumWeight = TD_Load%WeightTD+(3.d0*TD_DrillStems(kk)%Weight) + else if ( data%State%TD_StConn%StringConnectionMode == 14 ) then + TD_SumWeight = data%State%TD_Load%WeightTD+(3.d0*data%State%TD_DrillStems(kk)%Weight) - else if ( TD_StConn%StringConnectionMode == 15 ) then - TD_SumWeight = TD_Load%WeightTD+(TD_DrillStems(kk)%Weight) + else if ( data%State%TD_StConn%StringConnectionMode == 15 ) then + TD_SumWeight = data%State%TD_Load%WeightTD+(data%State%TD_DrillStems(kk)%Weight) - else if ( TD_StConn%StringConnectionMode == 16 ) then - TD_SumWeight = TD_Load%WeightTD + else if ( data%State%TD_StConn%StringConnectionMode == 16 ) then + TD_SumWeight = data%State%TD_Load%WeightTD - else if ( TD_StConn%StringConnectionMode == 17 ) then - TD_SumWeight = TD_Load%WeightTD + else if ( data%State%TD_StConn%StringConnectionMode == 17 ) then + TD_SumWeight = data%State%TD_Load%WeightTD end if @@ -234,38 +237,38 @@ subroutine TD_HookLoadCalculation - !print* , 'TD_String%HookLoad3=' , TD_String%HookLoad + !print* , 'data%State%TD_String%HookLoad3=' , data%State%TD_String%HookLoad - !if ( Hoisting%DriveType==1 ) then !==> Kelly_DriveType + !if ( data%State%Hoisting%DriveType==1 ) then !==> Kelly_DriveType ! - ! if ( TD_String%DrillStemForceType==1 .or. TD_String%DrillStemForceType==2 ) then - ! TD_Load%WeightIndicator = ( sngl(TD_Load%NumOfCables)*(TD_eConst-1.d0)*(TD_SumWeight) )& - ! /( TD_eConst*(1.d0-(1.d0/(TD_eConst**TD_Load%NumOfCables))) ) - ! else if ( TD_String%DrillStemForceType==3 .or. TD_String%DrillStemForceType==4 ) then - ! TD_Load%WeightIndicator = ( sngl(TD_Load%NumOfCables)*(1.d0-TD_eConst)*(TD_SumWeight) )& - ! /( 1.d0-(TD_eConst**TD_Load%NumOfCables) ) - ! else if ( TD_String%DrillStemForceType==5 ) then - TD_Load%WeightIndicator = TD_SumWeight + ! if ( data%State%TD_String%DrillStemForceType==1 .or. data%State%TD_String%DrillStemForceType==2 ) then + ! data%State%TD_Load%WeightIndicator = ( sngl(data%State%TD_Load%NumOfCables)*(TD_eConst-1.d0)*(TD_SumWeight) )& + ! /( TD_eConst*(1.d0-(1.d0/(TD_eConst**data%State%TD_Load%NumOfCables))) ) + ! else if ( data%State%TD_String%DrillStemForceType==3 .or. data%State%TD_String%DrillStemForceType==4 ) then + ! data%State%TD_Load%WeightIndicator = ( sngl(data%State%TD_Load%NumOfCables)*(1.d0-TD_eConst)*(TD_SumWeight) )& + ! /( 1.d0-(TD_eConst**data%State%TD_Load%NumOfCables) ) + ! else if ( data%State%TD_String%DrillStemForceType==5 ) then + data%State%TD_Load%WeightIndicator = TD_SumWeight ! end if ! ! - !else if ( Hoisting%DriveType==0 ) then !==> TopDrive_DriveType ?????????????? + !else if ( data%State%Hoisting%DriveType==0 ) then !==> TopDrive_DriveType ?????????????? ! - ! if ( TD_String%DrillStemForceType==1 .or. TD_String%DrillStemForceType==2 ) then - ! TD_Load%WeightIndicator = ( sngl(TD_Load%NumOfCables)*(TD_eConst-1.d0)*(TD_SumWeight) )& - ! /( TD_eConst*(1.d0-(1.d0/(TD_eConst**TD_Load%NumOfCables))) ) - ! else if ( TD_String%DrillStemForceType==3 .or. TD_String%DrillStemForceType==4 ) then - ! TD_Load%WeightIndicator = ( sngl(TD_Load%NumOfCables)*(1.d0-TD_eConst)*(TD_SumWeight) )& - ! /( 1.d0-(TD_eConst**TD_Load%NumOfCables) ) - ! else if ( TD_String%DrillStemForceType==5 ) then - ! TD_Load%WeightIndicator = TD_SumWeight + ! if ( data%State%TD_String%DrillStemForceType==1 .or. data%State%TD_String%DrillStemForceType==2 ) then + ! data%State%TD_Load%WeightIndicator = ( sngl(data%State%TD_Load%NumOfCables)*(TD_eConst-1.d0)*(TD_SumWeight) )& + ! /( TD_eConst*(1.d0-(1.d0/(TD_eConst**data%State%TD_Load%NumOfCables))) ) + ! else if ( data%State%TD_String%DrillStemForceType==3 .or. data%State%TD_String%DrillStemForceType==4 ) then + ! data%State%TD_Load%WeightIndicator = ( sngl(data%State%TD_Load%NumOfCables)*(1.d0-TD_eConst)*(TD_SumWeight) )& + ! /( 1.d0-(TD_eConst**data%State%TD_Load%NumOfCables) ) + ! else if ( data%State%TD_String%DrillStemForceType==5 ) then + ! data%State%TD_Load%WeightIndicator = TD_SumWeight ! end if ! !!else - !!TD_Load%WeightIndicator = 0. !????????????????? + !!data%State%TD_Load%WeightIndicator = 0. !????????????????? ! !end if @@ -273,10 +276,10 @@ subroutine TD_HookLoadCalculation - TD_Load%DrawworksLoadInput = TD_Load%WeightIndicator/(sngl(TD_Load%NumOfCables)) ! [lb] - !print* , 'TD_String%HookLoad4=' , TD_String%HookLoad - !HookLoadPointer = TD_Load%WeightIndicator/1.0d3 ! [klb] - call Set_HookLoad ((1-TD_General%WeightIndicatorMalf)*AINT(TD_Load%WeightIndicator/1.0d3)) ! [klb] + data%State%TD_Load%DrawworksLoadInput = data%State%TD_Load%WeightIndicator/(sngl(data%State%TD_Load%NumOfCables)) ! [lb] + !print* , 'data%State%TD_String%HookLoad4=' , data%State%TD_String%HookLoad + !HookLoadPointer = data%State%TD_Load%WeightIndicator/1.0d3 ! [klb] + call Set_HookLoad ((1-data%State%TD_General%WeightIndicatorMalf)*AINT(data%State%TD_Load%WeightIndicator/1.0d3)) ! [klb] diff --git a/TorqueDrag/TD_Forces/TD_StaticHookLoadCalculation.f90 b/TorqueDrag/TD_Forces/TD_StaticHookLoadCalculation.f90 index 8202350..52071fe 100644 --- a/TorqueDrag/TD_Forces/TD_StaticHookLoadCalculation.f90 +++ b/TorqueDrag/TD_Forces/TD_StaticHookLoadCalculation.f90 @@ -1,9 +1,9 @@ subroutine TD_StaticHookLoadCalculation Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -15,34 +15,34 @@ subroutine TD_StaticHookLoadCalculation i = 1 - if(TD_DrillStems(i)%HoleType == 0) then - TD_DrillStems(i)%StaticHookLoad = TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - TD_DrillStems(i)%BouyancyFactor * cos(TD_DrillStems(i)%StartAngle) + if(data%State%TD_DrillStems(i)%HoleType == 0) then + data%State%TD_DrillStems(i)%StaticHookLoad = data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + data%State%TD_DrillStems(i)%BouyancyFactor * cos(data%State%TD_DrillStems(i)%StartAngle) - else if (TD_DrillStems(i)%HoleType == 1) then - TD_DrillStems(i)%StaticHookLoad = -(TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (sin(TD_DrillStems(i)%EndAngle) - sin(TD_DrillStems(i)%StartAngle))) + else if (data%State%TD_DrillStems(i)%HoleType == 1) then + data%State%TD_DrillStems(i)%StaticHookLoad = -(data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (sin(data%State%TD_DrillStems(i)%EndAngle) - sin(data%State%TD_DrillStems(i)%StartAngle))) - else if (TD_DrillStems(i)%HoleType == 2) then - TD_DrillStems(i)%StaticHookLoad = (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (sin(TD_DrillStems(i)%EndAngle) - sin(TD_DrillStems(i)%StartAngle))) + else if (data%State%TD_DrillStems(i)%HoleType == 2) then + data%State%TD_DrillStems(i)%StaticHookLoad = (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (sin(data%State%TD_DrillStems(i)%EndAngle) - sin(data%State%TD_DrillStems(i)%StartAngle))) end if - do i = 2, TD_String%DrillStemComponentsNumbs + do i = 2, data%State%TD_String%DrillStemComponentsNumbs - if(TD_DrillStems(i)%HoleType == 0) then - TD_DrillStems(i)%StaticHookLoad = TD_DrillStems(i-1)%StaticHookLoad + TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - TD_DrillStems(i)%BouyancyFactor * cos(TD_DrillStems(i)%StartAngle) + if(data%State%TD_DrillStems(i)%HoleType == 0) then + data%State%TD_DrillStems(i)%StaticHookLoad = data%State%TD_DrillStems(i-1)%StaticHookLoad + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + data%State%TD_DrillStems(i)%BouyancyFactor * cos(data%State%TD_DrillStems(i)%StartAngle) - else if (TD_DrillStems(i)%HoleType == 1) then - TD_DrillStems(i)%StaticHookLoad = TD_DrillStems(i-1)%StaticHookLoad -(TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (sin(TD_DrillStems(i)%EndAngle) - sin(TD_DrillStems(i)%StartAngle))) + else if (data%State%TD_DrillStems(i)%HoleType == 1) then + data%State%TD_DrillStems(i)%StaticHookLoad = data%State%TD_DrillStems(i-1)%StaticHookLoad -(data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (sin(data%State%TD_DrillStems(i)%EndAngle) - sin(data%State%TD_DrillStems(i)%StartAngle))) - else if (TD_DrillStems(i)%HoleType == 2) then - TD_DrillStems(i)%StaticHookLoad = TD_DrillStems(i-1)%StaticHookLoad +(TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%RCurvature * & - (sin(TD_DrillStems(i)%EndAngle) - sin(TD_DrillStems(i)%StartAngle))) + else if (data%State%TD_DrillStems(i)%HoleType == 2) then + data%State%TD_DrillStems(i)%StaticHookLoad = data%State%TD_DrillStems(i-1)%StaticHookLoad +(data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * & + (sin(data%State%TD_DrillStems(i)%EndAngle) - sin(data%State%TD_DrillStems(i)%StartAngle))) end if end do @@ -50,17 +50,17 @@ subroutine TD_StaticHookLoadCalculation !--------------------------------------------------------------------------------------------------- ! i = 1 - !TD_DrillStems(i)%TotalSHookLoad = TD_DrillStems(i)%StaticHookLoad ???????????????????????????? - TD_DrillStems(i)%Dl = TD_DrillStems(i)%StaticHookLoad * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - TD_DrillStems(i)%DlTotal = TD_DrillStems(i)%Dl - do i = 2 , TD_String%DrillStemComponentsNumbs - !TD_DrillStems(i)%TotalSHookLoad = TD_DrillStems(i-1)%TotalSHookLoad + TD_DrillStems(i)%StaticHookLoad ????????????????????????? - TD_DrillStems(i)%Dl = TD_DrillStems(i)%StaticHookLoad * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - TD_DrillStems(i)%DlTotal = TD_DrillStems(i-1)%DlTotal + TD_DrillStems(i)%Dl + !data%State%TD_DrillStems(i)%TotalSHookLoad = data%State%TD_DrillStems(i)%StaticHookLoad ???????????????????????????? + data%State%TD_DrillStems(i)%Dl = data%State%TD_DrillStems(i)%StaticHookLoad * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i)%Dl + do i = 2 , data%State%TD_String%DrillStemComponentsNumbs + !data%State%TD_DrillStems(i)%TotalSHookLoad = data%State%TD_DrillStems(i-1)%TotalSHookLoad + data%State%TD_DrillStems(i)%StaticHookLoad ????????????????????????? + data%State%TD_DrillStems(i)%Dl = data%State%TD_DrillStems(i)%StaticHookLoad * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i-1)%DlTotal + data%State%TD_DrillStems(i)%Dl end do - TD_String%StaticHookLoad = TD_DrillStems(TD_String%DrillStemComponentsNumbs)%StaticHookLoad - TD_String%DlMax = TD_DrillStems(TD_String%DrillStemComponentsNumbs)%DlTotal + data%State%TD_String%StaticHookLoad = data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%StaticHookLoad + data%State%TD_String%DlMax = data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%DlTotal diff --git a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownS.f90 b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownS.f90 index 0569663..ec97af1 100644 --- a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownS.f90 +++ b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownS.f90 @@ -1,9 +1,9 @@ subroutine TD_ForceDownS(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -12,25 +12,25 @@ subroutine TD_ForceDownS(i,TD_SemiMudVisc) Real(8) :: TD_SemiMudVisc , TD_SemiAngle - if ( TD_DrillStems(i)%StartAngle<=(pi/180.) ) then + if ( data%State%TD_DrillStems(i)%StartAngle<=(pi/180.) ) then TD_SemiAngle = (pi/180.) else - TD_SemiAngle = TD_DrillStems(i)%StartAngle + TD_SemiAngle = data%State%TD_DrillStems(i)%StartAngle end if If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - TD_DrillStems(i)%BouyancyFactor * (cos(TD_DrillStems(i)%StartAngle) - & - (TD_SemiMudVisc * sin(TD_DrillStems(i)%StartAngle)))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + data%State%TD_DrillStems(i)%BouyancyFactor * (cos(data%State%TD_DrillStems(i)%StartAngle) - & + (TD_SemiMudVisc * sin(data%State%TD_DrillStems(i)%StartAngle)))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_SemiMudVisc* TD_DrillStems(i)%BouyancyFactor* & - TD_DrillStems(i)%WeightperLength* TD_DrillStems(i)%Length* TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc* data%State%TD_DrillStems(i)%BouyancyFactor* & + data%State%TD_DrillStems(i)%WeightperLength* data%State%TD_DrillStems(i)%Length* data%State%TD_DrillStems(i)%RtoolJoint * & sin(TD_SemiAngle) end if @@ -40,21 +40,21 @@ subroutine TD_ForceDownS(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - TD_DrillStems(i)%BouyancyFactor * (cos(TD_DrillStems(i)%StartAngle) - & - (TD_SemiMudVisc * sin(TD_DrillStems(i)%StartAngle)))) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + data%State%TD_DrillStems(i)%BouyancyFactor * (cos(data%State%TD_DrillStems(i)%StartAngle) - & + (TD_SemiMudVisc * sin(data%State%TD_DrillStems(i)%StartAngle)))) ! ! !Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length ) / & ! (Elements(i)%Area * Element%ElasticModule) ! - TD_DrillStems(i)%Torque = TD_SemiMudVisc* TD_DrillStems(i)%BouyancyFactor* & - TD_DrillStems(i)%WeightperLength* TD_DrillStems(i)%Length* TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%Torque = TD_SemiMudVisc* data%State%TD_DrillStems(i)%BouyancyFactor* & + data%State%TD_DrillStems(i)%WeightperLength* data%State%TD_DrillStems(i)%Length* data%State%TD_DrillStems(i)%RtoolJoint * & sin(TD_SemiAngle) ! diff --git a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownSRot.f90 b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownSRot.f90 index 954dd93..858e117 100644 --- a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownSRot.f90 +++ b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceDownSRot.f90 @@ -1,9 +1,9 @@ subroutine TD_ForceDownSRot(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -12,26 +12,26 @@ subroutine TD_ForceDownSRot(i,TD_SemiMudVisc) Real(8) :: TD_SemiMudVisc , TD_SemiAngle - if ( TD_DrillStems(i)%StartAngle<=(pi/180.) ) then + if ( data%State%TD_DrillStems(i)%StartAngle<=(pi/180.) ) then TD_SemiAngle = (pi/180.) else - TD_SemiAngle = TD_DrillStems(i)%StartAngle + TD_SemiAngle = data%State%TD_DrillStems(i)%StartAngle end if If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%BouyancyFactor * TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - cos(TD_DrillStems(i)%StartAngle)) - (TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - sin(TD_DrillStems(i)%StartAngle) * sin(TD_DrillStems(i)%CombVelRatio)) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%BouyancyFactor * data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + cos(data%State%TD_DrillStems(i)%StartAngle)) - (TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + sin(data%State%TD_DrillStems(i)%StartAngle) * sin(data%State%TD_DrillStems(i)%CombVelRatio)) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = data%State%TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(data%State%TD_DrillStems(i)%CombVelRatio) end if @@ -40,17 +40,17 @@ subroutine TD_ForceDownSRot(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%BouyancyFactor * TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - cos(TD_DrillStems(i)%StartAngle)) - (TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - sin(TD_DrillStems(i)%StartAngle) * sin(TD_DrillStems(i)%CombVelRatio)) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%BouyancyFactor * data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + cos(data%State%TD_DrillStems(i)%StartAngle)) - (TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + sin(data%State%TD_DrillStems(i)%StartAngle) * sin(data%State%TD_DrillStems(i)%CombVelRatio)) ! - TD_DrillStems(i)%Torque = TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = data%State%TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(data%State%TD_DrillStems(i)%CombVelRatio) ! !Strains(i)%dL = TDForces(i)%Force * (Elements(i)%Length) / & diff --git a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpS.f90 b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpS.f90 index 1545a93..74b6c43 100644 --- a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpS.f90 +++ b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpS.f90 @@ -1,9 +1,9 @@ subroutine TD_ForceUpS(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -12,25 +12,25 @@ subroutine TD_ForceUpS(i,TD_SemiMudVisc) Real(8) :: TD_SemiMudVisc , TD_SemiAngle - if ( TD_DrillStems(i)%StartAngle<=(pi/180.) ) then + if ( data%State%TD_DrillStems(i)%StartAngle<=(pi/180.) ) then TD_SemiAngle = (pi/180.) else - TD_SemiAngle = TD_DrillStems(i)%StartAngle + TD_SemiAngle = data%State%TD_DrillStems(i)%StartAngle end if If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - TD_DrillStems(i)%BouyancyFactor * (cos(TD_DrillStems(i)%StartAngle) + & - (TD_SemiMudVisc * sin(TD_DrillStems(i)%StartAngle)))) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + data%State%TD_DrillStems(i)%BouyancyFactor * (cos(data%State%TD_DrillStems(i)%StartAngle) + & + (TD_SemiMudVisc * sin(data%State%TD_DrillStems(i)%StartAngle)))) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_DrillStems(i)%MudViscosity* TD_DrillStems(i)%BouyancyFactor* & - TD_DrillStems(i)%WeightperLength* TD_DrillStems(i)%Length* TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%Torque = data%State%TD_DrillStems(i)%MudViscosity* data%State%TD_DrillStems(i)%BouyancyFactor* & + data%State%TD_DrillStems(i)%WeightperLength* data%State%TD_DrillStems(i)%Length* data%State%TD_DrillStems(i)%RtoolJoint * & sin(TD_SemiAngle) end if @@ -39,26 +39,26 @@ subroutine TD_ForceUpS(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - TD_DrillStems(i)%BouyancyFactor * (cos(TD_DrillStems(i)%StartAngle) + & - (TD_SemiMudVisc * sin(TD_DrillStems(i)%StartAngle)))) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + data%State%TD_DrillStems(i)%BouyancyFactor * (cos(data%State%TD_DrillStems(i)%StartAngle) + & + (TD_SemiMudVisc * sin(data%State%TD_DrillStems(i)%StartAngle)))) !Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length ) / & ! (Elements(i)%Area * Element%ElasticModule) - TD_DrillStems(i)%Torque = TD_DrillStems(i)%MudViscosity* TD_DrillStems(i)%BouyancyFactor* & - TD_DrillStems(i)%WeightperLength* TD_DrillStems(i)%Length* TD_DrillStems(i)%RtoolJoint * & + data%State%TD_DrillStems(i)%Torque = data%State%TD_DrillStems(i)%MudViscosity* data%State%TD_DrillStems(i)%BouyancyFactor* & + data%State%TD_DrillStems(i)%WeightperLength* data%State%TD_DrillStems(i)%Length* data%State%TD_DrillStems(i)%RtoolJoint * & sin(TD_SemiAngle) - !!if (TD_DrillStems(i)%Torque>500.) then - ! print* , 'TD_String%TotalTorque=' , i , TD_String%TotalTorque , TD_DrillStems(i)%Torque , TD_String%WeightOnBit - ! print* , 'propertiess=' , TD_DrillStems(i)%Force2 , TD_DrillStems(i)%Force1 , TD_DrillStems(i)%MudViscosity , TD_DrillStems(i)%EndAngle , TD_DrillStems(i)%StartAngle , TD_DrillStems(i)%WeightperLength , TD_DrillStems(i)%MudVisCorrectCoef + !!if (data%State%TD_DrillStems(i)%Torque>500.) then + ! print* , 'data%State%TD_String%TotalTorque=' , i , data%State%TD_String%TotalTorque , data%State%TD_DrillStems(i)%Torque , data%State%TD_String%WeightOnBit + ! print* , 'propertiess=' , data%State%TD_DrillStems(i)%Force2 , data%State%TD_DrillStems(i)%Force1 , data%State%TD_DrillStems(i)%MudViscosity , data%State%TD_DrillStems(i)%EndAngle , data%State%TD_DrillStems(i)%StartAngle , data%State%TD_DrillStems(i)%WeightperLength , data%State%TD_DrillStems(i)%MudVisCorrectCoef ! !end if diff --git a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpSRot.f90 b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpSRot.f90 index 5abbabd..019cbe3 100644 --- a/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpSRot.f90 +++ b/TorqueDrag/TD_Forces/TD_StraightArea/TD_ForceUpSRot.f90 @@ -1,9 +1,9 @@ subroutine TD_ForceUpSRot(i,TD_SemiMudVisc) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -12,26 +12,26 @@ subroutine TD_ForceUpSRot(i,TD_SemiMudVisc) Real(8) :: TD_SemiMudVisc , TD_SemiAngle - if ( TD_DrillStems(i)%StartAngle<=(pi/180.d0) ) then + if ( data%State%TD_DrillStems(i)%StartAngle<=(pi/180.d0) ) then TD_SemiAngle = (pi/180.) else - TD_SemiAngle = TD_DrillStems(i)%StartAngle + TD_SemiAngle = data%State%TD_DrillStems(i)%StartAngle end if If (i==1) then - TD_DrillStems(1)%Force1 = -TD_String%WeightOnBit - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%BouyancyFactor * TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - cos(TD_DrillStems(i)%StartAngle)) + (TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - sin(TD_DrillStems(i)%StartAngle) * sin(TD_DrillStems(i)%CombVelRatio)) + data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%BouyancyFactor * data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + cos(data%State%TD_DrillStems(i)%StartAngle)) + (TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + sin(data%State%TD_DrillStems(i)%StartAngle) * sin(data%State%TD_DrillStems(i)%CombVelRatio)) - if (TD_DrillStems(i)%ComponentType==0) then - TD_DrillStems(i)%Torque = TD_String%BitTorque + if (data%State%TD_DrillStems(i)%ComponentType==0) then + data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque else - TD_DrillStems(i)%Torque = TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = data%State%TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(data%State%TD_DrillStems(i)%CombVelRatio) end if @@ -40,17 +40,17 @@ subroutine TD_ForceUpSRot(i,TD_SemiMudVisc) !=========> F1 Calculation - TD_DrillStems(i)%Force1 = TD_DrillStems(i-1)%Force2 + data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2 !=========> F2 Calculation - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force1 + (TD_DrillStems(i)%BouyancyFactor * TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - cos(TD_DrillStems(i)%StartAngle)) + (TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * & - sin(TD_DrillStems(i)%StartAngle) * sin(TD_DrillStems(i)%CombVelRatio)) + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%BouyancyFactor * data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + cos(data%State%TD_DrillStems(i)%StartAngle)) + (TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * & + sin(data%State%TD_DrillStems(i)%StartAngle) * sin(data%State%TD_DrillStems(i)%CombVelRatio)) ! - TD_DrillStems(i)%Torque = TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * TD_DrillStems(i)%BouyancyFactor * & - TD_DrillStems(i)%WeightperLength * TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(TD_DrillStems(i)%CombVelRatio) + data%State%TD_DrillStems(i)%Torque = data%State%TD_DrillStems(i)%RtoolJoint * TD_SemiMudVisc * data%State%TD_DrillStems(i)%BouyancyFactor * & + data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%Length * sin(TD_SemiAngle) * cos(data%State%TD_DrillStems(i)%CombVelRatio) ! !Strains(i)%dL = TDForces(i)%Force * (Elements(i)%Length) / & ! (Elements(i)%Area * Element%ElasticModule) diff --git a/TorqueDrag/TD_Forces/TD_StrainCalculation.f90 b/TorqueDrag/TD_Forces/TD_StrainCalculation.f90 index 1164868..f53cc22 100644 --- a/TorqueDrag/TD_Forces/TD_StrainCalculation.f90 +++ b/TorqueDrag/TD_Forces/TD_StrainCalculation.f90 @@ -1,9 +1,9 @@ subroutine TD_StrainCalculation(i) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -12,32 +12,32 @@ subroutine TD_StrainCalculation(i) - if (TD_String%DrillStemAxialVelocity>=0.d0) then + if (data%State%TD_String%DrillStemAxialVelocity>=0.d0) then if (i == 1) then - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 + TD_DrillStems(i)%Drag - TD_DrillStems(i)%Dl = (TD_DrillStems(i)%Force2) * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - TD_DrillStems(i)%DlTotal = TD_DrillStems(i)%Dl + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 + data%State%TD_DrillStems(i)%Drag + data%State%TD_DrillStems(i)%Dl = (data%State%TD_DrillStems(i)%Force2) * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i)%Dl else - !do i = 2 , TD_String%DrillStemComponentsNumbs - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 + TD_DrillStems(i)%Drag - TD_DrillStems(i)%Dl = (TD_DrillStems(i)%Force2) * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - TD_DrillStems(i)%DlTotal = TD_DrillStems(i-1)%DlTotal + TD_DrillStems(i)%Dl + !do i = 2 , data%State%TD_String%DrillStemComponentsNumbs + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 + data%State%TD_DrillStems(i)%Drag + data%State%TD_DrillStems(i)%Dl = (data%State%TD_DrillStems(i)%Force2) * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i-1)%DlTotal + data%State%TD_DrillStems(i)%Dl !end do end if - else if (TD_String%DrillStemAxialVelocity<0.) then + else if (data%State%TD_String%DrillStemAxialVelocity<0.) then if (i == 1) then - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 - TD_DrillStems(i)%Drag - TD_DrillStems(i)%Dl = (TD_DrillStems(i)%Force2) * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - TD_DrillStems(i)%DlTotal = TD_DrillStems(i)%Dl + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 - data%State%TD_DrillStems(i)%Drag + data%State%TD_DrillStems(i)%Dl = (data%State%TD_DrillStems(i)%Force2) * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i)%Dl else - !do i = 2 , TD_String%DrillStemComponentsNumbs - TD_DrillStems(i)%Force2 = TD_DrillStems(i)%Force2 - TD_DrillStems(i)%Drag - TD_DrillStems(i)%Dl = (TD_DrillStems(i)%Force2) * TD_DrillStems(i)%Length / TD_DrillStems(i)%Area / TD_DrillStems(i)%ElasticModule - TD_DrillStems(i)%DlTotal = TD_DrillStems(i-1)%DlTotal + TD_DrillStems(i)%Dl + !do i = 2 , data%State%TD_String%DrillStemComponentsNumbs + data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 - data%State%TD_DrillStems(i)%Drag + data%State%TD_DrillStems(i)%Dl = (data%State%TD_DrillStems(i)%Force2) * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule + data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i-1)%DlTotal + data%State%TD_DrillStems(i)%Dl !end do end if @@ -46,8 +46,8 @@ subroutine TD_StrainCalculation(i) !=====> Modified Length of Drill Stem - !TD_DrillStems(i)%Length = TD_DrillStems(i)%LengthIni + TD_DrillStems(i)%Dl - TD_DrillStems(i)%Length = TD_DrillStems(i)%LengthIni + !data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(i)%LengthIni + data%State%TD_DrillStems(i)%Dl + data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(i)%LengthIni diff --git a/TorqueDrag/TD_Forces/TD_TorqueCalculation.f90 b/TorqueDrag/TD_Forces/TD_TorqueCalculation.f90 index 21e6f0f..dbdf8be 100644 --- a/TorqueDrag/TD_Forces/TD_TorqueCalculation.f90 +++ b/TorqueDrag/TD_Forces/TD_TorqueCalculation.f90 @@ -1,12 +1,13 @@ subroutine TD_TorqueCalculation(i) - Use CHoistingVariables - Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData - Use RTable_VARIABLES, only: RTable - Use TopDrive_VARIABLES, only: TDS + use CHoistingVariables + use ConfigurationVariables +! Use TD_DrillStemComponents +! use ConfigurationVariables !@ +! use ConfigurationVariables !@ +! use ConfigurationVariables !@ +! use ConfigurationVariables !@, only: RTable +! use ConfigurationVariables, only: TDS implicit none @@ -16,24 +17,24 @@ subroutine TD_TorqueCalculation(i) - if ( Hoisting%DriveType==1 .and. RTable%Speed==0.d0 ) then - TD_DrillStems(i)%Torque = 0.d0 - else if ( Hoisting%DriveType==0 .and. TDS%Speed==0.d0 .and. RTable%Speed==0.d0 ) then - TD_DrillStems(i)%Torque = 0.d0 + if ( data%State%Hoisting%DriveType==1 .and. data%State%RTable%Speed==0.d0 ) then + data%State%TD_DrillStems(i)%Torque = 0.d0 + else if ( data%State%Hoisting%DriveType==0 .and. data%State%TDS%Speed==0.d0 .and. data%State%RTable%Speed==0.d0 ) then + data%State%TD_DrillStems(i)%Torque = 0.d0 end if if ( i==1 ) then - TD_String%TotalTorque = TD_DrillStems(i)%Torque + data%State%TD_String%TotalTorque = data%State%TD_DrillStems(i)%Torque else - TD_String%TotalTorque = TD_String%TotalTorque + TD_DrillStems(i)%Torque + data%State%TD_String%TotalTorque = data%State%TD_String%TotalTorque + data%State%TD_DrillStems(i)%Torque end if - !if (TD_DrillStems(i)%Torque>500.) then - ! print* , 'TD_String%TotalTorque=' , i , TD_String%TotalTorque , TD_DrillStems(i)%Torque - ! !print* , 'properties=' , TD_DrillStems(i)%Force1 , TD_DrillStems(i)%MudViscosity , TD_DrillStems(i)%EndAngle , TD_DrillStems(i)%StartAngle , TD_DrillStems(i)%WeightperLength , TD_DrillStems(i)%MudVisCorrectCoef + !if (data%State%TD_DrillStems(i)%Torque>500.) then + ! print* , 'data%State%TD_String%TotalTorque=' , i , data%State%TD_String%TotalTorque , data%State%TD_DrillStems(i)%Torque + ! !print* , 'properties=' , data%State%TD_DrillStems(i)%Force1 , data%State%TD_DrillStems(i)%MudViscosity , data%State%TD_DrillStems(i)%EndAngle , data%State%TD_DrillStems(i)%StartAngle , data%State%TD_DrillStems(i)%WeightperLength , data%State%TD_DrillStems(i)%MudVisCorrectCoef !end if diff --git a/TorqueDrag/TD_Forces/TD_ViscousDragForce/TD_ViscousDragForce.f90 b/TorqueDrag/TD_Forces/TD_ViscousDragForce/TD_ViscousDragForce.f90 index 5b557fc..f12d6b1 100644 --- a/TorqueDrag/TD_Forces/TD_ViscousDragForce/TD_ViscousDragForce.f90 +++ b/TorqueDrag/TD_Forces/TD_ViscousDragForce/TD_ViscousDragForce.f90 @@ -1,9 +1,9 @@ subroutine TD_ViscousDragForce Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -17,19 +17,19 @@ subroutine TD_ViscousDragForce - Do i = 1 , TD_String%DrillStemComponentsNumbs + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs - if ( TD_DrillStems(i)%MudDensityOut==0.d0 .or. TD_DrillStems(i)%MudDensityIn==0.d0 ) then - TD_DrillStems(i)%Drag = 0.d0 + if ( data%State%TD_DrillStems(i)%MudDensityOut==0.d0 .or. data%State%TD_DrillStems(i)%MudDensityIn==0.d0 ) then + data%State%TD_DrillStems(i)%Drag = 0.d0 cycle end if - TDmdup = TD_DrillStems(i)%TopDepthIni + TDmdup = data%State%TD_DrillStems(i)%TopDepthIni Call AnnulusPropertyCalculator ( INT(TDmdup) , TDden , TDpreup , TDtem ) - TDmddown = TD_DrillStems(i)%DownDepthIni + TDmddown = data%State%TD_DrillStems(i)%DownDepthIni Call AnnulusPropertyCalculator ( INT(TDmddown) , TDden , TDpredown , TDtem ) - TD_DrillStems(i)%Drag = abs(TDpredown-TDpreup)*(pi*TD_DrillStems(i)%Length*12.d0*TD_DrillStems(i)%Od*12.d0) ![psi]*[inch^2]=[lb] ????? + data%State%TD_DrillStems(i)%Drag = abs(TDpredown-TDpreup)*(pi*data%State%TD_DrillStems(i)%Length*12.d0*data%State%TD_DrillStems(i)%Od*12.d0) ![psi]*[inch^2]=[lb] ????? - TD_DrillStems(i)%Drag = 0.0d0 !????????????????????? + data%State%TD_DrillStems(i)%Drag = 0.0d0 !????????????????????? End Do @@ -38,135 +38,135 @@ subroutine TD_ViscousDragForce - !Do i = 1 , TD_String%DrillStemComponentsNumbs + !Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs ! ! - ! if ( TD_DrillStems(i)%MudDensityOut==0.d0 .or. TD_DrillStems(i)%MudDensityIn==0.d0 ) then - ! TD_DrillStems(i)%Drag = 0.d0 + ! if ( data%State%TD_DrillStems(i)%MudDensityOut==0.d0 .or. data%State%TD_DrillStems(i)%MudDensityIn==0.d0 ) then + ! data%State%TD_DrillStems(i)%Drag = 0.d0 ! cycle ! end if ! ! !------------------------------------------------------------------------------------ - ! TD_DrillStems(i)%Od = TD_DrillStems(i)%Od*12.d0 ! [inch] - ! TD_DrillStems(i)%HoleDiameter = TD_DrillStems(i)%HoleDiameter*12.d0 ! [inch] - ! TD_DrillStems(i)%MudDensityOut = TD_DrillStems(i)%MudDensityOut/7.48051948d0 ! [ppg] + ! data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(i)%Od*12.d0 ! [inch] + ! data%State%TD_DrillStems(i)%HoleDiameter = data%State%TD_DrillStems(i)%HoleDiameter*12.d0 ! [inch] + ! data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_DrillStems(i)%MudDensityOut/7.48051948d0 ! [ppg] ! !------------------------------------------------------------------------------------ ! ! - ! TD_ThetaCoef1 = TD_DrillStems(i)%MudYieldPoint+TD_DrillStems(i)%MudPlasticVis - ! TD_ThetaCoef2 = (2.0d0*TD_DrillStems(i)%MudPlasticVis)+TD_DrillStems(i)%MudYieldPoint + ! TD_ThetaCoef1 = data%State%TD_DrillStems(i)%MudYieldPoint+data%State%TD_DrillStems(i)%MudPlasticVis + ! TD_ThetaCoef2 = (2.0d0*data%State%TD_DrillStems(i)%MudPlasticVis)+data%State%TD_DrillStems(i)%MudYieldPoint ! TD_NCoef = 3.32d0*log10(TD_ThetaCoef2/TD_ThetaCoef1) ! TD_KCoef = (TD_ThetaCoef1)/(511.d0*TD_NCoef) ! ! ! - ! If (TD_DrillStems(i)%TopDepth>0.d0) then + ! If (data%State%TD_DrillStems(i)%TopDepth>0.d0) then ! - ! TD_DrillStems(i)%PipeVelocity = abs(TD_String%DrillStemAxialVelocity) + ! data%State%TD_DrillStems(i)%PipeVelocity = abs(data%State%TD_String%DrillStemAxialVelocity) ! - ! TD_DrillStems(i)%DiamRatio = (TD_DrillStems(i)%Od)/TD_DrillStems(i)%HoleDiameter + ! data%State%TD_DrillStems(i)%DiamRatio = (data%State%TD_DrillStems(i)%Od)/data%State%TD_DrillStems(i)%HoleDiameter ! ! - ! TD_DrillStems(i)%MudClingingConst = ((TD_DrillStems(i)%DiamRatio**2) * (1.0d0 - (2.0d0*log(TD_DrillStems(i)%DiamRatio))) - 1.0d0) & - ! / (2.0d0*(1.0d0-(TD_DrillStems(i)%DiamRatio**2))*log(TD_DrillStems(i)%DiamRatio)) + ! data%State%TD_DrillStems(i)%MudClingingConst = ((data%State%TD_DrillStems(i)%DiamRatio**2) * (1.0d0 - (2.0d0*log(data%State%TD_DrillStems(i)%DiamRatio))) - 1.0d0) & + ! / (2.0d0*(1.0d0-(data%State%TD_DrillStems(i)%DiamRatio**2))*log(data%State%TD_DrillStems(i)%DiamRatio)) ! - ! TD_DrillStems(i)%AveEffVelocity = TD_DrillStems(i)%PipeVelocity * ( ((TD_DrillStems(i)%DiamRatio**2)/(1.0d0-(TD_DrillStems(i)%DiamRatio**2))) & - ! + TD_DrillStems(i)%MudClingingConst) + ! data%State%TD_DrillStems(i)%AveEffVelocity = data%State%TD_DrillStems(i)%PipeVelocity * ( ((data%State%TD_DrillStems(i)%DiamRatio**2)/(1.0d0-(data%State%TD_DrillStems(i)%DiamRatio**2))) & + ! + data%State%TD_DrillStems(i)%MudClingingConst) ! - ! TD_DrillStems(i)%ReNumber = (926.4*(TD_DrillStems(i)%MudDensityOut * TD_DrillStems(i)%AveEffVelocity * (TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od))) & - ! / TD_DrillStems(i)%MudPlasticVis !Bingham-plastic drilling fluid - ! !TD_DrillStems(i)%ReNumber = 10.9d4*( TD_DrillStems(i)%MudDensityOut*(TD_DrillStems(i)%AveEffVelocity**(2-TD_NCoef))/TD_DrillStems(i)%MudPlasticVis ) & - ! ! *( (((TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od)/48.)*(TD_NCoef/((2.*TD_NCoef)+1.)))**TD_NCoef ) !Power-law fluid + ! data%State%TD_DrillStems(i)%ReNumber = (926.4*(data%State%TD_DrillStems(i)%MudDensityOut * data%State%TD_DrillStems(i)%AveEffVelocity * (data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od))) & + ! / data%State%TD_DrillStems(i)%MudPlasticVis !Bingham-plastic drilling fluid + ! !data%State%TD_DrillStems(i)%ReNumber = 10.9d4*( data%State%TD_DrillStems(i)%MudDensityOut*(data%State%TD_DrillStems(i)%AveEffVelocity**(2-TD_NCoef))/data%State%TD_DrillStems(i)%MudPlasticVis ) & + ! ! *( (((data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od)/48.)*(TD_NCoef/((2.*TD_NCoef)+1.)))**TD_NCoef ) !Power-law fluid ! - ! if ( TD_DrillStems(i)%ReNumber .le. 2.1d3 ) then !Bingham-plastic drilling fluid - ! !if ( TD_DrillStems(i)%ReNumber .le. (3479.-(1370.*TD_NCoef)) ) then !Power-law fluid + ! if ( data%State%TD_DrillStems(i)%ReNumber .le. 2.1d3 ) then !Bingham-plastic drilling fluid + ! !if ( data%State%TD_DrillStems(i)%ReNumber .le. (3479.-(1370.*TD_NCoef)) ) then !Power-law fluid ! - ! TD_DrillStems(i)%FricFactor = 1.60d1/TD_DrillStems(i)%ReNumber + ! data%State%TD_DrillStems(i)%FricFactor = 1.60d1/data%State%TD_DrillStems(i)%ReNumber ! - ! !TD_DrillStems(i)%Dp_Dl = ( TD_KCoef/(14.4d4*(TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od)) )& - ! ! *( ((48./(TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od))*(((2.*TD_NCoef)+1.)/TD_NCoef))**TD_NCoef ) !Power-law fluid - ! TD_DrillStems(i)%Dp_Dl = (TD_DrillStems(i)%FricFactor * (TD_DrillStems(i)%AveEffVelocity**2) * TD_DrillStems(i)%MudDensityOut) & - ! / (25.78d0*(TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od)) !Bingham-plastic drilling fluid + ! !data%State%TD_DrillStems(i)%Dp_Dl = ( TD_KCoef/(14.4d4*(data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od)) )& + ! ! *( ((48./(data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od))*(((2.*TD_NCoef)+1.)/TD_NCoef))**TD_NCoef ) !Power-law fluid + ! data%State%TD_DrillStems(i)%Dp_Dl = (data%State%TD_DrillStems(i)%FricFactor * (data%State%TD_DrillStems(i)%AveEffVelocity**2) * data%State%TD_DrillStems(i)%MudDensityOut) & + ! / (25.78d0*(data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od)) !Bingham-plastic drilling fluid ! ! else !Bingham-plastic drilling fluid - ! !else if ( TD_DrillStems(i)%ReNumber .gt. (4270.-(1370.*TD_NCoef)) ) then !Power-law fluid + ! !else if ( data%State%TD_DrillStems(i)%ReNumber .gt. (4270.-(1370.*TD_NCoef)) ) then !Power-law fluid ! - ! TD_DrillStems(i)%MudClingingConst = (sqrt(( (TD_DrillStems(i)%DiamRatio**4) + TD_DrillStems(i)%DiamRatio ) & - ! /(1.0d0 + TD_DrillStems(i)%DiamRatio )) - (TD_DrillStems(i)%DiamRatio**2)) & - ! /(1.0d0- (TD_DrillStems(i)%DiamRatio**2)) + ! data%State%TD_DrillStems(i)%MudClingingConst = (sqrt(( (data%State%TD_DrillStems(i)%DiamRatio**4) + data%State%TD_DrillStems(i)%DiamRatio ) & + ! /(1.0d0 + data%State%TD_DrillStems(i)%DiamRatio )) - (data%State%TD_DrillStems(i)%DiamRatio**2)) & + ! /(1.0d0- (data%State%TD_DrillStems(i)%DiamRatio**2)) ! - ! TD_DrillStems(i)%AveEffVelocity = TD_DrillStems(i)%PipeVelocity * ( ((TD_DrillStems(i)%DiamRatio**2)/(1.0d0-(TD_DrillStems(i)%DiamRatio**2))) & - ! + TD_DrillStems(i)%MudClingingConst) + ! data%State%TD_DrillStems(i)%AveEffVelocity = data%State%TD_DrillStems(i)%PipeVelocity * ( ((data%State%TD_DrillStems(i)%DiamRatio**2)/(1.0d0-(data%State%TD_DrillStems(i)%DiamRatio**2))) & + ! + data%State%TD_DrillStems(i)%MudClingingConst) ! - ! TD_DrillStems(i)%ReNumber = (926.4d0*(TD_DrillStems(i)%MudDensityOut * TD_DrillStems(i)%AveEffVelocity * (TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od))) & - ! / TD_DrillStems(i)%MudPlasticVis !Bingham-plastic drilling fluid - ! !TD_DrillStems(i)%ReNumber = 10.9d4*( TD_DrillStems(i)%MudDensityOut*(TD_DrillStems(i)%AveEffVelocity**(2-TD_NCoef))/TD_DrillStems(i)%MudPlasticVis ) & - ! ! *( (((TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od)/48.)*(TD_NCoef/((2.*TD_NCoef)+1.)))**TD_NCoef ) !Power-law fluid + ! data%State%TD_DrillStems(i)%ReNumber = (926.4d0*(data%State%TD_DrillStems(i)%MudDensityOut * data%State%TD_DrillStems(i)%AveEffVelocity * (data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od))) & + ! / data%State%TD_DrillStems(i)%MudPlasticVis !Bingham-plastic drilling fluid + ! !data%State%TD_DrillStems(i)%ReNumber = 10.9d4*( data%State%TD_DrillStems(i)%MudDensityOut*(data%State%TD_DrillStems(i)%AveEffVelocity**(2-TD_NCoef))/data%State%TD_DrillStems(i)%MudPlasticVis ) & + ! ! *( (((data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od)/48.)*(TD_NCoef/((2.*TD_NCoef)+1.)))**TD_NCoef ) !Power-law fluid ! - ! TD_DrillStems(i)%FricFactor = 0.0791d0/(TD_DrillStems(i)%ReNumber**0.25d0) + ! data%State%TD_DrillStems(i)%FricFactor = 0.0791d0/(data%State%TD_DrillStems(i)%ReNumber**0.25d0) ! - ! TD_DrillStems(i)%Dp_Dl = (TD_DrillStems(i)%FricFactor * (TD_DrillStems(i)%AveEffVelocity**2) * TD_DrillStems(i)%MudDensityOut) & - ! / (25.78d0*(TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od)) !Bingham-plastic drilling fluid - ! !TD_DrillStems(i)%Dp_Dl = (TD_DrillStems(i)%FricFactor * (TD_DrillStems(i)%AveEffVelocity**2) * TD_DrillStems(i)%MudDensityOut) & - ! ! / (21.1*(TD_DrillStems(i)%HoleDiameter - TD_DrillStems(i)%Od)) !Power-law fluid + ! data%State%TD_DrillStems(i)%Dp_Dl = (data%State%TD_DrillStems(i)%FricFactor * (data%State%TD_DrillStems(i)%AveEffVelocity**2) * data%State%TD_DrillStems(i)%MudDensityOut) & + ! / (25.78d0*(data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od)) !Bingham-plastic drilling fluid + ! !data%State%TD_DrillStems(i)%Dp_Dl = (data%State%TD_DrillStems(i)%FricFactor * (data%State%TD_DrillStems(i)%AveEffVelocity**2) * data%State%TD_DrillStems(i)%MudDensityOut) & + ! ! / (21.1*(data%State%TD_DrillStems(i)%HoleDiameter - data%State%TD_DrillStems(i)%Od)) !Power-law fluid ! ! end if ! ! - ! TD_DrillStems(i)%Drag = ( (pi/4.0d0)*TD_DrillStems(i)%Dp_Dl*TD_DrillStems(i)%Length*(TD_DrillStems(i)%Od**2)/10.d0 ) ! drag/10 = because of the value of drag force + ! data%State%TD_DrillStems(i)%Drag = ( (pi/4.0d0)*data%State%TD_DrillStems(i)%Dp_Dl*data%State%TD_DrillStems(i)%Length*(data%State%TD_DrillStems(i)%Od**2)/10.d0 ) ! drag/10 = because of the value of drag force ! ! Else - ! TD_DrillStems(i)%Drag = 0.0d0 + ! data%State%TD_DrillStems(i)%Drag = 0.0d0 ! ! End if ! ! ! !------------------------------------------------------------------------------------ - ! TD_DrillStems(i)%Od = TD_DrillStems(i)%Od/12.d0 ! [ft] - ! TD_DrillStems(i)%HoleDiameter = TD_DrillStems(i)%HoleDiameter/12.d0 ! [ft] - ! TD_DrillStems(i)%MudDensityOut = TD_DrillStems(i)%MudDensityOut*7.48051948d0 ! [lb/ft3] + ! data%State%TD_DrillStems(i)%Od = data%State%TD_DrillStems(i)%Od/12.d0 ! [ft] + ! data%State%TD_DrillStems(i)%HoleDiameter = data%State%TD_DrillStems(i)%HoleDiameter/12.d0 ! [ft] + ! data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_DrillStems(i)%MudDensityOut*7.48051948d0 ! [lb/ft3] ! !------------------------------------------------------------------------------------ ! ! !end do - if (TD_DrillStems(1)%ComponentType==0) then - TD_DrillStems(1)%Drag = 50.d0*TD_DrillStems(1)%Od !Od[ft] , Drag[lb]????? - if ( TD_DrillStems(1)%MudDensityOut==0.d0 .or. TD_DrillStems(1)%MudDensityIn==0.d0 ) then - TD_DrillStems(1)%Drag = 0.d0 + if (data%State%TD_DrillStems(1)%ComponentType==0) then + data%State%TD_DrillStems(1)%Drag = 50.d0*data%State%TD_DrillStems(1)%Od !Od[ft] , Drag[lb]????? + if ( data%State%TD_DrillStems(1)%MudDensityOut==0.d0 .or. data%State%TD_DrillStems(1)%MudDensityIn==0.d0 ) then + data%State%TD_DrillStems(1)%Drag = 0.d0 end if end if !!TD_DragSum = 0. - !!Do i = 1 , TD_String%DrillStemComponentsNumbs - !! TD_DragSum = TD_DragSum+TD_DrillStems(i)%Drag + !!Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs + !! TD_DragSum = TD_DragSum+data%State%TD_DrillStems(i)%Drag !!end do ! print*, 'TD_NCoef=' , TD_NCoef ! print*, 'TD_KCoef=' , TD_KCoef ! - ! print*, 'TD_DrillStems(1)%DiamRatio=' , TD_DrillStems(1)%DiamRatio - ! print*, 'TD_DrillStems(1)%Od=' , TD_DrillStems(1)%Od - ! print*, 'TD_DrillStems(1)%HoleDiameter=' , TD_DrillStems(1)%HoleDiameter + ! print*, 'data%State%TD_DrillStems(1)%DiamRatio=' , data%State%TD_DrillStems(1)%DiamRatio + ! print*, 'data%State%TD_DrillStems(1)%Od=' , data%State%TD_DrillStems(1)%Od + ! print*, 'data%State%TD_DrillStems(1)%HoleDiameter=' , data%State%TD_DrillStems(1)%HoleDiameter ! ! - ! print*, 'TD_DrillStems(1)%MudClingingConst=' , TD_DrillStems(1)%MudClingingConst + ! print*, 'data%State%TD_DrillStems(1)%MudClingingConst=' , data%State%TD_DrillStems(1)%MudClingingConst ! ! - ! print*, 'TD_DrillStems(1)%AveEffVelocity=' , TD_DrillStems(1)%AveEffVelocity + ! print*, 'data%State%TD_DrillStems(1)%AveEffVelocity=' , data%State%TD_DrillStems(1)%AveEffVelocity ! ! - ! !print*, 'TD_DrillStems(1)%MudPlasticVis=' , TD_DrillStems(1)%MudPlasticVis - ! print*, 'TD_DrillStems(1)%MudDensityOut=' , TD_DrillStems(1)%MudDensityOut - ! print*, 'TD_DrillStems(1)%ReNumber=' , TD_DrillStems(1)%ReNumber + ! !print*, 'data%State%TD_DrillStems(1)%MudPlasticVis=' , data%State%TD_DrillStems(1)%MudPlasticVis + ! print*, 'data%State%TD_DrillStems(1)%MudDensityOut=' , data%State%TD_DrillStems(1)%MudDensityOut + ! print*, 'data%State%TD_DrillStems(1)%ReNumber=' , data%State%TD_DrillStems(1)%ReNumber ! ! - ! print*, 'TD_DrillStems(1)%FricFactor=' , TD_DrillStems(1)%FricFactor - ! print*, 'TD_DrillStems(1)%Dp_Dl=' , TD_DrillStems(1)%Dp_Dl - ! print*, 'TD_DrillStems(1)%Drag=' , TD_DrillStems(1)%Drag - ! print*, 'TD_DrillStems(2)%Drag=' , TD_DrillStems(2)%Drag - ! print*, 'TD_DrillStems(3)%Drag=' , TD_DrillStems(3)%Drag + ! print*, 'data%State%TD_DrillStems(1)%FricFactor=' , data%State%TD_DrillStems(1)%FricFactor + ! print*, 'data%State%TD_DrillStems(1)%Dp_Dl=' , data%State%TD_DrillStems(1)%Dp_Dl + ! print*, 'data%State%TD_DrillStems(1)%Drag=' , data%State%TD_DrillStems(1)%Drag + ! print*, 'data%State%TD_DrillStems(2)%Drag=' , data%State%TD_DrillStems(2)%Drag + ! print*, 'data%State%TD_DrillStems(3)%Drag=' , data%State%TD_DrillStems(3)%Drag ! print*, 'TD_DragSum=' , TD_DragSum - ! print*, 'TD_DrillStems(330)%Drag=' , TD_DrillStems(330)%Drag - ! print*, 'TD_DrillStems(331)%Drag=' , TD_DrillStems(331)%Drag - ! print*, 'TD_DrillStems(333)%Drag=' , TD_DrillStems(333)%Drag + ! print*, 'data%State%TD_DrillStems(330)%Drag=' , data%State%TD_DrillStems(330)%Drag + ! print*, 'data%State%TD_DrillStems(331)%Drag=' , data%State%TD_DrillStems(331)%Drag + ! print*, 'data%State%TD_DrillStems(333)%Drag=' , data%State%TD_DrillStems(333)%Drag diff --git a/TorqueDrag/TD_Forces/TD_WeightOnBitCalculation.f90 b/TorqueDrag/TD_Forces/TD_WeightOnBitCalculation.f90 index b21b79d..401f058 100644 --- a/TorqueDrag/TD_Forces/TD_WeightOnBitCalculation.f90 +++ b/TorqueDrag/TD_Forces/TD_WeightOnBitCalculation.f90 @@ -1,11 +1,12 @@ subroutine TD_WeightOnBitCalculation Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData - Use CDataDisplayConsoleVariables + use CDataDisplayConsole + use ConfigurationVariables implicit none @@ -13,24 +14,24 @@ subroutine TD_WeightOnBitCalculation Integer :: i - !TD_StConn%TouchConnectionHeight = TD_String%DlMax + TD_String%DrillStemTotalLengthIni - TD_WellGeneral%WellTotalLength - TD_StConn%TouchConnectionHeight = TD_String%DrillStemTotalLengthIni - TD_WellGeneral%WellTotalLength + !data%State%TD_StConn%TouchConnectionHeight = data%State%TD_String%DlMax + data%State%TD_String%DrillStemTotalLengthIni - data%State%TD_WellGeneral%WellTotalLength + data%State%TD_StConn%TouchConnectionHeight = data%State%TD_String%DrillStemTotalLengthIni - data%State%TD_WellGeneral%WellTotalLength - !if (TD_DrillStems(1)%ComponentType == 0) then ????????????? + !if (data%State%TD_DrillStems(1)%ComponentType == 0) then ????????????? - !if (TD_DrillStems(1)%DownDepth < TD_WellGeneral%WellTotalLength) then - if (TD_StConn%ConnectionHeight < TD_StConn%TouchConnectionHeight) then - TD_String%DlTouch = TD_String%DlMax-(TD_StConn%TouchConnectionHeight-TD_StConn%ConnectionHeight) - TD_String%WeightOnBit = ((TD_String%StaticHookLoad/2.0d0)/TD_String%DlMax)*(TD_String%DlMax-TD_String%DlTouch) !(TD_String%StaticHookLoad/2.0d0) ---> because of Uniform drill stem(drillpipes) ?????????? + !if (data%State%TD_DrillStems(1)%DownDepth < data%State%TD_WellGeneral%WellTotalLength) then + if (data%State%TD_StConn%ConnectionHeight < data%State%TD_StConn%TouchConnectionHeight) then + data%State%TD_String%DlTouch = data%State%TD_String%DlMax-(data%State%TD_StConn%TouchConnectionHeight-data%State%TD_StConn%ConnectionHeight) + data%State%TD_String%WeightOnBit = ((data%State%TD_String%StaticHookLoad/2.0d0)/data%State%TD_String%DlMax)*(data%State%TD_String%DlMax-data%State%TD_String%DlTouch) !(data%State%TD_String%StaticHookLoad/2.0d0) ---> because of Uniform drill stem(drillpipes) ?????????? else - TD_String%WeightOnBit = 0.d0 ![lb] + data%State%TD_String%WeightOnBit = 0.d0 ![lb] end if - Call Set_WeightOnBit(AINT(real(TD_String%WeightOnBit,8))) + Call Set_WeightOnBit(AINT(real(data%State%TD_String%WeightOnBit,8))) diff --git a/TorqueDrag/TD_MainCalculations.f90 b/TorqueDrag/TD_MainCalculations.f90 index 173a4b3..a4788a3 100644 --- a/TorqueDrag/TD_MainCalculations.f90 +++ b/TorqueDrag/TD_MainCalculations.f90 @@ -4,12 +4,13 @@ subroutine TD_MainCalculations Use CStringConfigurationVariables ! Use CSimulationVariables Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData USE FricPressDropVarsModule - Use MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none @@ -20,7 +21,7 @@ subroutine TD_MainCalculations - TD_General%TimeStep = 0.1d0 ! Unit: [s] + data%State%TD_General%TimeStep = 0.1d0 ! Unit: [s] !Call TD_StartUp !Call TD_WellReadData !Call TD_WellElementsReadData @@ -47,43 +48,43 @@ subroutine TD_MainCalculations !===> Mud properties Read_Data from Fluid Module !!TD_StringNoHorizontalMudElements = TDNoHorizontalMudElements - !!TD_String%NoStringMudElements = TDNoStringMudElements - !!TD_String%NoCasingMudElements = TDNoCasingMudElements + !!data%State%TD_String%NoStringMudElements = TDNoStringMudElements + !!data%State%TD_String%NoCasingMudElements = TDNoCasingMudElements !! - !!if (allocated(TDDensity_MudElementArray) .and. (TD_StringNoHorizontalMudElements+TD_String%NoStringMudElements+TD_String%NoCasingMudElements)/=0) then - !! if (Allocated(TD_String%FluidMudDensity)) Deallocate(TD_String%FluidMudDensity) - !! Allocate(TD_String%FluidMudDensity(TD_StringNoHorizontalMudElements+TD_String%NoStringMudElements+TD_String%NoCasingMudElements)) - !! TD_String%FluidMudDensity(:) = TDDensity_MudElementArray(:) + !!if (allocated(TDDensity_MudElementArray) .and. (TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+data%State%TD_String%NoCasingMudElements)/=0) then + !! if (Allocated(data%State%TD_String%FluidMudDensity)) Deallocate(data%State%TD_String%FluidMudDensity) + !! Allocate(data%State%TD_String%FluidMudDensity(TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+data%State%TD_String%NoCasingMudElements)) + !! data%State%TD_String%FluidMudDensity(:) = TDDensity_MudElementArray(:) !!end if !! !!if (allocated(TDXend_MudElementArray)) then - !! if (Allocated(TD_String%FluidMudEndX)) Deallocate(TD_String%FluidMudEndX) - !! Allocate(TD_String%FluidMudEndX(TD_StringNoHorizontalMudElements+TD_String%NoStringMudElements+TD_String%NoCasingMudElements)) - !! TD_String%FluidMudEndX(:) = TDXend_MudElementArray(:) + !! if (Allocated(data%State%TD_String%FluidMudEndX)) Deallocate(data%State%TD_String%FluidMudEndX) + !! Allocate(data%State%TD_String%FluidMudEndX(TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+data%State%TD_String%NoCasingMudElements)) + !! data%State%TD_String%FluidMudEndX(:) = TDXend_MudElementArray(:) !!end if !! !!if (allocated(TDXstart_MudElementArray)) then - !! if (Allocated(TD_String%FluidMudStartX)) Deallocate(TD_String%FluidMudStartX) - !! Allocate(TD_String%FluidMudStartX(TD_StringNoHorizontalMudElements+TD_String%NoStringMudElements+TD_String%NoCasingMudElements)) - !! TD_String%FluidMudStartX(:) = TDXstart_MudElementArray(:) + !! if (Allocated(data%State%TD_String%FluidMudStartX)) Deallocate(data%State%TD_String%FluidMudStartX) + !! Allocate(data%State%TD_String%FluidMudStartX(TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+data%State%TD_String%NoCasingMudElements)) + !! data%State%TD_String%FluidMudStartX(:) = TDXstart_MudElementArray(:) !!end if - if (TD_DrillStem(1)%ComponentType==0) then - Do i = 2 , TD_String%DrillStemComponentsNumbs + if (data%State%TD_DrillStem(1)%ComponentType==0) then + Do i = 2 , data%State%TD_String%DrillStemComponentsNumbs Call TD_MudPropertiesReadData(i) Call TD_BouyancyFactor(i) Call TD_CombinedMotionData(i) End Do - TD_DrillStems(1)%MudDensityIn = TD_DrillStems(2)%MudDensityIn !(1): bit mud properties - TD_DrillStems(1)%MudDensityOut = TD_DrillStems(2)%MudDensityOut - TD_DrillStems(1)%MudWeight = TD_DrillStems(2)%MudWeight - TD_DrillStems(1)%MudPlasticVis = 5.d0+(5.d0*(TD_DrillStems(1)%MudWeight-8.3d0)) - TD_DrillStems(1)%MudViscosity = 0.2d0 !TD_DrillStems(i)%MudPlasticVis - TD_DrillStems(1)%MudYieldPoint = 10.d0+(TD_DrillStems(1)%MudWeight-8.3d0) + data%State%TD_DrillStems(1)%MudDensityIn = data%State%TD_DrillStems(2)%MudDensityIn !(1): bit mud properties + data%State%TD_DrillStems(1)%MudDensityOut = data%State%TD_DrillStems(2)%MudDensityOut + data%State%TD_DrillStems(1)%MudWeight = data%State%TD_DrillStems(2)%MudWeight + data%State%TD_DrillStems(1)%MudPlasticVis = 5.d0+(5.d0*(data%State%TD_DrillStems(1)%MudWeight-8.3d0)) + data%State%TD_DrillStems(1)%MudViscosity = 0.2d0 !data%State%TD_DrillStems(i)%MudPlasticVis + data%State%TD_DrillStems(1)%MudYieldPoint = 10.d0+(data%State%TD_DrillStems(1)%MudWeight-8.3d0) Call TD_BouyancyFactor(1) Call TD_CombinedMotionData(1) else - Do i = 1 , TD_String%DrillStemComponentsNumbs + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs Call TD_MudPropertiesReadData(i) Call TD_BouyancyFactor(i) Call TD_CombinedMotionData(i) @@ -98,11 +99,11 @@ subroutine TD_MainCalculations Call TD_StaticHookLoadCalculation Call TD_WeightOnBitCalculation - if (abs(TD_String%DrillStemAxialVelocity)>3.2808d0) then !1[m/s]=3.2808[ft/s] + if (abs(data%State%TD_String%DrillStemAxialVelocity)>3.2808d0) then !1[m/s]=3.2808[ft/s] Call TD_ViscousDragForce else - TD_DrillStems%Drag = 0.d0 - TD_String%DrillStemForceType = 5 + data%State%TD_DrillStems%Drag = 0.d0 + data%State%TD_String%DrillStemForceType = 5 end if Call TD_ForceCalculation Call TD_HookLoadCalculation @@ -111,7 +112,7 @@ subroutine TD_MainCalculations - TD_StConn%HookHeightOld = TD_StConn%HookHeight + data%State%TD_StConn%HookHeightOld = data%State%TD_StConn%HookHeight diff --git a/TorqueDrag/TD_Modules/GeoElements_FluidModule.f90 b/TorqueDrag/TD_Modules/GeoElements_FluidModule.f90 index 02fa1e4..3041587 100644 --- a/TorqueDrag/TD_Modules/GeoElements_FluidModule.f90 +++ b/TorqueDrag/TD_Modules/GeoElements_FluidModule.f90 @@ -9,7 +9,6 @@ MODULE GeoElements_FluidModule TYPE , PUBLIC :: Geo_Data REAL(8) , Allocatable :: MD(:) , TVD(:) , Angle(:) END TYPE Geo_Data - TYPE(Geo_Data) :: TDGeo !************************************************************************************************************************************ @@ -22,7 +21,6 @@ MODULE GeoElements_FluidModule INTEGER :: FirstElement , LastElement , ElType REAL(8) :: ID , OD , TopDepth , DownDepth END TYPE F_StringData - TYPE(F_StringData) , Allocatable :: F_String(:) !************************************************************************************************************************************ @@ -32,7 +30,6 @@ MODULE GeoElements_FluidModule INTEGER :: IntervalsTotalCounts , StringIntervalCounts , BottomHoleIntervalCounts , AnnulusIntervalCounts INTEGER :: OutOfWellIntervalCounts END TYPE F_IntervalsCountsData - TYPE(F_IntervalsCountsData):: F_Counts !************************************************************************************************************************************ @@ -43,8 +40,7 @@ MODULE GeoElements_FluidModule REAL(8) :: ID , OD , StartDepth , EndDepth , HydDiameter , Volume REAL(8) :: StartTVD , EndTVD , StartAngle , EndAngle END TYPE F_IntervalData - TYPE(F_IntervalData) , Allocatable :: F_Interval(:) - !####F_Interval(:)%GeoType = + !####data%State%F_Interval(:)%GeoType = ! 0 : String Interval ! 1 : BottomHole Interval ! 2 : Annulus Interval @@ -56,12 +52,7 @@ MODULE GeoElements_FluidModule TYPE , PUBLIC :: OD_AnnulusData REAL(8) :: ODValue , StartMD , EndMD END TYPE OD_AnnulusData - TYPE(OD_AnnulusData) :: OD_Annulus(4) !************************************************************************************************************************************ - - - - END MODULE GeoElements_FluidModule \ No newline at end of file diff --git a/TorqueDrag/TD_Modules/TD_DrillStem.f90 b/TorqueDrag/TD_Modules/TD_DrillStem.f90 index aa5bcdb..e9eb26c 100644 --- a/TorqueDrag/TD_Modules/TD_DrillStem.f90 +++ b/TorqueDrag/TD_Modules/TD_DrillStem.f90 @@ -22,7 +22,6 @@ MODULE TD_DrillStemComponents REAL(8) :: NearFloorConnectionHeight !==================================================== END TYPE TD_StringInfo - TYPE(TD_StringInfo) :: TD_String !************************************************************************************************************************************ @@ -35,7 +34,6 @@ MODULE TD_DrillStemComponents INTEGER :: Numbs , ComponentType REAL(8) :: Length , TopDepth , DownDepth , Od , Id , WeightperLength , TotalLength , TotalWeight END TYPE TD_DrillStemInfo - TYPE(TD_DrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStem !************************************************************************************************************************************ @@ -64,7 +62,6 @@ MODULE TD_DrillStemComponents !=========> Hook Load REAL(8) :: StaticHookLoad , TotalSHookLoad , Dl , DlTotal END TYPE TD_SeparatedDrillStemInfo - TYPE(TD_SeparatedDrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStems !************************************************************************************************************************************ @@ -86,7 +83,6 @@ MODULE TD_DrillStemComponents !integer :: TD_KellyOldStatus15 , TD_KellyNewStatus15 , TD_KellyOldStatus16 , TD_KellyNewStatus16 , TD_KellyOldStatus17 , TD_KellyNewStatus17 !integer :: TD_KellyOldStatus18 , TD_KellyNewStatus18 , TD_KellyOldStatus19 , TD_KellyNewStatus19 END TYPE TD_AddRemoveInfo - TYPE(TD_AddRemoveInfo) :: TD_Count !************************************************************************************************************************************ @@ -99,7 +95,6 @@ MODULE TD_DrillStemComponents ! Integer :: ComponentType ! REAL(8) :: Length , TopDepth , DownDepth , Od , Id !END TYPE CStringComponent - TYPE(CStringComponents), ALLOCATABLE, DIMENSION(:) :: G_StringElement !************************************************************************************************************************************ @@ -112,6 +107,5 @@ MODULE TD_DrillStemComponents Integer :: PreCount REAL(8) :: RemoveVolume , PreElementVolume , PreElementLength END TYPE TD_RemovedVolumeInfo - TYPE(TD_RemovedVolumeInfo) :: TD_Vol !************************************************************************************************************************************ END MODULE TD_DrillStemComponents \ No newline at end of file diff --git a/TorqueDrag/TD_Modules/TD_GeneralData.f90 b/TorqueDrag/TD_Modules/TD_GeneralData.f90 index 66eaede..d356248 100644 --- a/TorqueDrag/TD_Modules/TD_GeneralData.f90 +++ b/TorqueDrag/TD_Modules/TD_GeneralData.f90 @@ -17,7 +17,6 @@ MODULE TD_GeneralData !=====> Problems INTEGER :: WeightIndicatorMalf END TYPE TD_GeneralInfo - TYPE(TD_GeneralInfo) :: TD_General !************************************************************************************************************************************ @@ -33,7 +32,6 @@ MODULE TD_GeneralData INTEGER , Dimension(6) :: BOPElementNo INTEGER , Dimension(6) :: BOPConnectionPossibility ! 0:impossible , 1:possible(for DrillPipe Element) END TYPE TD_BOPInfo - TYPE(TD_BOPInfo) :: TD_BOP !************************************************************************************************************************************ @@ -43,7 +41,6 @@ MODULE TD_GeneralData ! INTEGER :: CType ! REAL(8) :: TopDepth , DownDepth !END TYPE TD_BOPElementData - TYPE(CBopElement) :: TD_BOPElement(4) !************************************************************************************************************************************ diff --git a/TorqueDrag/TD_Modules/TD_StringConnectionData.f90 b/TorqueDrag/TD_Modules/TD_StringConnectionData.f90 index bf100a8..4e7feb8 100644 --- a/TorqueDrag/TD_Modules/TD_StringConnectionData.f90 +++ b/TorqueDrag/TD_Modules/TD_StringConnectionData.f90 @@ -19,7 +19,6 @@ MODULE TD_StringConnectionData REAL(8) :: TDSHeight , TDSElevatorHeight , TDSLength , TDSElevatorLength , TDSToolJointLength , TDSElevatorToolLength REAL(8) :: TDSElevatorECG , ElevatorECG END TYPE TD_StringconnectionInfo - TYPE(TD_StringconnectionInfo) :: TD_StConn !************************************************************************************************************************************ @@ -35,7 +34,6 @@ MODULE TD_StringConnectionData INTEGER :: ZeroStringSpeed REAL(8) :: DrawworksLoadInput END TYPE TD_LoadInfo - TYPE(TD_LoadInfo) :: TD_Load !************************************************************************************************************************************ diff --git a/TorqueDrag/TD_Modules/TD_WellElements.f90 b/TorqueDrag/TD_Modules/TD_WellElements.f90 index 7311233..16fce66 100644 --- a/TorqueDrag/TD_Modules/TD_WellElements.f90 +++ b/TorqueDrag/TD_Modules/TD_WellElements.f90 @@ -13,7 +13,6 @@ MODULE TD_WellElements INTEGER :: ROPHoleNumbs REAL(8) :: ROP END TYPE TD_WellElementsInfo - TYPE(TD_WellElementsInfo) :: TD_WellEl !************************************************************************************************************************************ @@ -26,7 +25,6 @@ MODULE TD_WellElements INTEGER :: HoleType REAL(8) :: Length , TopDepth , DownDepth , Od , Id , Weight , CollapsePressure , TensileStrength , Roughness END TYPE TD_CasingInfo - TYPE(TD_CasingInfo), ALLOCATABLE, DIMENSION(:) :: TD_Casing !************************************************************************************************************************************ @@ -38,7 +36,6 @@ MODULE TD_WellElements TYPE, PUBLIC :: TD_LinerInfo REAL(8) :: Length , TopDepth , DownDepth , Od , Id , Weight , CollapsePressure , TensileStrength , Roughness , HoleType END TYPE TD_LinerInfo - TYPE(TD_LinerInfo), ALLOCATABLE, DIMENSION(:) :: TD_Liner !************************************************************************************************************************************ @@ -50,7 +47,6 @@ MODULE TD_WellElements TYPE, PUBLIC :: TD_OpenHoleInfo REAL(8) :: Length , TopDepth , DownDepth , Id , HoleType END TYPE TD_OpenHoleInfo - TYPE(TD_OpenHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_OpenHole !************************************************************************************************************************************ @@ -62,7 +58,6 @@ MODULE TD_WellElements TYPE, PUBLIC :: TD_ROPHoleInfo REAL(8) :: Length , TopDepth , DownDepth , Id , HoleType END TYPE TD_ROPHoleInfo - TYPE(TD_ROPHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_ROPHole !************************************************************************************************************************************ diff --git a/TorqueDrag/TD_Modules/TD_WellGeometry.f90 b/TorqueDrag/TD_Modules/TD_WellGeometry.f90 index caa948e..60d92d3 100644 --- a/TorqueDrag/TD_Modules/TD_WellGeometry.f90 +++ b/TorqueDrag/TD_Modules/TD_WellGeometry.f90 @@ -3,7 +3,7 @@ MODULE TD_WellGeometry IMPLICIT NONE PUBLIC - REAL(8) , PARAMETER :: pi=3.14159265d0 + ! REAL(8) , PARAMETER :: pi=3.14159265d0 @@ -15,7 +15,6 @@ MODULE TD_WellGeometry INTEGER :: WellIntervalsCount REAL(8) :: WellTotalLength , WellTotalVerticalLength END TYPE TD_WellGeneralInfo - TYPE(TD_WellGeneralInfo) :: TD_WellGeneral !************************************************************************************************************************************ @@ -25,7 +24,6 @@ MODULE TD_WellGeometry INTEGER :: HoleType REAL(8) :: StartAngle , EndAngle , IntervalLength , VerticalDepth , TopDepth , DownDepth , RCurvature END TYPE TD_WellGeometryData - TYPE(TD_WellGeometryData), Allocatable :: TD_WellGeo(:) !************************************************************************************************************************************ diff --git a/TorqueDrag/TD_ReadDataSubroutines/TD_DrillStemReadData.f90 b/TorqueDrag/TD_ReadDataSubroutines/TD_DrillStemReadData.f90 index a53c32d..2fa4018 100644 --- a/TorqueDrag/TD_ReadDataSubroutines/TD_DrillStemReadData.f90 +++ b/TorqueDrag/TD_ReadDataSubroutines/TD_DrillStemReadData.f90 @@ -2,10 +2,10 @@ subroutine TD_DrillStemReadData use ConfigurationVariables Use CStringConfigurationVariables Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData - Use Drawworks_VARIABLES, only: Drawworks + ! use ConfigurationVariables !@, only: Drawworks implicit none @@ -22,11 +22,11 @@ subroutine TD_DrillStemReadData !==================================================== ! Set Drill Stem Components Data !==================================================== - TD_String%StringConfigurationCount = Configuration%StringConfiguration%StringConfigurationCount - TD_String%DrillStemComponentsNumbs = 0 + data%State%TD_String%StringConfigurationCount = data%Configuration%StringConfiguration%StringConfigurationCount + data%State%TD_String%DrillStemComponentsNumbs = 0 - !########## TD_DrillStem%ComponentType :: + !########## data%State%TD_DrillStem%ComponentType :: !#Bit_ComponentType = 0 !#Stabilizer_ComponentType = 1 !#Collar_ComponentType = 2 @@ -37,30 +37,30 @@ subroutine TD_DrillStemReadData !#SafetyValve (TripMode) = 7 - if (Allocated(TD_DrillStem)) deAllocate (TD_DrillStem) - Allocate (TD_DrillStem(TD_String%StringConfigurationCount+100)) + if (Allocated(data%State%TD_DrillStem)) deAllocate (data%State%TD_DrillStem) + Allocate (data%State%TD_DrillStem(data%State%TD_String%StringConfigurationCount+100)) - Do i=1, TD_String%StringConfigurationCount - TD_DrillStem(i)%ComponentType = Configuration%StringConfiguration%StringConfigurations(i)%ComponentType - TD_DrillStem(i)%Numbs = Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint - TD_DrillStem(i)%Id = Configuration%StringConfiguration%StringConfigurations(i)%NominalId/12.d0 ![ft] - TD_DrillStem(i)%Od = Configuration%StringConfiguration%StringConfigurations(i)%NominalOd/12.d0 ![ft] - TD_DrillStem(i)%Length = Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint ![ft] - TD_DrillStem(i)%WeightperLength = Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength ![lb/ft] - TD_DrillStem(i)%TotalLength = Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength - TD_DrillStem(i)%TotalWeight = TD_DrillStem(i)%TotalLength*TD_DrillStem(i)%WeightperLength + Do i=1, data%State%TD_String%StringConfigurationCount + data%State%TD_DrillStem(i)%ComponentType = data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType + data%State%TD_DrillStem(i)%Numbs = data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint + data%State%TD_DrillStem(i)%Id = data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId/12.d0 ![ft] + data%State%TD_DrillStem(i)%Od = data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd/12.d0 ![ft] + data%State%TD_DrillStem(i)%Length = data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint ![ft] + data%State%TD_DrillStem(i)%WeightperLength = data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength ![lb/ft] + data%State%TD_DrillStem(i)%TotalLength = data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength + data%State%TD_DrillStem(i)%TotalWeight = data%State%TD_DrillStem(i)%TotalLength*data%State%TD_DrillStem(i)%WeightperLength - TD_String%DrillStemComponentsNumbs = TD_String%DrillStemComponentsNumbs+Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint + data%State%TD_String%DrillStemComponentsNumbs = data%State%TD_String%DrillStemComponentsNumbs+data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint !!=========> Set Separated Drill Stem Components Data ! TD_LastIndex = TD_LastIndex+StringConfigurations(i)%NumberOfJoint ! - ! TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ComponentType = TD_DrillStem(i)%ComponentType - ! TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Id = TD_DrillStem(i)%Id - ! TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Od = TD_DrillStem(i)%Od - ! TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Length = TD_DrillStem(i)%Length - ! TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Weight = TD_DrillStem(i)%Weight + ! data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ComponentType = data%State%TD_DrillStem(i)%ComponentType + ! data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Id = data%State%TD_DrillStem(i)%Id + ! data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Od = data%State%TD_DrillStem(i)%Od + ! data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Length = data%State%TD_DrillStem(i)%Length + ! data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Weight = data%State%TD_DrillStem(i)%Weight ! ! TD_FirstIndex = TD_LastIndex+1 End Do @@ -71,13 +71,13 @@ subroutine TD_DrillStemReadData !===> Initial Values of Removed-Volume Variables - if (TD_DrillStem(1)%ComponentType==0) then - TD_Vol%PreCount = TD_String%StringConfigurationCount-1 + if (data%State%TD_DrillStem(1)%ComponentType==0) then + data%State%TD_Vol%PreCount = data%State%TD_String%StringConfigurationCount-1 else - TD_Vol%PreCount = TD_String%StringConfigurationCount + data%State%TD_Vol%PreCount = data%State%TD_String%StringConfigurationCount end if - TD_Vol%PreElementVolume = TD_DrillStem(TD_String%StringConfigurationCount)%TotalLength*(((pi*((TD_DrillStem(TD_String%StringConfigurationCount)%Id)**2))/4.d0)) ![ft^3] - TD_Vol%PreElementLength = TD_DrillStem(TD_String%StringConfigurationCount)%TotalLength + data%State%TD_Vol%PreElementVolume = data%State%TD_DrillStem(data%State%TD_String%StringConfigurationCount)%TotalLength*(((pi*((data%State%TD_DrillStem(data%State%TD_String%StringConfigurationCount)%Id)**2))/4.d0)) ![ft^3] + data%State%TD_Vol%PreElementLength = data%State%TD_DrillStem(data%State%TD_String%StringConfigurationCount)%TotalLength @@ -91,35 +91,35 @@ subroutine TD_DrillStemReadData TD_FirstIndex = 1 TD_LastIndex = 0 - if (Allocated(TD_DrillStems)) deAllocate (TD_DrillStems) - Allocate (TD_DrillStems(TD_String%DrillStemComponentsNumbs+300)) ! +300: because of: Add or Remove DrillStem Components + if (Allocated(data%State%TD_DrillStems)) deAllocate (data%State%TD_DrillStems) + Allocate (data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs+300)) ! +300: because of: Add or Remove DrillStem Components Call TD_DrillStemStartUp - Do i=1, TD_String%StringConfigurationCount + Do i=1, data%State%TD_String%StringConfigurationCount - TD_LastIndex = TD_LastIndex+Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint + TD_LastIndex = TD_LastIndex+data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ComponentType = TD_DrillStem(i)%ComponentType - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Id = TD_DrillStem(i)%Id - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Od = TD_DrillStem(i)%Od - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Area = (pi*((TD_DrillStem(i)%Od**2)-(TD_DrillStem(i)%Id**2)))/4.0d0 + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ComponentType = data%State%TD_DrillStem(i)%ComponentType + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Id = data%State%TD_DrillStem(i)%Id + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Od = data%State%TD_DrillStem(i)%Od + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Area = (pi*((data%State%TD_DrillStem(i)%Od**2)-(data%State%TD_DrillStem(i)%Id**2)))/4.0d0 - if (TD_DrillStem(i)%ComponentType == 3 .or. TD_DrillStem(i)%ComponentType == 4) then - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%RtoolJoint = TD_DrillStem(i)%Od*1.30d0/2.0d0 - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ToolJointRange = TD_String%ToolJointRange - else if (TD_DrillStem(i)%ComponentType == 1 .or. TD_DrillStem(i)%ComponentType == 2) then - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%RtoolJoint = TD_DrillStem(i)%Od/2.0d0 - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ToolJointRange = TD_String%ToolJointRange - else if (TD_DrillStem(i)%ComponentType == 0) then - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%RtoolJoint = TD_DrillStem(i)%Od - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ToolJointRange = 0.0d0 + if (data%State%TD_DrillStem(i)%ComponentType == 3 .or. data%State%TD_DrillStem(i)%ComponentType == 4) then + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%RtoolJoint = data%State%TD_DrillStem(i)%Od*1.30d0/2.0d0 + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ToolJointRange = data%State%TD_String%ToolJointRange + else if (data%State%TD_DrillStem(i)%ComponentType == 1 .or. data%State%TD_DrillStem(i)%ComponentType == 2) then + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%RtoolJoint = data%State%TD_DrillStem(i)%Od/2.0d0 + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ToolJointRange = data%State%TD_String%ToolJointRange + else if (data%State%TD_DrillStem(i)%ComponentType == 0) then + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%RtoolJoint = data%State%TD_DrillStem(i)%Od + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%ToolJointRange = 0.0d0 end if - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Length = TD_DrillStem(i)%Length - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%LengthIni = TD_DrillStem(i)%Length - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%WeightperLength= TD_DrillStem(i)%WeightperLength - TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Weight = TD_DrillStem(i)%WeightperLength*TD_DrillStem(i)%Length + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Length = data%State%TD_DrillStem(i)%Length + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%LengthIni = data%State%TD_DrillStem(i)%Length + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%WeightperLength= data%State%TD_DrillStem(i)%WeightperLength + data%State%TD_DrillStems(TD_FirstIndex:TD_LastIndex)%Weight = data%State%TD_DrillStem(i)%WeightperLength*data%State%TD_DrillStem(i)%Length TD_FirstIndex = TD_LastIndex+1 @@ -134,8 +134,8 @@ subroutine TD_DrillStemReadData !==================================================== ! Set Hook Height Data !==================================================== - TD_StConn%HookHeightOld = Drawworks%Hook_Height_ini - TD_StConn%HookHeight = TD_StConn%HookHeightOld + data%State%TD_StConn%HookHeightOld = data%State%Drawworks%Hook_Height_ini + data%State%TD_StConn%HookHeight = data%State%TD_StConn%HookHeightOld diff --git a/TorqueDrag/TD_ReadDataSubroutines/TD_ForceReadData.f90 b/TorqueDrag/TD_ReadDataSubroutines/TD_ForceReadData.f90 index 1507ffb..86035f0 100644 --- a/TorqueDrag/TD_ReadDataSubroutines/TD_ForceReadData.f90 +++ b/TorqueDrag/TD_ReadDataSubroutines/TD_ForceReadData.f90 @@ -1,14 +1,12 @@ subroutine TD_ForceReadData - Use CHoistingVariables + use CHoistingVariables + use ConfigurationVariables Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData - Use RTable_VARIABLES, only: RTable Use sROP_Variables - Use TopDrive_VARIABLES, only: TDS implicit none @@ -18,39 +16,39 @@ subroutine TD_ForceReadData - TD_String%DrillStemAxialVelocity = TD_StConn%StringVelocity - Do i = 1 , TD_String%DrillStemComponentsNumbs - if ( Hoisting%DriveType==1) then - TD_String%DrillStemRotVelocity = (2.d0*pi*TD_DrillStems(i)%RtoolJoint)*(RTable%Speed)/60.d0 ! RTable%Speed[RPM] ---> TD_String%DrillStemRotVelocity[ft/s] - else if ( Hoisting%DriveType==0) then - TD_String%DrillStemRotVelocity = (2.d0*pi*TD_DrillStems(i)%RtoolJoint)*(TDS%Speed+RTable%Speed)/60.d0 ! TDS%Speed[RPM] ---> TD_String%DrillStemRotVelocity[ft/s] + data%State%TD_String%DrillStemAxialVelocity = data%State%TD_StConn%StringVelocity + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs + if ( data%State%Hoisting%DriveType==1) then + data%State%TD_String%DrillStemRotVelocity = (2.d0*pi*data%State%TD_DrillStems(i)%RtoolJoint)*(data%State%RTable%Speed)/60.d0 ! data%State%RTable%Speed[RPM] ---> data%State%TD_String%DrillStemRotVelocity[ft/s] + else if ( data%State%Hoisting%DriveType==0) then + data%State%TD_String%DrillStemRotVelocity = (2.d0*pi*data%State%TD_DrillStems(i)%RtoolJoint)*(data%State%TDS%Speed+data%State%RTable%Speed)/60.d0 ! data%State%TDS%Speed[RPM] ---> data%State%TD_String%DrillStemRotVelocity[ft/s] end if End Do - TD_String%BitTorque = ROP_Bit%BitTorque + data%State%TD_String%BitTorque = data%State%ROP_Bit%BitTorque - !TD_String%DrillStemAxialVelocity = 0.0 !??????????????????? - !TD_String%DrillStemRotVelocity = 0.0 !??????????????????? + !data%State%TD_String%DrillStemAxialVelocity = 0.0 !??????????????????? + !data%State%TD_String%DrillStemRotVelocity = 0.0 !??????????????????? - TD_String%DrillStemForceType = 0 - if(TD_String%DrillStemAxialVelocity > 0.) then !??????????????????? check - TD_String%DrillStemForceType = 1 - if(TD_String%DrillStemRotVelocity /= 0.d0) TD_String%DrillStemForceType = 2 - else if(TD_String%DrillStemAxialVelocity < 0.d0) then - TD_String%DrillStemForceType = 3 - if(TD_String%DrillStemRotVelocity /= 0.d0) TD_String%DrillStemForceType = 4 - else if(TD_String%DrillStemAxialVelocity == 0.d0) then - TD_String%DrillStemForceType = 5 !no axial motion + data%State%TD_String%DrillStemForceType = 0 + if(data%State%TD_String%DrillStemAxialVelocity > 0.) then !??????????????????? check + data%State%TD_String%DrillStemForceType = 1 + if(data%State%TD_String%DrillStemRotVelocity /= 0.d0) data%State%TD_String%DrillStemForceType = 2 + else if(data%State%TD_String%DrillStemAxialVelocity < 0.d0) then + data%State%TD_String%DrillStemForceType = 3 + if(data%State%TD_String%DrillStemRotVelocity /= 0.d0) data%State%TD_String%DrillStemForceType = 4 + else if(data%State%TD_String%DrillStemAxialVelocity == 0.d0) then + data%State%TD_String%DrillStemForceType = 5 !no axial motion end if diff --git a/TorqueDrag/TD_ReadDataSubroutines/TD_MudPropertiesReadData.f90 b/TorqueDrag/TD_ReadDataSubroutines/TD_MudPropertiesReadData.f90 index 99b2481..52c081e 100644 --- a/TorqueDrag/TD_ReadDataSubroutines/TD_MudPropertiesReadData.f90 +++ b/TorqueDrag/TD_ReadDataSubroutines/TD_MudPropertiesReadData.f90 @@ -1,11 +1,12 @@ subroutine TD_MudPropertiesReadData (i) Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ USE FricPressDropVarsModule - Use MudSystemVARIABLES + USE MudSystemVARIABLES +use ConfigurationVariables !@@@ implicit none @@ -21,39 +22,39 @@ subroutine TD_MudPropertiesReadData (i) !==================================================== IF ( ALLOCATED(FlowEl) ) THEN if ( i==2 ) then - TDmd = int(TD_DrillStems(i)%DownDepthIni-1.d0) + TDmd = int(data%State%TD_DrillStems(i)%DownDepthIni-1.d0) else - TDmd = int(TD_DrillStems(i)%DownDepthIni) + TDmd = int(data%State%TD_DrillStems(i)%DownDepthIni) end if Call StringPropertyCalculator (TDmd , TDden, TDpre, TDtem) - TD_DrillStems(i)%MudDensityIn = TDden*7.48051948d0 ! [ppg]*7.48051948=[lb/ft3] + data%State%TD_DrillStems(i)%MudDensityIn = TDden*7.48051948d0 ! [ppg]*7.48051948=[lb/ft3] Call AnnulusPropertyCalculator (TDmd , TDden, TDpre, TDtem) - TD_DrillStems(i)%MudDensityOut = TDden*7.48051948d0 ! [ppg]*7.48051948=[lb/ft3] - TD_DrillStems(i)%MudWeight = TDden ! [ppg] ??????????????? + data%State%TD_DrillStems(i)%MudDensityOut = TDden*7.48051948d0 ! [ppg]*7.48051948=[lb/ft3] + data%State%TD_DrillStems(i)%MudWeight = TDden ! [ppg] ??????????????? ELSE - TD_DrillStems(i)%MudDensityIn = TD_DrillStems(i)%MudDensityIn - TD_DrillStems(i)%MudDensityOut = TD_DrillStems(i)%MudDensityOut - TD_DrillStems(i)%MudWeight = TD_DrillStems(i)%MudWeight + data%State%TD_DrillStems(i)%MudDensityIn = data%State%TD_DrillStems(i)%MudDensityIn + data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_DrillStems(i)%MudDensityOut + data%State%TD_DrillStems(i)%MudWeight = data%State%TD_DrillStems(i)%MudWeight END IF - !TD_DrillStems(i)%Drag = + !data%State%TD_DrillStems(i)%Drag = - !IF (ALLOCATED(TD_String%FluidMudDensity) .and. ALLOCATED(TD_String%FluidMudStartX) .and. TD_String%NoStringMudElements/=0) THEN - ! Do j = TD_StringNoHorizontalMudElements+1,TD_StringNoHorizontalMudElements+TD_String%NoStringMudElements - ! if ( TD_DrillStems(i)%DownDepthIni<=TD_String%FluidMudStartX(j) ) then + !IF (ALLOCATED(data%State%TD_String%FluidMudDensity) .and. ALLOCATED(data%State%TD_String%FluidMudStartX) .and. data%State%TD_String%NoStringMudElements/=0) THEN + ! Do j = TD_StringNoHorizontalMudElements+1,TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements + ! if ( data%State%TD_DrillStems(i)%DownDepthIni<=data%State%TD_String%FluidMudStartX(j) ) then ! exit ! end if - ! TD_DrillStems(i)%MudDensityIn = TD_String%FluidMudDensity(j)*7.48051948d0 !10.*7.48051948 ! [ppg]*7.48051948=[lb/ft3] - ! !print*, 'TD_DrillStems(i)%MudDensityIn=' ,TD_DrillStems(i)%MudDensityIn , i + ! data%State%TD_DrillStems(i)%MudDensityIn = data%State%TD_String%FluidMudDensity(j)*7.48051948d0 !10.*7.48051948 ! [ppg]*7.48051948=[lb/ft3] + ! !print*, 'data%State%TD_DrillStems(i)%MudDensityIn=' ,data%State%TD_DrillStems(i)%MudDensityIn , i ! !print*, 'FlowEl(j)%density=' ,FlowEl(j)%density , i ! End Do !ELSE - ! TD_DrillStems(i)%MudDensityIn = TD_DrillStems(i)%MudDensityIn ! [ppg]*7.48051948=[lb/ft3] + ! data%State%TD_DrillStems(i)%MudDensityIn = data%State%TD_DrillStems(i)%MudDensityIn ! [ppg]*7.48051948=[lb/ft3] !! !print*, '=================' , i !END IF ! @@ -63,17 +64,17 @@ subroutine TD_MudPropertiesReadData (i) ! ! ! - !IF (ALLOCATED(TD_String%FluidMudDensity) .and. ALLOCATED(TD_String%FluidMudEndX) .and. TD_String%NoCasingMudElements/=0) THEN - ! Do j = (TD_StringNoHorizontalMudElements+TD_String%NoStringMudElements+TD_String%NoCasingMudElements),(TD_StringNoHorizontalMudElements+TD_String%NoStringMudElements+1),-1 - ! if ( TD_DrillStems(i)%DownDepthIni<=TD_String%FluidMudEndX(j) ) then + !IF (ALLOCATED(data%State%TD_String%FluidMudDensity) .and. ALLOCATED(data%State%TD_String%FluidMudEndX) .and. data%State%TD_String%NoCasingMudElements/=0) THEN + ! Do j = (TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+data%State%TD_String%NoCasingMudElements),(TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+1),-1 + ! if ( data%State%TD_DrillStems(i)%DownDepthIni<=data%State%TD_String%FluidMudEndX(j) ) then ! exit ! end if - ! TD_DrillStems(i)%MudDensityOut = TD_String%FluidMudDensity(j)*7.48051948d0 !10.*7.48051948 ! [ppg]*7.48051948=[lb/ft3] - ! TD_DrillStems(i)%MudWeight = TD_String%FluidMudDensity(j) !10.0 ! [ppg] ??????????????? + ! data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_String%FluidMudDensity(j)*7.48051948d0 !10.*7.48051948 ! [ppg]*7.48051948=[lb/ft3] + ! data%State%TD_DrillStems(i)%MudWeight = data%State%TD_String%FluidMudDensity(j) !10.0 ! [ppg] ??????????????? ! End Do !ELSE - ! TD_DrillStems(i)%MudDensityOut = TD_DrillStems(i)%MudDensityOut ! [ppg]*7.48051948=[lb/ft3] - ! TD_DrillStems(i)%MudWeight = TD_DrillStems(i)%MudWeight ! [ppg] ??????????????? + ! data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_DrillStems(i)%MudDensityOut ! [ppg]*7.48051948=[lb/ft3] + ! data%State%TD_DrillStems(i)%MudWeight = data%State%TD_DrillStems(i)%MudWeight ! [ppg] ??????????????? !END IF @@ -83,10 +84,10 @@ subroutine TD_MudPropertiesReadData (i) - TD_DrillStems(i)%MudPlasticVis = 5.d0+(5.d0*(TD_DrillStems(i)%MudWeight-8.3d0)) ! [cP] - !TD_DrillStems(i)%MudPlasticVis= TD_DrillStems(i)%MudPlasticVis * 6.71968d-4 ! [cP]*6.71968d-4=[lb/(ft.s)] - TD_DrillStems(i)%MudViscosity = 0.2d0 !TD_DrillStems(i)%MudPlasticVis - TD_DrillStems(i)%MudYieldPoint = 10.d0+(TD_DrillStems(i)%MudWeight-8.3d0) + data%State%TD_DrillStems(i)%MudPlasticVis = 5.d0+(5.d0*(data%State%TD_DrillStems(i)%MudWeight-8.3d0)) ! [cP] + !data%State%TD_DrillStems(i)%MudPlasticVis= data%State%TD_DrillStems(i)%MudPlasticVis * 6.71968d-4 ! [cP]*6.71968d-4=[lb/(ft.s)] + data%State%TD_DrillStems(i)%MudViscosity = 0.2d0 !data%State%TD_DrillStems(i)%MudPlasticVis + data%State%TD_DrillStems(i)%MudYieldPoint = 10.d0+(data%State%TD_DrillStems(i)%MudWeight-8.3d0) diff --git a/TorqueDrag/TD_ReadDataSubroutines/TD_PipePropertiesReadData.f90 b/TorqueDrag/TD_ReadDataSubroutines/TD_PipePropertiesReadData.f90 index 4c6b040..d168b94 100644 --- a/TorqueDrag/TD_ReadDataSubroutines/TD_PipePropertiesReadData.f90 +++ b/TorqueDrag/TD_ReadDataSubroutines/TD_PipePropertiesReadData.f90 @@ -1,9 +1,9 @@ subroutine TD_PipePropertiesReadData Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -14,9 +14,9 @@ subroutine TD_PipePropertiesReadData ! Set Pipe Properties Data !==================================================== - Do i = 1 , TD_String%DrillStemComponentsNumbs - TD_DrillStems(i)%Density = 7850.d0*0.06242796d0 ![kg/m3]*0.06242796=[lb/ft3] - TD_DrillStems(i)%ElasticModule = 200.0d9*0.02088543d0 ![lb/ft2] !200GPa=29Mpsi (steel) + Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs + data%State%TD_DrillStems(i)%Density = 7850.d0*0.06242796d0 ![kg/m3]*0.06242796=[lb/ft3] + data%State%TD_DrillStems(i)%ElasticModule = 200.0d9*0.02088543d0 ![lb/ft2] !200GPa=29Mpsi (steel) End Do diff --git a/TorqueDrag/TD_ReadDataSubroutines/TD_WellElementsReadData.f90 b/TorqueDrag/TD_ReadDataSubroutines/TD_WellElementsReadData.f90 index b7ebce2..4d09fe7 100644 --- a/TorqueDrag/TD_ReadDataSubroutines/TD_WellElementsReadData.f90 +++ b/TorqueDrag/TD_ReadDataSubroutines/TD_WellElementsReadData.f90 @@ -3,8 +3,8 @@ subroutine TD_WellElementsReadData Use CCasingLinerChokeVariables use CStringConfigurationVariables use ConfigurationVariables - Use TD_WellElements - Use TD_WellGeometry + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -18,20 +18,20 @@ subroutine TD_WellElementsReadData !==================================================== ! Set Casing Data !==================================================== - TD_WellEl%CasingNumbs = 1 - - if (Allocated(TD_Casing)) deAllocate (TD_Casing) - Allocate (TD_Casing(TD_WellEl%CasingNumbs)) - - Do i=1, TD_WellEl%CasingNumbs - TD_Casing(i)%Length = CasingLinerChoke%CasingDepth ! unit: [ft] - TD_Casing(i)%TopDepth = 0.d0 - TD_Casing(i)%DownDepth = TD_Casing(i)%Length - TD_Casing(i)%Od = CasingLinerChoke%CasingOd/12.d0 ! unit: [ft] - TD_Casing(i)%Id = CasingLinerChoke%CasingId/12.d0 ! unit: [ft] - TD_Casing(i)%Weight = CasingLinerChoke%CasingWeight - TD_Casing(i)%CollapsePressure = CasingLinerChoke%CasingCollapsePressure - TD_Casing(i)%TensileStrength = CasingLinerChoke%CasingTensileStrength + data%State%TD_WellEl%CasingNumbs = 1 + + if (Allocated(data%State%TD_Casing)) deAllocate (data%State%TD_Casing) + Allocate (data%State%TD_Casing(data%State%TD_WellEl%CasingNumbs)) + + Do i=1, data%State%TD_WellEl%CasingNumbs + data%State%TD_Casing(i)%Length = CasingLinerChoke%CasingDepth ! unit: [ft] + data%State%TD_Casing(i)%TopDepth = 0.d0 + data%State%TD_Casing(i)%DownDepth = data%State%TD_Casing(i)%Length + data%State%TD_Casing(i)%Od = CasingLinerChoke%CasingOd/12.d0 ! unit: [ft] + data%State%TD_Casing(i)%Id = CasingLinerChoke%CasingId/12.d0 ! unit: [ft] + data%State%TD_Casing(i)%Weight = CasingLinerChoke%CasingWeight + data%State%TD_Casing(i)%CollapsePressure = CasingLinerChoke%CasingCollapsePressure + data%State%TD_Casing(i)%TensileStrength = CasingLinerChoke%CasingTensileStrength End Do @@ -41,36 +41,36 @@ subroutine TD_WellElementsReadData !==================================================== ! Set Liner Data !==================================================== - TD_WellEl%LinerNumbs = 0 + data%State%TD_WellEl%LinerNumbs = 0 if(CasingLinerChoke%LinerLength > 0.d0) then - TD_WellEl%LinerNumbs = 1 + data%State%TD_WellEl%LinerNumbs = 1 - !if (TD_WellEl%LinerNumbs>0) then - if (Allocated(TD_Liner)) deAllocate (TD_Liner) - Allocate (TD_Liner(TD_WellEl%LinerNumbs)) + !if (data%State%TD_WellEl%LinerNumbs>0) then + if (Allocated(data%State%TD_Liner)) deAllocate (data%State%TD_Liner) + Allocate (data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs)) - Do i=1, TD_WellEl%LinerNumbs - TD_Liner(i)%TopDepth = CasingLinerChoke%LinerTopDepth ! unit: [ft] - if (TD_Liner(i)%TopDepth 0.d0) TD_WellEl%OpenHoleNumbs=1 + TD_OpenHoleLength=data%State%TD_WellGeneral%WellTotalLength-(data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs)%DownDepth) + if(TD_OpenHoleLength > 0.d0) data%State%TD_WellEl%OpenHoleNumbs=1 - if (TD_WellEl%OpenHoleNumbs>0) then - if (Allocated(TD_OpenHole)) deAllocate (TD_OpenHole) - Allocate (TD_OpenHole(TD_WellEl%OpenHoleNumbs)) !!!??????????????????check + if (data%State%TD_WellEl%OpenHoleNumbs>0) then + if (Allocated(data%State%TD_OpenHole)) deAllocate (data%State%TD_OpenHole) + Allocate (data%State%TD_OpenHole(data%State%TD_WellEl%OpenHoleNumbs)) !!!??????????????????check - Do i = 1, TD_WellEl%OpenHoleNumbs - TD_OpenHole(i)%TopDepth = TD_Liner(TD_WellEl%LinerNumbs)%DownDepth - TD_OpenHole(i)%Length = TD_OpenHoleLength ! unit: [ft] - TD_OpenHole(i)%DownDepth = TD_OpenHole(i)%TopDepth+TD_OpenHole(i)%Length - TD_OpenHole(i)%Id = CasingLinerChoke%OpenHoleId/12.d0 ! unit: [ft] + Do i = 1, data%State%TD_WellEl%OpenHoleNumbs + data%State%TD_OpenHole(i)%TopDepth = data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs)%DownDepth + data%State%TD_OpenHole(i)%Length = TD_OpenHoleLength ! unit: [ft] + data%State%TD_OpenHole(i)%DownDepth = data%State%TD_OpenHole(i)%TopDepth+data%State%TD_OpenHole(i)%Length + data%State%TD_OpenHole(i)%Id = CasingLinerChoke%OpenHoleId/12.d0 ! unit: [ft] End Do else - if (Allocated(TD_OpenHole)) deAllocate (TD_OpenHole) - Allocate (TD_OpenHole(1)) - TD_WellEl%OpenHoleNumbs = 1 - TD_OpenHole%Length = 0.d0 - TD_OpenHole%TopDepth = TD_Liner(TD_WellEl%LinerNumbs)%DownDepth - TD_OpenHole%DownDepth = TD_OpenHole%TopDepth + if (Allocated(data%State%TD_OpenHole)) deAllocate (data%State%TD_OpenHole) + Allocate (data%State%TD_OpenHole(1)) + data%State%TD_WellEl%OpenHoleNumbs = 1 + data%State%TD_OpenHole%Length = 0.d0 + data%State%TD_OpenHole%TopDepth = data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs)%DownDepth + data%State%TD_OpenHole%DownDepth = data%State%TD_OpenHole%TopDepth end if @@ -114,15 +114,15 @@ subroutine TD_WellElementsReadData ! Set ROP_Hole Data !==================================================== - TD_WellEl%ROPHoleNumbs = 1 - if (Allocated(TD_ROPHole)) deAllocate (TD_ROPHole) - Allocate (TD_ROPHole(TD_WellEl%ROPHoleNumbs)) + data%State%TD_WellEl%ROPHoleNumbs = 1 + if (Allocated(data%State%TD_ROPHole)) deAllocate (data%State%TD_ROPHole) + Allocate (data%State%TD_ROPHole(data%State%TD_WellEl%ROPHoleNumbs)) - Do i = 1, TD_WellEl%ROPHoleNumbs - TD_ROPHole(i)%TopDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%TopDepth - TD_ROPHole(i)%DownDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%DownDepth - TD_ROPHole(i)%Length = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%IntervalLength - TD_ROPHole(i)%Id = Configuration%StringConfiguration%BitDefinition%BitSize/12.d0 ! unit: [ft] + Do i = 1, data%State%TD_WellEl%ROPHoleNumbs + data%State%TD_ROPHole(i)%TopDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth + data%State%TD_ROPHole(i)%DownDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth + data%State%TD_ROPHole(i)%Length = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength + data%State%TD_ROPHole(i)%Id = data%Configuration%StringConfiguration%BitDefinition%BitSize/12.d0 ! unit: [ft] End Do diff --git a/TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.f90 b/TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.f90 index 238f3d0..5e4cbd3 100644 --- a/TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.f90 +++ b/TorqueDrag/TD_ReadDataSubroutines/TD_WellReadData.f90 @@ -1,7 +1,7 @@ subroutine TD_WellReadData - Use CPathGenerationVariables - Use TD_WellGeometry + use ConfigurationVariables !@ + use ConfigurationVariables !@ implicit none @@ -9,10 +9,10 @@ subroutine TD_WellReadData - TD_WellGeneral%WellIntervalsCount = PathGeneration%ItemCount + 1 ! +1 is belong to ROP hole + data%State%TD_WellGeneral%WellIntervalsCount = PathGeneration%ItemCount + 1 ! +1 is belong to ROP hole - if (Allocated(TD_WellGeo)) deAllocate (TD_WellGeo) - Allocate (TD_WellGeo(TD_WellGeneral%WellIntervalsCount)) + if (Allocated(data%State%TD_WellGeo)) deAllocate (data%State%TD_WellGeo) + Allocate (data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)) @@ -21,29 +21,29 @@ subroutine TD_WellReadData ! Set Well Geometry Data !==================================================== - TD_WellGeo(1)%HoleType = PathGeneration%Items(1)%HoleType - TD_WellGeo(1)%StartAngle = 0.d0 ![rad] - TD_WellGeo(1)%EndAngle = PathGeneration%Items(1)%FinalAngle*(pi/180.d0) ![rad] - TD_WellGeo(1)%IntervalLength= PathGeneration%Items(1)%TotalLength ![ft] - !TD_WellGeo(1)%VerticalDepth = PathGenerations(1)%TotalVerticalDepth - TD_WellGeo(1)%TopDepth = 0.d0 - TD_WellGeo(1)%DownDepth = PathGeneration%Items(1)%MeasuredDepth + data%State%TD_WellGeo(1)%HoleType = PathGeneration%Items(1)%HoleType + data%State%TD_WellGeo(1)%StartAngle = 0.d0 ![rad] + data%State%TD_WellGeo(1)%EndAngle = PathGeneration%Items(1)%FinalAngle*(pi/180.d0) ![rad] + data%State%TD_WellGeo(1)%IntervalLength= PathGeneration%Items(1)%TotalLength ![ft] + !data%State%TD_WellGeo(1)%VerticalDepth = PathGenerations(1)%TotalVerticalDepth + data%State%TD_WellGeo(1)%TopDepth = 0.d0 + data%State%TD_WellGeo(1)%DownDepth = PathGeneration%Items(1)%MeasuredDepth - Do i=2,TD_WellGeneral%WellIntervalsCount-1 + Do i=2,data%State%TD_WellGeneral%WellIntervalsCount-1 - TD_WellGeo(i)%HoleType = PathGeneration%Items(i)%HoleType - TD_WellGeo(i)%StartAngle = PathGeneration%Items(i-1)%FinalAngle*(pi/180.d0) - TD_WellGeo(i)%EndAngle = PathGeneration%Items(i)%FinalAngle*(pi/180.d0) - TD_WellGeo(i)%IntervalLength= PathGeneration%Items(i)%TotalLength - !TD_WellGeo(i)%VerticalDepth = PathGeneration%Items(i)%TotalVerticalDepth - TD_WellGeo(i)%TopDepth = PathGeneration%Items(i-1)%MeasuredDepth - TD_WellGeo(i)%DownDepth = PathGeneration%Items(i)%MeasuredDepth + data%State%TD_WellGeo(i)%HoleType = PathGeneration%Items(i)%HoleType + data%State%TD_WellGeo(i)%StartAngle = PathGeneration%Items(i-1)%FinalAngle*(pi/180.d0) + data%State%TD_WellGeo(i)%EndAngle = PathGeneration%Items(i)%FinalAngle*(pi/180.d0) + data%State%TD_WellGeo(i)%IntervalLength= PathGeneration%Items(i)%TotalLength + !data%State%TD_WellGeo(i)%VerticalDepth = PathGeneration%Items(i)%TotalVerticalDepth + data%State%TD_WellGeo(i)%TopDepth = PathGeneration%Items(i-1)%MeasuredDepth + data%State%TD_WellGeo(i)%DownDepth = PathGeneration%Items(i)%MeasuredDepth !=====> Radius Of Curvature Calculation - if (TD_WellGeo(i)%HoleType/=0) then - TD_WellGeo(i)%RCurvature = ((TD_WellGeo(i)%IntervalLength)/abs(TD_WellGeo(i)%EndAngle-TD_WellGeo(i)%StartAngle)) + if (data%State%TD_WellGeo(i)%HoleType/=0) then + data%State%TD_WellGeo(i)%RCurvature = ((data%State%TD_WellGeo(i)%IntervalLength)/abs(data%State%TD_WellGeo(i)%EndAngle-data%State%TD_WellGeo(i)%StartAngle)) end if End Do @@ -53,13 +53,13 @@ subroutine TD_WellReadData !=====> Set ROP Hole Data - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%HoleType = 0 !Straight - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%StartAngle = TD_WellGeo(TD_WellGeneral%WellIntervalsCount-1)%EndAngle - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%EndAngle = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%StartAngle - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%IntervalLength= 0.d0 - !TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%VerticalDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount-1)%VerticalDepth - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%TopDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount-1)%DownDepth - TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%DownDepth = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%TopDepth+TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%IntervalLength + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%HoleType = 0 !Straight + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount-1)%EndAngle + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%EndAngle = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength= 0.d0 + !data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount-1)%VerticalDepth + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount-1)%DownDepth + data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth+data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength @@ -67,30 +67,30 @@ subroutine TD_WellReadData !=====> Vertical Depth Calculation - if ( TD_WellGeo(1)%HoleType==0 ) then - TD_WellGeo(1)%VerticalDepth = TD_WellGeo(1)%IntervalLength*cos(TD_WellGeo(1)%StartAngle) - else if ( TD_WellGeo(1)%HoleType==1 ) then - TD_WellGeo(1)%VerticalDepth = (TD_WellGeo(1)%RCurvature*sin(abs(TD_WellGeo(1)%EndAngle)-abs(TD_WellGeo(1)%StartAngle))*cos(abs(TD_WellGeo(1)%StartAngle)))-(TD_WellGeo(1)%RCurvature*(1.-cos(abs(TD_WellGeo(1)%EndAngle)-abs(TD_WellGeo(1)%StartAngle)))*sin(abs(TD_WellGeo(1)%StartAngle))) - else if ( TD_WellGeo(1)%HoleType==2 ) then - TD_WellGeo(1)%VerticalDepth = (TD_WellGeo(1)%RCurvature*sin(abs(abs(TD_WellGeo(1)%EndAngle)-abs(TD_WellGeo(1)%StartAngle)))*cos(abs(TD_WellGeo(1)%StartAngle)))+(TD_WellGeo(1)%RCurvature*(1.-cos(abs(abs(TD_WellGeo(1)%EndAngle)-abs(TD_WellGeo(1)%StartAngle))))*sin(abs(TD_WellGeo(1)%StartAngle))) + if ( data%State%TD_WellGeo(1)%HoleType==0 ) then + data%State%TD_WellGeo(1)%VerticalDepth = data%State%TD_WellGeo(1)%IntervalLength*cos(data%State%TD_WellGeo(1)%StartAngle) + else if ( data%State%TD_WellGeo(1)%HoleType==1 ) then + data%State%TD_WellGeo(1)%VerticalDepth = (data%State%TD_WellGeo(1)%RCurvature*sin(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle))*cos(abs(data%State%TD_WellGeo(1)%StartAngle)))-(data%State%TD_WellGeo(1)%RCurvature*(1.-cos(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle)))*sin(abs(data%State%TD_WellGeo(1)%StartAngle))) + else if ( data%State%TD_WellGeo(1)%HoleType==2 ) then + data%State%TD_WellGeo(1)%VerticalDepth = (data%State%TD_WellGeo(1)%RCurvature*sin(abs(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle)))*cos(abs(data%State%TD_WellGeo(1)%StartAngle)))+(data%State%TD_WellGeo(1)%RCurvature*(1.-cos(abs(abs(data%State%TD_WellGeo(1)%EndAngle)-abs(data%State%TD_WellGeo(1)%StartAngle))))*sin(abs(data%State%TD_WellGeo(1)%StartAngle))) End if - Do i= 2,TD_WellGeneral%WellIntervalsCount - if ( TD_WellGeo(i)%HoleType==0 ) then - TD_WellGeo(i)%VerticalDepth = TD_WellGeo(i-1)%VerticalDepth+TD_WellGeo(i)%IntervalLength*cos(TD_WellGeo(i)%StartAngle) - else if ( TD_WellGeo(i)%HoleType==1 ) then - TD_WellGeo(i)%VerticalDepth = TD_WellGeo(i-1)%VerticalDepth+(TD_WellGeo(i)%RCurvature*sin(abs(TD_WellGeo(i)%EndAngle)-abs(TD_WellGeo(i)%StartAngle))*cos(abs(TD_WellGeo(i)%StartAngle)))-(TD_WellGeo(i)%RCurvature*(1.-cos(abs(TD_WellGeo(i)%EndAngle)-abs(TD_WellGeo(i)%StartAngle)))*sin(abs(TD_WellGeo(i)%StartAngle))) - else if ( TD_WellGeo(i)%HoleType==2 ) then - TD_WellGeo(i)%VerticalDepth = TD_WellGeo(i-1)%VerticalDepth+(TD_WellGeo(i)%RCurvature*sin(abs(abs(TD_WellGeo(i)%EndAngle)-abs(TD_WellGeo(i)%StartAngle)))*cos(abs(TD_WellGeo(i)%StartAngle)))+(TD_WellGeo(i)%RCurvature*(1.-cos(abs(abs(TD_WellGeo(i)%EndAngle)-abs(TD_WellGeo(i)%StartAngle))))*sin(abs(TD_WellGeo(i)%StartAngle))) + Do i= 2,data%State%TD_WellGeneral%WellIntervalsCount + if ( data%State%TD_WellGeo(i)%HoleType==0 ) then + data%State%TD_WellGeo(i)%VerticalDepth = data%State%TD_WellGeo(i-1)%VerticalDepth+data%State%TD_WellGeo(i)%IntervalLength*cos(data%State%TD_WellGeo(i)%StartAngle) + else if ( data%State%TD_WellGeo(i)%HoleType==1 ) then + data%State%TD_WellGeo(i)%VerticalDepth = data%State%TD_WellGeo(i-1)%VerticalDepth+(data%State%TD_WellGeo(i)%RCurvature*sin(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle))*cos(abs(data%State%TD_WellGeo(i)%StartAngle)))-(data%State%TD_WellGeo(i)%RCurvature*(1.-cos(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle)))*sin(abs(data%State%TD_WellGeo(i)%StartAngle))) + else if ( data%State%TD_WellGeo(i)%HoleType==2 ) then + data%State%TD_WellGeo(i)%VerticalDepth = data%State%TD_WellGeo(i-1)%VerticalDepth+(data%State%TD_WellGeo(i)%RCurvature*sin(abs(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle)))*cos(abs(data%State%TD_WellGeo(i)%StartAngle)))+(data%State%TD_WellGeo(i)%RCurvature*(1.-cos(abs(abs(data%State%TD_WellGeo(i)%EndAngle)-abs(data%State%TD_WellGeo(i)%StartAngle))))*sin(abs(data%State%TD_WellGeo(i)%StartAngle))) End if End Do - !Do i=1,TD_WellGeneral%WellIntervalsCount - ! print*, 'TD_WellGeo(i)%TopDepth=' , i , TD_WellGeo(i)%TopDepth - ! print*, 'TD_WellGeo(i)%DownDepth=' , i , TD_WellGeo(i)%DownDepth - ! print*, 'TD_WellGeo(i)%HoleType=' , i , TD_WellGeo(i)%HoleType - ! print*, 'TD_WellGeo(i)%RCurvature=' , i , TD_WellGeo(i)%RCurvature - ! print*, 'TD_WellGeo(i)%EndAngle=' , i , TD_WellGeo(i)%EndAngle - ! print*, 'TD_WellGeo(i)%StartAngle=' , i , TD_WellGeo(i)%StartAngle - ! print*, 'TD_WellGeo(i)%VerticalDepth=' , i , TD_WellGeo(i)%VerticalDepth + !Do i=1,data%State%TD_WellGeneral%WellIntervalsCount + ! print*, 'data%State%TD_WellGeo(i)%TopDepth=' , i , data%State%TD_WellGeo(i)%TopDepth + ! print*, 'data%State%TD_WellGeo(i)%DownDepth=' , i , data%State%TD_WellGeo(i)%DownDepth + ! print*, 'data%State%TD_WellGeo(i)%HoleType=' , i , data%State%TD_WellGeo(i)%HoleType + ! print*, 'data%State%TD_WellGeo(i)%RCurvature=' , i , data%State%TD_WellGeo(i)%RCurvature + ! print*, 'data%State%TD_WellGeo(i)%EndAngle=' , i , data%State%TD_WellGeo(i)%EndAngle + ! print*, 'data%State%TD_WellGeo(i)%StartAngle=' , i , data%State%TD_WellGeo(i)%StartAngle + ! print*, 'data%State%TD_WellGeo(i)%VerticalDepth=' , i , data%State%TD_WellGeo(i)%VerticalDepth !end do @@ -100,8 +100,8 @@ subroutine TD_WellReadData !=====> Well Total Length Calculation - TD_WellGeneral%WellTotalLength = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%DownDepth - TD_WellGeneral%WellTotalVerticalLength = TD_WellGeo(TD_WellGeneral%WellIntervalsCount)%VerticalDepth + data%State%TD_WellGeneral%WellTotalLength = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth + data%State%TD_WellGeneral%WellTotalVerticalLength = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth diff --git a/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 b/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 index a4aa178..90eecfa 100644 --- a/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 +++ b/TorqueDrag/TD_StartUp/TD_DrillStemStartUp.f90 @@ -4,9 +4,9 @@ subroutine TD_DrillStemStartUp Use CStringConfigurationVariables ! Use CSimulationVariables Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData @@ -15,64 +15,64 @@ subroutine TD_DrillStemStartUp - TD_String%DrillStemTotalLength = 500.d0 !??????????????????? - TD_String%DrillStemTotalLengthIni = 500.d0 !??????????????????? - TD_String%OutOfWellLength = 3.48d0 - TD_String%DrillStemAxialVelocity = 0.d0 - TD_String%DrillStemRotVelocity = 0.d0 - TD_String%WeightOnBit = 0.d0 - TD_String%BitTorque = 0.d0 - TD_String%TotalTorque = 0.d0 - TD_String%StaticHookLoad = 0.d0 - TD_String%DlMax = 0.d0 - TD_String%DlTotal = 0.d0 - TD_String%DlTouch = 1.d0 !(=/0.) because of TD_StringConnectionModes subroutine (initial value for first iteration in if condition) - TD_String%HookLoad = 0.d0 - TD_String%StringTorque = 0.d0 - TD_String%ToolJointRange = 0.4005d0*3.28d0 ![m]*3.28=[ft] , ToolJointLength=400.5mm - TD_Vol%RemoveVolume = 0.0d0 + data%State%TD_String%DrillStemTotalLength = 500.d0 !??????????????????? + data%State%TD_String%DrillStemTotalLengthIni = 500.d0 !??????????????????? + data%State%TD_String%OutOfWellLength = 3.48d0 + data%State%TD_String%DrillStemAxialVelocity = 0.d0 + data%State%TD_String%DrillStemRotVelocity = 0.d0 + data%State%TD_String%WeightOnBit = 0.d0 + data%State%TD_String%BitTorque = 0.d0 + data%State%TD_String%TotalTorque = 0.d0 + data%State%TD_String%StaticHookLoad = 0.d0 + data%State%TD_String%DlMax = 0.d0 + data%State%TD_String%DlTotal = 0.d0 + data%State%TD_String%DlTouch = 1.d0 !(=/0.) because of TD_StringConnectionModes subroutine (initial value for first iteration in if condition) + data%State%TD_String%HookLoad = 0.d0 + data%State%TD_String%StringTorque = 0.d0 + data%State%TD_String%ToolJointRange = 0.4005d0*3.28d0 ![m]*3.28=[ft] , ToolJointLength=400.5mm + data%State%TD_Vol%RemoveVolume = 0.0d0 - TD_String%DrillStemBottom = TD_String%DrillStemTotalLength-TD_String%OutOfWellLength !???????????? - !TD_DrillStems%TopDepth = - !TD_DrillStems%DownDepth = - !TD_DrillStems%StartAngle = - !TD_DrillStems%EndAngle = - TD_DrillStems%Area = 0.d0 - TD_DrillStems%RCurvature = 0.d0 - TD_DrillStems%RtoolJoint = 0.d0 - TD_DrillStems%ToolJointRange = 0.d0 - TD_DrillStems%HoleDiameter = 0.d0 + data%State%TD_String%DrillStemBottom = data%State%TD_String%DrillStemTotalLength-data%State%TD_String%OutOfWellLength !???????????? + !data%State%TD_DrillStems%TopDepth = + !data%State%TD_DrillStems%DownDepth = + !data%State%TD_DrillStems%StartAngle = + !data%State%TD_DrillStems%EndAngle = + data%State%TD_DrillStems%Area = 0.d0 + data%State%TD_DrillStems%RCurvature = 0.d0 + data%State%TD_DrillStems%RtoolJoint = 0.d0 + data%State%TD_DrillStems%ToolJointRange = 0.d0 + data%State%TD_DrillStems%HoleDiameter = 0.d0 - TD_DrillStems%Force1 = 0.d0 - TD_DrillStems%Force2 = 0.d0 - TD_DrillStems%Torque = 0.d0 - TD_DrillStems%Drag = 0.d0 - TD_DrillStems%CombVelRatio = 0.d0 + data%State%TD_DrillStems%Force1 = 0.d0 + data%State%TD_DrillStems%Force2 = 0.d0 + data%State%TD_DrillStems%Torque = 0.d0 + data%State%TD_DrillStems%Drag = 0.d0 + data%State%TD_DrillStems%CombVelRatio = 0.d0 - TD_DrillStems%MudDensityIn = 10.d0*7.48051948d0 - TD_DrillStems%MudDensityOut = 10.d0*7.48051948d0 - TD_DrillStems%MudViscosity = 0.16d0 !???????????????? - TD_DrillStems%MudVisCorrectCoef = 1.d0 !???????????????? - TD_DrillStems%MudWeight = 10.d0 - !TD_DrillStems%MudPlasticVis = !???????????????? - !TD_DrillStems%MudYieldPoint = !???????????????? + data%State%TD_DrillStems%MudDensityIn = 10.d0*7.48051948d0 + data%State%TD_DrillStems%MudDensityOut = 10.d0*7.48051948d0 + data%State%TD_DrillStems%MudViscosity = 0.16d0 !???????????????? + data%State%TD_DrillStems%MudVisCorrectCoef = 1.d0 !???????????????? + data%State%TD_DrillStems%MudWeight = 10.d0 + !data%State%TD_DrillStems%MudPlasticVis = !???????????????? + !data%State%TD_DrillStems%MudYieldPoint = !???????????????? - !TD_DrillStems%FricFactor = - !TD_DrillStems% = - !TD_DrillStems% = + !data%State%TD_DrillStems%FricFactor = + !data%State%TD_DrillStems% = + !data%State%TD_DrillStems% = - !TD_DrillStems%StaticHookLoad = - !TD_DrillStems%TotalSHookLoad = - !TD_DrillStems%Dl = - !TD_DrillStems%DlTotal = + !data%State%TD_DrillStems%StaticHookLoad = + !data%State%TD_DrillStems%TotalSHookLoad = + !data%State%TD_DrillStems%Dl = + !data%State%TD_DrillStems%DlTotal = - !if (allocated(TD_String%FluidMudDensity)) deallocate(TD_String%FluidMudDensity) - !if (allocated(TD_String%FluidMudEndX)) deallocate(TD_String%FluidMudEndX) - !if (allocated(TD_String%FluidMudStartX)) deallocate(TD_String%FluidMudStartX) - !Allocate (TD_String%FluidMudDensity(1) , TD_String%FluidMudEndX(1) , TD_String%FluidMudStartX(1)) - !TD_String%FluidMudDensity(:) = 10.d0 - !TD_String%FluidMudStartX(:) = -268.d0 !?????????? - !TD_String%FluidMudEndX(:) = 9990.d0 !?????????? + !if (allocated(data%State%TD_String%FluidMudDensity)) deallocate(data%State%TD_String%FluidMudDensity) + !if (allocated(data%State%TD_String%FluidMudEndX)) deallocate(data%State%TD_String%FluidMudEndX) + !if (allocated(data%State%TD_String%FluidMudStartX)) deallocate(data%State%TD_String%FluidMudStartX) + !Allocate (data%State%TD_String%FluidMudDensity(1) , data%State%TD_String%FluidMudEndX(1) , data%State%TD_String%FluidMudStartX(1)) + !data%State%TD_String%FluidMudDensity(:) = 10.d0 + !data%State%TD_String%FluidMudStartX(:) = -268.d0 !?????????? + !data%State%TD_String%FluidMudEndX(:) = 9990.d0 !?????????? diff --git a/TorqueDrag/TD_StartUp/TD_StartUp.f90 b/TorqueDrag/TD_StartUp/TD_StartUp.f90 index db9c288..0d65c4d 100644 --- a/TorqueDrag/TD_StartUp/TD_StartUp.f90 +++ b/TorqueDrag/TD_StartUp/TD_StartUp.f90 @@ -4,15 +4,17 @@ subroutine TD_StartUp Use CStringConfigurationVariables ! use CSimulationVariables use UnitySignalVariables - ! Use COperationConditionEnumVariables - Use CHoistingVariables - Use CPathGenerationVariables + use UnitySignalsModule + ! use UnitySignalsModuleVariables + use CHoistingVariables + use ConfigurationVariables + use ConfigurationVariables !@ Use TD_DrillStemComponents - Use TD_WellElements - Use TD_WellGeometry - Use TD_GeneralData + use ConfigurationVariables !@ + use ConfigurationVariables !@ + use ConfigurationVariables !@ Use TD_StringConnectionData - Use Drawworks_VARIABLES!, only: Drawworks + use ConfigurationVariables !@!, only: Drawworks Use sROP_Variables Use sROP_Other_Variables @@ -24,133 +26,133 @@ subroutine TD_StartUp !! Allocate Modules !!==================================================== ! !=====> Set WellGeo Dimension -! TD_WellGeneral%WellIntervalsCount = PathGeneration%ItemCount + 1 ! +1 is belong to ROP hole -! Allocate (TD_WellGeo(TD_WellGeneral%WellIntervalsCount)) +! data%State%TD_WellGeneral%WellIntervalsCount = PathGeneration%ItemCount + 1 ! +1 is belong to ROP hole +! Allocate (data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)) ! ! !=====> Set WellGeo Dimension !=====> Set ROP StartUp - ROP_Bit%BitWearing = 0.d0 - ROP_Bit%RateOfPenetration = 0.d0 - ROP_Bit%BearingWear = 0.d0 - ROP_Spec%FormationNumber = 0 - ROP_Bit%OldROPDepth = PathGeneration%Items(PathGeneration%ItemCount)%MeasuredDepth - ROP_Bit%OldROPValue = 0.d0 - ROP_Bit%SetROPGauge = 0.d0 + data%State%ROP_Bit%BitWearing = 0.d0 + data%State%ROP_Bit%RateOfPenetration = 0.d0 + data%State%ROP_Bit%BearingWear = 0.d0 + data%State%ROP_Spec%FormationNumber = 0 + data%State%ROP_Bit%OldROPDepth = PathGeneration%Items(PathGeneration%ItemCount)%MeasuredDepth + data%State%ROP_Bit%OldROPValue = 0.d0 + data%State%ROP_Bit%SetROPGauge = 0.d0 !=====> Set BOP StartUp - TD_BOP%BOPCondition = 0 - TD_BOP%BOPThickness = (0.13477d0/2.d0)*3.28d0 ![m]*3.28=[ft] , Total Thickness (RAM)= 134.77mm - TD_BOP%AnnularFillingFinal = 0.d0 + data%State%TD_BOP%BOPCondition = 0 + data%State%TD_BOP%BOPThickness = (0.13477d0/2.d0)*3.28d0 ![m]*3.28=[ft] , Total Thickness (RAM)= 134.77mm + data%State%TD_BOP%AnnularFillingFinal = 0.d0 - Drawworks%TDHookHeight = 75.d0 ![ft] - Drawworks%Hook_Height_ini = 75.d0 ![ft] - Drawworks%Hook_Height_final = 75.d0 ![ft] + data%State%Drawworks%TDHookHeight = 75.d0 ![ft] + data%State%Drawworks%Hook_Height_ini = 75.d0 ![ft] + data%State%Drawworks%Hook_Height_final = 75.d0 ![ft] !=====> String Connection Mode if ( Get_OperationCondition()==OPERATION_TRIP ) then - TD_StConn%OldOperationCondition = 1 + data%State%TD_StConn%OldOperationCondition = 1 else - TD_StConn%OldOperationCondition = 0 + data%State%TD_StConn%OldOperationCondition = 0 end if - TD_StConn%KellyDriveTypeMode = 0 !Kelly Mode - TD_StConn%FluidStringConnectionMode = 0 - TD_StConn%ConnectionHeight = 3.48d0 ![ft] - TD_StConn%RigidConnectionHeight = 3.48d0 ![ft] - TD_StConn%GRigidConnectionHeight = 3.48d0 ![ft] - TD_String%TopJointHeight = 3.48d0 ![ft] - !TD_StConn%TouchConnectionHeight = - TD_StConn%StringVelocity = 0.0d0 - TD_StConn%HookHeightOld = 75.d0 ![ft] - TD_StConn%HookHeight = 75.d0 ![ft] - TD_StConn%HookVelocity = 0.0d0 + data%State%TD_StConn%KellyDriveTypeMode = 0 !Kelly Mode + data%State%TD_StConn%FluidStringConnectionMode = 0 + data%State%TD_StConn%ConnectionHeight = 3.48d0 ![ft] + data%State%TD_StConn%RigidConnectionHeight = 3.48d0 ![ft] + data%State%TD_StConn%GRigidConnectionHeight = 3.48d0 ![ft] + data%State%TD_String%TopJointHeight = 3.48d0 ![ft] + !data%State%TD_StConn%TouchConnectionHeight = + data%State%TD_StConn%StringVelocity = 0.0d0 + data%State%TD_StConn%HookHeightOld = 75.d0 ![ft] + data%State%TD_StConn%HookHeight = 75.d0 ![ft] + data%State%TD_StConn%HookVelocity = 0.0d0 !=====> Element Specification - TD_StConn%HookHeight = Drawworks%TDHookHeight ! unit: [ft] - TD_StConn%ElevatorConst = 17.985 ! [ft] Elevator Length(14.84) ????????????????? adad ha daghigh shavand - TD_StConn%ElevatorECG = 2.217 ! [ft] - TD_StConn%KellyConst = 63.280d0 ! [ft] Kelly Length(61.74) + Safety Valve Length(1.54) - TD_StConn%KellyElementConst = 41.840d0 ! [ft] Kelly Element Length(40.3) + Safety Valve Length(1.54) - TD_StConn%TDSLength = 24.08d0 !??????????????????? ! [ft] - TD_StConn%TDSToolJointLength = 0.77d0 !??????????????????? ! [ft] - TD_StConn%TDSElevatorLength = 26.837d0 !?????? ! TDS with Elevator Length [ft] - TD_StConn%TDSElevatorToolLength= 0.859d0 !??????????????????? ! [ft] - TD_StConn%TDSElevatorECG = 2.454 ! [ft] - TD_Load%NumOfCables = Hoisting%NumberOfLine - TD_Load%WeightTB = Hoisting%TravelingBlockWeight ! [lb] - TD_Load%WeightTD = Hoisting%TopDriveWeight ! [lb] - TD_Load%KellyWeight = Hoisting%KellyWeight ! [lb] - TD_StConn%SafetyValveLength = 1.54d0 ! [ft] - TD_StConn%IBOPLength = 1.54d0 ! [ft] - TD_StConn%KellyElementID = 3.0d0/12.d0 ! [ft] - TD_StConn%KellyElementOD = 5.90d0/12.d0 ! [ft] - TD_Load%DrawworksLoadInput = Hoisting%TravelingBlockWeight/Hoisting%NumberOfLine - - TD_Count%IBOPNewAdd = 0 - TD_Count%IBOPOldAdd = 0 !Remove - TD_Count%SafetyValveNewAdd = 0 - TD_Count%SafetyValveOldAdd = 1 !Install - TD_Count%KellyNewAdd = 0 - TD_Count%KellyOldAdd = 0 - TD_Count%IBOPNewRemove = 0 - TD_Count%IBOPOldRemove = 1 !Remove - TD_Count%SafetyValveNewRemove = 0 - TD_Count%SafetyValveOldRemove = 0 !Install - TD_Count%KellyNewRemove = 0 - TD_Count%KellyOldRemove = 1 - - TD_Count%KellyOldStatus(1) = 0 - TD_Count%KellyNewStatus(1) = 0 - TD_Count%KellyOldStatus(2) = 1 ! Kelly Connected Nothing - TD_Count%KellyNewStatus(2) = 1 ! Kelly Connected Nothing - TD_Count%KellyOldStatus(3) = 0 - TD_Count%KellyNewStatus(3) = 0 - - TD_Count%KellyOldStatus(4) = 0 - TD_Count%KellyNewStatus(4) = 0 - TD_Count%KellyOldStatus(5) = 0 - TD_Count%KellyNewStatus(5) = 0 - TD_Count%KellyOldStatus(6) = 0 - TD_Count%KellyNewStatus(6) = 0 - TD_Count%KellyOldStatus(7) = 0 - TD_Count%KellyNewStatus(7) = 0 - TD_Count%KellyOldStatus(8) = 0 - TD_Count%KellyNewStatus(8) = 0 - TD_Count%KellyOldStatus(18) = 0 - TD_Count%KellyNewStatus(18) = 0 - TD_Count%KellyOldStatus(19) = 0 - TD_Count%KellyNewStatus(19) = 0 - - TD_Count%KellyOldStatus(9) = 0 - TD_Count%KellyNewStatus(9) = 0 - TD_Count%KellyOldStatus(10) = 0 - TD_Count%KellyNewStatus(10) = 0 - TD_Count%KellyOldStatus(11) = 0 - TD_Count%KellyNewStatus(11) = 0 - TD_Count%KellyOldStatus(12) = 0 - TD_Count%KellyNewStatus(12) = 0 - TD_Count%KellyOldStatus(13) = 1 - TD_Count%KellyNewStatus(13) = 1 - TD_Count%KellyOldStatus(14) = 0 - TD_Count%KellyNewStatus(14) = 0 - TD_Count%KellyOldStatus(15) = 0 - TD_Count%KellyNewStatus(15) = 0 - TD_Count%KellyOldStatus(16) = 0 - TD_Count%KellyNewStatus(16) = 0 - TD_Count%KellyOldStatus(17) = 0 - TD_Count%KellyNewStatus(17) = 0 + data%State%TD_StConn%HookHeight = data%State%Drawworks%TDHookHeight ! unit: [ft] + data%State%TD_StConn%ElevatorConst = 17.985 ! [ft] Elevator Length(14.84) ????????????????? adad ha daghigh shavand + data%State%TD_StConn%ElevatorECG = 2.217 ! [ft] + data%State%TD_StConn%KellyConst = 63.280d0 ! [ft] Kelly Length(61.74) + Safety Valve Length(1.54) + data%State%TD_StConn%KellyElementConst = 41.840d0 ! [ft] Kelly Element Length(40.3) + Safety Valve Length(1.54) + data%State%TD_StConn%TDSLength = 24.08d0 !??????????????????? ! [ft] + data%State%TD_StConn%TDSToolJointLength = 0.77d0 !??????????????????? ! [ft] + data%State%TD_StConn%TDSElevatorLength = 26.837d0 !?????? ! TDS with Elevator Length [ft] + data%State%TD_StConn%TDSElevatorToolLength= 0.859d0 !??????????????????? ! [ft] + data%State%TD_StConn%TDSElevatorECG = 2.454 ! [ft] + data%State%TD_Load%NumOfCables = data%State%Hoisting%NumberOfLine + data%State%TD_Load%WeightTB = data%State%Hoisting%TravelingBlockWeight ! [lb] + data%State%TD_Load%WeightTD = data%State%Hoisting%TopDriveWeight ! [lb] + data%State%TD_Load%KellyWeight = data%State%Hoisting%KellyWeight ! [lb] + data%State%TD_StConn%SafetyValveLength = 1.54d0 ! [ft] + data%State%TD_StConn%IBOPLength = 1.54d0 ! [ft] + data%State%TD_StConn%KellyElementID = 3.0d0/12.d0 ! [ft] + data%State%TD_StConn%KellyElementOD = 5.90d0/12.d0 ! [ft] + data%State%TD_Load%DrawworksLoadInput = data%State%Hoisting%TravelingBlockWeight/data%State%Hoisting%NumberOfLine + + data%State%TD_Count%IBOPNewAdd = 0 + data%State%TD_Count%IBOPOldAdd = 0 !Remove + data%State%TD_Count%SafetyValveNewAdd = 0 + data%State%TD_Count%SafetyValveOldAdd = 1 !Install + data%State%TD_Count%KellyNewAdd = 0 + data%State%TD_Count%KellyOldAdd = 0 + data%State%TD_Count%IBOPNewRemove = 0 + data%State%TD_Count%IBOPOldRemove = 1 !Remove + data%State%TD_Count%SafetyValveNewRemove = 0 + data%State%TD_Count%SafetyValveOldRemove = 0 !Install + data%State%TD_Count%KellyNewRemove = 0 + data%State%TD_Count%KellyOldRemove = 1 + + data%State%TD_Count%KellyOldStatus(1) = 0 + data%State%TD_Count%KellyNewStatus(1) = 0 + data%State%TD_Count%KellyOldStatus(2) = 1 ! Kelly Connected Nothing + data%State%TD_Count%KellyNewStatus(2) = 1 ! Kelly Connected Nothing + data%State%TD_Count%KellyOldStatus(3) = 0 + data%State%TD_Count%KellyNewStatus(3) = 0 + + data%State%TD_Count%KellyOldStatus(4) = 0 + data%State%TD_Count%KellyNewStatus(4) = 0 + data%State%TD_Count%KellyOldStatus(5) = 0 + data%State%TD_Count%KellyNewStatus(5) = 0 + data%State%TD_Count%KellyOldStatus(6) = 0 + data%State%TD_Count%KellyNewStatus(6) = 0 + data%State%TD_Count%KellyOldStatus(7) = 0 + data%State%TD_Count%KellyNewStatus(7) = 0 + data%State%TD_Count%KellyOldStatus(8) = 0 + data%State%TD_Count%KellyNewStatus(8) = 0 + data%State%TD_Count%KellyOldStatus(18) = 0 + data%State%TD_Count%KellyNewStatus(18) = 0 + data%State%TD_Count%KellyOldStatus(19) = 0 + data%State%TD_Count%KellyNewStatus(19) = 0 + + data%State%TD_Count%KellyOldStatus(9) = 0 + data%State%TD_Count%KellyNewStatus(9) = 0 + data%State%TD_Count%KellyOldStatus(10) = 0 + data%State%TD_Count%KellyNewStatus(10) = 0 + data%State%TD_Count%KellyOldStatus(11) = 0 + data%State%TD_Count%KellyNewStatus(11) = 0 + data%State%TD_Count%KellyOldStatus(12) = 0 + data%State%TD_Count%KellyNewStatus(12) = 0 + data%State%TD_Count%KellyOldStatus(13) = 1 + data%State%TD_Count%KellyNewStatus(13) = 1 + data%State%TD_Count%KellyOldStatus(14) = 0 + data%State%TD_Count%KellyNewStatus(14) = 0 + data%State%TD_Count%KellyOldStatus(15) = 0 + data%State%TD_Count%KellyNewStatus(15) = 0 + data%State%TD_Count%KellyOldStatus(16) = 0 + data%State%TD_Count%KellyNewStatus(16) = 0 + data%State%TD_Count%KellyOldStatus(17) = 0 + data%State%TD_Count%KellyNewStatus(17) = 0 !=====> Problems - TD_General%WeightIndicatorMalf = 0 + data%State%TD_General%WeightIndicatorMalf = 0 end subroutine \ No newline at end of file diff --git a/TorqueDrag/TorqueDragMain.f90 b/TorqueDrag/TorqueDragMain.f90 index 71daa0c..4e93e3b 100644 --- a/TorqueDrag/TorqueDragMain.f90 +++ b/TorqueDrag/TorqueDragMain.f90 @@ -1,9 +1,13 @@ MODULE TorqueDragMain - USE CPumpsVariables - USE CDrillingConsoleVariables - USE CDataDisplayConsoleVariables + use CPumpsVariables + use CPumps + use CDrillingConsoleVariables + use ConfigurationVariables + use ConfigurationVariables + use CDataDisplayConsole + use ConfigurationVariables ! USE CSimulationVariables - USE Pumps_VARIABLES + use ConfigurationVariables IMPLICIT NONE PUBLIC CONTAINS diff --git a/helper.ipynb b/helper.ipynb index e268f4b..b7680a0 100644 --- a/helper.ipynb +++ b/helper.ipynb @@ -265,33 +265,154 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "State\n", + "Hoisting\n", + "OperationScenario\n", + "notifications\n", + "permissions\n", + "unitySignals\n", + "StudentStation\n", + "BopStackInput\n", + "BopStackAcc\n", + "RamLine\n", + "AnnularComputational\n", + "Annular\n", + "PipeRam1\n", + "ShearRam\n", + "PipeRam2\n", + "ChokeLine\n", + "KillLine\n", + "Pumps\n", + "RAM\n", + "RAMS\n", + "Choke\n", + "AirDrivenPump\n", + "AirPumpLine\n", + "CHOOKE\n", + "Drawworks\n", + "MudSystem\n", + "MUD\n", + "PUMP\n", + "RTable\n", + "TDS\n", + "GasType(3)\n", + "PressureDisplay\n", + "ObservationPoint(:)\n", + "FricPressDrop\n", + "ROP_Spec\n", + "ROP_Bit\n", + "TDGeo\n", + "F_String(:)\n", + "F_Counts\n", + "F_Interval(:)\n", + "OD_Annulus(4)\n", + "TD_DrillStem\n", + "TD_DrillStems\n", + "TD_String\n", + "TD_Count\n", + "G_StringElement\n", + "TD_Vol\n", + "TD_General\n", + "TD_BOP\n", + "TD_BOPElement(4)\n", + "TD_StConn\n", + "TD_Load\n", + "TD_WellEl\n", + "TD_Casing\n", + "data%State%TD_Liner\n", + "TD_OpenHole\n", + "TD_ROPHole\n", + "TD_WellGeneral\n", + "TD_WellGeo(:)\n", + "EquipmentControl\n", + "BopControlPanel\n", + "ChokeControlPanel\n", + "ChokeManifold\n", + "DataDisplayConsole\n", + "DrillingConsole\n", + "Hook\n", + "StandPipeManifold\n", + "TopDrivePanel\n", + "DrillingWatch\n", + "Tank\n", + "Configuration\n", + "StringConfiguration\n", + "Formation\n", + "Reservoir\n", + "Shoe\n", + "Accumulator\n", + "BopStackSpecification\n", + "Hoisting\n", + "Power\n", + "PumpsSpecification\n", + "RigSize\n", + "CasingLinerChoke\n", + "PathGeneration\n", + "WellSurveyData\n", + "MudProperties\n", + "problems\n", + "BitProblems\n", + "BopProblems\n", + "ChokeProblems\n", + "DrillStemProblems\n", + "GaugesProblems\n", + "HoistingProblems\n", + "KickProblems\n", + "LostProblems\n", + "MudTreatmentProblems\n", + "OtherProblems\n", + "PumpProblems\n", + "RotaryProblems\n" + ] + }, + { + "ename": "IndexError", + "evalue": "list index out of range", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Projects\\VSIM\\SimulationCore2\\helper.ipynb Cell 6\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m nsp\u001b[39m+\u001b[39m\u001b[39m=\u001b[39m\u001b[39m1\u001b[39m\n\u001b[0;32m 7\u001b[0m splits \u001b[39m=\u001b[39m line\u001b[39m.\u001b[39msplit(\u001b[39m\"\u001b[39m\u001b[39m::\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m----> 8\u001b[0m \u001b[39mprint\u001b[39m(splits[\u001b[39m1\u001b[39;49m]\u001b[39m.\u001b[39mstrip())\n", + "\u001b[1;31mIndexError\u001b[0m: list index out of range" + ] + } + ], + "source": [ + "f = open(\"hier.txt\")\n", + "lines = f.readlines()\n", + "for line in lines[1:]:\n", + " nsp=0\n", + " while line[nsp]==' ':\n", + " nsp+=1\n", + " splits = line.split(\"::\")\n", + " print(splits[1].strip())" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('.',\n", - " ['.git',\n", - " '.vs',\n", - " 'Common',\n", - " 'CSharp',\n", - " 'Equipments',\n", - " 'FluidFlow',\n", - " 'Geo',\n", - " 'lib',\n", - " 'Rop',\n", - " 'TorqueDrag',\n", - " 'x64'])" + "'type SimulationDataType type(SimulationStateType)::State Type(HoistingType)::Hoisting type(OperationScenarioType)::OperationScenario type(NotificationType)::notifications type(PermissionsType):: permissions type(UnitySignalsType):: unitySignals type(StudentStationType)::StudentStation type(BopStackInputType)::BopStackInput type(BopStackAccType)::BopStackAcc type(RamLineType)::RamLine type(AnnularComputationalType)::AnnularComputational type(AnnularType)::Annular type(PipeRams1Type)::PipeRam1 type(ShearRamType)::ShearRam type(PipeRam2Type)::PipeRam2 type(ChokeLineType)::ChokeLine type(KillLineType)::KillLine type(PumpsType)::Pumps TYPE(BOP_TypeVars), DIMENSION(1:6) :: RAM TYPE(BOP_TypeVars2D) :: RAMS type(ChokeType)::Choke type(AirDrivenPumpType)::AirDrivenPump type(AirPumpLineType)::AirPumpLine TYPE(CHOKE_TypeVars), DIMENSION(1:2) :: CHOOKE TYPE(Drawworks_Var) :: Drawworks type(MudSystemType)::MudSystem TYPE(MUD_TypeVars), DIMENSION(1:10) :: MUD TYPE(Pump_Var), DIMENSION(1:3) :: PUMP TYPE(RTable_Var) :: RTable TYPE(TDS_Var) :: TDS TYPE(GasData) :: GasType(3) ! 1 = methane , 2 = Hydrogen sulfide , 3 = Carbon dioxid TYPE(PressureDisplayVARIABLESTYPE) :: PressureDisplay TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: ObservationPoint(:) TYPE(FricPressDropVarsTYPE) :: FricPressDrop TYPE(ROPSpecificationInfo) :: ROP_Spec TYPE(ROPInfo) :: ROP_Bit TYPE(Geo_Data) :: TDGeo TYPE(F_StringData) , Allocatable :: F_String(:) TYPE(F_IntervalsCountsData):: F_Counts TYPE(F_IntervalData) , Allocatable :: F_Interval(:) TYPE(OD_AnnulusData) :: OD_Annulus(4) TYPE(TD_DrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStem TYPE(TD_SeparatedDrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStems TYPE(TD_StringInfo) :: TD_String TYPE(TD_AddRemoveInfo) :: TD_Count TYPE(CStringComponents), ALLOCATABLE, DIMENSION(:) :: G_StringElement TYPE(TD_RemovedVolumeInfo) :: TD_Vol TYPE(TD_GeneralInfo) :: TD_General TYPE(TD_BOPInfo) :: TD_BOP TYPE(CBopElement) :: TD_BOPElement(4) TYPE(TD_StringconnectionInfo) :: TD_StConn TYPE(TD_LoadInfo) :: TD_Load TYPE(TD_WellElementsInfo) :: TD_WellEl TYPE(TD_CasingInfo), ALLOCATABLE, DIMENSION(:) :: TD_Casing TYPE(TD_LinerInfo), ALLOCATABLE, DIMENSION(:) :: data%State%TD_Liner TYPE(TD_OpenHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_OpenHole TYPE(TD_ROPHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_ROPHole TYPE(TD_WellGeneralInfo) :: TD_WellGeneral TYPE(TD_WellGeometryData), Allocatable :: TD_WellGeo(:) type(EquipmentControlType)::EquipmentControl type(BopControlPanelType) :: BopControlPanel Type(ChokeControlPanelType)::ChokeControlPanel Type(ChokeManifoldType)::ChokeManifold Type(DataDisplayConsoleType) :: DataDisplayConsole TYPE(DrillingConsoleType) :: DrillingConsole Type(HookType)::Hook type(StandPipeManifoldType)::StandPipeManifold Type(TopDrivePanelType)::TopDrivePanel Type(DrillingWatchType)::DrillingWatch Type(TankType)::Tank type(ConfigurationType)::Configuration Type(StringConfigurationType)::StringConfiguration Type(FormationType) :: Formation Type(ReservoirType)::Reservoir Type(ShoeType)::Shoe Type(AccumulatorType)::Accumulator Type(BopStackSpecificationType)::BopStackSpecification Type(HoistingType)::Hoisting Type(PowerType)::Power Type(PumpSpecificationType)::PumpsSpecification Type(RigSizeType)::RigSize Type(CasingLinerChokeType)::CasingLinerChoke Type(PathGenerationType)::PathGeneration Type(WellSurveyDataType)::WellSurveyData Type(MudPropertiesType)::MudProperties type(ProblemsType)::problems type(BitProblemsType)::BitProblems type(BopProblemsType)::BopProblems type(ChokeProblemsType)::ChokeProblems type(DrillStemProblemsType)::DrillStemProblems type(GaugesProblemsType)::GaugesProblems type(HoistingProblemsType):: HoistingProblems type(KickProblemsType)::KickProblems type(LostProblemsType)::LostProblems type(MudTreatmentProblemsType)::MudTreatmentProblems type(OtherProblemsType)::OtherProblems type(PumpProblemsType)::PumpProblems type(RotaryProblemsType)::RotaryProblems end type SimulationDataType'" ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "dir,subdirs" + "line" ] }, { diff --git a/hier.txt b/hier.txt new file mode 100644 index 0000000..c93c709 --- /dev/null +++ b/hier.txt @@ -0,0 +1,101 @@ +type::SimulationDataType + type(SimulationStateType)::State + Type(HoistingType)::Hoisting + type(OperationScenarioType)::OperationScenario + type(NotificationType)::notifications + type(PermissionsType):: permissions + type(UnitySignalsType):: unitySignals + type(StudentStationType)::StudentStation + type(BopStackInputType)::BopStackInput + type(BopStackAccType)::BopStackAcc + type(RamLineType)::RamLine + type(AnnularComputationalType)::AnnularComputational + type(AnnularType)::Annular + type(PipeRams1Type)::PipeRam1 + type(ShearRamType)::ShearRam + type(PipeRam2Type)::PipeRam2 + type(ChokeLineType)::ChokeLine + type(KillLineType)::KillLine + type(PumpsType)::Pumps + TYPE(BOP_TypeVars), DIMENSION(1:6) :: RAM + TYPE(BOP_TypeVars2D) :: RAMS + type(ChokeType)::Choke + type(AirDrivenPumpType)::AirDrivenPump + type(AirPumpLineType)::AirPumpLine + TYPE(CHOKE_TypeVars), DIMENSION(1:2) :: CHOOKE + TYPE(Drawworks_Var) :: Drawworks + type(MudSystemType)::MudSystem + TYPE(MUD_TypeVars), DIMENSION(1:10) :: MUD + TYPE(Pump_Var), DIMENSION(1:3) :: PUMP + TYPE(RTable_Var) :: RTable + TYPE(TDS_Var) :: TDS + TYPE(GasData) :: GasType(3) + TYPE(PressureDisplayVARIABLESTYPE) :: PressureDisplay + TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: ObservationPoint(:) + TYPE(FricPressDropVarsTYPE) :: FricPressDrop + TYPE(ROPSpecificationInfo) :: ROP_Spec + TYPE(ROPInfo) :: ROP_Bit + TYPE(Geo_Data) :: TDGeo + TYPE(F_StringData) , Allocatable :: F_String(:) + TYPE(F_IntervalsCountsData):: F_Counts + TYPE(F_IntervalData) , Allocatable :: F_Interval(:) + TYPE(OD_AnnulusData) :: OD_Annulus(4) + TYPE(TD_DrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStem + TYPE(TD_SeparatedDrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStems + TYPE(TD_StringInfo) :: TD_String + TYPE(TD_AddRemoveInfo) :: TD_Count + TYPE(CStringComponents), ALLOCATABLE, DIMENSION(:) :: G_StringElement + TYPE(TD_RemovedVolumeInfo) :: TD_Vol + TYPE(TD_GeneralInfo) :: TD_General + TYPE(TD_BOPInfo) :: TD_BOP + TYPE(CBopElement) :: TD_BOPElement(4) + TYPE(TD_StringconnectionInfo) :: TD_StConn + TYPE(TD_LoadInfo) :: TD_Load + TYPE(TD_WellElementsInfo) :: TD_WellEl + TYPE(TD_CasingInfo), ALLOCATABLE, DIMENSION(:) :: TD_Casing + TYPE(TD_LinerInfo), ALLOCATABLE, DIMENSION(:) :: data%State%TD_Liner + TYPE(TD_OpenHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_OpenHole + TYPE(TD_ROPHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_ROPHole + TYPE(TD_WellGeneralInfo) :: TD_WellGeneral + TYPE(TD_WellGeometryData), Allocatable :: TD_WellGeo(:) + type(EquipmentControlType)::EquipmentControl + type(BopControlPanelType) :: BopControlPanel + Type(ChokeControlPanelType)::ChokeControlPanel + Type(ChokeManifoldType)::ChokeManifold + Type(DataDisplayConsoleType) :: DataDisplayConsole + TYPE(DrillingConsoleType) :: DrillingConsole + Type(HookType)::Hook + type(StandPipeManifoldType)::StandPipeManifold + Type(TopDrivePanelType)::TopDrivePanel + Type(DrillingWatchType)::DrillingWatch + Type(TankType)::Tank + type(ConfigurationType)::Configuration + Type(StringConfigurationType)::StringConfiguration + Type(FormationType) :: Formation + Type(ReservoirType)::Reservoir + Type(ShoeType)::Shoe + Type(AccumulatorType)::Accumulator + Type(BopStackSpecificationType)::BopStackSpecification + Type(HoistingType)::Hoisting + Type(PowerType)::Power + Type(PumpSpecificationType)::PumpsSpecification + Type(RigSizeType)::RigSize + Type(CasingLinerChokeType)::CasingLinerChoke + Type(PathGenerationType)::PathGeneration + Type(WellSurveyDataType)::WellSurveyData + Type(MudPropertiesType)::MudProperties + type(ProblemsType)::problems + type(BitProblemsType)::BitProblems + type(BopProblemsType)::BopProblems + type(ChokeProblemsType)::ChokeProblems + type(DrillStemProblemsType)::DrillStemProblems + type(GaugesProblemsType)::GaugesProblems + type(HoistingProblemsType):: HoistingProblems + type(KickProblemsType)::KickProblems + type(LostProblemsType)::LostProblems + type(MudTreatmentProblemsType)::MudTreatmentProblems + type(OtherProblemsType)::OtherProblems + type(PumpProblemsType)::PumpProblems + type(RotaryProblemsType)::RotaryProblems + end type SimulationDataType +