crystals.Crystal

class crystals.Crystal(unitcell, lattice_vectors, source=None, **kwargs)

The Crystal class is a set-like container that represent crystalline structures. In addition to constructing the Crystal object yourself, other constructors are also available (and preferred):

  • Crystal.from_cif(): create an instance from a CIF file;

  • Crystal.from_pdb(): create an instance from a Protein Data Bank entry;

  • Crystal.from_database(): create an instance from the internal database of CIF files;

  • Crystal.from_cod(): create an instance from a Crystallography Open Database entry;

  • Crystal.from_mp(): create an instance from the Materials Project database;

  • Crystal.from_pwscf(): create an instance from the output of the PWSCF program;

  • Crystal.from_ase(): create an instance from an ase.Atoms instance;

  • Crystal.from_poscar(): create an instance from VASP POSCAR files.

Parameters
  • unitcell (iterable of Atom or AtomicStructure) – Unit cell atoms or substructures. It is assumed that the atoms are in fractional coordinates.

  • lattice_vectors (iterable of array_like) – Lattice vectors. If lattice_vectors is provided as a 3x3 array, it is assumed that each lattice vector is a row.

  • source (str or None, optional) – Provenance, e.g. filename. Only used for bookkeeping.

__init__(unitcell, lattice_vectors, source=None, **kwargs)

Methods

__add__(other)

Create a new structure made from the combination of two structures.

__array__(*args, **kwargs)

Returns an array in which each row represents an Atom instance.

__bool__()

An AtomicStructure is False if empty, and True otherwise

__contains__(item)

Check containership of Atom instances or AtomicStructure substructures recursively.

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(other)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(unitcell, lattice_vectors[, source])

__init_subclass__

This method is called when a class is subclassed.

__iter__()

Yields Atom instances from the structure and substructures recursively.

__le__(value, /)

Return self<=value.

__len__()

Number of Atom instances present in the structure and substructures

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Verbose string representation of this instance.

__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

String representation of this instance.

__subclasshook__

Abstract classes can override this to customize issubclass().

_from_spglib_cell(lattice_vectors, ...)

Build a Crystal object from the return value of many SPGLIB routines.

_spglib_cell()

Returns an array in spglib's cell format.

_to_string(natoms)

Generate a string representation of this Crystal.

asymmetric_cell()

Calculates the asymmetric cell that generates the crystal unit cell.

bounded_reflections(bound[, min_bound])

Generates reflections (hkl) with norm(G) <= bound

frac_mesh(*xi[, indexing])

Coordinate arrays for fractional coordinates.

from_ase(atoms, **kwargs)

Returns a Crystal object created from an ASE Atoms object.

from_cif(path, **kwargs)

Returns a Crystal object created from a CIF 1.0, 1.1 or 2.0 file.

from_cod(num[, revision, download_dir, ...])

Returns a Crystal object built from the Crystallography Open Database.

from_database(name, **kwargs)

Returns a Crystal object create from the internal CIF database.

from_mp(query[, api_key, download_dir, ...])

Returns a Crystal object built from the Materials Project.

from_parameters(a, b, c, alpha, beta, gamma)

Create a Lattice instance from three lengths and angles.

from_pdb(ID[, download_dir, overwrite])

Returns a Crystal object created from a Protein DataBank entry.

from_poscar(path, **kwargs)

Returns a Crystal object created from a VASP's POSCAR file.

from_pwscf(path, **kwargs)

Returns a Crystal object created from an output file of PWSCF.

ideal([symprec])

Returns a Crystal object with an idealized unit cell.

indexed_by(lattice)

Return a crystal structure, indexed by another lattice/crystal structure.

itersorted(*[, key, reverse])

Yields Atom in sorted order.

mesh(*xi[, indexing])

Cartesian coordinate arrays from fractional coordinate vectors.

miller_indices(scattering_vector)

Miller indices from scattering vector components.

primitive([symprec])

Returns a Crystal object in the primitive unit cell.

reciprocal_symmetry_operations([symprec])

Get the symmetry operations that the reciprocal unit cell respects.

satisfying(predicate)

Builds a new AtomicStructure from atoms satisfying a predicate.

scattering_vector(reflection)

Scattering vector from Miller indices.

supercell(n1, n2, n3)

Create a supercell from this crystal, i.e. an atomic structure where the crystal unit cell is duplicated along lattice vectors.

symmetry([symprec, angle_tolerance])

Returns a dictionary containing space-group information.

symmetry_operations([symprec])

Get the symmetry operations that the crystal unit cell respects.

to_ase(**kwargs)

Convert a into an ase.Atoms object.

to_cif(filename)

Convert this Crystal instance to a CIF file.

to_poscar(filename, **kwargs)

Convert this Crystal instance to a POSCAR file.

to_xyz(filename)

Convert this Crystal instance to a XYZ file.

transform(*operators)

Return a transformed AtomicStructure based on symmetry operators.

Attributes

builtins

centering

Centering type of this crystals.

chemical_composition

Chemical composition of this structure as an ordered dictionary.

chemical_formula

Empirical chemical formula for this structure based on the chemical symbols.

hall_number

Hall number (between 1 and 531).

hall_symbol

Hall symbol.

hm_symbol

Hermann-Mauguin symbol.

international_full

International Tables of Crystallography space-group full symbol.

international_number

International Tables of Crystallography space-group number (between 1 and 230).

international_symbol

International Tables of Crystallography space-group short symbol.

lattice_parameters

Lattice parameters as three lengths [Å] and three angles [degrees].

lattice_system

One of the seven lattice system, returned in the form of the LatticeSystem enumeration.

lattice_vectors

Iterable of lattice vectors

periodicity

Crystal periodicity in x, y and z direction from the lattice constants.

pointgroup

International Tables of Crystallography point-group.

reciprocal

Reciprocal lattice

reciprocal_vectors

Reciprocal lattice vectors, defined as:

unitcell

Generator of atoms forming the crystal unit cell.

volume

Lattice cell volume Angtroms cubed