bandu 1.1.1__py3-none-any.whl → 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bandu/bandu.py CHANGED
@@ -123,7 +123,7 @@ class BandU():
123
123
  if self.grid:
124
124
  wfk = wfk.GridWFK()
125
125
  if self.fft:
126
- wfk = wfk.FFT()
126
+ wfk = wfk.IFFT()
127
127
  if self.norm:
128
128
  wfk = wfk.Normalize()
129
129
  yield wfk
@@ -244,7 +244,7 @@ class BandU():
244
244
  ):
245
245
  total_states = self.found_states
246
246
  if nums is []:
247
- nums = [0,total_states-1]
247
+ nums = [1,total_states]
248
248
  else:
249
249
  # check if list has only 2 elements
250
250
  if len(nums) != 2:
@@ -268,6 +268,6 @@ class BandU():
268
268
  for i in range(nums[0]-1, nums[1]):
269
269
  file_name = xsf_name + f'_{i+1}'
270
270
  wfk = copy(self.bandu_fxns[i])
271
- wfk.wfk_coeffs = wfk.wfk_coeffs.reshape((z,x,y))
271
+ wfk.wfk_coeffs = wfk.wfk_coeffs.reshape((x,y,z))
272
272
  wfk = wfk.XSFFormat()
273
273
  wfk.WriteXSF(xsf_file=file_name)
bandu/isosurface_class.py CHANGED
@@ -42,6 +42,10 @@ class Isosurface():
42
42
  Default 0.05, this scales inversely with kpoint grid size (larger grids require smaller radius)
43
43
  sym_ops : np.ndarray
44
44
  Array of symmetry operations for generating points in Brillouin Zone
45
+ grid_stretch : float
46
+ Value that stretches grid that is used to interpolate bands
47
+ If portions of Brillouin Zone are cropped off, increase this value
48
+ Default is 0.15
45
49
 
46
50
  Methods
47
51
  -------
@@ -51,7 +55,8 @@ class Isosurface():
51
55
  def __init__(
52
56
  self, points:np.ndarray=np.zeros(1), values:np.ndarray=np.zeros(1), rec_latt:np.ndarray=np.zeros(1),
53
57
  wfk_name:str='', grid_steps:tuple=(50,50,50), fermi_energy:float=0.0, energy_level:float=0.0,
54
- width:float=0.005, radius:float=0.05, nbands:list[int]=[], sym_ops:np.ndarray=np.zeros(1), _debug:bool=False
58
+ width:float=0.005, radius:float=0.05, nbands:list[int]=[], sym_ops:np.ndarray=np.zeros(1),
59
+ grid_stretch:float=0.15
55
60
  )->None:
56
61
  # define attributes
57
62
  self.points=points
@@ -64,9 +69,9 @@ class Isosurface():
64
69
  self.radius=radius
65
70
  self.nbands=nbands
66
71
  self.sym_ops=sym_ops
67
- self._debug=_debug
72
+ self.grid_stretch=grid_stretch
68
73
  # check if enough information is provided to class to construct isosurfaces
69
- if self.points.all() == np.zeros(1) and self.values.all() == np.zeros(1):
74
+ if self.points.shape == (1,) and self.values.shape == (1,):
70
75
  if wfk_name == '':
71
76
  raise ValueError((
72
77
  'Either the points and the values attributes must be defined or the wfk_name attribute '
@@ -126,8 +131,18 @@ class Isosurface():
126
131
  dimy = self.grid_steps[1]
127
132
  dimz = self.grid_steps[2]
128
133
  grid = pv.ImageData()
129
- grid.origin = (xmin-0.035, ymin-0.035, zmin-0.035)
130
- grid.spacing = (2*(xmax+0.05)/dimx, 2*(ymax+0.05)/dimy, 2*(zmax+0.05)/dimz)
134
+ stretch_factor = self.grid_stretch
135
+ dim_stretch = [2*stretch_factor/dim for dim in self.grid_steps]
136
+ grid.origin = (
137
+ xmin - 0.5*stretch_factor,
138
+ ymin - 0.5*stretch_factor,
139
+ zmin - 0.5*stretch_factor
140
+ )
141
+ grid.spacing = (
142
+ 2*xmax/dimx + dim_stretch[0],
143
+ 2*ymax/dimy + dim_stretch[1],
144
+ 2*zmax/dimz + dim_stretch[2]
145
+ )
131
146
  grid.dimensions = (dimx, dimy, dimz)
132
147
  return grid
133
148
  #-----------------------------------------------------------------------------------------------------------------#
@@ -185,22 +200,18 @@ class Isosurface():
185
200
  nkpt = wfk.nkpt
186
201
  self.fermi_energy = wfk.fermi
187
202
  self.rec_latt = wc.WFK(lattice=wfk.real_lattice).Real2Reciprocal()
188
- if self._debug:
189
- eigs = np.zeros((nkpt,10))
190
- band_num = [1,2,3,4,5]
191
- else:
192
- for wfk_obj in wfk.ReadEigenvalues():
193
- eigs.append(wfk_obj.eigenvalues)
194
- eigs = np.array(eigs).reshape((nkpt,nbands))
195
- # look through eigenvalues to find which bands to contour
196
- min_val = self.fermi_energy + self.energy_level - self.width/2
197
- max_val = self.fermi_energy + self.energy_level + self.width/2
198
- band_num = []
199
- for i in range(nbands):
200
- for eigval in eigs[:,i]:
201
- if min_val <= eigval <= max_val:
202
- band_num.append(i)
203
- break
203
+ for wfk_obj in wfk.ReadEigenvalues():
204
+ eigs.append(wfk_obj.eigenvalues)
205
+ eigs = np.array(eigs).reshape((nkpt,nbands))
206
+ # look through eigenvalues to find which bands to contour
207
+ min_val = self.fermi_energy + self.energy_level - self.width/2
208
+ max_val = self.fermi_energy + self.energy_level + self.width/2
209
+ band_num = []
210
+ for i in range(nbands):
211
+ for eigval in eigs[:,i]:
212
+ if min_val <= eigval <= max_val:
213
+ band_num.append(i)
214
+ break
204
215
  # return kpoints and bands of interest
205
216
  bands = np.take(eigs, band_num, axis=1)
206
217
  shifts = brlzn.BZ(self.rec_latt).GetShifts(kpoints)
@@ -222,8 +233,4 @@ class Isosurface():
222
233
  kpoints = np.delete(all_kpts, 0, axis=0)
223
234
  bands = np.delete(all_eigs, 0, axis=0)
224
235
  kpoints = np.matmul(kpoints, self.rec_latt)
225
- if self._debug:
226
- print(kpoints.shape)
227
- print(bands.shape)
228
- raise SystemExit()
229
236
  return kpoints, bands, band_num, ir_kpts
bandu/wfk_class.py CHANGED
@@ -138,16 +138,16 @@ class WFK():
138
138
  If nothing is passed, it is assumed the coefficients of a single band are supplied.
139
139
  '''
140
140
  # initialize 3D grid
141
- gridded_wfk = np.zeros((self.ngfftz, self.ngfftx, self.ngffty), dtype=complex)
141
+ gridded_wfk = np.zeros((self.ngfftx, self.ngffty, self.ngfftz), dtype=complex)
142
142
  # update grid with wfk coefficients
143
143
  for k, kpt in enumerate(self.pw_indices):
144
144
  kx = kpt[0]
145
145
  ky = kpt[1]
146
146
  kz = kpt[2]
147
147
  if band_index >= 0:
148
- gridded_wfk[kz, kx, ky] = self.wfk_coeffs[band_index][k]
148
+ gridded_wfk[kx, ky, kz] = self.wfk_coeffs[band_index][k]
149
149
  else:
150
- gridded_wfk[kz, kx, ky] = self.wfk_coeffs[k]
150
+ gridded_wfk[kx, ky, kz] = self.wfk_coeffs[k]
151
151
  new_WFK = copy(self)
152
152
  new_WFK.wfk_coeffs = gridded_wfk
153
153
  return new_WFK
@@ -166,9 +166,9 @@ class WFK():
166
166
  If nothing is passed, it is assumed the coefficients of a single band are supplied.
167
167
  '''
168
168
  # check if coefficients are gridded before undoing grid format
169
- if self.wfk_coeffs.shape != (self.ngfftz,self.ngfftx,self.ngffty):
169
+ if self.wfk_coeffs.shape != (self.ngfftx,self.ngffty,self.ngfftz):
170
170
  raise ValueError((
171
- f'Plane wave coefficients must be in 3D grid with shape ({self.ngfftz}, {self.ngfftx}, {self.ngffty})'
171
+ f'Plane wave coefficients must be in 3D grid with shape ({self.ngfftx}, {self.ngffty}, {self.ngfftz})'
172
172
  ' in order to remove the gridded format'
173
173
  ))
174
174
  if band_index >= 0:
@@ -192,7 +192,7 @@ class WFK():
192
192
  # Fourier transform reciprocal grid to real space grid
193
193
  real_coeffs = fftn(self.wfk_coeffs, norm='ortho')
194
194
  new_WFK = copy(self)
195
- new_WFK.wfk_coeffs = np.array(real_coeffs).reshape((self.ngfftz, self.ngfftx, self.ngffty))
195
+ new_WFK.wfk_coeffs = np.array(real_coeffs).reshape((self.ngfftx, self.ngffty, self.ngfftz))
196
196
  return new_WFK
197
197
  #-----------------------------------------------------------------------------------------------------------------#
198
198
  # method transforming real space wfks to reciprocal space
@@ -206,7 +206,7 @@ class WFK():
206
206
  # Fourier transform real space grid to reciprocal space grid
207
207
  reciprocal_coeffs = ifftn(self.wfk_coeffs, norm='ortho')
208
208
  new_WFK = copy(self)
209
- new_WFK.wfk_coeffs = reciprocal_coeffs
209
+ new_WFK.wfk_coeffs = np.array(reciprocal_coeffs).reshape((self.ngfftx,self.ngffty,self.ngfftz))
210
210
  return new_WFK
211
211
  #-----------------------------------------------------------------------------------------------------------------#
212
212
  # method for normalizing wfks
@@ -430,34 +430,34 @@ class WFK():
430
430
  # append zeros to ends of all axes in grid_wfk
431
431
  # zeros get replaced by values at beginning of each axis
432
432
  # this repetition is required by XSF format
433
- if np.shape(self.wfk_coeffs) != (self.ngfftz, self.ngfftx, self.ngffty):
433
+ if np.shape(self.wfk_coeffs) != (self.ngfftx, self.ngffty, self.ngfftz):
434
434
  raise ValueError(
435
435
  f'''Passed array is not the correct shape:
436
- Expected: ({self.ngfftz}, {self.ngfftx}, {self.ngffty}),
436
+ Expected: ({self.ngfftx}, {self.ngffty}, {self.ngfftz}),
437
437
  Received: {np.shape(self.wfk_coeffs)}
438
438
  ''')
439
439
  else:
440
440
  grid_wfk = self.wfk_coeffs
441
- grid_wfk = np.append(grid_wfk, np.zeros((1, self.ngfftx, self.ngffty)), axis=0)
442
- grid_wfk = np.append(grid_wfk, np.zeros((self.ngfftz+1, 1, self.ngffty)), axis=1)
443
- grid_wfk = np.append(grid_wfk, np.zeros((self.ngfftz+1, self.ngfftx+1, 1)), axis=2)
441
+ grid_wfk = np.append(grid_wfk, np.zeros((1, self.ngffty, self.ngfftz)), axis=0)
442
+ grid_wfk = np.append(grid_wfk, np.zeros((self.ngfftx+1, 1, self.ngfftz)), axis=1)
443
+ grid_wfk = np.append(grid_wfk, np.zeros((self.ngfftx+1, self.ngffty+1, 1)), axis=2)
444
444
  for x in range(self.ngfftx+1):
445
445
  for y in range(self.ngffty+1):
446
446
  for z in range(self.ngfftz+1):
447
447
  if x == self.ngfftx:
448
- grid_wfk[z][x][y] = grid_wfk[z][0][y]
448
+ grid_wfk[x,y,z] = grid_wfk[0,y,z]
449
449
  if y == self.ngffty:
450
- grid_wfk[z][x][y] = grid_wfk[z][x][0]
450
+ grid_wfk[x,y,z] = grid_wfk[x,0,z]
451
451
  if z == self.ngfftz:
452
- grid_wfk[z][x][y] = grid_wfk[0][x][y]
452
+ grid_wfk[x,y,z] = grid_wfk[x,y,0]
453
453
  if x == self.ngfftx and y == self.ngffty:
454
- grid_wfk[z][x][y] = grid_wfk[z][0][0]
454
+ grid_wfk[x,y,z] = grid_wfk[0,0,z]
455
455
  if x == self.ngfftx and z == self.ngfftz:
456
- grid_wfk[z][x][y] = grid_wfk[0][0][y]
456
+ grid_wfk[x,y,z] = grid_wfk[0,y,0]
457
457
  if z == self.ngfftz and y == self.ngffty:
458
- grid_wfk[z][x][y] = grid_wfk[0][x][0]
458
+ grid_wfk[x,y,z] = grid_wfk[x,0,0]
459
459
  if x == self.ngfftx and y == self.ngffty and z == self.ngfftz:
460
- grid_wfk[z][x][y] = grid_wfk[0][0][0]
460
+ grid_wfk[x,y,z] = grid_wfk[0,0,0]
461
461
  new_WFK = copy(self)
462
462
  new_WFK.wfk_coeffs = grid_wfk
463
463
  new_WFK.ngfftx += 1
@@ -474,18 +474,18 @@ class WFK():
474
474
  '''
475
475
  grid = self.wfk_coeffs
476
476
  # to_be_del will be used to remove all extra data points added for XSF formatting
477
- to_be_del = np.ones((self.ngfftz, self.ngfftx, self.ngffty), dtype=bool)
477
+ to_be_del = np.ones((self.ngfftx, self.ngffty, self.ngfftz), dtype=bool)
478
478
  for z in range(self.ngfftz):
479
- for x in range(self.ngfftx):
480
- for y in range(self.ngffty):
479
+ for y in range(self.ngffty):
480
+ for x in range(self.ngfftx):
481
481
  # any time you reach the last density point it is a repeat of the first point
482
482
  # remove the end points along each axis
483
483
  if y == self.ngffty - 1 or x == self.ngfftx - 1 or z == self.ngfftz - 1:
484
- to_be_del[z,x,y] = False
484
+ to_be_del[x,y,z] = False
485
485
  # remove xsf entries from array
486
486
  grid = grid[to_be_del]
487
487
  # restore grid shape
488
- grid = grid.reshape((self.ngfftz-1, self.ngfftx-1, self.ngffty-1))
488
+ grid = grid.reshape((self.ngfftx-1, self.ngffty-1, self.ngfftz-1))
489
489
  new_WFK = copy(self)
490
490
  new_WFK.wfk_coeffs = grid
491
491
  new_WFK.ngfftx -= 1
@@ -522,16 +522,16 @@ class WFK():
522
522
  print(f'{self.natom} 1', file=xsf)
523
523
  for i, coord in enumerate(self.xred):
524
524
  atomic_num = int(self.znucltypat[self.typat[i] - 1])
525
- cart_coord = np.dot(coord, self.lattice)
525
+ cart_coord = np.matmul(coord, self.lattice)
526
526
  print(f'{atomic_num} {cart_coord[0]} {cart_coord[1]} {cart_coord[2]}', file=xsf)
527
527
  print('ATOMS', file=xsf)
528
528
  for i, coord in enumerate(self.xred):
529
529
  atomic_num = int(self.znucltypat[self.typat[i] - 1])
530
- cart_coord = np.dot(coord, self.lattice)
530
+ cart_coord = np.matmul(coord, self.lattice)
531
531
  print(f'{atomic_num} {cart_coord[0]} {cart_coord[1]} {cart_coord[2]}', file=xsf)
532
- print('BEGIN_BLOCK_DATAGRID3D', file=xsf)
532
+ print('BEGIN_BLOCK_DATAGRID_3D', file=xsf)
533
533
  print('datagrids', file=xsf)
534
- print('DATAGRID_3D_DENSITY', file=xsf)
534
+ print('BEGIN_DATAGRID_3D_principal_orbital_component', file=xsf)
535
535
  print(f'{self.ngfftx} {self.ngffty} {self.ngfftz}', file=xsf)
536
536
  print('0.0 0.0 0.0', file=xsf)
537
537
  print(f'{self.lattice[0,0]} {self.lattice[0,1]} {self.lattice[0,2]}', file=xsf)
@@ -539,18 +539,18 @@ class WFK():
539
539
  print(f'{self.lattice[2,0]} {self.lattice[2,1]} {self.lattice[2,2]}', file=xsf)
540
540
  count = 0
541
541
  for z in range(self.ngfftz):
542
- for x in range(self.ngfftx):
543
- for y in range(self.ngffty):
542
+ for y in range(self.ngffty):
543
+ for x in range(self.ngfftx):
544
544
  count += 1
545
545
  if _component:
546
- print(self.wfk_coeffs[z,x,y].real, file=xsf, end=' ')
546
+ print(self.wfk_coeffs[x,y,z].real, file=xsf, end=' ')
547
547
  else:
548
- print(self.wfk_coeffs[z,x,y].imag, file=xsf, end=' ')
548
+ print(self.wfk_coeffs[x,y,z].imag, file=xsf, end=' ')
549
549
  if count == 6:
550
550
  count = 0
551
551
  print('\n', file=xsf, end='')
552
552
  print('END_DATAGRID_3D', file=xsf)
553
- print('END_BLOCK_DATAGRID3D', file=xsf)
553
+ print('END_BLOCK_DATAGRID_3D', file=xsf)
554
554
  # rerun method to write out imaginary part
555
555
  if _component:
556
556
  xsf_file = xsf_file.split('_real')[0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bandu
3
- Version: 1.1.1
3
+ Version: 1.3.0
4
4
  Summary: The BandU program constructs a rank ordered series of crystal orbitals using principal component analysis. These principal orbital components can then be projected on the Fermi surface and visualized
5
5
  Author-email: Patrick Cross <pcross@wisc.edu>
6
6
  Project-URL: Homepage, https://github.com/pcross0405/BandU
@@ -0,0 +1,14 @@
1
+ bandu/abinit_reader.py,sha256=U4HUUTnju9MpyGtWMOedUQLln90k2F0XIv0Q0zcP05c,47704
2
+ bandu/bandu.py,sha256=1B7FZb3eYNm9JhPzEwZoGCAUNZpPD9Oux79eVCwSopE,12785
3
+ bandu/brillouin_zone.py,sha256=-SarCuvUthk5h_sFHM6KDHLns1eCWGk_v5fHngWFu08,7997
4
+ bandu/colors.py,sha256=OcIBwVh9ieu04n1cruRgyoYslKsdfJKf-u4oWMd3CwQ,2316
5
+ bandu/isosurface_class.py,sha256=M6XAuy89uyX3v_JX3wYd5VqAWel9JiMQ7wRBhFhhn3A,10236
6
+ bandu/plotter.py,sha256=wSIA1TpwhioPUHpBe4_gc14e8K98fv3q0LwwD5NLboo,27725
7
+ bandu/translate.py,sha256=YGTkwne4bdrw649OjRKBio7IBsCNVoa__rjkFZK6uRI,2217
8
+ bandu/wfk_class.py,sha256=ANpGtdB5DUJsUjs9804t6Vmoh5wtWGmAzelE-b57pWo,26221
9
+ bandu/xsf_reader.py,sha256=gfv7LsTofWw4PrcOeqltOREJD6RLDq8CeFSsnlfohEw,4778
10
+ bandu-1.3.0.dist-info/licenses/LICENSE,sha256=jk_B-WYDiyH9RtxC45pO6JUtBxmfX5i240dVzv1okCg,1088
11
+ bandu-1.3.0.dist-info/METADATA,sha256=WivTIcB4CKkcOc5PySUPPT5f2RxhComT_qRhf2O_0fs,8945
12
+ bandu-1.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ bandu-1.3.0.dist-info/top_level.txt,sha256=AxbMFU3BRdjCr75K9gAdblwlBMQ3qr9-AaCC-IS8OWs,6
14
+ bandu-1.3.0.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- bandu/abinit_reader.py,sha256=U4HUUTnju9MpyGtWMOedUQLln90k2F0XIv0Q0zcP05c,47704
2
- bandu/bandu.py,sha256=EA8AsM517NrnUL6Za5q4W0NAklOCbLomvY_7v51jQ48,12786
3
- bandu/brillouin_zone.py,sha256=-SarCuvUthk5h_sFHM6KDHLns1eCWGk_v5fHngWFu08,7997
4
- bandu/colors.py,sha256=OcIBwVh9ieu04n1cruRgyoYslKsdfJKf-u4oWMd3CwQ,2316
5
- bandu/isosurface_class.py,sha256=o9VqcZ8b1tqkSQN6oJp7PSPkt-QNZg1V_IUbhAsFcgA,10018
6
- bandu/plotter.py,sha256=wSIA1TpwhioPUHpBe4_gc14e8K98fv3q0LwwD5NLboo,27725
7
- bandu/translate.py,sha256=YGTkwne4bdrw649OjRKBio7IBsCNVoa__rjkFZK6uRI,2217
8
- bandu/wfk_class.py,sha256=zsgC17OcWTLan4riaGW2ObBvFHICmZqbizClJV8hsmI,26158
9
- bandu/xsf_reader.py,sha256=gfv7LsTofWw4PrcOeqltOREJD6RLDq8CeFSsnlfohEw,4778
10
- bandu-1.1.1.dist-info/licenses/LICENSE,sha256=jk_B-WYDiyH9RtxC45pO6JUtBxmfX5i240dVzv1okCg,1088
11
- bandu-1.1.1.dist-info/METADATA,sha256=hLKKV7kP7l0lo6CKnUvHxHXH1_MozcRGG7ck98O1NDw,8945
12
- bandu-1.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- bandu-1.1.1.dist-info/top_level.txt,sha256=AxbMFU3BRdjCr75K9gAdblwlBMQ3qr9-AaCC-IS8OWs,6
14
- bandu-1.1.1.dist-info/RECORD,,
File without changes