def _interpret_reagent_count(rgt_cnt_str): _pattern = (STRING_START + capturing(maybe(DIGIT)) + capturing(one_or_more(NONSPACE))) cnt, rgt = find_first_capture(_pattern, rgt_cnt_str) cnt = int(cnt) if cnt else 1 rgts = (rgt, ) * cnt return rgts
def zero_point_vibrational_energies(output_str): """ Reads the zero-point energies for each of the hindered rotors from MESS output file string. :param output_str: string of lines of MESS output file :type output_str: str :return zpves: zero-point energy for each of the rotors :rtype: list(float) """ # Patterns for the ZPVE of a rotor num_patterns = (app.EXPONENTIAL_FLOAT, app.FLOAT, app.INTEGER) pattern1 = (app.escape('minimum energy[kcal/mol]') + app.one_or_more(app.SPACE) + '=' + app.one_or_more(app.SPACE) + app.capturing(app.one_of_these(num_patterns))) pattern2 = (app.escape('ground energy [kcal/mol]') + app.one_or_more(app.SPACE) + '=' + app.one_or_more(app.SPACE) + app.capturing(app.one_of_these(num_patterns))) # Obtain each ZPVE from the output string tmp1 = tuple(-float(val) for val in apf.all_captures(pattern1, output_str)) tmp2 = tuple(float(val) for val in apf.all_captures(pattern2, output_str)) tors_zpves = [sum(tmp) for tmp in zip(tmp1, tmp2)] # Convert to Hartrees for i, _ in enumerate(tors_zpves): tors_zpves[i] *= phycon.KCAL2EH return tuple(tors_zpves)
def _read_irc_reaction_path_summary(output_str, read_val): """ Reads the values for the Intrinsic Reaction Path from the table. :param output_str: string of the program's output file :type output_str: str :param read_val: value to read from table :type read_val: str :rtype: tuple(automol geom data structure) """ assert read_val in ('energy', 'coord') block = apf.last_capture( (app.escape('Summary of reaction path following') + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + app.escape('Total number of points:') + app.SPACES + app.INTEGER), output_str) if read_val == 'energy': pattern = (app.INTEGER + app.SPACES + app.capturing(app.FLOAT) + app.SPACES + app.FLOAT) elif read_val == 'coord': pattern = (app.INTEGER + app.SPACES + app.FLOAT + app.SPACES + app.capturing(app.FLOAT)) captures = apf.all_captures(pattern, block) if captures is not None: values = [float(capture) for capture in captures] else: values = None return values
def block_pattern(sym_ptt=par.Pattern.ATOM_SYMBOL, key_ptt=KEY_PATTERN, name_ptt=NAME_PATTERN, val_ptt=par.Pattern.NUMERIC_VALUE, mat_entry_start_ptt=None, mat_entry_sep_ptt=MAT_ENTRY_SEP_PATTERN, mat_entry_end_ptt=None, mat_line_start_ptt=None, mat_line_end_ptt=None, setv_start_ptt=SETVAL_START_PATTERN, setv_entry_sep_ptt=SETVAL_ENTRY_SEP_PATTERN, setv_entry_start_ptt=None, setv_sep_ptt=SETVAL_SEP_PATTERN, capture_matrix_block=False, capture_setval_block=False): """ full z-matrix pattern """ mat_ptt = _matrix_block_pattern(sym_ptt=sym_ptt, key_ptt=key_ptt, name_ptt=name_ptt, entry_start_ptt=mat_entry_start_ptt, entry_sep_ptt=mat_entry_sep_ptt, entry_end_ptt=mat_entry_end_ptt, line_start_ptt=mat_line_start_ptt, line_end_ptt=mat_line_end_ptt) setv_ptt = app.maybe( _setval_block_pattern(name_ptt=name_ptt, val_ptt=val_ptt, entry_sep_ptt=setv_entry_sep_ptt, entry_start_ptt=setv_entry_start_ptt, sep_ptt=setv_sep_ptt)) mat_ptt = app.capturing(mat_ptt) if capture_matrix_block else mat_ptt setv_ptt = app.capturing(setv_ptt) if capture_setval_block else setv_ptt block_ptt = app.padded(setv_start_ptt).join([mat_ptt, setv_ptt]) return block_ptt
def low_p_parameters(rxn_dstr, ea_units, a_units): """ Parses the data string for a reaction in the reactions block for a line containing the low-pressure fitting parameters, then reads the parameters from this line. :param rxn_dstr: data string for species in reaction block :type rxn_dstr: str :return params: Arrhenius fitting parameters for low-P rates :rtype: list(float) """ pattern = ('LOW' + app.zero_or_more(app.SPACE) + app.escape('/') + app.zero_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.zero_or_more(app.SPACE) + app.escape('/')) cap1 = apf.first_capture(pattern, rxn_dstr) if cap1 is not None: params = [float(val) for val in cap1] # Convert the units of Ea and A ea_conv_factor = get_ea_conv_factor(rxn_dstr, ea_units) a_conv_factor = get_a_conv_factor(rxn_dstr, a_units) params[2] = params[2] * ea_conv_factor params[0] = params[0] * a_conv_factor else: params = None return params
def plog_parameters(rxn_dstr): """ Parses the data string for a reaction in the reactions block for the lines containing the PLog fitting parameters, then reads the parameters from these lines. :param rxn_dstr: data string for species in reaction block :type rxn_dstr: str :return params: PLog fitting parameters :rtype: dict[pressure: params] """ pattern = ('PLOG' + app.zero_or_more(app.SPACE) + app.escape('/') + app.zero_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.zero_or_more(app.SPACE) + app.escape('/')) params_lst = apf.all_captures(pattern, rxn_dstr) # Build dictionary of parameters, indexed by parameter if params_lst: params_dct = {} for params in params_lst: pressure = float(params[0]) vals = list(map(float, params[1:])) if pressure not in params_dct: params_dct[pressure] = [vals] else: params_dct[pressure].append(vals) else: params_dct = None return params_dct
def zpves(output_string): """ Reads the zero-point energies for each of the hindered rotors from MESS output file string. :param output_string: string of lines of MESS output file :type output_string: str :return zpves: zero-point energy for each of the rotors :rtype: list(float) """ # Patterns for the ZPVE of a rotor num_patterns = (app.EXPONENTIAL_FLOAT, app.FLOAT) pattern1 = (app.escape('minimum energy[kcal/mol]') + app.one_or_more(app.SPACE) + '=' + app.one_or_more(app.SPACE) + app.capturing(app.one_of_these(num_patterns))) pattern2 = (app.escape('ground energy [kcal/mol]') + app.one_or_more(app.SPACE) + '=' + app.one_or_more(app.SPACE) + app.capturing(app.one_of_these(num_patterns))) # Obtain each ZPVE from the output string tmp1 = [-float(val) for val in apf.all_captures(pattern1, output_string)] tmp2 = [float(val) for val in apf.all_captures(pattern2, output_string)] tors_zpes = [sum(tmp) for tmp in zip(tmp1, tmp2)] # print('tors_zpes calc test:', tmp1, tmp2, tors_zpes) return tors_zpes
def _interpret_reagent_count(rgt_cnt_str): _pattern = (app.STRING_START + app.capturing(app.maybe(app.DIGIT)) + app.capturing(app.one_or_more(app.NONSPACE))) cnt, rgt = apf.first_capture(_pattern, rgt_cnt_str) cnt = int(cnt) if cnt else 1 rgts = (rgt, ) * cnt return rgts
def plog_parameters(rxn_dstr): """ gets parameters associated with plog strings """ pattern = ('PLOG' + app.zero_or_more(app.SPACE) + app.escape('/') + app.zero_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.zero_or_more(app.SPACE) + app.escape('/')) params_lst = apf.all_captures(pattern, rxn_dstr) # Build dictionary of parameters, indexed by parameter if params_lst: params_dct = {} for params in params_lst: pressure = float(params[0]) vals = list(map(float, params[1:])) params_dct[pressure] = vals # if pressure not in params_dct: # params_dct[pressure] = [vals] # else: # params_dct[pressure].append(vals) else: params_dct = None return params_dct
def cent_dist_const_reader(output_string): """ Get the quartic centrifugal distortion constants """ # block block = apf.last_capture( ('Quartic Centrifugal Distortion Constants Tau Prime' + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + 'Asymmetric Top Reduction'), output_string) if not block: block = apf.last_capture( ('Quartic Centrifugal Distortion Constants Tau Prime' + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + 'Constants in the Symmetrically Reduced Hamiltonian'), output_string) if not block: block = apf.last_capture( ('Quartic Centrifugal Distortion Constants Tau Prime' + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + 'Rotational l-type doubling constants'), output_string) # pattern pattern = ('TauP' + app.SPACE + app.capturing(app.one_or_more(app.LOWERCASE_LETTER)) + app.SPACES + app.capturing(app.EXPONENTIAL_FLOAT_D) + app.SPACES + app.EXPONENTIAL_FLOAT_D) # Get list of values cent_dist_const = [[lbl, float(val.replace('D', 'E'))] for (lbl, val) in apf.all_captures(pattern, block)] return cent_dist_const
def cubic_force_constants(output_str): """ Reads the cubic force constants from the output file string. Returns the constants in _. Hartree*amu(-3/2)*Bohr(-3) :param output_str: string of the program's output file :type output_str: str :rtype: tuple(tuple(float)) """ block = apf.last_capture( ('CUBIC FORCE CONSTANTS IN NORMAL MODES' + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + 'QUARTIC FORCE CONSTANTS IN NORMAL MODES'), output_str) pattern = (app.capturing(app.INTEGER) + app.SPACES + app.capturing(app.INTEGER) + app.SPACES + app.capturing(app.INTEGER) + app.SPACES + app.FLOAT + app.SPACES + app.FLOAT + app.SPACES + app.capturing(app.FLOAT)) caps = apf.all_captures(pattern, block) if caps: cfc_mat = _fc_mat(caps) else: cfc_mat = None return cfc_mat
def buffer_enhance_factors(rxn_dstr): """ get the factors of speed-up from bath gas """ species_char = app.one_of_these([ app.LETTER, app.DIGIT, app.escape('('), app.escape(')'), app.UNDERSCORE ]) species_name = app.one_or_more(species_char) # Get the line that could have the bath gas buffer enhancements bath_line_pattern = (_first_line_pattern(rct_ptt=SPECIES_NAMES_PATTERN, prd_ptt=SPECIES_NAMES_PATTERN, coeff_ptt=COEFF_PATTERN) + '\n' + app.capturing(app.LINE)) bath_string = apf.first_capture(bath_line_pattern, rxn_dstr) # Check if this line has bath gas factors or is for something else # If factors in string, get factors bad_strings = ('DUPLICATE', 'LOW', 'TROE', 'CHEB', 'PLOG') if (any(string in bath_string for string in bad_strings) and bath_string.strip() != ''): factors = None else: bath_string = '\n'.join(bath_string.strip().split()) factor_pattern = (app.capturing(species_name) + app.escape('/') + app.capturing(app.NUMBER) + app.escape('/')) baths = apf.all_captures(factor_pattern, bath_string) factors = {} for bath in baths: factors[bath[0]] = float(bath[1]) return factors
def low_p(rxn_str, ea_units, a_units): """ Parses the data string for a reaction in the reactions block for a line containing the low-pressure fitting parameters, then reads the parameters from this line. :param rxn_str: raw Chemkin string for a single reaction :type rxn_str: str :param ea_units: units of activation energies :type ea_units: string :param a_units: units of rate constants; either 'moles' or 'molecules' :type a_units: str :return params: Arrhenius fitting parameters for low-P rates :rtype: list(list(float)) """ pattern = ('LOW' + app.zero_or_more(app.SPACE) + app.escape('/') + app.zero_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.zero_or_more(app.SPACE) + app.escape('/')) cap1 = apf.first_capture(pattern, rxn_str) if cap1 is not None: params = [float(val) for val in cap1] # Convert the units of Ea and A ea_conv_factor = get_ea_conv_factor(ea_units) a_conv_factor = get_a_conv_factor(rxn_str, a_units) params[2] = params[2] * ea_conv_factor params[0] = params[0] * a_conv_factor params = [params] # convert to list inside a list else: params = None return params
def irc_coordinates(output_string): """ get the coordinates relative to the saddle point """ block = apf.last_capture( (app.escape('@IRC **** IRC Steps ****') + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + app.escape('---Fragment 1 Intrafragment Coordinates---')), output_string) pattern = (app.escape('@IRC') + app.SPACES + app.INTEGER + app.SPACES + app.FLOAT + app.SPACES + app.capturing(app.FLOAT) + app.SPACES + app.FLOAT + app.SPACES + app.LINE_FILL) captures = apf.all_captures(pattern, block) if captures is not None: # Remove duplicates that may appear because of Psi4 output printing unique_coords = [] for coord in captures: if coord not in unique_coords: unique_coords.append(coord) coords = [float(coord) for coord in unique_coords] else: coords = None return coords
def anharmonic_frequencies_reader(output_string): """ Get the anharmonic vibrational frequencies """ # block block = apf.last_capture( (app.escape('Fundamental Bands (DE w.r.t. Ground State)') + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + app.escape('Overtones (DE w.r.t. Ground State)')), output_string) pattern = (app.INTEGER + app.escape('(1)') + app.SPACE + app.maybe(app.one_or_more(app.LOWERCASE_LETTER)) + app.one_or_more(app.SPACE) + app.FLOAT + app.one_or_more(app.SPACE) + app.capturing(app.FLOAT)) # pattern2 = ( # app.INTEGER + # app.escape('(1)') + # app.SPACE + # app.maybe(app.one_or_more(app.LOWERCASE_LETTER)) + # app.one_or_more(app.SPACE) + # app.FLOAT + # app.one_or_more(app.SPACE) + # app.capturing(app.FLOAT) + # app.one_or_more(app.SPACE) + # app.one_or_more(app.escape('*')) + # app.one_or_more(app.SPACE) + # app.one_or_more(app.escape('*')) + # app.one_or_more(app.SPACE) + # app.FLOAT # ) # Get list of values anharm_freq = [float(val) for val in apf.all_captures(pattern, block)] return sorted(anharm_freq)
def formula(ich): """ Generate a formula dictionary from a ChI string. :param ich: ChI string :type ich: str :rtype: dict[str: int] """ sym_ptt = app.UPPERCASE_LETTER + app.zero_or_more(app.LOWERCASE_LETTER) num_ptt = app.maybe(app.UNSIGNED_INTEGER) ptt = app.capturing(sym_ptt) + app.capturing(num_ptt) def _connected_formula(ich): fml_str = formula_string(ich) fml = { s: int(n) if n else 1 for s, n in apf.all_captures(ptt, fml_str) } return fml # split it up to handle hard-coded molecules in multi-component inchis ichs = split(ich) fmls = list(map(_connected_formula, ichs)) fml = functools.reduce(automol.formula.join, fmls) return fml
def _read_irc_reaction_path_summary(output_string, read_val): """ get the desired values from the reaction path summary block """ assert read_val in ('energy', 'coord') block = apf.last_capture( (app.escape('Summary of reaction path following') + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + app.escape('Total number of points:') + app.SPACES + app.INTEGER), output_string) if read_val == 'energy': pattern = (app.INTEGER + app.SPACES + app.capturing(app.FLOAT) + app.SPACES + app.FLOAT) elif read_val == 'coord': pattern = (app.INTEGER + app.SPACES + app.FLOAT + app.SPACES + app.capturing(app.FLOAT)) captures = apf.all_captures(pattern, block) if captures is not None: values = [float(capture) for capture in captures] else: values = None return values
def troe(rxn_str): """ Parses the data string for a reaction in the reactions block for a line containing the Troe fitting parameters, then reads the parameters from this line. Only gets the 4 Troe-specific parameters: alpha, T***, T*, and T** :param rxn_str: raw Chemkin string for a single reaction :type rxn_str: str :return params: Troe fitting parameters :rtype: list(float) """ pattern = ( 'TROE' + app.zero_or_more(app.SPACE) + app.escape('/') + app.zero_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.maybe(app.one_or_more(app.SPACE) + app.capturing(app.NUMBER)) + app.zero_or_more(app.SPACE) + app.escape('/')) cap1 = apf.first_capture(pattern, rxn_str) if cap1 is not None: params = [] for val in cap1: if val is not None: params.append(float(val)) else: params.append(None) else: params = None return params
def troe_parameters(rxn_dstr): """ Parses the data string for a reaction in the reactions block for a line containing the Troe fitting parameters, then reads the parameters from this line. :param rxn_dstr: data string for species in reaction block :type rxn_dstr: str :return params: Troe fitting parameters :rtype: list(float) """ pattern = ( 'TROE' + app.zero_or_more(app.SPACE) + app.escape('/') + app.zero_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.one_or_more(app.SPACE) + app.capturing(app.NUMBER) + app.maybe(app.one_or_more(app.SPACE) + app.capturing(app.NUMBER)) + app.zero_or_more(app.SPACE) + app.escape('/')) cap1 = apf.first_capture(pattern, rxn_dstr) if cap1 is not None: params = [] for val in cap1: if val is not None: params.append(float(val)) else: params.append(None) else: params = None return params
def centrifugal_distortion_constants(output_str): """ Reads the VPT2-computed quartic centrifugal distortion constants from the output file string. Returns the constants in _. :param output_str: string of the program's output file :type output_str: str :rtype: tuple(tuple(float)) """ # Set patterns for all molecule types and symmetries block = apf.last_capture( ('Quartic Centrifugal Distortion Constants Tau Prime' + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + 'Asymmetric Top Reduction'), output_str) if not block: block = apf.last_capture( ('Quartic Centrifugal Distortion Constants Tau Prime' + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + 'Constants in the Symmetrically Reduced Hamiltonian'), output_str) if not block: block = apf.last_capture( ('Quartic Centrifugal Distortion Constants Tau Prime' + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + 'Rotational l-type doubling constants'), output_str) # Read values pattern = ('TauP' + app.SPACE + app.capturing(app.one_or_more(app.LOWERCASE_LETTER)) + app.SPACES + app.capturing(app.EXPONENTIAL_FLOAT_D) + app.SPACES + app.EXPONENTIAL_FLOAT_D) cent_dist_const = [[lbl, float(val.replace('D', 'E'))] for (lbl, val) in apf.all_captures(pattern, block)] return cent_dist_const
def ratek_fit_info(rxn_dstr): """ Read the information describing features of the fits to the rate constants """ # Read the temperatures and the Errors from the lines pressure_ptt = ( 'Pressure:' + app.SPACES + app.capturing(app.one_of_these([app.FLOAT, 'High'])) ) trange_ptt = ( 'Temps: ' + app.SPACES + app.capturing(app.INTEGER) + '-' + app.capturing(app.INTEGER) + app.SPACES + 'K' ) mean_ptt = ( 'MeanAbsErr:' + app.SPACES + app.capturing(app.FLOAT) + app.escape('%') + ',' ) max_ptt = ( 'MaxErr:' + app.SPACES + app.capturing(app.FLOAT) + app.escape('%') ) pressure_caps = apf.all_captures(pressure_ptt, rxn_dstr) trange_caps = apf.all_captures(trange_ptt, rxn_dstr) mean_caps = apf.all_captures(mean_ptt, rxn_dstr) max_caps = apf.all_captures(max_ptt, rxn_dstr) pressures = [] for pressure in pressure_caps: if pressure != 'High': pressures.append(float(pressure)) elif pressure == 'High': pressures.append(pressure) trange_vals = [] for cap in trange_caps: temp1, temp2 = cap trange_vals.append([int(temp1), int(temp2)]) if mean_caps is not None: mean_vals = [float(val) for val in mean_caps] else: mean_vals = [] if max_caps is not None: max_vals = [float(val) for val in max_caps] else: max_vals = [] # Build the inf_dct inf_dct = {} for idx, pressure in enumerate(pressures): inf_dct[pressure] = {'temps': trange_vals[idx]} if mean_vals: inf_dct[pressure].update({'mean_err': mean_vals[idx]}) if max_vals: inf_dct[pressure].update({'max_err': max_vals[idx]}) return inf_dct
def variable_value_pattern(variable_pattern=VARIABLE_PATTERN, delim_pattern=DELIM_PATTERN): """ captures the variable name and value from a line of the variable block """ patterns = [ app.capturing(variable_pattern), delim_pattern, app.capturing(app.FLOAT) ] pattern = _LSTART + app.LINESPACES.join(patterns) + _LEND return pattern
def dipole_moment(output_string): """ Reads the dipole moment """ pattern = (app.escape('Dipole moment (field-independent basis, Debye):') + app.NEWLINE + app.padded('X=') + app.capturing(app.FLOAT) + app.padded('Y=') + app.capturing(app.FLOAT) + app.padded('Z=') + app.capturing(app.FLOAT)) vals = [float(val) for val in apf.last_capture(pattern, output_string)] return vals
def _sublayers(lyr): """ get sublayers from a layer, by prefix """ if lyr: ptt = _sublayer_pattern(key_ptt=app.capturing(app.LOWERCASE_LETTER), val_ptt=app.capturing(NONSLASHES)) dct = dict(apf.all_captures(ptt, lyr)) else: dct = dict() return dct
def irc_path(output_str): """ Reads the coordinates and electronic energies (relative to saddple point) of the Intrinsic Reaction Coordinate. :param output_str: string of the program's output file :type output_str: str :rtype: tuple(automol geom data structure) """ # coordinates block = apf.last_capture( (app.escape('@IRC **** IRC Steps ****') + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + app.escape('---Fragment 1 Intrafragment Coordinates---')), output_str) pattern = ( app.escape('@IRC') + app.SPACES + app.INTEGER + app.SPACES + app.FLOAT + app.SPACES + app.capturing(app.FLOAT) + app.SPACES + app.FLOAT + app.SPACES + app.LINE_FILL ) captures = apf.all_captures(pattern, block) if captures is not None: # Remove duplicates that may appear because of Psi4 output printing unique_coords = [] for coord in captures: if coord not in unique_coords: unique_coords.append(coord) coords = [float(coord) for coord in unique_coords] else: coords = None # energies block = apf.last_capture( (app.escape('@IRC **** IRC Report ****') + app.capturing(app.one_or_more(app.WILDCARD, greedy=False)) + app.escape('@IRC **** IRC Steps ****')), output_str) pattern = ( app.escape('@IRC') + app.SPACES + app.INTEGER + app.SPACES + app.capturing(app.FLOAT) + app.SPACES + app.FLOAT ) captures = apf.all_captures(pattern, block) if captures is not None: energies = [float(capture) for capture in captures] else: energies = None return (coords, energies)
def temperatures(thm_dstr): """ get the common temperature from a thermo data string """ headline = apf.split_lines(thm_dstr)[0] pattern = (app.LINESPACES + app.capturing(app.UNSIGNED_FLOAT) + app.LINESPACES + app.capturing(app.UNSIGNED_FLOAT) + app.LINESPACES + app.capturing(app.UNSIGNED_FLOAT)) captures = apf.first_capture(pattern, headline) assert captures tmps = tuple(map(float, captures)) return tmps
def dipole_moment(output_string): """ Reads the dipole moment """ pattern = app.padded((app.LINESPACES.join( [app.escape('Dipole moment [Debye]:'), app.FLOAT])) + app.NEWLINE + app.padded('x=') + app.capturing(app.FLOAT) + app.padded('y=') + app.capturing(app.FLOAT) + app.padded('z=') + app.capturing(app.FLOAT)) vals = [float(val) for val in apf.last_capture(pattern, output_string)] return vals
def thermo_data_temperatures(thm_dstr): """ get the common temperature from a thermo data string """ headline = find_split_lines(thm_dstr)[0] pattern = (LINESPACES + capturing(UNSIGNED_FLOAT) + LINESPACES + capturing(UNSIGNED_FLOAT) + LINESPACES + capturing(UNSIGNED_FLOAT)) captures = find_first_capture(pattern, headline) assert captures tmps = tuple(map(float, captures)) return tmps
def low_p_parameters(rxn_dstr): """ low-pressure parameters """ pattern = ('LOW' + app.zero_or_more(app.SPACE) + app.escape('/') + app.SPACES + app.capturing(app.NUMBER) + app.SPACES + app.capturing(app.NUMBER) + app.SPACES + app.capturing(app.NUMBER) + app.zero_or_more(app.SPACE) + app.escape('/')) params = apf.first_capture(pattern, rxn_dstr) if params is not None: params = [float(val) for val in params] return params
def dipole_moment(output_string): """ Reads the dipole moment """ pattern = app.LINESPACES.join([ 'Total Dipole Moment', ':', app.capturing(app.FLOAT), app.capturing(app.FLOAT), app.capturing(app.FLOAT) ]) vals = [float(val) for val in apf.last_capture(pattern, output_string)] return vals