bandu 1.3.0__tar.gz → 1.3.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bandu
3
- Version: 1.3.0
3
+ Version: 1.3.2
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "bandu"
7
- version = "1.3.0"
7
+ version = "1.3.2"
8
8
  authors = [
9
9
  { name="Patrick Cross", email="pcross@wisc.edu" },
10
10
  ]
@@ -963,11 +963,7 @@ class AbinitNetCDF():
963
963
  self.nband:int = int(self.dataset.dimensions['bantot'].size / self.nkpt)
964
964
  self.typat:list = self.dataset.variables['atom_species'][:].tolist()
965
965
  self.zion:np.ndarray = self.dataset.variables['atomic_numbers'][:]
966
- _all_ions = [int(self.zion[i-1]) for i in self.typat]
967
- self.znucltypat:list = []
968
- for i in _all_ions:
969
- if i not in self.znucltypat:
970
- self.znucltypat.append(i)
966
+ self.znucltypat:list = [int(nuc) for nuc in self.zion]
971
967
  self.bands = [self.nband]
972
968
  #---------------------------------------------------------------------------------------------------------------------#
973
969
  #------------------------------------------------------ METHODS ------------------------------------------------------#
@@ -338,8 +338,8 @@ class Plotter():
338
338
  self.p.app.exec_() # type: ignore
339
339
  #-----------------------------------------------------------------------------------------------------------------#
340
340
  # method to compute bandu fxn and one electron wfk overlaps
341
- def _Overlaps_w_sym(
342
- self, ir_wfk:wc.WFK, bandu:wc.WFK, num_bands:int
341
+ def _OverlapsWithSym(
342
+ self, ir_wfk:wc.WFK, bandu:wc.WFK
343
343
  )->np.ndarray:
344
344
  # kpoint to symmetrically generate
345
345
  kpt = ir_wfk.kpoints
@@ -348,15 +348,14 @@ class Plotter():
348
348
  dupes, unique_inds = ir_wfk._FindOrbit(sym_kpoints)
349
349
  count = sum([1 for i, _ in enumerate(unique_inds) if i not in dupes])
350
350
  # initialize array for overlap values
351
+ num_bands = len(self.isosurface.nbands)
351
352
  overlap_vals = np.zeros((count,num_bands), dtype=float)
352
- if self._debug:
353
- return overlap_vals
354
353
  # loop over bands
355
354
  for i, band in enumerate(self.isosurface.nbands):
356
355
  # generate symmetric coefficients for each band
357
356
  for j, wfk in enumerate(ir_wfk.SymWFKs(kpoint=kpt, band=band)):
358
357
  wfk = wfk.GridWFK()
359
- wfk = wfk.FFT()
358
+ wfk = wfk.IFFT()
360
359
  wfk = wfk.Normalize()
361
360
  overlap = np.sum(np.conj(bandu.wfk_coeffs)*wfk.wfk_coeffs)
362
361
  overlap = np.square(np.abs(overlap))
@@ -364,15 +363,16 @@ class Plotter():
364
363
  return overlap_vals
365
364
  #-----------------------------------------------------------------------------------------------------------------#
366
365
  # method to compute bandu fxn and one electron wfk overlaps
367
- def _Overlaps_no_sym(
368
- self, ir_wfk:wc.WFK, bandu:wc.WFK, num_bands:int
366
+ def _OverlapsNoSym(
367
+ self, ir_wfk:wc.WFK, bandu:wc.WFK
369
368
  )->np.ndarray:
370
369
  # initialize array for overlap values
370
+ num_bands = len(self.isosurface.nbands)
371
371
  overlap_vals = np.zeros((1,num_bands), dtype=float)
372
372
  # loop over bands
373
373
  for i, band in enumerate(self.isosurface.nbands):
374
374
  wfk = ir_wfk.GridWFK(band_index=band)
375
- wfk = wfk.FFT()
375
+ wfk = wfk.IFFT()
376
376
  wfk = wfk.Normalize()
377
377
  overlap = np.sum(np.conj(bandu.wfk_coeffs)*wfk.wfk_coeffs)
378
378
  overlap = np.square(np.abs(overlap))
@@ -430,7 +430,7 @@ class Plotter():
430
430
  # read fermi surface wavefunction
431
431
  fermi_wfk = ar.AbinitWFK(filename=wfk_path)
432
432
  # get number of bands
433
- nband = len(self.isosurface.nbands)
433
+ nbands = len(self.isosurface.nbands)
434
434
  # paths to real and imaginary bandu xsf files
435
435
  real_path = xsf_path + '_real.xsf'
436
436
  imag_path = xsf_path + '_imag.xsf'
@@ -440,7 +440,7 @@ class Plotter():
440
440
  print('XSF read')
441
441
  # convert xsf to wfk object
442
442
  bandu_fxn = wc.WFK(
443
- wfk_coeffs=real_fxn.ReadDensity() + 1j*imag_fxn.ReadDensity(),
443
+ wfk_coeffs=real_fxn.ReadGrid() + 1j*imag_fxn.ReadGrid(),
444
444
  ngfftx=real_fxn.ngfftx,
445
445
  ngffty=real_fxn.ngffty,
446
446
  ngfftz=real_fxn.ngfftz
@@ -450,9 +450,9 @@ class Plotter():
450
450
  # loop through fermi surface kpoints and calc overlap with bandu fxn
451
451
  for i, kpt in enumerate(fermi_wfk.ReadWFK()):
452
452
  if sym:
453
- vals = self._Overlaps_w_sym(kpt, bandu_fxn, nband)
453
+ vals = self._OverlapsWithSym(kpt, bandu_fxn)
454
454
  else:
455
- vals = self._Overlaps_no_sym(kpt, bandu_fxn, nband)
455
+ vals = self._OverlapsNoSym(kpt, bandu_fxn)
456
456
  if i == 0:
457
457
  overlaps = vals
458
458
  else:
@@ -463,8 +463,8 @@ class Plotter():
463
463
  nsym = fermi_wfk.nsym
464
464
  kpts = fermi_wfk.kpts
465
465
  all_kpts = np.zeros((1,3))
466
- all_overlaps = np.zeros((1,nband))
467
- new_wfk = wc.WFK(symrel=np.array(symrel), nsym=nsym, nbands=nband)
466
+ all_overlaps = np.zeros((1,nbands))
467
+ new_wfk = wc.WFK(symrel=np.array(symrel), nsym=nsym, nbands=nbands)
468
468
  for i, kpt in enumerate(kpts):
469
469
  unique_kpts, _ = new_wfk.Symmetrize(
470
470
  points=kpt,
@@ -189,10 +189,10 @@ class WFK():
189
189
  Returns copy of WFK with wavefunction coefficients expressed in real space.
190
190
  Assumes existing wavefunction coefficients are expressed in reciprocal space.
191
191
  '''
192
- # Fourier transform reciprocal grid to real space grid
193
- real_coeffs = fftn(self.wfk_coeffs, norm='ortho')
192
+ # Fourier transform real grid to reciprocal grid
193
+ reciprocal_coeffs = fftn(self.wfk_coeffs, norm='ortho')
194
194
  new_WFK = copy(self)
195
- new_WFK.wfk_coeffs = np.array(real_coeffs).reshape((self.ngfftx, self.ngffty, self.ngfftz))
195
+ new_WFK.wfk_coeffs = np.array(reciprocal_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
@@ -203,10 +203,10 @@ class WFK():
203
203
  Returns copy of WFK with wavefunction coefficients in expressed in reciprocal space.
204
204
  Assumes existing wavefunction coefficients are expressed in real space.
205
205
  '''
206
- # Fourier transform real space grid to reciprocal space grid
207
- reciprocal_coeffs = ifftn(self.wfk_coeffs, norm='ortho')
206
+ # Fourier transform reciprocal grid to real grid
207
+ real_coeffs = ifftn(self.wfk_coeffs, norm='ortho')
208
208
  new_WFK = copy(self)
209
- new_WFK.wfk_coeffs = np.array(reciprocal_coeffs).reshape((self.ngfftx,self.ngffty,self.ngfftz))
209
+ new_WFK.wfk_coeffs = np.array(real_coeffs).reshape((self.ngfftx,self.ngffty,self.ngfftz))
210
210
  return new_WFK
211
211
  #-----------------------------------------------------------------------------------------------------------------#
212
212
  # method for normalizing wfks
@@ -40,7 +40,7 @@ class XSF():
40
40
  del coord[0]
41
41
  self.coords[atom,:] = coord
42
42
  # once density block is reached, get ngfft spacing and end init
43
- if line.strip() == 'DATAGRID_3D_DENSITY':
43
+ if line.strip() == 'BEGIN_DATAGRID_3D_principal_orbital_component':
44
44
  ngfft_spacing = self.xsf_lines[i+1].strip().split(' ')
45
45
  ngfft_spacing = [int(val) for val in ngfft_spacing]
46
46
  self.ngfftx = ngfft_spacing[0]
@@ -49,7 +49,7 @@ class XSF():
49
49
  return None
50
50
  #-----------------------------------------------------------------------------------------------------------------#
51
51
  # method reading in BandU eigenfunction from XSF
52
- def ReadDensity(
52
+ def ReadGrid(
53
53
  self
54
54
  )->np.ndarray:
55
55
  '''
@@ -63,22 +63,22 @@ class XSF():
63
63
  density_lines:list|np.ndarray=[]
64
64
  for i, line in enumerate(self.xsf_lines):
65
65
  # get density block, this assumes density is the end most data grid in the XSF
66
- if line.strip() == 'DATAGRID_3D_DENSITY':
67
- # density starts 6 lines down from DATAGRID_3D_DENSITY header
66
+ if line.strip() == 'BEGIN_DATAGRID_3D_principal_orbital_component':
67
+ # density starts 6 lines down from BEGIN_DATAGRID_3D_principal_orbital_component header
68
68
  density_lines = self.xsf_lines[i+6:]
69
69
  # last line indicates end of data block, remove it
70
70
  del density_lines[-1]
71
- # last entry in density is a string indicating end of density, remove it
71
+ # last entry in datagrid has a string indicating end of grid, remove it
72
72
  last_line = density_lines[-1].strip().split(' ')
73
73
  last_line = [val for val in last_line if val != 'END_DATAGRID_3D']
74
74
  # cast line back to a single string
75
75
  last_line = ' '.join(last_line)
76
76
  density_lines[-1] = last_line
77
77
  if density_lines is []:
78
- raise LookupError('3D density data not found in XSF file')
78
+ raise LookupError('3D grid data not found in XSF file')
79
79
  # convert density to 3D array of floats
80
80
  density_lines = [line.strip().split(' ') for line in density_lines]
81
81
  density_lines = [val for line in density_lines for val in line if val != '']
82
82
  density_lines = np.array(density_lines, dtype=float)
83
- density_lines = density_lines.reshape((self.ngfftz, self.ngfftx, self.ngffty))
83
+ density_lines = density_lines.reshape((self.ngfftx, self.ngffty, self.ngfftz), order='F')
84
84
  return density_lines
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bandu
3
- Version: 1.3.0
3
+ Version: 1.3.2
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes