Hello,
I am trying to write a python script to read columns of data from a file, construct a vector and plot the vector data at the height of the 'energy eigenvalue with quivers.
The data file contains values in arrays, which are indexed as follows: (1,2,3,4,5)
1) k-point index along the band path
2) energy eigenvalue at that k-point for the given band in ascending order
3) Inner product <v_x|S_x|v_x>, where v are the momentum vectors & S is the spin operator
4) <v_y|S_y|v_y>
5) <v_z|S_z|v_z>
Below is an extract of the data in the file.
I suspect that the error is because column data for a given k-point index has been repeated 8 times, but I seem not to be able to resolve it. Can some one please help me to resolve this? Many Thanks.
Akan2019
I am trying to write a python script to read columns of data from a file, construct a vector and plot the vector data at the height of the 'energy eigenvalue with quivers.
The data file contains values in arrays, which are indexed as follows: (1,2,3,4,5)
1) k-point index along the band path
2) energy eigenvalue at that k-point for the given band in ascending order
3) Inner product <v_x|S_x|v_x>, where v are the momentum vectors & S is the spin operator
4) <v_y|S_y|v_y>
5) <v_z|S_z|v_z>
Below is an extract of the data in the file.
Output:.. .......... .......... .......... ...........
.. .......... .......... .......... ...........
.. .......... .......... .......... ...........
0 -1.50130272 0.29539386 0.10102223 0.11229778
0 -1.50130272 0.12128843 0.10224725 -0.11838105
0 -1.50130272 -0.23449300 -0.12928661 0.15616594
0 -1.50130272 -0.00406320 -0.12316091 0.19962574
0 -1.50130272 -0.09734207 -0.18171369 0.10098940
0 -1.50130272 -0.32677786 -0.10058231 0.19818153
0 -1.50130272 -0.04296365 -0.23818066 0.27718375
0 -1.50130272 0.16150633 0.30050758 -0.27279976
0 -1.50130272 0.22917431 0.23741317 -0.20997378
1 -10.30514599 0.25892590 -0.30211219 0.30279491
1 -10.30514519 -0.25892590 0.30211219 -0.30279491
1 -4.31937390 0.00137811 0.00131593 0.17088916
1 -4.31936483 -0.00148159 -0.00132088 -0.17131238
1 -4.31873238 0.00222529 -0.00095999 -0.14031846
1 -4.31872339 -0.00212181 0.00096493 0.14074167
1 -3.32780691 -0.10005349 -0.10468926 -0.08245917
1 -3.32780687 0.10005350 0.10468926 0.08245917
1 -1.50345745 -0.03940457 -0.00001612 0.24928449
1 -1.50341604 0.04158210 0.00001587 -0.01415652
1 -1.50155535 -0.00130022 0.00014557 -0.41895805
1 -1.50152959 -0.00031409 -0.00021268 0.10965419
1 -1.50143974 0.00168496 0.00016275 -0.22938156
1 -1.50139700 -0.00543279 -0.00012325 0.03405084
1 -1.50119921 -0.00266643 0.00018164 0.14872297
1 -1.50118189 0.00358695 -0.00015420 -0.10866479
1 -1.49957620 0.04234086 -0.00001716 0.23775471
1 -1.49953180 -0.04007677 0.00001758 -0.00830627
2 -10.30286550 0.25906433 -0.30360808 0.30117178
2 -10.30286471 -0.25906433 0.30360808 -0.30117178
2 -4.31964207 0.00503474 0.00072119 0.18418195
2 -4.31962590 -0.00519166 -0.00072270 -0.18488460
2 -4.31833846 0.00547139 -0.00077038 -0.12655688
2 -4.31832237 -0.00531449 0.00077188 0.12725952
2 -3.32777089 -0.08508128 -0.09603560 -0.10626185
2 -3.32777084 0.08508131 0.09603561 0.10626186
2 -1.50606083 -0.07268781 -0.00000978 0.25048951
2 -1.50589834 0.08068684 0.00000968 -0.01762940
3 -10.29909184 0.25868818 -0.30424575 0.30084442
3 -10.29909106 -0.25868818 0.30424575 -0.30084442
3 -4.31988477 0.00809942 0.00057520 0.19719435
.. .......... .......... .......... ...........
.. .......... .......... .......... ...........
.. .......... .......... .......... ...........
2012 -7.17530157 0.47111371 0.03095341 0.15926909
2012 -7.17530153 -0.47111371 -0.03095341 -0.15926909
2012 -6.74613574 -0.15631889 -0.47146077 -0.02570853
2012 -6.74613569 0.15631889 0.47146077 0.02570853
2012 -1.50130272 0.07043042 0.10622515 -0.32089398
2012 -1.50130272 -0.01111296 -0.04815089 0.30052043
2012 -1.50130272 -0.00416382 -0.18072740 0.31338851
2012 -1.50130272 0.05414869 0.16778418 -0.03810172
2012 -1.50130272 -0.08613654 0.06130466 0.05875245
2012 -1.50130272 -0.03268877 0.07182628 0.30880541
2012 -1.50130272 -0.07334530 -0.12579718 -0.10262646
2012 -1.50130272 0.08986212 0.10267243 0.39510054
2012 -1.50130272 -0.07380371 0.14772347 0.24665560
2012 -1.50130272 -0.14678094 -0.06249843 -0.19324538
2012 -1.50130272 -0.01097422 0.13942742 -0.20510344
2012 -1.50130272 0.02379699 -0.31902199 -0.04546258
2012 -1.50130272 0.03577866 -0.13224697 -0.42033007
2012 -1.50130272 0.16498938 0.07147928 -0.29745931
Below is my script, but it is not working.import csv import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D #f=open("my_spin-texture-bands.dat", "r") #if f.mode == 'r': #contents =f.read() with open('path/to/my_spin-texture-bands.dat') as inf: reader = csv.reader(inf, delimiter=" ") ik = list(zip(*reader))[0] #k-points index along band path which spin texture was computed. ek = list(zip(*reader))[1] # energy eigenvalue at k-points along this band path U = list(zip(*reader))[2] # <Vx|Sx|vx> expectation value of Sx V = list(zip(*reader))[3] # <Vy|Sy|vy> expectation value of Sy W = list(zip(*reader))[4] # <Vz|Sz|vz> expectation value of Sz # Make the grid X = np.arange(-ek, ek), Y = np.arange(-ek, ek), Z = np.arange(-ek, ek), # Make the direction data for the arrows U, V, W = np.meshgrid(X, Y, Z) # Color by azimuthal angle c = np.arctan2(V, U) # Flatten and normalize c = (c.ravel() - c.min()) / c.ptp() # Repeat for each body line and two head lines c = np.concatenate((c, np.repeat(c, 2))) # Colormap c = plt.cm.hsv() fig = plt.figure() ax = fig.gca(projection='3d') ax.quiver(X, Y, Z, U, V, W, length=0.1, normalize=True, color=c) plt.show()The error message is IndexError: List out of range.
I suspect that the error is because column data for a given k-point index has been repeated 8 times, but I seem not to be able to resolve it. Can some one please help me to resolve this? Many Thanks.
Akan2019