def testGetRingGroupsFromComments(self): """ Test that getRingGroupsFromComments method works for fused polycyclics. """ from rmgpy.thermo.thermoengine import generateThermoData # set-up RMG object rmg = RMG() # load kinetic database and forbidden structures rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) # forbidden structure loading rmg.database.loadThermo(os.path.join(path, 'thermo')) smi = 'C12C(C3CCC2C3)C4CCC1C4' #two norbornane rings fused together spc = Species().fromSMILES(smi) spc.thermo = generateThermoData(spc) thermodb = rmg.database.thermo thermodb.getRingGroupsFromComments(spc.thermo) import rmgpy.data.rmg rmgpy.data.rmg.database = None
def testGetRingGroupsFromComments(self): """ Test that getRingGroupsFromComments method works for fused polycyclics. """ from rmgpy.thermo.thermoengine import generateThermoData # set-up RMG object rmg = RMG() # load kinetic database and forbidden structures rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) # forbidden structure loading rmg.database.loadThermo(os.path.join(path, 'thermo')) smi = 'C12C(C3CCC2C3)C4CCC1C4'#two norbornane rings fused together spc = Species().fromSMILES(smi) spc.thermo = generateThermoData(spc) thermodb = rmg.database.thermo thermodb.getRingGroupsFromComments(spc.thermo) import rmgpy.data.rmg rmgpy.data.rmg.database = None
def run_thermo_estimator(input_file, library_flag): """ Estimate thermo for a list of species using RMG and the settings chosen inside a thermo input file. """ rmg = RMG() rmg.load_thermo_input(input_file) rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) # forbidden structure loading rmg.database.load_thermo(os.path.join(path, 'thermo'), rmg.thermo_libraries, depository=False) if rmg.solvent: rmg.database.load_solvation(os.path.join(path, 'solvation')) Species.solvent_data = rmg.database.solvation.get_solvent_data( rmg.solvent) Species.solvent_name = rmg.solvent for species in rmg.initial_species: submit(species) if library_flag: library = ThermoLibrary(name='Thermo Estimation Library') for species in rmg.initial_species: library.load_entry( index=len(library.entries) + 1, label=species.label, molecule=species.molecule[0].to_adjacency_list(), thermo=species.get_thermo_data().to_thermo_data(), shortDesc=species.get_thermo_data().comment, ) library.save(os.path.join(rmg.output_directory, 'ThermoLibrary.py')) # Save the thermo data to chemkin format output files and dictionary, with no reactions save_chemkin_file(os.path.join(rmg.output_directory, 'chem_annotated.inp'), species=rmg.initial_species, reactions=[]) save_species_dictionary(os.path.join(rmg.output_directory, 'species_dictionary.txt'), species=rmg.initial_species)
def load(): """ A method that is run before each unit test in this class. """ tearDown() # set-up RMG object rmg = RMG() # load kinetic database and forbidden structures rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) # forbidden structure loading rmg.database.loadForbiddenStructures(os.path.join(path, 'forbiddenStructures.py')) # kinetics family loading rmg.database.loadKinetics(os.path.join(path, 'kinetics'), kineticsFamilies=[TESTFAMILY], reactionLibraries=[] )
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 for species in rmg.initialSpecies: submit(species) # library = ThermoLibrary(name='Thermo Estimation Library') # for spc 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'))
def setUpClass(cls): """ A method that is run before each unit test in this class. """ test_family = 'H_Abstraction' # set-up RMG object rmg = RMG() # load kinetic database and forbidden structures rmg.database = RMGDatabase() path = os.path.join(settings['test_data.directory'], 'testing_database') # kinetics family loading rmg.database.load_kinetics(os.path.join(path, 'kinetics'), kinetics_families=[test_family], reaction_libraries=[]) # load empty forbidden structures to avoid any dependence on forbidden structures # for these tests for family in rmg.database.kinetics.families.values(): family.forbidden = ForbiddenStructures() rmg.database.forbidden_structures = ForbiddenStructures()
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 for species in rmg.initialSpecies: submit(species) # library = ThermoLibrary(name='Thermo Estimation Library') # for spc 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 setUpClass(cls): """ A method that is run before each unit test in this class. """ TESTFAMILY = 'H_Abstraction' # set-up RMG object rmg = RMG() # load kinetic database and forbidden structures rmg.database = RMGDatabase() path=os.path.join(settings['test_data.directory'], 'testing_database') # kinetics family loading rmg.database.loadKinetics(os.path.join(path, 'kinetics'), kineticsFamilies=[TESTFAMILY], reactionLibraries=[] ) #load empty forbidden structures to avoid any dependence on forbidden structures #for these tests for family in rmg.database.kinetics.families.values(): family.forbidden = ForbiddenStructures() rmg.database.forbiddenStructures = ForbiddenStructures()
import os from rmgpy.molecule.molecule import Molecule from rmgpy.rmg.model import Species from rmgpy.rmg.model import CoreEdgeReactionModel from rmgpy.rmg.main import RMG from rmgpy import settings from rmgpy.data.rmg import RMGDatabase rmg = RMG() rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) rmg.database.loadThermo(os.path.join(path,'thermo')) mol = Molecule().fromSMILES('C1=CC=CC=C1') tdt = rmg.database.thermo.estimateThermoViaGroupAdditivity(mol) print tdt.comment print mol.isAromatic() spc = Species().fromSMILES('C1=CC=CC=C1') tdt = rmg.database.thermo.getThermoDataFromGroups(spc) print tdt.comment print '\n' rmg.reactionModel = CoreEdgeReactionModel() spc, isNew = rmg.reactionModel.makeNewSpecies(mol) rmg.reactionModel.addSpeciesToEdge(spc) rmg.initialSpecies = [] rmg.initialSpecies.append(spc) for species in rmg.initialSpecies: #species.generateThermoData(rmg.database, quantumMechanics=rmg.reactionModel.quantumMechanics) #print species.thermo.comment tdt = rmg.database.thermo.getThermoDataFromGroups(spc)
import os import csv from rmgpy.molecule.molecule import Molecule from rmgpy.rmg.model import Species from rmgpy.rmg.model import CoreEdgeReactionModel from rmgpy.rmg.main import RMG from rmgpy import settings from rmgpy.data.rmg import RMGDatabase rmg = RMG() rmg.database = RMGDatabase() path = os.path.join(settings['database.directory']) rmg.database.loadThermo(os.path.join(path,'thermo')) rmg.reactionModel = CoreEdgeReactionModel() rmg.initialSpecies = [] delimiter = '\t' JtoCal = 1.0/4.184 fw = open('output_thermo.txt','w') fw.write('Name\tSMILES\tH298\tS298\t300 K\t400 K\t500 K\t600 K\t800 K\t1000 K\t1500 K\tComment\n') count = 0 spc_name = [] spc_smi = [] reader = csv.reader(open('TestSet.csv', 'r')) for row in reader: k, v = row mol = Molecule().fromSMILES(v) spc, isNew = rmg.reactionModel.makeNewSpecies(mol) # rmg.reactionModel.addSpeciesToEdge(spc)