Skip to content

Commit 324529d

Browse files
committed
Added a new function to finalize that prints the total forces on output
1 parent 4448973 commit 324529d

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

Modules/SchaMinimizer.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,25 @@ def finalize(self, verbose = 1):
12321232
self.__gw_err__[-1] * __RyTomev__))
12331233
print ("Kong-Liu effective sample size = ", self.ensemble.get_effective_sample_size())
12341234
print ()
1235-
1235+
1236+
# Print the total force on the structure
1237+
print("Total force on the centroids [eV/A]:")
1238+
forces, err = self.ensembe.get_average_forces()
1239+
# Apply the symmetries
1240+
if not self.neglect_symmetries:
1241+
qe_sym = CC.symmetries.QE_Symmetry(self.dyn.structure)
1242+
if self.use_spglib:
1243+
qe_sym.SetupFromSPGLIB()
1244+
else:
1245+
qe_sym.SetupQPoint()
1246+
qe_sym.SymmetrizeVector(forces)
1247+
qe_sym.SymmetrizeVector(err)
1248+
err /= np.sqrt(qe_sym.QE_nsym)
1249+
1250+
for i in range(self.dyn.structure.N_atoms):
1251+
print("{:4d}) {:14.6f}{:14.6f}{:14.6f} +- {:14.6f}{:14.6f}{:14.6f}".format(*list([i] + list(forces[i, :] * CC.Units.RY_TO_EV) + list(err[i,:] * CC.Units.RY_TO_EV)))
1252+
print()
1253+
12361254
if self.ensemble.has_stress and verbose >= 1:
12371255
print ()
12381256
print (" ==== STRESS TENSOR [GPa] ==== ")

0 commit comments

Comments
 (0)