Skip to content

Commit 751d238

Browse files
committed
Now the fix of a frequency works
1 parent 4b9fb8e commit 751d238

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

Modules/Ensemble.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,12 @@ def get_preconditioned_gradient(self, subtract_sscha = True, return_error = Fals
17061706

17071707
# Dyagonalize
17081708
w, pols = supercell_dyn.DyagDinQ(0)
1709-
trans = CC.Methods.get_translations(pols, supercell_dyn.structure.get_masses_array())
1709+
1710+
if not self.ignore_small_w:
1711+
trans = CC.Methods.get_translations(pols, supercell_dyn.structure.get_masses_array())
1712+
else:
1713+
trans = np.abs(w) < CC.Phonons.__EPSILON_W__
1714+
17101715
ityp = supercell_dyn.structure.get_ityp() + 1 # Py to fortran convertion
17111716
mass = np.array(list(supercell_dyn.structure.masses.values()))
17121717

@@ -1893,7 +1898,12 @@ def get_stress_tensor(self, offset_stress = None, add_centroid_contrib = False,
18931898
# Get frequencies and polarization vectors
18941899
super_dyn = self.current_dyn.GenerateSupercellDyn(self.supercell)
18951900
wr, pols = super_dyn.DyagDinQ(0)
1896-
trans = ~ CC.Methods.get_translations(pols, super_dyn.structure.get_masses_array())
1901+
1902+
if not self.ignore_small_w:
1903+
trans = ~ CC.Methods.get_translations(pols, super_dyn.structure.get_masses_array())
1904+
else:
1905+
trans = np.abs(wr) > CC.Phonons.__EPSILON_W__
1906+
18971907
wr = np.real( wr[trans])
18981908
pols = np.real( pols[:, trans])
18991909

@@ -2606,7 +2616,10 @@ def get_free_energy_hessian(self, include_v4 = False, get_full_hessian = True, v
26062616

26072617

26082618
# Get the translational modes
2609-
trans = CC.Methods.get_translations(pols, dyn_supercell.structure.get_masses_array())
2619+
if not self.ignore_small_w:
2620+
trans = CC.Methods.get_translations(pols, dyn_supercell.structure.get_masses_array())
2621+
else:
2622+
trans = np.abs(w) < CC.Phonons.__EPSILON_W__
26102623

26112624

26122625
# Get the atomic types

Modules/SchaMinimizer.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def minimization_step(self, custom_function_gradient = None):
410410

411411
# Preconditionate the gradient for the wyckoff minimization
412412
if self.precond_wyck:
413-
struct_precond = GetStructPrecond(self.ensemble.current_dyn)
413+
struct_precond = GetStructPrecond(self.ensemble.current_dyn, ignore_small_w = self.ensemble.ignore_small_w)
414414
struct_grad_precond = struct_precond.dot(struct_grad_reshaped)
415415
struct_grad = struct_grad_precond.reshape( (self.dyn.structure.N_atoms, 3))
416416

@@ -1298,7 +1298,10 @@ def check_imaginary_frequencies(self):
12981298

12991299
ss0 = self.ensemble.dyn_0.structure.generate_supercell(self.dyn.GetSupercell())
13001300

1301-
trans_mask = ~CC.Methods.get_translations(pold, ss0.get_masses_array())
1301+
if not self.ensemble.ignore_small_w:
1302+
trans_mask = ~CC.Methods.get_translations(pold, ss0.get_masses_array())
1303+
else:
1304+
trans_mask = np.abs(wold) > CC.Phonons.__EPSILON_W__
13021305

13031306
old_n_trans = np.sum((~trans_mask).astype(int))
13041307

@@ -1781,7 +1784,7 @@ def ApplyFCPrecond(current_dyn, matrix, T = 0):
17811784

17821785

17831786

1784-
def GetStructPrecond(current_dyn):
1787+
def GetStructPrecond(current_dyn, ignore_small_w = False):
17851788
r"""
17861789
GET THE PRECONDITIONER FOR THE STRUCTURE MINIMIZATION
17871790
=====================================================
@@ -1824,7 +1827,10 @@ def GetStructPrecond(current_dyn):
18241827
_msi_ = 1 / np.sqrt(_m_)
18251828

18261829
# Select translations
1827-
not_trans = ~CC.Methods.get_translations(pols, mass)
1830+
if not ignore_small_w:
1831+
not_trans = ~CC.Methods.get_translations(pols, mass)
1832+
else:
1833+
not_trans = np.abs(w) > CC.Phonons.__EPSILON_W__
18281834

18291835
# Delete the translations from the dynamical matrix
18301836
w = w[not_trans]

0 commit comments

Comments
 (0)