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_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_energy(edge): Wis = [5,7,9,11,13] datas = get_log_data('LJ', T, '%s_twistTaito' %edge, Wis) wili_used = [] n = 0 colors = ['red', 'blue', 'green', 'black', 'cyan', 'yellow'] aopms = [] teor_aopms = [] W0s = [] def shear_e(W0, L0, theta): #return k*L*(W/R)**2*W/24 tau = 1.54 #-.13 # -.064/W0 - .13 #- .13 Y = 18.75 #19.89 # 11.43/W0 + 19.89 # 19.89 # return 1./6*Y*L0*W0*theta**2*(1. - 2*tau/(k*W0))**2 #- 2*tau**2/(k*W0)*L0 def shear_eNoedge(W0, L0, theta): return 1./6*k*L0*W0*theta**2 def x2(thetas, a): return a*thetas**2 ang_vs = np.zeros(len(datas)) for i, dat in enumerate(datas): ang_vs[i] = dat[5] ang_vs = np.max(ang_vs) for data in 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]) heights = energy_table[:,4] inds = np.where(5 < heights)[0] indv = max(inds) indb = min(inds) thetas = W/(2*(L/phi)) if edge == 'ac': W0 = (Wi - 1)*np.sqrt(3)/2*bond L0 = Li*3.*bond - 1.*bond Area = W0 * L0 natoms2 = W0 * L0 / (3*np.sqrt(3)/4*bond**2) else: raise if [Wi, Li] not in wili_used: wili_used.append([Wi, Li]) weff = 1 * W0 #- (bond*np.sqrt(3))*.3 # .02/(.16/W0 + .02)*W0 # epot_t = shear_e(weff, L0, thetas) plt.plot(thetas, epot_t/Area, '.-', color = colors[n], alpha = .4) #, label = 'Epot teor') W0s.append(W0) teor_aopms.append(shear_e(weff, L0, 1)/Area) n += 1 #epot_t2 = shear_eNoedge(W0, L0, thetas) ind_last = np.where(.02 < thetas)[0][-1] aopm = curve_fit(x2, thetas[ind_last:], epot[ind_last:]/Area, 1)[0][0] #aopm = curve_fit(x2, thetas[:indb], epot[:indb]/Area, 1)[0][0] if len(aopms) < n: aopms.append([]) aopms[n - 1].append(aopm) erange = np.max(epot/Area) #plt.plot(thetas, x2(thetas, aopm), color = colors[n -1], alpha = .4) #, label = 'Epot') plt.plot(thetas, epot/Area, color = colors[n -1], alpha = .1) #, label = 'Epot') ''' plt.plot([thetas[indv], thetas[indv]], [epot[indv]/Area - erange/7, epot[indv]/Area + erange/7], '--', color = colors[n -1], alpha = .3) plt.plot([thetas[indb], thetas[indb]], [epot[indb]/Area - erange/7, epot[indb]/Area + erange/7], '--', color = colors[n -1], alpha = .3) ''' #plt.plot(thetas, z, color = colors[n -1], alpha = v/ang_vs) #, label = 'maxH') #plt.scatter(thetas[indv], heights[indv], color = colors[n -1], alpha = .5) #plt.scatter(thetas[indb], heights[indb], color = colors[n -1], alpha = .5) #plt.plot(thetas, epot_t2, label = 'Epot teor2') plt.xlabel('Theta w/(2R)') plt.legend(loc = 1) #plt.ylabel('tot Edens eV/angst2') #plt.title('width = %.2fAngst, edge = %s' %(W, edge)) plt.legend(loc = 2) plt.ylabel('height max Angst') plt.show() aopm_av = np.zeros(len(aopms)) for i in range(n): aopm_av[i] = np.average(aopms[i]) plt.scatter(W0s, aopm_av, color = 'red') plt.scatter(W0s, teor_aopms, color = 'green', label = 'teor') plt.ylabel('aopm') plt.xlabel('width') plt.legend(loc = 2, frameon = False) plt.twinx() plt.scatter(W0s, np.array(aopm_av)/np.array(teor_aopms), color = 'black', label = 'teor/expr') plt.ylabel('aopm teor over aopm expr') plt.legend(loc = 4, frameon = False) plt.show()
def plot_energy(edge): Wis = [5, 7, 9, 11, 13] datas = get_log_data('LJ', T, '%s_twistTaito' % edge, Wis) wili_used = [] n = 0 colors = ['red', 'blue', 'green', 'black', 'cyan', 'yellow'] aopms = [] teor_aopms = [] W0s = [] def shear_e(W0, L0, theta): #return k*L*(W/R)**2*W/24 tau = 1.54 #-.13 # -.064/W0 - .13 #- .13 Y = 18.75 #19.89 # 11.43/W0 + 19.89 # 19.89 # return 1. / 6 * Y * L0 * W0 * theta**2 * ( 1. - 2 * tau / (k * W0))**2 #- 2*tau**2/(k*W0)*L0 def shear_eNoedge(W0, L0, theta): return 1. / 6 * k * L0 * W0 * theta**2 def x2(thetas, a): return a * thetas**2 ang_vs = np.zeros(len(datas)) for i, dat in enumerate(datas): ang_vs[i] = dat[5] ang_vs = np.max(ang_vs) for data in 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]) heights = energy_table[:, 4] inds = np.where(5 < heights)[0] indv = max(inds) indb = min(inds) thetas = W / (2 * (L / phi)) if edge == 'ac': W0 = (Wi - 1) * np.sqrt(3) / 2 * bond L0 = Li * 3. * bond - 1. * bond Area = W0 * L0 natoms2 = W0 * L0 / (3 * np.sqrt(3) / 4 * bond**2) else: raise if [Wi, Li] not in wili_used: wili_used.append([Wi, Li]) weff = 1 * W0 #- (bond*np.sqrt(3))*.3 # .02/(.16/W0 + .02)*W0 # epot_t = shear_e(weff, L0, thetas) plt.plot(thetas, epot_t / Area, '.-', color=colors[n], alpha=.4) #, label = 'Epot teor') W0s.append(W0) teor_aopms.append(shear_e(weff, L0, 1) / Area) n += 1 #epot_t2 = shear_eNoedge(W0, L0, thetas) ind_last = np.where(.02 < thetas)[0][-1] aopm = curve_fit(x2, thetas[ind_last:], epot[ind_last:] / Area, 1)[0][0] #aopm = curve_fit(x2, thetas[:indb], epot[:indb]/Area, 1)[0][0] if len(aopms) < n: aopms.append([]) aopms[n - 1].append(aopm) erange = np.max(epot / Area) #plt.plot(thetas, x2(thetas, aopm), color = colors[n -1], alpha = .4) #, label = 'Epot') plt.plot(thetas, epot / Area, color=colors[n - 1], alpha=.1) #, label = 'Epot') ''' plt.plot([thetas[indv], thetas[indv]], [epot[indv]/Area - erange/7, epot[indv]/Area + erange/7], '--', color = colors[n -1], alpha = .3) plt.plot([thetas[indb], thetas[indb]], [epot[indb]/Area - erange/7, epot[indb]/Area + erange/7], '--', color = colors[n -1], alpha = .3) ''' #plt.plot(thetas, z, color = colors[n -1], alpha = v/ang_vs) #, label = 'maxH') #plt.scatter(thetas[indv], heights[indv], color = colors[n -1], alpha = .5) #plt.scatter(thetas[indb], heights[indb], color = colors[n -1], alpha = .5) #plt.plot(thetas, epot_t2, label = 'Epot teor2') plt.xlabel('Theta w/(2R)') plt.legend(loc=1) #plt.ylabel('tot Edens eV/angst2') #plt.title('width = %.2fAngst, edge = %s' %(W, edge)) plt.legend(loc=2) plt.ylabel('height max Angst') plt.show() aopm_av = np.zeros(len(aopms)) for i in range(n): aopm_av[i] = np.average(aopms[i]) plt.scatter(W0s, aopm_av, color='red') plt.scatter(W0s, teor_aopms, color='green', label='teor') plt.ylabel('aopm') plt.xlabel('width') plt.legend(loc=2, frameon=False) plt.twinx() plt.scatter(W0s, np.array(aopm_av) / np.array(teor_aopms), color='black', label='teor/expr') plt.ylabel('aopm teor over aopm expr') plt.legend(loc=4, frameon=False) plt.show()
def plot_kinkOfBend3(edge): plot_mus = False magic_par = 0.0203724 datas = get_log_data('LJ', T, '%s_twistTaito' % edge) coll_data = np.zeros((len(datas), 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 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): energy_table = data[6] v = data[5] natoms = data[4] Wi, Li, Wd, 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 = Wd #int_toAngst(Wi, edge, key='width', C_C = bond) + 1.2 print W, Wd, Wd - W thetas = W / (2 * (L / phi)) mus = thetas * 2. / W * 360 / (2 * np.pi) * 10 coll_data[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)): plt.scatter(coll_data[i, 0], coll_data[i, 4], alpha=coll_data[i, 1] / vmax, color='red') plt.scatter(coll_data[i, 0], coll_data[i, 5], alpha=coll_data[i, 1] / vmax, color='blue') pot = 2. alpha.set_pot(pot) sopm2, topm2 = curve_fit(theta_teorFitPar, coll_data[:, 0], coll_data[:, 2], p0=[1., 1])[0][:2] alpha.set_pot(1) alpha.set_t(magic_par) sopm1 = curve_fit(theta_teorFitPar, coll_data[:, 0], coll_data[:, 2], p0=[1.])[0][:1] print sopm2, topm2 print sopm1 plot_widths = np.linspace( np.min(coll_data[:, 0]) - .5, np.max(coll_data[:, 0]) + 2, 50) plt.plot(plot_widths, 2 / plot_widths * 3600 / (2 * np.pi) * theta_teorFitPar(plot_widths, sopm2, topm2, 2.), '--', label=r'$\Theta \approx \frac{%.2f}{w^2} + %.3f$' % (sopm2, topm2), color='red') plt.plot(plot_widths, 2 / plot_widths * 3600 / (2 * np.pi) * theta_teorFitPar(plot_widths, sopm1, magic_par, 1.), '--', label=r'$\Theta \approx \frac{%.2f}{w} + %.3f$' % (sopm1, magic_par), color='green') plt.scatter(8.46, 4, marker='D', color='black') plt.text(np.min(coll_data[:, 0]), 4.1, 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(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') plt.ylabel(r'$\alpha$') plt.legend(frameon=False) plt.show() else: for i in range(len(coll_data)): plt.scatter(coll_data[i, 0], coll_data[i, 2], alpha=coll_data[i, 1] / vmax, color='red') plt.scatter(coll_data[i, 0], coll_data[i, 3], alpha=coll_data[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[:, 0], coll_data[:, 2], p0=[1., 1])[0][:2] alpha.set_pot(1) alpha.set_t(magic_par) sopm1 = curve_fit(theta_teorFitPar, coll_data[:, 0], coll_data[:, 2], p0=[1.])[0][:1] sopm1 = .16 #sopm3, topm3, potopm = curve_fit(theta_teorFitPar, coll_data[:,0], coll_data[:,2], p0 = [1., 1, 1])[0][:3] print sopm2, topm2 print sopm1 #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[:, 0]) - .5, np.max(coll_data[:, 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[:, 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') #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()