add support to create tables for fix wall/table

This commit is contained in:
Axel Kohlmeyer
2023-02-22 23:31:04 -05:00
parent a3ff40ccf0
commit 0dcb591ee8
3 changed files with 136 additions and 0 deletions

View File

@ -279,6 +279,53 @@ class DihedralTabulate(Tabulate):
if self.args.filename != '-':
self.fp.close()
################################################################################
# create tabulation for fix wall/table
class WallTabulate(Tabulate):
def __init__(self, efunc, ffunc=None, units=None, comment=None):
super(WallTabulate, self).__init__('wall', efunc, ffunc, units, comment)
self.parser.add_argument('--eshift', '-e', dest='eshift', default=False,
action='store_true',
help="Shift potential energy to be zero at outer cutoff")
idx = [a.dest for a in self.parser._actions].index('xmin')
self.parser._actions[idx].required=False
self.parser._actions[idx].default=0.0
try:
self.args = self.parser.parse_args()
except argparse.ArgumentError:
sys.exit()
def run(self, label):
# sanity checks
if self.args.num < 2:
self.helpexit('Expect 2 or more points in table for tabulation')
if self.args.xmin < 0.0:
self.helpexit('Inner cutoff must not be negative')
self.diff = self.args.diff
if not self.forcefunc:
self.diff = True
table, xzero = mktable(self.tstyle, label, self.args.num, self.args.xmin, self.args.xmax,
self.energyfunc, self.args.diff, self.forcefunc)
print("# Minimum energy of tabulated potential is at %g" % xzero)
offset = 0.0
if self.args.eshift:
offset=self.energyfunc(self.args.xmax)
self.openfile(label)
if self.forcefunc:
diffmin = -numdiff(self.args.xmin, self.forcefunc)
diffmax = -numdiff(self.args.xmax, self.forcefunc)
self.fp.write("N %d FP %- 22.15g %- 22.15g\n\n" % (self.args.num, diffmin, diffmax))
else:
self.fp.write("N %d\n\n" % (self.args.num))
self.writetable(table, offset)
if self.args.filename != '-':
self.fp.close()
################################################################################
if __name__ == "__main__":
sys.exit("The tabulate module is not meant to be executed directly")