How to use the thermo.utils.MixtureProperty function in thermo

To help you get started, we’ve selected a few thermo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CalebBell / thermo / thermo / viscosity.py View on Github external
dPr = (P-P_sat)/Pc
    if dPr < 0:
        dPr = 0
    return (1. + D*(dPr/2.118)**A)/(1. + C*omega*dPr)*mu_l

### Viscosity of liquid mixtures


LALIBERTE_MU = 'Laliberte'
MIXING_LOG_MOLAR = 'Logarithmic mixing, molar'
MIXING_LOG_MASS = 'Logarithmic mixing, mass'

viscosity_liquid_mixture_methods = [LALIBERTE_MU, MIXING_LOG_MOLAR, MIXING_LOG_MASS]


class ViscosityLiquidMixture(MixtureProperty):
    '''Class for dealing with the viscosity of a liquid mixture as a   
    function of temperature, pressure, and composition.
    Consists of one electrolyte-specific method, and logarithmic rules based
    on either mole fractions of mass fractions. 
         
    Prefered method is :obj:`mixing_logarithmic` with mole
    fractions, or **Laliberte** if the mixture is aqueous and has electrolytes.  
        
    Parameters
    ----------
    CASs : list[str], optional
        The CAS numbers of all species in the mixture
    ViscosityLiquids : list[ViscosityLiquid], optional
        ViscosityLiquid objects created for all species in the mixture,  
        normally created by :obj:`thermo.chemical.Chemical`.
github CalebBell / thermo / thermo / heat_capacity.py View on Github external
elif method in self.tabular_data:
            return float(quad(lambda T: self.calculate(T, method)/T, T1, T2)[0])
        else:
            raise Exception('Method not valid')



### Mixture heat capacities
SIMPLE = 'SIMPLE'
LALIBERTE = 'Laliberte'
heat_capacity_gas_mixture_methods = [SIMPLE]
heat_capacity_liquid_mixture_methods = [LALIBERTE, SIMPLE]
heat_capacity_solid_mixture_methods = [SIMPLE]


class HeatCapacityLiquidMixture(MixtureProperty):
    '''Class for dealing with liquid heat capacity of a mixture as a function  
    of temperature, pressure, and composition.
    Consists only of mole weighted averaging, and the Laliberte method for 
    aqueous electrolyte solutions.
                 
    Parameters
    ----------
    MWs : list[float], optional
        Molecular weights of all species in the mixture, [g/mol]
    CASs : str, optional
        The CAS numbers of all species in the mixture
    HeatCapacityLiquids : list[HeatCapacityLiquid], optional
        HeatCapacityLiquid objects created for all species in the mixture,  
        normally created by :obj:`thermo.chemical.Chemical`.

    Notes
github CalebBell / thermo / thermo / volume.py View on Github external
validity = PhaseSI('T', T, 'P', P, self.CASRN) in ['gas', 'supercritical_gas', 'supercritical', 'supercritical_liquid']
        elif method in self.tabular_data:
            if not self.tabular_extrapolation_permitted:
                Ts, Ps, properties = self.tabular_data[method]
                if T < Ts[0] or T > Ts[-1] or P < Ps[0] or P > Ps[-1]:
                    validity = False
        else:
            raise Exception('Method not valid')
        return validity


volume_gas_mixture_methods = [EOS, SIMPLE, IDEAL]



class VolumeGasMixture(MixtureProperty):
    '''Class for dealing with the molar volume of a gas mixture as a   
    function of temperature, pressure, and composition.
    Consists of an equation of state, the ideal gas law, and one mole-weighted
    averaging method.
    
    Prefered method is **EOS**, or **IDEAL** if critical properties of
    components are unavailable.
        
    Parameters
    ----------
    CASs : list[str], optional
        The CAS numbers of all species in the mixture
    VolumeGases : list[VolumeGas], optional
        VolumeGas objects created for all species in the mixture,  
        normally created by :obj:`thermo.chemical.Chemical`.
    eos : container[EOS Object], optional
github CalebBell / thermo / thermo / interface.py View on Github external
raise ValueError('T > Tc according to Kays rule - model is not valid in this range.')
    Tb = mixing_simple(xs, Tbs)
    sigmar = mixing_simple(xs, sigmas_Tb)
    Tst = (Tc/T - 1.)/(Tc/Tb - 1)
    return 1.002855*Tst**1.118091*(T/Tb)*sigmar


WINTERFELDSCRIVENDAVIS = 'Winterfeld, Scriven, and Davis (1978)'
DIGUILIOTEJA = 'Diguilio and Teja (1988)'
SIMPLE = 'Simple'
NONE = 'None'

surface_tension_mixture_methods = [WINTERFELDSCRIVENDAVIS, DIGUILIOTEJA, SIMPLE]


class SurfaceTensionMixture(MixtureProperty):
    '''Class for dealing with surface tension of a mixture as a function of 
    temperature, pressure, and composition.
    Consists of two mixing rules specific to surface tension, and mole
    weighted averaging. 
         
    Prefered method is :obj:`Winterfeld_Scriven_Davis` which requires mole
    fractions, pure component surface tensions, and the molar density of each
    pure component. :obj:`Diguilio_Teja` is of similar accuracy, but requires
    the surface tensions of pure components at their boiling points, as well
    as boiling points and critical points and mole fractions. An ideal mixing
    rule based on mole fractions, **SIMPLE**, is also available and is still
    relatively accurate.
        
    Parameters
    ----------
    MWs : list[float], optional
github CalebBell / thermo / thermo / heat_capacity.py View on Github external
Weight fractions of all species in the mixture, [-]
        method : str
            Method name to use

        Returns
        -------
        validity : bool
            Whether or not a specifid method is valid
        '''
        if method in self.all_methods:
            return True
        else:
            raise Exception('Method not valid')


class HeatCapacityGasMixture(MixtureProperty):
    '''Class for dealing with the gas heat capacity of a mixture as a function  
    of temperature, pressure, and composition. Consists only of mole weighted 
    averaging.
                 
    Parameters
    ----------
    CASs : list[str], optional
        The CAS numbers of all species in the mixture
    HeatCapacityGases : list[HeatCapacityGas], optional
        HeatCapacityGas objects created for all species in the mixture,  
        normally created by :obj:`thermo.chemical.Chemical`.

    Notes
    -----
    To iterate over all methods, use the list stored in
    :obj:`heat_capacity_gas_mixture_methods`.
github CalebBell / thermo / thermo / volume.py View on Github external
omega = mixing_simple(xs, omegas)
    Tcm = sum([xs[i]*xs[j]*VijTcij[i][j]/Vm for j in cmps for i in cmps])
    return COSTALD(T, Tcm, Vm, omega)


NONE = 'None'
LALIBERTE = 'Laliberte'
COSTALD_MIXTURE = 'COSTALD mixture'
COSTALD_MIXTURE_FIT = 'COSTALD mixture parameters'
SIMPLE = 'SIMPLE'
RACKETT = 'RACKETT'
RACKETT_PARAMETERS = 'RACKETT Parameters'
volume_liquid_mixture_methods = [LALIBERTE, SIMPLE, COSTALD_MIXTURE_FIT, RACKETT_PARAMETERS, COSTALD, RACKETT]


class VolumeLiquidMixture(MixtureProperty):
    '''Class for dealing with the molar volume of a liquid mixture as a   
    function of temperature, pressure, and composition.
    Consists of one electrolyte-specific method, four corresponding states
    methods which do not use pure-component volumes, and one mole-weighted
    averaging method.
    
    Prefered method is **SIMPLE**, or **Laliberte** if the mixture is aqueous
    and has electrolytes.  
        
    Parameters
    ----------
    MWs : list[float], optional
        Molecular weights of all species in the mixture, [g/mol]
    Tcs : list[float], optional
        Critical temperatures of all species in the mixture, [K]
    Pcs : list[float], optional
github CalebBell / thermo / thermo / volume.py View on Github external
#            if T < self.Tt*0.3:
#                validity = False
        elif method in self.tabular_data:
            # if tabular_extrapolation_permitted, good to go without checking
            if not self.tabular_extrapolation_permitted:
                Ts, properties = self.tabular_data[method]
                if T < Ts[0] or T > Ts[-1]:
                    validity = False
        else:
            raise Exception('Method not valid')
        return validity


volume_solid_mixture_methods = [SIMPLE]

class VolumeSolidMixture(MixtureProperty):
    '''Class for dealing with the molar volume of a solid mixture as a   
    function of temperature, pressure, and composition.
    Consists of only mole-weighted averaging.
            
    Parameters
    ----------
    CASs : list[str], optional
        The CAS numbers of all species in the mixture
    VolumeSolids : list[VolumeSolid], optional
        VolumeSolid objects created for all species in the mixture,  
        normally created by :obj:`thermo.chemical.Chemical`.
                 
    Notes
    -----
    To iterate over all methods, use the list stored in
    :obj:`volume_solid_mixture_methods`.
github CalebBell / thermo / thermo / viscosity.py View on Github external
Aij[i][j] = mij[i][j]*Mij[i][j]**-0.5*(1 + (Mij[i][j]-Mij[i][j]**0.45)/(2*(1+Mij[i][j]) + (1+Mij[i][j]**0.45)*mij[i][j]**-0.5/(1+mij[i][j])))

            phiij[i][j] = (mus[i]/mus[j])**0.5*Sij[i][j]*Aij[i][j]

    return sum([ys[i]*mus[i]/sum([ys[j]*phiij[i][j] for j in cmps]) for i in cmps])


BROKAW = 'Brokaw'
HERNING_ZIPPERER = 'Herning-Zipperer'
WILKE = 'Wilke'
SIMPLE = 'Simple'
viscosity_gas_mixture_methods = [BROKAW, HERNING_ZIPPERER, WILKE, SIMPLE]


class ViscosityGasMixture(MixtureProperty):
    '''Class for dealing with the viscosity of a gas mixture as a   
    function of temperature, pressure, and composition.
    Consists of three gas viscosity specific mixing rules and a mole-weighted
    simple mixing rule.
         
    Prefered method is :obj:`Brokaw`.
    
    Parameters
    ----------
    MWs : list[float], optional
        Molecular weights of all species in the mixture, [g/mol]
    molecular_diameters : list[float], optional
        Lennard-Jones molecular diameters, [Angstrom]
    Stockmayers : list[float], optional
        Lennard-Jones depth of potential-energy minimum over k 
        or epsilon_k, [K]
github CalebBell / thermo / thermo / thermal_conductivity.py View on Github external
iz. Mat. Estestv.Nauk, CI0B): 37-40A955); Chem. Abstr., 49: 11366 A955).
    '''
    if not none_and_length_check([ks, ws], 2):  # check same-length inputs
        raise Exception('Function inputs are incorrect format')
    return ws[0]*ks[0] + ws[1]*ks[1] - 0.72*ws[0]*ws[1]*(ks[1] - ks[0])


MAGOMEDOV = 'Magomedov'
DIPPR_9H = 'DIPPR9H'
FILIPPOV = 'Filippov'
SIMPLE = 'SIMPLE'

thermal_conductivity_liquid_mixture_methods = [MAGOMEDOV, DIPPR_9H, FILIPPOV, SIMPLE]


class ThermalConductivityLiquidMixture(MixtureProperty):
    '''Class for dealing with thermal conductivity of a liquid mixture as a   
    function of temperature, pressure, and composition.
    Consists of two mixing rule specific to liquid thremal conductivity, one
    coefficient-based method for aqueous electrolytes, and mole weighted 
    averaging. 
         
    Prefered method is :obj:`DIPPR9H` which requires mass
    fractions, and pure component liquid thermal conductivities. This is 
    substantially better than the ideal mixing rule based on mole fractions, 
    **SIMPLE**. **Filippov** is of similar accuracy but applicable to binary
    systems only.
        
    Parameters
    ----------
    CASs : str, optional
        The CAS numbers of all species in the mixture
github CalebBell / thermo / thermo / heat_capacity.py View on Github external
method : str
            Method name to use

        Returns
        -------
        validity : bool
            Whether or not a specifid method is valid
        '''
        if method in self.all_methods:
            return True
        else:
            raise Exception('Method not valid')



class HeatCapacitySolidMixture(MixtureProperty):
    '''Class for dealing with solid heat capacity of a mixture as a function of 
    temperature, pressure, and composition.
    Consists only of mole weighted averaging.
                 
    Parameters
    ----------
    CASs : list[str], optional
        The CAS numbers of all species in the mixture
    HeatCapacitySolids : list[HeatCapacitySolid], optional
        HeatCapacitySolid objects created for all species in the mixture,  
        normally created by :obj:`thermo.chemical.Chemical`.

    Notes
    -----
    To iterate over all methods, use the list stored in
    :obj:`heat_capacity_solid_mixture_methods`.