signature:
def calculate_integral ( self , T1 , T2 , method ) :
    r'''Method to calculate the integral of a property with respect to
 temperature , using a specified method . Implements the analytical
 integrals of all available methods except for tabular data .
 Parameters
 T1 : float
 Lower limit of integration , [ K ]
 T2 : float
 Upper limit of integration , [ K ]
 method : str
 Method for which to find the integral
 Returns
 integral : float
 Calculated integral of the property over the given range ,
 [ ` units * K ` ]'''

implementation:
if method == TRCIG :
    H2 = TRCCp_integral ( T2 , * self . TRCIG_coefs )
    H1 = TRCCp_integral ( T1 , * self . TRCIG_coefs )
    return H2 - H1
elif method == POLING :
    A , B , C , D , E = self . POLING_coefs
    H2 = ( ( ( ( ( 0.2 * E ) * T2 + 0.25 * D ) * T2 + C / 3. ) * T2 + 0.5 * B ) * T2 + A ) * T2
    H1 = ( ( ( ( ( 0.2 * E ) * T1 + 0.25 * D ) * T1 + C / 3. ) * T1 + 0.5 * B ) * T1 + A ) * T1
    return R * ( H2 - H1 )
elif method == POLING_CONST :
    return ( T2 - T1 ) * self . POLING_constant
elif method == CRCSTD :
    return ( T2 - T1 ) * self . CRCSTD_constant
elif method == LASTOVKA_SHAW :
    dH = ( Lastovka_Shaw_integral ( T2 , self . similarity_variable ) - Lastovka_Shaw_integral ( T1 , self . similarity_variable ) )
    return property_mass_to_molar ( dH , self . MW )
elif method in self . tabular_data or method == COOLPROP :
    return float ( quad ( self . calculate , T1 , T2 , args = ( method ) ) [ 0 ] )
else :
    raise Exception ( 'Method not valid' )


signature:
def calculate_integral_over_T ( self , T1 , T2 , method ) :
    r'''Method to calculate the integral of a property over temperature
 with respect to temperature , using a specified method . Implements the
 analytical integrals of all available methods except for tabular data .
 Parameters
 T1 : float
 Lower limit of integration , [ K ]
 T2 : float
 Upper limit of integration , [ K ]
 method : str
 Method for which to find the integral
 Returns
 integral : float
 Calculated integral of the property over the given range ,
 [ ` units ` ]'''

implementation:
if method == TRCIG :
    S2 = TRCCp_integral_over_T ( T2 , * self . TRCIG_coefs )
    S1 = TRCCp_integral_over_T ( T1 , * self . TRCIG_coefs )
    return S2 - S1
elif method == CRCSTD :
    return self . CRCSTD_constant * log ( T2 / T1 )
elif method == POLING_CONST :
    return self . POLING_constant * log ( T2 / T1 )
elif method == POLING :
    A , B , C , D , E = self . POLING_coefs
    S2 = ( ( ( ( 0.25 * E ) * T2 + D / 3. ) * T2 + 0.5 * C ) * T2 + B ) * T2
    S1 = ( ( ( ( 0.25 * E ) * T1 + D / 3. ) * T1 + 0.5 * C ) * T1 + B ) * T1
    return R * ( S2 - S1 + A * log ( T2 / T1 ) )
elif method == LASTOVKA_SHAW :
    dS = ( Lastovka_Shaw_integral_over_T ( T2 , self . similarity_variable ) - Lastovka_Shaw_integral_over_T ( T1 , self . similarity_variable ) )
    return property_mass_to_molar ( dS , self . MW )
elif method in self . tabular_data or method == COOLPROP :
    return float ( quad ( lambda T : self . calculate ( T , method ) / T , T1 , T2 ) [ 0 ] )
else :
    raise Exception ( 'Method not valid' )


signature:
def calculate_integral ( self , T1 , T2 ) :
    r'''Method to compute the enthalpy integral of heat capacity from
 ` T1 ` to ` T2 ` .
 Parameters
 T1 : float
 Initial temperature , [ K ]
 T2 : float
 Final temperature , [ K ]
 Returns
 dH : float
 Enthalpy difference between ` T1 ` and ` T2 ` , [ J / mol ]'''

implementation: return ( Zabransky_quasi_polynomial_integral ( T2 , self . Tc , * self . coeffs ) - Zabransky_quasi_polynomial_integral ( T1 , self . Tc , * self . coeffs ) )


signature:
def calculate_integral_over_T ( self , T1 , T2 ) :
    r'''Method to compute the entropy integral of heat capacity from
 ` T1 ` to ` T2 ` .
 Parameters
 T1 : float
 Initial temperature , [ K ]
 T2 : float
 Final temperature , [ K ]
 Returns
 dS : float
 Entropy difference between ` T1 ` and ` T2 ` , [ J / mol / K ]'''

implementation: return ( Zabransky_quasi_polynomial_integral_over_T ( T2 , self . Tc , * self . coeffs ) - Zabransky_quasi_polynomial_integral_over_T ( T1 , self . Tc , * self . coeffs ) )


signature:
def add_coeffs ( self , Tmin , Tmax , coeffs ) :
    '''Called internally during the parsing of the Zabransky database , to
 add coefficients as they are read one per line'''

implementation:
self . n += 1
if not self . Ts :
    self . Ts = [ Tmin , Tmax ]
    self . coeff_sets = [ coeffs ]
else :
    for ind , T in enumerate ( self . Ts ) :
        if Tmin < T : # Under an existing coefficient set - assume Tmax will come from another set
            self . Ts . insert ( ind , Tmin )
            self . coeff_sets . insert ( ind , coeffs )
            return
    # Must be appended to end instead
    self . Ts . append ( Tmax )
    self . coeff_sets . append ( coeffs )


signature:
def _coeff_ind_from_T ( self , T ) :
    '''Determines the index at which the coefficients for the current
 temperature are stored in ` coeff _ sets ` .'''

implementation:
# DO NOT CHANGE
if self . n == 1 :
    return 0
for i in range ( self . n ) :
    if T <= self . Ts [ i + 1 ] :
        return i
return self . n - 1


signature:
def calculate ( self , T ) :
    r'''Method to actually calculate heat capacity as a function of
 temperature .
 Parameters
 T : float
 Temperature , [ K ]
 Returns
 Cp : float
 Liquid heat capacity as T , [ J / mol / K ]'''

implementation: return Zabransky_cubic ( T , * self . coeff_sets [ self . _coeff_ind_from_T ( T ) ] )


signature:
def calculate_integral ( self , T1 , T2 ) :
    r'''Method to compute the enthalpy integral of heat capacity from
 ` T1 ` to ` T2 ` . Analytically integrates across the piecewise spline
 as necessary .
 Parameters
 T1 : float
 Initial temperature , [ K ]
 T2 : float
 Final temperature , [ K ]
 Returns
 dS : float
 Enthalpy difference between ` T1 ` and ` T2 ` , [ J / mol / K ]'''

implementation:
# Simplify the problem so we can assume T2 > = T1
if T2 < T1 :
    flipped = True
    T1 , T2 = T2 , T1
else :
    flipped = False
# Fastest case - only one coefficient set , occurs surprisingly often
if self . n == 1 :
    dH = ( Zabransky_cubic_integral ( T2 , * self . coeff_sets [ 0 ] ) - Zabransky_cubic_integral ( T1 , * self . coeff_sets [ 0 ] ) )
else :
    ind_T1 , ind_T2 = self . _coeff_ind_from_T ( T1 ) , self . _coeff_ind_from_T ( T2 )
    # Second fastest case - both are in the same coefficient set
    if ind_T1 == ind_T2 :
        dH = ( Zabransky_cubic_integral ( T2 , * self . coeff_sets [ ind_T2 ] ) - Zabransky_cubic_integral ( T1 , * self . coeff_sets [ ind_T1 ] ) )
    # Fo through the loop if we need to - inevitably slow
    else :
        dH = ( Zabransky_cubic_integral ( self . Ts [ ind_T1 ] , * self . coeff_sets [ ind_T1 ] ) - Zabransky_cubic_integral ( T1 , * self . coeff_sets [ ind_T1 ] ) )
        for i in range ( ind_T1 , ind_T2 ) :
            diff = ( Zabransky_cubic_integral ( self . Ts [ i + 1 ] , * self . coeff_sets [ i ] ) - Zabransky_cubic_integral ( self . Ts [ i ] , * self . coeff_sets [ i ] ) )
            dH += diff
        end = ( Zabransky_cubic_integral ( T2 , * self . coeff_sets [ ind_T2 ] ) - Zabransky_cubic_integral ( self . Ts [ ind_T2 ] , * self . coeff_sets [ ind_T2 ] ) )
        dH += end
return - dH if flipped else dH


signature:
def calculate_integral_over_T ( self , T1 , T2 ) :
    r'''Method to compute the entropy integral of heat capacity from
 ` T1 ` to ` T2 ` . Analytically integrates across the piecewise spline
 as necessary .
 Parameters
 T1 : float
 Initial temperature , [ K ]
 T2 : float
 Final temperature , [ K ]
 Returns
 dS : float
 Entropy difference between ` T1 ` and ` T2 ` , [ J / mol / K ]'''

implementation:
# Simplify the problem so we can assume T2 > = T1
if T2 < T1 :
    flipped = True
    T1 , T2 = T2 , T1
else :
    flipped = False
# Fastest case - only one coefficient set , occurs surprisingly often
if self . n == 1 :
    dS = ( Zabransky_cubic_integral_over_T ( T2 , * self . coeff_sets [ 0 ] ) - Zabransky_cubic_integral_over_T ( T1 , * self . coeff_sets [ 0 ] ) )
else :
    ind_T1 , ind_T2 = self . _coeff_ind_from_T ( T1 ) , self . _coeff_ind_from_T ( T2 )
    # Second fastest case - both are in the same coefficient set
    if ind_T1 == ind_T2 :
        dS = ( Zabransky_cubic_integral_over_T ( T2 , * self . coeff_sets [ ind_T2 ] ) - Zabransky_cubic_integral_over_T ( T1 , * self . coeff_sets [ ind_T1 ] ) )
    # Fo through the loop if we need to - inevitably slow
    else :
        dS = ( Zabransky_cubic_integral_over_T ( self . Ts [ ind_T1 ] , * self . coeff_sets [ ind_T1 ] ) - Zabransky_cubic_integral_over_T ( T1 , * self . coeff_sets [ ind_T1 ] ) )
        for i in range ( ind_T1 , ind_T2 ) :
            diff = ( Zabransky_cubic_integral_over_T ( self . Ts [ i + 1 ] , * self . coeff_sets [ i ] ) - Zabransky_cubic_integral_over_T ( self . Ts [ i ] , * self . coeff_sets [ i ] ) )
            dS += diff
        end = ( Zabransky_cubic_integral_over_T ( T2 , * self . coeff_sets [ ind_T2 ] ) - Zabransky_cubic_integral_over_T ( self . Ts [ ind_T2 ] , * self . coeff_sets [ ind_T2 ] ) )
        dS += end
return - dS if flipped else dS


signature:
def load_all_methods ( self ) :
    r'''Method which picks out coefficients for the specified chemical
 from the various dictionaries and DataFrames storing it . All data is
 stored as attributes . This method also sets : obj : ` Tmin ` , : obj : ` Tmax ` ,
 and : obj : ` all _ methods ` as a set of methods for which the data exists for .
 Called on initialization only . See the source code for the variables at
 which the coefficients are stored . The coefficients can safely be
 altered once the class is initialized . This method can be called again
 to reset the parameters .'''

implementation:
methods = [ ]
Tmins , Tmaxs = [ ] , [ ]
if self . CASRN in zabransky_dict_const_s :
    methods . append ( ZABRANSKY_SPLINE )
    self . Zabransky_spline = zabransky_dict_const_s [ self . CASRN ]
if self . CASRN in zabransky_dict_const_p :
    methods . append ( ZABRANSKY_QUASIPOLYNOMIAL )
    self . Zabransky_quasipolynomial = zabransky_dict_const_p [ self . CASRN ]
if self . CASRN in zabransky_dict_iso_s :
    methods . append ( ZABRANSKY_SPLINE_C )
    self . Zabransky_spline_iso = zabransky_dict_iso_s [ self . CASRN ]
if self . CASRN in zabransky_dict_iso_p :
    methods . append ( ZABRANSKY_QUASIPOLYNOMIAL_C )
    self . Zabransky_quasipolynomial_iso = zabransky_dict_iso_p [ self . CASRN ]
if self . CASRN in Poling_data . index and not np . isnan ( Poling_data . at [ self . CASRN , 'Cpl' ] ) :
    methods . append ( POLING_CONST )
    self . POLING_T = 298.15
    self . POLING_constant = float ( Poling_data . at [ self . CASRN , 'Cpl' ] )
if self . CASRN in CRC_standard_data . index and not np . isnan ( CRC_standard_data . at [ self . CASRN , 'Cpl' ] ) :
    methods . append ( CRCSTD )
    self . CRCSTD_T = 298.15
    self . CRCSTD_constant = float ( CRC_standard_data . at [ self . CASRN , 'Cpl' ] )
# Saturation functions
if self . CASRN in zabransky_dict_sat_s :
    methods . append ( ZABRANSKY_SPLINE_SAT )
    self . Zabransky_spline_sat = zabransky_dict_sat_s [ self . CASRN ]
if self . CASRN in zabransky_dict_sat_p :
    methods . append ( ZABRANSKY_QUASIPOLYNOMIAL_SAT )
    self . Zabransky_quasipolynomial_sat = zabransky_dict_sat_p [ self . CASRN ]
if self . CASRN in _VDISaturationDict : # NOTE : VDI data is for the saturation curve , i . e . at increasing
# pressure ; it is normally substantially higher than the ideal gas
# value
    methods . append ( VDI_TABULAR )
    Ts , props = VDI_tabular_data ( self . CASRN , 'Cp (l)' )
    self . VDI_Tmin = Ts [ 0 ]
    self . VDI_Tmax = Ts [ - 1 ]
    self . tabular_data [ VDI_TABULAR ] = ( Ts , props )
    Tmins . append ( self . VDI_Tmin ) ;
    Tmaxs . append ( self . VDI_Tmax )
if self . Tc and self . omega :
    methods . extend ( [ ROWLINSON_POLING , ROWLINSON_BONDI ] )
if has_CoolProp and self . CASRN in coolprop_dict :
    methods . append ( COOLPROP )
    self . CP_f = coolprop_fluids [ self . CASRN ]
    Tmins . append ( self . CP_f . Tt ) ;
    Tmaxs . append ( self . CP_f . Tc )
if self . MW and self . similarity_variable :
    methods . append ( DADGOSTAR_SHAW )
self . all_methods = set ( methods )
if Tmins and Tmaxs : # TODO : More Tmin , Tmax ranges
    self . Tmin , self . Tmax = min ( Tmins ) , max ( Tmaxs )


signature:
def calculate ( self , T , method ) :
    r'''Method to calculate heat capacity of a liquid at temperature ` T `
 with a given method .
 This method has no exception handling ; see ` T _ dependent _ property `
 for that .
 Parameters
 T : float
 Temperature at which to calculate heat capacity , [ K ]
 method : str
 Name of the method to use
 Returns
 Cp : float
 Heat capacity of the liquid at T , [ J / mol / K ]'''

implementation:
if method == ZABRANSKY_SPLINE :
    return self . Zabransky_spline . calculate ( T )
elif method == ZABRANSKY_QUASIPOLYNOMIAL :
    return self . Zabransky_quasipolynomial . calculate ( T )
elif method == ZABRANSKY_SPLINE_C :
    return self . Zabransky_spline_iso . calculate ( T )
elif method == ZABRANSKY_QUASIPOLYNOMIAL_C :
    return self . Zabransky_quasipolynomial_iso . calculate ( T )
elif method == ZABRANSKY_SPLINE_SAT :
    return self . Zabransky_spline_sat . calculate ( T )
elif method == ZABRANSKY_QUASIPOLYNOMIAL_SAT :
    return self . Zabransky_quasipolynomial_sat . calculate ( T )
elif method == COOLPROP :
    return CoolProp_T_dependent_property ( T , self . CASRN , 'CPMOLAR' , 'l' )
elif method == POLING_CONST :
    return self . POLING_constant
elif method == CRCSTD :
    return self . CRCSTD_constant
elif method == ROWLINSON_POLING :
    Cpgm = self . Cpgm ( T ) if hasattr ( self . Cpgm , '__call__' ) else self . Cpgm
    return Rowlinson_Poling ( T , self . Tc , self . omega , Cpgm )
elif method == ROWLINSON_BONDI :
    Cpgm = self . Cpgm ( T ) if hasattr ( self . Cpgm , '__call__' ) else self . Cpgm
    return Rowlinson_Bondi ( T , self . Tc , self . omega , Cpgm )
elif method == DADGOSTAR_SHAW :
    Cp = Dadgostar_Shaw ( T , self . similarity_variable )
    return property_mass_to_molar ( Cp , self . MW )
elif method in self . tabular_data :
    return self . interpolate ( T , method )
else :
    raise Exception ( 'Method not valid' )


signature:
def calculate_integral ( self , T1 , T2 , method ) :
    r'''Method to calculate the integral of a property with respect to
 temperature , using a specified method . Implements the
 analytical integrals of all available methods except for tabular data ,
 the case of multiple coefficient sets needed to encompass the temperature
 range of any of the ZABRANSKY methods , and the CSP methods using the
 vapor phase properties .
 Parameters
 T1 : float
 Lower limit of integration , [ K ]
 T2 : float
 Upper limit of integration , [ K ]
 method : str
 Method for which to find the integral
 Returns
 integral : float
 Calculated integral of the property over the given range ,
 [ ` units * K ` ]'''

implementation:
if method == ZABRANSKY_SPLINE :
    return self . Zabransky_spline . calculate_integral ( T1 , T2 )
elif method == ZABRANSKY_SPLINE_C :
    return self . Zabransky_spline_iso . calculate_integral ( T1 , T2 )
elif method == ZABRANSKY_SPLINE_SAT :
    return self . Zabransky_spline_sat . calculate_integral ( T1 , T2 )
elif method == ZABRANSKY_QUASIPOLYNOMIAL :
    return self . Zabransky_quasipolynomial . calculate_integral ( T1 , T2 )
elif method == ZABRANSKY_QUASIPOLYNOMIAL_C :
    return self . Zabransky_quasipolynomial_iso . calculate_integral ( T1 , T2 )
elif method == ZABRANSKY_QUASIPOLYNOMIAL_SAT :
    return self . Zabransky_quasipolynomial_sat . calculate_integral ( T1 , T2 )
elif method == POLING_CONST :
    return ( T2 - T1 ) * self . POLING_constant
elif method == CRCSTD :
    return ( T2 - T1 ) * self . CRCSTD_constant
elif method == DADGOSTAR_SHAW :
    dH = ( Dadgostar_Shaw_integral ( T2 , self . similarity_variable ) - Dadgostar_Shaw_integral ( T1 , self . similarity_variable ) )
    return property_mass_to_molar ( dH , self . MW )
elif method in self . tabular_data or method == COOLPROP or method in [ ROWLINSON_POLING , ROWLINSON_BONDI ] :
    return float ( quad ( self . calculate , T1 , T2 , args = ( method ) ) [ 0 ] )
else :
    raise Exception ( 'Method not valid' )


signature:
def calculate_integral_over_T ( self , T1 , T2 , method ) :
    r'''Method to calculate the integral of a property over temperature
 with respect to temperature , using a specified method . Implements the
 analytical integrals of all available methods except for tabular data ,
 the case of multiple coefficient sets needed to encompass the temperature
 range of any of the ZABRANSKY methods , and the CSP methods using the
 vapor phase properties .
 Parameters
 T1 : float
 Lower limit of integration , [ K ]
 T2 : float
 Upper limit of integration , [ K ]
 method : str
 Method for which to find the integral
 Returns
 integral : float
 Calculated integral of the property over the given range ,
 [ ` units ` ]'''

implementation:
if method == ZABRANSKY_SPLINE :
    return self . Zabransky_spline . calculate_integral_over_T ( T1 , T2 )
elif method == ZABRANSKY_SPLINE_C :
    return self . Zabransky_spline_iso . calculate_integral_over_T ( T1 , T2 )
elif method == ZABRANSKY_SPLINE_SAT :
    return self . Zabransky_spline_sat . calculate_integral_over_T ( T1 , T2 )
elif method == ZABRANSKY_QUASIPOLYNOMIAL :
    return self . Zabransky_quasipolynomial . calculate_integral_over_T ( T1 , T2 )
elif method == ZABRANSKY_QUASIPOLYNOMIAL_C :
    return self . Zabransky_quasipolynomial_iso . calculate_integral_over_T ( T1 , T2 )
elif method == ZABRANSKY_QUASIPOLYNOMIAL_SAT :
    return self . Zabransky_quasipolynomial_sat . calculate_integral_over_T ( T1 , T2 )
elif method == POLING_CONST :
    return self . POLING_constant * log ( T2 / T1 )
elif method == CRCSTD :
    return self . CRCSTD_constant * log ( T2 / T1 )
elif method == DADGOSTAR_SHAW :
    dS = ( Dadgostar_Shaw_integral_over_T ( T2 , self . similarity_variable ) - Dadgostar_Shaw_integral_over_T ( T1 , self . similarity_variable ) )
    return property_mass_to_molar ( dS , self . MW )
elif method in self . tabular_data or method == COOLPROP or method in [ ROWLINSON_POLING , ROWLINSON_BONDI ] :
    return float ( quad ( lambda T : self . calculate ( T , method ) / T , T1 , T2 ) [ 0 ] )
else :
    raise Exception ( 'Method not valid' )


implementation:
methods = [ ]
Tmins , Tmaxs = [ ] , [ ]
if self . CASRN and self . CASRN in _PerryI and 'c' in _PerryI [ self . CASRN ] :
    self . PERRY151_Tmin = _PerryI [ self . CASRN ] [ 'c' ] [ 'Tmin' ] if _PerryI [ self . CASRN ] [ 'c' ] [ 'Tmin' ] else 0
    self . PERRY151_Tmax = _PerryI [ self . CASRN ] [ 'c' ] [ 'Tmax' ] if _PerryI [ self . CASRN ] [ 'c' ] [ 'Tmax' ] else 2000
    self . PERRY151_const = _PerryI [ self . CASRN ] [ 'c' ] [ 'Const' ]
    self . PERRY151_lin = _PerryI [ self . CASRN ] [ 'c' ] [ 'Lin' ]
    self . PERRY151_quad = _PerryI [ self . CASRN ] [ 'c' ] [ 'Quad' ]
    self . PERRY151_quadinv = _PerryI [ self . CASRN ] [ 'c' ] [ 'Quadinv' ]
    methods . append ( PERRY151 )
    Tmins . append ( self . PERRY151_Tmin ) ;
    Tmaxs . append ( self . PERRY151_Tmax )
if self . CASRN in CRC_standard_data . index and not np . isnan ( CRC_standard_data . at [ self . CASRN , 'Cpc' ] ) :
    self . CRCSTD_Cp = float ( CRC_standard_data . at [ self . CASRN , 'Cpc' ] )
    methods . append ( CRCSTD )
if self . MW and self . similarity_variable :
    methods . append ( LASTOVKA_S )
    Tmins . append ( 1.0 ) ;
    Tmaxs . append ( 10000 )
    # Works above roughly 1 K up to 10K .
self . all_methods = set ( methods )
if Tmins and Tmaxs :
    self . Tmin , self . Tmax = min ( Tmins ) , max ( Tmaxs )


signature:
def calculate ( self , T , method ) :
    r'''Method to calculate heat capacity of a solid at temperature ` T `
 with a given method .
 This method has no exception handling ; see ` T _ dependent _ property `
 for that .
 Parameters
 T : float
 Temperature at which to calculate heat capacity , [ K ]
 method : str
 Name of the method to use
 Returns
 Cp : float
 Heat capacity of the solid at T , [ J / mol / K ]'''

implementation:
if method == PERRY151 :
    Cp = ( self . PERRY151_const + self . PERRY151_lin * T + self . PERRY151_quadinv / T ** 2 + self . PERRY151_quad * T ** 2 ) * calorie
elif method == CRCSTD :
    Cp = self . CRCSTD_Cp
elif method == LASTOVKA_S :
    Cp = Lastovka_solid ( T , self . similarity_variable )
    Cp = property_mass_to_molar ( Cp , self . MW )
elif method in self . tabular_data :
    Cp = self . interpolate ( T , method )
return Cp


implementation:
if method == PERRY151 :
    H2 = ( self . PERRY151_const * T2 + 0.5 * self . PERRY151_lin * T2 ** 2 - self . PERRY151_quadinv / T2 + self . PERRY151_quad * T2 ** 3 / 3. )
    H1 = ( self . PERRY151_const * T1 + 0.5 * self . PERRY151_lin * T1 ** 2 - self . PERRY151_quadinv / T1 + self . PERRY151_quad * T1 ** 3 / 3. )
    return ( H2 - H1 ) * calorie
elif method == CRCSTD :
    return ( T2 - T1 ) * self . CRCSTD_Cp
elif method == LASTOVKA_S :
    dH = ( Lastovka_solid_integral ( T2 , self . similarity_variable ) - Lastovka_solid_integral ( T1 , self . similarity_variable ) )
    return property_mass_to_molar ( dH , self . MW )
elif method in self . tabular_data :
    return float ( quad ( self . calculate , T1 , T2 , args = ( method ) ) [ 0 ] )
else :
    raise Exception ( 'Method not valid' )


implementation:
if method == PERRY151 :
    S2 = ( self . PERRY151_const * log ( T2 ) + self . PERRY151_lin * T2 - self . PERRY151_quadinv / ( 2. * T2 ** 2 ) + 0.5 * self . PERRY151_quad * T2 ** 2 )
    S1 = ( self . PERRY151_const * log ( T1 ) + self . PERRY151_lin * T1 - self . PERRY151_quadinv / ( 2. * T1 ** 2 ) + 0.5 * self . PERRY151_quad * T1 ** 2 )
    return ( S2 - S1 ) * calorie
elif method == CRCSTD :
    S2 = self . CRCSTD_Cp * log ( T2 )
    S1 = self . CRCSTD_Cp * log ( T1 )
    return ( S2 - S1 )
elif method == LASTOVKA_S :
    dS = ( Lastovka_solid_integral_over_T ( T2 , self . similarity_variable ) - Lastovka_solid_integral_over_T ( T1 , self . similarity_variable ) )
    return property_mass_to_molar ( dS , self . MW )
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' )


signature:
def load_all_methods ( self ) :
    r'''Method to initialize the object by precomputing any values which
 may be used repeatedly and by retrieving mixture - specific variables .
 All data are stored as attributes . This method also sets : obj : ` Tmin ` ,
 : obj : ` Tmax ` , and : obj : ` all _ methods ` as a set of methods which should
 work to calculate the property .
 Called on initialization only . See the source code for the variables at
 which the coefficients are stored . The coefficients can safely be
 altered once the class is initialized . This method can be called again
 to reset the parameters .'''

implementation:
methods = [ SIMPLE ]
if len ( self . CASs ) > 1 and '7732-18-5' in self . CASs :
    wCASs = [ i for i in self . CASs if i != '7732-18-5' ]
    if all ( [ i in _Laliberte_Heat_Capacity_ParametersDict for i in wCASs ] ) :
        methods . append ( LALIBERTE )
        self . wCASs = wCASs
        self . index_w = self . CASs . index ( '7732-18-5' )
self . all_methods = set ( methods )


signature:
def calculate ( self , T , P , zs , ws , method ) :
    r'''Method to calculate heat capacity of a liquid mixture at
 temperature ` T ` , pressure ` P ` , mole fractions ` zs ` and weight fractions
 ` ws ` with a given method .
 This method has no exception handling ; see ` mixture _ property `
 for that .
 Parameters
 T : float
 Temperature at which to calculate the property , [ K ]
 P : float
 Pressure at which to calculate the property , [ Pa ]
 zs : list [ float ]
 Mole fractions of all species in the mixture , [ - ]
 ws : list [ float ]
 Weight fractions of all species in the mixture , [ - ]
 method : str
 Name of the method to use
 Returns
 Cplm : float
 Molar heat capacity of the liquid mixture at the given conditions ,
 [ J / mol ]'''

implementation:
if method == SIMPLE :
    Cplms = [ i ( T ) for i in self . HeatCapacityLiquids ]
    return mixing_simple ( zs , Cplms )
elif method == LALIBERTE :
    ws = list ( ws ) ;
    ws . pop ( self . index_w )
    Cpl = Laliberte_heat_capacity ( T , ws , self . wCASs )
    MW = mixing_simple ( zs , self . MWs )
    return property_mass_to_molar ( Cpl , MW )
else :
    raise Exception ( 'Method not valid' )


signature:
def calculate ( self , T , P , zs , ws , method ) :
    r'''Method to calculate heat capacity of a solid mixture at
 temperature ` T ` , pressure ` P ` , mole fractions ` zs ` and weight fractions
 ` ws ` with a given method .
 This method has no exception handling ; see ` mixture _ property `
 for that .
 Parameters
 T : float
 Temperature at which to calculate the property , [ K ]
 P : float
 Pressure at which to calculate the property , [ Pa ]
 zs : list [ float ]
 Mole fractions of all species in the mixture , [ - ]
 ws : list [ float ]
 Weight fractions of all species in the mixture , [ - ]
 method : str
 Name of the method to use
 Returns
 Cpsm : float
 Molar heat capacity of the solid mixture at the given conditions , [ J / mol ]'''

implementation:
if method == SIMPLE :
    Cpsms = [ i ( T ) for i in self . HeatCapacitySolids ]
    return mixing_simple ( zs , Cpsms )
else :
    raise Exception ( 'Method not valid' )


signature:
def calculate ( self , T , P , zs , ws , method ) :
    r'''Method to calculate heat capacity of a gas mixture at
 temperature ` T ` , pressure ` P ` , mole fractions ` zs ` and weight fractions
 ` ws ` with a given method .
 This method has no exception handling ; see ` mixture _ property `
 for that .
 Parameters
 T : float
 Temperature at which to calculate the property , [ K ]
 P : float
 Pressure at which to calculate the property , [ Pa ]
 zs : list [ float ]
 Mole fractions of all species in the mixture , [ - ]
 ws : list [ float ]
 Weight fractions of all species in the mixture , [ - ]
 method : str
 Name of the method to use
 Returns
 Cpgm : float
 Molar heat capacity of the gas mixture at the given conditions ,
 [ J / mol ]'''

implementation:
if method == SIMPLE :
    Cpgms = [ i ( T ) for i in self . HeatCapacityGases ]
    return mixing_simple ( zs , Cpgms )
else :
    raise Exception ( 'Method not valid' )


signature:
def K_value ( P = None , Psat = None , phi_l = None , phi_g = None , gamma = None , Poynting = 1 ) :
    r'''Calculates the equilibrium K - value assuming Raoult ' s law ,
 or an equation of state model , or an activity coefficient model ,
 or a combined equation of state - activity model .
 The calculation procedure will use the most advanced approach with the
 provided inputs :
 * If ` P ` , ` Psat ` , ` phi _ l ` , ` phi _ g ` , and ` gamma ` are provided , use the
 combined approach .
 * If ` P ` , ` Psat ` , and ` gamma ` are provided , use the modified Raoult ' s
 law .
 * If ` phi _ l ` and ` phi _ g ` are provided , use the EOS only method .
 * If ` P ` and ` Psat ` are provided , use Raoult ' s law .
 Definitions :
 . . math : :
 K _ i = \ frac { y _ i } { x _ i }
 Raoult ' s law :
 . . math : :
 K _ i = \ frac { P _ { i } ^ { sat } } { P }
 Activity coefficient , no EOS ( modified Raoult ' s law ) :
 . . math : :
 K _ i = \ frac { \ gamma _ i P _ { i } ^ { sat } } { P }
 Equation of state only :
 . . math : :
 K _ i = \ frac { \ phi _ i ^ l } { \ phi _ i ^ v } = \ frac { f _ i ^ l } { f _ i ^ v }
 Combined approach ( liquid reference fugacity coefficient is normally
 calculated the saturation pressure for it as a pure species ; vapor fugacity
 coefficient calculated normally ) :
 . . math : :
 K _ i = \ frac { \ gamma _ i P _ i ^ { sat } \ phi _ i ^ { l , ref } } { \ phi _ i ^ v P }
 Combined approach , with Poynting Correction Factor ( liquid molar volume in
 the integral is for i as a pure species only ) :
 . . math : :
 K _ i = \ frac { \ gamma _ i P _ i ^ { sat } \ phi _ i ^ { l , ref } \ exp \ left [ \ frac {
 \ int _ { P _ i ^ { sat } } ^ P V _ i ^ l dP } { RT } \ right ] } { \ phi _ i ^ v P }
 Parameters
 P : float
 System pressure , optional
 Psat : float
 Vapor pressure of species i , [ Pa ]
 phi _ l : float
 Fugacity coefficient of species i in the liquid phase , either
 at the system conditions ( EOS - only case ) or at the saturation pressure
 of species i as a pure species ( reference condition for the combined
 approach ) , optional [ - ]
 phi _ g : float
 Fugacity coefficient of species i in the vapor phase at the system
 conditions , optional [ - ]
 gamma : float
 Activity coefficient of species i in the liquid phase , optional [ - ]
 Poynting : float
 Poynting correction factor , optional [ - ]
 Returns
 K : float
 Equilibrium K value of component i , calculated with an approach
 depending on the provided inputs [ - ]
 Notes
 The Poynting correction factor is normally simplified as follows , due to
 a liquid ' s low pressure dependency :
 . . math : :
 K _ i = \ frac { \ gamma _ i P _ i ^ { sat } \ phi _ i ^ { l , ref } \ exp \ left [ \ frac { V _ l
 ( P - P _ i ^ { sat } ) } { RT } \ right ] } { \ phi _ i ^ v P }
 Examples
 Raoult ' s law :
 > > > K _ value ( 101325 , 3000 . )
 0.029607698001480384
 Modified Raoult ' s law :
 > > > K _ value ( P = 101325 , Psat = 3000 , gamma = 0.9)
 0.026646928201332347
 EOS - only approach :
 > > > K _ value ( phi _ l = 1.6356 , phi _ g = 0.88427)
 1.8496613025433408
 Gamma - phi combined approach :
 > > > K _ value ( P = 1E6 , Psat = 1938800 , phi _ l = 1.4356 , phi _ g = 0.88427 , gamma = 0.92)
 2.8958055544121137
 Gamma - phi combined approach with a Poynting factor :
 > > > K _ value ( P = 1E6 , Psat = 1938800 , phi _ l = 1.4356 , phi _ g = 0.88427 , gamma = 0.92,
 . . . Poynting = 0.999)
 2.8929097488577016
 References
 . . [ 1 ] Gmehling , Jurgen , Barbel Kolbe , Michael Kleiber , and Jurgen Rarey .
 Chemical Thermodynamics for Process Simulation . 1st edition . Weinheim :
 Wiley - VCH , 2012.
 . . [ 2 ] Skogestad , Sigurd . Chemical and Energy Process Engineering . 1st
 edition . Boca Raton , FL : CRC Press , 2008.'''

implementation:
try :
    if gamma :
        if phi_l :
            return gamma * Psat * phi_l * Poynting / ( phi_g * P )
        return gamma * Psat * Poynting / P
    elif phi_l :
        return phi_l / phi_g
    return Psat / P
except TypeError :
    raise Exception ( 'Input must consist of one set from (P, Psat, phi_l, \
phi_g, gamma), (P, Psat, gamma), (phi_l, phi_g), (P, Psat)' )


signature:
def Rachford_Rice_flash_error ( V_over_F , zs , Ks ) :
    r'''Calculates the objective function of the Rachford - Rice flash equation .
 This function should be called by a solver seeking a solution to a flash
 calculation . The unknown variable is ` V _ over _ F ` , for which a solution
 must be between 0 and 1.
 . . math : :
 \ sum _ i \ frac { z _ i ( K _ i - 1 ) } { 1 + \ frac { V } { F } ( K _ i - 1 ) } = 0
 Parameters
 V _ over _ F : float
 Vapor fraction guess [ - ]
 zs : list [ float ]
 Overall mole fractions of all species , [ - ]
 Ks : list [ float ]
 Equilibrium K - values , [ - ]
 Returns
 error : float
 Deviation between the objective function at the correct V _ over _ F
 and the attempted V _ over _ F , [ - ]
 Notes
 The derivation is as follows :
 . . math : :
 F z _ i = L x _ i + V y _ i
 x _ i = \ frac { z _ i } { 1 + \ frac { V } { F } ( K _ i - 1 ) }
 \ sum _ i y _ i = \ sum _ i K _ i x _ i = 1
 \ sum _ i ( y _ i - x _ i ) = 0
 \ sum _ i \ frac { z _ i ( K _ i - 1 ) } { 1 + \ frac { V } { F } ( K _ i - 1 ) } = 0
 Examples
 > > > Rachford _ Rice _ flash _ error ( 0.5 , zs = [ 0.5 , 0.3 , 0.2 ] ,
 . . . Ks = [ 1.685 , 0.742 , 0.532 ] )
 0.04406445591174976
 References
 . . [ 1 ] Rachford , H . H . Jr , and J . D . Rice . " Procedure for Use of Electronic
 Digital Computers in Calculating Flash Vaporization Hydrocarbon
 Equilibrium . " Journal of Petroleum Technology 4 , no . 10 ( October 1,
 1952 ) : 19-3 . doi : 10.2118/952327 - G .'''

implementation: return sum ( [ zi * ( Ki - 1. ) / ( 1. + V_over_F * ( Ki - 1. ) ) for Ki , zi in zip ( Ks , zs ) ] )


signature:
def Rachford_Rice_solution ( zs , Ks ) :
    r'''Solves the objective function of the Rachford - Rice flash equation .
 Uses the method proposed in [ 2 ] _ to obtain an initial guess .
 . . math : :
 \ sum _ i \ frac { z _ i ( K _ i - 1 ) } { 1 + \ frac { V } { F } ( K _ i - 1 ) } = 0
 Parameters
 zs : list [ float ]
 Overall mole fractions of all species , [ - ]
 Ks : list [ float ]
 Equilibrium K - values , [ - ]
 Returns
 V _ over _ F : float
 Vapor fraction solution [ - ]
 xs : list [ float ]
 Mole fractions of each species in the liquid phase , [ - ]
 ys : list [ float ]
 Mole fractions of each species in the vapor phase , [ - ]
 Notes
 The initial guess is the average of the following , as described in [ 2 ] _ .
 . . math : :
 \ left ( \ frac { V } { F } \ right ) _ { min } = \ frac { ( K _ { max } - K _ { min } ) z _ { of \ ; K _ { max } }
 - ( 1 - K _ { min } ) } { ( 1 - K _ { min } ) ( K _ { max } - 1 ) }
 \ left ( \ frac { V } { F } \ right ) _ { max } = \ frac { 1 } { 1 - K _ { min } }
 Another algorithm for determining the range of the correct solution is
 given in [ 3 ] _ ; [ 2 ] _ provides a narrower range however . For both cases ,
 each guess should be limited to be between 0 and 1 as they are often
 negative or larger than 1.
 . . math : :
 \ left ( \ frac { V } { F } \ right ) _ { min } = \ frac { 1 } { 1 - K _ { max } }
 \ left ( \ frac { V } { F } \ right ) _ { max } = \ frac { 1 } { 1 - K _ { min } }
 If the ` newton ` method does not converge , a bisection method ( brenth ) is
 used instead . However , it is somewhat slower , especially as newton will
 attempt 50 iterations before giving up .
 Examples
 > > > Rachford _ Rice _ solution ( zs = [ 0.5 , 0.3 , 0.2 ] , Ks = [ 1.685 , 0.742 , 0.532 ] )
 (0.6907302627738542 , [ 0.3394086969663436 , 0.3650560590371706 , 0.2955352439964858 ] , [ 0.571903654388289 , 0.27087159580558057 , 0.15722474980613044 ] )
 References
 . . [ 1 ] Rachford , H . H . Jr , and J . D . Rice . " Procedure for Use of Electronic
 Digital Computers in Calculating Flash Vaporization Hydrocarbon
 Equilibrium . " Journal of Petroleum Technology 4 , no . 10 ( October 1,
 1952 ) : 19-3 . doi : 10.2118/952327 - G .
 . . [ 2 ] Li , Yinghui , Russell T . Johns , and Kaveh Ahmadi . " A Rapid and Robust
 Alternative to Rachford - Rice in Flash Calculations . " Fluid Phase
 Equilibria 316 ( February 25 , 2012 ) : 85-97.
 doi : 10.1016 / j . fluid . 2011.12.005.
 . . [ 3 ] Whitson , Curtis H . , and Michael L . Michelsen . " The Negative Flash . "
 Fluid Phase Equilibria , Proceedings of the Fifth International
 Conference , 53 ( December 1 , 1989 ) : 51-71.
 doi : 10.1016/0378-3812(89)80072 - X .'''

implementation:
Kmin = min ( Ks )
Kmax = max ( Ks )
z_of_Kmax = zs [ Ks . index ( Kmax ) ]
V_over_F_min = ( ( Kmax - Kmin ) * z_of_Kmax - ( 1. - Kmin ) ) / ( ( 1. - Kmin ) * ( Kmax - 1. ) )
V_over_F_max = 1. / ( 1. - Kmin )
V_over_F_min2 = max ( 0. , V_over_F_min )
V_over_F_max2 = min ( 1. , V_over_F_max )
x0 = ( V_over_F_min2 + V_over_F_max2 ) * 0.5
try : # Newton ' s method is marginally faster than brenth
    V_over_F = newton ( Rachford_Rice_flash_error , x0 = x0 , args = ( zs , Ks ) )
    # newton skips out of its specified range in some cases , finding another solution
    # Check for that with asserts , and use brenth if it did
    assert V_over_F >= V_over_F_min2
    assert V_over_F <= V_over_F_max2
except :
    V_over_F = brenth ( Rachford_Rice_flash_error , V_over_F_max - 1E-7 , V_over_F_min + 1E-7 , args = ( zs , Ks ) )
# Cases not covered by the above solvers : When all components have K > 1 , or all have K < 1
# Should get a solution for all other cases .
xs = [ zi / ( 1. + V_over_F * ( Ki - 1. ) ) for zi , Ki in zip ( zs , Ks ) ]
ys = [ Ki * xi for xi , Ki in zip ( xs , Ks ) ]
return V_over_F , xs , ys


signature:
def Li_Johns_Ahmadi_solution ( zs , Ks ) :
    r'''Solves the objective function of the Li - Johns - Ahmadi flash equation .
 Uses the method proposed in [ 1 ] _ to obtain an initial guess .
 . . math : :
 0 = 1 + \ left ( \ frac { K _ { max } - K _ { min } } { K _ { min } - 1 } \ right ) x _ 1
 + \ sum _ { i = 2 } ^ { n - 1 } \ frac { K _ i - K _ { min } } { K _ { min } - 1 } \ left [ \ frac { z _ i ( K _ { max }
 -1 ) x _ { max } } { ( K _ i - 1 ) z _ { max } + ( K _ { max } - K _ i ) x _ { max } } \ right ]
 Parameters
 zs : list [ float ]
 Overall mole fractions of all species , [ - ]
 Ks : list [ float ]
 Equilibrium K - values , [ - ]
 Returns
 V _ over _ F : float
 Vapor fraction solution [ - ]
 xs : list [ float ]
 Mole fractions of each species in the liquid phase , [ - ]
 ys : list [ float ]
 Mole fractions of each species in the vapor phase , [ - ]
 Notes
 The initial guess is the average of the following , as described in [ 1 ] _ .
 Each guess should be limited to be between 0 and 1 as they are often
 negative or larger than 1 . ` max ` refers to the corresponding mole fractions
 for the species with the largest K value .
 . . math : :
 \ left ( \ frac { 1 - K _ { min } } { K _ { max } - K _ { min } } \ right ) z _ { max } \ le x _ { max } \ le
 \ left ( \ frac { 1 - K _ { min } } { K _ { max } - K _ { min } } \ right )
 If the ` newton ` method does not converge , a bisection method ( brenth ) is
 used instead . However , it is somewhat slower , especially as newton will
 attempt 50 iterations before giving up .
 This method does not work for problems of only two components .
 K values are sorted internally . Has not been found to be quicker than the
 Rachford - Rice equation .
 Examples
 > > > Li _ Johns _ Ahmadi _ solution ( zs = [ 0.5 , 0.3 , 0.2 ] , Ks = [ 1.685 , 0.742 , 0.532 ] )
 (0.6907302627738544 , [ 0.33940869696634357 , 0.3650560590371706 , 0.2955352439964858 ] , [ 0.5719036543882889 , 0.27087159580558057 , 0.15722474980613044 ] )
 References
 . . [ 1 ] Li , Yinghui , Russell T . Johns , and Kaveh Ahmadi . " A Rapid and Robust
 Alternative to Rachford - Rice in Flash Calculations . " Fluid Phase
 Equilibria 316 ( February 25 , 2012 ) : 85-97.
 doi : 10.1016 / j . fluid . 2011.12.005.'''

implementation:
# Re - order both Ks and Zs by K value , higher coming first
p = sorted ( zip ( Ks , zs ) , reverse = True )
Ks_sorted , zs_sorted = [ K for ( K , z ) in p ] , [ z for ( K , z ) in p ]
# Largest K value and corresponding overall mole fraction
k1 = Ks_sorted [ 0 ]
z1 = zs_sorted [ 0 ]
# Smallest K value
kn = Ks_sorted [ - 1 ]
x_min = ( 1. - kn ) / ( k1 - kn ) * z1
x_max = ( 1. - kn ) / ( k1 - kn )
x_min2 = max ( 0. , x_min )
x_max2 = min ( 1. , x_max )
x_guess = ( x_min2 + x_max2 ) * 0.5
length = len ( zs ) - 1
kn_m_1 = kn - 1.
k1_m_1 = ( k1 - 1. )
t1 = ( k1 - kn ) / ( kn - 1. )
objective = lambda x1 : 1. + t1 * x1 + sum ( [ ( ki - kn ) / ( kn_m_1 ) * zi * k1_m_1 * x1 / ( ( ki - 1. ) * z1 + ( k1 - ki ) * x1 ) for ki , zi in zip ( Ks_sorted [ 1 : length ] , zs_sorted [ 1 : length ] ) ] )
try :
    x1 = newton ( objective , x_guess )
    # newton skips out of its specified range in some cases , finding another solution
    # Check for that with asserts , and use brenth if it did
    # Must also check that V _ over _ F is right .
    assert x1 >= x_min2
    assert x1 <= x_max2
    V_over_F = ( - x1 + z1 ) / ( x1 * ( k1 - 1. ) )
    assert 0 <= V_over_F <= 1
except :
    x1 = brenth ( objective , x_min , x_max )
    V_over_F = ( - x1 + z1 ) / ( x1 * ( k1 - 1. ) )
xs = [ zi / ( 1. + V_over_F * ( Ki - 1. ) ) for zi , Ki in zip ( zs , Ks ) ]
ys = [ Ki * xi for xi , Ki in zip ( xs , Ks ) ]
return V_over_F , xs , ys


signature:
def flash_inner_loop ( zs , Ks , AvailableMethods = False , Method = None ) :
    r'''This function handles the solution of the inner loop of a flash
 calculation , solving for liquid and gas mole fractions and vapor fraction
 based on specified overall mole fractions and K values . As K values are
 weak functions of composition , this should be called repeatedly by an outer
 loop . Will automatically select an algorithm to use if no Method is
 provided . Should always provide a solution .
 The automatic algorithm selection will try an analytical solution , and use
 the Rachford - Rice method if there are 4 or more components in the mixture .
 Parameters
 zs : list [ float ]
 Overall mole fractions of all species , [ - ]
 Ks : list [ float ]
 Equilibrium K - values , [ - ]
 Returns
 V _ over _ F : float
 Vapor fraction solution [ - ]
 xs : list [ float ]
 Mole fractions of each species in the liquid phase , [ - ]
 ys : list [ float ]
 Mole fractions of each species in the vapor phase , [ - ]
 methods : list , only returned if AvailableMethods = = True
 List of methods which can be used to obtain a solution with the given
 inputs
 Other Parameters
 Method : string , optional
 The method name to use . Accepted methods are ' Analytical ' ,
 ' Rachford - Rice ' , and ' Li - Johns - Ahmadi ' . All valid values are also held
 in the list ` flash _ inner _ loop _ methods ` .
 AvailableMethods : bool , optional
 If True , function will determine which methods can be used to obtain
 a solution for the desired chemical , and will return methods instead of
 ` V _ over _ F ` , ` xs ` , and ` ys ` .
 Notes
 A total of three methods are available for this function . They are :
 * ' Analytical ' , an exact solution derived with SymPy , applicable only
 only to mixtures of two or three components
 * ' Rachford - Rice ' , which numerically solves an objective function
 described in : obj : ` Rachford _ Rice _ solution ` .
 * ' Li - Johns - Ahmadi ' , which numerically solves an objective function
 described in : obj : ` Li _ Johns _ Ahmadi _ solution ` .
 Examples
 > > > flash _ inner _ loop ( zs = [ 0.5 , 0.3 , 0.2 ] , Ks = [ 1.685 , 0.742 , 0.532 ] )
 (0.6907302627738537 , [ 0.3394086969663437 , 0.36505605903717053 , 0.29553524399648573 ] , [ 0.5719036543882892 , 0.2708715958055805 , 0.1572247498061304 ] )'''


signature:
def NRTL ( xs , taus , alphas ) :
    r'''Calculates the activity coefficients of each species in a mixture
 using the Non - Random Two - Liquid ( NRTL ) method , given their mole fractions ,
 dimensionless interaction parameters , and nonrandomness constants . Those
 are normally correlated with temperature in some form , and need to be
 calculated separately .
 . . math : :
 \ ln ( \ gamma _ i ) = \ frac { \ displaystyle \ sum _ { j = 1 } ^ { n } { x _ { j } \ tau _ { ji } G _ { ji } } }
 { \ displaystyle \ sum _ { k = 1 } ^ { n } { x _ { k } G _ { ki } } } + \ sum _ { j = 1 } ^ { n }
 { \ frac { x _ { j } G _ { ij } } { \ displaystyle \ sum _ { k = 1 } ^ { n } { x _ { k } G _ { kj } } } }
 { \ left ( { \ tau _ { ij } - \ frac { \ displaystyle \ sum _ { m = 1 } ^ { n } { x _ { m } \ tau _ { mj }
 G _ { mj } } } { \ displaystyle \ sum _ { k = 1 } ^ { n } { x _ { k } G _ { kj } } } } \ right ) }
 G _ { ij } = \ text { exp } \ left ( { - \ alpha _ { ij } \ tau _ { ij } } \ right )
 Parameters
 xs : list [ float ]
 Liquid mole fractions of each species , [ - ]
 taus : list [ list [ float ] ]
 Dimensionless interaction parameters of each compound with each other ,
 alphas : list [ list [ float ] ]
 Nonrandomness constants of each compound interacting with each other , [ - ]
 Returns
 gammas : list [ float ]
 Activity coefficient for each species in the liquid mixture , [ - ]
 Notes
 This model needs N ^ 2 parameters .
 One common temperature dependence of the nonrandomness constants is :
 . . math : :
 \ alpha _ { ij } = c _ { ij } + d _ { ij } T
 Most correlations for the interaction parameters include some of the terms
 shown in the following form :
 . . math : :
 \ tau _ { ij } = A _ { ij } + \ frac { B _ { ij } } { T } + \ frac { C _ { ij } } { T ^ { 2 } } + D _ { ij }
 \ ln { \ left ( { T } \ right ) } + E _ { ij } T ^ { F _ { ij } }
 Examples
 Ethanol - water example , at 343.15 K and 1 MPa :
 > > > NRTL ( xs = [ 0.252 , 0.748 ] , taus = [ [ 0 , - 0.178 ] , [ 1.963 , 0 ] ] ,
 . . . alphas = [ [ 0 , 0.2974 ] , [ . 2974 , 0 ] ] )
 [1.9363183763514304 , 1.1537609663170014]
 References
 . . [ 1 ] Renon , Henri , and J . M . Prausnitz . " Local Compositions in
 Thermodynamic Excess Functions for Liquid Mixtures . " AIChE Journal 14,
 no . 1 ( 1968 ) : 135-144 . doi : 10.1002 / aic . 690140124.
 . . [ 2 ] Gmehling , Jurgen , Barbel Kolbe , Michael Kleiber , and Jurgen Rarey .
 Chemical Thermodynamics for Process Simulation . 1st edition . Weinheim :
 Wiley - VCH , 2012.'''

implementation:
gammas = [ ]
cmps = range ( len ( xs ) )
Gs = [ [ exp ( - alphas [ i ] [ j ] * taus [ i ] [ j ] ) for j in cmps ] for i in cmps ]
for i in cmps :
    tn1 , td1 , total2 = 0. , 0. , 0.
    for j in cmps : # Term 1 , numerator and denominator
        tn1 += xs [ j ] * taus [ j ] [ i ] * Gs [ j ] [ i ]
        td1 += xs [ j ] * Gs [ j ] [ i ]
        # Term 2
        tn2 = xs [ j ] * Gs [ i ] [ j ]
        td2 = td3 = sum ( [ xs [ k ] * Gs [ k ] [ j ] for k in cmps ] )
        tn3 = sum ( [ xs [ m ] * taus [ m ] [ j ] * Gs [ m ] [ j ] for m in cmps ] )
        total2 += tn2 / td2 * ( taus [ i ] [ j ] - tn3 / td3 )
    gamma = exp ( tn1 / td1 + total2 )
    gammas . append ( gamma )
return gammas


signature:
def Wilson ( xs , params ) :
    r'''Calculates the activity coefficients of each species in a mixture
 using the Wilson method , given their mole fractions , and
 dimensionless interaction parameters . Those are normally correlated with
 temperature , and need to be calculated separately .
 . . math : :
 \ ln \ gamma _ i = 1 - \ ln \ left ( \ sum _ j ^ N \ Lambda _ { ij } x _ j \ right )
 - \ sum _ j ^ N \ frac { \ Lambda _ { ji } x _ j } { \ displaystyle \ sum _ k ^ N \ Lambda _ { jk } x _ k }
 Parameters
 xs : list [ float ]
 Liquid mole fractions of each species , [ - ]
 params : list [ list [ float ] ]
 Dimensionless interaction parameters of each compound with each other ,
 Returns
 gammas : list [ float ]
 Activity coefficient for each species in the liquid mixture , [ - ]
 Notes
 This model needs N ^ 2 parameters .
 The original model correlated the interaction parameters using the standard
 pure - component molar volumes of each species at 25 ° C , in the following form :
 . . math : :
 \ Lambda _ { ij } = \ frac { V _ j } { V _ i } \ exp \ left ( \ frac { - \ lambda _ { i , j } } { RT } \ right )
 However , that form has less flexibility and offered no advantage over
 using only regressed parameters .
 Most correlations for the interaction parameters include some of the terms
 shown in the following form :
 . . math : :
 \ ln \ Lambda _ { ij } = a _ { ij } + \ frac { b _ { ij } } { T } + c _ { ij } \ ln T + d _ { ij } T
 + \ frac { e _ { ij } } { T ^ 2 } + h _ { ij } { T ^ 2}
 The Wilson model is not applicable to liquid - liquid systems .
 Examples
 Ethanol - water example , at 343.15 K and 1 MPa :
 > > > Wilson ( [ 0.252 , 0.748 ] , [ [ 1 , 0.154 ] , [ 0.888 , 1 ] ] )
 [1.8814926087178843 , 1.1655774931125487]
 References
 . . [ 1 ] Wilson , Grant M . " Vapor - Liquid Equilibrium . XI . A New Expression for
 the Excess Free Energy of Mixing . " Journal of the American Chemical
 Society 86 , no . 2 ( January 1 , 1964 ) : 127-130 . doi : 10.1021 / ja01056a002.
 . . [ 2 ] Gmehling , Jurgen , Barbel Kolbe , Michael Kleiber , and Jurgen Rarey .
 Chemical Thermodynamics for Process Simulation . 1st edition . Weinheim :
 Wiley - VCH , 2012.'''

implementation:
gammas = [ ]
cmps = range ( len ( xs ) )
for i in cmps :
    tot1 = log ( sum ( [ params [ i ] [ j ] * xs [ j ] for j in cmps ] ) )
    tot2 = 0.
    for j in cmps :
        tot2 += params [ j ] [ i ] * xs [ j ] / sum ( [ params [ j ] [ k ] * xs [ k ] for k in cmps ] )
    gamma = exp ( 1. - tot1 - tot2 )
    gammas . append ( gamma )
return gammas


signature:
def UNIQUAC ( xs , rs , qs , taus ) :
    r'''Calculates the activity coefficients of each species in a mixture
 using the Universal quasi - chemical ( UNIQUAC ) equation , given their mole
 fractions , ` rs ` , ` qs ` , and dimensionless interaction parameters . The
 interaction parameters are normally correlated with temperature , and need
 to be calculated separately .
 . . math : :
 \ ln \ gamma _ i = \ ln \ frac { \ Phi _ i } { x _ i } + \ frac { z } { 2 } q _ i \ ln
 \ frac { \ theta _ i } { \ Phi _ i } + l _ i - \ frac { \ Phi _ i } { x _ i } \ sum _ j ^ N x _ j l _ j
 - q _ i \ ln \ left ( \ sum _ j ^ N \ theta _ j \ tau _ { ji } \ right ) + q _ i - q _ i \ sum _ j ^ N
 \ frac { \ theta _ j \ tau _ { ij } } { \ sum _ k ^ N \ theta _ k \ tau _ { kj } }
 \ theta _ i = \ frac { x _ i q _ i } { \ displaystyle \ sum _ { j = 1 } ^ { n } x _ j q _ j }
 \ Phi _ i = \ frac { x _ i r _ i } { \ displaystyle \ sum _ { j = 1 } ^ { n } x _ j r _ j }
 l _ i = \ frac { z } { 2 } ( r _ i - q _ i ) - ( r _ i - 1)
 Parameters
 xs : list [ float ]
 Liquid mole fractions of each species , [ - ]
 rs : list [ float ]
 Van der Waals volume parameters for each species , [ - ]
 qs : list [ float ]
 Surface area parameters for each species , [ - ]
 taus : list [ list [ float ] ]
 Dimensionless interaction parameters of each compound with each other ,
 Returns
 gammas : list [ float ]
 Activity coefficient for each species in the liquid mixture , [ - ]
 Notes
 This model needs N ^ 2 parameters .
 The original expression for the interaction parameters is as follows :
 . . math : :
 \ tau _ { ji } = \ exp \ left ( \ frac { - \ Delta u _ { ij } } { RT } \ right )
 However , it is seldom used . Most correlations for the interaction
 parameters include some of the terms shown in the following form :
 . . math : :
 \ ln \ tau { ij } = a _ { ij } + \ frac { b _ { ij } } { T } + c _ { ij } \ ln T + d _ { ij } T
 + \ frac { e _ { ij } } { T ^ 2}
 This model is recast in a slightly more computationally efficient way in
 [2 ] _ , as shown below :
 . . math : :
 \ ln \ gamma _ i = \ ln \ gamma _ i ^ { res } + \ ln \ gamma _ i ^ { comb }
 \ ln \ gamma _ i ^ { res } = q _ i \ left ( 1 - \ ln \ frac { \ sum _ j ^ N q _ j x _ j \ tau _ { ji } }
 { \ sum _ j ^ N q _ j x _ j } - \ sum _ j \ frac { q _ k x _ j \ tau _ { ij } } { \ sum _ k q _ k x _ k
 \ tau _ { kj } } \ right )
 \ ln \ gamma _ i ^ { comb } = ( 1 - V _ i + \ ln V _ i ) - \ frac { z } { 2 } q _ i \ left ( 1 -
 \ frac { V _ i } { F _ i } + \ ln \ frac { V _ i } { F _ i } \ right )
 V _ i = \ frac { r _ i } { \ sum _ j ^ N r _ j x _ j }
 F _ i = \ frac { q _ i } { \ sum _ j q _ j x _ j }
 Examples
 Ethanol - water example , at 343.15 K and 1 MPa :
 > > > UNIQUAC ( xs = [ 0.252 , 0.748 ] , rs = [ 2.1055 , 0.9200 ] , qs = [ 1.972 , 1.400 ] ,
 . . . taus = [ [ 1.0 , 1.0919744384510301 ] , [ 0.37452902779205477 , 1.0 ] ] )
 [2.35875137797083 , 1.2442093415968987]
 References
 . . [ 1 ] Abrams , Denis S . , and John M . Prausnitz . " Statistical Thermodynamics
 of Liquid Mixtures : A New Expression for the Excess Gibbs Energy of
 Partly or Completely Miscible Systems . " AIChE Journal 21 , no . 1 ( January
 1 , 1975 ) : 116-28 . doi : 10.1002 / aic . 690210115.
 . . [ 2 ] Gmehling , Jurgen , Barbel Kolbe , Michael Kleiber , and Jurgen Rarey .
 Chemical Thermodynamics for Process Simulation . 1st edition . Weinheim :
 Wiley - VCH , 2012.
 . . [ 3 ] Maurer , G . , and J . M . Prausnitz . " On the Derivation and Extension of
 the Uniquac Equation . " Fluid Phase Equilibria 2 , no . 2 ( January 1,
 1978 ) : 91-99 . doi : 10.1016/0378-3812(78)85002 - X .'''

implementation:
cmps = range ( len ( xs ) )
rsxs = sum ( [ rs [ i ] * xs [ i ] for i in cmps ] )
phis = [ rs [ i ] * xs [ i ] / rsxs for i in cmps ]
qsxs = sum ( [ qs [ i ] * xs [ i ] for i in cmps ] )
vs = [ qs [ i ] * xs [ i ] / qsxs for i in cmps ]
Ss = [ sum ( [ vs [ j ] * taus [ j ] [ i ] for j in cmps ] ) for i in cmps ]
loggammacs = [ log ( phis [ i ] / xs [ i ] ) + 1 - phis [ i ] / xs [ i ] - 5 * qs [ i ] * ( log ( phis [ i ] / vs [ i ] ) + 1 - phis [ i ] / vs [ i ] ) for i in cmps ]
loggammars = [ qs [ i ] * ( 1 - log ( Ss [ i ] ) - sum ( [ taus [ i ] [ j ] * vs [ j ] / Ss [ j ] for j in cmps ] ) ) for i in cmps ]
return [ exp ( loggammacs [ i ] + loggammars [ i ] ) for i in cmps ]


implementation:
if not fugacities :
    fugacities = [ 1 for i in range ( len ( Psats ) ) ]
if not gammas :
    gammas = [ 1 for i in range ( len ( Psats ) ) ]
if not none_and_length_check ( ( zs , Psats , fugacities , gammas ) ) :
    raise Exception ( 'Input dimentions are inconsistent or some input parameters are missing.' )
P = sum ( zs [ i ] * Psats [ i ] * gammas [ i ] / fugacities [ i ] for i in range ( len ( zs ) ) )
return P


signature:
def identify_phase ( T , P , Tm = None , Tb = None , Tc = None , Psat = None ) :
    r'''Determines the phase of a one - species chemical system according to
 basic rules , using whatever information is available . Considers only the
 phases liquid , solid , and gas ; does not consider two - phase
 scenarios , as should occurs between phase boundaries .
 * If the melting temperature is known and the temperature is under or equal
 to it , consider it a solid .
 * If the critical temperature is known and the temperature is greater or
 equal to it , consider it a gas .
 * If the vapor pressure at ` T ` is known and the pressure is under or equal
 to it , consider it a gas . If the pressure is greater than the vapor
 pressure , consider it a liquid .
 * If the melting temperature , critical temperature , and vapor pressure are
 not known , attempt to use the boiling point to provide phase information .
 If the pressure is between 90 kPa and 110 kPa ( approximately normal ) ,
 consider it a liquid if it is under the boiling temperature and a gas if
 above the boiling temperature .
 * If the pressure is above 110 kPa and the boiling temperature is known ,
 consider it a liquid if the temperature is under the boiling temperature .
 * Return None otherwise .
 Parameters
 T : float
 Temperature , [ K ]
 P : float
 Pressure , [ Pa ]
 Tm : float , optional
 Normal melting temperature , [ K ]
 Tb : float , optional
 Normal boiling point , [ K ]
 Tc : float , optional
 Critical temperature , [ K ]
 Psat : float , optional
 Vapor pressure of the fluid at ` T ` , [ Pa ]
 Returns
 phase : str
 Either ' s ' , ' l ' , ' g ' , or None if the phase cannot be determined
 Notes
 No special attential is paid to any phase transition . For the case where
 the melting point is not provided , the possibility of the fluid being solid
 is simply ignored .
 Examples
 > > > identify _ phase ( T = 280 , P = 101325 , Tm = 273.15 , Psat = 991)'''

implementation:
if Tm and T <= Tm :
    return 's'
elif Tc and T >= Tc : # No special return value for the critical point
    return 'g'
elif Psat : # Do not allow co - existence of phases ; transition to ' l ' directly under
    if P <= Psat :
        return 'g'
    elif P > Psat :
        return 'l'
elif Tb : # Crude attempt to model phases without Psat
# Treat Tb as holding from 90 kPa to 110 kPa
    if 9E4 < P < 1.1E5 :
        if T < Tb :
            return 'l'
        else :
            return 'g'
    elif P > 1.1E5 and T <= Tb : # For the higher - pressure case , it is definitely liquid if under Tb
    # Above the normal boiling point , impossible to say - return None
        return 'l'
    else :
        return None
else :
    return None


implementation:
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


signature:
def Pbubble_mixture ( T = None , zs = None , Psats = None , CASRNs = None , AvailableMethods = False , Method = None ) : # pragma : no cover
    '''> > > Pbubble _ mixture ( zs = [ 0.5 , 0.5 ] , Psats = [ 1400 , 7000 ] )
 4200.0'''

implementation:
def list_methods ( ) :
    methods = [ ]
    if none_and_length_check ( ( Psats , zs ) ) :
        methods . append ( 'IDEAL_VLE' )
    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
if Method == 'IDEAL_VLE' :
    Pbubble = bubble_at_T ( zs , Psats )
elif Method == 'NONE' :
    Pbubble = None
else :
    raise Exception ( 'Failure in in function' )
return Pbubble


signature:
def bubble_at_P ( P , zs , vapor_pressure_eqns , fugacities = None , gammas = None ) :
    '''Calculates bubble point for a given pressure
 Parameters
 P : float
 Pressure , [ Pa ]
 zs : list [ float ]
 Overall mole fractions of all species , [ - ]
 vapor _ pressure _ eqns : list [ functions ]
 Temperature dependent function for each specie , Returns Psat , [ Pa ]
 fugacities : list [ float ] , optional
 fugacities of each species , defaults to list of ones , [ - ]
 gammas : list [ float ] , optional
 gammas of each species , defaults to list of ones , [ - ]
 Returns
 Tbubble : float , optional
 Temperature of bubble point at pressure ` P ` , [ K ]'''

implementation:
def bubble_P_error ( T ) :
    Psats = [ VP ( T ) for VP in vapor_pressure_eqns ]
    Pcalc = bubble_at_T ( zs , Psats , fugacities , gammas )
    return P - Pcalc
T_bubble = newton ( bubble_P_error , 300 )
return T_bubble


signature:
def Pdew_mixture ( T = None , zs = None , Psats = None , CASRNs = None , AvailableMethods = False , Method = None ) : # pragma : no cover
    '''> > > Pdew _ mixture ( zs = [ 0.5 , 0.5 ] , Psats = [ 1400 , 7000 ] )
 2333.333335'''

implementation:
def list_methods ( ) :
    methods = [ ]
    if none_and_length_check ( ( Psats , zs ) ) :
        methods . append ( 'IDEAL_VLE' )
    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
if Method == 'IDEAL_VLE' :
    Pdew = dew_at_T ( zs , Psats )
elif Method == 'NONE' :
    Pdew = None
else :
    raise Exception ( 'Failure in in function' )
return Pdew


signature:
def draw_2d ( self , width = 300 , height = 300 , Hs = False ) : # pragma : no cover
    r'''Interface for drawing a 2D image of the molecule .
 Requires an HTML5 browser , and the libraries RDKit and
 IPython . An exception is raised if either of these libraries is
 absent .
 Parameters
 width : int
 Number of pixels wide for the view
 height : int
 Number of pixels tall for the view
 Hs : bool
 Whether or not to show hydrogen
 Examples
 > > > Chemical ( ' decane ' ) . draw _ 2d ( ) # doctest : + ELLIPSIS
 < PIL . Image . Image image mode = RGBA size = 300x300 at 0x . . . >'''

implementation:
try :
    from rdkit . Chem import Draw
    from rdkit . Chem . Draw import IPythonConsole
    if Hs :
        mol = self . rdkitmol_Hs
    else :
        mol = self . rdkitmol
    return Draw . MolToImage ( mol , size = ( width , height ) )
except :
    return 'Rdkit is required for this feature.'


signature:
def draw_3d ( self , width = 300 , height = 500 , style = 'stick' , Hs = True ) : # pragma : no cover
    r'''Interface for drawing an interactive 3D view of the molecule .
 Requires an HTML5 browser , and the libraries RDKit , pymol3D , and
 IPython . An exception is raised if all three of these libraries are
 not installed .
 Parameters
 width : int
 Number of pixels wide for the view
 height : int
 Number of pixels tall for the view
 style : str
 One of ' stick ' , ' line ' , ' cross ' , or ' sphere '
 Hs : bool
 Whether or not to show hydrogen
 Examples
 > > > Chemical ( ' cubane ' ) . draw _ 3d ( )
 < IPython . core . display . HTML object >'''

implementation:
try :
    import py3Dmol
    from IPython . display import display
    if Hs :
        mol = self . rdkitmol_Hs
    else :
        mol = self . rdkitmol
    AllChem . EmbedMultipleConfs ( mol )
    mb = Chem . MolToMolBlock ( mol )
    p = py3Dmol . view ( width = width , height = height )
    p . addModel ( mb , 'sdf' )
    p . setStyle ( { style : { } } )
    p . zoomTo ( )
    display ( p . show ( ) )
except :
    return 'py3Dmol, RDKit, and IPython are required for this feature.'


signature:
def Um ( self ) :
    r'''Internal energy of the chemical at its current temperature and
 pressure , in units of [ J / mol ] .
 This property requires that : obj : ` thermo . chemical . set _ thermo ` ran
 successfully to be accurate .
 It also depends on the molar volume of the chemical at its current
 conditions .'''

implementation: return self . Hm - self . P * self . Vm if ( self . Vm and self . Hm is not None ) else None


signature:
def Am ( self ) :
    r'''Helmholtz energy of the chemical at its current temperature and
 pressure , in units of [ J / mol ] .
 This property requires that : obj : ` thermo . chemical . set _ thermo ` ran
 successfully to be accurate .
 It also depends on the molar volume of the chemical at its current
 conditions .'''

implementation: return self . Um - self . T * self . Sm if ( self . Um is not None and self . Sm is not None ) else None


signature:
def A ( self ) :
    r'''Helmholtz energy of the chemical at its current temperature and
 pressure , in units of [ J / kg ] .
 This property requires that : obj : ` thermo . chemical . set _ thermo ` ran
 successfully to be accurate .
 It also depends on the molar volume of the chemical at its current
 conditions .'''

implementation: return self . U - self . T * self . S if ( self . U is not None and self . S is not None ) else None


signature:
def charge ( self ) :
    r'''Charge of a chemical , computed with RDKit from a chemical ' s SMILES .
 If RDKit is not available , holds None .
 Examples
 > > > Chemical ( ' sodium ion ' ) . charge'''

implementation:
try :
    if not self . rdkitmol :
        return charge_from_formula ( self . formula )
    else :
        return Chem . GetFormalCharge ( self . rdkitmol )
except :
    return charge_from_formula ( self . formula )


signature:
def rdkitmol ( self ) :
    r'''RDKit object of the chemical , without hydrogen . If RDKit is not
 available , holds None .
 For examples of what can be done with RDKit , see
 ` their website < http : / / www . rdkit . org / docs / GettingStartedInPython . html > ` _ .'''

implementation:
if self . __rdkitmol :
    return self . __rdkitmol
else :
    try :
        self . __rdkitmol = Chem . MolFromSmiles ( self . smiles )
        return self . __rdkitmol
    except :
        return None


signature:
def rdkitmol_Hs ( self ) :
    r'''RDKit object of the chemical , with hydrogen . If RDKit is not
 available , holds None .
 For examples of what can be done with RDKit , see
 ` their website < http : / / www . rdkit . org / docs / GettingStartedInPython . html > ` _ .'''

implementation:
if self . __rdkitmol_Hs :
    return self . __rdkitmol_Hs
else :
    try :
        self . __rdkitmol_Hs = Chem . AddHs ( self . rdkitmol )
        return self . __rdkitmol_Hs
    except :
        return None


signature:
def Hill ( self ) :
    r'''Hill formula of a compound . For a description of the Hill system ,
 see : obj : ` thermo . elements . atoms _ to _ Hill ` .
 Examples
 > > > Chemical ( ' furfuryl alcohol ' ) . Hill
 ' C5H6O2' '''

implementation:
if self . __Hill :
    return self . __Hill
else :
    self . __Hill = atoms_to_Hill ( self . atoms )
    return self . __Hill


signature:
def atom_fractions ( self ) :
    r'''Dictionary of atom : fractional occurence of the elements in a
 chemical . Useful when performing element balances . For mass - fraction
 occurences , see : obj : ` mass _ fractions ` .
 Examples
 > > > Chemical ( ' Ammonium aluminium sulfate ' ) . atom _ fractions
 { ' H ' : 0.25 , ' S ' : 0.125 , ' Al ' : 0.0625 , ' O ' : 0.5 , ' N ' : 0.0625}'''

implementation:
if self . __atom_fractions :
    return self . __atom_fractions
else :
    self . __atom_fractions = atom_fractions ( self . atoms )
    return self . __atom_fractions


signature:
def mass_fractions ( self ) :
    r'''Dictionary of atom : mass - weighted fractional occurence of elements .
 Useful when performing mass balances . For atom - fraction occurences , see
 : obj : ` atom _ fractions ` .
 Examples
 > > > Chemical ( ' water ' ) . mass _ fractions
 { ' H ' : 0.11189834407236524 , ' O ' : 0.8881016559276347}'''

implementation:
if self . __mass_fractions :
    return self . __mass_fractions
else :
    self . __mass_fractions = mass_fractions ( self . atoms , self . MW )
    return self . __mass_fractions


signature:
def legal_status ( self ) :
    r'''Dictionary of legal status indicators for the chemical .
 Examples
 > > > pprint ( Chemical ( ' benzene ' ) . legal _ status )
 { ' DSL ' : ' LISTED ' ,
 ' EINECS ' : ' LISTED ' ,
 ' NLP ' : ' UNLISTED ' ,
 ' SPIN ' : ' LISTED ' ,
 ' TSCA ' : ' LISTED ' }'''

implementation:
if self . __legal_status :
    return self . __legal_status
else :
    self . __legal_status = legal_status ( self . CAS , Method = 'COMBINED' )
    return self . __legal_status


signature:
def economic_status ( self ) :
    r'''Dictionary of economic status indicators for the chemical .
 Examples
 > > > pprint ( Chemical ( ' benzene ' ) . economic _ status )
 [ " US public : { ' Manufactured ' : 6165232.1 , ' Imported ' : 463146.474 , ' Exported ' : 271908.252 } " ,
 u ' 1,000,000 - 10,000,000 tonnes per annum ' ,
 u ' Intermediate Use Only ' ,
 ' OECD HPV Chemicals ' ]'''

implementation:
if self . __economic_status :
    return self . __economic_status
else :
    self . __economic_status = economic_status ( self . CAS , Method = 'Combined' )
    return self . __economic_status


signature:
def UNIFAC_groups ( self ) :
    r'''Dictionary of UNIFAC subgroup : count groups for the original
 UNIFAC subgroups , as determined by ` DDBST ' s online service < http : / / www . ddbst . com / unifacga . html > ` _ .
 Examples
 > > > pprint ( Chemical ( ' Cumene ' ) . UNIFAC _ groups )
 {1 : 2 , 9 : 5 , 13 : 1}'''

implementation:
if self . __UNIFAC_groups :
    return self . __UNIFAC_groups
else :
    load_group_assignments_DDBST ( )
    if self . InChI_Key in DDBST_UNIFAC_assignments :
        self . __UNIFAC_groups = DDBST_UNIFAC_assignments [ self . InChI_Key ]
        return self . __UNIFAC_groups
    else :
        return None


signature:
def UNIFAC_Dortmund_groups ( self ) :
    r'''Dictionary of Dortmund UNIFAC subgroup : count groups for the
 Dortmund UNIFAC subgroups , as determined by ` DDBST ' s online service < http : / / www . ddbst . com / unifacga . html > ` _ .
 Examples
 > > > pprint ( Chemical ( ' Cumene ' ) . UNIFAC _ Dortmund _ groups )
 {1 : 2 , 9 : 5 , 13 : 1}'''

implementation:
if self . __UNIFAC_Dortmund_groups :
    return self . __UNIFAC_Dortmund_groups
else :
    load_group_assignments_DDBST ( )
    if self . InChI_Key in DDBST_MODIFIED_UNIFAC_assignments :
        self . __UNIFAC_Dortmund_groups = DDBST_MODIFIED_UNIFAC_assignments [ self . InChI_Key ]
        return self . __UNIFAC_Dortmund_groups
    else :
        return None


signature:
def PSRK_groups ( self ) :
    r'''Dictionary of PSRK subgroup : count groups for the PSRK subgroups ,
 as determined by ` DDBST ' s online service < http : / / www . ddbst . com / unifacga . html > ` _ .
 Examples
 > > > pprint ( Chemical ( ' Cumene ' ) . PSRK _ groups )
 {1 : 2 , 9 : 5 , 13 : 1}'''

implementation:
if self . __PSRK_groups :
    return self . __PSRK_groups
else :
    load_group_assignments_DDBST ( )
    if self . InChI_Key in DDBST_PSRK_assignments :
        self . __PSRK_groups = DDBST_PSRK_assignments [ self . InChI_Key ]
        return self . __PSRK_groups
    else :
        return None


signature:
def Hvap ( self ) :
    r'''Enthalpy of vaporization of the chemical at its current temperature ,
 in units of [ J / kg ] .
 This property uses the object - oriented interface
 : obj : ` thermo . phase _ change . EnthalpyVaporization ` , but converts its
 results from molar to mass units .
 Examples
 > > > Chemical ( ' water ' , T = 320 ) . Hvap
 2389540.219347256'''

implementation:
Hvamp = self . Hvapm
if Hvamp :
    return property_molar_to_mass ( Hvamp , self . MW )
return None


signature:
def Cps ( self ) :
    r'''Solid - phase heat capacity of the chemical at its current temperature ,
 in units of [ J / kg / K ] . For calculation of this property at other
 temperatures , or specifying manually the method used to calculate it ,
 and more - see the object oriented interface
 : obj : ` thermo . heat _ capacity . HeatCapacitySolid ` ; each Chemical instance
 creates one to actually perform the calculations . Note that that
 interface provides output in molar units .
 Examples
 > > > Chemical ( ' palladium ' , T = 400 ) . Cps
 241.63563239992484
 > > > Pd = Chemical ( ' palladium ' , T = 400)
 > > > Cpsms = [ Pd . HeatCapacitySolid . T _ dependent _ property ( T ) for T in np . linspace ( 300,500 , 5 ) ]
 > > > [ property _ molar _ to _ mass ( Cps , Pd . MW ) for Cps in Cpsms ]
 [234.40150347679008 , 238.01856793835751 , 241.63563239992484 , 245.25269686149224 , 248.86976132305958]'''

implementation:
Cpsm = self . HeatCapacitySolid ( self . T )
if Cpsm :
    return property_molar_to_mass ( Cpsm , self . MW )
return None


signature:
def Cpl ( self ) :
    r'''Liquid - phase heat capacity of the chemical at its current temperature ,
 in units of [ J / kg / K ] . For calculation of this property at other
 temperatures , or specifying manually the method used to calculate it ,
 and more - see the object oriented interface
 : obj : ` thermo . heat _ capacity . HeatCapacityLiquid ` ; each Chemical instance
 creates one to actually perform the calculations . Note that that
 interface provides output in molar units .
 Examples
 > > > Chemical ( ' water ' , T = 320 ) . Cpl
 4177.518996988284
 Ideal entropy change of water from 280 K to 340 K , output converted
 back to mass - based units of J / kg / K .
 > > > dSm = Chemical ( ' water ' ) . HeatCapacityLiquid . T _ dependent _ property _ integral _ over _ T ( 280 , 340)
 > > > property _ molar _ to _ mass ( dSm , Chemical ( ' water ' ) . MW )
 812.1024585274956'''

implementation:
Cplm = self . HeatCapacityLiquid ( self . T )
if Cplm :
    return property_molar_to_mass ( Cplm , self . MW )
return None


signature:
def Cpg ( self ) :
    r'''Gas - phase heat capacity of the chemical at its current temperature ,
 in units of [ J / kg / K ] . For calculation of this property at other
 temperatures , or specifying manually the method used to calculate it ,
 and more - see the object oriented interface
 : obj : ` thermo . heat _ capacity . HeatCapacityGas ` ; each Chemical instance
 creates one to actually perform the calculations . Note that that
 interface provides output in molar units .
 Examples
 > > > w = Chemical ( ' water ' , T = 520)
 > > > w . Cpg
 1967.6698314620658'''

implementation:
Cpgm = self . HeatCapacityGas ( self . T )
if Cpgm :
    return property_molar_to_mass ( Cpgm , self . MW )
return None


signature:
def Cvgm ( self ) :
    r'''Gas - phase ideal - gas contant - volume heat capacity of the chemical at
 its current temperature , in units of [ J / mol / K ] . Subtracts R from
 the ideal - gas heat capacity ; does not include pressure - compensation
 from an equation of state .
 Examples
 > > > w = Chemical ( ' water ' , T = 520)
 > > > w . Cvgm
 27.13366316134193'''

implementation:
Cpgm = self . HeatCapacityGas ( self . T )
if Cpgm :
    return Cpgm - R
return None


signature:
def Cvg ( self ) :
    r'''Gas - phase ideal - gas contant - volume heat capacity of the chemical at
 its current temperature , in units of [ J / kg / K ] . Subtracts R from
 the ideal - gas heat capacity ; does not include pressure - compensation
 from an equation of state .
 Examples
 > > > w = Chemical ( ' water ' , T = 520)
 > > > w . Cvg
 1506.1471795798861'''

implementation:
Cvgm = self . Cvgm
if Cvgm :
    return property_molar_to_mass ( Cvgm , self . MW )
return None


signature:
def isentropic_exponent ( self ) :
    r'''Gas - phase ideal - gas isentropic exponent of the chemical at its
 current temperature , [ dimensionless ] . Does not include
 pressure - compensation from an equation of state .
 Examples
 > > > Chemical ( ' hydrogen ' ) . isentropic _ exponent
 1.405237786321222'''

implementation:
Cp , Cv = self . Cpg , self . Cvg
if all ( ( Cp , Cv ) ) :
    return isentropic_exponent ( Cp , Cv )
return None


signature:
def rhos ( self ) :
    r'''Solid - phase mass density of the chemical at its current temperature ,
 in units of [ kg / m ^ 3 ] . For calculation of this property at
 other temperatures , or specifying manually the method used
 to calculate it , and more - see the object oriented interface
 : obj : ` thermo . volume . VolumeSolid ` ; each Chemical instance
 creates one to actually perform the calculations . Note that that
 interface provides output in molar units .
 Examples
 > > > Chemical ( ' iron ' ) . rhos
 7869.999994'''

implementation:
Vms = self . Vms
if Vms :
    return Vm_to_rho ( Vms , self . MW )
return None


signature:
def rhol ( self ) :
    r'''Liquid - phase mass density of the chemical at its current
 temperature and pressure , in units of [ kg / m ^ 3 ] . For calculation of this
 property at other temperatures and pressures , or specifying manually
 the method used to calculate it , and more - see the object oriented
 interface : obj : ` thermo . volume . VolumeLiquid ` ; each Chemical instance
 creates one to actually perform the calculations . Note that that
 interface provides output in molar units .
 Examples
 > > > Chemical ( ' o - xylene ' , T = 297 ) . rhol
 876.9946785618097'''

implementation:
Vml = self . Vml
if Vml :
    return Vm_to_rho ( Vml , self . MW )
return None


signature:
def rhog ( self ) :
    r'''Gas - phase mass density of the chemical at its current temperature
 and pressure , in units of [ kg / m ^ 3 ] . For calculation of this property at
 other temperatures or pressures , or specifying manually the method used
 to calculate it , and more - see the object oriented interface
 : obj : ` thermo . volume . VolumeGas ` ; each Chemical instance
 creates one to actually perform the calculations . Note that that
 interface provides output in molar units .
 Examples
 Estimate the density of the core of the sun , at 15 million K and
 26.5 PetaPascals , assuming pure helium ( actually 68 % helium ) :
 > > > Chemical ( ' helium ' , T = 15E6 , P = 26.5E15 ) . rhog
 8329.27226509739
 Compared to a result on
 ` Wikipedia < https : / / en . wikipedia . org / wiki / Solar _ core > ` _ of 150000
 kg / m ^ 3 , the fundamental equation of state performs poorly .
 > > > He = Chemical ( ' helium ' , T = 15E6 , P = 26.5E15)
 > > > He . VolumeGas . set _ user _ methods _ P ( [ ' IDEAL ' ] ) ; He . rhog
 850477.8065477367
 The ideal - gas law performs somewhat better , but vastly overshoots
 the density prediction .'''

implementation:
Vmg = self . Vmg
if Vmg :
    return Vm_to_rho ( Vmg , self . MW )
return None


signature:
def Zs ( self ) :
    r'''Compressibility factor of the chemical in the solid phase at the
 current temperature and pressure , [ dimensionless ] .
 Utilizes the object oriented interface and
 : obj : ` thermo . volume . VolumeSolid ` to perform the actual calculation of
 molar volume .
 Examples
 > > > Chemical ( ' palladium ' ) . Z
 0.00036248477437931853'''

implementation:
Vms = self . Vms
if Vms :
    return Z ( self . T , self . P , Vms )
return None


signature:
def Zl ( self ) :
    r'''Compressibility factor of the chemical in the liquid phase at the
 current temperature and pressure , [ dimensionless ] .
 Utilizes the object oriented interface and
 : obj : ` thermo . volume . VolumeLiquid ` to perform the actual calculation of
 molar volume .
 Examples
 > > > Chemical ( ' water ' ) . Zl
 0.0007385375470263454'''

implementation:
Vml = self . Vml
if Vml :
    return Z ( self . T , self . P , Vml )
return None


signature:
def Zg ( self ) :
    r'''Compressibility factor of the chemical in the gas phase at the
 current temperature and pressure , [ dimensionless ] .
 Utilizes the object oriented interface and
 : obj : ` thermo . volume . VolumeGas ` to perform the actual calculation of
 molar volume .
 Examples
 > > > Chemical ( ' sulfur hexafluoride ' , T = 700 , P = 1E9 ) . Zg
 11.140084184207813'''

implementation:
Vmg = self . Vmg
if Vmg :
    return Z ( self . T , self . P , Vmg )
return None


signature:
def SGg ( self ) :
    r'''Specific gravity of the gas phase of the chemical , [ dimensionless ] .
 The reference condition is air at 15.6 ° C ( 60 ° F ) and 1 atm
 ( rho = 1.223 kg / m ^ 3 ) . The definition for gases uses the compressibility
 factor of the reference gas and the chemical both at the reference
 conditions , not the conditions of the chemical .
 Examples
 > > > Chemical ( ' argon ' ) . SGg
 1.3795835970877504'''

implementation:
Vmg = self . VolumeGas ( T = 288.70555555555552 , P = 101325 )
if Vmg :
    rho = Vm_to_rho ( Vmg , self . MW )
    return SG ( rho , rho_ref = 1.2231876628642968 )
    # calculated with Mixture
return None


signature:
def API ( self ) :
    r'''API gravity of the liquid phase of the chemical , [ degrees ] .
 The reference condition is water at 15.6 ° C ( 60 ° F ) and 1 atm
 ( rho = 999.016 kg / m ^ 3 , standardized ) .
 Examples
 > > > Chemical ( ' water ' ) . API
 9.999752435378895'''

implementation:
Vml = self . VolumeLiquid ( T = 288.70555555555552 , P = 101325 )
if Vml :
    rho = Vm_to_rho ( Vml , self . MW )
sg = SG ( rho , rho_ref = 999.016 )
return SG_to_API ( sg )


signature:
def Bvirial ( self ) :
    r'''Second virial coefficient of the gas phase of the chemical at its
 current temperature and pressure , in units of [ mol / m ^ 3 ] .
 This property uses the object - oriented interface
 : obj : ` thermo . volume . VolumeGas ` , converting its result with
 : obj : ` thermo . utils . B _ from _ Z ` .
 Examples
 > > > Chemical ( ' water ' ) . Bvirial
 -0.0009596286322838357'''

implementation:
if self . Vmg :
    return B_from_Z ( self . Zg , self . T , self . P )
return None


signature:
def isobaric_expansion_l ( self ) :
    r'''Isobaric ( constant - pressure ) expansion of the liquid phase of the
 chemical at its current temperature and pressure , in units of [ 1 / K ] .
 . . math : :
 \ beta = \ frac { 1 } { V } \ left ( \ frac { \ partial V } { \ partial T } \ right ) _ P
 Utilizes the temperature - derivative method of
 : obj : ` thermo . volume . VolumeLiquid ` to perform the actual calculation .
 The derivatives are all numerical .
 Examples
 > > > Chemical ( ' dodecane ' , T = 400 ) . isobaric _ expansion _ l
 0.0011617555762469477'''

implementation:
dV_dT = self . VolumeLiquid . TP_dependent_property_derivative_T ( self . T , self . P )
Vm = self . Vml
if dV_dT and Vm :
    return isobaric_expansion ( V = Vm , dV_dT = dV_dT )


signature:
def isobaric_expansion_g ( self ) :
    r'''Isobaric ( constant - pressure ) expansion of the gas phase of the
 chemical at its current temperature and pressure , in units of [ 1 / K ] .
 . . math : :
 \ beta = \ frac { 1 } { V } \ left ( \ frac { \ partial V } { \ partial T } \ right ) _ P
 Utilizes the temperature - derivative method of
 : obj : ` thermo . VolumeGas ` to perform the actual calculation .
 The derivatives are all numerical .
 Examples
 > > > Chemical ( ' Hexachlorobenzene ' , T = 900 ) . isobaric _ expansion _ g
 0.001151869741981048'''

implementation:
dV_dT = self . VolumeGas . TP_dependent_property_derivative_T ( self . T , self . P )
Vm = self . Vmg
if dV_dT and Vm :
    return isobaric_expansion ( V = Vm , dV_dT = dV_dT )


signature:
def JTl ( self ) :
    r'''Joule Thomson coefficient of the chemical in the liquid phase at
 its current temperature and pressure , in units of [ K / Pa ] .
 . . math : :
 \ mu _ { JT } = \ left ( \ frac { \ partial T } { \ partial P } \ right ) _ H = \ frac { 1 } { C _ p }
 \ left [ T \ left ( \ frac { \ partial V } { \ partial T } \ right ) _ P - V \ right ]
 = \ frac { V } { C _ p } \ left ( \ beta T - 1 \ right )
 Utilizes the temperature - derivative method of
 : obj : ` thermo . volume . VolumeLiquid ` and the temperature - dependent heat
 capacity method : obj : ` thermo . heat _ capacity . HeatCapacityLiquid ` to
 obtain the properties required for the actual calculation .
 Examples
 > > > Chemical ( ' dodecane ' , T = 400 ) . JTl
 -3.0827160465192742e - 07'''

implementation:
Vml , Cplm , isobaric_expansion_l = self . Vml , self . Cplm , self . isobaric_expansion_l
if all ( ( Vml , Cplm , isobaric_expansion_l ) ) :
    return Joule_Thomson ( T = self . T , V = Vml , Cp = Cplm , beta = isobaric_expansion_l )
return None


signature:
def JTg ( self ) :
    r'''Joule Thomson coefficient of the chemical in the gas phase at
 its current temperature and pressure , in units of [ K / Pa ] .
 . . math : :
 \ mu _ { JT } = \ left ( \ frac { \ partial T } { \ partial P } \ right ) _ H = \ frac { 1 } { C _ p }
 \ left [ T \ left ( \ frac { \ partial V } { \ partial T } \ right ) _ P - V \ right ]
 = \ frac { V } { C _ p } \ left ( \ beta T - 1 \ right )
 Utilizes the temperature - derivative method of
 : obj : ` thermo . volume . VolumeGas ` and the temperature - dependent heat
 capacity method : obj : ` thermo . heat _ capacity . HeatCapacityGas ` to
 obtain the properties required for the actual calculation .
 Examples
 > > > Chemical ( ' dodecane ' , T = 400 , P = 1000 ) . JTg
 5.4089897835384913e - 05'''

implementation:
Vmg , Cpgm , isobaric_expansion_g = self . Vmg , self . Cpgm , self . isobaric_expansion_g
if all ( ( Vmg , Cpgm , isobaric_expansion_g ) ) :
    return Joule_Thomson ( T = self . T , V = Vmg , Cp = Cpgm , beta = isobaric_expansion_g )
return None


signature:
def nul ( self ) :
    r'''Kinematic viscosity of the liquid phase of the chemical at its
 current temperature and pressure , in units of [ m ^ 2 / s ] .
 . . math : :
 \ nu = \ frac { \ mu } { \ rho }
 Utilizes the temperature and pressure dependent object oriented
 interfaces : obj : ` thermo . volume . VolumeLiquid ` ,
 : obj : ` thermo . viscosity . ViscosityLiquid ` to calculate the
 actual properties .
 Examples
 > > > Chemical ( ' methane ' , T = 110 ) . nul
 2.858088468937331e - 07'''

implementation:
mul , rhol = self . mul , self . rhol
if all ( [ mul , rhol ] ) :
    return nu_mu_converter ( mu = mul , rho = rhol )
return None


signature:
def nug ( self ) :
    r'''Kinematic viscosity of the gas phase of the chemical at its
 current temperature and pressure , in units of [ m ^ 2 / s ] .
 . . math : :
 \ nu = \ frac { \ mu } { \ rho }
 Utilizes the temperature and pressure dependent object oriented
 interfaces : obj : ` thermo . volume . VolumeGas ` ,
 : obj : ` thermo . viscosity . ViscosityGas ` to calculate the
 actual properties .
 Examples
 > > > Chemical ( ' methane ' , T = 115 ) . nug
 2.5056924327995865e - 06'''

implementation:
mug , rhog = self . mug , self . rhog
if all ( [ mug , rhog ] ) :
    return nu_mu_converter ( mu = mug , rho = rhog )
return None


signature:
def alphal ( self ) :
    r'''Thermal diffusivity of the liquid phase of the chemical at its
 current temperature and pressure , in units of [ m ^ 2 / s ] .
 . . math : :
 \ alpha = \ frac { k } { \ rho Cp }
 Utilizes the temperature and pressure dependent object oriented
 interfaces : obj : ` thermo . volume . VolumeLiquid ` ,
 : obj : ` thermo . thermal _ conductivity . ThermalConductivityLiquid ` ,
 and : obj : ` thermo . heat _ capacity . HeatCapacityLiquid ` to calculate the
 actual properties .
 Examples
 > > > Chemical ( ' nitrogen ' , T = 70 ) . alphal
 9.444949636299626e - 08'''

implementation:
kl , rhol , Cpl = self . kl , self . rhol , self . Cpl
if all ( [ kl , rhol , Cpl ] ) :
    return thermal_diffusivity ( k = kl , rho = rhol , Cp = Cpl )
return None


signature:
def alphag ( self ) :
    r'''Thermal diffusivity of the gas phase of the chemical at its
 current temperature and pressure , in units of [ m ^ 2 / s ] .
 . . math : :
 \ alpha = \ frac { k } { \ rho Cp }
 Utilizes the temperature and pressure dependent object oriented
 interfaces : obj : ` thermo . volume . VolumeGas ` ,
 : obj : ` thermo . thermal _ conductivity . ThermalConductivityGas ` ,
 and : obj : ` thermo . heat _ capacity . HeatCapacityGas ` to calculate the
 actual properties .
 Examples
 > > > Chemical ( ' ammonia ' ) . alphag
 1.6931865425158556e - 05'''

implementation:
kg , rhog , Cpg = self . kg , self . rhog , self . Cpg
if all ( [ kg , rhog , Cpg ] ) :
    return thermal_diffusivity ( k = kg , rho = rhog , Cp = Cpg )
return None


signature:
def Prl ( self ) :
    r'''Prandtl number of the liquid phase of the chemical at its
 current temperature and pressure , [ dimensionless ] .
 . . math : :
 Pr = \ frac { C _ p \ mu } { k }
 Utilizes the temperature and pressure dependent object oriented
 interfaces : obj : ` thermo . viscosity . ViscosityLiquid ` ,
 : obj : ` thermo . thermal _ conductivity . ThermalConductivityLiquid ` ,
 and : obj : ` thermo . heat _ capacity . HeatCapacityLiquid ` to calculate the
 actual properties .
 Examples
 > > > Chemical ( ' nitrogen ' , T = 70 ) . Prl
 2.7828214501488886'''

implementation:
Cpl , mul , kl = self . Cpl , self . mul , self . kl
if all ( [ Cpl , mul , kl ] ) :
    return Prandtl ( Cp = Cpl , mu = mul , k = kl )
return None


signature:
def Prg ( self ) :
    r'''Prandtl number of the gas phase of the chemical at its
 current temperature and pressure , [ dimensionless ] .
 . . math : :
 Pr = \ frac { C _ p \ mu } { k }
 Utilizes the temperature and pressure dependent object oriented
 interfaces : obj : ` thermo . viscosity . ViscosityGas ` ,
 : obj : ` thermo . thermal _ conductivity . ThermalConductivityGas ` ,
 and : obj : ` thermo . heat _ capacity . HeatCapacityGas ` to calculate the
 actual properties .
 Examples
 > > > Chemical ( ' NH3 ' ) . Prg
 0.847263731933008'''

implementation:
Cpg , mug , kg = self . Cpg , self . mug , self . kg
if all ( [ Cpg , mug , kg ] ) :
    return Prandtl ( Cp = Cpg , mu = mug , k = kg )
return None


signature:
def solubility_parameter ( self ) :
    r'''Solubility parameter of the chemical at its
 current temperature and pressure , in units of [ Pa ^ 0.5 ] .
 . . math : :
 \ delta = \ sqrt { \ frac { \ Delta H _ { vap } - RT } { V _ m } }
 Calculated based on enthalpy of vaporization and molar volume .
 Normally calculated at STP . For uses of this property , see
 : obj : ` thermo . solubility . solubility _ parameter ` .
 Examples
 > > > Chemical ( ' NH3 ' ) . solubility _ parameter
 24766.329043856073'''

implementation: return solubility_parameter ( T = self . T , Hvapm = self . Hvapm , Vml = self . Vml , Method = self . solubility_parameter_method , CASRN = self . CAS )


signature:
def Parachor ( self ) :
    r'''Parachor of the chemical at its
 current temperature and pressure , in units of [ N ^ 0.25 * m ^ 2.75 / mol ] .
 . . math : :
 P = \ frac { \ sigma ^ { 0.25 } MW } { \ rho _ L - \ rho _ V }
 Calculated based on surface tension , density of the liquid and gas
 phase , and molecular weight . For uses of this property , see
 : obj : ` thermo . utils . Parachor ` .
 Examples
 > > > Chemical ( ' octane ' ) . Parachor
 6.291693072841486e - 05'''

implementation:
sigma , rhol , rhog = self . sigma , self . rhol , self . rhog
if all ( ( sigma , rhol , rhog , self . MW ) ) :
    return Parachor ( sigma = sigma , MW = self . MW , rhol = rhol , rhog = rhog )
return None


signature:
def Cp ( self ) :
    r'''Mass heat capacity of the chemical at its current phase and
 temperature , in units of [ J / kg / K ] .
 Utilizes the object oriented interfaces
 : obj : ` thermo . heat _ capacity . HeatCapacitySolid ` ,
 : obj : ` thermo . heat _ capacity . HeatCapacityLiquid ` ,
 and : obj : ` thermo . heat _ capacity . HeatCapacityGas ` to perform the
 actual calculation of each property . Note that those interfaces provide
 output in molar units ( J / mol / K ) .
 Examples
 > > > w = Chemical ( ' water ' )
 > > > w . Cp , w . phase
 (4180.597021827336 , ' l ' )
 > > > Chemical ( ' palladium ' ) . Cp
 234.26767209171211'''

implementation: return phase_select_property ( phase = self . phase , s = self . Cps , l = self . Cpl , g = self . Cpg )


signature:
def Cpm ( self ) :
    r'''Molar heat capacity of the chemical at its current phase and
 temperature , in units of [ J / mol / K ] .
 Utilizes the object oriented interfaces
 : obj : ` thermo . heat _ capacity . HeatCapacitySolid ` ,
 : obj : ` thermo . heat _ capacity . HeatCapacityLiquid ` ,
 and : obj : ` thermo . heat _ capacity . HeatCapacityGas ` to perform the
 actual calculation of each property .
 Examples
 > > > Chemical ( ' cubane ' ) . Cpm
 137.05489206785944
 > > > Chemical ( ' ethylbenzene ' , T = 550 , P = 3E6 ) . Cpm
 294.18449553310046'''

implementation: return phase_select_property ( phase = self . phase , s = self . Cpsm , l = self . Cplm , g = self . Cpgm )


signature:
def Vm ( self ) :
    r'''Molar volume of the chemical at its current phase and
 temperature and pressure , in units of [ m ^ 3 / mol ] .
 Utilizes the object oriented interfaces
 : obj : ` thermo . volume . VolumeSolid ` ,
 : obj : ` thermo . volume . VolumeLiquid ` ,
 and : obj : ` thermo . volume . VolumeGas ` to perform the
 actual calculation of each property .
 Examples
 > > > Chemical ( ' ethylbenzene ' , T = 550 , P = 3E6 ) . Vm
 0.00017758024401627633'''

implementation: return phase_select_property ( phase = self . phase , s = self . Vms , l = self . Vml , g = self . Vmg )


signature:
def rho ( self ) :
    r'''Mass density of the chemical at its current phase and
 temperature and pressure , in units of [ kg / m ^ 3 ] .
 Utilizes the object oriented interfaces
 : obj : ` thermo . volume . VolumeSolid ` ,
 : obj : ` thermo . volume . VolumeLiquid ` ,
 and : obj : ` thermo . volume . VolumeGas ` to perform the
 actual calculation of each property . Note that those interfaces provide
 output in units of m ^ 3 / mol .
 Examples
 > > > Chemical ( ' decane ' , T = 550 , P = 2E6 ) . rho
 498.67008448640604'''

implementation: return phase_select_property ( phase = self . phase , s = self . rhos , l = self . rhol , g = self . rhog )


signature:
def Z ( self ) :
    r'''Compressibility factor of the chemical at its current phase and
 temperature and pressure , [ dimensionless ] .
 Examples
 > > > Chemical ( ' MTBE ' , T = 900 , P = 1E - 2 ) . Z
 0.99999079768'''

implementation:
Vm = self . Vm
if Vm :
    return Z ( self . T , self . P , Vm )
return None


signature:
def SG ( self ) :
    r'''Specific gravity of the chemical , [ dimensionless ] .
 For gas - phase conditions , this is calculated at 15.6 ° C ( 60 ° F ) and 1
 atm for the chemical and the reference fluid , air .
 For liquid and solid phase conditions , this is calculated based on a
 reference fluid of water at 4 ° C at 1 atm , but the with the liquid or
 solid chemical ' s density at the currently specified conditions .
 Examples
 > > > Chemical ( ' MTBE ' ) . SG
 0.7428160596603596'''

implementation:
phase = self . phase
if phase == 'l' :
    return self . SGl
elif phase == 's' :
    return self . SGs
elif phase == 'g' :
    return self . SGg
rho = self . rho
if rho is not None :
    return SG ( rho )
return None


signature:
def isobaric_expansion ( self ) :
    r'''Isobaric ( constant - pressure ) expansion of the chemical at its
 current phase and temperature , in units of [ 1 / K ] .
 . . math : :
 \ beta = \ frac { 1 } { V } \ left ( \ frac { \ partial V } { \ partial T } \ right ) _ P
 Examples
 Radical change in value just above and below the critical temperature
 of water :
 > > > Chemical ( ' water ' , T = 647.1 , P = 22048320.0 ) . isobaric _ expansion
 0.34074205839222449
 > > > Chemical ( ' water ' , T = 647.2 , P = 22048320.0 ) . isobaric _ expansion
 0.18143324022215077'''

implementation: return phase_select_property ( phase = self . phase , l = self . isobaric_expansion_l , g = self . isobaric_expansion_g )


signature:
def JT ( self ) :
    r'''Joule Thomson coefficient of the chemical at its
 current phase and temperature , in units of [ K / Pa ] .
 . . math : :
 \ mu _ { JT } = \ left ( \ frac { \ partial T } { \ partial P } \ right ) _ H = \ frac { 1 } { C _ p }
 \ left [ T \ left ( \ frac { \ partial V } { \ partial T } \ right ) _ P - V \ right ]
 = \ frac { V } { C _ p } \ left ( \ beta T - 1 \ right )
 Examples
 > > > Chemical ( ' water ' ) . JT
 -2.2150394958666407e - 07'''

implementation: return phase_select_property ( phase = self . phase , l = self . JTl , g = self . JTg )


signature:
def mu ( self ) :
    r'''Viscosity of the chemical at its current phase , temperature , and
 pressure in units of [ Pa * s ] .
 Utilizes the object oriented interfaces
 : obj : ` thermo . viscosity . ViscosityLiquid ` and
 : obj : ` thermo . viscosity . ViscosityGas ` to perform the
 actual calculation of each property .
 Examples
 > > > Chemical ( ' ethanol ' , T = 300 ) . mu
 0.001044526538460911
 > > > Chemical ( ' ethanol ' , T = 400 ) . mu
 1.1853097849748217e - 05'''

implementation: return phase_select_property ( phase = self . phase , l = self . mul , g = self . mug )


signature:
def k ( self ) :
    r'''Thermal conductivity of the chemical at its current phase ,
 temperature , and pressure in units of [ W / m / K ] .
 Utilizes the object oriented interfaces
 : obj : ` thermo . thermal _ conductivity . ThermalConductivityLiquid ` and
 : obj : ` thermo . thermal _ conductivity . ThermalConductivityGas ` to perform
 the actual calculation of each property .
 Examples
 > > > Chemical ( ' ethanol ' , T = 300 ) . kl
 0.16313594741877802
 > > > Chemical ( ' ethanol ' , T = 400 ) . kg
 0.026019924109310026'''

implementation: return phase_select_property ( phase = self . phase , s = None , l = self . kl , g = self . kg )


signature:
def nu ( self ) :
    r'''Kinematic viscosity of the the chemical at its current temperature ,
 pressure , and phase in units of [ m ^ 2 / s ] .
 . . math : :
 \ nu = \ frac { \ mu } { \ rho }
 Examples
 > > > Chemical ( ' argon ' ) . nu
 1.3846930410865003e - 05'''

implementation: return phase_select_property ( phase = self . phase , l = self . nul , g = self . nug )


signature:
def alpha ( self ) :
    r'''Thermal diffusivity of the chemical at its current temperature ,
 pressure , and phase in units of [ m ^ 2 / s ] .
 . . math : :
 \ alpha = \ frac { k } { \ rho Cp }
 Examples
 > > > Chemical ( ' furfural ' ) . alpha
 8.696537158635412e - 08'''

implementation: return phase_select_property ( phase = self . phase , l = self . alphal , g = self . alphag )


signature:
def Pr ( self ) :
    r'''Prandtl number of the chemical at its current temperature ,
 pressure , and phase ; [ dimensionless ] .
 . . math : :
 Pr = \ frac { C _ p \ mu } { k }
 Examples
 > > > Chemical ( ' acetone ' ) . Pr
 4.183039103542709'''

implementation: return phase_select_property ( phase = self . phase , l = self . Prl , g = self . Prg )


signature:
def Poynting ( self ) :
    r'''Poynting correction factor [ dimensionless ] for use in phase
 equilibria methods based on activity coefficients or other reference
 states . Performs the shortcut calculation assuming molar volume is
 independent of pressure .
 . . math : :
 \ text { Poy } = \ exp \ left [ \ frac { V _ l ( P - P ^ { sat } ) } { RT } \ right ]
 The full calculation normally returns values very close to the
 approximate ones . This property is defined in terms of
 pure components only .
 Examples
 > > > Chemical ( ' pentane ' , T = 300 , P = 1E7 ) . Poynting
 1.5743051250679803
 Notes
 The full equation shown below can be used as follows :
 . . math : :
 \ text { Poy } = \ exp \ left [ \ frac { \ int _ { P _ i ^ { sat } } ^ P V _ i ^ l dP } { RT } \ right ]
 > > > from scipy . integrate import quad
 > > > c = Chemical ( ' pentane ' , T = 300 , P = 1E7)
 > > > exp ( quad ( lambda P : c . VolumeLiquid ( c . T , P ) , c . Psat , c . P ) [ 0 ] / R / c . T )
 1.5821826990975127'''

implementation:
Vml , Psat = self . Vml , self . Psat
if Vml and Psat :
    return exp ( Vml * ( self . P - Psat ) / R / self . T )
return None