apply some pylint recommendations
This commit is contained in:
@ -11,9 +11,10 @@ This script requires the numpy library.
|
||||
|
||||
import sys
|
||||
import argparse as ap
|
||||
from datetime import date
|
||||
|
||||
import numpy as np
|
||||
from eamDatabase import Database
|
||||
from datetime import date
|
||||
|
||||
def prof(at, r):
|
||||
atom = Database[at]
|
||||
@ -72,7 +73,7 @@ def write_file(attypes, filename, Fr, rhor, z2r, nrho, drho, nr, dr, rc):
|
||||
f.write(" CONTRIBUTOR: Xiaowang Zhou xzhou@sandia.gov and")
|
||||
f.write(" Lucas Hale lucas.hale@nist.gov")
|
||||
f.write(" Germain Clavier g.m.g.c.clavier@tue.nl/germain.clavier@gmail.com\n")
|
||||
f.write(" CITATION: X. W. Zhou, R. A. Johnson, H. N. G. Wadley, Phys. Rev. B, 69, 144113(2004) ")
|
||||
f.write(" CITATION: X. W. Zhou, R. A. Johnson, H. N. G. Wadley, Phys. Rev. B, 69, 144113(2004)\n")
|
||||
f.write("Generated by create_eam.py\n")
|
||||
f.write("{:<5d} {:<24}\n".format(len(attypes), " ".join(attypes)))
|
||||
f.write("{:<5d} {:<24.16e} {:<5d} {:<24.16e} {:<24.16e}\n".format(nrho, drho, nr, dr, rc))
|
||||
@ -98,16 +99,15 @@ def write_file(attypes, filename, Fr, rhor, z2r, nrho, drho, nr, dr, rc):
|
||||
if not (i + 1) % 5:
|
||||
f.write("\n")
|
||||
|
||||
return
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = ap.ArgumentParser(description="Script to create EAM alloy potential files.")
|
||||
|
||||
parser.add_argument("-n", "--names", dest="name", nargs="+", help="Element names.")
|
||||
parser.add_argument("-nr", dest="nr", type=int, default=2000, help="Number of point in r space [default 2000].")
|
||||
parser.add_argument("-nrho", dest="nrho", type=int, default=2000, help="Number of point in rho space [default 2000].")
|
||||
parser.add_argument("-n", "--names", dest="name", nargs="+",
|
||||
help="Element names")
|
||||
parser.add_argument("-nr", dest="nr", type=int, default=2000,
|
||||
help="Number of point in r space [default 2000]")
|
||||
parser.add_argument("-nrho", dest="nrho", type=int, default=2000,
|
||||
help="Number of point in rho space [default 2000]")
|
||||
args = parser.parse_args()
|
||||
if not args.name:
|
||||
parser.print_help()
|
||||
@ -138,24 +138,20 @@ def main():
|
||||
dr = r[1] - r[0]
|
||||
r[r < rst] = rst
|
||||
z2r = np.zeros([ntypes, ntypes, nr])
|
||||
fmax = -np.inf
|
||||
rhomax = -np.inf
|
||||
|
||||
for i, n1 in enumerate(atnames):
|
||||
for j, n2 in enumerate(atnames):
|
||||
if j > i:
|
||||
continue
|
||||
elif i == j:
|
||||
if i == j:
|
||||
rhor[n1] = prof(n1, r)
|
||||
rhomax = np.max(rhor[n1]) if rhomax < np.max(rhor[n1]) else rhomax
|
||||
rhomax = max(rhomax,np.max(rhor[n1]))
|
||||
z2r[i, j, :] = r * pair(n1, n2, r)
|
||||
else:
|
||||
z2r[i, j, :] = r * pair(n1, n2, r)
|
||||
z2r = np.where(z2r, z2r, z2r.transpose((1, 0, 2)))
|
||||
if rhomax < 2.0 * rhoemax:
|
||||
rhomax = 2.0 * rhoemax
|
||||
if rhomax < 100.0:
|
||||
rhomax = 100.0
|
||||
rhomax = max(rhomax, 2.0 * rhoemax, 100.0)
|
||||
rho = np.linspace(0.0, rhomax, num=nrho, dtype=np.double)
|
||||
drho = rho[1] - rho[0]
|
||||
for i, n1 in enumerate(atnames):
|
||||
@ -163,11 +159,8 @@ def main():
|
||||
|
||||
write_file(atnames, outfilename, Fr, rhor, z2r, nrho, drho, nr, dr, rc)
|
||||
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit("User interruption.")
|
||||
except KeyboardInterrupt as exc:
|
||||
raise SystemExit("User interruption.") from exc
|
||||
|
||||
Reference in New Issue
Block a user