|
14 | 14 | from vaspy.incar import InCar |
15 | 15 |
|
16 | 16 | if "__main__" == __name__: |
| 17 | + |
17 | 18 | # Set argument parser. |
18 | 19 | parser = argparse.ArgumentParser() |
19 | 20 |
|
20 | 21 | # Add kpoint optional argument. |
21 | 22 | parser.add_argument("-k", "--kpoints", help="set k-points") |
22 | 23 | args = parser.parse_args() |
23 | 24 |
|
24 | | - #create POSCAR |
| 25 | + # create POSCAR |
25 | 26 | status, output = commands.getstatusoutput('ls *.xsd | head -1') |
26 | 27 | xsd = XsdFile(filename=output) |
27 | 28 | poscar_content = xsd.get_poscar_content(bases_const=1.0) |
28 | 29 | with open('POSCAR', 'w') as f: |
29 | 30 | f.write(poscar_content) |
30 | 31 |
|
31 | | - #create POTCAR |
| 32 | + # create POTCAR |
32 | 33 | potdir = r'/data/pot/vasp/potpaw_PBE2010/' |
33 | | - #delete old POTCAR |
| 34 | + # delete old POTCAR |
34 | 35 | if os.path.exists('./POTCAR'): |
35 | 36 | os.remove('./POTCAR') |
36 | 37 | for elem in xsd.atoms: |
|
43 | 44 | sys.exit(1) |
44 | 45 | commands.getstatusoutput('cat ' + potcar + ' >> ./POTCAR') |
45 | 46 |
|
46 | | - #creat KPOINTS |
| 47 | + # creat KPOINTS |
47 | 48 | if not args.kpoints: |
48 | 49 | kpoints = [] |
49 | 50 | for base in xsd.bases: |
|
58 | 59 | with open('KPOINTS', 'w') as f: |
59 | 60 | f.write(kpt_content) |
60 | 61 |
|
61 | | - #copy INCAR vasp.script |
| 62 | + # copy INCAR vasp.script |
62 | 63 | commands.getstatusoutput('cp $HOME/example/INCAR $HOME/example/vasp.script ./') |
63 | | - #change jobname |
| 64 | + # change jobname |
64 | 65 | jobname = output.split('.')[0] |
65 | 66 | with open('vasp.script', 'r') as f: |
66 | 67 | content_list = f.readlines() |
|
69 | 70 | with open('vasp.script', 'w') as f: |
70 | 71 | f.writelines(content_list) |
71 | 72 |
|
72 | | - #create fort.188 |
| 73 | + # create fort.188 |
73 | 74 | atom_idxs = [] |
74 | 75 | atom_names = [] |
75 | 76 | for idx, atom_name in enumerate(xsd.atom_names): |
|
92 | 93 | (atom_idxs[0]+1, atom_idxs[1]+1, distance) |
93 | 94 | with open('fort.188', 'w') as f: |
94 | 95 | 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) |
101 | 102 |
|
102 | 103 | # set IBRION = 1 |
103 | 104 | incar = InCar() |
104 | 105 | incar.set('IBRION', 1) |
105 | 106 | incar.tofile() |
106 | | - print "IBRION is set to 1." |
| 107 | + logging.info("IBRION is set to 1.") |
0 commit comments