text
stringlengths
81
112k
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 dat...
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. ...
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...
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. ...
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...
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 represent...
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...
: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"] = velocitie...
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, ...
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", ...
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"...
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_gue...
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" --- ...
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 ...
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...
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. ...
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...
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 t...
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: St...
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 a...
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. :par...
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 ...
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 ma...
: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): """ ...
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 fo...
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...
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 = C...
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 mak...
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 ...
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) ...
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 ap...
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...
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 ...
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"), l...
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 ope...
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 ...
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]) ...
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.') t...
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 extrac...
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....
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...
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'), ...
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...
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...
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 ...
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 ...
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...
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 =...
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 = sel...
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,...
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["l...
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(): ...
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...
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_...
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. ...
1D plot. Plots the change in the area contribution of each facet as a function of chemical potential. Args: ref_delu (sympy Symbol): The free variable chempot with the format: Symbol("delu_el") where el is the name of the element. chempot_range (list): Min/max ra...
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). ...
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...
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...
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...
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...
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 ...
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 (...
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...
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...
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 ...
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 ...
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 t...
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...
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...
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 ...
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...
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):...
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...
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_pa...
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...
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...
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,...
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...
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...
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...
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()]...
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 ...
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...
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 Ar...
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...
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 ...
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...
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. Arg...
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 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_f...
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...
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 ...
Algorithm for finding the dimensions of connected subunits in a crystal structure. This method finds the dimensionality of the material even when the material is not layered along low-index planes, or does not have flat layers/molecular wires. See details at : Cheon, G.; Duerloo, K.-A. N.; Sendek, A. D.; Porter...
Returns a string with the structure in XSF format See http://www.xcrysden.org/doc/XSF.html def to_string(self): """ Returns a string with the structure in XSF format See http://www.xcrysden.org/doc/XSF.html """ lines = [] app = lines.append app("CRYSTAL"...
Initialize a `Structure` object from a string with data in XSF format. Args: input_string: String with the structure in XSF format. See http://www.xcrysden.org/doc/XSF.html cls_: Structure class to be created. default: pymatgen structure def from_string(cls, input_strin...
Returns: the kpoints along the paths in cartesian coordinates together with the labels for symmetry points -Wei def get_kpoints(self, line_density=20, coords_are_cartesian=True): """ Returns: the kpoints along the paths in cartesian coordinates together w...