def rpath_fs(ts_dct, tsname, mod_ini_thy_info, es_keyword_dct, run_prefix, save_prefix): """ reaction path filesystem """ # Set up coordinate name rxn_coord = es_keyword_dct.get('rxncoord') # Get the zma and ts locs zma_locs = (ts_dct['zma_idx'], ) ts_locs = (int(tsname.split('_')[-1]), ) # Build filesys object down to TS FS ts_fs = build_fs(run_prefix, save_prefix, 'TRANSITION STATE', thy_locs=mod_ini_thy_info[1:], **root_locs(ts_dct, saddle=True)) ini_ts_run_fs, ini_ts_save_fs = ts_fs # generate fs if rxn_coord == 'irc': # Try and locate a minimum-energy conformer cnf_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_ini_thy_info[1:], **root_locs(ts_dct, saddle=True, name=tsname)) ini_cnf_run_fs, ini_cnf_save_fs = cnf_fs ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_locs, ini_pfx_save_path = ini_loc_info if any(ini_min_locs): # Run IRC from saddle point minimum-energy conformer ini_pfx_run_path = ini_cnf_run_fs[-1].path(ini_min_locs) ini_pfx_save_path = ini_cnf_save_fs[-1].path(ini_min_locs) scn_alg = 'irc-sadpt' else: # Run IRC from series of points {Rmax, Rmax-1, ...} ini_pfx_run_path = ini_ts_run_fs[-1].path(ts_locs) ini_pfx_save_path = ini_ts_save_fs[-1].path(ts_locs) scn_alg = 'irc-rmax' else: # Run a scan along the requested reaction coordinates # Have an auto option that just selects the coordinate? ini_pfx_run_path = ini_ts_run_fs[-1].path(ts_locs) ini_pfx_save_path = ini_ts_save_fs[-1].path(ts_locs) scn_alg = 'drp' # Set up the scan filesystem objects using the predefined prefix scn_fs = build_fs(ini_pfx_run_path, ini_pfx_save_path, 'SCAN', zma_locs=zma_locs) return scn_alg, scn_fs, cnf_fs, ini_min_locs
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 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 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 rpath_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ run a scan over the specified torsional coordinates """ # Get dct for specific species task is run for spc_dct_i = spc_dct[spc_name] # Set up coordinate name rxn_coord = es_keyword_dct.get('rxn_coord') if rxn_coord == 'auto': coord_name = ['Rn'] # grab from zrxn object else: # coord_name = coord_name = ['IRC'] # Set the spc_info spc_info = sinfo.from_dct(spc_dct_i) # Modify the theory 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) # Get options from the dct or es options lst overwrite = es_keyword_dct['overwrite'] # retryfail = es_keyword_dct['retryfail'] # Set up the script script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) # Set the filesystem objects rxn_info = spc_dct_i['rxn_info'] fs_rxn_info = rinfo.sort(rxn_info) # New filesystem objects if coord_name == 'irc': _root = root_locs(spc_dct_i, saddle=True) # ini_cnf_run_fs, ini_cnf_save_fs = build_fs( # run_prefix, save_prefix, 'CONFORMER', # thy_locs=mod_ini_thy_info[1:], # **_root) # cnf_run_fs, cnf_save_fs = build_fs( # run_prefix, save_prefix, 'CONFORMER', # thy_locs=mod_thy_info[1:], # **_root) ini_cnf_run_fs, ini_cnf_save_fs = build_fs( run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_ini_thy_info[1:], **_root) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_thy_info[1:], **_root) ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_locs, ini_pfx_save_path = ini_loc_info # ini_min_rng_locs, ini_min_cnf_locs = ini_min_cnf_locs # ini_min_rng_path, ini_min_cnf_path = ini_min_cnf_path ini_cnf_run_fs[-1].create(ini_min_locs) ini_pfx_run_path = ini_cnf_run_fs[-1].path(ini_min_locs) else: ts_info = (ts_num, ) ini_ts_run_fs, ini_ts_save_fs = build_fs(run_prefix, save_prefix, 'TS', thy_locs=mod_ini_thy_info[1:], **_root) ini_pfx_run_path = ini_ts_run_fs.path(ts_info) ini_pfx_save_path = ini_ts_save_fs.path(ts_info) # Get options from the dct or es options lst overwrite = es_keyword_dct['overwrite'] ini_scn_run_fs, ini_scn_save_fs = build_fs(ini_pfx_run_path, ini_pfx_save_path, 'SCAN', zma_locs=(0, )) ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path) geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) # Run job if job == 'scan': if rcoord == 'auto': pass elif rcoord == 'irc': rpath.irc_scan(geo, spc_info, coord_name, mod_ini_thy_info, ini_method_dct, ini_scn_save_fs, ini_cnf_run_path, overwrite) elif job in ('energy', 'grad', 'hess'): # Script script_str, kwargs = qchem_params(method_dct) # Need to put in something with the IRC idxs for locs in ini_scn_save_fs[-1].existing(): geo_run_path = ini_scn_run_fs[-1].path(locs) geo_save_path = ini_scn_save_fs[-1].path(locs) geo = ini_scn_save_fs[-1].file.geometry.read(locs) zma = None ini_scn_run_fs[-1].create(locs) ES_TSKS[job](zma, geo, spc_info, mod_thy_info, ini_scn_save_fs, geo_run_path, geo_save_path, locs, script_str, overwrite, **kwargs) ioprinter.obj('vspace') elif job == 'infene': pass
def hr_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ run a scan over the specified torsional coordinates """ spc_dct_i = spc_dct[spc_name] saddle = bool('ts_' in spc_name) # Set the spc_info if not saddle: spc_info = sinfo.from_dct(spc_dct_i) else: spc_info = rinfo.ts_info(spc_dct_i['rxn_info']) # Modify the theory 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 _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name) ini_cnf_run_fs, ini_cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_ini_thy_info[1:], **_root) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_thy_info[1:], **_root) instab_save_fs = () ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_locs, ini_cnf_save_path = ini_loc_info # ini_min_rng_locs, ini_min_cnf_locs = ini_min_cnf_locs # ini_min_rng_path, ini_min_cnf_path = ini_min_cnf_path # Create run fs if that directory has been deleted to run the jobs ini_cnf_run_fs[-1].create(ini_min_locs) ini_cnf_run_path = ini_cnf_run_fs[-1].path(ini_min_locs) # Get options from the dct or es options lst overwrite = es_keyword_dct['overwrite'] retryfail = es_keyword_dct['retryfail'] tors_model = es_keyword_dct['tors_model'] # Read zma, geo, and torsions ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path) geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) if ini_zma_save_fs[-1].file.torsions.exists([0]): tors_dct = ini_zma_save_fs[-1].file.torsions.read([0]) torsions = automol.rotor.from_data( zma, tors_dct, ) else: torsions = () # Run the task if any torsions exist if any(torsions): scn = 'SCAN' if 'fa' not in tors_model else 'CSCAN' ini_scn_run_fs, ini_scn_save_fs = build_fs(ini_cnf_run_path, ini_cnf_save_path, scn, zma_locs=(0, )) if job == 'scan': increment = spc_dct_i.get('hind_inc', 30.0 * phycon.DEG2RAD) hr.hindered_rotor_scans(zma, spc_info, mod_thy_info, instab_save_fs, ini_scn_run_fs, ini_scn_save_fs, torsions, tors_model, method_dct, overwrite, saddle=saddle, increment=increment, retryfail=retryfail) # elif job == 'reopt': # # pull stuff from dcts # two_stage = saddle # rxn_class = spc_dct_i['class'] if saddle else '' # mc_nsamp = spc_dct_i['mc_nsamp'] # ethresh = es_keyword_dct['hrthresh'] # # Read and print the potential # sp_fs = autofile.fs.single_point(ini_cnf_save_path) # ref_ene = sp_fs[-1].file.energy.read(mod_ini_thy_info[1:4]) # # ref_ene = ini_cnf_save_fs[-1].file.energy.read(ini_min_cnf_locs) # tors_pots, tors_zmas, tors_paths = {}, {}, {} # for tors_names, tors_grids in zip(run_tors_names, run_tors_grids): # constraint_dct = automol.zmat.build_constraint_dct( # zma, const_names, tors_names) # pot, _, _, _, zmas, paths = filesys.read.potential( # tors_names, tors_grids, # ini_cnf_save_path, # mod_ini_thy_info, ref_ene, # constraint_dct, # read_zma=True) # tors_pots[tors_names] = pot # tors_zmas[tors_names] = zmas # tors_paths[tors_names] = paths # # Check for new minimum conformer # new_min_zma = __.check_hr_pot( # tors_pots, tors_zmas, tors_paths, emax=ethresh) # if new_min_zma is not None: # ioprinter.info_message( # 'Finding new low energy conformer...', newline=1) # conformer.single_conformer( # zma, spc_info, mod_thy_info, # ini_cnf_run_fs, ini_cnf_save_fs, # script_str, overwrite, # retryfail=retryfail, rxn=rxn, **kwargs) elif job in ('energy', 'grad', 'hess', 'vpt2'): # Script (add energy script call) script_str, kwargs = qchem_params(method_dct) run_tors_names = automol.rotor.names(torsions, flat=True) for tors_names in run_tors_names: # Set the constraint dct and filesys for the scan const_names = automol.zmat.set_constraint_names( zma, run_tors_names, tors_model) constraint_dct = automol.zmat.build_constraint_dct( zma, const_names, tors_names) # get the scn_locs, maybe get a function? scn_locs = () for locs in scn_locs: geo_run_path = ini_scn_run_fs[-1].path(locs) geo_save_path = ini_scn_save_fs[-1].path(locs) geo = ini_scn_save_fs[-1].file.geometry.read(locs) zma = ini_scn_save_fs[-1].file.zmatrix.read(locs) ini_scn_run_fs[-1].create(locs) ES_TSKS[job](zma, geo, spc_info, mod_thy_info, ini_scn_save_fs, geo_run_path, geo_save_path, locs, script_str, overwrite, retryfail=retryfail, **kwargs) ioprinter.obj('vspace') else: ioprinter.info_message('No torsional modes in the species')
def conformer_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ Launch tasks associated with conformers. Scan: Generate a set of conformer geometries and energies via random sampling over torsional coordinates following by optimization SP: Calculate ene, grad, .. """ saddle = bool('ts_' in spc_name) spc_dct_i = spc_dct[spc_name] # Set the spc_info if not saddle: spc_info = sinfo.from_dct(spc_dct_i) else: spc_info = rinfo.ts_info(spc_dct_i['rxn_info']) zrxn = spc_dct_i.get('zrxn', None) overwrite = es_keyword_dct['overwrite'] retryfail = es_keyword_dct['retryfail'] # Modify the theory 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) # New filesystem objects _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name) ini_cnf_run_fs, ini_cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_ini_thy_info[1:], **_root) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_thy_info[1:], **_root) if job == 'samp': # Build the ini zma filesys ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_locs, ini_min_cnf_path = ini_loc_info ini_min_rid, ini_min_cid = ini_locs ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path) # Set up the run scripts script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) # Set variables if it is a saddle two_stage = saddle mc_nsamp = spc_dct_i['mc_nsamp'] resave = es_keyword_dct['resave'] # Read the geometry and zma from the ini file system geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read([0]) # Read the torsions from the ini file sys if ini_zma_save_fs[-1].file.torsions.exists([0]): tors_dct = ini_zma_save_fs[-1].file.torsions.read([0]) rotors = automol.rotor.from_data(zma, tors_dct) tors_names = automol.rotor.names(rotors, flat=True) else: tors_names = () geo_path = ini_cnf_save_fs[-1].path(ini_locs) ioprinter.initial_geom_path('Sampling started', geo_path) # Check runsystem for equal ring CONF make conf_fs # Else make new ring conf directory rid = conformer.rng_loc_for_geo(geo, cnf_run_fs, cnf_save_fs) if rid is None: conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, **kwargs) rid = conformer.rng_loc_for_geo(geo, cnf_run_fs, cnf_save_fs) # Run the sampling conformer.conformer_sampling(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, rid, script_str, overwrite, nsamp_par=mc_nsamp, tors_names=tors_names, zrxn=zrxn, two_stage=two_stage, retryfail=retryfail, resave=resave, **kwargs) elif job == 'pucker': # Build the ini zma filesys ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_locs, ini_min_cnf_path = ini_loc_info ini_min_rid, ini_min_cid = ini_min_locs ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path) # Set up the run scripts script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) # Set variables if it is a saddle two_stage = saddle mc_nsamp = spc_dct_i['mc_nsamp'] # Read the geometry and zma from the ini file system geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read([0]) # Read the torsions from the ini file sys if ini_zma_save_fs[-1].file.ring_torsions.exists([0]): ring_tors_dct = ini_zma_save_fs[-1].file.ring_torsions.read([0]) else: ring_tors_dct = {} geo_path = ini_cnf_save_fs[-1].path(ini_min_locs) ioprinter.initial_geom_path('Sampling started', geo_path) # Run the sampling conformer.ring_conformer_sampling(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, nsamp_par=mc_nsamp, ring_tors_dct=ring_tors_dct, zrxn=zrxn, two_stage=two_stage, retryfail=retryfail, **kwargs) elif job == 'opt': cnf_range = es_keyword_dct['cnf_range'] ioprinter.debug_message('range', cnf_range) # Set up the run scripts script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_locs, ini_min_cnf_path = ini_loc_info ini_min_rid, ini_min_cid = ini_min_locs rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range='all') ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( ini_cnf_save_fs, mod_ini_thy_info, cnf_range=cnf_range) # Truncate the list of the ini confs uni_rng_locs_lst, uni_cnf_locs_lst = conformer.unique_fs_ring_confs( cnf_save_fs, rng_cnf_locs_lst, ini_cnf_save_fs, ini_rng_cnf_locs_lst) ioprinter.debug_message('uni lst that has no similar ring', uni_rng_locs_lst) ioprinter.debug_message('uni lst that has similar ring', uni_cnf_locs_lst) for locs in uni_rng_locs_lst: rid, cid = locs # Obtain the zma from ini loc ini_cnf_save_path = ini_cnf_save_fs[-1].path(locs) ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) # Make the ring filesystem conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, use_locs=locs, **kwargs) for locs in uni_cnf_locs_lst: ini_locs, rid = locs ini_rid, ini_cid = ini_locs # Obtain the zma from ini loc ini_cnf_save_path = ini_cnf_save_fs[-1].path(ini_locs) ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) # obtain conformer filesystem associated with the ring at the runlevel cid = autofile.schema.generate_new_conformer_id() conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, use_locs=(rid, cid), **kwargs) rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range=cnf_range) for locs in rng_cnf_locs_lst: geo = cnf_save_fs[-1].file.geometry.read(locs) ioprinter.geometry(geo) elif job in ('energy', 'grad', 'hess', 'vpt2', 'prop'): cnf_range = es_keyword_dct['cnf_range'] ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( ini_cnf_save_fs, mod_ini_thy_info, cnf_range=cnf_range) # Check if locs exist, kill if it doesn't if not ini_rng_cnf_locs_lst: ioprinter.error_message('No min-energy conformer found for level:') sys.exit() # Set up the run scripts script_str, kwargs = qchem_params(method_dct) # Run the job over all the conformers requested by the user for ini_locs in ini_rng_cnf_locs_lst: ini_rid, ini_cid = ini_locs ioprinter.running('task for conformer: ', ini_locs, newline=2) ini_cnf_run_fs[-1].create(ini_locs) geo_run_path = ini_cnf_run_fs[-1].path(ini_locs) geo_save_path = ini_cnf_save_fs[-1].path(ini_locs) ini_zma_save_fs = autofile.fs.zmatrix(geo_save_path) ioprinter.debug_message('reading geometry from ', geo_save_path) geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) ES_TSKS[job](zma, geo, spc_info, mod_thy_info, ini_cnf_save_fs, geo_run_path, geo_save_path, ini_locs, script_str, overwrite, retryfail=retryfail, **kwargs)
def hr_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ Prepares and executes all electronic structure tasks that generate information for points along hindered-rotor coordinate scans which are launched from some conformer in the save filesystem. For species and transition state conformers. This includes scanning procedures to generate geometries (relaxed) or energies (rigid) points along conformer structures, as well as __ calculations using some saved conformer as input. :param job: :type job: :param spc_dct: :type spc_dct: :param spc_name: :type spc_name: :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] saddle = bool('ts_' in spc_name) # Set the spc_info if not saddle: spc_info = sinfo.from_dct(spc_dct_i) else: spc_info = rinfo.ts_info(spc_dct_i['rxn_info']) # Get options from the dct or es options lst overwrite = es_keyword_dct['overwrite'] retryfail = es_keyword_dct['retryfail'] tors_model = es_keyword_dct['tors_model'] # nprocs = es_keyword_dct['nprocs'] nprocs = 1 # Modify the theory 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 _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name) _, ini_cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_ini_thy_info[1:], **_root) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_thy_info[1:], **_root) cnf_range = es_keyword_dct['cnf_range'] hbond_cutoffs = spc_dct_i['hbond_cutoffs'] user_conf_ids = spc_dct_i.get('conf_id') if user_conf_ids is None: cnf_sort_info_lst = _sort_info_lst(es_keyword_dct['sort'], thy_dct, spc_info) ini_min_locs_lst, ini_path_lst = filesys.mincnf.conformer_locators( ini_cnf_save_fs, mod_ini_thy_info, cnf_range=cnf_range, sort_info_lst=cnf_sort_info_lst, hbond_cutoffs=hbond_cutoffs, print_enes=True, nprocs=nprocs) else: ini_min_locs_lst = (user_conf_ids, ) ini_path_lst = (ini_cnf_save_fs[-1].path(user_conf_ids), ) all_run_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range='all', nprocs=nprocs) ini_to_run_locs_dct = filesys.mincnf.fs_confs_dict(cnf_save_fs, all_run_cnf_locs_lst, ini_cnf_save_fs, ini_min_locs_lst) for ini_min_locs, ini_cnf_save_path in zip(ini_min_locs_lst, ini_path_lst): # Read zma, geo, and torsions ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path) geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) if ini_zma_save_fs[-1].file.torsions.exists([0]): tors_dct = ini_zma_save_fs[-1].file.torsions.read([0]) torsions = automol.rotor.from_data( zma, tors_dct, ) else: torsions = () zrxn = spc_dct_i.get('zrxn', None) # Run the task if any torsions exist if any(torsions): # Find equivalent conformer in the run filesys, if it doesn't exist # run a single conformer to generate it min_locs = ini_to_run_locs_dct[tuple(ini_min_locs)] if min_locs is None: script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) rid = conformer.rng_loc_for_geo(geo, cnf_save_fs) if rid is None: new_rid = autofile.schema.generate_new_ring_id() new_cid = autofile.schema.generate_new_conformer_id() conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, use_locs=(new_rid, new_cid), **kwargs) min_locs = (new_rid, new_cid) else: new_cid = autofile.schema.generate_new_conformer_id() conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, use_locs=(rid, new_cid), **kwargs) min_locs = (rid, new_cid) save_locs = cnf_save_fs[-1].existing() if min_locs not in save_locs: locinf = filesys.mincnf.this_conformer_was_run_in_run( zma, cnf_run_fs) _, sym_locs_lst = locinf for sym_locs in sym_locs_lst: if sym_locs in save_locs: min_locs = sym_locs cnf_save_path = cnf_save_fs[-1].path(min_locs) ioprinter.info_message( f'Same conformer saved at {ini_cnf_save_path} ' f'and {cnf_save_path}') # Create run fs if that directory has been deleted to run the jobs # ini_cnf_run_fs[-1].create(ini_min_locs) # ini_cnf_run_path = ini_cnf_run_fs[-1].path(ini_min_locs) cnf_run_fs[-1].create(min_locs) cnf_run_path = cnf_run_fs[-1].path(min_locs) # Get the runlvl zma and torsion info zma_save_fs = autofile.fs.zmatrix(cnf_save_path) geo = cnf_save_fs[-1].file.geometry.read(min_locs) zma = zma_save_fs[-1].file.zmatrix.read((0, )) if zma_save_fs[-1].file.torsions.exists([0]): tors_dct = zma_save_fs[-1].file.torsions.read([0]) torsions = automol.rotor.from_data( zma, tors_dct, ) else: torsions = () if 'fa' in tors_model: scn = 'CSCAN' elif 'f' in tors_model: if len(torsions) > 1: scn = 'CSCAN' else: scn = 'SCAN' else: scn = 'SCAN' # ini_scn_run_fs, ini_scn_save_fs = build_fs( # ini_cnf_run_path, ini_cnf_save_path, scn, # zma_locs=(0,)) scn_run_fs, scn_save_fs = build_fs(cnf_run_path, cnf_save_path, scn, zma_locs=(0, )) if job == 'scan': increment = spc_dct_i.get('hind_inc', 30.0 * phycon.DEG2RAD) hr.hindered_rotor_scans(zma, spc_info, mod_thy_info, scn_run_fs, scn_save_fs, torsions, tors_model, method_dct, overwrite, zrxn=zrxn, saddle=saddle, increment=increment, retryfail=retryfail) elif job == 'reopt': script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) # pull stuff from dcts ethresh = es_keyword_dct['hrthresh'] increment = spc_dct_i.get('hind_inc', 30.0 * phycon.DEG2RAD) zrxn = spc_dct_i.get('zrxn', None) run_tors_names = automol.rotor.names(torsions) run_tors_grids = automol.rotor.grids(torsions, increment=increment) # Set constraints const_names = automol.zmat.set_constraint_names( zma, run_tors_names, tors_model) # Read and print the potential sp_fs = autofile.fs.single_point(cnf_save_path) ref_ene = sp_fs[-1].file.energy.read(mod_thy_info[1:4]) tors_pots, tors_zmas, tors_paths = {}, {}, {} for tors_names, tors_grids in zip(run_tors_names, run_tors_grids): constraint_dct = automol.zmat.constraint_dct( zma, const_names, tors_names) pot, _, _, _, zmas, paths = filesys.read.potential( tors_names, tors_grids, cnf_save_path, mod_thy_info, ref_ene, constraint_dct, read_zma=True) tors_pots[tors_names] = pot tors_zmas[tors_names] = zmas tors_paths[tors_names] = paths # Check for new minimum conformer new_min_zma = hr.check_hr_pot(tors_pots, tors_zmas, tors_paths, emax=ethresh) if new_min_zma is not None: ioprinter.info_message( 'Finding new low energy conformer...', newline=1) new_min_geo = automol.zmat.geometry(new_min_zma) rid = conformer.rng_loc_for_geo(new_min_geo, cnf_save_fs) if rid is None: new_locs = None else: cid = autofile.schema.generate_new_conformer_id() new_locs = (rid, cid) conformer.single_conformer(new_min_zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, use_locs=new_locs, **kwargs) elif job in ('energy', 'grad', 'hess', 'vpt2'): # Script (add energy script call) script_str, kwargs = qchem_params(method_dct) run_tors_names = automol.rotor.names(torsions, flat=True) for tors_names in run_tors_names: # Set the constraint dct and filesys for the scan const_names = automol.zmat.set_constraint_names( zma, run_tors_names, tors_model) constraint_dct = automol.zmat.constraint_dct( zma, const_names, tors_names) # get the scn_locs, maybe get a function? _, scn_locs = scan.scan_locs(scn_save_fs, tors_names, constraint_dct=constraint_dct) for locs in scn_locs: geo = scn_save_fs[-1].file.geometry.read(locs) zma = scn_save_fs[-1].file.zmatrix.read(locs) scn_run_fs[-1].create(locs) ES_TSKS[job](zma, geo, spc_info, mod_thy_info, scn_run_fs, scn_save_fs, locs, run_prefix, script_str, overwrite, zrxn=zrxn, retryfail=retryfail, **kwargs) ioprinter.obj('vspace') else: ioprinter.info_message('No torsional modes in the species')
def conformer_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix, print_debug=False): """ Prepares and executes all electronic structure tasks that generate information for species and transition state conformers. This includes sampling and optimization procedures to generate conformer structures, as well as __ calculations using some saved conformer as input. :param job(subtask): calculatiion(s) to perform for conformer :type job: str :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-values 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 """ saddle = bool('ts_' in spc_name) spc_dct_i = spc_dct[spc_name] # Set the spc_info if not saddle: spc_info = sinfo.from_dct(spc_dct_i) else: spc_info = rinfo.ts_info(spc_dct_i['rxn_info']) zrxn = spc_dct_i.get('zrxn', None) overwrite = es_keyword_dct['overwrite'] retryfail = es_keyword_dct['retryfail'] nprocs = 1 # Modify the theory 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) # New filesystem objects _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name) ini_cnf_run_fs, ini_cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_ini_thy_info[1:], **_root) cnf_run_fs, cnf_save_fs = build_fs(run_prefix, save_prefix, 'CONFORMER', thy_locs=mod_thy_info[1:], **_root) if job == 'samp': # Build the ini zma filesys user_conf_ids = spc_dct_i.get('conf_id') if user_conf_ids is None: ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_locs, ini_min_cnf_path = ini_loc_info else: print(f'Using user specified conformer IDs: {user_conf_ids}') ini_locs = user_conf_ids if any(ini_locs): ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path) # Set up the run scripts script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) # Set variables if it is a saddle two_stage = saddle mc_nsamp = spc_dct_i['mc_nsamp'] resave = es_keyword_dct['resave'] # Read the geometry and zma from the ini file system geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read([0]) # Read the torsions from the ini file sys if ini_zma_save_fs[-1].file.torsions.exists([0]): tors_dct = ini_zma_save_fs[-1].file.torsions.read([0]) rotors = automol.rotor.from_data(zma, tors_dct) tors_names = automol.rotor.names(rotors, flat=True) else: tors_names = () geo_path = ini_cnf_save_fs[-1].path(ini_locs) ioprinter.initial_geom_path('Sampling started', geo_path) # Check runsystem for equal ring CONF make conf_fs # Else make new ring conf directory rid = conformer.rng_loc_for_geo(geo, cnf_save_fs) if rid is None: conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, **kwargs) rid = conformer.rng_loc_for_geo(geo, cnf_save_fs) # Run the sampling conformer.conformer_sampling(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, rid, script_str, overwrite, nsamp_par=mc_nsamp, tors_names=tors_names, zrxn=zrxn, two_stage=two_stage, retryfail=retryfail, resave=resave, repulsion_thresh=40.0, print_debug=print_debug, **kwargs) else: ioprinter.info_message('Missing conformers. Skipping task...') elif job == 'pucker': # Build the ini zma filesys ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_locs, ini_min_cnf_path = ini_loc_info ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path) # Set up the run scripts script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) # Set variables if it is a saddle two_stage = saddle mc_nsamp = spc_dct_i['mc_nsamp'] # Read the geometry and zma from the ini file system geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read([0]) # Read the torsions from the ini file sys if ini_zma_save_fs[-1].file.ring_torsions.exists([0]): ring_tors_dct = ini_zma_save_fs[-1].file.ring_torsions.read([0]) else: ring_tors_dct = {} geo_path = ini_cnf_save_fs[-1].path(ini_min_locs) ioprinter.initial_geom_path('Sampling started', geo_path) # Run the sampling conformer.ring_conformer_sampling(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, nsamp_par=mc_nsamp, ring_tors_dct=ring_tors_dct, zrxn=zrxn, two_stage=two_stage, retryfail=retryfail, **kwargs) elif job == 'opt': cnf_range = es_keyword_dct['cnf_range'] hbond_cutoffs = spc_dct_i['hbond_cutoffs'] cnf_sort_info_lst = _sort_info_lst(es_keyword_dct['sort'], thy_dct, spc_info) # Set up the run scripts script_str, kwargs = qchem_params(method_dct, elstruct.Job.OPTIMIZATION) rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range='all', nprocs=nprocs) ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( ini_cnf_save_fs, mod_ini_thy_info, cnf_range=cnf_range, sort_info_lst=cnf_sort_info_lst, hbond_cutoffs=hbond_cutoffs, print_enes=True, nprocs=nprocs) # Truncate the list of the ini confs uni_rng_locs_lst, uni_cnf_locs_lst = conformer.unique_fs_ring_confs( cnf_save_fs, rng_cnf_locs_lst, ini_cnf_save_fs, ini_rng_cnf_locs_lst) # ioprinter.debug_message( # 'uni lst that has no similar ring', uni_rng_locs_lst) # ioprinter.debug_message( # 'uni lst that has similar ring', uni_cnf_locs_lst) for locs in uni_rng_locs_lst: rid, cid = locs # Obtain the zma from ini loc ini_cnf_save_path = ini_cnf_save_fs[-1].path(locs) ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) # Make the ring filesystem conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, use_locs=locs, **kwargs) for locs in uni_cnf_locs_lst: ini_locs, rid = locs # Obtain the zma from ini loc ini_cnf_save_path = ini_cnf_save_fs[-1].path(ini_locs) ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) # obtain conformer filesys associated with ring at the runlevel cid = autofile.schema.generate_new_conformer_id() conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, script_str, overwrite, retryfail=retryfail, zrxn=zrxn, use_locs=(rid, cid), **kwargs) # print all geometres within cnfrange rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range=cnf_range, sort_info_lst=cnf_sort_info_lst, hbond_cutoffs=hbond_cutoffs, nprocs=nprocs) for locs in rng_cnf_locs_lst: geo = cnf_save_fs[-1].file.geometry.read(locs) ioprinter.geometry(geo) elif job in ('energy', 'grad', 'hess', 'vpt2', 'prop'): cnf_range = es_keyword_dct['cnf_range'] hbond_cutoffs = spc_dct_i['hbond_cutoffs'] cnf_sort_info_lst = _sort_info_lst(es_keyword_dct['sort'], thy_dct, spc_info) user_conf_ids = spc_dct_i.get('conf_id') if user_conf_ids is None: ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( ini_cnf_save_fs, mod_ini_thy_info, cnf_range=cnf_range, sort_info_lst=cnf_sort_info_lst, hbond_cutoffs=hbond_cutoffs, print_enes=True, nprocs=nprocs) else: print(f'Using user specified conformer IDs: {user_conf_ids}') ini_rng_cnf_locs_lst = (user_conf_ids, ) # Check if locs exist, kill if it doesn't if not ini_rng_cnf_locs_lst: ioprinter.error_message('No min-energy conformer found for level:') else: # Set up the run scripts script_str, kwargs = qchem_params(method_dct) # Grab frequencies for the reference, print ref freqs if job == 'hess': if ini_cnf_save_fs[-1].file.harmonic_frequencies.exists( ini_rng_cnf_locs_lst[0]): frq = ini_cnf_save_fs[-1].file.harmonic_frequencies.read( ini_rng_cnf_locs_lst[0]) ref_val = frq else: ref_val = None if ref_val is not None and zrxn is not None: ref_path = cnf_save_fs[-1].path(ini_rng_cnf_locs_lst[0]) print('Found reference frequencies for saddle-point ' f'checks for conformer at\n {ref_path}') ioprinter.frequencies(ref_val) else: ref_val = None # Run the job over all the conformers requested by the user print('Going over all requested conformers for task...\n') for ini_locs in ini_rng_cnf_locs_lst: ini_cnf_run_fs[-1].create(ini_locs) geo_save_path = ini_cnf_save_fs[-1].path(ini_locs) ini_zma_save_fs = autofile.fs.zmatrix(geo_save_path) print('Running task for geometry at ', geo_save_path) geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read((0, )) ES_TSKS[job](zma, geo, spc_info, mod_thy_info, ini_cnf_run_fs, ini_cnf_save_fs, ini_locs, run_prefix, script_str, overwrite, zrxn=zrxn, retryfail=retryfail, method_dct=method_dct, ref_val=ref_val, **kwargs) print('\n === FINISHED CONF ===\n')