# Kernel Polynomial Method

**URL:** <https://discourse.julialang.org/t/kernel-polynomial-method/34240>\
**Category:** Numerics\
**Tags:** package\
**Created:** [February 6, 2020, 8:20am UTC](https://discourse.julialang.org/t/kernel-polynomial-method/34240 "2020-02-06T08:20:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgaffar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgaffar/32/9311_2.png) [@mgaffar](https://discourse.julialang.org/u/mgaffar)\
**Post date:** [February 6, 2020, 8:20am UTC](https://discourse.julialang.org/t/kernel-polynomial-method/34240/1 "2020-02-06T08:20:33Z")

</div>

Is there any packages that already implement KPM?

> **[The kernel polynomial method](https://journals.aps.org/rmp/abstract/10.1103/RevModPhys.78.275)**
>
> Efficient and stable algorithms for the calculation of spectral quantities and correlation functions are some of the key tools in computational condensed-matter physics. In this paper basic properties and recent developments of Chebyshev expansion...

---

<div class="post-metadata">

**Author:** ![pablosanjose](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablosanjose/32/7006_2.png) [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Post date:** [February 6, 2020, 8:39am UTC](https://discourse.julialang.org/t/kernel-polynomial-method/34240/2 "2020-02-06T08:39:04Z")

</div>

We have [GitHub - pablosanjose/Elsa.jl: Efficient lattice simulation algorithms - a Julia library](https://github.com/pablosanjose/Elsa.jl)  
Still in development but has KPM built in.  
I would actually appreciate it if you take it for a spin and report issues.

---

<div class="post-metadata">

**Author:** ![mgaffar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgaffar/32/9311_2.png) [@mgaffar](https://discourse.julialang.org/u/mgaffar)\
**Post date:** [February 7, 2020, 9:31am UTC](https://discourse.julialang.org/t/kernel-polynomial-method/34240/3 "2020-02-07T09:31:06Z")

</div>

your package seems really good!, I will try it soon.

---

<div class="post-metadata">

**Author:** ![pablosanjose](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablosanjose/32/7006_2.png) [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Post date:** [February 7, 2020, 6:56pm UTC](https://discourse.julialang.org/t/kernel-polynomial-method/34240/4 "2020-02-07T18:56:57Z")

</div>

Please do. For the moment I’m afraid you’ll have to make do with the docstrings, as we haven’t had time to write a narrative documentation. To get you started, you could compute the density of states of a simple graphene monolayer (circular flake of radius 300a0) using stochastic traces with something like

```julia
julia> using Elsa, FFTW, Plots

julia> h = LatticePresets.honeycomb() |> hamiltonian(hopping(1, range = 1/√3)) |> unitcell(region = RegionPresets.circle(300))
Hamiltonian{<:Lattice} : Hamiltonian on a 0D Lattice in 2D space
  Bloch harmonics : 1 (SparseMatrixCSC, sparse)
  Harmonic size : 652966 × 652966
  Orbitals : ((:a,), (:a,))
  Element type : scalar (Complex{Float64})
  Onsites : 0
  Hoppings : 1956506
  Coordination : 2.9963367158473795

julia> dos = dosKPM(h, order = 1000, bandrange = (-3,3), randomkets = 1);

julia> plot(dos)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/2/e2fcc1d16879a4fa3d257292d04964402b65ed68.png)

EDIT: to reduce noise, increase system size or `randomkets`. Also, if you use MKLSparse.jl you will get a nice performance boost on Intel machines, thanks to hyperthreaded sparse `mul!`, at least for single-orbital hamiltonians (scalar eltype).
