From 62dbae3b59ca6a1e196141950a7f518440f74266 Mon Sep 17 00:00:00 2001 From: Lorenzo Van Munoz Date: Tue, 29 Oct 2024 12:14:50 -0400 Subject: [PATCH] add pythtb band visualization example --- .github/workflows/documentation.yml | 2 +- docs/Project.toml | 1 + docs/src/pages/viz/band.md | 47 +++++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 3214e9f..474fbdc 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -29,7 +29,7 @@ jobs: - name: Install documentation dependencies run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev - name: Install dependencies - run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ -e 'ENV["PYTHON"]=""; using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); using Conda; Conda.pip_interop(true); Conda.pip("install", "pythtb")' - name: Build and deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token diff --git a/docs/Project.toml b/docs/Project.toml index eb60e60..c515236 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] Brillouin = "23470ee3-d0df-4052-8b1a-8cbd6363e7f0" +Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" diff --git a/docs/src/pages/viz/band.md b/docs/src/pages/viz/band.md index 10ae614..3301fe4 100644 --- a/docs/src/pages/viz/band.md +++ b/docs/src/pages/viz/band.md @@ -7,9 +7,50 @@ visualize k-paths. ## Energy bands -!!! note "In progress" - This will be added soon +In the following example, we plot the band structure of graphene defined as a tight binding model in PythTB. +This serves to reproduce the [PythTB homepage example](https://www.physics.rutgers.edu/pythtb/) using AutoBZ.jl and highlight the [`load_pythtb_data`](@ref) interface. + +```@example +using PyCall +py""" +from pythtb import * + +# lattice vectors and orbital positions +lat=[[1.0, 0.0], [0.5, np.sqrt(3.0)/2.0]] +orb=[[1./3., 1./3.], [2./3., 2./3.]] + +# two-dimensional tight-binding model +gra=tb_model(2, 2, lat, orb) + +# define hopping between orbitals +gra.set_hop(-1.0, 0, 1, [ 0, 0]) +gra.set_hop(-1.0, 1, 0, [ 1, 0]) +gra.set_hop(-1.0, 1, 0, [ 0, 1]) + +k=[[0.0, 0.0],[1./3., 2./3.],[0.5,0.5]] +path=gra.k_path(k, 100) +""" +gra = py"gra" +(k_vec,k_dist,k_node)=py"path" + +using AutoBZ +h,bz = load_pythtb_data(gra) + +using LinearAlgebra +hk = getproperty.(eigen.(h.(eachrow(k_vec))), :values) + +using GLMakie +fig = Figure() +ax = Axis(fig[1,1]; xticks = (k_node, ["Γ", "K", "M"])) +series!(ax, k_dist, stack(hk)) +save("grapheneband.png", fig); nothing # hide +``` + +![Graphene band kpath](grapheneband.png) ## Band velocities -To overlay band velocities on the k-ath \ No newline at end of file +!!! note "In progress" + This will be added soon + +To overlay band velocities on the k-path \ No newline at end of file