Exemplo n.º 1
0
            pair_params.append(tuple([ float(x) for x in line.split()[4:] ]))
    nn_pair_params = pair_params[2*n_native_pairs + 1::2]
    Enn_obs = observables.PairEnergySum(top, nn_pairs, nn_pair_type, nn_eps, nn_pair_params)

    # Parameterize native energy 
    nat_pair_type = np.loadtxt("%s/pairwise_params" % dir, usecols=(3,), dtype=int)[1:2*n_native_pairs:2]
    nat_pairs = np.loadtxt("%s/pairwise_params" % dir, usecols=(0,1), dtype=int)[1:2*n_native_pairs:2] - 1
    nat_eps = np.loadtxt("%s/model_params" % dir)[1:2*n_native_pairs:2]

    nat_pair_params = pair_params[1:2*n_native_pairs:2]
    Enat_obs = observables.PairEnergySum(top, nat_pairs, nat_pair_type, nat_eps, nat_pair_params)

    # Load or compute Enn vs Q
    if not os.path.exists("binned_Enn_vs_%s/Enn_vs_bin.dat" % coordname):
        print "binning Enn"
        Enn_bin_avg = observables.bin_observable(trajfiles, Enn_obs, qtanh, bin_edges)

        if not os.path.exists("binned_Enn_vs_%s" % coordname):
            os.mkdir("binned_Enn_vs_%s" % coordname)
        os.chdir("binned_Enn_vs_%s" % coordname)
        np.savetxt("Enn_vs_bin.dat",Enn_bin_avg)
        np.savetxt("bin_edges.dat",bin_edges)
        os.chdir("..")
    else:
        print "loading Enn"
        Enn_bin_avg = np.loadtxt("binned_Enn_vs_%s/Enn_vs_bin.dat" % coordname)

    # Load or compute Enat vs Q
    if not os.path.exists("binned_Enat_vs_%s/Enat_vs_bin.dat" % coordname):
        print "binning Enat"
        Enat_bin_avg = observables.bin_observable(trajfiles, Enat_obs, qtanh, bin_edges)
Exemplo n.º 2
0
    Atanhi_obs = observables.TanhContacts(top, nn_pairs, nn_r0_cont, widths)
    if os.path.exists("binned_Ai_vs_Qtanh_0_05/Ai_vs_bin.dat"):
        os.chdir("binned_Ai_vs_Qtanh_0_05")
        mid_bin = np.loadtxt("mid_bin.dat")
        Atanhi_bin_avg = np.loadtxt("Ai_vs_bin.dat")
        os.chdir("..")
        
        bins = np.zeros(mid_bin.shape[0] + 1, float)
        bins[1:-1] = 0.5*(mid_bin[1:] + mid_bin[:-1])
        bins[0] = mid_bin[0] - (bins[1] - mid_bin[0])
        bins[-1] = mid_bin[-1] + (mid_bin[-1] - bins[-2])
    else:
        n, bins = np.histogram(np.concatenate(qtanh),bins=40)
        mid_bin = 0.5*(bins[1:] + bins[:-1])

        Atanhi_bin_avg = observables.bin_observable(trajfiles, Atanhi_obs, qtanh, bin_edges)

        if not os.path.exists("binned_Ai_vs_Qtanh_0_05"):
            os.mkdir("binned_Ai_vs_Qtanh_0_05")
        os.chdir("binned_Ai_vs_Qtanh_0_05")
        np.savetxt("mid_bin.dat",mid_bin)
        np.savetxt("Ai_vs_bin.dat",Atanhi_bin_avg)
        os.chdir("..")

    bin_edges = np.array([ [bins[i], bins[i+1]] for i in range(len(bins) - 1 ) ])

    # Calculate variance in Ai
    dAtanhi2_bin_avg = observables.bin_observable_variance(trajfiles, Atanhi_obs, Atanhi_bin_avg, qtanh, bin_edges)

    if not os.path.exists("binned_dAi2_vs_Qtanh_0_05"):
        os.mkdir("binned_dAi2_vs_Qtanh_0_05")