当前位置: 首页>>代码示例>>Python>>正文


Python Timer.progress方法代码示例

本文整理汇总了Python中timer.Timer.progress方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.progress方法的具体用法?Python Timer.progress怎么用?Python Timer.progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在timer.Timer的用法示例。


在下文中一共展示了Timer.progress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ent_agr_var_plots

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import progress [as 别名]
def ent_agr_var_plots(spin, N, hmin, hmax, points, c, num_psis, phis):
    """
    This function creates data dumps for plotting of eigenstate entropy,
    adjusted gap ratio, and variance. Also data for histograms
    :param spin: is the spin of the individual particles
    :param N: is the system size
    :param hmin: minimum h to plot
    :param hmax: maximum h to plot
    :param points: number of h to plot
    :param c: quasirandom factor
    :param num_psis: number of eigenstates to find near a specified energy
    :param phis: number of phases to average over
    :return: dumped data files
    """
    h_list = np.linspace(hmin, hmax, points)
    phi_list = np.linspace(0, 0.5 * np.pi, phis + 1)
    phi_list = phi_list[0:-1]
    Sz_tot = aubryC.half_chain_Sz(N)
    Sz_tot2 = Sz_tot**2
    ent_plt = np.zeros(points)
    # var_plt = np.zeros(points)
    agr_plt = np.zeros(points)
    ent_std = np.zeros(points)
    # var_std = np.zeros(points)
    agr_std = np.zeros(points)
    timer = Timer(points*phis, mode='average')
    for i in range(points):
        ent_lst_full = np.array([])
        # var_lst_full = np.array([])
        agr_lst_full = np.array([])
        # eig_lst_full = ent_lst_full
        for k in range(phis):
            H = aubryHo.spin_block(N, h_list[i], c, phi_list[k])
            try:
                H, psis, eigvs = aubryC.gen_eigenpairs(N, H, num_psis)
            except:
                print("Configuration failed to converge: H ", h_list[i], " Phi ", phi_list[k])
                continue
            ent_lst, var_lst = \
                aubryC.ent_var_lst(psis, spin, N, Sz_tot, Sz_tot2)
            eigvs = np.sort(eigvs)
            agr_lst = aubryC.adj_gap_ratio(eigvs)
            ent_lst_full = np.append(ent_lst_full, ent_lst)
            # var_lst_full = np.append(var_lst_full, var_lst)
            agr_lst_full = np.append(agr_lst_full, agr_lst)
            # eig_lst_full = np.append(eig_lst_full, eigvs)
            timer.progress()
        ent_plt[i] = np.mean(ent_lst_full/N)
        ent_std[i] = np.std(ent_lst_full/N)
        # var_plt[i] = np.mean(var_lst_full)
        # var_std[i] = np.std(var_lst_full)
        agr_plt[i] = np.mean(agr_lst_full)
        agr_std[i] = np.std(agr_lst_full)
        ent_hst_file = 'DATA/ent_hst_L' + str(N) + '_h' + str(
            h_list[i]) + '_c' + str(round(c, 2)) + '.txt'
        # var_hst_file = 'DATA/var_hst_L' + str(N) + '_h' + str(
        #     h_list[i]) + '_c' + str(round(c, 2)) + '.txt'
        agr_hst_file = 'DATA/agr_hst_L' + str(N) + '_h' + str(
            h_list[i]) + '_c' + str(round(c, 2)) + '.txt'
        # eig_hst_file = 'eig_hst_L' + str(N) + '_h' + str(
        #     h_list[i]) + '_c' + str(round(c, 2)) + '.txt'
        np.savetxt(ent_hst_file, np.transpose(ent_lst_full))
        # np.savetxt(var_hst_file, np.transpose(var_lst_full))
        np.savetxt(agr_hst_file, np.transpose(agr_lst_full))
        # np.savetxt(eig_hst_file, eig_lst_full)
    ent_agr_var_plot_file = 'DATA/plot_data_L' + str(N) + '_c' + str(round(c, 2))\
                            + '_phi' + str(phis) + '.txt'
    # np.savetxt(ent_agr_var_plot_file, (h_list, ent_plt, ent_std, agr_plt, agr_std, var_plt, var_std))
    np.savetxt(ent_agr_var_plot_file, (h_list, ent_plt, ent_std, agr_plt, agr_std))
开发者ID:1119group,项目名称:helloworld,代码行数:71,代码来源:entropy.py


注:本文中的timer.Timer.progress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。