calc_n_numba
- static ThomasFermi.calc_n_numba(n_0, qV, K_mat, g_0, beta, mu, delta_x, rel_tol, abs_tol, coulomb_steps, use_n_guess, max_iterations, use_combination_method, g0_dx_K_plus_1_inv)
Calculates the particle density n(x) using numba.
This is done by by solving the set of self-consistent equations, eqs. (4) & (5) of arXiv:2509.13298 by using the successive iteration method.
- Parameters:
n_0 (ndarray[float]) – Initial guess (in 1/nm) for the particle density n(x). Pass
np.zeros(len(qV))if no initial guess is desired.qV (ndarray[float]) – The potential V(x) formed by the gates, multiplied by the particle charge q. (
qVhas units of meV).K_mat (ndarray[float]) – A 2D array with shape
(len(x), len(x)), whereK_mat[i, j]gives the value of the Coulomb interaction (in meV) between two particles at pointsx[i]andx[j].g_0 (float) – Coefficient of the density of states (in 1/(meV*nm) for 2D).
beta (float) – The inverse temperature \(1/(k_B T)\) (in 1/meV).
mu (float) – The Fermi level (in meV).
delta_x – The spacing (in nm) between successive x-values.
rel_tol (float) – The relative tolerance to accept a solution. The calculation will terminate if the difference
delta_nbetween successive iterations of n(x) is small enough thatnorm(delta_n)**2 < rel_tol**2 * norm(n) * norm(n_prev), or if the condition forabs_tolis satisfied.abs_tol (float) – The absolute tolerance to accept a solution. The calculation will terminate if the difference
delta_nbetween successive iterations of n(x) is small enough thatnorm(delta_n) * delta_x < abs_tol, or if the condition forrel_tolis satisfied.coulomb_steps (int) – The number of steps over which to turn on the Coulomb interaction.
use_n_guess (bool) – If True, the Coulomb potential will be applied all at once. If false, it will be turned on slowly over a series of steps.
max_iterations (int) – The maximum number of iterations to perfom.
use_combination_method (bool) – Whether to use a combination of the previous 2 iterations when solving for n(x):
n = (1 + g_0 * delta_x * K_mat)^-1 * (n + g_0 * delta_x * K_mat * n_prev)g0_dx_K_plus_1_inv (ndarray[float]) – Inverse of
(g_0 * delta_x * K_mat + identity).
- Returns:
n (ndarray[float]) – The calculated particle density (in 1/nm).
phi (ndarray[float]) – The calculated value (in meV) of phi(x), given by
np.dot(K_mat, n) * delta_x.converged (bool) – Whether the process converged to the required tolerance within the specified number of iterations.