Skip to content

Commit b719828

Browse files
authored
Update ti.py | enhancing data precision (#32)
* Update ti.py | enhancing data precision change the format of lammps thermo from %.8g (8 significant figures) to %20.6f for concerned thermal quantities. some systems have very large per-atom energy (lower than -1000 eV/atom) While the reference point of the energy could be arbitary that gives even lower values, the deltaE in cared range of thermal conditions is fixed e.g. ~ several meV/atom. Storing the total energy of such systems may run out of significant figures before the cared precision. formats of related data-duplication output files 'data' are also changed from %.6e to %20.6f format of ti.out is also changed from %.8e in to %.12e which stores total energy too * Update ti.py * Update ti.py fix typo * Update ti.py thermo_modify should be after the thermo_style, and the colum range 4~8 (nooted as 4*8) is dependent on the thermo_style. Developer should add new thermo_modify lines if they add other kinds of ens and corresponding thermol_style. * Update in.lammps | enhancing data precision * Update in.lammps | enhancing data precision * Update in.lammps | enhancing data precision * Update in.lammps | enhancing data precision * Update test_ti_gen_lammps_input.py | enhancing data precision * Update in.lammps | enhancing data precision
1 parent c5d4cd9 commit b719828

7 files changed

Lines changed: 13 additions & 4 deletions

File tree

dpti/ti.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ def _gen_lammps_input (conf_file,
8686
ret += 'compute allmsd all msd\n'
8787
if ens == 'nvt' :
8888
ret += 'thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]\n'
89+
ret += 'thermo_modify 4*8 format %20.6f\n'
8990
elif 'npt' in ens :
9091
ret += 'thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]\n'
92+
ret += 'thermo_modify 4*8 format %20.6f\n'
9193
else :
92-
raise RuntimeError('unknow ensemble %s\n' % ens)
94+
raise RuntimeError('unknow ensemble %s\n' % ens)
9395
ret += '# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z\n'
9496
if ens == 'nvt' :
9597
ret += 'fix 1 all nvt temp ${TEMP} ${TEMP} ${TAU_T}\n'
@@ -442,7 +444,7 @@ def post_tasks(iter_name, jdata, Eo, Eo_err = 0, To = None, natoms = None, schem
442444
# get energy stat
443445
log_name = os.path.join(ii, 'log.lammps')
444446
data = get_thermo(log_name)
445-
np.savetxt(os.path.join(ii, 'data'), data, fmt = '%.6e')
447+
np.savetxt(os.path.join(ii, 'data'), data, fmt = '%20.6f')
446448
ea, ee = block_avg(data[:, stat_col],
447449
skip = stat_skip,
448450
block_size = stat_bsize)
@@ -488,7 +490,7 @@ def post_tasks(iter_name, jdata, Eo, Eo_err = 0, To = None, natoms = None, schem
488490
all_print = np.array(all_print)
489491
np.savetxt(os.path.join(iter_name, 'ti.out'),
490492
all_print.T,
491-
fmt = '%.8e',
493+
fmt = '%.12e',
492494
header = 't/p Integrand U/V U/V_err enthalpy msd_xyz')
493495

494496
info0 = _compute_thermo(os.path.join(all_tasks[ 0], 'log.lammps'), natoms, stat_skip, stat_bsize)
@@ -612,7 +614,7 @@ def post_tasks_mbar(iter_name, jdata, Eo, natoms = None) :
612614
for ii in all_tasks :
613615
log_name = os.path.join(ii, 'log.lammps')
614616
data = get_thermo(log_name)
615-
np.savetxt(os.path.join(ii, 'data'), data, fmt = '%.6e')
617+
np.savetxt(os.path.join(ii, 'data'), data, fmt = '%20.6f')
616618
block_u = []
617619
if path == 't' or path == 't-ginv':
618620
this_e = data[stat_skip::1, stat_col]

tests/benchmark_gdi/deepmd/0/in.lammps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ timestep 0.002
2424
thermo ${THERMO_FREQ}
2525
compute allmsd all msd
2626
thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]
27+
thermo_modify 4*8 format %20.6f
2728
# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z
2829
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P}
2930
fix mzero all momentum 10 linear 1 1 1

tests/benchmark_ti/path-p/in.lammps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ timestep 0.002
2626
thermo ${THERMO_FREQ}
2727
compute allmsd all msd
2828
thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]
29+
thermo_modify 4*8 format %20.6f
2930
# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z
3031
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} aniso ${PRES} ${PRES} ${TAU_P} couple xy
3132
fix mzero all momentum 10 linear 1 1 1

tests/benchmark_ti/path-p/task.000006/in.lammps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ timestep 0.002
2525
thermo ${THERMO_FREQ}
2626
compute allmsd all msd
2727
thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]
28+
thermo_modify 4*8 format %20.6f
2829
# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z
2930
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} aniso ${PRES} ${PRES} ${TAU_P} couple xy
3031
fix mzero all momentum 10 linear 1 1 1

tests/benchmark_ti/path-t/task.000006/in.lammps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ timestep 0.002
2525
thermo ${THERMO_FREQ}
2626
compute allmsd all msd
2727
thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]
28+
thermo_modify 4*8 format %20.6f
2829
# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z
2930
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} aniso ${PRES} ${PRES} ${TAU_P} couple xy
3031
fix mzero all momentum 10 linear 1 1 1

tests/benchmark_ti_water/new_job/task.000003/in.lammps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ timestep 0.0005
2626
thermo ${THERMO_FREQ}
2727
compute allmsd all msd
2828
thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]
29+
thermo_modify 4*8 format %20.6f
2930
# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z
3031
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P}
3132
fix mzero all momentum 10 linear 1 1 1

tests/test_ti_gen_lammps_input.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_deepmd(self, patch_random):
5858
thermo ${THERMO_FREQ}
5959
compute allmsd all msd
6060
thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]
61+
thermo_modify 4*8 format %20.6f
6162
# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z
6263
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P}
6364
fix mzero all momentum 10 linear 1 1 1
@@ -117,6 +118,7 @@ def test_meam(self, patch_random):
117118
thermo ${THERMO_FREQ}
118119
compute allmsd all msd
119120
thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]
121+
thermo_modify 4*8 format %20.6f
120122
# dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z
121123
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P}
122124
fix mzero all momentum 10 linear 1 1 1

0 commit comments

Comments
 (0)