def read_kinetic_lib_from_path(lib_path, kinetic_db, overwrite=False, create=False): """ Read RMG kinetic library given its file path. The species dictionary should be included under the same directory. Args: lib_path (str): Path to thermo library file kinetic_db (RMG KineticsDatabase): RMG database object """ if not os.path.exists(lib_path) and create: create_kinetic_lib(os.path.dirname(lib_path)) lib = KineticsLibrary() kinetic_db.libraries[lib_path] = lib kinetic_db.library_order.append(lib_path) logging.info( 'Created kinetics library {1} at {0} ...'.format( os.path.split(lib_path)[0], os.path.split(lib_path)[1]), ) elif lib_path not in kinetic_db.library_order or overwrite: lib = KineticsLibrary() try: lib.load(lib_path, KineticsDatabase().local_context, KineticsDatabase().global_context) except: logging.error('The library file %s is not vaild.' % (lib_path)) else: lib.label = lib_path kinetic_db.libraries[lib.label] = lib kinetic_db.library_order.append(lib.label) logging.info( 'Loading kinetics library {1} from {0} ...'.format( os.path.split(lib_path)[0], os.path.split(lib_path)[1]), ) else: logging.warning('The library %s has already been loaded' % (lib_path))