def test__read(): """ test read """ val1 = dict_.values_by_unordered_tuple(DCT4, ('C', 'H')) val2 = dict_.values_by_unordered_tuple(DCT4, ('H', 'C')) assert numpy.isclose(val1, val2, 1.54)
def alpha(freqs, cfc_dct, vr4=None): """ calculate alpha from expansion """ # Obtain the imaginary frequency (finds negative ridxs = (idx for idx, freq in enumerate(freqs) if freq < 0.0) assert len(ridxs) == 1, ('Freqs should only have one imag') freqs = (abs(freq) for freq in freqs) ridx = ridxs[0] rfreq = freqs[ridx] # Calculate alpha with cubic contributions term1 = (5.0 / 3.0) * (cfc_dct[(ridx, ridx, ridx)]**2 / rfreq**3) term2 = 0.0 for i, ifreq in enumerate(freqs): vval = dict_.values_by_unordered_tuple(cfc_dct, (i, ridx, ridx)) tm1 = (vval**2 / ifreq**3) tm2 = 2.0 * ifreq**(-2) + (1.0 / (4.0 * rfreq**2 + ifreq**2)) term2 += ((tm1 * tm2), ) _alpha = (numpy.pi / 8.0) * (term1 - term2) # Calculate quartic contributions to alpha, if available if vr4 is not None: _alpha -= (numpy.pi / 8.0) * (cfc_dct[(ridx, ridx, ridx, ridx)] / rfreq**6) return _alpha
def _ts_bnd_len(zma, scan_coord): """ Obtain the current value of the bond defined by the scam coordinate """ symbs = automol.zmat.symbols(zma) dist_coo, = automol.zmat.coordinates(zma)[scan_coord] ts_bnd_symbs = tuple(sorted(map(symbs.__getitem__, dist_coo))) ts_bnd_len = dict_.values_by_unordered_tuple(bnd.LEN_DCT, ts_bnd_symbs) return ts_bnd_len
def _pairwise_potentials(geo, idx_pair, potential='exp6'): """ Calculate the sum of the pairwise potential for a given pair of atoms in a geometry. :param geo: automol geometry object :type geo: tuple(tuple(float)) :param idx_pair: indices of atoms for which to calculate interaction :type idx_pair: tuple(int, int) :param potential: potential model of the atomic interactions :type potential: str :rtype: nd.array """ assert potential in ('exp6', 'lj_12_6'), ( f'potential {potential} != exp6 or lj_12_6') # Get the indexes and symbols idx1, idx2 = idx_pair if idx1 != idx2: # Get the symbols of the atoms symbs = symbols(geo) symb1, symb2 = symbs[idx1], symbs[idx2] # Calculate interatomic distance rdist = (distance(geo, idx1, idx2) * phycon.BOHR2ANG) # Calculate the potential if potential == 'exp6': params = dict_.values_by_unordered_tuple(EXP6_DCT, (symb1, symb2)) pot_val = exp6_potential(rdist, *params) elif potential == 'lj_12_6': params = dict_.values_by_unordered_tuple(LJ_DCT, (symb1, symb2)) pot_val = lj_potential(rdist, *params) else: pot_val = 1.0e10 return pot_val
def test__read(): """ test dict_.values_by_unordered_tuple test dict_.values_in_multilevel """ # Unordered unordered tuple reads val1 = dict_.values_by_unordered_tuple(DCT4, ('C', 'H')) val2 = dict_.values_by_unordered_tuple(DCT4, ('H', 'C')) assert numpy.isclose(1.54, val1, val2) val3 = dict_.values_by_unordered_tuple(DCT4, ('C', 'H'), fill_val=1.15) val4 = dict_.values_by_unordered_tuple(DCT4, ('C', 'N'), fill_val=1.15) assert numpy.isclose(1.54, val3) assert numpy.isclose(1.15, val4) # Multilevel dct reads val1 = dict_.values_in_multilevel_dct(GDCT3, 'key1', 'subkey2', fill_val='fill') val2 = dict_.values_in_multilevel_dct(GDCT3, 'key2', 'subkey1', fill_val='fill') val3 = dict_.values_in_multilevel_dct(GDCT3, 'key1', 'subkey3', fill_val='fill') val4 = dict_.values_in_multilevel_dct(GDCT3, 'key3', 'subkey1', fill_val='fill') assert val1 == 'subval1-2' assert val2 == 'subval2-1' assert val3 == 'fill' assert val4 == 'fill'
def _ts_compare(ref_zma, zma, zrxn): """ Perform a series of checks to assess the viability of a transition state geometry prior to saving """ # Initialize viable viable = True # Get the bond dists and calculate the distance of bond being formed ref_geo = automol.zmat.geometry(ref_zma) cnf_geo = automol.zmat.geometry(zma) grxn = automol.reac.relabel_for_geometry(zrxn) frm_bnd_keys = automol.reac.forming_bond_keys(grxn) brk_bnd_keys = automol.reac.breaking_bond_keys(grxn) cnf_dist_lst = [] ref_dist_lst = [] bnd_key_lst = [] cnf_ang_lst = [] ref_ang_lst = [] for frm_bnd_key in frm_bnd_keys: frm_idx1, frm_idx2 = list(frm_bnd_key) cnf_dist = distance(cnf_geo, frm_idx1, frm_idx2) ref_dist = distance(ref_geo, frm_idx1, frm_idx2) cnf_dist_lst.append(cnf_dist) ref_dist_lst.append(ref_dist) bnd_key_lst.append(frm_bnd_key) for brk_bnd_key in brk_bnd_keys: brk_idx1, brk_idx2 = list(brk_bnd_key) cnf_dist = distance(cnf_geo, brk_idx1, brk_idx2) ref_dist = distance(ref_geo, brk_idx1, brk_idx2) cnf_dist_lst.append(cnf_dist) ref_dist_lst.append(ref_dist) bnd_key_lst.append(brk_bnd_key) for frm_bnd_key in frm_bnd_keys: for brk_bnd_key in brk_bnd_keys: for frm_idx in frm_bnd_key: for brk_idx in brk_bnd_key: if frm_idx == brk_idx: idx2 = frm_idx idx1 = list(frm_bnd_key - frozenset({idx2}))[0] idx3 = list(brk_bnd_key - frozenset({idx2}))[0] cnf_ang = central_angle(cnf_geo, idx1, idx2, idx3) ref_ang = central_angle(ref_geo, idx1, idx2, idx3) cnf_ang_lst.append(cnf_ang) ref_ang_lst.append(ref_ang) # print('bnd_key_list', bnd_key_lst) # print('conf_dist', cnf_dist_lst) # print('ref_dist', ref_dist_lst) # print('conf_angle', cnf_ang_lst) # print('ref_angle', ref_ang_lst) # Set the maximum allowed displacement for a TS conformer max_disp = 0.6 # better to check for bond-form length in bond scission with ring forming if 'addition' in grxn.class_: max_disp = 0.8 if 'abstraction' in grxn.class_: # this was 1.4 - SJK reduced it to work for some OH abstractions max_disp = 1.0 # Check forming bond angle similar to ini config if 'elimination' not in grxn.class_: for ref_angle, cnf_angle in zip(ref_ang_lst, cnf_ang_lst): if abs(cnf_angle - ref_angle) > .44: print('angle', ref_angle, cnf_angle) viable = False symbs = symbols(cnf_geo) lst_info = zip(ref_dist_lst, cnf_dist_lst, bnd_key_lst) for ref_dist, cnf_dist, bnd_key in lst_info: if 'add' in grxn.class_ or 'abst' in grxn.class_: bnd_key1, bnd_key2 = min(list(bnd_key)), max(list(bnd_key)) symb1 = symbs[bnd_key1] symb2 = symbs[bnd_key2] if bnd_key in frm_bnd_keys: # Check if radical atom is closer to some atom # other than the bonding atom cls = automol.zmat.base.is_atom_closest_to_bond_atom( zma, bnd_key2, cnf_dist) if not cls: print('distance', ref_dist, cnf_dist) print(' - Radical atom now has a new nearest neighbor') viable = False # check forming bond distance if abs(cnf_dist - ref_dist) > max_disp: print('distance', ref_dist, cnf_dist) viable = False # Check distance relative to equi. bond equi_bnd = dict_.values_by_unordered_tuple(bnd.LEN_DCT, (symb1, symb2), fill_val=0.0) displace_from_equi = cnf_dist - equi_bnd dchk1 = abs(cnf_dist - ref_dist) > 0.1 dchk2 = displace_from_equi < 0.2 if dchk1 and dchk2: print(cnf_dist, equi_bnd) viable = False else: # check forming/breaking bond distance # if abs(cnf_dist - ref_dist) > 0.4: # max disp of 0.4 causes problems for bond scission w/ ring forming # not sure if setting it to 0.3 will cause problems for other cases if abs(cnf_dist - ref_dist) > 0.3: print('distance', ref_dist, cnf_dist) viable = False return viable