INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Find the symmetric operations of the reciprocal lattice to be used for hkl transformations Args: structure ( Structure ): conventional unit cell symprec: default is 0. 001
def get_recp_symmetry_operation(structure, symprec=0.01): """ Find the symmetric operations of the reciprocal lattice, to be used for hkl transformations Args: structure (Structure): conventional unit cell symprec: default is 0.001 """ recp_lattice = structure.lattice.reciprocal...
Returns all symmetrically distinct indices below a certain max - index for a given structure. Analysis is based on the symmetry of the reciprocal lattice of the structure. Args: structure ( Structure ): input structure. max_index ( int ): The maximum index. For example a max_index of 1 means that ( 100 ) ( 110 ) and ( ...
def get_symmetrically_distinct_miller_indices(structure, max_index): """ Returns all symmetrically distinct indices below a certain max-index for a given structure. Analysis is based on the symmetry of the reciprocal lattice of the structure. Args: structure (Structure): input structure. ...
Returns the Miller index from setting A to B using a transformation matrix Args: transf ( 3x3 array ): The transformation matrix that transforms a lattice of A to B miller_index ( [ h k l ] ): Miller index to transform to setting B
def hkl_transformation(transf, miller_index): """ Returns the Miller index from setting A to B using a transformation matrix Args: transf (3x3 array): The transformation matrix that transforms a lattice of A to B miller_index ([h, k, l]): Miller index to transform to setting ...
A function that finds all different slabs up to a certain miller index. Slabs oriented under certain Miller indices that are equivalent to other slabs in other Miller indices are filtered out using symmetry operations to get rid of any repetitive slabs. For example under symmetry operations CsCl has equivalent slabs in...
def generate_all_slabs(structure, max_index, min_slab_size, min_vacuum_size, bonds=None, tol=1e-3, max_broken_bonds=0, lll_reduce=False, center_slab=False, primitive=True, max_normal_search=None, symmetrize=False, repair=False, ...
Function to get the ranges of the slab regions. Useful for discerning where the slab ends and vacuum begins if the slab is not fully within the cell Args: slab ( Structure ): Structure object modelling the surface blength ( float Ang ): The bondlength between atoms. You generally want this value to be larger than the a...
def get_slab_regions(slab, blength=3.5): """ Function to get the ranges of the slab regions. Useful for discerning where the slab ends and vacuum begins if the slab is not fully within the cell Args: slab (Structure): Structure object modelling the surface blength (float, Ang): The bondl...
Get the Miller index of a plane from a list of site coordinates.
def miller_index_from_sites(lattice, coords, coords_are_cartesian=True, round_dp=4, verbose=True): """ Get the Miller index of a plane from a list of site coordinates. A minimum of 3 sets of coordinates are required. If more than 3 sets of coordinates are given, the best pla...
The goal here is to ensure the center of the slab region is centered close to c = 0. 5. This makes it easier to find the surface sites and apply operations like doping.
def center_slab(slab): """ The goal here is to ensure the center of the slab region is centered close to c=0.5. This makes it easier to find the surface sites and apply operations like doping. There are three cases where the slab in not centered: 1. The slab region is completely between...
This method returns a Slab where the normal ( c lattice vector ) is forced to be exactly orthogonal to the surface a and b lattice vectors. ** Note that this breaks inherent symmetries in the slab. ** It should be pointed out that orthogonality is not required to get good surface energies but it can be useful in cases ...
def get_orthogonal_c_slab(self): """ This method returns a Slab where the normal (c lattice vector) is "forced" to be exactly orthogonal to the surface a and b lattice vectors. **Note that this breaks inherent symmetries in the slab.** It should be pointed out that orthogonality ...
Get a list of slabs that have been Tasker 2 corrected.
def get_tasker2_slabs(self, tol=0.01, same_species_only=True): """ Get a list of slabs that have been Tasker 2 corrected. Args: tol (float): Tolerance to determine if atoms are within same plane. This is a fractional tolerance, not an absolute one. same_s...
Checks if slab is symmetric i. e. contains inversion symmetry.
def is_symmetric(self, symprec=0.1): """ Checks if slab is symmetric, i.e., contains inversion symmetry. Args: symprec (float): Symmetry precision used for SpaceGroup analyzer. Returns: (bool) Whether slab contains inversion symmetry. """ sg = S...
Get a sorted copy of the structure. The parameters have the same meaning as in list. sort. By default sites are sorted by the electronegativity of the species. Note that Slab has to override this because of the different __init__ args.
def get_sorted_structure(self, key=None, reverse=False): """ Get a sorted copy of the structure. The parameters have the same meaning as in list.sort. By default, sites are sorted by the electronegativity of the species. Note that Slab has to override this because of the differen...
Convenience method to get a copy of the structure with options to add site properties.
def copy(self, site_properties=None, sanitize=False): """ Convenience method to get a copy of the structure, with options to add site properties. Args: site_properties (dict): Properties to add or override. The properties are specified in the same way as the ...
Calculates the dipole of the Slab in the direction of the surface normal. Note that the Slab must be oxidation state - decorated for this to work properly. Otherwise the Slab will always have a dipole of 0.
def dipole(self): """ Calculates the dipole of the Slab in the direction of the surface normal. Note that the Slab must be oxidation state-decorated for this to work properly. Otherwise, the Slab will always have a dipole of 0. """ dipole = np.zeros(3) mid_pt = np...
Checks whether the surface is polar by computing the dipole per unit area. Note that the Slab must be oxidation state - decorated for this to work properly. Otherwise the Slab will always be non - polar.
def is_polar(self, tol_dipole_per_unit_area=1e-3): """ Checks whether the surface is polar by computing the dipole per unit area. Note that the Slab must be oxidation state-decorated for this to work properly. Otherwise, the Slab will always be non-polar. Args: tol_d...
Calculates the surface normal vector of the slab
def normal(self): """ Calculates the surface normal vector of the slab """ normal = np.cross(self.lattice.matrix[0], self.lattice.matrix[1]) normal /= np.linalg.norm(normal) return normal
Calculates the surface area of the slab
def surface_area(self): """ Calculates the surface area of the slab """ m = self.lattice.matrix return np.linalg.norm(np.cross(m[0], m[1]))
Calculates the center of mass of the slab
def center_of_mass(self): """ Calculates the center of mass of the slab """ weights = [s.species.weight for s in self] center_of_mass = np.average(self.frac_coords, weights=weights, axis=0) return center_of_mass
Gets the structure of single atom adsorption. slab structure from the Slab class ( in [ 0 0 1 ] )
def add_adsorbate_atom(self, indices, specie, distance): """ Gets the structure of single atom adsorption. slab structure from the Slab class(in [0, 0, 1]) Args: indices ([int]): Indices of sites on which to put the absorbate. Absorbed atom will be displaced ...
Returns the surface sites and their indices in a dictionary. The oriented unit cell of the slab will determine the coordination number of a typical site. We use VoronoiNN to determine the coordination number of bulk sites and slab sites. Due to the pathological error resulting from some surface sites in the VoronoiNN w...
def get_surface_sites(self, tag=False): """ Returns the surface sites and their indices in a dictionary. The oriented unit cell of the slab will determine the coordination number of a typical site. We use VoronoiNN to determine the coordination number of bulk sites and slab sites...
Check if we have same number of equivalent sites on both surfaces. This is an alternative to checking Laue symmetry ( is_symmetric () ) if we want to ensure both surfaces in the slab are the same
def have_equivalent_surfaces(self): """ Check if we have same number of equivalent sites on both surfaces. This is an alternative to checking Laue symmetry (is_symmetric()) if we want to ensure both surfaces in the slab are the same """ # tag the sites as either surface ...
This method uses symmetry operations to find equivalent sites on both sides of the slab. Works mainly for slabs with Laue symmetry. This is useful for retaining the non - polar and symmetric properties of a slab when creating adsorbed structures or symmetric reconstructions.
def get_symmetric_site(self, point, cartesian=False): """ This method uses symmetry operations to find equivalent sites on both sides of the slab. Works mainly for slabs with Laue symmetry. This is useful for retaining the non-polar and symmetric properties of a slab ...
Class method for adding a site at a specified point in a slab. Will add the corresponding site on the other side of the slab to maintain equivalent surfaces.
def symmetrically_add_atom(self, specie, point, coords_are_cartesian=False): """ Class method for adding a site at a specified point in a slab. Will add the corresponding site on the other side of the slab to maintain equivalent surfaces. Arg: specie (str): ...
Class method for removing sites corresponding to a list of indices. Will remove the corresponding site on the other side of the slab to maintain equivalent surfaces.
def symmetrically_remove_atoms(self, indices): """ Class method for removing sites corresponding to a list of indices. Will remove the corresponding site on the other side of the slab to maintain equivalent surfaces. Arg: indices ([indices]): The indices of ...
This method takes in shift value for the c lattice direction and generates a slab based on the given shift. You should rarely use this method. Instead it is used by other generation algorithms to obtain all slabs.
def get_slab(self, shift=0, tol=0.1, energy=None): """ This method takes in shift value for the c lattice direction and generates a slab based on the given shift. You should rarely use this method. Instead, it is used by other generation algorithms to obtain all slabs. A...
This method returns a list of slabs that are generated using the list of shift values from the method _calculate_possible_shifts (). Before the shifts are used to create the slabs however if the user decides to take into account whether or not a termination will break any polyhedral structure ( bonds is not None ) this...
def get_slabs(self, bonds=None, ftol=0.1, tol=0.1, max_broken_bonds=0, symmetrize=False, repair=False): """ This method returns a list of slabs that are generated using the list of shift values from the method, _calculate_possible_shifts(). Before the shifts are used to...
This method will find undercoordinated atoms due to slab cleaving specified by the bonds parameter and move them to the other surface to make sure the bond is kept intact. In a future release of surface. py the ghost_sites will be used to tell us how the repair bonds should look like.
def repair_broken_bonds(self, slab, bonds): """ This method will find undercoordinated atoms due to slab cleaving specified by the bonds parameter and move them to the other surface to make sure the bond is kept intact. In a future release of surface.py, the ghost_sites will be ...
This method will Move a set of sites to the other side of the slab ( opposite surface ).
def move_to_other_side(self, init_slab, index_of_sites): """ This method will Move a set of sites to the other side of the slab (opposite surface). Arg: init_slab (structure): A structure object representing a slab. index_of_sites (list of ints): The list of indi...
This method checks whether or not the two surfaces of the slab are equivalent. If the point group of the slab has an inversion symmetry ( ie. belong to one of the Laue groups ) then it is assumed that the surfaces should be equivalent. Otherwise sites at the bottom of the slab will be removed until the slab is symmetri...
def nonstoichiometric_symmetrized_slab(self, init_slab, tol=1e-3): """ This method checks whether or not the two surfaces of the slab are equivalent. If the point group of the slab has an inversion symmetry ( ie. belong to one of the Laue groups), then it is assumed that the sur...
Builds the reconstructed slab by: ( 1 ) Obtaining the unreconstructed slab using the specified parameters for the SlabGenerator. ( 2 ) Applying the appropriate lattice transformation in the a and b lattice vectors. ( 3 ) Remove any specified sites from both surfaces. ( 4 ) Add any specified sites to both surfaces.
def build_slabs(self): """ Builds the reconstructed slab by: (1) Obtaining the unreconstructed slab using the specified parameters for the SlabGenerator. (2) Applying the appropriate lattice transformation in the a and b lattice vectors. ...
Generates the unreconstructed or pristine super slab.
def get_unreconstructed_slabs(self): """ Generates the unreconstructed or pristine super slab. """ slabs = [] for slab in SlabGenerator(**self.slabgen_params).get_slabs(): slab.make_supercell(self.trans_matrix) slabs.append(slab) return slabs
Reads a Poscar from a file.
def from_file(filename, check_for_POTCAR=True, read_velocities=True): """ Reads a Poscar from a file. The code will try its best to determine the elements in the POSCAR in the following order: 1. If check_for_POTCAR is True, the code will try to check if a POTCAR is in t...
Reads a Poscar from a string.
def from_string(data, default_names=None, read_velocities=True): """ Reads a Poscar from a string. The code will try its best to determine the elements in the POSCAR in the following order: 1. If default_names are supplied and valid, it will use those. Usually, default n...
Returns a string to be written as a POSCAR file. By default site symbols are written which means compatibility is for vasp > = 5.
def get_string(self, direct=True, vasp4_compatible=False, significant_figures=6): """ Returns a string to be written as a POSCAR file. By default, site symbols are written, which means compatibility is for vasp >= 5. Args: direct (bool): Whether coordinate...
Writes POSCAR to a file. The supported kwargs are the same as those for the Poscar. get_string method and are passed through directly.
def write_file(self, filename, **kwargs): """ Writes POSCAR to a file. The supported kwargs are the same as those for the Poscar.get_string method and are passed through directly. """ with zopen(filename, "wt") as f: f.write(self.get_string(**kwargs))
Initializes the velocities based on Maxwell - Boltzmann distribution. Removes linear but not angular drift ( same as VASP )
def set_temperature(self, temperature): """ Initializes the velocities based on Maxwell-Boltzmann distribution. Removes linear, but not angular drift (same as VASP) Scales the energies to the exact temperature (microcanonical ensemble) Velocities are given in A/fs. This is the v...
Returns a string representation of the INCAR. The reason why this method is different from the __str__ method is to provide options for pretty printing.
def get_string(self, sort_keys=False, pretty=False): """ Returns a string representation of the INCAR. The reason why this method is different from the __str__ method is to provide options for pretty printing. Args: sort_keys (bool): Set to True to sort the INCAR pa...
Reads an Incar object from a string.
def from_string(string): """ Reads an Incar object from a string. Args: string (str): Incar string Returns: Incar object """ lines = list(clean_lines(string.splitlines())) params = {} for line in lines: for sline in li...
Static helper method to convert INCAR parameters to proper types e. g. integers floats lists etc.
def proc_val(key, val): """ Static helper method to convert INCAR parameters to proper types, e.g., integers, floats, lists, etc. Args: key: INCAR parameter key val: Actual value of INCAR parameter. """ list_keys = ("LDAUU", "LDAUL", "LDAUJ", "MAG...
Diff function for Incar. Compares two Incars and indicates which parameters are the same and which are not. Useful for checking whether two runs were done using the same parameters.
def diff(self, other): """ Diff function for Incar. Compares two Incars and indicates which parameters are the same and which are not. Useful for checking whether two runs were done using the same parameters. Args: other (Incar): The other Incar object to compare to...
Convenient static constructor for an automatic Gamma centered Kpoint grid.
def gamma_automatic(kpts=(1, 1, 1), shift=(0, 0, 0)): """ Convenient static constructor for an automatic Gamma centered Kpoint grid. Args: kpts: Subdivisions N_1, N_2 and N_3 along reciprocal lattice vectors. Defaults to (1,1,1) shift: Shift to be...
Convenient static constructor for an automatic Monkhorst pack Kpoint grid.
def monkhorst_automatic(kpts=(2, 2, 2), shift=(0, 0, 0)): """ Convenient static constructor for an automatic Monkhorst pack Kpoint grid. Args: kpts: Subdivisions N_1, N_2 and N_3 along reciprocal lattice vectors. Defaults to (2,2,2) shift: Shift t...
Returns an automatic Kpoint object based on a structure and a kpoint density. Uses Gamma centered meshes for hexagonal cells and Monkhorst - Pack grids otherwise.
def automatic_density(structure, kppa, force_gamma=False): """ Returns an automatic Kpoint object based on a structure and a kpoint density. Uses Gamma centered meshes for hexagonal cells and Monkhorst-Pack grids otherwise. Algorithm: Uses a simple approach scaling t...
Returns an automatic Kpoint object based on a structure and a kpoint density. Uses Gamma centered meshes always. For GW.
def automatic_gamma_density(structure, kppa): """ Returns an automatic Kpoint object based on a structure and a kpoint density. Uses Gamma centered meshes always. For GW. Algorithm: Uses a simple approach scaling the number of divisions along each reciprocal latt...
Returns an automatic Kpoint object based on a structure and a kpoint density per inverse Angstrom^3 of reciprocal cell.
def automatic_density_by_vol(structure, kppvol, force_gamma=False): """ Returns an automatic Kpoint object based on a structure and a kpoint density per inverse Angstrom^3 of reciprocal cell. Algorithm: Same as automatic_density() Args: structure (Struct...
Convenient static constructor for a KPOINTS in mode line_mode. gamma centered Monkhorst - Pack grids and the number of subdivisions along each reciprocal lattice vector determined by the scheme in the VASP manual.
def automatic_linemode(divisions, ibz): """ Convenient static constructor for a KPOINTS in mode line_mode. gamma centered Monkhorst-Pack grids and the number of subdivisions along each reciprocal lattice vector determined by the scheme in the VASP manual. Args: ...
Reads a Kpoints object from a KPOINTS string.
def from_string(string): """ Reads a Kpoints object from a KPOINTS string. Args: string (str): KPOINTS string. Returns: Kpoints object """ lines = [line.strip() for line in string.splitlines()] comment = lines[0] num_kpts = int(l...
json friendly dict representation of Kpoints
def as_dict(self): """json friendly dict representation of Kpoints""" d = {"comment": self.comment, "nkpoints": self.num_kpts, "generation_style": self.style.name, "kpoints": self.kpts, "usershift": self.kpts_shift, "kpts_weights": self.kpts_weights, "coord_type": ...
Attempt to return the atomic symbol based on the VRHFIN keyword.
def element(self): """ Attempt to return the atomic symbol based on the VRHFIN keyword. """ element = self.keywords["VRHFIN"].split(":")[0].strip() try: return Element(element).symbol except ValueError: # VASP incorrectly gives the element symbol f...
Initialize the POTCAR from a set of symbols. Currently the POTCARs can be fetched from a location specified in. pmgrc. yaml. Use pmg config to add this setting.
def set_symbols(self, symbols, functional=None, sym_potcar_map=None): """ Initialize the POTCAR from a set of symbols. Currently, the POTCARs can be fetched from a location specified in .pmgrc.yaml. Use pmg config to add this setting. Args: symbol...
Write VASP input to a directory.
def write_input(self, output_dir=".", make_dir_if_not_present=True): """ Write VASP input to a directory. Args: output_dir (str): Directory to write to. Defaults to current directory ("."). make_dir_if_not_present (bool): Create the directory if not ...
Read in a set of VASP input from a directory. Note that only the standard INCAR POSCAR POTCAR and KPOINTS files are read unless optional_filenames is specified.
def from_directory(input_dir, optional_files=None): """ Read in a set of VASP input from a directory. Note that only the standard INCAR, POSCAR, POTCAR and KPOINTS files are read unless optional_filenames is specified. Args: input_dir (str): Directory to read VASP in...
Write input files and run VASP.
def run_vasp(self, run_dir: PathLike = ".", vasp_cmd: list = None, output_file: PathLike = "vasp.out", err_file: PathLike = "vasp.err"): """ Write input files and run VASP. :param run_dir: Where to write input files and do the run. :par...
Get kpoints object from JHU servlet per Wisesa - McGill - Mueller methodology. Refer to http:// muellergroup. jhu. edu/ K - Points. html and P. Wisesa K. A. McGill T. Mueller Phys. Rev. B 93 155109 ( 2016 )
def get_kpoints(structure, min_distance=0, min_total_kpoints=1, kppra=None, gap_distance=7, remove_symmetry=None, include_gamma="auto", header="simple", incar=None): """ Get kpoints object from JHU servlet, per Wisesa-McGill-Mueller methodology. Refer to http://muellergrou...
Get the simplex facets for the Convex hull.
def get_facets(qhull_data, joggle=False): """ Get the simplex facets for the Convex hull. Args: qhull_data (np.ndarray): The data from which to construct the convex hull as a Nxd array (N being number of data points and d being the dimension) joggle (boolean): Whethe...
Given all the facets convert it into a set of unique lines. Specifically used for converting convex hull facets into line pairs of coordinates.
def uniquelines(q): """ Given all the facets, convert it into a set of unique lines. Specifically used for converting convex hull facets into line pairs of coordinates. Args: q: A 2-dim sequence, where each row represents a facet. E.g., [[1,2,3],[3,6,7],...] Returns: s...
Convert a 2D coordinate into a triangle - based coordinate system for a prettier phase diagram.
def triangular_coord(coord): """ Convert a 2D coordinate into a triangle-based coordinate system for a prettier phase diagram. Args: coordinate: coordinate used in the convex hull computation. Returns: coordinates in a triangular-based coordinate system. """ unitvec = np.ar...
Orders the entries ( their coordinates ) in a phase diagram plot according to the user specified ordering. Ordering should be given as [ Up Left Right ] where Up Left and Right are the names of the entries in the upper left and right corners of the triangle respectively.
def order_phase_diagram(lines, stable_entries, unstable_entries, ordering): """ Orders the entries (their coordinates) in a phase diagram plot according to the user specified ordering. Ordering should be given as ['Up', 'Left', 'Right'], where Up, Left and Right are the names of the entries in the u...
The phase diagram is generated in a reduced dimensional space ( n_elements - 1 ). This function returns the coordinates in that space. These coordinates are compatible with the stored simplex objects.
def pd_coords(self, comp): """ The phase diagram is generated in a reduced dimensional space (n_elements - 1). This function returns the coordinates in that space. These coordinates are compatible with the stored simplex objects. """ if set(comp.elements).difference(self....
Returns the formation energy for an entry ( NOT normalized ) from the elemental references.
def get_form_energy(self, entry): """ Returns the formation energy for an entry (NOT normalized) from the elemental references. Args: entry: A PDEntry-like object. Returns: Formation energy from the elemental references. """ c = entry.com...
Get any facet that a composition falls into. Cached so successive calls at same composition are fast.
def _get_facet_and_simplex(self, comp): """ Get any facet that a composition falls into. Cached so successive calls at same composition are fast. """ c = self.pd_coords(comp) for f, s in zip(self.facets, self.simplexes): if s.in_simplex(c, PhaseDiagram.numeric...
Calculates the chemical potentials for each element within a facet.
def _get_facet_chempots(self, facet): """ Calculates the chemical potentials for each element within a facet. Args: facet: Facet of the phase diagram. Returns: { element: chempot } for all elements in the phase diagram. """ complist = [self.qhull...
Provides the decomposition at a particular composition.
def get_decomposition(self, comp): """ Provides the decomposition at a particular composition. Args: comp: A composition Returns: Decomposition as a dict of {Entry: amount} """ facet, simplex = self._get_facet_and_simplex(comp) decomp_amt...
Args: comp ( Composition ): Input composition
def get_hull_energy(self, comp): """ Args: comp (Composition): Input composition Returns: Energy of lowest energy equilibrium at desired composition. Not normalized by atoms, i.e. E(Li4O2) = 2 * E(Li2O) """ e = 0 for k, v in self.get_d...
Provides the decomposition and energy above convex hull for an entry. Due to caching can be much faster if entries with the same composition are processed together.
def get_decomp_and_e_above_hull(self, entry, allow_negative=False): """ Provides the decomposition and energy above convex hull for an entry. Due to caching, can be much faster if entries with the same composition are processed together. Args: entry: A PDEntry like o...
Provides the reaction energy of a stable entry from the neighboring equilibrium stable entries ( also known as the inverse distance to hull ).
def get_equilibrium_reaction_energy(self, entry): """ Provides the reaction energy of a stable entry from the neighboring equilibrium stable entries (also known as the inverse distance to hull). Args: entry: A PDEntry like object Returns: Equilib...
Get the critical chemical potentials for an element in the Phase Diagram.
def get_transition_chempots(self, element): """ Get the critical chemical potentials for an element in the Phase Diagram. Args: element: An element. Has to be in the PD in the first place. Returns: A sorted sequence of critical chemical potentials, from ...
Get the critical compositions along the tieline between two compositions. I. e. where the decomposition products change. The endpoints are also returned. Args: comp1 comp2 ( Composition ): compositions that define the tieline Returns: [ ( Composition ) ]: list of critical compositions. All are of the form x * comp1 + (...
def get_critical_compositions(self, comp1, comp2): """ Get the critical compositions along the tieline between two compositions. I.e. where the decomposition products change. The endpoints are also returned. Args: comp1, comp2 (Composition): compositions that define t...
Provides the element evolution data for a composition. For example can be used to analyze Li conversion voltages by varying uLi and looking at the phases formed. Also can be used to analyze O2 evolution by varying uO2.
def get_element_profile(self, element, comp, comp_tol=1e-5): """ Provides the element evolution data for a composition. For example, can be used to analyze Li conversion voltages by varying uLi and looking at the phases formed. Also can be used to analyze O2 evolution by varying ...
Returns a chemical potential range map for each stable entry.
def get_chempot_range_map(self, elements, referenced=True, joggle=True): """ Returns a chemical potential range map for each stable entry. Args: elements: Sequence of elements to be considered as independent variables. E.g., if you want to show the stability ranges ...
returns a set of chemical potentials corresponding to the vertices of the simplex in the chemical potential phase diagram. The simplex is built using all elements in the target_composition except dep_elt. The chemical potential of dep_elt is computed from the target composition energy. This method is useful to get the ...
def getmu_vertices_stability_phase(self, target_comp, dep_elt, tol_en=1e-2): """ returns a set of chemical potentials corresponding to the vertices of the simplex in the chemical potential phase diagram. The simplex is built using all elements in the target_composition except dep...
returns a set of chemical potentials corresponding to the max and min chemical potential of the open element for a given composition. It is quite common to have for instance a ternary oxide ( e. g. ABO3 ) for which you want to know what are the A and B chemical potential leading to the highest and lowest oxygen chemica...
def get_chempot_range_stability_phase(self, target_comp, open_elt): """ returns a set of chemical potentials corresponding to the max and min chemical potential of the open element for a given composition. It is quite common to have for instance a ternary oxide (e.g., ABO3) for w...
Method to transform all entries to the composition coordinate in the terminal compositions. If the entry does not fall within the space defined by the terminal compositions they are excluded. For example Li3PO4 is mapped into a Li2O: 1. 5 P2O5: 0. 5 composition. The terminal compositions are represented by DummySpecies...
def transform_entries(self, entries, terminal_compositions): """ Method to transform all entries to the composition coordinate in the terminal compositions. If the entry does not fall within the space defined by the terminal compositions, they are excluded. For example, Li3PO4 is...
Get the CompoundPhaseDiagram object which can then be used for plotting.
def get_compound_pd(self): """ Get the CompoundPhaseDiagram object, which can then be used for plotting. Returns: (CompoundPhaseDiagram) """ # For this plot, since the reactions are reported in formation # energies, we need to set the energies of the ...
Plot data for phase diagram. 2 - comp - Full hull with energies 3/ 4 - comp - Projection into 2D or 3D Gibbs triangle.
def pd_plot_data(self): """ Plot data for phase diagram. 2-comp - Full hull with energies 3/4-comp - Projection into 2D or 3D Gibbs triangle. Returns: (lines, stable_entries, unstable_entries): - lines is a list of list of coordinates for lines in the PD....
Draw the element profile plot for a composition varying different chemical potential of an element. X value is the negative value of the chemical potential reference to elemental chemical potential. For example if choose Element ( Li ) X = - ( µLi - µLi0 ) which corresponds to the voltage versus metal anode. Y values r...
def plot_element_profile(self, element, comp, show_label_index=None, xlim=5): """ Draw the element profile plot for a composition varying different chemical potential of an element. X value is the negative value of the chemical potential reference to ...
Shows the plot using pylab. Usually I won t do imports in methods but since plotting is a fairly expensive library to load and not all machines have matplotlib installed I have done it this way.
def _get_2d_plot(self, label_stable=True, label_unstable=True, ordering=None, energy_colormap=None, vmin_mev=-60.0, vmax_mev=60.0, show_colorbar=True, process_attributes=False, plt=None): """ Shows the plot using pylab. Usually I won't do i...
Shows the plot using pylab. Usually I won t do imports in methods but since plotting is a fairly expensive library to load and not all machines have matplotlib installed I have done it this way.
def _get_3d_plot(self, label_stable=True): """ Shows the plot using pylab. Usually I won"t do imports in methods, but since plotting is a fairly expensive library to load and not all machines have matplotlib installed, I have done it this way. """ import matplotlib.pyplo...
Writes the phase diagram to an image in a stream.
def write_image(self, stream, image_format="svg", **kwargs): """ Writes the phase diagram to an image in a stream. Args: stream: stream to write to. Can be a file stream or a StringIO stream. image_format format for image. Can be any of ma...
Plot the chemical potential range _map. Currently works only for 3 - component PDs.
def plot_chempot_range_map(self, elements, referenced=True): """ Plot the chemical potential range _map. Currently works only for 3-component PDs. Args: elements: Sequence of elements to be considered as independent variables. E.g., if you want to show the st...
Returns a plot of the chemical potential range _map. Currently works only for 3 - component PDs.
def get_chempot_range_map_plot(self, elements, referenced=True): """ Returns a plot of the chemical potential range _map. Currently works only for 3-component PDs. Args: elements: Sequence of elements to be considered as independent variables. E.g., if you wa...
Plot a contour phase diagram plot where phase triangles are colored according to degree of instability by interpolation. Currently only works for 3 - component phase diagrams.
def get_contour_pd_plot(self): """ Plot a contour phase diagram plot, where phase triangles are colored according to degree of instability by interpolation. Currently only works for 3-component phase diagrams. Returns: A matplotlib plot object. """ fr...
Returns all input files as a dict of { filename: feffio object }
def all_input(self): """ Returns all input files as a dict of {filename: feffio object} """ d = {"HEADER": self.header(), "PARAMETERS": self.tags} if "RECIPROCAL" not in self.tags: d.update({"POTENTIALS": self.potential, "ATOMS": self.atoms}) return d
Writes a set of FEFF input to a directory.
def write_input(self, output_dir=".", make_dir_if_not_present=True): """ Writes a set of FEFF input to a directory. Args: output_dir: Directory to output the FEFF input files make_dir_if_not_present: Set to True if you want the directory ( and the whole p...
FEFF job parameters.
def tags(self): """ FEFF job parameters. Returns: Tags """ if "RECIPROCAL" in self.config_dict: if self.small_system: self.config_dict["CIF"] = "{}.cif".format( self.structure.formula.replace(" ", "")) s...
Read in a set of FEFF input files from a directory which is useful when existing FEFF input needs some adjustment.
def from_directory(input_dir): """ Read in a set of FEFF input files from a directory, which is useful when existing FEFF input needs some adjustment. """ sub_d = {} for fname, ftype in [("HEADER", Header), ("PARAMETERS", Tags)]: fullzpath = zpath(os.path.join...
Method that compares two functions
def function_comparison(f1, f2, x1, x2, numpoints_check=500): """ Method that compares two functions Args: f1: First function to compare f2: Second function to compare x1: Lower bound of the interval to compare x2: Upper bound of the interval to compa...
Method that creates two quarter - ellipse functions based on points xx and yy. The ellipsis is supposed to be aligned with the axes. The two ellipsis pass through the two points xx and yy.
def quarter_ellipsis_functions(xx, yy): """ Method that creates two quarter-ellipse functions based on points xx and yy. The ellipsis is supposed to be aligned with the axes. The two ellipsis pass through the two points xx and yy. Args: xx: First point yy: Second...
Method that creates two ( upper and lower ) spline functions based on points lower_points and upper_points.
def spline_functions(lower_points, upper_points, degree=3): """ Method that creates two (upper and lower) spline functions based on points lower_points and upper_points. Args: lower_points: Points defining the lower function. upper_points: Points defining the upper f...
Method that creates two upper and lower functions based on points xx and yy as well as intercepts defined by y_x0 and x_y0. The resulting functions form kind of a distorted diamond - like structure aligned from point xx to point yy.
def diamond_functions(xx, yy, y_x0, x_y0): """ Method that creates two upper and lower functions based on points xx and yy as well as intercepts defined by y_x0 and x_y0. The resulting functions form kind of a distorted diamond-like structure aligned from point xx to point yy. Schematically : ...
Method to calculate the surface of the intersection of a rectangle ( aligned with axes ) and another surface defined by two functions f_lower and f_upper.
def rectangle_surface_intersection(rectangle, f_lower, f_upper, bounds_lower=None, bounds_upper=None, check=True, numpoints_check=500): """ Method to calculate the surface of the intersection of a rectangle (aligned with axes) and another sur...
Helper method to calculate the solid angle of a set of coords from the center.
def my_solid_angle(center, coords): """ Helper method to calculate the solid angle of a set of coords from the center. Args: center: Center to measure solid angle from. coords: List of coords to determine solid angle. Returns: The solid angle. ""...
Performs the vector multiplication of the elements of two vectors constructing the 3x3 matrix.: param aa: One vector of size 3: param bb: Another vector of size 3: return: A 3x3 matrix M composed of the products of the elements of aa and bb: M_ij = aa_i * bb_j
def vectorsToMatrix(aa, bb): """ Performs the vector multiplication of the elements of two vectors, constructing the 3x3 matrix. :param aa: One vector of size 3 :param bb: Another vector of size 3 :return: A 3x3 matrix M composed of the products of the elements of aa and bb : M_ij = aa_i * bb_j...
Rotate the list of points using rotation matrix R: param coords: List of points to be rotated: param R: Rotation matrix: return: List of rotated points
def rotateCoords(coords, R): """ Rotate the list of points using rotation matrix R :param coords: List of points to be rotated :param R: Rotation matrix :return: List of rotated points """ newlist = list() for pp in coords: rpp = matrixTimesVector(R, pp) newlist.append(rp...
For a list of points given in standard coordinates ( in terms of e1 e2 and e3 ) returns the same list expressed in the basis ( uu vv nn ) which is supposed to be orthonormal.: param uu: First vector of the basis: param vv: Second vector of the basis: param nn: Third vector of the bais: param pps: List of points in basi...
def changebasis(uu, vv, nn, pps): """ For a list of points given in standard coordinates (in terms of e1, e2 and e3), returns the same list expressed in the basis (uu, vv, nn), which is supposed to be orthonormal. :param uu: First vector of the basis :param vv: Second vector of the basis :param ...
Checks if the three points p1 p2 and p3 are collinear or not within a given tolerance. The collinearity is checked by computing the area of the triangle defined by the three points p1 p2 and p3. If the area of this triangle is less than ( tolerance x largest_triangle ) then the three points are considered collinear. Th...
def collinear(p1, p2, p3=None, tolerance=0.25): """ Checks if the three points p1, p2 and p3 are collinear or not within a given tolerance. The collinearity is checked by computing the area of the triangle defined by the three points p1, p2 and p3. If the area of this triangle is less than (tolerance x ...
Sort a list of 2D points in anticlockwise order: param pps: List of points to be sorted: return: Sorted list of points
def anticlockwise_sort(pps): """ Sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Sorted list of points """ newpps = list() angles = np.zeros(len(pps), np.float) for ipp, pp in enumerate(pps): angles[ipp] = np.arctan2(pp[1], pp[0]) ...
Returns the indices that would sort a list of 2D points in anticlockwise order: param pps: List of points to be sorted: return: Indices of the sorted list of points
def anticlockwise_sort_indices(pps): """ Returns the indices that would sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Indices of the sorted list of points """ angles = np.zeros(len(pps), np.float) for ipp, pp in enumerate(pps): angle...
Checks if the separation indices of a plane are already in the list: param separation_indices: list of separation indices ( three arrays of integers ): param separation_indices_list: list of the list of separation indices to be compared to: return: True if the separation indices are already in the list False otherwise
def separation_in_list(separation_indices, separation_indices_list): """ Checks if the separation indices of a plane are already in the list :param separation_indices: list of separation indices (three arrays of integers) :param separation_indices_list: list of the list of separation indices to be compa...
Checks if two given sites are an anion and a cation.: param valences: list of site valences: param ii: index of a site: param jj: index of another site: return: True if one site is an anion and the other is a cation ( from the valences )
def is_anion_cation_bond(valences, ii, jj): """ Checks if two given sites are an anion and a cation. :param valences: list of site valences :param ii: index of a site :param jj: index of another site :return: True if one site is an anion and the other is a cation (from the valences) """ ...
Determines if point pp is in the plane within the tolerance dist_tolerance: param pp: point to be tested: param dist_tolerance: tolerance on the distance to the plane within which point pp is considered in the plane: return: True if pp is in the plane False otherwise
def is_in_plane(self, pp, dist_tolerance): """ Determines if point pp is in the plane within the tolerance dist_tolerance :param pp: point to be tested :param dist_tolerance: tolerance on the distance to the plane within which point pp is considered in the plane :return: True if ...