Skip to content

Commit

Permalink
Merge branch 'dev' into dev_kun
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleBug committed Oct 29, 2022
2 parents 06165de + 151a9ed commit c9175ed
Show file tree
Hide file tree
Showing 5 changed files with 629 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export Brillouin, get_latvec
"""
Compute the inverse of the lattice. Require lattice to be square matrix
"""
function _compute_inverse_lattice(lattice::Matrix{T}) where {T}
function _compute_inverse_lattice(lattice::AbstractMatrix{T}) where {T}
@assert size(lattice, 2) == size(lattice, 2)
return inv(lattice)
end
Expand All @@ -21,15 +21,15 @@ Compute the reciprocal lattice.
We use the convention that the reciprocal lattice is the set of G vectors such
that G ⋅ R ∈ 2π ℤ for all R in the lattice.
"""
function _compute_recip_lattice(lattice::Matrix{T}) where {T}
return 2T(π) * _compute_inverse_lattice(lattice)
function _compute_recip_lattice(lattice::AbstractMatrix{T}) where {T}
return 2T(π) * _compute_inverse_lattice(lattice')
end

"""
Return I-th lattice vector of lattice.
Lattice vectors are specified column-wise in lattice::Matrix.
"""
function get_latvec(lattice::Matrix{T}, I::Int) where {T}
function get_latvec(lattice::AbstractMatrix{T}, I::Int) where {T}
return view(lattice, :, I)
end

Expand Down Expand Up @@ -307,4 +307,4 @@ function Base.show(io::IO, ::MIME"text/plain", model::Brillouin{T,DIM}) where {T
end
end

end
end
16 changes: 11 additions & 5 deletions test/Model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,36 @@ using BrillouinZoneMeshes.PointSymmetry: spglib_spacegroup_number, spglib_standa

@testset "Brillouin" begin
Brillouin = BrillouinZoneMeshes.Model.Brillouin

get_latvec = BrillouinZoneMeshes.Model.get_latvec
# square lattice
DIM = 2
lattice = Matrix([1.0 0; 0 1]')
br = Brillouin(lattice=lattice)
@test br.inv_lattice .* 2π br.recip_lattice
@test br.inv_lattice .* 2π br.recip_lattice'
@test br.unit_cell_volume abs(det(lattice))
@test br.recip_cell_volume 1 / abs(det(lattice)) * (2π)^DIM

# triagular lattice
DIM = 2
lattice = Matrix([2.0 0; 1 sqrt(3)]')
br = Brillouin(lattice=lattice)
@test br.inv_lattice .* 2π br.recip_lattice
@test br.inv_lattice .* 2π br.recip_lattice'
@test br.unit_cell_volume abs(det(lattice))
@test br.recip_cell_volume 1 / abs(det(lattice)) * (2π)^DIM

for i in 1:DIM
@test dot(get_latvec(br.recip_lattice,i),get_latvec(br.lattice,i)) 2π
end
# 3d testing lattice
DIM = 3
lattice = Matrix([2.0 0 0; 1 sqrt(3) 0; 7 11 19]')
br = Brillouin(lattice=lattice)
@test br.inv_lattice .* 2π br.recip_lattice
@test br.inv_lattice .* 2π br.recip_lattice'
@test br.unit_cell_volume abs(det(lattice))
@test br.recip_cell_volume 1 / abs(det(lattice)) * (2π)^DIM
for i in 1:DIM
@test dot(get_latvec(br.recip_lattice,i),get_latvec(br.lattice,i)) 2π
end

end

@testset "Standard Brillouin" begin
Expand Down
19 changes: 19 additions & 0 deletions toolbox/default_colors.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const TRANSPARENT_COL = Ref("rgba(255, 255, 255, 1)")

# --- wigner-seitz colors ---
# from https://flatuicolors.com/palette/gb
const BZ_COL = Ref("rgb(47,54,64)") # "electromagnetic"
const BASIS_COL = Ref("rgb(39,60,117)") # "pico void"
const BASIS_LIGHT_COL = Ref("rgb(212,216,227)") # 20% BASIS_COL, 80% white
const AXIS_COL = Ref("rgb(194,54,22)") # "harley davidson orange"
const AXIS_LIGHT_COL = Ref("rgb(242,215,208)") # 20% AXIS_COL, 80% white

# --- k-path colors ---
# from https://flatuicolors.com/palette/ca
const KPATH_COL = Ref("rgb(95,39,205)") # "nasu purple"

# --- dispersion colors ---
# from https://flatuicolors.com/palette/gb
const BAND_COL = Ref("rgb(39,60,117)") # "mazarine blue"
const KLINE_COL = Ref("rgb(220,221,225)") # "hint of pensive" (light gray)
const ANNOTATE_COL = Ref("rgb(53, 59, 72)") # "blue nights" (dark gray)
Loading

0 comments on commit c9175ed

Please # to comment.