2626from qha .single_configuration import free_energy
2727from qha .thermodynamics import *
2828from qha .type_aliases import Vector
29- from qha .unit_conversion import gpa_to_ry_b3 , ry_b3_to_gpa , b3_to_a3 , ry_to_j_mol , ry_to_ev
29+ from qha .unit_conversion import gpa_to_ry_b3 , ry_b3_to_gpa , b3_to_a3 , ry_to_j_mol , ry_to_ev , ry_to_j
3030from qha .v2p import v2p
3131
3232# ===================== What can be exported? =====================
@@ -48,7 +48,8 @@ def __init__(self, user_settings: Dict[str, Any]):
4848 try :
4949 runtime_settings .update ({key : user_settings [key ]})
5050 except KeyError :
51- continue # If a key is not set in user settings, use the default.
51+ # If a key is not set in user settings, use the default.
52+ continue
5253
5354 self ._settings = runtime_settings
5455
@@ -106,12 +107,15 @@ def v_ratio(self) -> Optional[float]:
106107
107108 def read_input (self ):
108109 try :
109- formula_unit_number , volumes , static_energies , frequencies , q_weights = read_input (self .settings ['input' ])
110+ formula_unit_number , volumes , static_energies , frequencies , q_weights = read_input (
111+ self .settings ['input' ])
110112 except KeyError :
111- raise KeyError ("The 'input' option must be given in your settings!" )
113+ raise KeyError (
114+ "The 'input' option must be given in your settings!" )
112115
113116 if not qha .tools .is_monotonic_decreasing (volumes ):
114- raise RuntimeError ("Check the input file to make sure the volume decreases!" )
117+ raise RuntimeError (
118+ "Check the input file to make sure the volume decreases!" )
115119
116120 self ._formula_unit_number : int = formula_unit_number
117121 self ._volumes = volumes
@@ -127,7 +131,8 @@ def where_negative_frequencies(self) -> Optional[Vector]:
127131 :return:
128132 """
129133 if self ._frequencies is None :
130- print ("Please invoke ``read_input`` method first!" ) # ``None`` is returned
134+ # ``None`` is returned
135+ print ("Please invoke ``read_input`` method first!" )
131136 else :
132137 _ = np .transpose (np .where (self ._frequencies < 0 ))
133138 if _ .size == 0 :
@@ -156,20 +161,23 @@ def refine_grid(self):
156161 try :
157162 p_min , p_min_modifier , ntv , order = d ['P_MIN' ], d ['p_min_modifier' ], d ['NTV' ], d ['order' ]
158163 except KeyError :
159- raise KeyError ("All the 'P_MIN', 'p_min_modifier', 'NTV', 'order' options must be given in your settings!" )
164+ raise KeyError (
165+ "All the 'P_MIN', 'p_min_modifier', 'NTV', 'order' options must be given in your settings!" )
160166
161167 r = FinerGrid (p_min - p_min_modifier , ntv , order = order )
162168
163169 if 'volume_ratio' in d :
164170 self ._finer_volumes_bohr3 , self ._f_tv_ry , self ._v_ratio = r .refine_grid (self .volumes , self .vib_ry ,
165171 ratio = d ['volume_ratio' ])
166172 else :
167- self ._finer_volumes_bohr3 , self ._f_tv_ry , self ._v_ratio = r .refine_grid (self .volumes , self .vib_ry )
173+ self ._finer_volumes_bohr3 , self ._f_tv_ry , self ._v_ratio = r .refine_grid (
174+ self .volumes , self .vib_ry )
168175
169176 @LazyProperty
170177 def vib_ry (self ):
171178 # We grep all the arguments once since they are being invoked for thousands of times, and will be an overhead.
172- args = self .q_weights , self .static_energies , self .frequencies , self .settings ['static_only' ]
179+ args = self .q_weights , self .static_energies , self .frequencies , self .settings [
180+ 'static_only' ]
173181
174182 mat = np .empty ((self .temperature_array .size , self .volumes .size ))
175183 for i , t in enumerate (self .temperature_array ):
@@ -218,7 +226,8 @@ def desired_pressure_status(self) -> None:
218226 self .p_tv_gpa [:, 0 ].max (), self .p_tv_gpa [:, - 1 ].min ()))
219227
220228 if self .p_tv_gpa [:, - 1 ].min () < self .desired_pressures_gpa .max ():
221- ntv_max = int ((self .p_tv_gpa [:, - 1 ].min () - self .desired_pressures_gpa .min ()) / d ['DELTA_P' ])
229+ ntv_max = int (
230+ (self .p_tv_gpa [:, - 1 ].min () - self .desired_pressures_gpa .min ()) / d ['DELTA_P' ])
222231
223232 save_to_output (d ['qha_output' ], textwrap .dedent ("""\
224233 !!!ATTENTION!!!
@@ -228,12 +237,17 @@ def desired_pressure_status(self) -> None:
228237 Please reduce the NTV accordingly, for example, try to set NTV < {:4d}.
229238 """ .format (ntv_max )))
230239
231- raise ValueError ("DESIRED PRESSURE is too high (NTV is too large), qha results might not be right!" )
240+ raise ValueError (
241+ "DESIRED PRESSURE is too high (NTV is too large), qha results might not be right!" )
232242
233243 @LazyProperty
234244 def p_tv_au (self ):
235245 return pressure (self .finer_volumes_bohr3 , self .f_tv_ry )
236246
247+ @LazyProperty
248+ def s_tv_j (self ):
249+ return ry_to_j (entropy (self .temperature_array , self .f_tv_ry ))
250+
237251 @LazyProperty
238252 def f_tv_ev (self ):
239253 return ry_to_ev (self .f_tv_ry )
@@ -373,12 +387,15 @@ def read_input(self):
373387 q_weights = []
374388
375389 for inp in input_data_files :
376- nm_tmp , volumes_tmp , static_energies_tmp , freq_tmp , weights_tmp = read_input (inp )
390+ nm_tmp , volumes_tmp , static_energies_tmp , freq_tmp , weights_tmp = read_input (
391+ inp )
377392
378393 if not qha .tools .is_monotonic_decreasing (volumes_tmp ):
379394 # TODO: Clean this sentence
380- save_to_output (self .settings ['qha_output' ], "Check the input file to make sure the volume decreases" )
381- raise ValueError ("Check the input file to make sure the volumes are monotonic decreasing!" )
395+ save_to_output (
396+ self .settings ['qha_output' ], "Check the input file to make sure the volume decreases" )
397+ raise ValueError (
398+ "Check the input file to make sure the volumes are monotonic decreasing!" )
382399
383400 formula_unit_numbers .append (nm_tmp )
384401 volumes .append (volumes_tmp )
@@ -393,12 +410,15 @@ def read_input(self):
393410 q_weights = np .array (q_weights )
394411
395412 if not len (set (formula_unit_numbers )) == 1 :
396- raise RuntimeError ("All the formula unit number in all inputs should be the same!" )
413+ raise RuntimeError (
414+ "All the formula unit number in all inputs should be the same!" )
397415
398416 if len (volumes .shape ) == 1 :
399- raise RuntimeError ("All configurations should have same number of volumes!" )
417+ raise RuntimeError (
418+ "All configurations should have same number of volumes!" )
400419
401- self ._formula_unit_number = formula_unit_numbers [0 ] # Choose any of them since they are all the same
420+ # Choose any of them since they are all the same
421+ self ._formula_unit_number = formula_unit_numbers [0 ]
402422 self ._volumes = volumes
403423 self ._static_energies = static_energies
404424 self ._frequencies = frequencies
@@ -408,11 +428,12 @@ def read_input(self):
408428 def vib_ry (self ):
409429 # We grep all the arguments once since they are being invoked for thousands of times, and will be an overhead.
410430 args = self .degeneracies , self .q_weights , self .static_energies , self ._volumes , self .frequencies , \
411- self .settings ['static_only' ]
431+ self .settings ['static_only' ]
412432
413433 mat = np .empty ((self .temperature_array .size , self ._volumes .shape [1 ]))
414434 for i , t in enumerate (self .temperature_array ):
415- mat [i ] = different_phonon_dos .PartitionFunction (t , * (arg for arg in args )).get_free_energies ()
435+ mat [i ] = different_phonon_dos .PartitionFunction (
436+ t , * (arg for arg in args )).get_free_energies ()
416437
417438 return mat
418439
@@ -424,9 +445,10 @@ def __init__(self, user_settings):
424445 @LazyProperty
425446 def vib_ry (self ):
426447 args = self .degeneracies , self .q_weights [0 ], self .static_energies , self ._volumes , self .frequencies [0 ], \
427- self .settings ['static_only' ], self .settings ['order' ]
448+ self .settings ['static_only' ], self .settings ['order' ]
428449 mat = np .empty ((self .temperature_array .size , self ._volumes .shape [1 ]))
429450
430451 for i , t in enumerate (self .temperature_array ):
431- mat [i ] = same_phonon_dos .FreeEnergy (t , * (arg for arg in args )).get_free_energies ()
452+ mat [i ] = same_phonon_dos .FreeEnergy (
453+ t , * (arg for arg in args )).get_free_energies ()
432454 return mat
0 commit comments