Skip to content

Commit 0c845a9

Browse files
Merge pull request #174 from SSCHAcode/asr_1d
ASR in 1D materials
2 parents 2cf8861 + e977c09 commit 0c845a9

File tree

4 files changed

+1169
-22
lines changed

4 files changed

+1169
-22
lines changed

Modules/Ensemble.py

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

17341734
# Exclude translations
17351735
if not self.ignore_small_w:
1736-
trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
1736+
trans_original = super_struct0.get_asr_modes(pols_original)
1737+
# trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
17371738
else:
17381739
trans_original = np.abs(w_original) < CC.Phonons.__EPSILON_W__
17391740

@@ -1750,15 +1751,14 @@ def update_weights_fourier(self, new_dynamical_matrix, newT, timer=None):
17501751

17511752

17521753
if not self.ignore_small_w:
1753-
trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
1754+
trans_mask = super_structure.get_asr_modes(pols)
1755+
# trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
17541756
else:
17551757
trans_mask = np.abs(w_new) < CC.Phonons.__EPSILON_W__
17561758

17571759

17581760
# Check if the new dynamical matrix satisfies the sum rule
1759-
violating_sum_rule = (np.sum(trans_mask.astype(int)) != 3) or (np.sum(trans_original.astype(int)) != 3)
1760-
if self.ignore_small_w:
1761-
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
1761+
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
17621762

17631763

17641764
if violating_sum_rule:
@@ -1955,7 +1955,8 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
19551955

19561956
# Exclude translations
19571957
if not self.ignore_small_w:
1958-
trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
1958+
trans_original = super_struct0.get_asr_modes(pols_original)
1959+
# trans_original = CC.Methods.get_translations(pols_original, super_struct0.get_masses_array())
19591960
else:
19601961
trans_original = np.abs(w_original) < CC.Phonons.__EPSILON_W__
19611962

@@ -1972,15 +1973,15 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
19721973

19731974

19741975
if not self.ignore_small_w:
1975-
trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
1976+
trans_mask = super_structure.get_asr_modes(pols)
1977+
# trans_mask = CC.Methods.get_translations(pols, super_structure.get_masses_array())
19761978
else:
19771979
trans_mask = np.abs(w_new) < CC.Phonons.__EPSILON_W__
19781980

19791981

19801982
# Check if the new dynamical matrix satisfies the sum rule
1981-
violating_sum_rule = (np.sum(trans_mask.astype(int)) != 3) or (np.sum(trans_original.astype(int)) != 3)
1982-
if self.ignore_small_w:
1983-
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
1983+
# violating_sum_rule = (np.sum(trans_mask.astype(int)) != 3) or (np.sum(trans_original.astype(int)) != 3)
1984+
violating_sum_rule = np.sum(trans_mask.astype(int)) != np.sum(trans_original.astype(int))
19841985

19851986

19861987
if violating_sum_rule:
@@ -1995,7 +1996,7 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
19951996
DETAILS OF ERROR:
19961997
Number of translatinal modes in the original dyn = {}
19971998
Number of translational modes in the target dyn = {}
1998-
(They should be both 3)
1999+
(They should be both be the same - 3 in bulk)
19992000
""".format(np.sum(trans_original.astype(int)), np.sum(trans_mask.astype(int)))
20002001

20012002
print(ERR_MSG)
@@ -2718,7 +2719,8 @@ def get_preconditioned_gradient(self, subtract_sscha = True, return_error = Fals
27182719
w, pols = self.current_dyn.DiagonalizeSupercell()#supercell_dyn.DyagDinQ(0)
27192720

27202721
if not self.ignore_small_w:
2721-
trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
2722+
trans = super_struct.get_asr_modes(pols)
2723+
# trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
27222724
else:
27232725
trans = np.abs(w) < CC.Phonons.__EPSILON_W__
27242726

@@ -2958,7 +2960,8 @@ def get_stress_tensor(self, offset_stress = None, use_spglib = False):
29582960
wr, pols = self.current_dyn.DiagonalizeSupercell()
29592961

29602962
if not self.ignore_small_w:
2961-
trans = ~ CC.Methods.get_translations(pols, super_structure.get_masses_array())
2963+
trans = ~ super_structure.get_asr_modes(pols)
2964+
# trans = ~ CC.Methods.get_translations(pols, super_structure.get_masses_array())
29622965
else:
29632966
trans = np.abs(wr) > CC.Phonons.__EPSILON_W__
29642967

@@ -3386,7 +3389,8 @@ def get_odd_realspace(self):
33863389
w_sc, pols_sc = super_dyn.DyagDinQ(0)
33873390

33883391
# Remove translations
3389-
no_trans_mask = ~CC.Methods.get_translations(pols_sc, super_dyn.structure.get_masses_array())
3392+
no_trans_mask = ~super_dyn.structure.get_asr_modes(pols_sc)
3393+
# no_trans_mask = ~CC.Methods.get_translations(pols_sc, super_dyn.structure.get_masses_array())
33903394
w_sc = w_sc[no_trans_mask]
33913395
pols_sc = pols_sc[:, no_trans_mask]
33923396

@@ -3681,7 +3685,8 @@ def get_free_energy_hessian(self, include_v4 = False, get_full_hessian = True, v
36813685

36823686
# Get the translational modes
36833687
if not self.ignore_small_w:
3684-
trans = CC.Methods.get_translations(pols, super_structure.get_masses_array())
3688+
trans = super_structure.get_asr_modes(pols)
3689+
# trans = CC.Methods.get_translations(pols, super_structure.get_masses_array())
36853690
else:
36863691
trans = np.abs(w) < CC.Phonons.__EPSILON_W__
36873692

Modules/SchaMinimizer.py

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

15061506
#w, pols = super_dyn.DyagDinQ(0)
1507-
trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
1507+
trans = super_struct.get_asr_modes(pols)
1508+
# trans = CC.Methods.get_translations(pols, super_struct.get_masses_array())
15081509

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

15121513
print ()
15131514

@@ -1535,7 +1536,8 @@ def check_imaginary_frequencies(self, timer=None):
15351536

15361537
# Get translations
15371538
if not self.ensemble.ignore_small_w:
1538-
trans_mask = ~CC.Methods.get_translations(pols, ss.get_masses_array())
1539+
trans_mask = ~ss.get_asr_modes(pols)
1540+
# trans_mask = ~CC.Methods.get_translations(pols, ss.get_masses_array())
15391541
else:
15401542
trans_mask = np.abs(w) > CC.Phonons.__EPSILON_W__
15411543

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

15581560
if not self.ensemble.ignore_small_w:
1559-
trans_mask = ~CC.Methods.get_translations(pold, ss.get_masses_array())
1561+
trans_mask = ~ss.get_asr_modes(pold)
1562+
# trans_mask = ~CC.Methods.get_translations(pold, ss.get_masses_array())
15601563
else:
15611564
trans_mask = np.abs(wold) > CC.Phonons.__EPSILON_W__
15621565

@@ -1945,7 +1948,8 @@ def ApplyLambdaTensor(current_dyn, matrix, T = 0):
19451948
w, pols = current_dyn.DyagDinQ(0)
19461949

19471950
# Get the translations
1948-
trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
1951+
trans = ~current_dyn.structure.get_asr_modes(pols)
1952+
# trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
19491953

19501954
# Restrict only to non translational modes
19511955
w = np.real(w[trans])
@@ -2009,7 +2013,8 @@ def ApplyFCPrecond(current_dyn, matrix, T = 0):
20092013
w, pols = current_dyn.DyagDinQ(0)
20102014

20112015
# Get the translations
2012-
trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
2016+
trans = ~current_dyn.structure.get_asr_modes(pols)
2017+
#trans = ~CC.Methods.get_translations(pols, current_dyn.structure.get_masses_array())
20132018

20142019
# Restrict only to non translational modes
20152020
w = np.real(w[trans])
@@ -2100,7 +2105,8 @@ def GetStructPrecond(current_dyn, ignore_small_w = False, w_pols = None):
21002105

21012106
# Select translations
21022107
if not ignore_small_w:
2103-
not_trans = ~CC.Methods.get_translations(pols, mass)
2108+
not_trans = ~current_dyn.structure.get_asr_modes(pols)
2109+
# not_trans = ~CC.Methods.get_translations(pols, mass)
21042110
else:
21052111
not_trans = np.abs(w) > CC.Phonons.__EPSILON_W__
21062112

0 commit comments

Comments
 (0)