Skip to content

Commit dae8044

Browse files
committed
Now it is doing the actual minimization in 1D
1 parent 358c330 commit dae8044

4 files changed

Lines changed: 1163 additions & 22 deletions

File tree

Modules/Ensemble.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,8 @@ def update_weights_fourier(self, new_dynamical_matrix, newT, timer=None):
17151715

17161716
# Exclude translations
17171717
if not self.ignore_small_w:
1718-
trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
1718+
trans_original = super_struct0.get_asr_modes(pols_original)
1719+
# trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
17191720
else:
17201721
trans_original = np.abs(w_original) < CC.Phonons.__EPSILON_W__
17211722

@@ -1732,15 +1733,14 @@ def update_weights_fourier(self, new_dynamical_matrix, newT, timer=None):
17321733

17331734

17341735
if not self.ignore_small_w:
1735-
trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
1736+
trans_mask = super_structure.get_asr_modes(pols)
1737+
# trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
17361738
else:
17371739
trans_mask = np.abs(w_new) < CC.Phonons.__EPSILON_W__
17381740

17391741

17401742
# Check if the new dynamical matrix satisfies the sum rule
1741-
violating_sum_rule = (np.sum(trans_mask.astype(int)) != 3) or (np.sum(trans_original.astype(int)) != 3)
1742-
if self.ignore_small_w:
1743-
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
1743+
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
17441744

17451745

17461746
if violating_sum_rule:
@@ -1937,7 +1937,8 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
19371937

19381938
# Exclude translations
19391939
if not self.ignore_small_w:
1940-
trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
1940+
trans_original = super_struct0.get_asr_modes(pols_original)
1941+
# trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
19411942
else:
19421943
trans_original = np.abs(w_original) < CC.Phonons.__EPSILON_W__
19431944

@@ -1954,15 +1955,15 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
19541955

19551956

19561957
if not self.ignore_small_w:
1957-
trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
1958+
trans_mask = super_structure.get_asr_modes(pols)
1959+
# trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
19581960
else:
19591961
trans_mask = np.abs(w_new) < CC.Phonons.__EPSILON_W__
19601962

19611963

19621964
# Check if the new dynamical matrix satisfies the sum rule
1963-
violating_sum_rule = (np.sum(trans_mask.astype(int)) != 3) or (np.sum(trans_original.astype(int)) != 3)
1964-
if self.ignore_small_w:
1965-
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
1965+
# violating_sum_rule = (np.sum(trans_mask.astype(int)) != 3) or (np.sum(trans_original.astype(int)) != 3)
1966+
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
19661967

19671968

19681969
if violating_sum_rule:
@@ -1977,7 +1978,7 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
19771978
DETAILS OF ERROR:
19781979
Number of translatinal modes in the original dyn = {}
19791980
Number of translational modes in the target dyn = {}
1980-
(They should be both 3)
1981+
(They should be both be the same - 3 in bulk)
19811982
""".format(np.sum(trans_original.astype(int)), np.sum(trans_mask.astype(int)))
19821983

19831984
print(ERR_MSG)
@@ -2699,7 +2700,8 @@ def get_preconditioned_gradient(self, subtract_sscha = True, return_error = Fals
26992700
w, pols = self.current_dyn.DiagonalizeSupercell()#supercell_dyn.DyagDinQ(0)
27002701

27012702
if not self.ignore_small_w:
2702-
trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
2703+
trans = super_struct.get_asr_modes(pols)
2704+
# trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
27032705
else:
27042706
trans = np.abs(w) < CC.Phonons.__EPSILON_W__
27052707

@@ -2939,7 +2941,8 @@ def get_stress_tensor(self, offset_stress = None, use_spglib = False):
29392941
wr, pols = self.current_dyn.DiagonalizeSupercell()
29402942

29412943
if not self.ignore_small_w:
2942-
trans = ~ CC.Methods.get_translations(pols, super_structure.get_masses_array())
2944+
trans = ~ super_structure.get_asr_modes(pols)
2945+
# trans = ~ CC.Methods.get_translations(pols, super_structure.get_masses_array())
29432946
else:
29442947
trans = np.abs(wr) > CC.Phonons.__EPSILON_W__
29452948

@@ -3367,7 +3370,8 @@ def get_odd_realspace(self):
33673370
w_sc, pols_sc = super_dyn.DyagDinQ(0)
33683371

33693372
# Remove translations
3370-
no_trans_mask = ~CC.Methods.get_translations(pols_sc, super_dyn.structure.get_masses_array())
3373+
no_trans_mask = ~super_dyn.structure.get_asr_modes(pols_sc)
3374+
# no_trans_mask = ~CC.Methods.get_translations(pols_sc, super_dyn.structure.get_masses_array())
33713375
w_sc = w_sc[no_trans_mask]
33723376
pols_sc = pols_sc[:, no_trans_mask]
33733377

@@ -3662,7 +3666,8 @@ def get_free_energy_hessian(self, include_v4 = False, get_full_hessian = True, v
36623666

36633667
# Get the translational modes
36643668
if not self.ignore_small_w:
3665-
trans = CC.Methods.get_translations(pols, super_structure.get_masses_array())
3669+
trans = super_structure.get_asr_modes(pols)
3670+
# trans = CC.Methods.get_translations(pols, super_structure.get_masses_array())
36663671
else:
36673672
trans = np.abs(w) < CC.Phonons.__EPSILON_W__
36683673

Modules/SchaMinimizer.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,10 +1502,11 @@ def finalize(self, verbose = 1, timer=None):
15021502
pols = self.ensemble.current_pols.copy()
15031503

15041504
#w, pols = super_dyn.DyagDinQ(0)
1505-
trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
1505+
trans = super_struct.get_asr_modes(pols)
1506+
# trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
15061507

15071508
for i in range(len(w)):
1508-
print ("Mode %5d: freq %16.8f cm-1 | is translation? " % (i+1, w[i] * __RyToCm__), trans[i])
1509+
print ("Mode %5d: freq %16.8f cm-1 | is asr? " % (i+1, w[i] * __RyToCm__), trans[i])
15091510

15101511
print ()
15111512

@@ -1533,7 +1534,8 @@ def check_imaginary_frequencies(self, timer=None):
15331534

15341535
# Get translations
15351536
if not self.ensemble.ignore_small_w:
1536-
trans_mask = ~CC.Methods.get_translations(pols, ss.get_masses_array())
1537+
trans_mask = ~ss.get_asr_modes(pols)
1538+
# trans_mask = ~CC.Methods.get_translations(pols, ss.get_masses_array())
15371539
else:
15381540
trans_mask = np.abs(w) > CC.Phonons.__EPSILON_W__
15391541

@@ -1554,7 +1556,8 @@ def check_imaginary_frequencies(self, timer=None):
15541556
#ss0 = self.ensemble.dyn_0.structure.generate_supercell(self.dyn.GetSupercell())
15551557

15561558
if not self.ensemble.ignore_small_w:
1557-
trans_mask = ~CC.Methods.get_translations(pold, ss.get_masses_array())
1559+
trans_mask = ~ss.get_asr_modes(pold)
1560+
# trans_mask = ~CC.Methods.get_translations(pold, ss.get_masses_array())
15581561
else:
15591562
trans_mask = np.abs(wold) > CC.Phonons.__EPSILON_W__
15601563

@@ -1938,7 +1941,8 @@ def ApplyLambdaTensor(current_dyn, matrix, T = 0):
19381941
w, pols = current_dyn.DyagDinQ(0)
19391942

19401943
# Get the translations
1941-
trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
1944+
trans = ~current_dyn.structure.get_asr_modes(pols)
1945+
# trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
19421946

19431947
# Restrict only to non translational modes
19441948
w = np.real(w[trans])
@@ -2002,7 +2006,8 @@ def ApplyFCPrecond(current_dyn, matrix, T = 0):
20022006
w, pols = current_dyn.DyagDinQ(0)
20032007

20042008
# Get the translations
2005-
trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
2009+
trans = ~current_dyn.structure.get_asr_modes(pols)
2010+
#trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
20062011

20072012
# Restrict only to non translational modes
20082013
w = np.real(w[trans])
@@ -2093,7 +2098,8 @@ def GetStructPrecond(current_dyn, ignore_small_w = False, w_pols = None):
20932098

20942099
# Select translations
20952100
if not ignore_small_w:
2096-
not_trans = ~CC.Methods.get_translations(pols, mass)
2101+
not_trans = ~current_dyn.structure.get_asr_modes(pols)
2102+
# not_trans = ~CC.Methods.get_translations(pols, mass)
20972103
else:
20982104
not_trans = np.abs(w) > CC.Phonons.__EPSILON_W__
20992105

0 commit comments

Comments
 (0)