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

Refactor of LatticeSlice and Contacts #234

Merged
merged 8 commits into from
Jan 22, 2024
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ version = "1.0.1"
ArnoldiMethod = "ec485272-7323-5ecc-a04f-4719b315124d"
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
FrankenTuples = "7e584817-dab4-53a9-9a51-4037a36b0ad0"
FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
IntervalTrees = "524e6230-43b7-53ae-be76-1e9e4d08d11b"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -27,6 +27,7 @@ SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"

[weakdeps]
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"

[extensions]
QuanticaMakieExt = "Makie"
Expand All @@ -42,12 +43,13 @@ GeometryBasics = "0.4"
IntervalTrees = "1"
KrylovKit = "0.6"
LinearMaps = "3"
Makie = "0.19.3, 0.20, 1.0"
Makie = "0.20, 1.0"
NearestNeighbors = "0.4"
ProgressMeter = "1.2"
QuadGK = "2"
SpecialFunctions = "2"
StaticArrays = "0.12.3, 0.13, 1.0"
Dictionaries = "0.3.26"
julia = "^1.9"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorial/lattices.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ julia> qplot(lat, hide = nothing)
GLMakie.jl is optimized for interactive GPU-accelerated, rasterized plots. If you need to export to PDF for publications or display plots inside a Jupyter notebook, use CairoMakie.jl instead, which in general renders non-interactive, but vector-based plots.

!!! tip "User-defined defaults for `qplot`"
The command `qplotdefaults(; axis, figure)` can be used to define the default value of `figure` and `axis` keyword arguments of `qplot`. Example: to fix the resolution of all subsequent plots, do `qplotdefaults(; figure = (resolution = (1000, 1000),))`.
The command `qplotdefaults(; axis, figure)` can be used to define the default value of `figure` and `axis` keyword arguments of `qplot`. Example: to fix the size of all subsequent plots, do `qplotdefaults(; figure = (size = (1000, 1000),))`.

## [SiteSelectors](@id siteselectors)

Expand Down
4 changes: 2 additions & 2 deletions ext/QuanticaMakieExt/defaults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ checkplotdim(::PlotArgumentType{E}) where {E} =

## plotlattice defaults

const plotlat_default_figure = (; resolution = (1200, 1200), fontsize = 40)
const plotlat_default_figure = (; size = (1200, 1200), fontsize = 40)

const plotlat_default_axis3D = (;
xlabel = "x", ylabel = "y", zlabel = "z",
Expand All @@ -86,7 +86,7 @@ const plotlat_default_3D =

## plotbands defaults

const plotbands_default_figure = (; resolution = (1200, 1200), fontsize = 40)
const plotbands_default_figure = (; size = (1200, 1200), fontsize = 40)

const plotbands_default_axis3D = (;
xlabel = "ϕ₁", ylabel = "ϕ₂", zlabel = "ε",
Expand Down
8 changes: 4 additions & 4 deletions ext/QuanticaMakieExt/docstrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cycling over them if necessary.

## Keywords

- `figure`: keywords to pass onto the plot `Figure` (e.g. `resolution` or `fontsize`, see `Makie.Figure`)
- `figure`: keywords to pass onto the plot `Figure` (e.g. `size` or `fontsize`, see `Makie.Figure`)
- `axis`: keywords to pass on to the plot axis (see `Makie.LScene`, `Makie.Axis3` or `Makie.Axis` for options)
- `fancyaxis::Bool`: for 3D plots, whether to use `Makie.LScene` (supports zoom+pan) instead of `Makie.Axis3`
- `inspector::Bool`: whether to enable interactive tooltips of plot elements
Expand Down Expand Up @@ -158,11 +158,11 @@ Equivalent to `qplotdefaults(; defaults...)`

# Examples
```jldoctest
julia> qplotdefaults(figure = (resolution = (1000, 1000),))
(user_default_figure = (resolution = (1000, 1000),), user_default_axis2D = NamedTuple(), user_default_axis3D = NamedTuple(), user_default_lscene = NamedTuple(), user_default_inspector = NamedTuple())
julia> qplotdefaults(figure = (size = (1000, 1000),))
(user_default_figure = (size = (1000, 1000),), user_default_axis2D = NamedTuple(), user_default_axis3D = NamedTuple(), user_default_lscene = NamedTuple(), user_default_inspector = NamedTuple())

julia> qplotdefaults(axis2D = (xlabel = "X",), inspector = (fontsize = 30,))
(user_default_figure = (resolution = (1000, 1000),), user_default_axis2D = (xlabel = "X",), user_default_axis3D = NamedTuple(), user_default_lscene = NamedTuple(), user_default_inspector = (fontsize = 30,))
(user_default_figure = (size = (1000, 1000),), user_default_axis2D = (xlabel = "X",), user_default_axis3D = NamedTuple(), user_default_lscene = NamedTuple(), user_default_inspector = (fontsize = 30,))
```
"""
qplotdefaults
2 changes: 1 addition & 1 deletion ext/QuanticaMakieExt/plotbands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function plotmeshes!(plot, mp::MeshPrimitives{<:Any,3})
if !ishidden((:wireframe, :simplices), plot)
color´ = darken.(mp.colors, plot[:nodedarken][])
poly!(plot, mp.verts, simps; color = mp.colors, inspectable = false, transparency,
strokewidth = plot[:size][], shading = true)
strokewidth = plot[:size][])
else
mesh!(plot, mp.verts, simps; color = mp.colors, inspectable = false, transparency)
end
Expand Down
2 changes: 1 addition & 1 deletion ext/QuanticaMakieExt/plotlattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ function plotbravais!(plot::PlotLattice, lat::Lattice{<:Any,E,L}, latslice) wher
mrect0 = GeometryBasics.mesh(rect, pointtype=Point{L,Float32}, facetype=QuadFace{Int})
vertices0 = mrect0.position
mat = Quantica.bravais_matrix(bravais)
for sc in Quantica.subcells(latslice)
for sc in Quantica.cellsdict(latslice)
cell = Quantica.cell(sc)
mrect = GeometryBasics.mesh(rect, pointtype=Point{E,Float32}, facetype=QuadFace{Int})
vertices = mrect.position
Expand Down
1 change: 1 addition & 0 deletions src/Quantica.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using NearestNeighbors
using SparseArrays
using SparseArrays: getcolptr, AbstractSparseMatrix, AbstractSparseMatrixCSC
using LinearAlgebra
using Dictionaries
using ProgressMeter
using Random
using SuiteSparse
Expand Down
3 changes: 3 additions & 0 deletions src/apply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ function apply(solver::AbstractEigenSolver, h::AbstractHamiltonian, ::Type{S}, m
apply_transform!(eigen, transform)
return eigen
end
# for some reason, unless this is called, h´ may be GC'ed despite the asolver closure in
# some systems, leading to segfaults. TODO: clarify why this is needed
sfunc(zero(S))
asolver = AppliedEigenSolver(FunctionWrapper{EigenComplex{T},Tuple{S}}(sfunc))
return asolver
end
Expand Down
12 changes: 6 additions & 6 deletions src/bands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ end

function subbands_diagonalize!(data)
baseverts = vertices(data.basemesh)
meter = Progress(length(baseverts), "Step 1 - Diagonalizing: ")
meter = Progress(length(baseverts); desc = "Step 1 - Diagonalizing: ")
push!(data.coloffsets, 0) # first element
if length(data.solvers) > 1
Threads.@threads :static for i in eachindex(baseverts)
Expand Down Expand Up @@ -327,7 +327,7 @@ end
#region

function subbands_knit!(data)
meter = Progress(length(data.eigens), "Step 2 - Knitting: ")
meter = Progress(length(data.eigens); desc = "Step 2 - Knitting: ")
for isrcbase in eachindex(data.eigens)
for idstbase in neighbors_forward(data.basemesh, isrcbase)
knit_seam!(data, isrcbase, idstbase)
Expand Down Expand Up @@ -401,8 +401,8 @@ function subbands_patch!(data)
queue_frustrated!(data)
data.warn && isempty(data.defects) &&
@warn "Trying to patch $(length(data.frustrated)) band dislocations without a list `defects` of defect positions."
meter = data.patches < Inf ? Progress(data.patches, "Step 3 - Patching: ") :
ProgressUnknown("Step 3 - Patching: ")
meter = data.patches < Inf ? Progress(data.patches; desc = "Step 3 - Patching: ") :
ProgressUnknown(; desc = "Step 3 - Patching: ")
newcols = 0
done = false
while !isempty(data.frustrated) && !done
Expand Down Expand Up @@ -567,7 +567,7 @@ function subbands_split!(data)
# vsinds are the subband index of each vertex index
# svinds is lists of band vertex indices that belong to the same subband
vsinds, svinds = subsets(data.bandneighs)
meter = Progress(length(svinds), "Step 4 - Splitting: ")
meter = Progress(length(svinds); desc = "Step 4 - Splitting: ")
new2old = sortperm(vsinds)
old2new = invperm(new2old)
offset = 0
Expand Down Expand Up @@ -607,7 +607,7 @@ end

function subband_projectors!(data)
nsimps = sum(s -> length(simplices(s)), data.subbands)
meter = Progress(nsimps, "Step 5 - Projectors: ")
meter = Progress(nsimps; desc = "Step 5 - Projectors: ")
if data.projectors
for s in data.subbands
subband_projectors!(s, data.hf, meter, data.showprogress)
Expand Down
6 changes: 3 additions & 3 deletions src/docstrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1398,11 +1398,11 @@ julia> gdisk = HP.graphene(a0 = 1, dim = 3) |> supercell(region = RP.circle(10))
attach

"""
cellsites(cell_indices, site_indices)
cellsites(cell_index, site_indices)

Simple selector of sites with given `site_indices` in a given cell at `cell_indices`. Here,
Simple selector of sites with given `site_indices` in a given cell at `cell_index`. Here,
`site_indices` can be an index, a collection of integers or `:` (for all sites), and
`cell_indices` should be a collection of `L` integers, where `L` is the lattice dimension.
`cell_index` should be a collection of `L` integers, where `L` is the lattice dimension.

# See also
`siteselector`
Expand Down
Loading
Loading