Skip to content

Commit 74a5cca

Browse files
committed
Use format method of string object.
1 parent a14896b commit 74a5cca

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

scripts/create_inputs.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@
1414
from vaspy.incar import InCar
1515

1616
if "__main__" == __name__:
17+
1718
# Set argument parser.
1819
parser = argparse.ArgumentParser()
1920

2021
# Add kpoint optional argument.
2122
parser.add_argument("-k", "--kpoints", help="set k-points")
2223
args = parser.parse_args()
2324

24-
#create POSCAR
25+
# create POSCAR
2526
status, output = commands.getstatusoutput('ls *.xsd | head -1')
2627
xsd = XsdFile(filename=output)
2728
poscar_content = xsd.get_poscar_content(bases_const=1.0)
2829
with open('POSCAR', 'w') as f:
2930
f.write(poscar_content)
3031

31-
#create POTCAR
32+
# create POTCAR
3233
potdir = r'/data/pot/vasp/potpaw_PBE2010/'
33-
#delete old POTCAR
34+
# delete old POTCAR
3435
if os.path.exists('./POTCAR'):
3536
os.remove('./POTCAR')
3637
for elem in xsd.atoms:
@@ -43,7 +44,7 @@
4344
sys.exit(1)
4445
commands.getstatusoutput('cat ' + potcar + ' >> ./POTCAR')
4546

46-
#creat KPOINTS
47+
# creat KPOINTS
4748
if not args.kpoints:
4849
kpoints = []
4950
for base in xsd.bases:
@@ -58,9 +59,9 @@
5859
with open('KPOINTS', 'w') as f:
5960
f.write(kpt_content)
6061

61-
#copy INCAR vasp.script
62+
# copy INCAR vasp.script
6263
commands.getstatusoutput('cp $HOME/example/INCAR $HOME/example/vasp.script ./')
63-
#change jobname
64+
# change jobname
6465
jobname = output.split('.')[0]
6566
with open('vasp.script', 'r') as f:
6667
content_list = f.readlines()
@@ -69,7 +70,7 @@
6970
with open('vasp.script', 'w') as f:
7071
f.writelines(content_list)
7172

72-
#create fort.188
73+
# create fort.188
7374
atom_idxs = []
7475
atom_names = []
7576
for idx, atom_name in enumerate(xsd.atom_names):
@@ -92,15 +93,15 @@
9293
(atom_idxs[0]+1, atom_idxs[1]+1, distance)
9394
with open('fort.188', 'w') as f:
9495
f.write(content)
95-
print "fort.188 has been created."
96-
print '-'*20
97-
print "atom number: %-5d%-5d" % (atom_idxs[0]+1, atom_idxs[1]+1)
98-
print "atom name: %s %s" % tuple(atom_names)
99-
print "distance: %f" % distance
100-
print '-'*20
96+
logging.info("fort.188 has been created.")
97+
logging.info('-'*20)
98+
logging.info("atom number: {:<5d}{:<5d}".format(atom_idxs[0]+1, atom_idxs[1]+1))
99+
logging.info("atom name: {} {}".format(*atom_names))
100+
logging.info("distance: {:f}".format(distance))
101+
logging.info('-'*20)
101102

102103
# set IBRION = 1
103104
incar = InCar()
104105
incar.set('IBRION', 1)
105106
incar.tofile()
106-
print "IBRION is set to 1."
107+
logging.info("IBRION is set to 1.")

0 commit comments

Comments
 (0)