Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algebra with compatible Hamiltonians #113

Merged
merged 1 commit into from
Oct 13, 2020
Merged

Algebra with compatible Hamiltonians #113

merged 1 commit into from
Oct 13, 2020

Conversation

pablosanjose
Copy link
Owner

@pablosanjose pablosanjose commented Oct 13, 2020

This PR allows one to do basic algebra with Hamiltonians (that share lattice and orbital structure). This includes ^, *, +, - and addition of the identity I.

An example

julia> h = LatticePresets.honeycomb() |> hamiltonian(hopping(I), orbitals = (Val(2), Val(1))) |> unitcell(2)
Hamiltonian{<:Lattice} : Hamiltonian on a 2D Lattice in 2D space
  Bloch harmonics  : 5 (SparseMatrixCSC, sparse)
  Harmonic size    : 8 × 8
  Orbitals         : ((:a, :a), (:a,))
  Element type     : 2 × 2 blocks (Complex{Float64})
  Onsites          : 0
  Hoppings         : 24
  Coordination     : 3.0

julia> 2h^2 + h
Hamiltonian{<:Lattice} : Hamiltonian on a 2D Lattice in 2D space
  Bloch harmonics  : 13 (SparseMatrixCSC, sparse)
  Harmonic size    : 8 × 8
  Orbitals         : ((:a, :a), (:a,))
  Element type     : 2 × 2 blocks (Complex{Float64})
  Onsites          : 8
  Hoppings         : 72
  Coordination     : 9.0

One possible usecase for this is the computation of the square of the shifted spectrum of h (doing e.g. spectrum((h-z*I)^2, method->ArpackPackage(which = :LM))) as a cheap way towards internal eigenvalues using Arnoldi.

(Note that the addition of UniformScaling respects the orbital structure of h)

fix check, more general tests

add UniformScaling

forgot -

add h1*h2
@codecov-io
Copy link

codecov-io commented Oct 13, 2020

Codecov Report

Merging #113 into master will increase coverage by 1.36%.
The diff coverage is 85.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   61.12%   62.48%   +1.36%     
==========================================
  Files          16       16              
  Lines        2765     2823      +58     
==========================================
+ Hits         1690     1764      +74     
+ Misses       1075     1059      -16     
Impacted Files Coverage Δ
src/plot_vegalite.jl 0.00% <0.00%> (ø)
src/hamiltonian.jl 79.56% <91.37%> (+4.04%) ⬆️
src/tools.jl 57.67% <100.00%> (+1.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73c55f8...37ef4ac. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants