-
Notifications
You must be signed in to change notification settings - Fork 835
/
prismatic.py
41 lines (32 loc) · 1.19 KB
/
prismatic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Write Prismatic (http://prism-em.com) input files."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pymatgen.core import Structure
class Prismatic:
"""
Class to write Prismatic (http://prism-em.com/) input files.
This is designed for STEM image simulation.
"""
def __init__(self, structure: Structure, comment: str = "Generated by pymatgen") -> None:
"""
Args:
structure: pymatgen Structure
comment (str): comment.
"""
self.structure = structure
self.comment = comment
def to_str(self) -> str:
"""
Returns:
str: Prismatic XYZ file. This is similar to XYZ format
but has specific requirements for extra fields, headers, etc.
"""
lattice = self.structure.lattice
lines = [self.comment, " ".join(map(str, lattice.lengths))]
for site in self.structure:
for sp, occu in site.species.items():
x, y, z = site.coords
lines.append(f"{sp.Z} {x} {y} {z} {occu} {site.properties.get('thermal_sigma', 0)}")
lines.append("-1")
return "\n".join(lines)