Esempio n. 1
0
 def load_cache(self, filename):
     """ Load data from cache."""
     fullpath = os.path.join(self.cache_dir, filename)
     if os.path.exists(fullpath + '.bcolz'):
         return load_array(fullpath + '.bcolz')
     elif os.path.exists(fullpath + '.pkl'):
         with open(fullpath + '.pkl', 'rb') as f:
             return pickle.load(f)
     else:
         raise FileNotFoundError
Esempio n. 2
0
    J = 1.

    H = 'TFI'  # XXZ

    if H == 'TFI':
        dir_path = 'data/1d_TFI_g%.1f/' % (g)
    elif H == 'XXZ':
        dir_path = 'data/1d_XXZ_g%.1f/' % (g)

    if not os.path.exists(dir_path):
        os.makedirs(dir_path)

    filename = 'exact_energy.csv'
    path = dir_path + filename

    # Try to load file
    # If data return
    E_dict = {}
    try:
        E_array = misc.load_array(path)
        E_dict = misc.nparray_2_dict(E_array)
        assert L in E_dict.keys()
        print("Found data")
    except Exception as error:
        print(error)
        energy = ed.get_E_exact(g, J, L, H)
        E_dict[L] = energy
        misc.save_array(path, misc.dict_2_nparray(E_dict))
        # If no data --> generate data
        print("Save new data")
Esempio n. 3
0
if __name__ == '__main__':
    L = int(sys.argv[1])
    g = float(sys.argv[2])
    order = str(sys.argv[3])
    Hamiltonian = 'XXZ'

    plt.close()
    fig=plt.figure(figsize=(6,8))

    ############################################
    dir_path = 'data/1d_%s_g%.1f/' % (Hamiltonian, g)
    filename = 'exact_energy.csv'
    path = dir_path + filename
    # Try to load file 
    # If data return
    exact_E_array = misc.load_array(path)
    exact_E_dict = misc.nparray_2_dict(exact_E_array)
    exact_E = exact_E_dict[L]
    print("Found exact energy data")

    circuit_num_para = []
    circuit_dE = []

    for depth in [1, 2, 3, 4]:
        E_list = []
        for N_iter in [1, 2, 10]:
            try:
                dir_path = 'data/1d_%s_g%.1f/' % (Hamiltonian, g)
                filename = 'circuit_depth%d_Niter%d_%s_energy.csv' % (depth, N_iter, order)
                path = dir_path + filename
                # Try to load file 
Esempio n. 4
0
if __name__ == '__main__':
    L = int(sys.argv[1])
    g = float(sys.argv[2])
    order = str(sys.argv[3])
    Hamiltonian = 'XXZ'

    plt.close()
    fig = plt.figure(figsize=(6, 8))

    ############################################
    dir_path = 'data/1d_%s_g%.1f/' % (Hamiltonian, g)
    filename = 'exact_energy.csv'
    path = dir_path + filename
    # Try to load file
    # If data return
    exact_E_array = misc.load_array(path)
    exact_E_dict = misc.nparray_2_dict(exact_E_array)
    exact_E = exact_E_dict[L]
    print("Found exact energy data")

    for chi in [2, 4]:
        dir_path = 'data/1d_%s_g%.1f/' % (Hamiltonian, g)
        filename = 'mps_chi%d_%s_energy.csv' % (chi, order)
        path = dir_path + filename
        mps_E_array = misc.load_array(path)
        mps_E_dict = misc.nparray_2_dict(mps_E_array)
        mps_E = mps_E_dict[L]
        print("Found mps data")

        filename = 'dmrg_chi%d_energy.csv' % chi
        path = dir_path + filename