text
stringlengths
81
112k
shorthand for matrix inverse on SquareTensor def inv(self): """ shorthand for matrix inverse on SquareTensor """ if self.det == 0: raise ValueError("SquareTensor is non-invertible") return SquareTensor(np.linalg.inv(self))
Test to see if tensor is a valid rotation matrix, performs a test to check whether the inverse is equal to the transpose and if the determinant is equal to one within the specified tolerance Args: tol (float): tolerance to both tests of whether the the determ...
Helper method for refining rotation matrix by ensuring that second and third rows are perpindicular to the first. Gets new y vector from an orthogonal projection of x onto y and the new z vector from a cross product of the new x and y Args: tol to test for rotation ...
Calculates the average oxidation state of a site Args: site: Site to compute average oxidation state Returns: Average oxidation state of site. def compute_average_oxidation_state(site): """ Calculates the average oxidation state of a site Args: site: Site to compute avera...
Gives total ewald energy for certain sites being removed, i.e. zeroed out. def compute_partial_energy(self, removed_indices): """ Gives total ewald energy for certain sites being removed, i.e. zeroed out. """ total_energy_matrix = self.total_energy_matrix.copy() ...
Gives total ewald energy for an sub structure in the same lattice. The sub_structure must be a subset of the original structure, with possible different charges. Args: substructure (Structure): Substructure to compute Ewald sum for. tol (float): Tolerance for site matchi...
The total energy. def total_energy(self): """ The total energy. """ return sum(sum(self._recip)) + sum(sum(self._real)) + sum(self._point) + self._charged_cell_energy
The total energy matrix. Each matrix element (i, j) corresponds to the total interaction energy between site i and site j. Note that this does not include the charged-cell energy, which is only important when the simulation cell is not charge balanced. def total_energy_matrix(self): ""...
Compute the energy for a single site in the structure Args: site_index (int): Index of site ReturnS: (float) - Energy of that site def get_site_energy(self, site_index): """Compute the energy for a single site in the structure Args: ...
Perform the reciprocal space summation. Calculates the quantity E_recip = 1/(2PiV) sum_{G < Gmax} exp(-(G.G/4/eta))/(G.G) S(G)S(-G) where S(G) = sum_{k=1,N} q_k exp(-i G.r_k) S(G)S(-G) = |S(G)|**2 This method is heavily vectorized to utilize numpy's C backend for speed. ...
Determines the self energy -(eta/pi)**(1/2) * sum_{i=1}^{N} q_i**2 def _calc_real_and_point(self): """ Determines the self energy -(eta/pi)**(1/2) * sum_{i=1}^{N} q_i**2 """ fcoords = self._s.frac_coords forcepf = 2.0 * self._sqrt_eta / sqrt(pi) coords = self._coords ...
This method finds and returns the permutations that produce the lowest ewald sum calls recursive function to iterate through permutations def minimize_matrix(self): """ This method finds and returns the permutations that produce the lowest ewald sum calls recursive function to iterate t...
This adds an m_list to the output_lists and updates the current minimum if the list is full. def add_m_list(self, matrix_sum, m_list): """ This adds an m_list to the output_lists and updates the current minimum if the list is full. """ if self._output_lists is None: ...
Computes a best case given a matrix and manipulation list. Args: matrix: the current matrix (with some permutations already performed) m_list: [(multiplication fraction, number_of_indices, indices, species)] describing the manipulation indices...
Returns an index that should have the most negative effect on the matrix sum def get_next_index(self, matrix, manipulation, indices_left): """ Returns an index that should have the most negative effect on the matrix sum """ f = manipulation[0] indices = list(indi...
This method recursively finds the minimal permutations using a binary tree search strategy. Args: matrix: The current matrix (with some permutations already performed). m_list: The list of permutations still to be performed indices: Set of indices whi...
Calculates the ensemble averaged Voronoi coordination numbers of a list of Structures using VoronoiNN. Typically used for analyzing the output of a Molecular Dynamics run. Args: structures (list): list of Structures. freq (int): sampling frequency of coordination number [every freq steps]. ...
Helper method to calculate the solid angle of a set of coords from the center. Args: center (3x1 array): Center to measure solid angle from. coords (Nx3 array): List of coords to determine solid angle. Returns: The solid angle. def solid_angle(center, coords): """ Helper m...
Provides max bond length estimates for a structure based on the JMol table and algorithms. Args: structure: (structure) el_radius_updates: (dict) symbol->float to update atomic radii Returns: (dict) - (Element1, Element2) -> float. The two elements are ordered by Z. def g...
This method returns whether a structure is 3D, 2D (layered), or 1D (linear chains or molecules) according to the algorithm published in Gorai, P., Toberer, E. & Stevanovic, V. Computational Identification of Promising Thermoelectric Materials Among Known Quasi-2D Binary Compounds. J. Mater. Chem. A 2, 4...
Determines if a structure contains peroxide anions. Args: structure (Structure): Input structure. relative_cutoff: The peroxide bond distance is 1.49 Angstrom. Relative_cutoff * 1.49 stipulates the maximum distance two O atoms must be to each other to be considered a peroxid...
Determines if an oxide is a peroxide/superoxide/ozonide/normal oxide Args: structure (Structure): Input structure. relative_cutoff (float): Relative_cutoff * act. cutoff stipulates the max distance two O atoms must be from each other. return_nbonds (bool): Should number of bonds...
Determines if a structure is a sulfide/polysulfide Args: structure (Structure): Input structure. Returns: (str) sulfide/polysulfide/sulfate def sulfide_type(structure): """ Determines if a structure is a sulfide/polysulfide Args: structure (Structure): Input structure. ...
Performs Voronoi analysis and returns the polyhedra around atom n in Schlaefli notation. Args: structure (Structure): structure to analyze n (int): index of the center atom in structure Returns: voronoi index of n: <c3,c4,c6,c6,c7,c8,c9,c10> ...
Perform Voronoi analysis on a list of Structures. Note that this might take a significant amount of time depending on the size and number of structures. Args: structures (list): list of Structures cutoff (float: cutoff distance around an atom to search for ...
Returns the percentage volume change. Returns: Volume change in percentage, e.g., 0.055 implies a 5.5% increase. def get_percentage_volume_change(self): """ Returns the percentage volume change. Returns: Volume change in percentage, e.g., 0.055 implies a 5.5% i...
Returns the percentage lattice parameter changes. Returns: A dict of the percentage change in lattice parameter, e.g., {'a': 0.012, 'b': 0.021, 'c': -0.031} implies a change of 1.2%, 2.1% and -3.1% in the a, b and c lattice parameters respectively. def get_percentage_lattic...
Returns the percentage bond distance changes for each site up to a maximum radius for nearest neighbors. Args: max_radius (float): Maximum radius to search for nearest neighbors. This radius is applied to the initial structure, not the final structure. ...
Provides connectivity array. Returns: connectivity: An array of shape [atomi, atomj, imagej]. atomi is the index of the atom in the input structure. Since the second atom can be outside of the unit cell, it must be described by both an atom index and an image ind...
Returns a list of site pairs that are Voronoi Neighbors, along with their real-space distances. def get_connections(self): """ Returns a list of site pairs that are Voronoi Neighbors, along with their real-space distances. """ con = [] maxconn = self.max_connecti...
Assuming there is some value in the connectivity array at indices (1, 3, 12). sitei can be obtained directly from the input structure (structure[1]). sitej can be obtained by passing 3, 12 to this function Args: site_index (int): index of the site (3 in the example) imag...
Determines if an oxide is a peroxide/superoxide/ozonide/normal oxide. Returns: oxide_type (str): Type of oxide ozonide/peroxide/superoxide/hydroxide/None. nbonds (int): Number of peroxide/superoxide/hydroxide bonds in structure. def parse_oxide(self): ""...
Identify non-H, non-C atoms in the MoleculeGraph, returning a list of their node indices. :param elements: List of elements to identify (if only certain functional groups are of interest). :return: set of ints representing node indices def get_heteroatoms(self, elements=None): ...
Identify Carbon atoms in the MoleculeGraph that fit the characteristics defined Ertl (2017), returning a list of their node indices. The conditions for marking carbon atoms are (quoted from Ertl): "- atoms connected by non-aromatic double or triple bond to any heteroatom ...
Take a list of marked "interesting" atoms (heteroatoms, special carbons) and attempt to connect them, returning a list of disjoint groups of special atoms (and their connected hydrogens). :param atoms: set of marked "interesting" atoms, presumably identified using other functions in...
Identify functional groups that cannot be identified by the Ertl method of get_special_carbon and get_heteroatoms, such as benzene rings, methyl groups, and ethyl groups. TODO: Think of other functional groups that are important enough to be added (ex: do we need ethyl, butyl, propyl?) ...
Identify all functional groups (or all within a certain subset) in the molecule, combining the methods described above. :param elements: List of elements that will qualify a carbon as special (if only certain functional groups are of interest). Default None. :param func_...
Determine classes of functional groups present in a set. :param groups: Set of functional groups. :return: dict containing representations of the groups, the indices of where the group occurs in the MoleculeGraph, and how many of each type of group there is. def categorize_func...
Wrapper for functions or properties that should raise an error if tensor is unphysical. def raise_error_if_unphysical(f): """ Wrapper for functions or properties that should raise an error if tensor is unphysical. """ def wrapper(self, *args, **kwargs): if self.k_vrh < 0 or self.g_vrh <...
nth order elastic constant fitting function based on central-difference derivatives with respect to distinct strain states. The algorithm is summarized as follows: 1. Identify distinct strain states as sets of indices for which nonzero strain values exist, typically [(0), (1), (2), (3), (4),...
Finds stress corresponding to zero strain state in stress-strain list Args: strains (Nx3x3 array-like): array corresponding to strains stresses (Nx3x3 array-like): array corresponding to stresses tol (float): tolerance to find zero strain state def find_eq_stress(strains, stresses, tol=1e-...
Creates a dictionary of voigt-notation stress-strain sets keyed by "strain state", i. e. a tuple corresponding to the non-zero entries in ratios to the lowest nonzero value, e.g. [0, 0.1, 0, 0.2, 0, 0] -> (0,1,0,2,0,0) This allows strains to be collected in stencils as to evaluate parameterized fini...
Generates the pseudoinverse for a given set of strains. Args: strain_states (6xN array like): a list of voigt-notation "strain-states", i. e. perturbed indices of the strain as a function of the smallest strain e. g. (0, 1, 0, 0, 1, 0) order (int): order of pseudoinverse to ...
Returns a symbolic representation of the voigt-notation tensor that places identical symbols for entries related by index transposition, i. e. C_1121 = C_1211 etc. Args: dim (int): dimension of matrix/tensor, e. g. 6 for voigt notation and 3 for standard rank (int): rank of tens...
Helper function to find difference coefficients of an derivative on an arbitrary mesh. Args: hvec (1D array-like): sampling stencil n (int): degree of derivative to find def get_diff_coeff(hvec, n=1): """ Helper function to find difference coefficients of an derivative on an arbitr...
Calculate's a given elastic tensor's contribution to the stress using Einstein summation Args: strain (3x3 array-like): matrix corresponding to strain def calculate_stress(self, strain): """ Calculate's a given elastic tensor's contribution to the stress using Einst...
Calculates the elastic energy density due to a strain def energy_density(self, strain, convert_GPa_to_eV=True): """ Calculates the elastic energy density due to a strain """ e_density = np.sum(self.calculate_stress(strain)*strain) / self.order if convert_GPa_to_eV: e...
returns the Voigt-notation compliance tensor, which is the matrix inverse of the Voigt-notation elastic tensor def compliance_tensor(self): """ returns the Voigt-notation compliance tensor, which is the matrix inverse of the Voigt-notation elastic tensor """ ...
returns the G_v shear modulus def g_voigt(self): """ returns the G_v shear modulus """ return (2. * self.voigt[:3, :3].trace() - np.triu(self.voigt[:3, :3]).sum() + 3 * self.voigt[3:, 3:].trace()) / 15.
returns the G_r shear modulus def g_reuss(self): """ returns the G_r shear modulus """ return 15. / (8. * self.compliance_tensor.voigt[:3, :3].trace() - 4. * np.triu(self.compliance_tensor.voigt[:3, :3]).sum() + 3. * self.compliance_tensor.voi...
Calculates Young's modulus (in SI units) using the Voigt-Reuss-Hill averages of bulk and shear moduli def y_mod(self): """ Calculates Young's modulus (in SI units) using the Voigt-Reuss-Hill averages of bulk and shear moduli """ return 9.e9 * self.k_vrh * self.g_vrh / (3...
Calculates the poisson ratio for a specific direction relative to a second, orthogonal direction Args: n (3-d vector): principal direction m (3-d vector): secondary direction orthogonal to n tol (float): tolerance for testing of orthogonality def directional_poisson...
Calculates transverse sound velocity (in SI units) using the Voigt-Reuss-Hill average bulk modulus Args: structure: pymatgen structure object Returns: transverse sound velocity (in SI units) def trans_v(self, structure): """ Calculates transverse sound velocity (in...
Calculates Snyder's acoustic sound velocity (in SI units) Args: structure: pymatgen structure object Returns: Snyder's acoustic sound velocity (in SI units) def snyder_ac(self, structure): """ Calculates Snyder's acoustic sound velocity (in SI units) Args: ...
Calculates Snyder's optical sound velocity (in SI units) Args: structure: pymatgen structure object Returns: Snyder's optical sound velocity (in SI units) def snyder_opt(self, structure): """ Calculates Snyder's optical sound velocity (in SI units) Args: ...
Calculates Clarke's thermal conductivity (in SI units) Args: structure: pymatgen structure object Returns: Clarke's thermal conductivity (in SI units) def clarke_thermalcond(self, structure): """ Calculates Clarke's thermal conductivity (in SI units) Args: ...
Estimates the debye temperature from longitudinal and transverse sound velocities Args: structure: pymatgen structure object Returns: debye temperature (in SI units) def debye_temperature(self, structure): """ Estimates the debye temperature from longitudinal and ...
returns the universal anisotropy value def universal_anisotropy(self): """ returns the universal anisotropy value """ return 5. * self.g_voigt / self.g_reuss + \ self.k_voigt / self.k_reuss - 6.
returns the homogeneous poisson ratio def homogeneous_poisson(self): """ returns the homogeneous poisson ratio """ return (1. - 2. / 3. * self.g_vrh / self.k_vrh) / \ (2. + 2. / 3. * self.g_vrh / self.k_vrh)
returns a dictionary of properties derived from the elastic tensor and an associated structure Args: structure (Structure): structure object for which to calculate associated properties include_base_props (bool): whether to include base properties, ...
Class method to fit an elastic tensor from stress/strain data. Method uses Moore-Penrose pseudoinverse to invert the s = C*e equation with elastic tensor, stress, and strain in voigt notation Args: stresses (Nx3x3 array-like): list or array of stresses strains (...
Constructs the elastic tensor least-squares fit of independent strains Args: strains (list of Strains): list of strain objects to fit stresses (list of Stresses): list of stress objects to use in fit corresponding to the list of strains eq_stress (Stress): equ...
Generates an elastic tensor expansion via the fitting function defined below in diff_fit def from_diff_fit(cls, strains, stresses, eq_stress=None, tol=1e-10, order=3): """ Generates an elastic tensor expansion via the fitting function defined below in diff_fit ...
Calculates the elastic energy density due to a strain def energy_density(self, strain, convert_GPa_to_eV=True): """ Calculates the elastic energy density due to a strain """ return sum([c.energy_density(strain, convert_GPa_to_eV) for c in self])
Gets the Generalized Gruneisen tensor for a given third-order elastic tensor expansion. Args: n (3x1 array-like): normal mode direction u (3x1 array-like): polarization direction def get_ggt(self, n, u): """ Gets the Generalized Gruneisen tensor for a given ...
Gets the thermodynamic Gruneisen tensor (TGT) by via an integration of the GGT weighted by the directional heat capacity. See refs: R. N. Thurston and K. Brugger, Phys. Rev. 113, A1604 (1964). K. Brugger Phys. Rev. 137, A1826 (1965). Args: temperatur...
Gets the single average gruneisen parameter from the TGT. Args: temperature (float): Temperature in kelvin, if not specified will return non-cv-normalized value structure (float): Structure to be used in directional heat capacity determination, only neces...
Gets the directional heat capacity for a higher order tensor expansion as a function of direction and polarization. Args: temperature (float): Temperature in kelvin structure (float): Structure to be used in directional heat capacity determination n (...
Finds directional frequency contribution to the heat capacity from direction and polarization Args: structure (Structure): Structure to be used in directional heat capacity determination n (3x1 array-like): direction for Cv determination u (3x1 array-...
Gets thermal expansion coefficient from third-order constants. Args: temperature (float): Temperature in kelvin, if not specified will return non-cv-normalized value structure (Structure): Structure to be used in directional heat capacity determination, o...
Gets a compliance tensor expansion from the elastic tensor expansion. def get_compliance_expansion(self): """ Gets a compliance tensor expansion from the elastic tensor expansion. """ # TODO: this might have a general form if not self.order <= 4: rais...
Gets the strain from a stress state according to the compliance expansion corresponding to the tensor expansion. def get_strain_from_stress(self, stress): """ Gets the strain from a stress state according to the compliance expansion corresponding to the tensor expansion....
Returns the effective elastic constants from the elastic tensor expansion. Args: strain (Strain or 3x3 array-like): strain condition under which to calculate the effective constants order (int): order of the ecs to be returned def get_effective_ecs(self, strain,...
Gets the Wallace Tensor for determining yield strength criteria. Args: tau (3x3 array-like): stress at which to evaluate the wallace tensor def get_wallace_tensor(self, tau): """ Gets the Wallace Tensor for determining yield strength criteria. ...
Gets the symmetrized wallace tensor for determining yield strength criteria. Args: tau (3x3 array-like): stress at which to evaluate the wallace tensor. def get_symmetric_wallace_tensor(self, tau): """ Gets the symmetrized wallace tensor for determining ...
Gets the stability criteria from the symmetric Wallace tensor from an input vector and stress value. Args: s (float): Stress value at which to evaluate the stability criteria n (3x1 array-like): direction of the applied stress def get_sta...
Gets the yield stress for a given direction Args: n (3x1 array-like): direction for which to find the yield stress def get_yield_stress(self, n): """ Gets the yield stress for a given direction Args: n (3x1 array-like): direction for which to fi...
Computes the continuous symmetry measure of the (distorted) set of points "points_distorted" with respect to the (perfect) set of points "points_perfect". :param points_distorted: List of points describing a given (distorted) polyhedron for which the symmetry measure has to be compu...
This finds the rotation matrix that aligns the (distorted) set of points "points_distorted" with respect to the (perfect) set of points "points_perfect" in a least-square sense. :param points_distorted: List of points describing a given (distorted) polyhedron for which the rotation that ...
This finds the scaling factor between the (distorted) set of points "points_distorted" and the (perfect) set of points "points_perfect" in a least-square sense. :param points_distorted: List of points describing a given (distorted) polyhedron for which the scaling factor has to be o...
Setup of the parameters for the coordination geometry finder. A reference point for the geometries has to be chosen. This can be the centroid of the structure (including or excluding the atom for which the coordination geometry is looked for) or the atom itself. In the 'standard' centering_type, the ref...
Sets up the structure for which the coordination geometries have to be identified. The structure is analyzed with the space group analyzer and a refined structure is used :param structure: A pymatgen Structure :param def setup_structure(self, structure): """ Sets up the structur...
Sets up the pymatgen structure for which the coordination geometries have to be identified starting from the lattice, the species and the coordinates :param lattice: The lattice of the structure :param species: The species on the sites :param coords: The coordinates of the sites ...
Computes and returns the StructureEnvironments object containing all the information about the coordination environments in the structure :param excluded_atoms: Atoms for which the coordination geometries does not have to be identified :param only_atoms: If not set to None, atoms for which the c...
Sets up the AbstractGeometry for the local geometry of site with index isite. :param isite: Index of the site for which the local geometry has to be set up :param coords: The coordinates of the (local) neighbors def setup_local_geometry(self, isite, coords, optimization=None): """ Sets ...
Sets up a purely random structure with a given coordination. :param coordination: coordination number for the random structure def setup_random_structure(self, coordination): """ Sets up a purely random structure with a given coordination. :param coordination: coordination number for th...
Sets up random indices for the local geometry, for testing purposes :param coordination: coordination of the local geometry def setup_random_indices_local_geometry(self, coordination): """ Sets up random indices for the local geometry, for testing purposes :param coordination: coordinat...
Sets up ordered indices for the local geometry, for testing purposes :param coordination: coordination of the local geometry def setup_ordered_indices_local_geometry(self, coordination): """ Sets up ordered indices for the local geometry, for testing purposes :param coordination: coordi...
Sets up explicit indices for the local geometry, for testing purposes :param explicit_indices: explicit indices for the neighbors (set of numbers from 0 to CN-1 in a given order) def setup_explicit_indices_local_geometry(self, explicit_indices): """ Sets up explicit indices for the loca...
Returns the continuous symmetry measures of the current local geometry in a dictionary. :return: the continuous symmetry measures of the current local geometry in a dictionary. def get_coordination_symmetry_measures(self, only_minimum=True, all_csms=True, optimization...
Returns the continuous symmetry measures of the current local geometry in a dictionary. :return: the continuous symmetry measures of the current local geometry in a dictionary. def get_coordination_symmetry_measures_optim(self, only_minimum=True, all_csms=True, ...
Returns the symmetry measures of a given coordination_geometry for a set of permutations depending on the permutation setup. Depending on the parameters of the LocalGeometryFinder and on the coordination geometry, different methods are called. :param coordination_geometry: Coordination geometry...
Returns the symmetry measures of a given coordination_geometry for a set of permutations depending on the permutation setup. Depending on the parameters of the LocalGeometryFinder and on the coordination geometry, different methods are called. :param coordination_geometry: Coordination geometry...
Returns the symmetry measures for a set of permutations (whose setup depends on the coordination geometry) for the coordination geometry "coordination_geometry". Standard implementation looking for the symmetry measures of each permutation :param coordination_geometry: The coordination geometry...
Returns the symmetry measures of the given coordination geometry "coordination_geometry" using separation facets to reduce the complexity of the system. Caller to the refined 2POINTS, 3POINTS and other ... :param coordination_geometry: The coordination geometry to be investigated :return: The sy...
Returns the symmetry measures of the given coordination geometry "coordination_geometry" using separation facets to reduce the complexity of the system. Caller to the refined 2POINTS, 3POINTS and other ... :param coordination_geometry: The coordination geometry to be investigated :return: The sy...
Returns the symmetry measures for a random set of permutations for the coordination geometry "coordination_geometry". Fallback implementation for the plane separation algorithms measures of each permutation :param coordination_geometry: The coordination geometry to be investigated :para...
Plot the Fermi surface at specific energy value. Args: data: energy values in a 3D grid from a CUBE file via read_cube_file function, or from a BoltztrapAnalyzer.fermi_surface_data structure: structure object of the material energy_levels: list of energy value ...
Adds the skeleton of the Wigner-Seitz cell of the lattice to a matplotlib Axes Args: lattice: Lattice object ax: matplotlib :class:`Axes` or None if a new figure should be created. kwargs: kwargs passed to the matplotlib function 'plot'. Color defaults to black and linewidth to ...
Adds the basis vectors of the lattice provided to a matplotlib Axes Args: lattice: Lattice object ax: matplotlib :class:`Axes` or None if a new figure should be created. kwargs: kwargs passed to the matplotlib function 'plot'. Color defaults to green and linewidth to 3. Ret...