text
stringlengths
81
112k
Get charge transfer from file. Args: feff_inp_file (str): name of feff.inp file for run ldos_file (str): ldos filename for run, assume consequetive order, i.e., ldos01.dat, ldos02.dat.... Returns: dictionary of dictionaries in order of potential site...
returns shrage transfer as string def charge_transfer_to_string(self): """returns shrage transfer as string""" ch = self.charge_transfer chts = ['\nCharge Transfer\n\nabsorbing atom'] for i in range(len(ch)): for atom, v2 in ch[str(i)].items(): a = ['\n', ato...
Get Xmu from file. Args: xmu_dat_file (str): filename and path for xmu.dat feff_inp_file (str): filename and path of feff.inp input file Returns: Xmu object def from_file(xmu_dat_file="xmu.dat", feff_inp_file="feff.inp"): """ Get Xmu from file. ...
Returns chemical formula of material from feff.inp file def material_formula(self): """ Returns chemical formula of material from feff.inp file """ try: form = self.header.formula except IndexError: form = 'No formula provided' return "".join(map(...
Returns dict representations of Xmu object def as_dict(self): """ Returns dict representations of Xmu object """ d = MSONable.as_dict(self) d["data"] = self.data.tolist() return d
A generator form of s.split('\n') for reducing memory overhead. Parameters ---------- s : str A multi-line string. Yields ------ line : str A string. def iterlines(s): """ A generator form of s.split('\n') for reducing memory overhead. Parameters ---------- ...
Return the option string. def _options_string(self): """ Return the option string. """ if len(self.options) > 0: s = "" for op in self.options: if self._sized_op: s += "{:s}={:s} ".format(*map(str, op)) else: ...
Return True if this AdfKey contains the given subkey. Parameters ---------- subkey : str or AdfKey A key name or an AdfKey object. Returns ------- has : bool True if this key contains the given key. Otherwise False. def has_subkey(self, subkey):...
Add a new subkey to this key. Parameters ---------- subkey : AdfKey A new subkey. Notes ----- Duplicate check will not be performed if this is an 'Atoms' block. def add_subkey(self, subkey): """ Add a new subkey to this key. Paramet...
Remove the given subkey, if existed, from this AdfKey. Parameters ---------- subkey : str or AdfKey The subkey to remove. def remove_subkey(self, subkey): """ Remove the given subkey, if existed, from this AdfKey. Parameters ---------- subke...
Add a new option to this key. Parameters ---------- option : Sized or str or int or float A new option to add. This must have the same format with exsiting options. Raises ------ TypeError If the format of the given ``option`` is diff...
Remove an option. Parameters ---------- option : str or int The name (str) or index (int) of the option to remove. Raises ------ TypeError If the option has a wrong type. def remove_option(self, option): """ Remove an option. ...
Return True if the option is included in this key. Parameters ---------- option : str The option. Returns ------- has : bool True if the option can be found. Otherwise False will be returned. def has_option(self, option): """ Ret...
A JSON serializable dict representation of self. def as_dict(self): """ A JSON serializable dict representation of self. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "name": self.name, "options": self.options} if len...
Construct a MSONable AdfKey object from the JSON dict. Parameters ---------- d : dict A dict of saved attributes. Returns ------- adfkey : AdfKey An AdfKey object recovered from the JSON dict ``d``. def from_dict(cls, d): """ Con...
Construct an AdfKey object from the string. Parameters ---------- string : str A string. Returns ------- adfkey : AdfKey An AdfKey object recovered from the string. Raises ------ ValueError Currently nested su...
Setup the block 'Geometry' given subkeys and the task. Parameters ---------- geo_subkeys : Sized User-defined subkeys for the block 'Geometry'. Notes ----- Most of the run types of ADF are specified in the Geometry block except the 'AnalyticFreq'. d...
A JSON serializable dict representation of self. def as_dict(self): """ A JSON serializable dict representation of self. """ return {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "operation": self.operation, "title": self.title,...
Construct a MSONable AdfTask object from the JSON dict. Parameters ---------- d : dict A dict of saved attributes. Returns ------- task : AdfTask An AdfTask object recovered from the JSON dict ``d``. def from_dict(cls, d): """ Co...
Write an ADF input file. Parameters ---------- molecule : Molecule The molecule for this task. inpfile : str The name where the input file will be saved. def write_file(self, molecule, inpfile): """ Write an ADF input file. Parameters ...
Parse the ADF outputs. There are two files: one is 'logfile', the other is the ADF output file. The final energy and structures are parsed from the 'logfile'. Frequencies and normal modes are parsed from the ADF output file. def _parse(self): """ Parse the ADF outputs. There are...
Parse the formatted logfile. def _parse_logfile(self, logfile): """ Parse the formatted logfile. """ cycle_patt = re.compile(r"Coordinates\sin\sGeometry\sCycle\s(\d+)") coord_patt = re.compile(r"\s+([0-9]+)\.([A-Za-z]+)"+3*r"\s+([-\.0-9]+)") energy_patt = re.compile(r"<...
Parse the standard ADF output file. def _parse_adf_output(self): """ Parse the standard ADF output file. """ numerical_freq_patt = re.compile( r"\s+\*\s+F\sR\sE\sQ\sU\sE\sN\sC\sI\sE\sS\s+\*") analytic_freq_patt = re.compile( r"\s+\*\s+F\sR\sE\sQ\sU\sE\sN\...
This method takes a list of band structures and reconstructs one band structure object from all of them. This is typically very useful when you split non self consistent band structure runs in several independent jobs and want to merge back the results Args: list_bs: A list of BandStructur...
Json-serializable dict representation of a kpoint def as_dict(self): """ Json-serializable dict representation of a kpoint """ return {"lattice": self.lattice.as_dict(), "fcoords": list(self.frac_coords), "ccoords": list(self.cart_coords), "label": self.l...
Method returning a dictionary of projections on elements. Returns: a dictionary in the {Spin.up:[][{Element:values}], Spin.down:[][{Element:values}]} format if there is no projections in the band structure returns an empty dict def get_projection_on_elements(sel...
Method returning a dictionary of projections on elements and specific orbitals Args: el_orb_spec: A dictionary of Elements and Orbitals for which we want to have projections on. It is given as: {Element:[orbitals]}, e.g., {'Cu':['d','s']} Returns: ...
Check if the band structure indicates a metal by looking if the fermi level crosses a band. Returns: True if a metal, False if not def is_metal(self, efermi_tol=1e-4): """ Check if the band structure indicates a metal by looking if the fermi level crosses a band. ...
Returns data about the VBM. Returns: dict as {"band_index","kpoint_index","kpoint","energy"} - "band_index": A dict with spin keys pointing to a list of the indices of the band containing the VBM (please note that you can have several bands sharing the VBM) {Spin...
Returns data about the CBM. Returns: {"band_index","kpoint_index","kpoint","energy"} - "band_index": A dict with spin keys pointing to a list of the indices of the band containing the VBM (please note that you can have several bands sharing the VBM) {Spin.up:[], ...
Returns band gap data. Returns: A dict {"energy","direct","transition"}: "energy": band gap energy "direct": A boolean telling if the gap is direct or not "transition": kpoint labels of the transition (e.g., "\\Gamma-X") def get_band_gap(self): """ ...
Returns a dictionary of information about the direct band gap Returns: a dictionary of the band gaps indexed by spin along with their band indices and k-point index def get_direct_band_gap_dict(self): """ Returns a dictionary of information about the direct ...
Returns the direct band gap. Returns: the value of the direct band gap def get_direct_band_gap(self): """ Returns the direct band gap. Returns: the value of the direct band gap """ if self.is_metal(): return 0.0 dg = self.g...
Returns a list of unique symmetrically equivalent k-points. Args: kpoint (1x3 array): coordinate of the k-point cartesian (bool): kpoint is in cartesian or fractional coordinates tol (float): tolerance below which coordinates are considered equal Returns: ...
Returns degeneracy of a given k-point based on structure symmetry Args: kpoint (1x3 array): coordinate of the k-point cartesian (bool): kpoint is in cartesian or fractional coordinates tol (float): tolerance below which coordinates are considered equal Returns: ...
Create from dict. Args: A dict with all data for a band structure object. Returns: A BandStructure object def from_dict(cls, d): """ Create from dict. Args: A dict with all data for a band structure object. Returns: A B...
Returns the list of kpoint indices equivalent (meaning they are the same frac coords) to the given one. Args: index: the kpoint index Returns: a list of equivalent indices TODO: now it uses the label we might want to use coordinates instead (in case the...
Json-serializable dict representation of BandStructureSymmLine. def as_dict(self): """ Json-serializable dict representation of BandStructureSymmLine. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "lattice_rec": self.lattice...
Args: d (dict): A dict with all data for a band structure symm line object. Returns: A BandStructureSymmLine object def from_dict(cls, d): """ Args: d (dict): A dict with all data for a band structure symm line object. ...
Args: d (dict): A dict with all data for a band structure symm line object. Returns: A BandStructureSymmLine object def from_old_dict(cls, d): """ Args: d (dict): A dict with all data for a band structure symm line object. ...
Apply a scissor operator (shift of the CBM) to fit the given band gap. If it's a metal. We look for the band crossing the fermi level and shift this one up. This will not work all the time for metals! Args: new_band_gap: the band gap the scissor band structure need to have. ...
Args: d (dict): A dict with all data for a band structure symm line object. Returns: A BandStructureSymmLine object def from_old_dict(cls, d): """ Args: d (dict): A dict with all data for a band structure symm line object. ...
Method returning a dictionary of projections on elements and specific orbitals Args: el_orb_spec: A dictionary of Elements and Orbitals for which we want to have projections on. It is given as: {Element:[orbitals]}, e.g., {'Si':['3s','3p']} or {'Si':['3s','3p...
Quadratic fit to get an initial guess for the parameters. Returns: tuple: (e0, b0, b1, v0) def _initial_guess(self): """ Quadratic fit to get an initial guess for the parameters. Returns: tuple: (e0, b0, b1, v0) """ a, b, c = np.polyfit(self.vol...
Do the fitting. Does least square fitting. If you want to use custom fitting, must override this. def fit(self): """ Do the fitting. Does least square fitting. If you want to use custom fitting, must override this. """ # the objective function that will be minimized in t...
The equation of state function with the paramters other than volume set to the ones obtained from fitting. Args: volume (list/numpy.array) Returns: numpy.array def func(self, volume): """ The equation of state function with the paramters other than vol...
Returns a summary dict. Returns: dict def results(self): """ Returns a summary dict. Returns: dict """ return dict(e0=self.e0, b0=self.b0, b1=self.b1, v0=self.v0)
Plot the equation of state. Args: width (float): Width of plot in inches. Defaults to 8in. height (float): Height of plot in inches. Defaults to width * golden ratio. plt (matplotlib.pyplot): If plt is supplied, changes will be made to an exis...
Plot the equation of state on axis `ax` Args: ax: matplotlib :class:`Axes` or None if a new figure should be created. fontsize: Legend fontsize. color (str): plot color. label (str): Plot label text (str): Legend text (options) Returns: ...
From Intermetallic compounds: Principles and Practice, Vol. I: Principles Chapter 9 pages 195-210 by M. Mehl. B. Klein, D. Papaconstantopoulos. case where n=0 def _func(self, volume, params): """ From Intermetallic compounds: Principles and Practice, Vol. I: Principles C...
BirchMurnaghan equation from PRB 70, 224107 def _func(self, volume, params): """ BirchMurnaghan equation from PRB 70, 224107 """ e0, b0, b1, v0 = tuple(params) eta = (v0 / volume) ** (1. / 3.) return (e0 + 9. * b0 * v0 / 16. * (eta ** 2 - 1)**2 * ...
Pourier-Tarantola equation from PRB 70, 224107 def _func(self, volume, params): """ Pourier-Tarantola equation from PRB 70, 224107 """ e0, b0, b1, v0 = tuple(params) eta = (volume / v0) ** (1. / 3.) squiggle = -3.*np.log(eta) return e0 + b0 * v0 * squiggle ** 2 /...
Use the fit polynomial to compute the parameter e0, b0, b1 and v0 and set to the _params attribute. def _set_params(self): """ Use the fit polynomial to compute the parameter e0, b0, b1 and v0 and set to the _params attribute. """ fit_poly = np.poly1d(self.eos_params) ...
Overriden since this eos works with volume**(2/3) instead of volume. def fit(self, order=3): """ Overriden since this eos works with volume**(2/3) instead of volume. """ x = self.volumes**(-2./3.) self.eos_params = np.polyfit(x, self.energies, order) self._set_params()
Overriden to account for the fact the fit with volume**(2/3) instead of volume. def _set_params(self): """ Overriden to account for the fact the fit with volume**(2/3) instead of volume. """ deriv0 = np.poly1d(self.eos_params) deriv1 = np.polyder(deriv0, 1) ...
Fit the input data to the 'numerical eos', the equation of state employed in the quasiharmonic Debye model described in the paper: 10.1103/PhysRevB.90.174107. credits: Cormac Toher Args: min_ndata_factor (int): parameter that controls the minimum number of d...
Fit energies as function of volumes. Args: volumes (list/np.array) energies (list/np.array) Returns: EOSBase: EOSBase object def fit(self, volumes, energies): """ Fit energies as function of volumes. Args: volumes (list/np.array...
Compute the defect densities using dilute solution model. Args: structure: pymatgen.core.structure.Structure object representing the primitive or unitcell of the crystal. e0: The total energy of the undefected system. This is E0 from VASP calculation. vac_defs: List ...
Wrapper for the dilute_solution_model. The computed plot data is prepared based on plot_style. Args: structure: pymatgen.core.structure.Structure object representing the primitive or unitcell of the crystal. e0: The total energy of the undefected system. This is E0 from ...
Compute the solute defect densities using dilute solution model. Args: structure: pymatgen.core.structure.Structure object representing the primitive or unitcell of the crystal. e0: The total energy of the undefected system. This is E0 from VASP calculation. T: Temper...
Wrapper for the solute_site_preference_finder. The computed plot data is prepared based on plot_style. Args: structure: pymatgen.core.structure.Structure object representing the primitive or unitcell of the crystal. e0: The total energy of the undefected system. This is ...
Evaluate the gibbs free energy as a function of V, T and P i.e G(V, T, P), minimize G(V, T, P) wrt V for each T and store the optimum values. Note: The data points for which the equation of state fitting fails are skipped. def optimize_gibbs_free_energy(self): """ E...
Evaluate G(V, T, P) at the given temperature(and pressure) and minimize it wrt V. 1. Compute the vibrational helmholtz free energy, A_vib. 2. Compute the gibbs free energy as a function of volume, temperature and pressure, G(V,T,P). 3. Preform an equation of state fit to ge...
Vibrational Helmholtz free energy, A_vib(V, T). Eq(4) in doi.org/10.1016/j.comphy.2003.12.001 Args: temperature (float): temperature in K volume (float) Returns: float: vibrational free energy in eV def vibrational_free_energy(self, temperature, volume): ...
Vibrational internal energy, U_vib(V, T). Eq(4) in doi.org/10.1016/j.comphy.2003.12.001 Args: temperature (float): temperature in K volume (float): in Ang^3 Returns: float: vibrational internal energy in eV def vibrational_internal_energy(self, temperature,...
Calculates the debye temperature. Eq(6) in doi.org/10.1016/j.comphy.2003.12.001. Thanks to Joey. Eq(6) above is equivalent to Eq(3) in doi.org/10.1103/PhysRevB.37.790 which does not consider anharmonic effects. Eq(20) in the same paper and Eq(18) in doi.org/10.1016/j.commatsci.2009.12.0...
Debye integral. Eq(5) in doi.org/10.1016/j.comphy.2003.12.001 Args: y (float): debye temperature/T, upper limit Returns: float: unitless def debye_integral(y): """ Debye integral. Eq(5) in doi.org/10.1016/j.comphy.2003.12.001 Args: y (flo...
Slater-gamma formulation(the default): gruneisen paramter = - d log(theta)/ d log(V) = - ( 1/6 + 0.5 d log(B)/ d log(V) ) = - (1/6 + 0.5 V/B dB/dV), where dB/dV = d^2E/dV^2 + V * d^3E/dV^3 Mie-gruneise...
Eq(17) in 10.1103/PhysRevB.90.174107 Args: temperature (float): temperature in K volume (float): in Ang^3 Returns: float: thermal conductivity in W/K/m def thermal_conductivity(self, temperature, volume): """ Eq(17) in 10.1103/PhysRevB.90.174107 ...
Returns a dict with a summary of the computed properties. def get_summary_dict(self): """ Returns a dict with a summary of the computed properties. """ d = defaultdict(list) d["pressure"] = self.pressure d["poisson"] = self.poisson d["mass"] = self.mass d...
Set all frac_coords of the input structure within [0,1]. Args: structure (pymatgen structure object): input structure matrix (lattice matrix, 3 by 3 array/matrix) new structure's lattice matrix, if none, use input structure's matrix Return: new struc...
obtain cubic symmetric eqivalents of the list of vectors. Args: matrix (lattice matrix, n by 3 array/matrix) Return: cubic symmetric eqivalents of the list of vectors. def symm_group_cubic(mat): """ obtain cubic symmetric eqivalents of the list of vectors. Args: matrix (...
Convenience method to get a copy of the structure, with options to add site properties. Returns: A copy of the Structure, with optionally new site_properties and optionally sanitized. def copy(self): """ Convenience method to get a copy of the structure, with op...
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. Args: key: Specifies a function of one a...
This method returns the sigma value of the gb. If using 'quick_gen' to generate GB, this value is not valid. def sigma(self): """ This method returns the sigma value of the gb. If using 'quick_gen' to generate GB, this value is not valid. """ return int(round(self.orient...
This method returns the sigma value of the gb from site properties. If the GB structure merge some atoms due to the atoms too closer with each other, this property will not work. def sigma_from_site_prop(self): """ This method returns the sigma value of the gb from site properties. ...
return the top grain (Structure) of the GB. def top_grain(self): """ return the top grain (Structure) of the GB. """ top_sites = [] for i, tag in enumerate(self.site_properties['grain_label']): if 'top' in tag: top_sites.append(self.sites[i]) ...
return the bottom grain (Structure) of the GB. def bottom_grain(self): """ return the bottom grain (Structure) of the GB. """ bottom_sites = [] for i, tag in enumerate(self.site_properties['grain_label']): if 'bottom' in tag: bottom_sites.append(self....
return the a list of coincident sites. def coincidents(self): """ return the a list of coincident sites. """ coincident_sites = [] for i, tag in enumerate(self.site_properties['grain_label']): if 'incident' in tag: coincident_sites.append(self.sites[i...
Args: rotation_axis (list): Rotation axis of GB in the form of a list of integer e.g.: [1, 1, 0] rotation_angle (float, in unit of degree): rotation angle used to generate GB. Make sure the angle is accurate enough. You can use the enum* functions in...
find the axial ratio needed for GB generator input. Args: max_denominator (int): the maximum denominator for the computed ratio, default to be 5. index_none (int): specify the irrational axis. 0-a, 1-b, 2-c. Only may be needed for orthorombic system. ...
Find the two transformation matrix for each grain from given rotation axis, GB plane, rotation angle and corresponding ratio (see explanation for ratio below). The structure of each grain can be obtained by applying the corresponding transformation matrix to the conventional cell. ...
Find all possible sigma values and corresponding rotation angles within a sigma value cutoff with known rotation axis in cubic system. The algorithm for this code is from reference, Acta Cryst, A40,108(1984) Args: cutoff (integer): the cutoff of sigma values. r_axis (list...
Find all possible sigma values and corresponding rotation angles within a sigma value cutoff with known rotation axis in rhombohedral system. The algorithm for this code is from reference, Acta Cryst, A45,505(1989). Args: cutoff (integer): the cutoff of sigma values. r_a...
Find all possible sigma values and corresponding rotation angles within a sigma value cutoff with known rotation axis in tetragonal system. The algorithm for this code is from reference, Acta Cryst, B46,117(1990) Args: cutoff (integer): the cutoff of sigma values. r_axis...
Find all possible sigma values and corresponding rotation angles within a sigma value cutoff with known rotation axis in orthorhombic system. The algorithm for this code is from reference, Scipta Metallurgica 27, 291(1992) Args: cutoff (integer): the cutoff of sigma values. ...
Find all possible plane combinations for GBs given a rotaion axis and angle for cubic system, and classify them to different categories, including 'Twist', 'Symmetric tilt', 'Normal tilt', 'Mixed' GBs. Args: plane_cutoff (integer): the cutoff of plane miller index. r_axi...
Find all possible rotation angle for the given sigma value. Args: sigma (integer): sigma value provided r_axis (list of three integers, e.g. u, v, w or four integers, e.g. u, v, t, w for hex/rho system only): the rotation axis ...
By linear operation of csl lattice vectors to get the best corresponding slab lattice. That is the area of a,b vectors (within the surface plane) is the smallest, the c vector first, has shortest length perpendicular to surface [h,k,l], second, has shortest length itself. Args: ...
Reduce integer array mat's determinant mag times by linear combination of its row vectors, so that the new array after rotation (r_matrix) is still an integer array Args: mat (3 by 3 array): input matrix mag (integer): reduce times for the determinant r_matri...
Transform a float vector to a surface miller index with integers. Args: vec (1 by 3 array float vector): input float vector Return: the surface miller index of the input vector. def vec_to_surface(vec): """ Transform a float vector to a surface miller index with...
Adds a Spectrum for plotting. Args: label (str): Label for the Spectrum. Must be unique. spectrum: Spectrum object color (str): This is passed on to matplotlib. E.g., "k--" indicates a dashed black line. If None, a color will be chosen based on ...
Add a dictionary of doses, with an optional sorting function for the keys. Args: dos_dict: dict of {label: Dos} key_sort_func: function used to sort the dos_dict keys. def add_spectra(self, spectra_dict, key_sort_func=None): """ Add a dictionary of doses, with a...
Get a matplotlib plot showing the DOS. Args: xlim: Specifies the x-axis limits. Set to None for automatic determination. ylim: Specifies the y-axis limits. def get_plot(self, xlim=None, ylim=None): """ Get a matplotlib plot showing the DOS. Args...
Save matplotlib plot to a file. Args: filename: Filename to write to. img_format: Image format to use. Defaults to EPS. def save_plot(self, filename, img_format="eps", **kwargs): """ Save matplotlib plot to a file. Args: filename: Filename to write ...
Apply the transformation. Args: structure: input structure return_ranked_list (bool/int): Boolean stating whether or not multiple structures are returned. If return_ranked_list is an int, that number of structures is returned. Returns: ...
For this transformation, the apply_transformation method will return only the ordered structure with the lowest Ewald energy, to be consistent with the method signature of the other transformations. However, all structures are stored in the all_structures attribute in the transformation...
Returns most primitive cell for structure. Args: structure: A structure Returns: The same structure in a conventional standard setting def apply_transformation(self, structure): """ Returns most primitive cell for structure. Args: structure...
Discretizes the site occupancies in the structure. Args: structure: disordered Structure to discretize occupancies Returns: A new disordered Structure with occupancies discretized def apply_transformation(self, structure): """ Discretizes the site occupancies i...
Returns a copy of structure with lattice parameters and sites scaled to the same degree as the relaxed_structure. Arg: structure (Structure): A structurally similar structure in regards to crystal and site positions. def apply_transformation(self, structure): """ ...