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

    
    END MODULE
    