def produce_boltzmann_weighted_conformers_pf(run_messpf_tsk, spc_locs_dct, spc_dct, thm_paths_dct): """ Combine PFs into final pf """ ioprinter.messpf('run_header') spc_mods, _ = parser.models.extract_models(run_messpf_tsk) print('starting produce_boltz...') for spc_name in spc_locs_dct: ioprinter.message(f'Run MESSPF: {spc_name}', newline=1) locs_pfs_arrays = [] hf_array = [] for idx, spc_locs in enumerate(spc_locs_dct[spc_name]): locs_pfs_arrays.append( reader.mess.messpf( thm_paths_dct[spc_name][tuple(spc_locs)]['mod_total'][0])) hf_val = 0. for spc_mod in spc_mods: hf_val += (spc_dct[spc_name]['Hfs'][idx][spc_mod][0] / len(spc_mods)) hf_array.append(hf_val) final_pf = thermfit.pf.boltzmann_pf_combination( locs_pfs_arrays, hf_array) writer.mess.output(fstring(spc_dct[spc_name]['inchi']), final_pf, thm_paths_dct[spc_name]['spc_total'][0], filename='pf.dat') spc_dct[spc_name]['Hfs']['final'] = [min(hf_array)] return spc_dct
def run_messpf_task(run_messpf_tsk, spc_locs_dct, spc_dct, thm_paths_dct): """ Run messpf input file """ ioprinter.messpf('run_header') spc_mods, _ = parser.models.extract_models(run_messpf_tsk) for spc_name in spc_locs_dct: ioprinter.therm_paths_messpf_run_locations(spc_name, spc_locs_dct[spc_name], spc_mods, thm_paths_dct) # Run MESSPF for all requested models, combine the PFS at the end ioprinter.message(f'Run MESSPF: {spc_name}', newline=1) _locs_pfs = [] for spc_locs in spc_locs_dct[spc_name]: _mod_pfs = [] for spc_mod in spc_mods: autorun.run_script( autorun.SCRIPT_DCT['messpf'], thm_paths_dct[spc_name][tuple(spc_locs)][spc_mod][0]) _mod_pfs.append( reader.mess.messpf( thm_paths_dct[spc_name][tuple(spc_locs)][spc_mod][0])) # Unpack the the pf model combination information spc_mod_info = parser.models.split_model(spc_mod) _spc_mods, coeffs, operators = spc_mod_info final_pf = thermfit.pf.combine(_mod_pfs, coeffs, operators) writer.mess.output( fstring(spc_dct[spc_name]['inchi']), final_pf, thm_paths_dct[spc_name][tuple(spc_locs)]['mod_total'][0], filename='pf.dat') _locs_pfs.append(final_pf)
def _scan_finished(coord_names, coord_grids, scn_save_fs, constraint_dct=None): """ See if the scan needs to be run maybe return the grid that is not finished? """ print('grid_coords test:', coord_grids) grid_vals = automol.pot.coords(coord_grids) run_finished = True for vals in grid_vals: # Set the locs for the scan point locs = [coord_names, vals] if constraint_dct is not None: locs = [constraint_dct] + locs # Check if ZMA (other info?) exists if not scn_save_fs[-1].file.zmatrix.exists(locs): run_finished = False break if run_finished: ioprinter.message('Scan saved previously at {}'.format( scn_save_fs[0].path())) else: ioprinter.message('Need to run scans') return run_finished
def nasa_polynomial_task(mdriver_path, spc_locs_dct, thm_paths_dct, spc_dct, spc_mod_dct, spc_mods, sort_info_lst, ref_scheme): """ generate the nasa polynomials """ ckin_nasa_str_dct = {} ckin_nasa_str_dct[0] = '' ckin_path = output_path('CKIN', prefix=mdriver_path) for spc_name in spc_locs_dct: for idx, spc_locs in enumerate(spc_locs_dct[spc_name], start=1): if idx not in ckin_nasa_str_dct: ckin_nasa_str_dct[idx] = '' spc_locs = tuple(spc_locs) ioprinter.nasa('calculate', spc_name) # for spc_mod in spc_mods: # ioprinter.message('for: ', spc_locs, spc_mod) # # Write the header describing the models used in thermo calcs # ckin_nasa_str += writer.ckin.model_header( # [spc_mod], spc_mod_dct, refscheme=ref_scheme) # # Build and write NASA polynomial in CHEMKIN-format string # # Call dies if you haven't run "write mess" task # ckin_nasa_str += nasapoly.build_polynomial( # spc_name, spc_dct, # thm_paths_dct[spc_name][tuple(spc_locs)][spc_mod][0], # thm_paths_dct[spc_name][tuple(spc_locs)][spc_mod][1], # spc_locs=spc_locs, spc_mod=spc_mod) # ckin_nasa_str += '\n\n' ioprinter.message('for: ', spc_locs, ' combined models') ckin_nasa_str_dct[idx] += writer.ckin.model_header( spc_mods, spc_mod_dct, sort_info_lst=sort_info_lst, refscheme=ref_scheme) ckin_nasa_str_dct[idx] += nasapoly.build_polynomial( spc_name, spc_dct, thm_paths_dct[spc_name][tuple(spc_locs)]['mod_total'][0], thm_paths_dct[spc_name][tuple(spc_locs)]['mod_total'][1], spc_locs_idx=idx - 1, spc_mod=','.join(spc_mods)) ckin_nasa_str_dct[idx] += '\n\n' ioprinter.info_message('CKIN NASA STR\n') ioprinter.info_message(ckin_nasa_str_dct[idx]) ioprinter.message('for combined rid cids:', spc_locs_dct[spc_name]) ckin_nasa_str_dct[0] += writer.ckin.model_header( spc_mods, spc_mod_dct, sort_info_lst=sort_info_lst, refscheme=ref_scheme) ckin_nasa_str_dct[0] += nasapoly.build_polynomial( spc_name, spc_dct, thm_paths_dct[spc_name]['spc_total'][0], thm_paths_dct[spc_name]['spc_total'][1], spc_locs_idx='final', spc_mod=','.join(spc_mods)) ckin_nasa_str_dct[0] += '\n\n' ioprinter.info_message('CKIN NASA STR\n') ioprinter.info_message(ckin_nasa_str_dct[0]) return ckin_nasa_str_dct, ckin_path
def status_message(print_str, label=None, path=None, newline=False, indent=False): if label: print_str += label if path: print_str += ' at {}'.format(path) message(print_str, newline=newline, indent=indent)
def output_keyword_list(es_keyword_dct, thy_dct=None): """ a """ message('Electronic structure level for property:', newline=1) for key, val in es_keyword_dct.items(): method_str = '' if key in ('inplvl', 'runlvl'): method_dct = thy_dct.get(es_keyword_dct[key]) method_str = '({}/{})'.format(method_dct['method'], method_dct['basis']) message('{}: {} '.format(key, val) + method_str) obj('vspace')
def runlst(run_inf, run_lst): """ checks if run lst is a species lst """ formula, pes_idx, sub_pes_idx = run_inf if formula != 'SPC': print_pes(pes_idx + 1, formula, sub_pes_idx + 1) for chnl in run_lst: cidx, rxn = chnl print_channel(cidx + 1, rxn[0], rxn[1]) else: for i, spc in enumerate(run_lst): message('Running SPC {}: {}'.format(i + 1, spc))
def program_header(driver): """ print the header for a program """ header_dct = { 'amech': AMECH_MSG, 'inp': INP_MSG, 'ktp': KTP_MSG, 'thermo': THM_MSG, 'trans': TRANS_MSG, 'es': ES_MSG, 'print': PRINT_MSG } message(header_dct[driver])
def random_cute_animal(): """ Print a picture of a fun, cute animal at random """ msg = random.choice([ r""" _,--._ ,' `. |\ / \ /| )o),/ ( ,--, ,--, ) \.(o( /o/// /| |\ \\ \\o\\ / / |\ \( .----, )/ /| \ \\ | | \o`-/ `--' \-'o/ | | \ \ `,' `.' / / \. \ `-' ,'| /\ |`. `-' / ,/ \`. `.__,' / / \ \ `.__,' ,'/ \o\ ,' ,' `. `. /o/ \o`---' ,' `. `---'o/ `.____,' `.____,' """, r""" ,,, ,,, ;" ^; ;' ", ; s$$$$$$$s ; , ss$$$$$$$$$$s ,' ;s$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$ $$$$P""Y$$$Y""W$$$$$ $$$$ 0"$$$"0 $$$$$ $$$$ .$$$$$. $$$$ $$$$$$$$$$$$$$$$$ "Y$$$"'*'"$$$Y" "$$b.d$$" """, r""" _.---~-~-~~-.. .. __. .-~ ~-. ((\ / `}.~ `. \\\\\ { } / \ \\ (\ \\\\~~ } | } \\ \`.-~-^~ } ,-,. | ) \\ (___, ) _} ( : | / / `. `----._-~. _\ \ |_ \ / /- _ -. ~~----~~ \ \| ~~--~~~( + / ~-. '--~. / / \ \ `~-..__ `~__ __/ / _\ ) `~~---' .<___.' .<___/ """]) message(msg) obj('vspace')
def _check_for_reference_energies(spc_basis, chn_basis_ene_dct, spc_mod): """ check the chn_basis_ene_dct for each reference species for this spc model and return them or say we need to prepare references """ ene_basis = [] energy_missing = False print('chn_basis_ene_dct', chn_basis_ene_dct) for spc_basis_i in spc_basis: if spc_basis_i in chn_basis_ene_dct[spc_mod]: ioprinter.message('Energy already found for basis species: ' + spc_basis_i) ene_basis.append(chn_basis_ene_dct[spc_mod][spc_basis_i]) else: ioprinter.message('Energy will be determined for basis species: ' + spc_basis_i) energy_missing = True return energy_missing, ene_basis
def _process(tsk, ktp_tsk_lst, pes_grp_rlst, spc_mod_dct, spc_dct, glob_dct, run_prefix, save_prefix): """ Build info needed for the task """ # Generic task/model info independent of PESs tsk_key_dct = tsk[-1] spc_mod = tsk_key_dct['spc_model'] spc_mod_dct_i = spc_mod_dct[spc_mod] label_dct = {} all_chkd_rxn_lst, all_instab_chnls = (), () for _, (pes_inf, rxn_lst) in enumerate(pes_grp_rlst.items()): _, pes_idx, _ = pes_inf # Obtain all of the transitions states ioprinter.message( 'Identifying reaction classes for transition states...') ts_dct = parser.spc.ts_dct_from_ktptsks(pes_idx, rxn_lst, ktp_tsk_lst, spc_mod_dct, spc_dct, run_prefix, save_prefix) spc_dct = parser.spc.combine_sadpt_spc_dcts(ts_dct, spc_dct, glob_dct) # Set reaction list with unstable species broken apart ioprinter.message('Identifying stability of all species...', newline=1) chkd_rxn_lst, instab_chnls = split_unstable_pes( rxn_lst, spc_dct, spc_mod_dct_i, save_prefix) all_chkd_rxn_lst += (chkd_rxn_lst, ) all_instab_chnls += (instab_chnls, ) # Build the MESS label idx dictionary for the PES label_dct.update( ktp_label.make_pes_label_dct(label_dct, chkd_rxn_lst, pes_idx, spc_dct, spc_mod_dct_i)) return spc_dct, all_chkd_rxn_lst, all_instab_chnls, label_dct
def _scan_finished(coord_names, coord_grids, scn_save_fs, constraint_dct=None): """ Assesses if the scan calculations requested by the user have been completed by assessing if Z-Matrices exist in the filesystem for all grid values of the scan coordinates. :param coord_names: names of the scan coordinates :type coord_names: tuple(tuple(str)) :param coord_grids: values of all the scan coordinates :type coord_grids: tuple(tuple(float)) :param scn_save_fs: SCAN/CSCAN object with save filesys prefix :type scn_save_fs: autofile.fs.scan or autofile.fs.cscan object :param constraint_dct: values of coordinates to constrain during scan :type constraint_dct: dict[str: float] """ run_finished = True grid_vals = automol.pot.coords(coord_grids) for vals in grid_vals: # Set the locs for the scan point locs = [coord_names, vals] if constraint_dct is not None: locs = [constraint_dct] + locs # Check if ZMA (other info?) exists if not scn_save_fs[-1].file.zmatrix.exists(locs): run_finished = False break if run_finished: ioprinter.message('Scan saved previously at {}'.format( scn_save_fs[0].path())) else: ioprinter.message('Need to run scans') return run_finished
def _process(pes_idx, rxn_lst, ktp_tsk_lst, spc_mod_dct, spc_mod, thy_dct, spc_dct, glob_dct, run_prefix, save_prefix): """ Build info needed for the task """ spc_mod_dct_i = spc_mod_dct[spc_mod] # Obtain all of the transitions states ioprinter.message('Identifying reaction classes for transition states...') ts_dct = parser.spc.ts_dct_from_ktptsks(pes_idx, rxn_lst, ktp_tsk_lst, spc_mod_dct, thy_dct, spc_dct, run_prefix, save_prefix) spc_dct = parser.spc.combine_sadpt_spc_dcts(ts_dct, spc_dct, glob_dct) # Set reaction list with unstable species broken apart ioprinter.message('Identifying stability of all species...', newline=1) chkd_rxn_lst = split_unstable_rxn(rxn_lst, spc_dct, spc_mod_dct_i, save_prefix) # Build the MESS label idx dictionary for the PES label_dct = ktproutines.label.make_pes_label_dct(chkd_rxn_lst, pes_idx, spc_dct, spc_mod_dct_i) return spc_dct, chkd_rxn_lst, label_dct
def nasa(statement, spc_name=None, temps=None): """ a """ obj('vspace') if statement == 'header': obj('line_dash') message('Running Thermochemistry calculations for all species', newline=1) elif statement == 'calculate': message( 'Starting NASA polynomials calculation for {}'.format(spc_name)) elif statement == 'fit': message( 'Attempting to fit NASA polynomials from', '200-1000 and 1000-3000 K ranges using\n', 'temps from MESSPF file = {}.'.format(' '.join( ('{:.2f}'.format(x) for x in temps))))
def task_header(tsk, spc_name): """ a """ obj('vspace') obj('line_dash') message('Task:', tsk, spc_name, newline=1)
def results(): message('Results:')
def output_task_header(tsk): """ a """ obj('vspace') obj('line_dash') message('Print Property:', tsk, newline=1)
def pes(pes_idx, formula, sub_pes_idx): """ a """ message('Running PES {}: {}, SUB PES {}'.format(pes_idx, formula, sub_pes_idx), newline=1)
def channel(chn_idx, reacs, prods): """ a """ message('Running Channel {}: {} = {}'.format(chn_idx, '+'.join(reacs), '+'.join(prods)), indent=1)
def messpf(statement, path=None): """ a """ obj('vspace') if statement == 'write_header': obj('line_dash') message('Preparing MESSPF input files for all species', newline=1) elif statement == 'input_string': message('MESSPF Input String:') obj('vspace') obj('vspace') elif statement == 'run_header': obj('line_dash') message('Running MESSPF calculations for all species', newline=1) elif statement == 'write_file': message('Writing MESS input file...') message(' - Path: {}'.format(path)) elif statement == 'write_output': message('Writing MESS Output file...') message(' - Path: {}'.format(path)) elif statement == 'run_file': message('Running MESS input file...') message(' - Path: {}'.format(path)) elif statement == 'global_header': message('Preparing global keywords section for MESS input...') message(' - Using temperatures and pressures defined by user') message(' - Using internal AutoMech defaults for other MESS keywords:') elif statement == 'transfer_section': message('Preparing energy transfer section for MESS input...') elif statement == 'well_section': message('- Determining reference well species...') elif statement == 'bath_section': message('- Determining information for the bath species...') elif statement == 'channel_section': message('Preparing reaction channel section for MESS input... ')
def program_run_message(prog, path): """ message for a program """ message('Run path for {}:'.format(prog), path)
def run(pes_rlst, spc_rlst, therm_tsk_lst, pes_mod_dct, spc_mod_dct, spc_dct, run_prefix, save_prefix): """ Executes all thermochemistry tasks. :param pes_rlst: species from PESs to run [(PES formula, PES idx, SUP-PES idx) (CHANNEL idx, (REACS, PRODS)) :type pes_rlst: tuple(dict[str: dict]) :param spc_rlst: lst of species to run :type spc_rlst: tuple(dict[str: dict]) :param es_tsk_lst: list of the electronic structure tasks tuple(tuple(obj, tsk, keyword_dict)) :type es_tsk_lst: tuple(tuple(str, str, dict)) :param spc_dct: species information dict[spc_name: spc_information] :type spc_dct: dict[str:dict] :param glob_dct: global information for all species dict[spc_name: spc_information] :type glob_dct: dict[str: dict] :param thy_dct: all of the theory information dict[thy name: inf] :type thy_dct: dict[str:dict] :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 """ # Print Header ioprinter.info_message('Calculating Thermochem:') ioprinter.runlst(('SPC', 0, 0), spc_rlst) # ------------------------------------------------ # # PREPARE INFORMATION TO PASS TO THERMDRIVER TASKS # # ------------------------------------------------ # # Build a list of the species to calculate thermochem for loops below spc_mods = list(spc_mod_dct.keys()) # hack spc_mod_dct_i = spc_mod_dct[spc_mods[0]] split_rlst = split_unstable_full( pes_rlst, spc_rlst, spc_dct, spc_mod_dct_i, save_prefix) spc_queue = parser.rlst.spc_queue( tuple(split_rlst.values())[0], 'SPC') # Build the paths [(messpf, nasa)], models and levels for each spc thm_paths = thermo_paths(spc_dct, spc_queue, spc_mods, run_prefix) # ----------------------------------- # # RUN THE REQUESTED THERMDRIVER TASKS # # ----------------------------------- # # Write and Run MESSPF inputs to generate the partition functions write_messpf_tsk = parser.run.extract_task('write_mess', therm_tsk_lst) if write_messpf_tsk is not None: ioprinter.messpf('write_header') spc_mods, pes_mod = parser.models.extract_models(write_messpf_tsk) for idx, spc_name in enumerate(spc_queue): print('write test {}'.format(spc_name)) for spc_mod in spc_mods: messpf_inp_str = thmroutines.qt.make_messpf_str( pes_mod_dct[pes_mod]['therm_temps'], spc_dct, spc_name, pes_mod_dct[pes_mod], spc_mod_dct[spc_mod], run_prefix, save_prefix) ioprinter.messpf('input_string') ioprinter.info_message(messpf_inp_str) autorun.write_input( thm_paths[idx][spc_mod][0], messpf_inp_str, input_name='pf.inp') # Run the MESSPF files that have been written run_messpf_tsk = parser.run.extract_task('run_mess', therm_tsk_lst) if run_messpf_tsk is not None: spc_mod, pes_mod = parser.models.extract_models(run_messpf_tsk) spc_mods = parser.models.split_model(spc_mod[0]) ioprinter.messpf('run_header') for idx, spc_name in enumerate(spc_queue): _spc_mods, coeffs, operators = spc_mods # Run MESSPF for all requested models, combine the PFS at the end ioprinter.message('Run MESSPF: {}'.format(spc_name), newline=1) _pfs = [] for spc_mod in _spc_mods: autorun.run_script( autorun.SCRIPT_DCT['messpf'], thm_paths[idx][spc_mod][0]) _pfs.append( reader.mess.messpf(thm_paths[idx][spc_mod][0])) final_pf = thermfit.pf.combine(_pfs, coeffs, operators) # need to clean thm path build tdx = len(spc_mods) spc_info = sinfo.from_dct(spc_dct[spc_name]) spc_fml = automol.inchi.formula_string(spc_info[0]) thm_prefix = [spc_fml, automol.inchi.inchi_key(spc_info[0])] thm_paths[idx]['final'] = ( job_path(run_prefix, 'MESS', 'PF', thm_prefix, locs_idx=tdx), job_path(run_prefix, 'THERM', 'NASA', thm_prefix, locs_idx=tdx) ) writer.mess.output( fstring(spc_dct[spc_name]['inchi']), final_pf, thm_paths[idx]['final'][0], filename='pf.dat') # Use MESS partition functions to compute thermo quantities run_fit_tsk = parser.run.extract_task('run_fits', therm_tsk_lst) if run_fit_tsk is not None: spc_mods, pes_mod = parser.models.extract_models(run_fit_tsk) pes_mod_dct_i = pes_mod_dct[pes_mod] ioprinter.nasa('header') chn_basis_ene_dct = {} for idx, spc_name in enumerate(spc_queue): # Take species model and add it to the chn_basis_ene dct spc_mod = spc_mods[0] spc_mod_dct_i = spc_mod_dct[spc_mod] if spc_mod not in chn_basis_ene_dct: chn_basis_ene_dct[spc_mod] = {} # Get the reference scheme and energies (ref in different place) ref_scheme = pes_mod_dct_i['therm_fit']['ref_scheme'] ref_enes = pes_mod_dct_i['therm_fit']['ref_enes'] # Determine info about the basis species used in thermochem calcs basis_dct, uniref_dct = thermfit.prepare_refs( ref_scheme, spc_dct, (spc_name,)) # Get the basis info for the spc of interest spc_basis, coeff_basis = basis_dct[spc_name] # Get the energies for the spc and its basis ene_basis = [] energy_missing = False for spc_basis_i in spc_basis: if spc_basis_i in chn_basis_ene_dct[spc_mod]: ioprinter.message( 'Energy already found for basis species: ' + spc_basis_i) ene_basis.append(chn_basis_ene_dct[spc_mod][spc_basis_i]) else: ioprinter.message( 'Energy will be determined for basis species: ' + spc_basis_i) energy_missing = True if not energy_missing: pf_filesystems = filesys.models.pf_filesys( spc_dct[spc_name], spc_mod_dct_i, run_prefix, save_prefix, saddle=False) ene_spc = ene.read_energy( spc_dct[spc_name], pf_filesystems, spc_mod_dct_i, run_prefix, read_ene=True, read_zpe=True, saddle=False) else: ene_spc, ene_basis = thmroutines.basis.basis_energy( spc_name, spc_basis, uniref_dct, spc_dct, spc_mod_dct_i, run_prefix, save_prefix) for spc_basis_i, ene_basis_i in zip(spc_basis, ene_basis): chn_basis_ene_dct[spc_mod][spc_basis_i] = ene_basis_i # Calculate and store the 0 K Enthalpy hf0k = thermfit.heatform.calc_hform_0k( ene_spc, ene_basis, spc_basis, coeff_basis, ref_set=ref_enes) spc_dct[spc_name]['Hfs'] = [hf0k] # Write the NASA polynomials in CHEMKIN format ckin_nasa_str = '' ckin_path = output_path('CKIN') for idx, spc_name in enumerate(spc_queue): ioprinter.nasa('calculate', spc_name) # Write the header describing the models used in thermo calcs ckin_nasa_str += writer.ckin.model_header(spc_mods, spc_mod_dct) # Build and write the NASA polynomial in CHEMKIN-format string # Call dies if you haven't run "write mess" task ckin_nasa_str += thmroutines.nasapoly.build_polynomial( spc_name, spc_dct, thm_paths[idx]['final'][0], thm_paths[idx]['final'][1]) ckin_nasa_str += '\n\n' print('CKIN NASA STR\n') print(ckin_nasa_str) nasa7_params_all = chemkin_io.parser.thermo.create_spc_nasa7_dct( ckin_nasa_str) ioprinter.info_message( 'SPECIES\t\tH(0 K)[kcal/mol]\tH(298 K)[kcal/mol]\t' + 'S(298 K)[cal/mol K]\n') for spc_name in nasa7_params_all: nasa7_params = nasa7_params_all[spc_name] ht0 = spc_dct[spc_name]['Hfs'][0] ht298 = mechanalyzer.calculator.thermo.enthalpy( nasa7_params, 298.15) st298 = mechanalyzer.calculator.thermo.entropy( nasa7_params, 298.15) ioprinter.info_message( '{}\t{:3.2f}\t{:3.2f}\t{:3.2f}'.format( spc_name, ht0, ht298/1000., st298)) # Write all of the NASA polynomial strings writer.ckin.write_nasa_file(ckin_nasa_str, ckin_path)
def driver_tasks( run_es, write_messpf, run_messpf, run_nasa, write_messrate, run_messrate, run_fits, run_trans): """ a """ if run_es: message(' - ESDriver') # Add the tasks for the ESDriver if write_messpf or run_messpf or run_nasa: message(' - ThermoDriver') if write_messpf: message(' - write_messpf') if run_messpf: message(' - run_messpf') if run_nasa: message(' - run_nasa') if write_messrate or run_messrate or run_fits: message(' - kTPDriver') if write_messrate: message(' - write_messrate') if run_messrate: message(' - run_messrate') if run_fits: message(' - run_fits') if run_trans: message(' - TransportDriver')
def host_name(): """ print the host the calculation is running on """ host_node = _get_host_node() pid = _get_pid() message(HOST_MSG.format(host_node, pid))
# Build the elec struct tsk lst TRANS_TSK_LST = parser.tsks.trans_tsk_lst(TRANS_TSK_STR, THY_DCT) # Call ThermoDriver for spc in PES if RUN_OBJ_DCT['pes']: for _, rxn_lst in RUN_PES_DCT.items(): transdriver.run( SPC_DCT, THY_DCT, rxn_lst, TRANS_TSK_LST, RUN_INP_DCT ) else: for spc in RUN_SPC_LST_DCT: ioprinter.message('Calculating Transport for species: {}'.format(spc), newline=1) transdriver.run( SPC_DCT, THY_DCT, RUN_SPC_LST_DCT, TRANS_TSK_LST, RUN_INP_DCT ) # kTPDriver if WRITE_MESSRATE or RUN_MESSRATE or RUN_FITS: ioprinter.program_header('ktp') # Call kTPDriver for each SUB PES if RUN_OBJ_DCT['pes']:
def run(spc_rlst, therm_tsk_lst, pes_mod_dct, spc_mod_dct, spc_dct, run_prefix, save_prefix): """ main driver for thermo run """ # Print Header fo ioprinter.info_message('Calculating Thermochem:') ioprinter.runlst(('SPC', 0, 0), spc_rlst) # ------------------------------------------------ # # PREPARE INFORMATION TO PASS TO THERMDRIVER TASKS # # ------------------------------------------------ # # Build a list of the species to calculate thermochem for loops below spc_mods = list(spc_mod_dct.keys()) # hack split_spc_lst = split_unstable_spc(spc_rlst, spc_dct, spc_mod_dct[spc_mods[0]], save_prefix) spc_queue = parser.rlst.spc_queue('spc', tuple(split_spc_lst.values())[0]) # Build the paths [(messpf, nasa)], models and levels for each spc thm_paths = thermo_paths(spc_dct, spc_queue, spc_mods, run_prefix) # ----------------------------------- # # RUN THE REQUESTED THERMDRIVER TASKS # # ----------------------------------- # # Write and Run MESSPF inputs to generate the partition functions write_messpf_tsk = parser.run.extract_task('write_mess', therm_tsk_lst) if write_messpf_tsk is not None: ioprinter.messpf('write_header') spc_mods, pes_mod = parser.models.extract_models(write_messpf_tsk) for idx, spc_name in enumerate(spc_queue): print('write test {}'.format(spc_name)) for spc_mod in spc_mods: messpf_inp_str = thmroutines.qt.make_messpf_str( pes_mod_dct[pes_mod]['therm_temps'], spc_dct, spc_name, pes_mod_dct[pes_mod], spc_mod_dct[spc_mod], run_prefix, save_prefix) ioprinter.messpf('input_string') ioprinter.info_message(messpf_inp_str) autorun.write_input(thm_paths[idx][spc_mod][0], messpf_inp_str, input_name='pf.inp') # Run the MESSPF files that have been written run_messpf_tsk = parser.run.extract_task('run_mess', therm_tsk_lst) if run_messpf_tsk is not None: spc_mod, pes_mod = parser.models.extract_models(run_messpf_tsk) spc_mods = parser.models.split_model(spc_mod[0]) ioprinter.messpf('run_header') for idx, spc_name in enumerate(spc_queue): _spc_mods, coeffs, operators = spc_mods # Run MESSPF for all requested models, combine the PFS at the end ioprinter.message('Run MESSPF: {}'.format(spc_name), newline=1) _pfs = [] for spc_mod in _spc_mods: autorun.run_script(autorun.SCRIPT_DCT['messpf'], thm_paths[idx][spc_mod][0]) _pfs.append( pfrunner.mess.read_messpf(thm_paths[idx][spc_mod][0])) final_pf = pfrunner.mess.combine_pfs(_pfs, coeffs, operators) # need to clean thm path build tot_idx = len(spc_mods) spc_info = sinfo.from_dct(spc_dct[spc_name]) spc_fml = automol.inchi.formula_string(spc_info[0]) thm_prefix = [spc_fml, automol.inchi.inchi_key(spc_info[0])] thm_paths[idx]['final'] = (job_path(run_prefix, 'MESS', 'PF', thm_prefix, locs_idx=tot_idx), job_path(run_prefix, 'THERM', 'NASA', thm_prefix, locs_idx=tot_idx)) pfrunner.mess.write_mess_output(fstring( spc_dct[spc_name]['inchi']), final_pf, thm_paths[idx]['final'][0], filename='pf.dat') # Use MESS partition functions to compute thermo quantities run_fit_tsk = parser.run.extract_task('run_fits', therm_tsk_lst) if run_fit_tsk is not None: spc_mods, pes_mod = parser.models.extract_models(run_fit_tsk) pes_mod_dct_i = pes_mod_dct[pes_mod] ioprinter.nasa('header') chn_basis_ene_dct = {} for idx, spc_name in enumerate(spc_queue): # Take species model and add it to the chn_basis_ene dct spc_mod = spc_mods[0] spc_mod_dct_i = spc_mod_dct[spc_mod] if spc_mod not in chn_basis_ene_dct: chn_basis_ene_dct[spc_mod] = {} # Get the reference scheme and energies (ref in different place) ref_scheme = pes_mod_dct_i['therm_fit']['ref_scheme'] ref_enes = pes_mod_dct_i['therm_fit']['ref_enes'] # Determine info about the basis species used in thermochem calcs basis_dct, uniref_dct = thmroutines.basis.prepare_refs( ref_scheme, spc_dct, [[spc_name, None]], run_prefix, save_prefix) # Get the basis info for the spc of interest spc_basis, coeff_basis = basis_dct[spc_name] # Get the energies for the spc and its basis ene_basis = [] energy_missing = False for spc_basis_i in spc_basis: if spc_basis_i in chn_basis_ene_dct[spc_mod]: ioprinter.message( 'Energy already found for basis species: ' + spc_basis_i) ene_basis.append(chn_basis_ene_dct[spc_mod][spc_basis_i]) else: ioprinter.message( 'Energy will be determined for basis species: ' + spc_basis_i) energy_missing = True if not energy_missing: pf_filesystems = filesys.models.pf_filesys(spc_dct[spc_name], spc_mod_dct_i, run_prefix, save_prefix, saddle=False) ene_spc = ene.read_energy(spc_dct[spc_name], pf_filesystems, spc_mod_dct_i, run_prefix, read_ene=True, read_zpe=True, saddle=False) else: ene_spc, ene_basis = thmroutines.basis.basis_energy( spc_name, spc_basis, uniref_dct, spc_dct, spc_mod_dct_i, run_prefix, save_prefix) for spc_basis_i, ene_basis_i in zip(spc_basis, ene_basis): chn_basis_ene_dct[spc_mod][spc_basis_i] = ene_basis_i # Calculate and store the 0 K Enthalpy hf0k = thmroutines.heatform.calc_hform_0k(ene_spc, ene_basis, spc_basis, coeff_basis, ref_set=ref_enes) spc_dct[spc_name]['Hfs'] = [hf0k] # Write the NASA polynomials in CHEMKIN format ckin_nasa_str = '' ckin_path = output_path('CKIN') for idx, spc_name in enumerate(spc_queue): ioprinter.nasa('calculate', spc_name) # Write the header describing the models used in thermo calcs ckin_nasa_str += writer.ckin.model_header(spc_mods, spc_mod_dct) # Build and write the NASA polynomial in CHEMKIN-format string # Call dies if you haven't run "write mess" task ckin_nasa_str += thmroutines.nasapoly.build_polynomial( spc_name, spc_dct, thm_paths[idx]['final'][0], thm_paths[idx]['final'][1]) ckin_nasa_str += '\n\n' print(ckin_nasa_str) nasa7_params_all = chemkin_io.parser.thermo.create_spc_nasa7_dct( ckin_nasa_str) # print('ckin_nasa_str test', ckin_nasa_str) ioprinter.info_message( 'SPECIES H(0 K) H(298 K) S(298 K) Cp(300 K) Cp(500 K) Cp(1000 K) Cp(1500 K)\n' ) ioprinter.info_message( ' kcal/mol kcal/mol cal/(mol K) ... \n') for spc_name in nasa7_params_all: nasa7_params = nasa7_params_all[spc_name] whitespace = 18 - len(spc_name) h0 = spc_dct[spc_name]['Hfs'][0] h298 = mechanalyzer.calculator.thermo.enthalpy( nasa7_params, 298.15) / 1000. s298 = mechanalyzer.calculator.thermo.entropy(nasa7_params, 298.15) cp300 = mechanalyzer.calculator.thermo.heat_capacity( nasa7_params, 300) cp500 = mechanalyzer.calculator.thermo.heat_capacity( nasa7_params, 500) cp1000 = mechanalyzer.calculator.thermo.heat_capacity( nasa7_params, 1000) cp1500 = mechanalyzer.calculator.thermo.heat_capacity( nasa7_params, 1500) whitespace = whitespace * ' ' ioprinter.info_message( '{}{}{:>7.2f}{:>9.2f}{:>9.2f}{:>9.2f}{:>9.2f}{:>9.2f}{:>9.2f}'. format(spc_name, whitespace, h0, h298, s298, cp300, cp500, cp1000, cp1500)) # Write all of the NASA polynomial strings writer.ckin.write_nasa_file(ckin_nasa_str, ckin_path)