Skip to content

Commit 37aac7a

Browse files
committed
Fix on the Mesh interpolation
1 parent fbb69b8 commit 37aac7a

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Modules/Ensemble.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ def get_free_energy(self, return_error = False):
23092309
return free_energy
23102310

23112311

2312-
def get_free_energy_interpolating(self, target_supercell, support_dyn_coarse = None, support_dyn_fine = None, error_on_imaginary_frequency = True, return_error = False):
2312+
def get_free_energy_interpolating(self, target_supercell, support_dyn_coarse = None, support_dyn_fine = None, error_on_imaginary_frequency = True, return_error = False, use_lo_to_splitting = False):
23132313
"""
23142314
GET THE FREE ENERGY IN A BIGGER CELL
23152315
====================================
@@ -2337,6 +2337,7 @@ def get_free_energy_interpolating(self, target_supercell, support_dyn_coarse = N
23372337
return_error : bool
23382338
As the normal get_free_energy, if this flag is True, the stochastic error is returned.
23392339
2340+
23402341
Returns
23412342
-------
23422343
free_energy : float
@@ -2354,17 +2355,17 @@ def get_free_energy_interpolating(self, target_supercell, support_dyn_coarse = N
23542355

23552356

23562357
# Interpolate the dynamical matrix
2357-
if support_dyn_fine is not None:
2358-
new_dyn = self.current_dyn.Interpolate( self.current_dyn.GetSupercell(),
2359-
target_supercell,
2360-
support_dyn_coarse,
2361-
support_dyn_fine)
2358+
if not use_lo_to_splitting:
2359+
if support_dyn_fine is not None:
2360+
new_dyn = self.current_dyn.Interpolate( self.current_dyn.GetSupercell(),
2361+
target_supercell,
2362+
support_dyn_coarse,
2363+
support_dyn_fine)
2364+
else:
2365+
new_dyn = self.current_dyn.Interpolate( self.current_dyn.GetSupercell(),
2366+
target_supercell)
23622367
else:
2363-
new_dyn = self.current_dyn.Interpolate( self.current_dyn.GetSupercell(),
2364-
target_supercell)
2365-
2366-
#else:
2367-
# new_dyn = self.current_dyn.InterpolateMesh(target_supercell, lo_to_splitting = True)
2368+
new_dyn = self.current_dyn.InterpolateMesh(target_supercell, lo_to_splitting = True)
23682369

23692370
#print("dyn after interpolation:", new_dyn.GetSupercell())
23702371

Modules/SchaMinimizer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def __init__(self, ensemble = None, root_representation = "normal",
216216

217217
# Setup the meaningful_factor
218218
self.meaningful_factor = meaningful_factor
219+
self.abs_conv_thr = 1e-8 # Below this number the minimization is considered converged
219220

220221
# Setup the minimization algorithm
221222
self.minimization_algorithm = minimization_algorithm
@@ -935,6 +936,7 @@ def print_info(self):
935936
print (" number of configurations = ", self.ensemble.N)
936937
print (" max number of steps (infinity if negative) = ", self.max_ka)
937938
print (" meaningful factor = ", self.meaningful_factor)
939+
print (" absolute convergence threshold = ", self.abs_conv_thr)
938940
print (" gradient to watch (for stopping) = ", self.gradi_op)
939941
print (" Kong-Liu minimum effective sample size = ", self.ensemble.N * self.kong_liu_ratio)
940942
print (" (Kong-Liu ratio = ", self.kong_liu_ratio, ")")
@@ -1617,6 +1619,11 @@ def check_stop(self, timer=None):
16171619
gc_cond = (last_gc < last_gc_err * self.meaningful_factor)
16181620
gw_cond = (last_gw < last_gw_err * self.meaningful_factor)
16191621

1622+
# Add a condition on the absolute value of the gradient
1623+
# (For perfectly harmonic systems, the error goes to zero)
1624+
gc_cond = gc_cond or (last_gc < self.abs_conv_thr)
1625+
gw_cond = gw_cond or (last_gw < self.abs_conv_thr)
1626+
16201627
total_cond = False
16211628

16221629
if gc_cond:

0 commit comments

Comments
 (0)