def projrot_freqs(geoms, hessians, run_path, grads=((),), rotors_str='', coord_proj='cartesian', script_str=DEFAULT_SCRIPT_DCT['projrot']): """ Get the projected frequencies from projrot code run path at thy later """ # Set up the filesys bld_locs = ['PROJROT', 0] bld_save_fs = autofile.fs.build(run_path) bld_save_fs[-1].create(bld_locs) projrot_path = bld_save_fs[-1].path(bld_locs) projrot_path = os.path.join(projrot_path, str(random.randint(0,1234567))) if not os.path.exists(projrot_path): os.makedirs(projrot_path) # print('run path test for ProjRot:', run_path) # bld_fs, bld_locs = filesys.build.build_fs( # run_path, 'PROJROT', locs_idx=None) # bld_fs[-1].create(bld_locs) # projrot_path = bld_fs[-1].path(bld_locs) print('Run path for ProjRot:') print(projrot_path) # Write the ProjRot input file projrot_inp_str = projrot_io.writer.rpht_input( geoms, grads, hessians, rotors_str=rotors_str, coord_proj=coord_proj) proj_file_path = os.path.join(projrot_path, 'RPHt_input_data.dat') with open(proj_file_path, 'w') as proj_file: proj_file.write(projrot_inp_str) # Run ProjRot run_script(script_str, projrot_path) # Read vibrational frequencies from ProjRot output rtproj_file = os.path.join(projrot_path, 'RTproj_freq.dat') if os.path.exists(rtproj_file): with open(rtproj_file, 'r') as projfile: rtproj_str = projfile.read() rtproj_freqs, rt_imag_freq = projrot_io.reader.rpht_output( rtproj_str) else: rtproj_freqs, rt_imag_freq = [], [] hrproj_file = os.path.join(projrot_path, 'hrproj_freq.dat') if os.path.exists(hrproj_file): with open(hrproj_file, 'r') as projfile: hrproj_str = projfile.read() hrproj_freqs, hr_imag_freq = projrot_io.reader.rpht_output( hrproj_str) else: hrproj_freqs, hr_imag_freq = [], [] return rtproj_freqs, hrproj_freqs, rt_imag_freq, hr_imag_freq
def run_pf(mess_path, script_str=DEFAULT_SCRIPT_DCT['messpf']): """ Run the mess file that was wriiten """ if os.path.exists(mess_path): #if os.path.exists(os.path.join(mess_path, 'pf.inp')): print('Running MESS input file...') print(' - Path: {}'.format(mess_path)) run_script(script_str, mess_path) else: print('No MESS input file at path: {}'.format(mess_path))
def _run_varecof(vrc_path): """ Write all of the VaReCoF inut files and run the code """ # Run VaReCoF run_script(DEFAULT_SCRIPT_DCT['varecof'], vrc_path) # Calculate the flux file from the output print('Generating flux file with TS N(E) from VaReCoF output...') run_script(DEFAULT_SCRIPT_DCT['mcflux'], vrc_path)
def mess_tors_zpes(tors_geo, hind_rot_str, tors_save_path, script_str=DEFAULT_SCRIPT_DCT['messpf']): """ Calculate the frequencies and ZPVES of the hindered rotors create a messpf input and run messpf to get tors_freqs and tors_zpes """ # Set up the filesys bld_locs = ['PF', 0] bld_save_fs = autofile.fs.build(tors_save_path) bld_save_fs[-1].create(bld_locs) pf_path = bld_save_fs[-1].path(bld_locs) pf_path = os.path.join(pf_path, str(random.randint(0, 1234567))) if not os.path.exists(pf_path): os.makedirs(pf_path) print('Run path for MESSPF:') print(pf_path) # Write the MESSPF input file global_pf_str = mess_io.writer.global_pf( temperatures=[100.0, 200.0, 300.0, 400.0, 500], rel_temp_inc=0.001, atom_dist_min=0.6) dat_str = mess_io.writer.molecule( core=mess_io.writer.core_rigidrotor(tors_geo, 1.0), freqs=[1000.0], elec_levels=[[0.0, 1.0]], hind_rot=hind_rot_str, ) spc_str = mess_io.writer.species(spc_label='Tmp', spc_data=dat_str, zero_energy=0.0) pf_inp_str = '\n'.join([global_pf_str, spc_str]) + '\n' with open(os.path.join(pf_path, 'pf.inp'), 'w') as pf_file: pf_file.write(pf_inp_str) # Run MESSPF run_script(script_str, pf_path) # Obtain the torsional zpes and freqs from the MESS output with open(os.path.join(pf_path, 'pf.log'), 'r') as mess_file: output_string = mess_file.read() tors_zpes = mess_io.reader.tors.zpves(output_string) # tors_freqs = mess_io.reader.tors.freqs(output_string) tors_freqs = mess_io.reader.grid_min_freqs(output_string) return tors_zpes, tors_freqs
def projrot_freqs(geoms, hessians, run_path, grads=((), ), rotors_str='', coord_proj='cartesian', script_str=DEFAULT_SCRIPT_DCT['projrot']): """ Get the projected frequencies from projrot code run path at thy later """ bld_fs, bld_locs = filesys.build.build_fs(run_path, 'PROJROT', locs_idx=0) bld_fs[-1].create(bld_locs) projrot_path = bld_fs[-1].path(bld_locs) # Write the ProjRot input file projrot_inp_str = projrot_io.writer.rpht_input(geoms, grads, hessians, rotors_str=rotors_str, coord_proj=coord_proj) proj_file_path = os.path.join(projrot_path, 'RPHt_input_data.dat') with open(proj_file_path, 'w') as proj_file: proj_file.write(projrot_inp_str) # Run ProjRot run_script(script_str, projrot_path) # Read vibrational frequencies from ProjRot output rtproj_file = os.path.join(projrot_path, 'RTproj_freq.dat') if os.path.exists(rtproj_file): with open(rtproj_file, 'r') as projfile: rtproj_str = projfile.read() rtproj_freqs, rt_imag_freq = projrot_io.reader.rpht_output(rtproj_str) else: rtproj_freqs, rt_imag_freq = [], [] hrproj_file = os.path.join(projrot_path, 'hrproj_freq.dat') if os.path.exists(hrproj_file): with open(hrproj_file, 'r') as projfile: hrproj_str = projfile.read() hrproj_freqs, hr_imag_freq = projrot_io.reader.rpht_output(hrproj_str) else: hrproj_freqs, hr_imag_freq = [], [] return rtproj_freqs, hrproj_freqs, rt_imag_freq, hr_imag_freq
def run_rates(mess_path, script_str=DEFAULT_SCRIPT_DCT['messrate']): """ Run the mess file that was wriiten """ run_script(script_str, mess_path)
def _runlj(nsamp_needed, lj_info, lj_mod_thy_info, tgt_mod_thy_info, bath_mod_thy_info, tgt_cnf_save_fs, bath_cnf_save_fs, etrans_run_fs, etrans_locs, etrans_keyword_dct): """ Run the Lennard-Jones parameters """ # Pull stuff from dct njobs = etrans_keyword_dct['njobs'] smin = etrans_keyword_dct['smin'] smax = etrans_keyword_dct['smax'] conf = etrans_keyword_dct['conf'] # Determine the number of samples per job nsamp_per_job = nsamp_needed // njobs # Set the path to the executable onedmin_exe_path = '/lcrc/project/CMRP/amech/OneDMin/build' # Obtain the geometry for the target and bath tgt_geo = geom.get_geometry( tgt_cnf_save_fs, tgt_mod_thy_info, conf=conf) bath_geo = geom.get_geometry( bath_cnf_save_fs, bath_mod_thy_info, conf=conf) # Set the path to the etrans lead fs etrans_run_path = etrans_run_fs[-1].path(etrans_locs) # Build the run directory onedmin_run_path = lj_runner.build_rundir(etrans_run_path) # Run an instancw of 1DMin for each processor for idx in range(njobs): # Build run directory onedmin_job_path = lj_runner.make_jobdir(onedmin_run_path, idx) # Write the input files xyz1_str, xyz2_str = lj_runner.write_xyz(tgt_geo, bath_geo) elstruct_inp_str, elstruct_sub_str = lj_runner.write_elstruct_inp( lj_info, lj_mod_thy_info) onedmin_str = lj_runner.write_input( nsamp_per_job, smin=smin, smax=smax, target_name='target.xyz', bath_name='bath.xyz') input_strs = ( xyz1_str, xyz2_str, elstruct_inp_str, elstruct_sub_str, onedmin_str) input_names = ( 'target.xyz', 'bath.xyz', 'qc.mol', 'ene.x', 'input.dat') inp = tuple(zip(input_strs, input_names)) amech_io.writer.write_files( inp, onedmin_job_path, exe_names=('ene.x')) # Write the batch submission script for each instance onedmin_sub_str = lj_runner.write_onedmin_sub( njobs, onedmin_run_path, onedmin_exe_path, exe_name='onedmin-dd-molpro.x') sub_inp = ((onedmin_sub_str, 'build.sh'),) amech_io.writer.write_files( sub_inp, onedmin_run_path, exe_names=('build.sh')) # Submit the all of the OneDMin jobs print('\n\nRunning each OneDMin job...') submission.run_script(onedmin_sub_str, onedmin_run_path)