crystal_torture.pymatgen_interface

crystal_torture.pymatgen_interface.clusters_from_file(filename, rcut, elements)

Take a pymatgen compatible file, and converts it to a cluster object

Args:

  • filename (str): name of file to set up graph from
  • rcut (float): cut-off radii for node-node connections in forming clusters
  • elements ([str,str,…..]): list of elements to include in setting up graph
Returns:
  • clusters ({clusters}): set of clusters
crystal_torture.pymatgen_interface.clusters_from_structure(structure, rcut, elements)

Take a pymatgen structure, and converts it to a graph object

Args:

  • structure (Structure): pymatgen structure object to set up graph from
  • rcut (float): cut-off radii for node-node connections in forming clusters
  • elements ({str,str,…..}): set of element strings to include in setting up graph

Returns:

  • clusters ({clusters}): set of clusters
crystal_torture.pymatgen_interface.create_halo(structure, neighbours)

Takes a pymatgen structure object, sets up a halo by making a 3x3x3 supercell,

Args:

  • structure (Structure): pymatgen Structure object
  • neighbours [[(site, dist, index, image) …], ..]: list of neighbours for sites in structure

Returns:

  • structure (Structure): 3x3x3x supercell pymatgen Structure object
  • neighbours [[(site, dist, index, image) …], ..]: new list of neighbours for sites in supercell structure
crystal_torture.pymatgen_interface.get_all_neighbors_and_image(structure, r, include_index=False)

Modified from pymatgen to return image (used for mapping to supercell), and to use the f2py wrapped OpenMP dist subroutine to get the distances (smaller memory footprint and faster than numpy).

Get neighbours for each atom in the unit cell, out to a distance r Returns a list of list of neighbors for each site in structure. Use this method if you are planning on looping over all sites in the crystal. If you only want neighbors for a particular site, use the method get_neighbors as it may not have to build such a large supercell However if you are looping over all sites in the crystal, this method is more efficient since it only performs one pass over a large enough supercell to contain all possible atoms out to a distance r. The return type is a [(site, dist) …] since most of the time, subsequent processing requires the distance.

Args:
  • r (float): Radius of sphere.
  • include_index (bool): Whether to include the non-supercell site
  • in the returned data
Returns:
  • A list of a list of nearest neighbors for each site, i.e.,

[[(site, dist, index, image) …], ..]. Index only supplied if include_index = True. The index is the index of the site in the original (non-supercell) structure. This is needed for ewaldmatrix by keeping track of which sites contribute to the ewald sum.

crystal_torture.pymatgen_interface.graph_from_file(filename, rcut, elements)

Takes a pymatgen compatible file, an converts it to a graph object

Args:

  • filename (str): name of file to set up graph from
  • rcut (float): cut-off radius node-node connections in forming clusters
  • elements ([str,str,…..]): list of elements to include in setting up graph
Returns:
  • graph (Graph): graph object for structure
crystal_torture.pymatgen_interface.graph_from_structure(structure, rcut, elements)

Takes a pymatgen compatible file, an converts it to a graph object

Args:

  • structure (Structure): pymatgen Structure object to set up graph from
  • rcut (float): cut-off radius node-node connections in forming clusters
  • elements ([str,str,…..]): list of elements to include in setting up graph
Returns:
  • graph (Graph): graph object for structure
crystal_torture.pymatgen_interface.map_index(uc_neighbours, uc_index, x_d, y_d, z_d)

Takes a list of neighbour indices for sites in the original unit cell, and maps them on to all of the supercell sites.

Args:

  • uc_neighbours(list(list(int))): list of lists containing neighbour indices for the nodes that are in the primitive cell
  • uc_index(list(int)): list of indices corresponding to the primitive cell nodes
  • x_d (int): x dimension of supercell
  • y_d (int): y dimension of supercell
  • z_d (int): z dimension of supercell

Returns:

  • neigh ([[int]…[int]]): list of neighbour indices for all nodes
crystal_torture.pymatgen_interface.nodes_from_structure(structure, rcut, get_halo=False)

Takes a pymatgen structure object and converts to Nodes for interogation.

Args:

  • structure (Structure): pymatgen Structure object
  • rcut (float): cut-off radius for crystal site neighbour set-up
  • halo (bool): whether to set up halo nodes (i.e. 3x3x3 supercell)
Returns:
  • nodes (set(Nodes)): set of Node objects representing structure sites
crystal_torture.pymatgen_interface.set_cluster_periodic(cluster)

Sets the periodicty of the cluster by counting through the number of labelled UC nodes it contains

Args:

  • None

Returns:

  • None

Sets:

  • cluster.periodic (int): periodicity of the cluster (1=1D,2=2D,3=3D)
crystal_torture.pymatgen_interface.set_fort_nodes(nodes)

Sets up a copy of the nodes and the neighbour indices in the tort.f90 Fortran module to allow access if using the Fortran tortuosity routines.

Args:
  • None
Returns:
  • None
Sets:
  • tort.tort_mod.nodes(:) : allocates space to hold node indices for full graph
  • tort.tort_mod.uc_tort(:) : allocates space to hold unit cell node tortuosity for full graph