Utility functions#

strawberrypy.utils.chemical_potential(evals, temperature: float, occupied_states: int)[source]#

Calculate the chemical potential of a given model knowing the eigenvalue distribution and the number of electrons (occupied states) in the system.

Parameters:
  • evals – List of eigenvalues of the Hamiltonian.

  • temperature – Temperature (real or fictitious, as in the case of smearing) of the system, appearing in the Fermi-Dirac distribution.

  • occupied_states – Number of occupied states of the system.

Returns:

mu – The chemical potential of the system.

Return type:

float

Warning

The chemical potential is calculated via bisection method, if convergence is not achieved in 200 iterations, an error is returned.

strawberrypy.utils.fermidirac(evals, temperature: float, mu: float)[source]#

The Fermi-Dirac distribution \(f(\epsilon, T, \mu)=\big[ 1 + e^{\frac{\epsilon-\mu}{T}} \big]^{-1}\).

Parameters:
  • evals – List of eigenvalues of the Hamiltonian.

  • temperature – Temperature of the system.

  • mu – The chemical potential of the system.

Returns:

occupations – The occupation(s) of the state corresponding to the given energy(ies)

Return type:

np.array | float

strawberrypy.utils.smearing(vecs, gamma_hevecs, evals, temperature: float, mu: float)[source]#

Smearing introduced to improve the convergence of the formula: it measures how much the projector built from vecs is similar to the one built from gamma_hevecs, the eigenstates of the Hamiltonian at the \(\Gamma\)-point. Naming \(|\phi_n\rangle\) the vectors in vecs and \(|u_n\rangle\) the ones in gamma_hevecs, the smearing factor is computed as \(c_n=\sum_m f(\epsilon_m, T_s, \mu)|\langle \phi_n|u_m\rangle|^2\), where \(\epsilon_m\) is the eigenvalue corresponding to the eigenstate \(|u_m\rangle\), \(T_s\) is the smearing temperature, \(\mu\) is the chemical potential.

Parameters:
  • vecs – List of states that need to be weighted according to some smearing.

  • gamma_hevecs – Eigenstates of th Hamiltonian at the \(\Gamma\)-point.

  • evals – Eigenvales of the Hamiltonian at the \(\Gamma\)-point.

  • temperature – Temperature introduced to smoothen the occupation of the states (smearing temperature).

  • mu – Chemical potential of the system.

Returns:

smearing_coeffs – A list of smearing coefficients that weights the states vecs.

Return type:

np.array

strawberrypy.utils.unique_vacancies(num: int, Lx: int, Ly: int, basis: int, seed: int | None = None)[source]#

Returns a list of unique random lattice sites to be removed in the model using the method add_vacancies.

Parameters:
  • num – Number of lattice positions to generate.

  • Lx – Number of unit cells of the model along the \(\mathbf{a}_1\) direction.

  • Ly – Number of unit cells of the model along the \(\mathbf{a}_2\) direction.

  • basis – Number of atoms per unit cell.

  • seed – Seed for the random number generation. Default is None.

Returns:

unique_list – List of unique random lattice site.

Return type:

list