def load_thermo_lib_by_path(path: str, thermo_db: ThermoDatabase, reload: bool = False): """ Load thermo library given its library path and store it into the given RMG ThermoDatabase instance Args: path (str): Path to thermo library file thermo_database (ThermoDatabase): RMG thermo database object reload (bool): Whether to reload the library if this library is in the ThermoDatabase """ lib = ThermoLibrary() try: lib.load(path, ThermoDatabase().local_context, ThermoDatabase().global_context) except FileNotFoundError: print(f'The library file {path} does not exist.') except (SyntaxError, ImportError): print(f'The library file {path} is not valid.') else: if path in thermo_db.library_order and not reload: print(f'The library {path} has already been loaded.') return elif path not in thermo_db.library_order: thermo_db.library_order.append(path) lib.label = path lib.name = path thermo_db.libraries[lib.label] = lib print(f'The thermodynamics library {path} is loaded.')
def load_thermo_lib_by_path(path: str, thermo_db: ThermoDatabase): """ Load thermo library given its path. This is really helpful when the library is not located in the RMG-database. Args: path (str): Path to thermo library file thermo_database (ThermoDatabase): RMG thermo database object """ if not os.path.exists(path): raise ValueError(f'The library file {path} does not exist.') if path not in thermo_db.library_order: lib = ThermoLibrary() try: lib.load(path, ThermoDatabase().local_context, ThermoDatabase().global_context) except: raise ValueError(f'The library file {path} is not vaild.') return else: lib.label = path thermo_db.libraries[lib.label] = lib thermo_db.library_order.append(lib.label) print(f'Loading thermo library {os.path.split(path)[1]} ' f'from {os.path.split(path)[0]} ...') else: print(f'The library {path} has already been loaded')
def read_thermo_lib_by_path(lib_path, thermo_db): """ Read thermo library given its library path Args: lib_path (str): Path to thermo library file thermo_database (ThermoDatabase): RMG thermo database object """ if not os.path.exists(lib_path): logging.error('The library file %s does not exist.' %(lib_path)) return if lib_path not in thermo_db.library_order: lib = ThermoLibrary() try: lib.load(lib_path, ThermoDatabase().local_context, ThermoDatabase().global_context) except: logging.error('The library file %s is not vaild.' % (lib_path)) return else: lib.label = lib_path thermo_db.libraries[lib.label] = lib thermo_db.library_order.append(lib.label) logging.info('Loading thermodynamics 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))