Created
November 16, 2017 15:14
-
-
Save thomasaarholt/64ff956e6a730ec0437cb7d50c68cc6c to your computer and use it in GitHub Desktop.
Python writer to create XYZ samples from ASE atoms objects
This file contains hidden or 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
def save_cell_for_prismatic(sample, name, path=""): | |
"Auto-adds 'prismatic' to filename" | |
import os | |
import numpy as np | |
if path == "": | |
path = os.getcwd() | |
name += "_Prismatic" | |
total = np.zeros(len(sample.numbers), dtype=[('Z', 'int8'), ("x", 'float'), ("y", 'float'), ("z", 'float'), ('occ', 'int'), ('dw', 'float')]) | |
total['Z'] = sample.numbers | |
total['x'], total['y'], total['z'] = sample.positions.T | |
total["occ"] = 1 | |
total['dw'] = 0.004 | |
header = "Test cell" + "\n\t" + " ".join(str(x)[:6] for x in sample.positions.max(axis=0)) | |
footer ="-1" | |
np.savetxt(os.path.join(path, name + ".xyz"), total, fmt="%s", header=header, footer=footer, comments="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment