Exemplo n.º 1
0
 def testSubtractInSameImage(self):
     self.assertTrue(
         np.allclose(pbc_calc_vector(VEC_1, VEC_2, PBC_BOX), VEC_21))
     self.assertTrue(
         np.allclose(pbc_calc_vector(VEC_3, VEC_2, PBC_BOX), VEC_23))
     self.assertFalse(
         np.allclose(pbc_calc_vector(VEC_3, VEC_2, PBC_BOX), VEC_21))
     self.assertTrue(
         np.allclose(pbc_calc_vector(A_VEC, B_VEC, PBC_BOX),
                     GOOD_A_MINUS_B))
Exemplo n.º 2
0
def calc_q_arq(r_ao, r_do, r_h, box, r0_sc, r0_da_q, lambda_q):
    """
    Calculates the 3-body term, keeping the pbc in mind, per Maupin et al. 2006,
    http://pubs.acs.org/doi/pdf/10.1021/jp053596r, equations 7-8
    @param r_ao: x,y,z position of the acceptor oxygen (closest water O)
    @param r_do: x,y,z position of the donor oxygen (always using the glu oxygen, for now)
    @param r_h: x,y,z position of the reactive H
    @param box: the dimensions of the periodic box (assumed 90 degree angles)
    @param r0_sc: parameter for calc
    @param r0_da_q: parameter for calc
    @param lambda_q: parameters for calc
    @return: the dot-product of the vector q (not the norm, as we need it squared for the next step)
    """
    da_dist = pbc_dist(r_do, r_ao, box)
    r_sc = r0_sc - lambda_q * (da_dist - r0_da_q)
    r_dh = pbc_calc_vector(r_h, r_do, box)
    r_da = pbc_calc_vector(r_ao, r_do, box)
    q_vec = np.subtract(r_dh, r_sc * r_da / 2.0)
    return da_dist, np.dot(q_vec, q_vec)
Exemplo n.º 3
0
def calc_more_ocoh_props(box, carboxyl_c_xyz, o_star_xyz, alt_o_xyz,
                         excess_h_xyz):
    """
    If requested and there are xyz coords,
    @param box: xyz box size
    @param carboxyl_c_xyz:
    @param o_star_xyz:
    @param alt_o_xyz:
    @param excess_h_xyz:
    @return: a dict of additional calculated properties
    """
    if carboxyl_c_xyz is not None:
        # TODO: test that accounts for the case when carboxyl group is broken over the PBC
        # does not have be be shown: move c_carbon to the origin; we know the results of moving it and multiplying
        #   the resulting xyz coords (0, 0, 0) by the COM_WEIGHT_C
        c_o_star_vec = pbc_calc_vector(o_star_xyz, carboxyl_c_xyz, box)
        c_alt_o_vec = pbc_calc_vector(alt_o_xyz, carboxyl_c_xyz, box)
        c_h_star_vec = pbc_calc_vector(excess_h_xyz, carboxyl_c_xyz, box)
        o_star_h_vec = pbc_calc_vector(excess_h_xyz, o_star_xyz, box)

        com_xyz = COM_WEIGHT_PER_O * c_o_star_vec
        com_xyz += COM_WEIGHT_PER_O * c_alt_o_vec

        oh_prop_dict = {
            COM_H_DIST: pbc_dist(com_xyz, c_h_star_vec, box),
            OCO_ANGLE: vec_angle(c_o_star_vec, c_alt_o_vec),
            OCOH_DIH: vec_dihedral(c_alt_o_vec, c_o_star_vec, o_star_h_vec),
            COM_XYZ: carboxyl_c_xyz + com_xyz
        }
    else:
        oh_prop_dict = {
            COM_H_DIST: np.nan,
            OCO_ANGLE: np.nan,
            OCOH_DIH: np.nan,
            COM_XYZ: np.nan
        }
    return oh_prop_dict
Exemplo n.º 4
0
def adjust_atom_dist(cfg, data_tpl_content):
    """
    If this options is selected, adjust the xyz coordinates to specified distances
    @param cfg: configuration for the run
    @param data_tpl_content: processed data from the template
    @return: will print new data files or raise InvalidDataError
    """
    for atom_num in cfg[ATOMS_DIST]:
        if atom_num > data_tpl_content[NUM_ATOMS]:
            raise InvalidDataError(
                "Keyword '{}' specified atom indexes {} but found only "
                "{} atoms in the data template file: {}".format(
                    ATOMS_DIST, cfg[ATOMS_DIST], data_tpl_content[NUM_ATOMS],
                    cfg[DATA_TPL_FILE]))
    # since python is zero-based, must subtract 1
    pivot_atom_num = cfg[ATOMS_DIST][0] - 1
    pivot_atom = data_tpl_content[ATOMS_CONTENT][pivot_atom_num]
    pivot_xyz = np.array(pivot_atom[4:7])

    moving_atom_num = cfg[ATOMS_DIST][1] - 1
    moving_atom = data_tpl_content[ATOMS_CONTENT][moving_atom_num]
    moving_xyz = np.array(moving_atom[4:7])

    diff_vector = pbc_calc_vector(moving_xyz, pivot_xyz,
                                  data_tpl_content[BOX_SIZE])
    base_dist = np.linalg.norm(diff_vector)

    head_content = data_tpl_content[HEAD_CONTENT]
    atoms_content = data_tpl_content[ATOMS_CONTENT]
    tail_content = data_tpl_content[TAIL_CONTENT]

    for new_dist in cfg[NEW_DIST_LIST]:
        multiplier = new_dist / base_dist
        f_name = create_out_fname(cfg[DATA_TPL_FILE],
                                  suffix='_' + str(new_dist),
                                  ext='.data')
        atoms_content[moving_atom_num][4:7] = np.round(
            multiplier * diff_vector + pivot_xyz, 6)
        list_to_file(head_content + atoms_content + tail_content, f_name)
Exemplo n.º 5
0
 def testSubtractInDiffImages(self):
     self.assertTrue(
         np.allclose(pbc_calc_vector(A_VEC, C_VEC, PBC_BOX),
                     GOOD_A_MINUS_C))