示例#1
0
def outBOOTAB(fVIP, dTab, eTab, sOil, sGas, rOil, rGas, qMonV, clsBLK, clsUNI,
              clsIO):

    nSat = len(dTab)
    nExt = len(eTab)

    iSat = nSat - 1
    iExt = nExt - 1

    qLiq = True
    cCon = clsBLK.Co
    dSTO = clsBLK.dSTO
    dSTG = clsBLK.dSTG

    #== Column Headers ====================================================

    fVIP.write("C \n")
    fVIP.write("C  Saturated Data\n")
    fVIP.write("C \n")
    fVIP.write("\n")
    fVIP.write("      RS         PSAT         BO           VO\n")

    #----------------------------------------------------------------------
    #  Saturated Data
    #----------------------------------------------------------------------

    while iSat >= 0:

        outputLiveOil(fVIP, iSat, dTab, clsBLK, clsIO, clsUNI)

        #== Decrement the iSat counter ========================================

        iSat -= 1

#----------------------------------------------------------------------
#  Extended Data
#----------------------------------------------------------------------

    while iExt >= 0:

        outputLiveOil(fVIP, iExt, eTab, clsBLK, clsIO, clsUNI)

        #== Decrement the iExt counter ========================================

        iExt -= 1

#== Terminating Slash =================================================

    fVIP.write("\n")

    #----------------------------------------------------------------------
    #  Undersaturated Data
    #----------------------------------------------------------------------

    fOil = []

    fVIP.write("C \n")
    fVIP.write("C  Undersaturated Data\n")
    fVIP.write("C \n")
    fVIP.write("\n")

    lSat = 0
    lExt = 0

    #== Saturated Data ====================================================

    iSat = nSat - 1

    while iSat >= 0:

        Ps = dTab[iSat][clsBLK.iPr]
        Rs = dTab[iSat][clsBLK.iRs]
        Us = dTab[iSat][clsBLK.iUo]

        BO.setEoSVis(iSat, sOil, sGas, rOil, rGas, clsBLK)

        dOut = outputUnderSatOil(Ps, Rs, Us, dTab, eTab, lSat, lExt, qMonV,
                                 clsBLK, clsIO, clsUNI)
        fVIP.write("\n")
        lSat += 1

        #-- Decrement the iSat counter --------------------------------------

        iSat -= 1
        fOil.append(dOut)

#== Extended Data =====================================================

    iExt = nExt - 1

    BO.setEoSVis(0, sOil, sGas, rOil, rGas, clsBLK)

    while iExt >= 0:

        Ps = eTab[iExt][clsBLK.iPr]
        Rs = eTab[iExt][clsBLK.iRs]
        Us = eTab[iExt][clsBLK.iUo]

        dOut = outputUnderSatOil(Ps, Rs, Us, dTab, eTab, lSat, lExt, qMonV,
                                 clsBLK, clsIO, clsUNI)
        fVIP.write("\n")
        lExt += 1

        #-- Decrement the iExt counter ========================================

        iExt -= 1
        fOil.append(dOut)

#== No return value ===================================================

    return fOil
示例#2
0
def outputUnderSatGas(Rd, Pd, dTab, eTab, lSat, lExt, sOil, sGas, rOil, rGas,
                      clsBLK, clsIO, clsUNI):

    #-- Initialisation --------------------------------------------------

    OutU = clsBLK.OutU
    fVIP = clsIO.fVIP
    nSat = len(dTab)
    nExt = len(eTab)
    qVap = False
    cCon = clsBLK.Co
    dSTO = clsBLK.dSTO
    dSTG = clsBLK.dSTG

    if OutU == "MET":
        sPrs = "kpa"
        sCGR = "sm3/sm3"
        sFVF = "rm3/sm3"
    else:
        sPrs = "psia"
        sCGR = "stb/mscf"
        sFVF = "rb/mscf"

    nTot = nSat + nExt - lSat - lExt

    nCol = 4
    nMod = nTot % nCol
    nRow = int(nTot / nCol)

    if nMod > 0: nRow = nRow + 1

    iSat = nSat - 1 - lSat
    iExt = nExt - 1 - lExt

    dOut = []
    qFrs = True

    #-- Saturated Data --------------------------------------------------

    while iSat >= 0:

        Pr = dTab[iSat][clsBLK.iPr]
        Rv = dTab[iSat][clsBLK.iRv]

        RTp = clsBLK.RT / Pr
        BO.setEoSVis(iSat, sOil, sGas, rOil, rGas, clsBLK)
        Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rd, clsBLK, clsIO)

        if qFrs:
            dRow = [Rv, Bg, Ug, Rd]
            qFrs = False
        else:
            dRow = [Rv, Bg, Ug]

        dOut.append(dRow)

        #-- Decrement iSat --------------------------------------------------

        iSat -= 1

#-- Extended Data ---------------------------------------------------

    BO.setEoSVis(0, sOil, sGas, rOil, rGas, clsBLK)

    while iExt >= 0:

        Pr = eTab[iExt][clsBLK.iPr]
        Rv = eTab[iExt][clsBLK.iRv]

        RTp = clsBLK.RT / Pr
        Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rd, clsBLK, clsIO)

        if qFrs:
            dRow = [Rv, Bg, Ug, Rd]
            qFrs = False
        else:
            dRow = [Rv, Bg, Ug]

        dOut.append(dRow)

        #-- Decrement iSat --------------------------------------------------

        iExt -= 1

#== Output nRow's worth of Triplets ===================================

    iVal = 0
    qExt = False

    Rd = clsUNI.I2X(Rd, sCGR)
    sRd = " {:10.5f}".format(Rd)

    for iRow in range(nRow):
        sLin1 = "RVSAT              "
        sLin2 = "RV           "
        sLin3 = sRd + "  "
        for jCol in range(nCol):
            Rv = dOut[iVal][0]
            Bg = dOut[iVal][1]
            Ug = dOut[iVal][2]
            Rv = clsUNI.I2X(Rv, sCGR)
            Bg = clsUNI.I2X(Bg, sFVF)
            sRv = " {:10.5f}".format(Rv)
            sBg = " {:10.5f}".format(Bg)
            sUg = " {:10.5f}".format(Ug)
            sLin1 = sLin1 + sRv + "             "
            sLin2 = sLin2 + "    BG      " + "     VG     "
            sLin3 = sLin3 + sBg + "  " + sUg
            iVal += 1
            if iVal == nTot:
                qExt = True
                break
        sLin1 = sLin1 + "\n"
        sLin2 = sLin2 + "\n"
        sLin3 = sLin3 + "\n"
        fVIP.write(sLin1)
        fVIP.write(sLin2)
        fVIP.write(sLin3)
        if qExt: break

#== Return value ======================================================

    return dOut
示例#3
0
def genUnderSatGas(fIMX, dTab, eTab, sOil, sGas, rOil, rGas, clsBLK, clsUNI,
                   clsIO):

    OutU = clsBLK.OutU  #-- FLD (Field) or MET (Metric)

    if OutU == "MET":
        sPrs = "kpa"
        sFVF = "rm3/sm3"
    else:
        sPrs = "psia"
        sFVF = "rb/scf"
    sVis = "cp"

    fPrs = " {:10.3f}"
    fFVF = " {:10.3e}"
    fVis = " {:10.3e}"

    iP = 0
    iB = 1
    iU = 2

    nSat = len(dTab)
    nExt = len(eTab)

    iSat = nSat - 1
    iExt = nExt - 1

    Rv0 = 0.0
    P0 = CO.pStand

    qVap = False
    cCon = clsBLK.Co
    dSTO = clsBLK.dSTO
    dSTG = clsBLK.dSTG

    #----------------------------------------------------------------------
    #  Generate Tables
    #----------------------------------------------------------------------

    fGas = []

    while iSat >= 0:

        #-- Set EoS/Visc coefficients based on pressure ---------------------

        BO.setEoSVis(iSat, sOil, sGas, rOil, rGas, clsBLK)

        Pd = dTab[iSat][clsBLK.iPr]
        Rd = dTab[iSat][clsBLK.iRv]
        Bd = dTab[iSat][clsBLK.iBg]
        Ud = dTab[iSat][clsBLK.iUg]

        RTp = clsBLK.RT / Pd

        dOut = []

        #-- Dry Gas Stage (Rv = 0.0) ----------------------------------------

        Bg0, Ug0 = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv0, clsBLK,
                                  clsIO)

        dRow = [P0, Bg0, Ug0]
        dOut.append(dRow)

        #== "Saturated Data" ==================================================

        jSat = nSat - 1

        while jSat >= iSat:

            Pr = dTab[jSat][clsBLK.iPr]
            Rv = dTab[jSat][clsBLK.iRv]

            Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK,
                                    clsIO)

            if jSat == iSat: dRow = [Pd, Bd, Ud, Rd]
            else: dRow = [Pr, Bg, Ug]

            dOut.append(dRow)

            #-- Decrement jSat counter ------------------------------------------

            jSat -= 1

#== Write BGUST/ZGUST for this sweep ==================================

        Pd = clsUNI.I2X(Pd, sPrs)
        sPd = "{:10.3f}".format(Pd)

        fIMX.write("** Pdew = " + sPd + "\n")
        fIMX.write("\n")

        outUnderSat(fIMX, "BGUST", dOut, iP, iB, sPrs, sFVF, fPrs, fFVF,
                    clsUNI)
        outUnderSat(fIMX, "VGUST", dOut, iP, iU, sPrs, sVis, fPrs, fVis,
                    clsUNI)

        #== Decrement iSat counter ============================================

        iSat -= 1
        fGas.append(dOut)

#----------------------------------------------------------------------
#  "Extended" Data
#----------------------------------------------------------------------

    BO.setEoSVis(0, sOil, sGas, rOil, rGas, clsBLK)

    while iExt >= 0:

        Pd = eTab[iExt][clsBLK.iPr]
        Rd = eTab[iExt][clsBLK.iRv]
        Bd = eTab[iExt][clsBLK.iBg]
        Ud = eTab[iExt][clsBLK.iUg]

        RTp = clsBLK.RT / Pr

        dOut = []

        #-- Dry Gas Stage (Rv = 0.0) ----------------------------------------

        Bg0, Ug0 = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv0, clsBLK,
                                  clsIO)

        dRow = [P0, Bg0, Ug0]
        dOut.append(dRow)

        #== "Saturated Data" ==================================================

        jSat = nSat - 1

        while jSat >= 0:

            Pr = dTab[jSat][clsBLK.iPr]
            Rv = dTab[jSat][clsBLK.iRv]

            Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK,
                                    clsIO)

            dRow = [Pr, Bg, Ug]

            dOut.append(dRow)

            #-- Decrement jSat counter ------------------------------------------

            jSat -= 1

#== "Extended Data" ===================================================

        jExt = nExt - 1

        while jExt >= iExt:

            Pr = eTab[jExt][clsBLK.iPr]
            Rv = eTab[jExt][clsBLK.iRv]

            Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK,
                                    clsIO)

            if jExt == iExt: dRow = [Pd, Bd, Ud, Rd]
            else: dRow = [Pr, Bg, Ug]

            dOut.append(dRow)

            #-- Decrement jExt counter ------------------------------------------

            jExt -= 1

#== Write BGUST/ZGUST for this sweep ==================================

        Pd = clsUNI.I2X(Pd, sPrs)
        sPd = "{:10.3f}".format(Pd)

        fIMX.write("** Pdew = " + sPd + "\n")
        fIMX.write("\n")

        outUnderSat(fIMX, "BGUST", dOut, iP, iB, sPrs, sFVF, fPrs, fFVF,
                    clsUNI)
        outUnderSat(fIMX, "VGUST", dOut, iP, iU, sPrs, sVis, fPrs, fVis,
                    clsUNI)

        #-- Decrement iExt counter ------------------------------------------

        iExt -= 1
        fGas.append(dOut)

#== Return value ======================================================

    return fGas
示例#4
0
def genUnderSatOil(fIMX, dTab, eTab, sOil, sGas, rOil, rGas, qMonV, clsBLK,
                   clsUNI, clsIO):

    OutU = clsBLK.OutU  #-- FLD (Field) or MET (Metric)

    if OutU == "MET":
        sPrs = "kpa"
        sGOR = "sm3/sm3"
        sFVF = "rm3/sm3"
    else:
        sPrs = "psia"
        sGOR = "scf/stb"
        sFVF = "rb/stb"
    sVis = "cp"

    fPrs = " {:10.3f}"
    fFVF = " {:10.5f}"
    fVis = " {:10.5f}"

    iP = 0
    iB = 1
    iU = 2

    nSat = len(dTab)
    nExt = len(eTab)

    iSat = nSat - 1
    iExt = nExt - 1

    qLiq = True
    cCon = clsBLK.Co
    dSTO = clsBLK.dSTO
    dSTG = clsBLK.dSTG
    pInc = clsBLK.Pinc

    #== "Saturated" Data ==================================================

    fOil = []

    while iSat >= 0:

        dOut = []

        Pb = dTab[iSat][clsBLK.iPr]
        Rb = dTab[iSat][clsBLK.iRs]
        Bb = dTab[iSat][clsBLK.iBo]
        Ub = dTab[iSat][clsBLK.iUo]

        dRow = [Pb, Bb, Ub, Rb]
        dOut.append(dRow)

        jSat = iSat - 1

        BO.setEoSVis(iSat, sOil, sGas, rOil, rGas, clsBLK)

        while jSat >= 0:

            Pr = dTab[jSat][clsBLK.iPr]
            RTp = clsBLK.RT / Pr

            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK,
                                    clsIO)

            if not qMonV: Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            dRow = [Pr, Bo, Uo]
            dOut.append(dRow)

            #-- Decrement jSat counter ------------------------------------------

            jSat -= 1

#-- Extended Pressure Stages ----------------------------------------

        jExt = nExt - 1

        while jExt >= 0:

            Pr = eTab[jExt][clsBLK.iPr]
            RTp = clsBLK.RT / Pr

            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK,
                                    clsIO)

            if not qMonV: Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            dRow = [Pr, Bo, Uo]
            dOut.append(dRow)

            #-- Decrement jExt counter ------------------------------------------

            jExt -= 1

#== Write BOT/VOT for this sweep ======================================

        Rb = clsUNI.I2X(Rb, sGOR)
        sRb = "{:10.3f}".format(Rb)

        fIMX.write("** GOR = " + sRb + "\n")
        fIMX.write("\n")

        outUnderSat(fIMX, "BOT", dOut, iP, iB, sPrs, sFVF, fPrs, fFVF, clsUNI)
        outUnderSat(fIMX, "VOT", dOut, iP, iU, sPrs, sVis, fPrs, fVis, clsUNI)

        #-- Decrement iSat counter ------------------------------------------

        iSat -= 1
        fOil.append(dOut)

#== "Extended" Data ===================================================

    BO.setEoSVis(0, sOil, sGas, rOil, rGas, clsBLK)

    while iExt >= 0:

        dOut = []

        Pb = eTab[iExt][clsBLK.iPr]
        Rb = eTab[iExt][clsBLK.iRs]
        Bb = eTab[iExt][clsBLK.iBo]
        Ub = eTab[iExt][clsBLK.iUo]

        dRow = [Pb, Bb, Ub, Rb]
        dOut.append(dRow)

        jExt = iExt - 1

        while jExt >= 0:

            Pr = eTab[jExt][clsBLK.iPr]
            RTp = clsBLK.RT / Pr

            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK,
                                    clsIO)

            if not qMonV: Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            dRow = [Pr, Bo, Uo]
            dOut.append(dRow)

            #-- Decrement jExt counter ------------------------------------------

            jExt -= 1

#-- Additional Row if last Row in the Extended Table ----------------

        if iExt == 0:

            Pr = Pr + pInc
            RTp = clsBLK.RT / Pr

            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK,
                                    clsIO)

            if not qMonV: Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            dRow = [Pr, Bo, Uo]
            dOut.append(dRow)

#== Write BOT/VOT for this sweep ======================================

        Rb = clsUNI.I2X(Rb, sGOR)
        sRb = "{:10.3f}".format(Rb)

        fIMX.write("** GOR = " + sRb + "\n")
        fIMX.write("\n")

        outUnderSat(fIMX, "BOT", dOut, iP, iB, sPrs, sFVF, fPrs, fFVF, clsUNI)
        outUnderSat(fIMX, "VOT", dOut, iP, iU, sPrs, sVis, fPrs, fVis, clsUNI)

        #-- Decrement iSat counter ------------------------------------------

        iExt -= 1
        fOil.append(dOut)

#== Return value ======================================================

    return fOil
示例#5
0
def outPVTG(f100, dTab, eTab, sOil, sGas, rOil, rGas, clsBLK, clsUNI, clsIO):

    nSat = len(dTab)
    nExt = len(eTab)

    iSat = nSat - 1
    iExt = nExt - 1

    qVap = False
    Tres = clsBLK.Tres
    cCon = clsBLK.Co
    dSTO = clsBLK.dSTO
    dSTG = clsBLK.dSTG
    mSTO = clsBLK.mSTO
    mSTG = clsBLK.mSTG

    fGas = []  #-- Store Under-Saturated Gas Data for Plotting

    #----------------------------------------------------------------------
    #  Saturated Data
    #----------------------------------------------------------------------

    while iSat >= 0:

        fCol = []

        if iSat == 0: sExt = "  -- Psat"
        else: sExt = "  -- Saturated"

        outputPVTGsat(f100, iSat, dTab, sExt, clsBLK, clsIO, clsUNI)

        Pd = dTab[iSat][clsBLK.iPr]
        Rd = dTab[iSat][clsBLK.iRv]
        Bd = dTab[iSat][clsBLK.iBg]
        Ud = dTab[iSat][clsBLK.iUg]

        UG = BO.gasViscLee(Rd, Bd, Tres, clsBLK)

        dRow = [Rd, Bd, Ud, Pd]
        fCol.append(dRow)

        RTp = clsBLK.RT / Pd

        #-- Re-fitted EoS/Visc data for under-saturated calculations --------

        BO.setEoSVis(iSat, sOil, sGas, rOil, rGas, clsBLK)

        #== Undersaturated Data ===============================================

        jSat = iSat + 1
        sExt = ""

        while jSat < nSat:

            Rv = dTab[jSat][clsBLK.iRv]
            Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK)
            outputPVTGund(f100, Rv, Bg, Ug, sExt, clsBLK, clsIO, clsUNI)

            dRow = [Rv, Bg, Ug]
            fCol.append(dRow)

            #-- Decrement the jSat counter --------------------------------------

            jSat += 1

#-- Dry Gas (Rv = 0) stage ------------------------------------------

        sExt = "  /\n"
        Rv = 0.0
        Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK)
        outputPVTGund(f100, Rv, Bg, Ug, sExt, clsBLK, clsIO, clsUNI)

        #== Decrement the iSat counter ========================================

        iSat -= 1
        fGas.append(fCol)

#----------------------------------------------------------------------
#  Extended Data
#----------------------------------------------------------------------

    BO.setEoSVis(0, sOil, sGas, rOil, rGas, clsBLK)

    while iExt >= 0:

        fCol = []
        sExt = "  -- Extended"

        outputPVTGsat(f100, iExt, eTab, sExt, clsBLK, clsIO, clsUNI)

        Pd = eTab[iExt][clsBLK.iPr]
        Rd = eTab[iExt][clsBLK.iRv]
        Bd = eTab[iExt][clsBLK.iBg]
        Ud = eTab[iExt][clsBLK.iUg]

        UG = BO.gasViscLee(Rd, Bd, Tres, clsBLK)

        dRow = [Rd, Bd, Ud, Pd]
        fCol.append(dRow)

        RTp = clsBLK.RT / Pd

        #== Undersaturated Data ===============================================

        jExt = iExt + 1
        sExt = ""

        while jExt < nExt:

            Rv = eTab[jExt][clsBLK.iRv]
            Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK)
            outputPVTGund(f100, Rv, Bg, Ug, sExt, clsBLK, clsIO, clsUNI)

            dRow = [Rv, Bg, Ug]
            fCol.append(dRow)

            #-- Increment the jSat counter --------------------------------------

            jExt += 1

#== Undersaturated Data ===============================================

        jSat = 0
        sExt = ""

        while jSat < nSat:

            Rv = dTab[jSat][clsBLK.iRv]
            Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK)
            outputPVTGund(f100, Rv, Bg, Ug, sExt, clsBLK, clsIO, clsUNI)

            dRow = [Rv, Bg, Ug]
            fCol.append(dRow)

            #-- Decrement the jSat counter --------------------------------------

            jSat += 1

#== Decrement the iExt counter ========================================

        iExt -= 1

        #-- Dry Gas (Rv = 0) stage ------------------------------------------

        sExt = "  /\n"
        Rv = 0.0
        Bg, Ug = BO.calcSatProp(qVap, RTp, cCon, dSTO, dSTG, Rv, clsBLK)
        outputPVTGund(f100, Rv, Bg, Ug, sExt, clsBLK, clsIO, clsUNI)

        dRow = [Rv, Bg, Ug]
        fCol.append(dRow)

        fGas.append(fCol)

#== Terminating Slash =================================================

    f100.write("/\n")
    f100.write("\n")

    #== Return value ======================================================

    return fGas
示例#6
0
def outPVTO(f100, dTab, eTab, sOil, sGas, rOil, rGas, qMonV, clsBLK, clsUNI,
            clsIO):

    nSat = len(dTab)
    nExt = len(eTab)

    iSat = nSat - 1
    iExt = nExt - 1

    qLiq = True
    cCon = clsBLK.Co
    dSTO = clsBLK.dSTO
    dSTG = clsBLK.dSTG
    pInc = clsBLK.Pinc

    fOil = []  #-- Store Under-Saturated Oil Data for Plotting

    #----------------------------------------------------------------------
    #  Saturated Data
    #----------------------------------------------------------------------

    while iSat >= 0:

        fCol = []

        if iSat == 0: sExt = "  -- Psat"
        else: sExt = "  -- Saturated"

        outputPVTOsat(f100, iSat, dTab, sExt, clsBLK, clsIO, clsUNI)

        Pb = dTab[iSat][clsBLK.iPr]
        Rb = dTab[iSat][clsBLK.iRs]
        Bb = dTab[iSat][clsBLK.iBo]
        Ub = dTab[iSat][clsBLK.iUo]

        dRow = [Pb, Bb, Ub, Rb]
        fCol.append(dRow)

        BO.setEoSVis(iSat, sOil, sGas, rOil, rGas, clsBLK)

        #== "Saturated" Under-Saturated Data ==================================

        jSat = iSat - 1
        sExt = ""

        while jSat >= 0:

            Pr = dTab[jSat][clsBLK.iPr]
            RTp = clsBLK.RT / Pr
            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK)

            #if not qMonV : Uo = BP.calcUndViscStand(Pb,Ub,Pr)
            Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            outputPVTOund(f100, Pr, Bo, Uo, sExt, clsBLK, clsIO, clsUNI)

            dRow = [Pr, Bo, Uo]
            fCol.append(dRow)

            #-- Decrement the jSat counter --------------------------------------

            jSat -= 1

#== "Extended" Under-Saturated Data ===================================

        jExt = nExt - 1

        while jExt >= 0:

            if jExt == 0: sExt = "  /"

            Pr = eTab[jExt][clsBLK.iPr]
            RTp = clsBLK.RT / Pr
            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK)

            #if not qMonV : Uo = BP.calcUndViscStand(Pb,Ub,Pr)
            Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            outputPVTOund(f100, Pr, Bo, Uo, sExt, clsBLK, clsIO, clsUNI)

            dRow = [Pr, Bo, Uo]
            fCol.append(dRow)

            #-- Decrement the jExt counter --------------------------------------

            jExt -= 1

#== Decrement the iSat counter ========================================

        f100.write("\n")

        iSat -= 1

        fOil.append(fCol)

#----------------------------------------------------------------------
#  Extended Data
#----------------------------------------------------------------------

    BO.setEoSVis(0, sOil, sGas, rOil, rGas, clsBLK)

    while iExt >= 0:

        fCol = []

        sExt = "  -- Extended"

        outputPVTOsat(f100, iExt, eTab, sExt, clsBLK, clsIO, clsUNI)

        Pb = eTab[iExt][clsBLK.iPr]
        Rb = eTab[iExt][clsBLK.iRs]
        Bb = eTab[iExt][clsBLK.iBo]
        Ub = eTab[iExt][clsBLK.iUo]

        dRow = [Pb, Bb, Ub, Rb]
        fCol.append(dRow)

        #== "Extended" Under-Saturated Data ===================================

        jExt = iExt - 1

        while jExt >= 0:

            if jExt == 0: sExt = "  /"
            else: sExt = ""

            Pr = eTab[jExt][clsBLK.iPr]
            RTp = clsBLK.RT / Pr
            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK)

            #if not qMonV : Uo = BP.calcUndViscStand(Pb,Ub,Pr)
            Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            outputPVTOund(f100, Pr, Bo, Uo, sExt, clsBLK, clsIO, clsUNI)

            dRow = [Pr, Bo, Uo]
            fCol.append(dRow)

            #-- Decrement the jExt counter --------------------------------------

            jExt -= 1

#== Extra Row =========================================================

        if iExt == 0:

            Pr = Pr + pInc
            RTp = clsBLK.RT / Pr
            Bo, Uo = BO.calcSatProp(qLiq, RTp, cCon, dSTO, dSTG, Rb, clsBLK)

            #if not qMonV : Uo = BP.calcUndViscStand(Pb,Ub,Pr)
            Uo = BP.calcUndViscStand(Pb, Ub, Pr)

            dRow = [Pr, Bo, Uo]
            fCol.append(dRow)

            sExt = "  /"
            outputPVTOund(f100, Pr, Bo, Uo, sExt, clsBLK, clsIO, clsUNI)

        f100.write("\n")

        #== Decrement the iExt counter ========================================

        iExt -= 1

        fOil.append(fCol)

    f100.write("/\n")
    f100.write("\n")

    #== Return value ======================================================

    return fOil
示例#7
0
def calcBlack(clsEOS,dicSAM,clsBLK,clsUNI,clsIO) :

    sim3 = clsBLK.tSim[:3]

#== Set Output File Name [rootName.sim] ===============================

    if   sim3 == "CMG" :

        if not clsIO.qIMX :
            pathIMX = clsIO.patR + ".imex"
            fIMX    = open(pathIMX,'w')
            clsIO.setQIMX(True)
            clsIO.setFIMX(fIMX)
        else :
            fIMX = clsIO.fIMX
            
        fSim = clsIO.fIMX
        sCom = "**"
        
    elif sim3 == "TEM" :

        if not clsIO.qMOR :
            pathMOR = clsIO.patR + ".mor"
            fMOR    = open(pathMOR,'w')
            clsIO.setQMOR(True)
            clsIO.setFMOR(fMOR)
        else :
            fMOR = clsIO.fMOR
            
        fSim = clsIO.fMOR
        sCom = "--"
        
    elif sim3 == "VIP" :

        if not clsIO.qVIP :
            pathVIP = clsIO.patR + ".vip"
            fVIP    = open(pathVIP,'w')
            clsIO.setQVIP(True)
            clsIO.setFVIP(fVIP)
        else :
            fVIP = clsIO.fVIP
            
        fSim = clsIO.fVIP
        sCom = "C "
        
    elif sim3 == "ECL" :

        if not clsIO.q100 :
            path100 = clsIO.patR + ".e100"
            f100    = open(path100,'w')
            clsIO.setQ100(True)
            clsIO.setF100(f100)
        else :
            f100 = clsIO.f100
            
        fSim = clsIO.f100
        sCom = "--"

#-- Write Header Information to Simulator File ----------------------        

    WO.outputHeader(fSim,sCom,clsIO)
    WO.outputEOS(fSim,sCom,clsIO,clsEOS)

#== Initialisation ====================================================    

    print("calcBlack: Entered")

    qLiq = True  ; qVap = False
    iLiq =  1    ; iVap = -1

    iSam = clsBLK.sNum
    nCom = clsEOS.nComp

    clsSAM = dicSAM[iSam]

    Z = NP.zeros(nCom)
    for iC in range(nCom) : Z[iC] = clsSAM.gZI(iC)

    sNam = dicSAM[iSam].sNam
    clsBLK.setSamp(iSam,sNam)  #-- Store the name

    xTyp = clsBLK.xTyp
    tRes = clsBLK.Tres
    pSep = clsBLK.pSep
    tSep = clsBLK.tSep

#-- Has User Defined Non-Standard Wiring for the Stage Order? -------

    if clsBLK.qLsep : Lsep = clsBLK.Lsep
    else            : Lsep = []

    if clsBLK.qVsep : Vsep = clsBLK.Vsep
    else            : Vsep = []

    #print("calcBlack: pSep,tSep,Lsep,Vsep ",pSep,tSep,Lsep,Vsep)

#-- Brine Density at Standard (Stock Tank) Conditions ---------------    

    pStc = UT.pStand    #-- Standard Pressure    [psia]
    tStc = UT.tStand    #-- Standard Temperature [degR = 60.0 degF]
    mFrc = clsBLK.bSalt #-- Mass Fraction of Salt in the Brine

    dSTW,comW = CW.calcRoweChouDen(mFrc,tStc,pStc,clsUNI)  #-- Stock Tank Brine Density

    clsBLK.setDenSTW(dSTW)

#-- Brine Properties at Reference Pressure & Tres (for PVTW keyword) 

    CW.calcPVTW(clsBLK,clsUNI,clsIO)

#======================================================================
#  Saturation Pressure Stage: Find Psat
#======================================================================

    clsEOS.eosCoefsNoPT()

#-- This experiment at varying temperature so set when needed -------

    pMea = -1.0
    
    qBub = None
    pSat = None
    logK = NP.empty(nCom)
    
    qBub,pSat,Ksat = CS.calcPsat(pMea,tRes,qBub,pSat,logK,clsEOS,clsSAM,clsIO)

    clsBLK.Psat = pSat

    Xsat = NP.zeros(nCom)
    Ysat = NP.zeros(nCom)
    
    if qBub :
        Xsat = NP.copy(Z)
        Ysat = NP.multiply(Z,Ksat)
    else :
        Xsat = NP.divide(Z,Ksat)
        Ysat = NP.copy(Z)

    Xsat = UT.Norm(Xsat) ; Ysat = UT.Norm(Ysat)

#-- Properties of the Feed and Incipient Phases at Psat -------------    

    Mx,Vx,Dx,Zx,Ux,Cx,Wx = CE.calcProps(iLiq,pSat,tRes,Xsat,clsEOS)
    My,Vy,Dy,Zy,Uy,dS,dS = CE.calcProps(iVap,pSat,tRes,Ysat,clsEOS)

    UgDew = Uy

#== Flash the Psat Liquid & Vapour through the Separator Train ========    

    if qBub : Vsat = Vx
    else    : Vsat = Vy

    Doo,Dgo,Rs,Bo,Bd,ySTG = \
        BO.sepFlash(iLiq,pSep,tSep,Lsep,Vsep,Xsat,Vx,clsEOS,clsIO)

    Dog,Dgg,Rv,Bg,Bd,ySTG = \
        BO.sepFlash(iVap,pSep,tSep,Lsep,Vsep,Ysat,Vy,clsEOS,clsIO)

    Md,Vd,Dd,Zd,Ud,dS,dS = CE.calcProps(iVap,pSat,tRes,ySTG,clsEOS)

    Bd = BO.gasFVF(pSat,tRes,Zd)

    RsSat = Rs      #-- Store the Saturated GOR & CGR 
    RvSat = Rv

#-- Stock Tank Densities from Saturated Stage depending on Type -----    

    if qBub :
        dSTO = Doo
        dSTG = Dgo
    else :
        dSTO = Dog
        dSTG = Dgg

    dTab = []  #-- Stores all Saturated data
    pTab = []  #-- Will store all values of Pres (including those > Psat)
    
    dRow = [pSat,Rs,Bo,Ux,Cx,Wx,Rv,Bg,Uy,Bd,Ud]
    dTab.append(dRow)

#== Setup Pressure Nodes in the Tables ================================    

    pMax = clsBLK.Pmax
    pMin = clsBLK.Pmin
    pInc = clsBLK.Pinc

    pRes = pMax
    qIns = True

#======================================================================
#  Build pTab-Array
#======================================================================

    while pRes >= pMin :

        if pRes > pSat :                #-- Above Psat
            pTab.append(pRes)
        else :
            if qIns :                   #-- Insert Psat
                pTab.append(pSat)
                qIns = False
            pTab.append(pRes)           #-- Below Psat
            
        pRes = pRes - pInc              #-- Decrement Pressure

#-- Total number of stages (pressure nodes) -------------------------

    nPrs = len(pTab)

#======================================================================
#  Depletion Stages
#======================================================================

    if qBub : vEst = 0.0
    else :    vEst = 1.0

    zTot = 1.0
    pRes = pMax
    qIns = True

    while pRes >= pMin :

#-- Above Psat ------------------------------------------------------        

        if pRes > pSat :
            pass
        else :

#-- Psat-Row? -------------------------------------------------------

            if qIns :
                qIns = False

#-- This experiment at varying temperature so set when needed -------

            V,K,X,Y = CF.calcFlash(pRes,tRes,Z,vEst,clsEOS,clsIO)
            vEst    = V

            Moil,Vliq,dLiq,Zoil,Uoil,Coil,Viso = CE.calcProps(iLiq,pRes,tRes,X,clsEOS)
            Mgas,Vvap,dVap,Zgas,Ugas,dumS,dumS = CE.calcProps(iVap,pRes,tRes,Y,clsEOS)

            zGas = zTot*     V
            zOil = zTot*(1.0-V)

            Xsep = NP.copy(X)  #-- Local copies of (X,Y) to flash thru Seps
            Ysep = NP.copy(Y)

#-- Flash Liquid thru the Separator Train ---------------------------

            Doo,Dgo,Rs,Bo,Bd,ySTG = \
                BO.sepFlash(iLiq,pSep,tSep,Lsep,Vsep,Xsep,Vliq,clsEOS,clsIO)

#-- Flash Vapour thru the Separator Train ---------------------------            
            
            Dog,Dgg,Rv,Bg,Bd,ySTG = \
                BO.sepFlash(iVap,pSep,tSep,Lsep,Vsep,Ysep,Vvap,clsEOS,clsIO)

            #Ud,dumm = CE.calcLBCderv(tRes,dVap,ySTG,clsEOS)  #-- Dry Gas Visc at pRes

            Md,Vd,Dd,Zd,Ud,dS,dS = CE.calcProps(iVap,pRes,tRes,ySTG,clsEOS)

            Bd = BO.gasFVF(pRes,tRes,Zd)

#== Modify the Moles to Next Stage, Depending on Depletion Type =======

            Voil = zOil*Vliq
            Vgas = zGas*Vvap
            
            Vtot = Voil + Vgas
            Vrem = Vtot - Vsat

            zRem = pRes*Vrem/(Zgas*UT.gasCon*tRes)

            if   xTyp == "CCE" :
                pass
            elif xTyp == "CVD" :
                for iC in range(nCom) : Z[iC] = (zTot*Z[iC] - zRem*Y[iC])/(zTot - zRem)
                zTot = zTot - zRem
            elif xTyp == "DLE" :
                Z    = NP.copy(X)
                zTot = zTot - zGas

            dRow = [pRes,Rs,Bo,Uoil,Coil,Viso,Rv,Bg,Ugas,Bd,Ud]
            dTab.append(dRow)

#== Decrement Pressure and Continue ===================================

        pRes = pRes - pInc

#== Work Arrays for "Back-Up" Fits ====================================        

    nSat = len(dTab)

    X = NP.zeros(nSat)
    Y = NP.zeros(nSat)

#======================================================================
#  Slope and Intercept of the (assumed linear) Bo versus Rs 
#======================================================================

    for i in range(nSat) :
        X[i] = dTab[i][clsBLK.iRs]
        Y[i] = dTab[i][clsBLK.iBo]

    slope,inter = UT.linearFit(X,Y)

    clsBLK.BoS = slope
    clsBLK.BoI = inter

#======================================================================
#  Slope and Intercept of the (assumed exp) Muo versus Rs 
#======================================================================

    for i in range(nSat) :
        X[i] =     dTab[i][clsBLK.iRs]
        Y[i] = log(dTab[i][clsBLK.iUo])

    slope,logIn = UT.linearFit(X,Y)
    inter = exp(logIn)

    clsBLK.UoS = slope
    clsBLK.UoI = inter

#======================================================================
#  Slope and Intercept of the (assumed linear) co.p versus Rs 
#======================================================================

    for i in range(nSat) :
        X[i] = dTab[i][clsBLK.iRs]
        Y[i] = dTab[i][clsBLK.iCo]*dTab[i][clsBLK.iPr]

    slope,inter = UT.linearFit(X,Y)

    clsBLK.CoS = slope
    clsBLK.CoI = inter

#======================================================================
#  Stock Tank Oil and Gas Properties
#======================================================================

    mSTO,oGrv = BP.initOilProps(dSTO,clsBLK)
    mSTG,gGrv = BP.initGasProps(dSTG,clsBLK)

    clsBLK.mSTO = mSTO
    clsBLK.mSTG = mSTG

    cCon = (dSTO/mSTO)*(UT.gasCon*UT.tStand/UT.pStand)  #-- Singh et al Eqn.(14)

    clsBLK.Co = cCon

#== Output Header =====================================================    

    WB.outputHeaderBO(fSim,iSam,sNam,clsBLK,clsIO,clsUNI)

#======================================================================
#  Generate the Saturated Oil and Gas STO Mole Fractions
#======================================================================

    cTab = []  #-- Table used to store 'calculated' data

    for iPrs in range(nSat) :

        Pr = dTab[iPrs][clsBLK.iPr]
        Rs = dTab[iPrs][clsBLK.iRs] ; Bo = dTab[iPrs][clsBLK.iBo]
        Rv = dTab[iPrs][clsBLK.iRv] ; Bg = dTab[iPrs][clsBLK.iBg]

        denO = BP.denOil(dSTO,dSTG,Rs,Bo)
        denG = BP.denGas(dSTO,dSTG,Rv,Bg)

        xLiq = cCon/(cCon +     Rs)
        yLiq = cCon/(cCon + 1.0/Rv)

        Mliq = BP.phaseMw(mSTG,mSTO,xLiq)
        Mvap = BP.phaseMw(mSTG,mSTO,yLiq)

        Vliq = Mliq/denO
        Vvap = Mvap/denG

        cRow = [xLiq,yLiq,denO,denG,Vliq,Vvap]
        
        cTab.append(cRow)

        #print("Pr,xO,yO,Vl,Vv {:10.3f}{:8.5f}{:8.5f}{:8.4f}{:8.4f}".format(Pr,xLiq,yLiq,Vliq,Vvap))

#======================================================================
#  Check the Oil Viscosity versus Pressure trend is physical
#  It can go wrong for condensates
#======================================================================

    qMonV = BP.oilViscMono(dTab,clsBLK)
    qMonC = BP.oilCompMono(dTab,clsBLK)

    #print("calcBlack: qMonv,qMonC ",qMonV,qMonC)

#== Initialise Extension Method =========================================        

    clsBLK.RT = UT.gasCon*tRes     #-- RT

    nEOS = clsBLK.nEOS

    clsBLK.EOS1["sOil"] = 0.5
    clsBLK.EOS1["sGas"] = 0.5

#========================================================================
#  Fit the 2-Component (STO & STG) EoS Parameters to Saturated Data
#========================================================================

    sOil,sGas = \
        BE.regEoSData(dTab,cTab,dicSAM,clsEOS,clsBLK,clsIO)

#========================================================================
#  Fit the 2-Component (STO & STG) Viscosity Parameters to Saturated Data
#========================================================================

    rOil,rGas = \
        BV.regViscData(dTab,cTab,dicSAM,clsEOS,clsBLK,clsIO)

#========================================================================
#  Calculate Convergence Pressure: Re-Set Saturated (sOil,sGas)
#========================================================================

    BO.setEoSVis(0,sOil,sGas,rOil,rGas,clsBLK)
    
    pCon = BO.convPressure(dTab,clsBLK)

    if pCon < pMax : pCon = pMax

    KoSat,KgSat,mO,mG = BO.extendTable(pSat,pCon,dTab,clsBLK)

    RsMax,RvMax = BO.calcRsRv(cCon,pCon,pSat,KoSat,KgSat,mO,mG)

#== Extended Data =====================================================

    eTab = []
    uLst = dTab[0][clsBLK.iUo]
    iRow = 0

    for iExt in range(len(pTab)) :
        
        if pTab[iExt] > pSat :
            
            pRes  = pTab[iExt]
            RTp   = clsBLK.RT/pRes
            
            Rs,Rv = BO.calcRsRv(cCon,pRes,pSat,KoSat,KgSat,mO,mG)
            
            Bo,Uo = BO.calcSatProp(qLiq,RTp,cCon,dSTO,dSTG,Rs ,clsBLK)
            Co,Vo = BO.calcComp(qLiq,RTp,cCon,dSTO,dSTG,Rs,Bo,Uo,clsBLK)

            Bg,Ug = BO.calcSatProp(qVap,RTp,cCon,dSTO,dSTG,Rv ,clsBLK)
            Bd,Ud = BO.calcSatProp(qVap,RTp,cCon,dSTO,dSTG,0.0,clsBLK)

#-- For condensates, Uo can go astray -------------------------------

            if Uo > uLst : Ux = clsBLK.UoI*exp(Rs*clsBLK.UoS)
            Uo   = Ux
            uLst = Uo

            eRow = [pRes,Rs,Bo,Uo,Co,Vo,Rv,Bg,Ug,Bd,Ud]
            eTab.append(eRow)

#========================================================================
#  Oil and Gas Output depends on Simulator Type
#========================================================================

    qDep = clsBLK.qDep

    if   sim3 == "TEM" :
        BM.outMORE(fSim,dTab,eTab,sOil,sGas,rOil,rGas,qMonV,clsBLK,clsUNI,clsIO)
        if not qDep : clsIO.qMOR = UT.closeFile(fSim)
    elif sim3 == "CMG" :
        BI.outIMEX(fSim,dTab,eTab,sOil,sGas,rOil,rGas,qMonV,clsBLK,clsUNI,clsIO)
        if not qDep : clsIO.qIMX = UT.closeFile(fSim)
    elif sim3 == "VIP" :
        BN.outVIP( fSim,dTab,eTab,sOil,sGas,rOil,rGas,qMonV,clsBLK,clsUNI,clsIO)
        if not qDep : clsIO.qVIP = UT.closeFile(fSim)
    else :
        B1.outE100(fSim,dTab,eTab,sOil,sGas,rOil,rGas,qMonV,clsBLK,clsUNI,clsIO)
        if not qDep : clsIO.q100 = UT.closeFile(fSim)

#========================================================================
#  Composition versus Depth Calculation?
#========================================================================

    if qDep :
        BG.blackGrad(clsEOS,dicSAM,clsBLK,clsUNI,clsIO)
        clsIO.q100 = UT.closeFile(fSim)

#========================================================================
#  End of Routine
#========================================================================

    print("calcBlack: Finished")

    return