text
stringlengths
81
112k
Variant of pretty_plot that does a dual axis plot. Adapted from matplotlib examples. Makes it easier to create plots with different axes. Args: x (np.ndarray/list): Data for x-axis. y1 (dict/np.ndarray/list): Data for y1 axis (left). If a dict, it will be interpreted as a {label: se...
Convenience method to plot data with trend lines based on polynomial fit. Args: x: Sequence of x data. y: Sequence of y data. deg (int): Degree of polynomial. Defaults to 1. xlabel (str): Label for x-axis. ylabel (str): Label for y-axis. \\*\\*kwargs: Keyword args pa...
A static method that generates a heat map overlapped on a periodic table. Args: elemental_data (dict): A dictionary with the element as a key and a value assigned to it, e.g. surface energy and frequency, etc. Elements missing in the elemental_data will be grey by default ...
Converts str of chemical formula into latex format for labelling purposes Args: formula (str): Chemical formula def format_formula(formula): """ Converts str of chemical formula into latex format for labelling purposes Args: formula (str): Chemical formula """ formatt...
A static method that generates a binary van Arkel-Ketelaar triangle to quantify the ionic, metallic and covalent character of a compound by plotting the electronegativity difference (y) vs average (x). See: A.E. van Arkel, Molecules and Crystals in Inorganic Chemistry, ...
Helper function used in plot functions supporting an optional Axes argument. If ax is None, we build the `matplotlib` figure and create the Axes else we return the current active figure. Args: kwargs: keyword arguments are passed to plt.figure if ax is not None. Returns: ax: :class:`Ax...
Helper function used in plot functions supporting an optional Axes3D argument. If ax is None, we build the `matplotlib` figure and create the Axes3D else we return the current active figure. Args: kwargs: keyword arguments are passed to plt.figure if ax is not None. Returns: ax: :class...
Helper function used in plot functions that accept an optional array of Axes as argument. If ax_array is None, we build the `matplotlib` figure and create the array of Axes by calling plt.subplots else we return the current active figure. Returns: ax: Array of :class:`Axes` objects figu...
Decorator that adds keyword arguments for functions returning matplotlib figures. The function should return either a matplotlib figure or None to signal some sort of error/unexpected event. See doc string below for the list of supported options. def add_fig_kwargs(func): """ Decorator that ad...
Method to sum two densities. Args: density1: First density. density2: Second density. Returns: Dict of {spin: density}. def add_densities(density1, density2): """ Method to sum two densities. Args: density1: First density. density2: Second density. Re...
Returns the equilibrium fermi-dirac. Args: E (float): energy in eV fermi (float): the fermi level in eV T (float): the temperature in kelvin def f0(E, fermi, T): """ Returns the equilibrium fermi-dirac. Args: E (float): energy in eV fermi (float): the fermi level...
Args: orb: string representation of orbital Returns: OrbitalType def _get_orb_type_lobster(orb): """ Args: orb: string representation of orbital Returns: OrbitalType """ orb_labs = ["s", "p_y", "p_z", "p_x", "d_xy", "d_yz", "d_z^2", "d_xz", "d_x^2-y^2", "f_y(...
Args: orb: string representation of orbital Returns: Orbital def _get_orb_lobster(orb): """ Args: orb: string representation of orbital Returns: Orbital """ orb_labs = ["s", "p_y", "p_z", "p_x", "d_xy", "d_yz", "d_z^2", "d_xz", "d_x^2-y^2", "f_y...
Expects a DOS object and finds the gap Args: tol: tolerance in occupations for determining the gap abs_tol: Set to True for an absolute tolerance and False for a relative one. spin: Possible values are None - finds the gap in the summed densit...
Expects a DOS object and finds the cbm and vbm. Args: tol: tolerance in occupations for determining the gap abs_tol: An absolute tolerance (True) and a relative one (False) spin: Possible values are None - finds the gap in the summed densities, Up - finds the...
Expects a DOS object and finds the gap. Args: tol: tolerance in occupations for determining the gap abs_tol: An absolute tolerance (True) and a relative one (False) spin: Possible values are None - finds the gap in the summed densities, Up - finds the gap in ...
Returns the density of states for a particular spin. Args: spin: Spin Returns: Returns the density of states for a particular spin. If Spin is None, the sum of all spins is returned. def get_densities(self, spin=None): """ Returns the density of sta...
Returns the Dict representation of the densities, {Spin: densities}, but with a Gaussian smearing of std dev sigma applied about the fermi level. Args: sigma: Std dev of Gaussian smearing function. Returns: Dict of Gaussian-smeared densities. def get_smeared_de...
Returns interpolated density for a particular energy. Args: energy: Energy to return the density for. def get_interpolated_value(self, energy): """ Returns interpolated density for a particular energy. Args: energy: Energy to return the density for. """...
Expects a DOS object and finds the cbm and vbm. Args: tol: tolerance in occupations for determining the gap abs_tol: An absolute tolerance (True) and a relative one (False) spin: Possible values are None - finds the gap in the summed densities, Up - finds the...
Returns Dos object from dict representation of Dos. def from_dict(cls, d): """ Returns Dos object from dict representation of Dos. """ return Dos(d["efermi"], d["energies"], {Spin(int(k)): v for k, v in d["densities"].items()})
Json-serializable dict representation of Dos. def as_dict(self): """ Json-serializable dict representation of Dos. """ return {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "efermi": self.efermi, "energies": list(self.energies),...
Calculate the doping (majority carrier concentration) at a given fermi level and temperature. A simple Left Riemann sum is used for integrating the density of states over energy & equilibrium Fermi-Dirac distribution Args: fermi (float): the fermi level in eV T (float): ...
Similar to get_fermi except that when get_fermi fails to converge, an interpolated or extrapolated fermi (depending on c) is returned with the assumption that the fermi level changes linearly with log(abs(c)). Args: c (float): doping concentration in 1/cm3. c<0 represents n-type ...
Finds the fermi level at which the doping concentration at the given temperature (T) is equal to c. A greedy algorithm is used where the relative error is minimized by calculating the doping at a grid which is continuously become finer. Args: c (float): doping concentration....
Get the Dos for a particular orbital of a particular site. Args: site: Site in Structure associated with CompleteDos. orbital: Orbital in the site. Returns: Dos containing densities for orbital of site. def get_site_orbital_dos(self, site, orbital): """ ...
Get the total Dos for a site (all orbitals). Args: site: Site in Structure associated with CompleteDos. Returns: Dos containing summed orbital densities for site. def get_site_dos(self, site): """ Get the total Dos for a site (all orbitals). Args: ...
Get orbital projected Dos of a particular site Args: site: Site in Structure associated with CompleteDos. Returns: dict of {orbital: Dos}, e.g. {"s": Dos object, ...} def get_site_spd_dos(self, site): """ Get orbital projected Dos of a particular site ...
Get the t2g, eg projected DOS for a particular site. Args: site: Site in Structure associated with CompleteDos. Returns: A dict {"e_g": Dos, "t2g": Dos} containing summed e_g and t2g DOS for the site. def get_site_t2g_eg_resolved_dos(self, site): """ ...
Get orbital projected Dos. Returns: dict of {orbital: Dos}, e.g. {"s": Dos object, ...} def get_spd_dos(self): """ Get orbital projected Dos. Returns: dict of {orbital: Dos}, e.g. {"s": Dos object, ...} """ spd_dos = {} for atom_dos in s...
Get element projected Dos. Returns: dict of {Element: Dos} def get_element_dos(self): """ Get element projected Dos. Returns: dict of {Element: Dos} """ el_dos = {} for site, atom_dos in self.pdos.items(): el = site.specie ...
Calculates spin polarization at Fermi level. See Sanvito et al., doi: 10.1126/sciadv.1602241 for an example usage. :return (float): spin polarization in range [0, 1], will also return NaN if spin polarization ill-defined (e.g. for insulator) def spin_polarization(self): ...
Json-serializable dict representation of CompleteDos. def as_dict(self): """ Json-serializable dict representation of CompleteDos. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "efermi": self.efermi, "structure": self.structu...
Get element and spd projected Dos Args: el: Element in Structure.composition associated with LobsterCompleteDos Returns: dict of {Element: {"S": densities, "P": densities, "D": densities}} def get_element_spd_dos(self, el): """ Get element and spd projected Do...
Returns: CompleteDos object from dict representation. def from_dict(cls, d): """ Returns: CompleteDos object from dict representation. """ tdos = Dos.from_dict(d) struct = Structure.from_dict(d["structure"]) pdoss = {} for i in range(len(d["pdos"])): ...
Get prototype(s) structures for a given input structure. If you use this method in your work, please cite the appropriate AFLOW publication: Mehl, M. J., Hicks, D., Toher, C., Levy, O., Hanson, R. M., Hart, G., & Curtarolo, S. (2017). The AFLOW library of crystallographi...
General pattern reading on an input string Args: text_str (str): the input string to search for patterns patterns (dict): A dict of patterns, e.g., {"energy": r"energy\\(sigma->0\\)\\s+=\\s+([\\d\\-.]+)"}. terminate_on_match (bool): Whether to terminate when ...
Parse table-like data. A table composes of three parts: header, main body, footer. All the data matches "row pattern" in the main body will be returned. Args: text_str (str): the input string to search for patterns header_pattern (str): The regular expression pattern matches the ...
Takes a dictionary and makes all the keys lower case. Also replaces "jobtype" with "job_type" just so that key specifically can be called elsewhere without ambiguity. Finally, ensures that multiple identical keys, that differed only due to different capitalizations, are not present. If there are multipl...
Takes a set of parsed coordinates, which come as an array of strings, and returns a numpy array of floats. def process_parsed_coords(coords): """ Takes a set of parsed coordinates, which come as an array of strings, and returns a numpy array of floats. """ geometry = np.zeros(shape=(len(coords)...
Generates the transformation matricies that convert a set of 2D vectors into a super lattice of integer area multiple as proven in Cassels: Cassels, John William Scott. An introduction to the geometry of numbers. Springer Science & Business Media, 2012. Args: area_multiple(int): integer mu...
Calculate angle between two vectors def vec_angle(a, b): """ Calculate angle between two vectors """ cosang = np.dot(a, b) sinang = fast_norm(np.cross(a, b)) return np.arctan2(sinang, cosang)
Generate independent and unique basis vectors based on the methodology of Zur and McGill def reduce_vectors(a, b): """ Generate independent and unique basis vectors based on the methodology of Zur and McGill """ if np.dot(a, b) < 0: return reduce_vectors(a, -b) if fast_norm(a) > fa...
Determine if two sets of vectors are the same within length and angle tolerances Args: vec_set1(array[array]): an array of two vectors vec_set2(array[array]): second array of two vectors def is_same_vectors(self, vec_set1, vec_set2): """ Determine if two sets of...
Generates transformation sets for film/substrate pair given the area of the unit cell area for the film and substrate. The transformation sets map the film and substrate unit cells to super lattices with a maximum area Args: film_area(int): the unit cell area for the film ...
Applies the transformation_sets to the film and substrate vectors to generate super-lattices and checks if they matches. Returns all matching vectors sets. Args: transformation_sets(array): an array of transformation sets: each transformation set is an array with the...
Returns dict which contains ZSL match Args: film_miller(array) substrate_miller(array) def match_as_dict(self, film_sl_vectors, substrate_sl_vectors, film_vectors, substrate_vectors, match_area): """ Returns dict which contains ZSL match Args: film_...
Generates the film/substrate slab combinations for a set of given miller indicies Args: film_millers(array): all miller indices to generate slabs for film substrate_millers(array): all miller indicies to generate slabs for substrate def generate_...
Finds all topological matches for the substrate and calculates elastic strain energy and total energy for the film if elasticity tensor and ground state energy are provided: Args: film(Structure): conventional standard structure for the film substrate(Structure): convent...
Calculates the multi-plane elastic energy. Returns 999 if no elastic tensor was given on init Args: film(Structure): conventional standard structure for the film match(dictionary) : match dictionary from substrate analyzer elasticity_tensor(ElasticTensor): elasticity...
Convert a single frame XYZ string to a molecule def _from_frame_string(contents): """ Convert a single frame XYZ string to a molecule """ lines = contents.split("\n") num_sites = int(lines[0]) coords = [] sp = [] coord_patt = re.compile( r"(\w...
Creates XYZ object from a string. Args: contents: String representing an XYZ file. Returns: XYZ object def from_string(contents): """ Creates XYZ object from a string. Args: contents: String representing an XYZ file. Returns: ...
Returns a chemical shielding tensor aligned to the principle axis system so that only the 3 diagnol components are non-zero def principal_axis_system(self): """ Returns a chemical shielding tensor aligned to the principle axis system so that only the 3 diagnol components are non-zero ...
Returns: the Chemical shielding tensor in Haeberlen Notation def haeberlen_values(self): """ Returns: the Chemical shielding tensor in Haeberlen Notation """ pas=self.principal_axis_system sigma_iso=pas.trace() / 3 sigmas=np.diag(pas) sigmas=sorted(sigmas, key=la...
Returns: the Chemical shielding tensor in Mehring Notation def mehring_values(self): """ Returns: the Chemical shielding tensor in Mehring Notation """ pas=self.principal_axis_system sigma_iso=pas.trace() / 3 sigma_11, sigma_22, sigma_33=np.diag(pas) return self....
Returns: the Chemical shielding tensor in Maryland Notation def maryland_values(self): """ Returns: the Chemical shielding tensor in Maryland Notation """ pas=self.principal_axis_system sigma_iso=pas.trace() / 3 omega=np.diag(pas)[2] - np.diag(pas)[0] # There is ...
Returns a electric field gradient tensor aligned to the principle axis system so that only the 3 diagnol components are non-zero def principal_axis_system(self): """ Returns a electric field gradient tensor aligned to the principle axis system so that only the 3 diagnol components are non-zero ...
Asymmetry of the electric field tensor defined as: (V_yy - V_xx)/V_zz def asymmetry(self): """ Asymmetry of the electric field tensor defined as: (V_yy - V_xx)/V_zz """ diags=np.diag(self.principal_axis_system) V=sorted(diags, key=np.abs) return n...
Computes the couplling constant C_q as defined in: Wasylishen R E, Ashbrook S E, Wimperis S. NMR of quadrupolar nuclei in solid materials[M]. John Wiley & Sons, 2012. (Chapter 3.2) C_q for a specific atom type for this electric field tensor: C_q=e*Q*V_zz/h h:...
Obtain an analysis of a given structure and if it may be Jahn-Teller active or not. This is a heuristic, and may give false positives and false negatives (false positives are preferred). :param structure: input structure :param calculate_valences (bool): whether to attempt to calculate ...
Get magnitude of Jahn-Teller effect from provided species, spin state and motife. :param species: e.g. Fe2+ :param spin_state (str): "high" or "low" :param motif (str): "oct" or "tet" :return (str): def get_magnitude_of_effect_from_species(self, species, spin_state, motif): ""...
Roughly, the magnitude of Jahn-Teller distortion will be: * in octahedral environments, strong if e_g orbitals unevenly occupied but weak if t_2g orbitals unevenly occupied * in tetrahedral environments always weaker :param motif (str): "oct" or "tet" :param spin_config (...
Simple heuristic to estimate spin state. If magnetic moment is sufficiently close to that predicted for a given spin state, we assign it that state. If we only have data for one spin state then that's the one we use (e.g. we assume all tetrahedral complexes are high-spin, since this is t...
Calculates the spin-only magnetic moment for a given species. Only supports transition metals. :param species: str or Species :param motif: "oct" or "tet" :param spin_state: "high" or "low" :return: spin-only magnetic moment in Bohr magnetons def mu_so(species, motif, spin_stat...
Conversion factor to convert between cm^2/s diffusivity measurements and mS/cm conductivity measurements based on number of atoms of diffusing species. Note that the charge is based on the oxidation state of the species (where available), or else the number of valence electrons (usually a good guess, es...
Internal method to support multiprocessing. def _get_vasprun(args): """ Internal method to support multiprocessing. """ return Vasprun(args[0], ionic_step_skip=args[1], parse_dos=False, parse_eigen=False)
Returns Ea, c, standard error of Ea from the Arrhenius fit: D = c * exp(-Ea/kT) Args: temps ([float]): A sequence of temperatures. units: K diffusivities ([float]): A sequence of diffusivities (e.g., from DiffusionAnalyzer.diffusivity). units: cm^2/s def fit_arrhenius(temps, di...
Returns (Arrhenius) extrapolated diffusivity at new_temp Args: temps ([float]): A sequence of temperatures. units: K diffusivities ([float]): A sequence of diffusivities (e.g., from DiffusionAnalyzer.diffusivity). units: cm^2/s new_temp (float): desired temperature. units: K ...
Returns extrapolated mS/cm conductivity. Args: temps ([float]): A sequence of temperatures. units: K diffusivities ([float]): A sequence of diffusivities (e.g., from DiffusionAnalyzer.diffusivity). units: cm^2/s new_temp (float): desired temperature. units: K structure (...
Returns an Arrhenius plot. Args: temps ([float]): A sequence of temperatures. diffusivities ([float]): A sequence of diffusivities (e.g., from DiffusionAnalyzer.diffusivity). diffusivity_errors ([float]): A sequence of errors for the diffusivities. If None, no error ...
Returns an iterator for the drift-corrected structures. Use of iterator is to reduce memory usage as # of structures in MD can be huge. You don't often need all the structures all at once. Args: start, stop, step (int): applies a start/stop/step to the iterator. Fast...
Provides a summary of diffusion information. Args: include_msd_t (bool): Whether to include mean square displace and time data with the data. include_msd_t (bool): Whether to include mean square charge displace and time data with the data. Return...
Get the plot of rms framework displacement vs time. Useful for checking for melting, especially if framework atoms can move via paddle-wheel or similar mechanism (which would show up in max framework displacement but doesn't constitute melting). Args: plt (matplotlib.pyplot)...
Get the plot of the smoothed msd vs time graph. Useful for checking convergence. This can be written to an image file. Args: plt: A plot object. Defaults to None, which means one will be generated. mode (str): Determines type of msd plot. By "species", "sites", ...
Writes MSD data to a csv file that can be easily plotted in other software. Args: filename (str): Filename. Supported formats are csv and dat. If the extension is csv, a csv file is written. Otherwise, a dat format is assumed. def export_msdt(self, filename)...
Convenient constructor that takes in a list of Structure objects to perform diffusion analysis. Args: structures ([Structure]): list of Structure objects (must be ordered in sequence of run). E.g., you may have performed sequential VASP runs to obtain suffici...
Convenient constructor that takes in a list of Vasprun objects to perform diffusion analysis. Args: vaspruns ([Vasprun]): List of Vaspruns (must be ordered in sequence of MD simulation). E.g., you may have performed sequential VASP runs to obtain sufficient ...
Convenient constructor that takes in a list of vasprun.xml paths to perform diffusion analysis. Args: filepaths ([str]): List of paths to vasprun.xml files of runs. ( must be ordered in sequence of MD simulation). For example, you may have done sequential VAS...
Applies the strategy to the structure_environments object in order to define the coordination environment of a given site. :param site: Site for which the coordination environment is looked for :return: The coordination environment of the site. For complex strategies, where one allows multiple ...
Applies the strategy to the structure_environments object in order to get coordination environments, their fraction, csm, geometry_info, and neighbors :param site: Site for which the above information is seeked :return: The list of neighbors of the site. For complex strategies, where one allows ...
Bson-serializable dict representation of the SimplestChemenvStrategy object. :return: Bson-serializable dict representation of the SimplestChemenvStrategy object. def as_dict(self): """ Bson-serializable dict representation of the SimplestChemenvStrategy object. :return: Bson-serializab...
Reconstructs the SimplestChemenvStrategy object from a dict representation of the SimplestChemenvStrategy object created using the as_dict method. :param d: dict representation of the SimplestChemenvStrategy object :return: StructureEnvironments object def from_dict(cls, d): """ ...
Bson-serializable dict representation of the SimpleAbundanceChemenvStrategy object. :return: Bson-serializable dict representation of the SimpleAbundanceChemenvStrategy object. def as_dict(self): """ Bson-serializable dict representation of the SimpleAbundanceChemenvStrategy object. :re...
Bson-serializable dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object. :return: Bson-serializable dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object. def as_dict(self): """ Bson-serializable dict representation of the TargettedPenaltiedAbundanc...
Reconstructs the TargettedPenaltiedAbundanceChemenvStrategy object from a dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object created using the as_dict method. :param d: dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object :return: TargettedPenalt...
Bson-serializable dict representation of the WeightedNbSetChemenvStrategy object. :return: Bson-serializable dict representation of the WeightedNbSetChemenvStrategy object. def as_dict(self): """ Bson-serializable dict representation of the WeightedNbSetChemenvStrategy object. :return: ...
Reconstructs the WeightedNbSetChemenvStrategy object from a dict representation of the WeightedNbSetChemenvStrategy object created using the as_dict method. :param d: dict representation of the WeightedNbSetChemenvStrategy object :return: WeightedNbSetChemenvStrategy object def from_dict(cls, d...
Bson-serializable dict representation of the MultiWeightsChemenvStrategy object. :return: Bson-serializable dict representation of the MultiWeightsChemenvStrategy object. def as_dict(self): """ Bson-serializable dict representation of the MultiWeightsChemenvStrategy object. :return: Bso...
Reconstructs the MultiWeightsChemenvStrategy object from a dict representation of the MultipleAbundanceChemenvStrategy object created using the as_dict method. :param d: dict representation of the MultiWeightsChemenvStrategy object :return: MultiWeightsChemenvStrategy object def from_dict(cls, ...
Returns the theoretical Pauling stability ratio (rC/rA) for this environment. def pauling_stability_ratio(self): """ Returns the theoretical Pauling stability ratio (rC/rA) for this environment. """ if self._pauling_stability_ratio is None: if self.ce_symbol in ['S:1', 'L:2'...
Returns the number of permutations of this coordination geometry. def number_of_permutations(self): """ Returns the number of permutations of this coordination geometry. """ if self.permutations_safe_override: return factorial(self.coordination) elif self.permutation...
Returns the list of faces of this coordination geometry. Each face is given as a list of its vertices coordinates. def faces(self, sites, permutation=None): """ Returns the list of faces of this coordination geometry. Each face is given as a list of its vertices coordinates. """...
Returns the list of edges of this coordination geometry. Each edge is given as a list of its end vertices coordinates. def edges(self, sites, permutation=None, input='sites'): """ Returns the list of edges of this coordination geometry. Each edge is given as a list of its end vertices c...
Returns the list of "perfect" solid angles Each edge is given as a list of its end vertices coordinates. def solid_angles(self, permutation=None): """ Returns the list of "perfect" solid angles Each edge is given as a list of its end vertices coordinates. """ if permutat...
Returns the pmesh strings used for jmol to show this geometry. def get_pmeshes(self, sites, permutation=None): """ Returns the pmesh strings used for jmol to show this geometry. """ pmeshes = [] # _vertices = [site.coords for site in sites] if permutation is None: ...
Returns a list of coordination geometries with the given coordination number. :param coordination: The coordination number of which the list of coordination geometries are returned. def get_geometries(self, coordination=None, returned='cg'): """ Returns a list of coordination geometries with th...
Returns a list of the implemented coordination geometries with the given coordination number. :param coordination: The coordination number of which the list of implemented coordination geometries are returned. def get_implemented_geometries(self, coordination=None, returned='cg', ...
Returns a list of the implemented coordination geometries with the given coordination number. :param coordination: The coordination number of which the list of implemented coordination geometries are returned. def get_not_implemented_geometries(self, coordination=None, ...
Returns the coordination geometry of the given name. :param name: The name of the coordination geometry. def get_geometry_from_name(self, name): """ Returns the coordination geometry of the given name. :param name: The name of the coordination geometry. """ for gg in sel...
Returns the coordination geometry of the given IUPAC symbol. :param IUPAC_symbol: The IUPAC symbol of the coordination geometry. def get_geometry_from_IUPAC_symbol(self, IUPAC_symbol): """ Returns the coordination geometry of the given IUPAC symbol. :param IUPAC_symbol: The IUPAC symbol...