def get_data(data, edge): W,L = data[0], data[1] Dy = data[2] R = data[3] Wf = int_toAngst(W, edge, key = 'width', C_C = 1.42) Lf = int_toAngst(L, edge, key = 'length', C_C = 1.42) theta = Wf / (2 * R) # new journal of physics Bending and buckling -> theta ~ 0.013 (7-ac ribbon). print Lf/Wf, Wf, R, theta, L return [Wf, Lf, Dy, R, theta]
def get_data(data, edge): W, L = data[0], data[1] Dy = data[2] R = data[3] Wf = int_toAngst(W, edge, key='width', C_C=1.42) Lf = int_toAngst(L, edge, key='length', C_C=1.42) theta = Wf / ( 2 * R ) # new journal of physics Bending and buckling -> theta ~ 0.013 (7-ac ribbon). print Lf / Wf, Wf, R, theta, L return [Wf, Lf, Dy, R, theta]
def plot_fig3c(): plot_mus = True # False # edge = 'ac' T, wis = 10, [5, 7, 9, 11, 13] _, axs = get_axes(1, 1, .8) deva = .6 data = np.empty(len(wis), dtype='object') width_f = np.zeros(len(wis)) F = .006 # eV/angst fmax = F * 1. / (3 * np.sqrt(3) * bond**2 / 4) * .4 a = .3 colors = ['red', 'blue', 'green', 'black', 'cyan', 'yellow'] for i, wi in enumerate(wis): data[i] = get_stick_data('KC', T, '%s_stickTaito' % edge, wi) width_f[i] = int_toAngst(wi, edge, key='width', C_C=bond) print width_f def axplusb(x, a, b): return a * x + b def Mmax(Lt, width_f, f): def gfun(x): return 0 def hfun(x): return width_f / 2 def func(y, x): return np.sqrt(x**2 + y**2) return 2 * f * dblquad(func, 0, Lt, gfun, hfun)[0] #thetas = width_f/(2*360/mus*1./(2*np.pi)*10) def teor(theta, W0): #return 2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 return 2 * 2 * np.sqrt(3) / 9 * 1000 * bond**3 / W0 * k * ( 1 - 2 * tau / (k * W0))**2 * theta**3 plot2 = [] plot3 = [] fit_vals = [ [.0007, .46], [.0008, .4], [.00075, .64], [.00084, .705], [.00085, .868], ] fit_vals = [ [.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6], ] for j, wi in enumerate(wis): LbLt = data[j] LbLt.view('i8,i8').sort(order=['f0'], axis=0) Rs = LbLt[:, 0] / (np.pi / 3.) thetas = width_f[j] / (2 * Rs) mus = thetas * 2. / width_f[j] * 360 / (2 * np.pi) * 10 print thetas if wi == 5: m = 0 if wi == 7: m = 1 if wi == 9: m = 2 if wi == 11: m = 3 if wi == 13: m = 4 if plot_mus: #plt.plot(mus, LbLt[:,1], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #a,b = curve_fit(axplusb, mus, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] #plt.plot(mus, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #plt.plot(mus, a*mus + b, '--', color = colors[j], # alpha = .8) #plot2.append([width_f[j], -b/a]) #plt.plot(mus, LbLt[:,1]/width_f[j], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) R_exp = width_f[j] / (2 * thetas) add_L = np.sqrt(2 * R_exp * deva + deva**2) / 10. axs[0].scatter(LbLt[:, 1] / 10 + add_L, mus, color=colors[m]) axs[0].text(3 + 1.5 / 4 * m, 11 - 7. / 4 * m, r'w=%i' % wi, color=colors[m]) else: axs[0].plot(thetas, LbLt[:, 1], '-o', color=colors[m], alpha=.8) ''' a,b = curve_fit(axplusb, thetas, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) plt.plot(thetas, a*thetas + b, '--', color = colors[j], alpha = .8) plot2.append([width_f[j], -b/a]) ''' #plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8) print np.sqrt(width_f[j] / .01 * a + a**2) def gfunc(Lt, theta, f, a): L = np.sqrt(width_f[j] / theta * a + a**2) + Lt return (1. / 6. * theta * k * width_f[j]**2 - Mmax(L, width_f[j], f))**2 def Ltail(thetas, f, a): Lts = np.zeros(len(thetas)) print f, a for i, theta in enumerate(thetas): Lts[i] = fmin(gfunc, 1, args=([theta, f, a]), disp=0)[0] return Lts def Ltail2(theta, f, a): return fmin(gfunc, 1, args=([theta, f, a]), disp=0)[0]**2 Lmax = 55 Lts = np.linspace(0, Lmax, 15) thts = np.linspace(0.005, .045, len(Lts)) teor_Lt = np.zeros(len(Lts)) if False: fmax, a = curve_fit(Ltail, thetas, LbLt[:, 1], p0=[fmax, .2])[0] else: fmax, a = fit_vals[j] print fmax, a for i, Lt in enumerate(Lts): #teor_theta[k] = 6*Mmax(Lt)/(k*width_f**2) teor_Lt[i] = Ltail([thts[i]], fmax, a) + np.sqrt( width_f[j] / thts[i] * deva + deva**2) #fmin(gfunc, 1, args=([thts[i]]), disp = 0)[0] #print thts[i], teor_Lt[i], 6*Mmax(teor_Lt[i], width_f[j])/(k*width_f[j]**2) - thts[i] if plot_mus: degs = thts * 2 / width_f[j] * 3600 / (2 * np.pi) Lbend_teor = np.pi / 3 * width_f[j] / (2 * thts) #plt.plot(degs, teor_Lt/Lbend_teor, '--', color = colors[j], label = 'width = %i' %wi) #plt.plot(degs, teor_Lt/width_f[j], '--', color = colors[j], label = 'width = %i' %wi) R_teor = width_f[j] / (2 * thts) axs[0].plot(teor_Lt / 10, degs, '--', color=colors[m], label='width = %i' % wi) theta0 = fmin(Ltail2, .001, args=([fmax, a]), disp=0)[0] deg0 = theta0 * 2 / width_f[j] * 3600 / (2 * np.pi) plot3.append([width_f[j], deg0, theta0]) else: axs[0].plot(teor_Lt / 10, thts, '--', color=colors[m], label='width = %i' % wi) #plt.legend(loc = 2, frameon = False) if not plot_mus: axs[0].set_ylabel(r'$\Theta$') axs[0].set_xlabel(r'$L (nm)$') else: axs[0].set_ylabel(r'Curvature $\kappa$ (deg/nm)') axs[0].set_xlabel(r'$L$ (nm)') #axs[0].legend(loc = 2, frameon = False) #axs[0].set_title('Required tail length for pinning') axs[0].set_ylim([0, 13]) axs[0].set_xlim([1, 6]) axs[0].set_xticks(np.linspace(0, 7, 8)) a = plt.axes([.3, .675, .27, .23]) plot3 = np.array(plot3) plt.plot(plot3[:, 0], plot3[:, 1], '--', color='black', alpha=.5) for i in range(5): plt.scatter(plot3[i, 0], plot3[i, 1], color=colors[i]) plt.yticks(np.linspace(.6, 2.2, 5)) plt.xticks(np.linspace(4, 16, 4)) plt.xlabel(r'Width (\AA)') plt.ylabel(r'$\kappa$ (deg/nm)') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:, 0], plot3[:, 1], '-o') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:, 0], plot3[:, 2], '-o') plt.show() plot2 = np.array(plot2) plt.plot(plot2[:, 0], plot2[:, 1], '-o') plt.show()
def plot_fig2(): Wis = [5, 7, 9, 11, 13] #,9,11,13] datas = get_log_data('LJ', T, '%s_twistTaito' % edge, Wis) wili_used = [] colors = ['red', 'blue', 'green', 'black', 'cyan', 'yellow'] W0s = [] offset = .4 thresz = 5 coll_data_ac = np.zeros((len(datas), 7)) vmax = -1 fig, axs = get_axes(1, 3, 1.5) def shear_eDens(W0, theta): return 1. / 6 * k * theta**2 * (1. - 2 * tau / (k * W0))**2 #- 2*tau**2/(k*W0)*L0 for i, data in enumerate(datas): Wi, Li, W, L = data[:4] energy_table = data[6] natoms = data[4] v = data[5] phi = energy_table[:, 3] z = energy_table[:, 4] epot = (energy_table[:, 5] - energy_table[-1, 5]) * 1000 cutn = int(len(epot) / 2) if Wi == 5: m = 0 if Wi == 7: m = 1 if Wi == 9: m = 2 if Wi == 11: m = 3 if Wi == 13: m = 4 epot = epot[cutn:] if edge == 'ac': W0 = (Wi - 1) * np.sqrt(3) / 2 * bond L0 = Li * 3. * bond - 1. * bond Area = W0 * L0 else: raise #print W0 thetash = W / (2 * (L / phi)) thetas = thetash[cutn:] heights = energy_table[:, 4] inds = np.where(thresz < heights)[0] indv = max(inds) indb = min(inds) W = int_toAngst(Wi, 'ac', key='width', C_C=bond) mus = thetash * 2. / W * 360 / (2 * np.pi) * 10 coll_data_ac[i] = [ W, v, thetash[indv], thetash[indb], mus[indv], mus[indb], Wi ] if v > vmax: vmax = v if [Wi, Li] not in wili_used: wili_used.append([Wi, Li]) epot_tDens = shear_eDens(W0, thetas) * 1000 axs[0].plot(thetas, epot_tDens + m * offset, '-', color=colors[m], alpha=1) #, label = 'Epot teor') W0s.append(W0) axs[0].text(.01 - (m + 1) * .0017, (m + 1) * offset * .85 + offset / 10, r'N=%i' % Wi, color=colors[m]) axs[1].text(.08 - float(m) / 4 * .04, float(m) / 4 * 6. + 9, r'N=%i' % Wi, color=colors[m]) axs[0].plot(thetas, epot / Area + m * offset, color=colors[m], alpha=.05) #, label = 'Epot') axs[1].plot(thetash, heights, color=colors[m], alpha=.15) #, label = 'Epot') axs[0].set_xlim([0, .03]) axs[0].set_ylim([-.2, 3.5]) axs[0].set_xlabel(r'$\Theta$') axs[0].set_ylabel(r'Energy density (m$eV/$\AA$^2$)') axs[1].set_ylim([2, 17]) axs[1].set_xlabel(r'$\Theta$') axs[1].set_ylabel(r'Max Height (\AA)') axs[0].legend(loc=2) # KINK magic_par = 0.0228171 class alpha(): def __init__(self): pass def set_s(self, s): self.s = s def set_t(self, t): self.t = t def set_pot(self, pot): self.pot = pot def set_params(self, s, t, pot): self.set_s(s) self.set_t(t) self.set_pot(pot) def get_alpha(self, w): return magic_par / (self.s / w**self.pot + self.t) alpha = alpha() def theta_teorFitPar(W, *args): if len(args) == 1: s = args[:1] alpha.set_s(s) if len(args) == 2: s, t = args[:2] alpha.set_s(s) alpha.set_t(t) if len(args) == 3: s, t, pot = args[:3] alpha.set_s(s) alpha.set_t(t) alpha.set_pot(pot) return magic_par / alpha.get_alpha(W) ac_curvature = np.zeros(5) amount = np.zeros(5) for i in range(len(coll_data_ac)): Wi = coll_data_ac[i, -1] if Wi == 5: m = 0 ac_curvature[0] += coll_data_ac[i, 4] amount[0] += 1 if Wi == 7: m = 1 ac_curvature[1] += coll_data_ac[i, 4] amount[1] += 1 if Wi == 9: m = 2 ac_curvature[2] += coll_data_ac[i, 4] amount[2] += 1 if Wi == 11: m = 3 ac_curvature[3] += coll_data_ac[i, 4] amount[3] += 1 if Wi == 13: m = 4 ac_curvature[4] += coll_data_ac[i, 4] amount[4] += 1 axs[2].scatter(coll_data_ac[i, 0], coll_data_ac[i, 4], alpha=coll_data_ac[i, 1] / vmax, color=colors[m]) axs[2].scatter(coll_data_ac[i, 0], coll_data_ac[i, 5], alpha=coll_data_ac[i, 1] / vmax, marker='D', color=colors[m]) for i in range(5): print 'average curvature %i-ac = %.4f deg/nm' % ( Wis[i], ac_curvature[i] / amount[i]) alpha.set_pot(1) alpha.set_t(magic_par) sopm1_ac = curve_fit(theta_teorFitPar, coll_data_ac[:, 0], coll_data_ac[:, 2], p0=[1.])[0][:1] plot_widths = np.linspace( np.min(coll_data_ac[:, 0]) - .5, np.max(coll_data_ac[:, 0]) + 2, 50) axs[2].plot(plot_widths, 2 / plot_widths * 3600 / (2 * np.pi) * theta_teorFitPar(plot_widths, sopm1_ac, magic_par, 1.), '--', label=r'$\Theta \approx \frac{%.2f}{w} + %.3f$' % (sopm1_ac, magic_par), color='black') #axs[2].legend(loc = 1, frameon = False) axs[2].set_ylabel(r'Curvature $\kappa$ (deg/nm)') axs[2].set_xlabel(r'Width (\AA)') #xticks = (np.array(Wis) - 1)*np.sqrt(3)/2*1.4 #xticklabels = Wis #axs[2].set_xticks(xticks) #axs[2].set_xticklabels(xticklabels) plt.show()
def plot_fig3c(): plot_mus = True # False # edge = 'ac' T, wis = 10, [5, 7, 9, 11, 13] _, axs = get_axes(1,1, .8) deva = .6 data = np.empty(len(wis), dtype = 'object') width_f = np.zeros(len(wis)) F = .006 # eV/angst fmax = F*1./(3*np.sqrt(3)*bond**2/4)*.4 a = .3 colors = ['red', 'blue', 'green', 'black', 'cyan', 'yellow'] for i, wi in enumerate(wis): data[i] = get_stick_data('KC', T, '%s_stickTaito' %edge, wi) width_f[i] = int_toAngst(wi, edge, key='width', C_C = bond) print width_f def axplusb(x, a, b): return a*x + b def Mmax(Lt, width_f, f): def gfun(x): return 0 def hfun(x): return width_f/2 def func(y,x): return np.sqrt(x**2 + y**2) return 2*f*dblquad(func, 0, Lt, gfun, hfun)[0] #thetas = width_f/(2*360/mus*1./(2*np.pi)*10) def teor(theta, W0): #return 2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 return 2*2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 plot2 = [] plot3 = [] fit_vals = [[.0007, .46], [.0008, .4], [.00075, .64], [.00084, .705], [.00085, .868],] fit_vals = [[.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6],] for j, wi in enumerate(wis): LbLt = data[j] LbLt.view('i8,i8').sort(order=['f0'], axis=0) Rs = LbLt[:,0]/(np.pi/3.) thetas = width_f[j]/(2*Rs) mus = thetas*2./width_f[j]*360/(2*np.pi)*10 print thetas if wi == 5: m = 0 if wi == 7: m = 1 if wi == 9: m = 2 if wi == 11: m = 3 if wi == 13: m = 4 if plot_mus: #plt.plot(mus, LbLt[:,1], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #a,b = curve_fit(axplusb, mus, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] #plt.plot(mus, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #plt.plot(mus, a*mus + b, '--', color = colors[j], # alpha = .8) #plot2.append([width_f[j], -b/a]) #plt.plot(mus, LbLt[:,1]/width_f[j], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) R_exp = width_f[j]/(2*thetas) add_L = np.sqrt(2*R_exp*deva + deva**2)/10. axs[0].scatter(LbLt[:,1]/10 + add_L, mus, color = colors[m]) axs[0].text(3 + 1.5/4*m, 11 - 7./4*m, r'w=%i' %wi, color = colors[m]) else: axs[0].plot(thetas, LbLt[:,1], '-o', color = colors[m], alpha = .8) ''' a,b = curve_fit(axplusb, thetas, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) plt.plot(thetas, a*thetas + b, '--', color = colors[j], alpha = .8) plot2.append([width_f[j], -b/a]) ''' #plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8) print np.sqrt(width_f[j]/.01*a + a**2) def gfunc(Lt, theta, f, a): L = np.sqrt(width_f[j]/theta*a + a**2) + Lt return (1./6.*theta*k*width_f[j]**2 - Mmax(L, width_f[j], f))**2 def Ltail(thetas, f, a): Lts = np.zeros(len(thetas)) print f, a for i, theta in enumerate(thetas): Lts[i] = fmin(gfunc, 1, args=([theta, f, a]), disp = 0)[0] return Lts def Ltail2(theta, f, a): return fmin(gfunc, 1, args=([theta, f, a]), disp = 0)[0]**2 Lmax = 55 Lts = np.linspace(0, Lmax, 15) thts = np.linspace(0.005, .045, len(Lts)) teor_Lt = np.zeros(len(Lts)) if False: fmax, a = curve_fit(Ltail, thetas, LbLt[:,1], p0 = [fmax, .2])[0] else: fmax, a = fit_vals[j] print fmax, a for i, Lt in enumerate(Lts): #teor_theta[k] = 6*Mmax(Lt)/(k*width_f**2) teor_Lt[i] = Ltail([thts[i]], fmax ,a) + np.sqrt(width_f[j]/thts[i]*deva + deva**2) #fmin(gfunc, 1, args=([thts[i]]), disp = 0)[0] #print thts[i], teor_Lt[i], 6*Mmax(teor_Lt[i], width_f[j])/(k*width_f[j]**2) - thts[i] if plot_mus: degs = thts*2/width_f[j]*3600/(2*np.pi) Lbend_teor = np.pi/3*width_f[j]/(2*thts) #plt.plot(degs, teor_Lt/Lbend_teor, '--', color = colors[j], label = 'width = %i' %wi) #plt.plot(degs, teor_Lt/width_f[j], '--', color = colors[j], label = 'width = %i' %wi) R_teor = width_f[j]/(2*thts) axs[0].plot(teor_Lt/10, degs, '--', color = colors[m], label = 'width = %i' %wi) theta0 = fmin(Ltail2, .001, args=([fmax, a]), disp = 0)[0] deg0 = theta0*2/width_f[j]*3600/(2*np.pi) plot3.append([width_f[j], deg0, theta0]) else: axs[0].plot(teor_Lt/10, thts, '--', color = colors[m], label = 'width = %i' %wi) #plt.legend(loc = 2, frameon = False) if not plot_mus: axs[0].set_ylabel(r'$\Theta$') axs[0].set_xlabel(r'$L (nm)$') else: axs[0].set_ylabel(r'Curvature $\kappa$ (deg/nm)') axs[0].set_xlabel(r'$L$ (nm)') #axs[0].legend(loc = 2, frameon = False) #axs[0].set_title('Required tail length for pinning') axs[0].set_ylim([0,13]) axs[0].set_xlim([1,6]) axs[0].set_xticks(np.linspace(0, 7, 8)) a = plt.axes([.3, .675, .27, .23]) plot3 = np.array(plot3) plt.plot(plot3[:,0], plot3[:,1], '--', color = 'black', alpha = .5) for i in range(5): plt.scatter(plot3[i,0], plot3[i,1], color = colors[i]) plt.yticks(np.linspace(.6, 2.2, 5)) plt.xticks(np.linspace(4, 16, 4)) plt.xlabel(r'Width (\AA)') plt.ylabel(r'$\kappa$ (deg/nm)') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:,0], plot3[:,1], '-o') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:,0], plot3[:,2], '-o') plt.show() plot2 = np.array(plot2) plt.plot(plot2[:,0], plot2[:,1], '-o') plt.show()
def plot_fig2(): Wis = [5,7,9,11,13] #,9,11,13] datas = get_log_data('LJ', T, '%s_twistTaito' %edge, Wis) wili_used = [] colors = ['red', 'blue', 'green', 'black', 'cyan', 'yellow'] W0s = [] offset = .4 thresz = 5 coll_data_ac= np.zeros((len(datas), 7)) vmax = -1 fig, axs = get_axes(1,3, 1.5) def shear_eDens(W0, theta): return 1./6*k*theta**2*(1. - 2*tau/(k*W0))**2 #- 2*tau**2/(k*W0)*L0 for i, data in enumerate(datas): Wi, Li, W, L= data[:4] energy_table= data[6] natoms = data[4] v = data[5] phi = energy_table[:,3] z = energy_table[:,4] epot = (energy_table[:,5] - energy_table[-1,5])*1000 cutn = int(len(epot)/2) if Wi == 5: m = 0 if Wi == 7: m = 1 if Wi == 9: m = 2 if Wi == 11: m = 3 if Wi == 13: m = 4 epot = epot[cutn:] if edge == 'ac': W0 = (Wi - 1)*np.sqrt(3)/2*bond L0 = Li*3.*bond - 1.*bond Area = W0 * L0 else: raise #print W0 thetash = W/(2*(L/phi)) thetas = thetash[cutn:] heights = energy_table[:,4] inds = np.where(thresz < heights)[0] indv = max(inds) indb = min(inds) W = int_toAngst(Wi, 'ac', key='width', C_C = bond) mus = thetash*2./W*360/(2*np.pi)*10 coll_data_ac[i] = [W, v, thetash[indv], thetash[indb], mus[indv], mus[indb], Wi] if v > vmax: vmax = v if [Wi, Li] not in wili_used: wili_used.append([Wi, Li]) epot_tDens = shear_eDens(W0, thetas)*1000 axs[0].plot(thetas, epot_tDens + m*offset, '-', color = colors[m], alpha = 1) #, label = 'Epot teor') W0s.append(W0) axs[0].text(.01 - (m+1)*.0017, (m+1)*offset*.85 + offset/10, r'N=%i' %Wi, color = colors[m]) axs[1].text(.08 - float(m)/4*.04, float(m)/4*6. + 9, r'N=%i' %Wi, color = colors[m]) axs[0].plot(thetas, epot/Area + m*offset, color = colors[m], alpha = .05) #, label = 'Epot') axs[1].plot(thetash, heights, color = colors[m], alpha = .15) #, label = 'Epot') axs[0].set_xlim([0, .03]) axs[0].set_ylim([-.2, 3.5]) axs[0].set_xlabel(r'$\Theta$') axs[0].set_ylabel(r'Energy density (m$eV/$\AA$^2$)') axs[1].set_ylim([2, 17]) axs[1].set_xlabel(r'$\Theta$') axs[1].set_ylabel(r'Max Height (\AA)') axs[0].legend(loc = 2) # KINK magic_par = 0.0228171 class alpha(): def __init__(self): pass def set_s(self, s): self.s = s def set_t(self, t): self.t = t def set_pot(self, pot): self.pot= pot def set_params(self, s,t, pot): self.set_s(s) self.set_t(t) self.set_pot(pot) def get_alpha(self, w): return magic_par/(self.s/w**self.pot + self.t) alpha = alpha() def theta_teorFitPar(W, *args): if len(args) == 1: s = args[:1] alpha.set_s(s) if len(args) == 2: s,t = args[:2] alpha.set_s(s) alpha.set_t(t) if len(args) == 3: s,t,pot = args[:3] alpha.set_s(s) alpha.set_t(t) alpha.set_pot(pot) return magic_par/alpha.get_alpha(W) ac_curvature = np.zeros(5) amount = np.zeros(5) for i in range(len(coll_data_ac)): Wi = coll_data_ac[i, -1] if Wi == 5: m = 0 ac_curvature[0] += coll_data_ac[i,4] amount[0] += 1 if Wi == 7: m = 1 ac_curvature[1] += coll_data_ac[i,4] amount[1] += 1 if Wi == 9: m = 2 ac_curvature[2] += coll_data_ac[i,4] amount[2] += 1 if Wi == 11: m = 3 ac_curvature[3] += coll_data_ac[i,4] amount[3] += 1 if Wi == 13: m = 4 ac_curvature[4] += coll_data_ac[i,4] amount[4] += 1 axs[2].scatter(coll_data_ac[i,0], coll_data_ac[i,4], alpha = coll_data_ac[i,1]/vmax, color = colors[m]) axs[2].scatter(coll_data_ac[i,0], coll_data_ac[i,5], alpha = coll_data_ac[i,1]/vmax, marker = 'D', color = colors[m]) for i in range(5): print 'average curvature %i-ac = %.4f deg/nm' %(Wis[i], ac_curvature[i]/amount[i]) alpha.set_pot(1) alpha.set_t(magic_par) sopm1_ac = curve_fit(theta_teorFitPar, coll_data_ac[:,0], coll_data_ac[:,2], p0 = [1.])[0][:1] plot_widths = np.linspace(np.min(coll_data_ac[:,0]) - .5, np.max(coll_data_ac[:,0]) + 2, 50) axs[2].plot(plot_widths, 2/plot_widths*3600/(2*np.pi)*theta_teorFitPar(plot_widths, sopm1_ac, magic_par, 1.), '--', label = r'$\Theta \approx \frac{%.2f}{w} + %.3f$' %(sopm1_ac, magic_par), color = 'black') #axs[2].legend(loc = 1, frameon = False) axs[2].set_ylabel(r'Curvature $\kappa$ (deg/nm)') axs[2].set_xlabel(r'Width (\AA)') #xticks = (np.array(Wis) - 1)*np.sqrt(3)/2*1.4 #xticklabels = Wis #axs[2].set_xticks(xticks) #axs[2].set_xticklabels(xticklabels) plt.show()
def plot_kinkOfBend_deg(edge): plot_mus = True #False # magic_par = 0.0228171 #0.0203724 datas_ac = get_log_data('LJ', T, '%s_twistTaito' %'ac') datas_zz = get_log_data('LJ', T, '%s_twistTaito' %'zz') coll_data_ac= np.zeros((len(datas_ac), 6)) coll_data_zz= np.zeros((len(datas_zz), 6)) thresz = 5 vmax = -1. eps = 0.002843732471143 #[eV] kappa = .95 #[eV] n = 1/(3*np.sqrt(3)*bond**2/4) pot = 1 def theta_teor(W): Y = 11.43/W + 19.88 return 24./Y*np.sqrt(eps*kappa*np.pi)*n class alpha(): def __init__(self): pass def set_s(self, s): self.s = s def set_t(self, t): self.t = t def set_pot(self, pot): self.pot= pot def set_params(self, s,t, pot): self.set_s(s) self.set_t(t) self.set_pot(pot) def get_alpha(self, w): #Y = 11.43/W + 19.88 #A, B = 48.7, .0055 #Length = 12.8 #B = 4/(Y*np.pi**2)*(A/Length**2 + B*Length**2) return magic_par/(self.s/w**self.pot + self.t) #return self.s/w**self.pot + self.t alpha = alpha() def theta_teorFitPar(W, *args): if len(args) == 1: s = args[:1] alpha.set_s(s) if len(args) == 2: s,t = args[:2] alpha.set_s(s) alpha.set_t(t) if len(args) == 3: s,t,pot = args[:3] alpha.set_s(s) alpha.set_t(t) alpha.set_pot(pot) #Y = 11.43/W + 19.88 #A, B = 48.7, .0055 #Length = 12.8 #print np.average(4/(Y*np.pi**2)*(A/Length**2 + B*Length**2)) return magic_par/alpha.get_alpha(W) #return 4/(Y*np.pi**2*alpha.get_alpha(W))*(A/Length**2 + B*Length**2) def overR(W, a1, a2): return a1/W + a2 def overRandconst(W, a1, a2): return a1/(W + a2) def overR2(W, a1, a2): return a1/W**2 + a2 for i, data in enumerate(datas_ac): energy_table = data[6] v = data[5] natoms = data[4] Wi, Li, W, L = data[:4] phi = energy_table[:,3] epot = (energy_table[:,5] - energy_table[-1,5])/natoms heights = energy_table[:,4] inds = np.where(thresz < heights)[0] indv = max(inds) indb = min(inds) W = int_toAngst(Wi, 'ac', key='width', C_C = bond) thetas = W/(2*(L/phi)) mus = thetas*2./W*360/(2*np.pi)*10 coll_data_ac[i] = [W, v, thetas[indv], thetas[indb], mus[indv], mus[indb]] if v > vmax: vmax = v for i, data in enumerate(datas_zz): energy_table = data[6] v = data[5] natoms = data[4] Wi, Li, W, L = data[:4] phi = energy_table[:,3] epot = (energy_table[:,5] - energy_table[-1,5])/natoms heights = energy_table[:,4] inds = np.where(thresz < heights)[0] indv = max(inds) indb = min(inds) W = int_toAngst(Wi, 'zz', key='width', C_C = bond) thetas = W/(2*(L/phi)) mus = thetas*2./W*360/(2*np.pi)*10 coll_data_zz[i] = [W, v, thetas[indv], thetas[indb], mus[indv], mus[indb]] if v > vmax: vmax = v if plot_mus: for i in range(len(coll_data_ac)): plt.scatter(coll_data_ac[i,0], coll_data_ac[i,4], alpha = coll_data_ac[i,1]/vmax, color = 'red') plt.scatter(coll_data_ac[i,0], coll_data_ac[i,5], alpha = coll_data_ac[i,1]/vmax, color = 'blue') #for i in range(len(coll_data_zz)): # plt.scatter(coll_data_zz[i,0], coll_data_zz[i,4], # alpha = coll_data_zz[i,1]/vmax, color = 'red') # plt.scatter(coll_data_zz[i,0], coll_data_zz[i,5], # alpha = coll_data_zz[i,1]/vmax, color = 'blue') alpha.set_pot(1) alpha.set_t(magic_par) sopm1_ac = curve_fit(theta_teorFitPar, coll_data_ac[:,0], coll_data_ac[:,2], p0 = [1.])[0][:1] plot_widths = np.linspace(np.min(coll_data_ac[:,0]) - .5, np.max(coll_data_ac[:,0]) + 2, 50) plt.plot(plot_widths, 2/plot_widths*3600/(2*np.pi)*theta_teorFitPar(plot_widths, sopm1_ac, magic_par, 1.), '--', label = r'$\Theta \approx \frac{%.2f}{w} + %.3f$' %(sopm1_ac, magic_par), color = 'green') plt.legend(loc = 2, frameon = False) plt.ylabel(r'$^{\circ}/$\AA') plt.xlabel(r'Width \AA') #plt.twinx() # #alpha.set_params(sopm1_ac, magic_par, 1) #plt.plot(plot_widths, alpha.get_alpha(plot_widths), # label = r'$\alpha = \frac{%.3f}{%.2f/w + %.3f} \rightarrow %.3f$' # %(magic_par, sopm1_ac, magic_par, 1), # color = 'green') #plt.legend(loc = 1, frameon = False) #plt.ylabel(r'$\alpha$') plt.show() else: for i in range(len(coll_data_ac)): plt.scatter(coll_data_ac[i,0], coll_data_ac[i,2], alpha = coll_data_ac[i,1]/vmax, color = 'red') plt.scatter(coll_data_ac[i,0], coll_data_ac[i,3], alpha = coll_data_ac[i,1]/vmax, color = 'blue') #pot = 1.5 #alpha.set_pot(pot) #sopm15, topm15 = curve_fit(theta_teorFitPar, coll_data[:,0], coll_data[:,2], p0 = [1., 1])[0][:2] pot = 2. alpha.set_pot(pot) sopm2, topm2 = curve_fit(theta_teorFitPar, coll_data_ac[:,0], coll_data_ac[:,2], p0 = [1., 1])[0][:2] alpha.set_pot(1) alpha.set_t(magic_par) sopm1 = curve_fit(theta_teorFitPar, coll_data_ac[:,0], coll_data_ac[:,2], p0 = [1.])[0][:1] sopm3, topm3, potopm = curve_fit(theta_teorFitPar, coll_data_ac[:,0], coll_data_ac[:,2], p0 = [1., 1, 1])[0][:3] #plt.plot(coll_data[:,0], np.ones(len(coll_data[:,0]))*.04, '-.', color = 'black') #plt.text(np.min(coll_data[:,0]), .041, 'teor') #plt.scatter(coll_data[:,0], theta_teor(coll_data[:,0])) #plt.text(np.min(coll_data[:,0]), .041, 'teor') plot_widths = np.linspace(np.min(coll_data_ac[:,0]) - .5, np.max(coll_data_ac[:,0]) + 2, 50) #plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm15, topm15, 1.5), '--', # label = 'alpha = %.2f/w**%.1f + %.3f' %(sopm15, 1.5, topm15)) ''' plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm2, topm2, 2.), '--', label = r'$\Theta \approx \frac{%.2f}{w^2} + %.3f$' %(sopm2, topm2), color = 'red') ''' plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm1, magic_par, 1.), '--', label = r'$\Theta \approx \frac{%.2f}{w} + %.3f$' %(sopm1, magic_par), color = 'green') #plt.plot(plot_widths, overR2(plot_widths, sopm2a, topm2a), # label = r'$\Theta \approx \frac{1}{%.2fw^2} + %.3f$' %(sopm2a, topm2a), ) ''' plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm3, topm3, potopm), '.-', label = r'$\Theta \approx \frac{%.2f}{w^{%.2f}} + %.3f$' %(sopm3, potopm, topm3), color = 'red') ''' plt.scatter(8.46, .026, marker = 'D', color = 'black') plt.text(np.min(coll_data_ac[:,0]), .028, r'Experim. $\Theta \approx 0.026 = 4deg/nm$') plt.legend(frameon = False, loc = 2) plt.xlabel('width Angst') plt.ylabel(r'$\Theta$') plt.twinx() #alpha.set_params(sopm15, topm15, 1.5) #plt.plot(plot_widths, alpha.get_alpha(plot_widths), # label = 'alpha -> %.3f' %alpha.get_alpha(10000)) ''' alpha.set_params(sopm2, topm2, 2) plt.plot(plot_widths, alpha.get_alpha(plot_widths), label = r'$\alpha = \frac{%.3f}{%.2f/w^2 + %.3f} \rightarrow %.3f$' %(magic_par, sopm2, topm2, magic_par/topm2), color = 'red') ''' alpha.set_params(sopm1, magic_par, 1) plt.plot(plot_widths, alpha.get_alpha(plot_widths), label = r'$\alpha = \frac{%.3f}{%.2f/w + %.3f} \rightarrow %.3f$' %(magic_par, sopm1, magic_par, 1), color = 'green') ''' print sopm1/magic_par, sopm1, magic_par plt.plot(plot_widths, plot_widths/(sopm1/magic_par + plot_widths), '-o', color = 'green') alpha.set_params(sopm3, topm3, potopm) plt.plot(plot_widths, alpha.get_alpha(plot_widths), '.-', label = r'$\alpha = \frac{%.3f}{%.2f/w^{%.2f} + %.3f} \rightarrow %.3f$' %(magic_par, sopm3, potopm, topm3, magic_par/topm3), color = 'red') ''' plt.ylabel(r'$\alpha$') plt.legend(frameon = False) plt.show()
def plot_stick2(edge): plot_mus = True # False # #edge = 'ac' T, wis = 10, [5, 7, 9, 11, 13] data = np.empty(len(wis), dtype = 'object') width_f = np.zeros(len(wis)) F = .006 # eV/angst fmax = F*1./(3*np.sqrt(3)*bond**2/4)*.4 a = .3 colors = ['blue', 'red', 'black', 'green', 'yellow'] #print fmax for i, wi in enumerate(wis): data[i] = get_stick_data('KC', T, '%s_stickTaito' %edge, wi) width_f[i] = int_toAngst(wi, edge, key='width', C_C = bond) print width_f def axplusb(x, a, b): return a*x + b def Mmax(Lt, width_f, f): def gfun(x): return 0 def hfun(x): return width_f/2 def func(y,x): return np.sqrt(x**2 + y**2) return 2*f*dblquad(func, 0, Lt, gfun, hfun)[0] #thetas = width_f/(2*360/mus*1./(2*np.pi)*10) def teor(theta, W0): #return 2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 return 2*2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 plot2 = [] plot3 = [] fit_vals = [[.0007, .46], [.0008, .4], [.00075, .64], [.00084, .705], [.00085, .868],] fit_vals = [[.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6],] for j, wi in enumerate(wis): LbLt = data[j] LbLt.view('i8,i8').sort(order=['f0'], axis=0) Rs = LbLt[:,0]/(np.pi/3.) thetas = width_f[j]/(2*Rs) mus = thetas*2./width_f[j]*360/(2*np.pi)*10 print thetas ''' if plot_mus: for i in range(len(mus)): if LbLt[i,1] < 3: print 'hoos' plt.scatter(mus[i], LbLt[i,1]/LbLt[i,0], marker = 'D',color = 'red') else: plt.scatter(mus[i], LbLt[i,1]/LbLt[i,0], color = 'blue') plt.scatter(mus, teor(thetas, width_f), marker = 'v', label = 'teor') plt.plot([2,2], [0, .4], '--', color = 'black') plt.plot([4,4], [0, .4], '--', color = 'black') plt.text(1.03, .4, 'experimetl stick below 2deg/angst') plt.text(1.03, -.05, 'red squares only one unit cell \n enought to hold bend') plt.text(3.7, .4, 'buckling') plt.title('Reguired tail length for bend to stick ac, w=7') plt.legend(loc = 2, frameon = False) plt.xlabel('Deg/angst') plt.ylabel('Ltail/Lbend') plt.show() else: ''' if plot_mus: #plt.plot(mus, LbLt[:,1], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #a,b = curve_fit(axplusb, mus, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] #plt.plot(mus, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #plt.plot(mus, a*mus + b, '--', color = colors[j], # alpha = .8) #plot2.append([width_f[j], -b/a]) #plt.plot(mus, LbLt[:,1]/width_f[j], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) R_exp = width_f[j]/(2*thetas) plt.plot(mus, LbLt[:,1]/R_exp, '-o', color = colors[j], alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) else: plt.plot(thetas, LbLt[:,1], '-o', color = colors[j], alpha = .8) ''' a,b = curve_fit(axplusb, thetas, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) plt.plot(thetas, a*thetas + b, '--', color = colors[j], alpha = .8) plot2.append([width_f[j], -b/a]) ''' #plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8) print np.sqrt(width_f[j]/.01*a + a**2) def gfunc(Lt, theta, f, a): L = np.sqrt(width_f[j]/theta*a + a**2) + Lt return (1./6.*theta*k*width_f[j]**2 - Mmax(L, width_f[j], f))**2 def Ltail(thetas, f, a): Lts = np.zeros(len(thetas)) print f, a for i, theta in enumerate(thetas): Lts[i] = fmin(gfunc, 1, args=([theta, f, a]), disp = 0)[0] return Lts def Ltail2(theta, f, a): return fmin(gfunc, 1, args=([theta, f, a]), disp = 0)[0]**2 Lmax = 35 Lts = np.linspace(0, Lmax, 15) thts = np.linspace(0.005, .04, len(Lts)) teor_Lt = np.zeros(len(Lts)) if False: fmax, a = curve_fit(Ltail, thetas, LbLt[:,1], p0 = [fmax, .2])[0] else: fmax, a = fit_vals[j] print fmax, a for i, Lt in enumerate(Lts): #teor_theta[k] = 6*Mmax(Lt)/(k*width_f**2) teor_Lt[i] = Ltail([thts[i]], fmax ,a) #fmin(gfunc, 1, args=([thts[i]]), disp = 0)[0] #print thts[i], teor_Lt[i], 6*Mmax(teor_Lt[i], width_f[j])/(k*width_f[j]**2) - thts[i] if plot_mus: degs = thts*2/width_f[j]*3600/(2*np.pi) Lbend_teor = np.pi/3*width_f[j]/(2*thts) #plt.plot(degs, teor_Lt/Lbend_teor, '--', color = colors[j], label = 'width = %i' %wi) #plt.plot(degs, teor_Lt/width_f[j], '--', color = colors[j], label = 'width = %i' %wi) R_teor = width_f[j]/(2*thts) plt.plot(degs, teor_Lt/R_teor, '--', color = colors[j], label = 'width = %i' %wi) theta0 = fmin(Ltail2, .001, args=([fmax, a]), disp = 0)[0] deg0 = theta0*2/width_f[j]*3600/(2*np.pi) plot3.append([width_f[j], deg0, theta0]) else: plt.plot(thts, teor_Lt, '--', color = colors[j], label = 'width = %i' %wi) #plt.legend(loc = 2, frameon = False) if not plot_mus: plt.xlabel('Theta') plt.ylabel('Ltail Angst') else: plt.xlabel('Curve deg/Angst') plt.ylabel('Ltail Angst') plt.legend(loc = 2, frameon = False) plt.title('Required tail length for pinning') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:,0], plot3[:,1], '-o') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:,0], plot3[:,2], '-o') plt.show() plot2 = np.array(plot2) plt.plot(plot2[:,0], plot2[:,1], '-o') plt.show()
def plot_stick(): #width_f = 7.5 #print 4./360*2*np.pi*width_f/10/2. #exit() plot_mus = False edge = 'ac' T, wi = 10, 11 LbLt = get_stick_data('KC', T, '%s_stickTaito' %edge, wi) LbLt.view('i8,i8').sort(order=['f0'], axis=0) width_f = int_toAngst(wi, edge, key='width', C_C = bond) Rs = LbLt[:,0]/(np.pi/3.) thetas = width_f/(2*Rs) mus = thetas*2./width_f*360/(2*np.pi)*10 #thetas = width_f/(2*360/mus*1./(2*np.pi)*10) def teor(theta, W0): #return 2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 return 2*2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 if plot_mus: for i in range(len(mus)): if LbLt[i,1] < 3: print 'hoos' plt.scatter(mus[i], LbLt[i,1]/LbLt[i,0], marker = 'D',color = 'red') else: plt.scatter(mus[i], LbLt[i,1]/LbLt[i,0], color = 'blue') plt.scatter(mus, teor(thetas, width_f), marker = 'v', label = 'teor') plt.plot([2,2], [0, .4], '--', color = 'black') plt.plot([4,4], [0, .4], '--', color = 'black') plt.text(1.03, .4, 'experimetl stick below 2deg/angst') plt.text(1.03, -.05, 'red squares only one unit cell \n enought to hold bend') plt.text(3.7, .4, 'buckling') plt.title('Reguired tail length for bend to stick ac, w=7') plt.legend(loc = 2, frameon = False) plt.xlabel('Deg/angst') plt.ylabel('Ltail/Lbend') plt.show() else: for i in range(len(mus)): if LbLt[i,1] < 3: print 'hoos' plt.scatter(thetas[i], LbLt[i,1]/LbLt[i,0], marker = 'D',color = 'red') #plt.scatter(thetas[i], LbLt[i,1], marker = 'D',color = 'red') else: plt.scatter(thetas[i], LbLt[i,1]/LbLt[i,0], color = 'blue') #plt.scatter(thetas[i], LbLt[i,1], color = 'blue') print LbLt[i,1]/(np.pi/3)*2*thetas[i]/width_f, LbLt[i,1], 1/(np.pi/3)*2*thetas[i]/width_f, LbLt[i,0] #plt.scatter(thetas, teor(thetas, width_f), marker = 'v', label = 'teor') #plt.scatter(thetas, teor(thetas, width_f)*LbLt[:,0], marker = 'v', label = 'teor') plt.twinx() plt.scatter(thetas, LbLt[:,0]) plt.scatter(thetas, LbLt[:,1]) plt.legend(loc = 2, frameon = False) plt.xlabel('Theta') plt.ylabel('Ltail Angst') plt.show()
def plot_stick2(edge): plot_mus = True # False # #edge = 'ac' T, wis = 10, [5, 7, 9, 11, 13] data = np.empty(len(wis), dtype='object') width_f = np.zeros(len(wis)) F = .006 # eV/angst fmax = F * 1. / (3 * np.sqrt(3) * bond**2 / 4) * .4 a = .3 colors = ['blue', 'red', 'black', 'green', 'yellow'] #print fmax for i, wi in enumerate(wis): data[i] = get_stick_data('KC', T, '%s_stickTaito' % edge, wi) width_f[i] = int_toAngst(wi, edge, key='width', C_C=bond) print width_f def axplusb(x, a, b): return a * x + b def Mmax(Lt, width_f, f): def gfun(x): return 0 def hfun(x): return width_f / 2 def func(y, x): return np.sqrt(x**2 + y**2) return 2 * f * dblquad(func, 0, Lt, gfun, hfun)[0] #thetas = width_f/(2*360/mus*1./(2*np.pi)*10) def teor(theta, W0): #return 2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 return 2 * 2 * np.sqrt(3) / 9 * 1000 * bond**3 / W0 * k * ( 1 - 2 * tau / (k * W0))**2 * theta**3 plot2 = [] plot3 = [] fit_vals = [ [.0007, .46], [.0008, .4], [.00075, .64], [.00084, .705], [.00085, .868], ] fit_vals = [ [.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6], [.00077, .6], ] for j, wi in enumerate(wis): LbLt = data[j] LbLt.view('i8,i8').sort(order=['f0'], axis=0) Rs = LbLt[:, 0] / (np.pi / 3.) thetas = width_f[j] / (2 * Rs) mus = thetas * 2. / width_f[j] * 360 / (2 * np.pi) * 10 print thetas ''' if plot_mus: for i in range(len(mus)): if LbLt[i,1] < 3: print 'hoos' plt.scatter(mus[i], LbLt[i,1]/LbLt[i,0], marker = 'D',color = 'red') else: plt.scatter(mus[i], LbLt[i,1]/LbLt[i,0], color = 'blue') plt.scatter(mus, teor(thetas, width_f), marker = 'v', label = 'teor') plt.plot([2,2], [0, .4], '--', color = 'black') plt.plot([4,4], [0, .4], '--', color = 'black') plt.text(1.03, .4, 'experimetl stick below 2deg/angst') plt.text(1.03, -.05, 'red squares only one unit cell \n enought to hold bend') plt.text(3.7, .4, 'buckling') plt.title('Reguired tail length for bend to stick ac, w=7') plt.legend(loc = 2, frameon = False) plt.xlabel('Deg/angst') plt.ylabel('Ltail/Lbend') plt.show() else: ''' if plot_mus: #plt.plot(mus, LbLt[:,1], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #a,b = curve_fit(axplusb, mus, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] #plt.plot(mus, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) #plt.plot(mus, a*mus + b, '--', color = colors[j], # alpha = .8) #plot2.append([width_f[j], -b/a]) #plt.plot(mus, LbLt[:,1]/width_f[j], '-o', color = colors[j], # alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) R_exp = width_f[j] / (2 * thetas) plt.plot(mus, LbLt[:, 1] / R_exp, '-o', color=colors[j], alpha=.8, label=r'width = %.2f\AA' % (width_f[j] + 2)) else: plt.plot(thetas, LbLt[:, 1], '-o', color=colors[j], alpha=.8) ''' a,b = curve_fit(axplusb, thetas, LbLt[:,1]/LbLt[:,0], p0 = [1.,11])[0][:2] plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8, label = r'width = %.2f\AA' %(width_f[j] + 2)) plt.plot(thetas, a*thetas + b, '--', color = colors[j], alpha = .8) plot2.append([width_f[j], -b/a]) ''' #plt.plot(thetas, LbLt[:,1]/LbLt[:,0], '-o', color = colors[j], alpha = .8) print np.sqrt(width_f[j] / .01 * a + a**2) def gfunc(Lt, theta, f, a): L = np.sqrt(width_f[j] / theta * a + a**2) + Lt return (1. / 6. * theta * k * width_f[j]**2 - Mmax(L, width_f[j], f))**2 def Ltail(thetas, f, a): Lts = np.zeros(len(thetas)) print f, a for i, theta in enumerate(thetas): Lts[i] = fmin(gfunc, 1, args=([theta, f, a]), disp=0)[0] return Lts def Ltail2(theta, f, a): return fmin(gfunc, 1, args=([theta, f, a]), disp=0)[0]**2 Lmax = 35 Lts = np.linspace(0, Lmax, 15) thts = np.linspace(0.005, .04, len(Lts)) teor_Lt = np.zeros(len(Lts)) if False: fmax, a = curve_fit(Ltail, thetas, LbLt[:, 1], p0=[fmax, .2])[0] else: fmax, a = fit_vals[j] print fmax, a for i, Lt in enumerate(Lts): #teor_theta[k] = 6*Mmax(Lt)/(k*width_f**2) teor_Lt[i] = Ltail( [thts[i]], fmax, a) #fmin(gfunc, 1, args=([thts[i]]), disp = 0)[0] #print thts[i], teor_Lt[i], 6*Mmax(teor_Lt[i], width_f[j])/(k*width_f[j]**2) - thts[i] if plot_mus: degs = thts * 2 / width_f[j] * 3600 / (2 * np.pi) Lbend_teor = np.pi / 3 * width_f[j] / (2 * thts) #plt.plot(degs, teor_Lt/Lbend_teor, '--', color = colors[j], label = 'width = %i' %wi) #plt.plot(degs, teor_Lt/width_f[j], '--', color = colors[j], label = 'width = %i' %wi) R_teor = width_f[j] / (2 * thts) plt.plot(degs, teor_Lt / R_teor, '--', color=colors[j], label='width = %i' % wi) theta0 = fmin(Ltail2, .001, args=([fmax, a]), disp=0)[0] deg0 = theta0 * 2 / width_f[j] * 3600 / (2 * np.pi) plot3.append([width_f[j], deg0, theta0]) else: plt.plot(thts, teor_Lt, '--', color=colors[j], label='width = %i' % wi) #plt.legend(loc = 2, frameon = False) if not plot_mus: plt.xlabel('Theta') plt.ylabel('Ltail Angst') else: plt.xlabel('Curve deg/Angst') plt.ylabel('Ltail Angst') plt.legend(loc=2, frameon=False) plt.title('Required tail length for pinning') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:, 0], plot3[:, 1], '-o') plt.show() plot3 = np.array(plot3) plt.plot(plot3[:, 0], plot3[:, 2], '-o') plt.show() plot2 = np.array(plot2) plt.plot(plot2[:, 0], plot2[:, 1], '-o') plt.show()
def plot_stick(): #width_f = 7.5 #print 4./360*2*np.pi*width_f/10/2. #exit() plot_mus = False edge = 'ac' T, wi = 10, 11 LbLt = get_stick_data('KC', T, '%s_stickTaito' % edge, wi) LbLt.view('i8,i8').sort(order=['f0'], axis=0) width_f = int_toAngst(wi, edge, key='width', C_C=bond) Rs = LbLt[:, 0] / (np.pi / 3.) thetas = width_f / (2 * Rs) mus = thetas * 2. / width_f * 360 / (2 * np.pi) * 10 #thetas = width_f/(2*360/mus*1./(2*np.pi)*10) def teor(theta, W0): #return 2*np.sqrt(3)/9*1000*bond**3/W0*k*(1- 2*tau/(k*W0))**2*theta**3 return 2 * 2 * np.sqrt(3) / 9 * 1000 * bond**3 / W0 * k * ( 1 - 2 * tau / (k * W0))**2 * theta**3 if plot_mus: for i in range(len(mus)): if LbLt[i, 1] < 3: print 'hoos' plt.scatter(mus[i], LbLt[i, 1] / LbLt[i, 0], marker='D', color='red') else: plt.scatter(mus[i], LbLt[i, 1] / LbLt[i, 0], color='blue') plt.scatter(mus, teor(thetas, width_f), marker='v', label='teor') plt.plot([2, 2], [0, .4], '--', color='black') plt.plot([4, 4], [0, .4], '--', color='black') plt.text(1.03, .4, 'experimetl stick below 2deg/angst') plt.text(1.03, -.05, 'red squares only one unit cell \n enought to hold bend') plt.text(3.7, .4, 'buckling') plt.title('Reguired tail length for bend to stick ac, w=7') plt.legend(loc=2, frameon=False) plt.xlabel('Deg/angst') plt.ylabel('Ltail/Lbend') plt.show() else: for i in range(len(mus)): if LbLt[i, 1] < 3: print 'hoos' plt.scatter(thetas[i], LbLt[i, 1] / LbLt[i, 0], marker='D', color='red') #plt.scatter(thetas[i], LbLt[i,1], marker = 'D',color = 'red') else: plt.scatter(thetas[i], LbLt[i, 1] / LbLt[i, 0], color='blue') #plt.scatter(thetas[i], LbLt[i,1], color = 'blue') print LbLt[i, 1] / (np.pi / 3) * 2 * thetas[i] / width_f, LbLt[ i, 1], 1 / (np.pi / 3) * 2 * thetas[i] / width_f, LbLt[i, 0] #plt.scatter(thetas, teor(thetas, width_f), marker = 'v', label = 'teor') #plt.scatter(thetas, teor(thetas, width_f)*LbLt[:,0], marker = 'v', label = 'teor') plt.twinx() plt.scatter(thetas, LbLt[:, 0]) plt.scatter(thetas, LbLt[:, 1]) plt.legend(loc=2, frameon=False) plt.xlabel('Theta') plt.ylabel('Ltail Angst') plt.show()
def plot_kinkOfBend_deg(edge): plot_mus = True #False # magic_par = 0.0228171 #0.0203724 datas_ac = get_log_data('LJ', T, '%s_twistTaito' % 'ac') datas_zz = get_log_data('LJ', T, '%s_twistTaito' % 'zz') coll_data_ac = np.zeros((len(datas_ac), 6)) coll_data_zz = np.zeros((len(datas_zz), 6)) thresz = 5 vmax = -1. eps = 0.002843732471143 #[eV] kappa = .95 #[eV] n = 1 / (3 * np.sqrt(3) * bond**2 / 4) pot = 1 def theta_teor(W): Y = 11.43 / W + 19.88 return 24. / Y * np.sqrt(eps * kappa * np.pi) * n class alpha(): def __init__(self): pass def set_s(self, s): self.s = s def set_t(self, t): self.t = t def set_pot(self, pot): self.pot = pot def set_params(self, s, t, pot): self.set_s(s) self.set_t(t) self.set_pot(pot) def get_alpha(self, w): #Y = 11.43/W + 19.88 #A, B = 48.7, .0055 #Length = 12.8 #B = 4/(Y*np.pi**2)*(A/Length**2 + B*Length**2) return magic_par / (self.s / w**self.pot + self.t) #return self.s/w**self.pot + self.t alpha = alpha() def theta_teorFitPar(W, *args): if len(args) == 1: s = args[:1] alpha.set_s(s) if len(args) == 2: s, t = args[:2] alpha.set_s(s) alpha.set_t(t) if len(args) == 3: s, t, pot = args[:3] alpha.set_s(s) alpha.set_t(t) alpha.set_pot(pot) #Y = 11.43/W + 19.88 #A, B = 48.7, .0055 #Length = 12.8 #print np.average(4/(Y*np.pi**2)*(A/Length**2 + B*Length**2)) return magic_par / alpha.get_alpha(W) #return 4/(Y*np.pi**2*alpha.get_alpha(W))*(A/Length**2 + B*Length**2) def overR(W, a1, a2): return a1 / W + a2 def overRandconst(W, a1, a2): return a1 / (W + a2) def overR2(W, a1, a2): return a1 / W**2 + a2 for i, data in enumerate(datas_ac): energy_table = data[6] v = data[5] natoms = data[4] Wi, Li, W, L = data[:4] phi = energy_table[:, 3] epot = (energy_table[:, 5] - energy_table[-1, 5]) / natoms heights = energy_table[:, 4] inds = np.where(thresz < heights)[0] indv = max(inds) indb = min(inds) W = int_toAngst(Wi, 'ac', key='width', C_C=bond) thetas = W / (2 * (L / phi)) mus = thetas * 2. / W * 360 / (2 * np.pi) * 10 coll_data_ac[i] = [ W, v, thetas[indv], thetas[indb], mus[indv], mus[indb] ] if v > vmax: vmax = v for i, data in enumerate(datas_zz): energy_table = data[6] v = data[5] natoms = data[4] Wi, Li, W, L = data[:4] phi = energy_table[:, 3] epot = (energy_table[:, 5] - energy_table[-1, 5]) / natoms heights = energy_table[:, 4] inds = np.where(thresz < heights)[0] indv = max(inds) indb = min(inds) W = int_toAngst(Wi, 'zz', key='width', C_C=bond) thetas = W / (2 * (L / phi)) mus = thetas * 2. / W * 360 / (2 * np.pi) * 10 coll_data_zz[i] = [ W, v, thetas[indv], thetas[indb], mus[indv], mus[indb] ] if v > vmax: vmax = v if plot_mus: for i in range(len(coll_data_ac)): plt.scatter(coll_data_ac[i, 0], coll_data_ac[i, 4], alpha=coll_data_ac[i, 1] / vmax, color='red') plt.scatter(coll_data_ac[i, 0], coll_data_ac[i, 5], alpha=coll_data_ac[i, 1] / vmax, color='blue') #for i in range(len(coll_data_zz)): # plt.scatter(coll_data_zz[i,0], coll_data_zz[i,4], # alpha = coll_data_zz[i,1]/vmax, color = 'red') # plt.scatter(coll_data_zz[i,0], coll_data_zz[i,5], # alpha = coll_data_zz[i,1]/vmax, color = 'blue') alpha.set_pot(1) alpha.set_t(magic_par) sopm1_ac = curve_fit(theta_teorFitPar, coll_data_ac[:, 0], coll_data_ac[:, 2], p0=[1.])[0][:1] plot_widths = np.linspace( np.min(coll_data_ac[:, 0]) - .5, np.max(coll_data_ac[:, 0]) + 2, 50) plt.plot(plot_widths, 2 / plot_widths * 3600 / (2 * np.pi) * theta_teorFitPar(plot_widths, sopm1_ac, magic_par, 1.), '--', label=r'$\Theta \approx \frac{%.2f}{w} + %.3f$' % (sopm1_ac, magic_par), color='green') plt.legend(loc=2, frameon=False) plt.ylabel(r'$^{\circ}/$\AA') plt.xlabel(r'Width \AA') #plt.twinx() # #alpha.set_params(sopm1_ac, magic_par, 1) #plt.plot(plot_widths, alpha.get_alpha(plot_widths), # label = r'$\alpha = \frac{%.3f}{%.2f/w + %.3f} \rightarrow %.3f$' # %(magic_par, sopm1_ac, magic_par, 1), # color = 'green') #plt.legend(loc = 1, frameon = False) #plt.ylabel(r'$\alpha$') plt.show() else: for i in range(len(coll_data_ac)): plt.scatter(coll_data_ac[i, 0], coll_data_ac[i, 2], alpha=coll_data_ac[i, 1] / vmax, color='red') plt.scatter(coll_data_ac[i, 0], coll_data_ac[i, 3], alpha=coll_data_ac[i, 1] / vmax, color='blue') #pot = 1.5 #alpha.set_pot(pot) #sopm15, topm15 = curve_fit(theta_teorFitPar, coll_data[:,0], coll_data[:,2], p0 = [1., 1])[0][:2] pot = 2. alpha.set_pot(pot) sopm2, topm2 = curve_fit(theta_teorFitPar, coll_data_ac[:, 0], coll_data_ac[:, 2], p0=[1., 1])[0][:2] alpha.set_pot(1) alpha.set_t(magic_par) sopm1 = curve_fit(theta_teorFitPar, coll_data_ac[:, 0], coll_data_ac[:, 2], p0=[1.])[0][:1] sopm3, topm3, potopm = curve_fit(theta_teorFitPar, coll_data_ac[:, 0], coll_data_ac[:, 2], p0=[1., 1, 1])[0][:3] #plt.plot(coll_data[:,0], np.ones(len(coll_data[:,0]))*.04, '-.', color = 'black') #plt.text(np.min(coll_data[:,0]), .041, 'teor') #plt.scatter(coll_data[:,0], theta_teor(coll_data[:,0])) #plt.text(np.min(coll_data[:,0]), .041, 'teor') plot_widths = np.linspace( np.min(coll_data_ac[:, 0]) - .5, np.max(coll_data_ac[:, 0]) + 2, 50) #plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm15, topm15, 1.5), '--', # label = 'alpha = %.2f/w**%.1f + %.3f' %(sopm15, 1.5, topm15)) ''' plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm2, topm2, 2.), '--', label = r'$\Theta \approx \frac{%.2f}{w^2} + %.3f$' %(sopm2, topm2), color = 'red') ''' plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm1, magic_par, 1.), '--', label=r'$\Theta \approx \frac{%.2f}{w} + %.3f$' % (sopm1, magic_par), color='green') #plt.plot(plot_widths, overR2(plot_widths, sopm2a, topm2a), # label = r'$\Theta \approx \frac{1}{%.2fw^2} + %.3f$' %(sopm2a, topm2a), ) ''' plt.plot(plot_widths, theta_teorFitPar(plot_widths, sopm3, topm3, potopm), '.-', label = r'$\Theta \approx \frac{%.2f}{w^{%.2f}} + %.3f$' %(sopm3, potopm, topm3), color = 'red') ''' plt.scatter(8.46, .026, marker='D', color='black') plt.text(np.min(coll_data_ac[:, 0]), .028, r'Experim. $\Theta \approx 0.026 = 4deg/nm$') plt.legend(frameon=False, loc=2) plt.xlabel('width Angst') plt.ylabel(r'$\Theta$') plt.twinx() #alpha.set_params(sopm15, topm15, 1.5) #plt.plot(plot_widths, alpha.get_alpha(plot_widths), # label = 'alpha -> %.3f' %alpha.get_alpha(10000)) ''' alpha.set_params(sopm2, topm2, 2) plt.plot(plot_widths, alpha.get_alpha(plot_widths), label = r'$\alpha = \frac{%.3f}{%.2f/w^2 + %.3f} \rightarrow %.3f$' %(magic_par, sopm2, topm2, magic_par/topm2), color = 'red') ''' alpha.set_params(sopm1, magic_par, 1) plt.plot( plot_widths, alpha.get_alpha(plot_widths), label=r'$\alpha = \frac{%.3f}{%.2f/w + %.3f} \rightarrow %.3f$' % (magic_par, sopm1, magic_par, 1), color='green') ''' print sopm1/magic_par, sopm1, magic_par plt.plot(plot_widths, plot_widths/(sopm1/magic_par + plot_widths), '-o', color = 'green') alpha.set_params(sopm3, topm3, potopm) plt.plot(plot_widths, alpha.get_alpha(plot_widths), '.-', label = r'$\alpha = \frac{%.3f}{%.2f/w^{%.2f} + %.3f} \rightarrow %.3f$' %(magic_par, sopm3, potopm, topm3, magic_par/topm3), color = 'red') ''' plt.ylabel(r'$\alpha$') plt.legend(frameon=False) plt.show()