当前位置: 首页>>代码示例>>Python>>正文


Python rmg.RMGDatabase类代码示例

本文整理汇总了Python中rmgpy.data.rmg.RMGDatabase的典型用法代码示例。如果您正苦于以下问题:Python RMGDatabase类的具体用法?Python RMGDatabase怎么用?Python RMGDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RMGDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUpModule

def setUpModule():
    """A function that is run ONCE before all unit tests in this module."""
    global database
    database = RMGDatabase()
    database.load(
        path=os.path.join(settings['test_data.directory'], 'testing_database'),
        thermoLibraries=['primaryThermoLibrary'],
        reactionLibraries=['GRI-Mech3.0'],
        kineticsFamilies=[
            'R_Recombination',
            'Disproportionation',
            'R_Addition_MultipleBond',
            'H_Abstraction',
            'intra_H_migration',
        ],
        testing=True,
        depository=False,
        solvation=False,
    )
    #load empty forbidden structures to avoid any dependence on forbidden structures
    #for these tests
    for family in database.kinetics.families.values():
        family.forbidden = ForbiddenStructures()
    database.forbiddenStructures = ForbiddenStructures()

    # Prepare the database by loading training reactions and averaging the rate rules
    for family in database.kinetics.families.values():
        family.addKineticsRulesFromTrainingSet(thermoDatabase=database.thermo)
        family.fillKineticsRulesByAveragingUp(verbose=True)
开发者ID:ReactionMechanismGenerator,项目名称:RMG-Py,代码行数:29,代码来源:kineticsTest.py

示例2: export

def export(input, output, database=None):

    print 'Loading the new RMG-Py database...'
    if not database:
        database = RMGDatabase()
    database.load(input)

    print 'Constructing additional rate rules from kinetics depository...'
    for family in database.kinetics.families.values():
        generateRules(family, database)

    print 'Saving old RMG-Java database...'
    database.saveOld(output)
开发者ID:eWizardII,项目名称:RMG-database,代码行数:13,代码来源:exportOldDatabase.py

示例3: convertPrIMe

def convertPrIMe(family):

    print 'Loading kinetics families...'
    database = RMGDatabase()
    database.kinetics = KineticsDatabase()
    database.kinetics.loadFamilies('input/kinetics/families')
    database.loadForbiddenStructures('input/forbiddenStructures.py')
    
    for depository in database.kinetics.families[family].depositories:
        if depository.label == '{0}/PrIMe'.format(family):
            break
    else:
        raise Exception('Could not find PrIMe depository in {0} family.'.format(family))
    
    entries = []
    
    print 'Determining unique list of reactions...'
    for entry0 in depository.entries.values():
        for entry in entries:
            if entry.item.isIsomorphic(entry0.item):
                break
        else:
            entries.append(entry0)
    print 'Found {0:d} unique reactions out of {1:d} entries.'.format(len(entries), len(depository.entries))
    
    print 'Sorting unique reactions...'
    entries.sort(key=lambda entry: sum([1 for r in entry.item.reactants for a in r.atoms if a.isNonHydrogen()]))
    
    print 'Saving reactions...'
    for index, entry in enumerate(entries):
        
        label = entry.label
        reaction = entry.item
        
        # Determine degeneracy in both directions
        reactions = database.kinetics.generateReactionsFromFamilies(reaction.reactants, reaction.products, only_families=[family])
        if len(reactions) != 1:
            print 'Warning: could not determine forward degeneracy for reaction #{0:d}.'.format(index+1)
            forwardDegeneracy = 1
        else:
            forwardDegeneracy = reactions[0].degeneracy
        reactions = database.kinetics.generateReactionsFromFamilies(reaction.products, reaction.reactants, only_families=[family])
        if len(reactions) != 1:
            print 'Warning: could not determine reverse degeneracy for reaction #{0:d}.'.format(index+1)
            reverseDegeneracy = 1
        else:
            reverseDegeneracy = reactions[0].degeneracy
        
        saveReaction('input/kinetics/families/{0}/training/{0}.py'.format(family, index+1), index+1, label, reaction, forwardDegeneracy, reverseDegeneracy)
开发者ID:ajalan,项目名称:RMG-database,代码行数:49,代码来源:convertPrIMe.py

示例4: loadDatabase

 def loadDatabase(self, kineticsFamilies='all',kineticsDepositories=None,thermoLibraries=None, reactionLibraries=None):
     """
     This function loads a single copy of the RMGDatabase with full verbose averaging
     of the rate rule to trace kinetics sources.  
     
     By default, this function loads all the kinetics families, only the training kinetics depository,
     the primaryThermoLibrary, and no reaction libraries.  
     """
     from rmgpy.data.rmg import RMGDatabase 
     from rmgpy import settings
     
     if not kineticsDepositories:
         kineticsDepositories = ['training']
     if not thermoLibraries:
         thermoLibraries = ['primaryThermoLibrary']
     if not reactionLibraries:
         reactionLibraries = []
         
         
     self.database = RMGDatabase()
     self.database.load(settings['database.directory'], 
                       kineticsFamilies=kineticsFamilies, 
                       kineticsDepositories=kineticsDepositories,
                       thermoLibraries=thermoLibraries,
                       reactionLibraries=reactionLibraries,
                       )
     
 
     # Prepare the database by loading training reactions but not averaging the rate rules
     for familyLabel, family in self.database.kinetics.families.iteritems():
         family.addKineticsRulesFromTrainingSet(thermoDatabase=self.database.thermo)
     
         family.fillKineticsRulesByAveragingUp(verbose=True)
开发者ID:ReactionMechanismGenerator,项目名称:RMG-Py,代码行数:33,代码来源:uncertainty.py

示例5: export

def export(input, output, database=None):

    print 'Loading the new RMG-Py database...'
    if not database:
        database = RMGDatabase()
    database.load(input, kineticsFamilies='all', kineticsDepositories='all')

    print 'Constructing additional rate rules from kinetics depository...'    
    for family in database.kinetics.families.values():
        family.addKineticsRulesFromTrainingSet(thermoDatabase=database.thermo)

    print "Deleting thermo library entries with atoms RMG-Java can't understand..."
    database.thermo.pruneHeteroatoms(allowed=['C','H','O','S'])
    print 'Saving old RMG-Java database...'
    database.saveOld(output)
    print "Done!"
开发者ID:Lyle-zhang,项目名称:RMG-database,代码行数:16,代码来源:exportOldDatabase.py

示例6: loadDatabase

def loadDatabase(component='', section=''):
    """
    Load the requested `component` of the RMG database if modified since last loaded.
    """
    global database
    if not database:
        database = RMGDatabase()
        database.thermo = ThermoDatabase()
        database.kinetics = KineticsDatabase()
        database.loadForbiddenStructures(os.path.join(settings.DATABASE_PATH, 'forbiddenStructures.py'))

    if component in ['thermo', '']:
        if section in ['depository', '']:
            dirpath = os.path.join(settings.DATABASE_PATH, 'thermo', 'depository')
            if isDirModified(dirpath):
                database.thermo.loadDepository(dirpath)
                resetDirTimestamps(dirpath)
        if section in ['libraries', '']:
            dirpath = os.path.join(settings.DATABASE_PATH, 'thermo', 'libraries')
            if isDirModified(dirpath):
                database.thermo.loadLibraries(dirpath)
                # put them in our preferred order, so that when we look up thermo in order to estimate kinetics,
                # we use our favourite values first.
                preferred_order = ['primaryThermoLibrary','DFT_QCI_thermo','GRI-Mech3.0','CBS_QB3_1dHR','KlippensteinH2O2']
                new_order = [i for i in preferred_order if i in database.thermo.libraryOrder]
                for i in database.thermo.libraryOrder:
                    if i not in new_order: new_order.append(i) 
                database.thermo.libraryOrder = new_order
                resetDirTimestamps(dirpath)
        if section in ['groups', '']:
            dirpath = os.path.join(settings.DATABASE_PATH, 'thermo', 'groups')
            if isDirModified(dirpath):
                database.thermo.loadGroups(dirpath)
                resetDirTimestamps(dirpath)
    if component in ['kinetics', '']:
        if section in ['libraries', '']:
            dirpath = os.path.join(settings.DATABASE_PATH, 'kinetics', 'libraries')
            if isDirModified(dirpath):
                database.kinetics.loadLibraries(dirpath)
                resetDirTimestamps(dirpath)
        if section in ['families', '']:
            dirpath = os.path.join(settings.DATABASE_PATH, 'kinetics', 'families')
            if isDirModified(dirpath):
                database.kinetics.loadFamilies(dirpath)
                resetDirTimestamps(dirpath)

    return database
开发者ID:alaraen,项目名称:RMG-website,代码行数:47,代码来源:tools.py

示例7: load

def load():
    tearDown()
    rmg = RMG()#for solvent
    database = RMGDatabase()
    database.loadThermo(os.path.join(settings['database.directory'], 'thermo'))
    database.loadTransport(os.path.join(settings['database.directory'], 'transport'))
    database.loadSolvation(os.path.join(settings['database.directory'], 'solvation'))
开发者ID:PengZhang13,项目名称:RMG-Py,代码行数:7,代码来源:thermoengineTest.py

示例8: __init__

 def __init__(self):
     self.database = RMGDatabase()
     self.database.kinetics = KineticsDatabase()
     self.database.thermo = ThermoDatabase()
     self.database.transport = TransportDatabase()
     self.database.statmech = StatmechDatabase()
     self.database.solvation = SolvationDatabase()
     self.database.loadForbiddenStructures(os.path.join(rmgweb.settings.DATABASE_PATH, 'forbiddenStructures.py'))
     self.timestamps = {}
开发者ID:ReactionMechanismGenerator,项目名称:RMG-website,代码行数:9,代码来源:tools.py

示例9: setUpModule

def setUpModule():
    """A function that is run ONCE before all unit tests in this module."""
    global database
    database = RMGDatabase()
    database.load(
        path=os.path.join(settings['test_data.directory'], 'testing_database'),
        kineticsFamilies=[
            'H_Abstraction','intra_H_migration'
        ],
        testing=True,
        depository=False,
        solvation=False,
    )
    database.loadForbiddenStructures()

    # Prepare the database by loading training reactions and averaging the rate rules
    for family in database.kinetics.families.values():
        family.addKineticsRulesFromTrainingSet(thermoDatabase=database.thermo)
        family.fillKineticsRulesByAveragingUp(verbose=True)
开发者ID:ReactionMechanismGenerator,项目名称:RMG-Py,代码行数:19,代码来源:isotopesTest.py

示例10: loadNecessaryDatabases

def loadNecessaryDatabases():
    """
    loads transport and statmech databases
    """
    from rmgpy.data.statmech import StatmechDatabase
    from rmgpy.data.transport import TransportDatabase

    #only load if they are not there already.
    try:
        getDB('transport')
        getDB('statmech')
    except DatabaseError:
        logging.info("Databases not found. Making databases")
        db = RMGDatabase()
        db.statmech = StatmechDatabase()
        db.statmech.load(os.path.join(settings['database.directory'],'statmech'))

        db.transport = TransportDatabase()
        db.transport.load(os.path.join(settings['database.directory'],'transport'))
开发者ID:ReactionMechanismGenerator,项目名称:RMG-Py,代码行数:19,代码来源:input.py

示例11: loadDatabase

 def loadDatabase(self):
     
     self.database = RMGDatabase()
     self.database.load(
         path = self.databaseDirectory,
         thermoLibraries = self.thermoLibraries,
         reactionLibraries = [library for library, option in self.reactionLibraries],
         seedMechanisms = self.seedMechanisms,
         kineticsDepositories = self.kineticsDepositories,
         #frequenciesLibraries = self.statmechLibraries,
         depository = False, # Don't bother loading the depository information, as we don't use it
     )
开发者ID:ajalan,项目名称:RMG-Py,代码行数:12,代码来源:main.py

示例12: loadDatabase

 def loadDatabase(self):
     
     self.database = RMGDatabase()
     self.database.load(
         path = self.databaseDirectory,
         thermoLibraries = self.thermoLibraries,
         reactionLibraries = [library for library, option in self.reactionLibraries],
         seedMechanisms = self.seedMechanisms,
         kineticsFamilies = self.kineticsFamilies,
         kineticsDepositories = self.kineticsDepositories,
         #frequenciesLibraries = self.statmechLibraries,
         depository = False, # Don't bother loading the depository information, as we don't use it
     )
     if self.kineticsEstimator == 'rate rules':
         logging.info('Adding rate rules from training set in kinetics families...')
         for family in self.database.kinetics.families.values():
             family.addKineticsRulesFromTrainingSet(thermoDatabase=self.database.thermo)
         logging.info('Filling in rate rules in kinetics families by averaging...')
         for family in self.database.kinetics.families.values():
             family.fillKineticsRulesByAveragingUp()
开发者ID:jbarlow3,项目名称:RMG-Py,代码行数:20,代码来源:main.py

示例13: obtainKineticsFamilyStatistics

                # Save to csv file
                csvwriter.writerow([familyName, QDict[familyName]])
     
    return


if __name__ == '__main__':
    from rmgpy import settings
    
    # Create the data evaluation directory
    trialDir = os.path.join(settings['database.directory'],'..','testing','eval')
    if not os.path.exists(trialDir):
        os.makedirs(trialDir)
        
    print 'Loading the RMG database...'
    FullDatabase=RMGDatabase()
    FullDatabase.load(settings['database.directory'], 
                      kineticsFamilies='all', 
                      kineticsDepositories='all',
                      thermoLibraries=['primaryThermoLibrary'],   # Use just the primary thermo library, which contains necessary small molecular thermo
                      reactionLibraries=[],
                      )

    # Prepare the database by loading training reactions but not averaging the rate rules
    for family in FullDatabase.kinetics.families.values():
        family.addKineticsRulesFromTrainingSet(thermoDatabase=FullDatabase.thermo)
    
    print '--------------------------------------------'
    print 'Obtaining statistics for the families...'
    obtainKineticsFamilyStatistics(FullDatabase, trialDir)
    
开发者ID:ReactionMechanismGenerator,项目名称:RMG-database,代码行数:30,代码来源:evaluateKinetics.py

示例14: Generator


#.........这里部分代码省略.........
        self.reactionModel.kineticsEstimator = self.kineticsEstimator
        if self.pressureDependence:
            # If the output directory is not yet set, then set it to the same
            # directory as the input file by default
            if not self.outputDirectory:
                self.outputDirectory = os.path.dirname(path)
            self.pressureDependence.outputFile = self.outputDirectory
            self.reactionModel.pressureDependence = self.pressureDependence
        
    def checkInput(self):
        """
        Check for a few common mistakes in the input file.
        """
        if self.pressureDependence:
            for index, reactionSystem in enumerate(self.reactionSystems):
                assert (reactionSystem.T.value_si < self.pressureDependence.Tmax.value_si), "Reaction system T is above pressureDependence range."
                assert (reactionSystem.T.value_si > self.pressureDependence.Tmin.value_si), "Reaction system T is below pressureDependence range."
                assert (reactionSystem.P.value_si < self.pressureDependence.Pmax.value_si), "Reaction system P is above pressureDependence range."
                assert (reactionSystem.P.value_si > self.pressureDependence.Pmin.value_si), "Reaction system P is below pressureDependence range."
            assert any([not s.reactive for s in reactionSystem.initialMoleFractions.keys()]), \
                "Pressure Dependence calculations require at least one inert (nonreacting) species for the bath gas."

    def saveInput(self, path=None):
        """
        Save an RMG job to the input file located at `path`, or
        from the `outputFile` attribute if not given as a parameter.
        """
        from input import saveInputFile
        if path is None: path = self.outputFile
        saveInputFile(path, self)
        
    def loadDatabase(self):
        
        self.database = RMGDatabase()
        self.database.load(
            path = self.databaseDirectory,
            thermoLibraries = self.thermoLibraries,
            reactionLibraries = [library for library, option in self.reactionLibraries],
            seedMechanisms = self.seedMechanisms,
            kineticsFamilies = self.kineticsFamilies,
            kineticsDepositories = self.kineticsDepositories,
            #frequenciesLibraries = self.statmechLibraries,
            depository = False, # Don't bother loading the depository information, as we don't use it
        )
        if self.kineticsEstimator == 'rate rules':
            logging.info('Adding rate rules from training set in kinetics families...')
            for family in self.database.kinetics.families.values():
                family.addKineticsRulesFromTrainingSet(thermoDatabase=self.database.thermo)
            logging.info('Filling in rate rules in kinetics families by averaging...')
            for family in self.database.kinetics.families.values():
                family.fillKineticsRulesByAveragingUp()
    
    def initialize(self, args):
        """
        Initialize an RMG job using the command-line arguments `args` as returned
        by the :mod:`argparse` package.
        """
    
        # Save initialization time
        self.initializationTime = time.time()
    
        # Log start timestamp
        logging.info('RMG execution initiated at ' + time.asctime() + '\n')
    
        # Print out RMG header
        self.logHeader()
开发者ID:jbarlow3,项目名称:RMG-Py,代码行数:67,代码来源:main.py

示例15: RMGWebDatabase

class RMGWebDatabase(object):
    """Wrapper class for RMGDatabase that provides loading functionality."""

    def __init__(self):
        self.database = RMGDatabase()
        self.database.kinetics = KineticsDatabase()
        self.database.thermo = ThermoDatabase()
        self.database.transport = TransportDatabase()
        self.database.statmech = StatmechDatabase()
        self.database.solvation = SolvationDatabase()
        self.database.loadForbiddenStructures(os.path.join(rmgweb.settings.DATABASE_PATH, 'forbiddenStructures.py'))
        self.timestamps = {}

    @property
    def kinetics(self):
        """Get the kinetics database."""
        return self.database.kinetics

    @property
    def thermo(self):
        """Get the thermo database."""
        return self.database.thermo

    @property
    def transport(self):
        """Get the transport database."""
        return self.database.transport

    @property
    def statmech(self):
        """Get the statmech database."""
        return self.database.statmech

    @property
    def solvation(self):
        """Get the solvation database."""
        return self.database.solvation

    def reset_timestamp(self, path):
        """
        Reset the files timestamp in the dictionary of timestamps.
        """
        mtime = os.stat(path).st_mtime
        self.timestamps[path] = mtime

    def reset_dir_timestamps(self, dirpath):
        """
        Walk the directory tree from dirpath, calling reset_timestamp(file) on each file.
        """
        print "Resetting 'last loaded' timestamps for {0} in process {1}".format(dirpath, os.getpid())
        for root, dirs, files in os.walk(dirpath):
            for name in files:
                self.reset_timestamp(os.path.join(root, name))

    def is_file_modified(self, path):
        """
        Return True if the file at `path` has been modified since `reset_timestamp(path)` was last called.
        """
        # If path doesn't denote a file and were previously
        # tracking it, then it has been removed or the file type
        # has changed, so return True.
        if not os.path.isfile(path):
            return path in self.timestamps

        # If path wasn't being tracked then it's new, so return True
        elif path not in self.timestamps:
            return True

        # Force restart when modification time has changed, even
        # if time now older, as that could indicate older file
        # has been restored.
        elif os.stat(path).st_mtime != self.timestamps[path]:
            return True

        # All the checks have been passed, so the file was not modified
        else:
            return False

    def is_dir_modified(self, dirpath):
        """
        Returns True if anything in the directory at dirpath has been modified since reset_dir_timestamps(dirpath).
        """
        to_check = set([path for path in self.timestamps if path.startswith(dirpath)])
        for root, dirs, files in os.walk(dirpath):
            for name in files:
                path = os.path.join(root, name)
                if self.is_file_modified(path):
                    return True
                to_check.remove(path)
        # If there's anything left in to_check, it's probably now gone and this will return True:
        for path in to_check:
            if self.is_file_modified(path):
                return True
        # Passed all tests.
        return False

    ################################################################################

    def load(self, component='', section=''):
        """
#.........这里部分代码省略.........
开发者ID:ReactionMechanismGenerator,项目名称:RMG-website,代码行数:101,代码来源:tools.py


注:本文中的rmgpy.data.rmg.RMGDatabase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。