text
stringlengths
81
112k
Parse the provided files for the corresponding strings. def parse_single(self, errmsg): """ Parse the provided files for the corresponding strings. """ found = False message = None metadata = None for k in errmsg.keys(): if self.files[k] is not None: ...
Parse for the occurens of all errors defined in ERRORS def parse(self): """ Parse for the occurens of all errors defined in ERRORS """ errors_tested = 0 for error in self.error_definitions: errors_tested += 1 result = self.parse_single(self.error_definiti...
Returns a symmetrized molecule The equivalent atoms obtained via :meth:`~pymatgen.symmetry.analyzer.PointGroupAnalyzer.get_equivalent_atoms` are rotated, mirrored... unto one position. Then the average position is calculated. The average position is rotated, mirrored... back with the inverse of...
Cluster sites based on distance and species type. Args: mol (Molecule): Molecule **with origin at center of mass**. tol (float): Tolerance to use. Returns: (origin_site, clustered_sites): origin_site is a site at the center of mass (None if there are no origin atoms). clustered...
Recursive algorithm to permute through all possible combinations of the initially supplied symmetry operations to arrive at a complete set of operations mapping a single atom to all other equivalent atoms in the point group. This assumes that the initial number already uniquely identifies all operation...
Get the point group associated with the structure. Returns: (Pointgroup): Point group for structure. def get_point_group_symbol(self): """ Get the point group associated with the structure. Returns: (Pointgroup): Point group for structure. """ r...
Get the crystal system for the structure, e.g., (triclinic, orthorhombic, cubic, etc.). Returns: (str): Crystal system for structure or None if system cannot be detected. def get_crystal_system(self): """ Get the crystal system for the structure, e.g., (triclinic, o...
Get the lattice for the structure, e.g., (triclinic, orthorhombic, cubic, etc.).This is the same than the crystal system with the exception of the hexagonal/rhombohedral lattice Returns: (str): Lattice type for structure or None if type cannot be detected. def get_lattice_t...
Get the symmetry operations associated with the structure. Returns: Symmetry operations as a tuple of two equal length sequences. (rotations, translations). "rotations" is the numpy integer array of the rotation matrices for scaled positions "translations" gives ...
Return symmetry operations as a list of SymmOp objects. By default returns fractional coord symmops. But cartesian can be returned too. Returns: ([SymmOp]): List of symmetry operations. def get_symmetry_operations(self, cartesian=False): """ Return symmetry operatio...
Get a symmetrized structure. A symmetrized structure is one where the sites have been grouped into symmetrically equivalent groups. Returns: :class:`pymatgen.symmetry.structure.SymmetrizedStructure` object. def get_symmetrized_structure(self): """ Get a symmetrized structur...
Get the refined structure based on detected symmetry. The refined structure is a *conventional* cell setting with atoms moved to the expected symmetry positions. Returns: Refined structure. def get_refined_structure(self): """ Get the refined structure based on dete...
Find a primitive version of the unit cell. Returns: A primitive cell in the input cell is searched and returned as an Structure object. If no primitive cell is found, None is returned. def find_primitive(self): """ Find a primitive version of the unit cell. ...
k-point mesh of the Brillouin zone generated taken into account symmetry.The method returns the irreducible kpoints of the mesh and their weights Args: mesh (3x1 array): The number of kpoint for the mesh needed in each direction is_shift (3x1 array): Whet...
Gives the transformation matrix to transform a conventional unit cell to a primitive cell according to certain standards the standards are defined in Setyawan, W., & Curtarolo, S. (2010). High-throughput electronic band structure calculations: Challenges and tools. Computational Material...
Gives a structure with a primitive cell according to certain standards the standards are defined in Setyawan, W., & Curtarolo, S. (2010). High-throughput electronic band structure calculations: Challenges and tools. Computational Materials Science, 49(2), 299-312. doi:10.1016/j.commatsci...
Gives a structure with a conventional cell according to certain standards. The standards are defined in Setyawan, W., & Curtarolo, S. (2010). High-throughput electronic band structure calculations: Challenges and tools. Computational Materials Science, 49(2), 299-312. doi:10.1016/j.comma...
Calculate the weights for a list of kpoints. Args: kpoints (Sequence): Sequence of kpoints. np.arrays is fine. Note that the code does not check that the list of kpoints provided does not contain duplicates. atol (float): Tolerance for fractional coordina...
Handles assymetric top molecules, which cannot contain rotational symmetry larger than 2. def _proc_asym_top(self): """ Handles assymetric top molecules, which cannot contain rotational symmetry larger than 2. """ self._check_R2_axes_asym() if len(self.rot_sym) =...
Handles symetric top molecules which has one unique eigenvalue whose corresponding principal axis is a unique rotational axis. More complex handling required to look for R2 axes perpendicular to this unique axis. def _proc_sym_top(self): """ Handles symetric top molecules which...
Handles molecules with no rotational symmetry. Only possible point groups are C1, Cs and Ci. def _proc_no_rot_sym(self): """ Handles molecules with no rotational symmetry. Only possible point groups are C1, Cs and Ci. """ self.sch_symbol = "C1" if self.is_valid_o...
Handles cyclic group molecules. def _proc_cyclic(self): """ Handles cyclic group molecules. """ main_axis, rot = max(self.rot_sym, key=lambda v: v[1]) self.sch_symbol = "C{}".format(rot) mirror_type = self._find_mirror(main_axis) if mirror_type == "h": ...
Handles dihedral group molecules, i.e those with intersecting R2 axes and a main axis. def _proc_dihedral(self): """ Handles dihedral group molecules, i.e those with intersecting R2 axes and a main axis. """ main_axis, rot = max(self.rot_sym, key=lambda v: v[1]) ...
Test for 2-fold rotation along the principal axes. Used to handle asymetric top molecules. def _check_R2_axes_asym(self): """ Test for 2-fold rotation along the principal axes. Used to handle asymetric top molecules. """ for v in self.principal_axes: op = Sym...
Looks for mirror symmetry of specified type about axis. Possible types are "h" or "vd". Horizontal (h) mirrors are perpendicular to the axis while vertical (v) or diagonal (d) mirrors are parallel. v mirrors has atoms lying on the mirror plane while d mirrors do not. def _find_mirror...
Returns the smallest list of atoms with the same species and distance from origin AND does not lie on the specified axis. This maximal set limits the possible rotational symmetry operations, since atoms lying on a test axis is irrelevant in testing rotational symmetryOperations. def _g...
Determines the rotational symmetry about supplied axis. Used only for symmetric top molecules which has possible rotational symmetry operations > 2. def _check_rot_sym(self, axis): """ Determines the rotational symmetry about supplied axis. Used only for symmetric top molecule...
Checks for R2 axes perpendicular to unique axis. For handling symmetric top molecules. def _check_perpendicular_r2_axis(self, axis): """ Checks for R2 axes perpendicular to unique axis. For handling symmetric top molecules. """ min_set = self._get_smallest_set_not_on_a...
Handles Sperhical Top Molecules, which belongs to the T, O or I point groups. def _proc_sph_top(self): """ Handles Sperhical Top Molecules, which belongs to the T, O or I point groups. """ self._find_spherical_axes() if len(self.rot_sym) == 0: logger....
Looks for R5, R4, R3 and R2 axes in spherical top molecules. Point group T molecules have only one unique 3-fold and one unique 2-fold axis. O molecules have one unique 4, 3 and 2-fold axes. I molecules have a unique 5-fold axis. def _find_spherical_axes(self): """ Looks for R5...
Check if a particular symmetry operation is a valid symmetry operation for a molecule, i.e., the operation maps all atoms to another equivalent atom. Args: symmop (SymmOp): Symmetry operation to test. Returns: (bool): Whether SymmOp is valid for Molecule. def i...
Calculates the dictionary for mapping equivalent atoms onto each other. Args: None Returns: dict: The returned dictionary has two possible keys: ``eq_sets``: A dictionary of indices mapping to sets of indices, each key maps to indices of all...
Combines the dicts of _get_equivalent_atom_dicts into one Args: eq_sets (dict) operations (dict) Returns: dict: The returned dictionary has two possible keys: ``eq_sets``: A dictionary of indices mapping to sets of indices, each ...
Returns a symmetrized molecule The equivalent atoms obtained via :meth:`~pymatgen.symmetry.analyzer.PointGroupAnalyzer.get_equivalent_atoms` are rotated, mirrored... unto one position. Then the average position is calculated. The average position is rotated, mirrored... back wit...
Given two sets of PeriodicSites, test if they are actually symmetrically equivalent under this space group. Useful, for example, if you want to test if selecting atoms 1 and 2 out of a set of 4 atoms are symmetrically the same as selecting atoms 3 and 4, etc. One use is in PartialRemov...
Find the indices of matches of a particular coord in a coord_list. Args: coord_list: List of coords to test coord: Specific coordinates atol: Absolute tolerance. Defaults to 1e-8. Accepts both scalar and array. Returns: Indices of matches, e.g., [0, 1, 2, 3]. Empty ...
Tests if a particular coord is within a coord_list. Args: coord_list: List of coords to test coord: Specific coordinates atol: Absolute tolerance. Defaults to 1e-8. Accepts both scalar and array. Returns: True if coord is in the coord list. def in_coord_list(coord_...
Tests if all coords in subset are contained in superset. Doesn't use periodic boundary conditions Args: subset, superset: List of coords Returns: True if all of subset is in superset. def is_coord_subset(subset, superset, atol=1e-8): """ Tests if all coords in subset are contained...
Gives the index mapping from a subset to a superset. Subset and superset cannot contain duplicate rows Args: subset, superset: List of coords Returns: list of indices such that superset[indices] = subset def coord_list_mapping(subset, superset, atol=1e-8): """ Gives the index mapp...
Gives the index mapping from a subset to a superset. Superset cannot contain duplicate matching rows Args: subset, superset: List of frac_coords Returns: list of indices such that superset[indices] = subset def coord_list_mapping_pbc(subset, superset, atol=1e-8): """ Gives the ind...
Returns an interpolated value by linear interpolation between two values. This method is written to avoid dependency on scipy, which causes issues on threading servers. Args: x_values: Sequence of x values. y_values: Corresponding sequence of y values x: Get value at particular x ...
Returns the distances between two lists of coordinates Args: coords1: First set of cartesian coordinates. coords2: Second set of cartesian coordinates. Returns: 2d array of cartesian distances. E.g the distance between coords1[i] and coords2[j] is distances[i,j] def all_distan...
Returns the 'fractional distance' between two coordinates taking into account periodic boundary conditions. Args: fcoords1: First set of fractional coordinates. e.g., [0.5, 0.6, 0.7] or [[1.1, 1.2, 4.3], [0.5, 0.6, 0.7]]. It can be a single coord or any array of coords. ...
Get the indices of all points in a fractional coord list that are equal to a fractional coord (with a tolerance), taking into account periodic boundary conditions. Args: fcoord_list: List of fractional coords fcoord: A specific fractional coord to test. atol: Absolute tolerance. Def...
Tests if a particular fractional coord is within a fractional coord_list. Args: fcoord_list: List of fractional coords to test fcoord: A specific fractional coord to test. atol: Absolute tolerance. Defaults to 1e-8. Returns: True if coord is in the coord list. def in_coord_lis...
Tests if all fractional coords in subset are contained in superset. Args: subset, superset: List of fractional coords atol (float or size 3 array): Tolerance for matching mask (boolean array): Mask of matches that are not allowed. i.e. if mask[1,2] == True, then subset[1] cannot...
Returns the list of points on the original lattice contained in the supercell in fractional coordinates (with the supercell basis). e.g. [[2,0,0],[0,1,0],[0,0,1]] returns [[0,0,0],[0.5,0,0]] Args: supercell_matrix: 3x3 matrix describing the supercell Returns: numpy array of the fractio...
Converts a list of coordinates to barycentric coordinates, given a simplex with d+1 points. Only works for d >= 2. Args: coords: list of n coords to transform, shape should be (n,d) simplex: list of coordinates that form the simplex, shape should be (d+1, d) Returns: a ...
Calculates the angle between two vectors. Args: v1: Vector 1 v2: Vector 2 units: "degrees" or "radians". Defaults to "degrees". Returns: Angle between them in degrees. def get_angle(v1, v2, units="degrees"): """ Calculates the angle between two vectors. Args: ...
Volume of the simplex. def volume(self): """ Volume of the simplex. """ return abs(np.linalg.det(self._aug)) / math.factorial(self.simplex_dim)
Computes the intersection points of a line with a simplex Args: point1, point2 ([float]): Points that determine the line Returns: points where the line intersects the simplex (0, 1, or 2) def line_intersection(self, point1, point2, tolerance=1e-8): """ Computes t...
Use pybtex to validate that a reference is in proper BibTeX format Args: reference: A String reference in BibTeX format. Returns: Boolean indicating if reference is valid bibtex. def is_valid_bibtex(reference): """ Use pybtex to validate that a reference is in proper BibTeX format ...
Parses a History Node object from either a dict or a tuple. Args: h_node: A dict with name/url/description fields or a 3-element tuple. Returns: History node. def parse_history_node(h_node): """ Parses a History Node object from either a dict or...
Parses an Author object from either a String, dict, or tuple Args: author: A String formatted as "NAME <email@domain.com>", (name, email) tuple, or a dict with name and email keys. Returns: An Author object. def parse_author(author): """ Parses ...
A convenience method for getting a list of StructureNL objects by specifying structures and metadata separately. Some of the metadata is applied to all of the structures for ease of use. Args: structures: A list of Structure objects authors: *List* of {"name":'', "email"...
This function converts a strain to a deformation gradient that will produce that strain. Supports three methods: Args: strain (3x3 array-like): strain matrix shape: (string): method for determining deformation, supports "upper" produces an upper triangular defo "lower" ...
Gets indices of perturbed elements of the deformation gradient, i. e. those that differ from the identity def get_perturbed_indices(self, tol=1e-8): """ Gets indices of perturbed elements of the deformation gradient, i. e. those that differ from the identity """ indices ...
Apply the deformation gradient to a structure. Args: structure (Structure object): the structure object to be modified by the deformation def apply_to_structure(self, structure): """ Apply the deformation gradient to a structure. Args: structure...
Factory method for constructing a Deformation object from a matrix position and amount Args: matrixpos (tuple): tuple corresponding the matrix position to have a perturbation added amt (float): amount to add to the identity matrix at position matr...
Factory method that returns a Strain object from a deformation gradient Args: deformation (3x3 array-like): def from_deformation(cls, deformation): """ Factory method that returns a Strain object from a deformation gradient Args: deformation (3x...
Like Deformation.from_index_amount, except generates a strain from the zero 3x3 tensor or voigt vector with the amount specified in the index location. Ensures symmetric strain. Args: idx (tuple or integer): index to be perturbed, can be voigt or full-tensor...
Equivalent strain to Von Mises Stress def von_mises_strain(self): """ Equivalent strain to Von Mises Stress """ eps = self - 1/3 * np.trace(self) * np.identity(3) return np.sqrt(np.sum(eps * eps) * 2/3)
Prepare for display on plots "(hkl)" for surfaces Agrs: hkl: in the form of [h, k, l] or (h, k, l) def hkl_tuple_to_str(hkl): """ Prepare for display on plots "(hkl)" for surfaces Agrs: hkl: in the form of [h, k, l] or (h, k, l) """ str_format = '($' for x in hkl: ...
Given a list of coords for 3 points, Compute the area of this triangle. Args: pts: [a, b, c] three points def get_tri_area(pts): """ Given a list of coords for 3 points, Compute the area of this triangle. Args: pts: [a, b, c] three points """ a, b, c = pts[0], pts[1], ...
from self: get miller_list(unique_miller), e_surf_list and symmetry operations(symmops) according to lattice apply symmops to get all the miller index, then get normal, get all the facets functions for wulff shape calculation: |normal| = 1, e_surf is plane's distance ...
|normal| = 1, e_surf is plane's distance to (0, 0, 0), plane function: normal[0]x + normal[1]y + normal[2]z = e_surf from self: normal_e_m to get the plane functions dual_simp: (i, j, k) simplices from the dual convex hull i, j, k: plane index(same or...
Locate the plane for simpx of on wulff_cv, by comparing the center of the simpx triangle with the plane functions. def _get_simpx_plane(self): """ Locate the plane for simpx of on wulff_cv, by comparing the center of the simpx triangle with the plane functions. """ on_wu...
assign colors according to the surface energies of on_wulff facets. return: (color_list, color_proxy, color_proxy_on_wulff, miller_on_wulff, e_surf_on_wulff_list) def _get_colors(self, color_set, alpha, off_color, custom_colors={}): """ assign colors according to the su...
Returns the sorted pts in a facet used to draw a line def get_line_in_facet(self, facet): """ Returns the sorted pts in a facet used to draw a line """ lines = list(facet.outer_lines) pt = [] prev = None while len(lines) > 0: if prev is None: ...
Get the Wulff shape plot. Args: color_set: default is 'PuBu' grid_off (bool): default is True axis_off (bool): default is Ture show_area (bool): default is False alpha (float): chosen from 0 to 1 (float), default is 1 off_color: Default co...
Args: miller_index: viewing direction Returns: azim, elev for plotting def _get_azimuth_elev(self, miller_index): """ Args: miller_index: viewing direction Returns: azim, elev for plotting """ if miller_index == (0, 0, 1)...
Returns: (dict): {hkl: area_hkl/total area on wulff} def area_fraction_dict(self): """ Returns: (dict): {hkl: area_hkl/total area on wulff} """ return {hkl: self.miller_area_dict[hkl] / self.surface_area for hkl in self.miller_area_dict.keys()}
Returns: (float) Coefficient of Variation from weighted surface energy The ideal sphere is 0. def anisotropy(self): """ Returns: (float) Coefficient of Variation from weighted surface energy The ideal sphere is 0. """ square_diff_energy = ...
Total surface energy of the Wulff shape. Returns: (float) sum(surface_energy_hkl * area_hkl) def total_surface_energy(self): """ Total surface energy of the Wulff shape. Returns: (float) sum(surface_energy_hkl * area_hkl) """ tot_surface_energy ...
Returns the number of edges in the convex hull. Useful for identifying catalytically active sites. def tot_edges(self): """ Returns the number of edges in the convex hull. Useful for identifying catalytically active sites. """ all_edges = [] for facet in ...
Construct SpaceGroupTransformation from its transformation string. :param P: matrix :param p: origin shift vector :return: def from_transformation_string(cls, transformation_string="a,b,c;0,0,0"): """ Construct SpaceGroupTransformation from its transformation string. :pa...
:return: JonesFaithfulTransformation def inverse(self): # type: () -> JonesFaithfulTransformation """ :return: JonesFaithfulTransformation """ Q = np.linalg.inv(self.P) return JonesFaithfulTransformation(Q, -np.matmul(Q, self.p))
Takes a symmetry operation and transforms it. :param symmop: SymmOp or MagSymmOp :return: def transform_symmop(self, symmop): # type: (Union[SymmOp, MagSymmOp]) -> Union[SymmOp, MagSymmOp] """ Takes a symmetry operation and transforms it. :param symmop: SymmOp or MagSymm...
Takes a list of co-ordinates and transforms them. :param coords: List of coords :return: def transform_coords(self, coords): # type: (List[List[float]]) -> List[List[float]] """ Takes a list of co-ordinates and transforms them. :param coords: List of coords :retu...
Takes a Lattice object and transforms it. :param lattice: Lattice :return: def transform_lattice(self, lattice): # type: (Lattice) -> Lattice """ Takes a Lattice object and transforms it. :param lattice: Lattice :return: """ return Lattice(np.mat...
Finds the element from "allowed elements" that (i) possesses the desired "oxidation state" and (ii) is closest in ionic radius to the target specie Args: target: (Specie) provides target ionic radius. oxidation_state: (float) codopant oxidation state. allowed_elements: ([str]) List of a...
Return either a single ordered structure or a sequence of all ordered structures. Args: structure: Structure to order. return_ranked_list (bool): Whether or not multiple structures are returned. If return_ranked_list is a number, that number of st...
Checks if a periodic site satisfies the constraint. def satisfies_constraint(self, site): """ Checks if a periodic site satisfies the constraint. """ if not site.is_ordered: return False if self.species_constraints \ and str(site.specie) in self.spec...
Determine the smallest supercell that is able to enumerate the provided structure with the given order parameter def determine_min_cell(disordered_structure): """ Determine the smallest supercell that is able to enumerate the provided structure with the given order parameter """...
:param structure: ordered Structure :param order_parameters: list of MagOrderParameterConstraints :return: A structure decorated with disordered DummySpecies on which to perform the enumeration. Note that the DummySpecies are super-imposed on to the original sites, to make it eas...
:return: Structure with dummy species removed, but their corresponding spin properties merged with the original sites. Used after performing enumeration. def _remove_dummy_species(structure): """ :return: Structure with dummy species removed, but their corresponding spin propert...
Replaces Spin.up/Spin.down with spin magnitudes specified by mag_species_spin. :param structure: :return: def _add_spin_magnitudes(self, structure): """ Replaces Spin.up/Spin.down with spin magnitudes specified by mag_species_spin. :param structure: :retu...
Apply MagOrderTransformation to an input structure. :param structure: Any ordered structure. :param return_ranked_list: As in other Transformations. :return: def apply_transformation(self, structure, return_ranked_list=False): """ Apply MagOrderTransformation to an input structu...
Args: structure (Structure): Input structure to dope Returns: [{"structure": Structure, "energy": float}] def apply_transformation(self, structure, return_ranked_list=False): """ Args: structure (Structure): Input structure to dope Returns: ...
Args: structure: ordered structure return_ranked_list: as in other pymatgen Transformations Returns: transformed disordered structure(s) def apply_transformation(self, structure, return_ranked_list=False): """ Args: structure: ordered structure r...
Private method to split a list of species into various partitions. def _partition_species(composition, max_components=2): """ Private method to split a list of species into various partitions. """ def _partition(collection): # thanks https://stackoverflow.co...
Private method to obtain the mapping to create a disordered structure from a given partition. def _get_disorder_mappings(composition, partitions): """ Private method to obtain the mapping to create a disordered structure from a given partition. """ def _get_replacement_...
helper to clean up an input string def clean(some_string, uppercase=False): """ helper to clean up an input string """ if uppercase: return some_string.strip().upper() else: return some_string.strip().lower()
Read the results of a full set of calculations from file def read_grid_from_file(filename): """ Read the results of a full set of calculations from file """ try: f = open(filename, mode='r') full_res = ast.literal_eval(f.read()) f.close() except SyntaxError: print('P...
performs a structure prediction targeting compounds containing all of the target_species, based on a list of structure (those structures can for instance come from a database like the ICSD). It will return all the structures formed by ionic substitutions with a probability higher than th...
checks if the structure object is charge balanced def _is_charge_balanced(struct): """ checks if the structure object is charge balanced """ if sum([s.specie.oxi_state for s in struct.sites]) == 0.0: return True else: return False
checks if the structure object is from the given chemical system def _is_from_chemical_system(chemical_system, struct): """ checks if the structure object is from the given chemical system """ chemsys = list(set([sp.symbol for sp in struct.composition])) if len(chemsys) != len(c...
There are an exceptionally large number of substitutions to look at (260^n), where n is the number of species in the list. We need a more efficient than brute force way of going through these possibilities. The brute force method would be:: output = [] for p in itertools...
Similar to pred_from_list except this method returns a list after checking that compositions are charge balanced. def pred_from_comp(self, composition): """ Similar to pred_from_list except this method returns a list after checking that compositions are charge balanced. """ ...
Provides a publication quality plot, with nice defaults for font sizes etc. Args: width (float): Width of plot in inches. Defaults to 8in. height (float): Height of plot in inches. Defaults to width * golden ratio. plt (matplotlib.pyplot): If plt is supplied, changes will be mad...