-
Notifications
You must be signed in to change notification settings - Fork 17
/
coul_tt
executable file
·68 lines (54 loc) · 1.96 KB
/
coul_tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
import argparse
def ReadData(dfile):
file = open(dfile, 'r')
atoms = list()
line = file.readline()
while line :
if 'Masses' in line:
break
line = file.readline()
line = file.readline()
line = file.readline()
while line :
if 'Bond Coeffs' in line:
del atoms[-1]
break
atoms.append(line.split())
line = file.readline()
cores = list()
for a in atoms:
if 'DC' in a[-1]:
cores.append(int(a[0]))
elif 'DP' in a[-1]:
dp = int(a[0])
break
return (cores, dp)
def WritePairFile(pfile, hatoms, cores, dp):
res = []
res.append('# Tang-Toennies charge-dipole damping')
for h in hatoms:
for c in cores:
if int(h) < c:
res.append('pair_coeff {0:4d} {1:4d} coul/tt 4.5 1.0'.format(int(h), c))
else:
res.append('pair_coeff {0:4d} {1:4d} coul/tt 4.5 1.0'.format(c, int(h)))
res.append('pair_coeff {0:4d} {1:3d}* coul/tt 4.5 1.0'.format(int(h), dp))
with open(pfile, 'w') as f:
for line in res:
f.write(line+'\n')
def WriteInputFile(pfile):
print('To inlcude in in-p.lmp:')
print(' pair_style hybrid/overlay [...] coul/tt 4 12.0')
print(' include {0}'.format(pfile))
def main():
parser = argparse.ArgumentParser( description = 'Automatic coul/tt pair style generator')
parser.add_argument('-d', '--dfile', dest='dfile', default='data-p.lmp', type=str, help='Data file with atomic indexes and labels of polarisable system [default: %(default)s]')
parser.add_argument('-a', '--hatoms', dest='hatoms', type=str, nargs='+', help='Atomic indexes of naked charge hydrogen atoms')
args = parser.parse_args()
pfile = "pair-tt.lmp"
(cores,dp) = ReadData(args.dfile)
WritePairFile(pfile, args.hatoms, cores, dp)
WriteInputFile(pfile)
if __name__ == '__main__':
main()