-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#! /usr/bin/env python | ||
from __future__ import print_function | ||
|
||
import argparse | ||
import numpy as np | ||
import ase.atoms | ||
import ase.build | ||
import ase.visualize | ||
|
||
def atoms_from_sqs(filename): | ||
|
||
with open(filename, 'r') as f: | ||
lines = f.readlines() | ||
lines = [line.split() for line in lines] | ||
|
||
basis = np.matrix([list(map(float, line)) for line in lines[:3]]) | ||
scell = np.matrix([list(map(float, line)) for line in lines[3:6]]) | ||
|
||
spositions = [np.matrix(list(map(float, line[:3]))) for line in lines[6:]] | ||
symbols = [line[-1] for line in lines[6:]] | ||
|
||
supercell = scell * basis | ||
positions = spositions * basis | ||
atoms = ase.atoms.Atoms(symbols=symbols, | ||
cell=supercell, | ||
positions=positions, | ||
pbc=True) | ||
|
||
return atoms | ||
|
||
def txt_display(atoms): | ||
print("Unit cell:") | ||
print(atoms.cell) | ||
print("Positions") | ||
atoms = ase.build.sort(atoms) | ||
for atom in atoms: | ||
|
||
print(atom.position, atom.symbol) | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('filename', nargs='?', default='bestsqs.out', | ||
help="Input file generated by ATAT") | ||
parser.add_argument('--output', '-o', default=None, | ||
help="If specified, write to this filename") | ||
parser.add_argument('--gui', '-g', action='store_true', | ||
help="Show structure in ASE-GUI") | ||
|
||
args = parser.parse_args() | ||
|
||
atoms = atoms_from_sqs(args.filename) | ||
|
||
if args.output is not None: | ||
# Write file with vasp5 flag if supported | ||
try: | ||
atoms.write(args.output, sort=True, vasp5=True) | ||
except TypeError: | ||
atoms = ase.build.sort(atoms) | ||
atoms.write(args.output) | ||
else: | ||
txt_display(atoms) | ||
|
||
if args.gui: | ||
ase.visualize.view(atoms) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters