def chk_therm(therm_dat_file, therm_calc_file, therm_dat_path, therm_calc_path, tmp_inp_dir, temps): """ Read Check the """ # Read the data in the thermo and rate CKIN files ckin_path = os.path.join(therm_calc_path, 'CKIN') therm_calc_str = pathtools.read_file(ckin_path, therm_calc_file) therm_dat_str = pathtools.read_file(therm_dat_path, therm_dat_file) nasa7_calc = chemkin_io.parser.thermo.create_spc_nasa7_dct(therm_calc_str) nasa7_dat = chemkin_io.parser.thermo.create_spc_nasa7_dct(therm_dat_str) thm_calc = mechanalyzer.calculator.thermo.create_spc_thermo_dct( nasa7_calc, temps) thm_dat = mechanalyzer.calculator.thermo.create_spc_thermo_dct( nasa7_dat, temps) spc_str = pathtools.read_file(tmp_inp_dir, 'species.csv') spc_ident_dct = mechanalyzer.parser.spc.build_spc_dct(spc_str, 'csv') thm_dct = mechanalyzer.calculator.compare.get_aligned_spc_thermo_dct( [thm_dat, thm_calc], [spc_ident_dct, spc_ident_dct]) for thm_data in thm_dct.values(): # 0 is data/therm and 1 is calc'd therm assert _assess(thm_data[0][0], thm_data[1][0], thresh=3.0) assert _assess(thm_data[0][1], thm_data[1][1], thresh=3.0) assert _assess(thm_data[0][2], thm_data[1][2], thresh=3.0) assert _assess(thm_data[0][3], thm_data[1][3], thresh=3.0)
def test__frequencies(): """ test projrot_io.reader.rpht_output """ ref_real1 = (1000.0, 2000.0, 3000.0, 4000.0, 5000.0) out_str1 = pathtools.read_file(DAT_PATH, 'min.out') real1, imag1 = projrot_io.reader.rpht_output(out_str1) assert numpy.allclose(real1, ref_real1) assert not imag1 ref_real2 = (2000.0, 3000.0, 4000.0, 5000.0) ref_imag2 = (1111.11, ) out_str2 = pathtools.read_file(DAT_PATH, 'one_imag.out') real2, imag2 = projrot_io.reader.rpht_output(out_str2) assert numpy.allclose(real2, ref_real2) assert numpy.allclose(imag2, ref_imag2) ref_real3 = (3000.0, 4000.0, 5000.0) ref_imag3 = (1111.11, 2222.22) out_str3 = pathtools.read_file(DAT_PATH, 'two_imag.out') real3, imag3 = projrot_io.reader.rpht_output(out_str3) assert numpy.allclose(real3, ref_real3) assert numpy.allclose(imag3, ref_imag3)
def test__ts_variational_writer(): """ ts mess_io.writer.ts_variational """ # fix var_pt_strings = [] for i in range(10): var_pt_string = '+++++++++++++++++++++++++++++++++++' var_pt_string += f'! Path Point {str(i+1)}\n' var_pt_string += MOL_MESS_STR var_pt_strings.append(var_pt_string) ts_var1_str = mess_io.writer.ts_variational(TS_LABEL, WELL_LABEL, BIMOL_LABEL, var_pt_strings, zero_enes=PATH_ENES, tunnel='') assert ts_var1_str == pathtools.read_file(INP_PATH, 'ts_var1.inp') ts_var2_str = mess_io.writer.ts_variational(TS_LABEL, WELL_LABEL, BIMOL_LABEL, var_pt_strings, zero_enes=PATH_ENES, tunnel=TUNNEL_STR) assert ts_var2_str == pathtools.read_file(INP_PATH, 'ts_var2.inp')
def test__ts_sadpt_writer(): """ ts sadpt writer """ ts_sadpt1_str = mess_io.writer.ts_sadpt(TS_LABEL, WELL_LABEL, BIMOL_LABEL, MOL_MESS_STR) assert ts_sadpt1_str == pathtools.read_file(INP_PATH, 'ts_sadpt1.inp').rstrip() ts_sadpt2_str = mess_io.writer.ts_sadpt(TS_LABEL, WELL_LABEL, BIMOL_LABEL, MOL_MESS_STR, zero_ene=ENE, tunnel=TUNNEL_STR) assert ts_sadpt2_str == pathtools.read_file(INP_PATH, 'ts_sadpt2.inp').rstrip() ts_sadpt3_str = mess_io.writer.ts_sadpt(TS_LABEL, WELL_LABEL, BIMOL_LABEL, MOL_MESS_STR, aux_id_label=AUX1_ID_LABEL) assert ts_sadpt3_str == pathtools.read_file(INP_PATH, 'ts_sadpt3.inp').rstrip()
def test__dummy_writer(): """ tests mess_io.writer.dummy """ dummy1_str = mess_io.writer.dummy(BIMOL_LABEL) assert dummy1_str == pathtools.read_file(INP_PATH, 'dummy1.inp') dummy2_str = mess_io.writer.dummy(BIMOL_LABEL, zero_ene=ENE) assert dummy2_str == pathtools.read_file(INP_PATH, 'dummy2.inp') dummy3_str = mess_io.writer.dummy(BIMOL_LABEL, aux_id_label=AUX1_ID_LABEL) assert dummy3_str == pathtools.read_file(INP_PATH, 'dummy3.inp')
def test__rotor_dist_cutoffs(): """ test projrot_io.writer.projection_distance_aux """ dist_cutoff_dct = {('H', 'O'): 2.26767, ('H', 'C'): 2.26767} rotor_dist1_str = projrot_io.writer.projection_distance_aux() rotor_dist2_str = projrot_io.writer.projection_distance_aux( dist_cutoff_dct=dist_cutoff_dct) assert rotor_dist1_str == pathtools.read_file(DAT_PATH, 'rotor_dist1.inp') assert rotor_dist2_str == pathtools.read_file(DAT_PATH, 'rotor_dist2.inp')
def test__(): """ test mess_io.writer._lump.well_lump_scheme """ ref_lump1_str = pathtools.read_file(INP_PATH, 'well_lump1.inp') ref_lump2_str = pathtools.read_file(INP_PATH, 'well_lump2.inp') lump1_str = mess_io.writer.well_lump_scheme(WELL_MERGE_LST) lump2_str = mess_io.writer.well_lump_scheme(WELL_MERGE_LST, separator='-') assert lump1_str == ref_lump1_str.rstrip() assert lump2_str == ref_lump2_str.rstrip()
def test__makefile_writer(): """ tests varecof_io.writer.corr_potentials.makefile """ makefile1_str = varecof_io.writer.corr_potentials.makefile( FORTRAN_COMPILER) makefile2_str = varecof_io.writer.corr_potentials.makefile( FORTRAN_COMPILER, pot_file_names=SPECIES_CORR_POTENTIALS) assert makefile1_str == pathtools.read_file(DAT_PATH, 'makefile1') assert makefile2_str == pathtools.read_file(DAT_PATH, 'makefile')
def test__tunnel_read_writer(): """ test mess_io.writer.tunnel_read """ tunnel_read1_str = mess_io.writer.tunnel_read(IMAG_FREQ, TUNNEL_FILE) tunnel_read2_str = mess_io.writer.tunnel_read(IMAG_FREQ, TUNNEL_FILE, cutoff_energy=CUTOFF_ENE) assert tunnel_read1_str == pathtools.read_file(INP_PATH, 'tunnel_read1.inp') assert tunnel_read2_str == pathtools.read_file(INP_PATH, 'tunnel_read2.inp')
def test__dat(): """ test mess_io.writer.mc_data """ mc_dat1_str = mess_io.writer.monte_carlo_data( GEOS, ENES) mc_dat2_str = mess_io.writer.monte_carlo_data( GEOS, ENES, grads=GRADS, hessians=HESSES) assert mc_dat1_str == pathtools.read_file(INP_PATH, 'mc_dat1.inp') assert mc_dat2_str == pathtools.read_file(INP_PATH, 'mc_dat2.inp')
def test__core_rigidrotor_writer(): """ test mess_io.writer.core_rigidrotor """ core_rigrot1_str = mess_io.writer.core_rigidrotor(GEO1, SYM_FACTOR1) core_rigrot2_str = mess_io.writer.core_rigidrotor(GEO1, SYM_FACTOR1, interp_emax=INTERP_EMAX) assert core_rigrot1_str == pathtools.read_file( INP_PATH, 'core_rigrot1.inp').rstrip() assert core_rigrot2_str == pathtools.read_file( INP_PATH, 'core_rigrot2.inp').rstrip()
def test__umbrella_writer(): """ test mess_io.writer.umbrella """ umbrella1_str = mess_io.writer.umbrella_mode(UMBR_GROUP, UMBR_PLANE, UMBR_REF, ONEDPOT) umbrella2_str = mess_io.writer.umbrella_mode(UMBR_GROUP, UMBR_PLANE, UMBR_REF, ONEDPOT, geo=GEO1) assert umbrella1_str == pathtools.read_file(INP_PATH, 'umbrella1.inp') assert umbrella2_str == pathtools.read_file(INP_PATH, 'umbrella2.inp')
def test__flux_mode(): """ test mess_io.writer.fluxional_mode """ # Write the fluxional mode string flux_mode1_str = mess_io.writer.fluxional_mode( FLUX_IDX) flux_mode2_str = mess_io.writer.fluxional_mode( FLUX_IDX, span=FLUX_SPAN) assert flux_mode1_str == pathtools.read_file( INP_PATH, 'flux_mode1.inp') assert flux_mode2_str == pathtools.read_file( INP_PATH, 'flux_mode2.inp')
def test__els_writer(): """ tests varecof_io.writer.input_file.elec_struct """ # Write the els input string els_inp1_str = varecof_io.writer.input_file.elec_struct( LIB_PATH, BASE_NAME, NPOT) els_inp2_str = varecof_io.writer.input_file.elec_struct( LIB_PATH, BASE_NAME, NPOT, dummy_name=DUMMY_NAME, lib_name=LIB_NAME, geo_ptt=GEO_PTT, ene_ptt=ENE_PTT) assert els_inp1_str == pathtools.read_file(DAT_PATH, 'els1.inp') assert els_inp2_str == pathtools.read_file(DAT_PATH, 'els2.inp')
def test_sct_coord_en(): """ test projrot_io.writer.rpht_path_coord_en """ en1_str = projrot_io.writer.rpht_path_coord_en(RXN_PATH_COORDS, RXN_PATH_ENERGIES, bnd1=(), bnd2=()) assert en1_str == pathtools.read_file(DAT_PATH, 'rpht_en1.inp') en2_str = projrot_io.writer.rpht_path_coord_en(RXN_PATH_COORDS, RXN_PATH_ENERGIES, bnd1=RCT_DISTS, bnd2=PRD_DISTS) assert en2_str == pathtools.read_file(DAT_PATH, 'rpht_en2.inp')
def test__compile_correction_potential(): """ test varecof_io.writer.corr_potentials.compile_correction_pot """ pathtools.write_file(pathtools.read_file(DAT_PATH, 'mol_corr.f'), TMP_PATH, 'mol_corr.f') pathtools.write_file(pathtools.read_file(DAT_PATH, 'pot_aux.f'), TMP_PATH, 'pot_aux.f') pathtools.write_file(pathtools.read_file(DAT_PATH, 'dummy_corr.f'), TMP_PATH, 'dummy_corr.f') pathtools.write_file(pathtools.read_file(DAT_PATH, 'makefile'), TMP_PATH, 'makefile') varecof_io.writer.corr_potentials.compile_corr_pot(TMP_PATH) assert os.path.exists(os.path.join(TMP_PATH, 'libcorrpot.so'))
def __bc_mat(): """ test projrot_io.writer.bmatrix test projrot_io.writer.cmatrix """ mat3d_str = pathtools.read_file(DAT_PATH, 'mat3d.dat') mat4d_str = pathtools.read_file(DAT_PATH, 'mat4d.dat') mat3d = automol.util.highd_mat.from_string(mat3d_str) mat4d = automol.util.highd_mat.from_string(mat4d_str) bmat_str = projrot_io.writer.bmatrix(mat3d) cmat_str = projrot_io.writer.cmatrix(mat4d) print(bmat_str) print(cmat_str)
def test__configs_union_writer(): """ tests mess_io.writer.configs_union """ mol_strs = [MOL_MESS_STR for _ in range(3)] tunnel_strs = [TUNNEL_STR for _ in range(3)] zero_enes = (1.00, 2.00, 3.00) union1_str = mess_io.writer.configs_union(mol_strs, zero_enes) union2_str = mess_io.writer.configs_union(mol_strs, zero_enes, tunnel_strs=tunnel_strs) assert union1_str == pathtools.read_file(INP_PATH, 'union1.inp') assert union2_str == pathtools.read_file(INP_PATH, 'union2.inp')
def test__core_multirotor_writer(): """ test mess_io.writer.rotor_internal test mess_io.writer.mdhr_data test mess_io.writer.core_multirotor """ # Internal Rotor Sections rotor_int1_str = mess_io.writer.rotor_internal(HR_GROUP, HR_AXIS, HR_SYMMETRY, HR_GRID_SIZE, HR_MASS_EXP_SIZE) rotor_int2_str = mess_io.writer.rotor_internal(HR_GROUP, HR_AXIS, HR_SYMMETRY, HR_GRID_SIZE, HR_MASS_EXP_SIZE, pot_exp_size=POT_EXP_SIZE, hmin=HMIN, hmax=HMAX, geo=GEO1, rotor_id=HR_ID) assert rotor_int1_str == pathtools.read_file(INP_PATH, 'rotor_int1.inp') assert rotor_int2_str == pathtools.read_file(INP_PATH, 'rotor_int2.inp') mdhr_dat_1d_str = mess_io.writer.mdhr_data(ONEDPOT) mdhr_dat_2dfr_str = mess_io.writer.mdhr_data(TWODPOT, freqs=TWODFREQ, nrot=3) mdhr_dat_3dfr_str = mess_io.writer.mdhr_data(THREEDPOT, freqs=THREEDFREQ, nrot=3) mdhr_dat_4dfr_str = mess_io.writer.mdhr_data(FOURDPOT, freqs=FOURDFREQ, nrot=3) assert mdhr_dat_1d_str == pathtools.read_file(INP_PATH, 'mdhr_dat_1d.inp') assert mdhr_dat_2dfr_str == pathtools.read_file(INP_PATH, 'mdhr_dat_2dfr.inp') assert mdhr_dat_3dfr_str == pathtools.read_file(INP_PATH, 'mdhr_dat_3dfr.inp') assert mdhr_dat_4dfr_str == pathtools.read_file(INP_PATH, 'mdhr_dat_4dfr.inp') # MultiRotor Core Sections core_multirot1_str = mess_io.writer.core_multirotor( GEO1, SYM_FACTOR1, POT_SURF_FILE, rotor_int1_str) core_multirot2_str = mess_io.writer.core_multirotor( GEO1, SYM_FACTOR1, POT_SURF_FILE, rotor_int1_str, interp_emax=INTERP_EMAX, quant_lvl_emax=QUANT_LVL_EMAX) assert core_multirot1_str == pathtools.read_file(INP_PATH, 'core_multirot1.inp') assert core_multirot2_str == pathtools.read_file(INP_PATH, 'core_multirot2.inp')
def test__tst_writer(): """ tests varecof_io.writer.input_file.tst """ tst_inp1_str = varecof_io.writer.input_file.tst( NSAMP_MAX, NSAMP_MIN, FLUX_ERR, PES_SIZE) tst_inp2_str = varecof_io.writer.input_file.tst( NSAMP_MAX, NSAMP_MIN, FLUX_ERR, PES_SIZE, faces=FACES, faces_symm=FACES_SYMM, ener_grid=ENER_GRID, amom_grid=AMOM_GRID) assert tst_inp1_str == pathtools.read_file(DAT_PATH, 'tst1.inp') assert tst_inp2_str == pathtools.read_file(DAT_PATH, 'tst2.inp')
def test__convert_writer(): """ tests varecof_io.writer.input_file.convert """ conv_inp_str = varecof_io.writer.input_file.convert() assert conv_inp_str == pathtools.read_file(DAT_PATH, 'conv.inp')
def test__mcflux_writer(): """ tests varecof_io.writer.input_file.mc_flux """ mc_flux_inp_str = varecof_io.writer.input_file.mc_flux() assert mc_flux_inp_str == pathtools.read_file(DAT_PATH, 'mc_flux.inp')
def test__full_str(): """ test mess_io.writer.messrates_inp_str test mess_io.writer.messpf_inp_str """ glob_keys_str = '<FAKE GLOB KEYS STR>' glob_etrans_str = '<FAKE ETRANS STR>' rxn_chan_str = '<FAKE REACTION CHANNEL STR>' pf_str = '<FAKE PF CHANNEL STR>' rates_str = mess_io.writer.messrates_inp_str(glob_keys_str, glob_etrans_str, rxn_chan_str) pf_str = mess_io.writer.messpf_inp_str(glob_keys_str, pf_str) assert rates_str == pathtools.read_file(INP_PATH, 'full_rates.inp') assert pf_str == pathtools.read_file(INP_PATH, 'full_pf.inp')
def test__gaussian_flux(): """ test autorun.nst """ ref_ncn_geo = automol.geom.from_string( pathtools.read_file(DAT_PATH, 'ncn_opt.xyz')) ref_ncn_flux = pathtools.read_file(DAT_PATH, 'ncn_lz_flux.dat') with tempfile.TemporaryDirectory(dir=PATH) as run_dir: msx_geo, _, flux_str = autorun.nst.isc_flux(run_dir, NCN_PROG, NCN_GEO, CHARGE, MULTS, NCN_METHOD, NCN_BASIS, NCN_ORB_TYPE, NCN_INI_KWARGS) assert automol.geom.almost_equal_dist_matrix(ref_ncn_geo, msx_geo) _check_flux_strings(ref_ncn_flux, flux_str)
def test__thermo(): """ test """ ref_hform298 = -0.028389069688367432 formula_str = automol.formula.string(FORMULA) thermp_script_str = autorun.SCRIPT_DCT['thermp'] pac99_script_str = autorun.SCRIPT_DCT['pac99'].format(formula_str) with tempfile.TemporaryDirectory(dir=PATH) as run_dir: hform298, nasa_poly = autorun.thermo(thermp_script_str, pac99_script_str, run_dir, PF_STR, NAME, FORMULA, HFORM0, enthalpyt=ENTHALPYT, breakt=BREAKT, convert=True) assert numpy.isclose(hform298, ref_hform298) assert nasa_poly == pathtools.read_file(DAT_PATH, 'ch4nasa.ckin')
def test__input(): """ test intder_io.writer.input_file """ inp_str = intder_io.writer.input_file(C2H5OH_GEO, C2H5OH_ZMA) assert inp_str == pathtools.read_file(DAT_PATH, 'intder.inp').rstrip()
def test__hess(): """ test intder_io.writer.cart_hess_file """ hess_str = intder_io.writer.cartesian_hessian_file(C2H5OH_HESS) assert hess_str == pathtools.read_file(DAT_PATH, 'file15')
def test__pot40(): """ test polyrate_io.writer.potential_file """ inp_str = polyrate_io.writer.potential_file(RCT_INFO, SADPT_INFO, MEP_INFOS) assert inp_str == pathtools.read_file(DAT_PATH, 'pot.fu40')
def load_rxn_ktp_dcts_chemkin(mech_filenames, direc, temps, pressures): """ Read one or more Chemkin-formatted mechanisms files and calculate rates at the indicated pressures and temperatures. Return a list of rxn_ktp_dcts. :param mech_filenames: filenames containing Chemkin-formatted kinetics information :type mech_filenames: list [filename1, filename2, ...] :param direc: directory with file(s) (all files must be in the same directory) :type direc: str :param temps: temperatures at which to do calculations (Kelvin) :type temps: list [float] :param pressures: pressures at which to do calculations (atm) :type pressures: list [float] :return rxn_ktp_dcts: list of rxn_ktp_dcts :rtype: list of dcts [rxn_ktp_dct1, rxn_ktp_dct2, ...] """ rxn_ktp_dcts = [] for mech_filename in mech_filenames: mech_str = parser.read_file(direc, mech_filename) ea_units, a_units = parser_mech.reaction_units(mech_str) rxn_block_str = parser_mech.reaction_block(mech_str) rxn_param_dct = parser_rxn.param_dct(rxn_block_str, ea_units, a_units) rxn_ktp_dct = calc_rates.eval_rxn_param_dct(rxn_param_dct, pressures, temps) rxn_ktp_dcts.append(rxn_ktp_dct) return rxn_ktp_dcts
def test__core_rotd_writer(): """ test mess_io.writer.core_rotd """ core_rotd_str = mess_io.writer.core_rotd(SYM_FACTOR1, FLUX_FILE, STOICH) assert core_rotd_str == pathtools.read_file(INP_PATH, 'core_rotd.inp')