Exemplo n.º 1
0
def multi_particle_interaction_energy_matrix_const_lz(Mmin, Mmax, N, H_2_particles, lz_val):
    basis_list = GA.create_basis_annulus_const_lz(Mmin, Mmax, N, lz_val)
    state2index = GA.state_index_dict(basis_list)

    MB_dim = len(basis_list)

    max_num_non_zero_entries = int(maximal_num_non_zero_elements_in_col_interacting(Mmin, Mmax, N) * MB_dim)
    row_total = np.zeros(shape=max_num_non_zero_entries, dtype=int)
    col_total = np.zeros(shape=max_num_non_zero_entries, dtype=int)
    mat_elements_total = np.zeros(shape=max_num_non_zero_entries, dtype=complex)
    index = 0

    for m in range(MB_dim):
        vec = basis_list[m]
        row, col, mat_elements = colum_in_interaction_matrix(m, vec, state2index, H_2_particles, Mmin)

        chunk_size = len(row)

        row_total[index:index + chunk_size] = row
        col_total[index:index + chunk_size] = col
        mat_elements_total[index:index + chunk_size] = mat_elements
        index = index + chunk_size

    if index < max_num_non_zero_entries:
        row_total = row_total[:index]
        col_total = col_total[:index]
        mat_elements_total = mat_elements_total[:index]
    mat_elements_total = 2 * mat_elements_total

    return row_total, col_total, mat_elements_total
Exemplo n.º 2
0
def multi_particle_interaction_energy_matrix(Mmin, Mmax, N, H_2_particles):
    basis_list = GA.create_basis_annulus(Mmin, Mmax, N)
    print("Size of hilbert space: " + str(len(basis_list)))
    MB_dim = len(basis_list)

    max_num_non_zero_entries = int(maximal_num_non_zero_elements_in_col_interacting(Mmin, Mmax, N) * MB_dim)
    row_total = np.zeros(shape=max_num_non_zero_entries, dtype=int)
    col_total = np.zeros(shape=max_num_non_zero_entries, dtype=int)
    mat_elements_total = np.zeros(shape=max_num_non_zero_entries, dtype=complex)
    index = 0

    state2index = GA.state_index_dict(basis_list)

    for m in range(MB_dim):
        vec = basis_list[m]
        row, col, mat_elements = colum_in_interaction_matrix(m, vec, state2index, H_2_particles, Mmin)
        chunk_size = len(row)

        row_total[index:index + chunk_size] = row
        col_total[index:index + chunk_size] = col
        mat_elements_total[index:index + chunk_size] = mat_elements
        index = index + chunk_size
    print("index = " + str(index))
    print("max estimation = " + str(max_num_non_zero_entries))
    if index < max_num_non_zero_entries:
        row_total = row_total[:index]
        col_total = col_total[:index]
        mat_elements_total = mat_elements_total[:index]

    mat_elements_total = 2 * mat_elements_total

    # V = sparse.coo_matrix((mat_elements_total, (row_total, col_total)), shape=(MB_dim, MB_dim))
    # V = V.tocsr()
    # return 2 * V
    return row_total, col_total, mat_elements_total
def unite_matrix_pieces(MminL,
                        MmaxL,
                        edge_states,
                        N,
                        lz_val,
                        matrix_label,
                        matrix_name,
                        output=1):
    args = [MminL, MmaxL, edge_states, N, lz_val, matrix_label]
    directory = FM.filename_matrix_pieces_directory(matrix_name, args)
    all_sliced_files = [
        f[:-4].split('_') for f in os.listdir(directory) if f[-4:] == '.npz'
    ]
    slices = [[int(f[0]), int(f[2])] for f in all_sliced_files]

    Mmin = MminL - edge_states
    Mmax = MmaxL + edge_states
    hilbert_size = GA.size_of_hilbert_space(Mmin, Mmax, N, lz_val)
    if matrix_name == 'interactions':
        max_num_nnz = LCA.maximal_num_non_zero_elements_in_col_interacting(
            Mmin, Mmax, N) * hilbert_size
        max_num_nnz = int(max_num_nnz)
    else:
        max_num_nnz = GA.maximal_num_non_zero_per_row_non_interacting(
            Mmin, Mmax, N) * hilbert_size
        max_num_nnz = int(max_num_nnz)

    row_total = np.zeros(shape=max_num_nnz, dtype=int)
    col_total = np.zeros(shape=max_num_nnz, dtype=int)
    mat_elements_total = np.zeros(shape=max_num_nnz, dtype=complex)
    index = 0

    for slice in slices:
        row, col, matrix_elements = FM.read_matrix_piece(
            matrix_name, args, slice)
        chunk_size = len(row)

        row_total[index:index + chunk_size] = row
        col_total[index:index + chunk_size] = col
        mat_elements_total[index:index + chunk_size] = matrix_elements
        index = index + chunk_size

    if index < max_num_nnz:
        row_total = row_total[:index]
        col_total = col_total[:index]
        mat_elements_total = mat_elements_total[:index]

    FM.write_complete_matrix(matrix_name, args, row_total, col_total,
                             mat_elements_total)
    if output:
        return row_total, col_total, mat_elements_total
    return 0
Exemplo n.º 4
0
def create_relevant_basis_list():
    """
    doesn't work with external set of lz_val
    If necessary, will add later
    :return:
    """
    if params.basis_list_queue == 'P' or params.basis_list_queue == 'M':
        JS.limit_num_threads(4)
    if params.lz_val == 'not_fixed':
        basis_list = GA.create_basis_annulus(Mmin, Mmax, params.N)
    else:
        basis_list = GA.create_basis_annulus_const_lz(Mmin, Mmax, params.N,
                                                      params.lz_val)
    return 0
def create_complete_matrix(MminL,
                           MmaxL,
                           edge_states,
                           N,
                           lz_val,
                           matrix_label,
                           matrix_name,
                           output='matrix'):
    args = [MminL, MmaxL, edge_states, N, lz_val, matrix_label]
    filename_matrix = FM.filename_complete_matrix(matrix_name, args)
    if EC.does_file_really_exist(filename_matrix):
        if output:
            row, col, mat_elements = FM.read_complete_matrix(matrix_name, args)
            return row, col, mat_elements
        return 0

    Mmin = MminL - edge_states
    Mmax = MmaxL + edge_states
    if matrix_name == 'interactions':
        if matrix_label[:8] == 'toy_flux':
            potential_type = matrix_label[:8]
            magnetic_flux = float(matrix_label[9:])
            H_2_particles = LCA.extract_two_particle_hamiltonian(
                Mmin, Mmax, potential_type, magnetic_flux)
        else:
            potential_type = matrix_label
            H_2_particles = LCA.extract_two_particle_hamiltonian(
                Mmin, Mmax, potential_type)

        if lz_val == 'not_fixed':
            row, col, mat_elements = LCA.multi_particle_interaction_energy_matrix(
                Mmin, Mmax, N, H_2_particles)
        else:
            row, col, mat_elements = LCA.multi_particle_interaction_energy_matrix_const_lz(
                Mmin, Mmax, N, H_2_particles, lz_val)

    else:
        single_particle_operator = SPA.create_single_particle_operator(
            MminL, MmaxL, edge_states, matrix_label, matrix_name)
        if lz_val == 'not_fixed':
            row, col, mat_elements = GA.bilinear_operator_N_particle_subspace(
                Mmin, Mmax, N, single_particle_operator)
        else:
            row, col, mat_elements = GA.bilinear_operator_N_particle_subspace_fixed_lz(
                Mmin, Mmax, N, single_particle_operator, lz_val)
    FM.write_complete_matrix(matrix_name, args, row, col, mat_elements)
    if output:
        return row, col, mat_elements
    return 0
def extract_complete_matrix(MminL,
                            MmaxL,
                            edge_states,
                            N,
                            lz_val,
                            matrix_label,
                            matrix_name,
                            run_on_cluster=1):
    args = [MminL, MmaxL, edge_states, N, lz_val, matrix_label]
    matrix_filename = FM.filename_complete_matrix(matrix_name, args)
    hilbert_space_dim = GA.size_of_hilbert_space(MminL - edge_states,
                                                 MmaxL + edge_states, N,
                                                 lz_val)
    if EC.does_file_really_exist(matrix_filename):
        row, col, mat_elements = FM.read_complete_matrix(matrix_name, args)
    else:

        if run_on_cluster:
            print("matrix should have been created by now. you have a bug!")
            return 0
        row, col, mat_elements = create_complete_matrix(
            MminL, MmaxL, edge_states, N, lz_val, matrix_label, matrix_name)

    matrix = sparse.coo_matrix((mat_elements, (row, col)),
                               shape=(hilbert_space_dim, hilbert_space_dim),
                               dtype=complex)
    matrix = matrix.tocsr()
    return matrix
Exemplo n.º 7
0
def find_basis_terms_from_vecs(vecs, Mmin, Mmax, N):
    basis_list = GA.create_basis_annulus(Mmin, Mmax, N)
    inds = [0] * len(vecs)
    basis_terms = []
    for i in range(len(vecs)):
        inds[i] = np.where(vecs[i] == 1)[0][0]
        basis_terms.append(basis_list[inds[i]])
    return basis_terms, inds
def extract_Hamiltonian(MminL,
                        MmaxL,
                        edge_states,
                        N,
                        lz_val,
                        hamiltonian_labels,
                        parameters,
                        run_on_cluster=1):
    # [interactions_label,confining_potential_label,SC_label,FM_label],[interactions_parameter,confining_potential_parameter,SC_parameter,FM_parameter]

    hamiltonian_terms_names = [
        'interactions', 'confining_potential', 'SC_term', 'FM_term'
    ]

    Mmin = MminL - edge_states
    Mmax = MmaxL + edge_states
    hilbert_space_dim = GA.size_of_hilbert_space(Mmin, Mmax, N, lz_val)

    hamiltonian = sparse.csr_matrix((hilbert_space_dim, hilbert_space_dim),
                                    dtype=complex)

    for i in range(len(hamiltonian_labels)):
        if hamiltonian_labels[i] != 'None':
            args = [
                MminL, MmaxL, edge_states, N, lz_val, hamiltonian_labels[i]
            ]
            filename_ham_term = FM.filename_complete_matrix(
                hamiltonian_terms_names[i], args)
            if EC.does_file_really_exist(filename_ham_term):
                row, col, mat_elements = FM.read_complete_matrix(
                    hamiltonian_terms_names[i], args)
            else:

                if run_on_cluster:
                    print(
                        "matrix should have been created by now. you have a bug!"
                    )
                    return 0
                else:
                    row, col, mat_elements = create_complete_matrix(
                        MminL, MmaxL, edge_states, N, lz_val,
                        hamiltonian_labels[i], hamiltonian_terms_names[i])

            mat_elements = parameters[i] * mat_elements

            ham_term = sparse.coo_matrix(
                (mat_elements, (row, col)),
                shape=(hilbert_space_dim, hilbert_space_dim),
                dtype=complex)
            ham_term = ham_term.tocsr()

            hamiltonian = hamiltonian + ham_term
    return hamiltonian
def get_low_lying_spectrum(MminL,
                           MmaxL,
                           edge_states,
                           N,
                           lz_val,
                           hamiltonian_labels,
                           parameters,
                           params_filename,
                           run_on_cluster=1):
    params = ParametersAnnulus(params_filename)
    if lz_val != 'not_fixed':
        lz_val = int(float(lz_val))
    filename_spectrum = FM.filename_spectrum_eigenstates(
        MminL, MmaxL, edge_states, N, lz_val, hamiltonian_labels, parameters)
    if EC.does_file_really_exist(filename_spectrum):
        spectrum = FM.read_spectrum_eigenstates(MminL, MmaxL, edge_states, N,
                                                lz_val, hamiltonian_labels,
                                                parameters)
        size_hilbert_space = GA.size_of_hilbert_space(MminL - edge_states,
                                                      MmaxL + edge_states, N,
                                                      lz_val)
        if len(
                spectrum
        ) >= params.num_of_eigstates or size_hilbert_space <= params.num_of_eigstates:
            return spectrum

    hamiltonian = extract_Hamiltonian(MminL, MmaxL, edge_states, N, lz_val,
                                      hamiltonian_labels, parameters,
                                      run_on_cluster)
    spectrum = calc_eigenVals_Vecs(hamiltonian, params.num_of_eigstates)
    if params.eigenstates_cutoff:
        print("eigenstates_cutoff")
        eig_spectrum_new1 = spectrum[:params.eigenstates_cutoff]

        eig_spectrum_new2 = [
            (spectrum[i][0], [])
            for i in range(params.eigenstates_cutoff, len(spectrum))
        ]
        spectrum = eig_spectrum_new1 + eig_spectrum_new2
    FM.write_spectrum_eigenstates(MminL, MmaxL, edge_states, N, lz_val,
                                  hamiltonian_labels, parameters, spectrum)
    return spectrum
Exemplo n.º 10
0
def create_all_basis():
    basis_list_all = GA.create_basis_annulus(Mmin, Mmax, params.N)

    if params.lz_val == 'not_fixed':

        print("do nothing for now")
        # lz_tot_vals = LCA.find_all_lz_total_values(Mmin, Mmax, N)
        # for lz_val in lz_tot_vals:
        #     try:
        #         basis_lz = FM.read_basis_annulus_const_lz(Mmin, Mmax, N, lz_val)
        #     except FileNotFoundError:
        #
        #         basis_ind = [np.where(vec == 1)[0] for vec in basis_list_all]
        #         lz_vals = np.array([sum(vec_ind) + N * Mmin for vec_ind in basis_ind])
        #         basis_lz = basis_list_all[lz_vals == lz_val]
        #         basis_lz = np.array(basis_lz, dtype=bool)
        #         FM.write_basis_annulus_const_lz(Mmin, Mmax, N, lz_val, basis_lz)
        #         FM.write_size_of_hilbert_space(Mmin, Mmax, N, lz_val, len(basis_lz))
    else:
        # lz_val = int(float(lz_val))
        try:
            basis_lz = FM.read_basis_annulus_const_lz(Mmin, Mmax, params.N,
                                                      params.lz_val)
        except FileNotFoundError:

            basis_ind = [np.where(vec == 1)[0] for vec in basis_list_all]
            lz_vals = np.array(
                [sum(vec_ind) + params.N * Mmin for vec_ind in basis_ind])
            basis_lz = basis_list_all[lz_vals == params.lz_val]
            basis_lz = np.array(basis_lz, dtype=bool)

            FM.write_basis_annulus_const_lz(Mmin, Mmax, params.N,
                                            params.lz_val, basis_lz)
            FM.write_size_of_hilbert_space(Mmin, Mmax, params.N, params.lz_val,
                                           len(basis_lz))

    return 0
Exemplo n.º 11
0
params_filename = sys.argv[11]

Mmin = MminL - edge_states
Mmax = MmaxL + edge_states
params = ParametersAnnulus(params_filename)

JS.limit_num_threads()
if params.matrix_pieces_queue == 'P' or params.matrix_pieces_queue == 'M':
    JS.limit_num_threads(4)

"""
matrix_name in [interactions,FM_term,confining_potential,edge_correlation,density]
"""

if lz_val == 'not_fixed':
    basis_list = GA.create_basis_annulus(Mmin, Mmax, N)
else:
    lz_val = int(float(lz_val))
    basis_list = GA.create_basis_annulus_const_lz(Mmin, Mmax, N, lz_val)

state2index = GA.state_index_dict(basis_list)

if matrix_name == 'interactions':
    if matrix_label[:8] == 'toy_flux':
        potential_type = matrix_label[:8]
        magnetic_flux = float(matrix_label[9:])
        H_2_particles = LCA.extract_two_particle_hamiltonian(Mmin, Mmax, potential_type, magnetic_flux)
    else:
        potential_type = matrix_label
        H_2_particles = LCA.extract_two_particle_hamiltonian(Mmin, Mmax, potential_type)
Exemplo n.º 12
0
# Mmax = MmaxL + 1
phi_range = np.arange(0, 1.01, 0.01)
# confining_potential_name = 'space_quadratic_flux'
confining_potential_name = 'space_parabolic_flux'
# confining_potential_name = 'ang_m_lin_phi'
# confining_potential_name = 'exp_flux'
# hamil_lbls = ['None', confining_potential_name, 'None', 'None']
# parameters = [0.0, 1.0, 0.0, 0.0]
# filename = 'flux_IQH_1'
# genPF.create_generic_parameters_file_for_annulus_geo(filename, MminL, MmaxL, edge_states, N, 'not_fixed', 'None', 0.0,
#                                                      confining_potential_name, 1.0, 'None', 0.0)
# full_params_filename = FM.filename_parameters_annulus(filename)
# spectrum = AMAS.get_low_lying_spectrum(MminL, MmaxL, edge_states, N, 'not_fixed', hamil_lbls, parameters,
#                                        full_params_filename, 0)
# phi = 0.1
hilbert_space_dim = GA.size_of_hilbert_space(Mmin, Mmax, N, 'not_fixed')
print(hilbert_space_dim)
FM_term_name = 'spatial_edge_flux'
# FM_term_name = 'spatial33_flux'

full_spec = {}

for phi in phi_range:
    FM_term_single = SPA.FM_hamiltonian_term_single_particle(
        Mmin, Mmax, MminL, MmaxL, FM_term_name + '_' + str(phi))
    row, col, mat_elements = GA.bilinear_operator_N_particle_subspace(
        Mmin, Mmax, N, FM_term_single)
    FM_term_multi = sparse.coo_matrix(
        (mat_elements, (row, col)),
        shape=(hilbert_space_dim, hilbert_space_dim),
        dtype=complex)
def create_matrix_pieces(MminL, MmaxL, edge_states, N, lz_val, matrix_label,
                         matrix_name, params_filename):
    params = ParametersAnnulus(params_filename)
    common_args = [MminL, MmaxL, edge_states, N, lz_val, matrix_label]

    filename_complete_matrix = FM.filename_complete_matrix(
        matrix_name, common_args)
    if EC.does_file_really_exist(filename_complete_matrix):
        print("already created " + filename_complete_matrix)
        return 0

    queue = params.matrix_pieces_queue
    mem, vmem = JS.get_mem_vmem_vals(queue, params.matrix_pieces_mem,
                                     params.matrix_pieces_vmem)

    Mmin = MminL - edge_states
    Mmax = MmaxL + edge_states
    hilbert_space_size = GA.size_of_hilbert_space(Mmin, Mmax, N, lz_val)
    if hilbert_space_size < 10000:
        args = [matrix_name] + common_args
        str_args = [str(a) for a in args]
        str_args = '-'.join(str_args)
        filename_job = str_args
        JS.send_job(scriptNames.fullMBMatrix,
                    queue,
                    mem=mem,
                    vmem=vmem,
                    script_args=args,
                    pbs_filename=filename_job)
        return 0

    slice_size = int(hilbert_space_size / params.speeding_parameter)
    last_slice_size = hilbert_space_size - params.speeding_parameter * slice_size

    slice_start = 0
    slice_end = slice_size
    count_num_jobs_sent = 0
    for i in range(params.speeding_parameter):
        filename_args = [MminL, MmaxL, edge_states, N, lz_val, matrix_label]
        filename_martix_piece = FM.filename_matrix_piece(
            matrix_name, filename_args, [slice_start, slice_end - 1])
        if EC.does_file_really_exist(filename_martix_piece):
            print("matrix piece " + filename_martix_piece + " already exists!")
        else:
            count_num_jobs_sent = count_num_jobs_sent + 1
            args = [matrix_name] + common_args + [slice_start, slice_end] + [
                params.speeding_parameter, params_filename
            ]
            str_args = [str(a) for a in args]
            str_args = '-'.join(str_args[:-1])
            filename_job = str_args
            JS.send_job(scriptNames.piecesMBMatrix,
                        queue,
                        mem=mem,
                        vmem=vmem,
                        script_args=args,
                        pbs_filename=filename_job)
            sleep(2)
        slice_start = slice_start + slice_size
        slice_end = slice_end + slice_size
    # taking care of last slice
    if last_slice_size > 0:
        slice_end = slice_start + last_slice_size
        filename_args = [MminL, MmaxL, edge_states, N, lz_val, matrix_label]
        filename_martix_piece = FM.filename_matrix_piece(
            matrix_name, filename_args, [slice_start, slice_end - 1])
        if EC.does_file_really_exist(filename_martix_piece):
            print("matrix piece " + filename_martix_piece + " already exists!")
        else:
            count_num_jobs_sent = count_num_jobs_sent + 1
            args = [matrix_name] + common_args + [slice_start, slice_end] + [
                params.speeding_parameter, params_filename
            ]
            str_args = [str(a) for a in args]
            str_args = '-'.join(str_args[:-1])
            filename = str_args
            JS.send_job(scriptNames.piecesMBMatrix,
                        queue,
                        mem=mem,
                        vmem=vmem,
                        script_args=args,
                        pbs_filename=filename)

    if count_num_jobs_sent == 0:
        AMASW.unite_and_write_full_matrix(MminL, MmaxL, edge_states, N, lz_val,
                                          matrix_label, matrix_name,
                                          params_filename)
    return 0
def calc_luttinger_spectrum_big(params_filename, send_jobs=True, wait=False):
    params = ParametersAnnulus(params_filename)
    window_of_lz = 'all'

    filename_luttinger_spectrum = FM.filename_spectrum_luttinger_parm(
        params.MminLaughlin, params.MmaxLaughlin, params.edge_states, params.N,
        window_of_lz, params.hamiltonian_labels, params.h_parameters)
    if EC.does_file_really_exist(filename_luttinger_spectrum):
        print("full lut spectrum created already!")
        full_spectrum = graphData.plot_spectrum_graph_data_from_file(
            filename_luttinger_spectrum)
        return full_spectrum

    queue = params.spectrum_job_manager_queue
    mem, vmem = JS.get_mem_vmem_vals(queue, params.spectrum_job_manager_mem,
                                     params.spectrum_job_manager_vmem)
    Mmin = params.MminLaughlin - params.edge_states
    Mmax = params.MmaxLaughlin + params.edge_states

    first_arc_lz = np.array([params.lz_laughlin + i for i in range(params.N)])
    umbrella_lz = np.array([
        params.lz_laughlin - params.N * params.edge_states + params.N * i
        for i in range(2 * params.edge_states + 1)
    ])

    lz_vals_to_add_spectrum = np.concatenate((first_arc_lz, umbrella_lz))

    all_file_names = []
    for lz in lz_vals_to_add_spectrum:
        lz = int(lz)
        filename_lz_spectrum = FM.filename_spectrum_eigenstates(
            params.MminLaughlin, params.MmaxLaughlin, params.edge_states,
            params.N, lz, params.hamiltonian_labels, params.h_parameters)
        if EC.does_file_really_exist(filename_lz_spectrum):
            spectrum = FM.read_spectrum_eigenstates(
                params.MminLaughlin, params.MmaxLaughlin, params.edge_states,
                params.N, lz, params.hamiltonian_labels, params.h_parameters)
            size_hilbert_space = GA.size_of_hilbert_space(
                Mmin, Mmax, params.N, lz)
            if len(
                    spectrum
            ) >= params.num_of_eigstates or size_hilbert_space <= params.num_of_eigstates:
                # print("we did this lz spectrum calculation already!")
                a = "do nothing"
            else:
                if send_jobs:
                    sleep(2)
                    print("finding the spectrum")
                    args = [params_filename, lz]
                    args = args + ['spectrum_eigenstates_manager']
                    # job_name = 'spectrum_job_manager_' + params.params_filename_no_path
                    job_name = 'lut_spectrum_N=' + str(
                        params.N) + '_MminL=' + str(
                            params.MminLaughlin) + '_edges=' + str(
                                params.edge_states) + '_lz=' + str(lz)
                    job_name = EC.make_job_name_short_again(job_name)
                    JS.send_job(scriptNames.multiFile,
                                pbs_filename=job_name,
                                script_args=args,
                                queue=queue,
                                mem=mem,
                                vmem=vmem)

                all_file_names.append(filename_lz_spectrum)

        else:
            if send_jobs:
                sleep(2)
                print("finding the spectrum")
                args = [params_filename, lz]
                args = args + ['spectrum_eigenstates_manager']
                # job_name = 'spectrum_job_manager_' + params.params_filename_no_path
                job_name = 'lut_spectrum_N=' + str(params.N) + '_MminL=' + str(
                    params.MminLaughlin) + '_edges=' + str(
                        params.edge_states) + '_lz=' + str(lz)
                job_name = EC.make_job_name_short_again(job_name)
                JS.send_job(scriptNames.multiFile,
                            pbs_filename=job_name,
                            script_args=args,
                            queue=queue,
                            mem=mem,
                            vmem=vmem)

            all_file_names.append(filename_lz_spectrum)

    while not EC.all_files_exist(all_file_names):
        if not wait:
            print("not done creating spectrum! still must create " +
                  str(len(all_file_names)) + " out of " +
                  str(len(lz_vals_to_add_spectrum)))
            return
        sleep(100)

    lut_spectrum = {}
    for lz in lz_vals_to_add_spectrum:
        lz = int(lz)
        spec_states = FM.read_spectrum_eigenstates(
            params.MminLaughlin, params.MmaxLaughlin, params.edge_states,
            params.N, lz, params.hamiltonian_labels, params.h_parameters)
        spectrum = np.array(
            [spec_states[i][0] for i in range(len(spec_states))])
        print("***************")
        print(spectrum)
        lut_spectrum[lz] = spectrum

    title = 'Luttinger spectrum of system with N=' + str(
        params.N) + ' MminL=' + str(params.MminLaughlin) + ' MmaxL=' + str(
            params.MmaxLaughlin) + '\nham_lbls: ' + ' '.join(
                params.hamiltonian_labels) + '\nLz laughlin at ' + str(
                    params.lz_laughlin)
    xlabel = 'Lz total'
    ylabel = 'Energy'
    graphData.write_spectrum_data_to_file(filename_luttinger_spectrum,
                                          lut_spectrum, title, xlabel, ylabel)

    return lut_spectrum
def calc_full_low_lying_spectrum(params_filename,
                                 send_jobs=True,
                                 wait=False,
                                 lz_val_middle=None,
                                 parameters_external=None,
                                 window_of_lz='all'):
    params = ParametersAnnulus(params_filename)
    if not lz_val_middle:
        lz_val = params.lz_laughlin
    else:
        lz_val = lz_val_middle
    if parameters_external:
        parameters = parameters_external
    else:
        parameters = params.h_parameters

    filename_full_spectrum = FM.filename_full_spectrum(
        params.MminLaughlin, params.MmaxLaughlin, params.edge_states, params.N,
        window_of_lz, params.hamiltonian_labels, parameters)
    if EC.does_file_really_exist(filename_full_spectrum):
        full_spectrum = graphData.plot_spectrum_graph_data_from_file(
            filename_full_spectrum)
        return full_spectrum

    queue = params.spectrum_job_manager_queue
    mem, vmem = JS.get_mem_vmem_vals(queue, params.spectrum_job_manager_mem,
                                     params.spectrum_job_manager_vmem)
    Mmin = params.MminLaughlin - params.edge_states
    Mmax = params.MmaxLaughlin + params.edge_states

    lz_total_vals = LCA.find_all_lz_total_values(Mmin, Mmax, params.N)
    if window_of_lz == 'all':
        lz_min = lz_total_vals[0]
        lz_max = lz_total_vals[-1]

    else:
        lz_min = max(lz_val - window_of_lz, lz_total_vals[0])
        lz_max = min(lz_val + window_of_lz, lz_total_vals[-1])

    all_file_names = []
    for lz in range(lz_min, lz_max + 1):
        filename_lz_spectrum = FM.filename_spectrum_eigenstates(
            params.MminLaughlin, params.MmaxLaughlin, params.edge_states,
            params.N, lz, params.hamiltonian_labels, parameters)
        if EC.does_file_really_exist(filename_lz_spectrum):
            spectrum = FM.read_spectrum_eigenstates(
                params.MminLaughlin, params.MmaxLaughlin, params.edge_states,
                params.N, lz, params.hamiltonian_labels, parameters)
            size_hilbert_space = GA.size_of_hilbert_space(
                Mmin, Mmax, params.N, lz_val)
            if len(
                    spectrum
            ) >= params.num_of_eigstates or size_hilbert_space <= params.num_of_eigstates:
                print("we did this lz spectrum calculation already!")
            else:
                if send_jobs:
                    sleep(2)
                    print("finding the spectrum")
                    args = [params_filename, lz]
                    if parameters_external:
                        args = args + parameters_external
                    args = args + ['spectrum_eigenstates_manager']
                    # job_name = 'spectrum_job_manager_' + params.params_filename_no_path
                    job_name = 'full_spectrum_N=' + str(
                        params.N) + '_MminL=' + str(
                            params.MminLaughlin) + '_MmaxL=' + str(
                                params.MmaxLaughlin) + '_edges=' + str(
                                    params.edge_states)
                    job_name = EC.make_job_name_short_again(job_name)
                    JS.send_job(scriptNames.multiFile,
                                pbs_filename=job_name,
                                script_args=args,
                                queue=queue,
                                mem=mem,
                                vmem=vmem)

                all_file_names.append(filename_lz_spectrum)

        else:
            if send_jobs:
                sleep(2)
                print("finding the spectrum")
                args = [params_filename, lz]
                if parameters_external:
                    args = args + parameters_external
                args = args + ['spectrum_eigenstates_manager']
                # job_name = 'spectrum_job_manager_' + params.params_filename_no_path
                job_name = 'full_spectrum_N=' + str(
                    params.N) + '_MminL=' + str(
                        params.MminLaughlin) + '_MmaxL=' + str(
                            params.MmaxLaughlin) + '_edges=' + str(
                                params.edge_states)
                job_name = EC.make_job_name_short_again(job_name)
                JS.send_job(scriptNames.multiFile,
                            pbs_filename=job_name,
                            script_args=args,
                            queue=queue,
                            mem=mem,
                            vmem=vmem)

            all_file_names.append(filename_lz_spectrum)

    while not EC.all_files_exist(all_file_names):
        if not wait:
            print("not done creating spectrum!")
            return
        sleep(100)

    full_spectrum = {}
    print(range(lz_min, lz_max + 1))
    for lz in range(lz_min, lz_max + 1):
        spec_states = FM.read_spectrum_eigenstates(
            params.MminLaughlin, params.MmaxLaughlin, params.edge_states,
            params.N, lz, params.hamiltonian_labels, parameters)
        spectrum = np.array(
            [spec_states[i][0] for i in range(len(spec_states))])
        print("***************")
        print(spectrum)
        full_spectrum[lz] = spectrum

    title = 'low lying spectrum of system with N=' + str(
        params.N) + ' MminL=' + str(params.MminLaughlin) + ' MmaxL=' + str(
            params.MmaxLaughlin) + '\nham_lbls: ' + ' '.join(
                params.hamiltonian_labels) + '\nLz laughlin at ' + str(
                    params.lz_laughlin)
    xlabel = 'Lz total'
    ylabel = 'Energy'
    graphData.write_spectrum_data_to_file(filename_full_spectrum,
                                          full_spectrum, title, xlabel, ylabel)

    return full_spectrum