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

Move bravais to kwarg #94

Merged
merged 2 commits into from
Sep 21, 2020
Merged

Move bravais to kwarg #94

merged 2 commits into from
Sep 21, 2020

Conversation

pablosanjose
Copy link
Owner

This is quite a breaking change. It changes the lattice(bravais, sublats...; kw...) syntax to lattice(sublats...; bravais = ..., kw...) syntax. Any user code that uses this method should be updated.

Examples

julia> lattice(sublat((0, 0)); bravais = (1, 0), dim = Val(3))
Lattice{3,1,Float64} : 1D lattice in 3D space
  Bravais vectors : ((1.0, 0.0, 0.0),)
  Sublattices     : 1
    Names         : (:A)
    Sites         : (1) --> 1 total per unit cell

julia> lattice(sublat((0, 0)); bravais = ((1, 0), (0, 1)), dim = Val(3))
Lattice{3,2,Float64} : 2D lattice in 3D space
  Bravais vectors : ((1.0, 0.0, 0.0), (0.0, 1.0, 0.0))
  Sublattices     : 1
    Names         : (:A)
    Sites         : (1) --> 1 total per unit cell

This has several advantages. For example we can override the Bravais vectors of a LatticePreset, since kwargs are forwarded

julia> LatticePresets.cubic(bravais = SA[1 0; 0 2])
Lattice{3,2,Float64} : 2D lattice in 3D space
  Bravais vectors : ((1.0, 0.0, 0.0), (0.0, 2.0, 0.0))
  Sublattices     : 1
    Names         : (:A)
    Sites         : (1) --> 1 total per unit cell

It also simplifies the API, since now the function bravais is restricted to method bravais(lattice), which returns the Bravais matrix of a lattice (or Hamiltonian)

This PR also simplifies the Bravais struct, which no longer contains information about "semiboundedness" of axes. That functionality is meant for higher level Green's function code, no need to clutter the basic data structures

This PR also enables a future PR that will allow modifying the Bravais vectors of a given lattice (or Hamiltonian) by doing

lattice(lat; bravais = newbravais)

along with any other modification of parameters passed as kwargs.

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2020

Codecov Report

Merging #94 into master will increase coverage by 0.16%.
The diff coverage is 73.46%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #94      +/-   ##
==========================================
+ Coverage   61.99%   62.15%   +0.16%     
==========================================
  Files          16       16              
  Lines        2631     2603      -28     
==========================================
- Hits         1631     1618      -13     
+ Misses       1000      985      -15     
Impacted Files Coverage Δ
src/convert.jl 50.00% <ø> (ø)
src/plot_makie.jl 0.00% <0.00%> (ø)
src/presets.jl 32.07% <11.11%> (ø)
src/lattice.jl 80.29% <92.85%> (+2.78%) ⬆️
src/hamiltonian.jl 74.74% <100.00%> (+0.21%) ⬆️
src/tools.jl 58.92% <100.00%> (ø)

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 2065248...8a78359. Read the comment docs.

@pablosanjose pablosanjose merged commit 37b2dba into master Sep 21, 2020
@pablosanjose pablosanjose deleted the bloch branch September 21, 2020 10:27
@pablosanjose pablosanjose mentioned this pull request Sep 21, 2020
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