Esempio n. 1
0
    def generateThermo(self):
        """
        Generate the thermodynamic data for the species and fit it to the
        desired heat capacity model (as specified in the `thermoClass` 
        attribute).
        """
        if self.thermoClass.lower() not in ['wilhoit', 'nasa']:
            raise Exception('Unknown thermodynamic model "{0}".'.format(
                self.thermoClass))

        species = self.species

        logging.info('Generating {0} thermo model for {1}...'.format(
            self.thermoClass, species))

        Tlist = numpy.arange(10.0, 3001.0, 10.0, numpy.float64)
        Cplist = numpy.zeros_like(Tlist)
        H298 = 0.0
        S298 = 0.0
        conformer = self.species.conformer
        for i in range(Tlist.shape[0]):
            Cplist[i] += conformer.getHeatCapacity(Tlist[i])
        H298 += conformer.getEnthalpy(298.) + conformer.E0.value_si
        S298 += conformer.getEntropy(298.)

        if not any([
                isinstance(mode, (LinearRotor, NonlinearRotor))
                for mode in conformer.modes
        ]):
            # Monatomic species
            linear = False
            Nfreq = 0
            Nrotors = 0
            Cp0 = 2.5 * constants.R
            CpInf = 2.5 * constants.R
        else:
            # Polyatomic species
            linear = True if isinstance(conformer.modes[1],
                                        LinearRotor) else False
            Nfreq = len(conformer.modes[2].frequencies.value)
            Nrotors = len(conformer.modes[3:])
            Cp0 = (3.5 if linear else 4.0) * constants.R
            CpInf = Cp0 + (Nfreq + 0.5 * Nrotors) * constants.R

        wilhoit = Wilhoit()
        if Nfreq == 0 and Nrotors == 0:
            wilhoit.Cp0 = (Cplist[0], "J/(mol*K)")
            wilhoit.CpInf = (Cplist[0], "J/(mol*K)")
            wilhoit.B = (500., "K")
            wilhoit.H0 = (0.0, "J/mol")
            wilhoit.S0 = (0.0, "J/(mol*K)")
            wilhoit.H0 = (H298 - wilhoit.getEnthalpy(298.15), "J/mol")
            wilhoit.S0 = (S298 - wilhoit.getEntropy(298.15), "J/(mol*K)")
        else:
            wilhoit.fitToData(Tlist, Cplist, Cp0, CpInf, H298, S298, B0=500.0)

        if self.thermoClass.lower() == 'nasa':
            species.thermo = wilhoit.toNASA(Tmin=10.0, Tmax=3000.0, Tint=500.0)
        else:
            species.thermo = wilhoit
 def generateThermo(self):
     """
     Generate the thermodynamic data for the species and fit it to the
     desired heat capacity model (as specified in the `thermoClass` 
     attribute).
     """
     if self.thermoClass.lower() not in ['wilhoit', 'nasa']:
         raise Exception('Unknown thermodynamic model "{0}".'.format(self.thermoClass))
 
     species = self.species
 
     logging.debug('Generating {0} thermo model for {1}...'.format(self.thermoClass, species))
     
     if species.thermo is not None:
         logging.info("Thermo already generated for species {}. Skipping thermo generation.".format(species))
         return None
     
     Tlist = np.arange(10.0, 3001.0, 10.0, np.float64)
     Cplist = np.zeros_like(Tlist)
     H298 = 0.0
     S298 = 0.0
     conformer = self.species.conformer
     for i in range(Tlist.shape[0]):
         Cplist[i] += conformer.getHeatCapacity(Tlist[i])
     H298 += conformer.getEnthalpy(298.) + conformer.E0.value_si
     S298 += conformer.getEntropy(298.)
     
     if not any([isinstance(mode, (LinearRotor, NonlinearRotor)) for mode in conformer.modes]):
         # Monatomic species
         linear = False
         Nfreq = 0
         Nrotors = 0
         Cp0 = 2.5 * constants.R
         CpInf = 2.5 * constants.R
     else:
         # Polyatomic species
         linear = True if isinstance(conformer.modes[1], LinearRotor) else False
         Nfreq = len(conformer.modes[2].frequencies.value)
         Nrotors = len(conformer.modes[3:])
         Cp0 = (3.5 if linear else 4.0) * constants.R
         CpInf = Cp0 + (Nfreq + 0.5 * Nrotors) * constants.R
 
     wilhoit = Wilhoit()
     if Nfreq == 0 and Nrotors == 0:
         wilhoit.Cp0 = (Cplist[0],"J/(mol*K)") 
         wilhoit.CpInf = (Cplist[0],"J/(mol*K)")
         wilhoit.B = (500.,"K") 
         wilhoit.H0 = (0.0,"J/mol")
         wilhoit.S0 = (0.0,"J/(mol*K)") 
         wilhoit.H0 =  (H298 -wilhoit.getEnthalpy(298.15), "J/mol") 
         wilhoit.S0 = (S298 - wilhoit.getEntropy(298.15),"J/(mol*K)")
     else:
         wilhoit.fitToData(Tlist, Cplist, Cp0, CpInf, H298, S298, B0=500.0)
     
     if self.thermoClass.lower() == 'nasa':
         species.thermo = wilhoit.toNASA(Tmin=10.0, Tmax=3000.0, Tint=500.0)
     else:
         species.thermo = wilhoit
Esempio n. 3
0
    def generate_thermo(self):
        """
        Generate the thermodynamic data for the species and fit it to the
        desired heat capacity model (as specified in the `thermo_class`
        attribute).
        """
        if self.thermo_class.lower() not in ['wilhoit', 'nasa']:
            raise InputError('Unknown thermodynamic model "{0}".'.format(
                self.thermo_class))

        species = self.species

        logging.debug('Generating {0} thermo model for {1}...'.format(
            self.thermo_class, species))

        if species.thermo is not None:
            logging.info(
                "Thermo already generated for species {}. Skipping thermo generation."
                .format(species))
            return None

        Tlist = np.arange(10.0, 3001.0, 10.0, np.float64)
        Cplist = np.zeros_like(Tlist)
        H298 = 0.0
        S298 = 0.0
        conformer = self.species.conformer
        for i in range(Tlist.shape[0]):
            Cplist[i] += conformer.get_heat_capacity(Tlist[i])
        H298 += conformer.get_enthalpy(298.) + conformer.E0.value_si
        S298 += conformer.get_entropy(298.)

        if not any([
                isinstance(mode, (LinearRotor, NonlinearRotor))
                for mode in conformer.modes
        ]):
            # Monatomic species
            n_freq = 0
            n_rotors = 0
            Cp0 = 2.5 * constants.R
            CpInf = 2.5 * constants.R
        else:
            # Polyatomic species
            linear = True if isinstance(conformer.modes[1],
                                        LinearRotor) else False
            n_freq = len(conformer.modes[2].frequencies.value)
            n_rotors = len(conformer.modes[3:])
            Cp0 = (3.5 if linear else 4.0) * constants.R
            CpInf = Cp0 + (n_freq + 0.5 * n_rotors) * constants.R

        wilhoit = Wilhoit()
        if n_freq == 0 and n_rotors == 0:
            wilhoit.Cp0 = (Cplist[0], "J/(mol*K)")
            wilhoit.CpInf = (Cplist[0], "J/(mol*K)")
            wilhoit.B = (500., "K")
            wilhoit.H0 = (0.0, "J/mol")
            wilhoit.S0 = (0.0, "J/(mol*K)")
            wilhoit.H0 = (H298 - wilhoit.get_enthalpy(298.15), "J/mol")
            wilhoit.S0 = (S298 - wilhoit.get_entropy(298.15), "J/(mol*K)")
        else:
            wilhoit.fit_to_data(Tlist,
                                Cplist,
                                Cp0,
                                CpInf,
                                H298,
                                S298,
                                B0=500.0)

        if self.thermo_class.lower() == 'nasa':
            species.thermo = wilhoit.to_nasa(Tmin=10.0,
                                             Tmax=3000.0,
                                             Tint=500.0)
        else:
            species.thermo = wilhoit