text
stringlengths
81
112k
Compare the bond table of the two molecules. Args: mol1: first molecule. pymatgen Molecule object. mol2: second moleculs. pymatgen Molecule objec. def are_equal(self, mol1, mol2): """ Compare the bond table of the two molecules. Args: mol1: first mo...
Find all the bond in a molcule Args: mol: the molecule. pymatgen Molecule object Returns: List of tuple. Each tuple correspond to a bond represented by the id of the two end atoms. def _get_bonds(self, mol): """ Find all the bond in a molcule ...
Compute the mean of correlation between bzt and vasp bandstructure on sym line, for all bands and locally (for each branches) the difference squared (%) if nb is specified. def compare_sym_bands(bands_obj, bands_ref_obj, nb=None): """ Compute the mean of correlation between bzt and vasp bandstructure o...
Seebeck analytic formula in the single parabolic model def seebeck_spb(eta,Lambda=0.5): """ Seebeck analytic formula in the single parabolic model """ from fdint import fdk return constants.k/constants.e * ((2. + Lambda) * fdk( 1.+ Lambda, eta)/ ((1.+Lambda)*fdk(Lambda, e...
It takes a value of seebeck and adjusts the analytic seebeck until it's equal Returns: eta where the two seebeck coefficients are equal (reduced chemical potential) def eta_from_seebeck(seeb,Lambda): """ It takes a value of seebeck and adjusts the analytic seebeck until it's equal ...
Calculate seebeck effective mass at a certain carrier concentration eta in kB*T units, n in cm-3, T in K, returns mass in m0 units def seebeck_eff_mass_from_carr(eta, n, T, Lambda): """ Calculate seebeck effective mass at a certain carrier concentration eta in kB*T units, n in cm-3, T in K,...
Find the chemical potential where analytic and calculated seebeck are identical and then calculate the seebeck effective mass at that chemical potential and a certain carrier concentration n def seebeck_eff_mass_from_seebeck_carr(seeb, n, T, Lambda): """ Find the chemical potential where a...
automatically determine the energy range as min/max eigenvalue minus/plus the buffer_in_ev def _auto_set_energy_range(self): """ automatically determine the energy range as min/max eigenvalue minus/plus the buffer_in_ev """ emins = [min([e_k[0] for e_k in self._bs.bands[...
Write inputs (optional), run BoltzTraP, and ensure convergence (optional) Args: path_dir (str): directory in which to run BoltzTraP convergence (bool): whether to check convergence and make corrections if needed write_input: (bool) whether to write inp...
Function useful to read bands from Boltztrap output and get a BandStructureSymmLine object comparable with that one from a DFT calculation (if the same kpt_line is provided). Default kpt_line and labels_dict is the standard path of high symmetry k-point for the specified ...
Compare sbs_bz BandStructureSymmLine calculated with boltztrap with the sbs_ref BandStructureSymmLine as reference (from MP for instance), computing correlation and energy difference for eight bands around the gap (semiconductors) or fermi level (metals). warn_thr is a th...
Gives the seebeck coefficient (microV/K) in either a full 3x3 tensor form, as 3 eigenvalues, or as the average value (trace/3.0) If doping_levels=True, the results are given at different p and n doping levels (given by self.doping), otherwise it is given as a series ...
Gives the conductivity (1/Ohm*m) in either a full 3x3 tensor form, as 3 eigenvalues, or as the average value (trace/3.0) If doping_levels=True, the results are given at different p and n doping levels (given by self.doping), otherwise it is given as a series o...
Gives the power factor (Seebeck^2 * conductivity) in units microW/(m*K^2) in either a full 3x3 tensor form, as 3 eigenvalues, or as the average value (trace/3.0) If doping_levels=True, the results are given at different p and n doping levels (given by self.doping), otherwise it i...
Gives the electronic part of the thermal conductivity in either a full 3x3 tensor form, as 3 eigenvalues, or as the average value (trace/3.0) If doping_levels=True, the results are given at different p and n doping levels (given by self.doping), otherwise it is given as a series ...
Gives the ZT coefficient (S^2*cond*T/thermal cond) in either a full 3x3 tensor form, as 3 eigenvalues, or as the average value (trace/3.0) If doping_levels=True, the results are given at different p and n doping levels (given by self.doping), otherwise it is given as a series of ...
Gives the average effective mass tensor. We call it average because it takes into account all the bands and regions in the Brillouin zone. This is different than the standard textbook effective mass which relates often to only one (parabolic) band. The average effective mass tens...
Seebeck effective mass calculated as explained in Ref. Gibbs, Z. M. et al., Effective mass and fermi surface complexity factor from ab initio band structure calculations. npj Computational Materials 3, 8 (2017). Args: output: 'average' returns the seebeck effective mass ca...
Fermi surface complexity factor respect to calculated as explained in Ref. Gibbs, Z. M. et al., Effective mass and fermi surface complexity factor from ab initio band structure calculations. npj Computational Materials 3, 8 (2017). Args: output: 'average' returns t...
This method takes in eigenvalues over a range of carriers, temperatures, and doping levels, and tells you what is the "best" value that can be achieved for the given target_property. Note that this method searches the doping dict only, not the full mu dict. Args: target_prop...
Gives a CompleteDos object with the DOS from the interpolated projected band structure Args: the structure (necessary to identify sites for projection) analyzer_for_second_spin must be specified to have a CompleteDos with both Spin components ...
gives the carrier concentration (in cm^-3) Returns a dictionary {temp:[]} with an array of carrier concentration (in cm^-3) at each temperature The array relates to each step of electron chemical potential def get_carrier_concentration(self): """ gives the c...
gives the Hall carrier concentration (in cm^-3). This is the trace of the Hall tensor (see Boltztrap source code) Hall carrier concentration are not always exactly the same than carrier concentration. Returns a dictionary {temp:[]} with an array of Hall carrier concentration ...
Parses .outputtrans file Args: path_dir: dir containing boltztrap.outputtrans Returns: tuple - (run_type, warning, efermi, gap, doping_levels) def parse_outputtrans(path_dir): """ Parses .outputtrans file Args: path_dir: dir containing bolt...
Parses .transdos (total DOS) and .transdos_x_y (partial DOS) files Args: path_dir: (str) dir containing DOS files efermi: (float) Fermi energy dos_spin: (int) -1 for spin down, +1 for spin up trim_dos: (bool) whether to post-process / trim DOS Returns: ...
Parses boltztrap.intrans mainly to extract the value of scissor applied to the bands or some other inputs Args: path_dir: (str) dir containing the boltztrap.intrans file Returns: intrans (dict): a dictionary containing various inputs that had been used in the Boltztrap run. def ...
Parses boltztrap.struct file (only the volume) Args: path_dir: (str) dir containing the boltztrap.struct file Returns: (float) volume def parse_struct(path_dir): """ Parses boltztrap.struct file (only the volume) Args: path_dir: (str) dir con...
Parses the conductivity and Hall tensors Args: path_dir: Path containing .condtens / .halltens files doping_levels: ([float]) - doping lvls, parse outtrans to get this Returns: mu_steps, cond, seebeck, kappa, hall, pn_doping_levels, mu_doping, seebeck_dop...
get a BoltztrapAnalyzer object from a set of files Args: path_dir: directory where the boltztrap files are dos_spin: in DOS mode, set to 1 for spin up and -1 for spin down Returns: a BoltztrapAnalyzer object def from_files(path_dir, dos_spin=1): """ ...
Check for the defined errors, put all found errors in self.errors, return True if any were found False if no errors were found def check(self): """ Check for the defined errors, put all found errors in self.errors, return True if any were found False if no errors were found """ ...
Method to directly apply the corrections. def apply_corrections(self): """ Method to directly apply the corrections. """ for error in self.errors: for solution in error.scheduler_adapter_solutions: if self.scheduler_adapter is not None: if...
Generator that parses dump file(s). Args: file_pattern (str): Filename to parse. The timestep wildcard (e.g., dump.atom.'*') is supported and the files are parsed in the sequence of timestep. Yields: LammpsDump for each available snapshot. def parse_lammps_dumps(file_p...
Parses log file with focus on thermo data. Both one and multi line formats are supported. Any incomplete runs (no "Loop time" marker) will not be parsed. Notes: SHAKE stats printed with thermo data are not supported yet. They are ignored in multi line format, while they may cause is...
Constructor from string parsing. Args: string (str): Input string. def from_string(cls, string): """ Constructor from string parsing. Args: string (str): Input string. """ lines = string.split("\n") timestep = int(lines[1]) nato...
Helper function for calling aconvasp with different arguments def run_aconvasp_command(command, structure): """ Helper function for calling aconvasp with different arguments """ poscar = Poscar(structure) p = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=subproces...
Get kpoint divisions for a given k-point density (per reciprocal-atom): kppa and a given structure def get_num_division_kpoints(structure, kppa): """ Get kpoint divisions for a given k-point density (per reciprocal-atom): kppa and a given structure """ output = run_aconvasp_command(["aconvasp",...
Get a minkowski reduced structure def get_minkowski_red(structure): """ Get a minkowski reduced structure """ output = run_aconvasp_command(["aconvasp", "--kpath"], structure) started = False poscar_string = "" if "ERROR" in output[1]: raise AconvaspError(output[1]) for line in ...
Get a minkowski reduced structure def get_conv_struct(structure): """ Get a minkowski reduced structure """ output = run_aconvasp_command(["aconvasp", "--std_conv"], structure) if "ERROR" in output[1]: raise AconvaspError(output[1]) tmp = Poscar.from_string(output[0]) return {'struc...
get a kpoint file ready to be ran in VASP along the symmetry lines of the Brillouin Zone def get_vasp_kpoint_file_sym(structure): """ get a kpoint file ready to be ran in VASP along the symmetry lines of the Brillouin Zone """ output = run_aconvasp_command(["aconvasp", "--kpath"], structure) ...
Partial returns a partial object and therefore we cannot inherit class methods defined in FloatWithUnit. This function calls partial and patches the new class before returning. def _my_partial(func, *args, **kwargs): """ Partial returns a partial object and therefore we cannot inherit class methods...
Returns a `FloatWithUnit` instance if obj is scalar, a dictionary of objects with units if obj is a dict, else an instance of `ArrayWithFloatWithUnit`. Args: unit: Specific units (eV, Ha, m, ang, etc.). def obj_with_unit(obj, unit): """ Returns a `FloatWithUnit` instance if obj is scalar, ...
Useful decorator to assign units to the output of a function. You can also use it to standardize the output units of a function that already returns a FloatWithUnit or ArrayWithUnit. For sequences, all values in the sequences are assigned the same unit. It works with Python sequences only. The creation ...
Converts all units to base SI units, including derived units. Returns: (base_units_dict, scaling factor). base_units_dict will not contain any constants, which are gathered in the scaling factor. def as_base_units(self): """ Converts all units to base SI units, includin...
Returns a conversion factor between this unit and a new unit. Compound units are supported, but must have the same powers in each unit type. Args: new_unit: The new unit. def get_conversion_factor(self, new_unit): """ Returns a conversion factor between this unit an...
Initialize a FloatWithUnit from a string. Example Memory.from_string("1. Mb") def from_string(cls, s): """ Initialize a FloatWithUnit from a string. Example Memory.from_string("1. Mb") """ # Extract num and unit string. s = s.strip() for i, char in enumerate(s): ...
Conversion to a new_unit. Right now, only supports 1 to 1 mapping of units of each type. Args: new_unit: New unit type. Returns: A FloatWithUnit object in the new units. Example usage: >>> e = Energy(1.1, "eV") >>> e = Energy(1.1, "Ha") ...
Conversion to a new_unit. Args: new_unit: New unit type. Returns: A ArrayWithFloatWithUnit object in the new units. Example usage: >>> e = EnergyArray([1, 1.1], "Ha") >>> e.to("eV") array([ 27.21138386, 29.93252225]) eV def to(...
Returns a string showing the available conversions. Useful tool in interactive mode. def conversions(self): """ Returns a string showing the available conversions. Useful tool in interactive mode. """ return "\n".join(str(self.to(unit)) for unit in self.supported_units)
Attempt to convert a vector of floats to whole numbers. Args: miller_index (list of float): A list miller indexes. round_dp (int, optional): The number of decimal places to round the miller index to. verbose (bool, optional): Whether to print warnings. Returns: (tup...
Returns the angles (alpha, beta, gamma) of the lattice. def angles(self) -> Tuple[float]: """ Returns the angles (alpha, beta, gamma) of the lattice. """ m = self._matrix lengths = self.lengths angles = np.zeros(3) for i in range(3): j = (i + 1) % 3 ...
Inverse of lattice matrix. def inv_matrix(self) -> np.ndarray: """ Inverse of lattice matrix. """ if self._inv_matrix is None: self._inv_matrix = inv(self._matrix) self._inv_matrix.setflags(write=False) return self._inv_matrix
The metric tensor of the lattice. def metric_tensor(self) -> np.ndarray: """ The metric tensor of the lattice. """ return dot(self._matrix, self._matrix.T)
Returns the cartesian coordinates given fractional coordinates. Args: fractional_coords (3x1 array): Fractional coords. Returns: Cartesian coordinates def get_cartesian_coords(self, fractional_coords: Vector3Like) -> np.ndarray: """ Returns the cartesian coordi...
Returns the fractional coordinates given cartesian coordinates. Args: cart_coords (3x1 array): Cartesian coords. Returns: Fractional coordinates. def get_fractional_coords(self, cart_coords: Vector3Like) -> np.ndarray: """ Returns the fractional coordinates giv...
Returns the distance between the hkl plane and the origin Args: miller_index ([h,k,l]): Miller index of plane Returns: d_hkl (float) def d_hkl(self, miller_index: Vector3Like) -> float: """ Returns the distance between the hkl plane and the origin Args...
Convenience constructor for a tetragonal lattice. Args: a (float): *a* lattice parameter of the tetragonal cell. c (float): *c* lattice parameter of the tetragonal cell. Returns: Tetragonal lattice of dimensions a x a x c. def tetragonal(a: float, c: float): ...
Convenience constructor for an orthorhombic lattice. Args: a (float): *a* lattice parameter of the orthorhombic cell. b (float): *b* lattice parameter of the orthorhombic cell. c (float): *c* lattice parameter of the orthorhombic cell. Returns: Orthorhom...
Convenience constructor for a monoclinic lattice. Args: a (float): *a* lattice parameter of the monoclinc cell. b (float): *b* lattice parameter of the monoclinc cell. c (float): *c* lattice parameter of the monoclinc cell. beta (float): *beta* angle between latt...
Convenience constructor for a hexagonal lattice. Args: a (float): *a* lattice parameter of the hexagonal cell. c (float): *c* lattice parameter of the hexagonal cell. Returns: Hexagonal lattice of dimensions a x a x c. def hexagonal(a: float, c: float): """...
Convenience constructor for a rhombohedral lattice. Args: a (float): *a* lattice parameter of the rhombohedral cell. alpha (float): Angle for the rhombohedral lattice in degrees. Returns: Rhombohedral lattice of dimensions a x a x a. def rhombohedral(a: float, alph...
Create a Lattice using unit cell lengths and angles (in degrees). Args: abc (3x1 array): Lattice parameters, e.g. (4, 4, 5). ang (3x1 array): Lattice angles in degrees, e.g., (90,90,120). Returns: A Lattice with the specified lattice parameters. def from_lengths_an...
Create a Lattice using unit cell lengths and angles (in degrees). Args: a (float): *a* lattice parameter. b (float): *b* lattice parameter. c (float): *c* lattice parameter. alpha (float): *alpha* angle in degrees. beta (float): *beta* angle in degree...
Create a Lattice from a dictionary containing the a, b, c, alpha, beta, and gamma parameters if fmt is None. If fmt == "abivars", the function build a `Lattice` object from a dictionary with the Abinit variables `acell` and `rprim` in Bohr. If acell is not given, the Abinit default is u...
Volume of the unit cell. def volume(self) -> float: """ Volume of the unit cell. """ m = self._matrix return float(abs(dot(np.cross(m[0], m[1]), m[2])))
Returns (lattice lengths, lattice angles). def lengths_and_angles(self) -> Tuple[Tuple[float, float, float], Tuple[float, float, float]]: """ Returns (lattice lengths, lattice angles). """ return self.lengths, self.angles
Return the reciprocal lattice. Note that this is the standard reciprocal lattice used for solid state physics with a factor of 2 * pi. If you are looking for the crystallographic reciprocal lattice, use the reciprocal_lattice_crystallographic property. The property is lazily generated fo...
Json-serialization dict representation of the Lattice. Args: verbosity (int): Verbosity level. Default of 0 only includes the matrix representation. Set to 1 for more details. def as_dict(self, verbosity: int = 0) -> Dict: """"" Json-serialization dict representatio...
Finds all mappings between current lattice and another lattice. Args: other_lattice (Lattice): Another lattice that is equivalent to this one. ltol (float): Tolerance for matching lengths. Defaults to 1e-5. atol (float): Tolerance for matching angles. Default...
Finds a mapping between current lattice and another lattice. There are an infinite number of choices of basis vectors for two entirely equivalent lattices. This method returns a mapping that maps other_lattice to this lattice. Args: other_lattice (Lattice): Another lattice t...
Performs a Lenstra-Lenstra-Lovasz lattice basis reduction to obtain a c-reduced basis. This method returns a basis which is as "good" as possible, with "good" defined by orthongonality of the lattice vectors. This basis is used for all the periodic boundary condition calculations. Args...
Given fractional coordinates in the lattice basis, returns corresponding fractional coordinates in the lll basis. def get_lll_frac_coords(self, frac_coords: Vector3Like) -> np.ndarray: """ Given fractional coordinates in the lattice basis, returns corresponding fractional coordinates in...
Given fractional coordinates in the lll basis, returns corresponding fractional coordinates in the lattice basis. def get_frac_coords_from_lll(self, lll_frac_coords: Vector3Like) -> np.ndarray: """ Given fractional coordinates in the lll basis, returns corresponding fractional coordinat...
Get the Niggli reduced lattice using the numerically stable algo proposed by R. W. Grosse-Kunstleve, N. K. Sauter, & P. D. Adams, Acta Crystallographica Section A Foundations of Crystallography, 2003, 60(1), 1-6. doi:10.1107/S010876730302186X Args: tol (float): The numerical...
Return a new Lattice with volume new_volume by performing a scaling of the lattice vectors so that length proportions and angles are preserved. Args: new_volume: New volume to scale to. Returns: New lattice with desired volume. def scale(self, n...
Returns the Wigner-Seitz cell for the given lattice. Returns: A list of list of coordinates. Each element in the list is a "facet" of the boundary of the Wigner Seitz cell. For instance, a list of four coordinates will represent a square facet. def get_wigner_se...
Compute the scalar product of vector(s). Args: coords_a, coords_b: Array-like objects with the coordinates. frac_coords (bool): Boolean stating whether the vector corresponds to fractional or cartesian coordinates. Returns: one-dimensional `numpy` ar...
Compute the norm of vector(s). Args: coords: Array-like object with the coordinates. frac_coords: Boolean stating whether the vector corresponds to fractional or cartesian coordinates. Returns: one-dimensional `numpy` ...
Find all points within a sphere from the point taking into account periodic boundary conditions. This includes sites in other periodic images. Algorithm: 1. place sphere of radius r in crystal and determine minimum supercell (parallelpiped) which would contain a sphere of ra...
Returns the distances between two lists of coordinates taking into account periodic boundary conditions and the lattice. Note that this computes an MxN array of distances (i.e. the distance between each point in fcoords1 and every coordinate in fcoords2). This is different functionality ...
Gets distance between two frac_coords assuming periodic boundary conditions. If the index jimage is not specified it selects the j image nearest to the i atom and returns the distance and jimage indices in terms of lattice vector translations. If the index jimage is specified it returns ...
Get the Miller index of a plane from a list of site coordinates. A minimum of 3 sets of coordinates are required. If more than 3 sets of coordinates are given, the best plane that minimises the distance to all points will be calculated. Args: coords (iterable): A list or nu...
read route line in gaussian input/output and return functional basis_set and a dictionary of other route parameters Args: route (str) : the route line return functional (str) : the method (HF, PBE ...) basis_set (str) : the basis set route (dict) : dictionary of parameters ...
Helper method to parse coordinates. def _parse_coords(coord_lines): """ Helper method to parse coordinates. """ paras = {} var_pattern = re.compile(r"^([A-Za-z]+\S*)[\s=,]+([\d\-\.]+)$") for l in coord_lines: m = var_pattern.match(l.strip()) if m:...
Creates GaussianInput from a string. Args: contents: String representing an Gaussian input file. Returns: GaussianInput object def from_string(contents): """ Creates GaussianInput from a string. Args: contents: String representing an Gaussi...
Returns index of nearest neighbor atoms. def _find_nn_pos_before_site(self, siteindex): """ Returns index of nearest neighbor atoms. """ alldist = [(self._mol.get_distance(siteindex, i), i) for i in range(siteindex)] alldist = sorted(alldist, key=lambda x: x[0...
Returns a z-matrix representation of the molecule. def get_zmatrix(self): """ Returns a z-matrix representation of the molecule. """ output = [] outputvar = [] for i, site in enumerate(self._mol): if i == 0: output.append("{}".format(site.spec...
Return the cartesian coordinates of the molecule def get_cart_coords(self): """ Return the cartesian coordinates of the molecule """ def to_s(x): return "%0.6f" % x outs = [] for i, site in enumerate(self._mol): outs.append(" ".join([site.species...
Return GaussianInput string Option: whe cart_coords sets to True return the cartesian coordinates instead of the z-matrix def to_string(self, cart_coords=False): """ Return GaussianInput string Option: whe cart_coords sets to True return the cartesian coordinates ...
Write the input string into a file Option: see __str__ method def write_file(self, filename, cart_coords=False): """ Write the input string into a file Option: see __str__ method """ with zopen(filename, "w") as f: f.write(self.to_string(cart_coords))
Json-serializable dict representation. def as_dict(self): """ Json-serializable dict representation. """ structure = self.final_structure d = {"has_gaussian_completed": self.properly_terminated, "nsites": len(structure)} comp = structure.composition ...
Read a potential energy surface from a gaussian scan calculation. Returns: A dict: {"energies": [ values ], "coords": {"d1": [ values ], "A2", [ values ], ... }} "energies" are the energies of all points of the potential energy surface. "coords" are th...
Get a matplotlib plot of the potential energy surface. Args: coords: internal coordinate name to use as abcissa. def get_scan_plot(self, coords=None): """ Get a matplotlib plot of the potential energy surface. Args: coords: internal coordinate name to use as ab...
Save matplotlib plot of the potential energy surface to a file. Args: filename: Filename to write to. img_format: Image format to use. Defaults to EPS. coords: internal coordinate name to use as abcissa. def save_scan_plot(self, filename="scan.pdf", i...
Read a excitation energies after a TD-DFT calculation. Returns: A list: A list of tuple for each transition such as [(energie (eV), lambda (nm), oscillatory strength), ... ] def read_excitation_energies(self): """ Read a excitation energies after a TD-DFT calcu...
Get a matplotlib plot of the UV-visible xas. Transition are plotted as vertical lines and as a sum of normal functions with sigma with. The broadening is applied in energy and the xas is plotted as a function of the wavelength. Args: sigma: Full width at half maximum in eV f...
Save matplotlib plot of the spectre to a file. Args: filename: Filename to write to. img_format: Image format to use. Defaults to EPS. sigma: Full width at half maximum in eV for normal functions. step: bin interval in eV def save_spectre_plot(self, filename="sp...
Create a new input object using by default the last geometry read in the output file and with the same calculation parameters. Arguments are the same as GaussianInput class. Returns gaunip (GaussianInput) : the gaussian input object def to_input(self, mol=None, charge=None, ...
Args: species: list of species to_this_composition: If true, substitutions with this as a final composition will be found. If false, substitutions with this as a starting composition will be found (these are slightly ...
Returns charged balanced substitutions from a starting or ending composition. Args: composition: starting or ending composition to_this_composition: If true, substitutions with this as a final composition will be found. If false, s...
Factory function to provide the parser for the specified scheduler. If the scheduler is not implemented None is returned. The files, string, correspond to file names of the out and err files: err_file stderr of the scheduler out_file stdout of the scheduler run_err_file stderr of the ap...