def runThermoEstimator(inputFile): """ Estimate thermo for a list of species using RMG and the settings chosen inside a thermo input file. """ rmg = RMG() rmg.loadThermoInput(inputFile) # initialize and load the database as well as any QM settings rmg.loadDatabase() if rmg.quantumMechanics: rmg.quantumMechanics.initialize() # Generate the thermo for all the species and write them to chemkin format as well as # ThermoLibrary format with values for H, S, and Cp's. output = open(os.path.join(rmg.outputDirectory, 'output.txt'),'wb') library = ThermoLibrary(name='Thermo Estimation Library') for species in rmg.initialSpecies: species.generateThermoData(rmg.database, quantumMechanics=rmg.reactionModel.quantumMechanics) library.loadEntry( index = len(library.entries) + 1, label = species.label, molecule = species.molecule[0].toAdjacencyList(), thermo = species.thermo.toThermoData(), shortDesc = species.thermo.comment, ) output.write(writeThermoEntry(species)) output.write('\n') output.close() library.save(os.path.join(rmg.outputDirectory,'ThermoLibrary.py'))
def save_thermo_lib(species_list, path, name, lib_long_desc): """ Save an RMG thermo library of all species in `species_list` in the supplied `path` `name` is the library's name (or project's name) `long_desc` is a multiline string with level of theory description """ if species_list: lib_path = os.path.join(path, 'thermo', '{0}.py'.format(name)) thermo_library = ThermoLibrary(name=name, longDesc=lib_long_desc) for i, spc in enumerate(species_list): if spc.thermo is not None: spc.long_thermo_description += '\nExternal symmetry: {0}, optical isomers: {1}\n'.format( spc.external_symmetry, spc.optical_isomers) spc.long_thermo_description += '\nGeometry:\n{0}'.format( spc.final_xyz) thermo_library.loadEntry( index=i + 1, label=spc.label, molecule=spc.mol_list[0].toAdjacencyList(), thermo=spc.thermo, shortDesc=spc.thermo.comment, longDesc=spc.long_thermo_description) else: logging.warning( 'Species {0} did not contain any thermo data and was omitted from the thermo' ' library.'.format(str(spc))) thermo_library.save(lib_path)
def runThermoEstimator(inputFile): """ Estimate thermo for a list of species using RMG and the settings chosen inside a thermo input file. """ rmg = RMG() rmg.loadThermoInput(inputFile) # initialize and load the database as well as any QM settings rmg.loadDatabase() if rmg.quantumMechanics: rmg.quantumMechanics.initialize() # Generate the thermo for all the species and write them to chemkin format as well as # ThermoLibrary format with values for H, S, and Cp's. output = open(os.path.join(rmg.outputDirectory, 'output.txt'), 'wb') library = ThermoLibrary(name='Thermo Estimation Library') for species in rmg.initialSpecies: species.generateThermoData( rmg.database, quantumMechanics=rmg.reactionModel.quantumMechanics) library.loadEntry( index=len(library.entries) + 1, label=species.label, molecule=species.molecule[0].toAdjacencyList(), thermo=species.thermo.toThermoData(), shortDesc=species.thermo.comment, ) output.write(writeThermoEntry(species)) output.write('\n') output.close() library.save(os.path.join(rmg.outputDirectory, 'ThermoLibrary.py'))
def runThermoEstimator(inputFile, library_flag): """ Estimate thermo for a list of species using RMG and the settings chosen inside a thermo input file. """ rmg = RMG() rmg.loadThermoInput(inputFile) rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) # forbidden structure loading rmg.database.loadThermo(os.path.join(path, 'thermo'), rmg.thermoLibraries, depository=False) if rmg.solvent: rmg.database.loadSolvation(os.path.join(path, 'solvation')) Species.solventData = rmg.database.solvation.getSolventData( rmg.solvent) Species.solventName = rmg.solvent for species in rmg.initialSpecies: submit(species) if library_flag: library = ThermoLibrary(name='Thermo Estimation Library') for species in rmg.initialSpecies: library.loadEntry( index=len(library.entries) + 1, label=species.label, molecule=species.molecule[0].toAdjacencyList(), thermo=species.getThermoData().toThermoData(), shortDesc=species.getThermoData().comment, ) library.save(os.path.join(rmg.outputDirectory, 'ThermoLibrary.py')) # Save the thermo data to chemkin format output files and dictionary, with no reactions saveChemkinFile(os.path.join(rmg.outputDirectory, 'chem_annotated.inp'), species=rmg.initialSpecies, reactions=[]) saveSpeciesDictionary(os.path.join(rmg.outputDirectory, 'species_dictionary.txt'), species=rmg.initialSpecies)
def runThermoEstimator(inputFile): """ Estimate thermo for a list of species using RMG and the settings chosen inside a thermo input file. """ rmg = RMG() rmg.loadThermoInput(inputFile) rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) # forbidden structure loading rmg.database.loadThermo(os.path.join(path, 'thermo'), rmg.thermoLibraries, depository=False) if rmg.solvent: rmg.database.loadSolvation(os.path.join(path, 'solvation')) Species.solventData = rmg.database.solvation.getSolventData(rmg.solvent) Species.solventName = rmg.solvent # Generate the thermo for all the species and write them to chemkin format as well as # ThermoLibrary format with values for H, S, and Cp's. output = open(os.path.join(rmg.outputDirectory, 'output.txt'),'wb') library = ThermoLibrary(name='Thermo Estimation Library') for species in rmg.initialSpecies: species.getThermoData(rmg.database) library.loadEntry( index = len(library.entries) + 1, label = species.label, molecule = species.molecule[0].toAdjacencyList(), thermo = species.thermo.toThermoData(), shortDesc = species.thermo.comment, ) output.write(writeThermoEntry(species)) output.write('\n') output.close() library.save(os.path.join(rmg.outputDirectory,'ThermoLibrary.py'))
print removeH speciesList, reactionList = loadChemkinFile(chemkinPath, dictionaryPath) # load thermo library entries thermoLibrary = ThermoLibrary() for i in range(len(speciesList)): species = speciesList[i] rdkitmol = species.molecule[0].toRDKitMol(removeHs=False) species.molecule = [Molecule().fromRDKitMol(rdkitmol)]#[0].toAdjacencyList(removeH=False) print species.molecule[0].toAdjacencyList(removeH = removeH) if species.thermo: thermoLibrary.loadEntry(index = i + 1, label = species.label, molecule = species.molecule[0].toAdjacencyList(removeH = removeH), thermo = species.thermo, shortDesc = species.thermo.comment ) else: logging.warning('Species {0} did not contain any thermo data and was omitted from the thermo library.'.format(str(species))) # load kinetics library entries kineticsLibrary = KineticsLibrary() kineticsLibrary.entries = {} for i in range(len(reactionList)): reaction = reactionList[i] entry = Entry( index = i+1, item = reaction, data = reaction.kinetics, )
def getLibraries(self): name = 'kineticsjobs' speciesList = self.speciesDict.values() reactionList = self.reactionDict.values() # remove duplicate species for rxn in reactionList: for i, rspc in enumerate(rxn.reactants): for spc in speciesList: if spc.isIsomorphic(rspc): rxn.reactants[i] = spc break for i, rspc in enumerate(rxn.products): for spc in speciesList: if spc.isIsomorphic(rspc): rxn.products[i] = spc break del_inds = [] for i, spc1 in enumerate(speciesList): for j, spc2 in enumerate(speciesList): if j > i and spc1.isIsomorphic(spc2): del_inds.append(j) for j in sorted(del_inds)[::-1]: del speciesList[j] thermoLibrary = ThermoLibrary(name=name) for i, species in enumerate(speciesList): if species.thermo: thermoLibrary.loadEntry( index=i + 1, label=species.label, molecule=species.molecule[0].toAdjacencyList(), thermo=species.thermo, shortDesc=species.thermo.comment) else: logging.warning( 'Species {0} did not contain any thermo data and was omitted from the thermo library.' .format(str(species))) # load kinetics library entries kineticsLibrary = KineticsLibrary(name=name, autoGenerated=True) kineticsLibrary.entries = {} for i, reaction in enumerate(reactionList): entry = Entry( index=i + 1, label=reaction.toLabeledStr(), item=reaction, data=reaction.kinetics, ) if reaction.kinetics is not None: if hasattr(reaction, 'library') and reaction.library: entry.longDesc = 'Originally from reaction library: ' +\ reaction.library + "\n" + reaction.kinetics.comment else: entry.longDesc = reaction.kinetics.comment kineticsLibrary.entries[i + 1] = entry kineticsLibrary.label = name return thermoLibrary, kineticsLibrary, speciesList
def getLibraries(self): name = 'kineticsjobs' speciesList = self.speciesDict.values() reactionList = self.reactionDict.values() # remove duplicate species for rxn in reactionList: for i,rspc in enumerate(rxn.reactants): for spc in speciesList: if spc.isIsomorphic(rspc): rxn.reactants[i] = spc break for i,rspc in enumerate(rxn.products): for spc in speciesList: if spc.isIsomorphic(rspc): rxn.products[i] = spc break del_inds = [] for i,spc1 in enumerate(speciesList): for j,spc2 in enumerate(speciesList): if j>i and spc1.isIsomorphic(spc2): del_inds.append(j) for j in sorted(del_inds)[::-1]: del speciesList[j] thermoLibrary = ThermoLibrary(name=name) for i,species in enumerate(speciesList): if species.thermo: thermoLibrary.loadEntry(index = i + 1, label = species.label, molecule = species.molecule[0].toAdjacencyList(), thermo = species.thermo, shortDesc = species.thermo.comment ) else: logging.warning('Species {0} did not contain any thermo data and was omitted from the thermo library.'.format(str(species))) # load kinetics library entries kineticsLibrary = KineticsLibrary(name=name,autoGenerated=True) kineticsLibrary.entries = {} for i,reaction in enumerate(reactionList): entry = Entry( index = i+1, label = reaction.toLabeledStr(), item = reaction, data = reaction.kinetics, ) if reaction.kinetics is not None: if hasattr(reaction,'library') and reaction.library: entry.longDesc = 'Originally from reaction library: ' +\ reaction.library + "\n" + reaction.kinetics.comment else: entry.longDesc = reaction.kinetics.comment kineticsLibrary.entries[i+1] = entry kineticsLibrary.label = name return thermoLibrary,kineticsLibrary,speciesList
name = args.name[0] speciesList, reactionList = loadChemkinFile(chemkinPath, dictionaryPath) # Make full species identifier the species labels for species in speciesList: species.label = getSpeciesIdentifier(species) species.index = -1 # load thermo library entries thermoLibrary = ThermoLibrary(name=name) for i in range(len(speciesList)): species = speciesList[i] if species.thermo: thermoLibrary.loadEntry(index = i + 1, label = species.label, molecule = species.molecule[0].toAdjacencyList(), thermo = species.thermo, shortDesc = species.thermo.comment ) else: logging.warning('Species {0} did not contain any thermo data and was omitted from the thermo library.'.format(str(species))) # load kinetics library entries kineticsLibrary = KineticsLibrary(name=name) kineticsLibrary.entries = {} for i in range(len(reactionList)): reaction = reactionList[i] entry = Entry( index = i+1, label = str(reaction), item = reaction, data = reaction.kinetics,