def _vtst_hess_ene(ts_info, coord_name, mod_thy_info, mod_vsp1_thy_info, scn_save_fs, scn_run_fs, overwrite, **cas_kwargs): """ VTST Hessians and Energies """ scn_locs = filesys.build.scn_locs_from_fs(scn_save_fs, [coord_name], constraint_dct=None) print('\n Running Hessians and Gradients...') hess_script_str, _, hess_kwargs, _ = qchem_params(*mod_thy_info[0:2]) hess_kwargs.update(cas_kwargs) for locs in scn_locs: geo_run_path = scn_run_fs[-1].path(locs) geo_save_path = scn_save_fs[-1].path(locs) scn_run_fs[-1].create(locs) zma, geo = filesys.inf.cnf_fs_zma_geo(scn_save_fs, locs) sp.run_hessian(zma, geo, ts_info, mod_thy_info, scn_save_fs, geo_run_path, geo_save_path, locs, hess_script_str, overwrite, **hess_kwargs) sp.run_gradient(zma, geo, ts_info, mod_thy_info, scn_save_fs, geo_run_path, geo_save_path, locs, hess_script_str, overwrite, **hess_kwargs) print('\n Running Energies...') script_str, _, ene_kwargs, _ = qchem_params(*mod_vsp1_thy_info[0:2]) ene_kwargs.update(cas_kwargs) for locs in scn_locs: geo_run_path = scn_run_fs[-1].path(locs) geo_save_path = scn_save_fs[-1].path(locs) scn_run_fs[-1].create(locs) zma, geo = filesys.inf.cnf_fs_zma_geo(scn_save_fs, locs) sp.run_energy(zma, geo, ts_info, mod_vsp1_thy_info, scn_save_fs, geo_run_path, geo_save_path, locs, script_str, overwrite, **ene_kwargs)
def multiref_rscan(ts_zma, ts_info, grid1, grid2, coord_name, mod_var_scn_thy_info, vscnlvl_thy_save_fs, scn_run_fs, scn_save_fs, overwrite, update_guess=True, constraint_dct=None, **cas_kwargs): """ run constrained optimization scan """ # Set the opt script string and build the opt_kwargs [prog, method, _, _] = mod_var_scn_thy_info _, opt_script_str, _, opt_kwargs = qchem_params( prog, method) opt_kwargs.update(cas_kwargs) # Run the scans run_two_way_scan( ts_zma, ts_info, mod_var_scn_thy_info, grid1, grid2, coord_name, vscnlvl_thy_save_fs, scn_run_fs, scn_save_fs, opt_script_str, overwrite, update_guess=update_guess, reverse_sweep=False, saddle=False, constraint_dct=constraint_dct, retryfail=False, **opt_kwargs )
def _scan_sp(ts_info, coord_name, vscnlvl_scn_run_fs, vscnlvl_scn_save_fs, mod_var_sp1_thy_info, overwrite, cas_kwargs): """ get sps for the scan; cas options and gen lines should be same """ # Set up script and kwargs for the irc run script_str, _, sp_kwargs, _ = qchem_params(*mod_var_sp1_thy_info[0:2]) sp_kwargs.update(cas_kwargs) # Compute the single-point energies along the scan for locs in vscnlvl_scn_save_fs[-1].existing([[coord_name]]): # Set up single point filesys vscnlvl_scn_run_fs[-1].create(locs) geo_run_path = vscnlvl_scn_run_fs[-1].path(locs) geo_save_path = vscnlvl_scn_save_fs[-1].path(locs) geo = vscnlvl_scn_save_fs[-1].file.geometry.read(locs) zma = vscnlvl_scn_save_fs[-1].file.zmatrix.read(locs) # Run the energy sp.run_energy(zma, geo, ts_info, mod_var_sp1_thy_info, vscnlvl_scn_save_fs, geo_run_path, geo_save_path, locs, script_str, overwrite, highspin=False, **sp_kwargs)
def write_elstruct_inp(lj_info, mod_lj_thy_info): """ writes the electronic structure input file """ # Unpack info objects [_, charge, mult] = lj_info [prog, method, basis, orb_lbl] = mod_lj_thy_info assert prog in ('gaussian09', 'gaussian16', 'molpro2015') # Get the job running options script_str, _, kwargs, _ = qchem_params(*mod_lj_thy_info[0:2]) # Write the string elstruct_inp_str = elstruct.writer.energy(geom='GEOMETRY', charge=charge, mult=mult, method=method, basis=basis, prog=prog, mol_options=('nosym', 'noorient'), memory=kwargs['memory'], comment='SAMPLE GEOM', orb_type=orb_lbl) elstruct_sp_str = '\n'.join(script_str.splitlines()[1:]) return elstruct_inp_str, elstruct_sp_str
def _remove_imag(spc_info, geo, mod_thy_info, thy_run_fs, run_fs, kickoff_size=0.1, kickoff_backward=False, overwrite=False): """ if there is an imaginary frequency displace geometry along the imaginary mode and then reoptimize """ print('The initial geometries will be checked for imaginary frequencies') script_str, opt_script_str, kwargs, opt_kwargs = qchem_params( *mod_thy_info[0:2]) imag, disp_xyzs = _check_imaginary(spc_info, geo, mod_thy_info, thy_run_fs, script_str, overwrite, **kwargs) # Make var to fix the imaginary mode if needed to pass to other functions imag_fix_needed = bool(imag) # Make five attempts to remove imag mode if found chk_idx = 0 while imag and chk_idx < 5: chk_idx += 1 print('Attempting kick off along mode, attempt {}...'.format(chk_idx)) geo = _kickoff_saddle(geo, disp_xyzs, spc_info, mod_thy_info, run_fs, thy_run_fs, opt_script_str, kickoff_size, kickoff_backward, opt_cart=True, **opt_kwargs) print('Removing faulty geometry from filesystem. Rerunning Hessian...') thy_run_path = thy_run_fs[-1].path(mod_thy_info[1:4]) run_fs = autofile.fs.run(thy_run_path) run_fs[-1].remove([elstruct.Job.HESSIAN]) print('Rerunning Hessian...') imag, disp_xyzs = _check_imaginary(spc_info, geo, mod_thy_info, thy_run_fs, script_str, overwrite, **kwargs) # Update kickoff size kickoff_size *= 2 return geo, imag_fix_needed
def geom_init(spc, thy_dct, es_keyword_dct, run_prefix, save_prefix, saddle): """ Find the initial geometry """ # Set the spc_info spc_info = filesys.inf.get_spc_info(spc) # Get es options [kickoff_size, kickoff_backward] = spc['kickoff'] overwrite = es_keyword_dct['overwrite'] # retryfail = es_keyword_dct['retryfail'] # Get the theory info ini_thy_info = filesys.inf.get_es_info(es_keyword_dct['inplvl'], thy_dct) thy_info = filesys.inf.get_es_info(es_keyword_dct['runlvl'], thy_dct) mod_thy_info = filesys.inf.modify_orb_restrict(spc_info, thy_info) mod_ini_thy_info = filesys.inf.modify_orb_restrict(spc_info, ini_thy_info) # Set the filesystem objects thy_run_fs, thy_run_path = filesys.build.spc_thy_fs_from_root( run_prefix, spc_info, mod_thy_info) thy_save_fs, thy_save_path = filesys.build.spc_thy_fs_from_root( save_prefix, spc_info, mod_thy_info) _, ini_thy_save_path = filesys.build.spc_thy_fs_from_root( save_prefix, spc_info, mod_ini_thy_info) cnf_save_fs = autofile.fs.conformer(thy_save_path) # Set the run filesystem if saddle: _, ts_path = filesys.build.ts_fs_from_thy(thy_run_path) run_fs = filesys.build.run_fs_from_prefix(ts_path) else: run_fs = filesys.build.run_fs_from_prefix(thy_run_path) # Set up the script _, opt_script_str, _, opt_kwargs = qchem_params(*thy_info[0:2]) # Get a reference geometry if one not found geo = geom.reference_geometry(spc, spc_info, mod_thy_info, thy_run_fs, thy_save_fs, cnf_save_fs, ini_thy_save_path, mod_ini_thy_info, run_fs, opt_script_str, overwrite, kickoff_size=kickoff_size, kickoff_backward=kickoff_backward, **opt_kwargs) return geo
def molrad_inf_sep_ene(rct_info, rcts_cnf_fs, mod_thy_info, overwrite): """ Calculate the inf spe ene for a mol-rad ene """ sp_script_str, _, kwargs, _ = qchem_params( *mod_thy_info[0:2]) inf_sep_ene = reac_sep_ene( rct_info, rcts_cnf_fs, mod_thy_info, overwrite, sp_script_str, **kwargs) return inf_sep_ene
def calc_vrctst_flux( ini_zma, ts_info, hs_info, ts_formula, high_mul, active_space, rct_info, rct_ichs, rct_zmas, rcts_cnf_fs, grid1, grid2, coord_name, mod_var_scn_thy_info, mod_var_sp1_thy_info, var_sp2_thy_info, hs_var_sp1_thy_info, hs_var_sp2_thy_info, vscnlvl_thy_save_fs, vscnlvl_ts_run_fs, vscnlvl_scn_run_fs, vscnlvl_scn_save_fs, vscnlvl_cscn_run_fs, vscnlvl_cscn_save_fs, overwrite, update_guess): """ Set up n VRC-TST calculations to get the flux file """ # Set vrc tst dct vrc_dct = _vrc_dct() # Set up the casscf options ref_zma = automol.zmatrix.set_values(ini_zma, {coord_name: grid1[0]}) cas_kwargs = wfn.build_wfn(ref_zma, ts_info, ts_formula, high_mul, rct_ichs, rct_info, active_space, mod_var_scn_thy_info) _, script_str, _, _ = qchem_params(mod_var_sp1_thy_info[0], mod_var_sp1_thy_info[1]) # Get indices for potentials and input bnd_frm_idxs = automol.zmatrix.coord_idxs(ini_zma, coord_name) min_idx, max_idx = min(bnd_frm_idxs), max(bnd_frm_idxs) bnd_frm_idxs = (bnd_frm_idxs[0] + 1, bnd_frm_idxs[1] + 1) # Build the VRC-TST run directory, including the needed scr dir vrc_path = _build_vrctst_fs(vscnlvl_ts_run_fs) # Calculate the correction potential along the MEP inf_sep_ene, npot, zma_for_inp = _build_correction_potential( ts_info, hs_info, ref_zma, coord_name, bnd_frm_idxs, grid1, grid2, rct_info, rcts_cnf_fs, rct_zmas, mod_var_scn_thy_info, mod_var_sp1_thy_info, hs_var_sp1_thy_info, var_sp2_thy_info, hs_var_sp2_thy_info, vscnlvl_scn_run_fs, vscnlvl_scn_save_fs, vscnlvl_cscn_run_fs, vscnlvl_cscn_save_fs, vscnlvl_thy_save_fs, overwrite, update_guess, vrc_dct, vrc_path, cas_kwargs) # Write remaining VaReCoF input files _write_varecof_input(zma_for_inp, ts_info, ts_formula, high_mul, rct_ichs, rct_info, rct_zmas, active_space, mod_var_sp1_thy_info, npot, inf_sep_ene, min_idx, max_idx, vrc_dct, vrc_path, script_str) # Run VaReCoF to generate flux file _run_varecof(vrc_path)
def molrad_scan(ts_zma, ts_info, rct_info, rcts_cnf_fs, rcts_gra, grid1, grid2, coord_name, frm_bnd_keys, thy_info, vsp1_thy_info, thy_save_fs, ts_save_fs, scn_run_fs, scn_save_fs, overwrite, update_guess, retryfail, zma_locs=(0, )): """ Run the scan for VTST calculations """ # Set the thy info objects appropriately if vsp1_thy_info is not None: inf_thy_info = vsp1_thy_info else: inf_thy_info = thy_info mod_thy_info = filesys.inf.modify_orb_restrict(ts_info, thy_info) mod_vsp1_thy_info = filesys.inf.modify_orb_restrict(ts_info, vsp1_thy_info) # Set script _, opt_script_str, _, opt_kwargs = qchem_params(*mod_thy_info[0:2]) # Setup and run the first part of the scan to shorte scan.run_two_way_scan( ts_zma, ts_info, mod_thy_info, grid1, grid2, coord_name, thy_save_fs, scn_run_fs, scn_save_fs, opt_script_str, overwrite, update_guess=update_guess, reverse_sweep=False, saddle=False, # opts along scan are min, not sadpt opts constraint_dct=None, retryfail=retryfail, **opt_kwargs) # Infinite seperation energy calculation print('\nCalculating infinite separation energy...') print('inf_thy_info', inf_thy_info) _ = scan.molrad_inf_sep_ene(rct_info, rcts_cnf_fs, inf_thy_info, overwrite) # Save the vmatrix for use in reading _save_traj(ts_zma, frm_bnd_keys, rcts_gra, ts_save_fs, zma_locs=zma_locs) print('\nRunning Hessians and energies...') _vtst_hess_ene(ts_info, coord_name, mod_thy_info, mod_vsp1_thy_info, scn_save_fs, scn_run_fs, overwrite, **{})
def find_vdw(ts_name, spc_dct, thy_info, ini_thy_info, vdw_params, nsamp_par, run_prefix, save_prefix, kickoff_size, kickoff_backward, overwrite): """ Find van der Waals structures for all the pairs of species in a reaction list. Fxn takes two species, performs a (random?) rotation, sticks them together and optimizes the combined geometry. Supposed to use the wells filesystem? """ new_vdws = [] _, opt_script_str, _, opt_kwargs = qchem_params(*thy_info[:2]) mul = spc_dct[ts_name]['low_mul'] vdw_names_lst = [] if vdw_params[0]: vdw_names_lst.append([sorted(spc_dct[ts_name]['reacs']), mul, 'r']) if vdw_params[1]: vdw_names_lst.append([sorted(spc_dct[ts_name]['prods']), mul, 'p']) for names, ts_mul, label in vdw_names_lst: if len(names) < 2: print('Cannot find van der Waals well for unimolecular', 'reactant or product') ichs = list(map(lambda name: spc_dct[name]['inchi'], names)) chgs = list(map(lambda name: spc_dct[name]['chg'], names)) muls = list(map(lambda name: spc_dct[name]['mul'], names)) # theory prog = thy_info[0] method = thy_info[1] _, opt_script_str, _, opt_kwargs = es_runner.qchem_params(prog, method) geos = [(), ()] ntaudof = 0. for i, (nam, ich, chg, mul) in enumerate(zip(names, ichs, chgs, muls)): spc_info = [ich, chg, mul] orb_restr = filesys.inf.orbital_restriction(spc_info, ini_thy_info) ini_g = ini_thy_info[0:3] ini_g.append(orb_restr) orb_restr = filesys.inf.orbital_restriction(spc_info, thy_info) thy_info = thy_info[0:3] thy_info.append(orb_restr) spc_run_fs = autofile.fs.species(run_prefix) spc_run_fs[-1].create(spc_info) spc_run_path = spc_run_fs[-1].path(spc_info) spc_save_fs = autofile.fs.species(save_prefix) spc_save_fs[-1].create(spc_info) spc_save_path = spc_save_fs[-1].path(spc_info) thy_run_fs = autofile.fs.theory(spc_run_path) thy_run_fs[-1].create(thy_info[1:4]) thy_run_path = thy_run_fs[-1].path(thy_info[1:4]) thy_save_fs = autofile.fs.theory(spc_save_path) thy_save_fs[-1].create(thy_info[1:4]) thy_save_path = thy_save_fs[-1].path(thy_info[1:4]) run_fs = autofile.fs.run(thy_run_path) ini_thy_save_fs = autofile.fs.theory(spc_save_path) ini_thy_save_fs[-1].create(ini_thy_info[1:4]) cnf_run_fs = autofile.fs.conformer(thy_run_path) cnf_save_fs = autofile.fs.conformer(thy_save_path) geo = geom.reference_geometry(spc_dct[nam], thy_info, ini_thy_info, thy_run_fs, thy_save_fs, ini_thy_save_fs, cnf_run_fs, cnf_save_fs, run_fs, kickoff_size=kickoff_size, kickoff_backward=kickoff_backward, overwrite=overwrite) geos[i] = geo gra = automol.geom.graph(geo) ntaudof += len( automol.graph.rotational_bond_keys(gra, with_h_rotors=False)) nsamp = util.nsamp_init(nsamp_par, ntaudof) geo1, geo2 = geos geo1 = automol.geom.mass_centered(geo1) geo2 = automol.geom.mass_centered(geo2) min_ene = 0. for idx in range(int(nsamp)): print('Optimizing vdw geometry {}/{}'.format(idx + 1, nsamp)) angs1 = numpy.multiply(numpy.random.rand(3), [1 * numpy.pi, 2 * numpy.pi, 2 * numpy.pi]) angs2 = numpy.multiply(numpy.random.rand(3), [1 * numpy.pi, 2 * numpy.pi, 2 * numpy.pi]) angs12 = numpy.multiply(numpy.random.rand(2), [1 * numpy.pi, 2 * numpy.pi]) geo1 = automol.geom.euler_rotate(geo1, *angs1) geo2 = automol.geom.euler_rotate(geo2, *angs2) dist_cutoff = 3.0 * phycon.ANG2BOHR geo = automol.geom.join(geo1, geo2, dist_cutoff, *angs12) print("Species: {}".format('+'.join(names))) print('vdw starting geometry') print(automol.geom.xyz_string(geo)) # Set up the filesystem ich = automol.inchi.recalculate(automol.inchi.join(ichs)) chg = sum(chgs) mul = ts_mul spc_info = (ich, chg, mul) spc_run_fs = autofile.fs.species(run_prefix) spc_run_fs[-1].create(spc_info) spc_run_path = spc_run_fs[-1].path(spc_info) spc_save_fs = autofile.fs.species(save_prefix) spc_save_fs[-1].create(spc_info) spc_save_path = spc_save_fs[-1].path(spc_info) orb_restr = filesys.inf.orbital_restriction(spc_info, thy_info) thy_info = thy_info[0:3] thy_info.append(orb_restr) thy_run_fs = autofile.fs.theory(spc_run_path) thy_run_fs[-1].create(thy_info[1:4]) thy_run_path = thy_run_fs[-1].path(thy_info[1:4]) thy_save_fs = autofile.fs.theory(spc_save_path) thy_save_fs[-1].create(thy_info[1:4]) thy_save_path = thy_save_fs[-1].path(thy_info[1:4]) run_fs = autofile.fs.run(thy_run_path) # Generate reference geometry # Generate the z-matrix and sampling ranges es_runner.run_job( job=elstruct.Job.OPTIMIZATION, geom=geo, spc_info=spc_info, th_info=thy_info, run_fs=run_fs, script_str=opt_script_str, overwrite=overwrite, **opt_kwargs, ) # Save info for the initial geometry (from ichi or fsave dir) success, ret = es_runner.read_job(job=elstruct.Job.OPTIMIZATION, run_fs=run_fs) if success: print('Saving reference geometry') print(" - Save path: {}".format(thy_save_path)) inf_obj, inp_str, out_str = ret prog = inf_obj.prog method = inf_obj.method geo = elstruct.reader.opt_geometry(prog, out_str) print('vdw ending geometry') print(automol.geom.xyz_string(geo)) thy_save_fs[-1].file.geometry.write(geo, thy_info[1:4]) ene = elstruct.reader.energy(prog, method, out_str) if ene < min_ene: min_ene = ene print('ene test in vdw') print(ene) thy_save_fs[-1].file.energy.write(ene, thy_info[1:4]) print('Saving reference geometry') print(" - Save path: {}".format(thy_save_path)) vdw_name = label + ts_name.replace('ts', 'vdw') spc_dct[vdw_name] = spc_dct[ts_name].copy() spc_dct[vdw_name]['inchi'] = ich spc_dct[vdw_name]['mul'] = mul spc_dct[vdw_name]['chg'] = chg spc_dct[vdw_name]['dist_info'][1] = dist_cutoff # Make a fake conformer cnf_save_fs = autofile.fs.conformer(thy_save_path) cnf_run_fs = autofile.fs.conformer(thy_run_path) cnf_save_fs[0].create() cnf_run_fs[0].create() tors_range_dct = {} cinf_obj = autofile.schema.info_objects.conformer[0]( 0, tors_range_dct) cinf_obj.nsamp = 1 cnf_save_fs[0].file.info.write(cinf_obj) locs_lst = cnf_save_fs[-1].existing() if not locs_lst: cid = autofile.schema.generate_new_conformer_id() locs = [cid] else: locs = locs_lst[0] cnf_save_fs[-1].create(locs) cnf_run_fs[-1].create(locs) cnf_save_fs[-1].file.geometry_info.write(inf_obj, locs) cnf_save_fs[-1].file.geometry_input.write(inp_str, locs) cnf_save_fs[-1].file.energy.write(ene, locs) cnf_save_fs[-1].file.geometry.write(geo, locs) if min_ene: new_vdws.append(vdw_name) return new_vdws
def irc_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 = spc_dct[spc_name] # Set up coordinate name coord_name = ['IRC'] # Set the spc_info spc_info = filesys.inf.get_spc_info(spc) # Modify the theory ini_thy_info = filesys.inf.get_es_info(es_keyword_dct['inplvl'], thy_dct) thy_info = filesys.inf.get_es_info(es_keyword_dct['runlvl'], thy_dct) mod_thy_info = filesys.inf.modify_orb_restrict(spc_info, thy_info) mod_ini_thy_info = filesys.inf.modify_orb_restrict(spc_info, ini_thy_info) # Get options from the dct or es options lst overwrite = es_keyword_dct['overwrite'] # retryfail = es_keyword_dct['retryfail'] # Set up the script _, opt_script_str, _, opt_kwargs = qchem_params(*mod_thy_info[0:2]) # Set the filesystem objects rxn_info = filesys.inf.rxn_info(spc['reacs'], spc['prods'], spc_dct) _, thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_thy_info) _, thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_thy_info) _, thy_save_path = filesys.build.ts_fs_from_thy(thy_save_path) _, thy_run_path = filesys.build.ts_fs_from_thy(thy_run_path) _, ini_thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_ini_thy_info) _, ini_thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_ini_thy_info) _, ini_ts_save_path = filesys.build.ts_fs_from_thy(ini_thy_save_path) _, ini_ts_run_path = filesys.build.ts_fs_from_thy(ini_thy_run_path) # Build cnf filesys using the ini thy filesys (needed for all HR jobs) ini_cnf_run_fs = autofile.fs.conformer(ini_thy_run_path) ini_cnf_save_fs = autofile.fs.conformer(ini_thy_save_path) ini_min_cnf_locs = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_cnf_save_paths = filesys.build.cnf_paths_from_locs( ini_cnf_save_fs, ini_min_cnf_locs) ini_cnf_run_paths = filesys.build.cnf_paths_from_locs( ini_cnf_run_fs, ini_min_cnf_locs) ini_cnf_run_fs[-1].create(ini_min_cnf_locs) # Set up ini filesystem for scans _, ini_zma_save_path = filesys.build.zma_fs_from_prefix( ini_cnf_save_paths[0], zma_idxs=[0]) ini_scn_save_fs = filesys.build.scn_fs_from_cnf(ini_zma_save_path, constraint_dct=None) _, ini_zma_run_path = filesys.build.zma_fs_from_prefix( ini_cnf_run_paths[0], zma_idxs=[0]) ini_scn_run_fs = filesys.build.scn_fs_from_cnf(ini_zma_run_path, constraint_dct=None) # Get the zma an geo zma, geo = filesys.inf.cnf_fs_zma_geo(ini_cnf_save_fs, ini_min_cnf_locs) # Run job if job == 'scan': # Script _, opt_script_str, _, opt_kwargs = qchem_params(*mod_thy_info[0:2]) opt_kwargs.update( {'job_options': ['calcall', 'stepsize=3', 'maxpoints=4']}) irc.scan(geo, spc_info, mod_ini_thy_info, coord_name, ini_scn_save_fs, ini_cnf_run_paths[0], overwrite, opt_script_str, **opt_kwargs) elif job in ('energy', 'grad', 'hess'): # Script script_str, _, kwargs, _ = qchem_params(*mod_thy_info[0:2]) # Need to put in something with the IRC idxs scn_locs = filesys.build.scn_locs_from_fs(ini_scn_save_fs, coord_name, constraint_dct=None) 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) zma, geo = filesys.inf.cnf_fs_zma_geo(ini_scn_save_fs, 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, **kwargs) print('\n')
def hr_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix, saddle): """ run a scan over the specified torsional coordinates """ spc = spc_dct[spc_name] # Set the spc_info spc_info = filesys.inf.get_spc_info(spc) # Modify the theory ini_thy_info = filesys.inf.get_es_info(es_keyword_dct['inplvl'], thy_dct) thy_info = filesys.inf.get_es_info(es_keyword_dct['runlvl'], thy_dct) mod_thy_info = filesys.inf.modify_orb_restrict(spc_info, thy_info) mod_ini_thy_info = filesys.inf.modify_orb_restrict(spc_info, ini_thy_info) # Script _, opt_script_str, _, opt_kwargs = qchem_params(*mod_thy_info[0:2]) # Set the filesystem objects if not saddle: _, ini_thy_run_path = filesys.build.spc_thy_fs_from_root( run_prefix, spc_info, mod_ini_thy_info) inifs = filesys.build.spc_thy_fs_from_root(save_prefix, spc_info, mod_ini_thy_info) [ini_thy_save_fs, ini_thy_save_path] = inifs else: rxn_info = filesys.inf.rxn_info(spc['reacs'], spc['prods'], spc_dct) _, ini_thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_ini_thy_info) _, ini_thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_ini_thy_info) inifs = filesys.build.ts_fs_from_thy(ini_thy_save_path) [ini_thy_save_fs, ini_thy_save_path] = inifs _, ini_thy_run_path = filesys.build.ts_fs_from_thy(ini_thy_run_path) # Build cnf filesys using the ini thy filesys (needed for all HR jobs) ini_cnf_run_fs = autofile.fs.conformer(ini_thy_run_path) ini_cnf_save_fs = autofile.fs.conformer(ini_thy_save_path) ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_cnf_locs, ini_cnf_save_path = ini_loc_info ini_cnf_run_path = filesys.build.cnf_paths_from_locs( ini_cnf_run_fs, [ini_min_cnf_locs])[0] # Create run fs if that directory has been deleted to run the jobs ini_cnf_run_fs[-1].create(ini_min_cnf_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'] scan_increment = spc['hind_inc'] # Bond key stuff if saddle: frm_bnd_keys, brk_bnd_keys = structure.ts.rxn_bnd_keys( ini_cnf_save_fs, ini_min_cnf_locs, zma_locs=[0]) else: frm_bnd_keys, brk_bnd_keys = (), () # Read fs for zma and geo zma, geo = filesys.inf.cnf_fs_zma_geo(ini_cnf_save_fs, ini_min_cnf_locs) # Set up the torsion info run_tors_names = structure.tors.tors_name_prep(spc, ini_cnf_save_fs, ini_min_cnf_locs, tors_model) print('run_tors_names', run_tors_names) run_tors_names, run_tors_grids, _ = structure.tors.hr_prep( zma, tors_name_grps=run_tors_names, scan_increment=scan_increment, tors_model=tors_model, frm_bnd_keys=frm_bnd_keys, brk_bnd_keys=brk_bnd_keys) print('run_tors_names', run_tors_names) # Run the task if any torsions exist if run_tors_names: # Set constraints const_names = structure.tors.set_constraint_names( zma, run_tors_names, tors_model) # Set if scan is rigid or relaxed scn_typ = 'relaxed' if tors_model != '1dhrfa' else 'rigid' # Set up ini filesystem for scans _, ini_zma_run_path = filesys.build.zma_fs_from_prefix( ini_cnf_run_path, zma_idxs=[0]) _, ini_zma_save_path = filesys.build.zma_fs_from_prefix( ini_cnf_save_path, zma_idxs=[0]) if job == 'scan': # Run the scan hr.hindered_rotor_scans(zma, spc_info, mod_thy_info, ini_thy_save_fs, ini_zma_run_path, ini_zma_save_path, run_tors_names, run_tors_grids, opt_script_str, overwrite, scn_typ=scn_typ, saddle=saddle, const_names=const_names, retryfail=retryfail, **opt_kwargs) # 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 = {}, {} for tors_names, tors_grids in zip(run_tors_names, run_tors_grids): constraint_dct = structure.tors.build_constraint_dct( zma, const_names, tors_names) pot, _, _, _, zmas, _ = structure.tors.read_hr_pot( 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 # Print potential structure.tors.print_hr_pot(tors_pots) elif job == 'reopt': # pull stuff from dcts two_stage = saddle rxn_class = spc['class'] if saddle else '' mc_nsamp = spc['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 = structure.tors.build_constraint_dct( zma, const_names, tors_names) pot, _, _, _, zmas, paths = structure.tors.read_hr_pot( 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 = structure.tors.check_hr_pot(tors_pots, tors_zmas, tors_paths, emax=ethresh) if new_min_zma is not None: print('\nFinding new low energy conformer...') conformer.single_conformer(zma, spc_info, mod_thy_info, ini_cnf_run_fs, ini_cnf_save_fs, opt_script_str, overwrite, retryfail=retryfail, saddle=saddle, **opt_kwargs) elif job in ('energy', 'grad', 'hess', 'vpt2'): script_str, _, kwargs, _ = qchem_params(*thy_info[0:2]) for tors_names in run_tors_names: # Set the constraint dct and filesys for the scan constraint_dct = structure.tors.build_constraint_dct( zma, const_names, tors_names) ini_scn_run_fs = filesys.build.scn_fs_from_cnf( ini_zma_run_path, constraint_dct=constraint_dct) ini_scn_save_fs = filesys.build.scn_fs_from_cnf( ini_zma_save_path, constraint_dct=constraint_dct) scn_locs = filesys.build.scn_locs_from_fs( ini_scn_save_fs, tors_names, constraint_dct=constraint_dct) if 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) print('\n') else: print('*WARNING: NO SCAN INFORMATION EXISTS.', 'Doing scan vs cscan?') else: print('No torsional modes in the species')
def conformer_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix, saddle): """ 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, .. """ spc = spc_dct[spc_name] # Set the spc_info spc_info = filesys.inf.get_spc_info(spc) # Get es options overwrite = es_keyword_dct['overwrite'] retryfail = es_keyword_dct['retryfail'] # Modify the theory ini_thy_info = filesys.inf.get_es_info(es_keyword_dct['inplvl'], thy_dct) thy_info = filesys.inf.get_es_info(es_keyword_dct['runlvl'], thy_dct) mod_thy_info = filesys.inf.modify_orb_restrict(spc_info, thy_info) mod_ini_thy_info = filesys.inf.modify_orb_restrict(spc_info, ini_thy_info) # Set the filesystem objects if not saddle: _, ini_thy_run_path = filesys.build.spc_thy_fs_from_root( run_prefix, spc_info, mod_ini_thy_info) ini_thy_fs = filesys.build.spc_thy_fs_from_root( save_prefix, spc_info, mod_ini_thy_info) [_, ini_thy_save_path] = ini_thy_fs else: rxn_info = filesys.inf.rxn_info(spc['reacs'], spc['prods'], spc_dct) _, ini_thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_ini_thy_info) _, ini_thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_ini_thy_info) _, ini_thy_save_path = filesys.build.ts_fs_from_thy(ini_thy_save_path) _, ini_thy_run_path = filesys.build.ts_fs_from_thy(ini_thy_run_path) # Build the thy filesyste if not saddle: _, thy_run_path = filesys.build.spc_thy_fs_from_root( run_prefix, spc_info, mod_thy_info) thy_save_fs, thy_save_path = filesys.build.spc_thy_fs_from_root( save_prefix, spc_info, mod_thy_info) else: _, thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_thy_info) thy_save_fs, thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_thy_info) thy_save_fs, thy_save_path = filesys.build.ts_fs_from_thy( thy_save_path) _, thy_run_path = filesys.build.ts_fs_from_thy(thy_run_path) if job == 'samp': # Build conformer filesys cnf_run_fs = autofile.fs.conformer(thy_run_path) cnf_save_fs = autofile.fs.conformer(thy_save_path) # Build the ini zma filesys # ini_cnf_run_fs = autofile.fs.conformer(ini_thy_run_path) ini_cnf_save_fs = autofile.fs.conformer(ini_thy_save_path) ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_cnf_locs, ini_min_cnf_path = ini_loc_info ini_zma_save_fs, _ = filesys.build.zma_fs_from_prefix(ini_min_cnf_path, zma_idxs=[0]) # Set up the run scripts _, opt_script_str, _, opt_kwargs = qchem_params(*thy_info[0:2]) # Set variables if it is a saddle two_stage = saddle rxn_class = spc['class'] if saddle else '' mc_nsamp = spc['mc_nsamp'] # Read the geometry and zma from the ini file system if not saddle: geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_cnf_locs) zma = ini_zma_save_fs[-1].file.zmatrix.read([0]) tors_names = automol.geom.zmatrix_torsion_coordinate_names(geo) geo_path = ini_cnf_save_fs[-1].path(ini_min_cnf_locs) else: print('ini path', ini_thy_save_path) geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_cnf_locs) # geo = ini_thy_save_fs[0].file.geometry.read() zma = ini_zma_save_fs[-1].file.zmatrix.read([0]) tors_names = spc['amech_ts_tors_names'] # geo_path = thy_save_fs[0].path() geo_path = ini_cnf_save_fs[-1].path(ini_min_cnf_locs) print('Sampling done using geom from {}'.format(geo_path)) # Run the sampling _ = conformer.conformer_sampling(zma, spc_info, mod_thy_info, thy_save_fs, cnf_run_fs, cnf_save_fs, opt_script_str, overwrite, saddle=saddle, nsamp_par=mc_nsamp, tors_names=tors_names, two_stage=two_stage, retryfail=retryfail, rxn_class=rxn_class, **opt_kwargs) elif job == 'opt': cnf_range = es_keyword_dct['cnf_range'] print('range', cnf_range) # Set up the run scripts _, opt_script_str, _, opt_kwargs = qchem_params(*mod_thy_info[0:2]) # Build conformer filesys cnf_run_fs = autofile.fs.conformer(thy_run_path) cnf_save_fs = autofile.fs.conformer(thy_save_path) cnf_locs_lst, _ = filesys.mincnf.conformer_locators(cnf_save_fs, mod_thy_info, cnf_range='all') ini_cnf_save_fs = autofile.fs.conformer(ini_thy_save_path) ini_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_locs_lst = conformer.unique_fs_confs(cnf_save_fs, cnf_locs_lst, ini_cnf_save_fs, ini_cnf_locs_lst) print('uni lst', uni_locs_lst) for locs in uni_locs_lst: zma, geo = filesys.inf.cnf_fs_zma_geo(ini_cnf_save_fs, locs) cnf_run_fs[-1].create(locs) conformer.single_conformer(zma, spc_info, mod_thy_info, cnf_run_fs, cnf_save_fs, opt_script_str, overwrite, retryfail=retryfail, saddle=saddle, **opt_kwargs) print_cnf_locs_lst, _ = filesys.mincnf.conformer_locators( cnf_save_fs, mod_thy_info, cnf_range=cnf_range) for locs in print_cnf_locs_lst: geo = cnf_save_fs[-1].file.geometry.read(locs) print('Geometry: \n{}'.format(automol.geom.string(geo))) elif job in ('energy', 'grad', 'hess', 'vpt2', 'prop'): cnf_range = es_keyword_dct['cnf_range'] # print('range', cnf_range) ini_cnf_run_fs = autofile.fs.conformer(ini_thy_run_path) ini_cnf_save_fs = autofile.fs.conformer(ini_thy_save_path) ini_cnf_save_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_cnf_save_locs_lst: print('*ERROR: No min-energy conformer found for level:', ini_thy_save_path) sys.exit() # Set up the run scripts script_str, _, kwargs, _ = qchem_params(*mod_thy_info[0:2]) # Run the job over all the conformers requested by the user for locs in ini_cnf_save_locs_lst: print('\n\nRunning task for cnf locs', locs) geo_run_path = ini_cnf_run_fs[-1].path(locs) geo_save_path = ini_cnf_save_fs[-1].path(locs) ini_cnf_run_fs[-1].create(locs) zma, geo = filesys.inf.cnf_fs_zma_geo(ini_cnf_save_fs, locs) ES_TSKS[job](zma, geo, spc_info, mod_thy_info, ini_cnf_save_fs, geo_run_path, geo_save_path, locs, script_str, overwrite, retryfail=retryfail, **kwargs)
def run_sadpt(spc_dct, tsname, es_keyword_dct, method_dct, runfs_dct, savefs_dct, info_dct, grid): """ find a transition state """ # Get es options overwrite = es_keyword_dct['overwrite'] update_guess = False # check # Get dct for specific species task is run for ts_dct = spc_dct[tsname] # Build inf objects for the rxn and ts ts_info = info_dct['ts_info'] # Set various TS information using the dictionary ini_zma = ts_dct['zma'] typ = ts_dct['class'] frm_bnd_keys = ts_dct['frm_bnd_keys'] brk_bnd_keys = ts_dct['brk_bnd_keys'] rcts_gra = ts_dct['rcts_gra'] # tors_names = ts_dct['amech_ts_tors_names'] # Get reaction coordinates frm_name = automol.zmatrix.bond_key_from_idxs(ini_zma, frm_bnd_keys) brk_name = automol.zmatrix.bond_key_from_idxs(ini_zma, brk_bnd_keys) # Constraint dcts for saddle point searches const_bnd_key = ts_dct['const_bnd_key'] const_tors_names = ts_dct['const_tors_names'] const_angs_names = ts_dct['const_angs_names'] constraint_dct = {} if const_bnd_key: const_name = automol.zmatrix.bond_key_from_idxs(ini_zma, const_bnd_key) coords = automol.zmatrix.values(ini_zma) const_val = coords[const_name] constraint_dct[const_name] = const_val if const_tors_names: coords = automol.zmatrix.values(ini_zma) for const_tors_name in const_tors_names: const_val = coords[const_tors_name] constraint_dct[const_tors_name] = const_val if const_angs_names: coords = automol.zmatrix.values(ini_zma) for const_angs_name in const_angs_names: const_val = coords[const_angs_name] constraint_dct[const_angs_name] = const_val if not constraint_dct: constraint_dct = None print('constraints in ts scan', constraint_dct) # Get method stuff mod_ini_thy_info = method_dct['inplvl'] mod_thy_info = method_dct['runlvl'] # Get filesys stuff _, ts_run_path = runfs_dct['runlvl_ts_fs'] _, thy_run_path = runfs_dct['runlvl_thy_fs'] _, ini_ts_save_path = savefs_dct['inilvl_ts_fs'] thy_save_fs, thy_save_path = savefs_dct['runlvl_thy_fs'] cnf_save_fs, cnf_save_locs = savefs_dct['runlvl_cnf_fs'] ts_save_fs, ts_save_path = savefs_dct['runlvl_ts_fs'] run_fs = autofile.fs.run(ts_run_path) # Find the TS if cnf_save_locs and not overwrite: print('TS found and saved previously in ', cnf_save_fs[-1].path(cnf_save_locs)) else: print('No transition state found in filesys', 'at {} level...'.format(es_keyword_dct['runlvl']), 'Proceeding to find it...') script_str, opt_script_str, _, opt_kwargs = qchem_params( *mod_thy_info[0:2]) sadpt.sadpt_transition_state( ini_zma, ts_info, mod_ini_thy_info, mod_thy_info, thy_run_path, thy_save_path, thy_save_fs, ini_ts_save_path, cnf_save_fs, ts_save_fs, ts_save_path, run_fs, typ, grid, update_guess, frm_name, brk_name, frm_bnd_keys, brk_bnd_keys, rcts_gra, opt_script_str, script_str, overwrite, es_keyword_dct, constraint_dct, **opt_kwargs)
def radrad_inf_sep_ene(hs_info, ref_zma, rct_info, rcts_cnf_fs, var_sp1_thy_info, var_sp2_thy_info, hs_var_sp1_thy_info, hs_var_sp2_thy_info, geo, geo_run_path, geo_save_path, scn_save_fs, inf_locs, overwrite=False, **cas_kwargs): """ Obtain the infinite separation energy from the multireference energy at a given reference point, the high-spin low-spin splitting at that reference point, and the high level energy for the high spin state at the reference geometry and for the fragments scn = thy for optimizations sp1 = low-spin single points sp2 = high-spin single points for inf sep inf = spc0 + spc1 - hs_sr_e + hs_mr_ene """ # Initialize infinite sep energy inf_sep_ene = -1.0e12 # Calculate the energies for the two cases hs_inf = (hs_var_sp2_thy_info, hs_var_sp1_thy_info) for idx, thy_info in enumerate(hs_inf): if idx == 0: print(" - Running high-spin single reference energy ...") else: print(" - Running high-spin multi reference energy ...") # Calculate the single point energy script_str, _, kwargs, _ = qchem_params(*thy_info[0:2]) cas_kwargs.update(kwargs) sp.run_energy(ref_zma, geo, hs_info, thy_info, scn_save_fs, geo_run_path, geo_save_path, inf_locs, script_str, overwrite, highspin=True, **cas_kwargs) # Read the energty from the filesystem hs_save_fs, _ = filesys.build.high_spin_from_prefix( geo_save_path, thy_info) if not hs_save_fs[-1].file.energy.exists(thy_info[1:4]): print('ERROR: High-spin energy job failed: ', 'energy is needed to evaluate infinite separation energy') ene = None else: print(" - Reading high-spin energy from filesystem...") ene = hs_save_fs[-1].file.energy.read(thy_info[1:4]) if idx == 0: hs_sr_ene = ene else: hs_mr_ene = ene # Get the single reference energy for each of the reactant configurations for thy_inf in (var_sp1_thy_info, var_sp2_thy_info): sp_script_str, _, kwargs, _ = qchem_params( *var_sp2_thy_info[0:2]) reac_ene = reac_sep_ene( rct_info, rcts_cnf_fs, thy_inf, overwrite, sp_script_str, **kwargs) # Calculate the infinite seperation energy all_enes = (reac_ene, hs_sr_ene, hs_mr_ene) if all(ene is not None for ene in all_enes): inf_sep_ene = reac_ene - hs_sr_ene + hs_mr_ene else: inf_sep_ene = None return inf_sep_ene
def run(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix): """ find a transition state """ var_sp1_thy_info, var_sp2_thy_info, var_scn_thy_info = None, None, None # Get dct for specific species task is run for ts_dct = spc_dct[spc_name] # Build inf objects for the rxn and ts ts_info = ('', spc_dct[spc_name]['charge'], spc_dct[spc_name]['mult']) rxn_info = filesys.inf.rxn_info( spc_dct[spc_name]['reacs'], spc_dct[spc_name]['prods'], spc_dct) # Set various TS information using the dictionary ini_zma = ts_dct['zma'] typ = ts_dct['class'] dist_info = ts_dct['dist_info'] dist_name, _, update_guess, brk_name, _ = dist_info frm_bnd_keys = ts_dct['frm_bnd_keys'] brk_bnd_keys = ts_dct['brk_bnd_keys'] rcts_gra = ts_dct['rcts_gra'] const_bnd_key = ts_dct['const_bnd_key'] const_tors_names = ts_dct['const_tors_names'] const_angs_names = ts_dct['const_angs_names'] constraint_dct = {} if const_bnd_key: const_name = automol.zmatrix.bond_key_from_idxs( ini_zma, const_bnd_key) coords = automol.zmatrix.values(ini_zma) const_val = coords[const_name] constraint_dct[const_name] = const_val if const_tors_names: coords = automol.zmatrix.values(ini_zma) for const_tors_name in const_tors_names: const_val = coords[const_tors_name] constraint_dct[const_tors_name] = const_val if const_angs_names: coords = automol.zmatrix.values(ini_zma) for const_angs_name in const_angs_names: const_val = coords[const_angs_name] constraint_dct[const_angs_name] = const_val if not constraint_dct: constraint_dct = None print('constraints in ts scan', constraint_dct) # set ts searching algorithm and grid info typ = ts_dct['class'] if 'ts_search' in ts_dct: ts_search = ts_dct['ts_search'] usr_choice = True elif 'ts_search' not in ts_dct and 'rad' in typ and 'low' in typ: ts_search = 'vtst' usr_choice = False else: ts_search = 'sadpt' usr_choice = False # elif 'ts_search' not in ts_dct and 'rad' not in typ: if ts_search in ('vtst', 'vrctst'): if 'rad' in typ: grid = ts_dct['grid'] else: grid = ts_dct['var_grid'] else: grid = ts_dct['grid'] # Get es options vrc_dct = {} overwrite = es_keyword_dct['overwrite'] nobar_mod = es_keyword_dct['nobarrier'] # Modify the theory ini_thy_info = filesys.inf.get_es_info( es_keyword_dct['inplvl'], thy_dct) thy_info = filesys.inf.get_es_info( es_keyword_dct['runlvl'], thy_dct) mod_thy_info = filesys.inf.modify_orb_restrict(ts_info, thy_info) mod_ini_thy_info = filesys.inf.modify_orb_restrict(ts_info, ini_thy_info) # Build filesys for thy info for single reference _, thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_thy_info) thy_save_fs, thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_thy_info) # Build filesys for ini thy info for single reference _, ini_thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_ini_thy_info) # Build the ts fs ts_save_fs, ts_save_path = filesys.build.ts_fs_from_thy(thy_save_path) _, ts_run_path = filesys.build.ts_fs_from_thy(thy_run_path) run_fs = autofile.fs.run(ts_run_path) # Build the ts fs (only need save to see if guess zmat can be found) _, ini_ts_save_path = filesys.build.ts_fs_from_thy( ini_thy_save_path) # Set the cnf fs to see if TS is available or for searching cnf_save_fs = autofile.fs.conformer(ts_save_path) min_cnf_locs, _ = filesys.mincnf.min_energy_conformer_locators( cnf_save_fs, mod_thy_info) # Find the transition state using the appropriate algorithm switch = False _print_ts_method( ts_dct, ts_search, usr_choice, es_keyword_dct['nobarrier']) # Run multireference VTST or VRCTST TS Search if _radrad_barrierless_search(ts_dct, ts_search): print('VRCTST/VTST') # Modify the theory hs_info = (ts_info[0], ts_info[1], ts_dct['high_mult']) mod_var_scn_thy_info = filesys.inf.modify_orb_restrict( ts_info, var_scn_thy_info) hs_var_scn_thy_info = filesys.inf.modify_orb_restrict( hs_info, var_scn_thy_info) mod_var_sp1_thy_info = filesys.inf.modify_orb_restrict( ts_info, var_sp1_thy_info) hs_var_sp1_thy_info = filesys.inf.modify_orb_restrict( hs_info, var_sp1_thy_info) if var_sp2_thy_info is not None: mod_var_sp2_thy_info = filesys.inf.modify_orb_restrict( ts_info, var_sp2_thy_info) hs_var_sp2_thy_info = filesys.inf.modify_orb_restrict( hs_info, var_sp2_thy_info) else: mod_var_sp2_thy_info = None hs_var_sp2_thy_info = None # Build multireference thy info objects if mod_var_scn_thy_info: _, thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_var_scn_thy_info) _, thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_var_scn_thy_info) scn_run_fs = autofile.fs.scan(thy_run_path) scn_save_fs = autofile.fs.scan(thy_save_path) else: print('Need mlvl specified') if mod_var_sp1_thy_info: _, thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_var_sp1_thy_info) _, thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_var_sp1_thy_info) else: print('Need mlvl specified') if mod_var_sp2_thy_info: _, thy_run_path = filesys.build.rxn_thy_fs_from_root( run_prefix, rxn_info, mod_var_sp2_thy_info) _, thy_save_path = filesys.build.rxn_thy_fs_from_root( save_prefix, rxn_info, mod_var_sp2_thy_info) else: print('Need mlvl specified') # Set up the scan filesys (need scan and cscan for rc scn_run_fs = autofile.fs.scan(thy_run_path) scn_save_fs = autofile.fs.scan(thy_save_path) # Run the barrierless transition state barrierless_transition_state( ts_info, ini_zma, ts_dct, spc_dct, grid, dist_name, nobar_mod, mod_ini_thy_info, mod_thy_info, mod_var_scn_thy_info, mod_var_sp1_thy_info, mod_var_sp2_thy_info, hs_var_scn_thy_info, hs_var_sp1_thy_info, hs_var_sp2_thy_info, run_prefix, save_prefix, scn_run_fs, scn_save_fs, overwrite, vrc_dct, update_guess) # Print switch message if switch: print('Analysis of computed surface suggests saddle point.') print('Attempting to find saddle point using surface...') print('ts_dct_grid test:', ts_dct['grid']) # Run single reference mol-rad VTST Search if _molrad_barrierless_search(ts_dct, ts_search): rcts = ts_dct['reacs'] spc_1_info = [spc_dct[rcts[0]]['inchi'], spc_dct[rcts[0]]['charge'], spc_dct[rcts[0]]['mult']] spc_2_info = [spc_dct[rcts[1]]['inchi'], spc_dct[rcts[1]]['charge'], spc_dct[rcts[1]]['mult']] [grid1, grid2] = grid print('in barrierless search', grid1, grid2, grid) # Set up the scan filesys (need scan and cscan for rc scn_run_fs = autofile.fs.scan(thy_run_path) scn_save_fs = autofile.fs.scan(thy_save_path) vtst.molrad_scan( ini_zma, ts_info, spc_1_info, spc_2_info, grid1, grid2, dist_name, thy_info, ini_thy_info, var_sp1_thy_info, scn_run_fs, scn_save_fs, run_prefix, save_prefix, overwrite, update_guess) # Run single/multi reference mol-rad Saddle Point Search if _sadpt_search(ts_dct, ts_search, switch): # ts_found = False if min_cnf_locs and not overwrite: print('TS found and saved previously in ', cnf_save_fs[-1].path(min_cnf_locs)) else: print('No transition state found in filesys', 'at {} level...'.format(es_keyword_dct['runlvl']), 'Proceeding to find it...') script_str, opt_script_str, _, opt_kwargs = qchem_params( *mod_thy_info[0:2]) sadpt_transition_state( ini_zma, ts_info, mod_ini_thy_info, mod_thy_info, thy_run_path, thy_save_path, thy_save_fs, ini_ts_save_path, cnf_save_fs, ts_save_fs, ts_save_path, run_fs, typ, grid, update_guess, dist_name, brk_name, frm_bnd_keys, brk_bnd_keys, rcts_gra, opt_script_str, script_str, overwrite, es_keyword_dct, constraint_dct, **opt_kwargs)
def tau_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix, save_prefix, saddle): """ Energies, gradients, and hessians, for set of arbitrarily sampled torsional coordinates with all other coordinates optimized """ spc = spc_dct[spc_name] # Set the spc_info spc_info = filesys.inf.get_spc_info(spc) # Get es options overwrite = es_keyword_dct['overwrite'] retryfail = es_keyword_dct['retryfail'] scan_increment = spc['hind_inc'] nsamp_par = spc['tau_nsamp'] # Modify the theory ini_thy_info = filesys.inf.get_es_info(es_keyword_dct['inplvl'], thy_dct) thy_info = filesys.inf.get_es_info(es_keyword_dct['runlvl'], thy_dct) mod_thy_info = filesys.inf.modify_orb_restrict(spc_info, thy_info) mod_ini_thy_info = filesys.inf.modify_orb_restrict(spc_info, ini_thy_info) # Script _, opt_script_str, _, opt_kwargs = qchem_params(*thy_info[0:2]) # Set the filesystem objects for thy info _, thy_run_path = filesys.build.spc_thy_fs_from_root( run_prefix, spc_info, mod_thy_info) _, thy_save_path = filesys.build.spc_thy_fs_from_root( save_prefix, spc_info, mod_thy_info) # Set the filesystem objects for ini thy_info _, ini_thy_save_path = filesys.build.spc_thy_fs_from_root( save_prefix, spc_info, mod_ini_thy_info) # Get the geom and energy of reference species ini_cnf_save_fs = autofile.fs.conformer(ini_thy_save_path) ini_loc_info = filesys.mincnf.min_energy_conformer_locators( ini_cnf_save_fs, mod_ini_thy_info) ini_min_cnf_locs, ini_min_cnf_path = ini_loc_info zma, geo = filesys.inf.cnf_fs_zma_geo(ini_cnf_save_fs, ini_min_cnf_locs) ini_sp_save_fs = autofile.fs.single_point(ini_min_cnf_path) if ini_sp_save_fs[-1].file.energy.exists(mod_ini_thy_info[1:4]): ref_ene = ini_sp_save_fs[-1].file.energy.read(mod_ini_thy_info[1:4]) else: ref_ene = ini_cnf_save_fs[-1].file.energy.read(ini_min_cnf_locs) # Bond key stuff if saddle: frm_bnd_keys, brk_bnd_keys = structure.ts.rxn_bnd_keys( ini_cnf_save_fs, ini_min_cnf_locs, zma_locs=[0]) else: frm_bnd_keys, brk_bnd_keys = (), () # Set up the torsion info dct_tors_names, _ = structure.tors.names_from_dct(spc, '1dhr') amech_spc_tors_names = structure.tors.names_from_geo(geo, '1dhr', saddle=saddle) if dct_tors_names: run_tors_names = dct_tors_names else: run_tors_names = amech_spc_tors_names print('Using tors names generated by AutoMech...') run_tors_names, _, _ = structure.tors.hr_prep( zma, tors_name_grps=run_tors_names, scan_increment=scan_increment, tors_model='1dhr', frm_bnd_keys=frm_bnd_keys, brk_bnd_keys=brk_bnd_keys) # Run the task if any torsions exist if run_tors_names: # Set up tau filesystem objects tau_run_fs, _ = filesys.build.tau_fs_from_thy(thy_run_path, tau='all') tau_save_fs, tau_save_locs = filesys.build.tau_fs_from_thy( thy_save_path, tau='all') # db_style = 'jsondb' db_style = 'directory' if db_style == 'jsondb': tau_save_fs[-1].root.create() tau_save_fs[-1].json_create() for locs in tau_save_locs: if tau_save_fs[-1].file.geometry.exists(locs): geol = tau_save_fs[-1].file.geometry.read(locs) tau_save_fs[-1].json.geometry.write(geol, locs) if tau_save_fs[-1].file.energy.exists(locs): enel = tau_save_fs[-1].file.energy.read(locs) tau_save_fs[-1].json.energy.write(enel, locs) if tau_save_fs[-1].file.geometry_info.exists(locs): geo_infl = tau_save_fs[-1].file.geometry_info.read(locs) tau_save_fs[-1].json.geometry_info.write(geo_infl, locs) if tau_save_fs[-1].file.geometry_input.exists(locs): inp_strl = tau_save_fs[-1].file.geometry_input.read(locs) tau_save_fs[-1].json.geometry_input.write(inp_strl, locs) if tau_save_fs[-1].file.gradient_input.exists(locs): inp_strl = tau_save_fs[-1].file.gradient_input.read(locs) tau_save_fs[-1].json.gradient_input.write(inp_strl, locs) if tau_save_fs[-1].file.hessian_input.exists(locs): inp_strl = tau_save_fs[-1].file.hessian_input.read(locs) tau_save_fs[-1].json.hessian_input.write(inp_strl, locs) if tau_save_fs[-1].file.gradient_info.exists(locs): inf_objl = tau_save_fs[-1].file.gradient_info.read(locs) tau_save_fs[-1].json.gradient_info.write(inf_objl, locs) if tau_save_fs[-1].file.hessian_info.exists(locs): inf_objl = tau_save_fs[-1].file.hessian_info.read(locs) tau_save_fs[-1].json.hessian_info.write(inf_objl, locs) if tau_save_fs[-1].file.gradient.exists(locs): gradl = tau_save_fs[-1].file.gradient.read(locs) tau_save_fs[-1].json.gradient.write(gradl, locs) if tau_save_fs[-1].file.hessian.exists(locs): hessl = tau_save_fs[-1].file.hessian.read(locs) tau_save_fs[-1].json.energy.hessian(hessl, locs) if tau_save_fs[-1].file.zmatrix.exists(locs): zmatl = tau_save_fs[-1].file.zmatrix.read(locs) tau_save_fs[-1].json.zmatrix.write(zmatl, locs) if tau_save_fs[-1].file.harmonic_frequencies.exists(locs): hfreql = tau_save_fs[-1].file.harmonic_frequencies.read( locs) tau_save_fs[-1].json.harmonic_frequencies.write( hfreql, locs) save_path = tau_save_fs[-1].path(locs) sp_save_fs = autofile.fs.single_point(save_path) sp_save_locs = sp_save_fs[-1].existing() save_path = tau_save_fs[-1].root.path() jsp_save_fs = autofile.fs.single_point(save_path, json_layer=locs) for sp_locs in sp_save_locs: if sp_save_fs[-1].file.energy.exists(sp_locs): enel = sp_save_fs[-1].file.energy.read(sp_locs) jsp_save_fs[-1].json.energy.write(enel, sp_locs) if sp_save_fs[-1].file.input.exists(sp_locs): inp_strl = sp_save_fs[-1].file.input.read(sp_locs) jsp_save_fs[-1].json.input.write(inp_strl, sp_locs) if sp_save_fs[-1].file.info.exists(sp_locs): inf_objl = sp_save_fs[-1].file.info.read(sp_locs) jsp_save_fs[-1].json.info.write(inf_objl, sp_locs) tau_save_locs = tau_save_fs[-1].json_existing() if job == 'samp': # Set up the script _, opt_script_str, _, opt_kwargs = qchem_params(*thy_info[0:2]) # Run sampling tau.tau_sampling(zma, ref_ene, spc_info, run_tors_names, nsamp_par, mod_ini_thy_info, tau_run_fs, tau_save_fs, opt_script_str, overwrite, saddle=saddle, **opt_kwargs) elif job in ('energy', 'grad'): # Set up the run scripts script_str, _, kwargs, _ = qchem_params(*thy_info[0:2]) # Run the job over all the conformers requested by the user for locs in tau_save_locs: geo_run_path = tau_run_fs[-1].path(locs) if db_style == 'jsondb': geo_save_path = tau_save_fs[-1].root.path() geo = tau_save_fs[-1].json.geometry.read(locs) elif db_style == 'directory': geo_save_path = tau_save_fs[-1].path(locs) geo = tau_save_fs[-1].file.geometry.read(locs) tau_run_fs[-1].create(locs) zma = None ES_TSKS[job](zma, geo, spc_info, mod_thy_info, tau_save_fs, geo_run_path, geo_save_path, locs, script_str, overwrite, retryfail=retryfail, **kwargs) print('\n') elif job == 'hess': # Add the hessian max hessmax = es_keyword_dct['hessmax'] # Set up the run scripts script_str, _, kwargs, _ = qchem_params(*thy_info[0:2]) # Run the job over all the conformers requested by the user hess_cnt = 0 for locs in tau_save_locs: print('\nHESS Number {}'.format(hess_cnt + 1)) geo_run_path = tau_run_fs[-1].path(locs) if db_style == 'directory': geo_save_path = tau_save_fs[-1].path(locs) if tau_save_fs[-1].file.hessian.exists(locs): print( 'Hessian found and saved previously at {}'.format( geo_save_path)) hess_cnt += 1 continue geo = tau_save_fs[-1].file.geometry.read(locs) elif db_style == 'jsondb': geo_save_path = tau_save_fs[-1].root.path() if tau_save_fs[-1].json.hessian.exists(locs): print( 'Hessian found and saved previously at {}'.format( geo_save_path)) hess_cnt += 1 continue geo = tau_save_fs[-1].json.geometry.read(locs) zma = None tau_run_fs[-1].create(locs) ES_TSKS[job](zma, geo, spc_info, mod_thy_info, tau_save_fs, geo_run_path, geo_save_path, locs, script_str, overwrite, retryfail=retryfail, **kwargs) hess_cnt += 1 if hess_cnt == hessmax: break else: print('No torsional modes in the species')