bandu 1.3.6__py3-none-any.whl → 1.3.7__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/xsf_reader.py CHANGED
@@ -1,92 +1,92 @@
1
- import numpy as np
2
-
3
- atom_labels = {1:'H', 2:'He', 3:'Li', 4:'Be', 5:'B', 6:'C', 7:'N', 8:'O', 9:'F', 10:'Ne', 11:'Na', 12:'Mg', 13:'Al',
4
- 14:'Si', 15:'P', 16:'S', 17:'Cl', 18:'Ar', 19:'K', 20:'Ca', 21:'Sc', 22:'Ti', 23:'V', 24:'Cr', 25:'Mn',
5
- 26:'Fe', 27:'Co', 28:'Ni', 29:'Cu', 30:'Zn', 31:'Ga', 32:'Ge', 33:'As', 34:'Se', 35:'Br', 36:'Kr',
6
- 37:'Rb', 38:'Sr', 39:'Y', 40:'Zr', 41:'Nb', 42:'Mo', 43:'Tc', 44:'Ru', 45:'Rh', 46:'Pd', 47:'Ag',
7
- 48:'Cd', 49:'In', 50:'Sn', 51:'Sb', 52:'Te', 53:'I', 54:'Xe', 55:'Cs', 56:'Ba', 57:'La', 58:'Ce',
8
- 59:'Pr', 60:'Nd', 61:'Pm', 62:'Sm', 63:'Eu', 64:'Gd', 65:'Tb', 66:'Dy', 67:'Ho', 68:'Er', 69:'Tm',
9
- 70:'Yb', 71:'Lu', 72:'Hf', 73:'Ta', 74:'W', 75:'Re', 76:'Os', 77:'Ir', 78:'Pt', 79:'Au', 80:'Hg',
10
- 81:'Tl', 82:'Pb', 83:'Bi', 84:'Po', 85:'At', 86:'Rn', 87:'Fr', 88:'Ra', 89:'Ac', 90:'Th', 91:'Pa',
11
- 92:'U'}
12
-
13
- class XSF():
14
- def __init__(
15
- self,
16
- xsf_file:str='WFK.xsf',
17
- datagrid:str='BEGIN_DATAGRID_3D_principal_orbital_component'
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
- '''
30
- # if xsf file is supplied, read in parameters
31
- self.xsf_file = xsf_file
32
- self.datagrid = datagrid
33
- with open(xsf_file, 'r') as xsf:
34
- self.xsf_lines = xsf.readlines()
35
- self.lattice = np.zeros((3,3))
36
- for i, line in enumerate(self.xsf_lines):
37
- # get lattice vectors from XSF file
38
- if line.strip() == 'PRIMVEC':
39
- self.lattice[0,:] = [float(val) for val in self.xsf_lines[i+1].strip().split(' ') if val != '']
40
- self.lattice[1,:] = [float(val) for val in self.xsf_lines[i+2].strip().split(' ') if val != '']
41
- self.lattice[2,:] = [float(val) for val in self.xsf_lines[i+3].strip().split(' ') if val != '']
42
- # get number of atoms and atomic symbols
43
- # get atomic coordinates from XSF file
44
- if line.strip() == 'PRIMCOORD':
45
- self.natoms = int(self.xsf_lines[i+1].strip().split(' ')[0])
46
- self.coords = np.zeros((self.natoms, 3))
47
- self.elements = []
48
- for atom in range(self.natoms):
49
- coord = self.xsf_lines[i+atom+2].strip().split(' ')
50
- coord = [float(val) for val in coord if val != '']
51
- element = atom_labels[int(coord[0])]
52
- self.elements.append(element)
53
- del coord[0]
54
- self.coords[atom,:] = coord
55
- # once density block is reached, get ngfft spacing and end init
56
- if line.strip() == self.datagrid:
57
- ngfft_spacing = self.xsf_lines[i+1].strip().split(' ')
58
- ngfft_spacing = [int(val) for val in ngfft_spacing if val != '']
59
- self.ngfftx = ngfft_spacing[0]
60
- self.ngffty = ngfft_spacing[1]
61
- self.ngfftz = ngfft_spacing[2]
62
- return None
63
- #-----------------------------------------------------------------------------------------------------------------#
64
- # method reading in BandU eigenfunction from XSF
65
- def ReadGrid(
66
- self
67
- )->np.ndarray:
68
- '''
69
- Method for reading in density grid from XSF file. Returns grid as N dimensional numpy array.
70
- '''
71
- density_lines:list|np.ndarray=[]
72
- for i, line in enumerate(self.xsf_lines):
73
- # get density block, this assumes density is the end most data grid in the XSF
74
- if line.strip() == self.datagrid:
75
- # density starts 6 lines down from BEGIN_DATAGRID_3D_principal_orbital_component header
76
- density_lines = self.xsf_lines[i+6:]
77
- # last line indicates end of data block, remove it
78
- del density_lines[-1]
79
- # last entry in datagrid has a string indicating end of grid, remove it
80
- last_line = density_lines[-1].strip().split(' ')
81
- last_line = [val for val in last_line if val != 'END_DATAGRID_3D']
82
- # cast line back to a single string
83
- last_line = ' '.join(last_line)
84
- density_lines[-1] = last_line
85
- if density_lines is []:
86
- raise LookupError('3D grid data not found in XSF file')
87
- # convert density to 3D array of floats
88
- density_lines = [line.strip().split(' ') for line in density_lines]
89
- density_lines = [val for line in density_lines for val in line if val != '']
90
- density_lines = np.array(density_lines, dtype=float)
91
- density_lines = density_lines.reshape((self.ngfftx, self.ngffty, self.ngfftz), order='F')
1
+ import numpy as np
2
+
3
+ atom_labels = {1:'H', 2:'He', 3:'Li', 4:'Be', 5:'B', 6:'C', 7:'N', 8:'O', 9:'F', 10:'Ne', 11:'Na', 12:'Mg', 13:'Al',
4
+ 14:'Si', 15:'P', 16:'S', 17:'Cl', 18:'Ar', 19:'K', 20:'Ca', 21:'Sc', 22:'Ti', 23:'V', 24:'Cr', 25:'Mn',
5
+ 26:'Fe', 27:'Co', 28:'Ni', 29:'Cu', 30:'Zn', 31:'Ga', 32:'Ge', 33:'As', 34:'Se', 35:'Br', 36:'Kr',
6
+ 37:'Rb', 38:'Sr', 39:'Y', 40:'Zr', 41:'Nb', 42:'Mo', 43:'Tc', 44:'Ru', 45:'Rh', 46:'Pd', 47:'Ag',
7
+ 48:'Cd', 49:'In', 50:'Sn', 51:'Sb', 52:'Te', 53:'I', 54:'Xe', 55:'Cs', 56:'Ba', 57:'La', 58:'Ce',
8
+ 59:'Pr', 60:'Nd', 61:'Pm', 62:'Sm', 63:'Eu', 64:'Gd', 65:'Tb', 66:'Dy', 67:'Ho', 68:'Er', 69:'Tm',
9
+ 70:'Yb', 71:'Lu', 72:'Hf', 73:'Ta', 74:'W', 75:'Re', 76:'Os', 77:'Ir', 78:'Pt', 79:'Au', 80:'Hg',
10
+ 81:'Tl', 82:'Pb', 83:'Bi', 84:'Po', 85:'At', 86:'Rn', 87:'Fr', 88:'Ra', 89:'Ac', 90:'Th', 91:'Pa',
11
+ 92:'U'}
12
+
13
+ class XSF():
14
+ def __init__(
15
+ self,
16
+ xsf_file:str='WFK.xsf',
17
+ datagrid:str='BEGIN_DATAGRID_3D_principal_orbital_component'
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
+ '''
30
+ # if xsf file is supplied, read in parameters
31
+ self.xsf_file = xsf_file
32
+ self.datagrid = datagrid
33
+ with open(xsf_file, 'r') as xsf:
34
+ self.xsf_lines = xsf.readlines()
35
+ self.lattice = np.zeros((3,3))
36
+ for i, line in enumerate(self.xsf_lines):
37
+ # get lattice vectors from XSF file
38
+ if line.strip() == 'PRIMVEC':
39
+ self.lattice[0,:] = [float(val) for val in self.xsf_lines[i+1].strip().split(' ') if val != '']
40
+ self.lattice[1,:] = [float(val) for val in self.xsf_lines[i+2].strip().split(' ') if val != '']
41
+ self.lattice[2,:] = [float(val) for val in self.xsf_lines[i+3].strip().split(' ') if val != '']
42
+ # get number of atoms and atomic symbols
43
+ # get atomic coordinates from XSF file
44
+ if line.strip() == 'PRIMCOORD':
45
+ self.natoms = int(self.xsf_lines[i+1].strip().split(' ')[0])
46
+ self.coords = np.zeros((self.natoms, 3))
47
+ self.elements = []
48
+ for atom in range(self.natoms):
49
+ coord = self.xsf_lines[i+atom+2].strip().split(' ')
50
+ coord = [float(val) for val in coord if val != '']
51
+ element = atom_labels[int(coord[0])]
52
+ self.elements.append(element)
53
+ del coord[0]
54
+ self.coords[atom,:] = coord
55
+ # once density block is reached, get ngfft spacing and end init
56
+ if line.strip() == self.datagrid:
57
+ ngfft_spacing = self.xsf_lines[i+1].strip().split(' ')
58
+ ngfft_spacing = [int(val) for val in ngfft_spacing if val != '']
59
+ self.ngfftx = ngfft_spacing[0]
60
+ self.ngffty = ngfft_spacing[1]
61
+ self.ngfftz = ngfft_spacing[2]
62
+ return None
63
+ #-----------------------------------------------------------------------------------------------------------------#
64
+ # method reading in BandU eigenfunction from XSF
65
+ def ReadGrid(
66
+ self
67
+ )->np.ndarray:
68
+ '''
69
+ Method for reading in density grid from XSF file. Returns grid as N dimensional numpy array.
70
+ '''
71
+ density_lines:list|np.ndarray=[]
72
+ for i, line in enumerate(self.xsf_lines):
73
+ # get density block, this assumes density is the end most data grid in the XSF
74
+ if line.strip() == self.datagrid:
75
+ # density starts 6 lines down from BEGIN_DATAGRID_3D_principal_orbital_component header
76
+ density_lines = self.xsf_lines[i+6:]
77
+ # last line indicates end of data block, remove it
78
+ del density_lines[-1]
79
+ # last entry in datagrid has a string indicating end of grid, remove it
80
+ last_line = density_lines[-1].strip().split(' ')
81
+ last_line = [val for val in last_line if val != 'END_DATAGRID_3D']
82
+ # cast line back to a single string
83
+ last_line = ' '.join(last_line)
84
+ density_lines[-1] = last_line
85
+ if density_lines is []:
86
+ raise LookupError('3D grid data not found in XSF file')
87
+ # convert density to 3D array of floats
88
+ density_lines = [line.strip().split(' ') for line in density_lines]
89
+ density_lines = [val for line in density_lines for val in line if val != '']
90
+ density_lines = np.array(density_lines, dtype=float)
91
+ density_lines = density_lines.reshape((self.ngfftx, self.ngffty, self.ngfftz), order='F')
92
92
  return density_lines
@@ -1,192 +1,192 @@
1
- Metadata-Version: 2.4
2
- Name: bandu
3
- Version: 1.3.6
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
- Author-email: Patrick Cross <pcross@wisc.edu>
6
- Project-URL: Homepage, https://github.com/pcross0405/BandU
7
- Project-URL: Issues, https://github.com/pcross0405/BandU/issues
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.11
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Dynamic: license-file
15
-
16
- # BandU
17
- -------------------------------------------------------------------------------------------------------
18
- <h1><p align="center">BandU OVERVIEW</p></h1>
19
-
20
- <p align="justify">A package that performs a principal component inspired analysis on the Bloch wavefunctions of
21
- periodic material to provide a real space visualization of the states that significantly contribute to the Fermi surface.
22
- </p>
23
-
24
- <p align="justify">These real space functions can then be projected onto the Fermi surface to provide a clear visual
25
- for where a nesting vector may combine two points in reciprocal space.</p>
26
-
27
- <p align="justify">This package is designed to be very straightforward in its use, offering Fermi surface and BandU function
28
- visualizations in as little as 5 lines of Python script. This package can also be used to just visual the Fermi surface, without
29
- BandU projections, if provided with the necessary k-point and eigenvalue data.</p>
30
-
31
- -------------------------------------------------------------------------------------------------------
32
- <h1><p align="center">INSTALLATION INSTRUCTIONS</p></h1>
33
-
34
- <h2><p align="center">THROUGH GITHUB</p></h2>
35
-
36
- 1) Inside that directory type on the command line
37
- "git clone https://github.com/pcross0405/BandU.git"
38
-
39
- 2) Type "cd BandU"
40
-
41
- 3) Make sure you have python's build tool up to date with
42
- "python3 -m pip install --upgrade build"
43
-
44
- 4) Once up to date type
45
- "python3 -m build"
46
-
47
- 5) This should create a "dist" directory with a .whl file inside
48
-
49
- 6) On the command line type
50
- "pip install dist/*.whl"
51
-
52
- <h2><p align="center">THROUGH PIP</p></h2>
53
-
54
- pip install bandu
55
-
56
- -------------------------------------------------------------------------------------------------------
57
- <h1><p align="center">DEPENDENCIES</p></h1>
58
-
59
- REQUIRED FOR VISUALIZING FERMI SURFACE
60
-
61
- - [pyvista](https://pyvista.org/)
62
-
63
- - [numpy](https://numpy.org/)
64
-
65
- REQUIRED FOR CUSTOM COLORS
66
-
67
- - [matplotlib](https://matplotlib.org/)
68
-
69
- WAVEFUNCTIONS THAT CAN BE READ DIRECTLY
70
-
71
- > Currently only reading directly from ABINIT 7 and 10 wavefunctions is supported.
72
- > Reading eigenvalues from other DFT packages will come in future updates.
73
-
74
- - [ABINIT](https://abinit.github.io/abinit_web/)
75
-
76
- ---------------------------------------------------------------------------------------------------------
77
- <h1><p align="center">REPORTING ISSUES</p></h1>
78
-
79
- Please report any issues [here](https://github.com/pcross0405/BandU/issues)
80
-
81
- -------------------------------------------------------------------------------------------------------------------------
82
- <h1><p align="center">TUTORIAL</p></h1>
83
-
84
- An example script that can run the different functions of the BandU program is given below.
85
- -------------------------------------------------------------------------------------------
86
- <pre>
87
- from bandu.bandu import BandU
88
- from bandu.abinit_reader import AbinitWFK
89
- from bandu.isosurface_class import Isosurface
90
- from bandu.plotter import Plotter
91
- from bandu.colors import Colors
92
-
93
- root_name = 'your file root name here' # root_name of WFK files and of XSF files
94
- xsf_number = 1 # XSF file number to be read in
95
- energy_level = 0.000 # Energy relative to the Fermi energy to be sampled
96
- width = 0.0005 # Search half the the width above and below the specified energy level
97
- wfk_path = f'path\to\WFK\file\{root_name}_o_WFK'
98
- xsf_path = f'path\to\XSF\file\{root_name}_bandu_{xsf_number}'
99
- bandu_name = f'{root_name}_bandu'
100
-
101
- def main(
102
- principal_orbital_components:bool,
103
- fermi_surface:bool,
104
- fermi_surface_projection:bool,
105
- load_fermi_surface:bool
106
- )->None:
107
- # this option will generate the principal orbital components 1 through 10
108
- # to generate more or less, adjust the range of the "nums" keyword in the ToXSF() function
109
- # the energy sampled can be set, relative to the Fermi energy, by changing the the "energy_level" global variable
110
- # states are included in the analysis if they are within +/- 1/2*width of the set energy_level
111
- # to get fewer or more states, decrease or increase, respectively, the "width" global variable
112
- # by default, the prinicipal orbital components are generated from an irreducible wedge of the Brillouin Zone
113
- # to generate from the full BZ, change the "sym" attribute in the BandU class from "False" to "True"
114
- if principal_orbital_components:
115
- wfk_gen = AbinitWFK(wfk_path).ReadWFK(
116
- energy_level = energy_level,
117
- width=width
118
- )
119
- wfk = BandU(
120
- wfks = wfk_gen,
121
- energy_level = energy_level,
122
- width = width,
123
- sym = False
124
- )
125
- wfk.ToXSF(
126
- xsf_name = bandu_name,
127
- nums = [1,10]
128
- )
129
- # this option will only generate an energy isosurface and will not project principal component overlap onto the surface
130
- # the "energy_level" global variable is the energy at which the isosurface will be be generated, relative to the Fermi energy
131
- # so energy_level = 0.0 will generate the Fermi surface
132
- # the "width" global variable determines how many states are included in the generation of the isosurface
133
- # a small width (~10 meV or ~0.5 mHa) is best here as larger widths may introduce bands that do not cross the Fermi energy
134
- # the color of the surface can be changed to any string compatible with the matplotlib colors
135
- # see named colors here: https://matplotlib.org/stable/gallery/color/named_colors.html
136
- # the Plot function has many other keywords to customize the visuals to the users liking, see the docstring for more
137
- elif fermi_surface:
138
- contours = Isosurface(
139
- wfk_name = wfk_path,
140
- energy_level = energy_level,
141
- width = width
142
- )
143
- contours.Contour() # make contours
144
- plot = Plotter(
145
- isosurface = contours,
146
- save_file=f'{root_name}_bandu_{xsf_number}_fermi_surf.pkl'
147
- ) # create plotter object
148
- plot.Plot(
149
- color = 'silver',
150
- ) # plot contours
151
- # this option will generate an energy isosurface as well as project the overlap of a principal orbital component onto the surface
152
- # everything remains the same as the previous option, except now the principal orbtial component XSF file is needed
153
- # also the color of the surface is done with the Colors module by default
154
- # other colors can be made with the Colors module, also any matplotlib colormap works
155
- elif fermi_surface_projection:
156
- contours = Isosurface(
157
- wfk_name = wfk_path,
158
- energy_level = energy_level,
159
- width = width
160
- )
161
- contours.Contour() # make contours
162
- plot = Plotter(
163
- isosurface = contours,
164
- save_file=f'{root_name}_bandu_{xsf_number}_fermi_surf.pkl'
165
- ) # create plotter object
166
- overlap_vals = plot.SurfaceColor(
167
- wfk_path=wfk_path,
168
- xsf_path=xsf_path,
169
- ) # compute overlap between principal orbital component and states in Brillouin Zone
170
- plot.Plot(
171
- surface_vals = overlap_vals,
172
- colormap = Colors().blues,
173
- ) # plot contours
174
- # this option will load a previously generated and saved fermi surface file
175
- # update the "save_path" keyword to match the path and name of your save file
176
- elif load_fermi_surface:
177
- Plotter().Load(
178
- save_path='{root_name}_bandu_{xsf_number}_fermi_surf.pkl',
179
- )
180
- # to run any of the options above, make sure to set that option to "True"
181
- # also be sure that the other options (or at least all options that come before) are set to "False"
182
- # the main function will only run which ever option is the first found to be "True" in top to bottom order
183
- # in other words, the priority follows as most to least in the order:
184
- # principal_orbital_components -> fermi_surface -> fermi_surface_projection -> load_fermi_surface
185
- if __name__ == '__main__':
186
- main(
187
- principal_orbital_components=True,
188
- fermi_surface=True,
189
- fermi_surface_projection=True,
190
- load_fermi_surface=True
191
- )
192
- <pre>
1
+ Metadata-Version: 2.4
2
+ Name: bandu
3
+ Version: 1.3.7
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
+ Author-email: Patrick Cross <pcross@wisc.edu>
6
+ Project-URL: Homepage, https://github.com/pcross0405/BandU
7
+ Project-URL: Issues, https://github.com/pcross0405/BandU/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # BandU
17
+ -------------------------------------------------------------------------------------------------------
18
+ <h1><p align="center">BandU OVERVIEW</p></h1>
19
+
20
+ <p align="justify">A package that performs a principal component inspired analysis on the Bloch wavefunctions of
21
+ periodic material to provide a real space visualization of the states that significantly contribute to the Fermi surface.
22
+ </p>
23
+
24
+ <p align="justify">These real space functions can then be projected onto the Fermi surface to provide a clear visual
25
+ for where a nesting vector may combine two points in reciprocal space.</p>
26
+
27
+ <p align="justify">This package is designed to be very straightforward in its use, offering Fermi surface and BandU function
28
+ visualizations in as little as 5 lines of Python script. This package can also be used to just visual the Fermi surface, without
29
+ BandU projections, if provided with the necessary k-point and eigenvalue data.</p>
30
+
31
+ -------------------------------------------------------------------------------------------------------
32
+ <h1><p align="center">INSTALLATION INSTRUCTIONS</p></h1>
33
+
34
+ <h2><p align="center">THROUGH GITHUB</p></h2>
35
+
36
+ 1) Inside that directory type on the command line
37
+ "git clone https://github.com/pcross0405/BandU.git"
38
+
39
+ 2) Type "cd BandU"
40
+
41
+ 3) Make sure you have python's build tool up to date with
42
+ "python3 -m pip install --upgrade build"
43
+
44
+ 4) Once up to date type
45
+ "python3 -m build"
46
+
47
+ 5) This should create a "dist" directory with a .whl file inside
48
+
49
+ 6) On the command line type
50
+ "pip install dist/*.whl"
51
+
52
+ <h2><p align="center">THROUGH PIP</p></h2>
53
+
54
+ pip install bandu
55
+
56
+ -------------------------------------------------------------------------------------------------------
57
+ <h1><p align="center">DEPENDENCIES</p></h1>
58
+
59
+ REQUIRED FOR VISUALIZING FERMI SURFACE
60
+
61
+ - [pyvista](https://pyvista.org/)
62
+
63
+ - [numpy](https://numpy.org/)
64
+
65
+ REQUIRED FOR CUSTOM COLORS
66
+
67
+ - [matplotlib](https://matplotlib.org/)
68
+
69
+ WAVEFUNCTIONS THAT CAN BE READ DIRECTLY
70
+
71
+ > Currently only reading directly from ABINIT 7 and 10 wavefunctions is supported.
72
+ > Reading eigenvalues from other DFT packages will come in future updates.
73
+
74
+ - [ABINIT](https://abinit.github.io/abinit_web/)
75
+
76
+ ---------------------------------------------------------------------------------------------------------
77
+ <h1><p align="center">REPORTING ISSUES</p></h1>
78
+
79
+ Please report any issues [here](https://github.com/pcross0405/BandU/issues)
80
+
81
+ -------------------------------------------------------------------------------------------------------------------------
82
+ <h1><p align="center">TUTORIAL</p></h1>
83
+
84
+ An example script that can run the different functions of the BandU program is given below.
85
+ -------------------------------------------------------------------------------------------
86
+ <pre>
87
+ from bandu.bandu import BandU
88
+ from bandu.abinit_reader import AbinitWFK
89
+ from bandu.isosurface_class import Isosurface
90
+ from bandu.plotter import Plotter
91
+ from bandu.colors import Colors
92
+
93
+ root_name = 'your file root name here' # root_name of WFK files and of XSF files
94
+ xsf_number = 1 # XSF file number to be read in
95
+ energy_level = 0.000 # Energy relative to the Fermi energy to be sampled
96
+ width = 0.0005 # Search half the the width above and below the specified energy level
97
+ wfk_path = f'path\to\WFK\file\{root_name}_o_WFK'
98
+ xsf_path = f'path\to\XSF\file\{root_name}_bandu_{xsf_number}'
99
+ bandu_name = f'{root_name}_bandu'
100
+
101
+ def main(
102
+ principal_orbital_components:bool,
103
+ fermi_surface:bool,
104
+ fermi_surface_projection:bool,
105
+ load_fermi_surface:bool
106
+ )->None:
107
+ # this option will generate the principal orbital components 1 through 10
108
+ # to generate more or less, adjust the range of the "nums" keyword in the ToXSF() function
109
+ # the energy sampled can be set, relative to the Fermi energy, by changing the the "energy_level" global variable
110
+ # states are included in the analysis if they are within +/- 1/2*width of the set energy_level
111
+ # to get fewer or more states, decrease or increase, respectively, the "width" global variable
112
+ # by default, the prinicipal orbital components are generated from an irreducible wedge of the Brillouin Zone
113
+ # to generate from the full BZ, change the "sym" attribute in the BandU class from "False" to "True"
114
+ if principal_orbital_components:
115
+ wfk_gen = AbinitWFK(wfk_path).ReadWFK(
116
+ energy_level = energy_level,
117
+ width=width
118
+ )
119
+ wfk = BandU(
120
+ wfks = wfk_gen,
121
+ energy_level = energy_level,
122
+ width = width,
123
+ sym = False
124
+ )
125
+ wfk.ToXSF(
126
+ xsf_name = bandu_name,
127
+ nums = [1,10]
128
+ )
129
+ # this option will only generate an energy isosurface and will not project principal component overlap onto the surface
130
+ # the "energy_level" global variable is the energy at which the isosurface will be be generated, relative to the Fermi energy
131
+ # so energy_level = 0.0 will generate the Fermi surface
132
+ # the "width" global variable determines how many states are included in the generation of the isosurface
133
+ # a small width (~10 meV or ~0.5 mHa) is best here as larger widths may introduce bands that do not cross the Fermi energy
134
+ # the color of the surface can be changed to any string compatible with the matplotlib colors
135
+ # see named colors here: https://matplotlib.org/stable/gallery/color/named_colors.html
136
+ # the Plot function has many other keywords to customize the visuals to the users liking, see the docstring for more
137
+ elif fermi_surface:
138
+ contours = Isosurface(
139
+ wfk_name = wfk_path,
140
+ energy_level = energy_level,
141
+ width = width
142
+ )
143
+ contours.Contour() # make contours
144
+ plot = Plotter(
145
+ isosurface = contours,
146
+ save_file=f'{root_name}_bandu_{xsf_number}_fermi_surf.pkl'
147
+ ) # create plotter object
148
+ plot.Plot(
149
+ color = 'silver',
150
+ ) # plot contours
151
+ # this option will generate an energy isosurface as well as project the overlap of a principal orbital component onto the surface
152
+ # everything remains the same as the previous option, except now the principal orbtial component XSF file is needed
153
+ # also the color of the surface is done with the Colors module by default
154
+ # other colors can be made with the Colors module, also any matplotlib colormap works
155
+ elif fermi_surface_projection:
156
+ contours = Isosurface(
157
+ wfk_name = wfk_path,
158
+ energy_level = energy_level,
159
+ width = width
160
+ )
161
+ contours.Contour() # make contours
162
+ plot = Plotter(
163
+ isosurface = contours,
164
+ save_file=f'{root_name}_bandu_{xsf_number}_fermi_surf.pkl'
165
+ ) # create plotter object
166
+ overlap_vals = plot.SurfaceColor(
167
+ wfk_path=wfk_path,
168
+ xsf_path=xsf_path,
169
+ ) # compute overlap between principal orbital component and states in Brillouin Zone
170
+ plot.Plot(
171
+ surface_vals = overlap_vals,
172
+ colormap = Colors().blues,
173
+ ) # plot contours
174
+ # this option will load a previously generated and saved fermi surface file
175
+ # update the "save_path" keyword to match the path and name of your save file
176
+ elif load_fermi_surface:
177
+ Plotter().Load(
178
+ save_path='{root_name}_bandu_{xsf_number}_fermi_surf.pkl',
179
+ )
180
+ # to run any of the options above, make sure to set that option to "True"
181
+ # also be sure that the other options (or at least all options that come before) are set to "False"
182
+ # the main function will only run which ever option is the first found to be "True" in top to bottom order
183
+ # in other words, the priority follows as most to least in the order:
184
+ # principal_orbital_components -> fermi_surface -> fermi_surface_projection -> load_fermi_surface
185
+ if __name__ == '__main__':
186
+ main(
187
+ principal_orbital_components=True,
188
+ fermi_surface=True,
189
+ fermi_surface_projection=True,
190
+ load_fermi_surface=True
191
+ )
192
+ <pre>
@@ -0,0 +1,14 @@
1
+ bandu/abinit_reader.py,sha256=frP70_tvtVLfe2qhdWLKyPXFpe3YJcBlYDEG5gI9ZNg,46462
2
+ bandu/bandu.py,sha256=SfpYZf7VM9pmZBcBjnssDer2AqYVUkuwlsZ7g0o_H5g,14726
3
+ bandu/brillouin_zone.py,sha256=QFXmJz-OM4XL-NuWFFP2C4lYI7-sOfHnU1rFXFK6gLI,7812
4
+ bandu/colors.py,sha256=v1XMljrcF81z6Fth5UjL3jKh0C9nPZzUsbUeg4hSDuE,2270
5
+ bandu/isosurface_class.py,sha256=dj1yCFGobhk0JrkGdmAA_EvYy-6ErvzsbRrwBRpmPEs,10022
6
+ bandu/plotter.py,sha256=hWEzBwR5eN46r-l6UF4BKmXauqYMf0GPWDZHQJ6fyak,27149
7
+ bandu/translate.py,sha256=gl-xUZezK3fnJAWaKhmksVewtfAlCc6DWSFf9FR4UCo,2180
8
+ bandu/wfk_class.py,sha256=ZfpNRkRUwNgGpC7tf_2_g4R_D8TEGU7rMICy8ZqJdzc,25618
9
+ bandu/xsf_reader.py,sha256=SLUQLCJ9qkdZbFKttVYP_4Xt-vjqumvcPG1xrFWOies,5009
10
+ bandu-1.3.7.dist-info/licenses/LICENSE,sha256=WLZVs8X4n-vorZwIPyFdeQew3E5e0KG4Jfhutc2W9RA,1067
11
+ bandu-1.3.7.dist-info/METADATA,sha256=hofiXVKFOEr_cQh6vFakbUJC7N7K5lIV4-KZw8QnNIc,8753
12
+ bandu-1.3.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
+ bandu-1.3.7.dist-info/top_level.txt,sha256=AxbMFU3BRdjCr75K9gAdblwlBMQ3qr9-AaCC-IS8OWs,6
14
+ bandu-1.3.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 pcross0405
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 pcross0405
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.