def identify_phase_mixture(T=None, P=None, zs=None, Tcs=None, Pcs=None,
                           Psats=None, CASRNs=None,
                           AvailableMethods=False, Method=None):  # pragma: no cover
    '''
    >>> identify_phase_mixture(T=280, P=5000., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('l', [0.5, 0.5], None, 0)
    >>> identify_phase_mixture(T=280, P=3000., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('two-phase', [0.7142857142857143, 0.2857142857142857], [0.33333333333333337, 0.6666666666666666], 0.5625000000000001)
    >>> identify_phase_mixture(T=280, P=800., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('g', None, [0.5, 0.5], 1)
    >>> identify_phase_mixture(T=280, P=800., zs=[0.5, 0.5])
    (None, None, None, None)
    '''
    def list_methods():
        methods = []
        if Psats and none_and_length_check((Psats, zs)):
            methods.append('IDEAL_VLE')
        if Tcs and none_and_length_check([Tcs]) and all([T >= i for i in Tcs]):
            methods.append('SUPERCRITICAL_T')
        if Pcs and none_and_length_check([Pcs]) and all([P >= i for i in Pcs]):
            methods.append('SUPERCRITICAL_P')
        if Tcs and none_and_length_check([zs, Tcs]) and any([T > Tc for Tc in Tcs]):
            methods.append('IDEAL_VLE_SUPERCRITICAL')
        methods.append('NONE')
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]
    # This is the calculate, given the method section
    xs, ys, phase, V_over_F = None, None, None, None
    if Method == 'IDEAL_VLE':
        Pdew = dew_at_T(zs, Psats)
        Pbubble = bubble_at_T(zs, Psats)
        if P >= Pbubble:
            phase = 'l'
            ys = None
            xs = zs
            V_over_F = 0
        elif P <= Pdew:
            phase = 'g'
            ys = zs
            xs = None
            V_over_F = 1
        elif Pdew < P < Pbubble:
            xs, ys, V_over_F = flash(P, zs, Psats)
            phase = 'two-phase'
    elif Method == 'SUPERCRITICAL_T':
        if all([T >= i for i in Tcs]):
            phase = 'g'
        else: # The following is nonsensical
            phase = 'two-phase'
    elif Method == 'SUPERCRITICAL_P':
        if all([P >= i for i in Pcs]):
            phase = 'g'
        else: # The following is nonsensical
            phase = 'two-phase'
    elif Method == 'IDEAL_VLE_SUPERCRITICAL':
        Psats = list(Psats)
        for i in range(len(Psats)):
            if not Psats[i] and Tcs[i] and Tcs[i] <= T:
                Psats[i] = 1E8
        Pdew = dew_at_T(zs, Psats)
        Pbubble = 1E99
        if P >= Pbubble:
            phase = 'l'
            ys = None
            xs = zs
            V_over_F = 0
        elif P <= Pdew:
            phase = 'g'
            ys = zs
            xs = None
            V_over_F = 1
        elif Pdew < P < Pbubble:
            xs, ys, V_over_F = flash(P, zs, Psats)
            phase = 'two-phase'

    elif Method == 'NONE':
        pass
    else:
        raise Exception('Failure in in function')
    return phase, xs, ys, V_over_F
def identify_phase_mixture(T=None, P=None, zs=None, Tcs=None, Pcs=None,
                           Psats=None, CASRNs=None,
                           AvailableMethods=False, Method=None):  # pragma: no cover
    '''
    >>> identify_phase_mixture(T=280, P=5000., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('l', [0.5, 0.5], None, 0)
    >>> identify_phase_mixture(T=280, P=3000., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('two-phase', [0.7142857142857143, 0.2857142857142857], [0.33333333333333337, 0.6666666666666666], 0.5625000000000001)
    >>> identify_phase_mixture(T=280, P=800., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('g', None, [0.5, 0.5], 1)
    >>> identify_phase_mixture(T=280, P=800., zs=[0.5, 0.5])
    (None, None, None, None)
    '''
    def list_methods():
        methods = []
        if Psats and none_and_length_check((Psats, zs)):
            methods.append('IDEAL_VLE')
        if Tcs and none_and_length_check([Tcs]) and all([T >= i for i in Tcs]):
            methods.append('SUPERCRITICAL_T')
        if Pcs and none_and_length_check([Pcs]) and all([P >= i for i in Pcs]):
            methods.append('SUPERCRITICAL_P')
        if Tcs and none_and_length_check([zs, Tcs]) and any([T > Tc for Tc in Tcs]):
            methods.append('IDEAL_VLE_SUPERCRITICAL')
        methods.append('NONE')
        return methods
    if AvailableMethods:
        return list_methods()
    if not Method:
        Method = list_methods()[0]
    # This is the calculate, given the method section
    xs, ys, phase, V_over_F = None, None, None, None
    if Method == 'IDEAL_VLE':
        Pdew = dew_at_T(zs, Psats)
        Pbubble = bubble_at_T(zs, Psats)
        if P >= Pbubble:
            phase = 'l'
            ys = None
            xs = zs
            V_over_F = 0
        elif P <= Pdew:
            phase = 'g'
            ys = zs
            xs = None
            V_over_F = 1
        elif Pdew < P < Pbubble:
            xs, ys, V_over_F = flash(P, zs, Psats)
            phase = 'two-phase'
    elif Method == 'SUPERCRITICAL_T':
        if all([T >= i for i in Tcs]):
            phase = 'g'
        else: # The following is nonsensical
            phase = 'two-phase'
    elif Method == 'SUPERCRITICAL_P':
        if all([P >= i for i in Pcs]):
            phase = 'g'
        else: # The following is nonsensical
            phase = 'two-phase'
    elif Method == 'IDEAL_VLE_SUPERCRITICAL':
        Psats = list(Psats)
        for i in range(len(Psats)):
            if not Psats[i] and Tcs[i] and Tcs[i] <= T:
                Psats[i] = 1E8
        Pdew = dew_at_T(zs, Psats)
        Pbubble = 1E99
        if P >= Pbubble:
            phase = 'l'
            ys = None
            xs = zs
            V_over_F = 0
        elif P <= Pdew:
            phase = 'g'
            ys = zs
            xs = None
            V_over_F = 1
        elif Pdew < P < Pbubble:
            xs, ys, V_over_F = flash(P, zs, Psats)
            phase = 'two-phase'

    elif Method == 'NONE':
        pass
    else:
        raise Exception('Failure in in function')
    return phase, xs, ys, V_over_F
def identify_phase_mixture ( T = None , P = None , zs = None , Tcs = None , Pcs = None , Psats = None , CASRNs = None , AvailableMethods = False , Method = None ) : # pragma: no cover def list_methods ( ) : methods = [ ] if Psats and none_and_length_check ( ( Psats , zs ) ) : methods . append ( 'IDEAL_VLE' ) if Tcs and none_and_length_check ( [ Tcs ] ) and all ( [ T >= i for i in Tcs ] ) : methods . append ( 'SUPERCRITICAL_T' ) if Pcs and none_and_length_check ( [ Pcs ] ) and all ( [ P >= i for i in Pcs ] ) : methods . append ( 'SUPERCRITICAL_P' ) if Tcs and none_and_length_check ( [ zs , Tcs ] ) and any ( [ T > Tc for Tc in Tcs ] ) : methods . append ( 'IDEAL_VLE_SUPERCRITICAL' ) methods . append ( 'NONE' ) return methods if AvailableMethods : return list_methods ( ) if not Method : Method = list_methods ( ) [ 0 ] # This is the calculate, given the method section xs , ys , phase , V_over_F = None , None , None , None if Method == 'IDEAL_VLE' : Pdew = dew_at_T ( zs , Psats ) Pbubble = bubble_at_T ( zs , Psats ) if P >= Pbubble : phase = 'l' ys = None xs = zs V_over_F = 0 elif P <= Pdew : phase = 'g' ys = zs xs = None V_over_F = 1 elif Pdew < P < Pbubble : xs , ys , V_over_F = flash ( P , zs , Psats ) phase = 'two-phase' elif Method == 'SUPERCRITICAL_T' : if all ( [ T >= i for i in Tcs ] ) : phase = 'g' else : # The following is nonsensical phase = 'two-phase' elif Method == 'SUPERCRITICAL_P' : if all ( [ P >= i for i in Pcs ] ) : phase = 'g' else : # The following is nonsensical phase = 'two-phase' elif Method == 'IDEAL_VLE_SUPERCRITICAL' : Psats = list ( Psats ) for i in range ( len ( Psats ) ) : if not Psats [ i ] and Tcs [ i ] and Tcs [ i ] <= T : Psats [ i ] = 1E8 Pdew = dew_at_T ( zs , Psats ) Pbubble = 1E99 if P >= Pbubble : phase = 'l' ys = None xs = zs V_over_F = 0 elif P <= Pdew : phase = 'g' ys = zs xs = None V_over_F = 1 elif Pdew < P < Pbubble : xs , ys , V_over_F = flash ( P , zs , Psats ) phase = 'two-phase' elif Method == 'NONE' : pass else : raise Exception ( 'Failure in in function' ) return phase , xs , ys , V_over_F
>>> identify_phase_mixture(T=280, P=5000., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('l', [0.5, 0.5], None, 0)
    >>> identify_phase_mixture(T=280, P=3000., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('two-phase', [0.7142857142857143, 0.2857142857142857], [0.33333333333333337, 0.6666666666666666], 0.5625000000000001)
    >>> identify_phase_mixture(T=280, P=800., zs=[0.5, 0.5], Psats=[1400, 7000])
    ('g', None, [0.5, 0.5], 1)
    >>> identify_phase_mixture(T=280, P=800., zs=[0.5, 0.5])
    (None, None, None, None)
>>> identify_phase_mixture ( T = 280 P = 5000 . zs = [ 0 . 5 0 . 5 ] Psats = [ 1400 7000 ] ) ( l [ 0 . 5 0 . 5 ] None 0 ) >>> identify_phase_mixture ( T = 280 P = 3000 . zs = [ 0 . 5 0 . 5 ] Psats = [ 1400 7000 ] ) ( two - phase [ 0 . 7142857142857143 0 . 2857142857142857 ] [ 0 . 33333333333333337 0 . 6666666666666666 ] 0 . 5625000000000001 ) >>> identify_phase_mixture ( T = 280 P = 800 . zs = [ 0 . 5 0 . 5 ] Psats = [ 1400 7000 ] ) ( g None [ 0 . 5 0 . 5 ] 1 ) >>> identify_phase_mixture ( T = 280 P = 800 . zs = [ 0 . 5 0 . 5 ] ) ( None None None None )