Ejemplo n.º 1
0
 def load_transport(self, path, transport_libraries=None):
     """
     Load the RMG transport database from the given 'path' on disk, where 
     'path' points to the top-level folder of the RMG transport database.
     """
     self.transport = TransportDatabase()
     self.transport.load(path, transport_libraries)
Ejemplo n.º 2
0
    def setUp(self):
        """
        a function run before each unit test in this class
        """
        self.libraries = ['GRI-Mech', 'PrimaryTransportLibrary']
        self.groups = ['ring', 'nonring']
        self.libraryOrder = []

        path = os.path.join(settings['database.directory'], 'transport')
        self.transportdb = TransportDatabase()
        self.transportdb.load(path, self.libraries)
Ejemplo n.º 3
0
 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.load_forbidden_structures(
         os.path.join(rmgweb.settings.DATABASE_PATH,
                      'forbiddenStructures.py'))
     self.timestamps = {}
Ejemplo n.º 4
0
    def setUpClass(self):
        """A function that is run ONCE before all unit tests in this class."""
        self.database = TransportDatabase()
        self.database.load(os.path.join(settings['database.directory'], 'transport'),
                           ['GRI-Mech', 'PrimaryTransportLibrary'])

        self.speciesList = [
            Species().from_smiles('C'),
            Species().from_smiles('CCCC'),
            Species().from_smiles('O'),
            Species().from_smiles('[CH3]'),
            Species().from_smiles('[OH]'),
            Species().from_smiles('c1ccccc1'),
        ]
Ejemplo n.º 5
0
 def load_old(self, path):
     """
     Load the old RMG database from the given `path` on disk, where `path`
     points to the top-level folder of the old RMG database.
     """
     self.thermo = ThermoDatabase()
     self.thermo.load_old(path)
     self.transport = TransportDatabase()
     # self.transport.load_old(path)   #  Currently no load_old import function available for transport groups
     self.forbidden_structures = ForbiddenStructures()
     self.forbidden_structures.load_old(os.path.join(path, 'ForbiddenStructures.txt'))
     self.kinetics = KineticsDatabase()
     self.kinetics.load_old(path)
     self.statmech = StatmechDatabase()
     self.statmech.load_old(path)
     self.solvation = SolvationDatabase()
def main(dictionary):

    database = TransportDatabase()
    database.load(path=os.path.join(settings['database.directory'],
                                    'transport'),
                  libraries=None)

    speciesDict = loadSpeciesDictionary(dictionary)

    path = 'tran.dat'

    with open(path, 'w') as f:
        f.write("! {0:15} {1:8} {2:9} {3:9} {4:9} {5:9} {6:9} {7:9}\n".format(
            'Species', 'Shape', 'LJ-depth', 'LJ-diam', 'DiplMom', 'Polzblty',
            'RotRelaxNum', 'Data'))
        f.write("! {0:15} {1:8} {2:9} {3:9} {4:9} {5:9} {6:9} {7:9}\n".format(
            'Name', 'Index', 'epsilon/k_B', 'sigma', 'mu', 'alpha', 'Zrot',
            'Source'))
        for label, spec in speciesDict.iteritems():
            transportDataList = database.getAllTransportProperties(spec)
            for transportData, _, _ in transportDataList:
                if (not transportData):
                    missingData = True
                else:
                    missingData = False

                if missingData:
                    f.write('! {0:19s} {1!r}\n'.format(label, transportData))
                else:
                    f.write(
                        '{0:19} {1:d}   {2:9.3f} {3:9.3f} {4:9.3f} {5:9.3f} {6:9.3f}    ! {7:s}\n'
                        .format(
                            label,
                            transportData.shapeIndex,
                            transportData.epsilon.value_si / constants.R,
                            transportData.sigma.value_si * 1e10,
                            (transportData.dipoleMoment.value_si *
                             constants.c *
                             1e21 if transportData.dipoleMoment else 0),
                            (transportData.polarizability.value_si *
                             1e30 if transportData.polarizability else 0),
                            (transportData.rotrelaxcollnum
                             if transportData.rotrelaxcollnum else 0),
                            transportData.comment,
                        ))
Ejemplo n.º 7
0
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'))
Ejemplo n.º 8
0
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.solvation = SolvationDatabase()
        database.thermo = ThermoDatabase()
        database.kinetics = KineticsDatabase()
        database.transport = TransportDatabase()
        database.statmech = StatmechDatabase()
        database.loadForbiddenStructures(
            os.path.join(rmgweb.settings.DATABASE_PATH,
                         'forbiddenStructures.py'))

    if component == 'initialize':
        return database
    if component in ['thermo', '']:
        if section in ['depository', '']:
            dirpath = os.path.join(rmgweb.settings.DATABASE_PATH, 'thermo',
                                   'depository')
            if isDirModified(dirpath):
                database.thermo.loadDepository(dirpath)
                resetDirTimestamps(dirpath)
        if section in ['libraries', '']:
            dirpath = os.path.join(rmgweb.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 favorite 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(rmgweb.settings.DATABASE_PATH, 'thermo',
                                   'groups')
            if isDirModified(dirpath):
                database.thermo.loadGroups(dirpath)
                resetDirTimestamps(dirpath)

    if component in ['transport', '']:
        if section in ['libraries', '']:
            dirpath = os.path.join(rmgweb.settings.DATABASE_PATH, 'transport',
                                   'libraries')
            if isDirModified(dirpath):
                database.transport.loadLibraries(dirpath)
                resetDirTimestamps(dirpath)
        if section in ['groups', '']:
            dirpath = os.path.join(rmgweb.settings.DATABASE_PATH, 'transport',
                                   'groups')
            if isDirModified(dirpath):
                database.transport.loadGroups(dirpath)
                resetDirTimestamps(dirpath)

    if component in ['solvation', '']:
        dirpath = os.path.join(rmgweb.settings.DATABASE_PATH, 'solvation')
        if isDirModified(dirpath):
            database.solvation.load(dirpath)
            resetDirTimestamps(dirpath)

    if component in ['kinetics', '']:
        if section in ['libraries', '']:
            dirpath = os.path.join(rmgweb.settings.DATABASE_PATH, 'kinetics',
                                   'libraries')
            if isDirModified(dirpath):
                database.kinetics.loadLibraries(dirpath)
                resetDirTimestamps(dirpath)
        if section in ['families', '']:
            dirpath = os.path.join(rmgweb.settings.DATABASE_PATH, 'kinetics',
                                   'families')
            if isDirModified(dirpath):
                database.kinetics.loadFamilies(dirpath,
                                               families='all',
                                               depositories='all')
                resetDirTimestamps(dirpath)

                # Make sure to load the entire thermo database prior to adding training values to the rules
                loadDatabase('thermo', '')
                for family in database.kinetics.families.values():
                    oldentries = len(family.rules.entries)
                    family.addKineticsRulesFromTrainingSet(
                        thermoDatabase=database.thermo)
                    newentries = len(family.rules.entries)
                    if newentries != oldentries:
                        print '{0} new entries added to {1} family after adding rules from training set.'.format(
                            newentries - oldentries, family.label)
                    # Filling in rate rules in kinetics families by averaging...
                    family.fillKineticsRulesByAveragingUp()

    if component in ['statmech', '']:
        dirpath = os.path.join(rmgweb.settings.DATABASE_PATH, 'statmech')
        if isDirModified(dirpath):
            database.statmech.load(dirpath)
            resetDirTimestamps(dirpath)

    return database