MODULE CHOKEVARIABLES
!IMPLICIT DOUBLEPRECISION(A-H,O-Z)
! use CBopControlPanel
! use ConfigurationVariables
! use CEquipmentsConstants
! use CSimulationVariables
! use CAccumulatorVariables
! use CBopStackVariables
! use CChokeControlPanelVariables
    ! use ConfigurationVariables

IMPLICIT NONE

!===========================================================================
!                               CHOKE VARIABLES
!===========================================================================
type::ChokeType
    REAL Ycritical,Cp,Cv,CL,kRatio,nPolytripic,x1,SGliquid,WaterDensity,LiquidDensity,VL,VG1
    REAL epsilon_step,epsilon_abs,step_size,Ycritical_a,Ycritical_b,Ycritical_c
    REAL G2,Cdrag,Pwh,MixDens2,Yratio_a,Yratio_b,Yratio_c,Yratio,Yratio_low,Yratio_high
    REAL FlowRate,Patm,MassFlux,LiquidPPG,time2,AreaChoke
    REAL eps_step,eps_abs,Yratiomat(100),Yrario_actual,Yrario
    REAL :: DegreeOpen,GRAVITY1=9.81!,PercentClose
    REAL ChokedMassFlux,ChokedFlowRate,PwhChoked
    REAL TotalStrokes1,TotalStrokes2
    !INTEGER WashoutMalf,PlugMalf,failMalf
    INTEGER GaugeChokePositionMailf,SoundChokePump
    Real Cumulative_AirVolume_Choke
    Real HydraulicChoke1WashoutCoef,HydraulicChoke2WashoutCoef

    Real Present_HydraulicChoke1Plug, Present_HydraulicChoke2Plug,DeltaPlug1Percent,DeltaPlug2Percent
    Integer HydraulicChoke1PluggedPercent_Old,HydraulicChoke2PluggedPercent_Old,Plug1TimeCounter,Plug2TimeCounter,ChokePlugTimeDelay
    Real ChokeAreaFullyOpen
end type ChokeType
!===========================================================================
!                               AIR DRIVEN PUMP VARIABLES
!===========================================================================
type::AirDrivenPumpType
    REAL QAIR_PUMP,cc1,cc2,cc3,cc4,cc5
    INTEGER ChokeAirFail
end type AirDrivenPumpType

! PARAMETER PI=3.141593
!============================================================================
!                       	OIL & ENVIRONMENT VARIABLES
!============================================================================
! REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000
!specific gravity of liquid
!water density(kg/m^3)


!===========================================================================
!                       AIR PUMP LINE COMPUTATIONAL VARIABLES
!===========================================================================
!logical ChokeIsClosing,ChokeIsOpening
type::AirPumpLineType
    REAL ChokeControlLeverOld
    REAL P_AIRP,QITER,DELTAV_AIR,TIME,DeltaT_Choke,TOL_AIR
    REAL diffp_air,losses_air,pipe_loss1air,minor_loss1air,static_loss1air
    integer NO_PIPINGS_AIRPLINE,NO_MINORS_AIRPLINE
    REAL,ALLOCATABLE:: Re_air(:),DIAM_AIR_MM(:),DIAM_AIR_INCH(:),AREA_AIR(:),REL_ROUGHAIR(:),LENGT_AIR(:),LF_AIR(:),CV_AIR(:),NOTE_AIR(:)
    REAL,ALLOCATABLE:: fric_air(:),fricloss_air(:),minlosspa_air(:),minloss_air(:),MINORS_AIRPUMP(:,:)
    REAL,ALLOCATABLE:: MINORDIAM_AIR_INCH(:),MINORAREA_AIR(:)
    REAL,ALLOCATABLE:: ROUGHNESS_AIRPLINE(:),PIPINGS_AIRPUMP(:,:)
    REAL Acylinder,CourseBase!,PassedCourse 
    REAL alpha_Qair,alpha_timeair,alpha_pairp,alpha_diffpair,alpha_lossesair,alpha_Pdownstrem,Pdownstrem
end type AirPumpLineType

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

    TYPE, PUBLIC :: CHOKE_TypeVars
        INTEGER WashoutMalf,PlugMalf,failMalf
        REAL PercentClose,PassedCourse,AreaChoke,AreaChokeFinal
        logical ChokeIsClosing,ChokeIsOpening
    END TYPE CHOKE_TypeVars


END MODULE