Author Topic: Band Structure  (Read 1447 times)

0 Members and 1 Guest are viewing this topic.

Offline Jahanzaib

  • QuantumATK Guru
  • ****
  • Posts: 103
  • Country: gb
  • Reputation: 3
    • View Profile
Band Structure
« on: October 30, 2024, 15:41 »
Dear Expert,

I have attached my band structure plot, and I would like to recreate this plot using "atkpython." Is there a way to extract the necessary information using a script?

Additionally, I already have a script for the density of states of the same system, and I was wondering if it would be possible to plot both BS and DOS side by side.

Thank you!
« Last Edit: October 30, 2024, 16:00 by Jahanzaib »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Band Structure
« Reply #1 on: October 30, 2024, 21:26 »
The easiest way to plot bands and DOS next to each other is in the GUI. You can drag and drop one of the plots onto the other to combine them.

Offline Jahanzaib

  • QuantumATK Guru
  • ****
  • Posts: 103
  • Country: gb
  • Reputation: 3
    • View Profile
Re: Band Structure
« Reply #2 on: October 31, 2024, 00:53 »
Thank you so much. Is there a way to extract BS using python code?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Band Structure
« Reply #3 on: October 31, 2024, 20:23 »
You can always extract the eigenvalues and k-points using the evaluate() and kpoints() methods on the band structure object (see https://docs.quantumatk.com/manual/Types/Bandstructure/Bandstructure.html), but recreating the plot with correct horizontal axis etc is quite complex, esp. when you have a non-trivial path in the Brillouin zone.

Offline Jahanzaib

  • QuantumATK Guru
  • ****
  • Posts: 103
  • Country: gb
  • Reputation: 3
    • View Profile
Re: Band Structure
« Reply #4 on: November 1, 2024, 04:12 »
Actually I saw your code in the previous discussion where you mentioned to extract BS using python code. The code is given below:
So, I am interested for my sytem, but it doesnot given what I saw in GUI. I already knew how to combine both BS and DOS in GUI, but i think using python code, both looks more better for publication ;D ;D

from NanoLanguage import *

# -----------------------------------------------
# Parameters
# -----------------------------------------------
max_band = 100
min_band = 0
min_energy = -20
max_energy = 10
show_grid = True
title = 'Gold FCC'

# Read the bandstructure from a file.
bs = nlread('bandstructure.nc', Bandstructure)[0]

# Read the data in.
data = bs.evaluate()

# Setup the axises.
axixes = bs._axisGUI()
ticks = bs._ticksGUI()
loc = [ t[0] for t in ticks]
label = [ t[1] for t in ticks]
for i in range(len(label)):
    if len(label) != 1:
        label = r'$\Gamma$'

# Slice the data.
sliced_data = data[:,min_band:max_band]

import pylab
pylab.figure()
pylab.plot(axixes, sliced_data, 'k-')
pylab.plot(axixes, numpy.array(axixes)*0.0, 'k--')
pylab.xlabel('K')
pylab.ylabel(r'$\epsilon_i$ / eV')
pylab.xticks( loc, label)
pylab.ylim(min_energy, max_energy)
pylab.grid(show_grid)
pylab.title(title)
pylab.show()


Offline Jahanzaib

  • QuantumATK Guru
  • ****
  • Posts: 103
  • Country: gb
  • Reputation: 3
    • View Profile
Re: Band Structure
« Reply #5 on: November 10, 2024, 01:41 »
Hello Expert
Is there a way to change the colors for spin up and down bands in the given figure below? I have checked and tried and I haven't find anything to change color. Please see the attached pictures.

Im previous discussion, I was interested to extract BS using python code?

Offline Habib

  • Regular QuantumATK user
  • **
  • Posts: 16
  • Country: gb
  • Reputation: 0
    • View Profile
Re: Band Structure
« Reply #6 on: November 11, 2024, 15:28 »
Hi Jahanzaib,

Yes, you can change the colour by clicking on the plot editor. From there, select the bands you’re interested in and choose your preferred colour and line width. Please see the attached screenshot for reference.

I’m using QuantumATK 2019.12, but I’m confident there’s a similar option in the new version as well.
cannot help with the python code, but I use the GUI for combining BS and DOS etc.

Kind Regards
Habib

Offline Jahanzaib

  • QuantumATK Guru
  • ****
  • Posts: 103
  • Country: gb
  • Reputation: 3
    • View Profile
Re: Band Structure
« Reply #7 on: November 11, 2024, 15:58 »
Many thanks Habib, I am able to change the color.
I have my code to extract DOS, PDOS but I am also interested to refine my code for BS, So I can make my plot more better.

Offline Jahanzaib

  • QuantumATK Guru
  • ****
  • Posts: 103
  • Country: gb
  • Reputation: 3
    • View Profile
Re: Band Structure
« Reply #8 on: November 11, 2024, 23:47 »
I am using this code to extract BS, but I got error i tried to fix but its not done. The error is (ValueError: x and y must have same first dimension, but have shapes (21,) and (2, 21, 3395))

from NanoLanguage import *
import pylab as P

# Parameters
ncfile = '/u/jem/wolf6252/N-P/With-hyd/Fe/BS/BS.hdf5'
plotfile = 'plot.png'
ymin = -0.5
ymax = 0.5
# Colors for each band structure (add more if you have more than 4 band structures in the file)
colors = ['r','b','g','m']

bandstructures = nlread(ncfile, Bandstructure)

for i,bs in enumerate(bandstructures):
     P.plot(bs._axisGUI(), bs.evaluate(), colors)

# Set x-ticks = the symmetry points
kticks = [ tick[0] for tick in bs._ticksGUI() ]
ticklabels = [ tick[1].replace('Γ','$\Gamma$') for tick in bs._ticksGUI() ]
P.xticks(kticks,ticklabels)

P.grid(kticks)
P.ylim(ymin,ymax)

P.savefig(plotfile)

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5573
  • Country: dk
  • Reputation: 95
    • View Profile
    • QuantumATK at Synopsys
Re: Band Structure
« Reply #9 on: November 18, 2024, 23:11 »
Spin-polarized? If so, make sure to only extract one spin component at the time using bs.evaluate(spin=Spin.Up)