using SparseArrays
using LinearAlgebra
using Arpack
using Plots
using LatticeTools
using ExactDiagonalization
println("# S=1/2 Heisenberg Chain")
n_sites = 8;
(hs, σ) = ExactDiagonalization.Toolkit.spin_half_system(n_sites)
println("Quantum number sectors (2Sz) : ", quantum_number_sectors(hs))
S = Dict(μ => sum(σ(i, μ) for i in 1:n_sites) for μ in [:x, :y, :z])
spin_squared = simplify(S[:x]^2 + S[:y]^2 + S[:z]^2)
j1 = simplify(sum(σ(i, j) * σ(mod(i, n_sites)+1 , j) for i in 1:n_sites for j in [:x, :y, :z]))
hs_rep = represent(hs); # Use FrozenSortedArrayIndex{UInt} for basis lookup
println("## All sectors at once")
plt = plot(size=(400, 400))
begin
j1_rep = represent(hs_rep, j1)
eigenvalues, eigenvectors = eigs(j1_rep; nev=32, which=:SR, )
eigenvalues = real.(eigenvalues)
println("E : ", eigenvalues[1:5])
scatter!(plt,
zeros(size(eigenvalues)), eigenvalues,
markershape=:hline,
markersize=10,
markerstrokecolor=:red,
legend=:none)
end
println("## Sz=0, each momentum sectors")
hs_sector = HilbertSpaceSector(hs, 0)
hs_rep = represent_dict(hs_sector) # Use Dict{UInt, Int} for basis lookup
unitcell = make_unitcell(1.0; SiteType=String)
addsite!(unitcell, "Spin", FractCoord([0], [0.0]))
lattice = make_lattice(unitcell, 8)
tsymbed = translation_symmetry_embedding(lattice)
#translation_group = TranslationGroup([Permutation([ mod(i, n_sites)+1 for i in 1:n_sites])])
ks = symmetry(tsymbed).fractional_momenta
for tsic in get_irrep_components(tsymbed)
k = ks[tsic.irrep_index]
hs_redrep = symmetry_reduce(hs_rep, tsic)
j1_redrep = represent(hs_redrep, j1)
j1_redrep_dense = Matrix(j1_redrep) # Make a dense matrix
eigenvalues = eigvals(Hermitian(j1_redrep_dense))
println("E(k=", join(string.(k), ","), ") : ", eigenvalues[1:5])
scatter!(plt,
ones(size(eigenvalues)).*tsic.irrep_index, eigenvalues,
markershape=:hline,
markersize=10,
markerstrokecolor=:blue,
legend=:none)
end
xticks!(plt, collect(0:n_sites), ["All", string.(1:n_sites)...])
xlims!(plt, -1, n_sites+1)
xlabel!(plt, "Momentum index")
ylabel!(plt, "Energy")
savefig(plt, "spinchain.svg"); nothing
# S=1/2 Heisenberg Chain
Quantum number sectors (2Sz) : [(-8,), (-6,), (-4,), (-2,), (0,), (2,), (4,), (6,), (8,)]
## All sectors at once
E : [-14.604373635748694, -12.513676255378352, -12.513676255378327, -12.513676255378277, -10.798512593101288]
## Sz=0, each momentum sectors
┌ Warning: Assignment to `eigenvalues` in soft scope is ambiguous because a global variable by the same name exists: `eigenvalues` will be treated as a new local. Disambiguate by using `local eigenvalues` to suppress this warning or `global eigenvalues` to assign to the existing global variable.
└ @ none:7
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=0//1) : [-14.604373635748708, -7.207750943219354, -4.000000000000003, -2.90443778014313, -1.780167471650515]
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=1//8) : [-9.834954035579337, -4.576491222541476, -2.5135137075322467, -2.0507328122554993, -1.17157287525381]
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=1//4) : [-7.418550718873841, -6.472135954999586, -5.068140393445466, -2.387873132949262, -1.0346080900166121]
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=3//8) : [-8.580593495682864, -6.828427124746191, -3.435694198841033, -1.7480640977952835, 1.0618108463019815]
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=1//2) : [-12.513676255378304, -10.798512593101272, -4.806558702893615, -3.043506886973782, 5.962399532906195e-16]
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=5//8) : [-8.580593495682873, -6.828427124746188, -3.4356941988410337, -1.7480640977952835, 1.0618108463019815]
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=3//4) : [-7.418550718873841, -6.472135954999586, -5.068140393445466, -2.387873132949262, -1.0346080900166121]
┌ Warning: Method deprecated. use simpler symmetry_reduce functions that takes symops_and_amplitudes as input
└ @ ExactDiagonalization ~/work/ExactDiagonalization.jl/ExactDiagonalization.jl/src/Symmetry/symmetry_reduce_translation.jl:16
E(k=7//8) : [-9.834954035579331, -4.576491222541474, -2.5135137075322467, -2.0507328122554993, -1.1715728752538095]
/home/runner/.julia/packages/GR/RlE5Y/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
