File: gen_angle_table.py

package info (click to toggle)
lammps 20220106.git7586adbb6a%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 348,064 kB
  • sloc: cpp: 831,421; python: 24,896; xml: 14,949; f90: 10,845; ansic: 7,967; sh: 4,226; perl: 4,064; fortran: 2,424; makefile: 1,501; objc: 238; lisp: 163; csh: 16; awk: 14; tcl: 6
file content (30 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (3)
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
from math import pi as M_PI
theta0 = [0.0, 110.1, 111.0, 120.0, 108.5]
k      = [0.0, 75.0,  45.0,  50.0, 100.0]

def compute(itype,theta):
    dtheta = theta-theta0[itype]
    tk = k[itype]*dtheta*M_PI/180.0*M_PI/180.0
    phi    =  tk*dtheta
    force  =  -2.0*tk
    return (phi,force)

fp = open("angle_table.txt","w")
fp.write("# generated by gen_angle.py\n")
num = 72
fac = 180.0/num

for i in [1,2,3,4]:
    fp.write("\nharmonic_%d\n" % i)
    if i > 2:
      fp.write("N %d EQ %g\n\n" % (num+1,theta0[i]))
    else:
      grad=2.0*k[i]*M_PI/180.0*M_PI/180.0
      fp.write("N %d FP %g %g EQ %g\n\n" % (num+1,grad, grad, theta0[i]))

    for j in range(num+1):
        theta = fac*j
        (phi,force) = compute(i,theta)
        fp.write("%d %.15g %.15g %.15g\n" % (j+1,theta,phi,force))

fp.close()