コード例 #1
0
def Hfus(T=298.15, P=101325, MW=None, AvailableMethods=False, Method=None, CASRN=''):  # pragma: no cover
    '''This function handles the calculation of a chemical's enthalpy of fusion.
    Generally this, is used by the chemical class, as all parameters are passed.
    Calling the function directly works okay.

    Enthalpy of fusion is a weak function of pressure, and its effects are
    neglected.

    This API is considered experimental, and is expected to be removed in a
    future release in favor of a more complete object-oriented interface.

    '''
    def list_methods():
        methods = []
        if CASRN in CRCHfus_data.index:
            methods.append('CRC, at melting point')
        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 == 'CRC, at melting point':
        _Hfus = CRCHfus_data.at[CASRN, 'Hfus']
    elif Method == 'None' or not MW:
        _Hfus = None
    else:
        raise Exception('Failure in in function')
    _Hfus = property_molar_to_mass(_Hfus, MW)
    return _Hfus
コード例 #2
0
def Hfus(T=298.15, P=101325, MW=None, AvailableMethods=False, Method=None, CASRN=''):  # pragma: no cover
    '''This function handles the calculation of a chemical's enthalpy of fusion.
    Generally this, is used by the chemical class, as all parameters are passed.
    Calling the function directly works okay.

    Enthalpy of fusion is a weak function of pressure, and its effects are
    neglected.

    This API is considered experimental, and is expected to be removed in a
    future release in favor of a more complete object-oriented interface.

    '''
    def list_methods():
        methods = []
        if CASRN in CRCHfus_data.index:
            methods.append('CRC, at melting point')
        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 == 'CRC, at melting point':
        _Hfus = CRCHfus_data.at[CASRN, 'Hfus']
    elif Method == 'None' or not MW:
        _Hfus = None
    else:
        raise Exception('Failure in in function')
    _Hfus = property_molar_to_mass(_Hfus, MW)
    return _Hfus
コード例 #3
0
def Hsub(T=298.15, P=101325, MW=None, AvailableMethods=False, Method=None, CASRN=''):  # pragma: no cover
    '''This function handles the calculation of a chemical's enthalpy of sublimation.
    Generally this, is used by the chemical class, as all parameters are passed.


    This API is considered experimental, and is expected to be removed in a
    future release in favor of a more complete object-oriented interface.
    '''
    def list_methods():
        methods = []
#        if Hfus(T=T, P=P, MW=MW, CASRN=CASRN) and Hvap(T=T, P=P, MW=MW, CASRN=CASRN):
#            methods.append('Hfus + Hvap')
        if CASRN in GharagheiziHsub_data.index:
            methods.append('Ghazerati Appendix, at 298K')
        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 == 'Hfus + Hvap':
#        p1 = Hfus(T=T, P=P, MW=MW, CASRN=CASRN)
#        p2 = Hvap(T=T, P=P, MW=MW, CASRN=CASRN)
#        if p1 and p2:
#            _Hsub = p1 + p2
#        else:
#            _Hsub = None
    if Method == 'Ghazerati Appendix, at 298K':
        _Hsub = float(GharagheiziHsub_data.at[CASRN, 'Hsub'])
    elif Method == 'None' or not _Hsub or not MW:
        return None
    else:
        raise Exception('Failure in in function')
    _Hsub = property_molar_to_mass(_Hsub, MW)
    return _Hsub
コード例 #4
0
def Hsub(T=298.15, P=101325, MW=None, AvailableMethods=False, Method=None, CASRN=''):  # pragma: no cover
    '''This function handles the calculation of a chemical's enthalpy of sublimation.
    Generally this, is used by the chemical class, as all parameters are passed.


    This API is considered experimental, and is expected to be removed in a
    future release in favor of a more complete object-oriented interface.
    '''
    def list_methods():
        methods = []
#        if Hfus(T=T, P=P, MW=MW, CASRN=CASRN) and Hvap(T=T, P=P, MW=MW, CASRN=CASRN):
#            methods.append('Hfus + Hvap')
        if CASRN in GharagheiziHsub_data.index:
            methods.append('Ghazerati Appendix, at 298K')
        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 == 'Hfus + Hvap':
#        p1 = Hfus(T=T, P=P, MW=MW, CASRN=CASRN)
#        p2 = Hvap(T=T, P=P, MW=MW, CASRN=CASRN)
#        if p1 and p2:
#            _Hsub = p1 + p2
#        else:
#            _Hsub = None
    if Method == 'Ghazerati Appendix, at 298K':
        _Hsub = float(GharagheiziHsub_data.at[CASRN, 'Hsub'])
    elif Method == 'None' or not _Hsub or not MW:
        return None
    else:
        raise Exception('Failure in in function')
    _Hsub = property_molar_to_mass(_Hsub, MW)
    return _Hsub
コード例 #5
0
ファイル: stream.py プロジェクト: CalebBell/thermo
 def __init__(self, IDs=None, zs=None, ws=None, Vfls=None, Vfgs=None,
              ns=None, ms=None, Qls=None, Qgs=None, 
              n=None, m=None, Q=None, T=298.15, P=101325, V_TP=(None, None)):
     composition_options = (zs, ws, Vfls, Vfgs, ns, ms, Qls, Qgs)
     composition_option_count = sum(i is not None for i in composition_options)
     if hasattr(IDs, 'strip') or (type(IDs) == list and len(IDs) == 1):
         pass # one component only - do not raise an exception
     elif composition_option_count < 1:
         raise Exception("No composition information is provided; one of "
                         "'ws', 'zs', 'Vfls', 'Vfgs', 'ns', 'ms', 'Qls' or "
                         "'Qgs' must be specified")
     elif composition_option_count > 1:
         raise Exception("More than one source of composition information "
                         "is provided; only one of "
                         "'ws', 'zs', 'Vfls', 'Vfgs', 'ns', 'ms', 'Qls' or "
                         "'Qgs' can be specified")
         
     # if more than 1 of composition_options is given, raise an exception
     flow_options = (ns, ms, Qls, Qgs, m, n, Q)
     flow_option_count = sum(i is not None for i in flow_options)
     if flow_option_count < 1:
         raise Exception("No flow rate information is provided; one of "
                         "'m', 'n', 'Q', 'ms', 'ns', 'Qls', or 'Qgs' must "
                         "be specified")
     elif flow_option_count > 1:
         raise Exception("More than one source of flow rate information is "
                         "provided; only one of "
                         "'m', 'n', 'Q', 'ms', 'ns', 'Qls', or 'Qgs' can "
                         "be specified")
     
     if ns is not None:
         zs = ns
     elif ms is not None:
         ws = ms
     elif Qls is not None:
         Vfls = Qls
     elif Qgs is not None:
         Vfgs = Qgs
     
     super(Stream, self).__init__(IDs, zs=zs, ws=ws, Vfls=Vfls, Vfgs=Vfgs,
          T=T, P=P, Vf_TP=V_TP)
     if n is not None:
         self.n = n
     elif m is not None:
         self.n = property_molar_to_mass(m, self.MW) # m*10000/MW
     elif Q is not None:
         try:
             self.n = Q/self.Vm
         except:
             raise Exception('Molar volume could not be calculated to determine the flow rate of the stream.')
     elif ns is not None:
         if isinstance(ns, (OrderedDict, dict)):
             ns = ns.values()
         self.n = sum(ns)
     elif ms is not None:
         if isinstance(ms, (OrderedDict, dict)):
             ms = ms.values()
         self.n = property_molar_to_mass(sum(ms), self.MW)
     elif Qls is not None:
         try:
             if isinstance(Qls, (OrderedDict, dict)):
                 Qls = Qls.values()
             self.n = sum([Q/Vml for Q, Vml in zip(Qls, self.Vmls)])
         except:
             raise Exception('Liquid molar volume could not be calculated to determine the flow rate of the stream.')
     elif Qgs is not None:
         try:
             if isinstance(Qgs, (OrderedDict, dict)):
                 Qgs = Qgs.values()
             self.n = sum([Q/Vmg for Q, Vmg in zip(Qgs, self.Vmgs)])
         except:
             raise Exception('Gas molar volume could not be calculated to determine the flow rate of the stream.')
     self.set_extensive_flow(self.n)
     self.set_extensive_properties()
コード例 #6
0
ファイル: stream.py プロジェクト: vesnin41/thermo
    def __init__(self,
                 IDs,
                 zs=None,
                 ws=None,
                 Vfls=None,
                 Vfgs=None,
                 ns=None,
                 ms=None,
                 Qls=None,
                 Qgs=None,
                 n=None,
                 m=None,
                 Q=None,
                 T=298.15,
                 P=101325,
                 V_TP=(None, None)):
        composition_options = (zs, ws, Vfls, Vfgs, ns, ms, Qls, Qgs)
        composition_option_count = sum(i is not None
                                       for i in composition_options)
        if hasattr(IDs, 'strip') or len(IDs) == 1:
            pass  # one component only - do not raise an exception
        elif composition_option_count < 1:
            raise Exception("No composition information is provided; one of "
                            "'ws', 'zs', 'Vfls', 'Vfgs', 'ns', 'ms', 'Qls' or "
                            "'Qgs' must be specified")
        elif composition_option_count > 1:
            raise Exception("More than one source of composition information "
                            "is provided; only one of "
                            "'ws', 'zs', 'Vfls', 'Vfgs', 'ns', 'ms', 'Qls' or "
                            "'Qgs' can be specified")

        # if more than 1 of composition_options is given, raise an exception
        flow_options = (ns, ms, Qls, Qgs, m, n, Q)
        flow_option_count = sum(i is not None for i in flow_options)
        if flow_option_count < 1:
            raise Exception("No flow rate information is provided; one of "
                            "'m', 'n', 'Q', 'ms', 'ns', 'Qls', or 'Qgs' must "
                            "be specified")
        elif flow_option_count > 1:
            raise Exception("More than one source of flow rate information is "
                            "provided; only one of "
                            "'m', 'n', 'Q', 'ms', 'ns', 'Qls', or 'Qgs' can "
                            "be specified")

        if ns is not None:
            zs = ns
        elif ms is not None:
            ws = ms
        elif Qls is not None:
            Vfls = Qls
        elif Qgs is not None:
            Vfgs = Qgs

        super(Stream, self).__init__(IDs,
                                     zs=zs,
                                     ws=ws,
                                     Vfls=Vfls,
                                     Vfgs=Vfgs,
                                     T=T,
                                     P=P,
                                     Vf_TP=V_TP)
        if n is not None:
            self.n = n
        elif m is not None:
            self.n = property_molar_to_mass(m, self.MW)  # m*10000/MW
        elif Q is not None:
            try:
                self.n = Q / self.Vm
            except:
                raise Exception(
                    'Molar volume could not be calculated to determine the flow rate of the stream.'
                )
        elif ns is not None:
            self.n = sum(ns)
        elif ms is not None:
            self.n = property_molar_to_mass(sum(ms), self.MW)
        elif Qls is not None:
            try:
                self.n = sum([Q / Vml for Q, Vml in zip(Qls, self.Vmls)])
            except:
                raise Exception(
                    'Liquid molar volume could not be calculated to determine the flow rate of the stream.'
                )
        elif Qgs is not None:
            try:
                self.n = sum([Q / Vmg for Q, Vmg in zip(Qgs, self.Vmgs)])
            except:
                raise Exception(
                    'Gas molar volume could not be calculated to determine the flow rate of the stream.'
                )
        self.set_extensive_flow(self.n)
        self.set_extensive_properties()