Пример #1
0
Nobs = len(fsw)
for i in range(len(LDCuts_2)):
        pickleName = os.path.join(data_dir, 'c25_fsw', 'corrcoeff.pickle')
        data = pickle.load(open(pickleName, 'r'))
        rsq = data[1][i,ind]**2.
        var_r = (1-rsq)*(1-rsq)/Nobs # look here: http://www.jstor.org/stable/2277400?seq=3#page_scan_tab_contents
        err[i] = np.sqrt(4*rsq*var_r) # Error propagation rules for products of random variables
        Rsq_avgerr += err[i]/rsq

Rsq_avgerr /= len(LDCuts_2)
file('errbar.dat', 'a').write('\n Rsq avg. error = %g %%\n' % Rsq_avgerr)


######################## PLOTTING ############################
# srel_rc plot and design
fig = plt.figure(figsize = (setup.set_width('single'),2.8*2))
ax1 = fig.add_subplot(2,1,1)
ax1.errorbar(LDCuts_1, srel, yerr = err_delta, color = 'black', fmt = '--o', linewidth = 1, markersize = 3)
ax1.plot(LDCuts_1, srel, 'k-')
for i, p in enumerate(crit_points): ax1.plot(p, crit_srel[i], 'ro', markersize = 3, markerfacecolor = 'k', markeredgecolor = 'r', markeredgewidth = 1)
ax1.set_ylabel('$S_{rel}$')
setup.prune(ax1, nbins = 6)
if system == 'methane25':
        ax1.set_ylim([-0.92,0.2])
        ax1.annotate(r'$r_c = 6$' + setup.Angstrom2, xy = (6.0, -0.75), fontsize = 10)
        ax1.annotate(r'$r_c = 7.8$' + setup.Angstrom2, xy = (7.8, -0.86), fontsize = 10)
else:
        ax1.annotate(r'$r_c = 6.5$' + setup.Angstrom2, xy = (6.1, -0.117), fontsize = 10)
        ax1.annotate(r'$r_c = 7.8$' + setup.Angstrom2, xy = (8.0, -0.15), fontsize = 10)

# corrcoeff plot and design
Пример #2
0
import setup
import parse_potential as pp
matplotlib.rcParams.update(setup.params)

# data paths
prefix = '/home/tanmoy/projects/paper1_plots/data/FORCEFIELDS/cgff_methane25_newrc_50LDKnots/methane25_wca_SPLD'
logfile, histfile, sumfile = pp.parseFileNames(prefix)
rho, pot = pp.parseLog(sumfile)['LD']
rholist = rho.tolist()

# start potential from zero
pot-= pot[0]
start = [rholist.index(x) for x in rholist if rholist.__contains__(x) and x >=1.][0]

# normalized f(rho)
fig1 = plt.figure(figsize = (setup.set_width('single'),2.8))	
ax1 = fig1.add_subplot(1,1,1)
ax1.plot(rho, pot, 'r-')

# normalized f(rho)/rho
fig2 = plt.figure(figsize = (setup.set_width('single'),2.8))
ax2 = fig2.add_subplot(1,1,1)
ax2.plot(rho, pot/rho, 'r-')


# Design
ax1.set_ylim([-2.5, 0.7])
for ax in [ax1,ax2]: setup.prune(ax, nbins = 8)
ax1.set_xlabel('local density of methane')
ax1.set_ylabel('potential ' + r'$(kcal/mol)$')
ax2.set_xlabel('local density of methane ' + r'$(\rho)$')
Пример #3
0
# get SASA correlations for all chain lengths
conv_factor = (4.184e6) / (6.023e23 * (1e-10) ** 2.0)  # kcal/A^2 to mJ/m^2
Nmons = [10, 20, 25, 30, 40]
gamma = np.zeros(len(Nmons))
gamma_err = np.zeros(len(Nmons))
for n, Nmon in enumerate(Nmons):
    SASApickle, Enepickle = getPickleNames(Nmon)
    SASA = getSASA(SASApickle, Nmon=Nmon)
    EnePairExcess, EneLD, EneSum = getEne(Enepickle)
    slope, intercept, corrcoeff, pval, stderr = linregress(SASA, EneSum)
    gamma[n] = slope * conv_factor
    gamma_err[n] = stderr * conv_factor

# master plot and design
fig = plt.figure(figsize=(setup.set_width("single"), 3))
ax = fig.add_subplot(1, 1, 1)
ax.plot(SASA25, EneSum25, linestyle="None", marker="o", color="r", markeredgecolor="r")
ax.plot(SASA25, m * SASA25 + c, linestyle="solid", color="k", linewidth=3)
ax.set_ylim([-5, 15])
setup.prune(ax, nbins=6)
ax.set_xlabel(r"$SASA\left( \mathrm{\AA}^2\right)$")
ax.set_ylabel(r"$U_{SP} - U_{WCA} + U_{LD}$" + setup.energy)
ax.annotate(r"$\gamma_{eff} = $" + " %d" % gamma[2] + r"$mN/m$", xy=(698, -0.2))

# inset plot and design
axL = fig.add_axes([0.23, 0.62, 0.3, 0.3])
ax_inset = axL.twinx()
ax_inset.errorbar(Nmons, gamma, xerr=gamma_err, color="k", ecolor="k")
axL.set_xlabel("Chain length", fontsize=8)
ax_inset.set_ylabel(r"$\gamma_{eff} (mN/m)$", fontsize=8)
Пример #4
0
LDCut = float(sys.argv[2])
if LDCut == 6.5: data_dir = os.path.join(setup.data_dir, 'GEOM_PROP', 'geom_prop_oldrc', 'polymer', 'c25_longtraj', 'hist')
else: data_dir = data_dir = os.path.join(setup.data_dir, 'GEOM_PROP', 'geom_prop_newrc', 'polymer', 'c25_longtraj', 'hist')

# Conversion factor
conv_factor = 0.001987 * 298.0

# offset each pmf such that average of last 10 bins is 0
def get_offset(pmf):
	pmf = pmf.flatten()
	pmf = pmf[np.logical_not(np.isinf(pmf))]
	pmf = np.sort(pmf)
	offset = np.mean(pmf[:10])
	return offset

fig = plt.figure(figsize = (setup.set_width('dbl'),5))
ax = []
for i in range(1,5): ax.append(fig.add_subplot(2,2,i))
cgtypes = ['AA', 'SP', 'SPLD', 'LD']

contour_clr = {'AA': 'w', 'SP': 'k', 'SPLD': 'k', 'LD': 'k'}
smoothing_level = {'wca': 0.55, 'lj' : 0.55}
if fftype == 'wca': levels = np.linspace(0.5 * conv_factor, 1.05*conv_factor, 2)
else: levels = np.linspace(0.5*conv_factor, 1.05*conv_factor, 2)

print 'Plotting...'
for i, cgtype in enumerate(cgtypes):
	pickleName = os.path.join(data_dir, 'pmf_Rg_R_EE_%s_%s.pickle' % (fftype, cgtype) )
	hist = pickle.load(open(pickleName, 'r'))
	Rg = hist[0][0]
	R_EE = hist[0][1]
Пример #5
0
	return R

def getPickleNames(Nmon = 25):
	SASApickle = os.path.join(data_dir_SASA, 'c%d' % Nmon, 'measure', 'SASA_atom_%s_SPLD.pickle' % fftype)
	Enepickle = os.path.join(data_dir_Ene, 'c%d_%s_SPLD_energy.pickle' % (Nmon, fftype))
	return SASApickle, Enepickle


# get data for c25
SASApickle, Enepickle = getPickleNames(Nmon = 25)
SASA = getSASA(SASApickle, Nmon = 25)
EnePairExcess, EneLD, EneSum = getEne(Enepickle)
Nmons = [10, 20, 25, 30, 40]

# SASA correlations for c25
fig = plt.figure(figsize = (setup.set_width('single'), 5))
axs = []
ax = fig.add_subplot(3,1,1) ; axs.append(ax) ; ax.plot(SASA, EnePairExcess, linestyle = 'None', marker = 'o', color = 'r', label = r'$U_{ex} = U_{SP} - U_{WCA}$')
ax = fig.add_subplot(3,1,2, sharex = axs[0]) ; axs.append(ax) ; ax.plot(SASA, EneLD, linestyle = 'None', marker = 'o', color = 'b',  label = r'$U_{LD}$')
ax = fig.add_subplot(3,1,3) ; axs.append(ax) ; ax.plot(SASA, EneSum, linestyle = 'None', marker = 'o', color = 'g', label = r'$U_{ex} + U_{LD}$')
for i, ax in enumerate(axs):
	setup.prune(ax, nbins = 6)
	ax.legend()
	if i == 0 or i == 1: ax.set_xticklabels('')
	if i == 2: ax.set_xlabel(r'$SASA\left( \mathrm{\AA}^2\right)$')
	if i == 1: ax.set_ylabel('Energy' + setup.energy)

plt.savefig('SASA_ene_corr_%s_%g.%s' % (fftype, LDCut, setup.params['savefig.format']))


# SASA correlations for different chain lengths
	r_AA, g_AA = getRDF(system, 'AA', fftype)
	r_SP, g_SP = getRDF(system, 'SP', fftype)
	r_SPLD, g_SPLD = getRDF(system, 'SPLD', fftype)
	if system == 'c25': r_LD, g_LD = getRDF(system, 'LD', fftype)
	ax.plot(r_AA, g_AA, 'ro-', label = 'AA', markersize = 6)
	ax.plot(r_SP, g_SP, 'b-', label = 'SP')
	ax.plot(r_SPLD, g_SPLD, 'g-', label = 'SPLD')
	if system == 'c25': ax.plot(r_LD, g_LD, 'k-', label = 'LD')
	if doLegend: ax.legend(loc = 'best')
	if doXLabel: ax.set_xlabel('r' + setup.Angstrom1)
	if doYLabel: ax.set_ylabel(r'$g(r)$')
	if not doXTickLabel: plt.setp(ax.get_xticklabels(), visible=False)


# REVIEWER QUES 1
fig = plt.figure(figsize = (setup.set_width('dbl'), 4.))	

ax1 = fig.add_subplot(2,2,1)
window = [3.0, 8.5, -0.15, 0.2]
plotPotential('c25', 'wca', ax1, window, doLegend = True, doXLabel = True, doYLabel = True, doXTickLabel = True)
ax1.annotate('c25 WCA', xy = (4.8, 0.03))

ax2 = fig.add_subplot(2,2,2)
window = [3.0, 18, -0.6, 0.6]
plotPotential('methane25', 'wca', ax2, window, doXLabel = True, doYLabel = True, doXTickLabel = True)
ax2.annotate('methane WCA', xy = (4.8, 0.2))

ax3 = fig.add_subplot(2,2,3)
plotRDF('c25', 'wca', ax3, doLegend = True, doXLabel = True, doYLabel = True, doXTickLabel = True)
ax3.annotate('c25 WCA', xy = (7.5, 200))