Skip to content

Commit

Permalink
fixed subtract()
Browse files Browse the repository at this point in the history
  • Loading branch information
kkly1995 committed Aug 5, 2022
1 parent e3833d3 commit bb33e43
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bin/mcase_nvt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ for i in range(number_samples):
walker.set_positions(r)
print(energy)
if i % save_interval == (save_interval - 1):
write(settings['save_xyz'], walker, format='extxyz', append=True)
write(settings['save_xyz'], walker, format='extxyz', append=True,
write_info=False, write_results=False)

# finished
print('particle move acceptance rate: %.2f' % (accepted / number_samples))
3 changes: 2 additions & 1 deletion bin/mcase_table_nvt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ for i in range(number_samples):
walker.set_positions(r)
print(energy)
if i % save_interval == (save_interval - 1):
write(settings['save_xyz'], walker, format='extxyz', append=True)
write(settings['save_xyz'], walker, format='extxyz', append=True,
write_info=False, write_results=False)

# finished
print('particle move acceptance rate: %.2f' % (accepted / number_samples))
15 changes: 12 additions & 3 deletions mcase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,25 @@ def subtract(samples, energy, force):
# for prepping data
# returns the samples with pair potential subtracted off
# no stresses / virials
# will overwrite the info dict as well as calculator results
from ase.calculators.singlepoint import SinglePointCalculator
new_samples = []
for i in range(len(samples)):
pairs = samples[i].get_all_distances(mic=True, vector=True)
e, f = evaluate(pairs, energy, force)
# replace
# replace info
new_sample = samples[i].copy()
new_sample.info['energy'] = samples[i].get_potential_energy() - e
new_sample.info['forces'] = samples[i].get_forces() - f
# if sample has stress, remove it
try:
new_sample.info.pop('stress')
except:
pass
# replace calc
new_calc = SinglePointCalculator(new_sample,
energy = samples[i].get_potential_energy() - e,
forces = samples[i].get_forces() - f,
energy = new_sample.info['energy'],
forces = new_sample.info['forces'],
stress = None
)
new_sample.calc = new_calc
Expand Down

0 comments on commit bb33e43

Please sign in to comment.