bandu 1.3.1__py3-none-any.whl → 1.3.3__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/abinit_reader.py CHANGED
@@ -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 ------------------------------------------------------#
bandu/bandu.py CHANGED
@@ -8,7 +8,7 @@ from . import wfk_class as wc
8
8
  class BandU():
9
9
  def __init__(
10
10
  self, wfks:Generator, energy_level:float, width:float, grid:bool=True, fft:bool=True, norm:bool=True,
11
- sym:bool=True, low_mem:bool=False, plot:bool=True
11
+ sym:bool=True, low_mem:bool=False, plot:bool=True, real_imag_sep:bool=True
12
12
  )->None:
13
13
  '''
14
14
  BandU object with methods for finding states and computing BandU functions from states.
@@ -56,7 +56,10 @@ class BandU():
56
56
  self._FindStates(energy_level, width, wfks)
57
57
  print(f'{self.found_states} states found within specified energy range')
58
58
  # construct principal orbital components
59
- principal_vals = self._PrincipalComponents()
59
+ if real_imag_sep:
60
+ principal_vals = self._RealImagPrnplComps()
61
+ else:
62
+ principal_vals = self._PrincipalComponents()
60
63
  # plot eigenvalues from PCA
61
64
  if plot:
62
65
  self._PlotEigs(principal_vals)
@@ -64,7 +67,11 @@ class BandU():
64
67
  for i in range(self.found_states):
65
68
  self.bandu_fxns[i] = self.bandu_fxns[i].Normalize()
66
69
  # compute ratios
67
- omega_vals, omega_check = self._CheckOmega()
70
+ if not real_imag_sep:
71
+ omega_vals, omega_check = self._CheckOmega()
72
+ else:
73
+ omega_vals = 0
74
+ omega_check = 0
68
75
  # write output file
69
76
  fermi = self.bandu_fxns[0].fermi_energy
70
77
  with open('eigenvalues.out', 'w') as f:
@@ -163,7 +170,7 @@ class BandU():
163
170
  dupes.extend(shifted_dupe)
164
171
  self.duped_states += self.found_states
165
172
  self.bandu_fxns.extend(dupes)
166
- #-----------------------------------------------------------------------------------------------------------------#
173
+ #-----------------------------------------------------------------------------------------------------------------#
167
174
  # find principal components
168
175
  def _PrincipalComponents(
169
176
  self
@@ -191,6 +198,40 @@ class BandU():
191
198
  self.bandu_fxns[i].wfk_coeffs = mat[i,:]
192
199
  return principal_vals
193
200
  #-----------------------------------------------------------------------------------------------------------------#
201
+ # find principal components with real and imaginary separated
202
+ def _RealImagPrnplComps(
203
+ self
204
+ )->np.ndarray:
205
+ x = self.bandu_fxns[0].ngfftx
206
+ y = self.bandu_fxns[0].ngffty
207
+ z = self.bandu_fxns[0].ngfftz
208
+ mat = np.zeros((2*self.found_states,x*y*z), dtype=complex)
209
+ for i in range(self.found_states):
210
+ ind = 2*i
211
+ real_coeffs = self.bandu_fxns[i].wfk_coeffs.real
212
+ imag_coeffs = self.bandu_fxns[i].wfk_coeffs.imag
213
+ mat[ind,:] = real_coeffs.reshape((1,x*y*z))
214
+ mat[ind+1,:] = imag_coeffs.reshape((1,x*y*z))
215
+ print('Computing overlap matrix')
216
+ overlap_mat = np.matmul(np.conj(mat),mat.T)
217
+ # diagonlize matrix
218
+ principal_vals, principal_vecs = np.linalg.eig(overlap_mat)
219
+ principal_vecs = principal_vecs.T
220
+ # organize eigenvectors and eigenvalues
221
+ sorted_inds = np.flip(principal_vals.argsort())
222
+ principal_vals = np.take(principal_vals, sorted_inds)
223
+ principal_vecs = np.take(principal_vecs, sorted_inds, axis=0)
224
+ mat = np.matmul(principal_vecs, mat)
225
+ for i in range(2*self.found_states):
226
+ if i < self.found_states:
227
+ self.bandu_fxns[i].wfk_coeffs = mat[i,:]
228
+ else:
229
+ new_coeffs = copy(self.bandu_fxns[0])
230
+ new_coeffs.wfk_coeffs = mat[i,:]
231
+ self.bandu_fxns.append(new_coeffs)
232
+ self.found_states *= 2
233
+ return principal_vals
234
+ #-----------------------------------------------------------------------------------------------------------------#
194
235
  # find ratio of real and imaginary components
195
236
  def _CheckOmega(
196
237
  self
bandu/xsf_reader.py CHANGED
@@ -13,8 +13,20 @@ atom_labels = {1:'H', 2:'He', 3:'Li', 4:'Be', 5:'B', 6:'C', 7:'N', 8:'O', 9:'F',
13
13
  class XSF():
14
14
  def __init__(
15
15
  self,
16
- xsf_file:str='WFK.xsf'
16
+ xsf_file:str='WFK.xsf',
17
+ datagrid:str='BEGIN_DATAGRID_3D_principal_orbital_component'
17
18
  )->None:
19
+ '''
20
+ Class for reading in XSF files
21
+
22
+ Parameters
23
+ ----------
24
+ xsf_file : str
25
+ Path to XSF file
26
+ datagrid : str
27
+ Name of datagrid to be read in\n
28
+ Default is "BEGIN_DATAGRID_3D_principal_orbital_component"
29
+ '''
18
30
  # if xsf file is supplied, read in parameters
19
31
  self.xsf_file = xsf_file
20
32
  with open(xsf_file, 'r') as xsf:
@@ -40,7 +52,7 @@ class XSF():
40
52
  del coord[0]
41
53
  self.coords[atom,:] = coord
42
54
  # once density block is reached, get ngfft spacing and end init
43
- if line.strip() == 'BEGIN_DATAGRID_3D_principal_orbital_component':
55
+ if line.strip() == datagrid:
44
56
  ngfft_spacing = self.xsf_lines[i+1].strip().split(' ')
45
57
  ngfft_spacing = [int(val) for val in ngfft_spacing]
46
58
  self.ngfftx = ngfft_spacing[0]
@@ -54,11 +66,6 @@ class XSF():
54
66
  )->np.ndarray:
55
67
  '''
56
68
  Method for reading in density grid from XSF file. Returns grid as N dimensional numpy array.
57
-
58
- Parameters
59
- ----------
60
- undo_xsf : bool
61
- If True (which is the default), then the XSF formatting is undone by removing end points.
62
69
  '''
63
70
  density_lines:list|np.ndarray=[]
64
71
  for i, line in enumerate(self.xsf_lines):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bandu
3
- Version: 1.3.1
3
+ Version: 1.3.3
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=ivrHoozX_oN-bbhMW-vb4FzodcIVM-wcO8-MRzo39H4,47556
2
+ bandu/bandu.py,sha256=p6qdt1LG1uPFPMGiZfypTOhxlT84xYU52juy8pSv-4s,14666
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=jvxsvabzTxgWUZxX2XtO1VFoMdiu0C_qXdODJqpBfrA,27718
7
+ bandu/translate.py,sha256=YGTkwne4bdrw649OjRKBio7IBsCNVoa__rjkFZK6uRI,2217
8
+ bandu/wfk_class.py,sha256=j7bvEAb9eUU77mHGNLGdPpmpgVBb6bsKQqej9n0cANc,26203
9
+ bandu/xsf_reader.py,sha256=tkJaBiUHsEKvpdJishi-MZyU1NYYMsgH_8UuuYsG07A,5030
10
+ bandu-1.3.3.dist-info/licenses/LICENSE,sha256=jk_B-WYDiyH9RtxC45pO6JUtBxmfX5i240dVzv1okCg,1088
11
+ bandu-1.3.3.dist-info/METADATA,sha256=w1VzntS0rWvnJzXJvFI1sRBTZYDZiguMscJNY9CZPf8,8945
12
+ bandu-1.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ bandu-1.3.3.dist-info/top_level.txt,sha256=AxbMFU3BRdjCr75K9gAdblwlBMQ3qr9-AaCC-IS8OWs,6
14
+ bandu-1.3.3.dist-info/RECORD,,
@@ -1,14 +0,0 @@
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=jvxsvabzTxgWUZxX2XtO1VFoMdiu0C_qXdODJqpBfrA,27718
7
- bandu/translate.py,sha256=YGTkwne4bdrw649OjRKBio7IBsCNVoa__rjkFZK6uRI,2217
8
- bandu/wfk_class.py,sha256=j7bvEAb9eUU77mHGNLGdPpmpgVBb6bsKQqej9n0cANc,26203
9
- bandu/xsf_reader.py,sha256=JegYFLXFaijR09qUauFzQ1IqOcgxxBXx4gfBPtooZfU,4860
10
- bandu-1.3.1.dist-info/licenses/LICENSE,sha256=jk_B-WYDiyH9RtxC45pO6JUtBxmfX5i240dVzv1okCg,1088
11
- bandu-1.3.1.dist-info/METADATA,sha256=WjYkKWHlGeMcrXkolD6uQnDZKIGcAEZEpDcW5XJ5q8A,8945
12
- bandu-1.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- bandu-1.3.1.dist-info/top_level.txt,sha256=AxbMFU3BRdjCr75K9gAdblwlBMQ3qr9-AaCC-IS8OWs,6
14
- bandu-1.3.1.dist-info/RECORD,,
File without changes