def reagent_energies(rgt, rxn_info, sp_thy_info, geo_thy_info, save_prefix): """ reagent energies """ assert rgt in ('reacs', 'prods') enes = [] for rgt_info in rinfo.rgts_info(rxn_info, rgt): # Set filesys spc_save_fs = autofile.fs.species(save_prefix) spc_save_path = spc_save_fs[-1].path(rgt_info) mod_geo_thy_info = tinfo.modify_orb_label(geo_thy_info, rgt_info) mod_sp_thy_info = tinfo.modify_orb_label(sp_thy_info, rgt_info) thy_save_fs = autofile.fs.theory(spc_save_path) thy_save_path = thy_save_fs[-1].path(mod_geo_thy_info[1:4]) cnf_save_fs = autofile.fs.conformer(thy_save_path) min_locs, min_path = filesys.min_energy_conformer_locators( cnf_save_fs, mod_geo_thy_info) # Read energy ene = None if min_locs: # Create run fs if that directory has been deleted to run the jobs sp_fs = autofile.fs.single_point(min_path) if sp_fs[-1].file.energy.exists(mod_sp_thy_info[1:4]): ene = sp_fs[-1].file.energy.read(mod_sp_thy_info[1:4]) enes.append(ene) if any(ene is None for ene in enes): enes = None return enes
def rpath_ref_idx(ts_dct, scn_vals, coord_name, scn_prefix, ene_info1, ene_info2): """ Get the reference energy along a reaction path """ # Set up the filesystem zma_fs = autofile.fs.zmatrix(scn_prefix) zma_path = zma_fs[-1].path([0]) scn_fs = autofile.fs.scan(zma_path) ene_info1 = ene_info1[1][0][1] ene_info2 = ene_info2[0] ioprinter.debug_message('mod_eneinf1', ene_info1) ioprinter.debug_message('mod_eneinf2', ene_info2) mod_ene_info1 = tinfo.modify_orb_label(sinfo.from_dct(ts_dct), ene_info1) mod_ene_info2 = tinfo.modify_orb_label(sinfo.from_dct(ts_dct), ene_info2) ene1, ene2, ref_val = None, None, None for val in reversed(scn_vals): locs = [[coord_name], [val]] path = scn_fs[-1].path(locs) hs_fs = autofile.fs.high_spin(path) if hs_fs[-1].file.energy.exists(mod_ene_info1[1:4]): ene1 = hs_fs[-1].file.energy.read(mod_ene_info1[1:4]) if hs_fs[-1].file.energy.exists(mod_ene_info2[1:4]): ene2 = hs_fs[-1].file.energy.read(mod_ene_info2[1:4]) if ene1 is not None and ene2 is not None: ref_val = val break if ref_val is not None: scn_idx = scn_vals.index(ref_val) return scn_idx, ene1, ene2
def geom_init(spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ Execute the task for a species used to seed the filesystem with a reliable initial conformer. :param spc_dct: :type spc_dct: :param spc_name: name of species :type spc_name: str :param thy_dct: :type thy_dct: :param es_keyword_dct: keyword-val pairs for electronic structure task :type es_keyword_dct: dict[str:str] :param run_prefix: root-path to the run-filesystem :type run_prefix: str :param save_prefix: root-path to the save-filesystem :type save_prefix: str """ spc_dct_i = spc_dct[spc_name] spc_info = sinfo.from_dct(spc_dct_i) # Get the theory info method_dct = thy_dct.get(es_keyword_dct['runlvl']) ini_method_dct = thy_dct.get(es_keyword_dct['inplvl']) thy_info = tinfo.from_dct(method_dct) ini_thy_info = tinfo.from_dct(ini_method_dct) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, spc_info) # Set the filesystem objects _, ini_cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', spc_locs=spc_info, thy_locs=mod_ini_thy_info[1:]) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', spc_locs=spc_info, thy_locs=mod_thy_info[1:]) # Get a reference geometry if one not found success = conformer.initial_conformer(spc_dct_i, spc_info, ini_method_dct, method_dct, ini_cnf_save_fs, cnf_run_fs, cnf_save_fs, es_keyword_dct) return success
def geom_init(spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ Find the initial geometry """ spc_dct_i = spc_dct[spc_name] spc_info = sinfo.from_dct(spc_dct_i) # Get the theory info method_dct = thy_dct.get(es_keyword_dct['runlvl']) ini_method_dct = thy_dct.get(es_keyword_dct['inplvl']) thy_info = tinfo.from_dct(method_dct) ini_thy_info = tinfo.from_dct(ini_method_dct) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, spc_info) # Set the filesystem objects _, ini_cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', spc_locs=spc_info, thy_locs=mod_ini_thy_info[1:]) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', spc_locs=spc_info, thy_locs=mod_thy_info[1:]) # _, ini_cnf_save_fs = build_fs( # run_prefix, save_prefix, 'CONFORMER', # spc_locs=spc_info, thy_locs=mod_ini_thy_info[1:]) # cnf_run_fs, cnf_save_fs = build_fs( # run_prefix, save_prefix, 'CONFORMER', # spc_locs=spc_info, thy_locs=mod_thy_info[1:]) _, instab_save_fs = build_fs(run_prefix, save_prefix, 'INSTAB', spc_locs=spc_info, thy_locs=mod_thy_info[1:]) # Get a reference geometry if one not found success = conformer.initial_conformer(spc_dct_i, spc_info, ini_method_dct, method_dct, ini_cnf_save_fs, cnf_run_fs, cnf_save_fs, instab_save_fs, es_keyword_dct) return success
def set_rpath_filesys(ts_dct, level): """ Gets filesystem objects for reading many calculations """ # Set the spc_info spc_info = sinfo.from_dct(ts_dct) # Set some path stuff save_path = ts_dct['rxn_fs'][3] run_path = ts_dct['rxn_fs'][2] # Set theory filesystem used throughout thy_save_fs = autofile.fs.theory(save_path) thy_run_fs = autofile.fs.theory(run_path) levelp = tinfo.modify_orb_label(level[1], spc_info) # Get the save fileystem path save_path = thy_save_fs[-1].path(levelp[1:4]) run_path = thy_run_fs[-1].path(levelp[1:4]) thy_save_fs[-1].create(levelp[1:4]) thy_run_fs[-1].create(levelp[1:4]) thy_save_path = thy_save_fs[-1].path(levelp[1:4]) thy_run_path = thy_run_fs[-1].path(levelp[1:4]) ts_save_fs = autofile.fs.transition_state(thy_save_path) ts_save_fs[0].create() ts_save_path = ts_save_fs[0].path() ts_run_fs = autofile.fs.transition_state(thy_run_path) ts_run_fs[0].create() ts_run_path = ts_run_fs[0].path() return ts_run_path, ts_save_path, thy_run_path, thy_save_path
def rcts_cnf_fs(rct_infos, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ set reactant filesystem stuff """ ini_method_dct = thy_dct.get(es_keyword_dct['inplvl']) ini_thy_info = tinfo.from_dct(ini_method_dct) rct_cnf_fs = () for rct_info in rct_infos: mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, rct_info) # Build filesys for ini thy info ini_cnf_run_fs, ini_cnf_save_fs = build_fs( run_prefix, save_prefix, 'CONFORMER', spc_locs=rct_info, thy_locs=mod_ini_thy_info[1:]) ini_loc_info = min_energy_conformer_locators(ini_cnf_save_fs, mod_ini_thy_info) ini_min_cnf_locs, ini_min_cnf_path = ini_loc_info # Create run fs if that directory has been deleted to run the jobs ini_cnf_run_fs[-1].create(ini_min_cnf_locs) rct_cnf_fs += ((ini_cnf_run_fs, ini_cnf_save_fs, ini_min_cnf_locs, ini_min_cnf_path), ) return rct_cnf_fs
def conformer_list_from_models(spc_name, thy_dct, print_keyword_dct, save_prefix, run_prefix, spc_dct_i, spc_mod_dct_i): """ Create a list of conformers based on the species name and model.dat info """ # conformer range cnf_range = _set_conf_range(print_keyword_dct) hbond_cutoffs = spc_dct_i['hbond_cutoffs'] # thy_info build thy_info = spc_mod_dct_i['vib']['geolvl'][1][1] spc_info = sinfo.from_dct(spc_dct_i) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) sort_info_lst = _set_sort_info_lst(print_keyword_dct['sort'], thy_dct, spc_info) zrxn = spc_dct_i.get('zrxn', None) _root = filesys.root_locs(spc_dct_i, name=spc_name, saddle=(zrxn is not None)) _, cnf_save_fs = filesys.build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_thy_info[1:], **_root) rng_cnf_locs_lst, rng_cnf_locs_path = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range=cnf_range, sort_info_lst=sort_info_lst, hbond_cutoffs=hbond_cutoffs, print_enes=True) return cnf_save_fs, rng_cnf_locs_lst, rng_cnf_locs_path, mod_thy_info
def instability_transformation(spc_dct, spc_name, thy_info, save_prefix, zma_locs=(0, )): """ see if a species and unstable and handle task management """ spc_info = sinfo.from_dct(spc_dct[spc_name]) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) _, cnf_save_fs = build_fs('', save_prefix, 'CONFORMER', spc_locs=spc_info, thy_locs=mod_thy_info[1:]) # Check if any locs exist first? ini_loc_info = min_energy_conformer_locators(cnf_save_fs, mod_thy_info) _, min_cnf_path = ini_loc_info zma_save_fs = autofile.fs.zmatrix(min_cnf_path) # Check if the instability files exist if zma_save_fs[-1].file.instability.exists(zma_locs): instab_trans = zma_save_fs[-1].file.instability.read(zma_locs) zma = zma_save_fs[-1].file.zmatrix.read(zma_locs) _instab = (instab_trans, zma) path = zma_save_fs[-1].file.zmatrix.path(zma_locs) else: _instab = None path = None return _instab, path
def _set_sort_info_lst(sort_str, thy_dct, spc_info): """ Return the levels to sort conformers by if zpve or sp levels were assigned in input if we ask for zpe(lvl_wbs),sp(lvl_b2t),gibbs(700) out sort_info_lst will be [('gaussian', 'wb97xd', '6-31*', 'RU'), ('gaussian', 'b2plypd3', 'cc-pvtz', 'RU'), None, None, 700.] """ sort_lvls = [None, None, None, None, None] sort_typ_lst = ['freqs', 'sp', 'enthalpy', 'entropy', 'gibbs'] if sort_str is not None: for sort_param in sort_str.split(','): idx = None for typ_idx, typ_str in enumerate(sort_typ_lst): if typ_str in sort_param: lvl_key = sort_str.split(typ_str + '(')[1].split(')')[0] idx = typ_idx if idx is not None: if idx < 2: method_dct = thy_dct.get(lvl_key) if method_dct is None: ioprinter.warning_message( f'no {lvl_key} in theory.dat, ' f'not using {sort_typ_lst[idx]} in sorting') continue thy_info = tinfo.from_dct(method_dct) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) sort_lvls[idx] = mod_thy_info else: sort_lvls[idx] = float(lvl_key) return sort_lvls
def reactions(rxn_info, ini_thy_info, zma_locs, save_prefix): """ Check if reaction exists in the filesystem and has been identified """ zrxns, zmas = (), () sort_rxn_info = rinfo.sort(rxn_info, scheme='autofile') ts_info = rinfo.ts_info(rxn_info) mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, ts_info) rxn_fs = autofile.fs.reaction(save_prefix) if rxn_fs[-1].exists(sort_rxn_info): _, ts_save_fs = build_fs(save_prefix, save_prefix, 'TRANSITION STATE', rxn_locs=sort_rxn_info, thy_locs=mod_ini_thy_info[1:]) for ts_locs in ts_save_fs[-1].existing(): zrxn, zma = reaction(rxn_info, ini_thy_info, zma_locs, save_prefix, ts_locs=ts_locs) if zrxn is not None: zrxns += (zrxn, ) zmas += (zma, ) if not zrxns: zrxns, zmas = None, None return zrxns, zmas
def _optimize_atom(spc_info, zma_init, method_dct, cnf_save_fs, locs, run_fs, overwrite): """ Deal with an atom separately """ thy_info = tinfo.from_dct(method_dct) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) script_str, kwargs = es_runner.qchem_params(method_dct, job=elstruct.Job.OPTIMIZATION) # Call the electronic structure optimizer success, ret = es_runner.execute_job(job=elstruct.Job.ENERGY, script_str=script_str, run_fs=run_fs, geo=zma_init, spc_info=spc_info, thy_info=mod_thy_info, overwrite=overwrite, **kwargs) if success: ioprinter.info_message('Succesful reference geometry optimization') filesys.save.atom(ret, cnf_save_fs, mod_thy_info[1:], zma_init, rng_locs=(locs[0], ), tors_locs=(locs[1], )) return success
def set_model_filesys(spc_dct_i, level, run_prefix, save_prefix, saddle, name=None, rings='all'): """ Gets filesystem objects for reading many calculations """ # Set the spc_info if saddle: rxn_info = spc_dct_i['rxn_info'] spc_info = rinfo.ts_info(rxn_info) else: spc_info = sinfo.from_dct(spc_dct_i) print('level', level) levelp = tinfo.modify_orb_label(level, spc_info) _root = root_locs(spc_dct_i, saddle=saddle, name=name) cnf_run_fs, cnf_save_fs = build_fs( run_prefix, save_prefix, 'CONFORMER', thy_locs=levelp[1:], **_root) if rings == 'min': min_rngs_locs, min_rngs_path = mincnf.min_energy_conformer_locators( cnf_save_fs, levelp) cnf_run_fs[-1].create(min_rngs_locs) else: min_rngs_locs, min_rngs_path = mincnf.conformer_locators( cnf_save_fs, levelp, cnf_range='r100') for min_locs in min_rngs_locs: cnf_run_fs[-1].create(min_locs) print('model filesys', min_rngs_locs, min_rngs_path) # Create run fs if that directory has been deleted to run the jobs return [cnf_save_fs, min_rngs_path, min_rngs_locs, '', cnf_run_fs]
def remove_imag(geo, ini_ret, spc_info, method_dct, run_fs, kickoff_size=0.1, kickoff_backward=False, kickoff_mode=0, overwrite=False): """ if there is an imaginary frequency displace geometry along the imaginary mode and then reoptimize """ thy_info = tinfo.from_dct(method_dct) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) opt_script_str, opt_kwargs = qchem_params( method_dct, job=elstruct.Job.OPTIMIZATION) script_str, kwargs = qchem_params( method_dct) ioprinter.info_message( 'The initial geometries will be checked for imaginary frequencies') imag, norm_coords = _check_imaginary( spc_info, geo, mod_thy_info, run_fs, script_str, overwrite, **kwargs) # Make five attempts to remove imag mode if found chk_idx = 0 kick_ret = None while imag and chk_idx < 5: chk_idx += 1 ioprinter.info_message( 'Attempting kick off along mode, attempt {}...'.format(chk_idx)) geo, kick_ret = _kickoff_saddle( geo, norm_coords, spc_info, mod_thy_info, run_fs, opt_script_str, kickoff_size, kickoff_backward, kickoff_mode, opt_cart=True, **opt_kwargs) ioprinter.info_message( 'Removing faulty geometry from filesystem. Rerunning Hessian...') run_fs[-1].remove([elstruct.Job.HESSIAN]) ioprinter.info_message('Rerunning Hessian...') imag, norm_coords = _check_imaginary( spc_info, geo, mod_thy_info, run_fs, script_str, overwrite, **kwargs) # Update kickoff size kickoff_size *= 2.0 if kick_ret is None: ret = ini_ret else: ret = kick_ret return geo, ret
def _reac_sep_ene(rct_info, sp_thy_info, rcts_cnf_fs, run_prefix, overwrite, sp_script_str, **kwargs): """ Determine the sum of electronic energies of two reactants specified at the level of theory described in the theory info object. Will calculate the energy if it is not currently in the SAVE filesystem. """ # get the single reference energy for each of the reactant configurations spc_enes = [] for (run_fs, save_fs, mlocs, mpath), inf in zip(rcts_cnf_fs, rct_info): # Set the modified thy info mod_sp_thy_info = tinfo.modify_orb_label(sp_thy_info, inf) # Build filesys zma_fs = autofile.fs.zmatrix(mpath) # Read the geometry and set paths zma = zma_fs[-1].file.zmatrix.read([0]) geo = save_fs[-1].file.geometry.read(mlocs) # Build the single point filesys objects sp_save_fs = autofile.fs.single_point(mpath) # Calculate the save single point energy sp.run_energy(zma, geo, inf, mod_sp_thy_info, run_fs, save_fs, mlocs, run_prefix, sp_script_str, overwrite, **kwargs) exists = sp_save_fs[-1].file.energy.exists(mod_sp_thy_info[1:4]) if not exists: ioprinter.warning_message('No ene found') ene = None else: ene = sp_save_fs[-1].file.energy.read(mod_sp_thy_info[1:4]) # Append ene to list spc_enes.append(ene) # Analyze the energies in the list inf_ene = 0.0 for ene, inf in zip(spc_enes, rct_info): if ene is not None: inf_ene += ene else: ioprinter.error_message( 'Single reference energy job fails', f'for {inf}: ', 'Energy needed to evaluate infinite separation energy') inf_ene = None if inf_ene is not None: ioprinter.info_message(f'Reactant Energy [au]: {inf_ene}') return inf_ene
def set_model_filesys(spc_dct_i, level, run_prefix, save_prefix, saddle, name=None, cnf_range='min', spc_locs=None, nprocs=1): """ Gets filesystem objects for reading many calculations """ # Set the spc_info if saddle: rxn_info = spc_dct_i['rxn_info'] spc_info = rinfo.ts_info(rxn_info) else: spc_info = sinfo.from_dct(spc_dct_i) levelp = tinfo.modify_orb_label(level, spc_info) _root = root_locs(spc_dct_i, saddle=saddle, name=name) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=levelp[1:], **_root) hbond_cutoffs = spc_dct_i['hbond_cutoffs'] if cnf_range == 'specified': min_rngs_locs = spc_locs min_rngs_path = cnf_save_fs[-1].path(min_rngs_locs) cnf_run_fs[-1].create(min_rngs_locs) elif cnf_range == 'min': min_rngs_locs, min_rngs_path = min_energy_conformer_locators( cnf_save_fs, levelp, hbond_cutoffs=hbond_cutoffs) cnf_run_fs[-1].create(min_rngs_locs) else: min_rngs_locs_lst, min_rngs_path_lst = conformer_locators( cnf_save_fs, levelp, cnf_range=cnf_range, hbond_cutoffs=hbond_cutoffs, nprocs=nprocs) for min_locs in min_rngs_locs_lst: cnf_run_fs[-1].create(min_locs) min_rngs_locs = min_rngs_locs_lst[0] min_rngs_path = min_rngs_path_lst[0] ioprinter.warning_message('Only returning first location in this list') # Create run fs if that directory has been deleted to run the jobs return [cnf_save_fs, min_rngs_path, min_rngs_locs, '', cnf_run_fs]
def electronic_energy(spc_dct_i, pf_filesystems, spc_model_dct_i, conf=None): """ get high level energy at low level optimized geometry """ ioprinter.info_message('- Calculating electronic energy') # spc_dct_i = spc_dct[spc_name] rxn_info = spc_dct_i.get('rxn_info', None) if rxn_info is not None: spc_info = rinfo.ts_info(rxn_info) else: spc_info = sinfo.from_dct(spc_dct_i) # Get the harmonic filesys information if conf: cnf_path = conf[1] else: [_, cnf_path, _, _, _] = pf_filesystems['harm'] # Get the electronic energy levels ene_levels = tuple(val[1] for key, val in spc_model_dct_i['ene'].items() if 'lvl' in key) print('ene levels', ene_levels) # Read the energies from the filesystem e_elec = None if os.path.exists(cnf_path): e_elec = 0.0 # ioprinter.info_message('lvls', ene_levels) for (coeff, level) in ene_levels: # Build SP filesys mod_thy_info = tinfo.modify_orb_label(level, spc_info) sp_save_fs = autofile.fs.single_point(cnf_path) sp_save_fs[-1].create(mod_thy_info[1:4]) # Read the energy sp_path = sp_save_fs[-1].path(mod_thy_info[1:4]) if os.path.exists(sp_path): ioprinter.reading('Energy', sp_path) ene = sp_save_fs[-1].file.energy.read(mod_thy_info[1:4]) e_elec += (coeff * ene) else: ioprinter.warning_message('No energy at path') e_elec = None break else: ioprinter.warning_message('No conformer to calculate the energy') return e_elec
def _get_prop_fs(spc_model_dct_i, spc_dct_i, prop, sort_info_lst, run_prefix, save_prefix, saddle=False, name=None): """ Get filesystem info for a property in the spc model dct """ if saddle: rxn_info = spc_dct_i['rxn_info'] spc_info = rinfo.ts_info(rxn_info) else: spc_info = sinfo.from_dct(spc_dct_i) level = spc_model_dct_i[prop]['geolvl'][1][1] levelp = tinfo.modify_orb_label(level, spc_info) mod_info_lst = [] if sort_info_lst is not None: for info in sort_info_lst[:2]: if info is not None: mod_info_lst.append(tinfo.modify_orb_label(info, spc_info)) else: mod_info_lst.append(info) for info in sort_info_lst[2:]: mod_info_lst.append(info) _root = root_locs(spc_dct_i, saddle=saddle, name=name) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=levelp[1:], **_root) return cnf_run_fs, cnf_save_fs, levelp, mod_info_lst
def reaction(rxn_info, ini_thy_info, zma_locs, save_prefix, ts_locs=(0, ), hbond_cutoffs=None): """ Check if reaction exists in the filesystem and has been identified """ zrxn, zma = None, None sort_rxn_info = rinfo.sort(rxn_info, scheme='autofile') ts_info = rinfo.ts_info(rxn_info) mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, ts_info) rxn_fs = autofile.fs.reaction(save_prefix) if rxn_fs[-1].exists(sort_rxn_info): _, cnf_save_fs = build_fs(save_prefix, save_prefix, 'CONFORMER', rxn_locs=sort_rxn_info, thy_locs=mod_ini_thy_info[1:], ts_locs=ts_locs) _, ini_min_cnf_path = min_energy_conformer_locators( cnf_save_fs, mod_ini_thy_info, hbond_cutoffs=hbond_cutoffs) if ini_min_cnf_path: zma_fs = autofile.fs.zmatrix(ini_min_cnf_path) if zma_fs[-1].file.reaction.exists(zma_locs): zrxn = zma_fs[-1].file.reaction.read(zma_locs) zma = zma_fs[-1].file.zmatrix.read(zma_locs) # For barrierless reactions with no conformer if zrxn is None: _, zma_fs = build_fs(save_prefix, save_prefix, 'ZMATRIX', rxn_locs=sort_rxn_info, ts_locs=ts_locs, thy_locs=mod_ini_thy_info[1:]) if zma_fs[-1].file.reaction.exists(zma_locs): zrxn = zma_fs[-1].file.reaction.read(zma_locs) zma = zma_fs[-1].file.zmatrix.read(zma_locs) return zrxn, zma
def build_rotors(spc_dct_i, pf_filesystems, spc_mod_dct_i, read_potentials=True): """ Add more rotor info """ run_prefix = pf_filesystems['run_prefix'] spc_info = sinfo.from_dct(spc_dct_i) spc_fml = automol.inchi.formula_string(spc_info[0]) if spc_fml is None: spc_fml = 'TS' run_path = job_path(run_prefix, 'PROJROT', 'FREQ', spc_fml, locs_idx=None) # Set up tors level filesystem and model and level tors_model = spc_mod_dct_i['tors']['mod'] tors_ene_info = spc_mod_dct_i['tors']['enelvl'][1][1] mod_tors_ene_info = tinfo.modify_orb_label( tors_ene_info, sinfo.from_dct(spc_dct_i)) rotors = None if pf_filesystems['tors'] is not None: [cnf_fs, cnf_save_path, min_cnf_locs, _, _] = pf_filesystems['tors'] # Build the rotors ref_ene = filesys.read.energy(cnf_fs, min_cnf_locs, mod_tors_ene_info) zma_fs = fs.zmatrix(cnf_fs[-1].path(min_cnf_locs)) if ( zma_fs[-1].file.torsions.exists([0]) and zma_fs[-1].file.zmatrix.exists([0]) and tors_model != 'rigid' ): rotors = automol.rotor.from_data( zma=zma_fs[-1].file.zmatrix.read([0]), tors_inf_dct=zma_fs[-1].file.torsions.read([0]), tors_names=spc_dct_i.get('tors_names', None), multi=bool('1d' in tors_model)) # Read the potential grids if read_potentials and rotors is not None: rotors = _read_potentials( rotors, spc_dct_i, run_path, cnf_save_path, ref_ene, mod_tors_ene_info, tors_model) return rotors
def _read_from_filesys(rxn_info, ini_thy_info, zma_locs, save_prefix): """ Check if reaction exists in the filesystem and has been identified """ zrxn, zma = None, None sort_rxn_info = rinfo.sort(rxn_info, scheme='autofile') ts_info = rinfo.ts_info(rxn_info) mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, ts_info) rxn_fs = autofile.fs.reaction(save_prefix) if rxn_fs[-1].exists(sort_rxn_info): _, cnf_save_fs = build_fs( save_prefix, save_prefix, 'CONFORMER', rxn_locs=sort_rxn_info, thy_locs=mod_ini_thy_info[1:], # this needs to be fixed for any case with more than one TS ts_locs=(0, )) _, ini_min_cnf_path = filesys.mincnf.min_energy_conformer_locators( cnf_save_fs, mod_ini_thy_info) if ini_min_cnf_path: zma_fs = autofile.fs.zmatrix(ini_min_cnf_path) if zma_fs[-1].file.reaction.exists(zma_locs): zrxn = zma_fs[-1].file.reaction.read(zma_locs) zma = zma_fs[-1].file.zmatrix.read(zma_locs) ts_locs = (0, ) if zrxn is None: _, zma_fs = build_fs('', save_prefix, 'ZMATRIX', rxn_locs=sort_rxn_info, ts_locs=ts_locs, thy_locs=mod_ini_thy_info[1:]) if zma_fs[-1].file.reaction.exists(zma_locs): zrxn = zma_fs[-1].file.reaction.read(zma_locs) zma = zma_fs[-1].file.zmatrix.read(zma_locs) return zrxn, zma
def saddle_point_hessian(opt_ret, ts_info, method_dct, run_fs, run_prefix, overwrite): """ run things for checking Hessian """ mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info) script_str, kwargs = qchem_params(method_dct) # Obtain geometry from optimization opt_inf_obj, _, opt_out_str = opt_ret opt_prog = opt_inf_obj.prog geo = elstruct.reader.opt_geometry(opt_prog, opt_out_str) # Run a Hessian hess_success, hess_ret = es_runner.execute_job( job='hessian', script_str=script_str, run_fs=run_fs, geo=geo, spc_info=ts_info, thy_info=mod_thy_info, overwrite=overwrite, **kwargs, ) # If successful, Read the geom and energy from the optimization if hess_success: hess_inf_obj, _, hess_out_str = hess_ret hess = elstruct.reader.hessian(hess_inf_obj.prog, hess_out_str) fml_str = automol.geom.formula_string(geo) vib_path = job_path(run_prefix, 'PROJROT', 'FREQ', fml_str) run_fs[-1].create(['hessian']) script_str = autorun.SCRIPT_DCT['projrot'] freqs, _, imags, _ = autorun.projrot.frequencies( script_str, vib_path, [geo], [[]], [hess]) else: freqs, imags = [], [] return hess_ret, freqs, imags
def save_saddle_point(opt_ret, hess_ret, ts_dct, method_dct, savefs_dct, cnf_locs): """ Given the saddle point guess structure, obtain a proper saddle point """ # Pull info from the dictionaries to save zrxn = ts_dct['zrxn'] runlvl_cnf_save_fs, _ = savefs_dct['runlvl_cnf_tuple'] ts_info = rinfo.ts_info(ts_dct['rxn_info']) mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info) # Save initial saddle point conformer filesys.save.conformer(opt_ret, hess_ret, runlvl_cnf_save_fs, mod_thy_info[1:], zrxn=zrxn, rng_locs=(cnf_locs[0], ), tors_locs=(cnf_locs[1], ), zma_locs=None)
def conformer_list_from_models(print_keyword_dct, save_prefix, run_prefix, spc_dct_i, spc_mod_dct_i): """ Create a list of conformers based on the species name and model.dat info """ # conformer range cnf_range = _set_conf_range(print_keyword_dct) # thy_info build thy_info = spc_mod_dct_i['geo'][1] spc_info = sinfo.from_dct(spc_dct_i) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) _root = filesys.root_locs(spc_dct_i, saddle=False) _, cnf_save_fs = filesys.build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_thy_info[1:], **_root) rng_cnf_locs_lst, rng_cnf_locs_path = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range=cnf_range) return cnf_save_fs, rng_cnf_locs_lst, rng_cnf_locs_path
def energy(spc_name, spc_dct_i, spc_mod_dct_i, proc_keyword_dct, thy_dct, locs, locs_path, cnf_fs, run_prefix, save_prefix): """ collect energy """ saddle = 'ts_' in spc_name _ene = None if spc_mod_dct_i: pf_filesystems = filesys.models.pf_filesys(spc_dct_i, spc_mod_dct_i, run_prefix, save_prefix, name=spc_name, saddle=saddle) _ene = ene.electronic_energy(spc_dct_i, pf_filesystems, spc_mod_dct_i, conf=(locs, locs_path, cnf_fs)) else: spc_info = sinfo.from_dct(spc_dct_i) thy_info = tinfo.from_dct(thy_dct.get(proc_keyword_dct['proplvl'])) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) sp_save_fs = autofile.fs.single_point(locs_path) # Read the energy sp_path = sp_save_fs[-1].path(mod_thy_info[1:4]) if os.path.exists(sp_path): if sp_save_fs[-1].file.energy.exists(mod_thy_info[1:4]): ioprinter.reading('Energy', sp_path) _ene = sp_save_fs[-1].file.energy.read(mod_thy_info[1:4]) if _ene is not None: miss_data = None else: miss_data = (spc_name + '_'.join(locs), mod_thy_info, 'energy') return [locs_path, _ene], miss_data
def instability_transformation(spc_dct, spc_name, thy_info, save_prefix, zma_locs=(0,)): """ see if a species and unstable and handle task management """ spc_info = sinfo.from_dct(spc_dct[spc_name]) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) _, zma_save_fs = build_fs( '', save_prefix, 'ZMATRIX', spc_locs=spc_info, thy_locs=mod_thy_info[1:], instab_locs=()) # Check if the instability files exist if zma_save_fs[-1].file.reaction.exists(zma_locs): zrxn = zma_save_fs[-1].file.reaction.read(zma_locs) zma = zma_save_fs[-1].file.zmatrix.read(zma_locs) _instab = (zrxn, zma) path = zma_save_fs[-1].file.zmatrix.path(zma_locs) else: _instab = None path = None return _instab, path
def run_tsk(tsk, spc_dct, spc_name, thy_dct, proc_keyword_dct, pes_mod_dct_i, spc_mod_dct_i, run_prefix, save_prefix): """ run a proc tess task for generating a list of conformer or tau sampling geometries """ # Print the head of the task ioprinter.output_task_header(tsk) ioprinter.obj('line_dash') ioprinter.output_keyword_list(proc_keyword_dct, thy_dct) # Setup csv data dictionary for specific task csv_data = util.set_csv_data(tsk) chn_basis_ene_dct = {} spc_array = [] # print species ioprinter.obj('line_dash') ioprinter.info_message("Species: ", spc_name) # Heat of formation basis molecules and coefficients # is not conformer specific if 'coeffs' in tsk: thy_info = spc_mod_dct_i['geo'][1] filelabel = 'coeffs' filelabel += '_{}'.format(pes_mod_dct_i['thermfit']['ref_scheme']) filelabel += '.csv' label = spc_name basis_dct, _ = basis.prepare_refs( pes_mod_dct_i['thermfit']['ref_scheme'], spc_dct, (spc_name, )) # Get the basis info for the spc of interest spc_basis, coeff_basis = basis_dct[spc_name] coeff_array = [] for spc_i in spc_basis: if spc_i not in spc_array: spc_array.append(spc_i) for spc_i in spc_array: if spc_i in spc_basis: coeff_array.append(coeff_basis[spc_basis.index(spc_i)]) else: coeff_array.append(0) csv_data[label] = [*coeff_array] else: # unpack spc and level info spc_dct_i = spc_dct[spc_name] if proc_keyword_dct['geolvl']: thy_info = tinfo.from_dct(thy_dct.get(proc_keyword_dct['geolvl'])) else: thy_info = spc_mod_dct_i['geo'][1] # Loop over conformers if proc_keyword_dct['geolvl']: _, rng_cnf_locs_lst, rng_cnf_locs_path = util.conformer_list( proc_keyword_dct, save_prefix, run_prefix, spc_dct_i, thy_dct) spc_mod_dct_i, pf_models = None, None else: ret = util.conformer_list_from_models(proc_keyword_dct, save_prefix, run_prefix, spc_dct_i, thy_dct, spc_mod_dct_i, pf_models) _, rng_cnf_locs_lst, rng_cnf_locs_path = ret for locs, locs_path in zip(rng_cnf_locs_lst, rng_cnf_locs_path): label = spc_name + '_' + '_'.join(locs) _, cnf_fs = filesys.build_fs(run_prefix, save_prefix, 'CONFORMER') if 'freq' in tsk: filelabel = 'freq' if spc_mod_dct_i: filelabel += '_m{}'.format(spc_mod_dct_i['harm'][0]) else: filelabel += '_{}'.format(proc_keyword_dct['geolvl']) filelabel += '.csv' if pf_models: pf_filesystems = filesys.models.pf_filesys(spc_dct_i, spc_mod_dct_i, run_prefix, save_prefix, saddle=False) ret = vib.full_vib_analysis(spc_dct_i, pf_filesystems, spc_mod_dct_i, run_prefix, zrxn=None) freqs, _, tors_zpe, sfactor, torsfreqs, all_freqs = ret csv_data['tfreq'][label] = torsfreqs csv_data['allfreq'][label] = all_freqs csv_data['scalefactor'][label] = [sfactor] else: es_model = util.freq_es_levels(proc_keyword_dct) spc_mod_dct_i = parser.model.pf_level_info( es_model, thy_dct) try: freqs, _, zpe = vib.read_locs_harmonic_freqs( cnf_fs, locs, run_prefix, zrxn=None) except: freqs = [] zpe = 0 tors_zpe = 0.0 spc_data = [] zpe = tors_zpe + (sum(freqs) / 2.0) * phycon.WAVEN2EH if freqs and proc_keyword_dct['scale'] is not None: freqs, zpe = vib.scale_frequencies(freqs, tors_zpe, spc_mod_dct_i, scale_method='3c') spc_data = [locs_path, zpe, *freqs] csv_data['freq'][label] = spc_data elif 'geo' in tsk: filelabel = 'geo' if spc_mod_dct_i: filelabel += '_{}'.format(spc_mod_dct_i['harm']) else: filelabel += '_{}'.format(proc_keyword_dct['geolvl']) filelabel += '.txt' if cnf_fs[-1].file.geometry.exists(locs): geo = cnf_fs[-1].file.geometry.read(locs) energy = cnf_fs[-1].file.energy.read(locs) comment = 'energy: {0:>15.10f}'.format(energy) xyz_str = automol.geom.xyz_string(geo, comment=comment) else: xyz_str = '\t -- Missing --' spc_data = '\n\nSPC: {}\tConf: {}\tPath: {}\n'.format( spc_name, locs, locs_path) + xyz_str csv_data[label] = spc_data elif 'zma' in tsk: filelabel = 'zmat' if spc_mod_dct_i: filelabel += '_{}'.format(spc_mod_dct_i['harm']) else: filelabel += '_{}'.format(proc_keyword_dct['geolvl']) filelabel += '.txt' geo = cnf_fs[-1].file.geometry.read(locs) zma = automol.geom.zmatrix(geo) energy = cnf_fs[-1].file.energy.read(locs) comment = 'energy: {0:>15.10f}\n'.format(energy) zma_str = automol.zmat.string(zma) spc_data = '\n\nSPC: {}\tConf: {}\tPath: {}\n'.format( spc_name, locs, locs_path) + comment + zma_str csv_data[label] = spc_data elif 'ene' in tsk: filelabel = 'ene' if spc_mod_dct_i: filelabel += '_{}'.format(spc_mod_dct_i['harm']) filelabel += '_{}'.format(spc_mod_dct_i['ene']) else: filelabel += '_{}'.format(proc_keyword_dct['geolvl']) filelabel += '_{}'.format(proc_keyword_dct['proplvl']) filelabel += '.csv' energy = None if spc_mod_dct_i: pf_filesystems = filesys.models.pf_filesys(spc_dct_i, spc_mod_dct_i, run_prefix, save_prefix, saddle=False) energy = ene.electronic_energy(spc_dct_i, pf_filesystems, spc_mod_dct_i, conf=(locs, locs_path, cnf_fs)) else: spc_info = sinfo.from_dct(spc_dct_i) thy_info = tinfo.from_dct( thy_dct.get(proc_keyword_dct['proplvl'])) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) sp_save_fs = autofile.fs.single_point(locs_path) sp_save_fs[-1].create(mod_thy_info[1:4]) # Read the energy sp_path = sp_save_fs[-1].path(mod_thy_info[1:4]) if os.path.exists(sp_path): if sp_save_fs[-1].file.energy.exists( mod_thy_info[1:4]): ioprinter.reading('Energy', sp_path) energy = sp_save_fs[-1].file.energy.read( mod_thy_info[1:4]) csv_data[label] = [locs_path, energy] elif 'enthalpy' in tsk: filelabel = 'enthalpy' if spc_mod_dct_i: filelabel += '_{}'.format(spc_mod_dct_i['harm']) filelabel += '_{}'.format(spc_mod_dct_i['ene']) else: filelabel += '_{}'.format(proc_keyword_dct['geolvl']) filelabel += '_{}'.format(proc_keyword_dct['proplvl']) filelabel = '.csv' energy = None pf_filesystems = filesys.models.pf_filesys(spc_dct_i, spc_mod_dct_i, run_prefix, save_prefix, saddle=False) ene_abs = ene.read_energy(spc_dct_i, pf_filesystems, spc_mod_dct_i, run_prefix, conf=(locs, locs_path, cnf_fs), read_ene=True, read_zpe=True, saddle=False) hf0k, _, chn_basis_ene_dct, hbasis = basis.enthalpy_calculation( spc_dct, spc_name, ene_abs, chn_basis_ene_dct, pes_mod_dct_i, spc_mod_dct_i, run_prefix, save_prefix, pforktp='pf', zrxn=None) spc_basis, coeff_basis = hbasis[spc_name] coeff_array = [] for spc_i in spc_basis: if spc_i not in spc_array: spc_array.append(spc_i) for spc_i in spc_array: if spc_i in spc_basis: coeff_array.append(coeff_basis[spc_basis.index(spc_i)]) else: coeff_array.append(0) csv_data[label] = [locs_path, ene_abs, hf0k, *coeff_array] util.write_csv_data(tsk, csv_data, filelabel, spc_array)
def optimize_saddle_point(guess_zmas, ts_dct, method_dct, mref_kwargs, runfs_dct, es_keyword_dct, cnf_locs): """ Optimize the transition state structure obtained from the grid search """ # Get info (move later) ts_info = rinfo.ts_info(ts_dct['rxn_info']) mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info) overwrite = es_keyword_dct['overwrite'] ts_info = rinfo.ts_info(ts_dct['rxn_info']) runlvl_cnf_run_fs = runfs_dct['runlvl_cnf'] runlvl_cnf_run_fs[-1].create(cnf_locs) run_fs = autofile.fs.run(runlvl_cnf_run_fs[-1].path(cnf_locs)) ioprinter.info_message( f'There are {len(guess_zmas)} guess Z-Matrices' 'to attempt to find saddle point.', newline=1) # Loop over all the guess zmas to find a TS opt_ret, hess_ret = None, None for idx, zma in enumerate(guess_zmas): ioprinter.info_message(f'\nOptimizing guess Z-Matrix {idx+1}...') # Run the transition state optimization script_str, kwargs = qchem_params(method_dct, job=elstruct.Job.OPTIMIZATION) kwargs.update(mref_kwargs) opt_success, opt_ret = es_runner.execute_job( job='optimization', script_str=script_str, run_fs=run_fs, geo=zma, spc_info=ts_info, thy_info=mod_thy_info, saddle=True, overwrite=overwrite, **kwargs, ) if opt_success: break if opt_success: script_str, kwargs = qchem_params(method_dct) # Obtain geometry from optimization opt_inf_obj, _, opt_out_str = opt_ret opt_prog = opt_inf_obj.prog geo = elstruct.reader.opt_geometry(opt_prog, opt_out_str) # Run a Hessian _, hess_ret = es_runner.execute_job( job='hessian', script_str=script_str, run_fs=run_fs, geo=geo, spc_info=ts_info, thy_info=mod_thy_info, overwrite=overwrite, **kwargs, ) return opt_ret, hess_ret
def internal_coordinates_scan(ts_zma, zrxn, ts_info, rxn_class, method_dct, mref_params, scn_run_fs, scn_save_fs, es_keyword_dct, find_max=True): """ Scan along the internal coordinates that correspond to the reaction coordinate. Additional constraints will be used as needed. Both the internal coordinate and constrained coordinates are set according to reaction class. """ # Determine if scan should be for variational reaction class # Build grid and names appropriate for reaction type var = (automol.par.is_radrad(rxn_class) and automol.par.is_low_spin(rxn_class)) scan_inf = automol.reac.build_scan_info(zrxn, ts_zma, var=var) coord_names, constraint_dct, coord_grids, update_guess = scan_inf # Set up script string and kwargs mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info) script_str, kwargs = qchem_params(method_dct, job=elstruct.Job.OPTIMIZATION) kwargs.update(mref_params) es_runner.scan.execute_scan( zma=ts_zma, spc_info=ts_info, mod_thy_info=mod_thy_info, coord_names=coord_names, coord_grids=coord_grids, scn_run_fs=scn_run_fs, scn_save_fs=scn_save_fs, scn_typ='relaxed', script_str=script_str, overwrite=es_keyword_dct['overwrite'], update_guess=update_guess, reverse_sweep=False, saddle=False, constraint_dct=constraint_dct, retryfail=False, **kwargs, ) if find_max: include_endpts = not mref_params max_zmas = rxngrid.grid_maximum_zmatrices( zrxn.class_, ts_zma, coord_grids, coord_names, scn_save_fs, mod_thy_info, constraint_dct, include_endpts=include_endpts) else: max_zmas = None return max_zmas
def remove_imag(geo, ini_ret, spc_info, method_dct, run_fs, kickoff_size=0.1, kickoff_backward=False, kickoff_mode=0): """ if there is an imaginary frequency displace geometry along the imaginary mode and then reoptimize """ thy_info = tinfo.from_dct(method_dct) mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) hess_script_str, kwargs = qchem_params(method_dct) ioprinter.info_message( 'Checking the initial geometry for imaginary frequencies...') hess, hess_ret = _hess(spc_info, mod_thy_info, geo, run_fs, hess_script_str, **kwargs) imags, norm_coords = _check_imaginary(geo, hess, hess_ret, run_fs) # Make five attempts to remove imag mode if found count, opt_ret = 1, None while imags and count <= 4: # Either attempt a kickoff-reopt or tight-reopt # Only attempt kickoff-reopt on first two tries if count <= 2: ioprinter.info_message( f'Attempting kick off along mode, attempt {count}...') opt_script_str, opt_kwargs = qchem_params( method_dct, job=elstruct.Job.OPTIMIZATION) disp_geo = _kickoff_saddle( geo, norm_coords, size=kickoff_size, backward=kickoff_backward, mode=kickoff_mode) geo, opt_ret = _opt(spc_info, mod_thy_info, disp_geo, run_fs, opt_script_str, opt_cart=True, **opt_kwargs) hess_script_str, hess_kwargs = qchem_params( method_dct) else: ioprinter.info_message( f'Attempting tight opt, attempt {count-2}...') opt_script_str, opt_kwargs = qchem_params( method_dct, job='tightopt') geo, opt_ret = _opt(spc_info, mod_thy_info, geo, run_fs, opt_script_str, opt_cart=True, **opt_kwargs) hess_script_str, hess_kwargs = qchem_params( method_dct, job='tightfreq') # Assess the imaginary mode after the reoptimization ioprinter.info_message('Rerunning Hessian...') hess, hess_ret = _hess(spc_info, mod_thy_info, geo, run_fs, hess_script_str, **hess_kwargs) imags, norm_coords = _check_imaginary(geo, hess, hess_ret, run_fs) # Update the loop counter and kickoff size count += 1 kickoff_size *= 2.0 if opt_ret is None: ret = ini_ret else: ret = opt_ret return geo, ret
def tau_data(spc_dct_i, spc_mod_dct_i, run_prefix, save_prefix, saddle=False): """ Read the filesystem to get information for TAU """ # Set up model and basic thy objects spc_info = sinfo.from_dct(spc_dct_i) thy_info = spc_mod_dct_i['vib']['geolvl'][1][1] mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info) vib_model = spc_mod_dct_i['vib']['mod'] # Set up reference conformer filesys pf_filesystems = filesys.models.pf_filesys(spc_dct_i, spc_mod_dct_i, run_prefix, save_prefix, saddle) [harm_save_fs, _, harm_min_locs, _, _] = pf_filesystems['harm'] # Obtain all values from initial reference conformer rotors = tors.build_rotors(spc_dct_i, pf_filesystems, spc_mod_dct_i, read_potentials=False) vib_info = vib.full_vib_analysis(spc_dct_i, pf_filesystems, spc_mod_dct_i, run_prefix, zrxn=None) freqs, _, zpe, _, tors_strs, _, harm_freqs, _ = vib_info harm_zpve = 0.5 * sum(harm_freqs) * phycon.WAVEN2EH ioprinter.info_message('Determining the symmetry factor...', newline=1) sym_factor = symm.symmetry_factor( pf_filesystems, spc_mod_dct_i, spc_dct_i, rotors, ) zpe_chnlvl = zpe * phycon.EH2KCAL ref_ene = harm_zpve * phycon.EH2KCAL ref_geom = [harm_save_fs[-1].file.geometry.read(harm_min_locs)] ref_grad = [harm_save_fs[-1].file.gradient.read(harm_min_locs)] ref_hessian = [harm_save_fs[-1].file.hessian.read(harm_min_locs)] min_cnf_ene = filesys.read.energy(harm_save_fs, harm_min_locs, mod_thy_info) # Set up the TAU filesystem objects, get locs, and read info _, tau_save_fs = filesys.build_fs(run_prefix, save_prefix, 'TAU', spc_locs=spc_info, thy_locs=mod_thy_info[1:]) db_style = 'jsondb' vib_model = spc_mod_dct_i['vib']['mod'] if vib_model == 'tau': if db_style == 'directory': tau_locs = [ locs for locs in tau_save_fs[-1].existing() if tau_save_fs[-1].file.hessian.exists(locs) ] elif db_style == 'jsondb': tau_locs = [ locs for locs in tau_save_fs[-1].json_existing() if tau_save_fs[-1].json.hessian.exists(locs) ] else: if db_style == 'directory': tau_locs = tau_save_fs[-1].existing() elif db_style == 'jsondb': tau_locs = tau_save_fs[-1].json_existing() ioprinter.info_message( 'Reading data for the Monte Carlo samples from db.json' f'at path {tau_save_fs[0].path()}') samp_geoms, samp_enes, samp_grads, samp_hessians = [], [], [], [] tot_locs = len(tau_locs) for idx, locs in enumerate(tau_locs): if db_style == 'directory': geo = tau_save_fs[-1].file.geometry.read(locs) elif db_style == 'jsondb': geo = tau_save_fs[-1].json.geometry.read(locs) # geo_str = autofile.data_types.swrite.geometry(geo) samp_geoms.append(geo) if db_style == 'directory': tau_ene = tau_save_fs[-1].file.energy.read(locs) elif db_style == 'jsondb': tau_ene = tau_save_fs[-1].json.energy.read(locs) rel_ene = (tau_ene - min_cnf_ene) * phycon.EH2KCAL # ene_str = autofile.data_types.swrite.energy(rel_ene) samp_enes.append(rel_ene) if vib_model == 'tau': if db_style == 'directory': grad = tau_save_fs[-1].file.gradient.read(locs) elif db_style == 'jsondb': grad = tau_save_fs[-1].json.gradient.read(locs) # grad_str = autofile.data_types.swrite.gradient(grad) samp_grads.append(grad) if db_style == 'directory': hess = tau_save_fs[-1].file.hessian.read(locs) elif db_style == 'jsondb': hess = tau_save_fs[-1].json.hessian.read(locs) # hess_str = autofile.data_types.swrite.hessian(hess) samp_hessians.append(hess) # Print progress message (every 150 geoms read) if idx % 149 == 0: print(f'Read {idx+1}/{tot_locs} samples...') # Determine the successful conformer ratio inf_obj = tau_save_fs[0].file.info.read() excluded_volume_factor = len(samp_geoms) / inf_obj.nsamp print('excluded volume factor test:', excluded_volume_factor, len(samp_geoms), inf_obj.nsamp) # Create info dictionary keys = [ 'geom', 'sym_factor', 'elec_levels', 'freqs', 'flux_mode_str', 'samp_geoms', 'samp_enes', 'samp_grads', 'samp_hessians', 'ref_geom', 'ref_grad', 'ref_hessian', 'zpe_chnlvl', 'ref_ene', 'excluded_volume_factor' ] vals = [ ref_geom[0], sym_factor, spc_dct_i['elec_levels'], freqs, tors_strs[2], samp_geoms, samp_enes, samp_grads, samp_hessians, ref_geom, ref_grad, ref_hessian, zpe_chnlvl, ref_ene, excluded_volume_factor ] inf_dct = dict(zip(keys, vals)) return inf_dct