Skip to content

Commit bb4c063

Browse files
authored
Merge pull request #185 from ICAMS/get_energy_dissipation
Get energy dissipation
2 parents bb30a28 + ef30db7 commit bb4c063

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

calphy/integrators.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def integrate_rs(simfolder, f0, t,
226226
227227
"""
228228
ws = []
229+
es = []
229230
p = p/(10000*160.21766208)
230231

231232
for i in range(1, nsims+1):
@@ -245,9 +246,12 @@ def integrate_rs(simfolder, f0, t,
245246
wf = cumtrapz(fdx, flambda,initial=0)
246247
wb = cumtrapz(bdx[::-1], blambda[::-1],initial=0)
247248
w = (wf + wb) / (2*flambda)
249+
e = np.max(np.abs((wf - wb)/(2*flambda)))
250+
248251
ws.append(w)
249-
252+
es.append(e)
250253

254+
e_diss = np.min(es)
251255
wmean = np.mean(ws, axis=0)
252256
werr = np.std(ws, axis=0)
253257
temp = t/flambda
@@ -257,8 +261,9 @@ def integrate_rs(simfolder, f0, t,
257261
if not return_values:
258262
outfile = os.path.join(simfolder, "temperature_sweep.dat")
259263
np.savetxt(outfile, np.column_stack((temp, f, werr)))
264+
return None, e_diss
260265
else:
261-
return (temp, f, werr)
266+
return (temp, f, werr), e_diss
262267

263268

264269
def integrate_ps(simfolder, f0, natoms, pi, pf, nsims=1,

calphy/phase.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ def integrate_reversible_scaling(self, scale_energy=True, return_values=False):
12061206
res : list of lists of shape 1x3
12071207
Only returned if `return_values` is True.
12081208
"""
1209-
res = integrate_rs(
1209+
res, ediss = integrate_rs(
12101210
self.simfolder,
12111211
self.fe,
12121212
self.calc._temperature,
@@ -1217,6 +1217,11 @@ def integrate_reversible_scaling(self, scale_energy=True, return_values=False):
12171217
return_values=return_values,
12181218
)
12191219

1220+
self.logger.info(f'Maximum energy dissipation along the temperature scaling part: {ediss} eV/atom')
1221+
if np.abs(ediss) > 1E-4:
1222+
self.logger.warning(f'Found max energy dissipation of {ediss} along the temperature scaling path. Please ensure there are no structural changes!')
1223+
1224+
12201225
if return_values:
12211226
return res
12221227

0 commit comments

Comments
 (0)