INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
An internal method to get a "default" covalent/element radius Args: site: (Site) Returns: Covalent radius of element on site, or Atomic radius if unavailable
def _get_default_radius(site): """ An internal method to get a "default" covalent/element radius Args: site: (Site) Returns: Covalent radius of element on site, or Atomic radius if unavailable """ try: return CovalentRadius.radius[sit...
An internal method to get the expected radius for a site with oxidation state. Args: site: (Site) Returns: Oxidation-state dependent radius: ionic, covalent, or atomic. Returns 0 if no oxidation state or appropriate radius is found.
def _get_radius(site): """ An internal method to get the expected radius for a site with oxidation state. Args: site: (Site) Returns: Oxidation-state dependent radius: ionic, covalent, or atomic. Returns 0 if no oxidation state or appropriate ...
Given NNData, transforms data to the specified fingerprint length Args: nndata: (NNData) length: (int) desired length of NNData
def transform_to_length(nndata, length): """ Given NNData, transforms data to the specified fingerprint length Args: nndata: (NNData) length: (int) desired length of NNData """ if length is None: return nndata if length: f...
Initialise a CutOffDictNN according to a preset set of cut-offs. Args: preset (str): A preset name. The list of supported presets are: - "vesta_2019": The distance cut-offs used by the VESTA visualisation program. Returns: A CutOffDictNN using...
def from_preset(preset): """ Initialise a CutOffDictNN according to a preset set of cut-offs. Args: preset (str): A preset name. The list of supported presets are: - "vesta_2019": The distance cut-offs used by the VESTA visualisation program. ...
Returns a structure in mcsqs rndstr.in format. :return (str):
def to_string(self): """ Returns a structure in mcsqs rndstr.in format. :return (str): """ # define coord system, use Cartesian output = ["1.0 0.0 0.0", "0.0 1.0 0.0", "0.0 0.0 1.0"] # add lattice vectors m = self.struct...
Parses a rndstr.in or lat.in file into pymatgen's Structure format. :param data: contents of a rndstr.in or lat.in file :return: Structure object
def structure_from_string(data): """ Parses a rndstr.in or lat.in file into pymatgen's Structure format. :param data: contents of a rndstr.in or lat.in file :return: Structure object """ data = data.splitlines() data = [x.split() for x in data if x] # r...
Analyze the void space in the input structure using voronoi decomposition Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elements in structure. If not given, Zeo++ default values are used. ...
def get_voronoi_nodes(structure, rad_dict=None, probe_rad=0.1): """ Analyze the void space in the input structure using voronoi decomposition Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elements in...
Analyze the void space in the input structure using high accuracy voronoi decomposition. Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elements in structure. If not given, Zeo++ default value...
def get_high_accuracy_voronoi_nodes(structure, rad_dict, probe_rad=0.1): """ Analyze the void space in the input structure using high accuracy voronoi decomposition. Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictio...
Analyze the void space in the input structure using voronoi decomposition Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elements in structure. If not given, Zeo++ default values are used. ...
def get_free_sphere_params(structure, rad_dict=None, probe_rad=0.1): """ Analyze the void space in the input structure using voronoi decomposition Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elemen...
Computes the volume and surface area of isolated void using Zeo++. Useful to compute the volume and surface area of vacant site. Args: structure: pymatgen Structure containing vacancy rad_dict(optional): Dictionary with short name of elements and their radii. chan_rad(option...
def get_void_volume_surfarea(structure, rad_dict=None, chan_rad=0.3, probe_rad=0.1): """ Computes the volume and surface area of isolated void using Zeo++. Useful to compute the volume and surface area of vacant site. Args: structure: pymatgen Structure containing v...
Reads a string representation to a ZeoCssr object. Args: string: A string representation of a ZeoCSSR. Returns: ZeoCssr object.
def from_string(string): """ Reads a string representation to a ZeoCssr object. Args: string: A string representation of a ZeoCSSR. Returns: ZeoCssr object. """ lines = string.split("\n") toks = lines[0].split() lengths = [float(i...
Creates Zeo++ Voronoi XYZ object from a string. from_string method of XYZ class is being redefined. Args: contents: String representing Zeo++ Voronoi XYZ file. Returns: ZeoVoronoiXYZ object
def from_string(contents): """ Creates Zeo++ Voronoi XYZ object from a string. from_string method of XYZ class is being redefined. Args: contents: String representing Zeo++ Voronoi XYZ file. Returns: ZeoVoronoiXYZ object """ lines = conte...
:param velocities (au): list of list of atom velocities :return:
def set_velocities(self, velocities): """ :param velocities (au): list of list of atom velocities :return: """ assert len(velocities) == len(self.mol) self.params["velocity"] = velocities
Set the maxium allowed memory. Args: total: The total memory. Integer. Unit: MBytes. If set to None, this parameter will be neglected. static: The static memory. Integer. Unit MBytes. If set to None, this parameterwill be neglected.
def set_memory(self, total=None, static=None): """ Set the maxium allowed memory. Args: total: The total memory. Integer. Unit: MBytes. If set to None, this parameter will be neglected. static: The static memory. Integer. Unit MBytes. If set to None, ...
Set algorithm used for converging SCF and max number of SCF iterations. Args: algorithm: The algorithm used for converging SCF. (str) iterations: The max number of SCF iterations. (Integer)
def set_scf_algorithm_and_iterations(self, algorithm="diis", iterations=50): """ Set algorithm used for converging SCF and max number of SCF iterations. Args: algorithm: The algorithm used for converging SCF. (str) iterations: The...
Set the grid for DFT numerical integrations. Args: radical_points: Radical points. (Integer) angular_points: Angular points. (Integer) grid_type: The type of of the grid. There are two standard grids: SG-1 and SG-0. The other two supported grids are "Lebedev"...
def set_dft_grid(self, radical_points=128, angular_points=302, grid_type="Lebedev"): """ Set the grid for DFT numerical integrations. Args: radical_points: Radical points. (Integer) angular_points: Angular points. (Integer) grid_type: The...
Set initial guess method to be used for SCF Args: guess: The initial guess method. (str)
def set_scf_initial_guess(self, guess="SAD"): """ Set initial guess method to be used for SCF Args: guess: The initial guess method. (str) """ availabel_guesses = {"core", "sad", "gwh", "read", "fragmo"} if guess.lower() not in availabel_guesses: ...
Set the coordinates system used in geometry optimization. "cartesian" --- always cartesian coordinates. "internal" --- always internal coordinates. "internal-switch" --- try internal coordinates first, if fails, switch to cartesian coordinates. "z-matrix" --- ...
def set_geom_opt_coords_type(self, coords_type="internal_switch"): """ Set the coordinates system used in geometry optimization. "cartesian" --- always cartesian coordinates. "internal" --- always internal coordinates. "internal-switch" --- try internal coordinates f...
Adjust the convergence criteria of geometry optimization. Args: gradient: the scale factor for gradient criteria. If less than 1.0, you are tightening the threshold. The base value is 300 × 10E−6 displacement: the scale factor for atomic displacement. If ...
def scale_geom_opt_threshold(self, gradient=0.1, displacement=0.1, energy=0.1): """ Adjust the convergence criteria of geometry optimization. Args: gradient: the scale factor for gradient criteria. If less than 1.0, you are tightening...
Set the solvent model to PCM. Default parameters are trying to comply to gaussian default value Args: pcm_params (dict): The parameters of "$pcm" section. solvent_key (str): for versions < 4.2 the section name is "pcm_solvent" solvent_params (dict): The parameters of...
def use_pcm(self, pcm_params=None, solvent_key="solvent", solvent_params=None, radii_force_field=None): """ Set the solvent model to PCM. Default parameters are trying to comply to gaussian default value Args: pcm_params (dict): The parameters of "$pcm" secti...
Creates QcInput from a string. Args: contents: String representing a QChem input file. Returns: QcInput object
def from_string(cls, contents): """ Creates QcInput from a string. Args: contents: String representing a QChem input file. Returns: QcInput object """ mol = None charge = None spin_multiplicity = None params = dict() ...
Calculates 'magnetic deformation proxy', a measure of deformation (norm of finite strain) between 'non-magnetic' (non-spin-polarized) and ferromagnetic structures. Adapted from Bocarsly et al. 2017, doi: 10.1021/acs.chemmater.6b04729 :param structure_A: Structure :param structure_B: Struct...
def magnetic_deformation(structure_A, structure_B): """ Calculates 'magnetic deformation proxy', a measure of deformation (norm of finite strain) between 'non-magnetic' (non-spin-polarized) and ferromagnetic structures. Adapted from Bocarsly et al. 2017, doi: 10.1021/acs.chemmater.6b04729 ...
If round_magmoms_mode is an integer, simply round to that number of decimal places, else if set to a float will try and round intelligently by grouping magmoms.
def _round_magmoms(magmoms, round_magmoms_mode: Union[int, float]): """ If round_magmoms_mode is an integer, simply round to that number of decimal places, else if set to a float will try and round intelligently by grouping magmoms. """ if isinstance(round_magmoms_mode, ...
Returns a Structure with species decorated with spin values instead of using magmom site properties. :return: Structure
def get_structure_with_spin(self): """ Returns a Structure with species decorated with spin values instead of using magmom site properties. :return: Structure """ structure = self.structure.copy() structure.add_spin_by_site(structure.site_properties["magmom"]) ...
Returns a Structure with only magnetic atoms present. :return: Structure
def get_structure_with_only_magnetic_atoms(self, make_primitive=True): """ Returns a Structure with only magnetic atoms present. :return: Structure """ sites = [site for site in self.structure if abs(site.properties["magmom"]) > 0] structure = Structure.from_sites(sites...
Returns a Structure without magnetic moments defined. :param make_primitive (bool): Return a primitive structure, defaults to True. :return: Structure
def get_nonmagnetic_structure(self, make_primitive=True): """ Returns a Structure without magnetic moments defined. :param make_primitive (bool): Return a primitive structure, defaults to True. :return: Structure """ structure = self.structure.copy() stru...
Returns a Structure with all magnetic moments positive or zero. :param make_primitive (bool): Return a primitive structure, defaults to True. :return: Structure
def get_ferromagnetic_structure(self, make_primitive=True): """ Returns a Structure with all magnetic moments positive or zero. :param make_primitive (bool): Return a primitive structure, defaults to True. :return: Structure """ structure = self.structure...
Returns a dict of magnetic species and the magnitude of their associated magmoms. Will return a set if there are multiple magmoms per species. :return: dict of magnetic species and magmoms
def magnetic_species_and_magmoms(self): """ Returns a dict of magnetic species and the magnitude of their associated magmoms. Will return a set if there are multiple magmoms per species. :return: dict of magnetic species and magmoms """ structure = self.get_ferr...
:param symprec (float): same as in SpacegroupAnalyzer :param angle_tolerance (float): same as in SpacegroupAnalyzer :return (int): Number of symmetrically-distinct magnetic sites present in structure.
def number_of_unique_magnetic_sites(self, symprec=1e-3, angle_tolerance=5): """ :param symprec (float): same as in SpacegroupAnalyzer :param angle_tolerance (float): same as in SpacegroupAnalyzer :return (int): Number of symmetrically-distinct magnetic sites present in structure....
Applies heuristics to return a magnetic ordering for a collinear magnetic structure. Result is not guaranteed for correctness. :return: Ordering Enum ('FiM' is used as the abbreviation for ferrimagnetic)
def ordering(self): """ Applies heuristics to return a magnetic ordering for a collinear magnetic structure. Result is not guaranteed for correctness. :return: Ordering Enum ('FiM' is used as the abbreviation for ferrimagnetic) """ if not self.is_collinear: ...
Returns the information on the symmetry of the Hamiltonian describing the exchange energy of the system, taking into account relative direction of magnetic moments but not their absolute direction. This is not strictly accurate (e.g. some/many atoms will have zero magnetic momen...
def get_exchange_group_info(self, symprec=1e-2, angle_tolerance=5.0): """ Returns the information on the symmetry of the Hamiltonian describing the exchange energy of the system, taking into account relative direction of magnetic moments but not their absolute direction. ...
Compares the magnetic orderings of one structure with another. :param other: Structure :return (bool):
def matches_ordering(self, other): """ Compares the magnetic orderings of one structure with another. :param other: Structure :return (bool): """ a = CollinearMagneticStructureAnalyzer( self.structure, overwrite_magmom_mode="normalize" ).get_structure...
Sanitize our input structure by removing magnetic information and making primitive. Args: input_structure: Structure Returns: Structure
def _sanitize_input_structure(input_structure): """ Sanitize our input structure by removing magnetic information and making primitive. Args: input_structure: Structure Returns: Structure """ input_structure = input_structure.copy() # remov...
The central problem with trying to enumerate magnetic orderings is that we have to enumerate orderings that might plausibly be magnetic ground states, while not enumerating orderings that are physically implausible. The problem is that it is not always obvious by e.g. symmetry arguments ...
def _generate_transformations(self, structure): """ The central problem with trying to enumerate magnetic orderings is that we have to enumerate orderings that might plausibly be magnetic ground states, while not enumerating orderings that are physically implausible. The problem ...
Apply our input structure to our list of transformations and output a list of ordered structures that have been pruned for duplicates and for those with low symmetry (optional). Args: sanitized_input_structure: A sanitized input structure (_sanitize_input_structure) ...
def _generate_ordered_structures(self, sanitized_input_structure, transformations): """ Apply our input structure to our list of transformations and output a list of ordered structures that have been pruned for duplicates and for those with low symmetry (optional). Args: ...
Remove uncertainty brackets from strings and return the float.
def str2float(text): """ Remove uncertainty brackets from strings and return the float. """ try: # Note that the ending ) is sometimes missing. That is why the code has # been modified to treat it as optional. Same logic applies to lists. return float(re.sub(r"\(.+\)*", "", text...
Some CIF files do not conform to spec. This function corrects known issues, particular in regards to Springer materials/ Pauling files. This function is here so that CifParser can assume its input conforms to spec, simplifying its implementation. :param data: CifBlock :r...
def _sanitize_data(self, data): """ Some CIF files do not conform to spec. This function corrects known issues, particular in regards to Springer materials/ Pauling files. This function is here so that CifParser can assume its input conforms to spec, simplifying its impl...
Generate unique coordinates using coord and symmetry positions and also their corresponding magnetic moments, if supplied.
def _unique_coords(self, coords_in, magmoms_in=None, lattice=None): """ Generate unique coordinates using coord and symmetry positions and also their corresponding magnetic moments, if supplied. """ coords = [] if magmoms_in: magmoms = [] if len(ma...
Generate the lattice from the provided lattice parameters. In the absence of all six lattice parameters, the crystal system and necessary parameters are parsed
def get_lattice(self, data, length_strings=("a", "b", "c"), angle_strings=("alpha", "beta", "gamma"), lattice_type=None): """ Generate the lattice from the provided lattice parameters. In the absence of all six lattice parameters, the crystal system ...
In order to generate symmetry equivalent positions, the symmetry operations are parsed. If the symops are not present, the space group symbol is parsed, and symops are generated.
def get_symops(self, data): """ In order to generate symmetry equivalent positions, the symmetry operations are parsed. If the symops are not present, the space group symbol is parsed, and symops are generated. """ symops = [] for symmetry_label in ["_symmetry_equ...
Equivalent to get_symops except for magnetic symmetry groups. Separate function since additional operation for time reversal symmetry (which changes magnetic moments on sites) needs to be returned.
def get_magsymops(self, data): """ Equivalent to get_symops except for magnetic symmetry groups. Separate function since additional operation for time reversal symmetry (which changes magnetic moments on sites) needs to be returned. """ magsymmops = [] # check to...
Parse oxidation states from data dictionary
def parse_oxi_states(self, data): """ Parse oxidation states from data dictionary """ try: oxi_states = { data["_atom_type_symbol"][i]: str2float(data["_atom_type_oxidation_number"][i]) for i in range(len(data["_atom_type_sy...
Parse atomic magnetic moments from data dictionary
def parse_magmoms(self, data, lattice=None): """ Parse atomic magnetic moments from data dictionary """ if lattice is None: raise Exception( 'Magmoms given in terms of crystal axes in magCIF spec.') try: magmoms = { data["_a...
Parse a string with a symbol to extract a string representing an element. Args: sym (str): A symbol to be parsed. Returns: A string with the parsed symbol. None if no parsing was possible.
def _parse_symbol(self, sym): """ Parse a string with a symbol to extract a string representing an element. Args: sym (str): A symbol to be parsed. Returns: A string with the parsed symbol. None if no parsing was possible. """ # Common representa...
Generate structure from part of the cif.
def _get_structure(self, data, primitive): """ Generate structure from part of the cif. """ def get_num_implicit_hydrogens(sym): num_h = {"Wat": 2, "wat": 2, "O-H": 1} return num_h.get(sym[:3], 0) lattice = self.get_lattice(data) # if magCIF, ge...
Return list of structures in CIF file. primitive boolean sets whether a conventional cell structure or primitive cell structure is returned. Args: primitive (bool): Set to False to return conventional unit cells. Defaults to True. With magnetic CIF files, will return primiti...
def get_structures(self, primitive=True): """ Return list of structures in CIF file. primitive boolean sets whether a conventional cell structure or primitive cell structure is returned. Args: primitive (bool): Set to False to return conventional unit cells. ...
Get BibTeX reference from CIF file. :param data: :return: BibTeX string
def get_bibtex_string(self): """ Get BibTeX reference from CIF file. :param data: :return: BibTeX string """ bibtex_keys = {'author': ('_publ_author_name', '_citation_author_name'), 'title': ('_publ_section_title', '_citation_title'), ...
Converts a list of SlabEntry to an appropriate dictionary. It is assumed that if there is no adsorbate, then it is a clean SlabEntry and that adsorbed SlabEntry has the clean_entry parameter set. Args: all_slab_entries (list): List of SlabEntry objects Returns: (dict): Dictionary of Sl...
def entry_dict_from_list(all_slab_entries): """ Converts a list of SlabEntry to an appropriate dictionary. It is assumed that if there is no adsorbate, then it is a clean SlabEntry and that adsorbed SlabEntry has the clean_entry parameter set. Args: all_slab_entries (list): List of SlabEntr...
Uses dot product of numpy array to sub chemical potentials into the surface grand potential. This is much faster than using the subs function in sympy. Args: gamma_dict (dict): Surface grand potential equation as a coefficient dictionary chempots (dict): Dictionary assign...
def sub_chempots(gamma_dict, chempots): """ Uses dot product of numpy array to sub chemical potentials into the surface grand potential. This is much faster than using the subs function in sympy. Args: gamma_dict (dict): Surface grand potential equation as a coefficient d...
Returns dict which contains Slab Entry data.
def as_dict(self): """ Returns dict which contains Slab Entry data. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__} d["structure"] = self.structure d["energy"] = self.energy d["miller_index"] = self.miller_index ...
Returns the adsorption energy or Gibb's binding energy of an adsorbate on a surface Args: eads (bool): Whether to calculate the adsorption energy (True) or the binding energy (False) which is just adsorption energy normalized by number of adsorbates.
def gibbs_binding_energy(self, eads=False): """ Returns the adsorption energy or Gibb's binding energy of an adsorbate on a surface Args: eads (bool): Whether to calculate the adsorption energy (True) or the binding energy (False) which is just ...
Calculates the surface energy of this SlabEntry. Args: ucell_entry (entry): An entry object for the bulk ref_entries (list: [entry]): A list of entries for each type of element to be used as a reservoir for nonstoichiometric systems. The length of this lis...
def surface_energy(self, ucell_entry, ref_entries=None): """ Calculates the surface energy of this SlabEntry. Args: ucell_entry (entry): An entry object for the bulk ref_entries (list: [entry]): A list of entries for each type of element to be used as a re...
Returns the surface area of the adsorbed system per unit area of the primitive slab system.
def get_unit_primitive_area(self): """ Returns the surface area of the adsorbed system per unit area of the primitive slab system. """ A_ads = self.surface_area A_clean = self.clean_entry.surface_area n = (A_ads / A_clean) return n
Returns the primitive unit surface area density of the adsorbate.
def get_monolayer(self): """ Returns the primitive unit surface area density of the adsorbate. """ unit_a = self.get_unit_primitive_area Nsurfs = self.Nsurfs_ads_in_slab Nads = self.Nads_in_slab return Nads / (unit_a * Nsurfs)
Returns the TOTAL number of adsorbates in the slab on BOTH sides
def Nads_in_slab(self): """ Returns the TOTAL number of adsorbates in the slab on BOTH sides """ return sum([self.composition.as_dict()[a] for a \ in self.ads_entries_dict.keys()])
Returns the TOTAL number of adsorbed surfaces in the slab
def Nsurfs_ads_in_slab(self): """ Returns the TOTAL number of adsorbed surfaces in the slab """ struct = self.structure weights = [s.species.weight for s in struct] center_of_mass = np.average(struct.frac_coords, weights=weights, axis=...
Returns a SlabEntry by reading in an dictionary
def from_dict(cls, d): """ Returns a SlabEntry by reading in an dictionary """ structure = SlabEntry.from_dict(d["structure"]) energy = SlabEntry.from_dict(d["energy"]) miller_index = d["miller_index"] label = d["label"] coverage = d["coverage"] a...
Returns a slab with the adsorbates removed
def cleaned_up_slab(self): """ Returns a slab with the adsorbates removed """ ads_strs = list(self.ads_entries_dict.keys()) cleaned = self.structure.copy() cleaned.remove_species(ads_strs) return cleaned
Returns a label (str) for this particular slab based on composition, coverage and Miller index.
def create_slab_label(self): """ Returns a label (str) for this particular slab based on composition, coverage and Miller index. """ if "label" in self.data.keys(): return self.data["label"] label = str(self.miller_index) ads_strs = list(self.ads...
Returns SlabEntry from a ComputedStructureEntry
def from_computed_structure_entry(entry, miller_index, label=None, adsorbates=None, clean_entry=None, **kwargs): """ Returns SlabEntry from a ComputedStructureEntry """ return SlabEntry(entry.structure, entry.energy, miller_index, label=label, ...
Returns the entry corresponding to the most stable slab for a particular facet at a specific chempot. We assume that surface energy is constant so all free variables must be set with delu_dict, otherwise they are assumed to be equal to delu_default. Args: miller_...
def get_stable_entry_at_u(self, miller_index, delu_dict=None, delu_default=0, no_doped=False, no_clean=False): """ Returns the entry corresponding to the most stable slab for a particular facet at a specific chempot. We assume that surface energy is constant ...
Method to get the Wulff shape at a specific chemical potential. Args: delu_dict (Dict): Dictionary of the chemical potentials to be set as constant. Note the key should be a sympy Symbol object of the format: Symbol("delu_el") where el is the name of the element. ...
def wulff_from_chempot(self, delu_dict=None, delu_default=0, symprec=1e-5, no_clean=False, no_doped=False): """ Method to get the Wulff shape at a specific chemical potential. Args: delu_dict (Dict): Dictionary of the chemical potentials to be set as ...
Takes in a list of SlabEntries and calculates the chemical potentials at which all slabs in the list coexists simultaneously. Useful for building surface phase diagrams. Note that to solve for x equations (x slab_entries), there must be x free variables (chemical potentials). ...
def get_surface_equilibrium(self, slab_entries, delu_dict=None): """ Takes in a list of SlabEntries and calculates the chemical potentials at which all slabs in the list coexists simultaneously. Useful for building surface phase diagrams. Note that to solve for x equations ...
Creates a dictionary where each entry is a key pointing to a chemical potential range where the surface of that entry is stable. Does so by enumerating through all possible solutions (intersect) for surface energies of a specific facet. Args: chempot_range ([max_chempot, min...
def stable_u_range_dict(self, chempot_range, ref_delu, no_doped=True, no_clean=False, delu_dict={}, miller_index=(), dmu_at_0=False, return_se_dict=False): """ Creates a dictionary where each entry is a key pointing to a chemical potential ...
Helper function to assign each facet a unique color using a dictionary. Args: alpha (float): Degree of transparency return (dict): Dictionary of colors (r,g,b,a) when plotting surface energy stability. The keys are individual surface entries where clean surfaces hav...
def color_palette_dict(self, alpha=0.35): """ Helper function to assign each facet a unique color using a dictionary. Args: alpha (float): Degree of transparency return (dict): Dictionary of colors (r,g,b,a) when plotting surface energy stability. The keys are i...
Helper function to help plot the surface energy of a single SlabEntry as a function of chemical potential. Args: plt (Plot): A plot. entry (SlabEntry): Entry of the slab whose surface energy we want to plot ref_delu (sympy Symbol): The range stabilit...
def chempot_vs_gamma_plot_one(self, plt, entry, ref_delu, chempot_range, delu_dict={}, delu_default=0, label='', JPERM2=False): """ Helper function to help plot the surface energy of a single SlabEntry as a function of chemical potential. Args: ...
Plots the surface energy as a function of chemical potential. Each facet will be associated with its own distinct colors. Dashed lines will represent stoichiometries different from that of the mpid's compound. Transparent lines indicates adsorption. Args: ref_del...
def chempot_vs_gamma(self, ref_delu, chempot_range, miller_index=(), delu_dict={}, delu_default=0, JPERM2=False, show_unstable=False, ylim=[], plt=None, no_clean=False, no_doped=False, use_entry_labels=False, no_label=Fa...
Plots the binding energy energy as a function of monolayers (ML), i.e. the fractional area adsorbate density for all facets. For each facet at a specific monlayer, only plot the lowest binding energy. Args: plot_eads (bool): Option to plot the adsorption energy (binding ...
def monolayer_vs_BE(self, plot_eads=False): """ Plots the binding energy energy as a function of monolayers (ML), i.e. the fractional area adsorbate density for all facets. For each facet at a specific monlayer, only plot the lowest binding energy. Args: plot...
Helper function to a chempot plot look nicer. Args: plt (Plot) Plot to add things to. xrange (list): xlim parameter ref_el (str): Element of the referenced chempot. axes(axes) Axes object from matplotlib pad (float) For tight layout rect (...
def chempot_plot_addons(self, plt, xrange, ref_el, axes, pad=2.4, rect=[-0.047, 0, 0.84, 1], ylim=[]): """ Helper function to a chempot plot look nicer. Args: plt (Plot) Plot to add things to. xrange (list): xlim parameter ref_el ...
For each facet, plot the clean surface energy against the most stable binding energy. Args: delu_dict (Dict): Dictionary of the chemical potentials to be set as constant. Note the key should be a sympy Symbol object of the format: Symbol("delu_el") where e...
def BE_vs_clean_SE(self, delu_dict, delu_default=0, plot_eads=False, annotate_monolayer=True, JPERM2=False): """ For each facet, plot the clean surface energy against the most stable binding energy. Args: delu_dict (Dict): Dictionary of the chemical...
Adapted from the get_chempot_range_map() method in the PhaseDiagram class. Plot the chemical potential range map based on surface energy stability. Currently works only for 2-component PDs. At the moment uses a brute force method by enumerating through the range of the fi...
def surface_chempot_range_map(self, elements, miller_index, ranges, incr=50, no_doped=False, no_clean=False, delu_dict=None, plt=None, annotate=True, show_unphyiscal_only=False, fontsize=10): """ Adapte...
Sets all chemical potential values and returns a dictionary where the key is a sympy Symbol and the value is a float (chempot). Args: entry (SlabEntry): Computed structure entry of the slab delu_dict (Dict): Dictionary of the chemical potentials to be set as ...
def set_all_variables(self, delu_dict, delu_default): """ Sets all chemical potential values and returns a dictionary where the key is a sympy Symbol and the value is a float (chempot). Args: entry (SlabEntry): Computed structure entry of the slab delu_dict (...
Returns a plot of the local potential (eV) vs the position along the c axis of the slab model (Ang) Args: label_energies (bool): Whether to label relevant energy quantities such as the work function, Fermi energy, vacuum locpot, bulk-like locpot ...
def get_locpot_along_slab_plot(self, label_energies=True, plt=None, label_fontsize=10): """ Returns a plot of the local potential (eV) vs the position along the c axis of the slab model (Ang) Args: label_energies (bool): Whether to labe...
Handles the optional labelling of the plot with relevant quantities Args: plt (plt): Plot of the locpot vs c axis label_fontsize (float): Fontsize of labels Returns Labelled plt
def get_labels(self, plt, label_fontsize=10): """ Handles the optional labelling of the plot with relevant quantities Args: plt (plt): Plot of the locpot vs c axis label_fontsize (float): Fontsize of labels Returns Labelled plt """ # center of vac...
A well converged work function should have a flat electrostatic potential within some distance (min_point) about where the peak electrostatic potential is found along the c direction of the slab. This is dependent on the size of the slab. Args: min_point (fraction...
def is_converged(self, min_points_frac=0.015, tol=0.0025): """ A well converged work function should have a flat electrostatic potential within some distance (min_point) about where the peak electrostatic potential is found along the c direction of the slab. This is d...
Gives the radial size of two particles where equilibrium is reached between both particles. NOTE: the solution here is not the same as the solution visualized in the plot because solving for r requires that both the total surface area and volume of the particles are funct...
def solve_equilibrium_point(self, analyzer1, analyzer2, delu_dict={}, delu_default=0, units="nanometers"): """ Gives the radial size of two particles where equilibrium is reached between both particles. NOTE: the solution here is not the same as th...
Calculates the formation energy of the particle with arbitrary radius r. Args: wulffshape (WulffShape): Initial, unscaled WulffShape bulk_entry (ComputedStructureEntry): Entry of the corresponding bulk. r (float (Ang)): Arbitrary effective radius of the WulffShape ...
def wulff_gform_and_r(self, wulffshape, bulk_entry, r, from_sphere_area=False, r_units="nanometers", e_units="keV", normalize=False, scale_per_atom=False): """ Calculates the formation energy of the particle with arbitrary radius r. Args: ...
Scales the Wulff shape with an effective radius r. Note that the resulting Wulff does not neccesarily have the same effective radius as the one provided. The Wulff shape is scaled by its surface energies where first the surface energies are scale by the minimum surface energy and the...
def scaled_wulff(self, wulffshape, r): """ Scales the Wulff shape with an effective radius r. Note that the resulting Wulff does not neccesarily have the same effective radius as the one provided. The Wulff shape is scaled by its surface energies where first the surfa...
Returns the plot of the formation energy of a particle against its effect radius Args: analyzer (SurfaceEnergyPlotter): Analyzer associated with the first polymorph max_r (float): The maximum radius of the particle to plot up to. delu_dict (Dict):...
def plot_one_stability_map(self, analyzer, max_r, delu_dict=None, label="", increments=50, delu_default=0, plt=None, from_sphere_area=False, e_units="keV", r_units="nanometers", normalize=False, s...
Returns the plot of the formation energy of a particles of different polymorphs against its effect radius Args: max_r (float): The maximum radius of the particle to plot up to. increments (int): Number of plot points delu_dict (Dict): Dictionary of the chemical p...
def plot_all_stability_map(self, max_r, increments=50, delu_dict=None, delu_default=0, plt=None, labels=None, from_sphere_area=False, e_units="keV", r_units="nanometers", normalize=False, scale_pe...
Maximum volume change along insertion
def max_delta_volume(self): """ Maximum volume change along insertion """ vols = [v.vol_charge for v in self.voltage_pairs] vols.extend([v.vol_discharge for v in self.voltage_pairs]) return max(vols) / min(vols) - 1
Maximum absolute difference in adjacent voltage steps
def max_voltage_step(self): """ Maximum absolute difference in adjacent voltage steps """ steps = [self.voltage_pairs[i].voltage - self.voltage_pairs[i + 1].voltage for i in range(len(self.voltage_pairs) - 1)] return max(steps) if len(steps) > 0 ...
Average voltage for path satisfying between a min and max voltage. Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage allowable for a given step. Returns: Aver...
def get_average_voltage(self, min_voltage=None, max_voltage=None): """ Average voltage for path satisfying between a min and max voltage. Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable...
Get the gravimetric capacity of the electrode. Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage allowable for a given step. use_overall_normalization (booL): If False...
def get_capacity_grav(self, min_voltage=None, max_voltage=None, use_overall_normalization=True): """ Get the gravimetric capacity of the electrode. Args: min_voltage (float): The minimum allowable voltage for a given step. max_vo...
Get the volumetric capacity of the electrode. Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage allowable for a given step. use_overall_normalization (booL): If False,...
def get_capacity_vol(self, min_voltage=None, max_voltage=None, use_overall_normalization=True): """ Get the volumetric capacity of the electrode. Args: min_voltage (float): The minimum allowable voltage for a given step. max_volta...
Returns the specific energy of the battery in mAh/g. Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage allowable for a given step. use_overall_normalization (booL): If...
def get_specific_energy(self, min_voltage=None, max_voltage=None, use_overall_normalization=True): """ Returns the specific energy of the battery in mAh/g. Args: min_voltage (float): The minimum allowable voltage for a given step. ...
Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage allowable for a given step. use_overall_normalization (booL): If False, normalize by the discharged state of o...
def get_energy_density(self, min_voltage=None, max_voltage=None, use_overall_normalization=True): """ Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage allowable...
Selects VoltagePairs within a certain voltage range. Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage allowable for a given step. Returns: A list of VoltageP...
def _select_in_voltage_range(self, min_voltage=None, max_voltage=None): """ Selects VoltagePairs within a certain voltage range. Args: min_voltage (float): The minimum allowable voltage for a given step. max_voltage (float): The maximum allowable voltage ...
Returns pymatgen Molecule object.
def pymatgen_mol(self): """ Returns pymatgen Molecule object. """ sp = [] coords = [] for atom in ob.OBMolAtomIter(self._obmol): sp.append(atom.GetAtomicNum()) coords.append([atom.GetX(), atom.GetY(), atom.GetZ()]) return Molecule(sp, coord...
A wrapper to pybel's localopt method to optimize a Molecule. Args: forcefield: Default is mmff94. Options are 'gaff', 'ghemical', 'mmff94', 'mmff94s', and 'uff'. steps: Default is 500.
def localopt(self, forcefield='mmff94', steps=500): """ A wrapper to pybel's localopt method to optimize a Molecule. Args: forcefield: Default is mmff94. Options are 'gaff', 'ghemical', 'mmff94', 'mmff94s', and 'uff'. steps: Default is 500. """ ...
A wrapper to pybel's make3D method generate a 3D structure from a 2D or 0D structure. The 3D structure is made very quickly using a combination of rules (e.g. sp3 atoms should have four bonds arranged in a tetrahedron) and ring templates (e.g. cyclohexane is shaped like a chair). Once 3D...
def make3d(self, forcefield="mmff94", steps=50): """ A wrapper to pybel's make3D method generate a 3D structure from a 2D or 0D structure. The 3D structure is made very quickly using a combination of rules (e.g. sp3 atoms should have four bonds arranged in a tetrahedron) and ...
Remove a bond from an openbabel molecule Args: idx1: The atom index of one of the atoms participating the in bond idx2: The atom index of the other atom participating in the bond
def remove_bond(self, idx1, idx2): """ Remove a bond from an openbabel molecule Args: idx1: The atom index of one of the atoms participating the in bond idx2: The atom index of the other atom participating in the bond """ for obbond in ob.OBMolBondIter(s...
Conformer search based on several Rotor Search algorithms of openbabel. If the input molecule is not 3D, make3d will be called (generate 3D structure, add hydrogen, a quick localopt). All hydrogen atoms need to be made explicit. Args: rotor_args: pass args to Rotor Search in...
def rotor_conformer(self, *rotor_args, algo="WeightedRotorSearch", forcefield="mmff94"): """ Conformer search based on several Rotor Search algorithms of openbabel. If the input molecule is not 3D, make3d will be called (generate 3D structure, add hydrogen, a quic...
A combined method to first generate 3D structures from 0D or 2D structures and then find the minimum energy conformer: 1. Use OBBuilder to create a 3D structure using rules and ring templates 2. Do 250 steps of a steepest descent geometry optimization with the MMFF94 forcefield ...
def gen3d_conformer(self): """ A combined method to first generate 3D structures from 0D or 2D structures and then find the minimum energy conformer: 1. Use OBBuilder to create a 3D structure using rules and ring templates 2. Do 250 steps of a steepest descent geometry optimizati...
Conformer generation based on Confab to generate all diverse low-energy conformers for molecules. This is different from rotor_conformer or gen3d_conformer as it aims to not simply to find a low energy conformation but to generate several different conformations. Args: force...
def confab_conformers(self, forcefield="mmff94", freeze_atoms=None, rmsd_cutoff=0.5, energy_cutoff=50.0, conf_cutoff=100000, verbose=False): """ Conformer generation based on Confab to generate all diverse low-energy conformers for molecules. T...
Uses OpenBabel to output all supported formats. Args: filename: Filename of file to output file_format: String specifying any OpenBabel supported formats.
def write_file(self, filename, file_format="xyz"): """ Uses OpenBabel to output all supported formats. Args: filename: Filename of file to output file_format: String specifying any OpenBabel supported formats. """ mol = pb.Molecule(self._obmol) re...
Uses OpenBabel to read a molecule from a file in all supported formats. Args: filename: Filename of input file file_format: String specifying any OpenBabel supported formats. Returns: BabelMolAdaptor object
def from_file(filename, file_format="xyz"): """ Uses OpenBabel to read a molecule from a file in all supported formats. Args: filename: Filename of input file file_format: String specifying any OpenBabel supported formats. Returns: BabelMolAdaptor ob...
Uses OpenBabel to read a molecule from a string in all supported formats. Args: string_data: String containing molecule data. file_format: String specifying any OpenBabel supported formats. Returns: BabelMolAdaptor object
def from_string(string_data, file_format="xyz"): """ Uses OpenBabel to read a molecule from a string in all supported formats. Args: string_data: String containing molecule data. file_format: String specifying any OpenBabel supported formats. Returns: ...
Finds the list of bonded atoms. Args: struct (Structure): Input structure tolerance: length in angstroms used in finding bonded atoms. Two atoms are considered bonded if (radius of atom 1) + (radius of atom 2) + (tolerance) < (distance between atoms 1 and 2). Default value = 0.45, the value used by...
def find_connected_atoms(struct, tolerance=0.45, ldict=JmolNN().el_radius): """ Finds the list of bonded atoms. Args: struct (Structure): Input structure tolerance: length in angstroms used in finding bonded atoms. Two atoms are considered bonded if (radius of atom 1) + (radius of atom 2) +...
Finds bonded clusters of atoms in the structure with periodic boundary conditions. If there are atoms that are not bonded to anything, returns [0,1,0].(For faster computation time in FindDimension()) Args: struct (Structure): Input structure connected_list: Must be made from the same structure ...
def find_clusters(struct, connected_list): """ Finds bonded clusters of atoms in the structure with periodic boundary conditions. If there are atoms that are not bonded to anything, returns [0,1,0].(For faster computation time in FindDimension()) Args: struct (Structure): Input structure ...