Извлечение координат и типов атомов из объекта структуры pymatgen
Каков синтаксис для извлечения списка атомных координат, [[x1, y1, z1], [x2, y2, z2], ...] и списка атомных видов, например. [1,1,1,1,...] из объекта структуры pymatgen?
0 ответов
Импортировать объект структуры из pymatgen
from pymatgen import Structure
прочитать структуру cif из файла.cif
structure_from_cif = Structure.from_file('mp-773116La20S29O.cif')
получить координаты
cartesian_coords = structure_from_cif.cart_coords
чтобы получить вид, вы можете сделать следующее
for i in structure_from_cif.species:
print(i)
Это довольно старый вопрос, но если вам (или кому-то еще) нужен ответ, он будет следующим:
from pymatgen.core.structure import Structure, Lattice
structure = Structure(lattice, atoms, coords)#some structure
coordinates = []
species = []
for s in structure:
coordinates.append(s.coords) #cartesian coordinates
#coordinates.append(s.frac_coords) #would give fractional coordinates instead
species.append(s.specie.Z)
#species.append(s.specie) #would give strings (e.g. "Fe") instead of atomic number
print(coordinates)
print(species)