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

Generalize unitcell and supercell to use generic SiteSelector machinery #98

Merged
merged 1 commit into from
Sep 23, 2020

Conversation

pablosanjose
Copy link
Owner

This was one tricky refactor, as it touches some of the oldest parts of Quantica. It generalizes the supercell routines to take arbitrary SiteSelectors. Before, supercell just took a region kwarg that was used to constrain any non-periodic direction of a superlattice (this then extended to unitcell too). With this PR we can specify other constraints, such as indices or sublats when building a new supercell or unitcell.

As an example application, we can combine this with the not wrapper from #97 to create vacancies by index (i.e. instead of by position). First create a Hamiltonian without vacancies, and plot it to locate the indices for the desired vacancies

using VegaLite
h = LatticePresets.honeycomb() |> unitcell(region = RegionPresets.circle(10)) |> hamiltonian(hopping(1))
vlplot(h)

Screen Shot 2020-09-22 at 21 26 51

Now, just rebuild the unitcell of h excluding the desired site with indices

h´ = unitcell(h, indices = not(549))
vlplot(h´)

Screen Shot 2020-09-22 at 21 28 41

@pablosanjose pablosanjose changed the title Generalize unitcell, supercell to use generic SiteSelector Generalize unitcell and supercell to use generic SiteSelector machinery Sep 22, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 22, 2020

Codecov Report

Merging #98 into master will decrease coverage by 0.05%.
The diff coverage is 94.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #98      +/-   ##
==========================================
- Coverage   62.07%   62.01%   -0.06%     
==========================================
  Files          16       16              
  Lines        2634     2651      +17     
==========================================
+ Hits         1635     1644       +9     
- Misses        999     1007       +8     
Impacted Files Coverage Δ
src/tools.jl 56.33% <66.66%> (-2.08%) ⬇️
src/model.jl 72.54% <88.88%> (+0.12%) ⬆️
src/lattice.jl 81.53% <96.49%> (+0.10%) ⬆️
src/hamiltonian.jl 74.82% <100.00%> (+0.08%) ⬆️

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 2587888...e5a3c8f. Read the comment docs.

@pablosanjose
Copy link
Owner Author

This includes a redesign of the supercell internals (the old ribbonfunc stuff), which (1) was rather obscure and (2) could lead to inconsistent/unexpected results, such as unitcell(lat) resulting in a unit cell different from lat.unitcell (!!).

wip, fixes

fixes

fixes

fixes

docstrings

fix sanitize_supercell

supercell redone

pinverse fix

fix

workaround StaticArrays bug

test
@pablosanjose pablosanjose merged commit 4d07cc0 into master Sep 23, 2020
@pablosanjose pablosanjose deleted the supercell_selector branch September 23, 2020 16:27
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