def plot_components(eigvec_file, eigval_file, bas_state_index, majorX = 50, majorY = 0.02, col="b-o"):
    ###
    '''LDOS Plots function
       Plot squared components in all eigenvectors of a bas_state_index basis element (min bas_state_index = 0) as a function of the state energy.''' 
    ###
    import numpy as np
    from matplotlib import pyplot
    from matplotlib.ticker import MultipleLocator, FormatStrFormatter
    #
    from survival_probability_basis import read_energy_data, read_eigenstates
    #
    #
    eigstates=read_eigenstates(eigvec_file)
    eigvals= read_energy_data(eigval_file)
    #
    #
    majorXLocator   = MultipleLocator(majorX)
    majorYLocator   = MultipleLocator(majorY)
    #
    ##    for bas_state in range(0,4):
    components = eigstates[bas_state_index,:]  ## Components of a given basis element in all eigenstates
    ##
    panel = pyplot.subplot(1, 1, 1)
    panel.tick_params(axis='both', which='major', labelsize=14)
    pyplot.plot(eigvals,components**2,col)
    ##
    panel.xaxis.set_major_locator(majorXLocator)
    panel.yaxis.set_major_locator(majorYLocator)
    ##
    ##
    ##    pyplot.annotate(bas_state, xy=(30, 0.07))
    pyplot.xlabel("Energy")
    pyplot.ylabel("Squared Eigenvector Components")
    panel.xaxis.label.set_fontsize(18)
    panel.yaxis.label.set_fontsize(18)
def hist_components(eigvec_file, basis_index, energy_file, N_value = 1, bins = 20, fig=False):
    ###
    '''Histogram of the squared components of the index-th basis state in the system eigenvectors 
       (min value = 0) as a function of the system eigenvalues.

       Options: 

           bins    : number of bins in the histogram
           N_value : renormalize by the system size
           fig     : plot bar fig

           '''
    #
    import numpy as np
    from matplotlib import pyplot
    from matplotlib.ticker import MultipleLocator, FormatStrFormatter
    #
    from survival_probability_basis import read_eigenstates, read_energy_data
    #
    #
    eigstates=read_eigenstates(eigvec_file)
    ##
    eigenvalues = read_energy_data(energy_file)/N_value
    #
    ## Energy bins
    energy_bins=np.linspace(eigenvalues[0], eigenvalues[-1],num = bins)
    col_values = np.zeros(len(energy_bins)) # Initialize histogram values
    #
    ## Basis state components
    components = eigstates[basis_index,:]**2   
    #
    columns = np.zeros(bins)
    ###
    idx = 0
    for index_bin in range(1,bins):
        #
        for aval_index in range(idx, len(eigenvalues)+1):
            #
            energy = eigenvalues[aval_index]
            #
            if (energy < energy_bins[index_bin]):
                columns[index_bin] = columns[index_bin] + components[aval_index]
                idx = idx + 1
            else:
                break
    #
    # Define bar centroids
    wdth = (energy_bins[1]-energy_bins[0])
    lngth = bins - 1
    centroids = energy_bins + wdth/2
    ##
    if (fig):
        figure = pyplot.figure()
        ax = pyplot.subplot(111)
        ax.bar(centroids[:lngth], columns[:lngth],width=wdth,alpha=0.5)
    ##
    return centroids[:lngth], columns[:lngth]
def plot_components(eigvec_file,
                    eigval_file,
                    bas_state_index,
                    majorX=50,
                    majorY=0.02,
                    col="b-o"):
    ###
    '''LDOS Plots function
       Plot squared components in all eigenvectors of a bas_state_index basis element (min bas_state_index = 0) as a function of the state energy.'''
    ###
    import numpy as np
    from matplotlib import pyplot
    from matplotlib.ticker import MultipleLocator, FormatStrFormatter
    #
    from survival_probability_basis import read_energy_data, read_eigenstates
    #
    #
    eigstates = read_eigenstates(eigvec_file)
    eigvals = read_energy_data(eigval_file)
    #
    #
    majorXLocator = MultipleLocator(majorX)
    majorYLocator = MultipleLocator(majorY)
    #
    ##    for bas_state in range(0,4):
    components = eigstates[
        bas_state_index, :]  ## Components of a given basis element in all eigenstates
    ##
    panel = pyplot.subplot(1, 1, 1)
    panel.tick_params(axis='both', which='major', labelsize=14)
    pyplot.plot(eigvals, components**2, col)
    ##
    panel.xaxis.set_major_locator(majorXLocator)
    panel.yaxis.set_major_locator(majorYLocator)
    ##
    ##
    ##    pyplot.annotate(bas_state, xy=(30, 0.07))
    pyplot.xlabel("Energy")
    pyplot.ylabel("Squared Eigenvector Components")
    panel.xaxis.label.set_fontsize(18)
    panel.yaxis.label.set_fontsize(18)
Esempio n. 4
0
diag_energies_so3 = energy_basis_so3(Nval,np.arange(0,Nval+1,2),0,0.6)

E0 = 366.56652341623544 # N = 2000, L = 0, xi = 0.6

diag_energies_so3 = (diag_energies_so3-E0)/Nval

vvec = (Nval-np.arange(0,Nval+1,2))/2

np.savetxt("fig_ebasis_so3_xi06.dat", np.transpose([vvec, diag_energies_so3]))


wvec = (np.arange(0,Nval+1,2))

np.savetxt("fig_ebasis_so3_xi06.dat", np.transpose([wvec, diag_energies_so3]))

eigenvalues = read_energy_data("../test/eigval_so3_N2000_L0.dat")

diffvec = diag_energies_so3-sep(0.6)

np.abs(diffvec).argmin()
#Out[16]: 578

n=0
cent,bar = hist_components_LDOS("../test/eigvec_so3_N2000_L0.dat", n, "../test/eigval_so3_N2000_L0.dat",N_value=2000, bins=40, OutputCentroid=True, fig=False)
#
diag = hist_components_LDOS("../test/eigvec_so3_N2000_L0.dat", n, "../test/eigval_u2_N2000_L0.dat",N_value=2000, bins=40, OutputCentroid=False, fig=True)
#
np.savetxt("hist_w"+str(n)+"_cent_xi06_N2000_so3.dat",np.transpose(np.array([cent,bar])))
#
np.savetxt("hist_w"+str(n)+"_shape_xi06_N2000_so3.dat",diag)
#time_grid = np.linspace( 0.0, t_max, dim_t)
## Variable length grids
t_max = 60.;dim_t = 5000
time_grid = np.zeros(dim_t+1)
for index in np.arange(0,dim_t+1):
    time_grid[index] = t_max*index**3/dim_t**3

# Basis states indexes (start in 1)  -1 --> Closest to separatrix 
basis_states_indexes = [-1] 
###########################################
#  End of Defs  ## Edit only this section #
###########################################
#
print "N = ", Nval, ", L = ", Lval, ", xi = ", xi
## Read eigenvalues (absolute eigenvalues) and eigenvectors
Eigenvalues = read_energy_data("../../test/eigval_"+basis+"_N"+str(Nval)+"_L"+str(Lval)+".dat")
Eigenstates = read_eigenstates("../../test/eigvec_"+basis+"_N"+str(Nval)+"_L"+str(Lval)+".dat")
E0 = Eigenvalues[0]
Eigenvalues = Eigenvalues - E0 # Escitation energies
# Computing survival probability
print "Computing survival probability ... "
#
sp=np.zeros((time_grid.shape[0],len(basis_states_indexes)+1),order="F") # +1 for the abscyssa values
#
for index, index_state in enumerate(basis_states_indexes):
    if (index == -1):
        # Find basis state close to separatrix
        if basis is "u3":
            basisen = energy_basis_I(Nval,np.arange(0,Nval+1,2), Lval, xi)
        else:
            basisen = energy_basis_II(Nval,np.arange(0,Nval+1,2), Lval, xi)
Esempio n. 6
0
N_value = 500
l_value = 0
xi_value = 0.4
##eigenvectors = "../test/eigvec_so3_xi04_N500_L0.dat"
eigenvectors = "../test/eigvec_u2_xi04_N500_L0.dat"
##eigenvalues = "../test/energy_so3_xi_04_N500_L0.dat"
eigenvalues = "../test/energy_u2_xi_04_N500_L0.dat"
#
## time_max = 16
## time_points = 300
time_max = 0.5
time_points = 200
nvals = np.arange(0, N_value + 2, 2)
#
eigstates = read_eigenstates(eigenvectors)
eigvals = read_energy_data(eigenvalues)
#
time_grid = np.linspace(0.0, time_max, time_points)
spb = survival_probability_basis_states(eigvals,
                                        eigstates,
                                        1,
                                        N_value / 2 + 1,
                                        t_max=time_max,
                                        dim_t=time_points)
#
##majorXLocator   = MultipleLocator(5)
##majorXFormatter = FormatStrFormatter('%d')
majorXLocator = MultipleLocator(0.2)
majorXFormatter = FormatStrFormatter('%3.1f')
#
fig, axes = pyplot.subplots(5, 5, sharex=True, sharey=True)
time_grid = np.linspace(0.0, t_max, dim_t)
## Variable length grids
#t_max = 5.;dim_t = 5000
#time_grid = np.zeros(dim_t+1)
#for index in np.arange(0,dim_t+1):
#    time_grid[index] = (t_max*index**3/dim_t**3)

# Basis states indexes (start in 1)  -1 --> Closest to separatrix
basis_states_indexes = [-1]
###########################################
#  End of Defs  ## Edit only this section #
###########################################
#
print "N = ", Nval, ", L = ", Lval, ", xi = ", xi
## Read eigenvalues (absolute eigenvalues) and eigenvectors
Eigenvalues = read_energy_data("../test/eigval_" + basis + "_N" + str(Nval) +
                               "_L" + str(Lval) + ".dat")
Eigenstates = read_eigenstates("../test/eigvec_" + basis + "_N" + str(Nval) +
                               "_L" + str(Lval) + ".dat")
E0 = Eigenvalues[0]
Eigenvalues = Eigenvalues - E0  # Excitation energies
# Computing survival probability
print "Computing survival probability ... "
#
sp = np.zeros((time_grid.shape[0], len(basis_states_indexes) + 1),
              order="F")  # +1 for the abscyssa values
#
for index, index_state in enumerate(basis_states_indexes):
    if (index_state == -1):
        # Find basis state close to separatrix
        if basis is "u2":
            basisen = energy_basis_u2(Nval, np.arange(Lval, Nval + 1, 2), Lval,
N_value = 500
l_value = 0
xi_value = 0.4
##eigenvectors = "../test/eigvec_so3_xi04_N500_L0.dat"
eigenvectors = "../test/eigvec_u2_xi04_N500_L0.dat"
##eigenvalues = "../test/energy_so3_xi_04_N500_L0.dat"
eigenvalues = "../test/energy_u2_xi_04_N500_L0.dat"
#
## time_max = 16
## time_points = 300
time_max = 0.5
time_points = 200
nvals = np.arange(0, N_value + 2, 2)
#
eigstates=read_eigenstates(eigenvectors)
eigvals= read_energy_data(eigenvalues)
#
time_grid = np.linspace( 0.0, time_max, time_points)
spb = survival_probability_basis_states(eigvals, eigstates, 1, N_value/2 + 1, t_max = time_max, dim_t = time_points)
#
##majorXLocator   = MultipleLocator(5)
##majorXFormatter = FormatStrFormatter('%d')
majorXLocator   = MultipleLocator(0.2)
majorXFormatter = FormatStrFormatter('%3.1f')
#
fig,axes = pyplot.subplots(5,5,sharex=True,sharey=True)
#
pyplot.xlim(0,time_max)
pyplot.ylim(0,1)
#
for index_i in np.arange(0,5):
def hist_components_LDOS(eigvec_file, basis_state, energy_file, ExcE = True, N_value = 1, bins = 20, OutputCentroid = False, fig=False, iprint=0):
    ###
    '''LDOS Plot: Histogram of the squared components of a basis state as a function of
       the system eigenvectors (min basis state value = 0) and as a function of the system eigenvalues.

       Options: 
           ExcE    : Transform energy_file to excitation energies. Default value True
           N_value : renormalize by the system size (N_value = N)
           bins    : number of bins in the histogram
           OutputCentroid : If True outputs the centroid value for the bardiagram.
           fig     : plot bar fig (pyplot.show())
           iprint  : control verbosity

           '''
    #
    import numpy as np
    from matplotlib import pyplot
    from matplotlib.ticker import MultipleLocator, FormatStrFormatter
    #
    from survival_probability_basis import read_eigenstates, read_energy_data
    #
    #
    eigstates=read_eigenstates(eigvec_file)
    ##
    eigenvalues = read_energy_data(energy_file)
    if (ExcE):
        E0 = eigenvalues[0]
        eigenvalues = eigenvalues - E0
    #
    eigenvalues = eigenvalues/N_value
    ## Energy bins
    energy_bins=np.linspace(eigenvalues[0], eigenvalues[-1],num = bins+1)
    if (iprint > 0):
        print "Energy bins = ", energy_bins
    #
    ## Basis state components
    components = eigstates[basis_state,:]**2   
    #
    columns = np.zeros(bins)
    ###
    idx = 0
    for index_bin in range(1,bins+1):
        #
        if (iprint > 0):
            print "bin index = ", index_bin, " of ", bins
        for aval_index in range(idx, len(eigenvalues)+1):
            #
            energy = eigenvalues[aval_index]
            if (iprint > 0):
                print "aval_index, energy = ", aval_index, energy
            #
            if (energy < energy_bins[index_bin]):
                columns[index_bin-1] = columns[index_bin-1] + components[aval_index]
                idx = idx + 1
                if (iprint > 0):
                    print "idx = ", idx, "col = ", columns[index_bin-1]
            else:
                if (iprint > 0):
                    print "BREAK", index_bin, aval_index
                break
    # Sum last component
    columns[index_bin-1] = columns[index_bin-1] + components[aval_index]
    if (iprint > 0):
        print "Columns = ", columns
    # Define bar centroids
    wdth = (energy_bins[1]-energy_bins[0])
    lngth = bins
    centroids = energy_bins + wdth/2.
    ##
    if (fig):
        figure = pyplot.figure()
        ax = pyplot.subplot(111)
        ax.bar(centroids[:lngth], columns[:lngth],width=wdth,alpha=0.5)
    ##
    if (OutputCentroid):
        return centroids[:lngth], columns[:lngth]
    else:
        output_data = np.zeros([2*bins+1,2]) # +1 to close the block diagram
        output_data[0,0] = energy_bins[0]
        output_data[0,1] = columns[0]
        #
        icount = 1
        for index_bin in range(1,bins):
            output_data[icount,0] = energy_bins[index_bin]
            output_data[icount,1] = columns[index_bin-1]
            output_data[icount+1,0] = energy_bins[index_bin]
            output_data[icount+1,1] = columns[index_bin]
            icount = icount + 2
        #   
        output_data[icount,0] = energy_bins[-1]
        output_data[icount,1] = columns[-1]
        output_data[icount+1,0] = energy_bins[-1]
        output_data[icount+1,1] = 0.0
        return output_data