Skip to content

Commit fc74e17

Browse files
committed
Create tersoff2gpumd.py
1 parent becdd0f commit fc74e17

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
import numpy as np
3+
4+
in_file = "1988.tersoff"
5+
out_file = "gpumd.txt"
6+
version = '1989' # 1988、1989
7+
chi = 1.0
8+
9+
tersoff_file = np.array(np.loadtxt(in_file, dtype=str))
10+
if tersoff_file.ndim == 1:
11+
tersoff_file = tersoff_file.reshape(1, -1)
12+
e1, e2, e3 = tersoff_file.T[:3]
13+
m, G, L3, c, d, ct0, n, b, L2, B, R, D, L1, A = np.round(tersoff_file.T[3:].astype(float), 4)
14+
15+
symbols = []
16+
for i in range(len(tersoff_file)):
17+
if e1[i] == e2[i] == e3[i]:
18+
symbols.append(e1[i])
19+
20+
with open(out_file, 'w') as f:
21+
if version == '1988':
22+
f.write(f'tersoff_1988 {len(symbols)} {" ".join(symbols)}\n')
23+
for i in range(len(symbols)**3):
24+
idx = f"{i:0{3}b}" # 如 '101'
25+
combo = [symbols[int(b)] for b in idx]
26+
for j in range(len(tersoff_file)):
27+
if combo[0] == e1[j] and combo[1] == e2[j] and combo[2] == e3[j]:
28+
f.write(f"{A[j]} {B[j]} {L1[j]} {L2[j]} {b[j]} {n[j]} {c[j]} {d[j]} {ct0[j]} {L2[j]} {R[j]-D[j]} {R[j]-D[j]+0.3} {m[j]} {L3[j]} {G[j]}\n")
29+
elif version == '1989':
30+
f.write(f'tersoff_1989 {len(symbols)} {" ".join(symbols)}\n')
31+
for i in range(len(tersoff_file)):
32+
if e1[i] == e2[i] == e3[i]:
33+
f.write(f"{A[i]} {B[i]} {L1[i]} {L2[i]} {b[i]} {n[i]} {c[i]} {d[i]} {ct0[i]} {L2[i]} {R[i]-D[i]} {R[i]-D[i]+0.3}\n")
34+
if len(symbols) == 2:
35+
f.write(f"{chi}\n")
36+

0 commit comments

Comments
 (0)