Supercell

Supercell:

The supercell module defines the supercell class for building supercells from crystal.Crystal classes.

Supercell class

Class to store supercells of crystals. A supercell is a lattice model of a crystal, with periodically repeating unit cells. In that framework we can

  1. add/remove/substitute atoms

  2. find the transformation map between two different representations of the same supercell

  3. output POSCAR format (possibly other formats?)

class supercell.Supercell(crys, super, interstitial=(), Nsolute=0, empty=False, NOSYM=False)[source]

A class that defines a Supercell of a crystal.

Takes in a crystal, a supercell (3x3 integer matrix). We can identify sites as interstitial sites, and specify if we’ll have solutes.

KrogerVink()[source]

Attempt to make a “simple” string based on the defectindices, using Kroger-Vink notation. That is, we identify: vacancies, antisites, and interstitial sites, and return a string. NOTE: there is no relative charges, so this is a pseudo-KV notation.

Return KV

string representation

POSCAR(name=None, stoichiometry=True)[source]

Return a VASP-style POSCAR, returned as a string.

Parameters
  • name – (optional) name to use for first list

  • stoichiometry – (optional) if True, append stoichiometry to name

Return POSCAR

string

__eq__(other)[source]

Return True if two supercells are equal; this means they should have the same occupancy. and the same ordering

Parameters

other – supercell for comparison

Returns

True if same crystal, supercell, occupancy, and ordering; False otherwise

__getitem__(key)[source]

Index into supercell

Parameters

key – index (either an int, a slice, or a position)

Returns

chemical occupation at that point

__imul__(other)[source]

Multiply by a GroupOp, in place.

Parameters

other – must be a GroupOp (and should be a GroupOp of the supercell!)

Returns

self

__init__(crys, super, interstitial=(), Nsolute=0, empty=False, NOSYM=False)[source]

Initialize our supercell to an empty supercell.

Parameters
  • crys – crystal object

  • super – 3x3 integer matrix

  • interstitial – (optional) list/tuple of indices that correspond to interstitial sites

  • Nsolute – (optional) number of substitutional solute elements to consider; default=0

  • empty – (optional) designed to allow “copy” to work–skips all derived info

  • NOSYM – (optional) does not do symmetry analysis (intended ONLY for testing purposes)

__mul__(other)[source]

Multiply by a GroupOp; returns a new supercell (constructed via copy).

Parameters

other – must be a GroupOp (and should be a GroupOp of the supercell!)

Returns

rotated supercell

__ne__(other)[source]

Inequality == not __eq__

__rmul__(other)[source]

Multiply by a GroupOp; returns a new supercell (constructed via copy).

Parameters

other – must be a GroupOp (and should be a GroupOp of the supercell!)

Returns

rotated supercell

__sane__()[source]

Return True if supercell occupation and chemorder are consistent

__setitem__(key, value)[source]

Set specific composition for site; uses same indexing as __getitem__

Parameters
  • key – index (either an int, a slice, or a position)

  • value – chemical occupation at that point

__str__()[source]

Human readable version of supercell

__weakref__

list of weak references to the object (if defined)

copy()[source]

Make a copy of the supercell; initializes, then copies over __copyattr__ and __eqattr__.

Returns

new supercell object, copy of the original

defectindices()[source]

Return a dictionary that corresponds to the “defect” content of the supercell.

Return defects

dictionary, keyed by defect type, with a set of indices of corresponding defects

definesolute(c, chemistry)[source]

Set the name of the chemistry of chemical index c. Only works for substitutional solutes.

Parameters
  • c – index

  • chemistry – string

equivalencemap(other)[source]

Given the super other we want to find a group operation that transforms self into other. This is a GroupOp along with an index mapping of chemorder. The index mapping is to get the occposlist to match up: (g*self).occposlist()[c][mapping[c][i]] == other.occposlist()[c][i] (We can write a similar expression using chemorder, since chemorder indexes into pos). We’re going to return both g and mapping.

Remember: g does not change the presentation ordering; mapping is necessary for full equivalence. If no such equivalence, return None,None.

Parameters

other – Supercell

Return g

GroupOp to transform sites from self to other

Return mapping

list of maps, such that (g*self).chemorder[c][mapping[c][i]] == other.chemorder[c][i]

fillperiodic(ci, Wyckoff=True)[source]

Occupies all of the (Wyckoff) sites corresponding to chemical index with the appropriate chemistry.

Parameters
  • ci – tuple of (chem, index) in crystal

  • Wyckoff – (optional) if False, only occupy the specific tuple, but still periodically

Return self

gengroup()[source]

Generate the group operations internal to the supercell

Return G

set of GroupOps

index(pos, threshold=1.0)[source]

Return the index that corresponds to the position closest to pos in the supercell. Done in direct coordinates of the supercell, using periodic boundary conditions.

Parameters
  • pos – 3-vector

  • threshold – (optional) minimum squared “distance” in supercell for a match; default=1.

Return index

index of closest position

makesites()[source]

Generate the array corresponding to the sites; the indexing is based on the translations and the atomindices in crys. These may not all be filled when the supercell is finished.

Return pos

array [N*size, 3] of supercell positions in direct coordinates

static maketrans(super)[source]

Takes in a supercell matrix, and returns a list of all translations of the unit cell that remain inside the supercell

Parameters

super – 3x3 integer matrix

Return size

integer, corresponding to number of unit cells

Return invsuper

integer matrix inverse of supercell (needs to be divided by size)

Return translist

list of integer vectors (to be divided by size) corresponding to unit cell positions

Return transdict

dictionary of tuples and their corresponding index (inverse of trans)

occposlist()[source]

Returns a list of lists of occupied positions, in (chem)order.

Return occposlist

list of lists of supercell coord. positions

reorder(mapping)[source]

Reorder (in place) the occupied sites. Does not change the occupancies, only the ordering for “presentation”.

Parameters

mapping – list of maps; will make newchemorder[c][i] = chemorder[c][mapping[c][i]]

Return self

If mapping is not a proper permutation, raises ValueError.

setocc(ind, c)[source]

Set the occupancy of position indexed by ind, to chemistry c. Used by all the other algorithms.

Parameters
  • ind – integer index

  • c – chemistry index

stoichiometry()[source]

Return a string representing the current stoichiometry