Author Topic: How to get 2D plt if more than one complex bandstructure is there in one NC file  (Read 2876 times)

0 Members and 1 Guest are viewing this topic.

Offline Mehboob

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Country: in
  • Reputation: 0
    • View Profile
Dear Quantumwise Users,

I'm a novice user of VNL/Quantumwise. I want to visualize the complex band strucutre (both real and imaginary part) in 2D. I've copied the required python file from quantumwise website but the problem is that the NC file contains two complexbandstructure. Can someone kindly tell me, what input is required to identify the required complex bandstructure from the NC file?

With regards,
Mehboob Alam
University of Calcutta

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5423
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Provided you know the object ID of the correct complex band structure (for instance gID002), you just do
Code: python
cbs = nlread("file.nc", object_id="gID002")[0]
To inspect the IDs, use the Result Browser in VNL. The last added object will have the highest number.

Offline Mehboob

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Country: in
  • Reputation: 0
    • View Profile
Hello Anders Blom,

Thanks for your kind help.

Regards,
Mehboob

Offline Mehboob

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Country: in
  • Reputation: 0
    • View Profile
Hello Everyone,

I have successfully obtained the 2D complex band structure for my system but the obtained plot does not have the scale division on either of the two axes. The script I used for this purpose is as below -

from NanoLanguage import *
import matplotlib.pyplot as plt
import math

# Read the complex bandstructure object from the NC file
cbs = nlread('/home/swapanchem/mehboob/cdcomplex-complexbandk5-121-k55-10001points-e-0-5.nc', object_id="gID003")[0]
energies = cbs.energies().inUnitsOf(eV)
k_real, k_complex = cbs.evaluate()

ax = plt.axes()
cmap="Spectral"

# First plot the real bands
kvr = numpy.array([])
e = numpy.array([])
for (j, energy) in enumerate(energies):
    k = k_real[j]*cbs.layerSeparation()/math.pi
    if len(k)>0:
        e = numpy.append(e,[energy,]*len(k))
        kvr = numpy.append(kvr,k)
       
# Plot
ax.scatter(kvr, e,
           c=numpy.abs(kvr),
           cmap=cmap, marker='o', linewidths=0, s=10)

# Next plot the complex bands
kvr = numpy.array([])
kvi = numpy.array([])
e = numpy.array([])

for (j, energy) in enumerate(energies):
    if len(k_complex[j])>0:
        kr = [numpy.abs(x.real) for x in k_complex[j]]
        ki = [numpy.abs(x.imag) for x in k_complex[j]]
        e = numpy.append(e,[energy,]*len(kr))
        kvr = numpy.append(kvr,kr)
        kvi = numpy.append(kvi,ki)

# Plot with color depending on the imaginary part (corresponding to real k-points)
sc = ax.scatter(-kvi,e,
               c=kvr,
               cmap=cmap, marker='o', linewidths=0, s=10)
               
# Put on labels and decorations
ax.axvline(0,color='b')
ax.grid(True, which='major')
ax.set_xlim(-1, 1)
ax.set_ylim(-5, 1)
plt.xticks([])
plt.yticks([])
ax.annotate('$\kappa$ (1/Ang)', xy=(0.25,-0.07), xycoords="axes fraction", ha="center")
ax.annotate('$kL / \pi$', xy=(0.75,-0.07), xycoords="axes fraction", ha="center")
ax.set_ylabel('Energy / eV')

# Add a colorbar
fig = plt.gcf()
x1, x2, y1, y2 = 0., 1, ax.get_ylim()[0], ax.get_ylim()[0]+1
trans = ax.transData + fig.transFigure.inverted()
ax_x1, ax_y1 = trans.transform_point([x1, y1])
ax_x2, ax_y2 = trans.transform_point([x2, y2])
ax_dx, ax_dy = ax_x2 - ax_x1, ax_y2 - ax_y1
cmap_axes = plt.axes([ax_x1, ax_y1, ax_dx, ax_dy])
a = numpy.outer(numpy.arange(0,1,0.01),numpy.ones(10)).transpose()
cmap_plt = plt.imshow(a,aspect='auto',cmap=plt.get_cmap(cmap),origin=(0,0))

plt.show()




I have tried to change the two lines
ax.set_xlim
ax.set_ylim
but without any success.

Kindly tell me which parameter in the script should I change to get the axis scale properly.

With best regards,
Mehboob

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5423
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
I didn't have time to check it carefully, but it appears reasonable that you get no ticks if you use

plt.xticks([])
plt.yticks([])

Offline Mehboob

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Country: in
  • Reputation: 0
    • View Profile
The script, I've posted, is taken from the quantumwise tutorial on complex band structure. In the same tutorial, the plots given (just below the script) have proper axes scales. As I don't know much about python, I could not understand which parameter should be changed. In the given script, I have just changed the range of Y-axis (as per my requirement) and nothing else. It gives the plot but not with the axes scale.

Offline Mehboob

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Country: in
  • Reputation: 0
    • View Profile
Hello Anderson,

Thanks for the clue..I have put the values (in plt.xticks and plt.yticks) where I need the ticks and now I get the axes scaling properly.
Once again, thanks.

With best regards,
Mehboob