@@ -128,6 +128,9 @@ def __init__(self, dyn0, T0, supercell = None):
128128
129129 self .sscha_energies = []
130130 self .sscha_forces = []
131+
132+ # If True the frequency smaller than CC.Phonons.__EPSILON_W__ are ignored
133+ self .ignore_small_w = False
131134
132135 # The original dynamical matrix used to generate the ensemble
133136 self .dyn_0 = dyn0 .Copy ()
@@ -924,7 +927,7 @@ class is created.
924927
925928 structures = []
926929 if evenodd :
927- structs = self .dyn_0 .ExtractRandomStructures (N // 2 , self .T0 , project_on_vectors = project_on_modes )
930+ structs = self .dyn_0 .ExtractRandomStructures (N // 2 , self .T0 , project_on_vectors = project_on_modes , lock_low_w = self . ignore_small_w )
928931
929932
930933
@@ -935,7 +938,7 @@ class is created.
935938 new_s .coords = super_struct .coords - new_s .get_displacement (super_struct )
936939 structures .append (new_s )
937940 else :
938- structures = self .dyn_0 .ExtractRandomStructures (N , self .T0 , project_on_vectors = project_on_modes )
941+ structures = self .dyn_0 .ExtractRandomStructures (N , self .T0 , project_on_vectors = project_on_modes , lock_low_w = self . ignore_small_w )
939942
940943
941944 # Enforce all the processors to share the same structures
@@ -1178,7 +1181,11 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False):
11781181 w , pols = self .dyn_0 .DiagonalizeSupercell ()#super_dyn.DyagDinQ(0)
11791182
11801183 # Exclude translations
1181- trans_original = CC .Methods .get_translations (pols , super_struct0 .get_masses_array ())
1184+ if not self .ignore_small_w :
1185+ trans_original = CC .Methods .get_translations (pols , super_struct0 .get_masses_array ())
1186+ else :
1187+ trans_original = np .abs (w ) < CC .Phonons .__EPSILON_W__
1188+
11821189 w = w [~ trans_original ]
11831190
11841191 # Convert from Ry to Ha and in fortran double precision
@@ -1193,10 +1200,19 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False):
11931200
11941201 w , pols = new_dynamical_matrix .DiagonalizeSupercell ()#new_super_dyn.DyagDinQ(0)
11951202
1196- trans_mask = CC .Methods .get_translations (pols , super_structure .get_masses_array ())
1203+ if not self .ignore_small_w :
1204+ trans_mask = CC .Methods .get_translations (pols , super_structure .get_masses_array ())
1205+ else :
1206+ trans_mask = np .abs (w ) < CC .Phonons .__EPSILON_W__
1207+
11971208
11981209 # Check if the new dynamical matrix satisfies the sum rule
1199- if (np .sum (trans_mask .astype (int )) != 3 ) or (np .sum (trans_original .astype (int )) != 3 ):
1210+ violating_sum_rule = (np .sum (trans_mask .astype (int )) != 3 ) or (np .sum (trans_original .astype (int )) != 3 )
1211+ if self .ignore_small_w :
1212+ violating_sum_rule = np .sum (trans_mask .astype (int )) != np .sum (trans_original .astype (int ))
1213+
1214+
1215+ if violating_sum_rule :
12001216 ERR_MSG = """
12011217ERROR WHILE UPDATING THE WEIGHTS
12021218
@@ -2821,6 +2837,7 @@ def split(self, split_mask):
28212837 ens .energies [:] = self .energies [split_mask ]
28222838 ens .forces [:, :, :] = self .forces [split_mask , :, :]
28232839 ens .has_stress = self .has_stress
2840+ ens .ignore_small_w = self .ignore_small_w
28242841 if self .has_stress :
28252842 ens .stresses [:, :, :] = self .stresses [split_mask , :, :]
28262843
0 commit comments