update
This commit is contained in:
		| @@ -10,7 +10,7 @@ import cmath | |||||||
| import time | import time | ||||||
|  |  | ||||||
|  |  | ||||||
| def hamiltonian(k1, k2, t1=2.82*sqrt(3)/2, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | def hamiltonian(k1, k2, t1=2.82, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | ||||||
|     h = np.zeros((2, 2))*(1+0j) |     h = np.zeros((2, 2))*(1+0j) | ||||||
|     h[0, 0] = 0.28/2 |     h[0, 0] = 0.28/2 | ||||||
|     h[1, 1] = -0.28/2 |     h[1, 1] = -0.28/2 | ||||||
| @@ -67,12 +67,19 @@ def main(): | |||||||
|                 F_all[i0, j0] = np.real(F) |                 F_all[i0, j0] = np.real(F) | ||||||
|                 i0 += 1 |                 i0 += 1 | ||||||
|             j0 += 1 |             j0 += 1 | ||||||
|         plot_matrix(kx_array/pi, ky_array/pi, F_all, band) |  | ||||||
|         write_matrix(kx_array/pi, ky_array/pi, F_all, band) |         if band==0: | ||||||
|  |             plot_3d_surface(kx_array/pi, ky_array/pi, F_all, xlabel='kx', ylabel='ky', zlabel='Berry curvature', title='Valence Band', rcount=300, ccount=300) | ||||||
|  |         else: | ||||||
|  |             plot_3d_surface(kx_array/pi, ky_array/pi, F_all, xlabel='kx', ylabel='ky', zlabel='Berry curvature', title='Conductance Band', rcount=300, ccount=300) | ||||||
|  |         # import guan | ||||||
|  |         # if band==0: | ||||||
|  |         #     guan.plot_3d_surface(kx_array/pi, ky_array/pi, F_all, xlabel='kx', ylabel='ky', zlabel='Berry curvature', title='Valence Band', rcount=300, ccount=300) | ||||||
|  |         # else: | ||||||
|  |         #     guan.plot_3d_surface(kx_array/pi, ky_array/pi, F_all, xlabel='kx', ylabel='ky', zlabel='Berry curvature', title='Conductance Band', rcount=300, ccount=300) | ||||||
|     end_time = time.time() |     end_time = time.time() | ||||||
|     print('运行时间(min)=', (end_time-start_time)/60) |     print('运行时间(min)=', (end_time-start_time)/60) | ||||||
|  |  | ||||||
|  |  | ||||||
| def find_vector_with_the_same_gauge(vector_1, vector_0): | def find_vector_with_the_same_gauge(vector_1, vector_0): | ||||||
|     # 寻找近似的同一的规范 |     # 寻找近似的同一的规范 | ||||||
|     phase_1_pre = 0 |     phase_1_pre = 0 | ||||||
| @@ -109,43 +116,44 @@ def find_vector_with_the_same_gauge(vector_1, vector_0): | |||||||
|     # print('二分查找找到的规范=', phase)    |     # print('二分查找找到的规范=', phase)    | ||||||
|     return vector_1 |     return vector_1 | ||||||
|  |  | ||||||
|  | def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', fontsize=20, labelsize=15, show=1, save=0, filename='a', format='jpg', dpi=300, z_min=None, z_max=None, rcount=100, ccount=100):  | ||||||
| def plot_matrix(k1, k2, matrix, band): |  | ||||||
|     import matplotlib.pyplot as plt |     import matplotlib.pyplot as plt | ||||||
|     from mpl_toolkits.mplot3d import Axes3D |  | ||||||
|     from matplotlib import cm |     from matplotlib import cm | ||||||
|     from matplotlib.ticker import LinearLocator, FormatStrFormatter |     from matplotlib.ticker import LinearLocator | ||||||
|     fig = plt.figure() |     matrix = np.array(matrix) | ||||||
|     ax = fig.gca(projection='3d') |     fig, ax = plt.subplots(subplot_kw={"projection": "3d"}) | ||||||
|     k1, k2 = np.meshgrid(k1, k2) |     plt.subplots_adjust(bottom=0.1, right=0.65)  | ||||||
|     ax.plot_surface(k1, k2, matrix, cmap="rainbow", linewidth=0, antialiased=False)  |     x_array, y_array = np.meshgrid(x_array, y_array) | ||||||
|     plt.xlabel('kx') |     if len(matrix.shape) == 2: | ||||||
|     plt.ylabel('ky')  |         surf = ax.plot_surface(x_array, y_array, matrix, rcount=rcount, ccount=ccount, cmap=cm.coolwarm, linewidth=0, antialiased=False)  | ||||||
|     ax.set_zlabel('Berry curvature')   |     elif len(matrix.shape) == 3: | ||||||
|     if band==0: |         for i0 in range(matrix.shape[2]): | ||||||
|         plt.title('Valence Band') |             surf = ax.plot_surface(x_array, y_array, matrix[:,:,i0], rcount=rcount, ccount=ccount, cmap=cm.coolwarm, linewidth=0, antialiased=False)  | ||||||
|     else: |     ax.set_title(title, fontsize=fontsize, fontfamily='Times New Roman') | ||||||
|         plt.title('Conductance Band') |     ax.set_xlabel(xlabel, fontsize=fontsize, fontfamily='Times New Roman')  | ||||||
|     plt.show() |     ax.set_ylabel(ylabel, fontsize=fontsize, fontfamily='Times New Roman')  | ||||||
|  |     ax.set_zlabel(zlabel, fontsize=fontsize, fontfamily='Times New Roman')  | ||||||
|  |     ax.zaxis.set_major_locator(LinearLocator(5))  | ||||||
| def write_matrix(k1, k2, matrix, band): |     ax.zaxis.set_major_formatter('{x:.2f}')   | ||||||
|     import os |     if z_min!=None or z_max!=None: | ||||||
|     os.chdir('D:/data')  # 设置路径 |         if z_min==None: | ||||||
|     with open('band='+str(band)+'.txt', 'w') as f: |             z_min=matrix.min() | ||||||
|         # np.set_printoptions(suppress=True)  # 取消输出科学记数法 |         if z_max==None: | ||||||
|         f.write('0           ') |             z_max=matrix.max() | ||||||
|         for k10 in k1: |         ax.set_zlim(z_min, z_max) | ||||||
|             f.write(str(k10)+'   ') |     ax.tick_params(labelsize=labelsize)  | ||||||
|         f.write('\n') |     labels = ax.get_xticklabels() + ax.get_yticklabels() + ax.get_zticklabels() | ||||||
|         i0 = 0 |     [label.set_fontname('Times New Roman') for label in labels]  | ||||||
|         for k20 in k2: |     cax = plt.axes([0.8, 0.1, 0.05, 0.8])  | ||||||
|             f.write(str(k20)) |     cbar = fig.colorbar(surf, cax=cax)   | ||||||
|             for j0 in range(k1.shape[0]): |     cbar.ax.tick_params(labelsize=labelsize) | ||||||
|                 f.write('  '+str(matrix[i0, j0])+'   ') |     for l in cbar.ax.yaxis.get_ticklabels(): | ||||||
|             f.write('\n') |         l.set_family('Times New Roman') | ||||||
|             i0 += 1    |     if save == 1: | ||||||
|  |         plt.savefig(filename+'.'+format, dpi=dpi)  | ||||||
|  |     if show == 1: | ||||||
|  |         plt.show() | ||||||
|  |     plt.close('all') | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     main() |     main() | ||||||
| @@ -10,7 +10,7 @@ import cmath | |||||||
| import time | import time | ||||||
|  |  | ||||||
|  |  | ||||||
| def hamiltonian(k1, k2, t1=2.82*sqrt(3)/2, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | def hamiltonian(k1, k2, t1=2.82, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | ||||||
|     h = np.zeros((2, 2))*(1+0j) |     h = np.zeros((2, 2))*(1+0j) | ||||||
|     h[0, 0] = 0.28/2 |     h[0, 0] = 0.28/2 | ||||||
|     h[1, 1] = -0.28/2 |     h[1, 1] = -0.28/2 | ||||||
| @@ -18,7 +18,6 @@ def hamiltonian(k1, k2, t1=2.82*sqrt(3)/2, a=1/sqrt(3)):  # 石墨烯哈密顿 | |||||||
|     h[0, 1] = h[1, 0].conj() |     h[0, 1] = h[1, 0].conj() | ||||||
|     return h |     return h | ||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|     start_time = time.time() |     start_time = time.time() | ||||||
|     n = 2000  # 取点密度 |     n = 2000  # 取点密度 | ||||||
| @@ -71,7 +70,6 @@ def main(): | |||||||
|     end_time = time.time() |     end_time = time.time() | ||||||
|     print('运行时间(min)=', (end_time-start_time)/60) |     print('运行时间(min)=', (end_time-start_time)/60) | ||||||
|  |  | ||||||
|  |  | ||||||
| def find_vector_with_the_same_gauge(vector_1, vector_0): | def find_vector_with_the_same_gauge(vector_1, vector_0): | ||||||
|     # 寻找近似的同一的规范 |     # 寻找近似的同一的规范 | ||||||
|     phase_1_pre = 0 |     phase_1_pre = 0 | ||||||
| @@ -108,7 +106,5 @@ def find_vector_with_the_same_gauge(vector_1, vector_0): | |||||||
|     # print('二分查找找到的规范=', phase)    |     # print('二分查找找到的规范=', phase)    | ||||||
|     return vector_1 |     return vector_1 | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     main() |     main() | ||||||
| @@ -9,7 +9,7 @@ from math import * | |||||||
| import cmath | import cmath | ||||||
|  |  | ||||||
|  |  | ||||||
| def hamiltonian(k1, k2, t1=2.82*sqrt(3)/2, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | def hamiltonian(k1, k2, t1=2.82, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | ||||||
|     h = np.zeros((2, 2))*(1+0j) |     h = np.zeros((2, 2))*(1+0j) | ||||||
|     h[0, 0] = 0.28/2 |     h[0, 0] = 0.28/2 | ||||||
|     h[1, 1] = -0.28/2 |     h[1, 1] = -0.28/2 | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ from math import * | |||||||
| import cmath | import cmath | ||||||
|  |  | ||||||
|  |  | ||||||
| def hamiltonian(k1, k2, t1=2.82*sqrt(3)/2, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | def hamiltonian(k1, k2, t1=2.82, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | ||||||
|     h = np.zeros((2, 2))*(1+0j) |     h = np.zeros((2, 2))*(1+0j) | ||||||
|     h[0, 0] = 0.28/2 |     h[0, 0] = 0.28/2 | ||||||
|     h[1, 1] = -0.28/2 |     h[1, 1] = -0.28/2 | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ from math import * | |||||||
| import cmath | import cmath | ||||||
|  |  | ||||||
|  |  | ||||||
| def hamiltonian(k1, k2, t1=2.82*sqrt(3)/2, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | def hamiltonian(k1, k2, t1=2.82, a=1/sqrt(3)):  # 石墨烯哈密顿量(a为原子间距,不赋值的话默认为1/sqrt(3)) | ||||||
|     h = np.zeros((2, 2))*(1+0j) |     h = np.zeros((2, 2))*(1+0j) | ||||||
|     h[0, 0] = 0.28/2 |     h[0, 0] = 0.28/2 | ||||||
|     h[1, 1] = -0.28/2 |     h[1, 1] = -0.28/2 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user