H ψ = E ψ Introduction to Exact Diagonalization Andreas Läuchli, New states of quantum matter MPI für Physik komplexer Systeme - Dresden http://www.pks.mpg.de/~aml laeuchli@comp-phys.org Simulations of Quantum Many Body Systems - Lecture Spring 2010
Outline of Today s Lecture (part 2 of 3) Introduction to Exact Diagonalization (part 2) Symmetries revisited Hamiltonian Matrix Linear Algebra Observables Parallelization Literature Example
Structure of an Exact Diagonalization code
Ingredients
Ingredients Hilbert space
Ingredients Hilbert space Basis represention, Lookup techniques
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk)
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free)
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation LAPACK full diagonalization
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation LAPACK full diagonalization Lanczos type diagonalization (needs only v = H u operations)
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation LAPACK full diagonalization Lanczos type diagonalization (needs only v = H u operations) More exotic eigensolver techniques, real oder imaginary-time propagation,
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation LAPACK full diagonalization Lanczos type diagonalization (needs only v = H u operations) More exotic eigensolver techniques, real oder imaginary-time propagation, Observables
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation LAPACK full diagonalization Lanczos type diagonalization (needs only v = H u operations) More exotic eigensolver techniques, real oder imaginary-time propagation, Observables Static quantities (multipoint correlation functions, correlation density matrices,...)
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation LAPACK full diagonalization Lanczos type diagonalization (needs only v = H u operations) More exotic eigensolver techniques, real oder imaginary-time propagation, Observables Static quantities (multipoint correlation functions, correlation density matrices,...) Dynamic observables (spectral functions, density of states,...)
Ingredients Hilbert space Basis represention, Lookup techniques Symmetries Hamiltonian Matrix Sparse Matrix representation (memory/disk) Matrix recalculation on the fly (matrix-free) Linear Algebra : Eigensolver / Time propagation LAPACK full diagonalization Lanczos type diagonalization (needs only v = H u operations) More exotic eigensolver techniques, real oder imaginary-time propagation, Observables Static quantities (multipoint correlation functions, correlation density matrices,...) Dynamic observables (spectral functions, density of states,...) Real-time evolution
Hilbert Space
Spatial Symmetries Symmetries are sometimes not easily visible, use graph theoretical tools to determine symmetry group [nauty, grape]. In an ED code a spatial symmetry operation is a site permutation operation. (could become more complicated with spin-orbit interactions and multiorbital sites) 40 sites square lattice T PG =40 x 4 elements Icosidodecahedron (30 vertices) Ih:120 elements
Spatial Symmetries: Building the basis Build a list of all allowed states satisfying the diagonal constraints, like particle number, total S z,... for each state we apply all symmetry operations and keep the state as a representative if it has the smallest integer representation among all generated states in the orbit. Example: 4 site ring with cyclic translation T, S z =3/2 sector T 0 ([0 1 1 1]) [0 1 1 1] T 1 ([0 1 1 1]) [1 0 1 1] T 2 ([0 1 1 1]) [1 1 0 1] T 3 ([0 1 1 1]) [1 1 1 0] keep state T 0 ([1 0 1 1]) [1 0 1 1] T 1 ([1 0 1 1]) [1 1 0 1] T 2 ([1 0 1 1]) [1 1 1 0] T 3 ([1 0 1 1]) [0 1 1 1] discard state...
Spatial Symmetries: Building the basis r = 1 N χ(g) g(r) G N = g G g G,g(r)=r χ(r)
Spatial Symmetries: Building the basis For one-dimensional representations χ of the spatial symmetry group: 1 Bloch state r = N χ(g) g(r) G Norm of the state is given as: N = The norm (and therefore the state itself) can vanish if it has a nontrivial stabilizer combined with a nontrivial representation χ. g G g G,g(r)=r χ(r)
Spatial Symmetries: Building the basis For one-dimensional representations χ of the spatial symmetry group: 1 Bloch state r = N χ(g) g(r) G Norm of the state is given as: N = The norm (and therefore the state itself) can vanish if it has a nontrivial stabilizer combined with a nontrivial representation χ. Example: 4 site S=1/2 ring with cyclic translations: g G g G,g(r)=r χ(r)
Spatial Symmetries: Building the basis For one-dimensional representations χ of the spatial symmetry group: 1 Bloch state r = N χ(g) g(r) G Norm of the state is given as: N = The norm (and therefore the state itself) can vanish if it has a nontrivial stabilizer combined with a nontrivial representation χ. Example: 4 site S=1/2 ring with cyclic translations: g G g G,g(r)=r χ(r) S z =2 S z =1 S z =0 K =0 1 1 1 1, N =2 0 1 1 1, N =1 0 1 0 1, N = 2 0 0 1 1, N =1
Spatial Symmetries: Building the basis For one-dimensional representations χ of the spatial symmetry group: 1 Bloch state r = N χ(g) g(r) G Norm of the state is given as: N = The norm (and therefore the state itself) can vanish if it has a nontrivial stabilizer combined with a nontrivial representation χ. Example: 4 site S=1/2 ring with cyclic translations: g G g G,g(r)=r χ(r) S z =2 S z =1 S z =0 K =0 1 1 1 1, N =2 0 1 1 1, N =1 0 1 0 1, N = 2 0 0 1 1, N =1 K = ±π/2 0 1 1 1, N =1 0 0 1 1, N =1
Spatial Symmetries: Building the basis For one-dimensional representations χ of the spatial symmetry group: 1 Bloch state r = N χ(g) g(r) G Norm of the state is given as: N = The norm (and therefore the state itself) can vanish if it has a nontrivial stabilizer combined with a nontrivial representation χ. Example: 4 site S=1/2 ring with cyclic translations: g G g G,g(r)=r χ(r) K =0 K = ±π/2 K = π S z =2 1 1 1 1, N =2 S z =1 0 1 1 1, N =1 0 1 1 1, N =1 0 1 1 1, N =1 S z =0 0 1 0 1, N = 2 0 0 1 1, N =1 0 0 1 1, N =1 0 1 0 1, N = 2 0 0 1 1, N =1
Spatial Symmetries: Building the basis For one-dimensional representations χ of the spatial symmetry group: 1 Bloch state r = N χ(g) g(r) G Norm of the state is given as: N = The norm (and therefore the state itself) can vanish if it has a nontrivial stabilizer combined with a nontrivial representation χ. Example: 4 site S=1/2 ring with cyclic translations: g G g G,g(r)=r χ(r) K =0 K = ±π/2 K = π 2 4 =16 S z =2 1 1 1 1, N =2 1+1 S z =1 S z =0 0 1 1 1, N =1 0 1 0 1, N = 2 0 0 1 1, N =1 0 1 1 1, N =1 0 0 1 1, N =1 0 1 1 1, N =1 0 1 0 1, N = 2 0 0 1 1, N =1 4+4 2 4
The Hamiltonian Matrix
The Hamiltonian Matrix Now that we have a list of representatives and their norms, can we calculate the matrix elements of the Hamiltonian? s H r =? Let us look at an elementary, non-branching term in the Hamiltonian: h α r = h α (r) s We can now calculate the matrix element the Bloch states: s h α r without double expanding s h α r = N s N r χ(g )h α (r) key algorithmic problem: given a possibly non-representative, how do we find the associated representative s, as well as a symmetry element g relating s to s? s
The Hamiltonian Matrix key algorithmic problem: given a possibly non-representative, how do we find the associated representative s, as well as a symmetry element g relating s to s? Brute force: loop over all symmetry operations applied on and retain s and. This is however often not efficient (many hundred symmetries). g Prepare a lookup list, relating each allowed configuration with the index of its representative, and also the associated group element linking the two. Gives fast implementation, but needs a list of the size of the non spatiallysymmetrized Hilbert space. For specific lattices and models (Hubbard models) clever tricks exist which factorize the symmetry group into a sublattice conserving subgroup times a sublattice exchange. They give s fast, then a hash or binary search is needed to locate in the list of representatives in order to get its index. s s s
Hamiltonian Matrix Storage Different possibilities exist: Store hamiltonian matrix elements in memory in a sparse matrix format Fast matrix vector multiplies, but obviously limited by available memory. Store hamiltonian matrix elements on disk in a sparse matrix format. In principle possible due to the vast disk space available, but I/O speed is much slower than main memory access times. Difficult to parallelize. Recalculate the hamiltonian matrix elements in each iterations on the fly. Needed for the cutting edge simulations, where the whole memory is used by the Lanczos vectors. Can be parallelized on most architectures.
The Linear Algebra Backend
The Reference: Online book at: http://www.cs.utk.edu/~dongarra/etemplates/index.html
Linear Algebra: The most popular: Lanczos Algorithm Lanczos Algorithm (C. Lanczos, 1950) Three vector recursion φ = H φ n β n φ n 1, α n = φ n φ, φ = φ α n φ n, β n+1 = φ = φ φ, φ n+1 = φ /β n+1, H N = α 0 β 1 0............ 0 β 1 α 1 β 2 0..... 0 0 β 2 α 2 β 3 0 0......... 0.. 0 β N 2 α N 2 β N 1 0....... 0 β N 1 α N 1 Eigenvalues of HN converge rapidly towards eigenvalues of H. Once desired eigenvalue is converged, restart recursion and assemble the eigenvector. very quick convergence for extremal eigenvalues!
Linear Algebra: Lanczos Algorithm The same algorithm according to the book:
Linear Algebra: Lanczos Algorithm Once the ground state has converged, the vectors in the recursion tend to lose their orthogonality. As a consequence fake new eigenvalues show up in the approximate spectrum. These can be removed by heuristic techniques Degeneracies of eigenvalues can not be resolved by construction. For this task one would need a band lanczos or the (Jacobi-)Davidson technique. However multiply degenerate eigenvalues are converged. Checkpointing is useful when performing large-scale simulations.
Full Diagonalization: Thermodynamics Lapack / Householder complete diagonalization of the spectrum. (LAPACK/SCALAPACK: choose vendor provided, higher performance) Calculate partition function and all the thermodynamic quantities you want, often the only pedestrian method available for frustrated systems. Symmetries are also very important, because the computational requirements scale as O(D 3 ), where D is the dimension of the block Hilbert space. Typical D s for a workstation are a few 1 000, up to a few 100 000 on supercomputers. F. Heidrich-Meisner, A. Honecker, T. Vekua, Phys. Rev. B 74, 020403(R) (2006).
Observables
Observables In principle once can calculate any correlation function, since one has access to the full many body wave functions. When using spatial symmetries, the correlation functions need to be properly symmetrized too. Complicated correlation functions occur in frustrated systems: (S i S j )(S k S l ) S i S j S k S l (S i S j ) z (S k S l ) z (S i S j ) z (S k S l ) z Dimer-dimer correlations Spin current correlations N=40, θ=0.3π
Frequency Dynamics G A (ω + iη) = ψ A 1 E 0 + ω + iη H A ψ A = S α (q),c k,... Generate Krylov space of A ψ Use continued fraction used to invert (E 0 + ω + iη H) Triangular Lattice Spin Dynamics in zero field 20 15 20 20 21 / M/3 26 / 2M/3 30 / M 15 15 10 10 10 5 5 5 0 0 2 4!/J 20 22 / K/2 15 0 0 2 4!/J 20 15 27 0 0 2 4!/J 20 15 28 / K 10 10 10 5 0 0 2 4!/J 5 0 0 2 4!/J 5 0 0 2 4!/J AML unpublished
Exact Diagonalization Real-Time Dynamics It is expensive to obtain the full propagator exp[ ith] Krylov methods exist to approximate the propagator for a given state ψ(0) One can get the time propagated state ψ(t) with only v = H u operations. Example: time evolution of a strongly correlated quantum systems after an abrupt change in the parameters in the Hamiltonian. Revivals and Relaxation. <b 0 b 1 > + + <b 0 b Δx > 0.9 0.6 0.3 0 0.9 0.6 0.3 (a) 1D Chain, U i =2 J, U f = 40 J L=14, ED L=64, t-dmrg L=32, U f =80 J (b) 2D Square, U i =2 J, U f =40 J N sites =16, ED N sites =18, ED 0 40 80 120 Frequency ω [J] 0 40 80 120 Frequency ω [J] 0 0 0.5 1 1.5 2 Time t [J -1 ] C. Kollath, AML, E. Altman, PRL 2007
Parallelization Strategies
Parallelization: Shared memory nodes In the Lanczos algorithm the heaviest part is the elementary matrix-vector multiplication. In a matrix-free formulation this part can easily be parallelized using OpenMP pragmas in the code, even on your multi-core workstation. Choose the right strategy between pull and push! v = H u
Parallelization: Shared memory nodes In the Lanczos algorithm the heaviest part is the elementary matrix-vector multiplication. In a matrix-free formulation this part can easily be parallelized using OpenMP pragmas in the code, even on your multi-core workstation. Choose the right strategy between pull and push! 1 1 v 2 v = 2 H u 3 3 4 4
Parallelization: Shared memory nodes In the Lanczos algorithm the heaviest part is the elementary matrix-vector multiplication. In a matrix-free formulation this part can easily be parallelized using OpenMP pragmas in the code, even on your multi-core workstation. Choose the right strategy between pull and push! v 1 2 v 3 = 1 2 H 3 u In this parallelization we have uncritical concurrent reads, but no concurrent updates of vector v. 4 4
Parallelization: v = H u Shared memory nodes Time per 3 iterations [s] 12000 10000 8000 6000 4000 SGI Origin 3800 [Eridan] IBM p690 [zahir019/020] Sun IBM p5 SGI Altix It2 1.5GHz 2000 0 0 4 8 12 16 20 Number of Threads scales well up to a few ten threads on memory uniform SMP machines.
Parallelization: Distributed memory nodes For some classes of problems the Hilbert space size is not too big, but the vast number of matrix elements is a challenge. [ED in momentum space formulation & Quantum Hall problems] These problems can be OpenMP parallelized, but are also suitable for large scale Message passing parallelization.
Parallelization: Distributed memory nodes For some classes of problems the Hilbert space size is not too big, but the vast number of matrix elements is a challenge. [ED in momentum space formulation & Quantum Hall problems] These problems can be OpenMP parallelized, but are also suitable for large scale Message passing parallelization. 1 1 u 2 2 u... node 1 node 2
Parallelization: Distributed memory nodes For some classes of problems the Hilbert space size is not too big, but the vast number of matrix elements is a challenge. [ED in momentum space formulation & Quantum Hall problems] These problems can be OpenMP parallelized, but are also suitable for large scale Message passing parallelization. 1 1 u 2 2 u... node 1 node 2 1 2 3 4 MPI Broadcast v
Parallelization: Distributed memory nodes Strong scaling example RG-ED: matrix dimension 10 million performed on a 1024 node Cray XT-3 machine: speedup of 800 on 1024 procs 100 1000 Elapsed Time per iteration [s] 80 60 40 20 Speedup 800 600 400 200 0 0 200 400 600 800 1000 N CPUS Local Multiplication Broadcast 0 0 200 400 600 800 1000 N CPUS
Parallelization: How to harness the petaflop computers? Cutting edge petaflop systems have a huge number of core, but only a moderate amount of node-local memory. Next generation ED codes need to be developed in order to attack e.g. the 80 billion Hilbert space of a 48 site kagome antiferromagnet. Problem remains difficult to parallelize due to its all-to-all structure. Global Arrays or UPC can help developing distributed ED codes. R a c k F"%7*Q8%)-+Q= )-?48Q N o d e C a r d F"%;D/,= E2UVHI= ""N%S'% C o m p u t e C a r d C h i p N%,+*;8==*+= E%;D/,6%"#% LCM(= EF2G%:HI= J%('%KLCM( EF2G%:HI= "2#%:'%LLC" ON2#:'%/=%-0%*,./*0P NFU%:HI= GN%:'% EF2R%SHI= "%S'
Exact Diagonalization Literature N. Laflorencie & D. Poilblanc, Simulations of pure and doped low-dimensional spin-1/2 gapped systems Lecture Notes in Physics 645, 227 (2004). R.M. Noack & S. Manmana, Diagonalization- and Numerical Renormalization-Group-Based Methods for Interacting Quantum Systems, AIP Conf. Proc. 789, 93 (2005). A. Weisse, H. Fehske Exact Diagonalization Techniques Lecture Notes in Physics 739, 529 (2008). A. Läuchli Numerical Simulations of Frustrated Systems to appear in Highly Frustratred Magnetism, Eds. Lacroix Mendels, Mila, (2010). http://www.pks.mpg.de/~aml/nsqm/people/andreaslauchli/talks/nsfs_aml.pdf
A simple example (1/4): #include <vector> #include <alps/bitops.h> class SpinOneHalfBasis { public: typedef unsigned int state_type; typedef unsigned int index_type; SpinOneHalfBasis (int L, int TwoSz); state_type state(index_type i) const {return states_[i];} // lookup based on Lin tables index_type lookup(state_type s) const { return shighlook[alps::gbits(s,sh,sl)]+slowlook[alps::gbits(s,sl,0)]; } unsigned int dimension() const { return states_.size();} private: // list of configurations in Hilbert space }; std::vector<state_type> states_; // Lin tables int sl,sh; std::vector<index_type> slowlook,shighlook;
A simple example (2/4): SpinOneHalfBasis::SpinOneHalfBasis(int L, int TwoSz) { if (L%2) { sl=(l+1)/2; sh=(l-1)/2; } else sl=sh=l/2; slowlook.resize(1<<sl); shighlook.resize(1<<sh); int Nup=(L+TwoSz)/2; // generating all configurations with correct TwoSz // and filling of Lin tables for (state_type s=0;s<all_states;++s) if(alps::bitcount(s)==nup) { // correct number of up spins states_.push_back(s); //get sl lowest bits of s const int low_nibble =gbits(s,sl,0); //get sh highest bits of s const int high_nibble =gbits(s,sh,sl); unsigned int all_states=1u<<l; unsigned int index=0; unsigned int last_n=0; int lasthigh_nibble=-1; if (lasthigh_nibble!=high_nibble) { shighlook[high_nibble]=index; } lasthigh_nibble=high_nibble; last_n=index; } } slowlook[low_nibble]=index-last_n; index++;
A simple example (3/4): class HamiltonianMultiplier : public SpinOneHalfBasis { public: HamiltonianMultiplier(int L, int TwoSz, double Jxy, double Jz) : SpinOneHalfBasis(L,TwoSz), Jxy_(Jxy), Jz_(Jz), L_(L) {} void multiply(std::valarray<double>& v, const std::valarray<double>& w); private: double Jxy_, Jz_; } int L_;
A simple example (4/4): void HamiltonianMultiplier::multiply(std::valarray<double>& v, } // check dimensions const std::valarray<double>& w) { assert(v.size()==dimension()); assert(w.size()==dimension()); // do the Jz-term for (int i=0;i<dimension();++i) { state_type s = state(i); // count number of parallel spins state_type s = state(i); for (int r=0;r<l_-1;++r) v[i]+=( 0.25*Jz_-0.5*Jz_*(alps::gbit(s,r)^alps::gbit(s,r+1)) )*w[i]; } // do the Jxy-term for (int i=0;i<dimension();++i) { } state_type s = state(i); for (int r=0;r<l_-1;++r) { if(alps:popcnt(s&(3<<r))==1) { // is state flippable? } } state_type snew = s^(3<<r); // exchange up and down spins index_type idx = lookup(snew); v[idx]+=w[i]*jxy_*0.5;
Homework: Take the code fragment from the example and Implement the Hamiltonian with periodic boundary conditions Use the fragment to dump the Hamilton matrix for a toy problem system and diagonalize it in Matlab/Mathematica,... Write a very basic implemention of a Lanczos eigensolver around it Implement Sz->-Sz symmetry for the Sz=0 sector Implement translation symmetry! Report any progress or questions to laeuchli@comp-phys.org
Next time: Modern concepts to detect exotic order in quantum many body systems Density Matrices, Correlation Density Matrices,... Tower of States (Magnetic order, superfluids, spin nematics, VBC,...)...
Thank you!