Skip to content
New issue

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

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

Already on GitHub? # to your account

fix 3D plot #42

Merged
merged 1 commit into from
Oct 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions toolbox/test_extend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ using BrillouinZoneMeshes.LinearAlgebra
include("default_colors.jl")
include("plotlyjs_wignerseitz.jl")
function wignerseitz_ext(basis::AVec{<:SVector{D,<:Real}};
merge::Bool = true,
Nmax::Integer = 3, cut = Nmax-1) where D
merge::Bool = false,
Nmax::Integer = 3, cut = Nmax/2) where D
# bringing in SciPy's Spatial module (for `Voronoi` and `ConvexHull`)
if PyCall.conda
copy!(PySpatial, pyimport_conda("scipy.spatial", "scipy"))
Expand Down Expand Up @@ -54,8 +54,8 @@ function wignerseitz_ext(basis::AVec{<:SVector{D,<:Real}};
c = WignerSeitz.reorient_normals!(c)

# return either raw simplices or "merged" polygons
if merge
latticize!(merge_coplanar!(c))
if merge || D > 2
latticize!(WignerSeitz.merge_coplanar!(c))
else
latticize!(c)
end
Expand All @@ -79,18 +79,30 @@ end

# Wigner-Seitz cells visualization
# 2D
Rs = [[1.0, 0.0], [-0.5, √3/2]]
N, DIM = 4, 2
origin = [0.0 0.0]
lattice =Matrix([2 0; 1 sqrt(3)]')
msize = (3,3)
#Rs = [[1.0, 0.0], [-0.5, √3/2]]
#N, DIM = 4, 2
#origin = [0.0 0.0]
#lattice =Matrix([2 0; 1 sqrt(3)]')
#msize = (3,3)
#br = BZMeshes.Brillouin(lattice = lattice)

# latvec = [1 0; 0 1]'
br = BZMeshes.Brillouin(lattice = lattice)
# 3D

lattice = [[0 1 1.0]; [1 0 1.0]; [1 1 0.0]]
atoms = [1, 1]
positions = [ones(3) / 8, -ones(3) / 8]
br = BZMeshes.Brillouin(lattice=lattice, atoms=atoms, positions=positions)
#lattice = [[1.0 0.0 0.0]; [0.0 1.0 0.0]; [0.0 0.0 1.0]]
#br = BZMeshes.Brillouin(lattice=lattice)
msize = (5, 5, 5)

bzmesh = UniformBZMesh(br=br, size=msize)
latvec = mapslices(x->[x],lattice_vector(bzmesh),dims=1)[:]
clist,idx_center = wignerseitz_ext(latvec;merge = false)
clist,idx_center = wignerseitz_ext(latvec)
P=plot(clist,idx_center)
addtraces!(P, scatter(x=[bzmesh[i][1] for i in 1:length(bzmesh)],y=[bzmesh[i][2] for i in 1:length(bzmesh)],mode="markers"))
#addtraces!(P, scatter(x=[bzmesh[i][1] for i in 1:length(bzmesh)],y=[bzmesh[i][2] for i in 1:length(bzmesh)],mode="markers"))
addtraces!(P, scatter3d(x=[bzmesh[i][1] for i in 1:length(bzmesh)],y=[bzmesh[i][2] for i in 1:length(bzmesh)],z=[bzmesh[i][3] for i in 1:length(bzmesh)],mode="markers", marker = attr(size=3)))
display(P)
readline()