1111This module contains useful functions to do post-processing analysis of the SSCHA.
1212
1313For example, it implements custom cluster calculators to compute the electron-phonon effect on
14- absorbption and the bandgap.
14+ absorption and the bandgap.
1515
1616'''
1717
@@ -23,7 +23,7 @@ class OpticalQECluster(sscha.Cluster.Cluster):
2323 '''
2424
2525 def __init__ (self , new_k_grid = None , random_offset = True , epsilon_data = None ,
26- epsilon_binary = 'epsilon.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo' ,
26+ epsilon_binary = 'epsilon.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo' ,
2727 ** kwargs ):
2828 '''
2929 Initialize the cluster object.
@@ -40,7 +40,7 @@ def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
4040 epsilon.x file
4141 epsilon_binary : string
4242 The path to the epsilon.x binary inside the cluster.
43- **kwargs :
43+ **kwargs :
4444 All other arguments to be passed to the cluster.
4545
4646 '''
@@ -67,7 +67,7 @@ def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
6767 'wmax' : 40 ,
6868 'nw' : 10000 ,
6969 'temperature' : 300
70- }
70+ }
7171 }
7272 if epsilon_data is not None :
7373 self .epsilon_data = epsilon_data
@@ -79,10 +79,10 @@ def __setattr__(self, __name, __value):
7979 super ().__setattr__ (__name , __value )
8080
8181 # Always regenerate the kpts
82- if __name == 'new_k_grid' and not __value is None :
82+ if __name == 'new_k_grid' and not __value is None :
8383 assert len (__value ) == 3 , 'Error, new_k_grid must be a tuple with 3 elements'
8484 self .generate_kpts ()
85-
85+
8686
8787 def generate_kpts (self ):
8888 '''
@@ -119,7 +119,7 @@ def get_execution_command(self, label):
119119
120120 # Get the MPI command replacing NPROC
121121 new_mpicmd = self .mpi_cmd .replace ("NPROC" , str (self .n_cpu ))
122-
122+
123123 # Replace the NPOOL variable and the PREFIX in the binary
124124 binary = self .binary .replace ("NPOOL" , str (self .n_pool )).replace ("PREFIX" , label )
125125 binary_nscf = self .binary .replace ("NPOOL" , str (self .n_pool )).replace ("PREFIX" , label + '_nscf' )
@@ -147,6 +147,18 @@ def get_execution_command(self, label):
147147 def read_results (self , calc , label ):
148148 '''
149149 Get the results
150+
151+ Parameters
152+ ----------
153+ calc : the ASE or CellConstructor calculator.
154+ In this case, it works with quantum espresso
155+ labels : List of strings
156+ The unique name of this calculation
157+ Returns
158+ -------
159+ results : array
160+ An array containing the real part of epsilon,
161+ and the mean of the real and imaginary parst of epsilon.
150162 '''
151163
152164 results = super ().read_results (calc , label )
@@ -176,7 +188,31 @@ def read_results(self, calc, label):
176188 def prepare_input_file (self , structures , calc , labels ):
177189 '''
178190 Prepare the input files for the cluster
179- '''
191+
192+ This is specific for quantum espresso and must be inherit and replaced for
193+ other calculators.
194+
195+ This crates the input files in the local working directory
196+ self.local_workdir and it returns the list of all the files generated.
197+
198+
199+ Parameters
200+ ----------
201+ structures : List of cellconstructor.Structure.Structure
202+ The atomic structures.
203+ calc : the ASE or CellConstructor calculator.
204+ In this case, it works with quantum espresso
205+ labels : List of strings
206+ The unique name of this calculation
207+
208+ Returns
209+ -------
210+ List_of_input : list
211+ List of strings containing all the input files
212+ List_of_output : list
213+ List of strings containing the output files expected
214+ for the calculation
215+ '''
180216
181217
182218 # Prepare the input file
@@ -185,7 +221,7 @@ def prepare_input_file(self, structures, calc, labels):
185221 for i , (label , structure ) in enumerate (zip (labels , structures )):
186222 # Avoid thread conflict
187223 self .lock .acquire ()
188-
224+
189225 try :
190226 calc .set_directory (self .local_workdir )
191227 PREFIX = label
@@ -204,7 +240,7 @@ def prepare_input_file(self, structures, calc, labels):
204240 input_file = '{}.pwi' .format (label )
205241 output_file = '{}.pwo' .format (label )
206242
207- list_of_inputs .append (input_file )
243+ list_of_inputs .append (input_file )
208244 list_of_outputs .append (output_file )
209245
210246 # prepare the nscf calculation
@@ -218,7 +254,7 @@ def prepare_input_file(self, structures, calc, labels):
218254 calc .write_input (structure )
219255 input_file = '{}.pwi' .format (new_label )
220256 output_file = '{}.pwo' .format (new_label )
221- list_of_inputs .append (input_file )
257+ list_of_inputs .append (input_file )
222258 list_of_outputs .append (output_file )
223259
224260
@@ -239,8 +275,8 @@ def prepare_input_file(self, structures, calc, labels):
239275 print ('fname: {} prepared' .format (eps_in_filename ))
240276
241277
242-
243- list_of_inputs .append (input_file )
278+
279+ list_of_inputs .append (input_file )
244280 list_of_outputs .append (output_file )
245281
246282 # Append also the imaginary and real part of epsilon and sigma
@@ -263,11 +299,11 @@ def prepare_input_file(self, structures, calc, labels):
263299 print (e )
264300
265301 # Release the lock on the threads
266- self .lock .release ()
302+ self .lock .release ()
267303
268304 print ('THREAD: {} inputs: {} outputs: {}' .format (threading .get_native_id (), list_of_inputs , list_of_outputs ))
269-
270-
305+
306+
271307 return list_of_inputs , list_of_outputs
272308
273309
@@ -306,7 +342,7 @@ def get_optical_spectrum(ensemble, w_array = None):
306342Error, the configuration {} has no 'epsilon' data.
307343""" .format (i )
308344 raise ValueError (ERR )
309-
345+
310346 data = np .array (ensemble .all_properties [i ]['epsilon' ])
311347
312348 if w_data is None :
@@ -330,13 +366,11 @@ def get_optical_spectrum(ensemble, w_array = None):
330366 kind = 'cubic' , bounds_error = False , fill_value = 'extrapolate' )
331367 eps_imag = f_imag (w_array )
332368 w_data = w_array
333-
369+
334370 # Build the complex epsilon
335371 epsilon = eps_real + 1j * eps_imag
336372
337373 # Build the refractive index
338374 n = np .sqrt (epsilon )
339375
340376 return w_data , n
341-
342-
0 commit comments