Exemplo n.º 1
0
def compare_rdf(simname,
                nhis,
                labels,
                bool_first,
                coords_loc=[3, 6],
                linewidthv=2,
                save=False):
    fig = plt.figure(figsize=(8, 8), dpi=100)
    ax = fig.add_subplot(1, 1, 1)
    fontProperties = {'family': 'serif', 'size': 20}
    ax.set_xticklabels(ax.get_xticks(), {'family': 'serif', 'size': 16})
    ax.xaxis.set_major_formatter(FormatStrFormatter('%g'))
    ax.set_xlabel('$r$', fontProperties)
    ax.tick_params(direction='in')
    ax.set_yticklabels(ax.get_yticks(), {'family': 'serif', 'size': 16})
    ax.yaxis.set_major_formatter(FormatStrFormatter('%g'))
    ax.set_ylabel('$g(r)$', fontProperties)
    ax.tick_params(direction='in')
    for index, filename in enumerate(simname):
        if bool_first[index] == 0:
            df, bs = extract.extract_unwrapped(filename,
                                               last_only=True,
                                               boxsize=True)
        elif bool_first[index] == 1:
            df, bs = extract.extract_unwrapped(filename,
                                               first_only=True,
                                               boxsize=True)
        coord = df['timestep_0']
        del df
        g, r = compute.radial_distribution_function(coord, bs, filename,
                                                    coords_loc, nhis)
        ax.plot(r, g, linewidth=linewidthv, label=labels[index])
    ax.legend(fontsize=16)
    if save:
        plt.savefig(simname[index] + '_comparison.png', dpi=300)
Exemplo n.º 2
0
def radius_of_gyration_squared_integrated(*args, mass=1, sidechain=False):
    """
    Enter the filenames of multiple parts of the same simulation
    and this file will return the cumulative R_g^2 for all of them
    combined.

    Args:
    *args (string): filenames of the simulation.

    Returns:
    Rog ^2, Rend^2
    """
    rog_sq = []
    rend_sq = []
    for filename in args:
        df_unwrap, bs = extract.extract_unwrapped(filename,
                                                  format_spec=[
                                                      'id', 'mol', 'type',
                                                      'xu', 'yu', 'zu', 'ix',
                                                      'iy', 'iz'
                                                  ],
                                                  boxsize_whole=True)
        rend_sq_curr, gauss_curr = compute.end_to_end_distance_squared(
            df_unwrap, bs, sidechain=sidechain)
        rog_sq_curr = compute.radius_of_gyration_squared(df_unwrap, mass)
        rog_sq = rog_sq + rog_sq_curr
        rend_sq = rend_sq + rend_sq_curr
    return rog_sq, rend_sq
def find_tracked_pairs_unique(distances, simname):
    """Find the number of tracked pairs below the specified cutoff"""
    coord, bs = extract.extract_unwrapped(simname, boxsize_whole=True)
    pairs_under_cutoff = np.zeros(len(coord.keys()))
    charged_pair_distances = {}
    for index, key in enumerate(coord):
        box_l = bs[key]
        sidehx = box_l[0] / 2
        sidehy = box_l[1] / 2
        sidehz = box_l[2] / 2
        chargedpairdistance = np.zeros((1634, 1))
        for index_inner, atomid in enumerate(distances['timestep_0']):
            current_timestep = coord[key]
            pcharge = current_timestep[current_timestep['id'] ==
                                       atomid[0]].iloc[:, 3:6].values
            ncharge = current_timestep[current_timestep['id'] ==
                                       atomid[1]].iloc[:, 3:6].values
            dx = pcharge[0][0] - ncharge[0][0]
            dy = pcharge[0][1] - ncharge[0][1]
            dz = pcharge[0][2] - ncharge[0][2]
            if (dx < -sidehx): dx = dx + box_l[0]
            if (dx > sidehx): dx = dx - box_l[0]
            if (dy < -sidehy): dy = dy + box_l[1]
            if (dy > sidehy): dy = dy - box_l[1]
            if (dz < -sidehz): dz = dz + box_l[2]
            if (dz > sidehz): dz = dz - box_l[2]
            distAB = [dx, dy, dz]
            chargedpairdistance[index_inner] = np.linalg.norm(distAB)
        chargedpairdistance = chargedpairdistance[chargedpairdistance != 0]
        charged_pair_distances[index] = chargedpairdistance
        #pairs_under_cutoff[index] = np.asarray(np.where(chargedpairdistance<cut_off)).shape[1]
    return charged_pair_distances
Exemplo n.º 4
0
def msd_integrated(*args, coord_loc=[3, 6]):
    """
    Args:
    *args (string): filenames of the simulation.

    Returns:
    msd (cumulative list)
    """
    msd = []
    df_unwrap = extract.extract_unwrapped(args[0])
    r_0 = df_unwrap['timestep_0']
    r_0.sort_values(by=['id'], inplace=True)
    r_0 = r_0.iloc[:, coord_loc[0]:coord_loc[1]].values
    for filename in args:
        df_unwrap = extract.extract_unwrapped(filename)
        msd_curr = compute.msd(df_unwrap, r_0, coord_loc)
        msd = msd + msd_curr
    return msd
Exemplo n.º 5
0
def msd_com_inner_integrated(*args, coord_loc=[3, 6]):
    """
    """
    msd = []
    df_unwrap = extract.extract_unwrapped(args[0])
    r_0 = df_unwrap['timestep_0']
    total_chains = sorted(r_0.mol.unique())
    r_0_com = np.empty((len(total_chains), 3),
                       dtype=None)  #Initialize a None array
    for chain in total_chains:
        curr_chain = r_0[r_0['mol'] ==
                         chain].iloc[:, coord_loc[0]:coord_loc[1]].values
        curr_com = np.mean(curr_chain, axis=0)
        r_0_com[int(chain - 1), :] = curr_com
    r_0.sort_values(by=['id'], inplace=True)
    r_0 = r_0.iloc[:, coord_loc[0]:coord_loc[1]].values
    for filename in args:
        df_unwrap = extract.extract_unwrapped(filename)
        msd_curr = compute.msd_com_inner(df_unwrap, r_0, r_0_com, coord_loc)
        msd = msd + msd_curr
    return msd
Exemplo n.º 6
0
def msd_molecular_com_integrated(*args, coord_loc=[3, 6]):
    """
    Args:
    *args (string): filenames of the different sequences/parts of the SAME
    simulation.

    Returns:
    msd(cumulative list)
    """
    msd = []
    df_unwrap = extract.extract_unwrapped(args[0])
    r_0 = df_unwrap['timestep_0']
    total_chains = sorted(r_0.mol.unique())
    r_0_com = np.empty((len(total_chains), 3), dtype=None)
    for chain in total_chains:
        curr_chain = r_0[r_0['mol'] ==
                         chain].iloc[:, coord_loc[0]:coord_loc[1]].values
        curr_com = np.mean(curr_chain, axis=0)
        r_0_com[int(chain - 1), :] = curr_com
    for filename in args:
        df_unwrap = extract.extract_unwrapped(filename)
        msd_curr = compute.msd_molecular_com(df_unwrap, r_0_com, coord_loc)
        msd = msd + msd_curr
    return msd
Exemplo n.º 7
0
def chain_orientation_parameter_combined(simname, nfiles, nc, dp):
    """
    Compute chain orientation parameter from multiple unwrapped files 
    (different parts of the same simulation) and combine them in one
    array.
        
    Args:
    simname (string): Name of the simulation (type the name of the simulation
    only till density which is mostly written as 'uk'). Do not add simulation
    number (e.g. uk_1).
    nfiles (int): Number of simulation parts for this specific simulation

    Returns:
    aggregate_cop_array: One array containing the evolution of chain
    orientation parameter from initial topology file to the last
    equilibration step.
    """
    cop_x = []
    cop_y = []
    cop_z = []
    for sims in range(1, nfiles + 1):
        curr_fname = simname + '_' + str(sims)
        coord = extract.extract_unwrapped(curr_fname)
        for key in coord:
            cop_x.append(
                compute.chain_orientation_parameter(coord[key], [1, 0, 0], nc,
                                                    dp))
            cop_y.append(
                compute.chain_orientation_parameter(coord[key], [0, 1, 0], nc,
                                                    dp))
            cop_z.append(
                compute.chain_orientation_parameter(coord[key], [0, 0, 1], nc,
                                                    dp))
    dumpnamex = simname + '_cop_x'
    dumpnamey = simname + '_cop_y'
    dumpnamez = simname + '_cop_z'

    hkl.dump(cop_x, dumpnamex)
    hkl.dump(cop_y, dumpnamey)
    hkl.dump(cop_z, dumpnamez)
    return zip(cop_x, cop_y, cop_z)