COGITOpost

Post-processing and plotting tools for visualizing COGITO results.

class COGITO_dft.COGITOpost.COGITO_TB_Model(directory: str, verbose: int = 0, file_suffix: str = '', file_type: str = 'npy', tb_file: str = 'TBparams', over_file: str = 'overlaps', orbs_orth: bool = False, spin_polar: bool = False)[source]

Bases: object

read_input(file: str = 'tb_input.txt') None[source]

Reads the tb_input.txt for information about the unit cell, atoms, orbitals, fermi energy, energy shift, and spin polarization.

read_TBparams(file: str = 'TBparams', file_type: str = 'npy') None[source]

Reads in the tight binding (hopping) parameters from a file formatted like wannier90_hr.dat.

Parameters:

file (str) – The file name for the TB parameters.

read_overlaps(file: str = 'overlaps', file_type: str = 'npy') None[source]

Reads in the orbital overlaps from a file formatted like wannier90_hr.dat.

Parameters:

file (str) – The file name for the overlaps.

read_orbitals(file: str = 'orbitals.npy') None[source]

This function reads in the orbitals as coefficents for a gaussian expansion. The information in ‘orbitals.npy’ is combined with the orbital data in ‘tb_input.txt’.

Parameters:

file (str) – Orbital file.

normalize_params()[source]

This function correctly normalized the overlap and hopping parameters such that the diagonal of overlap is one. i.e. overlap[orb1=orb2,trans123=0]=1. While the COGITO process gets nearly correctly normalized orbitals (0.99-1.01), generated the TB model from VASP psuedo is not correctly normalized. Running this function ensures that comparison between models of different types and normalizations is correct.

set_hoppings(value: float, orb1: int, orb2: int, trans: tuple, spin: int = 0) None[source]

Change a TB parameter.

Parameters:
  • value (float) – The new parameter.

  • orb1 (int) – The first orbital index of the parameter.

  • orb2 (int) – The second orbital index of the parameter.

  • trans (tuple) – The tuple of translation indices.

Return type:

None

restrict_params(maximum_dist: float = 12.0, minimum_value: float = 0.0001) None[source]

Generates self.use_tbparams, self.use_overlaps, and self.use_vecs_to_orbs which are used in the get_ham() funciton. With this, the calculation of hamiltonians by get_ham() is both sparse and vectorized.

Parameters:
  • maximum_dist (float) – The maximmum distance between hopping parameters which should be included.

  • minimum_value (float) – The minimum magnitude of hopping parameter which should be included.

static make_orbitals(self, cartXYZ)[source]
static plot_orbitals(self)[source]
static generate_gpnts(self, kpt: list)[source]

Similar to from pymatgen.io.vasp.outputs.Wavecar but is vectorized.

Parameters:

kpt (list) – The k-point in reduced coordinates.

Returns:

The gpoints

Return type:

NDArray

static get_ham(self: object, kpt: list, return_overlap: bool = False, return_truevec: bool = True, spin: int = 0) list[source]

This function generates the hamiltonian and overlap matrices for a given kpt. Then it solves the generalized eigenvalue problem to return the eigvalues and vectors.

Parameters:
  • self (object) – An object with the attributes of the COGITO_TB_Model class.

  • kpt (list) – The kpoint to regenerate at in reduced coordinates.

  • return_overlap (bool) – If True, the function will also return the overlap matrix at the kpt. Default is False.

  • return_truevec (bool) – If True, the function will return the eigenvectors in the original nonorthogonal basis. Default if True.

  • spin (int) – The spin of the parameters for a spin-polarized calculation. Default is 0–for non spin-polarized.

Returns:

Returns a list of the eigenvalues and eigenvectors (and overlap if return_overlap=True).

Return type:

list

static get_fullHam(self: object, kpt: list, spin: int = 0)[source]

Find and return the full overlap and hamiltonian matrices (orb1,orb2,T1,T2,T3) but scaled with the phase of a specific k-point.

Parameters:
  • self (object) – An object with the attributes of the COGITO_TB_Model class.

  • kpt (list) – The kpoint to regenerate at in reduced coordinates.

  • spin (int) – The spin of the parameters for a spin-polarized calculation. Default is 0–for non spin-polarized.

@return:

static get_neighbors(self) list[source]

This sorts the matrix of TB parameters into terms which are 1NN, 2NN, etc. Relevant for labeling equivalent bonds and creates NN numbers which is used in COOP and COHP plots.

static plot_crystal_field(self, atomnum: int = 0, orbitals: str = '', ylim: list = (-10, 0), spin: int = 0) None[source]

Plots the crystal field splitting diagram for the orbitals and atom given. Add stuff to plot the orbital type and orbital radius on the energy line (in pretty small font) Also have default to plot all the orbital on the atom.

Parameters:
  • atomnum (int) – Which atom to plot for.

  • orbitals (str) – Which orbitals to plot. If not set shows all the orbitals.

  • ylim (list) – The limits of the y-axis in the plot, will default to good value if left (-10,0).

static plot_hopping(self, spin: int = 0) None[source]

Plots the log(hopping) versus distance between parameters. Used to check quality of tight binding model. Parameters should show a rough linear decay on plot. Although, it is common for them to flatten out after ~10Ang.

static plot_overlaps(self, spin: int = 0) None[source]

Plots the log(overlaps) versus distance between parameters. Used to check quality of tight binding model. Parameters should show a rough linear decay on plot. Although, it is common for them to flatten out after ~10Ang.

static compare_to_DFT(self, directory: str, extra_tag='') list[source]

This function reads the EIGENVAL from a DFT run, generates the energies from the TB model for the kpt grid. Then it plots and compares the error between the TB model energies and DFT energies.

Parameters:
  • self (unknown) – An object of the class COGITO_TB_Model (can not be the BAND or UNIFORM classes!).

  • directory (str) – The directory where the EIGENVAL file is.

Returns:

Saves a png of the DFT and COGITO bands at (self.directory+’compareDFT’ + self.file_suff + extra_tag + ‘.png’). txt: Saves a error values at self.directory + “DFT_band_error” + self.file_suff + extra_tag + “.txt” list: Returns a list of the (averaged over the valance bands) band distance (as defined by Marzari), average maximum error, and average band error.

Return type:

png

static get_COHP(self: object, orbs: dict, max_dist: float = None, min_dist: float = None, NN: int = None, include_onsite: bool = False, spin: int = 0, normalize: bool = False) NDArray[source]

Calculates the COHP for the given orbitals and nearest neighbors.

Parameters:
  • self (object) – An object of the class COGITO_BAND or COGITO_UNIFORM.

  • orbs (dict) – Either a list of two dictionaries giving elements as keys and orbital types as items (eg [{“Pb”:[“s”,”d”],”O”:[“s”,”p”]},{“Pb”:[“s”]”O”:[“p”]}]) or give list of orb numbers [[1,2,3,5,6,7],[1,2,3,4,5,6,7,8]]. See atmorb_dict_to_ind() for more details.

  • max_dist (float) – The maximum distance to include. Default of None reverts to filtering based on ‘NN’.

  • min_dist (float) – The minimum distance to include. Default of None sets to 0.0 (but to really include onsite terms, ‘include_onsite’ below must be set to True).

  • NN (int) – Alternative/old way to filtering distance terms. Is less robust because requires segmenting NNs. An integer for which nearest neighbor number to include (eg 1 for 1NN) or None or “All” for all nearest neighbors.

  • include_onsite (bool) – Includes atomic orbital energy terms (H_ab(R) where R=0 and a=b) instead of just bonding terms.

  • spin (int) – The spin of the tight binding parameters; default is 0 works for nonspin-polarized.

Returns:

Returns COHP values in a [kpt,band] dimension.

Return type:

npt.NDArray

static get_ICOHP(self, spin: int = 0, normalize: bool = False) NDArray[source]

Generates an ICOHP matrix with same dimension as TB parameters (orb1,orb2,T1,T2,T3). Used for fast calculation of energies in crystal bond plot or other integrated energy quantities.

static get_point_data(self, kind, bnd, spin: int = 0, normalize: bool = False) NDArray[source]

Generates an COHP/COOP/bond_occup matrices with same dimension as TB parameters (orb1,orb2,T1,T2,T3) for one specific band, kpoint, and spin.

static get_COOP(self: object, orbs: dict, max_dist: float = None, min_dist: float = None, NN: int = None, include_onsite: bool = False, spin: int = 0) NDArray[source]

Calculates the COOP for the given orbitals and nearest neighbors.

Parameters:
  • self (object) – An object of the class COGITO_BAND or COGITO_UNIFORM.

  • orbs (dict) – Either a list of two dictionaries giving elements (or site index) as keys and orbital types as items (eg [{“Pb”:[“s”,”d”],”O”:[“s”,”p”]},{“Pb”:[“s”]”O”:[“p”]}])

  • [[1 (or give list of orb numbers)

  • 2

  • 3

  • 5

  • 6

  • 7]

  • [1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • details. (8]]. See atmorb_dict_to_ind() for more)

  • max_dist (float) – The maximum distance to include. Default of None reverts to filtering based on ‘NN’.

  • min_dist (float) – The minimum distance to include. Default of None sets to 0.0 (but to really include onsite terms, ‘include_onsite’ below must be set to True).

  • NN (int) – Alternative/old way to filtering distance terms. Is less robust because requires segmenting NNs. An integer for which nearest neighbor number to include (eg 1 for 1NN) or None or “All” for all nearest neighbors.

  • include_onsite (bool) – Includes atomic overlap terms (S_ab(R) where R=0 and a=b) instead of just bonding terms, this can be used with NN=0 to give a projected bandstructure.

  • spin (int) – The spin of the tight binding parameters; default is 0 works for nonspin-polarized.

Returns:

Returns COOP values in a [kpt,band] dimension.

Return type:

npt.NDArray

static get_ICOOP(self, spin: int = 0, normalize: bool = False) NDArray[source]

Generates an ICOOP matrix with same dimension as TB parameters (orb1,orb2,T1,T2,T3). Used for fast calculation of bond charges in crystal bond plot or other integrated charge quantities.

static get_bond_occup(self, spin: int = 0) NDArray[source]

Generates an bond occupancy matrix with same dimension as TB parameters (orb1,orb2,T1,T2,T3). Used for fast calculation of bond charges in crystal bond plot or other integrated charge quantities.

static get_orbprojs(self, spin: int = 0, mulliken: bool = True) NDArray[source]

Returns the orbital projections on the kpoints and band of self object. Output shape is [nkpts, nbands, norbs].

static atmorb_dict_to_ind(self, orbdict)[source]

This function converts an element+orbtype dictionary into the related orbital indices.

Parameters:
  • self – COGITO_TB_Model (or derivative) class

  • curorbdict (dict/list) – Either a dict giving elements as keys and orbital types as items (eg {“Pb”:[“s”,”d”],”O”:[“s”,”p”]}) or already the list of orbital indices. You can also use site/atom index (int) instead of a element (str) as the dict key to single out specific atoms. Specific orbital types (e.g. ‘px’ or ‘dxy’) will not work. This is because the invariance implemented in COGITO uses the local environment to define the angular part of each orbital as a linear combination of all 2l+1 spherical harmonics as defined by self.orb_vec and in the “orbital spherical harmonics combo” section of tb_input.txt.

Returns:

List of orbital indices for the given dict.

Return type:

list

static filter_all_indices(self, orbs: list, max_dist: float = None, min_dist: float = None, NN: int = None, include_onsite: bool = False)[source]

Filter the total 5D (norb, norb, nT1, nT2, nT3) interactions down. Doing this makes calculating COHP and other matrices much faster.

Parameters:
  • self (obj) – COGITO_TB_Model class

  • orbs (list) – List of two lists of orb numbers, e.g. [[1,2,3,5,6,7],[1,2,3,4,5,6,7,8]]. Cannot be dictionary.

  • max_dist (float) – The maximum distance to include. Default of None reverts to filtering based on ‘NN’.

  • min_dist (float) – The minimum distance to include. Default of None sets to 0.0 (but to really include onsite terms, ‘include_onsite’ below must be set to True).

  • NN (int) – Alternative/old way to filtering distance terms. Is less robust because requires segmenting NNs. An integer for which nearest neighbor number to include (eg 1 for 1NN) or None or “All” for all nearest neighbors.

  • include_onsite (bool) – Includes atomic orbital energy terms (H_ab(R) where R=0 and a=b) instead of just bonding terms.

Returns:

int ND.Array of shape [5, N] where N is the number of interactions that fit the parameters given. The 5 gives the [orb1, orb2, T1, T2, T3] of each interaction.

class COGITO_dft.COGITOpost.COGITO_BAND(TB_model: object, line_density: int = 20, high_sym_kpnts: dict = {}, high_sym_kpath: list = [], all_kpts: list = [], kpt_labels: list = [])[source]

Bases: object

get_bandstructure(line_density: int = 20, high_sym_kpnts: dict = {}, high_sym_kpath: list = [], all_kpts: list = [[]], kpt_labels: list = []) None[source]

The function automatically generates a kpath using pymatgen and kpathseek. Then calculates the band energies and vectors for the kpath.

Parameters:
  • line_density (int) – The number of kpoints between EACH kpath.

  • high_sym_kpnts (dict) – Dictionary of high symmetry points in reduced coordinates. e.g. {‘GAMMA’: [0.0, 0.0, 0.0], ‘Z’: [0.0, 0.0, 0.5], ‘M’: [0.5, 0.5, 0.0]} If not provided, use KpathSeek to find using structure.

  • high_sym_kpath (list) – The list of paths between the high symmetry points. e.g. [[‘GAMMA’, ‘X’, ‘M’, ‘GAMMA’]] If this and high_sym_pnts not provide, use KpathSeek. If just this not provided, defaults to single path through points in order provided.

  • all_kpts (list) – List of all k-points in reduced coordinates. If not provided, uses high_sym_kpnts/kpath and pymatgen Kpath.

  • kpt_labels (list) – Labels for the full list of k-points. Only used if all_kpts is provided. Default is empty string array.

Returns:

Nothing

Return type:

None

static plotBS(self, ax: object = None, ylim: list = (-10, 10), color_label: str = '', colors: NDArray = array([], dtype=float64), colorhalf: float = 10) object[source]
Parameters:
  • ax (object) – (matplotlib.pyplot axis): Axis to save the bandstructure to, otherwise generate new axis.

  • ylim (list) – Limits on the y-axis of plot.

  • color_label (str) – When being plotted from another function, this passes “COHP” or “COOP”.

  • colors (npt.NDArray) – Magnitude for each point to use in color plotting, passed by get_COHP() function.

  • colorhalf (float) – Sets scale of color bar.

Returns:

matplotlib.pyplot axis with bandstructure plotted.

Return type:

object

static plotlyBS(self, ylim=(-10, 10), color_label='', colors=None, colorhalf=None, orbProj: bool = False) object[source]

Plots bandstructure (or projected bandstructure) using plotly graph_objects.

Parameters:
  • ylim (unknown) – Limits on the y-axis of plot.

  • color_label (unknown) – When being plotted from another function, this passes “COHP” or “COOP”.

  • colors (unknown) – Magnitude for each point to use in color plotting, passed by plot_COHP() function.

  • colorhalf (unknown) – Sets scale of color bar.

Returns:

plotly figure with bandstructure plotted.

Return type:

object

static plot_COHP(self, orbs: dict, max_dist: float = None, min_dist: float = None, NN: int = None, ylim: list = (-10, 10), colorhalf: float = 10, include_onsite: bool = False, return_plot: bool = False) None[source]

Calculates and plots the projected COHP values for each band and k-point on band structure.

Parameters:
  • orbs (dict) – Either a list of two dictionaries giving elements as keys and orbital types as items (eg [{“Pb”:[“s”,”d”],”O”:[“s”,”p”]},{“Pb”:[“s”]”O”:[“p”]}]) or give list of orb numbers [[1,2,3,5,6,7],[1,2,3,4,5,6,7,8]].See atmorb_dict_to_ind() for more details.

  • max_dist (float) – The maximum distance to include. Default of None reverts to filtering based on ‘NN’.

  • min_dist (float) – The minimum distance to include. Default of None sets to 0.0 (but to really include onsite terms, ‘include_onsite’ below must be set to True).

  • NN (int) – Alternative/old way to filtering distance terms. Is less robust because requires segmenting NNs. An integer for which nearest neighbor number to include (eg 1 for 1NN) or None or “All” for all nearest neighbors.

  • ylim (list) – The limits of the y-axis (energy) of the band structure plot.

  • colorhalf (float) – Set the magnitude for the color bar; For default value of 10, it is set automatically to average(COHP)*3.

  • include_onsite (bool) – Includes atomic orbital energy terms (H_ab(R) where R=0 and a=b) instead of just bonding terms.

  • return_plot (bool) – Flag to set when calling from the dash app, sets plotting backend to plotly and returns the axis.

Returns:

Nothing or plotly figure, depending no return_plot.

Return type:

None

static plot_COOP(self, orbs: dict, max_dist: float = None, min_dist: float = None, NN: int = None, ylim: list = (-10, 10), colorhalf: float = 10, include_onsite: bool = False, return_plot=False, color_label: str = '-COOP', orbProj: bool = False) None[source]

Calculates and plots the projected COOP values for each band and k-point on band structure.

Parameters:
  • orbs (dict) – either a list of two dictionaries giving elements as keys and orbital types as items (eg [{“Pb”:[“s”,”d”],”O”:[“s”,”p”]},{“Pb”:[“s”]”O”:[“p”]}])

  • [[1 (or give list of orb numbers)

  • 2

  • 3

  • 5

  • 6

  • 7]

  • [1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • details. (8]].See atmorb_dict_to_ind() for more)

  • max_dist (float) – The maximum distance to include. Default of None reverts to filtering based on ‘NN’.

  • min_dist (float) – The minimum distance to include. Default of None sets to 0.0 (but to really include onsite terms, ‘include_onsite’ below must be set to True).

  • NN (int) – Alternative/old way to filtering distance terms. Is less robust because requires segmenting NNs. An integer for which nearest neighbor number to include (eg 1 for 1NN) or None or “All” for all nearest neighbors.

  • ylim (list) – The limits of the y-axis (energy) of the band structure plot.

  • colorhalf (float) – Set the magnitude for the color bar; For default value of 10, it is set automatically to average(COOP)*3.

  • include_onsite (bool) – Includes atomic overlap terms (S_ab(R) where R=0 and a=b) instead of just bonding terms, this can be used with NN=0 to give a projected bandstructure.

  • return_plot (unknown) – Flag to set when calling from the dash app, sets plotting backend to plotly and returns the axis.

Returns:

Nothing or plotly figure, depending no return_plot.

Return type:

None

static get_pymatgen_bandstruc(self, mulliken: bool = True)[source]

This function will generate a pymatgen bandstructure class object that is projected with the COGITO orbitals.

Parameters:
  • self – COGITO_BAND object

  • mulliken – Whether to do mulliken projection or onsite projection. For nonorthogonal basis, the sum of the onsite projection is <1 for bonding states and >1 (often by 2-5x) for antibonding states.

Returns:

Pymatgen BandStructureSymmLine object

Return type:

obj

static plot_projectedBS(self, orbdict: dict, ylim: list = (-10, 10), colorhalf: float = 10, mulliken: bool = True) None[source]

Returns the COGITO-orbital projected band structure. By construction, this performs the projection by Mulliken-style analysis. Projection without Mulliken is obfuscated by the nonorthogonal nature of the orbitals, which causes much larger projection at high energy states due to antibonding.

This function is mostly useful just for plotting orbital projected BS. If you only need the raw projected values for specific atoms and orbitals (defined in orbdict), use the indices returned by COGITO_TB_Model.atmorb_dict_to_ind(my_TB/UN/BS class, {“Si”:[“s”,”p”]}) on the projections returned by COGITO_TB_Model.get_orbprojs(my_UN/BS class, spin=0) (where spin is a 0 or 1 int).

Parameters:
  • orbdict (dict) – Single dictionary of orbitals to include in projection. For example, {“Pb”:[“s”,”d”],”O”:[“s”,”p”]}.

  • ylim (tuple) – The y-axis limits.

  • colorhalf (float) – The upper and lower value for the projection. The code will find a reasonable value. For this, colorhalf=1 would be good. (Default is only 10 for signaling auto-update in later code.)

Returns:

Saves the projection plot at self.directory+”projectedBS”+elem+”.html”.

Return type:

html

static make_COHP_dashapp(self, pathname: str = '/COGITO_COHP/') None[source]

This function generate a dash app which allows the user to interactively select orbitals and nearest neighbors to examine their project COHP band structure quickly.

Parameters:

pathname (str) – Name appended to the default pathname for the html.

Returns:

Nothing

Return type:

None

class COGITO_dft.COGITOpost.COGITO_UNIFORM(TB_model: object, grid: tuple)[source]

Bases: object

get_uniform(grid: tuple) None[source]

Sets up the uniform grid, calculating all eigenenergies and eigenvectors, and adjust fermi energy to ensure charge conservation.

Parameters:

grid (tuple) – The kpoint grid to use for the uniform sampling.

get_ICOHP()[source]

Generates an ICOHP matrix with from the TB_Model static function. Then reduces the matrix size. Used for fast calculation of energies in crystal bond plot or other integrated energy quantities.

get_ICOOP()[source]

Generates an ICOOP matrix with from the TB_Model static function. Then reduces the matrix size. Used for fast calculation of energies in crystal bond plot or other integrated energy quantities.

get_bond_occup()[source]

Generates an bond occupation matrix with from the TB_Model static function. Then reduces the matrix size. Used for fast calculation of energies in crystal bond plot or other integrated energy quantities.

get_all_integrated()[source]

This function efficiently gets the ICOHP, ICOHP, and bond occupation (density matrix) @return:

save_bond_occup()[source]

Saves the smaller bond occupation (density) matrix to (self.directory+”bond_occup”+str(key)+”.npy”) for reading in later with COGITOico.

save_ICOOP()[source]

Saves the smaller ICOOP matrix to (self.directory+”ICOOP”+str(key)+”.npy”) for reading in later with COGITOico.

save_ICOHP()[source]

Saves the smaller ICOHP matrix to (self.directory+”ICOHP”+str(key)+”.npy”) for reading in later with COGITOico.

static get_mulliken_charge(self: object, elem: str, only_onsite=False) float[source]

Returns the atomic partial charge by Mulliken partitioning. If the calculation is spin polarized, also returns the atomic magnetization by Mulliken. If the element label (str) is used, the code returns the average charge/magnetization for the element type.

Parameters:
  • elem (str or int) – Either the element label (e.g. “Pb”) or the index of the atom in the list of atoms (as seen in tb_input.txt). When is the element label, the function will return a value for each atom of that type.

  • only_onsite (bool) – Default False. If True, don’t actually do the Mulliken repartitioning from bonds, only include onsite charges. Note if True: Summing only atoms with onsite charge will not be charge neutral, need to include bond charge for neutrality.

Returns:

Atomic partial charge or if spin polarized, (partial charge, atomic magnetic moment).

If elem is element label (e.g. “Pb”), returns a list for charge and magmom.

Return type:

(float or tuple)

static get_occupation(self, spin: int = 0)[source]

This function prints information about electron occupation/partitioning. It prints a version using Mulliken to assign charge to orbitals and one that just uses the onsite orbital terms. The onsite one will not be charge balanced as some charge is in bonds. It also prints the atomic partial charge by Mulliken population.

static get_COHP_DOS(self, orbs: dict, max_dist: float = None, min_dist: float = None, NN: int = None, ylim: list = (-10, 10), sigma=0.1, include_onsite: bool = False, save_plot: bool = True)[source]

Calculates and plots the projected COHP values on the density of states.

Parameters:
  • orbs (dict) – Either a list of two dictionaries giving elements as keys and orbital types as items (eg [{“Pb”:[“s”,”d”],”O”:[“s”,”p”]},{“Pb”:[“s”]”O”:[“p”]}])

  • [[1 (or give list of orb numbers)

  • 2

  • 3

  • 5

  • 6

  • 7]

  • [1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • details. (8]].See atmorb_dict_to_ind() for more)

  • max_dist (float) – The maximum distance to include. Default of None reverts to filtering based on ‘NN’.

  • min_dist (float) – The minimum distance to include. Default of None sets to 0.0 (but to really include onsite terms, ‘include_onsite’ below must be set to True).

  • NN (int) – Alternative/old way to filtering distance terms. Is less robust because requires segmenting NNs. An integer for which nearest neighbor number to include (eg 1 for 1NN) or None or “All” for all nearest neighbors.

  • ylim (list) – The limits of the y-axis (energy) of the DOS plot.

  • sigma (float) – Sets the spread (in energy) of the gaussian for the each wavefunction COHP. The full pCOHP is created by summing the gaussians. This should trade off with k-point resolution. Low resolution requires high sigma (0.2) to smear between points. High resoltion can have low sigma (0.02).

  • include_onsite (bool) – Includes atomic orbital energy terms (H_ab(R) where R=0 and a=b) instead of just bonding terms.

Returns:

1D COHP values}). The energies are shifted so that Efermi=0 png: Saves projected COHP DOS to self.directory+’COHP_DOS.png’.

Return type:

Tuple of (1D energies, and dict{spin

static get_COOP_DOS(self, orbs: dict, max_dist: float = None, min_dist: float = None, NN: int = None, ylim: list = (-10, 10), sigma=0.1, include_onsite: bool = False, save_plot: bool = True)[source]

Calculates and plots the projected COOP values on the density of states.

Parameters:
  • orbs (dict) – Either a list of two dictionaries giving elements as keys and orbital types as items (eg [{“Pb”:[“s”,”d”],”O”:[“s”,”p”]},{“Pb”:[“s”]”O”:[“p”]}])

  • [[1 (or give list of orb numbers)

  • 2

  • 3

  • 5

  • 6

  • 7]

  • [1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • details. (8]].See atmorb_dict_to_ind() for more)

  • max_dist (float) – The maximum distance to include. Default of None reverts to filtering based on ‘NN’.

  • min_dist (float) – The minimum distance to include. Default of None sets to 0.0 (but to really include onsite terms, ‘include_onsite’ below must be set to True).

  • NN (int) – Alternative/old way to filtering distance terms. Is less robust because requires segmenting NNs. An integer for which nearest neighbor number to include (eg 1 for 1NN) or None or “All” for all nearest neighbors.

  • ylim (list) – The limits of the y-axis (energy) of the DOS plot.

  • sigma (float) – Sets the spread (in energy) of the gaussian for the each wavefunction COOP. The full pCOOP is created by summing the gaussians. This should trade off with k-point resolution. Low resolution requires high sigma (0.2) to smear between points. High resoltion can have low sigma (0.02).

  • include_onsite (bool) – Includes atomic orbital energy terms (H_ab(R) where R=0 and a=b) instead of just bonding terms.

Returns:

1D COOP values}). The energies are shifted so that Efermi=0 png: Saves projected COOP DOS to self.directory+’COOP_DOS.png’.

Return type:

Tuple of (1D energies, and dict{spin

static get_projectedDOS(self, elem: str, ylim: list = (-10, 10), sigma: float = 0.1, mulliken: bool = True, save_plot: bool = True)[source]

Returns the COGITO-orbital projected density of states for a specific element. This function is mostly plotting functionality for visualizing an orbital decomposed projected DOS for one element. If you only need the raw projected values (at kpt,band indices instead of on energy axis) for specific atoms and orbitals (defined in orbdict), use the indices returned by COGITO_TB_Model.atmorb_dict_to_ind(my_TB/UN/BS class, {“Si”:[“s”,”p”]}) on the projections returned by COGITO_TB_Model.get_orbprojs(my_UN/BS class, spin=0) (where spin is a 0 or 1 int).

By construction, this performs the projection by Mulliken-style analysis. Projection without Mulliken is obfuscated by the nonorthogonal nature of the orbitals, which causes much larger projection at high energy states due to antibonding.

Parameters:
  • self (obj) – COGITO_UNIFORM class object.

  • elem (str) – String of the element label. For example, “Pb”.

  • ylim (tuple) – The y-axis limits.

  • sigma (float) – Sets the spread (in energy) of the gaussian for the each wavefunction COOP. The full pCOOP is created by summing the gaussians. This should trade off with k-point resolution. Low resolution requires high sigma (0.2) to smear between points. High resoltion can have low sigma (0.02).

  • mulliken (bool) – Whether to do mulliken projection or onsite projection. For nonorthogonal basis, the sum of the onsite projection is <1 for bonding states and >1 (often by 2-5x) for antibonding states.

Returns:

1D total DOS}, dict{spin: dict{orbtype: 1D projected DOS}}). The energies are shifted so that Efermi=0 png: Saves the projection plot at self.directory+elem+’projectedDOS.png’.

Return type:

Tuple of (1D energies, dict{spin

static get_pymatgen_bandstruc(self, mulliken: bool = True)[source]

This function will generate a pymatgen bandstructure class object that is projected with the COGITO orbitals.

Parameters:
  • self – COGITO_UNIFORM object

  • mulliken – Whether to do mulliken projection or onsite projection. For nonorthogonal basis, the sum of the onsite projection is <1 for bonding states and >1 (often by 2-5x) for antibonding states.

Returns:

Pymatgen BandStructureSymmLine object

Return type:

object

static get_pymatgen_completedos(self, sigma: float = 0.1, mulliken: bool = True)[source]

This function will generate a pymatgen CompleteDos class object that is projected with the COGITO orbitals.

Parameters:
  • self – COGITO_UNIFORM object

  • sigma (float) – Sets the spread (in energy) of the gaussian for the each wavefunction COOP. The full pCOOP is created by summing the gaussians. This should trade off with k-point resolution. Low resolution requires high sigma (0.2) to smear between points. High resoltion can have low sigma (0.02).

  • mulliken (bool) – Whether to do mulliken projection or onsite projection. For nonorthogonal basis, the sum of the onsite projection is <1 for bonding states and >1 (often by 2-5x) for antibonding states.

Returns:

Pymatgen CompleteDos object

Return type:

object

make_bond(atmind1, atmind2, center1, center2, orbCOOP, cartXYZ)[source]

This is a function which will generate populate the cartXYZ grid with values for the bond density between the atoms given using the orbCOOP provided.

Parameters:
  • atmind1 (unknown) – The atom number for the first atom.

  • atmind2 (unknown) – The atom number for the second atom.

  • center1 (unknown) – The center of the first atom (not using self.primATOMs).

  • center2 (unknown) – The center of the second atom (not using self.primATOMs).

  • orbCOOP (unknown) – The orbCOOP which reveals how much of each orbital combo that is included in the bond. Dimension nxm where n is the # of orbitals for atom 1 and m is # of orbitals for atom 2.

  • cartXYZ (unknown) – The 3D flattened grid that the bond density is calculated on.

Returns:

A 1D array (3D flattened) of the bond density.

Return type:

unknown

get_bonds_charge_figure(energy_cutoff: float = 0.1, bond_max: float = 3.0, elem_colors: list = [], atom_colors: list = [], atom_labels: list = [], auto_label: str = '', plot_atom: int = None, one_atom: bool = False, fovy: float = 10, return_fig: bool = False) None[source]

Plots the crystal structure atoms with bonds plotted based on iCOHP. Each line should also be hoverable to reveal the number and amounts that are s-s,s-p, and p-p. The charge and magnetic moment will also be plotted acording to auto_label.

Parameters:
  • energy_cutoff (float) – This is the minimum bond magnitude that will be plotted.

  • bond_max (float) – Atoms are plotted outside the primitive cell only if they have a bond with a primitive cell atom that is shorter than this amount. This does not filter bonds between atoms that are already plotted.

  • elem_colors (list) – Colors for the elements based on order in tb_input. Length of list should be the number of unique elements. Can either be integer list to reference the default colors or list of plotly compatable colors.

  • atom_colors (list) – Colors for the atoms based on order in tb_input. Length of list should be the number of atoms in the primitive cell. Can either be integer list to reference the default colors or list of plotly compatable colors. If not set defaults to elem_colors.

  • atom_labels (list) – List of atom labels as a string.

  • auto_label (str) – Different options for plotting includes: (can include multiple in the string) “mulliken” -Plots the onsite charge and mag (if spin_polar) on atoms by mulliken population (overrides atom_labels). “full” - Plots the charge and magnetics moments (if spin_polar) on atoms and bonds (overrides atom_labels). “color” - Colors the atoms and bonds based on their charge (overrides atom_colors or elem_colors). “color mag” - Colors the atoms and bonds based on their magnetic moments (overrides atom_colors or elem_colors). NOTE: Only use “mulliken” OR “full”, NOT both

  • plot_atom (int) – Set with one_atom=True, plots only one atom and it’s bonds, this passes the atom number to plot.

  • one_atom (bool) – Whether only the atom defined in plot_atom should be plotted; default is False.

  • fovy (float) – field of view in the vertical direction. Use this tag to adjust depth perception in crystal. Set between 3 (for close to orthographic) and 30 (for good perspective depth).

  • return_fig (bool) – If False, this function saves figure to crystal_bonds.html. If True, this function will return the plotly figure object.

Returns:

Depends on return_fig parameter.

Return type:

None

get_bond_density_figure(energy_cutoff: float = 0.1, iso_max: float = 0.03, iso_min: float = -0.003, elem_colors: list = [], atom_colors: list = [], atom_labels: list = [], auto_label: str = '', plot_atom: int = None, one_atom: bool = False, bond_max: float = 3.0, fovy: float = 10, return_fig: bool = False) None[source]

Plots the crystal structure atoms with bonds plotted based on iCOHP. Each line should also be hoverable to reveal the number and amounts that are s-s,s-p, and p-p. The charge and magnetic moment will also be plotted acording to auto_label.

Parameters:
  • energy_cutoff (float) – This is the minimum bond magnitude that will be plotted.

  • iso_max (float) – The positive isosurface for plotting the bonds.

  • iso_min (float) – The negative isosurface for plotting the bonds.

  • elem_colors (list) – Colors for the elements based on order in tb_input. Length of list should be the number of unique elements. Can either be integer list to reference the default colors or list of plotly compatable colors.

  • atom_colors (list) – Colors for the atoms based on order in tb_input. Length of list should be the number of atoms in the primitive cell. Can either be integer list to reference the default colors or list of plotly compatable colors. If not set defaults to elem_colors.

  • atom_labels (list) – List of atom labels as a string.

  • auto_label (str) – Different options for plotting includes: (can include multiple in the string) “mulliken” - Plots the onsite charge and mag (if spin_polar) on atoms by mulliken population (overrides atom_labels). “full” - Plots the charge and magnetics moments (if spin_polar) on atoms and bonds (overrides atom_labels). “color” - Colors the atoms and bonds based on their charge (overrides atom_colors or elem_colors). “color mag” - Colors the atoms and bonds based on their magnetic moments (overrides atom_colors or elem_colors). NOTE: Only use “mulliken” OR “full”, NOT both.

  • plot_atom (int) – Set with one_atom=True, plots only one atom and it’s bonds, this passes the atom number to plot.

  • one_atom (bool) – Whether only the atom defined in plot_atom should be plotted; default is False.

  • bond_max (float) – Atoms are plotted outside the primitive cell only if they have a bond with a primitive cell atom that is shorter than this amount. This does not filter bonds between atoms that are already plotted.

  • fovy (float) – field of view in the vertical direction. Use this tag to adjust depth perception in crystal. Set between 3 (for close to orthographic) and 30 (for good perspective depth).

  • return_fig (bool) – If False, this function saves figure to crystal_bonds.html. If True, this function will return the plotly figure object.

Returns:

Depends on return_fig parameter. Default is to return nothing but save “crystal_bonds.html”.

Return type:

html, or object

jsonify_bonddata(minimum_cohp: float = 1e-05, make_bond_info_txt=True)[source]

This function covers the raw ICOHP and ICOOP and bond_occup matrices into something more interpretable while still preserving norms. This constructs three json files: all_bonds.json : includes bonds between all atoms that have a elements above the minimum_cohp. all_unique_bonds : groups the all_bonds into unique ones for more interpretable viewing. all_atoms.json : all onsite atom information, including the bond orb_orb_dict + added onsite and mulliken orbital occupations and partial charges + lone-pair-like energy (cohp) contributions. The structure of the all_bonds json: {“uniq_bonds by “el1_el2_dist_energy”: { “bondlength”: float, “degeneracy”: int, “cohp”: float , “coop”: float, “bondmagmom”: float, “all atom-atom bonds in this set by ‘atm1_atm2_T1_T2_T3’:{ # just ‘atm1_atm2’ is not enough since atoms can bond outside unit cell “atmorbs1, atmorbs2”: [[int…],[int…]] # used to reference orbital energy, radius, and shape “cohp”: [float…] , “coop”: [float…], “bondlength”: float, “bondmagmom”: float, “angle”?:float, # same data just without averaging “orb-orb e.g. ‘s-d’”: { “cohp”: [float…], “coop”: [float…], # is referenced to spin state. For non spin-polarized: [float], for spin-polar: [float,float] “orbnums1, orbnums2”: [[int…],[int…]] for orbital numbers e.g. for s-p: [[0],[1,2,3]], # orbital number referenced to atom already selected “bond_occup_matrix”: [numorbs1×numorbs2…], “orb_ediff_matrix”: [numorbs1×numorbs2…], “cohp_matrix”: [numorbs1×numorbs2…], “coop_matrix”: [numorbs1×numorbs2…], “S_matrix”: [numorbs1×numorbs2…], “H_matrix”: [numorbs1×numorbs2…], } } } @return:

get_bond_info()[source]

Creates the bond_info.txt file which lists all the relavent bonds by there involved atoms, length, energy, charge, and multiplicity.

get_COHP_DOS_bybond(sigma=0.1, return_fig: bool = False)[source]

Creates an interactive plot pCOHP DOS plot for all relevant bonds and their orbital decomposition.

Returns:

Plotly figure object.

Return type:

object

get_crystal_plus_COHP(energy_cutoff: float = 0.05, bond_max: float = 3, auto_label: str = 'mulliken', fovy: float = 10) None[source]

The will plot the crystal bond plot on the left with interactivity to a COHP DOS plot on the right.

Parameters:
  • energy_cutoff (float) – This is the minimum bond magnitude that will be plotted.

  • bond_max (float) – Atoms are plotted outside the primitive cell only if they have a bond with a primitive cell atom that is shorter than this amount. This does not filter bonds between atoms that are already plotted.

  • auto_label (str) – Different options for plotting includes: (can include multiple in the string) “mulliken” - Plots the onsite charge and mag (if spin_polar) on atoms by mulliken population (overrides atom_labels). “full” - Plots the charge and magnetics moments (if spin_polar) on atoms and bonds (overrides atom_labels). “color” - Colors the atoms and bonds based on their charge (overrides atom_colors or elem_colors). “color mag” - Colors the atoms and bonds based on their magnetic moments (overrides atom_colors or elem_colors). NOTE: Only use “mulliken” OR “full”, NOT both.

  • fovy (float) – field of view in the vertical direction. Use this tag to adjust depth perception in crystal.

Returns:

Nothing, but saved to ‘bond_cohp_plot.html’.

Return type:

None

class COGITO_dft.COGITOpost.COGITO_BS_widget(TB_model: object, num_kpts: int = 100)[source]

Bases: object

get_bandstructure(num_kpts: int = 100) None[source]

The function automatically generates a kpath using pymatgen and kpathseek. Then calculates the band energies and vectors for the kpath.

Parameters:

num_kpts (int) – The number of kpoints between EACH kpath.

Returns:

Nothing

Return type:

None

plotlyBS(ylim=(-10, 10), selectedDot=None, plotnew=False) object[source]

Plots bandstructure (or projected bandstructure) using plotly graph_objects.

Parameters:

ylim (unknown) – Limits on the y-axis of plot.

Returns:

Plotly figure with bandstructure plotted.

Return type:

object

plotBS(ax=None, selectedDot=None, plotnew=False, ylim=None)[source]
Parameters:
  • ax (unknown) – (matplotlib.pyplot axis): Axis to save the bandstructure to, otherwise generate new axis.

  • selectedDot (unknown) – (1D integer array): Gives kpoint and band index of the dot selected to make green circle. eg: [3,4]

Returns:

matplotlib.pyplot axis with bandstructure plotted.

Return type:

unknown

get_significant_bonds(band, kpoint, spin)[source]
plot_bond_run(num_bond=0)[source]
change_sig_bonds(old_vals, new_vals, tbvals=None, num_bond=None)[source]

To change tight-binding parameter, need to know two orbitals and three translations.

make_BS_widget(app=None)[source]
get_coulomb()[source]

This function is for me trying out building the coulomb operator 4D kernel from the COGITO gaussian functions. In this I will test first using outside method to calculate overlap / coulomb operator. (Compare directly calculated overlap to overlap params!) Then I will verify whether the sum of terms converges or diverges (should diverge). Then I will try out how to repartition the coulomb operator to a convergent sum. My main method for this is to take the next closest density in a equal amount of charge and have it cancel. This should converge with the decrease in distance between consequetive layers. Test on PbO. @return:

COGITO_dft.COGITOpost.analyze_bandgap(self, minimum_cohp: float = 0.001, make_bond_info_txt=False)[source]

This function finds the VBM and CBM points and obtains the 5D (orb1,orb2,T1,T2,T3) COHP, COOP, and bond_occup matrices for these points. Then it saves the data into dictionaries and json files in the same format as jsonify_bonddata() does for the integrated matrices. @return:

COGITO_dft.COGITOpost.func_for_rad(x, a, b, c, d, e, f, g, h, l)[source]
COGITO_dft.COGITOpost.complex128funs(phi, theta, sphharm_key)[source]
COGITO_dft.COGITOpost.get_simple_fermi(shifted_energies, kpnt_coords, kpt_grid, e_cut: float = 0.0, b_vecs=array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]), plot_iso=False)[source]

This function returns k-point values for the surface constructed by the band energies at a given energy. Best to pass a uniform grid. WARNING: This is a very simple function! The values returned are not neccessary in the best cell for visualization, etc. For more advanced uses, I would recommend interfacing COGITO with IFermi. :param shifted_energies: The eigenvalues of one spin with respect to the Fermi energy. Of dimension [nkpt,nband]. :type shifted_energies: NDArray :param kpnt_coords: The reduced coordinates of the energies. Of dimension [nkpt,3]. :type kpnt_coords: NDArray :param e_cut: The energy of the band isosurface with represent to the Fermi energy. :type e_cut: float :param b_vecs: The reciprocal space vectors used to translate the isosurface back to cartesian coordinates if plotting. :type b_vecs: NDArray :param plot_iso: Whether to plot an html pop-up using plotly of the isosurface. :type plot_iso: float

Returns:

The vertices (k-point coordinates) and faces of the Fermi surface.

Return type:

tuple

COGITO_dft.COGITOpost.run_cogito_model(dir: str = './', tag: str = '', eigfile: str = 'EIGENVAL', tb_file: str = 'TBparams', over_file: str = 'overlaps', file_type: str = 'npy', save_quality_info: bool = True, show_figs: bool = True, save_crystal_bonds: bool = True, save_bondswCOHP: bool = True, save_ico: bool = True, max_dist: float = 15, min_val: float = 1e-05, auto_label: str = 'full', densify: float = 1, energy_cutoff: float = 0.2, bond_max: float = 3, crystal_field=[])[source]

This function solves the COGITO TB model for specific k-points. Options for grids are uniform, band structure, or provided (via EIGENVAL). Primarily, this function saves all atom and bond data (from a uniform grid) to jsons for later analysis. By toggling the various ‘save_*’ options (all default true), this function can also plot parameter decay and band error, make the crystal bond diagrams (w or w/o the interactive COHP plots), and save ICOHP and ICOOP for more computationally effecient analysis. This can also plot the crystal field splitting of orbital energy levels on an atoms specified by a supplied ‘crystal_field’ list.

Parameters:
  • dir (str) – The directory that contains the COGITO output files.

  • tag (str) – The tag appended to COGITO output files.

  • eigfile (str) – The EIGVAL file to use for compare_to_DFT(). Note: is appended to dir.

  • tb_file (str) – The file name for the tight binding parmaeters.

  • over_file (str) – The file name for the overlap parameters.

  • file_type (str) – The suffix of the parameters. Options are ‘npy’ or ‘txt’. If ‘txt’, is same format as wannier90.

  • save_quality_info (bool) – Whether to make hopping/overlap decay plots and DFT band error analysis.

  • show_figs (bool) – If called, does not call any plt.show() or fig.show().

  • save_crystal_bonds (bool) – Whether to make and save the crystal bonds plot.

  • save_bondswCOHP (bool) – Whether to make and save the crystal bonds plot interacting with the COHP vs energy.

  • save_ico (bool) – Whether to save integrated COHP and COOP data for speedy use in COGITOico.py.

  • max_dist (float) – Maximum interatomic distance for including hopping or overlap parameters.

  • min_val (float) – The minimum value cutoff to include parameters.

  • auto_label (str) – Determines how to partition charge for crystal bond plots. ‘mulliken’ does Mulliken paritioning to atomic site, ‘full’ doesn’t repartition but plots charges on atoms and bonds.

  • densify (float) – Increase k-point density by this factor.

  • energy_cutoff (float) – The minimum energy cutoff to plot a bond in crystal bond plots.

  • bond_max (float) – Atoms are plotted outside the primitive cell only if they have a bond with a primitive cell atom that is shorter than this amount. This does not filter bonds between atoms that are already plotted.

  • crystal_field (list) – List of all the atoms that the crystal field diagram is plotted for (e.g. ‘0 1 3’).

Returns:

COGITO_dft.COGITOpost.main(argv=None)[source]