# DOS and LDOS using Quantica

**URL:** https://discourse.julialang.org/t/dos-and-ldos-using-quantica/109822
**Category:** Quantum
**Created:** [February 6, 2024, 4:52pm UTC](https://discourse.julialang.org/t/dos-and-ldos-using-quantica/109822 "2024-02-06T16:52:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alex123](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alex123](https://discourse.julialang.org/u/alex123)
#### Post date: [February 6, 2024, 4:52pm UTC](https://discourse.julialang.org/t/dos-and-ldos-using-quantica/109822/1 "2024-02-06T16:52:32Z")

</div>

Hello @pablosanjose , looking through the Quantica documentation, I could only see how to find the LDOS at a fixed energy at all sites in the lattice.

Is there a way to get the LDOS at a fixed position for a range of energies?

And is there a way to calculate the total DOS of the lattice for different energies?

Thanks.

---

<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, 2024, 7:37am UTC](https://discourse.julialang.org/t/dos-and-ldos-using-quantica/109822/2 "2024-02-07T07:37:32Z")

</div>

Hello Alex,

yes, you need to pass a GreenSlice to `ldos`, like this:

First build your Hamiltonian and GreenFunction. I’ll use the one in the `ldos` documentation

```julia
h = LP.square() |> onsite(4) - hopping(1) |> supercell(region = r -> norm(r) < 40*(1+0.2*cos(5*atan(r[2],r[1]))));

g = h|> greenfunction;

```

Then you select the sites you want (see `siteselector`), creating a GreenSlice

```julia
julia> gs = g[region = r->norm(r) < 2]
GreenSlice{Float64,2,0}: Green function at arbitrary energy, but at a fixed lattice positions

```

Then you pass _that_ to `ldos`

```julia
julia> ρ = ldos(gs)
LocalSpectralDensitySlice{Float64} : local density of states at a fixed location and arbitrary energy
  kernel : LinearAlgebra.UniformScaling{Bool}(true)

```

Finally, you choose your energies

```julia
julia> ρ(0.2)
9-element Vector{Float64}:
 2.2297735490934158e-6
 2.436670202919316e-6
 2.229773549066893e-6
 2.974103757821811e-6
 3.2313768522869836e-6
 2.974103757803625e-6
 3.194724428617991e-6
 3.463660881255997e-6
 3.194724428575867e-6

```

One value for each orbital (unless you use `kernel`, see the `ldos` docstring).

In the near future (very soon), you will be able to use siteselectors also on this result.

If your GreenSolver allows for cheap evaluation of different energies (like `GS.KPM`) the latter should be fast. Here, we have used the default `GS.SparseLU`, which needs to do an `ldiv!` for each energy, but it is exact.
